updated the proto with the new definition for the i2c scan stuff, and updated the react components accordingly

This commit is contained in:
csawatzky 2025-07-14 13:25:54 -06:00
parent 8b69632be4
commit 4cfbe9f1c6
4 changed files with 13 additions and 13 deletions

4
package-lock.json generated
View file

@ -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#cable_expander",
"protobuf-ts": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#i2c_detect",
"query-string": "^9.2.1",
"react": "^18.3.1",
"react-beautiful-dnd": "^13.1.1",
@ -10889,7 +10889,7 @@
},
"node_modules/protobuf-ts": {
"version": "1.0.0",
"resolved": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#eff6e4e51be080fdee9503d74ee66a0504436545",
"resolved": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#955871c0a855e8da5dd10b8d72a1ccc5e391d218",
"dependencies": {
"protobufjs": "^6.8.8"
}

View file

@ -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#cable_expander",
"protobuf-ts": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#i2c_detect",
"query-string": "^9.2.1",
"react": "^18.3.1",
"react-beautiful-dnd": "^13.1.1",

View file

@ -207,7 +207,7 @@ export default function DeviceScannedComponents(props: Props){
</Box>
{scannedI2C.settings?.foundAddresses && scannedI2C.settings.foundAddresses.length > 0 ? scannedI2C?.settings?.foundAddresses.map((addr, index) => {
return (
<ScannedI2C key={index} sensorNum={index+1} decimalAddress={addr} deviceProduct={device.settings.product} componentSelectionCallback={componentSelection} availablePositions={availablePositions.get(quack.AddressType.ADDRESS_TYPE_I2C) ?? []}/>
<ScannedI2C key={index} sensorNum={index+1} addressData={addr} deviceProduct={device.settings.product} componentSelectionCallback={componentSelection} availablePositions={availablePositions.get(quack.AddressType.ADDRESS_TYPE_I2C) ?? []}/>
)
}) :
<Box sx={{

View file

@ -8,7 +8,7 @@ import { quack } from "protobuf-ts/quack";
import React, { useEffect, useState } from "react";
interface Props {
decimalAddress: number
addressData: quack.AddressData
deviceProduct: pond.DeviceProduct
componentSelectionCallback: (component: Component[], checked: boolean) => void
availablePositions: DevicePositions
@ -16,7 +16,7 @@ interface Props {
}
export default function ScannedI2C(props: Props){
const {decimalAddress, deviceProduct, componentSelectionCallback, availablePositions, sensorNum} = props
const {addressData, deviceProduct, componentSelectionCallback, availablePositions, sensorNum} = props
const [types, setTypes] = useState<quack.ComponentType[]>([])
const [subtypeOptions, setSubtypeOptions] = useState<Array<Subtype>>([])
const [selectedPrimaryType, setSelectedPrimaryType] = useState<quack.ComponentType>(quack.ComponentType.COMPONENT_TYPE_INVALID)
@ -34,7 +34,7 @@ export default function ScannedI2C(props: Props){
if(i2cMap){
i2cMap.forEach((val, key) => {
let addresses = val as number[] ?? []
if(addresses.length > 0 && addresses.includes(decimalAddress)){
if(addresses.length > 0 && addresses.includes(addressData.address)){
types.push(key)
}
})
@ -47,7 +47,7 @@ export default function ScannedI2C(props: Props){
checkAddressAvailable(types[0])
}
setTypes(types)
},[decimalAddress, deviceProduct])
},[addressData, deviceProduct])
const buildSubtypeOptions = (compType: quack.ComponentType) => {
let subtypes = getSubtypes(compType)
@ -69,7 +69,7 @@ export default function ScannedI2C(props: Props){
const checkAddressAvailable = (compType: quack.ComponentType) => {
let i2cMap = availablePositions as ComponentAvailabilityMap
let compAddresses = i2cMap.get(compType) ?? []
if (!compAddresses.includes(decimalAddress)){
if (!compAddresses.includes(addressData.address)){
setAddressInUse(true)
}else{
setAddressInUse(false)
@ -86,7 +86,10 @@ export default function ScannedI2C(props: Props){
primaryComponent.settings.type = selectedPrimaryType
primaryComponent.settings.subtype = selectedPrimarySubtype
primaryComponent.settings.addressType = quack.AddressType.ADDRESS_TYPE_I2C
primaryComponent.settings.address = decimalAddress
primaryComponent.settings.address = addressData.address
primaryComponent.settings.expansionLine = addressData.expansionLine
primaryComponent.settings.muxLine = addressData.muxLine
primaryComponent.settings.name = getFriendlyName(selectedPrimaryType, selectedPrimarySubtype)
toAdd.push(primaryComponent)
@ -161,9 +164,6 @@ export default function ScannedI2C(props: Props){
</Grid2>
</Grid2>
{
}
</React.Fragment>
:
<Typography>Sensor Not Supported By Product</Typography>