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 => {