From b0828b85ad3e889e5c063daf6054fbb714b2ddce Mon Sep 17 00:00:00 2001 From: csawatzky Date: Thu, 16 Oct 2025 16:23:29 -0600 Subject: [PATCH 01/10] changing the versino number for the feature --- src/models/Device.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/models/Device.ts b/src/models/Device.ts index 46ce943..b91cdd1 100644 --- a/src/models/Device.ts +++ b/src/models/Device.ts @@ -42,11 +42,11 @@ const featureVersions: Map = new Map([ v2Cell: "N/A", v2WifiS3: "N/A", v2CellS3: "N/A", - v2CellBlack: "2.1.6", + v2CellBlack: "2.1.7", v2CellGreen: "N/A", - v2WifiBlue: "2.1.6", - v2CellBlue: "2.1.6", - v2EthBlue: "2.1.6" + v2WifiBlue: "2.1.7", + v2CellBlue: "2.1.7", + v2EthBlue: "2.1.7" } ] ]); From 98a153816722f7f49be1708347b67e52f465daad Mon Sep 17 00:00:00 2001 From: csawatzky Date: Thu, 23 Oct 2025 13:01:54 -0600 Subject: [PATCH 02/10] fix for the I2C Drager stuff so it uses the expansion line and not cable id so the address type stays as 2, onewire drager will still use cable id --- src/component/ComponentSettings.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/component/ComponentSettings.tsx b/src/component/ComponentSettings.tsx index a7b8877..5dd2695 100644 --- a/src/component/ComponentSettings.tsx +++ b/src/component/ComponentSettings.tsx @@ -514,7 +514,8 @@ export default function ComponentSettings(props: Props) { } const supportsExpansion = () => { - return (formComponent.settings.type === quack.ComponentType.COMPONENT_TYPE_GRAIN_CABLE && + return ((formComponent.settings.type === quack.ComponentType.COMPONENT_TYPE_GRAIN_CABLE || + formComponent.settings.type === quack.ComponentType.COMPONENT_TYPE_DRAGER_GAS_DONGLE) && formComponent.settings.addressType === quack.AddressType.ADDRESS_TYPE_I2C) } From d6f33a873c8e1f292b52fc6706f2f402dbeb42d9 Mon Sep 17 00:00:00 2001 From: csawatzky Date: Mon, 27 Oct 2025 15:11:27 -0600 Subject: [PATCH 03/10] adding ne alarm subtype to the boolean output --- package-lock.json | 2 +- package.json | 2 +- src/pbHelpers/ComponentTypes/OnOffOutput.ts | 5 +++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index afd8bad..d11bc29 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10953,7 +10953,7 @@ }, "node_modules/protobuf-ts": { "version": "1.0.0", - "resolved": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#c65c13a8eb98331c6648e401219debf8c9adc657", + "resolved": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#31866a5a4ebad3770b82f4687bec2fd4c3b8417e", "dependencies": { "protobufjs": "^6.8.8" } diff --git a/package.json b/package.json index ee0e9b7..fc7a1ac 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "mui-tel-input": "^7.0.0", "notistack": "^3.0.1", "openweathermap-ts": "^1.2.10", - "protobuf-ts": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#master", + "protobuf-ts": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#staging", "query-string": "^9.2.1", "react": "^18.3.1", "react-beautiful-dnd": "^13.1.1", diff --git a/src/pbHelpers/ComponentTypes/OnOffOutput.ts b/src/pbHelpers/ComponentTypes/OnOffOutput.ts index 0e83b8c..be8ec61 100644 --- a/src/pbHelpers/ComponentTypes/OnOffOutput.ts +++ b/src/pbHelpers/ComponentTypes/OnOffOutput.ts @@ -63,6 +63,11 @@ const subtypes = [ key: quack.BooleanOutputSubtype.BOOLEAN_OUTPUT_SUBTYPE_EXHAUST_FAN, value: "BOOLEAN_OUTPUT_SUBTYPE_FAN", friendlyName: "Exhaust Fan" + } as Subtype, + { + key: quack.BooleanOutputSubtype.BOOLEAN_OUTPUT_SUBTYPE_ALARM, + value: "BOOLEAN_OUTPUT_SUBTYPE_ALARM", + friendlyName: "Alarm" } as Subtype ]; From d63022ca88cd55a27f250cec2c4442f96bc219c3 Mon Sep 17 00:00:00 2001 From: csawatzky Date: Tue, 28 Oct 2025 09:27:42 -0600 Subject: [PATCH 04/10] fix for the drager voltage showing incorrectly on the chart for o2 subtypes --- src/pbHelpers/ComponentTypes/DragerGasDongle.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/pbHelpers/ComponentTypes/DragerGasDongle.ts b/src/pbHelpers/ComponentTypes/DragerGasDongle.ts index bec3b1e..dd28f75 100644 --- a/src/pbHelpers/ComponentTypes/DragerGasDongle.ts +++ b/src/pbHelpers/ComponentTypes/DragerGasDongle.ts @@ -170,6 +170,7 @@ export function dragerGasDongle(subtype: number = 0): ComponentTypeExtension { let firstTime: Moment | undefined; let lastTime: Moment | undefined; let valMap: Map = new Map(); + if(measurement.type === quack.MeasurementType.MEASUREMENT_TYPE_PPM){ measurement.values.forEach((vals, i) => { let avgVals: Point[] = []; let newLineData: LineData = { @@ -205,6 +206,14 @@ export function dragerGasDongle(subtype: number = 0): ComponentTypeExtension { valMap = new Map(); } }); + } else { + chartData = simpleLineChartData( + quack.ComponentType.COMPONENT_TYPE_DRAGER_GAS_DONGLE, + measurement, + smoothingAverages, + filters + ); + } } else { chartData = simpleLineChartData( quack.ComponentType.COMPONENT_TYPE_DRAGER_GAS_DONGLE, From 5c5d8debc45e1a1ed1b412dc0f65b7feaf5ead9e Mon Sep 17 00:00:00 2001 From: csawatzky Date: Tue, 28 Oct 2025 09:33:55 -0600 Subject: [PATCH 05/10] fix for the mV decimals on drager sensors, there shouldn't be any --- src/pbHelpers/MeasurementDescriber.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pbHelpers/MeasurementDescriber.ts b/src/pbHelpers/MeasurementDescriber.ts index 1fc2751..790b9a9 100644 --- a/src/pbHelpers/MeasurementDescriber.ts +++ b/src/pbHelpers/MeasurementDescriber.ts @@ -176,6 +176,7 @@ export class MeasurementDescriber { this.details.unit = "mV"; this.details.graph = GraphType.MULTILINE; this.details.unit = "mV"; + this.details.decimals = 0 // this.details.nodeDetails = { // colours: ["white", "black", "red", "blue"], // labels: ["millivolt1", "millivolt2", "millivolt3", "millivolt4"] From af279cb2f3333bebc84534b1d05839541db7310f Mon Sep 17 00:00:00 2001 From: Carter Date: Wed, 29 Oct 2025 12:12:30 -0600 Subject: [PATCH 06/10] switched back to master proto --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fc7a1ac..ee0e9b7 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "mui-tel-input": "^7.0.0", "notistack": "^3.0.1", "openweathermap-ts": "^1.2.10", - "protobuf-ts": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#staging", + "protobuf-ts": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#master", "query-string": "^9.2.1", "react": "^18.3.1", "react-beautiful-dnd": "^13.1.1", From c5a3487db0d93e11bb5c8ee169a563d9b2bcea74 Mon Sep 17 00:00:00 2001 From: csawatzky Date: Thu, 30 Oct 2025 16:49:00 -0600 Subject: [PATCH 07/10] added button to send down the onewire scan request --- package-lock.json | 4 +-- package.json | 2 +- src/device/DeviceWizard.tsx | 22 ++++++++++++++++ .../autoDetect/DeviceScannedComponents.tsx | 26 ++++++++++++++++--- src/device/autoDetect/ScannedOneWirePort.tsx | 7 +++++ src/models/Device.ts | 15 +++++++++++ src/pages/Device.tsx | 9 ++++--- src/providers/pond/deviceAPI.tsx | 15 +++++++++++ 8 files changed, 89 insertions(+), 11 deletions(-) create mode 100644 src/device/autoDetect/ScannedOneWirePort.tsx diff --git a/package-lock.json b/package-lock.json index 2f6f8fc..8bf5f65 100644 --- a/package-lock.json +++ b/package-lock.json @@ -42,7 +42,7 @@ "mui-tel-input": "^7.0.0", "notistack": "^3.0.1", "openweathermap-ts": "^1.2.10", - "protobuf-ts": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#i2c_detect", + "protobuf-ts": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#onewire_detect", "query-string": "^9.2.1", "react": "^18.3.1", "react-beautiful-dnd": "^13.1.1", @@ -10953,7 +10953,7 @@ }, "node_modules/protobuf-ts": { "version": "1.0.0", - "resolved": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#0d0084ce207218ea5c8c94addfbf009814c35a1f", + "resolved": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#aab2a77a75ca78e22d69d4a44e1c900bbac41bcf", "dependencies": { "protobufjs": "^6.8.8" } diff --git a/package.json b/package.json index c3e3fdc..c73e616 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "mui-tel-input": "^7.0.0", "notistack": "^3.0.1", "openweathermap-ts": "^1.2.10", - "protobuf-ts": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#i2c_detect", + "protobuf-ts": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#onewire_detect", "query-string": "^9.2.1", "react": "^18.3.1", "react-beautiful-dnd": "^13.1.1", diff --git a/src/device/DeviceWizard.tsx b/src/device/DeviceWizard.tsx index 32387eb..6c8f361 100644 --- a/src/device/DeviceWizard.tsx +++ b/src/device/DeviceWizard.tsx @@ -141,6 +141,28 @@ export default function DeviceWizard(props: Props) { )} + {selectedPort && + // selectedPort.addressType === quack.AddressType.ADDRESS_TYPE_CONFIGURABLE_PIN_ARRAY && + // device.featureSupported("detectOneWire") && + selectedPort.autoDetectable && ( + + { + setButtonClicked(true) + console.log(selectedPort) + deviceAPI.detectOneWire(device.id(), selectedPort.address) + .then(resp => { + openSnack("Device will scan port on next check-in") + }).catch(err => { + openSnack("Command failed to send to device") + }) + }}> + Scan Port + + + )} {portComponents.length > 0 && ( Current Components diff --git a/src/device/autoDetect/DeviceScannedComponents.tsx b/src/device/autoDetect/DeviceScannedComponents.tsx index 0381281..530ecb9 100644 --- a/src/device/autoDetect/DeviceScannedComponents.tsx +++ b/src/device/autoDetect/DeviceScannedComponents.tsx @@ -31,7 +31,8 @@ export default function DeviceScannedComponents(props: Props){ const compAPI = useComponentAPI(); const deviceAPI = useDeviceAPI() const [scannedI2C, setScannedI2C] = useState() //the unmodified scan of addresses - const [validCompAddresses, setValidComponentAddresses] = useState([]) //the filtered array of address data + const [scannedOneWire, setScannedOneWire] = useState([]) + const [validI2CCompAddresses, setValidI2CComponentAddresses] = useState([]) //the filtered array of address data const [components, setComponents] = useState([]) const [steps, setSteps] = useState([]); const { error, success } = useSnackbar(); @@ -40,8 +41,8 @@ export default function DeviceScannedComponents(props: Props){ const [openDialog, setOpenDialog] = useState(false); useEffect(()=>{ - //console.log(scannedComponents) if (scannedComponents.i2c) setScannedI2C(scannedComponents.i2c) + if (scannedComponents.oneWire) setScannedOneWire(scannedComponents.oneWire) //makes the array empty for testing // if (scannedComponents.i2c) { // let clone = cloneDeep(scannedComponents.i2c) @@ -76,7 +77,7 @@ export default function DeviceScannedComponents(props: Props){ } }) } - setValidComponentAddresses(valid) + setValidI2CComponentAddresses(valid) },[scannedI2C]) const stepper = () => { @@ -225,7 +226,7 @@ export default function DeviceScannedComponents(props: Props){ - {validCompAddresses.length > 0 ? validCompAddresses.map((addr, index) => { + {validI2CCompAddresses.length > 0 ? validI2CCompAddresses.map((addr, index) => { return ( ()}/> ) @@ -242,6 +243,23 @@ export default function DeviceScannedComponents(props: Props){ } } + {scannedOneWire.length > 0 && + + + + Pin Port Sensors + + + + {scannedOneWire.map(scan => { + return( + + + + ) + })} + + } diff --git a/src/device/autoDetect/ScannedOneWirePort.tsx b/src/device/autoDetect/ScannedOneWirePort.tsx new file mode 100644 index 0000000..f391dd3 --- /dev/null +++ b/src/device/autoDetect/ScannedOneWirePort.tsx @@ -0,0 +1,7 @@ +import React from "react" + +export default function ScannedOneWirePort(){ + return ( + + ) +} \ No newline at end of file diff --git a/src/models/Device.ts b/src/models/Device.ts index 0aec35a..29f06ef 100644 --- a/src/models/Device.ts +++ b/src/models/Device.ts @@ -48,6 +48,21 @@ const featureVersions: Map = new Map([ v2CellBlue: "2.1.7", v2EthBlue: "2.1.7" } + ],[ + "detectOneWire", + { + photon: "N/A", + electron: "N/A", + v2Wifi: "N/A", + v2Cell: "N/A", + v2WifiS3: "N/A", + v2CellS3: "N/A", + v2CellBlack: "2.1.8", + v2CellGreen: "N/A", + v2WifiBlue: "2.1.8", + v2CellBlue: "2.1.8", + v2EthBlue: "2.1.8" + } ] ]); export class Device { diff --git a/src/pages/Device.tsx b/src/pages/Device.tsx index 4d7d41f..e9012ee 100644 --- a/src/pages/Device.tsx +++ b/src/pages/Device.tsx @@ -1,4 +1,4 @@ -import { Button, Card, Divider, List, ListItem, Typography } from "@mui/material"; +import { Box, Button, Card, Divider, List, ListItem, Typography } from "@mui/material"; import Grid from '@mui/material/Grid2'; import { Component, Device, Interaction, User } from "models"; import { getContextKeys, getContextTypes } from "pbHelpers/Context"; @@ -169,7 +169,8 @@ export default function DevicePage() { const loadPortScan = () => { deviceAPI.listFoundComponents(parseInt(deviceID)) .then(resp => { - if (resp.data.foundComponents?.i2c){ + console.log(resp.data) + if (resp.data.foundComponents){ setScannedAddresses(resp.data.foundComponents ?? undefined) } }) @@ -430,8 +431,8 @@ export default function DevicePage() { refreshCallback={loadDevice} /> - {scannedAddresses && - + {(scannedAddresses?.i2c || scannedAddresses?.oneWire) && + Promise>; getMulti: (ids: number[] | string[], otherTeam?: string) => Promise>; detectI2C: (id: number, otherTeam?: string) => Promise>; + detectOneWire: (id: number, port: number, otherTeam?: string) => Promise> listFoundComponents: (id: number, otherTeam?: string) => Promise> getGeoJson: (id: number | string, demo?: boolean, otherTeam?: string) => Promise; getMultiGeoJson: (ids: number[] | string[], otherTeam?: string) => Promise; @@ -962,6 +963,19 @@ export default function DeviceProvider(props: PropsWithChildren) { }) } + const detectOneWire = (id: number, port: number, otherTeam?: string) => { + let url = "/devices/" + id + "/detectOneWire?port=" + port; + const view = otherTeam ? otherTeam : as + if(view) url = url + "?as=" + view + return new Promise>((resolve, reject) => { + put(pondURL(url)).then(resp => { + return resolve(resp) + }).catch(err => { + return reject(err) + }) + }) + } + const listFoundComponents = (id: number, otherTeam?: string) => { let url = "/devices/" + id + "/listScannedComponents"; const view = otherTeam ? otherTeam : as @@ -1035,6 +1049,7 @@ export default function DeviceProvider(props: PropsWithChildren) { updateComponentPreferences, listDeviceComponentPreferences, detectI2C, + detectOneWire, listFoundComponents, removeFoundComponents }}> From 8f601b360e26f14eb5aa97ebc9b4b062619d9ee8 Mon Sep 17 00:00:00 2001 From: csawatzky Date: Mon, 3 Nov 2025 09:22:47 -0600 Subject: [PATCH 08/10] put in all the data that will be displayed --- package-lock.json | 2 +- .../autoDetect/DeviceScannedComponents.tsx | 21 +++++++-- .../autoDetect/OneWire/PortComponent.tsx | 47 +++++++++++++++++++ .../autoDetect/OneWire/ScannedOneWirePort.tsx | 31 ++++++++++++ src/device/autoDetect/ScannedOneWirePort.tsx | 7 --- src/pages/Device.tsx | 2 +- 6 files changed, 97 insertions(+), 13 deletions(-) create mode 100644 src/device/autoDetect/OneWire/PortComponent.tsx create mode 100644 src/device/autoDetect/OneWire/ScannedOneWirePort.tsx delete mode 100644 src/device/autoDetect/ScannedOneWirePort.tsx diff --git a/package-lock.json b/package-lock.json index 8bf5f65..04f2a51 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10953,7 +10953,7 @@ }, "node_modules/protobuf-ts": { "version": "1.0.0", - "resolved": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#aab2a77a75ca78e22d69d4a44e1c900bbac41bcf", + "resolved": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#53e313b9d0a3b0c081be17f9a599abed80259c6c", "dependencies": { "protobufjs": "^6.8.8" } diff --git a/src/device/autoDetect/DeviceScannedComponents.tsx b/src/device/autoDetect/DeviceScannedComponents.tsx index 530ecb9..18ea15f 100644 --- a/src/device/autoDetect/DeviceScannedComponents.tsx +++ b/src/device/autoDetect/DeviceScannedComponents.tsx @@ -7,9 +7,11 @@ import { useEffect, useState } from "react"; import ScannedI2C from "./ScannedI2C"; import ComponentForm from "component/ComponentForm"; import { Component, Device } from "models"; -import { DeviceAvailabilityMap, OffsetAvailabilityMap } from "pbHelpers/DeviceAvailability"; +import { DeviceAvailabilityMap, FindAvailablePositions, OffsetAvailabilityMap } from "pbHelpers/DeviceAvailability"; import ResponsiveDialog from "common/ResponsiveDialog"; import { useComponentAPI, useDeviceAPI, useSnackbar } from "hooks"; +import { ConfigurablePin } from "pbHelpers/AddressTypes"; +import ScannedOneWirePort from "./OneWire/ScannedOneWirePort"; interface Props { scannedComponents: pond.ComponentAddressMap @@ -251,10 +253,21 @@ export default function DeviceScannedComponents(props: Props){ - {scannedOneWire.map(scan => { + {scannedOneWire.map((scan,i) => { + let map = FindAvailablePositions([], device.settings.product).availability.get(quack.AddressType.ADDRESS_TYPE_CONFIGURABLE_PIN_ARRAY) + let portAddress = scan.settings?.oneWireData?.port + let portLabel = "" + + map?.forEach(entry => { + let pin = entry as ConfigurablePin + if (pin.address && pin.address === portAddress) { + portLabel = pin.label + } + }) return( - - + + Port: {portLabel} + ) })} diff --git a/src/device/autoDetect/OneWire/PortComponent.tsx b/src/device/autoDetect/OneWire/PortComponent.tsx new file mode 100644 index 0000000..c92dfac --- /dev/null +++ b/src/device/autoDetect/OneWire/PortComponent.tsx @@ -0,0 +1,47 @@ +import { Box, MenuItem, TextField } from "@mui/material" +import { getFriendlyName, getSubtypes, Subtype } from "pbHelpers/ComponentType" +import { quack } from "protobuf-ts/quack" +import React, { useEffect, useState } from "react" + +interface Props { + compData: quack.OneWireComponentData +} + +export default function PortComponent(props: Props){ + const {compData} = props + const [selectedSubtype, setSelectedSubtype] = useState(-1) + + useEffect(()=>{ + setSelectedSubtype(compData.subtype) + },[compData]) + + const subtypeSelector = (compData: quack.OneWireComponentData) => { + let validSubtypes: Subtype[] = [] + getSubtypes(compData.type).forEach(option => { + if(compData.subtype === option.key || compData.subtype === 0){ + validSubtypes.push(option) + } + }) + return ( + + Select the Component Subtype + {validSubtypes.map((s, i) => ( + {s.friendlyName} + ))} + + ) + } + + return ( + + + {getFriendlyName(compData.type)} + Cable ID: {compData.cableId} + Number of nodes: {compData.nodeCount} + {subtypeSelector(compData)} + + + ) +} \ No newline at end of file diff --git a/src/device/autoDetect/OneWire/ScannedOneWirePort.tsx b/src/device/autoDetect/OneWire/ScannedOneWirePort.tsx new file mode 100644 index 0000000..a4f3e11 --- /dev/null +++ b/src/device/autoDetect/OneWire/ScannedOneWirePort.tsx @@ -0,0 +1,31 @@ +import { Box, MenuItem, TextField } from "@mui/material" +import { extension, getFriendlyName, getSubtypes, Subtype } from "pbHelpers/ComponentType" +import { pond } from "protobuf-ts/pond" +import { quack } from "protobuf-ts/quack" +import React, { useEffect, useState } from "react" +import PortComponent from "./PortComponent" + +interface Props { + scan: pond.DetectOneWire +} + +export default function ScannedOneWirePort(props: Props){ + const {scan} = props + const [portComponents, setPortComponents] = useState([]) + + useEffect(()=>{ + setPortComponents(scan.settings?.oneWireData?.components ?? []) + },[scan]) + + return ( + + {portComponents.map((compData, i) => { + // let ext = extension(compData.type, compData.subtype) + // console.log(ext) + return ( + + ) + })} + + ) +} \ No newline at end of file diff --git a/src/device/autoDetect/ScannedOneWirePort.tsx b/src/device/autoDetect/ScannedOneWirePort.tsx deleted file mode 100644 index f391dd3..0000000 --- a/src/device/autoDetect/ScannedOneWirePort.tsx +++ /dev/null @@ -1,7 +0,0 @@ -import React from "react" - -export default function ScannedOneWirePort(){ - return ( - - ) -} \ No newline at end of file diff --git a/src/pages/Device.tsx b/src/pages/Device.tsx index e9012ee..ec3443d 100644 --- a/src/pages/Device.tsx +++ b/src/pages/Device.tsx @@ -171,7 +171,7 @@ export default function DevicePage() { .then(resp => { console.log(resp.data) if (resp.data.foundComponents){ - setScannedAddresses(resp.data.foundComponents ?? undefined) + setScannedAddresses(pond.ListFoundComponentsResponse.fromObject(resp.data).foundComponents ?? undefined) } }) .catch(err => { From beee7b6f2a0bf4e98d021676030f38d702825d66 Mon Sep 17 00:00:00 2001 From: csawatzky Date: Mon, 3 Nov 2025 09:52:27 -0600 Subject: [PATCH 09/10] hotfix for putting the interactions on the component cards the interactions are loading and being added correctly but when determining which card to display the interaction on it was not considering the expansion and mux lines in the check for the same component id --- src/pages/Device.tsx | 4 +++- src/pbHelpers/Component.ts | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/pages/Device.tsx b/src/pages/Device.tsx index a06a173..0313373 100644 --- a/src/pages/Device.tsx +++ b/src/pages/Device.tsx @@ -252,7 +252,9 @@ export default function DevicePage() { let id: quack.IComponentID = quack.ComponentID.fromObject({ type: c.settings.type, addressType: c.settings.addressType, - address: c.settings.address + address: c.settings.address, + expansionLine: c.settings.expansionLine, + muxLine: c.settings.muxLine }); let filteredInteractions = interactions.filter(interaction => { let isSource = false; diff --git a/src/pbHelpers/Component.ts b/src/pbHelpers/Component.ts index 9329878..e809649 100644 --- a/src/pbHelpers/Component.ts +++ b/src/pbHelpers/Component.ts @@ -15,7 +15,9 @@ export function sameComponentID( const sameType: boolean = id1.type === id2.type; const sameAddressType: boolean = id1.addressType === id2.addressType; const sameAddress: boolean = (!id1.address && !id2.address) || id1.address === id2.address; - return sameType && sameAddressType && sameAddress; + const sameExpansion: boolean = (!id1.expansionLine && !id2.expansionLine) || id1.expansionLine === id2.expansionLine; + const sameMux: boolean = (!id1.muxLine && !id2.muxLine) || id1.muxLine === id2.muxLine; + return sameType && sameAddressType && sameAddress && sameExpansion && sameMux; } export function getComponentIDString(component?: Component): string { From 65cb7acbab85037fc39d8e016071dfc082d46faa Mon Sep 17 00:00:00 2001 From: csawatzky Date: Mon, 3 Nov 2025 13:23:02 -0600 Subject: [PATCH 10/10] finished the functionality for adding components from the scan --- .../autoDetect/DeviceScannedComponents.tsx | 13 ++-- .../autoDetect/OneWire/PortComponent.tsx | 62 +++++++++++++++---- .../autoDetect/OneWire/ScannedOneWirePort.tsx | 31 ++++++++-- src/pbHelpers/ComponentType.tsx | 1 + .../ComponentTypes/CapacitorCable.ts | 1 + src/pbHelpers/ComponentTypes/GrainCable.ts | 1 + src/pbHelpers/ComponentTypes/PressureCable.ts | 1 + 7 files changed, 90 insertions(+), 20 deletions(-) diff --git a/src/device/autoDetect/DeviceScannedComponents.tsx b/src/device/autoDetect/DeviceScannedComponents.tsx index 18ea15f..e1fc020 100644 --- a/src/device/autoDetect/DeviceScannedComponents.tsx +++ b/src/device/autoDetect/DeviceScannedComponents.tsx @@ -203,6 +203,7 @@ export default function DeviceScannedComponents(props: Props){ }) }) } + console.log(cloneList) setComponents(cloneList) } @@ -251,7 +252,6 @@ export default function DeviceScannedComponents(props: Props){ Pin Port Sensors - {scannedOneWire.map((scan,i) => { let map = FindAvailablePositions([], device.settings.product).availability.get(quack.AddressType.ADDRESS_TYPE_CONFIGURABLE_PIN_ARRAY) @@ -265,9 +265,14 @@ export default function DeviceScannedComponents(props: Props){ } }) return( - - Port: {portLabel} - + + + Port: {portLabel} + + + ) })} diff --git a/src/device/autoDetect/OneWire/PortComponent.tsx b/src/device/autoDetect/OneWire/PortComponent.tsx index c92dfac..ee2ab3f 100644 --- a/src/device/autoDetect/OneWire/PortComponent.tsx +++ b/src/device/autoDetect/OneWire/PortComponent.tsx @@ -1,46 +1,84 @@ -import { Box, MenuItem, TextField } from "@mui/material" +import { Box, Checkbox, MenuItem, TextField, Tooltip } from "@mui/material" import { getFriendlyName, getSubtypes, Subtype } from "pbHelpers/ComponentType" import { quack } from "protobuf-ts/quack" import React, { useEffect, useState } from "react" interface Props { compData: quack.OneWireComponentData + componentSelect: (selected: boolean, componentData: quack.OneWireComponentData) => void } export default function PortComponent(props: Props){ - const {compData} = props - const [selectedSubtype, setSelectedSubtype] = useState(-1) + const {compData, componentSelect} = props + // const [selectedSubtype, setSelectedSubtype] = useState(0) + const [subtypeVal, setSubtypeVal] = useState("none")//note that this is the friendly name and not the key or the value because it needs to be different from the other alias options + const [subtypeMap, setSubtypeMap] = useState>(new Map()) + const [subtypeOptions, setSubtypeOptions] = useState([]) + const [added, setAdded] = useState(false) useEffect(()=>{ - setSelectedSubtype(compData.subtype) - },[compData]) - - const subtypeSelector = (compData: quack.OneWireComponentData) => { + // setSelectedSubtype(compData.subtype) let validSubtypes: Subtype[] = [] + let subMap: Map = new Map() + let subVal: string = "none" getSubtypes(compData.type).forEach(option => { if(compData.subtype === option.key || compData.subtype === 0){ validSubtypes.push(option) + if(subVal === "none"){ + subVal = option.friendlyName + } } + subMap.set(option.friendlyName, option.key) }) + setSubtypeOptions(validSubtypes) + setSubtypeMap(subMap) + setSubtypeVal(subVal) + },[compData]) + + const subtypeSelector = () => { return ( { + setSubtypeVal(event.target.value) + // setSelectedSubtype(subtypeMap.get(event.target.value) ?? 0) + compData.subtype = subtypeMap.get(event.target.value) ?? 0 + }} select> - Select the Component Subtype - {validSubtypes.map((s, i) => ( - {s.friendlyName} + Select the Component Subtype + {subtypeOptions.map((s, i) => ( + {s.friendlyName} ))} ) } + const selectCompCheckbox = () => { + return ( + { + setAdded(checked) + componentSelect(checked, compData) + }} + /> + } + /> + ) + } + return ( {getFriendlyName(compData.type)} Cable ID: {compData.cableId} Number of nodes: {compData.nodeCount} - {subtypeSelector(compData)} + {subtypeOptions.length < 2 ? subtypeVal : subtypeSelector()} + {selectCompCheckbox()} ) diff --git a/src/device/autoDetect/OneWire/ScannedOneWirePort.tsx b/src/device/autoDetect/OneWire/ScannedOneWirePort.tsx index a4f3e11..4fd99d8 100644 --- a/src/device/autoDetect/OneWire/ScannedOneWirePort.tsx +++ b/src/device/autoDetect/OneWire/ScannedOneWirePort.tsx @@ -4,26 +4,49 @@ import { pond } from "protobuf-ts/pond" import { quack } from "protobuf-ts/quack" import React, { useEffect, useState } from "react" import PortComponent from "./PortComponent" +import { Component } from "models" interface Props { scan: pond.DetectOneWire + componentSelectionCallback: (newComponents: Component[], checked: boolean) => void } export default function ScannedOneWirePort(props: Props){ - const {scan} = props + const {scan, componentSelectionCallback} = props const [portComponents, setPortComponents] = useState([]) useEffect(()=>{ setPortComponents(scan.settings?.oneWireData?.components ?? []) },[scan]) + const componentSelected = (checked: boolean, componentData: quack.OneWireComponentData) => { + let newComponents: Component[] = [] + //use the component data to create a new Component + //build a component with given information and defaults for the rest + let primaryComponent = Component.create() + primaryComponent.settings.type = componentData.type + primaryComponent.settings.subtype = componentData.subtype + primaryComponent.settings.address = scan.settings?.oneWireData?.port ?? 0 + primaryComponent.settings.addressType = quack.AddressType.ADDRESS_TYPE_CONFIGURABLE_PIN_ARRAY + primaryComponent.settings.name = getFriendlyName(componentData.type, componentData.subtype) + + //need to check if the component is chainable, meaning the address type will reflect the cable id + let ext = extension(componentData.type, componentData.subtype) + if(ext.isChainable){ + primaryComponent.settings.addressType = componentData.cableId + 8 + } + newComponents.push(primaryComponent) + + componentSelectionCallback(newComponents, checked) + } + return ( {portComponents.map((compData, i) => { - // let ext = extension(compData.type, compData.subtype) - // console.log(ext) return ( - + { + componentSelected(checked, component) + }}/> ) })} diff --git a/src/pbHelpers/ComponentType.tsx b/src/pbHelpers/ComponentType.tsx index 60f14cd..03be638 100644 --- a/src/pbHelpers/ComponentType.tsx +++ b/src/pbHelpers/ComponentType.tsx @@ -168,6 +168,7 @@ export interface ComponentTypeExtension { //if the map does not exist then just use the array from the device availability, //if the map does exist filter the availability after claims to find matching address between them and use that subtypeI2CMap?: Map + isChainable?: boolean } export interface Summary { diff --git a/src/pbHelpers/ComponentTypes/CapacitorCable.ts b/src/pbHelpers/ComponentTypes/CapacitorCable.ts index cc56e27..8843952 100644 --- a/src/pbHelpers/ComponentTypes/CapacitorCable.ts +++ b/src/pbHelpers/ComponentTypes/CapacitorCable.ts @@ -68,6 +68,7 @@ export function CapacitorCable(subtype: number = 0): ComponentTypeExtension { isSource: true, isArray: true, isCalibratable: false, + isChainable: true, addressTypes: addressTypes, interactionResultTypes: [], states: [], diff --git a/src/pbHelpers/ComponentTypes/GrainCable.ts b/src/pbHelpers/ComponentTypes/GrainCable.ts index c715611..bacc514 100644 --- a/src/pbHelpers/ComponentTypes/GrainCable.ts +++ b/src/pbHelpers/ComponentTypes/GrainCable.ts @@ -176,6 +176,7 @@ export function GrainCable(subtype: number = 0): ComponentTypeExtension { isSource: true, isArray: true, isCalibratable: false, + isChainable: true, addressTypes: [quack.AddressType.ADDRESS_TYPE_CONFIGURABLE_PIN_ARRAY, quack.AddressType.ADDRESS_TYPE_I2C], interactionResultTypes: [], states: [], diff --git a/src/pbHelpers/ComponentTypes/PressureCable.ts b/src/pbHelpers/ComponentTypes/PressureCable.ts index f03cc9e..3a22362 100644 --- a/src/pbHelpers/ComponentTypes/PressureCable.ts +++ b/src/pbHelpers/ComponentTypes/PressureCable.ts @@ -64,6 +64,7 @@ export function PressureCable(subtype: number = 0): ComponentTypeExtension { isArray: true, hasFan: true, isCalibratable: false, + isChainable: true, addressTypes: [quack.AddressType.ADDRESS_TYPE_CONFIGURABLE_PIN_ARRAY], interactionResultTypes: [], states: [],