put in all the data that will be displayed
This commit is contained in:
parent
c5a3487db0
commit
8f601b360e
6 changed files with 97 additions and 13 deletions
2
package-lock.json
generated
2
package-lock.json
generated
|
|
@ -10953,7 +10953,7 @@
|
||||||
},
|
},
|
||||||
"node_modules/protobuf-ts": {
|
"node_modules/protobuf-ts": {
|
||||||
"version": "1.0.0",
|
"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": {
|
"dependencies": {
|
||||||
"protobufjs": "^6.8.8"
|
"protobufjs": "^6.8.8"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,11 @@ import { useEffect, useState } from "react";
|
||||||
import ScannedI2C from "./ScannedI2C";
|
import ScannedI2C from "./ScannedI2C";
|
||||||
import ComponentForm from "component/ComponentForm";
|
import ComponentForm from "component/ComponentForm";
|
||||||
import { Component, Device } from "models";
|
import { Component, Device } from "models";
|
||||||
import { DeviceAvailabilityMap, OffsetAvailabilityMap } from "pbHelpers/DeviceAvailability";
|
import { DeviceAvailabilityMap, FindAvailablePositions, OffsetAvailabilityMap } from "pbHelpers/DeviceAvailability";
|
||||||
import ResponsiveDialog from "common/ResponsiveDialog";
|
import ResponsiveDialog from "common/ResponsiveDialog";
|
||||||
import { useComponentAPI, useDeviceAPI, useSnackbar } from "hooks";
|
import { useComponentAPI, useDeviceAPI, useSnackbar } from "hooks";
|
||||||
|
import { ConfigurablePin } from "pbHelpers/AddressTypes";
|
||||||
|
import ScannedOneWirePort from "./OneWire/ScannedOneWirePort";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
scannedComponents: pond.ComponentAddressMap
|
scannedComponents: pond.ComponentAddressMap
|
||||||
|
|
@ -251,10 +253,21 @@ export default function DeviceScannedComponents(props: Props){
|
||||||
</Typography>
|
</Typography>
|
||||||
<Button variant="contained" color="primary" onClick={()=>{}}>Clear Scan</Button>
|
<Button variant="contained" color="primary" onClick={()=>{}}>Clear Scan</Button>
|
||||||
</Box>
|
</Box>
|
||||||
{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(
|
return(
|
||||||
<Box>
|
<Box key={i}>
|
||||||
|
<Typography>Port: {portLabel}</Typography>
|
||||||
|
<ScannedOneWirePort scan={scan}/>
|
||||||
</Box>
|
</Box>
|
||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
|
|
|
||||||
47
src/device/autoDetect/OneWire/PortComponent.tsx
Normal file
47
src/device/autoDetect/OneWire/PortComponent.tsx
Normal file
|
|
@ -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<number>(-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 (
|
||||||
|
<TextField
|
||||||
|
value={selectedSubtype}
|
||||||
|
select>
|
||||||
|
<MenuItem key={-1} value={-1}>Select the Component Subtype</MenuItem>
|
||||||
|
{validSubtypes.map((s, i) => (
|
||||||
|
<MenuItem key={i} value={s.key}>{s.friendlyName}</MenuItem>
|
||||||
|
))}
|
||||||
|
</TextField>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<React.Fragment>
|
||||||
|
<Box>
|
||||||
|
{getFriendlyName(compData.type)}
|
||||||
|
Cable ID: {compData.cableId}
|
||||||
|
Number of nodes: {compData.nodeCount}
|
||||||
|
{subtypeSelector(compData)}
|
||||||
|
</Box>
|
||||||
|
</React.Fragment>
|
||||||
|
)
|
||||||
|
}
|
||||||
31
src/device/autoDetect/OneWire/ScannedOneWirePort.tsx
Normal file
31
src/device/autoDetect/OneWire/ScannedOneWirePort.tsx
Normal file
|
|
@ -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<quack.OneWireComponentData[]>([])
|
||||||
|
|
||||||
|
useEffect(()=>{
|
||||||
|
setPortComponents(scan.settings?.oneWireData?.components ?? [])
|
||||||
|
},[scan])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<React.Fragment>
|
||||||
|
{portComponents.map((compData, i) => {
|
||||||
|
// let ext = extension(compData.type, compData.subtype)
|
||||||
|
// console.log(ext)
|
||||||
|
return (
|
||||||
|
<PortComponent compData={compData}/>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
</React.Fragment>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
import React from "react"
|
|
||||||
|
|
||||||
export default function ScannedOneWirePort(){
|
|
||||||
return (
|
|
||||||
<React.Fragment></React.Fragment>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
@ -171,7 +171,7 @@ export default function DevicePage() {
|
||||||
.then(resp => {
|
.then(resp => {
|
||||||
console.log(resp.data)
|
console.log(resp.data)
|
||||||
if (resp.data.foundComponents){
|
if (resp.data.foundComponents){
|
||||||
setScannedAddresses(resp.data.foundComponents ?? undefined)
|
setScannedAddresses(pond.ListFoundComponentsResponse.fromObject(resp.data).foundComponents ?? undefined)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue