From bbd49be89bd3494cd5eb07d492d654f33b1f129c Mon Sep 17 00:00:00 2001 From: Martin Man Date: Fri, 4 Oct 2024 11:50:06 +0200 Subject: [PATCH] fix: do not display duplicate generator devices - 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. --- .../boxes/DevicesOverview/DevicesOverview.tsx | 35 +++++++++++-------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/src/app/Marine2/components/boxes/DevicesOverview/DevicesOverview.tsx b/src/app/Marine2/components/boxes/DevicesOverview/DevicesOverview.tsx index 26f7741a..25bfcfe0 100644 --- a/src/app/Marine2/components/boxes/DevicesOverview/DevicesOverview.tsx +++ b/src/app/Marine2/components/boxes/DevicesOverview/DevicesOverview.tsx @@ -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( - - ) - }) - } else if ( + // we have relay controlled generator present, show it + if ( generatorRelay.relayFunction === RELAY_FUNCTION.GENERATOR_START_STOP && generatorRelay.statusCode !== undefined ) { @@ -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( + + ) + }) + } } }