Skip to content

Commit

Permalink
fix: do not display duplicate generator devices
Browse files Browse the repository at this point in the history
- When connected AC genset is present at /generator/1, we display its controls.
- When relay connected genset is present at /generator/0, we display it.
- When neither relay/genset control service is present, but some AC inputs
  are configured to be GENERATOR, we display them.
  • Loading branch information
mman committed Oct 4, 2024
1 parent 5b9d2cd commit bbd49be
Showing 1 changed file with 21 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,20 +176,8 @@ const getAvailableDeviceBoxes = function (
}

if (!!generatorRelay.settings) {
if (generatorRelay.settings.includes(AC_SOURCE.GENERATOR)) {
generatorRelay.settings.forEach((source: number, i: number) => {
if (source === AC_SOURCE.GENERATOR)
devices.push(
<GeneratorRelay
key={"generator_relay" + i}
{...generatorRelay}
active={generatorRelay.activeInput === i}
componentMode={componentMode}
compactBoxSize={compactBoxSize}
/>
)
})
} else if (
// we have relay controlled generator present, show it
if (
generatorRelay.relayFunction === RELAY_FUNCTION.GENERATOR_START_STOP &&
generatorRelay.statusCode !== undefined
) {
Expand All @@ -201,6 +189,25 @@ const getAvailableDeviceBoxes = function (
compactBoxSize={compactBoxSize}
/>
)
} else if (generatorRelay.settings.includes(AC_SOURCE.GENERATOR)) {
// we do not have relay controlled generator configured,
// but one or more of the AC inputs is set to GENERATOR
if (generatorConnectedGenset.gensetState.gensetType !== ConnectedGensetType.ACGENSET) {
// display generator controls for each GENERATOR AC input
// unless there is a connected genset
generatorRelay.settings.forEach((source: number, i: number) => {
if (source === AC_SOURCE.GENERATOR)
devices.push(
<GeneratorRelay
key={"generator_relay" + i}
{...generatorRelay}
active={generatorRelay.activeInput === i}
componentMode={componentMode}
compactBoxSize={compactBoxSize}
/>
)
})
}
}
}

Expand Down

0 comments on commit bbd49be

Please sign in to comment.