From: Jérôme Benoit Date: Sat, 22 Apr 2023 21:11:43 +0000 (+0200) Subject: refactor(simulator): consolidate connector status transition X-Git-Tag: v1.2.11~8 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=0a376442c47f8e1c89cff78e822a936f3d4c783a;p=e-mobility-charging-stations-simulator.git refactor(simulator): consolidate connector status transition Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/ocpp/1.6/OCPP16Constants.ts b/src/charging-station/ocpp/1.6/OCPP16Constants.ts index 5f695881..15ea099b 100644 --- a/src/charging-station/ocpp/1.6/OCPP16Constants.ts +++ b/src/charging-station/ocpp/1.6/OCPP16Constants.ts @@ -1,118 +1,115 @@ -import { OCPP16ChargePointStatus } from '../../../types'; +import { ConnectorStatusTransition, OCPP16ChargePointStatus } from '../../../types'; import { OCPPConstants } from '../internal'; -type Transition = Readonly<{ - from?: OCPP16ChargePointStatus; - to: OCPP16ChargePointStatus; -}>; - export class OCPP16Constants extends OCPPConstants { - static readonly ChargePointStatusChargingStationTransitions: Readonly = + static readonly ChargePointStatusChargingStationTransitions: Readonly< + ConnectorStatusTransition[] + > = Object.freeze([ + { to: OCPP16ChargePointStatus.Available }, + // { from: OCPP16ChargePointStatus.Available, to: OCPP16ChargePointStatus.Available }, + { from: OCPP16ChargePointStatus.Available, to: OCPP16ChargePointStatus.Unavailable }, + { from: OCPP16ChargePointStatus.Available, to: OCPP16ChargePointStatus.Faulted }, + { to: OCPP16ChargePointStatus.Unavailable }, + { from: OCPP16ChargePointStatus.Unavailable, to: OCPP16ChargePointStatus.Available }, + // { from: OCPP16ChargePointStatus.Unavailable, to: OCPP16ChargePointStatus.Unavailable }, + { from: OCPP16ChargePointStatus.Unavailable, to: OCPP16ChargePointStatus.Faulted }, + { to: OCPP16ChargePointStatus.Faulted }, + { from: OCPP16ChargePointStatus.Faulted, to: OCPP16ChargePointStatus.Available }, + { from: OCPP16ChargePointStatus.Faulted, to: OCPP16ChargePointStatus.Unavailable }, + // { from: OCPP16ChargePointStatus.Faulted, to: OCPP16ChargePointStatus.Faulted }, + ]); + + static readonly ChargePointStatusConnectorTransitions: Readonly = Object.freeze([ { to: OCPP16ChargePointStatus.Available }, // { from: OCPP16ChargePointStatus.Available, to: OCPP16ChargePointStatus.Available }, + { from: OCPP16ChargePointStatus.Available, to: OCPP16ChargePointStatus.Preparing }, + { from: OCPP16ChargePointStatus.Available, to: OCPP16ChargePointStatus.Charging }, + { from: OCPP16ChargePointStatus.Available, to: OCPP16ChargePointStatus.SuspendedEV }, + { from: OCPP16ChargePointStatus.Available, to: OCPP16ChargePointStatus.SuspendedEVSE }, + // { from: OCPP16ChargePointStatus.Available, to: OCPP16ChargePointStatus.Finishing }, + { from: OCPP16ChargePointStatus.Available, to: OCPP16ChargePointStatus.Reserved }, { from: OCPP16ChargePointStatus.Available, to: OCPP16ChargePointStatus.Unavailable }, { from: OCPP16ChargePointStatus.Available, to: OCPP16ChargePointStatus.Faulted }, + // { to: OCPP16ChargePointStatus.Preparing }, + { from: OCPP16ChargePointStatus.Preparing, to: OCPP16ChargePointStatus.Available }, + // { from: OCPP16ChargePointStatus.Preparing, to: OCPP16ChargePointStatus.Preparing }, + { from: OCPP16ChargePointStatus.Preparing, to: OCPP16ChargePointStatus.Charging }, + { from: OCPP16ChargePointStatus.Preparing, to: OCPP16ChargePointStatus.SuspendedEV }, + { from: OCPP16ChargePointStatus.Preparing, to: OCPP16ChargePointStatus.SuspendedEVSE }, + { from: OCPP16ChargePointStatus.Preparing, to: OCPP16ChargePointStatus.Finishing }, + // { from: OCPP16ChargePointStatus.Preparing, to: OCPP16ChargePointStatus.Reserved }, + // { from: OCPP16ChargePointStatus.Preparing, to: OCPP16ChargePointStatus.Unavailable }, + { from: OCPP16ChargePointStatus.Preparing, to: OCPP16ChargePointStatus.Faulted }, + // { to: OCPP16ChargePointStatus.Charging }, + { from: OCPP16ChargePointStatus.Charging, to: OCPP16ChargePointStatus.Available }, + // { from: OCPP16ChargePointStatus.Charging, to: OCPP16ChargePointStatus.Preparing }, + // { from: OCPP16ChargePointStatus.Charging, to: OCPP16ChargePointStatus.Charging }, + { from: OCPP16ChargePointStatus.Charging, to: OCPP16ChargePointStatus.SuspendedEV }, + { from: OCPP16ChargePointStatus.Charging, to: OCPP16ChargePointStatus.SuspendedEVSE }, + { from: OCPP16ChargePointStatus.Charging, to: OCPP16ChargePointStatus.Finishing }, + // { from: OCPP16ChargePointStatus.Charging, to: OCPP16ChargePointStatus.Reserved }, + { from: OCPP16ChargePointStatus.Charging, to: OCPP16ChargePointStatus.Unavailable }, + { from: OCPP16ChargePointStatus.Charging, to: OCPP16ChargePointStatus.Faulted }, + // { to: OCPP16ChargePointStatus.SuspendedEV }, + { from: OCPP16ChargePointStatus.SuspendedEV, to: OCPP16ChargePointStatus.Available }, + // { from: OCPP16ChargePointStatus.SuspendedEV, to: OCPP16ChargePointStatus.Preparing }, + { from: OCPP16ChargePointStatus.SuspendedEV, to: OCPP16ChargePointStatus.Charging }, + // { from: OCPP16ChargePointStatus.SuspendedEV, OCPP16ChargePointStatus.SuspendedEV }, + { from: OCPP16ChargePointStatus.SuspendedEV, to: OCPP16ChargePointStatus.SuspendedEVSE }, + { from: OCPP16ChargePointStatus.SuspendedEV, to: OCPP16ChargePointStatus.Finishing }, + // { from: OCPP16ChargePointStatus.SuspendedEV, to: OCPP16ChargePointStatus.Reserved }, + { from: OCPP16ChargePointStatus.SuspendedEV, to: OCPP16ChargePointStatus.Unavailable }, + { from: OCPP16ChargePointStatus.SuspendedEV, to: OCPP16ChargePointStatus.Faulted }, + // { to: OCPP16ChargePointStatus.SuspendedEVSE }, + { from: OCPP16ChargePointStatus.SuspendedEVSE, to: OCPP16ChargePointStatus.Available }, + // { from: OCPP16ChargePointStatus.SuspendedEVSE, to: OCPP16ChargePointStatus.Preparing }, + { from: OCPP16ChargePointStatus.SuspendedEVSE, to: OCPP16ChargePointStatus.Charging }, + { from: OCPP16ChargePointStatus.SuspendedEVSE, to: OCPP16ChargePointStatus.SuspendedEV }, + // { from: OCPP16ChargePointStatus.SuspendedEVSE, to: OCPP16ChargePointStatus.SuspendedEVSE }, + { from: OCPP16ChargePointStatus.SuspendedEVSE, to: OCPP16ChargePointStatus.Finishing }, + // { from: OCPP16ChargePointStatus.SuspendedEVSE, to: OCPP16ChargePointStatus.Reserved }, + { from: OCPP16ChargePointStatus.SuspendedEVSE, to: OCPP16ChargePointStatus.Unavailable }, + { from: OCPP16ChargePointStatus.SuspendedEVSE, to: OCPP16ChargePointStatus.Faulted }, + // { to: OCPP16ChargePointStatus.Finishing}, + { from: OCPP16ChargePointStatus.Finishing, to: OCPP16ChargePointStatus.Available }, + { from: OCPP16ChargePointStatus.Finishing, to: OCPP16ChargePointStatus.Preparing }, + // { from: OCPP16ChargePointStatus.Finishing, to: OCPP16ChargePointStatus.Charging }, + // { from: OCPP16ChargePointStatus.Finishing, to: OCPP16ChargePointStatus.SuspendedEV }, + // { from: OCPP16ChargePointStatus.Finishing, to: OCPP16ChargePointStatus.SuspendedEVSE }, + // { from: OCPP16ChargePointStatus.Finishing, to: OCPP16ChargePointStatus.Finishing }, + // { from: OCPP16ChargePointStatus.Finishing, to: OCPP16ChargePointStatus.Reserved }, + { from: OCPP16ChargePointStatus.Finishing, to: OCPP16ChargePointStatus.Unavailable }, + { from: OCPP16ChargePointStatus.Finishing, to: OCPP16ChargePointStatus.Faulted }, + // { to: OCPP16ChargePointStatus.Reserved }, + { from: OCPP16ChargePointStatus.Reserved, to: OCPP16ChargePointStatus.Available }, + { from: OCPP16ChargePointStatus.Reserved, to: OCPP16ChargePointStatus.Preparing }, + // { from: OCPP16ChargePointStatus.Reserved, to: OCPP16ChargePointStatus.Charging }, + // { from: OCPP16ChargePointStatus.Reserved, to: OCPP16ChargePointStatus.SuspendedEV }, + // { from: OCPP16ChargePointStatus.Reserved, to: OCPP16ChargePointStatus.SuspendedEVSE }, + // { from: OCPP16ChargePointStatus.Reserved, to: OCPP16ChargePointStatus.Finishing }, + // { from: OCPP16ChargePointStatus.Reserved, to: OCPP16ChargePointStatus.Reserved }, + { from: OCPP16ChargePointStatus.Reserved, to: OCPP16ChargePointStatus.Unavailable }, + { from: OCPP16ChargePointStatus.Reserved, to: OCPP16ChargePointStatus.Faulted }, { to: OCPP16ChargePointStatus.Unavailable }, { from: OCPP16ChargePointStatus.Unavailable, to: OCPP16ChargePointStatus.Available }, + { from: OCPP16ChargePointStatus.Unavailable, to: OCPP16ChargePointStatus.Preparing }, + { from: OCPP16ChargePointStatus.Unavailable, to: OCPP16ChargePointStatus.Charging }, + { from: OCPP16ChargePointStatus.Unavailable, to: OCPP16ChargePointStatus.SuspendedEV }, + { from: OCPP16ChargePointStatus.Unavailable, to: OCPP16ChargePointStatus.SuspendedEVSE }, + // { from: OCPP16ChargePointStatus.Unavailable, to: OCPP16ChargePointStatus.Finishing }, + // { from: OCPP16ChargePointStatus.Unavailable, to: OCPP16ChargePointStatus.Reserved }, // { from: OCPP16ChargePointStatus.Unavailable, to: OCPP16ChargePointStatus.Unavailable }, { from: OCPP16ChargePointStatus.Unavailable, to: OCPP16ChargePointStatus.Faulted }, { to: OCPP16ChargePointStatus.Faulted }, { from: OCPP16ChargePointStatus.Faulted, to: OCPP16ChargePointStatus.Available }, + { from: OCPP16ChargePointStatus.Faulted, to: OCPP16ChargePointStatus.Preparing }, + { from: OCPP16ChargePointStatus.Faulted, to: OCPP16ChargePointStatus.Charging }, + { from: OCPP16ChargePointStatus.Faulted, to: OCPP16ChargePointStatus.SuspendedEV }, + { from: OCPP16ChargePointStatus.Faulted, to: OCPP16ChargePointStatus.SuspendedEVSE }, + { from: OCPP16ChargePointStatus.Faulted, to: OCPP16ChargePointStatus.Finishing }, + { from: OCPP16ChargePointStatus.Faulted, to: OCPP16ChargePointStatus.Reserved }, { from: OCPP16ChargePointStatus.Faulted, to: OCPP16ChargePointStatus.Unavailable }, // { from: OCPP16ChargePointStatus.Faulted, to: OCPP16ChargePointStatus.Faulted }, ]); - - static readonly ChargePointStatusConnectorTransitions: Readonly = Object.freeze([ - { to: OCPP16ChargePointStatus.Available }, - // { from: OCPP16ChargePointStatus.Available, to: OCPP16ChargePointStatus.Available }, - { from: OCPP16ChargePointStatus.Available, to: OCPP16ChargePointStatus.Preparing }, - { from: OCPP16ChargePointStatus.Available, to: OCPP16ChargePointStatus.Charging }, - { from: OCPP16ChargePointStatus.Available, to: OCPP16ChargePointStatus.SuspendedEV }, - { from: OCPP16ChargePointStatus.Available, to: OCPP16ChargePointStatus.SuspendedEVSE }, - // { from: OCPP16ChargePointStatus.Available, to: OCPP16ChargePointStatus.Finishing }, - { from: OCPP16ChargePointStatus.Available, to: OCPP16ChargePointStatus.Reserved }, - { from: OCPP16ChargePointStatus.Available, to: OCPP16ChargePointStatus.Unavailable }, - { from: OCPP16ChargePointStatus.Available, to: OCPP16ChargePointStatus.Faulted }, - // { to: OCPP16ChargePointStatus.Preparing }, - { from: OCPP16ChargePointStatus.Preparing, to: OCPP16ChargePointStatus.Available }, - // { from: OCPP16ChargePointStatus.Preparing, to: OCPP16ChargePointStatus.Preparing }, - { from: OCPP16ChargePointStatus.Preparing, to: OCPP16ChargePointStatus.Charging }, - { from: OCPP16ChargePointStatus.Preparing, to: OCPP16ChargePointStatus.SuspendedEV }, - { from: OCPP16ChargePointStatus.Preparing, to: OCPP16ChargePointStatus.SuspendedEVSE }, - { from: OCPP16ChargePointStatus.Preparing, to: OCPP16ChargePointStatus.Finishing }, - // { from: OCPP16ChargePointStatus.Preparing, to: OCPP16ChargePointStatus.Reserved }, - // { from: OCPP16ChargePointStatus.Preparing, to: OCPP16ChargePointStatus.Unavailable }, - { from: OCPP16ChargePointStatus.Preparing, to: OCPP16ChargePointStatus.Faulted }, - // { to: OCPP16ChargePointStatus.Charging }, - { from: OCPP16ChargePointStatus.Charging, to: OCPP16ChargePointStatus.Available }, - // { from: OCPP16ChargePointStatus.Charging, to: OCPP16ChargePointStatus.Preparing }, - // { from: OCPP16ChargePointStatus.Charging, to: OCPP16ChargePointStatus.Charging }, - { from: OCPP16ChargePointStatus.Charging, to: OCPP16ChargePointStatus.SuspendedEV }, - { from: OCPP16ChargePointStatus.Charging, to: OCPP16ChargePointStatus.SuspendedEVSE }, - { from: OCPP16ChargePointStatus.Charging, to: OCPP16ChargePointStatus.Finishing }, - // { from: OCPP16ChargePointStatus.Charging, to: OCPP16ChargePointStatus.Reserved }, - { from: OCPP16ChargePointStatus.Charging, to: OCPP16ChargePointStatus.Unavailable }, - { from: OCPP16ChargePointStatus.Charging, to: OCPP16ChargePointStatus.Faulted }, - // { to: OCPP16ChargePointStatus.SuspendedEV }, - { from: OCPP16ChargePointStatus.SuspendedEV, to: OCPP16ChargePointStatus.Available }, - // { from: OCPP16ChargePointStatus.SuspendedEV, to: OCPP16ChargePointStatus.Preparing }, - { from: OCPP16ChargePointStatus.SuspendedEV, to: OCPP16ChargePointStatus.Charging }, - // { from: OCPP16ChargePointStatus.SuspendedEV, OCPP16ChargePointStatus.SuspendedEV }, - { from: OCPP16ChargePointStatus.SuspendedEV, to: OCPP16ChargePointStatus.SuspendedEVSE }, - { from: OCPP16ChargePointStatus.SuspendedEV, to: OCPP16ChargePointStatus.Finishing }, - // { from: OCPP16ChargePointStatus.SuspendedEV, to: OCPP16ChargePointStatus.Reserved }, - { from: OCPP16ChargePointStatus.SuspendedEV, to: OCPP16ChargePointStatus.Unavailable }, - { from: OCPP16ChargePointStatus.SuspendedEV, to: OCPP16ChargePointStatus.Faulted }, - // { to: OCPP16ChargePointStatus.SuspendedEVSE }, - { from: OCPP16ChargePointStatus.SuspendedEVSE, to: OCPP16ChargePointStatus.Available }, - // { from: OCPP16ChargePointStatus.SuspendedEVSE, to: OCPP16ChargePointStatus.Preparing }, - { from: OCPP16ChargePointStatus.SuspendedEVSE, to: OCPP16ChargePointStatus.Charging }, - { from: OCPP16ChargePointStatus.SuspendedEVSE, to: OCPP16ChargePointStatus.SuspendedEV }, - // { from: OCPP16ChargePointStatus.SuspendedEVSE, to: OCPP16ChargePointStatus.SuspendedEVSE }, - { from: OCPP16ChargePointStatus.SuspendedEVSE, to: OCPP16ChargePointStatus.Finishing }, - // { from: OCPP16ChargePointStatus.SuspendedEVSE, to: OCPP16ChargePointStatus.Reserved }, - { from: OCPP16ChargePointStatus.SuspendedEVSE, to: OCPP16ChargePointStatus.Unavailable }, - { from: OCPP16ChargePointStatus.SuspendedEVSE, to: OCPP16ChargePointStatus.Faulted }, - // { to: OCPP16ChargePointStatus.Finishing}, - { from: OCPP16ChargePointStatus.Finishing, to: OCPP16ChargePointStatus.Available }, - { from: OCPP16ChargePointStatus.Finishing, to: OCPP16ChargePointStatus.Preparing }, - // { from: OCPP16ChargePointStatus.Finishing, to: OCPP16ChargePointStatus.Charging }, - // { from: OCPP16ChargePointStatus.Finishing, to: OCPP16ChargePointStatus.SuspendedEV }, - // { from: OCPP16ChargePointStatus.Finishing, to: OCPP16ChargePointStatus.SuspendedEVSE }, - // { from: OCPP16ChargePointStatus.Finishing, to: OCPP16ChargePointStatus.Finishing }, - // { from: OCPP16ChargePointStatus.Finishing, to: OCPP16ChargePointStatus.Reserved }, - { from: OCPP16ChargePointStatus.Finishing, to: OCPP16ChargePointStatus.Unavailable }, - { from: OCPP16ChargePointStatus.Finishing, to: OCPP16ChargePointStatus.Faulted }, - // { to: OCPP16ChargePointStatus.Reserved }, - { from: OCPP16ChargePointStatus.Reserved, to: OCPP16ChargePointStatus.Available }, - { from: OCPP16ChargePointStatus.Reserved, to: OCPP16ChargePointStatus.Preparing }, - // { from: OCPP16ChargePointStatus.Reserved, to: OCPP16ChargePointStatus.Charging }, - // { from: OCPP16ChargePointStatus.Reserved, to: OCPP16ChargePointStatus.SuspendedEV }, - // { from: OCPP16ChargePointStatus.Reserved, to: OCPP16ChargePointStatus.SuspendedEVSE }, - // { from: OCPP16ChargePointStatus.Reserved, to: OCPP16ChargePointStatus.Finishing }, - // { from: OCPP16ChargePointStatus.Reserved, to: OCPP16ChargePointStatus.Reserved }, - { from: OCPP16ChargePointStatus.Reserved, to: OCPP16ChargePointStatus.Unavailable }, - { from: OCPP16ChargePointStatus.Reserved, to: OCPP16ChargePointStatus.Faulted }, - { to: OCPP16ChargePointStatus.Unavailable }, - { from: OCPP16ChargePointStatus.Unavailable, to: OCPP16ChargePointStatus.Available }, - { from: OCPP16ChargePointStatus.Unavailable, to: OCPP16ChargePointStatus.Preparing }, - { from: OCPP16ChargePointStatus.Unavailable, to: OCPP16ChargePointStatus.Charging }, - { from: OCPP16ChargePointStatus.Unavailable, to: OCPP16ChargePointStatus.SuspendedEV }, - { from: OCPP16ChargePointStatus.Unavailable, to: OCPP16ChargePointStatus.SuspendedEVSE }, - // { from: OCPP16ChargePointStatus.Unavailable, to: OCPP16ChargePointStatus.Finishing }, - // { from: OCPP16ChargePointStatus.Unavailable, to: OCPP16ChargePointStatus.Reserved }, - // { from: OCPP16ChargePointStatus.Unavailable, to: OCPP16ChargePointStatus.Unavailable }, - { from: OCPP16ChargePointStatus.Unavailable, to: OCPP16ChargePointStatus.Faulted }, - { to: OCPP16ChargePointStatus.Faulted }, - { from: OCPP16ChargePointStatus.Faulted, to: OCPP16ChargePointStatus.Available }, - { from: OCPP16ChargePointStatus.Faulted, to: OCPP16ChargePointStatus.Preparing }, - { from: OCPP16ChargePointStatus.Faulted, to: OCPP16ChargePointStatus.Charging }, - { from: OCPP16ChargePointStatus.Faulted, to: OCPP16ChargePointStatus.SuspendedEV }, - { from: OCPP16ChargePointStatus.Faulted, to: OCPP16ChargePointStatus.SuspendedEVSE }, - { from: OCPP16ChargePointStatus.Faulted, to: OCPP16ChargePointStatus.Finishing }, - { from: OCPP16ChargePointStatus.Faulted, to: OCPP16ChargePointStatus.Reserved }, - { from: OCPP16ChargePointStatus.Faulted, to: OCPP16ChargePointStatus.Unavailable }, - // { from: OCPP16ChargePointStatus.Faulted, to: OCPP16ChargePointStatus.Faulted }, - ]); } diff --git a/src/charging-station/ocpp/2.0/OCPP20Constants.ts b/src/charging-station/ocpp/2.0/OCPP20Constants.ts index f24cc565..f02c89c8 100644 --- a/src/charging-station/ocpp/2.0/OCPP20Constants.ts +++ b/src/charging-station/ocpp/2.0/OCPP20Constants.ts @@ -1,72 +1,91 @@ -import { OCPP20ConnectorStatusEnumType } from '../../../types'; +import { ConnectorStatusTransition, OCPP20ConnectorStatusEnumType } from '../../../types'; import { OCPPConstants } from '../internal'; -type Transition = Readonly<{ - from?: OCPP20ConnectorStatusEnumType; - to: OCPP20ConnectorStatusEnumType; -}>; - export class OCPP20Constants extends OCPPConstants { - static readonly ChargingStationStatusTransitions: Readonly = Object.freeze([ - { to: OCPP20ConnectorStatusEnumType.Available }, - // { from: OCPP20ConnectorStatusEnumType.Available, to: OCPP20ConnectorStatusEnumType.Available }, - { - from: OCPP20ConnectorStatusEnumType.Available, - to: OCPP20ConnectorStatusEnumType.Unavailable, - }, - { from: OCPP20ConnectorStatusEnumType.Available, to: OCPP20ConnectorStatusEnumType.Faulted }, - { to: OCPP20ConnectorStatusEnumType.Unavailable }, - { - from: OCPP20ConnectorStatusEnumType.Unavailable, - to: OCPP20ConnectorStatusEnumType.Available, - }, - // { - // from: OCPP20ConnectorStatusEnumType.Unavailable, - // to: OCPP20ConnectorStatusEnumType.Unavailable, - // }, - { from: OCPP20ConnectorStatusEnumType.Unavailable, to: OCPP20ConnectorStatusEnumType.Faulted }, - { to: OCPP20ConnectorStatusEnumType.Faulted }, - { from: OCPP20ConnectorStatusEnumType.Faulted, to: OCPP20ConnectorStatusEnumType.Available }, - { from: OCPP20ConnectorStatusEnumType.Faulted, to: OCPP20ConnectorStatusEnumType.Unavailable }, - // { from: OCPP20ConnectorStatusEnumType.Faulted, to: OCPP20ConnectorStatusEnumType.Faulted }, - ]); + static readonly ChargingStationStatusTransitions: Readonly = + Object.freeze([ + { to: OCPP20ConnectorStatusEnumType.Available }, + // { from: OCPP20ConnectorStatusEnumType.Available, to: OCPP20ConnectorStatusEnumType.Available }, + { + from: OCPP20ConnectorStatusEnumType.Available, + to: OCPP20ConnectorStatusEnumType.Unavailable, + }, + { from: OCPP20ConnectorStatusEnumType.Available, to: OCPP20ConnectorStatusEnumType.Faulted }, + { to: OCPP20ConnectorStatusEnumType.Unavailable }, + { + from: OCPP20ConnectorStatusEnumType.Unavailable, + to: OCPP20ConnectorStatusEnumType.Available, + }, + // { + // from: OCPP20ConnectorStatusEnumType.Unavailable, + // to: OCPP20ConnectorStatusEnumType.Unavailable, + // }, + { + from: OCPP20ConnectorStatusEnumType.Unavailable, + to: OCPP20ConnectorStatusEnumType.Faulted, + }, + { to: OCPP20ConnectorStatusEnumType.Faulted }, + { from: OCPP20ConnectorStatusEnumType.Faulted, to: OCPP20ConnectorStatusEnumType.Available }, + { + from: OCPP20ConnectorStatusEnumType.Faulted, + to: OCPP20ConnectorStatusEnumType.Unavailable, + }, + // { from: OCPP20ConnectorStatusEnumType.Faulted, to: OCPP20ConnectorStatusEnumType.Faulted }, + ]); - static readonly ConnectorStatusTransitions: Readonly = Object.freeze([ - { to: OCPP20ConnectorStatusEnumType.Available }, - // { from: OCPP20ConnectorStatusEnumType.Available, to: OCPP20ConnectorStatusEnumType.Available }, - { from: OCPP20ConnectorStatusEnumType.Available, to: OCPP20ConnectorStatusEnumType.Occupied }, - { from: OCPP20ConnectorStatusEnumType.Available, to: OCPP20ConnectorStatusEnumType.Reserved }, - { - from: OCPP20ConnectorStatusEnumType.Available, - to: OCPP20ConnectorStatusEnumType.Unavailable, - }, - { from: OCPP20ConnectorStatusEnumType.Available, to: OCPP20ConnectorStatusEnumType.Faulted }, - // { to: OCPP20ConnectorStatusEnumType.Occupied }, - { from: OCPP20ConnectorStatusEnumType.Occupied, to: OCPP20ConnectorStatusEnumType.Available }, - // { from: OCPP20ConnectorStatusEnumType.Occupied, to: OCPP20ConnectorStatusEnumType.Occupied }, - // { from: OCPP20ConnectorStatusEnumType.Occupied, to: OCPP20ConnectorStatusEnumType.Reserved }, - { from: OCPP20ConnectorStatusEnumType.Occupied, to: OCPP20ConnectorStatusEnumType.Unavailable }, - { from: OCPP20ConnectorStatusEnumType.Occupied, to: OCPP20ConnectorStatusEnumType.Faulted }, - // { to: OCPP20ConnectorStatusEnumType.Reserved }, - { from: OCPP20ConnectorStatusEnumType.Reserved, to: OCPP20ConnectorStatusEnumType.Available }, - { from: OCPP20ConnectorStatusEnumType.Reserved, to: OCPP20ConnectorStatusEnumType.Occupied }, - // { from: OCPP20ConnectorStatusEnumType.Reserved, to: OCPP20ConnectorStatusEnumType.Reserved }, - { from: OCPP20ConnectorStatusEnumType.Reserved, to: OCPP20ConnectorStatusEnumType.Unavailable }, - { from: OCPP20ConnectorStatusEnumType.Reserved, to: OCPP20ConnectorStatusEnumType.Faulted }, - { to: OCPP20ConnectorStatusEnumType.Unavailable }, - { - from: OCPP20ConnectorStatusEnumType.Unavailable, - to: OCPP20ConnectorStatusEnumType.Available, - }, - { from: OCPP20ConnectorStatusEnumType.Unavailable, to: OCPP20ConnectorStatusEnumType.Occupied }, - // { from: OCPP20ConnectorStatusEnumType.Unavailable, to: OCPP20ConnectorStatusEnumType.Reserved }, - // { from: OCPP20ConnectorStatusEnumType.Unavailable, to: OCPP20ConnectorStatusEnumType.Unavailable }, - { from: OCPP20ConnectorStatusEnumType.Unavailable, to: OCPP20ConnectorStatusEnumType.Faulted }, - { to: OCPP20ConnectorStatusEnumType.Faulted }, - { from: OCPP20ConnectorStatusEnumType.Faulted, to: OCPP20ConnectorStatusEnumType.Available }, - { from: OCPP20ConnectorStatusEnumType.Faulted, to: OCPP20ConnectorStatusEnumType.Occupied }, - { from: OCPP20ConnectorStatusEnumType.Faulted, to: OCPP20ConnectorStatusEnumType.Reserved }, - { from: OCPP20ConnectorStatusEnumType.Faulted, to: OCPP20ConnectorStatusEnumType.Unavailable }, - // { from: OCPP20ConnectorStatusEnumType.Faulted, to: OCPP20ConnectorStatusEnumType.Faulted }, - ]); + static readonly ConnectorStatusTransitions: Readonly = Object.freeze( + [ + { to: OCPP20ConnectorStatusEnumType.Available }, + // { from: OCPP20ConnectorStatusEnumType.Available, to: OCPP20ConnectorStatusEnumType.Available }, + { from: OCPP20ConnectorStatusEnumType.Available, to: OCPP20ConnectorStatusEnumType.Occupied }, + { from: OCPP20ConnectorStatusEnumType.Available, to: OCPP20ConnectorStatusEnumType.Reserved }, + { + from: OCPP20ConnectorStatusEnumType.Available, + to: OCPP20ConnectorStatusEnumType.Unavailable, + }, + { from: OCPP20ConnectorStatusEnumType.Available, to: OCPP20ConnectorStatusEnumType.Faulted }, + // { to: OCPP20ConnectorStatusEnumType.Occupied }, + { from: OCPP20ConnectorStatusEnumType.Occupied, to: OCPP20ConnectorStatusEnumType.Available }, + // { from: OCPP20ConnectorStatusEnumType.Occupied, to: OCPP20ConnectorStatusEnumType.Occupied }, + // { from: OCPP20ConnectorStatusEnumType.Occupied, to: OCPP20ConnectorStatusEnumType.Reserved }, + { + from: OCPP20ConnectorStatusEnumType.Occupied, + to: OCPP20ConnectorStatusEnumType.Unavailable, + }, + { from: OCPP20ConnectorStatusEnumType.Occupied, to: OCPP20ConnectorStatusEnumType.Faulted }, + // { to: OCPP20ConnectorStatusEnumType.Reserved }, + { from: OCPP20ConnectorStatusEnumType.Reserved, to: OCPP20ConnectorStatusEnumType.Available }, + { from: OCPP20ConnectorStatusEnumType.Reserved, to: OCPP20ConnectorStatusEnumType.Occupied }, + // { from: OCPP20ConnectorStatusEnumType.Reserved, to: OCPP20ConnectorStatusEnumType.Reserved }, + { + from: OCPP20ConnectorStatusEnumType.Reserved, + to: OCPP20ConnectorStatusEnumType.Unavailable, + }, + { from: OCPP20ConnectorStatusEnumType.Reserved, to: OCPP20ConnectorStatusEnumType.Faulted }, + { to: OCPP20ConnectorStatusEnumType.Unavailable }, + { + from: OCPP20ConnectorStatusEnumType.Unavailable, + to: OCPP20ConnectorStatusEnumType.Available, + }, + { + from: OCPP20ConnectorStatusEnumType.Unavailable, + to: OCPP20ConnectorStatusEnumType.Occupied, + }, + // { from: OCPP20ConnectorStatusEnumType.Unavailable, to: OCPP20ConnectorStatusEnumType.Reserved }, + // { from: OCPP20ConnectorStatusEnumType.Unavailable, to: OCPP20ConnectorStatusEnumType.Unavailable }, + { + from: OCPP20ConnectorStatusEnumType.Unavailable, + to: OCPP20ConnectorStatusEnumType.Faulted, + }, + { to: OCPP20ConnectorStatusEnumType.Faulted }, + { from: OCPP20ConnectorStatusEnumType.Faulted, to: OCPP20ConnectorStatusEnumType.Available }, + { from: OCPP20ConnectorStatusEnumType.Faulted, to: OCPP20ConnectorStatusEnumType.Occupied }, + { from: OCPP20ConnectorStatusEnumType.Faulted, to: OCPP20ConnectorStatusEnumType.Reserved }, + { + from: OCPP20ConnectorStatusEnumType.Faulted, + to: OCPP20ConnectorStatusEnumType.Unavailable, + }, + // { from: OCPP20ConnectorStatusEnumType.Faulted, to: OCPP20ConnectorStatusEnumType.Faulted }, + ] + ); } diff --git a/src/types/index.ts b/src/types/index.ts index 5170678f..eaf26be9 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -47,6 +47,7 @@ export { ConnectorPhaseRotation, type ConnectorStatus, ConnectorStatusEnum, + type ConnectorStatusTransition, CurrentType, DBName, type DataTransferRequest, diff --git a/src/types/ocpp/ConnectorStatusEnum.ts b/src/types/ocpp/ConnectorStatusEnum.ts index a98e15d9..6c251cb7 100644 --- a/src/types/ocpp/ConnectorStatusEnum.ts +++ b/src/types/ocpp/ConnectorStatusEnum.ts @@ -5,3 +5,8 @@ export const ConnectorStatusEnum = { ...OCPP20ConnectorStatusEnumType, } as const; export type ConnectorStatusEnum = OCPP16ChargePointStatus | OCPP20ConnectorStatusEnumType; + +export type ConnectorStatusTransition = Readonly<{ + from?: ConnectorStatusEnum; + to: ConnectorStatusEnum; +}>;