From: Jérôme Benoit Date: Tue, 14 Feb 2023 17:04:57 +0000 (+0100) Subject: feat(simulator): add more OCPP 2.x.x types definition X-Git-Tag: v1.1.95~56 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=28f1c5749ad4ee138c34c345a7bd812b40ccbcfa;p=e-mobility-charging-stations-simulator.git feat(simulator): add more OCPP 2.x.x types definition Signed-off-by: Jérôme Benoit --- 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;