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