fix: ensure charging station uid is stable between firmware update
[e-mobility-charging-stations-simulator.git] / src / types / ocpp / Requests.ts
... / ...
CommitLineData
1import type { ChargingStation } from '../../charging-station';
2import type { OCPPError } from '../../exception';
3import {
4 type JsonType,
5 type MessageType,
6 OCPP16AvailabilityType,
7 type OCPP16BootNotificationRequest,
8 type OCPP16DataTransferRequest,
9 OCPP16DiagnosticsStatus,
10 type OCPP16DiagnosticsStatusNotificationRequest,
11 OCPP16FirmwareStatus,
12 type OCPP16FirmwareStatusNotificationRequest,
13 type OCPP16HeartbeatRequest,
14 OCPP16IncomingRequestCommand,
15 OCPP16MessageTrigger,
16 type OCPP16MeterValuesRequest,
17 OCPP16RequestCommand,
18 type OCPP16StatusNotificationRequest,
19 type OCPP20BootNotificationRequest,
20 OCPP20IncomingRequestCommand,
21 OCPP20RequestCommand,
22 type OCPP20StatusNotificationRequest,
23} from '../internal';
24
25export const RequestCommand = {
26 ...OCPP16RequestCommand,
27 ...OCPP20RequestCommand,
28} as const;
29export type RequestCommand = OCPP16RequestCommand | OCPP20RequestCommand;
30
31export type OutgoingRequest = [MessageType.CALL_MESSAGE, string, RequestCommand, JsonType];
32
33export type RequestParams = {
34 skipBufferingOnError?: boolean;
35 triggerMessage?: boolean;
36 throwError?: boolean;
37};
38
39export const IncomingRequestCommand = {
40 ...OCPP16IncomingRequestCommand,
41 ...OCPP20IncomingRequestCommand,
42} as const;
43export type IncomingRequestCommand = OCPP16IncomingRequestCommand | OCPP20IncomingRequestCommand;
44
45export type IncomingRequest = [MessageType.CALL_MESSAGE, string, IncomingRequestCommand, JsonType];
46
47export type ResponseCallback = (payload: JsonType, requestPayload: JsonType) => void;
48
49export type ErrorCallback = (error: OCPPError, requestStatistic?: boolean) => void;
50
51export type CachedRequest = [
52 ResponseCallback,
53 ErrorCallback,
54 RequestCommand | IncomingRequestCommand,
55 JsonType
56];
57
58export const MessageTrigger = {
59 ...OCPP16MessageTrigger,
60} as const;
61export type MessageTrigger = OCPP16MessageTrigger;
62
63export type BootNotificationRequest = OCPP16BootNotificationRequest | OCPP20BootNotificationRequest;
64
65export type HeartbeatRequest = OCPP16HeartbeatRequest;
66
67export type StatusNotificationRequest =
68 | OCPP16StatusNotificationRequest
69 | OCPP20StatusNotificationRequest;
70
71export type MeterValuesRequest = OCPP16MeterValuesRequest;
72
73export type DataTransferRequest = OCPP16DataTransferRequest;
74
75export type DiagnosticsStatusNotificationRequest = OCPP16DiagnosticsStatusNotificationRequest;
76
77export type FirmwareStatusNotificationRequest = OCPP16FirmwareStatusNotificationRequest;
78
79export type IncomingRequestHandler = (
80 chargingStation: ChargingStation,
81 commandPayload: JsonType
82) => JsonType | Promise<JsonType>;
83
84export const AvailabilityType = {
85 ...OCPP16AvailabilityType,
86} as const;
87export type AvailabilityType = OCPP16AvailabilityType;
88
89export const DiagnosticsStatus = {
90 ...OCPP16DiagnosticsStatus,
91} as const;
92export type DiagnosticsStatus = OCPP16DiagnosticsStatus;
93
94export const FirmwareStatus = {
95 ...OCPP16FirmwareStatus,
96} as const;
97export type FirmwareStatus = OCPP16FirmwareStatus;
98
99export type ResponseType = JsonType | OCPPError;