Merge pull request #1041 from syuusei3/issue39-ocpp2
[e-mobility-charging-stations-simulator.git] / src / types / ocpp / Responses.ts
... / ...
CommitLineData
1import type { ChargingStation } from '../../charging-station/index.js'
2import type { JsonType } from '../JsonType.js'
3import type { OCPP16MeterValuesResponse } from './1.6/MeterValues.js'
4import {
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 OCPP16ReservationStatus,
16 type OCPP16StatusNotificationResponse,
17 OCPP16TriggerMessageStatus,
18 OCPP16UnlockStatus
19} from './1.6/Responses.js'
20import type { OCPP20BootNotificationResponse, OCPP20ClearCacheResponse } from './2.0/Responses.js'
21import { type GenericResponse, GenericStatus } from './Common.js'
22import type { ErrorType } from './ErrorType.js'
23import type { MessageType } from './MessageType.js'
24
25export type Response = [MessageType.CALL_RESULT_MESSAGE, string, JsonType]
26
27export type ErrorResponse = [MessageType.CALL_ERROR_MESSAGE, string, ErrorType, string, JsonType]
28
29export type ResponseHandler = (
30 chargingStation: ChargingStation,
31 payload: JsonType,
32 requestPayload?: JsonType
33) => void | Promise<void>
34
35export type BootNotificationResponse =
36 | OCPP16BootNotificationResponse
37 | OCPP20BootNotificationResponse
38
39export type HeartbeatResponse = OCPP16HeartbeatResponse
40
41export type ClearCacheResponse = GenericResponse | OCPP20ClearCacheResponse
42
43export type StatusNotificationResponse = OCPP16StatusNotificationResponse
44
45export type MeterValuesResponse = OCPP16MeterValuesResponse
46
47export type DataTransferResponse = OCPP16DataTransferResponse
48
49export type DiagnosticsStatusNotificationResponse = OCPP16DiagnosticsStatusNotificationResponse
50
51export type FirmwareStatusNotificationResponse = OCPP16FirmwareStatusNotificationResponse
52
53export const AvailabilityStatus = {
54 ...OCPP16AvailabilityStatus
55} as const
56// eslint-disable-next-line @typescript-eslint/no-redeclare
57export type AvailabilityStatus = OCPP16AvailabilityStatus
58
59export const ChargingProfileStatus = {
60 ...OCPP16ChargingProfileStatus
61} as const
62// eslint-disable-next-line @typescript-eslint/no-redeclare
63export type ChargingProfileStatus = OCPP16ChargingProfileStatus
64
65export const ClearChargingProfileStatus = {
66 ...OCPP16ClearChargingProfileStatus
67} as const
68// eslint-disable-next-line @typescript-eslint/no-redeclare
69export type ClearChargingProfileStatus = OCPP16ClearChargingProfileStatus
70
71export const ConfigurationStatus = {
72 ...OCPP16ConfigurationStatus
73} as const
74// eslint-disable-next-line @typescript-eslint/no-redeclare
75export type ConfigurationStatus = OCPP16ConfigurationStatus
76
77export const UnlockStatus = {
78 ...OCPP16UnlockStatus
79} as const
80// eslint-disable-next-line @typescript-eslint/no-redeclare
81export type UnlockStatus = OCPP16UnlockStatus
82
83export const TriggerMessageStatus = {
84 ...OCPP16TriggerMessageStatus
85} as const
86// eslint-disable-next-line @typescript-eslint/no-redeclare
87export type TriggerMessageStatus = OCPP16TriggerMessageStatus
88
89export const DataTransferStatus = {
90 ...OCPP16DataTransferStatus
91} as const
92// eslint-disable-next-line @typescript-eslint/no-redeclare
93export type DataTransferStatus = OCPP16DataTransferStatus
94
95export type ReservationStatus = OCPP16ReservationStatus
96// eslint-disable-next-line @typescript-eslint/no-redeclare
97export const ReservationStatus = {
98 ...OCPP16ReservationStatus
99} as const
100
101export type CancelReservationStatus = GenericStatus
102// eslint-disable-next-line @typescript-eslint/no-redeclare
103export const CancelReservationStatus = {
104 ...GenericStatus
105} as const
106
107export type CancelReservationResponse = GenericResponse