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
This commit is contained in:
parent
54a826bc2d
commit
3325c9d75b
11 changed files with 113 additions and 36 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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 => {
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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: [
|
||||
|
|
|
|||
|
|
@ -11,6 +11,11 @@ export type DevicePositions = number[] | ComponentAvailabilityMap | Configurable
|
|||
export type DeviceAvailabilityMap = Map<quack.AddressType, DevicePositions>;
|
||||
export type OffsetAvailabilityMap = Map<quack.AddressType, number[][]>;
|
||||
|
||||
//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<quack.AddressType, De
|
|||
[quack.ComponentType.COMPONENT_TYPE_CAPACITANCE, [0x50]],
|
||||
[quack.ComponentType.COMPONENT_TYPE_CAPACITOR_CABLE, [0x50]],
|
||||
[quack.ComponentType.COMPONENT_TYPE_SEN5X, [0x69]],
|
||||
[quack.ComponentType.COMPONENT_TYPE_AIRFLOW, [0x2a]]
|
||||
[quack.ComponentType.COMPONENT_TYPE_AIRFLOW, [0x2a]],
|
||||
[quack.ComponentType.COMPONENT_TYPE_GRAIN_CABLE, [0x71]] // the address cables will use when they are plugged into the expander with V2 device only
|
||||
])
|
||||
],
|
||||
[quack.AddressType.ADDRESS_TYPE_DAC, [0, 1]],
|
||||
|
|
@ -103,7 +109,8 @@ export class DeviceAvailability {
|
|||
ClaimAddress(
|
||||
addressType: quack.AddressType,
|
||||
componentType: quack.ComponentType,
|
||||
address: number
|
||||
address: number,
|
||||
expansionLine?: number
|
||||
) {
|
||||
let offset = addressType - 8;
|
||||
if (offset > 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
|
||||
);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue