Hook the OCPP 2.0 stack into the main code
[e-mobility-charging-stations-simulator.git] / ui / web / src / types / ChargingStationType.ts
1 import type { JsonObject } from './JsonType';
2
3 export type ChargingStationData = {
4 stationInfo: ChargingStationInfo;
5 started: boolean;
6 wsState?:
7 | typeof WebSocket.CONNECTING
8 | typeof WebSocket.OPEN
9 | typeof WebSocket.CLOSING
10 | typeof WebSocket.CLOSED;
11 bootNotificationResponse: BootNotificationResponse;
12 connectors: ConnectorStatus[];
13 automaticTransactionGeneratorStatuses?: Status[];
14 };
15
16 export type ChargingStationInfo = {
17 hashId: string;
18 chargingStationId?: string;
19 chargePointModel: string;
20 chargePointVendor: string;
21 firmwareVersionPattern?: string;
22 firmwareVersion?: string;
23 numberOfConnectors?: number | number[];
24 baseName: string;
25 infoHash?: string;
26 templateHash?: string;
27 chargeBoxSerialNumber?: string;
28 chargePointSerialNumber?: string;
29 meterSerialNumber?: string;
30 maximumPower?: number; // Always in Watt
31 maximumAmperage?: number; // Always in Ampere
32 supervisionUrls?: string | string[];
33 supervisionUrlOcppConfiguration?: boolean;
34 supervisionUrlOcppKey?: string;
35 supervisionUser?: string;
36 supervisionPassword?: string;
37 ocppVersion?: OCPPVersion;
38 ocppProtocol?: OCPPProtocol;
39 ocppStrictCompliance?: boolean;
40 ocppPersistentConfiguration?: boolean;
41 stationInfoPersistentConfiguration?: boolean;
42 authorizationFile?: string;
43 nameSuffix?: string;
44 fixedName?: boolean;
45 iccid?: string;
46 imsi?: string;
47 meterType?: string;
48 powerSharedByConnectors?: boolean;
49 currentOutType?: CurrentType;
50 voltageOut?: Voltage;
51 numberOfPhases?: number;
52 useConnectorId0?: boolean;
53 randomConnectors?: boolean;
54 resetTime?: number;
55 autoRegister?: boolean;
56 autoReconnectMaxRetries?: number;
57 reconnectExponentialDelay?: boolean;
58 registrationMaxRetries?: number;
59 enableStatistics?: boolean;
60 mustAuthorizeAtRemoteStart?: boolean;
61 amperageLimitationOcppKey?: string;
62 amperageLimitationUnit?: AmpereUnits;
63 beginEndMeterValues?: boolean;
64 outOfOrderEndMeterValues?: boolean;
65 meteringPerTransaction?: boolean;
66 transactionDataMeterValues?: boolean;
67 mainVoltageMeterValues?: boolean;
68 phaseLineToLineVoltageMeterValues?: boolean;
69 customValueLimitationMeterValues?: boolean;
70 commandsSupport?: CommandsSupport;
71 messageTriggerSupport?: Record<MessageTrigger, boolean>;
72 };
73
74 export enum OCPP16IncomingRequestCommand {
75 RESET = 'Reset',
76 CLEAR_CACHE = 'ClearCache',
77 CHANGE_AVAILABILITY = 'ChangeAvailability',
78 UNLOCK_CONNECTOR = 'UnlockConnector',
79 GET_CONFIGURATION = 'GetConfiguration',
80 CHANGE_CONFIGURATION = 'ChangeConfiguration',
81 SET_CHARGING_PROFILE = 'SetChargingProfile',
82 CLEAR_CHARGING_PROFILE = 'ClearChargingProfile',
83 REMOTE_START_TRANSACTION = 'RemoteStartTransaction',
84 REMOTE_STOP_TRANSACTION = 'RemoteStopTransaction',
85 GET_DIAGNOSTICS = 'GetDiagnostics',
86 TRIGGER_MESSAGE = 'TriggerMessage',
87 }
88
89 export const IncomingRequestCommand = {
90 ...OCPP16IncomingRequestCommand,
91 } as const;
92 export type IncomingRequestCommand = OCPP16IncomingRequestCommand;
93
94 export enum OCPP16RequestCommand {
95 BOOT_NOTIFICATION = 'BootNotification',
96 HEARTBEAT = 'Heartbeat',
97 STATUS_NOTIFICATION = 'StatusNotification',
98 AUTHORIZE = 'Authorize',
99 START_TRANSACTION = 'StartTransaction',
100 STOP_TRANSACTION = 'StopTransaction',
101 METER_VALUES = 'MeterValues',
102 DIAGNOSTICS_STATUS_NOTIFICATION = 'DiagnosticsStatusNotification',
103 }
104
105 export const RequestCommand = {
106 ...OCPP16RequestCommand,
107 } as const;
108 export type RequestCommand = OCPP16RequestCommand;
109
110 export type BootNotificationResponse = OCPP16BootNotificationResponse;
111
112 export enum OCPP16RegistrationStatus {
113 ACCEPTED = 'Accepted',
114 PENDING = 'Pending',
115 REJECTED = 'Rejected',
116 }
117
118 export interface OCPP16BootNotificationResponse extends JsonObject {
119 status: OCPP16RegistrationStatus;
120 currentTime: string;
121 interval: number;
122 }
123
124 export enum OCPP16MessageTrigger {
125 BootNotification = 'BootNotification',
126 DiagnosticsStatusNotification = 'DiagnosticsStatusNotification',
127 FirmwareStatusNotification = 'FirmwareStatusNotification',
128 Heartbeat = 'Heartbeat',
129 MeterValues = 'MeterValues',
130 StatusNotification = 'StatusNotification',
131 }
132
133 export const MessageTrigger = {
134 ...OCPP16MessageTrigger,
135 } as const;
136 export type MessageTrigger = OCPP16MessageTrigger;
137
138 type CommandsSupport = {
139 incomingCommands: Record<IncomingRequestCommand, boolean>;
140 outgoingCommands?: Record<RequestCommand, boolean>;
141 };
142
143 export enum OCPPVersion {
144 VERSION_16 = '1.6',
145 VERSION_20 = '2.0',
146 }
147
148 export enum OCPPProtocol {
149 JSON = 'json',
150 }
151
152 export enum CurrentType {
153 AC = 'AC',
154 DC = 'DC',
155 }
156
157 export enum Voltage {
158 VOLTAGE_110 = 110,
159 VOLTAGE_230 = 230,
160 VOLTAGE_400 = 400,
161 VOLTAGE_800 = 800,
162 }
163
164 export enum AmpereUnits {
165 MILLI_AMPERE = 'mA',
166 CENTI_AMPERE = 'cA',
167 DECI_AMPERE = 'dA',
168 AMPERE = 'A',
169 }
170
171 export type ConnectorStatus = {
172 availability: AvailabilityType;
173 bootStatus?: ChargePointStatus;
174 status?: ChargePointStatus;
175 authorizeIdTag?: string;
176 idTagAuthorized?: boolean;
177 localAuthorizeIdTag?: string;
178 idTagLocalAuthorized?: boolean;
179 transactionRemoteStarted?: boolean;
180 transactionStarted?: boolean;
181 transactionId?: number;
182 transactionIdTag?: string;
183 energyActiveImportRegisterValue?: number; // In Wh
184 transactionEnergyActiveImportRegisterValue?: number; // In Wh
185 };
186
187 export type AvailabilityType = OCPP16AvailabilityType;
188
189 export enum OCPP16AvailabilityType {
190 INOPERATIVE = 'Inoperative',
191 OPERATIVE = 'Operative',
192 }
193
194 export type ChargePointStatus = OCPP16ChargePointStatus;
195
196 export enum OCPP16ChargePointStatus {
197 AVAILABLE = 'Available',
198 PREPARING = 'Preparing',
199 CHARGING = 'Charging',
200 OCCUPIED = 'Occupied',
201 SUSPENDED_EVSE = 'SuspendedEVSE',
202 SUSPENDED_EV = 'SuspendedEV',
203 FINISHING = 'Finishing',
204 RESERVED = 'Reserved',
205 UNAVAILABLE = 'Unavailable',
206 FAULTED = 'Faulted',
207 }
208
209 export type Status = {
210 start?: boolean;
211 startDate?: Date;
212 lastRunDate?: Date;
213 stopDate?: Date;
214 stoppedDate?: Date;
215 authorizeRequests?: number;
216 acceptedAuthorizeRequests?: number;
217 rejectedAuthorizeRequests?: number;
218 startTransactionRequests?: number;
219 acceptedStartTransactionRequests?: number;
220 rejectedStartTransactionRequests?: number;
221 stopTransactionRequests?: number;
222 acceptedStopTransactionRequests?: number;
223 rejectedStopTransactionRequests?: number;
224 skippedConsecutiveTransactions?: number;
225 skippedTransactions?: number;
226 };