Skip to content

Commit

Permalink
Merge pull request #79 from Solar-Gators/nov-changes
Browse files Browse the repository at this point in the history
Power consumption + integral + misc qol changes
  • Loading branch information
jackschedel authored Dec 2, 2024
2 parents 0a16f7f + 5e14994 commit 3873d80
Show file tree
Hide file tree
Showing 14 changed files with 13,784 additions and 246 deletions.
92 changes: 45 additions & 47 deletions backend/controllers/live.server.controller.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Mitsuba_RX0 from "../shared/models/Mitsuba/RX0"
import Mitsuba_RX1 from "../shared/models/Mitsuba/RX1"
import Mitsuba_RX2 from "../shared/models/Mitsuba/RX2"
import { getMostRecent } from "../helper/helper.route"
import Mitsuba_RX0 from "../shared/models/Mitsuba/RX0";
import Mitsuba_RX1 from "../shared/models/Mitsuba/RX1";
import Mitsuba_RX2 from "../shared/models/Mitsuba/RX2";
import { getMostRecent } from "../helper/helper.route";
import { Response } from "express";
import { DataResponse } from "../shared/sdk/telemetry";
import BMS_RX0 from "../shared/models/Custom_BMS/RX0";
Expand All @@ -15,57 +15,55 @@ import MPPT_RX3 from "../shared/models/MPPT/RX3";
import MPPT_RX4 from "../shared/models/MPPT/RX4";
import MPPT_RX5 from "../shared/models/MPPT/RX5";
import GPS from "../shared/models/GPS/GPS";
import Alive from "../shared/models/PI/Alive"
import Alive from "../shared/models/PI/Alive";
import DistanceTraveled from "../shared/models/Stats/DistanceTraveled";
import LapCount from "../shared/models/Stats/LapCount";
import PowerBoard_RX0 from "../shared/models/PowerBoard/RX0";
import PowerBoard_RX1 from "../shared/models/PowerBoard/RX1";


/**
Return data for the sensor read outs on the live tab
*/
exports.data = async (req, res: Response<DataResponse>) => {
async function getMppt(mpptNumber: number) {
return {
rx0: await getMostRecent(MPPT_RX0, { mpptNumber }),
rx1: await getMostRecent(MPPT_RX1, { mpptNumber }),
rx2: await getMostRecent(MPPT_RX2, { mpptNumber }),
rx3: await getMostRecent(MPPT_RX3, { mpptNumber }),
rx4: await getMostRecent(MPPT_RX4, { mpptNumber }),
rx5: await getMostRecent(MPPT_RX5, { mpptNumber }),
};
}

async function getMppt(mpptNumber: number) {
return {
rx0: await getMostRecent(MPPT_RX0, { mpptNumber }),
rx1: await getMostRecent(MPPT_RX1, { mpptNumber }),
rx2: await getMostRecent(MPPT_RX2, { mpptNumber }),
rx3: await getMostRecent(MPPT_RX3, { mpptNumber }),
rx4: await getMostRecent(MPPT_RX4, { mpptNumber }),
rx5: await getMostRecent(MPPT_RX5, { mpptNumber }),
}
}

return res.json({
gps: await getMostRecent(GPS),
bms: {
rx0: await getMostRecent(BMS_RX0),
rx1: await getMostRecent(BMS_RX1),
rx2: await getMostRecent(BMS_RX2),
rx3: await getMostRecent(BMS_RX3),
},
mitsuba: {
rx0: await getMostRecent(Mitsuba_RX0),
rx1: await getMostRecent(Mitsuba_RX1),
rx2: await getMostRecent(Mitsuba_RX2),
distance_traveled: await getMostRecent(DistanceTraveled)
},
mppt: {
"1": await getMppt(1),
"2": await getMppt(2),
"3": await getMppt(3),
},
laps: {
rx0: await getMostRecent(LapCount)
},
powerBoard: {
rx0: await getMostRecent(PowerBoard_RX0),
rx1: await getMostRecent(PowerBoard_RX1),
},
pi: {
alive: await getMostRecent(Alive),
}
})
return res.json({
gps: await getMostRecent(GPS),
bms: {
rx0: await getMostRecent(BMS_RX0),
rx1: await getMostRecent(BMS_RX1),
rx2: await getMostRecent(BMS_RX2),
rx3: await getMostRecent(BMS_RX3),
},
mitsuba: {
rx0: await getMostRecent(Mitsuba_RX0),
rx1: await getMostRecent(Mitsuba_RX1),
rx2: await getMostRecent(Mitsuba_RX2),
distance_traveled: await getMostRecent(DistanceTraveled),
},
mppt: {
"1": await getMppt(1),
"2": await getMppt(2),
"3": await getMppt(3),
},
laps: {
rx0: await getMostRecent(LapCount),
},
powerBoard: {
rx0: await getMostRecent(PowerBoard_RX0),
rx1: await getMostRecent(PowerBoard_RX1),
},
pi: {
alive: await getMostRecent(Alive),
},
});
};
16 changes: 16 additions & 0 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"react-bootstrap": "^2.8.0",
"react-d3-speedometer": "^2.1.0-rc.0",
"react-dom": "^18.2.0",
"react-icons": "^5.3.0",
"react-materialize": "^3.4.1",
"react-router-dom": "^6.3.0",
"react-scripts": "^5.0.1",
Expand Down Expand Up @@ -56,7 +57,10 @@
"prettier": "3.0.3"
},
"options": {
"allowedHosts": ["localhost", ".localhost"],
"allowedHosts": [
"localhost",
".localhost"
],
"proxy": "http://localhost:9000/"
}
}
Loading

0 comments on commit 3873d80

Please sign in to comment.