ocpp 0.24.1
A C++ implementation of the Open Charge Point Protocol
types.hpp
1// SPDX-License-Identifier: Apache-2.0
2// Copyright Pionix GmbH and Contributors to EVerest
3
4#ifndef OCPP_COMMON_TYPES_HPP
5#define OCPP_COMMON_TYPES_HPP
6
7#include <chrono>
8#include <cstddef>
9#include <iostream>
10#include <optional>
11#include <sstream>
12#include <stdexcept>
13#include <string>
14
15#include <nlohmann/json_fwd.hpp>
16
17#include <date/date.h>
18#include <date/tz.h>
19
20#include <ocpp/common/cistring.hpp>
21#include <ocpp/common/support_older_cpp_versions.hpp>
22#include <ocpp/v16/ocpp_enums.hpp>
23#include <ocpp/v2/ocpp_enums.hpp>
24
25using json = nlohmann::json;
26
27namespace ocpp {
28
30struct Message {
33 virtual std::string get_type() const = 0;
34};
35
37class TimePointParseException : public std::exception {
38public:
39 explicit TimePointParseException(const std::string& timepoint_str) :
40 msg{"Timepoint string parsing failed. Could not convert: \"" + timepoint_str + "\" into DateTime."} {
41 }
42
43 const char* what() const noexcept override {
44 return msg.c_str();
45 }
46
47private:
48 std::string msg;
49};
50
53private:
54 std::chrono::time_point<date::utc_clock> timepoint;
55
56public:
59
60 ~DateTimeImpl() = default;
61
63 explicit DateTimeImpl(std::chrono::time_point<date::utc_clock> timepoint);
64
66 explicit DateTimeImpl(const std::string& timepoint_str);
67
70 std::string to_rfc3339() const;
71
73 void from_rfc3339(const std::string& timepoint_str);
74
77 std::chrono::time_point<date::utc_clock> to_time_point() const;
78
81
84 operator std::string() {
85 return this->to_rfc3339();
86 }
87
90 friend std::ostream& operator<<(std::ostream& os, const DateTimeImpl& dt);
91
93 friend bool operator>(const DateTimeImpl& lhs, const DateTimeImpl& rhs);
94
96 friend bool operator>=(const DateTimeImpl& lhs, const DateTimeImpl& rhs);
97
99 friend bool operator<(const DateTimeImpl& lhs, const DateTimeImpl& rhs);
100
102 friend bool operator<=(const DateTimeImpl& lhs, const DateTimeImpl& rhs);
103
105 friend bool operator==(const DateTimeImpl& lhs, const DateTimeImpl& rhs);
106};
107
109class DateTime : public DateTimeImpl {
110public:
112 DateTime();
113
114 ~DateTime() = default;
115
117 explicit DateTime(std::chrono::time_point<date::utc_clock> timepoint);
118
120 explicit DateTime(const std::string& timepoint_str);
121};
122
124class EnumConversionException : public std::out_of_range {
125public:
126 using std::out_of_range::out_of_range;
127};
128
131public:
135 template <typename T>
136 explicit EnumToStringException(T enumValue, std::string_view type) :
137 EnumConversionException{std::string{"No known conversion from value '"} +
138 std::to_string(static_cast<int>(enumValue)) + "' to " + type.data()} {
139 }
140};
141
144public:
148 StringToEnumException(std::string_view str, std::string_view type) :
149 EnumConversionException{std::string{"Provided string '"} + str.data() + "' could not be converted to " +
150 type.data()} {
151 }
152};
153
155enum SessionStartedReason {
156 EVConnected,
157 Authorized
158};
159namespace conversions {
162std::string session_started_reason_to_string(SessionStartedReason e);
163
166SessionStartedReason string_to_session_started_reason(const std::string& s);
167} // namespace conversions
168
171std::ostream& operator<<(std::ostream& os, const SessionStartedReason& session_started_reason);
172
173struct Current {
174 std::optional<float> DC;
175 std::optional<float> L1;
176 std::optional<float> L2;
177 std::optional<float> L3;
178 std::optional<float> N;
179
181 friend void to_json(json& j, const Current& k);
182
184 friend void from_json(const json& j, Current& k);
185
186 // \brief Writes the string representation of the given Current \p k to the given output stream \p os
188 friend std::ostream& operator<<(std::ostream& os, const Current& k);
189};
190struct Voltage {
191 std::optional<float> DC;
192 std::optional<float> L1;
193 std::optional<float> L2;
194 std::optional<float> L3;
195
197 friend void to_json(json& j, const Voltage& k);
198
200 friend void from_json(const json& j, Voltage& k);
201
202 // \brief Writes the string representation of the given Voltage \p k to the given output stream \p os
204 friend std::ostream& operator<<(std::ostream& os, const Voltage& k);
205};
206struct Frequency {
207 float L1;
208 std::optional<float> L2;
209 std::optional<float> L3;
210
212 friend void to_json(json& j, const Frequency& k);
213
215 friend void from_json(const json& j, Frequency& k);
216
217 // \brief Writes the string representation of the given Frequency \p k to the given output stream \p os
219 friend std::ostream& operator<<(std::ostream& os, const Frequency& k);
220};
221struct Power {
222 float total;
223 std::optional<float> L1;
224 std::optional<float> L2;
225 std::optional<float> L3;
226
228 friend void to_json(json& j, const Power& k);
229
231 friend void from_json(const json& j, Power& k);
232
233 // \brief Writes the string representation of the given Power \p k to the given output stream \p os
235 friend std::ostream& operator<<(std::ostream& os, const Power& k);
236};
237struct Energy {
238 float total;
239 std::optional<float> L1;
240 std::optional<float> L2;
241 std::optional<float> L3;
242
244 friend void to_json(json& j, const Energy& k);
245
247 friend void from_json(const json& j, Energy& k);
248
249 // \brief Writes the string representation of the given Energy \p k to the given output stream \p os
251 friend std::ostream& operator<<(std::ostream& os, const Energy& k);
252};
254 float total;
255 std::optional<float> VARphA;
256 std::optional<float> VARphB;
257 std::optional<float> VARphC;
258
260 friend void to_json(json& j, const ReactivePower& k);
261
263 friend void from_json(const json& j, ReactivePower& k);
264
265 // \brief Writes the string representation of the given ReactivePower \p k to the given output stream \p os
267 friend std::ostream& operator<<(std::ostream& os, const ReactivePower& k);
268};
269
271 std::string timestamp;
273 std::optional<std::string> meter_id;
274 std::optional<bool> phase_seq_error;
275 std::optional<Energy> energy_Wh_export;
276 std::optional<Power>
278 std::optional<Voltage> voltage_V;
279 std::optional<ReactivePower> VAR;
280 std::optional<Current> current_A;
281 std::optional<Frequency> frequency_Hz;
282
284 friend void to_json(json& j, const Powermeter& k);
285
287 friend void from_json(const json& j, Powermeter& k);
288
289 // \brief Writes the string representation of the given Powermeter \p k to the given output stream \p os
291 friend std::ostream& operator<<(std::ostream& os, const Powermeter& k);
292};
293
295 float value;
296 std::optional<std::string> location;
297
299 friend void to_json(json& j, const StateOfCharge& k);
300
302 friend void from_json(const json& j, StateOfCharge& k);
303
304 // \brief Writes the string representation of the given StateOfCharge \p k to the given output stream \p os
306 friend std::ostream& operator<<(std::ostream& os, const StateOfCharge& k);
307};
308
310 float value;
311 std::optional<std::string> location;
312
314 friend void to_json(json& j, const Temperature& k);
315
317 friend void from_json(const json& j, Temperature& k);
318
319 // \brief Writes the string representation of the given Temperature \p k to the given output stream \p os
321 friend std::ostream& operator<<(std::ostream& os, const Temperature& k);
322};
323
324struct RPM {
325 float value;
326 std::optional<std::string> location;
327
329 friend void to_json(json& j, const RPM& k);
330
332 friend void from_json(const json& j, RPM& k);
333
334 // \brief Writes the string representation of the given RPM \p k to the given output stream \p os
336 friend std::ostream& operator<<(std::ostream& os, const RPM& k);
337};
338
341 std::optional<StateOfCharge> soc_Percent;
342 std::vector<Temperature> temperature_C;
343 std::optional<RPM> rpm;
344
346 friend void to_json(json& j, const Measurement& k);
347
349 friend void from_json(const json& j, Measurement& k);
350
351 // \brief Writes the string representation of the given Measurement \p k to the given output stream \p os
353 friend std::ostream& operator<<(std::ostream& os, const Measurement& k);
354};
355
357 std::string message;
358 std::optional<std::string> language;
359 std::optional<v2::MessageFormatEnum> message_format;
360
361 friend void from_json(const json& j, DisplayMessageContent& m);
362 friend void to_json(json& j, const DisplayMessageContent& m);
363};
364
368enum class IdentifierType {
369 SessionId,
370 IdToken,
371 TransactionId
372};
373
375 std::optional<int32_t> id;
376 std::optional<v2::MessagePriorityEnum> priority;
377 std::optional<v2::MessageStateEnum> state;
378 std::optional<DateTime> timestamp_from;
379 std::optional<DateTime> timestamp_to;
380 std::optional<std::string> identifier_id;
381 std::optional<IdentifierType> identifier_type;
382 DisplayMessageContent message;
383 std::optional<std::string> qr_code;
384};
385
387 std::optional<double> kWh_price;
388 std::optional<double> hour_price;
389 std::optional<double> flat_fee;
390
391 friend void from_json(const json& j, RunningCostChargingPrice& c);
392 friend void to_json(json& j, const RunningCostChargingPrice& c);
393};
394
396 std::optional<uint32_t> idle_grace_minutes;
397 std::optional<double> idle_hour_price;
398
399 friend void from_json(const json& j, RunningCostIdlePrice& c);
400 friend void to_json(json& j, const RunningCostIdlePrice& c);
401};
402
403enum class RunningCostState {
404 Charging,
405 Idle,
406 Finished
407};
408
409namespace conversions {
410RunningCostState string_to_running_cost_state(const std::string& state);
411std::string running_cost_state_to_string(const RunningCostState& state);
412} // namespace conversions
413
415 std::string transaction_id;
416 std::optional<DateTime> timestamp;
417 std::optional<uint32_t> meter_value;
418 double cost;
419 // Running cost state: "Charging" or "Idle". When this is the final price, state will be "Finished".
420 RunningCostState state;
421 std::optional<RunningCostChargingPrice> charging_price;
422 std::optional<RunningCostIdlePrice> idle_price;
423 std::optional<DateTime> next_period_at_time;
424 std::optional<RunningCostChargingPrice> next_period_charging_price;
425 std::optional<RunningCostIdlePrice> next_period_idle_price;
426 std::optional<std::vector<DisplayMessageContent>> cost_messages;
427 std::optional<std::string> qr_code_text;
428
429 friend void from_json(const json& j, RunningCost& c);
430};
431
433 std::optional<DateTime> at_time;
434 std::optional<int> at_energy_kwh;
435 std::optional<int> at_power_kw;
436 std::vector<v16::ChargePointStatus> at_chargepoint_status;
437
438 friend void from_json(const json& j, TriggerMeterValue& t);
439};
440
441enum class CaCertificateType {
442 V2G,
443 MO,
444 CSMS,
445 MF
446};
447
448namespace conversions {
451std::string ca_certificate_type_to_string(CaCertificateType e);
452
455CaCertificateType string_to_ca_certificate_type(const std::string& s);
456} // namespace conversions
457
462std::ostream& operator<<(std::ostream& os, const CaCertificateType& ca_certificate_type);
463
464enum class CertificateValidationResult {
465 Valid,
466 Expired,
467 InvalidSignature,
468 IssuerNotFound,
469 InvalidLeafSignature,
470 InvalidChain,
471 Unknown,
472};
473
474namespace conversions {
477std::string certificate_validation_result_to_string(CertificateValidationResult e);
478
481CertificateValidationResult string_to_certificate_validation_result(const std::string& s);
482} // namespace conversions
483
487std::ostream& operator<<(std::ostream& os, const CertificateValidationResult& certificate_validation_result);
488
489enum class InstallCertificateResult {
490 InvalidSignature,
491 InvalidCertificateChain,
492 InvalidFormat,
493 InvalidCommonName,
494 NoRootCertificateInstalled,
495 Expired,
496 CertificateStoreMaxLengthExceeded,
497 WriteError,
498 Accepted
499};
500
501namespace conversions {
504std::string install_certificate_result_to_string(InstallCertificateResult e);
505
508InstallCertificateResult string_to_install_certificate_result(const std::string& s);
509} // namespace conversions
510
514std::ostream& operator<<(std::ostream& os, const InstallCertificateResult& install_certificate_result);
515
516enum class DeleteCertificateResult {
517 Accepted,
518 Failed,
519 NotFound,
520};
521
522namespace conversions {
525std::string delete_certificate_result_to_string(DeleteCertificateResult e);
526
529DeleteCertificateResult string_to_delete_certificate_result(const std::string& s);
530} // namespace conversions
531
535std::ostream& operator<<(std::ostream& os, const DeleteCertificateResult& delete_certificate_result);
536
537// from: GetInstalledCertificateIdsResponse
538enum class HashAlgorithmEnumType {
539 SHA256,
540 SHA384,
541 SHA512,
542};
543
544namespace conversions {
547std::string hash_algorithm_enum_type_to_string(HashAlgorithmEnumType e);
548
551HashAlgorithmEnumType string_to_hash_algorithm_enum_type(const std::string& s);
552} // namespace conversions
553
556std::ostream& operator<<(std::ostream& os, const HashAlgorithmEnumType& hash_algorithm_enum_type);
557
559 HashAlgorithmEnumType hashAlgorithm;
560 CiString<128> issuerNameHash;
561 CiString<128> issuerKeyHash;
562 CiString<40> serialNumber;
563};
565void to_json(json& j, const CertificateHashDataType& k);
566
568void from_json(const json& j, CertificateHashDataType& k);
569
570// \brief Writes the string representation of the given CertificateHashDataType \p k to the given output stream \p os
572std::ostream& operator<<(std::ostream& os, const CertificateHashDataType& k);
573
574enum class CertificateType {
575 V2GRootCertificate,
576 MORootCertificate,
577 CSMSRootCertificate,
578 V2GCertificateChain,
579 MFRootCertificate,
580};
581
582namespace conversions {
585std::string certificate_type_to_string(CertificateType e);
586
589CertificateType string_to_certificate_type(const std::string& s);
590} // namespace conversions
591
594std::ostream& operator<<(std::ostream& os, const CertificateType& ceritficate_type);
595
597 CertificateHashDataType certificateHashData;
598 CertificateType certificateType;
599 std::optional<std::vector<CertificateHashDataType>> childCertificateHashData;
600};
602void to_json(json& j, const CertificateHashDataChain& k);
603
605void from_json(const json& j, CertificateHashDataChain& k);
606
607// \brief Writes the string representation of the given CertificateHashDataChain \p k to the given output stream \p os
609std::ostream& operator<<(std::ostream& os, const CertificateHashDataChain& k);
610
611enum class OcppProtocolVersion {
612 v16,
613 v201,
614 v21,
615 Unknown,
616};
617
618namespace conversions {
621std::string ocpp_protocol_version_to_string(OcppProtocolVersion e);
622
625OcppProtocolVersion string_to_ocpp_protocol_version(const std::string& s);
626} // namespace conversions
627
631std::ostream& operator<<(std::ostream& os, const OcppProtocolVersion& ocpp_protocol_version);
632
633enum class CertificateSigningUseEnum {
634 ChargingStationCertificate,
635 V2GCertificate,
636 ManufacturerCertificate
637};
638
639namespace conversions {
642std::string certificate_signing_use_enum_to_string(CertificateSigningUseEnum e);
643
646CertificateSigningUseEnum string_to_certificate_signing_use_enum(const std::string& s);
647} // namespace conversions
648
651std::ostream& operator<<(std::ostream& os, const CertificateSigningUseEnum& certificate_signing_use_enum);
652
655 HashAlgorithmEnumType hashAlgorithm;
656 std::string issuerNameHash;
657 std::string issuerKeyHash;
658 std::string serialNumber;
659 std::string responderUrl;
660};
661
662enum class GetCertificateSignRequestStatus {
663 Accepted,
664 InvalidRequestedType,
665 KeyGenError,
666 GenerationError,
667};
668
669enum class GetCertificateInfoStatus {
670 Accepted,
671 Rejected,
672 NotFound,
673 NotFoundValid,
674 PrivateKeyNotFound,
675};
676
678 GetCertificateSignRequestStatus status;
679 std::optional<std::string> csr;
680};
681
684 std::optional<fs::path> ocsp_path;
685};
686
688 std::optional<fs::path> certificate_path; // path to the full certificate chain
689 std::optional<fs::path> certificate_single_path; // path to the single leaf certificate
690 int certificate_count; // count of certs in the chain
691 fs::path key_path; // path to private key of the leaf certificate
692 std::optional<std::string> password; // optional password for the private key
693 std::vector<CertificateOCSP> ocsp; // OCSP data if requested
694};
695
697 GetCertificateInfoStatus status;
698 std::optional<CertificateInfo> info;
699};
700
701enum class LeafCertificateType {
702 CSMS, // Charging Station Management System
703 V2G, // Vehicle to grid
704 MF, // Manufacturer
705 MO // Mobility Operator
706};
707
708namespace conversions {
711std::string bool_to_string(bool b);
712
715bool string_to_bool(const std::string& s);
716
719std::string double_to_string(double d, int precision);
720
723std::string double_to_string(double d);
724} // namespace conversions
725
726enum class FirmwareStatusNotification {
727 Downloaded,
728 DownloadFailed,
729 Downloading,
730 DownloadScheduled,
731 DownloadPaused,
732 Idle,
733 InstallationFailed,
734 Installing,
735 Installed,
736 InstallRebooting,
737 InstallScheduled,
738 InstallVerificationFailed,
739 InvalidSignature,
740 SignatureVerified
741};
742
743namespace conversions {
745std::string generate_certificate_signing_request_status_to_string(const GetCertificateSignRequestStatus status);
746} // namespace conversions
747
748namespace conversions {
749
751v16::FirmwareStatus firmware_status_notification_to_firmware_status(const FirmwareStatusNotification status);
752
754v16::FirmwareStatusEnumType
755firmware_status_notification_to_firmware_status_enum_type(const FirmwareStatusNotification status);
756
757} // namespace conversions
758
759namespace security {
760// The security profiles defined in OCPP 2.0.1 resp. in the OCPP 1.6 security-whitepaper.
761enum SecurityProfile { // no "enum class" because values are used in implicit `switch`-comparisons to `int
762 // security_profile`
763 OCPP_1_6_ONLY_UNSECURED_TRANSPORT_WITHOUT_BASIC_AUTHENTICATION = 0,
764 UNSECURED_TRANSPORT_WITH_BASIC_AUTHENTICATION = 1,
765 TLS_WITH_BASIC_AUTHENTICATION = 2,
766 TLS_WITH_CLIENT_SIDE_CERTIFICATES = 3,
767};
768} // namespace security
769
770namespace security_events {
771
772// This is the list of security events defined in OCPP 2.0.1 (and the 1.6 security whitepper).
773// Security events that are marked critical should be pushed to the CSMS.
774// This is a non-exhaustive list of security events, when a security event matches the description in the OCPP
775// specification of one of the Security Events in this list, for interoperability reasons, the Security Event from this
776// list shall be used, instead of adding a new (proprietary) Security Event.
777
778inline const std::string FIRMWARE_UPDATED = "FirmwareUpdated"; // CRITICAL
779inline const std::string FAILEDTOAUTHENTICATEATCSMS = "FailedToAuthenticateAtCsms";
780inline const std::string CSMSFAILEDTOAUTHENTICATE = "CsmsFailedToAuthenticate";
781inline const std::string CSRGENERATIONFAILED = "CSRGenerationFailed";
782inline const std::string SETTINGSYSTEMTIME = "SettingSystemTime"; // CRITICAL
783inline const std::string RESET_OR_REBOOT = "ResetOrReboot"; // CRITICAL
784inline const std::string STARTUP_OF_THE_DEVICE = "StartupOfTheDevice"; // CRITICAL
785inline const std::string SECURITYLOGWASCLEARED = "SecurityLogWasCleared"; // CRITICAL
786inline const std::string RECONFIGURATIONOFSECURITYPARAMETERS = "ReconfigurationOfSecurityParameters";
787inline const std::string MEMORYEXHAUSTION = "MemoryExhaustion"; // CRITICAL
788inline const std::string INVALIDMESSAGES = "InvalidMessages";
789inline const std::string ATTEMPTEDREPLAYATTACKS = "AttemptedReplayAttacks";
790inline const std::string TAMPERDETECTIONACTIVATED = "TamperDetectionActivated"; // CRITICAL
791inline const std::string INVALIDFIRMWARESIGNATURE = "InvalidFirmwareSignature";
792inline const std::string INVALIDFIRMWARESIGNINGCERTIFICATE = "InvalidFirmwareSigningCertificate";
793inline const std::string INVALIDCSMSCERTIFICATE = "InvalidCsmsCertificate";
794inline const std::string INVALIDCENTRALSYSTEMCERTIFICATE = "InvalidCentralSystemCertificate";
795inline const std::string INVALIDCHARGINGSTATIONCERTIFICATE = "InvalidChargingStationCertificate";
796inline const std::string INVALIDCHARGEPOINTCERTIFICATE = "InvalidChargePointCertificate"; // for OCPP1.6
797inline const std::string INVALIDTLSVERSION = "InvalidTLSVersion";
798inline const std::string INVALIDTLSCIPHERSUITE = "InvalidTLSCipherSuite";
799inline const std::string MAINTENANCELOGINACCEPTED = "MaintenanceLoginAccepted";
800inline const std::string MAINTENANCELOGINFAILED = "MaintenanceLoginFailed";
801} // namespace security_events
802
803enum class MessageDirection {
804 CSMSToChargingStation,
805 ChargingStationToCSMS
806};
807
808enum class ConnectionFailedReason {
809 InvalidCSMSCertificate = 0,
810 FailedToAuthenticateAtCsms
811};
812
816enum class WebsocketCloseReason : uint8_t {
818 Normal = 1,
819 ForceTcpDrop,
820 GoingAway,
821 AbnormalClose,
822 ServiceRestart
823};
824
826enum class QueueType {
827 Normal,
828 Transaction,
829 None,
830};
831
834 int32_t amps;
835 int32_t watts;
836 int32_t number_phases;
837};
838
840enum class ReservationCheckStatus {
841 NotReserved,
842 ReservedForToken,
843 ReservedForOtherToken,
845 ReservedForOtherTokenAndHasParentToken,
846};
847
848} // namespace ocpp
849
850#endif
Contains a DateTime implementation that can parse and create RFC 3339 compatible strings.
Definition: types.hpp:52
friend bool operator<(const DateTimeImpl &lhs, const DateTimeImpl &rhs)
Comparison operator< between two DateTimeImpl lhs and rhs.
Definition: types.cpp:74
std::chrono::time_point< date::utc_clock > to_time_point() const
Converts this DateTimeImpl to a std::chrono::time_point.
Definition: types.cpp:52
friend bool operator<=(const DateTimeImpl &lhs, const DateTimeImpl &rhs)
Comparison operator<= between two DateTimeImpl lhs and rhs.
Definition: types.cpp:78
void from_rfc3339(const std::string &timepoint_str)
Sets the timepoint of this DateTimeImpl to the given timepoint_str.
Definition: types.cpp:34
friend bool operator==(const DateTimeImpl &lhs, const DateTimeImpl &rhs)
Comparison operator== between two DateTimeImpl lhs and rhs.
Definition: types.cpp:82
friend bool operator>=(const DateTimeImpl &lhs, const DateTimeImpl &rhs)
Comparison operator>= between two DateTimeImpl lhs and rhs.
Definition: types.cpp:70
std::string to_rfc3339() const
Converts this DateTimeImpl to a RFC 3339 compatible string.
Definition: types.cpp:30
DateTimeImpl()
Creates a new DateTimeImpl object with the current utc time.
Definition: types.cpp:19
friend std::ostream & operator<<(std::ostream &os, const DateTimeImpl &dt)
Writes the given DateTimeImpl dt to the given output stream os as a RFC 3339 compatible string.
Definition: types.cpp:61
DateTimeImpl & operator=(const DateTimeImpl &dt)
Assignment operator= to assign another DateTimeImpl dt to this DateTimeImpl.
Definition: types.cpp:56
friend bool operator>(const DateTimeImpl &lhs, const DateTimeImpl &rhs)
Comparison operator> between two DateTimeImpl lhs and rhs.
Definition: types.cpp:66
Contains a DateTime implementation that can parse and create RFC 3339 compatible strings.
Definition: types.hpp:109
DateTime()
Creates a new DateTime object with the current system time.
Definition: types.cpp:10
Base exception for when a conversion from string to enum or vice versa fails.
Definition: types.hpp:124
Exception used when conversion from enum to string fails.
Definition: types.hpp:130
EnumToStringException(T enumValue, std::string_view type)
Creates a new StringToEnumException.
Definition: types.hpp:136
Exception used when conversion from string to enum fails.
Definition: types.hpp:143
StringToEnumException(std::string_view str, std::string_view type)
Creates a new StringToEnumException.
Definition: types.hpp:148
Exception used when DateTime class is initialized by invalid timepoint string.
Definition: types.hpp:37
Definition: types.hpp:596
Definition: types.hpp:558
Definition: types.hpp:687
Definition: types.hpp:682
Struct containing default limits for amps, watts and number of phases.
Definition: types.hpp:833
Definition: types.hpp:173
std::optional< float > N
AC Neutral value only.
Definition: types.hpp:178
friend std::ostream & operator<<(std::ostream &os, const Current &k)
Definition: types.cpp:189
std::optional< float > DC
DC current.
Definition: types.hpp:174
std::optional< float > L3
AC L3 value only.
Definition: types.hpp:177
friend void from_json(const json &j, Current &k)
Conversion from a given json object j to a given Current k.
Definition: types.cpp:168
friend void to_json(json &j, const Current &k)
Conversion from a given Current k to a given json object j.
Definition: types.cpp:147
std::optional< float > L2
AC L2 value only.
Definition: types.hpp:176
std::optional< float > L1
AC L1 value only.
Definition: types.hpp:175
Definition: types.hpp:356
Definition: types.hpp:374
Definition: types.hpp:237
friend void to_json(json &j, const Energy &k)
Conversion from a given Energy k to a given json object j.
Definition: types.cpp:305
std::optional< float > L3
AC L3 value only.
Definition: types.hpp:241
float total
DC / AC Sum value (which is relevant for billing)
Definition: types.hpp:238
friend void from_json(const json &j, Energy &k)
Conversion from a given json object j to a given Energy k.
Definition: types.cpp:322
friend std::ostream & operator<<(std::ostream &os, const Energy &k)
Definition: types.cpp:338
std::optional< float > L1
AC L1 value only.
Definition: types.hpp:239
std::optional< float > L2
AC L2 value only.
Definition: types.hpp:240
Definition: types.hpp:206
float L1
AC L1 value.
Definition: types.hpp:207
std::optional< float > L2
AC L2 value.
Definition: types.hpp:208
friend void to_json(json &j, const Frequency &k)
Conversion from a given Frequency k to a given json object j.
Definition: types.cpp:235
std::optional< float > L3
AC L3 value.
Definition: types.hpp:209
friend std::ostream & operator<<(std::ostream &os, const Frequency &k)
Definition: types.cpp:262
friend void from_json(const json &j, Frequency &k)
Conversion from a given json object j to a given Frequency k.
Definition: types.cpp:249
Definition: types.hpp:696
Definition: types.hpp:677
Definition: types.hpp:339
Powermeter power_meter
Powermeter data.
Definition: types.hpp:340
friend void from_json(const json &j, Measurement &k)
Conversion from a given json object j to a given Measurement k.
Definition: types.cpp:540
std::optional< RPM > rpm
RPM.
Definition: types.hpp:343
friend std::ostream & operator<<(std::ostream &os, const Measurement &k)
Definition: types.cpp:551
std::vector< Temperature > temperature_C
Temperature in degree Celsius.
Definition: types.hpp:342
std::optional< StateOfCharge > soc_Percent
State of Charge in percent.
Definition: types.hpp:341
friend void to_json(json &j, const Measurement &k)
Conversion from a given Measurement k to a given json object j.
Definition: types.cpp:529
Parent structure for all OCPP messages supported by this implementation.
Definition: types.hpp:30
virtual std::string get_type() const =0
Provides the type of the message.
Struct for OCSPRequestData.
Definition: types.hpp:654
Definition: types.hpp:221
friend std::ostream & operator<<(std::ostream &os, const Power &k)
Definition: types.cpp:300
friend void from_json(const json &j, Power &k)
Conversion from a given json object j to a given Power k.
Definition: types.cpp:284
float total
DC / AC Sum value.
Definition: types.hpp:222
friend void to_json(json &j, const Power &k)
Conversion from a given Power k to a given json object j.
Definition: types.cpp:267
std::optional< float > L2
AC L2 value only.
Definition: types.hpp:224
std::optional< float > L1
AC L1 value only.
Definition: types.hpp:223
std::optional< float > L3
AC L3 value only.
Definition: types.hpp:225
Definition: types.hpp:270
std::optional< Frequency > frequency_Hz
Grid frequency in Hertz.
Definition: types.hpp:281
std::optional< bool > phase_seq_error
AC only: true for 3 phase rotation error (ccw)
Definition: types.hpp:274
std::optional< ReactivePower > VAR
Reactive power VAR.
Definition: types.hpp:279
friend std::ostream & operator<<(std::ostream &os, const Powermeter &k)
Definition: types.cpp:446
std::optional< Energy > energy_Wh_export
Exported energy in Wh (to grid)
Definition: types.hpp:275
std::optional< Voltage > voltage_V
Voltage in Volts.
Definition: types.hpp:278
std::optional< Current > current_A
Current in ampere.
Definition: types.hpp:280
std::string timestamp
Timestamp of measurement.
Definition: types.hpp:271
std::optional< std::string > meter_id
A (user defined) meter if (e.g. id printed on the case)
Definition: types.hpp:273
friend void to_json(json &j, const Powermeter &k)
Conversion from a given Powermeter k to a given json object j.
Definition: types.cpp:381
Energy energy_Wh_import
Imported energy in Wh (from grid)
Definition: types.hpp:272
std::optional< Power > power_W
Instantaneous power in Watt. Negative values are exported, positive values imported Energy.
Definition: types.hpp:277
friend void from_json(const json &j, Powermeter &k)
Conversion from a given json object j to a given Powermeter k.
Definition: types.cpp:414
Definition: types.hpp:324
friend std::ostream & operator<<(std::ostream &os, const RPM &k)
Definition: types.cpp:524
friend void to_json(json &j, const RPM &k)
Conversion from a given RPM k to a given json object j.
Definition: types.cpp:503
std::optional< std::string > location
Location of the RPM measurement.
Definition: types.hpp:326
float value
RPM.
Definition: types.hpp:325
friend void from_json(const json &j, RPM &k)
Conversion from a given json object j to a given RPM k.
Definition: types.cpp:514
Definition: types.hpp:253
std::optional< float > VARphA
VAR phase A.
Definition: types.hpp:255
float total
VAR total.
Definition: types.hpp:254
friend void from_json(const json &j, ReactivePower &k)
Conversion from a given json object j to a given ReactivePower k.
Definition: types.cpp:360
std::optional< float > VARphB
VAR phase B.
Definition: types.hpp:256
friend std::ostream & operator<<(std::ostream &os, const ReactivePower &k)
Definition: types.cpp:376
std::optional< float > VARphC
VAR phase C.
Definition: types.hpp:257
friend void to_json(json &j, const ReactivePower &k)
Conversion from a given ReactivePower k to a given json object j.
Definition: types.cpp:343
Definition: types.hpp:386
Definition: types.hpp:395
Definition: types.hpp:414
Definition: types.hpp:294
std::optional< std::string > location
Location of the State of Charge measurement.
Definition: types.hpp:296
friend void to_json(json &j, const StateOfCharge &k)
Conversion from a given StateOfCharge k to a given json object j.
Definition: types.cpp:477
friend void from_json(const json &j, StateOfCharge &k)
Conversion from a given json object j to a given StateOfCharge k.
Definition: types.cpp:488
friend std::ostream & operator<<(std::ostream &os, const StateOfCharge &k)
Definition: types.cpp:498
float value
State of Charge in percent.
Definition: types.hpp:295
Definition: types.hpp:309
std::optional< std::string > location
Location of the Temperature measurement.
Definition: types.hpp:311
friend std::ostream & operator<<(std::ostream &os, const Temperature &k)
Definition: types.cpp:472
friend void from_json(const json &j, Temperature &k)
Conversion from a given json object j to a given Temperature k.
Definition: types.cpp:462
float value
Temperature in degree Celsius.
Definition: types.hpp:310
friend void to_json(json &j, const Temperature &k)
Conversion from a given Temperature k to a given json object j.
Definition: types.cpp:451
Definition: types.hpp:432
Definition: types.hpp:190
std::optional< float > L2
AC L2 value only.
Definition: types.hpp:193
friend std::ostream & operator<<(std::ostream &os, const Voltage &k)
Definition: types.cpp:230
friend void to_json(json &j, const Voltage &k)
Conversion from a given Voltage k to a given json object j.
Definition: types.cpp:194
friend void from_json(const json &j, Voltage &k)
Conversion from a given json object j to a given Voltage k.
Definition: types.cpp:212
std::optional< float > L3
AC L3 value only.
Definition: types.hpp:194
std::optional< float > L1
AC L1 value only.
Definition: types.hpp:192
std::optional< float > DC
DC voltage.
Definition: types.hpp:191