added button to send down the onewire scan request
This commit is contained in:
parent
33eb4e6eca
commit
c5a3487db0
8 changed files with 89 additions and 11 deletions
|
|
@ -141,6 +141,28 @@ export default function DeviceWizard(props: Props) {
|
|||
</MenuItem>
|
||||
</Tooltip>
|
||||
)}
|
||||
{selectedPort &&
|
||||
// selectedPort.addressType === quack.AddressType.ADDRESS_TYPE_CONFIGURABLE_PIN_ARRAY &&
|
||||
// device.featureSupported("detectOneWire") &&
|
||||
selectedPort.autoDetectable && (
|
||||
<Tooltip title="Used to tell the Device to scan this port for any plugged in sensors">
|
||||
<MenuItem
|
||||
key={"scanOneWire"}
|
||||
disabled={scanInProgress || buttonClicked}
|
||||
onClick={() => {
|
||||
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
|
||||
</MenuItem>
|
||||
</Tooltip>
|
||||
)}
|
||||
{portComponents.length > 0 && (
|
||||
<List>
|
||||
<ListSubheader>Current Components</ListSubheader>
|
||||
|
|
|
|||
|
|
@ -31,7 +31,8 @@ export default function DeviceScannedComponents(props: Props){
|
|||
const compAPI = useComponentAPI();
|
||||
const deviceAPI = useDeviceAPI()
|
||||
const [scannedI2C, setScannedI2C] = useState<pond.DetectI2C>() //the unmodified scan of addresses
|
||||
const [validCompAddresses, setValidComponentAddresses] = useState<quack.AddressData[]>([]) //the filtered array of address data
|
||||
const [scannedOneWire, setScannedOneWire] = useState<pond.DetectOneWire[]>([])
|
||||
const [validI2CCompAddresses, setValidI2CComponentAddresses] = useState<quack.AddressData[]>([]) //the filtered array of address data
|
||||
const [components, setComponents] = useState<Component[]>([])
|
||||
const [steps, setSteps] = useState<CompStep[]>([]);
|
||||
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){
|
|||
</Typography>
|
||||
<Button variant="contained" color="primary" onClick={()=>{removeScan(scannedI2C.key)}}>Clear Scan</Button>
|
||||
</Box>
|
||||
{validCompAddresses.length > 0 ? validCompAddresses.map((addr, index) => {
|
||||
{validI2CCompAddresses.length > 0 ? validI2CCompAddresses.map((addr, index) => {
|
||||
return (
|
||||
<ScannedI2C key={index} sensorNum={index+1} addressData={addr} deviceProduct={device.settings.product} componentSelectionCallback={componentSelection} availablePositions={availablePositions.get(quack.AddressType.ADDRESS_TYPE_I2C) ?? new Map<quack.ComponentType, number[]>()}/>
|
||||
)
|
||||
|
|
@ -242,6 +243,23 @@ export default function DeviceScannedComponents(props: Props){
|
|||
}
|
||||
</React.Fragment>
|
||||
}
|
||||
{scannedOneWire.length > 0 &&
|
||||
<Box marginTop={10}>
|
||||
<Box justifyContent="space-between" display="flex">
|
||||
<Typography sx={{fontWeight: 650}}>
|
||||
Pin Port Sensors
|
||||
</Typography>
|
||||
<Button variant="contained" color="primary" onClick={()=>{}}>Clear Scan</Button>
|
||||
</Box>
|
||||
{scannedOneWire.map(scan => {
|
||||
return(
|
||||
<Box>
|
||||
|
||||
</Box>
|
||||
)
|
||||
})}
|
||||
</Box>
|
||||
}
|
||||
<Box display="flex" flexDirection="row-reverse" marginTop={2}>
|
||||
<Button disabled={components.length === 0} variant="contained" color="primary" onClick={()=>{setOpenDialog(true)}}>Add Components</Button>
|
||||
</Box>
|
||||
|
|
|
|||
7
src/device/autoDetect/ScannedOneWirePort.tsx
Normal file
7
src/device/autoDetect/ScannedOneWirePort.tsx
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import React from "react"
|
||||
|
||||
export default function ScannedOneWirePort(){
|
||||
return (
|
||||
<React.Fragment></React.Fragment>
|
||||
)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue