Skip to content

Commit

Permalink
Fix URCL
Browse files Browse the repository at this point in the history
  • Loading branch information
jwbonner committed Nov 5, 2024
1 parent 73256d2 commit 82f0211
Show file tree
Hide file tree
Showing 6 changed files with 448 additions and 428 deletions.
157 changes: 116 additions & 41 deletions package-lock.json

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

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@rollup/plugin-json": "^6.0.0",
"@rollup/plugin-node-resolve": "^15.2.1",
"@rollup/plugin-replace": "^5.0.2",
"@rollup/plugin-typescript": "11.1.3",
"@rollup/plugin-typescript": "12.1.1",
"@types/bignumber.js": "^5.0.4",
"@types/chart.js": "^2.9.38",
"@types/color-convert": "^2.0.3",
Expand All @@ -46,6 +46,7 @@
"@types/ssh2": "^1.11.13",
"@types/three": "^0.168.0",
"bignumber.js": "^9.1.2",
"buffer": "^6.0.3",
"camera-controls": "^2.9.0",
"chart.js": "^4.4.0",
"color-convert": "^2.0.1",
Expand All @@ -66,7 +67,7 @@
"three": "^0.168.0",
"tslib": "^2.6.2",
"type-fest": "^4.26.1",
"typescript": "5.2.2"
"typescript": "5.6.3"
},
"dependencies": {
"@distube/ytdl-core": "^4.14.4",
Expand Down
25 changes: 22 additions & 3 deletions src/hub/dataSources/schema/URCLSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ export default class URCLSchema {
}
if (((messageId >> 6) & 0x3ff) === FIRMWARE_API) {
// Firmware frame
let firmwareValues = parseCanFrame(FIRMWARE_FRAME_SPEC, { data: messageValue });
let fullMessageValue = new Uint8Array(8);
fullMessageValue.set(messageValue, 0);
let firmwareValues = parseCanFrame(FIRMWARE_FRAME_SPEC, { data: fullMessageValue });
devices[deviceId].firmware = {
major: Number(firmwareValues.MAJOR),
minor: Number(firmwareValues.MINOR),
Expand Down Expand Up @@ -120,7 +122,18 @@ export default class URCLSchema {
Object.entries(frameValues).forEach(([signalKey, signalValue]) => {
if (!(signalKey in frameSpec.signals)) return;
let signalSpec = (frameSpec.signals as { [key: string]: any })[signalKey];
let signalLogKey = (deviceKey = "/" + (signalSpec.name as string).replaceAll(" ", ""));
if (signalSpec.name.includes("Reserved")) return;
let signalGroup = "";
if (signalSpec.name.includes("Fault")) {
signalGroup = "Fault";
} else if (signalSpec.name.includes("Warning")) {
signalGroup = "Warning";
}
let signalLogKey =
deviceKey +
"/" +
(signalGroup.length === 0 ? "" : signalGroup + "/") +
(signalSpec.name as string).replaceAll(" ", "");
switch (signalSpec.type as string) {
case "int":
case "uint":
Expand All @@ -132,7 +145,13 @@ export default class URCLSchema {
break;
}
if ("description" in signalSpec) {
log.setMetadataString(key, JSON.stringify({ description: signalSpec.description }));
log.setMetadataString(signalLogKey, JSON.stringify({ description: signalSpec.description }));
}
if (signalSpec.name === "Applied Output") {
const voltage = getOrDefault(log, deviceKey + "/Voltage", LoggableType.Number, timestamp, 0);
if (voltage > 0) {
log.putNumber(deviceKey + "/AppliedOutputVoltage", timestamp, Number(signalValue) * voltage);
}
}
});
}
Expand Down
Loading

0 comments on commit 82f0211

Please sign in to comment.