From 3325c9d75b99cf7d70df2ea4e17c518f86bb585d Mon Sep 17 00:00:00 2001 From: csawatzky Date: Fri, 11 Jul 2025 13:56:17 -0600 Subject: [PATCH 01/16] implemented the epansion line stuff made adjustments to to the grain cable by adding i2c as an option as long as you set and expander line, also ajusted DeviceAvailability so that an i2c address will not be claimed if the component has an expansion line set, updated the device wizard to removed pin options if the i2c port was selected and vice versa for pins since we now have a components that supports both types, updated the components setting to set the default address type based on the restriction passed in that is set by the wizard, and fall back to what is was before if one is not passed in --- package-lock.json | 4 +- package.json | 2 +- src/component/ComponentSettings.tsx | 74 ++++++++++++++++----- src/device/DeviceWizard.tsx | 9 ++- src/models/Component.ts | 15 +++-- src/pbHelpers/AddressTypes/I2C.ts | 3 +- src/pbHelpers/Bin.ts | 1 + src/pbHelpers/Component.ts | 15 +++-- src/pbHelpers/ComponentTypes/GrainCable.ts | 2 +- src/pbHelpers/DeviceAvailability.ts | 17 ++++- src/products/Bindapt/BindaptAvailability.ts | 7 +- 11 files changed, 113 insertions(+), 36 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1d88f79..46b99c0 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#staging", + "protobuf-ts": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#cable_expander", "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#4523ffef42032eb4a923bd50d4cfcccbb1397dbd", + "resolved": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#eff6e4e51be080fdee9503d74ee66a0504436545", "dependencies": { "protobufjs": "^6.8.8" } diff --git a/package.json b/package.json index af322fc..28bd178 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#cable_expander", "query-string": "^9.2.1", "react": "^18.3.1", "react-beautiful-dnd": "^13.1.1", diff --git a/src/component/ComponentSettings.tsx b/src/component/ComponentSettings.tsx index 54653a2..01ee66d 100644 --- a/src/component/ComponentSettings.tsx +++ b/src/component/ComponentSettings.tsx @@ -169,6 +169,7 @@ export default function ComponentSettings(props: Props) { const [removeDialogOpen, setRemoveDialogOpen] = useState(false); const [formComponent, setFormComponent] = useState(new Component()); const [cableID, setCableID] = useState(0); + const [expansionLine, setExpansionLine] = useState(0); const [overlayIndex, setOverlayIndex] = useState(0); const [overlayColourDialog, setOverlayCoulourDialog] = useState(false); const [tabVal, setTabVal] = useState(0); @@ -222,6 +223,9 @@ export default function ComponentSettings(props: Props) { const isFormValid = () => { //let { component } = form; let type = or(formComponent.settings.type, ""); + if(supportsExpansion() && expansionLine === 0){ + return false + } return isComponentTypeValid(type) && isAddressValid(formComponent); }; @@ -238,7 +242,6 @@ export default function ComponentSettings(props: Props) { componentType: quack.ComponentType ): number[] => { let positions = availablePositions.get(addressType); - console.log(positions) if (!positions) return []; switch (addressType) { case quack.AddressType.ADDRESS_TYPE_I2C: @@ -306,6 +309,7 @@ export default function ComponentSettings(props: Props) { const component = formComponent; //component.settings.calibrationCoefficient = Number(form.coefficient); if (cableID > 0) component.settings.addressType = cableID + 8; + component.settings.expansionLine = expansionLine componentAPI .add(device.id(), component.settings, as) .then((_response: any) => { @@ -372,10 +376,10 @@ export default function ComponentSettings(props: Props) { let ext = extension(type, subtype); formComponent.settings.type = type; formComponent.settings.subtype = subtype; - formComponent.settings.addressType = getAddressTypes( + formComponent.settings.addressType = or(addressTypeRestriction, getAddressTypes( formComponent.settings.type, formComponent.settings.subtype - )[0]; + )[0]); formComponent.settings.address = or( getAvailablePositions(formComponent.settings.addressType, formComponent.settings.type)[0], Component.create().settings.address @@ -398,11 +402,19 @@ export default function ComponentSettings(props: Props) { }; const handlePositionChanged = (event: any) => { + setCableID(0) + setExpansionLine(0) let f = cloneDeep(formComponent); - f.settings.address = event.target.value - .toString() - .split(":") - .pop(); + //split the string + let split: string[] = event.target.value.toString().split(":") + // pop the addres off of the end of the array + f.settings.address = parseInt(split.pop() ?? "0") + // pop the address type out of the array next + f.settings.addressType = parseInt(split.pop() ?? "0") + // f.settings.address = event.target.value + // .toString() + // .split(":") + // .pop(); setFormComponent(f); }; @@ -413,7 +425,6 @@ export default function ComponentSettings(props: Props) { for (let i = 0; i < addressTypes.length; i++) { let addressType = addressTypes[i]; let availablePositions = getAvailablePositions(addressType, type); - console.log(availablePositions) availableMenuItemPositions.push( @@ -490,6 +501,21 @@ export default function ComponentSettings(props: Props) { ); }; + const isCableComponent = () => { + return (formComponent.settings.type === quack.ComponentType.COMPONENT_TYPE_GRAIN_CABLE || + formComponent.settings.type === + quack.ComponentType.COMPONENT_TYPE_DRAGER_GAS_DONGLE || + formComponent.settings.type === quack.ComponentType.COMPONENT_TYPE_PRESSURE_CABLE || + (formComponent.settings.type === quack.ComponentType.COMPONENT_TYPE_CAPACITOR_CABLE && + formComponent.subType() === + quack.CapacitorCableSubtype.CAPACITOR_CABLE_SUBTYPE_FROG)) + } + + const supportsExpansion = () => { + return (formComponent.settings.type === quack.ComponentType.COMPONENT_TYPE_GRAIN_CABLE && + formComponent.settings.addressType === quack.AddressType.ADDRESS_TYPE_I2C) + } + const addForm = () => { return ( @@ -543,14 +569,8 @@ export default function ComponentSettings(props: Props) { formComponent.settings.subtype )} - {(formComponent.settings.type === quack.ComponentType.COMPONENT_TYPE_GRAIN_CABLE || - formComponent.settings.type === - quack.ComponentType.COMPONENT_TYPE_DRAGER_GAS_DONGLE || - formComponent.settings.type === quack.ComponentType.COMPONENT_TYPE_PRESSURE_CABLE || - (formComponent.settings.type === quack.ComponentType.COMPONENT_TYPE_CAPACITOR_CABLE && - formComponent.subType() === - quack.CapacitorCableSubtype.CAPACITOR_CABLE_SUBTYPE_FROG)) && - setComponentAddrType()} + {supportsExpansion() && setExpLine()} + {(isCableComponent() && !supportsExpansion())&& setComponentAddrType()} ) : activeStep === 1 ? ( ); }; + + const setExpLine = () => { + return ( + 12} + fullWidth + variant="outlined" + value={expansionLine} + helperText="Enter line the cable is connected to on your expander" + onChange={e => { + let number = parseInt(e.target.value); + if (number < 0 || isNaN(number)) number = 0; + if (number > 12) number = 12; + setExpansionLine(number); + }} + /> + ); + }; + const setComponentAddrType = () => { return ( { let currentAvailability = availability; + console.log(port) switch (port.addressType) { case quack.AddressType.ADDRESS_TYPE_CONFIGURABLE_PIN_ARRAY: currentAvailability.set(port.addressType, [{ address: port.address, label: port.label }]); + //since we now have a component type that can be pins or i2c need to remove i2c options if they selected a pin port + currentAvailability.set(quack.AddressType.ADDRESS_TYPE_I2C, new Map()); + break; + case quack.AddressType.ADDRESS_TYPE_I2C: + //since we now have a component type that can be pins or i2c need to remove pin options if they selected the i2c port + currentAvailability.set(quack.AddressType.ADDRESS_TYPE_CONFIGURABLE_PIN_ARRAY, []); + break; } return currentAvailability; }; diff --git a/src/models/Component.ts b/src/models/Component.ts index 84f5574..9b96599 100644 --- a/src/models/Component.ts +++ b/src/models/Component.ts @@ -67,18 +67,25 @@ export class Component { return quack.ComponentID.fromObject({ type: this.settings.type, addressType: this.settings.addressType, - address: this.settings.address + address: this.settings.address, + expansionLine: this.settings.expansionLine, + muxLine: this.settings.muxLine }); } public locationString(): string { - return ( - or(this.settings.type, 0).toString() + + let compositeLocation = or(this.settings.type, 0).toString() + "-" + or(this.settings.addressType, 0).toString() + "-" + or(this.settings.address, 0).toString() - ); + if(this.settings.expansionLine){ + compositeLocation = compositeLocation + "-" + this.settings.expansionLine + } + if(this.settings.muxLine){ + compositeLocation = compositeLocation + ":" + this.settings.muxLine + } + return compositeLocation; } public type(): quack.ComponentType { diff --git a/src/pbHelpers/AddressTypes/I2C.ts b/src/pbHelpers/AddressTypes/I2C.ts index c17c743..339ce70 100644 --- a/src/pbHelpers/AddressTypes/I2C.ts +++ b/src/pbHelpers/AddressTypes/I2C.ts @@ -16,7 +16,8 @@ export const I2C: AddressTypeExtension = { [quack.ComponentType.COMPONENT_TYPE_CAPACITANCE, 0x4f], [quack.ComponentType.COMPONENT_TYPE_CAPACITOR_CABLE, 0x4f], [quack.ComponentType.COMPONENT_TYPE_SEN5X, 0x68], - [quack.ComponentType.COMPONENT_TYPE_AIRFLOW, 0x29] + [quack.ComponentType.COMPONENT_TYPE_AIRFLOW, 0x29], + [quack.ComponentType.COMPONENT_TYPE_GRAIN_CABLE, 0x70] ]); const offset = offsets.get(componentType); diff --git a/src/pbHelpers/Bin.ts b/src/pbHelpers/Bin.ts index 1d16928..7c868e0 100644 --- a/src/pbHelpers/Bin.ts +++ b/src/pbHelpers/Bin.ts @@ -16,6 +16,7 @@ export const GetBinShapeDescribers = (): BinShapeDescriber[] => { ]; }; +// DEPRECATED -- the bon now knows its components from the relative object table export const HasGrainCable = (bin?: pond.BinSettings): boolean => { if (bin && bin.deviceComponents) { bin.deviceComponents.forEach(dc => { diff --git a/src/pbHelpers/Component.ts b/src/pbHelpers/Component.ts index e5d0df1..9329878 100644 --- a/src/pbHelpers/Component.ts +++ b/src/pbHelpers/Component.ts @@ -23,7 +23,9 @@ export function getComponentIDString(component?: Component): string { ? componentIDToString({ type: component.settings.type, addressType: component.settings.addressType, - address: component.settings.address + address: component.settings.address, + expansionLine: component.settings.expansionLine, + muxLine: component.settings.muxLine }) : "0-0-0"; } @@ -40,13 +42,18 @@ export function componentIDToString(componentID?: quack.IComponentID | null): st if (!componentID) { return "0-0-0"; } - return ( - or(componentID.type, 0).toString() + + let compositeLocation = or(componentID.type, 0).toString() + "-" + or(componentID.addressType, 0).toString() + "-" + or(componentID.address, 0).toString() - ); + if(componentID.expansionLine){ + compositeLocation = compositeLocation + "-" + componentID.expansionLine + } + if(componentID.muxLine){ + compositeLocation = compositeLocation + ":" + componentID.muxLine + } + return compositeLocation; } export function stringToComponentId(componentIDString: string): quack.ComponentID { diff --git a/src/pbHelpers/ComponentTypes/GrainCable.ts b/src/pbHelpers/ComponentTypes/GrainCable.ts index 4ddfd21..5369000 100644 --- a/src/pbHelpers/ComponentTypes/GrainCable.ts +++ b/src/pbHelpers/ComponentTypes/GrainCable.ts @@ -176,7 +176,7 @@ export function GrainCable(subtype: number = 0): ComponentTypeExtension { isSource: true, isArray: true, isCalibratable: false, - addressTypes: [quack.AddressType.ADDRESS_TYPE_CONFIGURABLE_PIN_ARRAY], + addressTypes: [quack.AddressType.ADDRESS_TYPE_CONFIGURABLE_PIN_ARRAY, quack.AddressType.ADDRESS_TYPE_I2C], interactionResultTypes: [], states: [], measurements: [ diff --git a/src/pbHelpers/DeviceAvailability.ts b/src/pbHelpers/DeviceAvailability.ts index c50a2a4..0d57698 100644 --- a/src/pbHelpers/DeviceAvailability.ts +++ b/src/pbHelpers/DeviceAvailability.ts @@ -11,6 +11,11 @@ export type DevicePositions = number[] | ComponentAvailabilityMap | Configurable export type DeviceAvailabilityMap = Map; export type OffsetAvailabilityMap = Map; +//component types that can be connected to an expander in the I2C port +const ExpansionComponentTypes: quack.ComponentType[] = [ + quack.ComponentType.COMPONENT_TYPE_GRAIN_CABLE +] + const DefaultPinArray: ConfigurablePin[] = [ { address: 1, label: "1" }, { address: 2, label: "2" }, @@ -60,7 +65,8 @@ const DefaultAvailability: DeviceAvailabilityMap = new Map 0) addressType = addressType - (7 + offset); @@ -127,6 +134,9 @@ export class DeviceAvailability { break; case quack.AddressType.ADDRESS_TYPE_I2C: case quack.AddressType.ADDRESS_TYPE_SPI: + if(expansionLine){ + break; + } let addressTypePositions = cloneDeep( this.availability.get(addressType) as ComponentAvailabilityMap ); @@ -171,7 +181,8 @@ export function FindAvailablePositions( available.ClaimAddress( component.settings.addressType, component.settings.type, - or(component.settings.address, 0) + or(component.settings.address, 0), + component.settings.expansionLine ); } }); diff --git a/src/products/Bindapt/BindaptAvailability.ts b/src/products/Bindapt/BindaptAvailability.ts index 3f70a11..be18f38 100644 --- a/src/products/Bindapt/BindaptAvailability.ts +++ b/src/products/Bindapt/BindaptAvailability.ts @@ -246,7 +246,7 @@ export const BindaptV2MonitorAvailability: DeviceAvailabilityMap = new Map< [ quack.AddressType.ADDRESS_TYPE_I2C, new Map([ - //[quack.ComponentType.COMPONENT_TYPE_PRESSURE, [0x18]], + [quack.ComponentType.COMPONENT_TYPE_PRESSURE, [0x18]], [quack.ComponentType.COMPONENT_TYPE_DHT, [0x40]], // [quack.ComponentType.COMPONENT_TYPE_VAPOUR_PRESSURE_DEFICIT, [0x40]], //component type deprecated? [quack.ComponentType.COMPONENT_TYPE_LIDAR, [0x62]], @@ -278,12 +278,13 @@ export const BindaptV2AutomateAvailability: DeviceAvailabilityMap = new Map< [ quack.AddressType.ADDRESS_TYPE_I2C, new Map([ - //[quack.ComponentType.COMPONENT_TYPE_PRESSURE, [0x18]], + [quack.ComponentType.COMPONENT_TYPE_PRESSURE, [0x18]], [quack.ComponentType.COMPONENT_TYPE_DHT, [0x40]], // [quack.ComponentType.COMPONENT_TYPE_VAPOUR_PRESSURE_DEFICIT, [0x40]], //component type deprecated? [quack.ComponentType.COMPONENT_TYPE_LIDAR, [0x62]], [quack.ComponentType.COMPONENT_TYPE_CO2, [0x61]], - [quack.ComponentType.COMPONENT_TYPE_SEN5X, [0x69]] + [quack.ComponentType.COMPONENT_TYPE_SEN5X, [0x69]], + [quack.ComponentType.COMPONENT_TYPE_GRAIN_CABLE, [0x71]] ]) ], [quack.AddressType.ADDRESS_TYPE_POWER, [0]], From 8b69632be40d90e794e07c25452d37e96426b1b8 Mon Sep 17 00:00:00 2001 From: csawatzky Date: Fri, 11 Jul 2025 13:56:39 -0600 Subject: [PATCH 02/16] removed the unused array --- src/pbHelpers/DeviceAvailability.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/pbHelpers/DeviceAvailability.ts b/src/pbHelpers/DeviceAvailability.ts index 0d57698..72bbbdc 100644 --- a/src/pbHelpers/DeviceAvailability.ts +++ b/src/pbHelpers/DeviceAvailability.ts @@ -11,11 +11,6 @@ export type DevicePositions = number[] | ComponentAvailabilityMap | Configurable export type DeviceAvailabilityMap = Map; export type OffsetAvailabilityMap = Map; -//component types that can be connected to an expander in the I2C port -const ExpansionComponentTypes: quack.ComponentType[] = [ - quack.ComponentType.COMPONENT_TYPE_GRAIN_CABLE -] - const DefaultPinArray: ConfigurablePin[] = [ { address: 1, label: "1" }, { address: 2, label: "2" }, From cb5e2a6ba4e9c451c46b03a2eed9091af0c737e1 Mon Sep 17 00:00:00 2001 From: csawatzky Date: Fri, 11 Jul 2025 14:12:08 -0600 Subject: [PATCH 03/16] proto update --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 46b99c0..437e5d5 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#cable_expander", + "protobuf-ts": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#dev", "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#801fdcc314a081c283564e1ac551f8b012c0d59c", "dependencies": { "protobufjs": "^6.8.8" } diff --git a/package.json b/package.json index 28bd178..ed3648f 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#cable_expander", + "protobuf-ts": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#dev", "query-string": "^9.2.1", "react": "^18.3.1", "react-beautiful-dnd": "^13.1.1", From f7266355515c74d179ff161faffa6532ab2cf6d9 Mon Sep 17 00:00:00 2001 From: csawatzky Date: Fri, 11 Jul 2025 15:18:07 -0600 Subject: [PATCH 04/16] forgot to add the address as an option to the monitor --- src/products/Bindapt/BindaptAvailability.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/products/Bindapt/BindaptAvailability.ts b/src/products/Bindapt/BindaptAvailability.ts index be18f38..50575d8 100644 --- a/src/products/Bindapt/BindaptAvailability.ts +++ b/src/products/Bindapt/BindaptAvailability.ts @@ -251,7 +251,8 @@ export const BindaptV2MonitorAvailability: DeviceAvailabilityMap = new Map< // [quack.ComponentType.COMPONENT_TYPE_VAPOUR_PRESSURE_DEFICIT, [0x40]], //component type deprecated? [quack.ComponentType.COMPONENT_TYPE_LIDAR, [0x62]], [quack.ComponentType.COMPONENT_TYPE_CO2, [0x61]], - [quack.ComponentType.COMPONENT_TYPE_SEN5X, [0x69]] + [quack.ComponentType.COMPONENT_TYPE_SEN5X, [0x69]], + [quack.ComponentType.COMPONENT_TYPE_GRAIN_CABLE, [0x71]] ]) ], [quack.AddressType.ADDRESS_TYPE_POWER, [0]], From 4cfbe9f1c6a89eca04e9c056e37c8722aae3f5f7 Mon Sep 17 00:00:00 2001 From: csawatzky Date: Mon, 14 Jul 2025 13:25:54 -0600 Subject: [PATCH 05/16] updated the proto with the new definition for the i2c scan stuff, and updated the react components accordingly --- package-lock.json | 4 ++-- package.json | 2 +- .../autoDetect/DeviceScannedComponents.tsx | 2 +- src/device/autoDetect/ScannedI2C.tsx | 18 +++++++++--------- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/package-lock.json b/package-lock.json index 46b99c0..2c26833 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#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" } diff --git a/package.json b/package.json index 28bd178..99939e6 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#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", diff --git a/src/device/autoDetect/DeviceScannedComponents.tsx b/src/device/autoDetect/DeviceScannedComponents.tsx index 2f5efdd..03a847e 100644 --- a/src/device/autoDetect/DeviceScannedComponents.tsx +++ b/src/device/autoDetect/DeviceScannedComponents.tsx @@ -207,7 +207,7 @@ export default function DeviceScannedComponents(props: Props){ {scannedI2C.settings?.foundAddresses && scannedI2C.settings.foundAddresses.length > 0 ? scannedI2C?.settings?.foundAddresses.map((addr, index) => { return ( - + ) }) : 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([]) const [subtypeOptions, setSubtypeOptions] = useState>([]) const [selectedPrimaryType, setSelectedPrimaryType] = useState(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){ - { - - } : Sensor Not Supported By Product From 38ae04f40caa512150041bc0c80a0669aee5d0b0 Mon Sep 17 00:00:00 2001 From: csawatzky Date: Thu, 24 Jul 2025 15:56:23 -0600 Subject: [PATCH 06/16] added the airlfow subtypes --- src/pbHelpers/ComponentTypes/Airflow.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/pbHelpers/ComponentTypes/Airflow.ts b/src/pbHelpers/ComponentTypes/Airflow.ts index fde83e2..2e46725 100644 --- a/src/pbHelpers/ComponentTypes/Airflow.ts +++ b/src/pbHelpers/ComponentTypes/Airflow.ts @@ -25,7 +25,18 @@ export function Airflow(subtype: number = 0): ComponentTypeExtension { ); return { type: quack.ComponentType.COMPONENT_TYPE_AIRFLOW, - subtypes: [], + subtypes: [ + { + key: quack.AirFlowSubtype.AIR_FLOW_SUBTYPE_PROSENSE, + value: "AIR_FLOW_SUBTYPE_PROSENSE", + friendlyName: "Prosense" + }, + { + key: quack.AirFlowSubtype.AIR_FLOW_SUBTYPE_ULTRASONIC, + value: "AIR_FLOW_SUBTYPE_ULTRASONIC", + friendlyName: "Ultrasonic" + }, + ], friendlyName: "Airflow", description: "Measure the flow of air though a specified area", isController: false, From 8a53f9689af227fd03557b70bb25ae66417f98c9 Mon Sep 17 00:00:00 2001 From: csawatzky Date: Fri, 25 Jul 2025 09:45:32 -0600 Subject: [PATCH 07/16] changed the speed to be m/s in metric rather than km/h and ft/m in imperial and added the measurement type for speed/velocity to the airflow component --- package.json | 2 +- src/models/UnitMeasurement.ts | 10 +++++++ src/pbHelpers/ComponentType.tsx | 5 ++-- src/pbHelpers/ComponentTypes/Airflow.ts | 38 +++++++++++++++++++------ src/pbHelpers/MeasurementDescriber.ts | 3 +- 5 files changed, 46 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index ee0e9b7..59e639d 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#airflow", "query-string": "^9.2.1", "react": "^18.3.1", "react-beautiful-dnd": "^13.1.1", diff --git a/src/models/UnitMeasurement.ts b/src/models/UnitMeasurement.ts index 966b545..344abe0 100644 --- a/src/models/UnitMeasurement.ts +++ b/src/models/UnitMeasurement.ts @@ -256,5 +256,15 @@ function unitConversion( }); } } + if (type === quack.MeasurementType.MEASUREMENT_TYPE_SPEED) { + if (user.settings.distanceUnit === pond.DistanceUnit.DISTANCE_UNIT_FEET) { + newVals.forEach((val, i) => { + val.values.forEach((v, j) => { + //convert m/s to ft/m by multiplying by 196.9 + newVals[i].values[j] = v * 196.9 + }); + }); + } + } return newVals; } diff --git a/src/pbHelpers/ComponentType.tsx b/src/pbHelpers/ComponentType.tsx index 2d66c9d..e03a1ce 100644 --- a/src/pbHelpers/ComponentType.tsx +++ b/src/pbHelpers/ComponentType.tsx @@ -146,7 +146,7 @@ export interface ComponentTypeExtension { interactionResultTypes: Array; states: Array; measurements: Array; - measurementSummary: Function; //Deprecated: this summary used the old measurement structure + measurementSummary?: Function; //Deprecated: this summary used the old measurement structure unitMeasurementSummary: ( measurements: convertedUnitMeasurement, excludedNodes?: number[] @@ -382,7 +382,8 @@ export async function getMeasurementSummary( measurement: quack.IMeasurement, filters: GraphFilters ): Promise> { - return extension(type, subtype).measurementSummary(measurement, filters); + let sumFunc = extension(type, subtype).measurementSummary + return sumFunc ? sumFunc(measurement, filters) : []; } const validNodes = (nodeVals: number[], filters?: GraphFilters) => { diff --git a/src/pbHelpers/ComponentTypes/Airflow.ts b/src/pbHelpers/ComponentTypes/Airflow.ts index 2e46725..acc52fe 100644 --- a/src/pbHelpers/ComponentTypes/Airflow.ts +++ b/src/pbHelpers/ComponentTypes/Airflow.ts @@ -1,14 +1,15 @@ import { ComponentTypeExtension, Summary, - simpleMeasurements, - simpleSummaries, + // simpleMeasurements, + // simpleSummaries, unitMeasurementSummaries, AreaChartData, GraphFilters, simpleAreaChartData, LineChartData, - simpleLineChartData + simpleLineChartData, + ComponentMeasurement } from "pbHelpers/ComponentType"; import PressureDarkIcon from "assets/components/pressureDark.png"; import PressureLightIcon from "assets/components/pressureLight.png"; @@ -18,11 +19,32 @@ import { convertedUnitMeasurement } from "models/UnitMeasurement"; import { pond } from "protobuf-ts/pond"; export function Airflow(subtype: number = 0): ComponentTypeExtension { - let airflow = describeMeasurement( + let cfm = describeMeasurement( quack.MeasurementType.MEASUREMENT_TYPE_CFM, quack.ComponentType.COMPONENT_TYPE_AIRFLOW, subtype ); + + let velocity = describeMeasurement( + quack.MeasurementType.MEASUREMENT_TYPE_CFM, + quack.ComponentType.COMPONENT_TYPE_AIRFLOW, + subtype + ); + + let measurementTypes = [ + { + measurementType: quack.MeasurementType.MEASUREMENT_TYPE_PPM, + label: cfm.label(), + colour: cfm.colour(), + graphType: cfm.graph() + } as ComponentMeasurement, + { + measurementType: quack.MeasurementType.MEASUREMENT_TYPE_VOLTAGE, + label: velocity.label(), + colour: velocity.colour(), + graphType: velocity.graph() + } as ComponentMeasurement + ]; return { type: quack.ComponentType.COMPONENT_TYPE_AIRFLOW, subtypes: [ @@ -47,10 +69,10 @@ export function Airflow(subtype: number = 0): ComponentTypeExtension { addressTypes: [quack.AddressType.ADDRESS_TYPE_I2C], interactionResultTypes: [], states: [], - measurements: simpleMeasurements(airflow), - measurementSummary: async function(measurement: quack.Measurement): Promise> { - return simpleSummaries(measurement, airflow); - }, + measurements: measurementTypes, + // measurementSummary: async function(measurement: quack.Measurement): Promise> { + // return simpleSummaries(measurement, airflow); + // }, unitMeasurementSummary: ( measurements: convertedUnitMeasurement, excludedNodes?: number[] diff --git a/src/pbHelpers/MeasurementDescriber.ts b/src/pbHelpers/MeasurementDescriber.ts index a364b77..1fc2751 100644 --- a/src/pbHelpers/MeasurementDescriber.ts +++ b/src/pbHelpers/MeasurementDescriber.ts @@ -450,8 +450,9 @@ export class MeasurementDescriber { this.details.max = 100000; break; case quack.MeasurementType.MEASUREMENT_TYPE_SPEED: + let speedUnit = getDistanceUnit() this.details.label = "Speed"; - this.details.unit = "km/h"; + this.details.unit = speedUnit === pond.DistanceUnit.DISTANCE_UNIT_METERS ? "m/s" : "ft/m"; this.details.colour = green["500"]; this.details.path = "edgeTriggered.rises"; this.details.max = 500; From c5091578d631be075ea2c10bb8635fae7e299ce9 Mon Sep 17 00:00:00 2001 From: csawatzky Date: Fri, 25 Jul 2025 16:19:29 -0600 Subject: [PATCH 08/16] adding versioning for detect i2c on v2 devices --- src/models/Device.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/models/Device.ts b/src/models/Device.ts index e45f7aa..31fb95f 100644 --- a/src/models/Device.ts +++ b/src/models/Device.ts @@ -38,15 +38,15 @@ const featureVersions: Map = new Map([ { photon: "N/A", electron: "N/A", - v2Wifi: "N/A", - v2Cell: "N/A", - v2WifiS3: "N/A", - v2CellS3: "N/A", - v2CellBlack: "N/A", - v2CellGreen: "N/A", - v2WifiBlue: "N/A", - v2CellBlue: "N/A", - v2EthBlue: "N/A" + v2Wifi: "2.1.6", + v2Cell: "2.1.6", + v2WifiS3: "2.1.6", + v2CellS3: "2.1.6", + v2CellBlack: "2.1.6", + v2CellGreen: "2.1.6", + v2WifiBlue: "2.1.6", + v2CellBlue: "2.1.6", + v2EthBlue: "2.1.6" } ] ]); From 131c4ebb891f505b99039ae24bbb7188baeefc3c Mon Sep 17 00:00:00 2001 From: csawatzky Date: Fri, 25 Jul 2025 16:33:43 -0600 Subject: [PATCH 09/16] setting the deprecated boards according to Ashton that wont reach the version for the detectI2C feature to have it as N/A --- src/models/Device.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/models/Device.ts b/src/models/Device.ts index 31fb95f..46ce943 100644 --- a/src/models/Device.ts +++ b/src/models/Device.ts @@ -38,12 +38,12 @@ const featureVersions: Map = new Map([ { photon: "N/A", electron: "N/A", - v2Wifi: "2.1.6", - v2Cell: "2.1.6", - v2WifiS3: "2.1.6", - v2CellS3: "2.1.6", + v2Wifi: "N/A", + v2Cell: "N/A", + v2WifiS3: "N/A", + v2CellS3: "N/A", v2CellBlack: "2.1.6", - v2CellGreen: "2.1.6", + v2CellGreen: "N/A", v2WifiBlue: "2.1.6", v2CellBlue: "2.1.6", v2EthBlue: "2.1.6" From 7d24cb7df41dc2f2afc28d54105496ce4f3b832b Mon Sep 17 00:00:00 2001 From: csawatzky Date: Mon, 28 Jul 2025 12:04:20 -0600 Subject: [PATCH 10/16] updating the address for airflow --- src/pbHelpers/AddressTypes/I2C.ts | 2 +- src/pbHelpers/DeviceAvailability.ts | 2 +- src/products/MiVent/MiVentAvailability.ts | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pbHelpers/AddressTypes/I2C.ts b/src/pbHelpers/AddressTypes/I2C.ts index c17c743..3c15ced 100644 --- a/src/pbHelpers/AddressTypes/I2C.ts +++ b/src/pbHelpers/AddressTypes/I2C.ts @@ -16,7 +16,7 @@ export const I2C: AddressTypeExtension = { [quack.ComponentType.COMPONENT_TYPE_CAPACITANCE, 0x4f], [quack.ComponentType.COMPONENT_TYPE_CAPACITOR_CABLE, 0x4f], [quack.ComponentType.COMPONENT_TYPE_SEN5X, 0x68], - [quack.ComponentType.COMPONENT_TYPE_AIRFLOW, 0x29] + [quack.ComponentType.COMPONENT_TYPE_AIRFLOW, 0x6b] ]); const offset = offsets.get(componentType); diff --git a/src/pbHelpers/DeviceAvailability.ts b/src/pbHelpers/DeviceAvailability.ts index c50a2a4..3d09a7f 100644 --- a/src/pbHelpers/DeviceAvailability.ts +++ b/src/pbHelpers/DeviceAvailability.ts @@ -60,7 +60,7 @@ const DefaultAvailability: DeviceAvailabilityMap = new Map Date: Mon, 28 Jul 2025 14:40:28 -0600 Subject: [PATCH 11/16] fixed isse with calibration no longer being defined in the pond proto --- src/component/ComponentForm.tsx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/component/ComponentForm.tsx b/src/component/ComponentForm.tsx index ef61681..08d6117 100644 --- a/src/component/ComponentForm.tsx +++ b/src/component/ComponentForm.tsx @@ -482,7 +482,7 @@ export default function ComponentForm(props: Props) { const updateCalibrationTypes = (event: any, index: number) => { let f = cloneDeep(form); - f.component.settings.calibrations[index].type = event.target.value as quack.MeasurementType; + f.component.settings.calibrations[index].measurementType = event.target.value as quack.MeasurementType; setForm(f); }; @@ -508,7 +508,7 @@ export default function ComponentForm(props: Props) { if (dimensions !== undefined && dimensions !== null) { dimensions.lengthCm = value; } else { - dimensions = pond.Dimensions.create({ + dimensions = quack.Dimensions.create({ heightCm: 0, lengthCm: value, widthCm: 0 @@ -537,7 +537,7 @@ export default function ComponentForm(props: Props) { if (dimensions !== undefined && dimensions !== null) { dimensions.heightCm = value; } else { - dimensions = pond.Dimensions.create({ + dimensions = quack.Dimensions.create({ heightCm: value, lengthCm: 0, widthCm: 0 @@ -566,7 +566,7 @@ export default function ComponentForm(props: Props) { if (dimensions !== undefined && dimensions !== null) { dimensions.widthCm = value; } else { - dimensions = pond.Dimensions.create({ + dimensions = quack.Dimensions.create({ heightCm: 0, lengthCm: 0, widthCm: value @@ -788,7 +788,7 @@ export default function ComponentForm(props: Props) { // !isMeasurementTypeValid(interaction.settings.conditions[index].measurementType) // } disabled={!component.settings.calibrate} - value={calibration.type ?? quack.MeasurementType.MEASUREMENT_TYPE_INVALID} + value={calibration.measurementType ?? quack.MeasurementType.MEASUREMENT_TYPE_INVALID} onChange={event => updateCalibrationTypes(event, i)} autoFocus={false} margin="normal" @@ -814,8 +814,8 @@ export default function ComponentForm(props: Props) { f.coefficients.push("0"); f.offsets.push("0"); f.component.settings.calibrations.push( - pond.Calibration.create({ - type: quack.MeasurementType.MEASUREMENT_TYPE_INVALID, + quack.Calibration.create({ + measurementType: quack.MeasurementType.MEASUREMENT_TYPE_INVALID, calibrationOffset: 0, calibrationCoefficient: 0 }) From 4ab5b4aedd607997a95079a45e0f0ef8e8d90e4b Mon Sep 17 00:00:00 2001 From: csawatzky Date: Mon, 28 Jul 2025 14:45:06 -0600 Subject: [PATCH 12/16] added mux address as a blacklisted address so it doesn't appear on the card, and changed the i2c address for airflow --- .../autoDetect/DeviceScannedComponents.tsx | 21 ++++++++++++++++--- src/pbHelpers/AddressTypes/I2C.ts | 2 +- src/pbHelpers/DeviceAvailability.ts | 2 +- src/products/MiVent/MiVentAvailability.ts | 2 +- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/device/autoDetect/DeviceScannedComponents.tsx b/src/device/autoDetect/DeviceScannedComponents.tsx index 03a847e..6899959 100644 --- a/src/device/autoDetect/DeviceScannedComponents.tsx +++ b/src/device/autoDetect/DeviceScannedComponents.tsx @@ -18,17 +18,20 @@ interface Props { availableOffsets: OffsetAvailabilityMap refreshCallback: () => void } - + interface CompStep { label: string; completed?: boolean; } +let i2cBlacklistAddresses: number[] = [0x70] + export default function DeviceScannedComponents(props: Props){ const {scannedComponents, device, availablePositions, availableOffsets, refreshCallback} = props const compAPI = useComponentAPI(); const deviceAPI = useDeviceAPI() - const [scannedI2C, setScannedI2C] = useState() + const [scannedI2C, setScannedI2C] = useState() //the unmodified scan of addresses + const [validCompAddresses, setValidComponentAddresses] = useState([]) //the filtered array of address data const [components, setComponents] = useState([]) const [steps, setSteps] = useState([]); const { error, success } = useSnackbar(); @@ -59,6 +62,18 @@ export default function DeviceScannedComponents(props: Props){ setSteps(steps) },[components]) + useEffect(()=>{ + let valid: quack.AddressData[] = [] + //filter the address data + scannedI2C?.settings?.foundAddresses.forEach(addrData => { + if(!i2cBlacklistAddresses.includes(addrData.address)){ + valid.push(addrData) + } + }) + console.log(valid) + setValidComponentAddresses(valid) + },[scannedI2C]) + const stepper = () => { return ( @@ -205,7 +220,7 @@ export default function DeviceScannedComponents(props: Props){ - {scannedI2C.settings?.foundAddresses && scannedI2C.settings.foundAddresses.length > 0 ? scannedI2C?.settings?.foundAddresses.map((addr, index) => { + {validCompAddresses.length > 0 ? validCompAddresses.map((addr, index) => { return ( ) diff --git a/src/pbHelpers/AddressTypes/I2C.ts b/src/pbHelpers/AddressTypes/I2C.ts index 339ce70..2410950 100644 --- a/src/pbHelpers/AddressTypes/I2C.ts +++ b/src/pbHelpers/AddressTypes/I2C.ts @@ -16,7 +16,7 @@ export const I2C: AddressTypeExtension = { [quack.ComponentType.COMPONENT_TYPE_CAPACITANCE, 0x4f], [quack.ComponentType.COMPONENT_TYPE_CAPACITOR_CABLE, 0x4f], [quack.ComponentType.COMPONENT_TYPE_SEN5X, 0x68], - [quack.ComponentType.COMPONENT_TYPE_AIRFLOW, 0x29], + [quack.ComponentType.COMPONENT_TYPE_AIRFLOW, 0x6b], [quack.ComponentType.COMPONENT_TYPE_GRAIN_CABLE, 0x70] ]); diff --git a/src/pbHelpers/DeviceAvailability.ts b/src/pbHelpers/DeviceAvailability.ts index 72bbbdc..5e8807f 100644 --- a/src/pbHelpers/DeviceAvailability.ts +++ b/src/pbHelpers/DeviceAvailability.ts @@ -60,7 +60,7 @@ const DefaultAvailability: DeviceAvailabilityMap = new Map Date: Mon, 28 Jul 2025 15:12:45 -0600 Subject: [PATCH 13/16] fixed errors from moving the calibration definition to the quack --- package-lock.json | 4 ++-- package.json | 2 +- src/component/ComponentForm.tsx | 14 +++++++------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index 222fcf3..2c64e83 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#beans", + "protobuf-ts": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#component_quack", "query-string": "^9.2.1", "react": "^18.3.1", "react-beautiful-dnd": "^13.1.1", @@ -10911,7 +10911,7 @@ }, "node_modules/protobuf-ts": { "version": "1.0.0", - "resolved": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#f09196cbc38911bab69fb35c16b1c8f691a4413f", + "resolved": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#4e16c7a754503111aad27eeaef98069f95451e59", "dependencies": { "protobufjs": "^6.8.8" } diff --git a/package.json b/package.json index 5a27ce1..1a32f62 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#beans", + "protobuf-ts": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#component_quack", "query-string": "^9.2.1", "react": "^18.3.1", "react-beautiful-dnd": "^13.1.1", diff --git a/src/component/ComponentForm.tsx b/src/component/ComponentForm.tsx index ef61681..08d6117 100644 --- a/src/component/ComponentForm.tsx +++ b/src/component/ComponentForm.tsx @@ -482,7 +482,7 @@ export default function ComponentForm(props: Props) { const updateCalibrationTypes = (event: any, index: number) => { let f = cloneDeep(form); - f.component.settings.calibrations[index].type = event.target.value as quack.MeasurementType; + f.component.settings.calibrations[index].measurementType = event.target.value as quack.MeasurementType; setForm(f); }; @@ -508,7 +508,7 @@ export default function ComponentForm(props: Props) { if (dimensions !== undefined && dimensions !== null) { dimensions.lengthCm = value; } else { - dimensions = pond.Dimensions.create({ + dimensions = quack.Dimensions.create({ heightCm: 0, lengthCm: value, widthCm: 0 @@ -537,7 +537,7 @@ export default function ComponentForm(props: Props) { if (dimensions !== undefined && dimensions !== null) { dimensions.heightCm = value; } else { - dimensions = pond.Dimensions.create({ + dimensions = quack.Dimensions.create({ heightCm: value, lengthCm: 0, widthCm: 0 @@ -566,7 +566,7 @@ export default function ComponentForm(props: Props) { if (dimensions !== undefined && dimensions !== null) { dimensions.widthCm = value; } else { - dimensions = pond.Dimensions.create({ + dimensions = quack.Dimensions.create({ heightCm: 0, lengthCm: 0, widthCm: value @@ -788,7 +788,7 @@ export default function ComponentForm(props: Props) { // !isMeasurementTypeValid(interaction.settings.conditions[index].measurementType) // } disabled={!component.settings.calibrate} - value={calibration.type ?? quack.MeasurementType.MEASUREMENT_TYPE_INVALID} + value={calibration.measurementType ?? quack.MeasurementType.MEASUREMENT_TYPE_INVALID} onChange={event => updateCalibrationTypes(event, i)} autoFocus={false} margin="normal" @@ -814,8 +814,8 @@ export default function ComponentForm(props: Props) { f.coefficients.push("0"); f.offsets.push("0"); f.component.settings.calibrations.push( - pond.Calibration.create({ - type: quack.MeasurementType.MEASUREMENT_TYPE_INVALID, + quack.Calibration.create({ + measurementType: quack.MeasurementType.MEASUREMENT_TYPE_INVALID, calibrationOffset: 0, calibrationCoefficient: 0 }) From e662645fa2eca72cf193f96067305d38d961819c Mon Sep 17 00:00:00 2001 From: csawatzky Date: Mon, 28 Jul 2025 15:23:49 -0600 Subject: [PATCH 14/16] rounding the ft/m conversion --- src/models/UnitMeasurement.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/models/UnitMeasurement.ts b/src/models/UnitMeasurement.ts index 344abe0..46e67ef 100644 --- a/src/models/UnitMeasurement.ts +++ b/src/models/UnitMeasurement.ts @@ -261,7 +261,7 @@ function unitConversion( newVals.forEach((val, i) => { val.values.forEach((v, j) => { //convert m/s to ft/m by multiplying by 196.9 - newVals[i].values[j] = v * 196.9 + newVals[i].values[j] = Math.round(v * 196.9) }); }); } From b6df61625d93f787cd1169b6b1a9d0879e8fd5d2 Mon Sep 17 00:00:00 2001 From: csawatzky Date: Mon, 28 Jul 2025 15:37:22 -0600 Subject: [PATCH 15/16] rounding to 2 decimals --- src/models/UnitMeasurement.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/models/UnitMeasurement.ts b/src/models/UnitMeasurement.ts index 46e67ef..d33c17d 100644 --- a/src/models/UnitMeasurement.ts +++ b/src/models/UnitMeasurement.ts @@ -261,7 +261,7 @@ function unitConversion( newVals.forEach((val, i) => { val.values.forEach((v, j) => { //convert m/s to ft/m by multiplying by 196.9 - newVals[i].values[j] = Math.round(v * 196.9) + newVals[i].values[j] = Math.round((v * 196.9)*100) /100 }); }); } From a3a8b9527759a7e9458b4b4afb3d3e47cd360814 Mon Sep 17 00:00:00 2001 From: csawatzky Date: Mon, 28 Jul 2025 16:37:11 -0600 Subject: [PATCH 16/16] added to the filter to remove any expander entries when there is no expander line --- src/device/autoDetect/DeviceScannedComponents.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/device/autoDetect/DeviceScannedComponents.tsx b/src/device/autoDetect/DeviceScannedComponents.tsx index 6899959..5e91dd0 100644 --- a/src/device/autoDetect/DeviceScannedComponents.tsx +++ b/src/device/autoDetect/DeviceScannedComponents.tsx @@ -67,10 +67,11 @@ export default function DeviceScannedComponents(props: Props){ //filter the address data scannedI2C?.settings?.foundAddresses.forEach(addrData => { if(!i2cBlacklistAddresses.includes(addrData.address)){ - valid.push(addrData) + if(!(addrData.address === 0x71 && addrData.expansionLine === undefined)){ + valid.push(addrData) + } } }) - console.log(valid) setValidComponentAddresses(valid) },[scannedI2C])