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