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