From a4b6179b2628b56ee952cbfa8d1bfbb66d14f4aa Mon Sep 17 00:00:00 2001 From: csawatzky Date: Thu, 26 Jun 2025 13:22:29 -0600 Subject: [PATCH] added function so the component can display its port and cable id --- src/models/Component.ts | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/models/Component.ts b/src/models/Component.ts index c9bbc2c..97b54ba 100644 --- a/src/models/Component.ts +++ b/src/models/Component.ts @@ -3,6 +3,7 @@ import { quack } from "protobuf-ts/pond"; import { or } from "utils/types"; import { cloneDeep } from "lodash"; import { getSubtypes } from "pbHelpers/ComponentType"; +import { getFriendlyAddressTypeName, getHumanReadableAddress } from "pbHelpers/AddressType"; // import { getSubtypes } from "pbHelpers/ComponentType"; export class Component { @@ -105,4 +106,33 @@ export class Component { } return 0; } + + public addressDescription = (deviceProduct?: pond.DeviceProduct) => { + if ( + this.settings.addressType === quack.AddressType.ADDRESS_TYPE_CONFIGURABLE_PIN_ARRAY || + (this.settings.addressType >= quack.AddressType.ADDRESS_TYPE_PIN_OFFSET1 && + this.settings.addressType <= quack.AddressType.ADDRESS_TYPE_PIN_OFFSET100) + ) { + let addressDescription = getHumanReadableAddress( + this.settings.addressType, + this.settings.type, + this.settings.address, + deviceProduct + ); + if (addressDescription === "") { + addressDescription = "Internal"; + } + let port = "Port: " + addressDescription; + let cableID = ""; + if ( + this.settings.addressType >= quack.AddressType.ADDRESS_TYPE_PIN_OFFSET1 && + this.settings.addressType <= quack.AddressType.ADDRESS_TYPE_PIN_OFFSET100 + ) { + cableID = "Cable: " + (this.settings.addressType - 8); + } + return port + " " + cableID; + } else { + return getFriendlyAddressTypeName(this.settings.addressType); + } + }; }