-
Notifications
You must be signed in to change notification settings - Fork 58
/
Copy pathtypes.hpp
205 lines (182 loc) · 6.67 KB
/
types.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
// SPDX-License-Identifier: Apache-2.0
// Copyright 2020 - 2023 Pionix GmbH and Contributors to EVerest
#ifndef OCPP_V16_TYPES_HPP
#define OCPP_V16_TYPES_HPP
#include <iostream>
#include <sstream>
#include <nlohmann/json_fwd.hpp>
#include <everest/logging.hpp>
#include <ocpp/common/types.hpp>
#include <ocpp/v16/enums.hpp>
using json = nlohmann::json;
namespace ocpp {
namespace v16 {
/// \brief Contains all supported OCPP 1.6 message types
enum class MessageType {
Authorize,
AuthorizeResponse,
BootNotification,
BootNotificationResponse,
CancelReservation,
CancelReservationResponse,
CertificateSigned,
CertificateSignedResponse,
ChangeAvailability,
ChangeAvailabilityResponse,
ChangeConfiguration,
ChangeConfigurationResponse,
ClearCache,
ClearCacheResponse,
ClearChargingProfile,
ClearChargingProfileResponse,
DataTransfer,
DataTransferResponse,
DeleteCertificate,
DeleteCertificateResponse,
DiagnosticsStatusNotification,
DiagnosticsStatusNotificationResponse,
ExtendedTriggerMessage,
ExtendedTriggerMessageResponse,
FirmwareStatusNotification,
FirmwareStatusNotificationResponse,
GetCompositeSchedule,
GetCompositeScheduleResponse,
GetConfiguration,
GetConfigurationResponse,
GetDiagnostics,
GetDiagnosticsResponse,
GetInstalledCertificateIds,
GetInstalledCertificateIdsResponse,
GetLocalListVersion,
GetLocalListVersionResponse,
GetLog,
GetLogResponse,
Heartbeat,
HeartbeatResponse,
InstallCertificate,
InstallCertificateResponse,
LogStatusNotification,
LogStatusNotificationResponse,
MeterValues,
MeterValuesResponse,
RemoteStartTransaction,
RemoteStartTransactionResponse,
RemoteStopTransaction,
RemoteStopTransactionResponse,
ReserveNow,
ReserveNowResponse,
Reset,
ResetResponse,
SecurityEventNotification,
SecurityEventNotificationResponse,
SendLocalList,
SendLocalListResponse,
SetChargingProfile,
SetChargingProfileResponse,
SignCertificate,
SignCertificateResponse,
SignedFirmwareStatusNotification,
SignedFirmwareStatusNotificationResponse,
SignedUpdateFirmware,
SignedUpdateFirmwareResponse,
StartTransaction,
StartTransactionResponse,
StatusNotification,
StatusNotificationResponse,
StopTransaction,
StopTransactionResponse,
TriggerMessage,
TriggerMessageResponse,
UnlockConnector,
UnlockConnectorResponse,
UpdateFirmware,
UpdateFirmwareResponse,
InternalError, // not in spec, for internal use
};
namespace conversions {
/// \brief Converts the given MessageType \p m to std::string
/// \returns a string representation of the MessageType
std::string messagetype_to_string(MessageType m);
/// \brief Converts the given std::string \p s to MessageType
/// \returns a MessageType from a string representation
MessageType string_to_messagetype(const std::string& s);
} // namespace conversions
/// \brief Writes the string representation of the given \p message_type to the given output stream \p os
/// \returns an output stream with the MessageType written to
std::ostream& operator<<(std::ostream& os, const MessageType& message_type);
/// \brief Contains the supported OCPP 1.6 feature profiles
enum SupportedFeatureProfiles {
Internal,
Core,
FirmwareManagement,
LocalAuthListManagement,
Reservation,
SmartCharging,
RemoteTrigger,
Security,
PnC,
Custom
};
namespace conversions {
/// \brief Converts the given SupportedFeatureProfiles \p e to std::string
/// \returns a string representation of the SupportedFeatureProfiles
std::string supported_feature_profiles_to_string(SupportedFeatureProfiles e);
/// \brief Converts the given std::string \p s to SupportedFeatureProfiles
/// \returns a SupportedFeatureProfiles from a string representation
SupportedFeatureProfiles string_to_supported_feature_profiles(const std::string& s);
} // namespace conversions
/// \brief Writes the string representation of the given \p supported_feature_profiles to the given output stream \p os
/// \returns an output stream with the SupportedFeatureProfiles written to
std::ostream& operator<<(std::ostream& os, const SupportedFeatureProfiles& supported_feature_profiles);
/// \brief Contains the different connection states of the charge point
enum ChargePointConnectionState {
Disconnected, // state when disconnected
Connected, // state when ws is connected
Booted, // state when ws is connected and BootNotifcation had been Accepted
Pending, // state when ws is connected and state when BootNotifcation is Pending
Rejected, // state when ws is connected and state when BootNotifcation had been Rejected
};
namespace conversions {
/// \brief Converts the given ChargePointConnectionState \p e to std::string
/// \returns a string representation of the ChargePointConnectionState
std::string charge_point_connection_state_to_string(ChargePointConnectionState e);
/// \brief Converts the given std::string \p s to ChargePointConnectionState
/// \returns a ChargePointConnectionState from a string representation
ChargePointConnectionState string_to_charge_point_connection_state(const std::string& s);
} // namespace conversions
/// \brief Writes the string representation of the given \p charge_point_connection_state
/// to the given output stream \p os \returns an output stream with the ChargePointConnectionState written to
std::ostream& operator<<(std::ostream& os, const ChargePointConnectionState& charge_point_connection_state);
/// \brief Combines a Measurand with an optional Phase
struct MeasurandWithPhase {
Measurand measurand; ///< A OCPP Measurand
std::optional<Phase> phase; ///< If applicable and available a Phase
/// \brief Comparison operator== between this MeasurandWithPhase and the given \p measurand_with_phase
/// \returns true when measurand and phase are equal
bool operator==(MeasurandWithPhase measurand_with_phase);
};
/// \brief Combines a Measurand with a list of Phases
struct MeasurandWithPhases {
Measurand measurand; ///< A OCPP Measurand
std::vector<Phase> phases; ///< A list of Phases
};
/// \brief Combines AvailabilityType with persist flag for scheduled Availability changes
struct AvailabilityChange {
AvailabilityType availability;
bool persist;
};
/// \brief BootReasonEnum contains the different boot reasons of the charge point (copied from OCPP2.0.1 definition)
enum BootReasonEnum {
ApplicationReset,
FirmwareUpdate,
LocalReset,
PowerUp,
RemoteReset,
ScheduledReset,
Triggered,
Unknown,
Watchdog
};
} // namespace v16
} // namespace ocpp
#endif // OCPP_V16_TYPES_HPP