From c8e02b0f57e0921cc64f62a1c3340e24cc1ae184 Mon Sep 17 00:00:00 2001 From: Mustan Pathetic Date: Mon, 7 Mar 2022 00:35:28 +0000 Subject: [PATCH] exports, close #7 --- Config/kpvToCsv.js | 127 ++++++++++++++----------- Routes/PastMatchesComponents/Header.js | 3 +- Routes/ScoutComponents/Autonomous.js | 18 ++-- Routes/ScoutComponents/TeleOp.js | 4 - 4 files changed, 81 insertions(+), 71 deletions(-) diff --git a/Config/kpvToCsv.js b/Config/kpvToCsv.js index 4c17b96..2f72e57 100644 --- a/Config/kpvToCsv.js +++ b/Config/kpvToCsv.js @@ -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"] diff --git a/Routes/PastMatchesComponents/Header.js b/Routes/PastMatchesComponents/Header.js index 97cc6aa..c119382 100644 --- a/Routes/PastMatchesComponents/Header.js +++ b/Routes/PastMatchesComponents/Header.js @@ -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"); diff --git a/Routes/ScoutComponents/Autonomous.js b/Routes/ScoutComponents/Autonomous.js index b5e45c2..fcdd062 100644 --- a/Routes/ScoutComponents/Autonomous.js +++ b/Routes/ScoutComponents/Autonomous.js @@ -45,24 +45,24 @@ export default function Autonomous() { Crosses Line/Taxi )}, - { pos: [0.27, 0.25], com: _=>( - Picks Up + { pos: [0.25, 0.24], com: _=>( + [1] Picks Up )}, - { pos: [0.27, 0.62], com: _=>( - Picks Up + { pos: [0.26, 0.62], com: _=>( + [2] Picks Up )}, - { pos: [0.38, 0.77], com: _=>( - Picks Up + { pos: [0.37, 0.77], com: _=>( + [3] Picks Up )}, - { pos: [0.07, 0.6], com: _=>( - Picks Up + { pos: [0.06, 0.6], com: _=>( + [4] Picks Up )}, { pos: [0.14, 0.6], com: _=>( - Picks Up + [5] Picks Up )}, { pos: [0.4, 0.4], com: _=>(Left Start)}, diff --git a/Routes/ScoutComponents/TeleOp.js b/Routes/ScoutComponents/TeleOp.js index b7720c6..475b2f2 100644 --- a/Routes/ScoutComponents/TeleOp.js +++ b/Routes/ScoutComponents/TeleOp.js @@ -32,10 +32,6 @@ export default function TeleOp() { Lower Hub Missed )}, - { pos: [0.1, 0.5], com: _=>( - Crosses Line/Taxi - )}, - { pos: [0.1, 0.5], com: _=>( Plays Defense )},