Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions packages/client/src/components/atoms/BatteryIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { useEffect, useState } from "react";

import { usePacket } from "@/contexts/PacketContext";

function BatteryIconComponent() {
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/components/atoms/FaultCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function FaultCard(props: FaultCardProps) {
<div
className={`flex size-full items-center justify-start border p-2 ${
severity === ISeverity.ERROR
? "border-[#9C0534]"
? "border-primary"
: severity === ISeverity.WARNING
? "border-[#F98D10]"
: severity === ISeverity.CLEAR
Expand Down
2 changes: 0 additions & 2 deletions packages/client/src/components/atoms/ThrottleIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { useEffect, useState } from "react";

import { usePacket } from "@/contexts/PacketContext";

function ThrottleIcon() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const fakeData = {
"Bus Voltage": 55,
};

function BottomInformationContainer(props: any) {
function BottomInformationContainer() {
return (
<div className="align-middle">
<div className="flex h-full flex-row flex-wrap justify-evenly gap-4 pt-4 text-center text-base md:gap-2 2xl:text-xl">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Fragment } from "react";
import NavBar from "@/components/tabs/NavBar";
import { type SolarCarRoutes, routes } from "@/objects/TabRoutes";

function TabsContainer(props: any) {
function TabsContainer() {
const router = useRouter();
const { slug } = router.query;

Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/components/global/Loading.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Image from "next/image";
import { use, useEffect, useMemo, useState } from "react";
import { useMemo } from "react";
import { twMerge } from "tailwind-merge";

import { LOADINGSTAGES } from "@/components/global/LoadingWrapper";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ import * as THREE from "three";

import { CarModelComponent } from "@/components/molecules/HeroMolecules/CarMolecules/CarModelComponent";
import { RoadComponent } from "@/components/molecules/HeroMolecules/CarMolecules/RoadComponent";
import type {
FaultLocations,
IndicationLocations,
} from "@/components/molecules/HeroMolecules/HeroTypes";
import type { IndicationLocations } from "@/components/molecules/HeroMolecules/HeroTypes";
import { ISeverity } from "@/components/molecules/HeroMolecules/HeroTypes";
import { usePacket } from "@/contexts/PacketContext";
import { ContactShadows, OrbitControls } from "@react-three/drei";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ interface roadComponentProps {
}
export function RoadComponent(props: roadComponentProps) {
const geometry = new PlaneGeometry(0.5, props.size * 5);
const planeGeom = new PlaneGeometry(9, props.size * 7);
return (
<>
<mesh
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import Image from "next/image";

import ParkingBrakeIcon from "@/components/atoms/ParkingBreakIcon";
import { usePacket } from "@/contexts/PacketContext";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
import Image from "next/image";

function LogoComponent() {
return (
<div className="w-full pt-2">
<img className="m-auto w-3/4" src="/assets/Logo.png" />
<Image
className="m-auto w-3/4"
src="/assets/Logo.png"
alt="Solar Car Logo"
layout="cover"
width={100}
height={100}
/>
</div>
);
}
Expand Down
7 changes: 0 additions & 7 deletions packages/client/src/components/tabs/BatteryTab.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
import PISTransformer from "@/components/transformers/PISTransformer";
import { usePacket } from "@/contexts/PacketContext";
import Battery from "@/objects/PIS/PIS.battery";

function BatteryTab() {
const { currentPacket } = usePacket();

const fakeBatteryData = currentPacket.Battery;

const fakeAuxBMSData = currentPacket.AuxBms;

return (
<div>
<PISTransformer root={Battery()} />
Expand Down
4 changes: 2 additions & 2 deletions packages/client/src/components/tabs/NavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import { type SolarCarRoutes, routes } from "@/objects/TabRoutes";
import Tab from "@mui/material/Tab";
import Tabs from "@mui/material/Tabs";

function NavBar(props: any): JSX.Element {
function NavBar(): JSX.Element {
const router = useRouter();

const getCurrentPath = () => {
let currIndex = "1";
routes.map((route: SolarCarRoutes, i: number) => {
routes.map((route: SolarCarRoutes) => {
if (route.path === router.pathname) {
currIndex = route.value.toString();
}
Expand Down
8 changes: 4 additions & 4 deletions packages/client/src/contexts/AppStateContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@ export function AppStateContextProvider({ children }: Props) {
}));
};

const saveSettingsToLocalStorage = () => {
localStorage.setItem("settings", JSON.stringify(currentAppState));
};

useEffect(() => {
fetchSettingsFromLocalStorage();
}, []);

useEffect(() => {
const saveSettingsToLocalStorage = () => {
localStorage.setItem("settings", JSON.stringify(currentAppState));
};

if (!currentAppState.loading) {
saveSettingsToLocalStorage();
}
Expand Down
69 changes: 35 additions & 34 deletions packages/client/src/contexts/FaultsContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,43 +36,44 @@ function incrementOrDropFaultTimer(faults: Map<string, IFaults>) {
export function FaultsContextProvider({ children }: Props) {
const faults = Faults();
const trueFaultsRef = useRef(new Map<string, IFaults>());
function processFaultSection(section: I_PIS) {
Object.keys(section).forEach((key) => {
const value = section[key];
if (Array.isArray(value)) {
value.forEach((fault) => {
if (fault?.data[0]?.value === false) {
return;
}
const existingFault = trueFaultsRef.current.get(fault.name);
// reset fault timer
if (existingFault) {
trueFaultsRef.current.set(fault.name, {
...existingFault,
faultTimer: 0,
});
return;
}
// add to trueFaults
const newFault: IFaults = {
faultTimer: 0,
severity: fault?.data[0]?.severity as ISeverity,
indicationLocation: fault?.data[0]
?.indicationLocation as FaultLocations,
value: !!fault?.data[0]?.value,
name: fault.name,
};
trueFaultsRef.current.set(fault.name, newFault);
});
} else {
processFaultSection(value as I_PIS);
}
});
}

const currentFaults = useMemo(() => {
function processFaultSection(section: I_PIS) {
Object.keys(section).forEach((key) => {
const value = section[key];
if (Array.isArray(value)) {
value.forEach((fault) => {
if (fault?.data[0]?.value === false) {
return;
}
const existingFault = trueFaultsRef.current.get(fault.name);
// reset fault timer
if (existingFault) {
trueFaultsRef.current.set(fault.name, {
...existingFault,
faultTimer: 0,
});
return;
}
// add to trueFaults
const newFault: IFaults = {
faultTimer: 0,
severity: fault?.data[0]?.severity as ISeverity,
indicationLocation: fault?.data[0]
?.indicationLocation as FaultLocations,
value: !!fault?.data[0]?.value,
name: fault.name,
};
trueFaultsRef.current.set(fault.name, newFault);
});
} else {
processFaultSection(value as I_PIS);
}
});
}

processFaultSection(faults);
incrementOrDropFaultTimer(trueFaultsRef.current);
console.log(trueFaultsRef.current);
return trueFaultsRef.current;
}, [faults]);
return (
Expand Down
1 change: 1 addition & 0 deletions packages/client/src/contexts/PacketContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export function PacketContextProvider({
function onPacket(packet: ITelemetryData) {
setCurrentPacket(packet);
}

useEffect(() => {
if (isFaking) {
const interval = setInterval(() => {
Expand Down
1 change: 0 additions & 1 deletion packages/client/src/objects/PIS/PIS.faults.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
} from "@/components/molecules/HeroMolecules/HeroTypes";
import { usePacket } from "@/contexts/PacketContext";
import type I_PIS from "@/objects/PIS/PIS.interface";
import { UnitType } from "@/objects/PIS/PIS.interface";

const Faults = (): I_PIS => {
const { currentPacket } = usePacket();
Expand Down
4 changes: 0 additions & 4 deletions packages/client/src/objects/telemetry-data.interface.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
enum Motor {
RightMotor = 1,
LeftMotor = 0,
}
export default interface ITelemetryData {
PacketTitle: string;
TimeStamp: number;
Expand Down