Skip to content

Commit d232987

Browse files
committed
fix compilation
1 parent eb21c59 commit d232987

File tree

6 files changed

+101
-117
lines changed

6 files changed

+101
-117
lines changed

frontend/app/components/visualizations/AccumulatorTemperature.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@ export default function AccumulatorTemperature() {
1919
let tempArray = Array(4)
2020
.fill(null)
2121
.map(() => Array(7).fill(0));
22-
for (let i = 0; i < 28; i++) {
23-
let segment = Math.floor(i / 7); // 7 sensors per segment
24-
let numInSegment = i % 7;
22+
for (let i = 0; i < 30; i++) {
23+
let segment = Math.floor(i / 6);
24+
let numInSegment = i % 6;
2525

2626
if (cursorRow) {
27-
const key = `Seg${segment}_TEMP_${numInSegment}` as keyof typeof cursorRow;
27+
// const key = `Seg${segment}_TEMP_${numInSegment}` as keyof typeof cursorRow; // fs-2
28+
const key =
29+
`ACC_SEG${segment}_VOLTS_CELL${numInSegment}` as keyof typeof cursorRow;
2830
tempArray[segment][numInSegment] = cursorRow[key] || 0;
2931
const fillRed = new SolidFill({
3032
color: ColorRGBA((cursorRow[key] || 0) * 10, 0, 0),

frontend/app/components/visualizations/LapCounter.tsx

Lines changed: 77 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -7,77 +7,80 @@ import { useDataMethods } from "@/app/data-processing/DataMethodsProvider";
77

88
// data is represented in row, column (y, x)
99

10-
export function LapCounter() {
11-
const { subscribeCursorRow, subscribeReset, dataArraysRef } = useDataMethods();
12-
13-
const lc = useContext(LightningChartsContext);
14-
const containerRef = useRef(null);
15-
const id = useId();
16-
17-
const columnNames = ["Lap #", "Lap Time (s)"];
18-
19-
useEffect(() => {
20-
// checks for invalid ref & context
21-
if (!containerRef.current || !lc) return;
22-
23-
let dataGrid = lc.DataGrid({ container: containerRef.current, theme: globalTheme });
24-
25-
let lapTimes: number[] = [];
26-
27-
function calculateLaps() {
28-
let lapArray = dataArraysRef.current[":Lap"];
29-
let lapTimeArray = dataArraysRef.current[":LapTime"];
30-
31-
dataGrid.setTitle("Lap Times");
32-
dataGrid.setRowContent(0, columnNames);
33-
34-
if (!lapArray || !lapTimeArray) return;
35-
36-
lapTimes = [];
37-
38-
let previous = lapArray[0];
39-
40-
for (let i = 0; i < lapArray.length; i++) {
41-
if (lapArray[i] > previous) {
42-
lapTimes.push(lapTimeArray[i - 1]);
43-
previous = lapArray[i];
44-
}
45-
}
46-
}
47-
48-
const unsubReset = subscribeReset(() => {
49-
calculateLaps();
50-
});
51-
52-
// defines subscribers
53-
const unsub = subscribeCursorRow((cursorRow) => {
54-
const lap = cursorRow ? cursorRow[":Lap"] : null;
55-
const lapTime = cursorRow ? cursorRow[":LapTime"] : null;
56-
57-
//TODO Fix this to work better with live
58-
59-
if (dataGrid.getRowMax() < 1) {
60-
calculateLaps();
61-
}
62-
63-
if (lap === null || lapTime === null) return;
64-
65-
for (let i = dataGrid.getRowMax(); i > lap + 1; i--) {
66-
dataGrid.removeRow(i);
67-
}
68-
69-
for (let i = 0; i < lap + 1; i++) {
70-
dataGrid.setRowContent(i + 1, [i + 1, lapTimes[i]]);
71-
}
72-
73-
dataGrid.setRowContent(dataGrid.getRowMax(), [dataGrid.getRowMax(), lapTime]);
74-
});
75-
76-
return () => {
77-
unsub();
78-
unsubReset();
79-
};
80-
}, [dataArraysRef.current]);
81-
82-
return <div id={id} ref={containerRef} className="w-[100%] h-[100%]"></div>;
83-
}
10+
// Lap counting won't work until we either calculate lap# based on GPS
11+
// coordinates on the car before logging, or calculate it after the fact.
12+
13+
// export function LapCounter() {
14+
// const { subscribeCursorRow, subscribeReset, dataArraysRef } = useDataMethods();
15+
//
16+
// const lc = useContext(LightningChartsContext);
17+
// const containerRef = useRef(null);
18+
// const id = useId();
19+
//
20+
// const columnNames = ["Lap #", "Lap Time (s)"];
21+
//
22+
// useEffect(() => {
23+
// // checks for invalid ref & context
24+
// if (!containerRef.current || !lc) return;
25+
//
26+
// let dataGrid = lc.DataGrid({ container: containerRef.current, theme: globalTheme });
27+
//
28+
// let lapTimes: number[] = [];
29+
//
30+
// function calculateLaps() {
31+
// let lapArray = dataArraysRef.current[":Lap"];
32+
// let lapTimeArray = dataArraysRef.current[":LapTime"];
33+
//
34+
// dataGrid.setTitle("Lap Times");
35+
// dataGrid.setRowContent(0, columnNames);
36+
//
37+
// if (!lapArray || !lapTimeArray) return;
38+
//
39+
// lapTimes = [];
40+
//
41+
// let previous = lapArray[0];
42+
//
43+
// for (let i = 0; i < lapArray.length; i++) {
44+
// if (lapArray[i] > previous) {
45+
// lapTimes.push(lapTimeArray[i - 1]);
46+
// previous = lapArray[i];
47+
// }
48+
// }
49+
// }
50+
//
51+
// const unsubReset = subscribeReset(() => {
52+
// calculateLaps();
53+
// });
54+
//
55+
// // defines subscribers
56+
// const unsub = subscribeCursorRow((cursorRow) => {
57+
// const lap = cursorRow ? cursorRow[":Lap"] : null;
58+
// const lapTime = cursorRow ? cursorRow[":LapTime"] : null;
59+
//
60+
// //TODO Fix this to work better with live
61+
//
62+
// if (dataGrid.getRowMax() < 1) {
63+
// calculateLaps();
64+
// }
65+
//
66+
// if (lap === null || lapTime === null) return;
67+
//
68+
// for (let i = dataGrid.getRowMax(); i > lap + 1; i--) {
69+
// dataGrid.removeRow(i);
70+
// }
71+
//
72+
// for (let i = 0; i < lap + 1; i++) {
73+
// dataGrid.setRowContent(i + 1, [i + 1, lapTimes[i]]);
74+
// }
75+
//
76+
// dataGrid.setRowContent(dataGrid.getRowMax(), [dataGrid.getRowMax(), lapTime]);
77+
// });
78+
//
79+
// return () => {
80+
// unsub();
81+
// unsubReset();
82+
// };
83+
// }, [dataArraysRef.current]);
84+
//
85+
// return <div id={id} ref={containerRef} className="w-[100%] h-[100%]"></div>;
86+
// }

frontend/app/components/visualizations/LapsTable.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ import TextBox from "./TextBox";
33
export default function LapsTable() {
44
return (
55
<div className="p-0">
6-
<TextBox title="Lap Time" keyName=":LapTime" />
7-
<TextBox title="Lap Number" keyName=":Lap" /> {/*TODO: lcjs datagrid*/}
6+
{/* Lap counting was done by the AEMdash, which we don't have a replacement for yet on fs-3. */}
7+
{/* <TextBox title="Lap Time" keyName=":LapTime" /> */}
8+
{/* <TextBox title="Lap Number" keyName=":Lap" /> */}
89
<TextBox title="Speed" keyName="VDM_GPS_SPEED" /> {/*TODO: lcjs guage chart*/}
910
</div>
1011
);

frontend/app/components/visualizations/SuspensionGauge.tsx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ function SuspensionCanvas({ s1, s2, s3, s4 }: SuspensionInfo) {
5959
(canvas.width / 4) * i,
6060
canvas.height,
6161
canvas.width / 4,
62-
(Math.abs(value) * -scaleFactor),
62+
Math.abs(value) * -scaleFactor,
6363
);
6464
});
6565
},
@@ -136,10 +136,10 @@ export default function SuspensionGauge() {
136136
useEffect(() => {
137137
return subscribeCursorRow((cursorRow) => {
138138
setValues({
139-
s1: cursorRow?.TELEM_BL_SUSTRAVEL ?? 0,
140-
s2: cursorRow?.TELEM_BR_SUSTRAVEL ?? 0,
141-
s3: cursorRow?.TELEM_FL_SUSTRAVEL ?? 0,
142-
s4: cursorRow?.TELEM_FR_SUSTRAVEL ?? 0,
139+
s1: cursorRow?.TPERIPH_FR_DATA_SUSTRAVEL ?? 0,
140+
s2: cursorRow?.TPERIPH_FL_DATA_SUSTRAVEL ?? 0,
141+
s3: cursorRow?.TPERIPH_BR_DATA_SUSTRAVEL ?? 0,
142+
s4: cursorRow?.TPERIPH_BL_DATA_SUSTRAVEL ?? 0,
143143
});
144144
});
145145
}, []);
@@ -162,7 +162,12 @@ export default function SuspensionGauge() {
162162
</div>
163163
<div className="flex flex-col justify-center items-center w-full h-full">
164164
<div className="w-[90%] h-[90%] rounded-[4%] overflow-hidden">
165-
<SuspensionCanvas s1={values.s1} s2={values.s2} s3={values.s3} s4={values.s4} />
165+
<SuspensionCanvas
166+
s1={values.s1}
167+
s2={values.s2}
168+
s3={values.s3}
169+
s4={values.s4}
170+
/>
166171
</div>
167172
<div
168173
className="w-[90%] h-[5%] flex flex-row justify-evenly"

frontend/app/components/visualizations/Visualizations.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import CarWireframe from "./CarWireframe";
66
import SuspensionGauge from "./SuspensionGauge";
77
import { VisualizationProps } from "../FlexLayoutComponent";
88
import { JSX } from "react";
9-
import { LapCounter } from "./LapCounter";
9+
// import { LapCounter } from "./LapCounter";
1010
import AccumulatorTemperature from "./AccumulatorTemperature";
1111

1212
export const visualizations: Record<string, (props: VisualizationProps<any>) => JSX.Element> =
@@ -16,8 +16,8 @@ export const visualizations: Record<string, (props: VisualizationProps<any>) =>
1616
"suspension-gauge": SuspensionGauge,
1717
"car-wireframe": CarWireframe,
1818
"g-force-gauge": GForceGauge,
19-
"timings-box": LapsTable,
20-
"lap-counter": LapCounter,
19+
// "timings-box": LapsTable,
20+
// "lap-counter": LapCounter, // doesn't work without AEMdash lap calculations (not on fs-3)
2121
"accumulator-temp": AccumulatorTemperature,
2222

2323
skeleton: () => <div className="w-full h-full bg-neutral-500"></div>,

frontend/app/components/visualizations/lightning-charts/StackedLineChart.tsx

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -34,34 +34,7 @@ export function StackedLineChart({
3434
label: "Time",
3535
units: "s",
3636
});
37-
const [yAxesInfo, setYAxesInfo] = useSavedState("yAxesInfo", [
38-
{
39-
columnNames: [
40-
"Seg0_TEMP_0",
41-
"Seg0_TEMP_1",
42-
"Seg0_TEMP_2",
43-
"Seg0_TEMP_3",
44-
"Seg0_TEMP_4",
45-
"Seg0_TEMP_5",
46-
"Seg0_TEMP_6",
47-
],
48-
label: "Seg0 Temps",
49-
units: "°C",
50-
},
51-
{
52-
columnNames: [
53-
"Seg0_VOLT_0",
54-
"Seg0_VOLT_1",
55-
"Seg0_VOLT_2",
56-
"Seg0_VOLT_3",
57-
"Seg0_VOLT_4",
58-
"Seg0_VOLT_5",
59-
"Seg0_VOLT_6",
60-
],
61-
label: "Seg0 Voltages",
62-
units: "V",
63-
},
64-
]);
37+
const [yAxesInfo, setYAxesInfo] = useSavedState("yAxesInfo", []);
6538

6639
const [search, setSearch] = useState("");
6740

0 commit comments

Comments
 (0)