implemented a way of filtering positions using the subtype
The lidar uses a different I2C address for each of the subtypes so this allows us to be able to control the options for a user for each of the subtypes so that one lidars address cant be used for another
This commit is contained in:
parent
ceaff4da9e
commit
50b33e587d
5 changed files with 54 additions and 11 deletions
|
|
@ -36,6 +36,7 @@ import {
|
|||
} from "pbHelpers/AddressType";
|
||||
import {
|
||||
extension,
|
||||
FilterSubtypeI2C,
|
||||
getAddressTypes,
|
||||
GetComponentTypeOptions,
|
||||
getFriendlyName,
|
||||
|
|
@ -240,7 +241,8 @@ export default function ComponentSettings(props: Props) {
|
|||
|
||||
const getAvailablePositions = (
|
||||
addressType: quack.AddressType,
|
||||
componentType: quack.ComponentType
|
||||
componentType: quack.ComponentType,
|
||||
subtype: number
|
||||
): number[] => {
|
||||
let positions = availablePositions.get(addressType);
|
||||
if (!positions) return [];
|
||||
|
|
@ -249,7 +251,8 @@ export default function ComponentSettings(props: Props) {
|
|||
case quack.AddressType.ADDRESS_TYPE_SPI:
|
||||
let componentPositions;
|
||||
if (positions) {
|
||||
componentPositions = (positions as ComponentAvailabilityMap).get(componentType);
|
||||
componentPositions = (positions as ComponentAvailabilityMap).get(componentType); //gets the addresses that are not claimed yet
|
||||
componentPositions = FilterSubtypeI2C(componentType, subtype, componentPositions as number[]) //filters the I2C addresses for valid ones for the subtype
|
||||
}
|
||||
return componentPositions ? (componentPositions as number[]) : [];
|
||||
case quack.AddressType.ADDRESS_TYPE_CONFIGURABLE_PIN_ARRAY:
|
||||
|
|
@ -264,7 +267,8 @@ export default function ComponentSettings(props: Props) {
|
|||
if (mode === "add") {
|
||||
let positions = getAvailablePositions(
|
||||
component.settings.addressType,
|
||||
component.settings.type
|
||||
component.settings.type,
|
||||
component.settings.subtype
|
||||
);
|
||||
availablePosition = positions ? positions.length > 0 : false;
|
||||
}
|
||||
|
|
@ -285,7 +289,7 @@ export default function ComponentSettings(props: Props) {
|
|||
component.settings.subtype
|
||||
);
|
||||
for (let i = 0; i < addressTypes.length; i++) {
|
||||
if (getAvailablePositions(addressTypes[i], component.settings.type).length > 0) {
|
||||
if (getAvailablePositions(addressTypes[i], component.settings.type, component.settings.subtype).length > 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -383,7 +387,7 @@ export default function ComponentSettings(props: Props) {
|
|||
formComponent.settings.subtype
|
||||
)[0]);
|
||||
formComponent.settings.address = or(
|
||||
getAvailablePositions(formComponent.settings.addressType, formComponent.settings.type)[0],
|
||||
getAvailablePositions(formComponent.settings.addressType, formComponent.settings.type, formComponent.settings.subtype)[0],
|
||||
Component.create().settings.address
|
||||
);
|
||||
formComponent.settings.name = option.label;
|
||||
|
|
@ -426,7 +430,7 @@ export default function ComponentSettings(props: Props) {
|
|||
let availableMenuItemPositions = [];
|
||||
for (let i = 0; i < addressTypes.length; i++) {
|
||||
let addressType = addressTypes[i];
|
||||
let availablePositions = getAvailablePositions(addressType, type);
|
||||
let availablePositions = getAvailablePositions(addressType, type, subtype);
|
||||
|
||||
availableMenuItemPositions.push(
|
||||
<MenuItem key={addressType} divider disabled>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue