Add initial classes structure for the OCPP 2.0 stack
[e-mobility-charging-stations-simulator.git] / src / types / ocpp / Requests.ts
CommitLineData
8114d10e 1import type ChargingStation from '../../charging-station/ChargingStation';
6c1761d4
JB
2import type OCPPError from '../../exception/OCPPError';
3import type { JsonType } from '../JsonType';
8114d10e 4import { OCPP16DiagnosticsStatus } from './1.6/DiagnosticsStatus';
6c1761d4 5import type { OCPP16MeterValuesRequest } from './1.6/MeterValues';
e7aeea18
JB
6import {
7 OCPP16AvailabilityType,
953d6b02
JB
8 type OCPP16BootNotificationRequest,
9 type OCPP16DataTransferRequest,
10 type OCPP16HeartbeatRequest,
e7aeea18 11 OCPP16IncomingRequestCommand,
c60ed4b8 12 OCPP16MessageTrigger,
e7aeea18 13 OCPP16RequestCommand,
953d6b02 14 type OCPP16StatusNotificationRequest,
e7aeea18 15} from './1.6/Requests';
953d6b02 16import { OCPP20IncomingRequestCommand, OCPP20RequestCommand } from './2.0/Requests';
6c1761d4 17import type { MessageType } from './MessageType';
6a64534b 18
e3018bc4
JB
19export type RequestCommand = OCPP16RequestCommand;
20
21export const RequestCommand = {
22 ...OCPP16RequestCommand,
953d6b02 23 ...OCPP20RequestCommand,
e3018bc4
JB
24};
25
5cc4b63b 26export type OutgoingRequest = [MessageType.CALL_MESSAGE, string, RequestCommand, JsonType];
b3ec7bc1 27
83e00df1 28export type RequestParams = {
e3018bc4
JB
29 skipBufferingOnError?: boolean;
30 triggerMessage?: boolean;
83e00df1 31};
e3018bc4
JB
32
33export type IncomingRequestCommand = OCPP16IncomingRequestCommand;
34
35export const IncomingRequestCommand = {
36 ...OCPP16IncomingRequestCommand,
953d6b02 37 ...OCPP20IncomingRequestCommand,
e3018bc4
JB
38};
39
5cc4b63b 40export type IncomingRequest = [MessageType.CALL_MESSAGE, string, IncomingRequestCommand, JsonType];
b3ec7bc1 41
d900c8d7
JB
42export type ResponseCallback = (payload: JsonType, requestPayload: JsonType) => void;
43
44export type ErrorCallback = (error: OCPPError, requestStatistic?: boolean) => void;
45
b3ec7bc1 46export type CachedRequest = [
d900c8d7
JB
47 ResponseCallback,
48 ErrorCallback,
b3ec7bc1 49 RequestCommand | IncomingRequestCommand,
5cc4b63b 50 JsonType
b3ec7bc1
JB
51];
52
c60ed4b8
JB
53export type MessageTrigger = OCPP16MessageTrigger;
54
55export const MessageTrigger = {
56 ...OCPP16MessageTrigger,
57};
58
c0560973
JB
59export type BootNotificationRequest = OCPP16BootNotificationRequest;
60
ef6fa3fb
JB
61export type HeartbeatRequest = OCPP16HeartbeatRequest;
62
63export type StatusNotificationRequest = OCPP16StatusNotificationRequest;
64
65export type MeterValuesRequest = OCPP16MeterValuesRequest;
66
91a7d3ea
JB
67export type DataTransferRequest = OCPP16DataTransferRequest;
68
e3018bc4
JB
69export type IncomingRequestHandler = (
70 chargingStation: ChargingStation,
71 commandPayload: JsonType
72) => JsonType | Promise<JsonType>;
73
7e3926cc 74export type AvailabilityType = OCPP16AvailabilityType;
c0560973
JB
75
76export const AvailabilityType = {
e7aeea18 77 ...OCPP16AvailabilityType,
c0560973
JB
78};
79
47e22477
JB
80export type DiagnosticsStatus = OCPP16DiagnosticsStatus;
81
82export const DiagnosticsStatus = {
e7aeea18 83 ...OCPP16DiagnosticsStatus,
47e22477 84};
e3018bc4
JB
85
86export type ResponseType = JsonType | OCPPError;