ocpp 0.24.1
A C++ implementation of the Open Charge Point Protocol
types.hpp
1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2020 - 2023 Pionix GmbH and Contributors to EVerest
3#ifndef OCPP_V16_TYPES_HPP
4#define OCPP_V16_TYPES_HPP
5
6#include <iostream>
7#include <sstream>
8
9#include <nlohmann/json_fwd.hpp>
10
11#include <everest/logging.hpp>
12
13#include <ocpp/common/types.hpp>
14#include <ocpp/v16/ocpp_enums.hpp>
15
16using json = nlohmann::json;
17
18namespace ocpp {
19namespace v16 {
20
22enum class MessageType {
23 Authorize,
24 AuthorizeResponse,
25 BootNotification,
26 BootNotificationResponse,
27 CancelReservation,
28 CancelReservationResponse,
29 CertificateSigned,
30 CertificateSignedResponse,
31 ChangeAvailability,
32 ChangeAvailabilityResponse,
33 ChangeConfiguration,
34 ChangeConfigurationResponse,
35 ClearCache,
36 ClearCacheResponse,
37 ClearChargingProfile,
38 ClearChargingProfileResponse,
39 DataTransfer,
40 DataTransferResponse,
41 DeleteCertificate,
42 DeleteCertificateResponse,
43 DiagnosticsStatusNotification,
44 DiagnosticsStatusNotificationResponse,
45 ExtendedTriggerMessage,
46 ExtendedTriggerMessageResponse,
47 FirmwareStatusNotification,
48 FirmwareStatusNotificationResponse,
49 GetCompositeSchedule,
50 GetCompositeScheduleResponse,
51 GetConfiguration,
52 GetConfigurationResponse,
53 GetDiagnostics,
54 GetDiagnosticsResponse,
55 GetInstalledCertificateIds,
56 GetInstalledCertificateIdsResponse,
57 GetLocalListVersion,
58 GetLocalListVersionResponse,
59 GetLog,
60 GetLogResponse,
61 Heartbeat,
62 HeartbeatResponse,
63 InstallCertificate,
64 InstallCertificateResponse,
65 LogStatusNotification,
66 LogStatusNotificationResponse,
67 MeterValues,
68 MeterValuesResponse,
69 RemoteStartTransaction,
70 RemoteStartTransactionResponse,
71 RemoteStopTransaction,
72 RemoteStopTransactionResponse,
73 ReserveNow,
74 ReserveNowResponse,
75 Reset,
76 ResetResponse,
77 SecurityEventNotification,
78 SecurityEventNotificationResponse,
79 SendLocalList,
80 SendLocalListResponse,
81 SetChargingProfile,
82 SetChargingProfileResponse,
83 SignCertificate,
84 SignCertificateResponse,
85 SignedFirmwareStatusNotification,
86 SignedFirmwareStatusNotificationResponse,
87 SignedUpdateFirmware,
88 SignedUpdateFirmwareResponse,
89 StartTransaction,
90 StartTransactionResponse,
91 StatusNotification,
92 StatusNotificationResponse,
93 StopTransaction,
94 StopTransactionResponse,
95 TriggerMessage,
96 TriggerMessageResponse,
97 UnlockConnector,
98 UnlockConnectorResponse,
99 UpdateFirmware,
100 UpdateFirmwareResponse,
101 InternalError, // not in spec, for internal use
102};
103
104namespace conversions {
107std::string messagetype_to_string(MessageType m);
108
111MessageType string_to_messagetype(const std::string& s);
112} // namespace conversions
113
116std::ostream& operator<<(std::ostream& os, const MessageType& message_type);
117
119enum SupportedFeatureProfiles {
120 Internal,
121 Core,
122 CostAndPrice,
123 FirmwareManagement,
124 LocalAuthListManagement,
125 Reservation,
126 SmartCharging,
127 RemoteTrigger,
128 Security,
129 PnC,
130 Custom
131};
132namespace conversions {
135std::string supported_feature_profiles_to_string(SupportedFeatureProfiles e);
136
139SupportedFeatureProfiles string_to_supported_feature_profiles(const std::string& s);
140} // namespace conversions
141
144std::ostream& operator<<(std::ostream& os, const SupportedFeatureProfiles& supported_feature_profiles);
145
147enum ChargePointConnectionState {
148 Disconnected, // state when disconnected
149 Connected, // state when ws is connected
150 Booted, // state when ws is connected and BootNotifcation had been Accepted
151 Pending, // state when ws is connected and state when BootNotifcation is Pending
152 Rejected, // state when ws is connected and state when BootNotifcation had been Rejected
153};
154namespace conversions {
157std::string charge_point_connection_state_to_string(ChargePointConnectionState e);
158
161ChargePointConnectionState string_to_charge_point_connection_state(const std::string& s);
162} // namespace conversions
163
166std::ostream& operator<<(std::ostream& os, const ChargePointConnectionState& charge_point_connection_state);
167
170 Measurand measurand;
171 std::optional<Phase> phase;
172
175 bool operator==(MeasurandWithPhase measurand_with_phase);
176};
177
180 Measurand measurand;
181 std::vector<Phase> phases;
182};
183
186 AvailabilityType availability;
187 bool persist;
188};
189
191enum BootReasonEnum {
192 ApplicationReset,
193 FirmwareUpdate,
194 LocalReset,
195 PowerUp,
196 RemoteReset,
197 ScheduledReset,
198 Triggered,
199 Unknown,
200 Watchdog
201};
202
205 int32_t startPeriod;
206 float limit;
207 std::optional<int32_t> numberPhases;
208 int32_t stackLevel;
209 bool periodTransformed = false; // indicates that a period was transformed from chargingRateUnit
210};
211
213void to_json(json& j, const EnhancedChargingSchedulePeriod& k);
214
216void from_json(const json& j, EnhancedChargingSchedulePeriod& k);
217
221 ChargingRateUnit chargingRateUnit;
222 std::vector<EnhancedChargingSchedulePeriod> chargingSchedulePeriod;
223 std::optional<int32_t> duration;
224 std::optional<ocpp::DateTime> startSchedule;
225 std::optional<float> minChargingRate;
226};
227
229void to_json(json& j, const EnhancedChargingSchedule& k);
230
232void from_json(const json& j, EnhancedChargingSchedule& k);
233
234} // namespace v16
235} // namespace ocpp
236
237#endif // OCPP_V16_TYPES_HPP
Combines AvailabilityType with persist flag for scheduled Availability changes.
Definition: types.hpp:185
Enhances ChargingSchedulePeriod with stackLevel.
Definition: types.hpp:204
Enhances ChargingSchedule by containing std::vector<EnhancedChargingSchedulePeriods> instead of std::...
Definition: types.hpp:220
Combines a Measurand with an optional Phase.
Definition: types.hpp:169
Measurand measurand
A OCPP Measurand.
Definition: types.hpp:170
bool operator==(MeasurandWithPhase measurand_with_phase)
Comparison operator== between this MeasurandWithPhase and the given measurand_with_phase.
Definition: types.cpp:553
std::optional< Phase > phase
If applicable and available a Phase.
Definition: types.hpp:171
Combines a Measurand with a list of Phases.
Definition: types.hpp:179
Measurand measurand
A OCPP Measurand.
Definition: types.hpp:180
std::vector< Phase > phases
A list of Phases.
Definition: types.hpp:181