From 28f1c5749ad4ee138c34c345a7bd812b40ccbcfa Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Tue, 14 Feb 2023 18:04:57 +0100 Subject: [PATCH] feat(simulator): add more OCPP 2.x.x types definition MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/types/internal.ts | 1 + src/types/ocpp/2.0/Common.ts | 31 ++++++++++++++++++++ src/types/ocpp/2.0/Requests.ts | 36 +++++++++-------------- src/types/ocpp/2.0/Responses.ts | 11 +++---- src/types/ocpp/2.0/Variables.ts | 51 ++++++++++++++++++++++++++++++++- 5 files changed, 101 insertions(+), 29 deletions(-) create mode 100644 src/types/ocpp/2.0/Common.ts diff --git a/src/types/internal.ts b/src/types/internal.ts index 105c983c..c7a141a4 100644 --- a/src/types/internal.ts +++ b/src/types/internal.ts @@ -7,6 +7,7 @@ export * from './ocpp/1.6/MeterValues'; export * from './ocpp/1.6/Requests'; export * from './ocpp/1.6/Responses'; export * from './ocpp/1.6/Transaction'; +export * from './ocpp/2.0/Common'; export * from './ocpp/2.0/Requests'; export * from './ocpp/2.0/Responses'; export * from './ocpp/2.0/Variables'; diff --git a/src/types/ocpp/2.0/Common.ts b/src/types/ocpp/2.0/Common.ts new file mode 100644 index 00000000..5e47a251 --- /dev/null +++ b/src/types/ocpp/2.0/Common.ts @@ -0,0 +1,31 @@ +import type { JsonObject } from '../../internal'; + +export enum BootReasonEnumType { + ApplicationReset = 'ApplicationReset', + FirmwareUpdate = 'FirmwareUpdate', + LocalReset = 'LocalReset', + PowerUp = 'PowerUp', + RemoteReset = 'RemoteReset', + ScheduledReset = 'ScheduledReset', + Triggered = 'Triggered', + Unknown = 'Unknown', + Watchdog = 'Watchdog', +} + +export enum OCPP20ConnectorStatusEnumType { + AVAILABLE = 'Available', + OCCUPIED = 'Occupied', + RESERVED = 'Reserved', + UNAVAILABLE = 'Unavailable', + FAULTED = 'Faulted', +} + +export type StatusInfoType = { + reasonCode: string; + additionalInfo?: string; +} & JsonObject; + +export type EVSEType = { + id: number; + connectorId?: string; +} & JsonObject; diff --git a/src/types/ocpp/2.0/Requests.ts b/src/types/ocpp/2.0/Requests.ts index c42cd8bb..220a39b6 100644 --- a/src/types/ocpp/2.0/Requests.ts +++ b/src/types/ocpp/2.0/Requests.ts @@ -1,4 +1,10 @@ -import type { EmptyObject, JsonObject } from '../../internal'; +import type { + BootReasonEnumType, + EmptyObject, + JsonObject, + OCPP20ConnectorStatusEnumType, + OCPP20SetVariableDataType, +} from '../../internal'; export enum OCPP20RequestCommand { BOOT_NOTIFICATION = 'BootNotification', @@ -12,24 +18,12 @@ export enum OCPP20IncomingRequestCommand { REQUEST_STOP_TRANSACTION = 'RequestStopTransaction', } -export enum BootReasonEnumType { - ApplicationReset = 'ApplicationReset', - FirmwareUpdate = 'FirmwareUpdate', - LocalReset = 'LocalReset', - PowerUp = 'PowerUp', - RemoteReset = 'RemoteReset', - ScheduledReset = 'ScheduledReset', - Triggered = 'Triggered', - Unknown = 'Unknown', - Watchdog = 'Watchdog', -} - -export type ModemType = { +type ModemType = { iccid?: string; imsi?: string; } & JsonObject; -export type ChargingStationType = { +type ChargingStationType = { serialNumber?: string; model: string; vendorName: string; @@ -46,17 +40,13 @@ export type OCPP20HeartbeatRequest = EmptyObject; export type OCPP20ClearCacheRequest = EmptyObject; -export enum OCPP20ConnectorStatusEnumType { - AVAILABLE = 'Available', - OCCUPIED = 'Occupied', - RESERVED = 'Reserved', - UNAVAILABLE = 'Unavailable', - FAULTED = 'Faulted', -} - export type OCPP20StatusNotificationRequest = { timestamp: Date; connectorStatus: OCPP20ConnectorStatusEnumType; evseId: number; connectorId: number; } & JsonObject; + +export type OCPP20SetVariablesRequest = { + setVariableData: OCPP20SetVariableDataType[]; +} & JsonObject; diff --git a/src/types/ocpp/2.0/Responses.ts b/src/types/ocpp/2.0/Responses.ts index 3f4d2f42..fdbebf15 100644 --- a/src/types/ocpp/2.0/Responses.ts +++ b/src/types/ocpp/2.0/Responses.ts @@ -2,14 +2,11 @@ import type { EmptyObject, GenericStatus, JsonObject, + OCPP20SetVariableResultType, RegistrationStatusEnumType, + StatusInfoType, } from '../../internal'; -export type StatusInfoType = { - reasonCode: string; - additionalInfo?: string; -} & JsonObject; - export type OCPP20BootNotificationResponse = { currentTime: Date; status: RegistrationStatusEnumType; @@ -27,3 +24,7 @@ export type OCPP20ClearCacheResponse = { } & JsonObject; export type OCPP20StatusNotificationResponse = EmptyObject; + +export type OCPP20SetVariablesResponse = { + setVariableResult: OCPP20SetVariableResultType[]; +} & JsonObject; diff --git a/src/types/ocpp/2.0/Variables.ts b/src/types/ocpp/2.0/Variables.ts index 3c708986..9de1dcc8 100644 --- a/src/types/ocpp/2.0/Variables.ts +++ b/src/types/ocpp/2.0/Variables.ts @@ -1,4 +1,6 @@ -export enum OCPP20ComponentName { +import type { EVSEType, JsonObject, StatusInfoType } from '../../internal'; + +enum OCPP20ComponentName { AlignedDataCtrlr = 'AlignedDataCtrlr', AuthCacheCtrlr = 'AuthCacheCtrlr', AuthCtrlr = 'AuthCtrlr', @@ -58,3 +60,50 @@ export enum OCPP20OptionalVariableName { export enum OCPP20VendorVariableName { ConnectionUrl = 'ConnectionUrl', } + +enum AttributeEnumType { + Actual = 'Actual', + Target = 'Target', + MinSet = 'MinSet', + MaxSet = 'MaxSet', +} + +type ComponentType = { + name: string | OCPP20ComponentName; + instance?: string; + evse?: EVSEType; +} & JsonObject; + +type VariableType = { + name: string | OCPP20RequiredVariableName | OCPP20OptionalVariableName | OCPP20VendorVariableName; + instance?: string; +} & JsonObject; + +export type OCPP20SetVariableDataType = { + attributeType?: AttributeEnumType; + attributeValue: string; + component: ComponentType; + variable: VariableType; +} & JsonObject; + +enum SetVariableStatusEnumType { + Accepted = 'Accepted', + Rejected = 'Rejected', + UnknownComponent = 'UnknownComponent', + UnknownVariable = 'UnknownVariable', + NotSupportedAttributeType = 'NotSupportedAttributeType', + RebootRequired = 'RebootRequired', +} + +export type OCPP20SetVariableResultType = { + attributeType?: AttributeEnumType; + attributeStatus: SetVariableStatusEnumType; + component: ComponentType; + variable: VariableType; + attributeStatusInfo?: StatusInfoType; +} & JsonObject; + +type OCPP20ComponentVariableType = { + component: ComponentType; + variable?: VariableType; +} & JsonObject; -- 2.34.1