c2b1f53a55a71cf39029238a417d691fb1612070
[e-mobility-charging-stations-simulator.git] / src / types / ocpp / Responses.ts
1 import type ChargingStation from '../../charging-station/ChargingStation';
2 import type { JsonType } from '../JsonType';
3 import type { OCPP16MeterValuesResponse } from './1.6/MeterValues';
4 import {
5 OCPP16AvailabilityStatus,
6 type OCPP16BootNotificationResponse,
7 OCPP16ChargingProfileStatus,
8 OCPP16ClearChargingProfileStatus,
9 OCPP16ConfigurationStatus,
10 type OCPP16DataTransferResponse,
11 OCPP16DataTransferStatus,
12 type OCPP16DiagnosticsStatusNotificationResponse,
13 type OCPP16FirmwareStatusNotificationResponse,
14 type OCPP16HeartbeatResponse,
15 type OCPP16StatusNotificationResponse,
16 OCPP16TriggerMessageStatus,
17 OCPP16UnlockStatus,
18 } from './1.6/Responses';
19 import type { OCPP20BootNotificationResponse } from './2.0/Responses';
20 import type { ErrorType } from './ErrorType';
21 import type { MessageType } from './MessageType';
22
23 export type Response = [MessageType.CALL_RESULT_MESSAGE, string, JsonType];
24
25 export type ErrorResponse = [MessageType.CALL_ERROR_MESSAGE, string, ErrorType, string, JsonType];
26
27 export type ResponseHandler = (
28 chargingStation: ChargingStation,
29 payload: JsonType,
30 requestPayload?: JsonType
31 ) => void | Promise<void>;
32
33 export type BootNotificationResponse =
34 | OCPP16BootNotificationResponse
35 | OCPP20BootNotificationResponse;
36
37 export type HeartbeatResponse = OCPP16HeartbeatResponse;
38
39 export type StatusNotificationResponse = OCPP16StatusNotificationResponse;
40
41 export type MeterValuesResponse = OCPP16MeterValuesResponse;
42
43 export type DataTransferResponse = OCPP16DataTransferResponse;
44
45 export type DiagnosticsStatusNotificationResponse = OCPP16DiagnosticsStatusNotificationResponse;
46
47 export type FirmwareStatusNotificationResponse = OCPP16FirmwareStatusNotificationResponse;
48
49 export enum DefaultStatus {
50 ACCEPTED = 'Accepted',
51 REJECTED = 'Rejected',
52 }
53
54 export type DefaultResponse = {
55 status: DefaultStatus;
56 };
57
58 export enum RegistrationStatusEnumType {
59 ACCEPTED = 'Accepted',
60 PENDING = 'Pending',
61 REJECTED = 'Rejected',
62 }
63
64 export const AvailabilityStatus = {
65 ...OCPP16AvailabilityStatus,
66 } as const;
67 export type AvailabilityStatus = OCPP16AvailabilityStatus;
68
69 export const ChargingProfileStatus = {
70 ...OCPP16ChargingProfileStatus,
71 } as const;
72 export type ChargingProfileStatus = OCPP16ChargingProfileStatus;
73
74 export const ClearChargingProfileStatus = {
75 ...OCPP16ClearChargingProfileStatus,
76 } as const;
77 export type ClearChargingProfileStatus = OCPP16ClearChargingProfileStatus;
78
79 export const ConfigurationStatus = {
80 ...OCPP16ConfigurationStatus,
81 } as const;
82 export type ConfigurationStatus = OCPP16ConfigurationStatus;
83
84 export const UnlockStatus = {
85 ...OCPP16UnlockStatus,
86 } as const;
87 export type UnlockStatus = OCPP16UnlockStatus;
88
89 export const TriggerMessageStatus = {
90 ...OCPP16TriggerMessageStatus,
91 } as const;
92 export type TriggerMessageStatus = OCPP16TriggerMessageStatus;
93
94 export const DataTransferStatus = {
95 ...OCPP16DataTransferStatus,
96 } as const;
97 export type DataTransferStatus = OCPP16DataTransferStatus;