Skip to content

Commit

Permalink
exports, close #7
Browse files Browse the repository at this point in the history
  • Loading branch information
PatheticMustan authored Mar 7, 2022
1 parent 826dd69 commit c8e02b0
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 71 deletions.
127 changes: 71 additions & 56 deletions Config/kpvToCsv.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,98 +3,113 @@
// matches: KPV[]
export default function kpvToCsv(matches) {
// the holy grail contains all the data for converting the kpv's to one giant csv file
const theHolyGrail = [{
const theHolyGrail = [{ // match info
name: "Team Number",
vf: kpv => kpv["TeamNumber"]
}, {
name: "Match Number",
vf: kpv => kpv["MatchNumber"]
}, {
name: "Fits Under Trench?",
vf: kpv => kpv["FitsUnderTrench"] ? "Yes" : "No"
}, {
name: "Plays Defense?",
vf: kpv => kpv["PlaysDefense"] ? "Yes" : "No"
}, {
},

// other (penalties/cards/breakdown)
{
name: "Penalties",
vf: kpv => {
const red = kpv["RedCard"];
const yellow = kpv["YellowCard"];

if (red && yellow) return "Red and Yellow";
if (red) return "Red";
if (yellow) return "Yellow";
if (red && yellow) return "Red and Yellow";
if (red) return "Red";
if (yellow) return "Yellow";

return "None";
}
}, {
name: "Starting Pieces",
vf: kpv => kpv["StartingPieces"]
name: "Fouls",
vf: kpv => {
const fouls = kpv["FoulCount"];
const techFouls = kpv["TechFoulCount"];

if (fouls && techFouls) return `${fouls} fouls, ${techFouls} tech fouls`;
if (fouls) return `${fouls} fouls`;
if (techFouls) return `${techFouls} tech fouls`;

return "No Fouls";
}
}, {
name: "Line Position",
vf: kpv => kpv["LinePosition"]
name: "Breakdown",
vf: kpv => {
return kpv["Breakdown"]? "Yes" : "No";
}
},

// auto
{
name: "Starting Pieces",
vf: kpv => kpv["StartingPieces"]? "Yes" : "No"
}, {
name: "Crosses Initiation Line?",
vf: kpv => kpv["CrossesInitiationLine"] ? "Yes" : "No"
name: "Starting Position",
vf: kpv => kpv["StartingPosition"]
}, {
name: "Auto Low",
vf: kpv => kpv["AutoLow"]
name: "Taxi",
vf: kpv => kpv["Taxi"]? "Yes" : "No"
}, {
name: "Auto Outer",
vf: kpv => kpv["AutoOuter"]
name: "Auto Upper",
vf: kpv => `${kpv["AutoUpperHubScored"]} scored, ${kpv["AutoUpperHubMissed"]} missed`
}, {
name: "Auto Inner",
vf: kpv => kpv["AutoInner"]
name: "Auto Lower",
vf: kpv => `${kpv["AutoLowerHubScored"]} scored, ${kpv["AutoLowerHubMissed"]} missed`
}, {
name: "Auto Missed",
vf: kpv => kpv["AutoMissed"]
name: "Picked Up",
vf: kpv =>
["AutoBP1", "AutoBP2", "AutoBP3", "AutoBP4", "AutoBP5"]
.map((v, i) => kpv[v]? i+1 : -1) // convert valid to their index+1, invalid to -1
.filter(v => v !== -1) // filter invalid
.join(", ") // make it pretty
|| "None" // set a default of "None"
}, {
name: "Autonomous Comments",
vf: kpv => kpv["AutonomousComments"]
},

// tele
{
name: "Picks From Ground",
vf: kpv => kpv["PicksFromGround"]? "Yes" : "No"
}, {
name: "Balls Picked Up From Loading Station",
vf: kpv => kpv["BallsPickedUpFromLoadingStation"]
name: "Plays Defense",
vf: kpv => kpv["PlaysDefense"]? "Yes" : "No"
}, {
name: "Balls Picked Up From Floor",
vf: kpv => kpv["BallsPickedUpFromFloor"]
name: "Human Player",
vf: kpv => kpv["HPStation"]? "Yes" : "No"
}, {
name: "Tele-Op Low",
vf: kpv => kpv["TeleLow"]
name: "Tele Upper",
vf: kpv => `${kpv["TeleopUpperHubScored"]} scored, ${kpv["TeleopUpperHubMissed"]} missed`
}, {
name: "Tele-Op Outer",
vf: kpv => kpv["TeleOuter"]
}, {
name: "Tele-Op Inner",
vf: kpv => kpv["TeleInner"]
}, {
name: "Tele-Op Missed",
vf: kpv => kpv["TeleMissed"]
}, {
name: "Shoot From",
vf: kpv => [kpv["TargetZone"]? "Target Zone" : "", kpv["TrenchZone"]? "Trench Zone" : "", kpv["Other"]? "Other" : ""]
.filter(v => v !== "") // filter out none
.join(", ") // make it look nice
}, {
name: "Rotation",
vf: kpv => kpv["Rotation"] ? "Yes" : "No"
}, {
name: "Color",
vf: kpv => kpv["Color"] ? "Yes" : "No"
name: "Tele Lower",
vf: kpv => `${kpv["TeleopLowerHubScored"]} scored, ${kpv["TeleopLowerHubMissed"]} missed`
}, {
name: "Teleop Comments",
vf: kpv => kpv["TeleopComments"]
}, {
name: "Endgame Type",
vf: kpv => kpv["EndgameType"]
}, {
},

// endgame
{
name: "Balls Scored",
vf: kpv => kpv["BallsScored"]
vf: kpv => `${kpv["BallsScored"]} scored`
}, {
name: "Climb Position",
vf: kpv => kpv["ClimbPosition"]
}, {
name: "Time",
vf: kpv => kpv["Time"]
vf: kpv => {
const seconds = kpv["Time"];

const fMinutes = (seconds - (seconds % 60)) / 60;
const fSeconds = ((seconds % 60) + "").padStart(2, "0");

return `${fMinutes}:${fSeconds}`
}
}, {
name: "Endgame Comments",
vf: kpv => kpv["EndgameComments"]
Expand Down
3 changes: 1 addition & 2 deletions Routes/PastMatchesComponents/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,10 @@ export default function Header() {
const output = kpvToCsv(matches);

Platform.OS == "web"
? webExport(output, `scouting-${Date}.csv`)
? webExport(output, `scouting-${Date.now()}.csv`)
: mobileExport(output);
};


function webExport(content, fileName) {
console.log("NAY");
let a = document.createElement("a");
Expand Down
18 changes: 9 additions & 9 deletions Routes/ScoutComponents/Autonomous.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,24 @@ export default function Autonomous() {
<BoolButton id="Taxi" bgc="lime" width={160}>Crosses Line/Taxi</BoolButton>
)},

{ pos: [0.27, 0.25], com: _=>(
<BoolButton id="AutoBP1" bgc={color} width={50}>Picks Up</BoolButton>
{ pos: [0.25, 0.24], com: _=>(
<BoolButton id="AutoBP1" bgc={color} width={70}>[1] Picks Up</BoolButton>
)},

{ pos: [0.27, 0.62], com: _=>(
<BoolButton id="AutoBP2" bgc={color} width={50}>Picks Up</BoolButton>
{ pos: [0.26, 0.62], com: _=>(
<BoolButton id="AutoBP2" bgc={color} width={70}>[2] Picks Up</BoolButton>
)},

{ pos: [0.38, 0.77], com: _=>(
<BoolButton id="AutoBP3" bgc={color} width={50}>Picks Up</BoolButton>
{ pos: [0.37, 0.77], com: _=>(
<BoolButton id="AutoBP3" bgc={color} width={70}>[3] Picks Up</BoolButton>
)},

{ pos: [0.07, 0.6], com: _=>(
<BoolButton id="AutoBP4" bgc={color} width={50}>Picks Up</BoolButton>
{ pos: [0.06, 0.6], com: _=>(
<BoolButton id="AutoBP4" bgc={color} width={70}>[4] Picks Up</BoolButton>
)},

{ pos: [0.14, 0.6], com: _=>(
<BoolButton id="AutoBP5" bgc={color} width={50}>Picks Up</BoolButton>
<BoolButton id="AutoBP5" bgc={color} width={70}>[5] Picks Up</BoolButton>
)},

{ pos: [0.4, 0.4], com: _=>(<WhiteText>Left Start</WhiteText>)},
Expand Down
4 changes: 0 additions & 4 deletions Routes/ScoutComponents/TeleOp.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ export default function TeleOp() {
<NumButton id="TeleopLowerHubMissed" width={160}>Lower Hub Missed</NumButton>
</>)},

{ pos: [0.1, 0.5], com: _=>(
<BoolButton id="Taxi" bgc="lime" width={160}>Crosses Line/Taxi</BoolButton>
)},

{ pos: [0.1, 0.5], com: _=>(
<BoolButton id="PlaysDefense" bgc="lime" width={160}>Plays Defense</BoolButton>
)},
Expand Down

0 comments on commit c8e02b0

Please sign in to comment.