fix: use nextTick to delay event emission
[e-mobility-charging-stations-simulator.git] / src / charging-station / ocpp / OCPPConstants.ts
1 import {
2 AvailabilityStatus,
3 ChargingProfileStatus,
4 ClearChargingProfileStatus,
5 ConfigurationStatus,
6 DataTransferStatus,
7 GenericStatus,
8 MeterValueMeasurand,
9 ReservationStatus,
10 TriggerMessageStatus,
11 UnlockStatus
12 } from '../../types/index.js'
13 import { Constants } from '../../utils/index.js'
14
15 // eslint-disable-next-line @typescript-eslint/no-extraneous-class
16 export class OCPPConstants {
17 static readonly OCPP_WEBSOCKET_TIMEOUT = 60000 // Ms
18
19 static readonly OCPP_MEASURANDS_SUPPORTED = Object.freeze([
20 MeterValueMeasurand.STATE_OF_CHARGE,
21 MeterValueMeasurand.VOLTAGE,
22 MeterValueMeasurand.POWER_ACTIVE_IMPORT,
23 MeterValueMeasurand.CURRENT_IMPORT,
24 MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER
25 ])
26
27 static readonly OCPP_REQUEST_EMPTY = Constants.EMPTY_FROZEN_OBJECT
28 static readonly OCPP_RESPONSE_EMPTY = Constants.EMPTY_FROZEN_OBJECT
29 static readonly OCPP_RESPONSE_ACCEPTED = Object.freeze({ status: GenericStatus.Accepted })
30 static readonly OCPP_RESPONSE_REJECTED = Object.freeze({ status: GenericStatus.Rejected })
31
32 static readonly OCPP_CONFIGURATION_RESPONSE_ACCEPTED = Object.freeze({
33 status: ConfigurationStatus.ACCEPTED
34 })
35
36 static readonly OCPP_CONFIGURATION_RESPONSE_REJECTED = Object.freeze({
37 status: ConfigurationStatus.REJECTED
38 })
39
40 static readonly OCPP_CONFIGURATION_RESPONSE_REBOOT_REQUIRED = Object.freeze({
41 status: ConfigurationStatus.REBOOT_REQUIRED
42 })
43
44 static readonly OCPP_CONFIGURATION_RESPONSE_NOT_SUPPORTED = Object.freeze({
45 status: ConfigurationStatus.NOT_SUPPORTED
46 })
47
48 static readonly OCPP_SET_CHARGING_PROFILE_RESPONSE_ACCEPTED = Object.freeze({
49 status: ChargingProfileStatus.ACCEPTED
50 })
51
52 static readonly OCPP_SET_CHARGING_PROFILE_RESPONSE_REJECTED = Object.freeze({
53 status: ChargingProfileStatus.REJECTED
54 })
55
56 static readonly OCPP_SET_CHARGING_PROFILE_RESPONSE_NOT_SUPPORTED = Object.freeze({
57 status: ChargingProfileStatus.NOT_SUPPORTED
58 })
59
60 static readonly OCPP_CLEAR_CHARGING_PROFILE_RESPONSE_ACCEPTED = Object.freeze({
61 status: ClearChargingProfileStatus.ACCEPTED
62 })
63
64 static readonly OCPP_CLEAR_CHARGING_PROFILE_RESPONSE_UNKNOWN = Object.freeze({
65 status: ClearChargingProfileStatus.UNKNOWN
66 })
67
68 static readonly OCPP_RESPONSE_UNLOCKED = Object.freeze({ status: UnlockStatus.UNLOCKED })
69 static readonly OCPP_RESPONSE_UNLOCK_FAILED = Object.freeze({
70 status: UnlockStatus.UNLOCK_FAILED
71 })
72
73 static readonly OCPP_RESPONSE_UNLOCK_NOT_SUPPORTED = Object.freeze({
74 status: UnlockStatus.NOT_SUPPORTED
75 })
76
77 static readonly OCPP_AVAILABILITY_RESPONSE_ACCEPTED = Object.freeze({
78 status: AvailabilityStatus.ACCEPTED
79 })
80
81 static readonly OCPP_AVAILABILITY_RESPONSE_REJECTED = Object.freeze({
82 status: AvailabilityStatus.REJECTED
83 })
84
85 static readonly OCPP_AVAILABILITY_RESPONSE_SCHEDULED = Object.freeze({
86 status: AvailabilityStatus.SCHEDULED
87 })
88
89 static readonly OCPP_TRIGGER_MESSAGE_RESPONSE_ACCEPTED = Object.freeze({
90 status: TriggerMessageStatus.ACCEPTED
91 })
92
93 static readonly OCPP_TRIGGER_MESSAGE_RESPONSE_REJECTED = Object.freeze({
94 status: TriggerMessageStatus.REJECTED
95 })
96
97 static readonly OCPP_TRIGGER_MESSAGE_RESPONSE_NOT_IMPLEMENTED = Object.freeze({
98 status: TriggerMessageStatus.NOT_IMPLEMENTED
99 })
100
101 static readonly OCPP_DATA_TRANSFER_RESPONSE_ACCEPTED = Object.freeze({
102 status: DataTransferStatus.ACCEPTED
103 })
104
105 static readonly OCPP_DATA_TRANSFER_RESPONSE_REJECTED = Object.freeze({
106 status: DataTransferStatus.REJECTED
107 })
108
109 static readonly OCPP_DATA_TRANSFER_RESPONSE_UNKNOWN_VENDOR_ID = Object.freeze({
110 status: DataTransferStatus.UNKNOWN_VENDOR_ID
111 })
112
113 static readonly OCPP_RESERVATION_RESPONSE_ACCEPTED = Object.freeze({
114 status: ReservationStatus.ACCEPTED
115 }) // Reservation has been made
116
117 static readonly OCPP_RESERVATION_RESPONSE_FAULTED = Object.freeze({
118 status: ReservationStatus.FAULTED
119 }) // Reservation has not been made, because of connector in FAULTED state
120
121 static readonly OCPP_RESERVATION_RESPONSE_OCCUPIED = Object.freeze({
122 status: ReservationStatus.OCCUPIED
123 }) // Reservation has not been made, because all connectors are OCCUPIED
124
125 static readonly OCPP_RESERVATION_RESPONSE_REJECTED = Object.freeze({
126 status: ReservationStatus.REJECTED
127 }) // Reservation has not been made, because charging station is not configured to accept reservations
128
129 static readonly OCPP_RESERVATION_RESPONSE_UNAVAILABLE = Object.freeze({
130 status: ReservationStatus.UNAVAILABLE
131 }) // Reservation has not been made, because connector is in UNAVAILABLE state
132
133 static readonly OCPP_CANCEL_RESERVATION_RESPONSE_ACCEPTED = Object.freeze({
134 status: GenericStatus.Accepted
135 }) // Reservation for id has been cancelled
136
137 static readonly OCPP_CANCEL_RESERVATION_RESPONSE_REJECTED = Object.freeze({
138 status: GenericStatus.Rejected
139 }) // Reservation could not be cancelled, because there is no reservation active for id
140
141 protected constructor () {
142 // This is intentional
143 }
144 }