diff --git a/.vscode/launch.json b/.vscode/launch.json index a70a919a..ae9c802d 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,14 +1,20 @@ { - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "type": "gdb", "request": "launch", "name": "x86 CP debug", - "target": "${workspaceRoot}/bin/gcc_native/quick_start_chargepoint", + "target": "${workspaceRoot}/bin/gcc_native/quick_start_chargepoint20", + "cwd": "${workspaceRoot}/bin/gcc_native/", + "arguments": "-r", + "valuesFormatting": "parseText" + }, + { + "type": "gdb", + "request": "launch", + "name": "x86 Basic CP debug", + "target": "${workspaceRoot}/bin/gcc_native/quick_start_basicchargepoint20", "cwd": "${workspaceRoot}/bin/gcc_native/", "arguments": "-r", "valuesFormatting": "parseText" @@ -17,7 +23,7 @@ "type": "gdb", "request": "launch", "name": "x86 CS debug", - "target": "${workspaceRoot}/bin/gcc_native/quick_start_centralsystem", + "target": "${workspaceRoot}/bin/gcc_native/quick_start_centralsystem20", "cwd": "${workspaceRoot}/bin/gcc_native/", "arguments": "-r", "valuesFormatting": "parseText" @@ -26,7 +32,7 @@ "type": "gdb", "request": "launch", "name": "x86 LC debug", - "target": "${workspaceRoot}/bin/gcc_native/quick_start_localcontroller", + "target": "${workspaceRoot}/bin/gcc_native/quick_start_localcontroller20", "cwd": "${workspaceRoot}/bin/gcc_native/", "arguments": "-r", "valuesFormatting": "parseText" @@ -58,6 +64,13 @@ "ignoreFailures": true } ] + }, + { + "name": "json2cpp", + "type": "debugpy", + "request": "launch", + "program": "${workspaceRoot}/tools/json2cpp/json2cpp.py", + "args": ["-i", "${workspaceRoot}/schemas/ocpp20", "-o", "${workspaceRoot}/out", "-t", "${workspaceRoot}/tools/json2cpp/templates", "-v", "ocpp20"] } ] } \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index bd07fa83..c5d3b810 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,8 +4,8 @@ cmake_minimum_required(VERSION 3.13) -project(OpenOCPP DESCRIPTION "Open Source C++ implementation of the OCPP 1.6 protocol" - VERSION 1.5.8 +project(OpenOCPP DESCRIPTION "Open Source C++ implementation of the OCPP 1.6 and 2.0.1 protocols" + VERSION 2.0.0 ) # Definitions for Version.h file @@ -72,9 +72,15 @@ if(${BUILD_STATIC_LIBRARY}) centralsystem chargepoint localcontroller + centralsystem20 + chargepoint20 + localcontroller20 config database messages + messages16 + messages20 + types20 rpc helpers log @@ -96,9 +102,15 @@ if (${BUILD_SHARED_LIBRARY}) centralsystem chargepoint localcontroller + centralsystem20 + chargepoint20 + localcontroller20 config database messages + messages16 + messages20 + types20 rpc helpers log @@ -121,8 +133,10 @@ include(GNUInstallDirs) file(GLOB_RECURSE PUBLIC_HEADERS LIST_DIRECTORIES false RELATIVE ${CMAKE_SOURCE_DIR} "${CMAKE_SOURCE_DIR}/src/*.h") -file(GLOB OCPP_SCHEMAS - LIST_DIRECTORIES false RELATIVE ${CMAKE_SOURCE_DIR} "${CMAKE_SOURCE_DIR}/schemas/*.json") +file(GLOB OCPP16_SCHEMAS + LIST_DIRECTORIES false RELATIVE ${CMAKE_SOURCE_DIR} "${CMAKE_SOURCE_DIR}/schemas/ocpp16/*.json") +file(GLOB OCPP20_SCHEMAS + LIST_DIRECTORIES false RELATIVE ${CMAKE_SOURCE_DIR} "${CMAKE_SOURCE_DIR}/schemas/ocpp20/*.json") install(TARGETS ${OPEN_OCPP_SHARED_TARGET} ${OPEN_OCPP_STATIC_TARGET} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} @@ -130,7 +144,8 @@ install(TARGETS ${OPEN_OCPP_SHARED_TARGET} ${OPEN_OCPP_STATIC_TARGET} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ) install(FILES ${PUBLIC_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/openocpp) -install(FILES ${OCPP_SCHEMAS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/openocpp/schemas) +install(FILES ${OCPP16_SCHEMAS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/openocpp/schemas/ocpp16) +install(FILES ${OCPP20_SCHEMAS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/openocpp/schemas/ocpp20) if(${INSTALL_RAPID_JSON}) file(GLOB RAPIDJSON_HEADERS diff --git a/README.md b/README.md index cfd90fd4..9fd51c34 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Open OCPP -**Open OCPP** is an Open Source C++ implementation of the OCPP 1.6 protocol ([Open Charge Alliance](https://www.openchargealliance.org/)). -This implementation targets only the Websocket/JSON version of this protocol. +**Open OCPP** is an Open Source C++ implementation of the OCPP 1.6 and 2.0.1 protocols ([Open Charge Alliance](https://www.openchargealliance.org/)). +This implementation targets only the Websocket/JSON version of these protocols. This implementation is based on the following libraries : * [OpenSSL](https://www.openssl.org) : TLS communications + certificates management @@ -23,23 +23,7 @@ As such it can be used and distributed in any commercial and non-commercial prod - [License](#license) - [Table of contents](#table-of-contents) - [Features](#features) - - [Key features](#key-features) - - [Supported OCPP feature profiles](#supported-ocpp-feature-profiles) - - [Supported OCPP configuration keys](#supported-ocpp-configuration-keys) - - [OCPP security extensions](#ocpp-security-extensions) - - [Security profiles](#security-profiles) - - [Security events](#security-events) - - [Extended trigger messages](#extended-trigger-messages) - - [Certificate management](#certificate-management) - - [Signed firmware update](#signed-firmware-update) - - [OCPP ISO15118 PnC extensions](#ocpp-iso15118-pnc-extensions) - - [Charge Point role](#charge-point-role) - - [Central System role](#central-system-role) - - [Internal configuration keys](#internal-configuration-keys) - - [Common keys](#common-keys) - - [Charge Point keys](#charge-point-keys) - - [Central System keys](#central-system-keys) - - [Local Controller keys](#local-controller-keys) + - [Branches and version management](#branches-and-version-management) - [Build](#build) - [Pre-requisites](#pre-requisites) - [Build options](#build-options) @@ -48,15 +32,6 @@ As such it can be used and distributed in any commercial and non-commercial prod - [Install and use](#install-and-use) - [Installation](#installation) - [Use with CMake](#use-with-cmake) - - [Quick start](#quick-start) - - [Charge Point role](#charge-point-role-1) - - [Configuration interface](#configuration-interface) - - [Event handler interface](#event-handler-interface) - - [Charge Point object](#charge-point-object) - - [Central System role](#central-system-role-1) - - [Configuration interface](#configuration-interface-1) - - [Event handler interfaces](#event-handler-interfaces) - - [Central System object](#central-system-object) - [Contributing](#contributing) - [Coding rules](#coding-rules) - [Issues](#issues) @@ -64,276 +39,21 @@ As such it can be used and distributed in any commercial and non-commercial prod ## Features -### Key features -**Open OCPP** is composed of the 4 layers defined by the protocol : - -* Websockets (Client or Server) -* OCPP-J RPC -* JSON messages serialization/deserialization -* OCPP role (Charge Point, Central System or Local Controller) - -As of this version : - -* All the messages defined in the OCPP 1.6 edition 2 protocol have been implemented -* All the configuration keys defined in the OCPP 1.6 edition 2 protocol have been implemented for the Charge Point role -* All the messages defined in the OCPP 1.6 security whitepaper edition 2 have been implemented -* All the messages defined in the Using ISO 15118 Plug & Charge with OCPP 1.6 Application Note v1.0 have been implemented - -The user application will have to implement some callbacks to provide the data needed by **Open OCPP** or to handle OCPP events (boot notification, remote start/stop notifications, meter values...). - -The persistent data handled by **Open OCPP** is stored into a single file which is an [SQLite](https://www.sqlite.org/) database. It contains : - -* For Charge Point role : - - + Internal configuration - + Persistent data : Central System's registration status, connector state, OCPP transaction related messages when offline, StopTx meter values - + Badge cache and local list - + Smart charging profile - + Logs - * X.509 Certificates - -* For Central System or Local Controller role : - - + Internal configuration - + Logs - -The standard OCPP configuration persistency has to be handled by the user application. - -### Supported OCPP feature profiles - -| Profile | Description | Restrictions | -| :------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------- | -| Core | Basic Charge Point functionality comparable with OCPP 1.5 [OCPP1.5] without support for firmware updates, local authorization list management and reservations | OCPP confguration persistency has to be handled by the user application | -| Firmware Management | Support for firmware update management and diagnostic log file download | Actual file download/upload as well as firmware installation must be handled by the user application in the callbacks provided by **Open OCPP** | -| Local Auth List Management | Features to manage the local authorization list in Charge Points | None | -| Reservation | Support for reservation of a Charge Point. | None | -| Smart Charging | Support for basic Smart Charging, for instance using control pilot | GetCompositeSchedule is not supported for connector 0 in Charge Point role | -| Remote Trigger | Support for remote triggering of Charge Point initiated messages | None | - -### Supported OCPP configuration keys - -The OCPP configuration keys support applies to Charge Point role only. - -In the "Owner" column, "S" means that the configuration key behavior is handled by the stack, "U" means that it must handled by the user application. - -| Key | Owner | Restrictions | -| :-------------------------------------: | :---: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| AllowOfflineTxForUnknownId | S | None | -| AuthorizationCacheEnabled | S | None | -| AuthorizeRemoteTxRequests | U | None | -| BlinkRepeat | U | None | -| ClockAlignedDataInterval | S | None | -| ConnectionTimeOut | U | None | -| ConnectorPhaseRotation | U | None | -| ConnectorPhaseRotationMaxLength | U | None | -| GetConfigurationMaxKeys | S | Must be set to the sum of OCPP configuration keys count (49) + user application configuration keys count to allow to export all the configuration in 1 message | -| HeartbeatInterval | S | Heartbeat are only sent if no messages have been exchanged since HeartbeatInterval seconds | -| LightIntensity | U | None | -| LocalAuthorizeOffline | S | None | -| LocalPreAuthorize | S | None | -| MaxEnergyOnInvalidId | U | None | -| MeterValuesAlignedData | S+U | User application must validate the requested meter value list according to its metering capacities when modified by the Central System | -| MeterValuesAlignedDataMaxLength | S | None | -| MeterValuesSampledData | S+U | User application must validate the requested meter value list according to its metering capacities when modified by the Central System | -| MeterValuesSampledDataMaxLength | S | None | -| MeterValueSampleInterval | S | None | -| MinimumStatusDuration | S | None | -| NumberOfConnectors | S | None | -| ResetRetries | U | None | -| StopTransactionOnEVSideDisconnect | U | None | -| StopTransactionOnInvalidId | U | None | -| StopTxnAlignedData | S+U | User application must validate the requested meter value list according to its metering capacities when modified by the Central System | -| StopTxnAlignedDataMaxLength | S | None | -| StopTxnSampledData | S+U | User application must validate the requested meter value list according to its metering capacities when modified by the Central System | -| StopTxnSampledDataMaxLength | S | None | -| SupportedFeatureProfiles | S | None | -| SupportedFeatureProfilesMaxLength | S | None | -| TransactionMessageAttempts | S | None | -| TransactionMessageRetryInterval | S | None | -| UnlockConnectorOnEVSideDisconnect | U | None | -| WebSocketPingInterval | S | Reboot required | -| LocalAuthListEnabled | S | None | -| LocalAuthListMaxLength | S | None | -| SendLocalListMaxLength | S | None | -| ReserveConnectorZeroSupported | S | None | -| ChargeProfileMaxStackLevel | S | None | -| ChargingScheduleAllowedChargingRateUnit | S | None | -| ChargingScheduleMaxPeriods | S | None | -| ConnectorSwitch3to1PhaseSupported | S | None | -| MaxChargingProfilesInstalled | S | None | -| AdditionalRootCertificateCheck | U/S | If internal certificate management is enabled, the stack handle this parameter (implemented behavior for now is the always the one corresponding to AdditionalRootCertificateCheck = False), otherwise it must be the user application | -| AuthorizationKey | S | None | -| CertificateSignedMaxChainSize | S | None | -| CertificateStoreMaxLength | U/S | If internal certificate management is enabled, the stack handle this parameter, otherwise it must be the user application | -| CpoName | S | None | -| SecurityProfile | S | None | -| SupportedFileTransferProtocols | U | None | -| CentralContractValidationAllowed | S | None | -| CertSigningWaitMinimum | S | None | -| CertSigningRepeatTimes | S | None | -| ContractValidationOffline | U/S | The stack will notify the user application for contract validation depending on the value of this parameter | -| ISO15118PnCEnabled | S | None | +* [OCPP 1.6 features](./README_ocpp16.md) +* [OCPP 2.0.1 features](./README_ocpp20.md) -### OCPP security extensions +## Branches and version management -#### Security profiles +The development of the OCPP 2.X.Y features has introduced a breaking change in the API and namespaces, so there are now 2 development branches: -**Open OCPP** support the following Security Profiles for both Charge Point and Central System roles : +* The **develop** branch is now dedicated to the implementation of the OCPP 2.X.Y features and to bug fixes on the OCPP 1.6 features using the new API and namespaces +* The **develop16** branch is dedicated for maintenance of the legacy OCPP 1.6 features and will only be used for bug fixing (backports from **develop** branch) -* 0 : No security profile -* 1 : Unsecured Transport with HTTP Basic Authentication -* 2 : TLS with HTTP Basic Authentication -* 3 : TLS with Client Side Certificates - -In Charge Point role, the stack will automatically disconnect and then reconnect using the new parameters to the Central System after one of the following parameters has been modified : -* **AuthorizationKey** -* **Security Profile** - -**Restriction** : The automatic fallback to old connection parameters if the connection fails after switching to a new security is not implemented yet. - -#### Security events - -**Open OCPP** support the whole use cases of security events and logging. - -In Charge Point role, it can optionnaly handle the storage of the security event log and the generation of the security log export when the Central System asks it. To enable/disable this feature, you have to modify the **SecurityLogMaxEntriesCount** charge point configuration key : - -* 0 = **Open OCPP** will not store security event and the security log must be generated by the user application -* \>0 = **Open OCPP** will store at max **SecurityLogMaxEntriesCount** (circular log) and will automatically generate the security log as a CSV file - -In Charge Point role, the user application can generate custom security events and defines its criticity so that they are forwarded to the Central System. - -In Charge Point role, the notification of security events can be enabled or disabled with the **SecurityEventNotificationEnabled** configuration key. This can be usefull to disable them when the Central System does not implement the security extensions. - -#### Extended trigger messages - -**Open OCPP** support this feature for both Charge Point and Central System roles. - -#### Certificate management - -**Open OCPP** support this feature for both Charge Point and Central System roles. - -The behavior of this feature is controlled by the **InternalCertificateManagementEnabled** configuration key. - -If **InternalCertificateManagementEnabled** is set to **false**, the actual storage of the certificates and their keys must be done by the user application. **Open OCPP** provides callbacks and helper classes to ease certificate manipulation and installation. The user application also has to configure the path to the installed certificates for the establishment of the secure connections using the following configuration keys : - -* TlsServerCertificateCa -* TlsClientCertificate -* TlsClientCertificatePrivateKey -* TlsClientCertificatePrivateKeyPassphrase - -If **InternalCertificateManagementEnabled** is set to **true**, the storage of certificates and their keys is fully handled by **Open OCPP**. The user application just has to provide a passphrase using the **TlsClientCertificatePrivateKeyPassphrase** configuration key to securily encrypt the certicates' private keys using AES-256-CBC algorithm. **Open OCPP** will automatically use the installed corresponding certificates depending on the configured Security Profile and the certificates validity dates. - -**Restriction** : The automatic fallback to old certificate if the connection fails after installing new certificate is not implemented yet. - -#### Signed firmware update - -**Open OCPP** support this feature for both Charge Point and Central System roles. - -**Open OCPP** provides helper classes based on OpenSSL to ease private keys, certificate and certificate requests usage : generation, signature, verification. They can be used in the user application callbacks. These helpers can be found in the ocpp::tools::x509 namespace and are widely used in the **Open OCPP** source code and examples. - -### OCPP ISO15118 PnC extensions - -**Open OCPP** fully supports the whole messaging, data types and configuration keys set associated to the ISO15118 PnC extensions. - -#### Charge Point role - -In Charge Point role these extensions consists mainly on forwarding messages from the ISO15118-2 stack layer to the Central System by using dedicated DataTransfer messages. - -**Open OCPP** implements the forwarding and provides callback and retries capabilities for certificates messages. - -Allthough **Open OCPP** is able to manage a certificate store, the Charge Point certificate used for ISO15118 communication won't be stored in it even if the **InternalCertificateManagementEnabled** configuration key is set to **true**. This is will allow for the ISO15118-2 stack to access this certificate and use it to secure its communications with the vehicule. - -#### Central System role - -In Central System role these extensions consists mainly in certificate management by forwarding request either to OCSP server or Mobility Operators. - -**Open OCPP** provides callbacks where the forwarding to the necessary servers must be implemented. - -### Internal configuration keys - -The behavior and the configuration of the **Open OCPP** stack can be modified through configuration keys. Some are specific to an OCPP role and some are common. - -#### Common keys - -| Key | Type | Description | -| :----------------: | :----: | :------------------------------------------------------------------ | -| DatabasePath | string | Path to the database to store persistent data | -| JsonSchemasPath | string | Path to the JSON schemas to validate the messages | -| CallRequestTimeout | uint | Call request timeout in milliseconds | -| Tlsv12CipherList | string | List of authorized ciphers for TLSv1.2 connections (OpenSSL format) | -| Tlsv13CipherList | string | List of authorized ciphers for TLSv1.3 connections (OpenSSL format) | -| LogMaxEntriesCount | uint | Maximum number of entries in the log (0 = no logs in database) | +The new **Open OCPP** releases created from the **develop** branch will have a version number **2.X.Y** starting with the **2.0.0** release. -#### Charge Point keys +The legacy **Open OCPP** releases created from the **develop16** branch will have a version number **1.X.Y** starting with the **1.6.0** release. -| Key | Type | Description | -| :---------------------------------------------: | :----: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| ConnexionUrl | string | URL of the Central System | -| ChargePointIdentifier | string | OCPP Charge Point identifier. Will be concatanated with the **ConnexionUrl** key | -| ConnectionTimeout | uint | Connection timeout in milliseconds | -| RetryInterval | uint | Retry interval when connection has failed in milliseconds | -| ChargeBoxSerialNumber | string | Deprecated. Charge Box serial number for BootNotification message | -| ChargePointModel | string | Charge Point model for BootNotification message | -| ChargePointSerialNumber | string | Charge Point serial number for BootNotification message | -| ChargePointVendor | string | Charge Point vendor for BootNotification message | -| FirmwareVersion | string | Charge Point firmware version for BootNotification message | -| Iccid | string | ICCID of the moden's SIM card for BootNotification message | -| Imsi | string | IMSI of the moden's SIM card for BootNotification message | -| MeterSerialNumber | string | Main electrical meter serial number for BootNotification message | -| MeterType | string | Main electrical meter type for BootNotification message | -| OperatingVoltage | float | Nominal operating voltage (needed for Watt to Amp conversions in smart charging profiles) | -| AuthentCacheMaxEntriesCount | uint | Maximum number of entries in the authentication cache | -| TlsServerCertificateCa | string | Path to Certification Authority signing chain to validate the Central System certificate | -| TlsClientCertificate | string | Path to Charge Point certificate | -| TlsClientCertificatePrivateKey | string | Path to Charge Point's certificate's private key | -| TlsClientCertificatePrivateKeyPassphrase | string | Charge Point certificate's private key passphrase | -| TlsAllowSelfSignedCertificates | bool | Allow TLS connections using self-signed certificates (Warning : enabling this feature is not recommended in production) | -| TlsAllowExpiredCertificates | bool | Allow TLS connections using expired certificates (Warning : enabling this feature is not recommended in production) | -| TlsAcceptNonTrustedCertificates | bool | Accept non trusted certificates for TLS connections (Warning : enabling this feature is not recommended in production) | -| TlsSkipServerNameCheck | bool | Skip server name check in certificates for TLS connections (Warning : enabling this feature is not recommended in production) | -| InternalCertificateManagementEnabled | bool | If true, certificates are stored inside **Open OCPP** databasen otherwise user application has to handle them | -| SecurityEventNotificationEnabled | bool | Enable security event notification | -| SecurityLogMaxEntriesCount | uint | Maximum number of entries in the security log (0 = no security logs in database) | -| ClientCertificateRequestHashType | string | Hash type for certificate request generation : sha256, sha384 or sha512 | -| ClientCertificateRequestKeyType | string | Key type for certificate request generation : ec or rsa | -| ClientCertificateRequestRsaKeyLength | uint | Length in bits of the key for certificate request generation if rsa has been selected for key type : minimum 2048 | -| ClientCertificateRequestEcCurve | string | Name of the elliptic curve for certificate request generation if ec has been selected for key type : prime256v1, secp256k1, secp384r1, secp521r1, brainpoolP256t1, brainpoolP384t1 or brainpoolP512t1 | -| ClientCertificateRequestSubjectCountry | string | Country for the subject field of certificate request generation (can be left empty) | -| ClientCertificateRequestSubjectState | string | State for the subject field of certificate request generation (can be left empty) | -| ClientCertificateRequestSubjectLocation | string | Location for the subject field of certificate request generation (can be left empty) | -| ClientCertificateRequestSubjectOrganizationUnit | string | Organization unit for the subject field of certificate request generation (can be left empty) | -| ClientCertificateRequestSubjectEmail | string | Email for the subject field of certificate request generation (can be left empty) | - -#### Central System keys - -| Key | Type | Description | -| :--------------------------------------: | :----: | :----------------------------------------------------------------------------------------------------------- | -| ListenUrl | string | URL to listen to incomming websocket connections | -| WebSocketPingInterval | uint | Websocket PING interval in seconds | -| BootNotificationRetryInterval | uint | Boot notification retry interval in second (sent in BootNotificationConf when status is Pending or Rejected) | -| HeartbeatInterval | uint | Heartbeat interval in seconds (sent in BootNotificationConf when status is Accepted) | -| HttpBasicAuthent | bool | If set to true, the Charge Points must autenticate themselves using HTTP Basic Authentication method | -| TlsEcdhCurve | string | ECDH curve to use for TLS connections with EC keys | -| TlsServerCertificate | string | Path to the Central System's certificate | -| TlsServerCertificatePrivateKey | string | Path to the Central System's certificate's private key | -| TlsServerCertificatePrivateKeyPassphrase | string | Central System's certificate's private key passphrase | -| TlsServerCertificateCa | string | Path to the Certification Authority signing chain for the Central System's certificate | -| TlsClientCertificateAuthent | bool | If set to true, the Charge Points must authenticate themselves using an X.509 certificate | - -#### Local Controller keys - -| Key | Type | Description | -| :--------------------------------------: | :----: | :---------------------------------------------------------------------------------------------------------------------------------------- | -| ListenUrl | string | URL to listen to incomming websocket connections | -| WebSocketPingInterval | uint | Websocket PING interval in seconds | -| HttpBasicAuthent | bool | If set to true, the Charge Points must autenticate themselves using HTTP Basic Authentication method | -| TlsEcdhCurve | string | ECDH curve to use for TLS connections with EC keys | -| TlsServerCertificate | string | Path to the Central System's certificate | -| TlsServerCertificatePrivateKey | string | Path to the Central System's certificate's private key | -| TlsServerCertificatePrivateKeyPassphrase | string | Central System's certificate's private key passphrase | -| TlsServerCertificateCa | string | Path to the Certification Authority signing chain for the Central System's certificate | -| TlsClientCertificateAuthent | bool | If set to true, the Charge Points must authenticate themselves using an X.509 certificate | -| DisconnectFromCpWhenCsDisconnected | bool | If set to true, the Charge Point is automatically disconnected when the connection to the Central System cannot be established or is lost | +So if you are already working with **Open OCPP** without having any intention to migrate to the new API or to use the OCPP 2.X.Y features, you can keep following the **1.X.Y** releases. All the OCPP1.6 bug fixes will be backported on these releases. ## Build @@ -438,307 +158,6 @@ Then you wil be able to use the following targets as dependencies for your proje See the deploy test [CMakeLists.txt](./tests/deploy/CMakeLists.txt) as an example -## Quick start - -The best way to start is to take a look at the [examples](./examples/README.md) and more specifically at the [quick start Charge Point example](./examples/quick_start_chargepoint/README.md), the [quick start Central System example](./examples/quick_start_centralsystem/README.md) and the [quick start Local Controller example](./examples/quick_start_localcontroller/README.md). - -### Charge Point role - -The implementation of a program using **Open OCPP** in Charge Point role is done in 3 steps : -* Implementation of the configuration interfaces [IOcppConfig](./src/config/IOcppConfig.h) and [IChargePointConfig](./src/chargepoint/interface/IChargePointConfig.h) -* Implementation of the event handler interface [IChargePointEventsHandler](./src/chargepoint/interface/IChargePointEventsHandler.h) -* Instanciation and use of the Charge Point object [IChargePoint](./src/chargepoint/interface/IChargePoint.h) - -#### Configuration interface - -The configuration interface allow **Open OCPP** to access to the values of the standard OCPP configuration keys and to the user application specific configuration keys. - -The persistency of OCPP configuration key is not handled by **Open OCPP** for 2 main reasons : - -* The user application will surely already have a configuration management component -* The user application may have to access the OCPP configuration keys or may want to export its own keys already managed by its configuration component - -The configuration interface is split in 2 parts : - -* IOcppConfig : interface to access OCPP configuration keys and user application specific configuration keys -* IChargePointConfig : interface to access Charge Point configuration (database paths, url, ...) - -In the examples, the interfaces have been implemented to retrieve the values from a file stored into an INI format. This is a simple implementaton which is good to show how to implement these interfaces but which is not the most optimized one since every access to a configuration value implies a conversion from a string. Try to have a better implementation to boost the performances of the software ;) - -#### Event handler interface - -Most of the OCPP behavior is handled by **Open OCPP** but to complete the implementation of the OCPP standard, some information may be needed by **Open OCPP** (Meter values, change availability permissions...) or some operations may be done by the user application (File upload/download, firmware install...). - -The event handler interface defines all these interaction as well as some usefull notifications to the user application : connection status, registration status, reservation status... - -Most of the notifications/operations can be left empty if the corresponding OCPP feature is not used by the user application. See inside the examples how to implement unused functionalities. - -Please keep in mind that all the calls to the event handler interface are made from different threads managed by **Open OCPP** depending the kind of notification/operation and that the treatment of theses calls must not be blocking (except for file upload/download) since it will have an impact to the global scheduling of **Open OCPP**. - -#### Charge Point object - -This is the easiest part :) - -The Charge Point object is instanciated through a factory interface : - -``` -/** - * @brief Instanciate a charge point - * @param stack_config Stack configuration - * @param ocpp_config Standard OCPP configuration - * @param event_handler Stack event handler - */ -static std::unique_ptr create(const ocpp::config::IChargePointConfig& stack_config, - ocpp::config::IOcppConfig& ocpp_config, - IChargePointEventsHandler& events_handler); -``` - -The 3 parameters are the instances of the interfaces you have implemented in the previous steps. - -Before starting the Charge Point object and thus the OCPP stack with the ```start()``` method, you can clear existing persistent data using the following methods: - -* ```resetConnectorData()``` : clear all connector related data -* ```resetData()``` : clear all the persistent data - -Once the Charge Point object has been started, **Open OCPP** will continuously try to connect/keep alive the communication with the Central System until a call to the ```stop()``` method which will disconnect and release the connection. - -Connectivity status, registration status and Central System initiated operations will be notified through the event handler interface. - -OCPP Charge Point operations are triggered by the Charge Point object interface. - -Extract of a quick start main() : - -``` -int main() -{ - // Configuration - ChargePointDemoConfig config("config.ini"); - - // Event handler - DefaultChargePointEventsHandler event_handler(config); - - // Instanciate charge point - std::unique_ptr charge_point = IChargePoint::create(config.stackConfig(), config.ocppConfig(), event_handler); - charge_point->start(); - - // From now on the stack is alive :) - - // App loop - while (true) - { - // Wait to be accepted by Central System - while (charge_point->getRegistrationStatus() != RegistrationStatus::Accepted) - { - std::this_thread::sleep_for(std::chrono::milliseconds(100u)); - } - - // Ask for authorization on a tag - std::string parent_id; - std::string id_tag = "AABBCCDDEEFF"; - AuthorizationStatus status = charge_point->authorize(connector_id, id_tag, parent_id); - if (status == AuthorizationStatus::Accepted) - { - std::cout << "Id tag authorized, parent id = " << parent_id << std::endl; - - // Preparing state - charge_point->statusNotification(connector_id, ChargePointStatus::Preparing); - std::this_thread::sleep_for(std::chrono::seconds(1u)); - - // Try to start charging session - status = charge_point->startTransaction(connector_id, id_tag); - if (status == AuthorizationStatus::Accepted) - { - std::cout << "Transaction authorized, start charging" << std::endl; - - // Charging state - charge_point->statusNotification(connector_id, ChargePointStatus::Charging); - std::this_thread::sleep_for(std::chrono::seconds(30u)); - - // End transaction - charge_point->stopTransaction(connector_id, id_tag, Reason::Local); - - // Finishing state - charge_point->statusNotification(connector_id, ChargePointStatus::Finishing); - std::this_thread::sleep_for(std::chrono::seconds(1u)); - } - else - { - std::cout << "Transaction not authorized by Central System : " << AuthorizationStatusHelper.toString(status) - << std::endl; - } - - // Available state - charge_point->statusNotification(connector_id, ChargePointStatus::Available); - } - else - { - std::cout << "Id tag not authorized by Central System : " << AuthorizationStatusHelper.toString(status) << std::endl; - } - - // Wait before next charging session - std::this_thread::sleep_for(std::chrono::seconds(10u)); - } - - return 0; -} -``` - -### Central System role - -The implementation of a program using **Open OCPP** in Central System role is done in 3 steps : -* Implementation of the configuration interface [ICentralSystemConfig](./src/centralsystem/interface/ICentralSystemConfig.h) -* Implementation of the event handler interfaces [ICentralSystemEventsHandler](./src/centralsystem/interface/ICentralSystemEventsHandler.h) and [IChargePointRequestHandler](./src/centralsystem/interface/IChargePointRequestHandler.h) -* Instanciation and use of the Central System object [ICentralSystem](./src/centralsystem/interface/ICentralSystem.h) - -#### Configuration interface - -The configuration interface allow **Open OCPP** to access to its configuration values. -The persistency of the configuration is not handled by **Open OCPP** for 2 main reasons : - -* The user application will surely already have a configuration management component -* The user application may have to access the **Open OCPP** configuration - -In the examples, the interface has been implemented to retrieve the values from a file stored into an INI format. This is a simple implementaton which is good to show how to implement this interface but which is not the most optimized one since every access to a configuration value implies a conversion from a string. Try to have a better implementation to boost the performances of the software ;) - -#### Event handler interfaces - -In Central System role, the OCPP behavior must be implemented by the user application. **Open OCPP** handles all the other layers of the stack (websocket, RPC, JSON serialization/deserialization). - -The **Open OCPP** stack will interact with the user application through 2 interfaces : - -* [ICentralSystemEventsHandler](./src/centralsystem/interface/ICentralSystemEventsHandler.h) : used for all connection related events (credentials check, connection notification...) -* [IChargePointRequestHandler](./src/centralsystem/interface/IChargePointRequestHandler.h) : used to handle incoming requests from a Charge Point (boot notification, status notification, start transaction...) - -The **ICentralSystemEventsHandler** must be instanciated only once for a Central System implementation. - -The **IChargePointRequestHandler** must be instanciated and registered to each connected Charge Point in the **ICentralSystemEventsHandler::chargePointConnected** method implementation. - -Example of Charge Point connection handling : - -``` -/** @copydoc bool ICentralSystemEventsHandler::chargePointConnected(std::shared_ptr) */ -void MyCentralSystemEventsHandler::chargePointConnected(std::shared_ptr chargepoint) -{ - cout << "Charge point [" << chargepoint->identifier() << "] connected" << endl; - auto iter_chargepoint = m_chargepoints.find(chargepoint->identifier()); - if (iter_chargepoint == m_chargepoints.end()) - { - MyChargePointRequestHandler* my_handler = new MyChargePointRequestHandler(*this, chargepoint); - chargepoint->registerHandler(*my_handler); - m_chargepoints[chargepoint->identifier()] = - std::shared_ptr(my_handler); - } - else - { - cout << "Charge point [" << chargepoint->identifier() << "] already connected" << endl; - chargepoint.reset(); - } -} -``` - -Please keep in mind that all the calls to the event handler interface are made from different threads managed by **Open OCPP** depending the kind of notification/operation and that the treatment of theses calls must not be blocking since it will have an impact to the global scheduling of **Open OCPP**. - -#### Central System object - -This is the easiest part :) - -The Central System object is instanciated through a factory interface : - -``` -/** - * @brief Instanciate a central system - * @param stack_config Stack configuration - * @param event_handler Stack event handler -*/ -static std::unique_ptr create(const ocpp::config::ICentralSystemConfig& stack_config, - ICentralSystemEventsHandler& events_handler); -``` - -The 2 parameters are the instances of the interfaces you have implemented in the previous steps. - -Before starting the Central System object and thus the OCPP stack with the ```start()``` method, you can clear existing persistent data using the following method: - -```resetData()``` : clear all the persistent data - -Once the Central System object has been started, **Open OCPP** will continuously listen to incoming connections from the Charge Points until a call to the ```stop()``` method which will disconnect all the Charge Points and release the connection. - -Connectivity status and Charge Point initiated operations will be notified through the event handler interfaces. - -OCPP Central System operations are triggered by the Charge Point proxy interface [ICentralSystem::IChargePoint](./src/centralsystem/interface/ICentralSystem.h) which is instanciated by **Open OCPP** for each connected Charge Point. - -Extract of a quick start main() : - -``` -int main() -{ - // Configuration - CentralSystemDemoConfig config("config.ini"); - - // Event handler - CentralSystemDemoConfig event_handler(config); - - // Instanciate central system - std::unique_ptr central_system = ICentralSystem::create(config.stackConfig(), event_handler); - central_system->start(); - - // From now on the stack is alive :) - - // App loop - while (true) - { - // Wait for at least 1 connected charge point - while (event_handler.chargePoints().size() == 0) - { - std::this_thread::sleep_for(std::chrono::milliseconds(250)); - } - std::this_thread::sleep_for(std::chrono::seconds(1)); - - // For each connected charge point - for (auto& iter_chargepoint : event_handler.chargePoints()) - { - { - auto chargepoint = iter_chargepoint.second->proxy(); - - std::cout << "---------------------------------------------" << std::endl; - std::cout << "Charge point : " << chargepoint->identifier() << std::endl; - std::cout << "---------------------------------------------" << std::endl; - - std::cout << "Read whole charge point configuration..." << std::endl; - std::vector keys; - std::vector config_keys; - std::vector unknown_keys; - if (chargepoint->getConfiguration(keys, config_keys, unknown_keys)) - { - std::cout << "Configuration keys :" << std::endl; - for (const KeyValue& key_value : config_keys) - { - std::cout << " - " << key_value.key.str() << " = " << (key_value.value.isSet() ? key_value.value.value().str() : "") - << " " << (key_value.readonly ? "(read-only)" : "") << std::endl; - } - } - else - { - std::cout << "Failed!" << std::endl; - } - - std::cout << "Configure heartbeat interval..." << std::endl; - ConfigurationStatus config_status = chargepoint->changeConfiguration("HeartbeatInterval", "10"); - std::cout << ConfigurationStatusHelper.toString(config_status) << std::endl; - - std::cout << "Trigger status notification..." << std::endl; - TriggerMessageStatus trigger_status = - chargepoint->triggerMessage(MessageTrigger::StatusNotification, Optional()); - std::cout << TriggerMessageStatusHelper.toString(trigger_status) << std::endl; - } - - std::this_thread::sleep_for(std::chrono::seconds(10)); - } - } - - return 0; -} -``` - ## Contributing **Open OCPP** welcomes contributions. When contributing, please follow the code below. diff --git a/README_ocpp16.md b/README_ocpp16.md new file mode 100644 index 00000000..6232e28d --- /dev/null +++ b/README_ocpp16.md @@ -0,0 +1,607 @@ +# Open OCPP 1.6 + +## Table of contents + +- [Open OCPP 1.6](#open-ocpp-1.6) + - [Table of contents](#table-of-contents) + - [Features](#features) + - [Key features](#key-features) + - [Supported OCPP feature profiles](#supported-ocpp-feature-profiles) + - [Supported OCPP configuration keys](#supported-ocpp-configuration-keys) + - [OCPP security extensions](#ocpp-security-extensions) + - [Security profiles](#security-profiles) + - [Security events](#security-events) + - [Extended trigger messages](#extended-trigger-messages) + - [Certificate management](#certificate-management) + - [Signed firmware update](#signed-firmware-update) + - [OCPP ISO15118 PnC extensions](#ocpp-iso15118-pnc-extensions) + - [Charge Point role](#charge-point-role) + - [Central System role](#central-system-role) + - [Internal configuration keys](#internal-configuration-keys) + - [Common keys](#common-keys) + - [Charge Point keys](#charge-point-keys) + - [Central System keys](#central-system-keys) + - [Local Controller keys](#local-controller-keys) + - [Quick start](#quick-start) + - [Charge Point role](#charge-point-role-1) + - [Configuration interface](#configuration-interface) + - [Event handler interface](#event-handler-interface) + - [Charge Point object](#charge-point-object) + - [Central System role](#central-system-role-1) + - [Configuration interface](#configuration-interface-1) + - [Event handler interfaces](#event-handler-interfaces) + - [Central System object](#central-system-object) + +## Features + +### Key features +**Open OCPP** is composed of the 4 layers defined by the protocol : + +* Websockets (Client or Server) +* OCPP-J RPC +* JSON messages serialization/deserialization +* OCPP role (Charge Point, Central System or Local Controller) + +As of this version : + +* All the messages defined in the OCPP 1.6 edition 2 protocol have been implemented +* All the configuration keys defined in the OCPP 1.6 edition 2 protocol have been implemented for the Charge Point role +* All the messages defined in the OCPP 1.6 security whitepaper edition 2 have been implemented +* All the messages defined in the Using ISO 15118 Plug & Charge with OCPP 1.6 Application Note v1.0 have been implemented + +The user application will have to implement some callbacks to provide the data needed by **Open OCPP** or to handle OCPP events (boot notification, remote start/stop notifications, meter values...). + +The persistent data handled by **Open OCPP** is stored into a single file which is an [SQLite](https://www.sqlite.org/) database. It contains : + +* For Charge Point role : + + + Internal configuration + + Persistent data : Central System's registration status, connector state, OCPP transaction related messages when offline, StopTx meter values + + Badge cache and local list + + Smart charging profile + + Logs + * X.509 Certificates + +* For Central System or Local Controller role : + + + Internal configuration + + Logs + +The standard OCPP configuration persistency has to be handled by the user application. + +### Supported OCPP feature profiles + +| Profile | Description | Restrictions | +| :------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------- | +| Core | Basic Charge Point functionality comparable with OCPP 1.5 [OCPP1.5] without support for firmware updates, local authorization list management and reservations | OCPP confguration persistency has to be handled by the user application | +| Firmware Management | Support for firmware update management and diagnostic log file download | Actual file download/upload as well as firmware installation must be handled by the user application in the callbacks provided by **Open OCPP** | +| Local Auth List Management | Features to manage the local authorization list in Charge Points | None | +| Reservation | Support for reservation of a Charge Point. | None | +| Smart Charging | Support for basic Smart Charging, for instance using control pilot | GetCompositeSchedule is not supported for connector 0 in Charge Point role | +| Remote Trigger | Support for remote triggering of Charge Point initiated messages | None | + +### Supported OCPP configuration keys + +The OCPP configuration keys support applies to Charge Point role only. + +In the "Owner" column, "S" means that the configuration key behavior is handled by the stack, "U" means that it must handled by the user application. + +| Key | Owner | Restrictions | +| :-------------------------------------: | :---: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| AllowOfflineTxForUnknownId | S | None | +| AuthorizationCacheEnabled | S | None | +| AuthorizeRemoteTxRequests | U | None | +| BlinkRepeat | U | None | +| ClockAlignedDataInterval | S | None | +| ConnectionTimeOut | U | None | +| ConnectorPhaseRotation | U | None | +| ConnectorPhaseRotationMaxLength | U | None | +| GetConfigurationMaxKeys | S | Must be set to the sum of OCPP configuration keys count (49) + user application configuration keys count to allow to export all the configuration in 1 message | +| HeartbeatInterval | S | Heartbeat are only sent if no messages have been exchanged since HeartbeatInterval seconds | +| LightIntensity | U | None | +| LocalAuthorizeOffline | S | None | +| LocalPreAuthorize | S | None | +| MaxEnergyOnInvalidId | U | None | +| MeterValuesAlignedData | S+U | User application must validate the requested meter value list according to its metering capacities when modified by the Central System | +| MeterValuesAlignedDataMaxLength | S | None | +| MeterValuesSampledData | S+U | User application must validate the requested meter value list according to its metering capacities when modified by the Central System | +| MeterValuesSampledDataMaxLength | S | None | +| MeterValueSampleInterval | S | None | +| MinimumStatusDuration | S | None | +| NumberOfConnectors | S | None | +| ResetRetries | U | None | +| StopTransactionOnEVSideDisconnect | U | None | +| StopTransactionOnInvalidId | U | None | +| StopTxnAlignedData | S+U | User application must validate the requested meter value list according to its metering capacities when modified by the Central System | +| StopTxnAlignedDataMaxLength | S | None | +| StopTxnSampledData | S+U | User application must validate the requested meter value list according to its metering capacities when modified by the Central System | +| StopTxnSampledDataMaxLength | S | None | +| SupportedFeatureProfiles | S | None | +| SupportedFeatureProfilesMaxLength | S | None | +| TransactionMessageAttempts | S | None | +| TransactionMessageRetryInterval | S | None | +| UnlockConnectorOnEVSideDisconnect | U | None | +| WebSocketPingInterval | S | Reboot required | +| LocalAuthListEnabled | S | None | +| LocalAuthListMaxLength | S | None | +| SendLocalListMaxLength | S | None | +| ReserveConnectorZeroSupported | S | None | +| ChargeProfileMaxStackLevel | S | None | +| ChargingScheduleAllowedChargingRateUnit | S | None | +| ChargingScheduleMaxPeriods | S | None | +| ConnectorSwitch3to1PhaseSupported | S | None | +| MaxChargingProfilesInstalled | S | None | +| AdditionalRootCertificateCheck | U/S | If internal certificate management is enabled, the stack handle this parameter (implemented behavior for now is the always the one corresponding to AdditionalRootCertificateCheck = False), otherwise it must be the user application | +| AuthorizationKey | S | None | +| CertificateSignedMaxChainSize | S | None | +| CertificateStoreMaxLength | U/S | If internal certificate management is enabled, the stack handle this parameter, otherwise it must be the user application | +| CpoName | S | None | +| SecurityProfile | S | None | +| SupportedFileTransferProtocols | U | None | +| CentralContractValidationAllowed | S | None | +| CertSigningWaitMinimum | S | None | +| CertSigningRepeatTimes | S | None | +| ContractValidationOffline | U/S | The stack will notify the user application for contract validation depending on the value of this parameter | +| ISO15118PnCEnabled | S | None | + +### OCPP security extensions + +#### Security profiles + +**Open OCPP** support the following Security Profiles for both Charge Point and Central System roles : + +* 0 : No security profile +* 1 : Unsecured Transport with HTTP Basic Authentication +* 2 : TLS with HTTP Basic Authentication +* 3 : TLS with Client Side Certificates + +In Charge Point role, the stack will automatically disconnect and then reconnect using the new parameters to the Central System after one of the following parameters has been modified : +* **AuthorizationKey** +* **Security Profile** + +**Restriction** : The automatic fallback to old connection parameters if the connection fails after switching to a new security is not implemented yet. + +#### Security events + +**Open OCPP** support the whole use cases of security events and logging. + +In Charge Point role, it can optionnaly handle the storage of the security event log and the generation of the security log export when the Central System asks it. To enable/disable this feature, you have to modify the **SecurityLogMaxEntriesCount** charge point configuration key : + +* 0 = **Open OCPP** will not store security event and the security log must be generated by the user application +* \>0 = **Open OCPP** will store at max **SecurityLogMaxEntriesCount** (circular log) and will automatically generate the security log as a CSV file + +In Charge Point role, the user application can generate custom security events and defines its criticity so that they are forwarded to the Central System. + +In Charge Point role, the notification of security events can be enabled or disabled with the **SecurityEventNotificationEnabled** configuration key. This can be usefull to disable them when the Central System does not implement the security extensions. + +#### Extended trigger messages + +**Open OCPP** support this feature for both Charge Point and Central System roles. + +#### Certificate management + +**Open OCPP** support this feature for both Charge Point and Central System roles. + +The behavior of this feature is controlled by the **InternalCertificateManagementEnabled** configuration key. + +If **InternalCertificateManagementEnabled** is set to **false**, the actual storage of the certificates and their keys must be done by the user application. **Open OCPP** provides callbacks and helper classes to ease certificate manipulation and installation. The user application also has to configure the path to the installed certificates for the establishment of the secure connections using the following configuration keys : + +* TlsServerCertificateCa +* TlsClientCertificate +* TlsClientCertificatePrivateKey +* TlsClientCertificatePrivateKeyPassphrase + +If **InternalCertificateManagementEnabled** is set to **true**, the storage of certificates and their keys is fully handled by **Open OCPP**. The user application just has to provide a passphrase using the **TlsClientCertificatePrivateKeyPassphrase** configuration key to securily encrypt the certicates' private keys using AES-256-CBC algorithm. **Open OCPP** will automatically use the installed corresponding certificates depending on the configured Security Profile and the certificates validity dates. + +**Restriction** : The automatic fallback to old certificate if the connection fails after installing new certificate is not implemented yet. + +#### Signed firmware update + +**Open OCPP** support this feature for both Charge Point and Central System roles. + +**Open OCPP** provides helper classes based on OpenSSL to ease private keys, certificate and certificate requests usage : generation, signature, verification. They can be used in the user application callbacks. These helpers can be found in the ocpp::tools::x509 namespace and are widely used in the **Open OCPP** source code and examples. + +### OCPP ISO15118 PnC extensions + +**Open OCPP** fully supports the whole messaging, data types and configuration keys set associated to the ISO15118 PnC extensions. + +#### Charge Point role + +In Charge Point role these extensions consists mainly on forwarding messages from the ISO15118-2 stack layer to the Central System by using dedicated DataTransfer messages. + +**Open OCPP** implements the forwarding and provides callback and retries capabilities for certificates messages. + +Allthough **Open OCPP** is able to manage a certificate store, the Charge Point certificate used for ISO15118 communication won't be stored in it even if the **InternalCertificateManagementEnabled** configuration key is set to **true**. This is will allow for the ISO15118-2 stack to access this certificate and use it to secure its communications with the vehicule. + +#### Central System role + +In Central System role these extensions consists mainly in certificate management by forwarding request either to OCSP server or Mobility Operators. + +**Open OCPP** provides callbacks where the forwarding to the necessary servers must be implemented. + +### Internal configuration keys + +The behavior and the configuration of the **Open OCPP** stack can be modified through configuration keys. Some are specific to an OCPP role and some are common. + +#### Common keys + +| Key | Type | Description | +| :----------------: | :----: | :------------------------------------------------------------------ | +| DatabasePath | string | Path to the database to store persistent data | +| JsonSchemasPath | string | Path to the JSON schemas to validate the messages | +| CallRequestTimeout | uint | Call request timeout in milliseconds | +| Tlsv12CipherList | string | List of authorized ciphers for TLSv1.2 connections (OpenSSL format) | +| Tlsv13CipherList | string | List of authorized ciphers for TLSv1.3 connections (OpenSSL format) | +| LogMaxEntriesCount | uint | Maximum number of entries in the log (0 = no logs in database) | + +#### Charge Point keys + +| Key | Type | Description | +| :---------------------------------------------: | :----: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| ConnexionUrl | string | URL of the Central System | +| ChargePointIdentifier | string | OCPP Charge Point identifier. Will be concatanated with the **ConnexionUrl** key | +| ConnectionTimeout | uint | Connection timeout in milliseconds | +| RetryInterval | uint | Retry interval when connection has failed in milliseconds | +| ChargeBoxSerialNumber | string | Deprecated. Charge Box serial number for BootNotification message | +| ChargePointModel | string | Charge Point model for BootNotification message | +| ChargePointSerialNumber | string | Charge Point serial number for BootNotification message | +| ChargePointVendor | string | Charge Point vendor for BootNotification message | +| FirmwareVersion | string | Charge Point firmware version for BootNotification message | +| Iccid | string | ICCID of the moden's SIM card for BootNotification message | +| Imsi | string | IMSI of the moden's SIM card for BootNotification message | +| MeterSerialNumber | string | Main electrical meter serial number for BootNotification message | +| MeterType | string | Main electrical meter type for BootNotification message | +| OperatingVoltage | float | Nominal operating voltage (needed for Watt to Amp conversions in smart charging profiles) | +| AuthentCacheMaxEntriesCount | uint | Maximum number of entries in the authentication cache | +| TlsServerCertificateCa | string | Path to Certification Authority signing chain to validate the Central System certificate | +| TlsClientCertificate | string | Path to Charge Point certificate | +| TlsClientCertificatePrivateKey | string | Path to Charge Point's certificate's private key | +| TlsClientCertificatePrivateKeyPassphrase | string | Charge Point certificate's private key passphrase | +| TlsAllowSelfSignedCertificates | bool | Allow TLS connections using self-signed certificates (Warning : enabling this feature is not recommended in production) | +| TlsAllowExpiredCertificates | bool | Allow TLS connections using expired certificates (Warning : enabling this feature is not recommended in production) | +| TlsAcceptNonTrustedCertificates | bool | Accept non trusted certificates for TLS connections (Warning : enabling this feature is not recommended in production) | +| TlsSkipServerNameCheck | bool | Skip server name check in certificates for TLS connections (Warning : enabling this feature is not recommended in production) | +| InternalCertificateManagementEnabled | bool | If true, certificates are stored inside **Open OCPP** databasen otherwise user application has to handle them | +| SecurityEventNotificationEnabled | bool | Enable security event notification | +| SecurityLogMaxEntriesCount | uint | Maximum number of entries in the security log (0 = no security logs in database) | +| ClientCertificateRequestHashType | string | Hash type for certificate request generation : sha256, sha384 or sha512 | +| ClientCertificateRequestKeyType | string | Key type for certificate request generation : ec or rsa | +| ClientCertificateRequestRsaKeyLength | uint | Length in bits of the key for certificate request generation if rsa has been selected for key type : minimum 2048 | +| ClientCertificateRequestEcCurve | string | Name of the elliptic curve for certificate request generation if ec has been selected for key type : prime256v1, secp256k1, secp384r1, secp521r1, brainpoolP256t1, brainpoolP384t1 or brainpoolP512t1 | +| ClientCertificateRequestSubjectCountry | string | Country for the subject field of certificate request generation (can be left empty) | +| ClientCertificateRequestSubjectState | string | State for the subject field of certificate request generation (can be left empty) | +| ClientCertificateRequestSubjectLocation | string | Location for the subject field of certificate request generation (can be left empty) | +| ClientCertificateRequestSubjectOrganizationUnit | string | Organization unit for the subject field of certificate request generation (can be left empty) | +| ClientCertificateRequestSubjectEmail | string | Email for the subject field of certificate request generation (can be left empty) | + +#### Central System keys + +| Key | Type | Description | +| :--------------------------------------: | :----: | :----------------------------------------------------------------------------------------------------------- | +| ListenUrl | string | URL to listen to incomming websocket connections | +| WebSocketPingInterval | uint | Websocket PING interval in seconds | +| BootNotificationRetryInterval | uint | Boot notification retry interval in second (sent in BootNotificationConf when status is Pending or Rejected) | +| HeartbeatInterval | uint | Heartbeat interval in seconds (sent in BootNotificationConf when status is Accepted) | +| HttpBasicAuthent | bool | If set to true, the Charge Points must autenticate themselves using HTTP Basic Authentication method | +| TlsEcdhCurve | string | ECDH curve to use for TLS connections with EC keys | +| TlsServerCertificate | string | Path to the Central System's certificate | +| TlsServerCertificatePrivateKey | string | Path to the Central System's certificate's private key | +| TlsServerCertificatePrivateKeyPassphrase | string | Central System's certificate's private key passphrase | +| TlsServerCertificateCa | string | Path to the Certification Authority signing chain for the Central System's certificate | +| TlsClientCertificateAuthent | bool | If set to true, the Charge Points must authenticate themselves using an X.509 certificate | + +#### Local Controller keys + +| Key | Type | Description | +| :--------------------------------------: | :----: | :---------------------------------------------------------------------------------------------------------------------------------------- | +| ListenUrl | string | URL to listen to incomming websocket connections | +| WebSocketPingInterval | uint | Websocket PING interval in seconds | +| HttpBasicAuthent | bool | If set to true, the Charge Points must autenticate themselves using HTTP Basic Authentication method | +| TlsEcdhCurve | string | ECDH curve to use for TLS connections with EC keys | +| TlsServerCertificate | string | Path to the Central System's certificate | +| TlsServerCertificatePrivateKey | string | Path to the Central System's certificate's private key | +| TlsServerCertificatePrivateKeyPassphrase | string | Central System's certificate's private key passphrase | +| TlsServerCertificateCa | string | Path to the Certification Authority signing chain for the Central System's certificate | +| TlsClientCertificateAuthent | bool | If set to true, the Charge Points must authenticate themselves using an X.509 certificate | +| DisconnectFromCpWhenCsDisconnected | bool | If set to true, the Charge Point is automatically disconnected when the connection to the Central System cannot be established or is lost | + +## Quick start + +The best way to start is to take a look at the [examples](./examples/README.md) and more specifically at the [quick start Charge Point example](./examples/ocpp16/quick_start_chargepoint/README.md), the [quick start Central System example](./examples/ocpp16/quick_start_centralsystem/README.md) and the [quick start Local Controller example](./examples/ocpp16/quick_start_localcontroller/README.md). + +### Charge Point role + +The implementation of a program using **Open OCPP** in Charge Point role is done in 3 steps : +* Implementation of the configuration interfaces [IOcppConfig](./src/ocpp16/config/IOcppConfig.h) and [IChargePointConfig](./src/ocpp16/chargepoint/interface/IChargePointConfig.h) +* Implementation of the event handler interface [IChargePointEventsHandler](./src/ocpp16/chargepoint/interface/IChargePointEventsHandler.h) +* Instanciation and use of the Charge Point object [IChargePoint](./src/ocpp16/chargepoint/interface/IChargePoint.h) + +#### Configuration interface + +The configuration interface allow **Open OCPP** to access to the values of the standard OCPP configuration keys and to the user application specific configuration keys. + +The persistency of OCPP configuration key is not handled by **Open OCPP** for 2 main reasons : + +* The user application will surely already have a configuration management component +* The user application may have to access the OCPP configuration keys or may want to export its own keys already managed by its configuration component + +The configuration interface is split in 2 parts : + +* IOcppConfig : interface to access OCPP configuration keys and user application specific configuration keys +* IChargePointConfig : interface to access Charge Point configuration (database paths, url, ...) + +In the examples, the interfaces have been implemented to retrieve the values from a file stored into an INI format. This is a simple implementaton which is good to show how to implement these interfaces but which is not the most optimized one since every access to a configuration value implies a conversion from a string. Try to have a better implementation to boost the performances of the software ;) + +#### Event handler interface + +Most of the OCPP behavior is handled by **Open OCPP** but to complete the implementation of the OCPP standard, some information may be needed by **Open OCPP** (Meter values, change availability permissions...) or some operations may be done by the user application (File upload/download, firmware install...). + +The event handler interface defines all these interaction as well as some usefull notifications to the user application : connection status, registration status, reservation status... + +Most of the notifications/operations can be left empty if the corresponding OCPP feature is not used by the user application. See inside the examples how to implement unused functionalities. + +Please keep in mind that all the calls to the event handler interface are made from different threads managed by **Open OCPP** depending the kind of notification/operation and that the treatment of theses calls must not be blocking (except for file upload/download) since it will have an impact to the global scheduling of **Open OCPP**. + +#### Charge Point object + +This is the easiest part :) + +The Charge Point object is instanciated through a factory interface : + +``` +/** + * @brief Instanciate a charge point + * @param stack_config Stack configuration + * @param ocpp_config Standard OCPP configuration + * @param event_handler Stack event handler + */ +static std::unique_ptr create(const ocpp::config::IChargePointConfig& stack_config, + ocpp::config::IOcppConfig& ocpp_config, + IChargePointEventsHandler& events_handler); +``` + +The 3 parameters are the instances of the interfaces you have implemented in the previous steps. + +Before starting the Charge Point object and thus the OCPP stack with the ```start()``` method, you can clear existing persistent data using the following methods: + +* ```resetConnectorData()``` : clear all connector related data +* ```resetData()``` : clear all the persistent data + +Once the Charge Point object has been started, **Open OCPP** will continuously try to connect/keep alive the communication with the Central System until a call to the ```stop()``` method which will disconnect and release the connection. + +Connectivity status, registration status and Central System initiated operations will be notified through the event handler interface. + +OCPP Charge Point operations are triggered by the Charge Point object interface. + +Extract of a quick start main() : + +``` +int main() +{ + // Configuration + ChargePointDemoConfig config("config.ini"); + + // Event handler + DefaultChargePointEventsHandler event_handler(config); + + // Instanciate charge point + std::unique_ptr charge_point = IChargePoint::create(config.stackConfig(), config.ocppConfig(), event_handler); + charge_point->start(); + + // From now on the stack is alive :) + + // App loop + while (true) + { + // Wait to be accepted by Central System + while (charge_point->getRegistrationStatus() != RegistrationStatus::Accepted) + { + std::this_thread::sleep_for(std::chrono::milliseconds(100u)); + } + + // Ask for authorization on a tag + std::string parent_id; + std::string id_tag = "AABBCCDDEEFF"; + AuthorizationStatus status = charge_point->authorize(connector_id, id_tag, parent_id); + if (status == AuthorizationStatus::Accepted) + { + std::cout << "Id tag authorized, parent id = " << parent_id << std::endl; + + // Preparing state + charge_point->statusNotification(connector_id, ChargePointStatus::Preparing); + std::this_thread::sleep_for(std::chrono::seconds(1u)); + + // Try to start charging session + status = charge_point->startTransaction(connector_id, id_tag); + if (status == AuthorizationStatus::Accepted) + { + std::cout << "Transaction authorized, start charging" << std::endl; + + // Charging state + charge_point->statusNotification(connector_id, ChargePointStatus::Charging); + std::this_thread::sleep_for(std::chrono::seconds(30u)); + + // End transaction + charge_point->stopTransaction(connector_id, id_tag, Reason::Local); + + // Finishing state + charge_point->statusNotification(connector_id, ChargePointStatus::Finishing); + std::this_thread::sleep_for(std::chrono::seconds(1u)); + } + else + { + std::cout << "Transaction not authorized by Central System : " << AuthorizationStatusHelper.toString(status) + << std::endl; + } + + // Available state + charge_point->statusNotification(connector_id, ChargePointStatus::Available); + } + else + { + std::cout << "Id tag not authorized by Central System : " << AuthorizationStatusHelper.toString(status) << std::endl; + } + + // Wait before next charging session + std::this_thread::sleep_for(std::chrono::seconds(10u)); + } + + return 0; +} +``` + +### Central System role + +The implementation of a program using **Open OCPP** in Central System role is done in 3 steps : +* Implementation of the configuration interface [ICentralSystemConfig](./src/ocpp16/centralsystem/interface/ICentralSystemConfig.h) +* Implementation of the event handler interfaces [ICentralSystemEventsHandler](./src/ocpp16/centralsystem/interface/ICentralSystemEventsHandler.h) and [IChargePointRequestHandler](./src/ocpp16/centralsystem/interface/IChargePointRequestHandler.h) +* Instanciation and use of the Central System object [ICentralSystem](./src/ocpp16/centralsystem/interface/ICentralSystem.h) + +#### Configuration interface + +The configuration interface allow **Open OCPP** to access to its configuration values. +The persistency of the configuration is not handled by **Open OCPP** for 2 main reasons : + +* The user application will surely already have a configuration management component +* The user application may have to access the **Open OCPP** configuration + +In the examples, the interface has been implemented to retrieve the values from a file stored into an INI format. This is a simple implementaton which is good to show how to implement this interface but which is not the most optimized one since every access to a configuration value implies a conversion from a string. Try to have a better implementation to boost the performances of the software ;) + +#### Event handler interfaces + +In Central System role, the OCPP behavior must be implemented by the user application. **Open OCPP** handles all the other layers of the stack (websocket, RPC, JSON serialization/deserialization). + +The **Open OCPP** stack will interact with the user application through 2 interfaces : + +* [ICentralSystemEventsHandler](./src/ocpp16/centralsystem/interface/ICentralSystemEventsHandler.h) : used for all connection related events (credentials check, connection notification...) +* [IChargePointRequestHandler](./src/ocpp16/centralsystem/interface/IChargePointRequestHandler.h) : used to handle incoming requests from a Charge Point (boot notification, status notification, start transaction...) + +The **ICentralSystemEventsHandler** must be instanciated only once for a Central System implementation. + +The **IChargePointRequestHandler** must be instanciated and registered to each connected Charge Point in the **ICentralSystemEventsHandler::chargePointConnected** method implementation. + +Example of Charge Point connection handling : + +``` +/** @copydoc bool ICentralSystemEventsHandler::chargePointConnected(std::shared_ptr) */ +void MyCentralSystemEventsHandler::chargePointConnected(std::shared_ptr chargepoint) +{ + cout << "Charge point [" << chargepoint->identifier() << "] connected" << endl; + auto iter_chargepoint = m_chargepoints.find(chargepoint->identifier()); + if (iter_chargepoint == m_chargepoints.end()) + { + MyChargePointRequestHandler* my_handler = new MyChargePointRequestHandler(*this, chargepoint); + chargepoint->registerHandler(*my_handler); + m_chargepoints[chargepoint->identifier()] = + std::shared_ptr(my_handler); + } + else + { + cout << "Charge point [" << chargepoint->identifier() << "] already connected" << endl; + chargepoint.reset(); + } +} +``` + +Please keep in mind that all the calls to the event handler interface are made from different threads managed by **Open OCPP** depending the kind of notification/operation and that the treatment of theses calls must not be blocking since it will have an impact to the global scheduling of **Open OCPP**. + +#### Central System object + +This is the easiest part :) + +The Central System object is instanciated through a factory interface : + +``` +/** + * @brief Instanciate a central system + * @param stack_config Stack configuration + * @param event_handler Stack event handler +*/ +static std::unique_ptr create(const ocpp::config::ICentralSystemConfig& stack_config, + ICentralSystemEventsHandler& events_handler); +``` + +The 2 parameters are the instances of the interfaces you have implemented in the previous steps. + +Before starting the Central System object and thus the OCPP stack with the ```start()``` method, you can clear existing persistent data using the following method: + +```resetData()``` : clear all the persistent data + +Once the Central System object has been started, **Open OCPP** will continuously listen to incoming connections from the Charge Points until a call to the ```stop()``` method which will disconnect all the Charge Points and release the connection. + +Connectivity status and Charge Point initiated operations will be notified through the event handler interfaces. + +OCPP Central System operations are triggered by the Charge Point proxy interface [ICentralSystem::IChargePoint](./src/ocpp16/centralsystem/interface/ICentralSystem.h) which is instanciated by **Open OCPP** for each connected Charge Point. + +Extract of a quick start main() : + +``` +int main() +{ + // Configuration + CentralSystemDemoConfig config("config.ini"); + + // Event handler + CentralSystemDemoConfig event_handler(config); + + // Instanciate central system + std::unique_ptr central_system = ICentralSystem::create(config.stackConfig(), event_handler); + central_system->start(); + + // From now on the stack is alive :) + + // App loop + while (true) + { + // Wait for at least 1 connected charge point + while (event_handler.chargePoints().size() == 0) + { + std::this_thread::sleep_for(std::chrono::milliseconds(250)); + } + std::this_thread::sleep_for(std::chrono::seconds(1)); + + // For each connected charge point + for (auto& iter_chargepoint : event_handler.chargePoints()) + { + { + auto chargepoint = iter_chargepoint.second->proxy(); + + std::cout << "---------------------------------------------" << std::endl; + std::cout << "Charge point : " << chargepoint->identifier() << std::endl; + std::cout << "---------------------------------------------" << std::endl; + + std::cout << "Read whole charge point configuration..." << std::endl; + std::vector keys; + std::vector config_keys; + std::vector unknown_keys; + if (chargepoint->getConfiguration(keys, config_keys, unknown_keys)) + { + std::cout << "Configuration keys :" << std::endl; + for (const KeyValue& key_value : config_keys) + { + std::cout << " - " << key_value.key.str() << " = " << (key_value.value.isSet() ? key_value.value.value().str() : "") + << " " << (key_value.readonly ? "(read-only)" : "") << std::endl; + } + } + else + { + std::cout << "Failed!" << std::endl; + } + + std::cout << "Configure heartbeat interval..." << std::endl; + ConfigurationStatus config_status = chargepoint->changeConfiguration("HeartbeatInterval", "10"); + std::cout << ConfigurationStatusHelper.toString(config_status) << std::endl; + + std::cout << "Trigger status notification..." << std::endl; + TriggerMessageStatus trigger_status = + chargepoint->triggerMessage(MessageTrigger::StatusNotification, Optional()); + std::cout << TriggerMessageStatusHelper.toString(trigger_status) << std::endl; + } + + std::this_thread::sleep_for(std::chrono::seconds(10)); + } + } + + return 0; +} +``` diff --git a/README_ocpp20.md b/README_ocpp20.md new file mode 100644 index 00000000..c532b8df --- /dev/null +++ b/README_ocpp20.md @@ -0,0 +1,29 @@ +# Open OCPP 2.0.1 + +**Work in progress, we welcome any new contributor!** + +## Table of contents + +- [Open OCPP 2.0.1](#open-ocpp-2.0.1) + - [Table of contents](#table-of-contents) + - [Features](#features) + +## Features + +**Open OCPP** is composed of the 4 layers defined by the protocol : + +* Websockets (Client or Server) +* OCPP-J RPC +* JSON messages serialization/deserialization +* OCPP role (Charge Point, Central System or Local Controller) + +As of this version : + +* All the messages defined in the OCPP 2.0.1 protocol have been implemented (automatic generation from the JSON schemas provided by the OCA) +* A JSON based device model has been implemented +* The following roles have been implemented: + * Charge Point + * Central System + * Local Controller + +No behavior has been implemented yet for these roles, the user application will have to implement behaviors in the callbacks provided by the **Open OCPP** stack. diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 65c42f41..553c58e9 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,12 +1,5 @@ # Subdirectories add_subdirectory(common) -add_subdirectory(iso15118_chargepoint) -add_subdirectory(iso15118_centralsystem) -add_subdirectory(quick_start_centralsystem) -add_subdirectory(quick_start_chargepoint) -add_subdirectory(quick_start_cs_lc_hybrid) -add_subdirectory(quick_start_localcontroller) -add_subdirectory(remote_chargepoint) -add_subdirectory(security_centralsystem) -add_subdirectory(security_chargepoint) +add_subdirectory(ocpp16) +add_subdirectory(ocpp20) diff --git a/examples/README.md b/examples/README.md index 2138e6e3..38c9b96e 100644 --- a/examples/README.md +++ b/examples/README.md @@ -4,21 +4,21 @@ All the examples are licensed under the MIT license so that code can be used and The following examples are available for OCPP 1.6 standard : -* [Quick start Central System example](./quick_start_centralsystem/README.md) -* [Quick start Charge Point example](./quick_start_chargepoint/README.md) -* [Quick start Local Controller example](./quick_start_localcontroller/README.md) -* [Quick start Hybrid Central System / Local Controller example](./quick_start_cs_lc_hybrid/README.md) -* [Remote Charge Point example](./remote_chargepoint/README.md) +* [Quick start Central System example](./ocpp16/quick_start_centralsystem/README.md) +* [Quick start Charge Point example](./ocpp16/quick_start_chargepoint/README.md) +* [Quick start Local Controller example](./ocpp16/quick_start_localcontroller/README.md) +* [Quick start Hybrid Central System / Local Controller example](./ocpp16/quick_start_cs_lc_hybrid/README.md) +* [Remote Charge Point example](./ocpp16/remote_chargepoint/README.md) The following examples are available for OCPP 1.6 security extensions : -* [Security Central System example](./security_centralsystem/README.md) -* [Security Charge Point example](./security_chargepoint/README.md) +* [Security Central System example](./ocpp16/security_centralsystem/README.md) +* [Security Charge Point example](./ocpp16/security_chargepoint/README.md) The following examples are available for OCPP 1.6 IS015118 PnC extensions : -* [ISO15118 Central System example](./iso15118_centralsystem/README.md) -* [ISO15118 Charge Point example](./iso15118_chargepoint/README.md) +* [ISO15118 Central System example](./ocpp16/iso15118_centralsystem/README.md) +* [ISO15118 Charge Point example](./ocpp16/iso15118_chargepoint/README.md) How to run the examples: diff --git a/examples/common/CMakeLists.txt b/examples/common/CMakeLists.txt index 586be478..3440fc75 100644 --- a/examples/common/CMakeLists.txt +++ b/examples/common/CMakeLists.txt @@ -1,16 +1,10 @@ -# Common utility class for examples library -add_library(examples_common OBJECT - DefaultCentralSystemEventsHandler.cpp - DefaultChargePointEventsHandler.cpp - DefaultLocalControllerEventsHandler.cpp - - config/OcppConfig.cpp - +# Common utility classes for examples libraries +add_library(examples_common STATIC simulators/MainMeterSimulator.cpp simulators/MeterSimulator.cpp ) -target_include_directories(examples_common PUBLIC . config simulators) +target_include_directories(examples_common PUBLIC . simulators) # Dependencies if (NOT MSVC) diff --git a/examples/ocpp16/CMakeLists.txt b/examples/ocpp16/CMakeLists.txt new file mode 100644 index 00000000..65c42f41 --- /dev/null +++ b/examples/ocpp16/CMakeLists.txt @@ -0,0 +1,12 @@ + +# Subdirectories +add_subdirectory(common) +add_subdirectory(iso15118_chargepoint) +add_subdirectory(iso15118_centralsystem) +add_subdirectory(quick_start_centralsystem) +add_subdirectory(quick_start_chargepoint) +add_subdirectory(quick_start_cs_lc_hybrid) +add_subdirectory(quick_start_localcontroller) +add_subdirectory(remote_chargepoint) +add_subdirectory(security_centralsystem) +add_subdirectory(security_chargepoint) diff --git a/examples/ocpp16/common/CMakeLists.txt b/examples/ocpp16/common/CMakeLists.txt new file mode 100644 index 00000000..7fac2c73 --- /dev/null +++ b/examples/ocpp16/common/CMakeLists.txt @@ -0,0 +1,13 @@ + +# Common utility class for examples library +add_library(examples_common16 OBJECT + DefaultCentralSystemEventsHandler.cpp + DefaultChargePointEventsHandler.cpp + DefaultLocalControllerEventsHandler.cpp + + config/OcppConfig.cpp +) +target_include_directories(examples_common16 PUBLIC . config) + +# Dependencies +target_link_libraries(examples_common16 examples_common) diff --git a/examples/common/DefaultCentralSystemEventsHandler.cpp b/examples/ocpp16/common/DefaultCentralSystemEventsHandler.cpp similarity index 84% rename from examples/common/DefaultCentralSystemEventsHandler.cpp rename to examples/ocpp16/common/DefaultCentralSystemEventsHandler.cpp index 6a1ee8b1..1eeb9dd0 100644 --- a/examples/common/DefaultCentralSystemEventsHandler.cpp +++ b/examples/ocpp16/common/DefaultCentralSystemEventsHandler.cpp @@ -39,6 +39,7 @@ SOFTWARE. using namespace std; using namespace ocpp::centralsystem; using namespace ocpp::types; +using namespace ocpp::types::ocpp16; using namespace ocpp::x509; /** @brief Constructor */ @@ -159,8 +160,8 @@ void DefaultCentralSystemEventsHandler::ChargePointRequestHandler::disconnected( m_event_handler.removeChargePoint(m_chargepoint->identifier()); } -/** @copydoc ocpp::types::IdTagInfo IChargePointRequestHandler::authorize(const std::string&) */ -ocpp::types::IdTagInfo DefaultCentralSystemEventsHandler::ChargePointRequestHandler::authorize(const std::string& id_tag) +/** @copydoc ocpp::types::ocpp16::IdTagInfo IChargePointRequestHandler::authorize(const std::string&) */ +ocpp::types::ocpp16::IdTagInfo DefaultCentralSystemEventsHandler::ChargePointRequestHandler::authorize(const std::string& id_tag) { cout << "[" << m_chargepoint->identifier() << "] - Authorize : " << id_tag << endl; @@ -170,7 +171,7 @@ ocpp::types::IdTagInfo DefaultCentralSystemEventsHandler::ChargePointRequestHand return tag_info; } -/** @copydoc ocpp::types::RegistrationStatus IChargePointRequestHandler::bootNotification(const std::string&, +/** @copydoc ocpp::types::ocpp16::RegistrationStatus IChargePointRequestHandler::bootNotification(const std::string&, const std::string&, const std::string&, const std::string&, @@ -178,7 +179,7 @@ ocpp::types::IdTagInfo DefaultCentralSystemEventsHandler::ChargePointRequestHand const std::string&, const std::string&, const std::string&) */ -ocpp::types::RegistrationStatus DefaultCentralSystemEventsHandler::ChargePointRequestHandler::bootNotification( +ocpp::types::ocpp16::RegistrationStatus DefaultCentralSystemEventsHandler::ChargePointRequestHandler::bootNotification( const std::string& model, const std::string& serial_number, const std::string& vendor, @@ -196,7 +197,7 @@ ocpp::types::RegistrationStatus DefaultCentralSystemEventsHandler::ChargePointRe cout << "[" << m_chargepoint->identifier() << "] - Boot notification : vendor = " << vendor << " - model = " << model << " - s/n = " << serial_number << " - firmware = " << firmware_version << endl; - ocpp::types::RegistrationStatus ret = RegistrationStatus::Accepted; + ocpp::types::ocpp16::RegistrationStatus ret = RegistrationStatus::Accepted; if (m_event_handler.setPendingEnabled()) { if (!m_event_handler.isAcceptedChargePoint(m_chargepoint->identifier())) @@ -209,14 +210,12 @@ ocpp::types::RegistrationStatus DefaultCentralSystemEventsHandler::ChargePointRe return ret; } -/** @copydoc ocpp::types::DataTransferStatus IChargePointRequestHandler::dataTransfer(const std::string&, +/** @copydoc ocpp::types::ocpp16::DataTransferStatus IChargePointRequestHandler::dataTransfer(const std::string&, const std::string&, const std::string&, std::string&) */ -ocpp::types::DataTransferStatus DefaultCentralSystemEventsHandler::ChargePointRequestHandler::dataTransfer(const std::string& vendor_id, - const std::string& message_id, - const std::string& request_data, - std::string& response_data) +ocpp::types::ocpp16::DataTransferStatus DefaultCentralSystemEventsHandler::ChargePointRequestHandler::dataTransfer( + const std::string& vendor_id, const std::string& message_id, const std::string& request_data, std::string& response_data) { cout << "[" << m_chargepoint->identifier() << "] - Data transfer : vendor = " << vendor_id << " - message = " << message_id << " - data = " << request_data << endl; @@ -225,25 +224,27 @@ ocpp::types::DataTransferStatus DefaultCentralSystemEventsHandler::ChargePointRe return DataTransferStatus::UnknownVendorId; } -/** @copydoc void IChargePointRequestHandler::diagnosticStatusNotification(ocpp::types::DiagnosticsStatus) */ -void DefaultCentralSystemEventsHandler::ChargePointRequestHandler::diagnosticStatusNotification(ocpp::types::DiagnosticsStatus status) +/** @copydoc void IChargePointRequestHandler::diagnosticStatusNotification(ocpp::types::ocpp16::DiagnosticsStatus) */ +void DefaultCentralSystemEventsHandler::ChargePointRequestHandler::diagnosticStatusNotification( + ocpp::types::ocpp16::DiagnosticsStatus status) { cout << "[" << m_chargepoint->identifier() << "] - Diagnostic status notification : " << DiagnosticsStatusHelper.toString(status) << endl; } -/** @copydoc void IChargePointRequestHandler::firmwareStatusNotification(ocpp::types::FirmwareStatus) */ -void DefaultCentralSystemEventsHandler::ChargePointRequestHandler::firmwareStatusNotification(ocpp::types::FirmwareStatus status) +/** @copydoc void IChargePointRequestHandler::firmwareStatusNotification(ocpp::types::ocpp16::FirmwareStatus) */ +void DefaultCentralSystemEventsHandler::ChargePointRequestHandler::firmwareStatusNotification(ocpp::types::ocpp16::FirmwareStatus status) { cout << "[" << m_chargepoint->identifier() << "] - Firmware status notification : " << FirmwareStatusHelper.toString(status) << endl; } /** @copydoc void IChargePointRequestHandler::meterValues(unsigned int, const ocpp::types::Optional&, - const std::vector&) */ -void DefaultCentralSystemEventsHandler::ChargePointRequestHandler::meterValues(unsigned int connector_id, - const ocpp::types::Optional& transaction_id, - const std::vector& meter_values) + const std::vector&) */ +void DefaultCentralSystemEventsHandler::ChargePointRequestHandler::meterValues( + unsigned int connector_id, + const ocpp::types::Optional& transaction_id, + const std::vector& meter_values) { cout << "[" << m_chargepoint->identifier() << "] - Meter values : connector = " << connector_id << " - transaction = " << (transaction_id.isSet() ? std::to_string(transaction_id) : "not set") << endl; @@ -282,13 +283,13 @@ void DefaultCentralSystemEventsHandler::ChargePointRequestHandler::meterValues(u } } -/** @copydoc ocpp::types::IdTagInfo IChargePointRequestHandler::startTransaction(unsigned int, +/** @copydoc ocpp::types::ocpp16::IdTagInfo IChargePointRequestHandler::startTransaction(unsigned int, const std::string&, int, const ocpp::types::Optional&, const ocpp::types::DateTime&, int&) */ -ocpp::types::IdTagInfo DefaultCentralSystemEventsHandler::ChargePointRequestHandler::startTransaction( +ocpp::types::ocpp16::IdTagInfo DefaultCentralSystemEventsHandler::ChargePointRequestHandler::startTransaction( unsigned int connector_id, const std::string& id_tag, int meter_start, @@ -313,19 +314,19 @@ ocpp::types::IdTagInfo DefaultCentralSystemEventsHandler::ChargePointRequestHand } /** @copydoc void IChargePointRequestHandler::statusNotification(unsigned int, - ocpp::types::ChargePointErrorCode, + ocpp::types::ocpp16::ChargePointErrorCode, const std::string&, - ocpp::types::ChargePointStatus, + ocpp::types::ocpp16::ChargePointStatus, const ocpp::types::DateTime&, const std::string&, const std::string&) */ -void DefaultCentralSystemEventsHandler::ChargePointRequestHandler::statusNotification(unsigned int connector_id, - ocpp::types::ChargePointErrorCode error_code, - const std::string& info, - ocpp::types::ChargePointStatus status, - const ocpp::types::DateTime& timestamp, - const std::string& vendor_id, - const std::string& vendor_error) +void DefaultCentralSystemEventsHandler::ChargePointRequestHandler::statusNotification(unsigned int connector_id, + ocpp::types::ocpp16::ChargePointErrorCode error_code, + const std::string& info, + ocpp::types::ocpp16::ChargePointStatus status, + const ocpp::types::DateTime& timestamp, + const std::string& vendor_id, + const std::string& vendor_error) { (void)vendor_id; (void)vendor_error; @@ -335,27 +336,27 @@ void DefaultCentralSystemEventsHandler::ChargePointRequestHandler::statusNotific << " - info = " << info << " - timestamp = " << ((timestamp == DateTime(0)) ? "not set" : timestamp.str()) << endl; } -/** @copydoc ocpp::types::Optional IChargePointRequestHandler::stopTransaction( +/** @copydoc ocpp::types::Optional IChargePointRequestHandler::stopTransaction( const std::string&, int, const ocpp::types::DateTime&, int, - ocpp::types::Reason, - const std::vector&) */ -ocpp::types::Optional DefaultCentralSystemEventsHandler::ChargePointRequestHandler::stopTransaction( - const std::string& id_tag, - int meter_stop, - const ocpp::types::DateTime& timestamp, - int transaction_id, - ocpp::types::Reason reason, - const std::vector& transaction_data) + ocpp::types::ocpp16::Reason, + const std::vector&) */ +ocpp::types::Optional DefaultCentralSystemEventsHandler::ChargePointRequestHandler::stopTransaction( + const std::string& id_tag, + int meter_stop, + const ocpp::types::DateTime& timestamp, + int transaction_id, + ocpp::types::ocpp16::Reason reason, + const std::vector& transaction_data) { (void)transaction_data; cout << "[" << m_chargepoint->identifier() << "] - Stop transaction : transaction = " << transaction_id << " - id tag = " << (id_tag.empty() ? "not set" : id_tag) << " - meter stop = " << meter_stop << " - reason = " << ReasonHelper.toString(reason) << " - timestamp = " << timestamp.str() << endl; - ocpp::types::Optional ret; + ocpp::types::Optional ret; if (!id_tag.empty()) { IdTagInfo& tag_info = ret.value(); @@ -367,9 +368,9 @@ ocpp::types::Optional DefaultCentralSystemEventsHandler: // Security extensions -/** @copydoc void IChargePointRequestHandler::logStatusNotification(ocpp::types::UploadLogStatusEnumType, const ocpp::types::Optional&) */ -void DefaultCentralSystemEventsHandler::ChargePointRequestHandler::logStatusNotification(ocpp::types::UploadLogStatusEnumType status, - const ocpp::types::Optional& request_id) +/** @copydoc void IChargePointRequestHandler::logStatusNotification(ocpp::types::ocpp16::UploadLogStatusEnumType, const ocpp::types::Optional&) */ +void DefaultCentralSystemEventsHandler::ChargePointRequestHandler::logStatusNotification( + ocpp::types::ocpp16::UploadLogStatusEnumType status, const ocpp::types::Optional& request_id) { cout << "[" << m_chargepoint->identifier() << "] - Log status notification : status = " << UploadLogStatusEnumTypeHelper.toString(status) @@ -474,10 +475,10 @@ bool DefaultCentralSystemEventsHandler::ChargePointRequestHandler::signCertifica return ret; } -/** @copydoc void IChargePointRequestHandler::signedFirmwareUpdateStatusNotification(ocpp::types::FirmwareStatusEnumType, +/** @copydoc void IChargePointRequestHandler::signedFirmwareUpdateStatusNotification(ocpp::types::ocpp16::FirmwareStatusEnumType, const ocpp::types::Optional&) */ void DefaultCentralSystemEventsHandler::ChargePointRequestHandler::signedFirmwareUpdateStatusNotification( - ocpp::types::FirmwareStatusEnumType status, const ocpp::types::Optional& request_id) + ocpp::types::ocpp16::FirmwareStatusEnumType status, const ocpp::types::Optional& request_id) { cout << "[" << m_chargepoint->identifier() << "] - Signed firmware update status notification : status = " << FirmwareStatusEnumTypeHelper.toString(status) @@ -486,22 +487,22 @@ void DefaultCentralSystemEventsHandler::ChargePointRequestHandler::signedFirmwar // ISO 15118 PnC extensions -/** @copydoc ocpp::types::IdTokenInfoType IChargePointRequestHandler::iso15118Authorize( +/** @copydoc ocpp::types::ocpp16::IdTokenInfoType IChargePointRequestHandler::iso15118Authorize( const ocpp::x509::Certificate&, const std::string&, - const std::vector&, - ocpp::types::Optional&) override; */ -ocpp::types::IdTokenInfoType DefaultCentralSystemEventsHandler::ChargePointRequestHandler::iso15118Authorize( - const ocpp::x509::Certificate& certificate, - const std::string& id_token, - const std::vector& cert_hash_data, - ocpp::types::Optional& cert_status) + const std::vector&, + ocpp::types::Optional&) override; */ +ocpp::types::ocpp16::IdTokenInfoType DefaultCentralSystemEventsHandler::ChargePointRequestHandler::iso15118Authorize( + const ocpp::x509::Certificate& certificate, + const std::string& id_token, + const std::vector& cert_hash_data, + ocpp::types::Optional& cert_status) { cout << "[" << m_chargepoint->identifier() << "] - [ISO15118] Authorize : certificate = " << certificate.pem().size() << " - id_token = " << id_token << " - cert_hash_data size = " << cert_hash_data.size() << endl; // Prepare response - ocpp::types::IdTokenInfoType ret; + ocpp::types::ocpp16::IdTokenInfoType ret; ret.status = AuthorizationStatus::Invalid; // Check certificate if present @@ -524,16 +525,16 @@ ocpp::types::IdTokenInfoType DefaultCentralSystemEventsHandler::ChargePointReque return ret; } -/** @copydoc ocpp::types::Iso15118EVCertificateStatusEnumType IChargePointRequestHandler::iso15118GetEVCertificate( +/** @copydoc ocpp::types::ocpp16::Iso15118EVCertificateStatusEnumType IChargePointRequestHandler::iso15118GetEVCertificate( const std::string&, - ocpp::types::CertificateActionEnumType, + ocpp::types::ocpp16::CertificateActionEnumType, const std::string&, std::string&) */ -ocpp::types::Iso15118EVCertificateStatusEnumType DefaultCentralSystemEventsHandler::ChargePointRequestHandler::iso15118GetEVCertificate( - const std::string& iso15118_schema_version, - ocpp::types::CertificateActionEnumType action, - const std::string& exi_request, - std::string& exi_response) +ocpp::types::ocpp16::Iso15118EVCertificateStatusEnumType DefaultCentralSystemEventsHandler::ChargePointRequestHandler:: + iso15118GetEVCertificate(const std::string& iso15118_schema_version, + ocpp::types::ocpp16::CertificateActionEnumType action, + const std::string& exi_request, + std::string& exi_response) { cout << "[" << m_chargepoint->identifier() << "] - [ISO15118] Get EV certificate : iso15118_schema_version = " << iso15118_schema_version @@ -567,11 +568,11 @@ ocpp::types::Iso15118EVCertificateStatusEnumType DefaultCentralSystemEventsHandl return Iso15118EVCertificateStatusEnumType::Accepted; } -/** @copydoc ocpp::types::GetCertificateStatusEnumType IChargePointRequestHandler::iso15118GetCertificateStatus( - const ocpp::types::OcspRequestDataType&, +/** @copydoc ocpp::types::ocpp16::GetCertificateStatusEnumType IChargePointRequestHandler::iso15118GetCertificateStatus( + const ocpp::types::ocpp16::OcspRequestDataType&, std::string&) */ -ocpp::types::GetCertificateStatusEnumType DefaultCentralSystemEventsHandler::ChargePointRequestHandler::iso15118GetCertificateStatus( - const ocpp::types::OcspRequestDataType& ocsp_request, std::string& ocsp_result) +ocpp::types::ocpp16::GetCertificateStatusEnumType DefaultCentralSystemEventsHandler::ChargePointRequestHandler:: + iso15118GetCertificateStatus(const ocpp::types::ocpp16::OcspRequestDataType& ocsp_request, std::string& ocsp_result) { cout << "[" << m_chargepoint->identifier() diff --git a/examples/common/DefaultCentralSystemEventsHandler.h b/examples/ocpp16/common/DefaultCentralSystemEventsHandler.h similarity index 69% rename from examples/common/DefaultCentralSystemEventsHandler.h rename to examples/ocpp16/common/DefaultCentralSystemEventsHandler.h index e0eccea7..24078f69 100644 --- a/examples/common/DefaultCentralSystemEventsHandler.h +++ b/examples/ocpp16/common/DefaultCentralSystemEventsHandler.h @@ -82,10 +82,10 @@ class DefaultCentralSystemEventsHandler : public ocpp::centralsystem::ICentralSy /** @copydoc void IChargePointRequestHandler::disconnected() */ void disconnected() override; - /** @copydoc ocpp::types::IdTagInfo IChargePointRequestHandler::authorize(const std::string&) */ - ocpp::types::IdTagInfo authorize(const std::string& id_tag) override; + /** @copydoc ocpp::types::ocpp16::IdTagInfo IChargePointRequestHandler::authorize(const std::string&) */ + ocpp::types::ocpp16::IdTagInfo authorize(const std::string& id_tag) override; - /** @copydoc ocpp::types::RegistrationStatus IChargePointRequestHandler::bootNotification(const std::string&, + /** @copydoc ocpp::types::ocpp16::RegistrationStatus IChargePointRequestHandler::bootNotification(const std::string&, const std::string&, const std::string&, const std::string&, @@ -93,84 +93,85 @@ class DefaultCentralSystemEventsHandler : public ocpp::centralsystem::ICentralSy const std::string&, const std::string&, const std::string&) */ - ocpp::types::RegistrationStatus bootNotification(const std::string& model, - const std::string& serial_number, - const std::string& vendor, - const std::string& firmware_version, - const std::string& iccid, - const std::string& imsi, - const std::string& meter_serial_number, - const std::string& meter_type) override; - - /** @copydoc ocpp::types::DataTransferStatus IChargePointRequestHandler::dataTransfer(const std::string&, + ocpp::types::ocpp16::RegistrationStatus bootNotification(const std::string& model, + const std::string& serial_number, + const std::string& vendor, + const std::string& firmware_version, + const std::string& iccid, + const std::string& imsi, + const std::string& meter_serial_number, + const std::string& meter_type) override; + + /** @copydoc ocpp::types::ocpp16::DataTransferStatus IChargePointRequestHandler::dataTransfer(const std::string&, const std::string&, const std::string&, std::string&) */ - ocpp::types::DataTransferStatus dataTransfer(const std::string& vendor_id, - const std::string& message_id, - const std::string& request_data, - std::string& response_data) override; + ocpp::types::ocpp16::DataTransferStatus dataTransfer(const std::string& vendor_id, + const std::string& message_id, + const std::string& request_data, + std::string& response_data) override; - /** @copydoc void IChargePointRequestHandler::diagnosticStatusNotification(ocpp::types::DiagnosticsStatus) */ - void diagnosticStatusNotification(ocpp::types::DiagnosticsStatus status) override; + /** @copydoc void IChargePointRequestHandler::diagnosticStatusNotification(ocpp::types::ocpp16::DiagnosticsStatus) */ + void diagnosticStatusNotification(ocpp::types::ocpp16::DiagnosticsStatus status) override; - /** @copydoc void IChargePointRequestHandler::firmwareStatusNotification(ocpp::types::FirmwareStatus) */ - void firmwareStatusNotification(ocpp::types::FirmwareStatus status) override; + /** @copydoc void IChargePointRequestHandler::firmwareStatusNotification(ocpp::types::ocpp16::FirmwareStatus) */ + void firmwareStatusNotification(ocpp::types::ocpp16::FirmwareStatus status) override; /** @copydoc void IChargePointRequestHandler::meterValues(unsigned int, const ocpp::types::Optional&, - const std::vector&) */ - void meterValues(unsigned int connector_id, - const ocpp::types::Optional& transaction_id, - const std::vector& meter_values) override; + const std::vector&) */ + void meterValues(unsigned int connector_id, + const ocpp::types::Optional& transaction_id, + const std::vector& meter_values) override; - /** @copydoc ocpp::types::IdTagInfo IChargePointRequestHandler::startTransaction(unsigned int, + /** @copydoc ocpp::types::ocpp16::IdTagInfo IChargePointRequestHandler::startTransaction(unsigned int, const std::string&, int, const ocpp::types::Optional&, const ocpp::types::DateTime&, int&) */ - ocpp::types::IdTagInfo startTransaction(unsigned int connector_id, - const std::string& id_tag, - int meter_start, - const ocpp::types::Optional& reservation_id, - const ocpp::types::DateTime& timestamp, - int& transaction_id) override; + ocpp::types::ocpp16::IdTagInfo startTransaction(unsigned int connector_id, + const std::string& id_tag, + int meter_start, + const ocpp::types::Optional& reservation_id, + const ocpp::types::DateTime& timestamp, + int& transaction_id) override; /** @copydoc void IChargePointRequestHandler::statusNotification(unsigned int, - ocpp::types::ChargePointErrorCode, + ocpp::types::ocpp16::ChargePointErrorCode, const std::string&, - ocpp::types::ChargePointStatus, + ocpp::types::ocpp16::ChargePointStatus, const ocpp::types::DateTime&, const std::string&, const std::string&) */ - void statusNotification(unsigned int connector_id, - ocpp::types::ChargePointErrorCode error_code, - const std::string& info, - ocpp::types::ChargePointStatus status, - const ocpp::types::DateTime& timestamp, - const std::string& vendor_id, - const std::string& vendor_error) override; - - /** @copydoc ocpp::types::Optional IChargePointRequestHandler::stopTransaction( + void statusNotification(unsigned int connector_id, + ocpp::types::ocpp16::ChargePointErrorCode error_code, + const std::string& info, + ocpp::types::ocpp16::ChargePointStatus status, + const ocpp::types::DateTime& timestamp, + const std::string& vendor_id, + const std::string& vendor_error) override; + + /** @copydoc ocpp::types::Optional IChargePointRequestHandler::stopTransaction( const std::string&, int, const ocpp::types::DateTime&, int, - ocpp::types::Reason, - const std::vector&) */ - ocpp::types::Optional stopTransaction( - const std::string& id_tag, - int meter_stop, - const ocpp::types::DateTime& timestamp, - int transaction_id, - ocpp::types::Reason reason, - const std::vector& transaction_data) override; + ocpp::types::ocpp16::Reason, + const std::vector&) */ + ocpp::types::Optional stopTransaction( + const std::string& id_tag, + int meter_stop, + const ocpp::types::DateTime& timestamp, + int transaction_id, + ocpp::types::ocpp16::Reason reason, + const std::vector& transaction_data) override; // Security extensions - /** @copydoc void IChargePointRequestHandler::logStatusNotification(ocpp::types::UploadLogStatusEnumType, const ocpp::types::Optional&) */ - void logStatusNotification(ocpp::types::UploadLogStatusEnumType status, const ocpp::types::Optional& request_id) override; + /** @copydoc void IChargePointRequestHandler::logStatusNotification(ocpp::types::ocpp16::UploadLogStatusEnumType, const ocpp::types::Optional&) */ + void logStatusNotification(ocpp::types::ocpp16::UploadLogStatusEnumType status, + const ocpp::types::Optional& request_id) override; /** @copydoc void IChargePointRequestHandler::securityEventNotification(const std::string&, const ocpp::types::DateTime&, @@ -182,39 +183,40 @@ class DefaultCentralSystemEventsHandler : public ocpp::centralsystem::ICentralSy /** @copydoc bool IChargePointRequestHandler::signCertificate(const ocpp::x509::CertificateRequest&) */ bool signCertificate(const ocpp::x509::CertificateRequest& certificate_request) override; - /** @copydoc void IChargePointRequestHandler::signedFirmwareUpdateStatusNotification(ocpp::types::FirmwareStatusEnumType, + /** @copydoc void IChargePointRequestHandler::signedFirmwareUpdateStatusNotification(ocpp::types::ocpp16::FirmwareStatusEnumType, const ocpp::types::Optional&) */ - void signedFirmwareUpdateStatusNotification(ocpp::types::FirmwareStatusEnumType status, - const ocpp::types::Optional& request_id) override; + void signedFirmwareUpdateStatusNotification(ocpp::types::ocpp16::FirmwareStatusEnumType status, + const ocpp::types::Optional& request_id) override; // ISO 15118 PnC extensions - /** @copydoc ocpp::types::IdTokenInfoType IChargePointRequestHandler::iso15118Authorize( + /** @copydoc ocpp::types::ocpp16::IdTokenInfoType IChargePointRequestHandler::iso15118Authorize( const ocpp::x509::Certificate&, const std::string&, - const std::vector&, - ocpp::types::Optional&) override; */ - ocpp::types::IdTokenInfoType iso15118Authorize( - const ocpp::x509::Certificate& certificate, - const std::string& id_token, - const std::vector& cert_hash_data, - ocpp::types::Optional& cert_status) override; - - /** @copydoc ocpp::types::Iso15118EVCertificateStatusEnumType IChargePointRequestHandler::iso15118GetEVCertificate( + const std::vector&, + ocpp::types::Optional&) override; */ + ocpp::types::ocpp16::IdTokenInfoType iso15118Authorize( + const ocpp::x509::Certificate& certificate, + const std::string& id_token, + const std::vector& cert_hash_data, + ocpp::types::Optional& cert_status) override; + + /** @copydoc ocpp::types::ocpp16::Iso15118EVCertificateStatusEnumType IChargePointRequestHandler::iso15118GetEVCertificate( const std::string&, - ocpp::types::CertificateActionEnumType, + ocpp::types::ocpp16::CertificateActionEnumType, const std::string&, std::string&) */ - ocpp::types::Iso15118EVCertificateStatusEnumType iso15118GetEVCertificate(const std::string& iso15118_schema_version, - ocpp::types::CertificateActionEnumType action, - const std::string& exi_request, - std::string& exi_response) override; - - /** @copydoc ocpp::types::GetCertificateStatusEnumType IChargePointRequestHandler::iso15118GetCertificateStatus( - const ocpp::types::OcspRequestDataType&, + ocpp::types::ocpp16::Iso15118EVCertificateStatusEnumType iso15118GetEVCertificate( + const std::string& iso15118_schema_version, + ocpp::types::ocpp16::CertificateActionEnumType action, + const std::string& exi_request, + std::string& exi_response) override; + + /** @copydoc ocpp::types::ocpp16::GetCertificateStatusEnumType IChargePointRequestHandler::iso15118GetCertificateStatus( + const ocpp::types::ocpp16::OcspRequestDataType&, std::string&) */ - ocpp::types::GetCertificateStatusEnumType iso15118GetCertificateStatus(const ocpp::types::OcspRequestDataType& ocsp_request, - std::string& ocsp_result) override; + ocpp::types::ocpp16::GetCertificateStatusEnumType iso15118GetCertificateStatus( + const ocpp::types::ocpp16::OcspRequestDataType& ocsp_request, std::string& ocsp_result) override; /** @copydoc bool iso15118SignCertificate(const ocpp::x509::CertificateRequest&) */ bool iso15118SignCertificate(const ocpp::x509::CertificateRequest& certificate_request) override; diff --git a/examples/common/DefaultChargePointEventsHandler.cpp b/examples/ocpp16/common/DefaultChargePointEventsHandler.cpp similarity index 89% rename from examples/common/DefaultChargePointEventsHandler.cpp rename to examples/ocpp16/common/DefaultChargePointEventsHandler.cpp index 6f9af439..8f26f4fe 100644 --- a/examples/common/DefaultChargePointEventsHandler.cpp +++ b/examples/ocpp16/common/DefaultChargePointEventsHandler.cpp @@ -39,6 +39,7 @@ SOFTWARE. using namespace std; using namespace ocpp::types; +using namespace ocpp::types::ocpp16; using namespace ocpp::x509; /** @brief Constructor */ @@ -67,8 +68,8 @@ void DefaultChargePointEventsHandler::connectionUrlChanged(std::string const& ur cout << "Connection url changed to : " << url << endl; } -/** @copydoc void IChargePointEventsHandler::connectionStateChanged(ocpp::types::RegistrationStatus) */ -void DefaultChargePointEventsHandler::connectionFailed(ocpp::types::RegistrationStatus status) +/** @copydoc void IChargePointEventsHandler::connectionFailed(ocpp::types::ocpp16::RegistrationStatus) */ +void DefaultChargePointEventsHandler::connectionFailed(ocpp::types::ocpp16::RegistrationStatus status) { cout << "Connection failed, previous registration status : " << RegistrationStatusHelper.toString(status) << endl; } @@ -79,8 +80,9 @@ void DefaultChargePointEventsHandler::connectionStateChanged(bool isConnected) cout << "Connection state changed : " << isConnected << endl; } -/** @copydoc void IChargePointEventsHandler::bootNotification(ocpp::types::RegistrationStatus, const ocpp::types::DateTime&) */ -void DefaultChargePointEventsHandler::bootNotification(ocpp::types::RegistrationStatus status, const ocpp::types::DateTime& datetime) +/** @copydoc void IChargePointEventsHandler::bootNotification(ocpp::types::ocpp16::RegistrationStatus, const ocpp::types::DateTime&) */ +void DefaultChargePointEventsHandler::bootNotification(ocpp::types::ocpp16::RegistrationStatus status, + const ocpp::types::DateTime& datetime) { cout << "Bootnotification : " << RegistrationStatusHelper.toString(status) << " - " << datetime.str() << endl; } @@ -91,9 +93,9 @@ void DefaultChargePointEventsHandler::datetimeReceived(const ocpp::types::DateTi cout << "Date time received : " << datetime.str() << endl; } -/** @copydoc AvailabilityStatus IChargePointEventsHandler::changeAvailabilityRequested(unsigned int, ocpp::types::AvailabilityType) */ -ocpp::types::AvailabilityStatus DefaultChargePointEventsHandler::changeAvailabilityRequested(unsigned int connector_id, - ocpp::types::AvailabilityType availability) +/** @copydoc AvailabilityStatus IChargePointEventsHandler::changeAvailabilityRequested(unsigned int, ocpp::types::ocpp16::AvailabilityType) */ +ocpp::types::ocpp16::AvailabilityStatus DefaultChargePointEventsHandler::changeAvailabilityRequested( + unsigned int connector_id, ocpp::types::ocpp16::AvailabilityType availability) { cout << "Change availability requested : " << connector_id << " - " << AvailabilityTypeHelper.toString(availability) << endl; return AvailabilityStatus::Accepted; @@ -120,14 +122,14 @@ void DefaultChargePointEventsHandler::reservationEnded(unsigned int connector_id cout << "End of reservation on connector " << connector_id << " (" << (canceled ? "canceled" : "expired") << ")" << endl; } -/** @copydoc ocpp::types::DataTransferStatus IChargePointEventsHandler::dataTransferRequested(const std::string&, +/** @copydoc ocpp::types::ocpp16::DataTransferStatus IChargePointEventsHandler::dataTransferRequested(const std::string&, const std::string&, const std::string&, std::string&) */ -ocpp::types::DataTransferStatus DefaultChargePointEventsHandler::dataTransferRequested(const std::string& vendor_id, - const std::string& message_id, - const std::string& request_data, - std::string& response_data) +ocpp::types::ocpp16::DataTransferStatus DefaultChargePointEventsHandler::dataTransferRequested(const std::string& vendor_id, + const std::string& message_id, + const std::string& request_data, + std::string& response_data) { DataTransferStatus ret = DataTransferStatus::Accepted; cout << "Data transfer received : " << vendor_id << " - " << message_id << " - " << request_data << endl; @@ -156,11 +158,11 @@ ocpp::types::DataTransferStatus DefaultChargePointEventsHandler::dataTransferReq return ret; } -/** @copydoc bool getMeterValue(unsigned int, const std::pair>&, ocpp::types::MeterValue&) */ +/** @copydoc bool getMeterValue(unsigned int, const std::pair>&, ocpp::types::ocpp16::MeterValue&) */ bool DefaultChargePointEventsHandler::getMeterValue( - unsigned int connector_id, - const std::pair>& measurand, - ocpp::types::MeterValue& meter_value) + unsigned int connector_id, + const std::pair>& measurand, + ocpp::types::ocpp16::MeterValue& meter_value) { (void)meter_value; @@ -202,25 +204,25 @@ void DefaultChargePointEventsHandler::transactionDeAuthorized(unsigned int conne cout << "Transaction deauthorized on connector : " << connector_id << endl; } -/** @copydoc bool IChargePointEventsHandler::getLocalLimitationsSchedule(unsigned int, ocpp::types::ChargingSchedule&) */ -bool DefaultChargePointEventsHandler::getLocalLimitationsSchedule(unsigned int connector_id, - unsigned int duration, - ocpp::types::ChargingSchedule& schedule) +/** @copydoc bool IChargePointEventsHandler::getLocalLimitationsSchedule(unsigned int, ocpp::types::ocpp16::ChargingSchedule&) */ +bool DefaultChargePointEventsHandler::getLocalLimitationsSchedule(unsigned int connector_id, + unsigned int duration, + ocpp::types::ocpp16::ChargingSchedule& schedule) { (void)schedule; cout << "Local limitations schedule requested : " << connector_id << " - " << duration << endl; return false; } -/** @copydoc bool IChargePointEventsHandler::resetRequested(ocpp::types::ResetType) */ -bool DefaultChargePointEventsHandler::resetRequested(ocpp::types::ResetType reset_type) +/** @copydoc bool IChargePointEventsHandler::resetRequested(ocpp::types::ocpp16::ResetType) */ +bool DefaultChargePointEventsHandler::resetRequested(ocpp::types::ocpp16::ResetType reset_type) { cout << "Reset requested : " << ResetTypeHelper.toString(reset_type) << endl; return true; } -/** @copydoc ocpp::types::UnlockStatus IChargePointEventsHandler::unlockConnectorRequested(unsigned int) */ -ocpp::types::UnlockStatus DefaultChargePointEventsHandler::unlockConnectorRequested(unsigned int connector_id) +/** @copydoc ocpp::types::ocpp16::UnlockStatus IChargePointEventsHandler::unlockConnectorRequested(unsigned int) */ +ocpp::types::ocpp16::UnlockStatus DefaultChargePointEventsHandler::unlockConnectorRequested(unsigned int connector_id) { cout << "Unlock connector " << connector_id << " requested" << endl; return UnlockStatus::Unlocked; @@ -352,10 +354,10 @@ bool DefaultChargePointEventsHandler::downloadFile(const std::string& url, const // Security extensions -/** @copydoc ocpp::types::CertificateStatusEnumType IChargePointEventsHandler::caCertificateReceived(ocpp::types::CertificateUseEnumType, +/** @copydoc ocpp::types::ocpp16::CertificateStatusEnumType IChargePointEventsHandler::caCertificateReceived(ocpp::types::ocpp16::CertificateUseEnumType, const ocpp::x509::Certificate&) */ -ocpp::types::CertificateStatusEnumType DefaultChargePointEventsHandler::caCertificateReceived(ocpp::types::CertificateUseEnumType type, - const ocpp::x509::Certificate& certificate) +ocpp::types::ocpp16::CertificateStatusEnumType DefaultChargePointEventsHandler::caCertificateReceived( + ocpp::types::ocpp16::CertificateUseEnumType type, const ocpp::x509::Certificate& certificate) { std::string ca_filename; CertificateStatusEnumType ret = CertificateStatusEnumType::Rejected; @@ -472,15 +474,15 @@ bool DefaultChargePointEventsHandler::chargePointCertificateReceived(const ocpp: return ret; } -/** @copydoc ocpp::types::DeleteCertificateStatusEnumType IChargePointEventsHandler::deleteCertificate(ocpp::types::HashAlgorithmEnumType, +/** @copydoc ocpp::types::ocpp16::DeleteCertificateStatusEnumType IChargePointEventsHandler::deleteCertificate(ocpp::types::ocpp16::HashAlgorithmEnumType, const std::string&, const std::string&, const std::string&) */ -ocpp::types::DeleteCertificateStatusEnumType DefaultChargePointEventsHandler::deleteCertificate( - ocpp::types::HashAlgorithmEnumType hash_algorithm, - const std::string& issuer_name_hash, - const std::string& issuer_key_hash, - const std::string& serial_number) +ocpp::types::ocpp16::DeleteCertificateStatusEnumType DefaultChargePointEventsHandler::deleteCertificate( + ocpp::types::ocpp16::HashAlgorithmEnumType hash_algorithm, + const std::string& issuer_name_hash, + const std::string& issuer_key_hash, + const std::string& serial_number) { DeleteCertificateStatusEnumType ret = DeleteCertificateStatusEnumType::NotFound; @@ -564,10 +566,10 @@ void DefaultChargePointEventsHandler::generateCsr(std::string& csr) csr = certificate_request.pem(); } -/** @copydoc void IChargePointEventsHandler::getInstalledCertificates(ocpp::types::CertificateUseEnumType, +/** @copydoc void IChargePointEventsHandler::getInstalledCertificates(ocpp::types::ocpp16::CertificateUseEnumType, * std::vector&) */ -void DefaultChargePointEventsHandler::getInstalledCertificates(ocpp::types::CertificateUseEnumType type, - std::vector& certificates) +void DefaultChargePointEventsHandler::getInstalledCertificates(ocpp::types::ocpp16::CertificateUseEnumType type, + std::vector& certificates) { cout << "Get installed CA certificates requested : type = " << CertificateUseEnumTypeHelper.toString(type) << endl; @@ -594,10 +596,10 @@ void DefaultChargePointEventsHandler::getInstalledCertificates(ocpp::types::Cert } } -/** @copydoc std::string IChargePointEventsHandler::getLog(ocpp::types::LogEnumType, +/** @copydoc std::string IChargePointEventsHandler::getLog(ocpp::types::ocpp16::LogEnumType, const ocpp::types::Optional&, const ocpp::types::Optional&) */ -std::string DefaultChargePointEventsHandler::getLog(ocpp::types::LogEnumType type, +std::string DefaultChargePointEventsHandler::getLog(ocpp::types::ocpp16::LogEnumType type, const ocpp::types::Optional& start_time, const ocpp::types::Optional& stop_time) { @@ -667,9 +669,9 @@ bool DefaultChargePointEventsHandler::hasChargePointCertificateInstalled() return false; } -/** @copydoc ocpp::types::UpdateFirmwareStatusEnumType IChargePointEventsHandler::checkFirmwareSigningCertificate( +/** @copydoc ocpp::types::ocpp16::UpdateFirmwareStatusEnumType IChargePointEventsHandler::checkFirmwareSigningCertificate( * const ocpp::x509::Certificate&) */ -ocpp::types::UpdateFirmwareStatusEnumType DefaultChargePointEventsHandler::checkFirmwareSigningCertificate( +ocpp::types::ocpp16::UpdateFirmwareStatusEnumType DefaultChargePointEventsHandler::checkFirmwareSigningCertificate( const ocpp::x509::Certificate& signing_certificate) { UpdateFirmwareStatusEnumType ret = UpdateFirmwareStatusEnumType::InvalidCertificate; @@ -777,15 +779,15 @@ bool DefaultChargePointEventsHandler::iso15118ChargePointCertificateReceived(con return ret; } -/** @copydoc ocpp::types::DeleteCertificateStatusEnumType IChargePointEventsHandler::iso15118DeleteCertificate(ocpp::types::HashAlgorithmEnumType, +/** @copydoc ocpp::types::ocpp16::DeleteCertificateStatusEnumType IChargePointEventsHandler::iso15118DeleteCertificate(ocpp::types::ocpp16::HashAlgorithmEnumType, const std::string&, const std::string&, const std::string&) */ -ocpp::types::DeleteCertificateStatusEnumType DefaultChargePointEventsHandler::iso15118DeleteCertificate( - ocpp::types::HashAlgorithmEnumType hash_algorithm, - const std::string& issuer_name_hash, - const std::string& issuer_key_hash, - const std::string& serial_number) +ocpp::types::ocpp16::DeleteCertificateStatusEnumType DefaultChargePointEventsHandler::iso15118DeleteCertificate( + ocpp::types::ocpp16::HashAlgorithmEnumType hash_algorithm, + const std::string& issuer_name_hash, + const std::string& issuer_key_hash, + const std::string& serial_number) { cout << "ISO15118 certificate deletion requested : hash = " << HashAlgorithmEnumTypeHelper.toString(hash_algorithm) << " - serial number = " << serial_number << endl; @@ -803,7 +805,8 @@ void DefaultChargePointEventsHandler::iso15118GetInstalledCertificates( bool mo_root_certificate, bool v2g_certificate_chain, bool oem_root_certificate, - std::vector>>& + std::vector< + std::tuple>>& certificates) { cout << "ISO15118 get installed certificates requested : v2g_root_certificate = " << (v2g_root_certificate ? "yes" : "no") @@ -860,11 +863,11 @@ void DefaultChargePointEventsHandler::iso15118GetInstalledCertificates( } } -/** @copydoc ocpp::types::InstallCertificateStatusEnumType IChargePointEventsHandler::iso15118CertificateReceived( - ocpp::types::InstallCertificateUseEnumType type, +/** @copydoc ocpp::types::ocpp16::InstallCertificateStatusEnumType IChargePointEventsHandler::iso15118CertificateReceived( + ocpp::types::ocpp16::InstallCertificateUseEnumType type, const ocpp::x509::Certificate&) */ -ocpp::types::InstallCertificateStatusEnumType DefaultChargePointEventsHandler::iso15118CertificateReceived( - ocpp::types::InstallCertificateUseEnumType type, const ocpp::x509::Certificate& certificate) +ocpp::types::ocpp16::InstallCertificateStatusEnumType DefaultChargePointEventsHandler::iso15118CertificateReceived( + ocpp::types::ocpp16::InstallCertificateUseEnumType type, const ocpp::x509::Certificate& certificate) { std::string cert_filename; InstallCertificateStatusEnumType ret = InstallCertificateStatusEnumType::Rejected; diff --git a/examples/common/DefaultChargePointEventsHandler.h b/examples/ocpp16/common/DefaultChargePointEventsHandler.h similarity index 71% rename from examples/common/DefaultChargePointEventsHandler.h rename to examples/ocpp16/common/DefaultChargePointEventsHandler.h index 706ec037..ddfeee00 100644 --- a/examples/common/DefaultChargePointEventsHandler.h +++ b/examples/ocpp16/common/DefaultChargePointEventsHandler.h @@ -51,21 +51,21 @@ class DefaultChargePointEventsHandler : public ocpp::chargepoint::IChargePointEv /** @copydoc void IChargePointEventsHandler::connectionUrlChanged(std::string const&) */ void connectionUrlChanged(std::string const& url) override; - /** @copydoc void IChargePointEventsHandler::connectionStateChanged(ocpp::types::RegistrationStatus) */ - void connectionFailed(ocpp::types::RegistrationStatus status) override; + /** @copydoc void IChargePointEventsHandler::connectionFailed(ocpp::types::RegistrationStatus) */ + void connectionFailed(ocpp::types::ocpp16::RegistrationStatus status) override; /** @copydoc void IChargePointEventsHandler::connectionStateChanged(bool) */ void connectionStateChanged(bool isConnected) override; - /** @copydoc void IChargePointEventsHandler::bootNotification(ocpp::types::RegistrationStatus, const ocpp::types::DateTime&) */ - void bootNotification(ocpp::types::RegistrationStatus status, const ocpp::types::DateTime& datetime) override; + /** @copydoc void IChargePointEventsHandler::bootNotification(ocpp::types::ocpp16::RegistrationStatus, const ocpp::types::DateTime&) */ + void bootNotification(ocpp::types::ocpp16::RegistrationStatus status, const ocpp::types::DateTime& datetime) override; /** @copydoc void IChargePointEventsHandler::datetimeReceived(const ocpp::types::DateTime&) */ void datetimeReceived(const ocpp::types::DateTime& datetime) override; - /** @copydoc AvailabilityStatus IChargePointEventsHandler::changeAvailabilityRequested(unsigned int, ocpp::types::AvailabilityType) */ - ocpp::types::AvailabilityStatus changeAvailabilityRequested(unsigned int connector_id, - ocpp::types::AvailabilityType availability) override; + /** @copydoc AvailabilityStatus IChargePointEventsHandler::changeAvailabilityRequested(unsigned int, ocpp::types::ocpp16::AvailabilityType) */ + ocpp::types::ocpp16::AvailabilityStatus changeAvailabilityRequested(unsigned int connector_id, + ocpp::types::ocpp16::AvailabilityType availability) override; /** @copydoc int IChargePointEventsHandler::getTxStartStopMeterValue(unsigned int) */ int getTxStartStopMeterValue(unsigned int connector_id) override; @@ -76,19 +76,19 @@ class DefaultChargePointEventsHandler : public ocpp::chargepoint::IChargePointEv /** @copydoc void IChargePointEventsHandler::reservationEnded(unsigned int, bool) */ void reservationEnded(unsigned int connector_id, bool canceled) override; - /** @copydoc ocpp::types::DataTransferStatus IChargePointEventsHandler::dataTransferRequested(const std::string&, + /** @copydoc ocpp::types::ocpp16::DataTransferStatus IChargePointEventsHandler::dataTransferRequested(const std::string&, const std::string&, const std::string&, std::string&) */ - ocpp::types::DataTransferStatus dataTransferRequested(const std::string& vendor_id, - const std::string& message_id, - const std::string& request_data, - std::string& response_data) override; + ocpp::types::ocpp16::DataTransferStatus dataTransferRequested(const std::string& vendor_id, + const std::string& message_id, + const std::string& request_data, + std::string& response_data) override; - /** @copydoc bool IChargePointEventsHandler::getMeterValue(unsigned int, const std::pair>&, ocpp::types::MeterValue&) */ - bool getMeterValue(unsigned int connector_id, - const std::pair>& measurand, - ocpp::types::MeterValue& meter_value) override; + /** @copydoc bool IChargePointEventsHandler::getMeterValue(unsigned int, const std::pair>&, ocpp::types::ocpp16::MeterValue&) */ + bool getMeterValue(unsigned int connector_id, + const std::pair>& measurand, + ocpp::types::ocpp16::MeterValue& meter_value) override; /** @copydoc bool IChargePointEventsHandler::remoteStartTransactionRequested(unsigned int, const std::string&) */ bool remoteStartTransactionRequested(unsigned int connector_id, const std::string& id_tag) override; @@ -99,14 +99,16 @@ class DefaultChargePointEventsHandler : public ocpp::chargepoint::IChargePointEv /** @copydoc void IChargePointEventsHandler::transactionDeAuthorized(unsigned int) */ void transactionDeAuthorized(unsigned int connector_id) override; - /** @copydoc bool IChargePointEventsHandler::getLocalLimitationsSchedule(unsigned int, unsigned int, ocpp::types::ChargingSchedule&) */ - bool getLocalLimitationsSchedule(unsigned int connector_id, unsigned int duration, ocpp::types::ChargingSchedule& schedule) override; + /** @copydoc bool IChargePointEventsHandler::getLocalLimitationsSchedule(unsigned int, unsigned int, ocpp::types::ocpp16::ChargingSchedule&) */ + bool getLocalLimitationsSchedule(unsigned int connector_id, + unsigned int duration, + ocpp::types::ocpp16::ChargingSchedule& schedule) override; - /** @copydoc bool IChargePointEventsHandler::resetRequested(ocpp::types::ResetType) */ - bool resetRequested(ocpp::types::ResetType reset_type) override; + /** @copydoc bool IChargePointEventsHandler::resetRequested(ocpp::types::ocpp16::ResetType) */ + bool resetRequested(ocpp::types::ocpp16::ResetType reset_type) override; - /** @copydoc ocpp::types::UnlockStatus IChargePointEventsHandler::unlockConnectorRequested(unsigned int) */ - ocpp::types::UnlockStatus unlockConnectorRequested(unsigned int connector_id) override; + /** @copydoc ocpp::types::ocpp16::UnlockStatus IChargePointEventsHandler::unlockConnectorRequested(unsigned int) */ + ocpp::types::ocpp16::UnlockStatus unlockConnectorRequested(unsigned int connector_id) override; /** @copydoc std::string IChargePointEventsHandler::getDiagnostics(const ocpp::types::Optional&, const ocpp::types::Optional&) */ @@ -127,34 +129,35 @@ class DefaultChargePointEventsHandler : public ocpp::chargepoint::IChargePointEv // Security extensions - /** @copydoc ocpp::types::CertificateStatusEnumType IChargePointEventsHandler::caCertificateReceived(ocpp::types::CertificateUseEnumType, + /** @copydoc ocpp::types::ocpp16::CertificateStatusEnumType IChargePointEventsHandler::caCertificateReceived(ocpp::types::ocpp16::CertificateUseEnumType, const ocpp::x509::Certificate&) */ - ocpp::types::CertificateStatusEnumType caCertificateReceived(ocpp::types::CertificateUseEnumType type, - const ocpp::x509::Certificate& certificate) override; + ocpp::types::ocpp16::CertificateStatusEnumType caCertificateReceived(ocpp::types::ocpp16::CertificateUseEnumType type, + const ocpp::x509::Certificate& certificate) override; /** @copydoc bool IChargePointEventsHandler::chargePointCertificateReceived(const ocpp::x509::Certificate&) */ bool chargePointCertificateReceived(const ocpp::x509::Certificate& certificate) override; - /** @copydoc ocpp::types::DeleteCertificateStatusEnumType IChargePointEventsHandler::deleteCertificate(ocpp::types::HashAlgorithmEnumType, + /** @copydoc ocpp::types::ocpp16::DeleteCertificateStatusEnumType IChargePointEventsHandler::deleteCertificate(ocpp::types::ocpp16::HashAlgorithmEnumType, const std::string&, const std::string&, const std::string&) */ - ocpp::types::DeleteCertificateStatusEnumType deleteCertificate(ocpp::types::HashAlgorithmEnumType hash_algorithm, - const std::string& issuer_name_hash, - const std::string& issuer_key_hash, - const std::string& serial_number) override; + ocpp::types::ocpp16::DeleteCertificateStatusEnumType deleteCertificate(ocpp::types::ocpp16::HashAlgorithmEnumType hash_algorithm, + const std::string& issuer_name_hash, + const std::string& issuer_key_hash, + const std::string& serial_number) override; /** @copydoc void IChargePointEventsHandler::generateCsr(std::string&) */ void generateCsr(std::string& csr) override; - /** @copydoc void IChargePointEventsHandler::getInstalledCertificates(ocpp::types::CertificateUseEnumType, + /** @copydoc void IChargePointEventsHandler::getInstalledCertificates(ocpp::types::ocpp16::CertificateUseEnumType, * std::vector&) */ - void getInstalledCertificates(ocpp::types::CertificateUseEnumType type, std::vector& certificates) override; + void getInstalledCertificates(ocpp::types::ocpp16::CertificateUseEnumType type, + std::vector& certificates) override; - /** @copydoc std::string IChargePointEventsHandler::getLog(ocpp::types::LogEnumType, + /** @copydoc std::string IChargePointEventsHandler::getLog(ocpp::types::ocpp16::LogEnumType, const ocpp::types::Optional&, const ocpp::types::Optional&) */ - std::string getLog(ocpp::types::LogEnumType type, + std::string getLog(ocpp::types::ocpp16::LogEnumType type, const ocpp::types::Optional& start_time, const ocpp::types::Optional& stop_time) override; @@ -164,9 +167,10 @@ class DefaultChargePointEventsHandler : public ocpp::chargepoint::IChargePointEv /** @copydoc bool IChargePointEventsHandler::hasChargePointCertificateInstalled() */ bool hasChargePointCertificateInstalled() override; - /** @copydoc ocpp::types::UpdateFirmwareStatusEnumType IChargePointEventsHandler::checkFirmwareSigningCertificate( + /** @copydoc ocpp::types::ocpp16::UpdateFirmwareStatusEnumType IChargePointEventsHandler::checkFirmwareSigningCertificate( * const ocpp::x509::Certificate&) */ - ocpp::types::UpdateFirmwareStatusEnumType checkFirmwareSigningCertificate(const ocpp::x509::Certificate& signing_certificate) override; + ocpp::types::ocpp16::UpdateFirmwareStatusEnumType checkFirmwareSigningCertificate( + const ocpp::x509::Certificate& signing_certificate) override; // ISO 15118 PnC extensions @@ -176,14 +180,15 @@ class DefaultChargePointEventsHandler : public ocpp::chargepoint::IChargePointEv /** @copydoc bool IChargePointEventsHandler::iso15118ChargePointCertificateReceived(const ocpp::x509::Certificate&) */ bool iso15118ChargePointCertificateReceived(const ocpp::x509::Certificate& certificate) override; - /** @copydoc ocpp::types::DeleteCertificateStatusEnumType IChargePointEventsHandler::iso15118DeleteCertificate(ocpp::types::HashAlgorithmEnumType, + /** @copydoc ocpp::types::ocpp16::DeleteCertificateStatusEnumType IChargePointEventsHandler::iso15118DeleteCertificate(ocpp::types::ocpp16::HashAlgorithmEnumType, const std::string&, const std::string&, const std::string&) */ - ocpp::types::DeleteCertificateStatusEnumType iso15118DeleteCertificate(ocpp::types::HashAlgorithmEnumType hash_algorithm, - const std::string& issuer_name_hash, - const std::string& issuer_key_hash, - const std::string& serial_number) override; + ocpp::types::ocpp16::DeleteCertificateStatusEnumType iso15118DeleteCertificate( + ocpp::types::ocpp16::HashAlgorithmEnumType hash_algorithm, + const std::string& issuer_name_hash, + const std::string& issuer_key_hash, + const std::string& serial_number) override; /** @copydoc void IChargePointEventsHandler::iso15118GetInstalledCertificates( bool, @@ -196,14 +201,15 @@ class DefaultChargePointEventsHandler : public ocpp::chargepoint::IChargePointEv bool mo_root_certificate, bool v2g_certificate_chain, bool oem_root_certificate, - std::vector>>& + std::vector< + std::tuple>>& certificates) override; - /** @copydoc ocpp::types::InstallCertificateStatusEnumType IChargePointEventsHandler::iso15118CertificateReceived( - * ocpp::types::InstallCertificateUseEnumType type, + /** @copydoc ocpp::types::ocpp16::InstallCertificateStatusEnumType IChargePointEventsHandler::iso15118CertificateReceived( + * ocpp::types::ocpp16::InstallCertificateUseEnumType type, const ocpp::x509::Certificate&) */ - ocpp::types::InstallCertificateStatusEnumType iso15118CertificateReceived(ocpp::types::InstallCertificateUseEnumType type, - const ocpp::x509::Certificate& certificate) override; + ocpp::types::ocpp16::InstallCertificateStatusEnumType iso15118CertificateReceived( + ocpp::types::ocpp16::InstallCertificateUseEnumType type, const ocpp::x509::Certificate& certificate) override; /** @copydoc void IChargePointEventsHandler::iso15118GenerateCsr(std::string&) */ void iso15118GenerateCsr(std::string& csr) override; diff --git a/examples/common/DefaultLocalControllerEventsHandler.cpp b/examples/ocpp16/common/DefaultLocalControllerEventsHandler.cpp similarity index 98% rename from examples/common/DefaultLocalControllerEventsHandler.cpp rename to examples/ocpp16/common/DefaultLocalControllerEventsHandler.cpp index 6c6d8f30..fa287f15 100644 --- a/examples/common/DefaultLocalControllerEventsHandler.cpp +++ b/examples/ocpp16/common/DefaultLocalControllerEventsHandler.cpp @@ -72,10 +72,10 @@ void DefaultLocalControllerEventsHandler::chargePointConnected(std::shared_ptr p_chargepoint = chargepoint; // Specific handling of heartbeat message - auto heartbeat_handler = [p_chargepoint](const ocpp::messages::HeartbeatReq& request, - ocpp::messages::HeartbeatConf& response, - std::string& error_code, - std::string& error_message) + auto heartbeat_handler = [p_chargepoint](const ocpp::messages::ocpp16::HeartbeatReq& request, + ocpp::messages::ocpp16::HeartbeatConf& response, + std::string& error_code, + std::string& error_message) { bool ret = true; auto chargepoint = p_chargepoint.lock(); diff --git a/examples/common/DefaultLocalControllerEventsHandler.h b/examples/ocpp16/common/DefaultLocalControllerEventsHandler.h similarity index 100% rename from examples/common/DefaultLocalControllerEventsHandler.h rename to examples/ocpp16/common/DefaultLocalControllerEventsHandler.h diff --git a/examples/common/config/CentralSystemConfig.h b/examples/ocpp16/common/config/CentralSystemConfig.h similarity index 100% rename from examples/common/config/CentralSystemConfig.h rename to examples/ocpp16/common/config/CentralSystemConfig.h diff --git a/examples/common/config/CentralSystemDemoConfig.h b/examples/ocpp16/common/config/CentralSystemDemoConfig.h similarity index 100% rename from examples/common/config/CentralSystemDemoConfig.h rename to examples/ocpp16/common/config/CentralSystemDemoConfig.h diff --git a/examples/common/config/ChargePointConfig.h b/examples/ocpp16/common/config/ChargePointConfig.h similarity index 100% rename from examples/common/config/ChargePointConfig.h rename to examples/ocpp16/common/config/ChargePointConfig.h diff --git a/examples/common/config/ChargePointDemoConfig.h b/examples/ocpp16/common/config/ChargePointDemoConfig.h similarity index 100% rename from examples/common/config/ChargePointDemoConfig.h rename to examples/ocpp16/common/config/ChargePointDemoConfig.h diff --git a/examples/common/config/LocalControllerConfig.h b/examples/ocpp16/common/config/LocalControllerConfig.h similarity index 100% rename from examples/common/config/LocalControllerConfig.h rename to examples/ocpp16/common/config/LocalControllerConfig.h diff --git a/examples/common/config/LocalControllerDemoConfig.h b/examples/ocpp16/common/config/LocalControllerDemoConfig.h similarity index 100% rename from examples/common/config/LocalControllerDemoConfig.h rename to examples/ocpp16/common/config/LocalControllerDemoConfig.h diff --git a/examples/common/config/OcppConfig.cpp b/examples/ocpp16/common/config/OcppConfig.cpp similarity index 97% rename from examples/common/config/OcppConfig.cpp rename to examples/ocpp16/common/config/OcppConfig.cpp index 6c4db9be..c38395f4 100644 --- a/examples/common/config/OcppConfig.cpp +++ b/examples/ocpp16/common/config/OcppConfig.cpp @@ -30,6 +30,7 @@ SOFTWARE. using namespace std; using namespace ocpp::types; +using namespace ocpp::types::ocpp16; using namespace ocpp::helpers; /** @brief Read attribute */ @@ -123,11 +124,11 @@ static const map CONFIGURATION_VALUES = { OcppConfig::OcppConfig(ocpp::helpers::IniFile& config) : m_config(config) { } /** @copydoc void IOcppConfig::getConfiguration(const std::vector>&, - * std::vector&, + * std::vector&, * std::vector>&); */ void OcppConfig::getConfiguration(const std::vector>& keys, - std::vector& values, + std::vector& values, std::vector>& unknown_values) { if (keys.empty()) @@ -189,7 +190,7 @@ void OcppConfig::getConfiguration(const std::vector>&, - * std::vector&, + * std::vector&, * std::vector>&); */ void getConfiguration(const std::vector>& keys, - std::vector& values, + std::vector& values, std::vector>& unknown_values) override; /// @@ -55,7 +55,7 @@ class OcppConfig : public ocpp::config::IOcppConfig /// /** @copydoc ConfigurationStatus IOcppConfig::setConfiguration(const std::string&, const std::string&) */ - ocpp::types::ConfigurationStatus setConfiguration(const std::string& key, const std::string& value) override; + ocpp::types::ocpp16::ConfigurationStatus setConfiguration(const std::string& key, const std::string& value) override; // // Specific getters diff --git a/examples/iso15118_centralsystem/CMakeLists.txt b/examples/ocpp16/iso15118_centralsystem/CMakeLists.txt similarity index 96% rename from examples/iso15118_centralsystem/CMakeLists.txt rename to examples/ocpp16/iso15118_centralsystem/CMakeLists.txt index bbb92dbd..d21a06cf 100644 --- a/examples/iso15118_centralsystem/CMakeLists.txt +++ b/examples/ocpp16/iso15118_centralsystem/CMakeLists.txt @@ -12,7 +12,7 @@ target_link_directories(iso15118_centralsystem PRIVATE ${BIN_DIR}) # Dependencies target_link_libraries(iso15118_centralsystem - examples_common + examples_common16 centralsystem ) diff --git a/examples/iso15118_centralsystem/README.md b/examples/ocpp16/iso15118_centralsystem/README.md similarity index 100% rename from examples/iso15118_centralsystem/README.md rename to examples/ocpp16/iso15118_centralsystem/README.md diff --git a/examples/iso15118_centralsystem/config/iso15118_centralsystem.ini b/examples/ocpp16/iso15118_centralsystem/config/iso15118_centralsystem.ini similarity index 96% rename from examples/iso15118_centralsystem/config/iso15118_centralsystem.ini rename to examples/ocpp16/iso15118_centralsystem/config/iso15118_centralsystem.ini index 90dac963..4b81294a 100644 --- a/examples/iso15118_centralsystem/config/iso15118_centralsystem.ini +++ b/examples/ocpp16/iso15118_centralsystem/config/iso15118_centralsystem.ini @@ -1,6 +1,6 @@ [CentralSystem] DatabasePath=./iso15118_centralsystem.db -JsonSchemasPath=../../schemas/ +JsonSchemasPath=../../schemas/ocpp16/ ListenUrl=wss://127.0.0.1:8080/openocpp/ CallRequestTimeout=2000 WebSocketPingInterval=30 diff --git a/examples/iso15118_centralsystem/main.cpp b/examples/ocpp16/iso15118_centralsystem/main.cpp similarity index 98% rename from examples/iso15118_centralsystem/main.cpp rename to examples/ocpp16/iso15118_centralsystem/main.cpp index e22761e1..fe631c19 100644 --- a/examples/iso15118_centralsystem/main.cpp +++ b/examples/ocpp16/iso15118_centralsystem/main.cpp @@ -36,6 +36,7 @@ SOFTWARE. using namespace ocpp::centralsystem; using namespace ocpp::types; +using namespace ocpp::types::ocpp16; using namespace ocpp::x509; /** @brief Create the certificates for the ISO15118 communications */ @@ -170,7 +171,7 @@ int main(int argc, char* argv[]) std::cout << "Charge point supports ISO15118 PnC extensions" << std::endl; // List installed certificates - std::vector certificates; + std::vector certificates; if (chargepoint->iso15118GetInstalledCertificateIds( std::vector{GetCertificateIdUseEnumType::V2GRootCertificate, GetCertificateIdUseEnumType::MORootCertificate}, diff --git a/examples/iso15118_chargepoint/CMakeLists.txt b/examples/ocpp16/iso15118_chargepoint/CMakeLists.txt similarity index 96% rename from examples/iso15118_chargepoint/CMakeLists.txt rename to examples/ocpp16/iso15118_chargepoint/CMakeLists.txt index 79f8da57..08d89719 100644 --- a/examples/iso15118_chargepoint/CMakeLists.txt +++ b/examples/ocpp16/iso15118_chargepoint/CMakeLists.txt @@ -12,7 +12,7 @@ target_link_directories(iso15118_chargepoint PRIVATE ${BIN_DIR}) # Dependencies target_link_libraries(iso15118_chargepoint - examples_common + examples_common16 ) diff --git a/examples/iso15118_chargepoint/README.md b/examples/ocpp16/iso15118_chargepoint/README.md similarity index 100% rename from examples/iso15118_chargepoint/README.md rename to examples/ocpp16/iso15118_chargepoint/README.md diff --git a/examples/iso15118_chargepoint/config/iso15118_chargepoint.ini b/examples/ocpp16/iso15118_chargepoint/config/iso15118_chargepoint.ini similarity index 98% rename from examples/iso15118_chargepoint/config/iso15118_chargepoint.ini rename to examples/ocpp16/iso15118_chargepoint/config/iso15118_chargepoint.ini index aa0143c1..605ac7c8 100644 --- a/examples/iso15118_chargepoint/config/iso15118_chargepoint.ini +++ b/examples/ocpp16/iso15118_chargepoint/config/iso15118_chargepoint.ini @@ -1,6 +1,6 @@ [ChargePoint] DatabasePath=./iso15118_chargepoint.db -JsonSchemasPath=../../schemas/ +JsonSchemasPath=../../schemas/ocpp16/ ConnexionUrl=wss://127.0.0.1:8080/openocpp/ Tlsv12CipherList=ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:PSK-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES128-GCM-SHA256:PSK-AES128-GCM-SHA256 Tlsv13CipherList=TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384 diff --git a/examples/iso15118_chargepoint/main.cpp b/examples/ocpp16/iso15118_chargepoint/main.cpp similarity index 99% rename from examples/iso15118_chargepoint/main.cpp rename to examples/ocpp16/iso15118_chargepoint/main.cpp index 13fc26e3..745e8102 100644 --- a/examples/iso15118_chargepoint/main.cpp +++ b/examples/ocpp16/iso15118_chargepoint/main.cpp @@ -33,6 +33,7 @@ SOFTWARE. using namespace ocpp::chargepoint; using namespace ocpp::types; +using namespace ocpp::types::ocpp16; using namespace ocpp::x509; /** @brief Entry point */ diff --git a/examples/quick_start_centralsystem/CMakeLists.txt b/examples/ocpp16/quick_start_centralsystem/CMakeLists.txt similarity index 96% rename from examples/quick_start_centralsystem/CMakeLists.txt rename to examples/ocpp16/quick_start_centralsystem/CMakeLists.txt index dc5f9446..97fa9e81 100644 --- a/examples/quick_start_centralsystem/CMakeLists.txt +++ b/examples/ocpp16/quick_start_centralsystem/CMakeLists.txt @@ -12,7 +12,7 @@ target_link_directories(quick_start_centralsystem PRIVATE ${BIN_DIR}) # Dependencies target_link_libraries(quick_start_centralsystem - examples_common + examples_common16 centralsystem ) diff --git a/examples/quick_start_centralsystem/README.md b/examples/ocpp16/quick_start_centralsystem/README.md similarity index 100% rename from examples/quick_start_centralsystem/README.md rename to examples/ocpp16/quick_start_centralsystem/README.md diff --git a/examples/quick_start_centralsystem/config/quick_start_centralsystem.ini b/examples/ocpp16/quick_start_centralsystem/config/quick_start_centralsystem.ini similarity index 96% rename from examples/quick_start_centralsystem/config/quick_start_centralsystem.ini rename to examples/ocpp16/quick_start_centralsystem/config/quick_start_centralsystem.ini index 3a23c170..ab854032 100644 --- a/examples/quick_start_centralsystem/config/quick_start_centralsystem.ini +++ b/examples/ocpp16/quick_start_centralsystem/config/quick_start_centralsystem.ini @@ -1,6 +1,6 @@ [CentralSystem] DatabasePath=./quick_start_centralsystem.db -JsonSchemasPath=../../schemas/ +JsonSchemasPath=../../schemas/ocpp16/ ListenUrl=wss://127.0.0.1:8080/openocpp/ CallRequestTimeout=2000 WebSocketPingInterval=30 diff --git a/examples/quick_start_centralsystem/main.cpp b/examples/ocpp16/quick_start_centralsystem/main.cpp similarity index 99% rename from examples/quick_start_centralsystem/main.cpp rename to examples/ocpp16/quick_start_centralsystem/main.cpp index 1ffd1525..f72e394c 100644 --- a/examples/quick_start_centralsystem/main.cpp +++ b/examples/ocpp16/quick_start_centralsystem/main.cpp @@ -33,6 +33,7 @@ SOFTWARE. using namespace ocpp::centralsystem; using namespace ocpp::types; +using namespace ocpp::types::ocpp16; /** @brief Entry point */ int main(int argc, char* argv[]) diff --git a/examples/quick_start_chargepoint/CMakeLists.txt b/examples/ocpp16/quick_start_chargepoint/CMakeLists.txt similarity index 96% rename from examples/quick_start_chargepoint/CMakeLists.txt rename to examples/ocpp16/quick_start_chargepoint/CMakeLists.txt index 15ada323..fab10b46 100644 --- a/examples/quick_start_chargepoint/CMakeLists.txt +++ b/examples/ocpp16/quick_start_chargepoint/CMakeLists.txt @@ -12,7 +12,7 @@ target_link_directories(quick_start_chargepoint PRIVATE ${BIN_DIR}) # Dependencies target_link_libraries(quick_start_chargepoint - examples_common + examples_common16 ) diff --git a/examples/quick_start_chargepoint/README.md b/examples/ocpp16/quick_start_chargepoint/README.md similarity index 100% rename from examples/quick_start_chargepoint/README.md rename to examples/ocpp16/quick_start_chargepoint/README.md diff --git a/examples/quick_start_chargepoint/config/quick_start_chargepoint.ini b/examples/ocpp16/quick_start_chargepoint/config/quick_start_chargepoint.ini similarity index 98% rename from examples/quick_start_chargepoint/config/quick_start_chargepoint.ini rename to examples/ocpp16/quick_start_chargepoint/config/quick_start_chargepoint.ini index 8ac47141..1d6b8a73 100644 --- a/examples/quick_start_chargepoint/config/quick_start_chargepoint.ini +++ b/examples/ocpp16/quick_start_chargepoint/config/quick_start_chargepoint.ini @@ -1,6 +1,6 @@ [ChargePoint] DatabasePath=./quick_start_chargepoint.db -JsonSchemasPath=../../schemas/ +JsonSchemasPath=../../schemas/ocpp16/ ConnexionUrl=wss://127.0.0.1:8080/openocpp/ Tlsv12CipherList=ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:PSK-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES128-GCM-SHA256:PSK-AES128-GCM-SHA256 Tlsv13CipherList=TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384 diff --git a/examples/quick_start_chargepoint/main.cpp b/examples/ocpp16/quick_start_chargepoint/main.cpp similarity index 99% rename from examples/quick_start_chargepoint/main.cpp rename to examples/ocpp16/quick_start_chargepoint/main.cpp index 8e743416..b40d7ac2 100644 --- a/examples/quick_start_chargepoint/main.cpp +++ b/examples/ocpp16/quick_start_chargepoint/main.cpp @@ -33,6 +33,7 @@ SOFTWARE. using namespace ocpp::chargepoint; using namespace ocpp::types; +using namespace ocpp::types::ocpp16; /** @brief Entry point */ int main(int argc, char* argv[]) diff --git a/examples/quick_start_cs_lc_hybrid/CMakeLists.txt b/examples/ocpp16/quick_start_cs_lc_hybrid/CMakeLists.txt similarity index 96% rename from examples/quick_start_cs_lc_hybrid/CMakeLists.txt rename to examples/ocpp16/quick_start_cs_lc_hybrid/CMakeLists.txt index 58e282a5..61a1f953 100644 --- a/examples/quick_start_cs_lc_hybrid/CMakeLists.txt +++ b/examples/ocpp16/quick_start_cs_lc_hybrid/CMakeLists.txt @@ -13,7 +13,7 @@ target_link_directories(quick_start_cs_lc_hybrid PRIVATE ${BIN_DIR}) # Dependencies target_link_libraries(quick_start_cs_lc_hybrid - examples_common + examples_common16 localcontroller ) diff --git a/examples/quick_start_cs_lc_hybrid/HybridCentralSystemEventsHandler.cpp b/examples/ocpp16/quick_start_cs_lc_hybrid/HybridCentralSystemEventsHandler.cpp similarity index 100% rename from examples/quick_start_cs_lc_hybrid/HybridCentralSystemEventsHandler.cpp rename to examples/ocpp16/quick_start_cs_lc_hybrid/HybridCentralSystemEventsHandler.cpp diff --git a/examples/quick_start_cs_lc_hybrid/HybridCentralSystemEventsHandler.h b/examples/ocpp16/quick_start_cs_lc_hybrid/HybridCentralSystemEventsHandler.h similarity index 100% rename from examples/quick_start_cs_lc_hybrid/HybridCentralSystemEventsHandler.h rename to examples/ocpp16/quick_start_cs_lc_hybrid/HybridCentralSystemEventsHandler.h diff --git a/examples/quick_start_cs_lc_hybrid/README.md b/examples/ocpp16/quick_start_cs_lc_hybrid/README.md similarity index 100% rename from examples/quick_start_cs_lc_hybrid/README.md rename to examples/ocpp16/quick_start_cs_lc_hybrid/README.md diff --git a/examples/quick_start_cs_lc_hybrid/config/quick_start_cs_lc_hybrid.ini b/examples/ocpp16/quick_start_cs_lc_hybrid/config/quick_start_cs_lc_hybrid.ini similarity index 97% rename from examples/quick_start_cs_lc_hybrid/config/quick_start_cs_lc_hybrid.ini rename to examples/ocpp16/quick_start_cs_lc_hybrid/config/quick_start_cs_lc_hybrid.ini index 256fbe0f..854645b0 100644 --- a/examples/quick_start_cs_lc_hybrid/config/quick_start_cs_lc_hybrid.ini +++ b/examples/ocpp16/quick_start_cs_lc_hybrid/config/quick_start_cs_lc_hybrid.ini @@ -1,6 +1,6 @@ [LocalController] DatabasePath=./quick_start_cs_lc_hybrid.db -JsonSchemasPath=../../schemas/ +JsonSchemasPath=../../schemas/ocpp16/ ListenUrl=wss://127.0.0.1:8080/openocpp/ ConnexionUrl=wss://127.0.0.1:8081/openocpp/ CallRequestTimeout=2000 diff --git a/examples/quick_start_cs_lc_hybrid/main.cpp b/examples/ocpp16/quick_start_cs_lc_hybrid/main.cpp similarity index 98% rename from examples/quick_start_cs_lc_hybrid/main.cpp rename to examples/ocpp16/quick_start_cs_lc_hybrid/main.cpp index 2165735d..4c0980e9 100644 --- a/examples/quick_start_cs_lc_hybrid/main.cpp +++ b/examples/ocpp16/quick_start_cs_lc_hybrid/main.cpp @@ -33,8 +33,10 @@ SOFTWARE. #include using namespace ocpp::centralsystem; -using namespace ocpp::types; using namespace ocpp::messages; +using namespace ocpp::messages::ocpp16; +using namespace ocpp::types; +using namespace ocpp::types::ocpp16; /** @brief Entry point */ int main(int argc, char* argv[]) diff --git a/examples/quick_start_localcontroller/CMakeLists.txt b/examples/ocpp16/quick_start_localcontroller/CMakeLists.txt similarity index 96% rename from examples/quick_start_localcontroller/CMakeLists.txt rename to examples/ocpp16/quick_start_localcontroller/CMakeLists.txt index 146a9afc..f3853fe0 100644 --- a/examples/quick_start_localcontroller/CMakeLists.txt +++ b/examples/ocpp16/quick_start_localcontroller/CMakeLists.txt @@ -12,7 +12,7 @@ target_link_directories(quick_start_localcontroller PRIVATE ${BIN_DIR}) # Dependencies target_link_libraries(quick_start_localcontroller - examples_common + examples_common16 localcontroller ) diff --git a/examples/quick_start_localcontroller/README.md b/examples/ocpp16/quick_start_localcontroller/README.md similarity index 100% rename from examples/quick_start_localcontroller/README.md rename to examples/ocpp16/quick_start_localcontroller/README.md diff --git a/examples/quick_start_localcontroller/config/quick_start_localcontroller.ini b/examples/ocpp16/quick_start_localcontroller/config/quick_start_localcontroller.ini similarity index 96% rename from examples/quick_start_localcontroller/config/quick_start_localcontroller.ini rename to examples/ocpp16/quick_start_localcontroller/config/quick_start_localcontroller.ini index decc8860..1cb0267f 100644 --- a/examples/quick_start_localcontroller/config/quick_start_localcontroller.ini +++ b/examples/ocpp16/quick_start_localcontroller/config/quick_start_localcontroller.ini @@ -1,6 +1,6 @@ [LocalController] DatabasePath=./quick_start_localcontroller.db -JsonSchemasPath=../../schemas/ +JsonSchemasPath=../../schemas/ocpp16/ ListenUrl=wss://127.0.0.1:8080/openocpp/ ConnexionUrl=wss://127.0.0.1:8081/openocpp/ CallRequestTimeout=2000 diff --git a/examples/quick_start_localcontroller/main.cpp b/examples/ocpp16/quick_start_localcontroller/main.cpp similarity index 99% rename from examples/quick_start_localcontroller/main.cpp rename to examples/ocpp16/quick_start_localcontroller/main.cpp index b112a008..7a3af960 100644 --- a/examples/quick_start_localcontroller/main.cpp +++ b/examples/ocpp16/quick_start_localcontroller/main.cpp @@ -33,8 +33,10 @@ SOFTWARE. #include using namespace ocpp::localcontroller; -using namespace ocpp::types; using namespace ocpp::messages; +using namespace ocpp::messages::ocpp16; +using namespace ocpp::types; +using namespace ocpp::types::ocpp16; /** @brief Entry point */ int main(int argc, char* argv[]) diff --git a/examples/remote_chargepoint/CMakeLists.txt b/examples/ocpp16/remote_chargepoint/CMakeLists.txt similarity index 96% rename from examples/remote_chargepoint/CMakeLists.txt rename to examples/ocpp16/remote_chargepoint/CMakeLists.txt index 8abc85f0..51e67bb6 100644 --- a/examples/remote_chargepoint/CMakeLists.txt +++ b/examples/ocpp16/remote_chargepoint/CMakeLists.txt @@ -14,7 +14,7 @@ target_link_directories(remote_chargepoint PRIVATE ${BIN_DIR}) # Dependencies target_link_libraries(remote_chargepoint - examples_common + examples_common16 ) diff --git a/examples/remote_chargepoint/ChargePointEventsHandler.cpp b/examples/ocpp16/remote_chargepoint/ChargePointEventsHandler.cpp similarity index 92% rename from examples/remote_chargepoint/ChargePointEventsHandler.cpp rename to examples/ocpp16/remote_chargepoint/ChargePointEventsHandler.cpp index e9b7d6b3..601c446e 100644 --- a/examples/remote_chargepoint/ChargePointEventsHandler.cpp +++ b/examples/ocpp16/remote_chargepoint/ChargePointEventsHandler.cpp @@ -32,6 +32,7 @@ SOFTWARE. using namespace std; using namespace ocpp::types; +using namespace ocpp::types::ocpp16; /** @brief Constructor */ ChargePointEventsHandler::ChargePointEventsHandler(ChargePointDemoConfig& config, const std::filesystem::path& working_dir) @@ -55,10 +56,11 @@ int ChargePointEventsHandler::getTxStartStopMeterValue(unsigned int connector_id return ret; } -/** @copydoc bool getMeterValue(unsigned int, const std::pair>&, ocpp::types::MeterValue&) */ -bool ChargePointEventsHandler::getMeterValue(unsigned int connector_id, - const std::pair>& measurand, - ocpp::types::MeterValue& meter_value) +/** @copydoc bool getMeterValue(unsigned int, const std::pair>&, ocpp::types::ocpp16::MeterValue&) */ +bool ChargePointEventsHandler::getMeterValue( + unsigned int connector_id, + const std::pair>& measurand, + ocpp::types::ocpp16::MeterValue& meter_value) { bool ret = false; diff --git a/examples/remote_chargepoint/ChargePointEventsHandler.h b/examples/ocpp16/remote_chargepoint/ChargePointEventsHandler.h similarity index 85% rename from examples/remote_chargepoint/ChargePointEventsHandler.h rename to examples/ocpp16/remote_chargepoint/ChargePointEventsHandler.h index a7449990..1b46e8d6 100644 --- a/examples/remote_chargepoint/ChargePointEventsHandler.h +++ b/examples/ocpp16/remote_chargepoint/ChargePointEventsHandler.h @@ -47,10 +47,10 @@ class ChargePointEventsHandler : public DefaultChargePointEventsHandler /** @copydoc int IChargePointEventsHandler::getTxStartStopMeterValue(unsigned int) */ int getTxStartStopMeterValue(unsigned int connector_id) override; - /** @copydoc bool IChargePointEventsHandler::getMeterValue(unsigned int, const std::pair>&, ocpp::types::MeterValue&) */ - bool getMeterValue(unsigned int connector_id, - const std::pair>& measurand, - ocpp::types::MeterValue& meter_value) override; + /** @copydoc bool IChargePointEventsHandler::getMeterValue(unsigned int, const std::pair>&, ocpp::types::ocpp16::MeterValue&) */ + bool getMeterValue(unsigned int connector_id, + const std::pair>& measurand, + ocpp::types::ocpp16::MeterValue& meter_value) override; // API diff --git a/examples/remote_chargepoint/ISetpointManager.h b/examples/ocpp16/remote_chargepoint/ISetpointManager.h similarity index 100% rename from examples/remote_chargepoint/ISetpointManager.h rename to examples/ocpp16/remote_chargepoint/ISetpointManager.h diff --git a/examples/remote_chargepoint/README.md b/examples/ocpp16/remote_chargepoint/README.md similarity index 100% rename from examples/remote_chargepoint/README.md rename to examples/ocpp16/remote_chargepoint/README.md diff --git a/examples/remote_chargepoint/SetpointManager.cpp b/examples/ocpp16/remote_chargepoint/SetpointManager.cpp similarity index 99% rename from examples/remote_chargepoint/SetpointManager.cpp rename to examples/ocpp16/remote_chargepoint/SetpointManager.cpp index 829bf43d..932d162f 100644 --- a/examples/remote_chargepoint/SetpointManager.cpp +++ b/examples/ocpp16/remote_chargepoint/SetpointManager.cpp @@ -25,6 +25,7 @@ SOFTWARE. #include "SetpointManager.h" using namespace ocpp::types; +using namespace ocpp::types::ocpp16; /** @brief Constructor */ SetpointManager::SetpointManager(ocpp::chargepoint::IChargePoint& charge_point, diff --git a/examples/remote_chargepoint/SetpointManager.h b/examples/ocpp16/remote_chargepoint/SetpointManager.h similarity index 100% rename from examples/remote_chargepoint/SetpointManager.h rename to examples/ocpp16/remote_chargepoint/SetpointManager.h diff --git a/examples/remote_chargepoint/config/remote_chargepoint.ini b/examples/ocpp16/remote_chargepoint/config/remote_chargepoint.ini similarity index 98% rename from examples/remote_chargepoint/config/remote_chargepoint.ini rename to examples/ocpp16/remote_chargepoint/config/remote_chargepoint.ini index 5d6f1229..623a9d48 100644 --- a/examples/remote_chargepoint/config/remote_chargepoint.ini +++ b/examples/ocpp16/remote_chargepoint/config/remote_chargepoint.ini @@ -1,6 +1,6 @@ [ChargePoint] DatabasePath=./remote_chargepoint.db -JsonSchemasPath=../../schemas/ +JsonSchemasPath=../../schemas/ocpp16/ ConnexionUrl=wss://127.0.0.1:8080/openocpp/ Tlsv12CipherList=ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:PSK-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES128-GCM-SHA256:PSK-AES128-GCM-SHA256 Tlsv13CipherList=TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384 diff --git a/examples/remote_chargepoint/main.cpp b/examples/ocpp16/remote_chargepoint/main.cpp similarity index 99% rename from examples/remote_chargepoint/main.cpp rename to examples/ocpp16/remote_chargepoint/main.cpp index 0b046d63..c026301d 100644 --- a/examples/remote_chargepoint/main.cpp +++ b/examples/ocpp16/remote_chargepoint/main.cpp @@ -37,6 +37,7 @@ SOFTWARE. using namespace ocpp::chargepoint; using namespace ocpp::types; +using namespace ocpp::types::ocpp16; /** @brief Entry point */ int main(int argc, char* argv[]) diff --git a/examples/security_centralsystem/CMakeLists.txt b/examples/ocpp16/security_centralsystem/CMakeLists.txt similarity index 98% rename from examples/security_centralsystem/CMakeLists.txt rename to examples/ocpp16/security_centralsystem/CMakeLists.txt index 7dcb4a60..27b9d7a2 100644 --- a/examples/security_centralsystem/CMakeLists.txt +++ b/examples/ocpp16/security_centralsystem/CMakeLists.txt @@ -15,7 +15,7 @@ target_link_directories(security_centralsystem PRIVATE ${BIN_DIR}) # Dependencies target_link_libraries(security_centralsystem - examples_common + examples_common16 centralsystem ) diff --git a/examples/security_centralsystem/CentralSystemEventsHandler.cpp b/examples/ocpp16/security_centralsystem/CentralSystemEventsHandler.cpp similarity index 97% rename from examples/security_centralsystem/CentralSystemEventsHandler.cpp rename to examples/ocpp16/security_centralsystem/CentralSystemEventsHandler.cpp index ef3ac4f6..bdb4f926 100644 --- a/examples/security_centralsystem/CentralSystemEventsHandler.cpp +++ b/examples/ocpp16/security_centralsystem/CentralSystemEventsHandler.cpp @@ -33,6 +33,7 @@ SOFTWARE. using namespace std; using namespace ocpp::types; +using namespace ocpp::types::ocpp16; /** @brief Constructor */ CentralSystemEventsHandler::CentralSystemEventsHandler(ChargePointDatabase& chargepoint_db) @@ -213,7 +214,7 @@ void CentralSystemEventsHandler::ChargePointRequestHandler::disconnected() m_event_handler.removeChargePoint(this->proxy()->identifier()); } -/** @copydoc ocpp::types::RegistrationStatus IChargePointRequestHandler::bootNotification(const std::string&, +/** @copydoc ocpp::types::ocpp16::RegistrationStatus IChargePointRequestHandler::bootNotification(const std::string&, const std::string&, const std::string&, const std::string&, @@ -221,7 +222,7 @@ void CentralSystemEventsHandler::ChargePointRequestHandler::disconnected() const std::string&, const std::string&, const std::string&) */ -ocpp::types::RegistrationStatus CentralSystemEventsHandler::ChargePointRequestHandler::bootNotification( +ocpp::types::ocpp16::RegistrationStatus CentralSystemEventsHandler::ChargePointRequestHandler::bootNotification( const std::string& model, const std::string& serial_number, const std::string& vendor, diff --git a/examples/security_centralsystem/CentralSystemEventsHandler.h b/examples/ocpp16/security_centralsystem/CentralSystemEventsHandler.h similarity index 87% rename from examples/security_centralsystem/CentralSystemEventsHandler.h rename to examples/ocpp16/security_centralsystem/CentralSystemEventsHandler.h index 34b6f97f..cebc8136 100644 --- a/examples/security_centralsystem/CentralSystemEventsHandler.h +++ b/examples/ocpp16/security_centralsystem/CentralSystemEventsHandler.h @@ -96,7 +96,7 @@ class CentralSystemEventsHandler : public DefaultCentralSystemEventsHandler /** @copydoc void IChargePointRequestHandler::disconnected() */ void disconnected() override; - /** @copydoc ocpp::types::RegistrationStatus IChargePointRequestHandler::bootNotification(const std::string&, + /** @copydoc ocpp::types::ocpp16::RegistrationStatus IChargePointRequestHandler::bootNotification(const std::string&, const std::string&, const std::string&, const std::string&, @@ -104,14 +104,14 @@ class CentralSystemEventsHandler : public DefaultCentralSystemEventsHandler const std::string&, const std::string&, const std::string&) */ - ocpp::types::RegistrationStatus bootNotification(const std::string& model, - const std::string& serial_number, - const std::string& vendor, - const std::string& firmware_version, - const std::string& iccid, - const std::string& imsi, - const std::string& meter_serial_number, - const std::string& meter_type) override; + ocpp::types::ocpp16::RegistrationStatus bootNotification(const std::string& model, + const std::string& serial_number, + const std::string& vendor, + const std::string& firmware_version, + const std::string& iccid, + const std::string& imsi, + const std::string& meter_serial_number, + const std::string& meter_type) override; // Security extensions diff --git a/examples/security_centralsystem/ChargePointDatabase.cpp b/examples/ocpp16/security_centralsystem/ChargePointDatabase.cpp similarity index 100% rename from examples/security_centralsystem/ChargePointDatabase.cpp rename to examples/ocpp16/security_centralsystem/ChargePointDatabase.cpp diff --git a/examples/security_centralsystem/ChargePointDatabase.h b/examples/ocpp16/security_centralsystem/ChargePointDatabase.h similarity index 100% rename from examples/security_centralsystem/ChargePointDatabase.h rename to examples/ocpp16/security_centralsystem/ChargePointDatabase.h diff --git a/examples/security_centralsystem/README.md b/examples/ocpp16/security_centralsystem/README.md similarity index 100% rename from examples/security_centralsystem/README.md rename to examples/ocpp16/security_centralsystem/README.md diff --git a/examples/security_centralsystem/config/security_centralsystem_p0.ini b/examples/ocpp16/security_centralsystem/config/security_centralsystem_p0.ini similarity index 93% rename from examples/security_centralsystem/config/security_centralsystem_p0.ini rename to examples/ocpp16/security_centralsystem/config/security_centralsystem_p0.ini index 6f03fac7..ecf82cb8 100644 --- a/examples/security_centralsystem/config/security_centralsystem_p0.ini +++ b/examples/ocpp16/security_centralsystem/config/security_centralsystem_p0.ini @@ -1,6 +1,6 @@ [CentralSystem] DatabasePath=./security_centralsystem_p0.db -JsonSchemasPath=../../schemas/ +JsonSchemasPath=../../schemas/ocpp16/ ListenUrl=ws://127.0.0.1:8080/openocpp/ CallRequestTimeout=2000 WebSocketPingInterval=30 diff --git a/examples/security_centralsystem/config/security_centralsystem_p1.ini b/examples/ocpp16/security_centralsystem/config/security_centralsystem_p1.ini similarity index 93% rename from examples/security_centralsystem/config/security_centralsystem_p1.ini rename to examples/ocpp16/security_centralsystem/config/security_centralsystem_p1.ini index 1011de05..72155715 100644 --- a/examples/security_centralsystem/config/security_centralsystem_p1.ini +++ b/examples/ocpp16/security_centralsystem/config/security_centralsystem_p1.ini @@ -1,6 +1,6 @@ [CentralSystem] DatabasePath=./security_centralsystem_p1.db -JsonSchemasPath=../../schemas/ +JsonSchemasPath=../../schemas/ocpp16/ ListenUrl=ws://127.0.0.1:8081/openocpp/ CallRequestTimeout=2000 WebSocketPingInterval=30 diff --git a/examples/security_centralsystem/config/security_centralsystem_p2.ini b/examples/ocpp16/security_centralsystem/config/security_centralsystem_p2.ini similarity index 96% rename from examples/security_centralsystem/config/security_centralsystem_p2.ini rename to examples/ocpp16/security_centralsystem/config/security_centralsystem_p2.ini index 1899fcec..a333a7ac 100644 --- a/examples/security_centralsystem/config/security_centralsystem_p2.ini +++ b/examples/ocpp16/security_centralsystem/config/security_centralsystem_p2.ini @@ -1,6 +1,6 @@ [CentralSystem] DatabasePath=./security_centralsystem_p2.db -JsonSchemasPath=../../schemas/ +JsonSchemasPath=../../schemas/ocpp16/ ListenUrl=wss://127.0.0.1:8082/openocpp/ CallRequestTimeout=2000 WebSocketPingInterval=30 diff --git a/examples/security_centralsystem/config/security_centralsystem_p3.ini b/examples/ocpp16/security_centralsystem/config/security_centralsystem_p3.ini similarity index 96% rename from examples/security_centralsystem/config/security_centralsystem_p3.ini rename to examples/ocpp16/security_centralsystem/config/security_centralsystem_p3.ini index 40eda180..0e182ad2 100644 --- a/examples/security_centralsystem/config/security_centralsystem_p3.ini +++ b/examples/ocpp16/security_centralsystem/config/security_centralsystem_p3.ini @@ -1,6 +1,6 @@ [CentralSystem] DatabasePath=./security_centralsystem_p3.db -JsonSchemasPath=../../schemas/ +JsonSchemasPath=../../schemas/ocpp16/ ListenUrl=wss://127.0.0.1:8083/openocpp/ CallRequestTimeout=2000 WebSocketPingInterval=30 diff --git a/examples/security_centralsystem/main.cpp b/examples/ocpp16/security_centralsystem/main.cpp similarity index 99% rename from examples/security_centralsystem/main.cpp rename to examples/ocpp16/security_centralsystem/main.cpp index fa6319c3..66636926 100644 --- a/examples/security_centralsystem/main.cpp +++ b/examples/ocpp16/security_centralsystem/main.cpp @@ -41,6 +41,7 @@ SOFTWARE. using namespace ocpp::centralsystem; using namespace ocpp::types; +using namespace ocpp::types::ocpp16; using namespace ocpp::x509; /** @brief Passphrase for the certificates' private keys */ diff --git a/examples/security_chargepoint/CMakeLists.txt b/examples/ocpp16/security_chargepoint/CMakeLists.txt similarity index 96% rename from examples/security_chargepoint/CMakeLists.txt rename to examples/ocpp16/security_chargepoint/CMakeLists.txt index ab8805d6..208eb7f6 100644 --- a/examples/security_chargepoint/CMakeLists.txt +++ b/examples/ocpp16/security_chargepoint/CMakeLists.txt @@ -12,7 +12,7 @@ target_link_directories(security_chargepoint PRIVATE ${BIN_DIR}) # Dependencies target_link_libraries(security_chargepoint - examples_common + examples_common16 ) diff --git a/examples/security_chargepoint/README.md b/examples/ocpp16/security_chargepoint/README.md similarity index 100% rename from examples/security_chargepoint/README.md rename to examples/ocpp16/security_chargepoint/README.md diff --git a/examples/security_chargepoint/config/security_chargepoint.ini b/examples/ocpp16/security_chargepoint/config/security_chargepoint.ini similarity index 98% rename from examples/security_chargepoint/config/security_chargepoint.ini rename to examples/ocpp16/security_chargepoint/config/security_chargepoint.ini index f93a75c2..f844f160 100644 --- a/examples/security_chargepoint/config/security_chargepoint.ini +++ b/examples/ocpp16/security_chargepoint/config/security_chargepoint.ini @@ -1,6 +1,6 @@ [ChargePoint] DatabasePath=./security_chargepoint.db -JsonSchemasPath=../../schemas/ +JsonSchemasPath=../../schemas/ocpp16/ ConnexionUrl=ws://127.0.0.1:8080/openocpp/ Tlsv12CipherList=ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:PSK-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES128-GCM-SHA256:PSK-AES128-GCM-SHA256 Tlsv13CipherList=TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384 diff --git a/examples/security_chargepoint/main.cpp b/examples/ocpp16/security_chargepoint/main.cpp similarity index 99% rename from examples/security_chargepoint/main.cpp rename to examples/ocpp16/security_chargepoint/main.cpp index 98a26b61..c359aedc 100644 --- a/examples/security_chargepoint/main.cpp +++ b/examples/ocpp16/security_chargepoint/main.cpp @@ -34,6 +34,7 @@ SOFTWARE. using namespace ocpp::chargepoint; using namespace ocpp::types; +using namespace ocpp::types::ocpp16; /** @brief Entry point */ int main(int argc, char* argv[]) diff --git a/examples/ocpp20/CMakeLists.txt b/examples/ocpp20/CMakeLists.txt new file mode 100644 index 00000000..c4d26702 --- /dev/null +++ b/examples/ocpp20/CMakeLists.txt @@ -0,0 +1,8 @@ + +# Subdirectories +add_subdirectory(common) +add_subdirectory(quick_start_basicchargepoint) +add_subdirectory(quick_start_centralsystem) +add_subdirectory(quick_start_chargepoint) +add_subdirectory(quick_start_localcontroller) + diff --git a/examples/ocpp20/common/CMakeLists.txt b/examples/ocpp20/common/CMakeLists.txt new file mode 100644 index 00000000..7108b404 --- /dev/null +++ b/examples/ocpp20/common/CMakeLists.txt @@ -0,0 +1,12 @@ + +# Common utility class for examples library +add_library(examples_common20 OBJECT + DefaultChargePointEventsHandler.cpp + DefaultBasicChargePointEventsHandler.cpp + DefaultCentralSystemEventsHandler.cpp + DefaultLocalControllerEventsHandler.cpp +) +target_include_directories(examples_common20 PUBLIC . config simulators) + +# Dependencies +target_link_libraries(examples_common20 examples_common) diff --git a/examples/ocpp20/common/DefaultBasicChargePointEventsHandler.cpp b/examples/ocpp20/common/DefaultBasicChargePointEventsHandler.cpp new file mode 100644 index 00000000..4b1fd9bc --- /dev/null +++ b/examples/ocpp20/common/DefaultBasicChargePointEventsHandler.cpp @@ -0,0 +1,81 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +#include "DefaultBasicChargePointEventsHandler.h" +#include "ChargePointDemoConfig.h" + +#include + +using namespace std; +using namespace ocpp::types; +using namespace ocpp::types::ocpp20; + +/** @brief Constructor */ +DefaultBasicChargePointEventsHandler::DefaultBasicChargePointEventsHandler(ChargePointDemoConfig& config, + const std::filesystem::path& working_dir) + : m_config(config), m_working_dir(working_dir), m_is_connected(false) +{ +} + +/** @brief Destructor */ +DefaultBasicChargePointEventsHandler::~DefaultBasicChargePointEventsHandler() { } + +/** @copydoc void IChargePointEventsHandler20::connectionFailed(ocpp::types::ocpp20::RegistrationStatusEnumType) */ +void DefaultBasicChargePointEventsHandler::connectionFailed(ocpp::types::ocpp20::RegistrationStatusEnumType status) +{ + cout << "Connection failed, previous registration status : " << RegistrationStatusEnumTypeHelper.toString(status) << endl; +} + +/** @copydoc void IChargePointEventsHandler20::connectionStateChanged(bool) */ +void DefaultBasicChargePointEventsHandler::connectionStateChanged(bool isConnected) +{ + cout << "Connection state changed : " << isConnected << endl; + m_is_connected = isConnected; +} + +/** @copydoc void IChargePointEventsHandler20::bootNotification(ocpp::types::ocpp20::RegistrationStatusEnumType, const ocpp::types::DateTime&) */ +void DefaultBasicChargePointEventsHandler::bootNotification(ocpp::types::ocpp20::RegistrationStatusEnumType status, + const ocpp::types::DateTime& datetime) +{ + cout << "Bootnotification : " << RegistrationStatusEnumTypeHelper.toString(status) << " - " << datetime.str() << endl; +} + +/** @copydoc void IChargePointEventsHandler20::datetimeReceived(ocpp::types::DateTime) */ +void DefaultBasicChargePointEventsHandler::datetimeReceived(const ocpp::types::DateTime& datetime) +{ + cout << "Date time received : " << datetime.str() << endl; +} + +// IDeviceModel20 interface + +/** @brief Called to retrieve the value of a variable */ +void DefaultBasicChargePointEventsHandler::getVariable(ocpp::types::ocpp20::GetVariableResultType& var) +{ + std::string value; + m_config.getDeviceModelValue(var.component, var.variable, value); + var.attributeValue.value().assign(std::move(value)); + var.attributeStatus = GetVariableStatusEnumType::Accepted; +} + +/** @brief Called to set the value of a variable */ +ocpp::types::ocpp20::SetVariableStatusEnumType DefaultBasicChargePointEventsHandler::setVariable( + const ocpp::types::ocpp20::SetVariableDataType& var) +{ + m_config.setDeviceModelValue(var.component, var.variable, var.attributeValue.str()); + return SetVariableStatusEnumType::Accepted; +} diff --git a/examples/ocpp20/common/DefaultBasicChargePointEventsHandler.h b/examples/ocpp20/common/DefaultBasicChargePointEventsHandler.h new file mode 100644 index 00000000..74dec985 --- /dev/null +++ b/examples/ocpp20/common/DefaultBasicChargePointEventsHandler.h @@ -0,0 +1,69 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +#ifndef OPENOCPP_DEFAULTBASICCHARGEPOINTEVENTSHANDLERCHARGEPOINT_H +#define OPENOCPP_DEFAULTBASICCHARGEPOINTEVENTSHANDLERCHARGEPOINT_H + +#include "IBasicChargePointEventsHandler20.h" +#include "IDeviceModel20.h" + +#include + +class ChargePointDemoConfig; + +/** @brief Interface for charge point event handlers implementations */ +class DefaultBasicChargePointEventsHandler : public ocpp::chargepoint::ocpp20::IBasicChargePointEventsHandler, + public ocpp::chargepoint::ocpp20::IDeviceModel::IListener +{ + public: + /** @brief Constructor */ + DefaultBasicChargePointEventsHandler(ChargePointDemoConfig& config, const std::filesystem::path& working_dir); + + /** @brief Destructor */ + virtual ~DefaultBasicChargePointEventsHandler(); + + /** @copydoc void IChargePointEventsHandler20::connectionFailed(ocpp::types::ocpp20::RegistrationStatusEnumType) */ + void connectionFailed(ocpp::types::ocpp20::RegistrationStatusEnumType status) override; + + /** @copydoc void IChargePointEventsHandler20::connectionStateChanged(bool) */ + void connectionStateChanged(bool isConnected) override; + + /** @copydoc void IChargePointEventsHandler20::bootNotification(ocpp::types::ocpp20::RegistrationStatusEnumType, const ocpp::types::DateTime&) */ + void bootNotification(ocpp::types::ocpp20::RegistrationStatusEnumType status, const ocpp::types::DateTime& datetime) override; + + /** @copydoc void IChargePointEventsHandler20::datetimeReceived(ocpp::types::DateTime) */ + void datetimeReceived(const ocpp::types::DateTime& datetime) override; + + // IDeviceModel interface + + /** @brief Called to retrieve the value of a variable */ + void getVariable(ocpp::types::ocpp20::GetVariableResultType& var) override; + + /** @brief Called to set the value of a variable */ + ocpp::types::ocpp20::SetVariableStatusEnumType setVariable(const ocpp::types::ocpp20::SetVariableDataType& var) override; + + private: + /** @brief Configuration */ + ChargePointDemoConfig& m_config; + /** @brief Working directory */ + std::filesystem::path m_working_dir; + /** @brief Indicate if the Charge Point is connected */ + bool m_is_connected; +}; + +#endif // OPENOCPP_DEFAULTBASICCHARGEPOINTEVENTSHANDLERCHARGEPOINT_H diff --git a/examples/ocpp20/common/DefaultCentralSystemEventsHandler.cpp b/examples/ocpp20/common/DefaultCentralSystemEventsHandler.cpp new file mode 100644 index 00000000..e63ea5ea --- /dev/null +++ b/examples/ocpp20/common/DefaultCentralSystemEventsHandler.cpp @@ -0,0 +1,694 @@ +/* +MIT License + +Copyright (c) 2020 Cedric Jimenez + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + +#include "DefaultCentralSystemEventsHandler.h" +#include "PrivateKey.h" +#include "Sha2.h" +#include "StringHelpers.h" + +#include +#include +#include + +// With MSVC compiler, the system() call returns directly the command's return value +#ifdef _MSC_VER +#define WEXITSTATUS(x) (x) +#endif // _MSC_VER + +using namespace std; +using namespace ocpp::centralsystem; +using namespace ocpp::types; +using namespace ocpp::types::ocpp20; +using namespace ocpp::x509; + +/** @brief Display a list of meter values */ +static void displayMeterValues(const std::vector meter_values); + +/** @brief Constructor */ +DefaultCentralSystemEventsHandler::DefaultCentralSystemEventsHandler(CentralSystemDemoConfig& config, + std::filesystem::path iso_v2g_root_ca, + std::filesystem::path iso_mo_root_ca, + bool set_pending_status) + : m_config(config), + m_chargepoints_mutex(), + m_iso_v2g_root_ca(iso_v2g_root_ca), + m_iso_mo_root_ca(iso_mo_root_ca), + m_set_pending_status(set_pending_status), + m_chargepoints(), + m_pending_chargepoints(), + m_accepted_chargepoints() +{ +} + +/** @brief Destructor */ +DefaultCentralSystemEventsHandler::~DefaultCentralSystemEventsHandler() { } + +// ICentralSystemEventsHandler interface + +/** @copydoc bool ICentralSystemEventsHandler::acceptConnection(const char*) */ +bool DefaultCentralSystemEventsHandler::acceptConnection(const char* ip_address) +{ + cout << "Accept connection from [" << ip_address << "]" << endl; + return true; +} + +/** @copydoc void ICentralSystemEventsHandler::clientFailedToConnect(const char*) */ +void DefaultCentralSystemEventsHandler::clientFailedToConnect(const char* ip_address) +{ + cout << "Client [" << ip_address << "] failed to connect" << endl; +} + +/** @copydoc bool ICentralSystemEventsHandler::checkCredentials(const std::string&, const std::string&) */ +bool DefaultCentralSystemEventsHandler::checkCredentials(const std::string& chargepoint_id, const std::string& password) +{ + cout << "Check credentials for [" << chargepoint_id << "] : " << password << endl; + return true; +} + +/** @copydoc bool ICentralSystemEventsHandler::chargePointConnected(std::shared_ptr) */ +void DefaultCentralSystemEventsHandler::chargePointConnected( + std::shared_ptr chargepoint) +{ + cout << "Charge point [" << chargepoint->identifier() << "] connected" << endl; + + std::lock_guard lock(m_chargepoints_mutex); + + auto iter_chargepoint = m_chargepoints.find(chargepoint->identifier()); + if (iter_chargepoint == m_chargepoints.end()) + { + m_chargepoints[chargepoint->identifier()] = + std::shared_ptr(new ChargePointRequestHandler(*this, chargepoint)); + } + else + { + cout << "Charge point [" << chargepoint->identifier() << "] already connected" << endl; + chargepoint.reset(); + } +} + +/** @brief Remove a charge point from the connected charge points */ +void DefaultCentralSystemEventsHandler::removeChargePoint(const std::string& identifier) +{ + std::thread t( + [this, identifier = identifier] + { + std::this_thread::sleep_for(std::chrono::milliseconds(50)); + + std::lock_guard lock(m_chargepoints_mutex); + m_chargepoints.erase(identifier); + m_pending_chargepoints.erase(identifier); + m_accepted_chargepoints.erase(identifier); + }); + t.detach(); +} + +/** @brief Indicate if a charge point must be accepted */ +bool DefaultCentralSystemEventsHandler::isAcceptedChargePoint(const std::string& identifier) +{ + std::lock_guard lock(m_chargepoints_mutex); + return (m_accepted_chargepoints.find(identifier) != m_accepted_chargepoints.end()); +} + +/** @brief Add a charge point to the pending list */ +void DefaultCentralSystemEventsHandler::addPendingChargePoint( + std::shared_ptr chargepoint) +{ + std::lock_guard lock(m_chargepoints_mutex); + m_pending_chargepoints[chargepoint->identifier()] = chargepoint; +} + +/** @brief Add a charge point to the accepted list */ +void DefaultCentralSystemEventsHandler::addAcceptedChargePoint( + std::shared_ptr chargepoint) +{ + std::lock_guard lock(m_chargepoints_mutex); + m_accepted_chargepoints[chargepoint->identifier()] = chargepoint; +} + +/** @brief Constructor */ +DefaultCentralSystemEventsHandler::ChargePointRequestHandler::ChargePointRequestHandler( + DefaultCentralSystemEventsHandler& event_handler, + std::shared_ptr& chargepoint) + : m_event_handler(event_handler), m_chargepoint(chargepoint) +{ + m_chargepoint->registerHandler(*this); +} + +/** @brief Destructor */ +DefaultCentralSystemEventsHandler::ChargePointRequestHandler::~ChargePointRequestHandler() { } + +// IChargePointRequestHandler20 interface + +/** @brief Called to notify the disconnection of the charge point */ +void DefaultCentralSystemEventsHandler::ChargePointRequestHandler::disconnected() +{ + cout << "[" << m_chargepoint->identifier() << "] - Disconnected" << endl; + m_event_handler.removeChargePoint(m_chargepoint->identifier()); +} + +/** @brief Called on reception of a BootNotification request from the charge point */ +bool DefaultCentralSystemEventsHandler::ChargePointRequestHandler::onBootNotification( + const ocpp::messages::ocpp20::BootNotificationReq& request, + ocpp::messages::ocpp20::BootNotificationConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)error; + (void)message; + + cout << "[" << m_chargepoint->identifier() << "] - BootNotification : vendor = " << request.chargingStation.vendorName.str() + << " model = " << request.chargingStation.model.str() << " S/N = " << request.chargingStation.serialNumber.value().str() + << " version = " << request.chargingStation.firmwareVersion.value().str() << endl; + + response.currentTime = DateTime::now(); + response.interval = m_event_handler.getConfig().heartbeatInterval().count(); + response.status = RegistrationStatusEnumType::Accepted; + if (m_event_handler.setPendingEnabled()) + { + if (!m_event_handler.isAcceptedChargePoint(m_chargepoint->identifier())) + { + m_event_handler.addPendingChargePoint(m_chargepoint); + response.interval = m_event_handler.getConfig().bootNotificationRetryInterval().count(); + response.status = RegistrationStatusEnumType::Pending; + } + } + + return ret; +} + +/** @brief Called on reception of a Authorize request from the charge point */ +bool DefaultCentralSystemEventsHandler::ChargePointRequestHandler::onAuthorize(const ocpp::messages::ocpp20::AuthorizeReq& request, + ocpp::messages::ocpp20::AuthorizeConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)error; + (void)message; + + cout << "[" << m_chargepoint->identifier() << "] - Authorize" + << " type = " << IdTokenEnumTypeHelper.toString(request.idToken.type) << " token = " << request.idToken.idToken.str() << endl; + + response.idTokenInfo.status = AuthorizationStatusEnumType::Accepted; + response.idTokenInfo.cacheExpiryDateTime.value() = DateTime(DateTime::now().timestamp() + 3600); + + return ret; +} + +/** @brief Called on reception of a ClearedChargingLimit request from the charge point */ +bool DefaultCentralSystemEventsHandler::ChargePointRequestHandler::onClearedChargingLimit( + const ocpp::messages::ocpp20::ClearedChargingLimitReq& request, + ocpp::messages::ocpp20::ClearedChargingLimitConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)request; + (void)response; + (void)error; + (void)message; + + cout << "[" << m_chargepoint->identifier() << "] - ClearedChargingLimit" << endl; + + return ret; +} + +/** @brief Called on reception of a CostUpdated request from the charge point */ +bool DefaultCentralSystemEventsHandler::ChargePointRequestHandler::onCostUpdated(const ocpp::messages::ocpp20::CostUpdatedReq& request, + ocpp::messages::ocpp20::CostUpdatedConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)request; + (void)response; + (void)error; + (void)message; + + cout << "[" << m_chargepoint->identifier() << "] - CostUpdated" << endl; + + return ret; +} + +/** @brief Called on reception of a DataTransfer request from the charge point */ +bool DefaultCentralSystemEventsHandler::ChargePointRequestHandler::onDataTransfer(const ocpp::messages::ocpp20::DataTransferReq& request, + ocpp::messages::ocpp20::DataTransferConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)request; + (void)error; + (void)message; + + cout << "[" << m_chargepoint->identifier() << "] - DataTransfer" << endl; + + response.status = DataTransferStatusEnumType::UnknownVendorId; + + return ret; +} + +/** @brief Called on reception of a FirmwareStatusNotification request from the charge point */ +bool DefaultCentralSystemEventsHandler::ChargePointRequestHandler::onFirmwareStatusNotification( + const ocpp::messages::ocpp20::FirmwareStatusNotificationReq& request, + ocpp::messages::ocpp20::FirmwareStatusNotificationConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)request; + (void)response; + (void)error; + (void)message; + + cout << "[" << m_chargepoint->identifier() << "] - FirmwareStatusNotification" << endl; + + return ret; +} + +/** @brief Called on reception of a Heartbeat request from the charge point */ +bool DefaultCentralSystemEventsHandler::ChargePointRequestHandler::onHeartbeat(const ocpp::messages::ocpp20::HeartbeatReq& request, + ocpp::messages::ocpp20::HeartbeatConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)request; + (void)error; + (void)message; + + cout << "[" << m_chargepoint->identifier() << "] - Heartbeat" << endl; + + response.currentTime = DateTime::now(); + + return ret; +} + +/** @brief Called on reception of a LogStatusNotification request from the charge point */ +bool DefaultCentralSystemEventsHandler::ChargePointRequestHandler::onLogStatusNotification( + const ocpp::messages::ocpp20::LogStatusNotificationReq& request, + ocpp::messages::ocpp20::LogStatusNotificationConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)request; + (void)response; + (void)error; + (void)message; + + cout << "[" << m_chargepoint->identifier() << "] - LogStatusNotification" << endl; + + return ret; +} + +/** @brief Called on reception of a MeterValues request from the charge point */ +bool DefaultCentralSystemEventsHandler::ChargePointRequestHandler::onMeterValues(const ocpp::messages::ocpp20::MeterValuesReq& request, + ocpp::messages::ocpp20::MeterValuesConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)request; + (void)response; + (void)error; + (void)message; + + cout << "[" << m_chargepoint->identifier() << "] - MeterValues" << endl; + displayMeterValues(request.meterValue); + + return ret; +} + +/** @brief Called on reception of a NotifyChargingLimit request from the charge point */ +bool DefaultCentralSystemEventsHandler::ChargePointRequestHandler::onNotifyChargingLimit( + const ocpp::messages::ocpp20::NotifyChargingLimitReq& request, + ocpp::messages::ocpp20::NotifyChargingLimitConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)request; + (void)response; + (void)error; + (void)message; + + cout << "[" << m_chargepoint->identifier() << "] - NotifyChargingLimit" << endl; + + return ret; +} + +/** @brief Called on reception of a NotifyCustomerInformation request from the charge point */ +bool DefaultCentralSystemEventsHandler::ChargePointRequestHandler::onNotifyCustomerInformation( + const ocpp::messages::ocpp20::NotifyCustomerInformationReq& request, + ocpp::messages::ocpp20::NotifyCustomerInformationConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)request; + (void)response; + (void)error; + (void)message; + + cout << "[" << m_chargepoint->identifier() << "] - NotifyCustomerInformation" << endl; + + return ret; +} + +/** @brief Called on reception of a NotifyDisplayMessages request from the charge point */ +bool DefaultCentralSystemEventsHandler::ChargePointRequestHandler::onNotifyDisplayMessages( + const ocpp::messages::ocpp20::NotifyDisplayMessagesReq& request, + ocpp::messages::ocpp20::NotifyDisplayMessagesConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)request; + (void)response; + (void)error; + (void)message; + + cout << "[" << m_chargepoint->identifier() << "] - NotifyDisplayMessages" << endl; + + return ret; +} + +/** @brief Called on reception of a NotifyEVChargingNeeds request from the charge point */ +bool DefaultCentralSystemEventsHandler::ChargePointRequestHandler::onNotifyEVChargingNeeds( + const ocpp::messages::ocpp20::NotifyEVChargingNeedsReq& request, + ocpp::messages::ocpp20::NotifyEVChargingNeedsConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)request; + (void)response; + (void)error; + (void)message; + + cout << "[" << m_chargepoint->identifier() << "] - NotifyEVChargingNeeds" << endl; + + return ret; +} + +/** @brief Called on reception of a NotifyEVChargingSchedule request from the charge point */ +bool DefaultCentralSystemEventsHandler::ChargePointRequestHandler::onNotifyEVChargingSchedule( + const ocpp::messages::ocpp20::NotifyEVChargingScheduleReq& request, + ocpp::messages::ocpp20::NotifyEVChargingScheduleConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)request; + (void)response; + (void)error; + (void)message; + + cout << "[" << m_chargepoint->identifier() << "] - NotifyEVChargingSchedule" << endl; + + return ret; +} + +/** @brief Called on reception of a NotifyEvent request from the charge point */ +bool DefaultCentralSystemEventsHandler::ChargePointRequestHandler::onNotifyEvent(const ocpp::messages::ocpp20::NotifyEventReq& request, + ocpp::messages::ocpp20::NotifyEventConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)request; + (void)response; + (void)error; + (void)message; + + cout << "[" << m_chargepoint->identifier() << "] - NotifyEvent" << endl; + + return ret; +} + +/** @brief Called on reception of a NotifyMonitoringReport request from the charge point */ +bool DefaultCentralSystemEventsHandler::ChargePointRequestHandler::onNotifyMonitoringReport( + const ocpp::messages::ocpp20::NotifyMonitoringReportReq& request, + ocpp::messages::ocpp20::NotifyMonitoringReportConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)request; + (void)response; + (void)error; + (void)message; + + cout << "[" << m_chargepoint->identifier() << "] - NotifyMonitoringReport" << endl; + + return ret; +} + +/** @brief Called on reception of a NotifyReport request from the charge point */ +bool DefaultCentralSystemEventsHandler::ChargePointRequestHandler::onNotifyReport(const ocpp::messages::ocpp20::NotifyReportReq& request, + ocpp::messages::ocpp20::NotifyReportConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)request; + (void)response; + (void)error; + (void)message; + + cout << "[" << m_chargepoint->identifier() << "] - NotifyReport" << endl; + + return ret; +} + +/** @brief Called on reception of a PublishFirmwareStatusNotification request from the charge point */ +bool DefaultCentralSystemEventsHandler::ChargePointRequestHandler::onPublishFirmwareStatusNotification( + const ocpp::messages::ocpp20::PublishFirmwareStatusNotificationReq& request, + ocpp::messages::ocpp20::PublishFirmwareStatusNotificationConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)request; + (void)response; + (void)error; + (void)message; + + cout << "[" << m_chargepoint->identifier() << "] - PublishFirmwareStatusNotification" << endl; + + return ret; +} + +/** @brief Called on reception of a ReportChargingProfiles request from the charge point */ +bool DefaultCentralSystemEventsHandler::ChargePointRequestHandler::onReportChargingProfiles( + const ocpp::messages::ocpp20::ReportChargingProfilesReq& request, + ocpp::messages::ocpp20::ReportChargingProfilesConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)request; + (void)response; + (void)error; + (void)message; + + cout << "[" << m_chargepoint->identifier() << "] - ReportChargingProfiles" << endl; + + return ret; +} + +/** @brief Called on reception of a ReservationStatusUpdate request from the charge point */ +bool DefaultCentralSystemEventsHandler::ChargePointRequestHandler::onReservationStatusUpdate( + const ocpp::messages::ocpp20::ReservationStatusUpdateReq& request, + ocpp::messages::ocpp20::ReservationStatusUpdateConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)request; + (void)response; + (void)error; + (void)message; + + cout << "[" << m_chargepoint->identifier() << "] - ReservationStatusUpdate" << endl; + + return ret; +} + +/** @brief Called on reception of a SecurityEventNotification request from the charge point */ +bool DefaultCentralSystemEventsHandler::ChargePointRequestHandler::onSecurityEventNotification( + const ocpp::messages::ocpp20::SecurityEventNotificationReq& request, + ocpp::messages::ocpp20::SecurityEventNotificationConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)request; + (void)response; + (void)error; + (void)message; + + cout << "[" << m_chargepoint->identifier() << "] - SecurityEventNotification" << endl; + + return ret; +} + +/** @brief Called on reception of a SignCertificate request from the charge point */ +bool DefaultCentralSystemEventsHandler::ChargePointRequestHandler::onSignCertificate( + const ocpp::messages::ocpp20::SignCertificateReq& request, + ocpp::messages::ocpp20::SignCertificateConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)request; + (void)error; + (void)message; + + cout << "[" << m_chargepoint->identifier() << "] - SignCertificate" << endl; + + response.status = GenericStatusEnumType::Rejected; + + return ret; +} + +/** @brief Called on reception of a StatusNotification request from the charge point */ +bool DefaultCentralSystemEventsHandler::ChargePointRequestHandler::onStatusNotification( + const ocpp::messages::ocpp20::StatusNotificationReq& request, + ocpp::messages::ocpp20::StatusNotificationConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)request; + (void)response; + (void)error; + (void)message; + + cout << "[" << m_chargepoint->identifier() << "] - StatusNotification" << endl; + + return ret; +} + +/** @brief Called on reception of a TransactionEvent request from the charge point */ +bool DefaultCentralSystemEventsHandler::ChargePointRequestHandler::onTransactionEvent( + const ocpp::messages::ocpp20::TransactionEventReq& request, + ocpp::messages::ocpp20::TransactionEventConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)response; + (void)error; + (void)message; + + cout << "[" << m_chargepoint->identifier() << "] - TransactionEvent" << endl; + + switch (request.eventType) + { + case TransactionEventEnumType::Started: + { + cout << "Start transaction : id = " << request.transactionInfo.transactionId.str() << endl; + } + break; + + case TransactionEventEnumType::Ended: + { + cout << "End transaction : id = " << request.transactionInfo.transactionId.str() << endl; + } + break; + + case TransactionEventEnumType::Updated: + { + cout << "Transaction update : id = " << request.transactionInfo.transactionId.str() << endl; + displayMeterValues(request.meterValue); + } + break; + + default: + break; + } + + return ret; +} + +/** @brief Display a list of meter values */ +static void displayMeterValues(const std::vector meter_values) +{ + for (const MeterValueType& meter_value : meter_values) + { + cout << " - timestamp : " << meter_value.timestamp.str() << ", sampled values : " << endl; + for (const SampledValueType& sampled_value : meter_value.sampledValue) + { + cout << " - value = " << sampled_value.value; + if (sampled_value.unitOfMeasure.isSet()) + { + cout << ", unit = " << sampled_value.unitOfMeasure.value().unit.value().str(); + } + if (sampled_value.phase.isSet()) + { + cout << ", phase = " << PhaseEnumTypeHelper.toString(sampled_value.phase); + } + if (sampled_value.measurand.isSet()) + { + cout << ", measurand = " << MeasurandEnumTypeHelper.toString(sampled_value.measurand); + } + if (sampled_value.context.isSet()) + { + cout << ", context = " << ReadingContextEnumTypeHelper.toString(sampled_value.context); + } + if (sampled_value.location.isSet()) + { + cout << ", location = " << LocationEnumTypeHelper.toString(sampled_value.location); + } + cout << endl; + } + } +} diff --git a/examples/ocpp20/common/DefaultCentralSystemEventsHandler.h b/examples/ocpp20/common/DefaultCentralSystemEventsHandler.h new file mode 100644 index 00000000..21c02dff --- /dev/null +++ b/examples/ocpp20/common/DefaultCentralSystemEventsHandler.h @@ -0,0 +1,313 @@ +/* +MIT License + +Copyright (c) 2020 Cedric Jimenez + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + +#ifndef DEFAULTCENTRALSYSTEMEVENTSHANDLER_H +#define DEFAULTCENTRALSYSTEMEVENTSHANDLER_H + +#include "CentralSystemDemoConfig.h" +#include "ICentralSystemEventsHandler20.h" +#include "IChargePointRequestHandler20.h" + +#include +#include +#include + +/** @brief Default central system event handlers implementation for the examples */ +class DefaultCentralSystemEventsHandler : public ocpp::centralsystem::ocpp20::ICentralSystemEventsHandler20 +{ + public: + /** @brief Constructor */ + DefaultCentralSystemEventsHandler(CentralSystemDemoConfig& config, + std::filesystem::path iso_v2g_root_ca = "", + std::filesystem::path iso_mo_root_ca = "", + bool set_pending_status = false); + + /** @brief Destructor */ + virtual ~DefaultCentralSystemEventsHandler(); + + // ICentralSystemEventsHandler interface + + /** @copydoc bool ICentralSystemEventsHandler::acceptConnection(const char*) */ + bool acceptConnection(const char* ip_address) override; + + /** @copydoc void ICentralSystemEventsHandler::clientFailedToConnect(const char*) */ + void clientFailedToConnect(const char* ip_address) override; + + /** @copydoc bool ICentralSystemEventsHandler::checkCredentials(const std::string&, const std::string&) */ + bool checkCredentials(const std::string& chargepoint_id, const std::string& password) override; + + /** @copydoc bool ICentralSystemEventsHandler::chargePointConnected(std::shared_ptr) */ + void chargePointConnected(std::shared_ptr chargepoint) override; + + // API + + /** @brief Handle requests/events from charge points */ + class ChargePointRequestHandler : public ocpp::centralsystem::ocpp20::IChargePointRequestHandler20 + { + public: + /** @brief Constructor */ + ChargePointRequestHandler(DefaultCentralSystemEventsHandler& event_handler, + std::shared_ptr& chargepoint); + + /** @brief Destructor */ + virtual ~ChargePointRequestHandler(); + + /** @brief Get the charge point proxy */ + std::shared_ptr proxy() { return m_chargepoint; } + + /** @brief Get the path to the genrated certificate */ + const std::string& generatedCertificate() { return m_generated_certificate; } + + // IChargePointRequestHandler20 interface + + /** @brief Called to notify the disconnection of the charge point */ + void disconnected() override; + + /** @brief Called on reception of a BootNotification request from the charge point */ + bool onBootNotification(const ocpp::messages::ocpp20::BootNotificationReq& request, + ocpp::messages::ocpp20::BootNotificationConf& response, + std::string& error, + std::string& message) override; + + /** @brief Called on reception of a Authorize request from the charge point */ + bool onAuthorize(const ocpp::messages::ocpp20::AuthorizeReq& request, + ocpp::messages::ocpp20::AuthorizeConf& response, + std::string& error, + std::string& message) override; + + /** @brief Called on reception of a ClearedChargingLimit request from the charge point */ + bool onClearedChargingLimit(const ocpp::messages::ocpp20::ClearedChargingLimitReq& request, + ocpp::messages::ocpp20::ClearedChargingLimitConf& response, + std::string& error, + std::string& message) override; + + /** @brief Called on reception of a CostUpdated request from the charge point */ + bool onCostUpdated(const ocpp::messages::ocpp20::CostUpdatedReq& request, + ocpp::messages::ocpp20::CostUpdatedConf& response, + std::string& error, + std::string& message) override; + + /** @brief Called on reception of a DataTransfer request from the charge point */ + bool onDataTransfer(const ocpp::messages::ocpp20::DataTransferReq& request, + ocpp::messages::ocpp20::DataTransferConf& response, + std::string& error, + std::string& message) override; + + /** @brief Called on reception of a FirmwareStatusNotification request from the charge point */ + bool onFirmwareStatusNotification(const ocpp::messages::ocpp20::FirmwareStatusNotificationReq& request, + ocpp::messages::ocpp20::FirmwareStatusNotificationConf& response, + std::string& error, + std::string& message) override; + + /** @brief Called on reception of a Heartbeat request from the charge point */ + bool onHeartbeat(const ocpp::messages::ocpp20::HeartbeatReq& request, + ocpp::messages::ocpp20::HeartbeatConf& response, + std::string& error, + std::string& message) override; + + /** @brief Called on reception of a LogStatusNotification request from the charge point */ + bool onLogStatusNotification(const ocpp::messages::ocpp20::LogStatusNotificationReq& request, + ocpp::messages::ocpp20::LogStatusNotificationConf& response, + std::string& error, + std::string& message) override; + + /** @brief Called on reception of a MeterValues request from the charge point */ + bool onMeterValues(const ocpp::messages::ocpp20::MeterValuesReq& request, + ocpp::messages::ocpp20::MeterValuesConf& response, + std::string& error, + std::string& message) override; + + /** @brief Called on reception of a NotifyChargingLimit request from the charge point */ + bool onNotifyChargingLimit(const ocpp::messages::ocpp20::NotifyChargingLimitReq& request, + ocpp::messages::ocpp20::NotifyChargingLimitConf& response, + std::string& error, + std::string& message) override; + + /** @brief Called on reception of a NotifyCustomerInformation request from the charge point */ + bool onNotifyCustomerInformation(const ocpp::messages::ocpp20::NotifyCustomerInformationReq& request, + ocpp::messages::ocpp20::NotifyCustomerInformationConf& response, + std::string& error, + std::string& message) override; + + /** @brief Called on reception of a NotifyDisplayMessages request from the charge point */ + bool onNotifyDisplayMessages(const ocpp::messages::ocpp20::NotifyDisplayMessagesReq& request, + ocpp::messages::ocpp20::NotifyDisplayMessagesConf& response, + std::string& error, + std::string& message) override; + + /** @brief Called on reception of a NotifyEVChargingNeeds request from the charge point */ + bool onNotifyEVChargingNeeds(const ocpp::messages::ocpp20::NotifyEVChargingNeedsReq& request, + ocpp::messages::ocpp20::NotifyEVChargingNeedsConf& response, + std::string& error, + std::string& message) override; + + /** @brief Called on reception of a NotifyEVChargingSchedule request from the charge point */ + bool onNotifyEVChargingSchedule(const ocpp::messages::ocpp20::NotifyEVChargingScheduleReq& request, + ocpp::messages::ocpp20::NotifyEVChargingScheduleConf& response, + std::string& error, + std::string& message) override; + + /** @brief Called on reception of a NotifyEvent request from the charge point */ + bool onNotifyEvent(const ocpp::messages::ocpp20::NotifyEventReq& request, + ocpp::messages::ocpp20::NotifyEventConf& response, + std::string& error, + std::string& message) override; + + /** @brief Called on reception of a NotifyMonitoringReport request from the charge point */ + bool onNotifyMonitoringReport(const ocpp::messages::ocpp20::NotifyMonitoringReportReq& request, + ocpp::messages::ocpp20::NotifyMonitoringReportConf& response, + std::string& error, + std::string& message) override; + + /** @brief Called on reception of a NotifyReport request from the charge point */ + bool onNotifyReport(const ocpp::messages::ocpp20::NotifyReportReq& request, + ocpp::messages::ocpp20::NotifyReportConf& response, + std::string& error, + std::string& message) override; + + /** @brief Called on reception of a PublishFirmwareStatusNotification request from the charge point */ + bool onPublishFirmwareStatusNotification(const ocpp::messages::ocpp20::PublishFirmwareStatusNotificationReq& request, + ocpp::messages::ocpp20::PublishFirmwareStatusNotificationConf& response, + std::string& error, + std::string& message) override; + + /** @brief Called on reception of a ReportChargingProfiles request from the charge point */ + bool onReportChargingProfiles(const ocpp::messages::ocpp20::ReportChargingProfilesReq& request, + ocpp::messages::ocpp20::ReportChargingProfilesConf& response, + std::string& error, + std::string& message) override; + + /** @brief Called on reception of a ReservationStatusUpdate request from the charge point */ + bool onReservationStatusUpdate(const ocpp::messages::ocpp20::ReservationStatusUpdateReq& request, + ocpp::messages::ocpp20::ReservationStatusUpdateConf& response, + std::string& error, + std::string& message) override; + + /** @brief Called on reception of a SecurityEventNotification request from the charge point */ + bool onSecurityEventNotification(const ocpp::messages::ocpp20::SecurityEventNotificationReq& request, + ocpp::messages::ocpp20::SecurityEventNotificationConf& response, + std::string& error, + std::string& message) override; + + /** @brief Called on reception of a SignCertificate request from the charge point */ + bool onSignCertificate(const ocpp::messages::ocpp20::SignCertificateReq& request, + ocpp::messages::ocpp20::SignCertificateConf& response, + std::string& error, + std::string& message) override; + + /** @brief Called on reception of a StatusNotification request from the charge point */ + bool onStatusNotification(const ocpp::messages::ocpp20::StatusNotificationReq& request, + ocpp::messages::ocpp20::StatusNotificationConf& response, + std::string& error, + std::string& message) override; + + /** @brief Called on reception of a TransactionEvent request from the charge point */ + bool onTransactionEvent(const ocpp::messages::ocpp20::TransactionEventReq& request, + ocpp::messages::ocpp20::TransactionEventConf& response, + std::string& error, + std::string& message) override; + + protected: + /** @brief Get the serial number of the charge point */ + virtual std::string getChargePointSerialNumber(const std::string& chargepoint_id) + { + (void)chargepoint_id; + return ""; + } + + private: + /** @brief Event handler */ + DefaultCentralSystemEventsHandler& m_event_handler; + + /** @brief Charge point proxy */ + std::shared_ptr m_chargepoint; + + /** @brief Path to the generated certificate */ + std::string m_generated_certificate; + }; + + /** @brief Get the central system's configuration */ + CentralSystemDemoConfig& getConfig() { return m_config; } + + /** @brief Get the number connected charge points */ + size_t chargePointsCount() + { + std::lock_guard lock(m_chargepoints_mutex); + return m_chargepoints.size(); + } + + /** @brief Get the list of the connected charge points */ + std::map> chargePoints() + { + std::lock_guard lock(m_chargepoints_mutex); + return m_chargepoints; + } + + /** @brief Get the list of the pending charge points */ + std::map> pendingChargePoints() + { + std::lock_guard lock(m_chargepoints_mutex); + return m_pending_chargepoints; + } + + /** @brief Path to the V2G root CA */ + std::filesystem::path& v2gRootCA() { return m_iso_v2g_root_ca; } + /** @brief Path to the MO root CA */ + std::filesystem::path& moRootCA() { return m_iso_mo_root_ca; } + + /** @brief Indicate if the charge point must be set on pending status upon connection */ + bool setPendingEnabled() const { return m_set_pending_status; } + + /** @brief Remove a charge point from the connected charge points */ + void removeChargePoint(const std::string& identifier); + + /** @brief Indicate if a charge point must be accepted */ + bool isAcceptedChargePoint(const std::string& identifier); + + /** @brief Add a charge point to the pending list */ + void addPendingChargePoint(std::shared_ptr chargepoint); + + /** @brief Add a charge point to the accepted list */ + void addAcceptedChargePoint(std::shared_ptr chargepoint); + + protected: + /** @brief Central system's configuration */ + CentralSystemDemoConfig& m_config; + /** @brief Mutex for charge point list */ + std::mutex m_chargepoints_mutex; + /** @brief Path to the V2G root CA */ + std::filesystem::path m_iso_v2g_root_ca; + /** @brief Path to the MO root CA */ + std::filesystem::path m_iso_mo_root_ca; + /** @brief Indicate if the charge point must be set on pending status upon connection */ + bool m_set_pending_status; + /** @brief Connected charge points */ + std::map> m_chargepoints; + /** @brief Pending charge points */ + std::map> m_pending_chargepoints; + /** @brief Accepted charge points */ + std::map> m_accepted_chargepoints; +}; + +#endif // DEFAULTCENTRALSYSTEMEVENTSHANDLER_H diff --git a/examples/ocpp20/common/DefaultChargePointEventsHandler.cpp b/examples/ocpp20/common/DefaultChargePointEventsHandler.cpp new file mode 100644 index 00000000..c79d668c --- /dev/null +++ b/examples/ocpp20/common/DefaultChargePointEventsHandler.cpp @@ -0,0 +1,955 @@ +/* +MIT License + +Copyright (c) 2020 Cedric Jimenez + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + +#include "DefaultChargePointEventsHandler.h" +#include "ChargePointDemoConfig.h" +#include "NotifyReport20.h" + +#include +#include +#include + +// With MSVC compiler, the system() call returns directly the command's return value +#ifdef _MSC_VER +#define WEXITSTATUS(x) (x) +#endif // _MSC_VER + +using namespace std; +using namespace ocpp::types; +using namespace ocpp::types::ocpp20; +using namespace ocpp::messages; +using namespace ocpp::messages::ocpp20; + +/** @brief Constructor */ +DefaultChargePointEventsHandler::DefaultChargePointEventsHandler(ChargePointDemoConfig& config, + ocpp::chargepoint::ocpp20::IDeviceModel& device_model, + const std::filesystem::path& working_dir) + : m_config(config), m_device_model(device_model), m_chargepoint(nullptr), m_working_dir(working_dir), m_is_connected(false) +{ + m_device_model.registerListener(*this); +} + +/** @brief Destructor */ +DefaultChargePointEventsHandler::~DefaultChargePointEventsHandler() { } + +/** @copydoc void IChargePointEventsHandler20::connectionStateChanged() */ +void DefaultChargePointEventsHandler::connectionFailed() +{ + cout << "Connection failed" << endl; +} + +/** @copydoc void IChargePointEventsHandler20::connectionStateChanged(bool) */ +void DefaultChargePointEventsHandler::connectionStateChanged(bool isConnected) +{ + cout << "Connection state changed : " << isConnected << endl; + m_is_connected = isConnected; +} + +// IDeviceModel20 interface + +/** @brief Called to retrieve the value of a variable */ +void DefaultChargePointEventsHandler::getVariable(ocpp::types::ocpp20::GetVariableResultType& var) +{ + std::string value; + m_config.getDeviceModelValue(var.component, var.variable, value); + var.attributeValue.value().assign(std::move(value)); + var.attributeStatus = GetVariableStatusEnumType::Accepted; +} + +/** @brief Called to set the value of a variable */ +ocpp::types::ocpp20::SetVariableStatusEnumType DefaultChargePointEventsHandler::setVariable( + const ocpp::types::ocpp20::SetVariableDataType& var) +{ + m_config.setDeviceModelValue(var.component, var.variable, var.attributeValue.str()); + return SetVariableStatusEnumType::Accepted; +} + +// OCPP operations + +/** @brief Called on reception of a CancelReservation message from the central */ +bool DefaultChargePointEventsHandler::onCancelReservation(const ocpp::messages::ocpp20::CancelReservationReq& request, + ocpp::messages::ocpp20::CancelReservationConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)request; + (void)error; + (void)message; + + cout << "CancelReservation" << endl; + + response.status = CancelReservationStatusEnumType::Rejected; + + return ret; +} + +/** @brief Called on reception of a CertificateSigned message from the central */ +bool DefaultChargePointEventsHandler::onCertificateSigned(const ocpp::messages::ocpp20::CertificateSignedReq& request, + ocpp::messages::ocpp20::CertificateSignedConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)request; + (void)error; + (void)message; + + cout << "CertificateSigned" << endl; + + response.status = CertificateSignedStatusEnumType::Rejected; + + return ret; +} + +/** @brief Called on reception of a ChangeAvailability message from the central */ +bool DefaultChargePointEventsHandler::onChangeAvailability(const ocpp::messages::ocpp20::ChangeAvailabilityReq& request, + ocpp::messages::ocpp20::ChangeAvailabilityConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)request; + (void)error; + (void)message; + + cout << "ChangeAvailability" << endl; + + response.status = ChangeAvailabilityStatusEnumType::Rejected; + + return ret; +} + +/** @brief Called on reception of a ClearCache message from the central */ +bool DefaultChargePointEventsHandler::onClearCache(const ocpp::messages::ocpp20::ClearCacheReq& request, + ocpp::messages::ocpp20::ClearCacheConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)request; + (void)error; + (void)message; + + cout << "ClearCache" << endl; + + response.status = ClearCacheStatusEnumType::Rejected; + + return ret; +} + +/** @brief Called on reception of a ClearChargingProfile message from the central */ +bool DefaultChargePointEventsHandler::onClearChargingProfile(const ocpp::messages::ocpp20::ClearChargingProfileReq& request, + ocpp::messages::ocpp20::ClearChargingProfileConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)request; + (void)error; + (void)message; + + cout << "ClearChargingProfile" << endl; + + response.status = ClearChargingProfileStatusEnumType::Unknown; + + return ret; +} + +/** @brief Called on reception of a ClearDisplayMessage message from the central */ +bool DefaultChargePointEventsHandler::onClearDisplayMessage(const ocpp::messages::ocpp20::ClearDisplayMessageReq& request, + ocpp::messages::ocpp20::ClearDisplayMessageConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)request; + (void)error; + (void)message; + + cout << "ClearDisplayMessage" << endl; + + response.status = ClearMessageStatusEnumType::Unknown; + + return ret; +} + +/** @brief Called on reception of a ClearVariableMonitoring message from the central */ +bool DefaultChargePointEventsHandler::onClearVariableMonitoring(const ocpp::messages::ocpp20::ClearVariableMonitoringReq& request, + ocpp::messages::ocpp20::ClearVariableMonitoringConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)error; + (void)message; + + cout << "ClearVariableMonitoring" << endl; + + for (const auto& id : request.id) + { + (void)id; + + ClearMonitoringResultType result; + result.status = ClearMonitoringStatusEnumType::Rejected; + response.clearMonitoringResult.push_back(result); + } + + return ret; +} + +/** @brief Called on reception of a CustomerInformation message from the central */ +bool DefaultChargePointEventsHandler::onCustomerInformation(const ocpp::messages::ocpp20::CustomerInformationReq& request, + ocpp::messages::ocpp20::CustomerInformationConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)request; + (void)error; + (void)message; + + cout << "CustomerInformation" << endl; + + response.status = CustomerInformationStatusEnumType::Rejected; + + return ret; +} + +/** @brief Called on reception of a DataTransfer message from the central */ +bool DefaultChargePointEventsHandler::onDataTransfer(const ocpp::messages::ocpp20::DataTransferReq& request, + ocpp::messages::ocpp20::DataTransferConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)request; + (void)error; + (void)message; + + cout << "DataTransfer" << endl; + + response.status = DataTransferStatusEnumType::UnknownVendorId; + + return ret; +} + +/** @brief Called on reception of a DeleteCertificate message from the central */ +bool DefaultChargePointEventsHandler::onDeleteCertificate(const ocpp::messages::ocpp20::DeleteCertificateReq& request, + ocpp::messages::ocpp20::DeleteCertificateConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)request; + (void)error; + (void)message; + + cout << "DeleteCertificate" << endl; + + response.status = DeleteCertificateStatusEnumType::NotFound; + + return ret; +} + +/** @brief Called on reception of a Get15118EVCertificate message from the central */ +bool DefaultChargePointEventsHandler::onGet15118EVCertificate(const ocpp::messages::ocpp20::Get15118EVCertificateReq& request, + ocpp::messages::ocpp20::Get15118EVCertificateConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)request; + (void)error; + (void)message; + + cout << "Get15118EVCertificate" << endl; + + response.status = Iso15118EVCertificateStatusEnumType::Failed; + + return ret; +} + +/** @brief Called on reception of a GetBaseReport message from the central */ +bool DefaultChargePointEventsHandler::onGetBaseReport(const ocpp::messages::ocpp20::GetBaseReportReq& request, + ocpp::messages::ocpp20::GetBaseReportConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)error; + (void)message; + + cout << "GetBaseReport" << endl; + + if (request.reportBase == ReportBaseEnumType::SummaryInventory) + { + response.status = GenericDeviceModelStatusEnumType::NotSupported; + } + else + { + std::thread report_thread( + [this, type = request.reportBase, req_id = request.requestId] + { + NotifyReportReq notif_req; + notif_req.requestId = req_id; + notif_req.generatedAt = DateTime::now(); + notif_req.seqNo = 0; + notif_req.tbc = false; + + const auto& device_model = m_device_model.getModel(); + for (const auto& [_, comps] : device_model.components) + { + for (const auto& component : comps) + { + for (const auto& [_, vars] : component.variables) + { + for (const auto& [_, var] : vars) + { + if ((type == ReportBaseEnumType::FullInventory) || !var.attributes.type.isSet() || + (var.attributes.mutability.value() == MutabilityEnumType::ReadWrite)) + { + ReportDataType report_data; + report_data.component.name.assign(component.name); + if (component.instance.isSet()) + { + report_data.component.instance.value().assign(component.instance.value()); + } + if (component.evse.isSet()) + { + report_data.component.evse.value().id = component.evse.value(); + } + if (component.connector.isSet()) + { + report_data.component.evse.value().connectorId.value() = component.connector.value(); + } + report_data.variable.name.assign(var.name); + if (var.instance.isSet()) + { + report_data.variable.instance.value().assign(var.instance.value()); + } + report_data.variableAttribute.push_back(var.attributes); + report_data.variableCharacteristics = var.characteristics; + + notif_req.reportData.push_back(std::move(report_data)); + } + } + } + } + } + + (void)device_model; + + std::this_thread::sleep_for(std::chrono::seconds(1)); + + NotifyReportConf notif_conf; + std::string error; + std::string error_msg; + m_chargepoint->call(notif_req, notif_conf, error, error_msg); + }); + report_thread.detach(); + } + + return ret; +} + +/** @brief Called on reception of a GetCertificateStatus message from the central */ +bool DefaultChargePointEventsHandler::onGetCertificateStatus(const ocpp::messages::ocpp20::GetCertificateStatusReq& request, + ocpp::messages::ocpp20::GetCertificateStatusConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)request; + (void)error; + (void)message; + + cout << "GetCertificateStatus" << endl; + + response.status = GetCertificateStatusEnumType::Failed; + + return ret; +} + +/** @brief Called on reception of a GetChargingProfiles message from the central */ +bool DefaultChargePointEventsHandler::onGetChargingProfiles(const ocpp::messages::ocpp20::GetChargingProfilesReq& request, + ocpp::messages::ocpp20::GetChargingProfilesConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)request; + (void)error; + (void)message; + + cout << "GetChargingProfiles" << endl; + + response.status = GetChargingProfileStatusEnumType::NoProfiles; + + return ret; +} + +/** @brief Called on reception of a GetCompositeSchedule message from the central */ +bool DefaultChargePointEventsHandler::onGetCompositeSchedule(const ocpp::messages::ocpp20::GetCompositeScheduleReq& request, + ocpp::messages::ocpp20::GetCompositeScheduleConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)request; + (void)error; + (void)message; + + cout << "GetCompositeSchedule" << endl; + + response.status = GenericStatusEnumType::Rejected; + + return ret; +} + +/** @brief Called on reception of a GetDisplayMessages message from the central */ +bool DefaultChargePointEventsHandler::onGetDisplayMessages(const ocpp::messages::ocpp20::GetDisplayMessagesReq& request, + ocpp::messages::ocpp20::GetDisplayMessagesConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)request; + (void)error; + (void)message; + + cout << "GetDisplayMessages" << endl; + + response.status = GetDisplayMessagesStatusEnumType::Unknown; + + return ret; +} + +/** @brief Called on reception of a GetInstalledCertificateIds message from the central */ +bool DefaultChargePointEventsHandler::onGetInstalledCertificateIds(const ocpp::messages::ocpp20::GetInstalledCertificateIdsReq& request, + ocpp::messages::ocpp20::GetInstalledCertificateIdsConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)request; + (void)error; + (void)message; + + cout << "GetInstalledCertificateIds" << endl; + + response.status = GetInstalledCertificateStatusEnumType::NotFound; + + return ret; +} + +/** @brief Called on reception of a GetLocalListVersion message from the central */ +bool DefaultChargePointEventsHandler::onGetLocalListVersion(const ocpp::messages::ocpp20::GetLocalListVersionReq& request, + ocpp::messages::ocpp20::GetLocalListVersionConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)request; + (void)error; + (void)message; + + cout << "GetLocalListVersion" << endl; + + response.versionNumber = 0; + + return ret; +} + +/** @brief Called on reception of a GetLog message from the central */ +bool DefaultChargePointEventsHandler::onGetLog(const ocpp::messages::ocpp20::GetLogReq& request, + ocpp::messages::ocpp20::GetLogConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)request; + (void)error; + (void)message; + + cout << "GetLog" << endl; + + response.status = LogStatusEnumType::Rejected; + + return ret; +} + +/** @brief Called on reception of a GetMonitoringReport message from the central */ +bool DefaultChargePointEventsHandler::onGetMonitoringReport(const ocpp::messages::ocpp20::GetMonitoringReportReq& request, + ocpp::messages::ocpp20::GetMonitoringReportConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)request; + (void)error; + (void)message; + + cout << "GetMonitoringReport" << endl; + + response.status = GenericDeviceModelStatusEnumType::NotSupported; + + return ret; +} + +/** @brief Called on reception of a GetReport message from the central */ +bool DefaultChargePointEventsHandler::onGetReport(const ocpp::messages::ocpp20::GetReportReq& request, + ocpp::messages::ocpp20::GetReportConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)request; + (void)error; + (void)message; + + cout << "GetReport" << endl; + + response.status = GenericDeviceModelStatusEnumType::NotSupported; + + return ret; +} + +/** @brief Called on reception of a GetTransactionStatus message from the central */ +bool DefaultChargePointEventsHandler::onGetTransactionStatus(const ocpp::messages::ocpp20::GetTransactionStatusReq& request, + ocpp::messages::ocpp20::GetTransactionStatusConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)request; + (void)error; + (void)message; + + cout << "GetTransactionStatus" << endl; + + response.messagesInQueue = false; + + return ret; +} + +/** @brief Called on reception of a GetVariables message from the central */ +bool DefaultChargePointEventsHandler::onGetVariables(const ocpp::messages::ocpp20::GetVariablesReq& request, + ocpp::messages::ocpp20::GetVariablesConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)error; + (void)message; + + cout << "GetVariables" << endl; + + for (const auto& var_data : request.getVariableData) + { + GetVariableResultType result = m_device_model.getVariable(var_data); + response.getVariableResult.push_back(result); + } + + return ret; +} + +/** @brief Called on reception of a InstallCertificate message from the central */ +bool DefaultChargePointEventsHandler::onInstallCertificate(const ocpp::messages::ocpp20::InstallCertificateReq& request, + ocpp::messages::ocpp20::InstallCertificateConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)request; + (void)error; + (void)message; + + cout << "InstallCertificate" << endl; + + response.status = InstallCertificateStatusEnumType::Rejected; + + return ret; +} + +/** @brief Called on reception of a PublishFirmware message from the central */ +bool DefaultChargePointEventsHandler::onPublishFirmware(const ocpp::messages::ocpp20::PublishFirmwareReq& request, + ocpp::messages::ocpp20::PublishFirmwareConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)request; + (void)error; + (void)message; + + cout << "PublishFirmware" << endl; + + response.status = GenericStatusEnumType::Rejected; + + return ret; +} + +/** @brief Called on reception of a RequestStartTransaction message from the central */ +bool DefaultChargePointEventsHandler::onRequestStartTransaction(const ocpp::messages::ocpp20::RequestStartTransactionReq& request, + ocpp::messages::ocpp20::RequestStartTransactionConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)request; + (void)error; + (void)message; + + cout << "RequestStartTransaction" << endl; + + response.status = RequestStartStopStatusEnumType::Rejected; + + return ret; +} + +/** @brief Called on reception of a RequestStopTransaction message from the central */ +bool DefaultChargePointEventsHandler::onRequestStopTransaction(const ocpp::messages::ocpp20::RequestStopTransactionReq& request, + ocpp::messages::ocpp20::RequestStopTransactionConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)request; + (void)error; + (void)message; + + cout << "RequestStopTransaction" << endl; + + response.status = RequestStartStopStatusEnumType::Rejected; + + return ret; +} + +/** @brief Called on reception of a ReserveNow message from the central */ +bool DefaultChargePointEventsHandler::onReserveNow(const ocpp::messages::ocpp20::ReserveNowReq& request, + ocpp::messages::ocpp20::ReserveNowConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)request; + (void)error; + (void)message; + + cout << "ReserveNow" << endl; + + response.status = ReserveNowStatusEnumType::Rejected; + + return ret; +} + +/** @brief Called on reception of a Reset message from the central */ +bool DefaultChargePointEventsHandler::onReset(const ocpp::messages::ocpp20::ResetReq& request, + ocpp::messages::ocpp20::ResetConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)request; + (void)error; + (void)message; + + cout << "Reset" << endl; + + response.status = ResetStatusEnumType::Rejected; + + return ret; +} + +/** @brief Called on reception of a SendLocalList message from the central */ +bool DefaultChargePointEventsHandler::onSendLocalList(const ocpp::messages::ocpp20::SendLocalListReq& request, + ocpp::messages::ocpp20::SendLocalListConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)request; + (void)error; + (void)message; + + cout << "SendLocalList" << endl; + + response.status = SendLocalListStatusEnumType::Failed; + + return ret; +} + +/** @brief Called on reception of a SetChargingProfile message from the central */ +bool DefaultChargePointEventsHandler::onSetChargingProfile(const ocpp::messages::ocpp20::SetChargingProfileReq& request, + ocpp::messages::ocpp20::SetChargingProfileConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)request; + (void)error; + (void)message; + + cout << "SetChargingProfile" << endl; + + response.status = ChargingProfileStatusEnumType::Rejected; + + return ret; +} + +/** @brief Called on reception of a SetDisplayMessage message from the central */ +bool DefaultChargePointEventsHandler::onSetDisplayMessage(const ocpp::messages::ocpp20::SetDisplayMessageReq& request, + ocpp::messages::ocpp20::SetDisplayMessageConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)request; + (void)error; + (void)message; + + cout << "SetDisplayMessage" << endl; + + response.status = DisplayMessageStatusEnumType::Rejected; + + return ret; +} + +/** @brief Called on reception of a SetMonitoringBase message from the central */ +bool DefaultChargePointEventsHandler::onSetMonitoringBase(const ocpp::messages::ocpp20::SetMonitoringBaseReq& request, + ocpp::messages::ocpp20::SetMonitoringBaseConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)request; + (void)error; + (void)message; + + cout << "SetMonitoringBase" << endl; + + response.status = GenericDeviceModelStatusEnumType::Rejected; + + return ret; +} + +/** @brief Called on reception of a SetMonitoringLevel message from the central */ +bool DefaultChargePointEventsHandler::onSetMonitoringLevel(const ocpp::messages::ocpp20::SetMonitoringLevelReq& request, + ocpp::messages::ocpp20::SetMonitoringLevelConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)request; + (void)error; + (void)message; + + cout << "SetMonitoringLevel" << endl; + + response.status = GenericStatusEnumType::Rejected; + + return ret; +} + +/** @brief Called on reception of a SetNetworkProfile message from the central */ +bool DefaultChargePointEventsHandler::onSetNetworkProfile(const ocpp::messages::ocpp20::SetNetworkProfileReq& request, + ocpp::messages::ocpp20::SetNetworkProfileConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)request; + (void)error; + (void)message; + + cout << "SetNetworkProfile" << endl; + + response.status = SetNetworkProfileStatusEnumType::Rejected; + + return ret; +} + +/** @brief Called on reception of a SetVariableMonitoring message from the central */ +bool DefaultChargePointEventsHandler::onSetVariableMonitoring(const ocpp::messages::ocpp20::SetVariableMonitoringReq& request, + ocpp::messages::ocpp20::SetVariableMonitoringConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)error; + (void)message; + + cout << "SetVariableMonitoring" << endl; + + for (const auto& data : request.setMonitoringData) + { + (void)data; + + SetMonitoringResultType result; + result.status = SetMonitoringStatusEnumType::Rejected; + result.type = data.type; + result.component = data.component; + result.variable = data.variable; + result.severity = data.severity; + response.setMonitoringResult.push_back(result); + } + + return ret; +} + +/** @brief Called on reception of a SetVariables message from the central */ +bool DefaultChargePointEventsHandler::onSetVariables(const ocpp::messages::ocpp20::SetVariablesReq& request, + ocpp::messages::ocpp20::SetVariablesConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)response; + (void)error; + (void)message; + + cout << "SetVariables" << endl; + + for (const auto& var_data : request.setVariableData) + { + SetVariableResultType result = m_device_model.setVariable(var_data); + response.setVariableResult.push_back(result); + } + + return ret; +} + +/** @brief Called on reception of a TriggerMessage message from the central */ +bool DefaultChargePointEventsHandler::onTriggerMessage(const ocpp::messages::ocpp20::TriggerMessageReq& request, + ocpp::messages::ocpp20::TriggerMessageConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)request; + (void)error; + (void)message; + + cout << "TriggerMessage" << endl; + + response.status = TriggerMessageStatusEnumType::Rejected; + + return ret; +} + +/** @brief Called on reception of a UnlockConnector message from the central */ +bool DefaultChargePointEventsHandler::onUnlockConnector(const ocpp::messages::ocpp20::UnlockConnectorReq& request, + ocpp::messages::ocpp20::UnlockConnectorConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)request; + (void)error; + (void)message; + + cout << "UnlockConnector" << endl; + + response.status = UnlockStatusEnumType::UnknownConnector; + + return ret; +} + +/** @brief Called on reception of a UnpublishFirmware message from the central */ +bool DefaultChargePointEventsHandler::onUnpublishFirmware(const ocpp::messages::ocpp20::UnpublishFirmwareReq& request, + ocpp::messages::ocpp20::UnpublishFirmwareConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)request; + (void)error; + (void)message; + + cout << "UnpublishFirmware" << endl; + + response.status = UnpublishFirmwareStatusEnumType::NoFirmware; + + return ret; +} + +/** @brief Called on reception of a UpdateFirmware message from the central */ +bool DefaultChargePointEventsHandler::onUpdateFirmware(const ocpp::messages::ocpp20::UpdateFirmwareReq& request, + ocpp::messages::ocpp20::UpdateFirmwareConf& response, + std::string& error, + std::string& message) +{ + bool ret = true; + + (void)request; + (void)error; + (void)message; + + cout << "UpdateFirmware" << endl; + + response.status = UpdateFirmwareStatusEnumType::Rejected; + + return ret; +} diff --git a/examples/ocpp20/common/DefaultChargePointEventsHandler.h b/examples/ocpp20/common/DefaultChargePointEventsHandler.h new file mode 100644 index 00000000..ec7ba9e2 --- /dev/null +++ b/examples/ocpp20/common/DefaultChargePointEventsHandler.h @@ -0,0 +1,337 @@ +/* +MIT License + +Copyright (c) 2020 Cedric Jimenez + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + +#ifndef DEFAULTCHARGEPOINTEVENTSHANDLER_H +#define DEFAULTCHARGEPOINTEVENTSHANDLER_H + +#include "IChargePoint20.h" +#include "IChargePointEventsHandler20.h" +#include "IDeviceModel20.h" + +#include +#include + +class ChargePointDemoConfig; + +/** @brief Default charge point event handlers implementation for the examples */ +class DefaultChargePointEventsHandler : public ocpp::chargepoint::ocpp20::IChargePointEventsHandler20, + public ocpp::chargepoint::ocpp20::IDeviceModel::IListener +{ + public: + /** @brief Constructor */ + DefaultChargePointEventsHandler(ChargePointDemoConfig& config, + ocpp::chargepoint::ocpp20::IDeviceModel& device_model, + const std::filesystem::path& working_dir); + + /** @brief Destructor */ + virtual ~DefaultChargePointEventsHandler(); + + /** @brief Set the associated Charge Point instance */ + void setChargePoint(ocpp::chargepoint::ocpp20::IChargePoint20& chargepoint) { m_chargepoint = &chargepoint; } + + /** @brief Indicate if the Charge Point is connected */ + bool isConnected() const { return m_is_connected; } + + // IDeviceModel interface + + /** @brief Called to retrieve the value of a variable */ + void getVariable(ocpp::types::ocpp20::GetVariableResultType& var) override; + + /** @brief Called to set the value of a variable */ + ocpp::types::ocpp20::SetVariableStatusEnumType setVariable(const ocpp::types::ocpp20::SetVariableDataType& var) override; + + // IChargePointEventsHandler20 interface + + /** @copydoc void IChargePointEventsHandler20::connectionStateChanged() */ + void connectionFailed() override; + + /** @copydoc void IChargePointEventsHandler20::connectionStateChanged(bool) */ + void connectionStateChanged(bool isConnected) override; + + // OCPP operations + + /** @brief Called on reception of a CancelReservation message from the central */ + bool onCancelReservation(const ocpp::messages::ocpp20::CancelReservationReq& request, + ocpp::messages::ocpp20::CancelReservationConf& response, + std::string& error, + std::string& message) override; + + /** @brief Called on reception of a CertificateSigned message from the central */ + bool onCertificateSigned(const ocpp::messages::ocpp20::CertificateSignedReq& request, + ocpp::messages::ocpp20::CertificateSignedConf& response, + std::string& error, + std::string& message) override; + + /** @brief Called on reception of a ChangeAvailability message from the central */ + bool onChangeAvailability(const ocpp::messages::ocpp20::ChangeAvailabilityReq& request, + ocpp::messages::ocpp20::ChangeAvailabilityConf& response, + std::string& error, + std::string& message) override; + + /** @brief Called on reception of a ClearCache message from the central */ + bool onClearCache(const ocpp::messages::ocpp20::ClearCacheReq& request, + ocpp::messages::ocpp20::ClearCacheConf& response, + std::string& error, + std::string& message) override; + + /** @brief Called on reception of a ClearChargingProfile message from the central */ + bool onClearChargingProfile(const ocpp::messages::ocpp20::ClearChargingProfileReq& request, + ocpp::messages::ocpp20::ClearChargingProfileConf& response, + std::string& error, + std::string& message) override; + + /** @brief Called on reception of a ClearDisplayMessage message from the central */ + bool onClearDisplayMessage(const ocpp::messages::ocpp20::ClearDisplayMessageReq& request, + ocpp::messages::ocpp20::ClearDisplayMessageConf& response, + std::string& error, + std::string& message) override; + + /** @brief Called on reception of a ClearVariableMonitoring message from the central */ + bool onClearVariableMonitoring(const ocpp::messages::ocpp20::ClearVariableMonitoringReq& request, + ocpp::messages::ocpp20::ClearVariableMonitoringConf& response, + std::string& error, + std::string& message) override; + + /** @brief Called on reception of a CustomerInformation message from the central */ + bool onCustomerInformation(const ocpp::messages::ocpp20::CustomerInformationReq& request, + ocpp::messages::ocpp20::CustomerInformationConf& response, + std::string& error, + std::string& message) override; + + /** @brief Called on reception of a DataTransfer message from the central */ + bool onDataTransfer(const ocpp::messages::ocpp20::DataTransferReq& request, + ocpp::messages::ocpp20::DataTransferConf& response, + std::string& error, + std::string& message) override; + + /** @brief Called on reception of a DeleteCertificate message from the central */ + bool onDeleteCertificate(const ocpp::messages::ocpp20::DeleteCertificateReq& request, + ocpp::messages::ocpp20::DeleteCertificateConf& response, + std::string& error, + std::string& message) override; + + /** @brief Called on reception of a Get15118EVCertificate message from the central */ + bool onGet15118EVCertificate(const ocpp::messages::ocpp20::Get15118EVCertificateReq& request, + ocpp::messages::ocpp20::Get15118EVCertificateConf& response, + std::string& error, + std::string& message) override; + + /** @brief Called on reception of a GetBaseReport message from the central */ + bool onGetBaseReport(const ocpp::messages::ocpp20::GetBaseReportReq& request, + ocpp::messages::ocpp20::GetBaseReportConf& response, + std::string& error, + std::string& message) override; + + /** @brief Called on reception of a GetCertificateStatus message from the central */ + bool onGetCertificateStatus(const ocpp::messages::ocpp20::GetCertificateStatusReq& request, + ocpp::messages::ocpp20::GetCertificateStatusConf& response, + std::string& error, + std::string& message) override; + + /** @brief Called on reception of a GetChargingProfiles message from the central */ + bool onGetChargingProfiles(const ocpp::messages::ocpp20::GetChargingProfilesReq& request, + ocpp::messages::ocpp20::GetChargingProfilesConf& response, + std::string& error, + std::string& message) override; + + /** @brief Called on reception of a GetCompositeSchedule message from the central */ + bool onGetCompositeSchedule(const ocpp::messages::ocpp20::GetCompositeScheduleReq& request, + ocpp::messages::ocpp20::GetCompositeScheduleConf& response, + std::string& error, + std::string& message) override; + + /** @brief Called on reception of a GetDisplayMessages message from the central */ + bool onGetDisplayMessages(const ocpp::messages::ocpp20::GetDisplayMessagesReq& request, + ocpp::messages::ocpp20::GetDisplayMessagesConf& response, + std::string& error, + std::string& message) override; + + /** @brief Called on reception of a GetInstalledCertificateIds message from the central */ + bool onGetInstalledCertificateIds(const ocpp::messages::ocpp20::GetInstalledCertificateIdsReq& request, + ocpp::messages::ocpp20::GetInstalledCertificateIdsConf& response, + std::string& error, + std::string& message) override; + + /** @brief Called on reception of a GetLocalListVersion message from the central */ + bool onGetLocalListVersion(const ocpp::messages::ocpp20::GetLocalListVersionReq& request, + ocpp::messages::ocpp20::GetLocalListVersionConf& response, + std::string& error, + std::string& message) override; + + /** @brief Called on reception of a GetLog message from the central */ + bool onGetLog(const ocpp::messages::ocpp20::GetLogReq& request, + ocpp::messages::ocpp20::GetLogConf& response, + std::string& error, + std::string& message) override; + + /** @brief Called on reception of a GetMonitoringReport message from the central */ + bool onGetMonitoringReport(const ocpp::messages::ocpp20::GetMonitoringReportReq& request, + ocpp::messages::ocpp20::GetMonitoringReportConf& response, + std::string& error, + std::string& message) override; + + /** @brief Called on reception of a GetReport message from the central */ + bool onGetReport(const ocpp::messages::ocpp20::GetReportReq& request, + ocpp::messages::ocpp20::GetReportConf& response, + std::string& error, + std::string& message) override; + + /** @brief Called on reception of a GetTransactionStatus message from the central */ + bool onGetTransactionStatus(const ocpp::messages::ocpp20::GetTransactionStatusReq& request, + ocpp::messages::ocpp20::GetTransactionStatusConf& response, + std::string& error, + std::string& message) override; + + /** @brief Called on reception of a GetVariables message from the central */ + bool onGetVariables(const ocpp::messages::ocpp20::GetVariablesReq& request, + ocpp::messages::ocpp20::GetVariablesConf& response, + std::string& error, + std::string& message) override; + + /** @brief Called on reception of a InstallCertificate message from the central */ + bool onInstallCertificate(const ocpp::messages::ocpp20::InstallCertificateReq& request, + ocpp::messages::ocpp20::InstallCertificateConf& response, + std::string& error, + std::string& message) override; + + /** @brief Called on reception of a PublishFirmware message from the central */ + bool onPublishFirmware(const ocpp::messages::ocpp20::PublishFirmwareReq& request, + ocpp::messages::ocpp20::PublishFirmwareConf& response, + std::string& error, + std::string& message) override; + + /** @brief Called on reception of a RequestStartTransaction message from the central */ + bool onRequestStartTransaction(const ocpp::messages::ocpp20::RequestStartTransactionReq& request, + ocpp::messages::ocpp20::RequestStartTransactionConf& response, + std::string& error, + std::string& message) override; + + /** @brief Called on reception of a RequestStopTransaction message from the central */ + bool onRequestStopTransaction(const ocpp::messages::ocpp20::RequestStopTransactionReq& request, + ocpp::messages::ocpp20::RequestStopTransactionConf& response, + std::string& error, + std::string& message) override; + + /** @brief Called on reception of a ReserveNow message from the central */ + bool onReserveNow(const ocpp::messages::ocpp20::ReserveNowReq& request, + ocpp::messages::ocpp20::ReserveNowConf& response, + std::string& error, + std::string& message) override; + + /** @brief Called on reception of a Reset message from the central */ + bool onReset(const ocpp::messages::ocpp20::ResetReq& request, + ocpp::messages::ocpp20::ResetConf& response, + std::string& error, + std::string& message) override; + + /** @brief Called on reception of a SendLocalList message from the central */ + bool onSendLocalList(const ocpp::messages::ocpp20::SendLocalListReq& request, + ocpp::messages::ocpp20::SendLocalListConf& response, + std::string& error, + std::string& message) override; + + /** @brief Called on reception of a SetChargingProfile message from the central */ + bool onSetChargingProfile(const ocpp::messages::ocpp20::SetChargingProfileReq& request, + ocpp::messages::ocpp20::SetChargingProfileConf& response, + std::string& error, + std::string& message) override; + + /** @brief Called on reception of a SetDisplayMessage message from the central */ + bool onSetDisplayMessage(const ocpp::messages::ocpp20::SetDisplayMessageReq& request, + ocpp::messages::ocpp20::SetDisplayMessageConf& response, + std::string& error, + std::string& message) override; + + /** @brief Called on reception of a SetMonitoringBase message from the central */ + bool onSetMonitoringBase(const ocpp::messages::ocpp20::SetMonitoringBaseReq& request, + ocpp::messages::ocpp20::SetMonitoringBaseConf& response, + std::string& error, + std::string& message) override; + + /** @brief Called on reception of a SetMonitoringLevel message from the central */ + bool onSetMonitoringLevel(const ocpp::messages::ocpp20::SetMonitoringLevelReq& request, + ocpp::messages::ocpp20::SetMonitoringLevelConf& response, + std::string& error, + std::string& message) override; + + /** @brief Called on reception of a SetNetworkProfile message from the central */ + bool onSetNetworkProfile(const ocpp::messages::ocpp20::SetNetworkProfileReq& request, + ocpp::messages::ocpp20::SetNetworkProfileConf& response, + std::string& error, + std::string& message) override; + + /** @brief Called on reception of a SetVariableMonitoring message from the central */ + bool onSetVariableMonitoring(const ocpp::messages::ocpp20::SetVariableMonitoringReq& request, + ocpp::messages::ocpp20::SetVariableMonitoringConf& response, + std::string& error, + std::string& message) override; + + /** @brief Called on reception of a SetVariables message from the central */ + bool onSetVariables(const ocpp::messages::ocpp20::SetVariablesReq& request, + ocpp::messages::ocpp20::SetVariablesConf& response, + std::string& error, + std::string& message) override; + + /** @brief Called on reception of a TriggerMessage message from the central */ + bool onTriggerMessage(const ocpp::messages::ocpp20::TriggerMessageReq& request, + ocpp::messages::ocpp20::TriggerMessageConf& response, + std::string& error, + std::string& message) override; + + /** @brief Called on reception of a UnlockConnector message from the central */ + bool onUnlockConnector(const ocpp::messages::ocpp20::UnlockConnectorReq& request, + ocpp::messages::ocpp20::UnlockConnectorConf& response, + std::string& error, + std::string& message) override; + + /** @brief Called on reception of a UnpublishFirmware message from the central */ + bool onUnpublishFirmware(const ocpp::messages::ocpp20::UnpublishFirmwareReq& request, + ocpp::messages::ocpp20::UnpublishFirmwareConf& response, + std::string& error, + std::string& message) override; + + /** @brief Called on reception of a UpdateFirmware message from the central */ + bool onUpdateFirmware(const ocpp::messages::ocpp20::UpdateFirmwareReq& request, + ocpp::messages::ocpp20::UpdateFirmwareConf& response, + std::string& error, + std::string& message) override; + + protected: + /** @brief Get the configuration */ + ChargePointDemoConfig& config() { return m_config; } + + private: + /** @brief Configuration */ + ChargePointDemoConfig& m_config; + /** @brief Device model */ + ocpp::chargepoint::ocpp20::IDeviceModel& m_device_model; + /** @brief Associated Charge Point instance */ + ocpp::chargepoint::ocpp20::IChargePoint20* m_chargepoint; + /** @brief Working directory */ + std::filesystem::path m_working_dir; + /** @brief Indicate if the Charge Point is connected */ + bool m_is_connected; +}; + +#endif // DEFAULTCHARGEPOINTEVENTSHANDLER_H diff --git a/examples/ocpp20/common/DefaultLocalControllerEventsHandler.cpp b/examples/ocpp20/common/DefaultLocalControllerEventsHandler.cpp new file mode 100644 index 00000000..bb348e98 --- /dev/null +++ b/examples/ocpp20/common/DefaultLocalControllerEventsHandler.cpp @@ -0,0 +1,183 @@ +/* +MIT License + +Copyright (c) 2020 Cedric Jimenez + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + +#include "DefaultLocalControllerEventsHandler.h" + +#include +#include + +using namespace std; +using namespace ocpp::localcontroller; + +/** @brief Constructor */ +DefaultLocalControllerEventsHandler::DefaultLocalControllerEventsHandler(LocalControllerConfig& config) + : m_config(config), m_mutex(), m_chargepoints() +{ +} + +/** @brief Destructor */ +DefaultLocalControllerEventsHandler::~DefaultLocalControllerEventsHandler() { } + +// ILocalControllerEventsHandler interface + +/** @copydoc bool ILocalControllerEventsHandler::acceptConnection(const char*) */ +bool DefaultLocalControllerEventsHandler::acceptConnection(const char* ip_address) +{ + cout << "Accept connection from [" << ip_address << "]" << endl; + return true; +} + +/** @copydoc void ILocalControllerEventsHandler::clientFailedToConnect(const char*) */ +void DefaultLocalControllerEventsHandler::clientFailedToConnect(const char* ip_address) +{ + cout << "Client [" << ip_address << "] failed to connect" << endl; +} + +/** @copydoc bool ILocalControllerEventsHandler::checkCredentials(const std::string&, const std::string&) */ +bool DefaultLocalControllerEventsHandler::checkCredentials(const std::string& chargepoint_id, const std::string& password) +{ + cout << "Check credentials for [" << chargepoint_id << "] : " << password << endl; + return true; +} + +/** @copydoc bool ILocalControllerEventsHandler::chargePointConnected(std::shared_ptr */ +void DefaultLocalControllerEventsHandler::chargePointConnected( + std::shared_ptr chargepoint) +{ + cout << "Charge point [" << chargepoint->identifier() << "] connected" << endl; + m_mutex.lock(); + auto iter_chargepoint = m_chargepoints.find(chargepoint->identifier()); + if (iter_chargepoint == m_chargepoints.end()) + { + std::weak_ptr p_chargepoint = chargepoint; + + // Specific handling of heartbeat message + auto heartbeat_handler = [p_chargepoint](const ocpp::messages::ocpp20::HeartbeatReq& request, + ocpp::messages::ocpp20::HeartbeatConf& response, + std::string& error_code, + std::string& error_message) + { + bool ret = true; + auto chargepoint = p_chargepoint.lock(); + if (chargepoint) + { + std::cout << "[" << chargepoint->identifier() << "] - Heartbeat received" << std::endl; + + // Forward message + ret = chargepoint->centralSystemProxy()->call(request, response, error_code, error_message); + if (!ret) + { + std::cout << "[" << chargepoint->identifier() << "] - Unable to forward heartbeat" << std::endl; + } + } + return ret; + }; + chargepoint->registerHandler(heartbeat_handler); + + // Open connection to the Central System + ocpp::websockets::IWebsocketClient::Credentials credentials; + credentials.accept_untrusted_certificates = false; + credentials.allow_expired_certificates = false; + credentials.allow_selfsigned_certificates = false; + credentials.skip_server_name_check = false; + credentials.encoded_pem_certificates = false; + credentials.tls12_cipher_list = m_config.tlsv12CipherList(); + credentials.tls13_cipher_list = m_config.tlsv13CipherList(); + credentials.server_certificate_ca = m_config.tlsServerCertificateCa(); + credentials.client_certificate = m_config.tlsClientCertificate(); + credentials.client_certificate_private_key = m_config.tlsClientCertificatePrivateKey(); + credentials.client_certificate_private_key_passphrase = m_config.tlsClientCertificatePrivateKeyPassphrase(); + if (!chargepoint->centralSystemProxy()->connect(m_config.connexionUrl(), credentials)) + { + cout << "Charge point [" << chargepoint->identifier() << "] unable to start connection to Central System" << endl; + chargepoint.reset(); + } + else + { + m_chargepoints[chargepoint->identifier()] = + std::make_shared(*this, chargepoint); + } + m_mutex.unlock(); + } + else + { + m_mutex.unlock(); + cout << "Charge point [" << chargepoint->identifier() << "] already connected" << endl; + chargepoint.reset(); + } +} + +/** @brief Remove a charge point from the connected charge points */ +void DefaultLocalControllerEventsHandler::removeChargePoint(const std::string& identifier) +{ + std::thread t( + [this, &identifier] + { + std::this_thread::sleep_for(std::chrono::milliseconds(50)); + std::lock_guard lock(m_mutex); + auto iter_chargepoint = m_chargepoints.find(identifier); + if (iter_chargepoint != m_chargepoints.end()) + { + m_chargepoints.erase(iter_chargepoint); + } + }); + t.detach(); +} + +/** @brief Constructor */ +DefaultLocalControllerEventsHandler::LocalControllerProxyEventsHandler::LocalControllerProxyEventsHandler( + DefaultLocalControllerEventsHandler& event_handler, std::shared_ptr& chargepoint) + : m_event_handler(event_handler), m_chargepoint(chargepoint) +{ + m_chargepoint->registerListener(*this); +} + +/** @brief Destructor */ +DefaultLocalControllerEventsHandler::LocalControllerProxyEventsHandler::~LocalControllerProxyEventsHandler() { } + +/** @brief Called to notify the disconnection of the charge point */ +void DefaultLocalControllerEventsHandler::LocalControllerProxyEventsHandler::disconnectedFromChargePoint() +{ + cout << "Charge Point [" << m_chargepoint->identifier() << "] disconnected!" << endl; + m_event_handler.removeChargePoint(m_chargepoint->identifier()); +} + +/** @brief Called to notify the connection to the central system */ +void DefaultLocalControllerEventsHandler::LocalControllerProxyEventsHandler::connectedToCentralSystem() +{ + cout << "Charge Point [" << m_chargepoint->identifier() << "] connected to Central System!" << endl; +} + +/** @brief Called to notify the failure of the connection to the central system */ +void DefaultLocalControllerEventsHandler::LocalControllerProxyEventsHandler::failedToConnectToCentralSystem() + +{ + cout << "Charge Point [" << m_chargepoint->identifier() << "] failed to connect to Central System!" << endl; +} + +/** @brief Called to notify the disconnection from the central system */ +void DefaultLocalControllerEventsHandler::LocalControllerProxyEventsHandler::disconnectedFromCentralSystem() +{ + cout << "Charge Point [" << m_chargepoint->identifier() << "] disconnected from Central System!" << endl; +} \ No newline at end of file diff --git a/examples/ocpp20/common/DefaultLocalControllerEventsHandler.h b/examples/ocpp20/common/DefaultLocalControllerEventsHandler.h new file mode 100644 index 00000000..5b0267ef --- /dev/null +++ b/examples/ocpp20/common/DefaultLocalControllerEventsHandler.h @@ -0,0 +1,115 @@ +/* +MIT License + +Copyright (c) 2020 Cedric Jimenez + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + +#ifndef DEFAULTLOCALCONTROLLEREVENTSHANDLER_H +#define DEFAULTLOCALCONTROLLEREVENTSHANDLER_H + +#include "ILocalControllerEventsHandler20.h" +#include "ILocalControllerProxyEventsHandler20.h" +#include "LocalControllerConfig.h" + +#include +#include + +/** @brief Default local controller event handlers implementation for the examples */ +class DefaultLocalControllerEventsHandler : public ocpp::localcontroller::ocpp20::ILocalControllerEventsHandler20 +{ + public: + /** @brief Constructor */ + DefaultLocalControllerEventsHandler(LocalControllerConfig& config); + + /** @brief Destructor */ + virtual ~DefaultLocalControllerEventsHandler(); + + // ILocalControllerEventsHandler interface + + /** @copydoc bool ILocalControllerEventsHandler::acceptConnection(const char*) */ + bool acceptConnection(const char* ip_address) override; + + /** @copydoc void ILocalControllerEventsHandler::clientFailedToConnect(const char*) */ + void clientFailedToConnect(const char* ip_address) override; + + /** @copydoc bool ILocalControllerEventsHandler::checkCredentials(const std::string&, const std::string&) */ + bool checkCredentials(const std::string& chargepoint_id, const std::string& password) override; + + /** @copydoc bool ILocalControllerEventsHandler::chargePointConnected(std::shared_ptr */ + void chargePointConnected(std::shared_ptr chargepoint) override; + + // API + + /** @brief Handle events from local controller proxys */ + class LocalControllerProxyEventsHandler : public ocpp::localcontroller::ocpp20::ILocalControllerProxyEventsHandler20 + { + public: + /** @brief Constructor */ + LocalControllerProxyEventsHandler(DefaultLocalControllerEventsHandler& event_handler, + std::shared_ptr& chargepoint); + + /** @brief Destructor */ + virtual ~LocalControllerProxyEventsHandler(); + + /** @brief Get the charge point proxy */ + std::shared_ptr proxy() { return m_chargepoint; } + + // ocpp::localcontroller::ocpp20::ILocalControllerProxyEventsHandler20 + + /** @brief Called to notify the disconnection of the charge point */ + void disconnectedFromChargePoint() override; + + /** @brief Called to notify the connection to the central system */ + void connectedToCentralSystem() override; + + /** @brief Called to notify the failure of the connection to the central system */ + void failedToConnectToCentralSystem() override; + + /** @brief Called to notify the disconnection from the central system */ + void disconnectedFromCentralSystem() override; + + private: + /** @brief Event handler */ + DefaultLocalControllerEventsHandler& m_event_handler; + + /** @brief Charge point proxy */ + std::shared_ptr m_chargepoint; + }; + + /** @brief Get the list of the connected charge points */ + std::map> chargePoints() + { + return m_chargepoints; + } + + /** @brief Remove a charge point from the connected charge points */ + void removeChargePoint(const std::string& identifier); + + private: + /** @brief Configuration */ + LocalControllerConfig& m_config; + /** @brief Mutex to protect the list of the charge points */ + std::mutex m_mutex; + /** @brief Connected charge points */ + std::map> m_chargepoints; +}; + +#endif // DEFAULTLOCALCONTROLLEREVENTSHANDLER_H diff --git a/examples/ocpp20/common/config/CentralSystemConfig.h b/examples/ocpp20/common/config/CentralSystemConfig.h new file mode 100644 index 00000000..be9d2e77 --- /dev/null +++ b/examples/ocpp20/common/config/CentralSystemConfig.h @@ -0,0 +1,113 @@ +/* +MIT License + +Copyright (c) 2020 Cedric Jimenez + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + +#ifndef CENTRALSYSTEMCONFIG_H +#define CENTRALSYSTEMCONFIG_H + +#include "ICentralSystemConfig20.h" +#include "IniFile.h" + +/** @brief Section name for the parameters */ +static const std::string STACK_PARAMS = "CentralSystem"; + +/** @brief Charge Point stack internal configuration */ +class CentralSystemConfig : public ocpp::config::ICentralSystemConfig20 +{ + public: + /** @brief Constructor */ + CentralSystemConfig(ocpp::helpers::IniFile& config) : m_config(config) { } + + // Paths + + /** @brief Path to the database to store persistent data */ + std::string databasePath() const override { return getString("DatabasePath"); } + /** @brief Path to the JSON schemas to validate the messages */ + std::string jsonSchemasPath() const override { return getString("JsonSchemasPath"); } + + // Communication parameters + + /** @brief Listen URL */ + std::string listenUrl() const override { return getString("ListenUrl"); } + /** @brief Call request timeout */ + std::chrono::milliseconds callRequestTimeout() const override { return get("CallRequestTimeout"); } + /** @brief Websocket PING interval */ + std::chrono::seconds webSocketPingInterval() const override { return get("WebSocketPingInterval"); } + /** @brief Enable HTTP basic authentication */ + bool httpBasicAuthent() const override { return getBool("HttpBasicAuthent"); } + /** @brief Cipher list to use for TLSv1.2 connections */ + std::string tlsv12CipherList() const override { return getString("Tlsv12CipherList"); } + /** @brief Cipher list to use for TLSv1.3 connections */ + std::string tlsv13CipherList() const override { return getString("Tlsv13CipherList"); } + /** @brief ECDH curve to use for TLS connections */ + std::string tlsEcdhCurve() const override { return getString("TlsEcdhCurve"); } + /** @brief Server certificate */ + std::string tlsServerCertificate() const override { return getString("TlsServerCertificate"); } + /** @brief Server certificate's private key */ + std::string tlsServerCertificatePrivateKey() const override { return getString("TlsServerCertificatePrivateKey"); } + /** @brief Server certificate's private key passphrase */ + std::string tlsServerCertificatePrivateKeyPassphrase() const override { return getString("TlsServerCertificatePrivateKeyPassphrase"); } + /** @brief Certification Authority signing chain for the server certificate */ + std::string tlsServerCertificateCa() const override { return getString("TlsServerCertificateCa"); } + /** @brief Enable client authentication using certificate */ + bool tlsClientCertificateAuthent() const override { return getBool("TlsClientCertificateAuthent"); } + + // Logs + + /** @brief Maximum number of entries in the log (0 = no logs in database) */ + unsigned int logMaxEntriesCount() const override { return get("LogMaxEntriesCount"); } + + // Behavior + + /** @brief Size of the thread pool to handle incoming requests from the Charge Points */ + unsigned int incomingRequestsFromCpThreadPoolSize() const override + { + return get("IncomingRequestsFromCpThreadPoolSize"); + }; + + // Not a stack parameter anymore + + /** @brief Boot notification retry interval */ + std::chrono::seconds bootNotificationRetryInterval() const { return get("BootNotificationRetryInterval"); } + /** @brief Heartbeat interval */ + std::chrono::seconds heartbeatInterval() const { return get("HeartbeatInterval"); } + + private: + /** @brief Configuration file */ + ocpp::helpers::IniFile& m_config; + + /** @brief Get a boolean parameter */ + bool getBool(const std::string& param) const { return m_config.get(STACK_PARAMS, param).toBool(); } + /** @brief Get a floating point parameter */ + double getFloat(const std::string& param) const { return m_config.get(STACK_PARAMS, param).toFloat(); } + /** @brief Get a string parameter */ + std::string getString(const std::string& param) const { return m_config.get(STACK_PARAMS, param); } + /** @brief Get a value which can be created from an unsigned integer */ + template + T get(const std::string& param) const + { + return T(m_config.get(STACK_PARAMS, param).toUInt()); + } +}; + +#endif // CENTRALSYSTEMCONFIG_H diff --git a/examples/ocpp20/common/config/CentralSystemDemoConfig.h b/examples/ocpp20/common/config/CentralSystemDemoConfig.h new file mode 100644 index 00000000..33d08df1 --- /dev/null +++ b/examples/ocpp20/common/config/CentralSystemDemoConfig.h @@ -0,0 +1,54 @@ +/* +MIT License + +Copyright (c) 2020 Cedric Jimenez + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + +#ifndef CENTRALSYSTEMDEMOCONFIG_H +#define CENTRALSYSTEMDEMOCONFIG_H + +#include "CentralSystemConfig.h" +#include "IniFile.h" + +/** @brief Configuration of the Central System demo */ +class CentralSystemDemoConfig +{ + public: + /** @brief Constructor */ + CentralSystemDemoConfig(const std::string& config_file) : m_config(config_file), m_stack_config(m_config) { } + + /** @brief Stack internal configuration */ + ocpp::config::ICentralSystemConfig20& stackConfig() { return m_stack_config; } + + /** @brief Boot notification retry interval */ + std::chrono::seconds bootNotificationRetryInterval() const { return m_stack_config.bootNotificationRetryInterval(); } + /** @brief Heartbeat interval */ + std::chrono::seconds heartbeatInterval() const { return m_stack_config.heartbeatInterval(); } + + private: + /** @brief Configuration file */ + ocpp::helpers::IniFile m_config; + + /** @brief Stack internal configuration */ + CentralSystemConfig m_stack_config; +}; + +#endif // CENTRALSYSTEMDEMOCONFIG_H diff --git a/examples/ocpp20/common/config/ChargePointConfig.h b/examples/ocpp20/common/config/ChargePointConfig.h new file mode 100644 index 00000000..42adb877 --- /dev/null +++ b/examples/ocpp20/common/config/ChargePointConfig.h @@ -0,0 +1,141 @@ +/* +MIT License + +Copyright (c) 2020 Cedric Jimenez + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + +#ifndef CHARGEPOINTCONFIG_H +#define CHARGEPOINTCONFIG_H + +#include "IChargePointConfig20.h" +#include "IniFile.h" + +/** @brief Section name for the parameters */ +static const std::string STACK_PARAMS = "ChargePoint"; + +/** @brief Charge Point stack internal configuration */ +class ChargePointConfig : public ocpp::config::IChargePointConfig20 +{ + public: + /** @brief Constructor */ + ChargePointConfig(ocpp::helpers::IniFile& config) : m_config(config) { } + + /** @brief Set the value of a stack internal configuration key */ + void setConfigValue(const std::string& key, const std::string& value) { m_config.set(STACK_PARAMS, key, value); } + + // Paths + + /** @brief Path to the database to store persistent data */ + std::string databasePath() const override { return getString("DatabasePath"); } + /** @brief Path to the JSON schemas to validate the messages */ + std::string jsonSchemasPath() const override { return getString("JsonSchemasPath"); } + + // Communication parameters + + /** @brief Connection URL */ + std::string connexionUrl() const override { return getString("ConnexionUrl"); }; + /** @brief Charge point identifier */ + std::string chargePointIdentifier() const override { return getString("ChargePointIdentifier"); } + /** @brief Connection timeout */ + std::chrono::milliseconds connectionTimeout() const override { return get("ConnectionTimeout"); } + /** @brief Retry interval */ + std::chrono::milliseconds retryInterval() const override { return get("RetryInterval"); } + /** @brief Call request timeout */ + std::chrono::milliseconds callRequestTimeout() const override { return get("CallRequestTimeout"); } + /** @brief Websocket PING interval */ + std::chrono::seconds webSocketPingInterval() const override { return get("WebSocketPingInterval"); } + /** @brief Cipher list to use for TLSv1.2 connections */ + std::string tlsv12CipherList() const override { return getString("Tlsv12CipherList"); } + /** @brief Cipher list to use for TLSv1.3 connections */ + std::string tlsv13CipherList() const override { return getString("Tlsv13CipherList"); } + /** @brief Certification Authority signing chain for the server certificate */ + std::string tlsServerCertificateCa() const override { return getString("TlsServerCertificateCa"); } + /** @brief Client certificate */ + std::string tlsClientCertificate() const override { return getString("TlsClientCertificate"); } + /** @brief Client certificate's private key */ + std::string tlsClientCertificatePrivateKey() const override { return getString("TlsClientCertificatePrivateKey"); } + /** @brief Client certificate's private key passphrase */ + std::string tlsClientCertificatePrivateKeyPassphrase() const override { return getString("TlsClientCertificatePrivateKeyPassphrase"); } + /** @brief Allow TLS connections using self-signed certificates + * (Warning : enabling this feature is not recommended in production) */ + bool tlsAllowSelfSignedCertificates() const override { return getBool("TlsAllowSelfSignedCertificates"); } + /** @brief Allow TLS connections using expired certificates + * (Warning : enabling this feature is not recommended in production) */ + bool tlsAllowExpiredCertificates() const override { return getBool("TlsAllowExpiredCertificates"); } + /** @brief Accept non trusted certificates for TLS connections + * (Warning : enabling this feature is not recommended in production) */ + bool tlsAcceptNonTrustedCertificates() const override { return getBool("TlsAcceptNonTrustedCertificates"); } + /** @brief Skip server name check in certificates for TLS connections + * (Warning : enabling this feature is not recommended in production) */ + bool tlsSkipServerNameCheck() const override { return getBool("TlsSkipServerNameCheck"); } + + // Charge point identification + + /** @brief Charge point model */ + std::string chargePointModel() const override { return getString("ChargePointModel"); } + /** @brief Charge point serial number */ + std::string chargePointSerialNumber() const override { return getString("ChargePointSerialNumber"); } + /** @brief Charge point vendor */ + std::string chargePointVendor() const override { return getString("ChargePointVendor"); } + /** @brief Firmware version */ + std::string firmwareVersion() const override { return getString("FirmwareVersion"); } + /** @brief ICCID of the moden's SIM card */ + std::string iccid() const override { return getString("Iccid"); } + /** @brief IMSI of the moden's SIM card */ + std::string imsi() const override { return getString("Imsi"); } + + // Logs + + /** @brief Maximum number of entries in the log (0 = no logs in database) */ + unsigned int logMaxEntriesCount() const override { return get("LogMaxEntriesCount"); } + + // Security + + /** @brief Security profile to use for connection with the central system [0-3] */ + unsigned int securityProfile() const override { return get("SecurityProfile"); } + /** @brief The basic authentication password is used for HTTP Basic Authentication. The password SHALL be a randomly + chosen passwordString with a sufficiently high entropy, consisting of minimum 16 and maximum 40 characters + (alpha-numeric characters and the special characters allowed by passwordString). The password SHALL be sent + as a UTF-8 encoded string (NOT encoded into octet string or base64). This configuration variable is write-only, so + that it cannot be accidentally stored in plaintext by the CSMS when it reads out all configuration variables. + This configuration variable is required unless only "security profile 3 - TLS with client side certificates" is + implemented. */ + std::string basicAuthPassword() const override { return getString("BasicAuthPassword"); } + + private: + /** @brief Configuration file */ + ocpp::helpers::IniFile& m_config; + + /** @brief Get a boolean parameter */ + bool getBool(const std::string& param) const { return m_config.get(STACK_PARAMS, param).toBool(); } + /** @brief Get a floating point parameter */ + double getFloat(const std::string& param) const { return m_config.get(STACK_PARAMS, param).toFloat(); } + /** @brief Get a string parameter */ + std::string getString(const std::string& param) const { return m_config.get(STACK_PARAMS, param); } + /** @brief Get a value which can be created from an unsigned integer */ + template + T get(const std::string& param) const + { + return T(m_config.get(STACK_PARAMS, param).toUInt()); + } +}; + +#endif // CHARGEPOINTCONFIG_H diff --git a/examples/ocpp20/common/config/ChargePointDemoConfig.h b/examples/ocpp20/common/config/ChargePointDemoConfig.h new file mode 100644 index 00000000..68c4fec0 --- /dev/null +++ b/examples/ocpp20/common/config/ChargePointDemoConfig.h @@ -0,0 +1,106 @@ +/* +MIT License + +Copyright (c) 2020 Cedric Jimenez + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + +#ifndef CHARGEPOINTDEMOCONFIG_H +#define CHARGEPOINTDEMOCONFIG_H + +#include "ChargePointConfig.h" +#include "IDeviceModel20.h" +#include "IniFile.h" + +/** @brief Configuration of the Charge Point demo */ +class ChargePointDemoConfig +{ + public: + /** @brief Constructor */ + ChargePointDemoConfig(const std::string& config_file) : m_config(config_file), m_stack_config(m_config) { } + + /** @brief Stack internal configuration */ + ocpp::config::IChargePointConfig20& stackConfig() { return m_stack_config; } + + /** @brief Set the value of a stack internal configuration key */ + void setStackConfigValue(const std::string& key, const std::string& value) { m_stack_config.setConfigValue(key, value); } + + /** @brief Get the value of a variable of the device model */ + bool getDeviceModelValue(const ocpp::types::ocpp20::ComponentType& component, + const ocpp::types::ocpp20::VariableType& variable, + std::string& value) + { + auto ini_value = m_config.get(buildComponentName(component), buildVariableName(variable)); + value = ini_value.toString(); + return true; + } + + /** @brief Set the value of a variable of the device model */ + bool setDeviceModelValue(const ocpp::types::ocpp20::ComponentType& component, + const ocpp::types::ocpp20::VariableType& variable, + const std::string& value) + { + m_config.set(buildComponentName(component), buildVariableName(variable), value); + m_config.store(); + return true; + } + + /** @brief Save the configuration */ + bool save() { return m_config.store(); } + + private: + /** @brief Configuration file */ + ocpp::helpers::IniFile m_config; + + /** @brief Stack internal configuration */ + ChargePointConfig m_stack_config; + + /** @brief Build the device model component unique name */ + std::string buildComponentName(const ocpp::types::ocpp20::ComponentType& component) + { + std::string name = component.name; + if (component.instance.isSet()) + { + name += "." + component.instance.value().str(); + } + if (component.evse.isSet()) + { + name += "." + std::to_string(component.evse.value().id); + if (component.evse.value().connectorId.isSet()) + { + name += "." + std::to_string(component.evse.value().connectorId.value()); + } + } + return name; + } + + /** @brief Build the device model variable unique name */ + std::string buildVariableName(const ocpp::types::ocpp20::VariableType& variable) + { + std::string name = variable.name; + if (variable.instance.isSet()) + { + name += "." + variable.instance.value().str(); + } + return name; + } +}; + +#endif // CHARGEPOINTDEMOCONFIG_H diff --git a/examples/ocpp20/common/config/LocalControllerConfig.h b/examples/ocpp20/common/config/LocalControllerConfig.h new file mode 100644 index 00000000..9a333dde --- /dev/null +++ b/examples/ocpp20/common/config/LocalControllerConfig.h @@ -0,0 +1,121 @@ +/* +MIT License + +Copyright (c) 2020 Cedric Jimenez + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + +#ifndef LOCALCONTROLLERCONFIG_H +#define LOCALCONTROLLERCONFIG_H + +#include "ILocalControllerConfig20.h" +#include "IniFile.h" + +/** @brief Section name for the parameters */ +static const std::string STACK_PARAMS = "LocalController"; + +/** @brief Local Controller stack internal configuration */ +class LocalControllerConfig : public ocpp::config::ILocalControllerConfig20 +{ + public: + /** @brief Constructor */ + LocalControllerConfig(ocpp::helpers::IniFile& config) : m_config(config) { } + + // Paths + + /** @brief Path to the database to store persistent data */ + std::string databasePath() const override { return getString("DatabasePath"); } + /** @brief Path to the JSON schemas to validate the messages */ + std::string jsonSchemasPath() const override { return getString("JsonSchemasPath"); } + + // Communication parameters + + /** @brief Listen URL */ + std::string listenUrl() const override { return getString("ListenUrl"); } + /** @brief Connection URL */ + std::string connexionUrl() const { return getString("ConnexionUrl"); }; + /** @brief Call request timeout */ + std::chrono::milliseconds callRequestTimeout() const override { return get("CallRequestTimeout"); } + /** @brief Websocket PING interval */ + std::chrono::seconds webSocketPingInterval() const override { return get("WebSocketPingInterval"); } + /** @brief Enable HTTP basic authentication */ + bool httpBasicAuthent() const override { return getBool("HttpBasicAuthent"); } + /** @brief Cipher list to use for TLSv1.2 connections */ + std::string tlsv12CipherList() const override { return getString("Tlsv12CipherList"); } + /** @brief Cipher list to use for TLSv1.3 connections */ + std::string tlsv13CipherList() const override { return getString("Tlsv13CipherList"); } + /** @brief ECDH curve to use for TLS connections */ + std::string tlsEcdhCurve() const override { return getString("TlsEcdhCurve"); } + /** @brief Server certificate */ + std::string tlsServerCertificate() const override { return getString("TlsServerCertificate"); } + /** @brief Server certificate's private key */ + std::string tlsServerCertificatePrivateKey() const override { return getString("TlsServerCertificatePrivateKey"); } + /** @brief Server certificate's private key passphrase */ + std::string tlsServerCertificatePrivateKeyPassphrase() const override { return getString("TlsServerCertificatePrivateKeyPassphrase"); } + /** @brief Certification Authority signing chain for the server certificate */ + std::string tlsServerCertificateCa() const override { return getString("TlsServerCertificateCa"); } + /** @brief Enable client authentication using certificate */ + bool tlsClientCertificateAuthent() const override { return getBool("TlsClientCertificateAuthent"); } + /** @brief Client certificate */ + std::string tlsClientCertificate() const { return getString("TlsClientCertificate"); } + /** @brief Client certificate's private key */ + std::string tlsClientCertificatePrivateKey() const { return getString("TlsClientCertificatePrivateKey"); } + /** @brief Client certificate's private key passphrase */ + std::string tlsClientCertificatePrivateKeyPassphrase() const { return getString("TlsClientCertificatePrivateKeyPassphrase"); } + + // Logs + + /** @brief Maximum number of entries in the log (0 = no logs in database) */ + unsigned int logMaxEntriesCount() const override { return get("LogMaxEntriesCount"); } + + // Behavior + + /** @brief Size of the thread pool to handle incoming requests from the Charge Points */ + unsigned int incomingRequestsFromCpThreadPoolSize() const override + { + return get("IncomingRequestsFromCpThreadPoolSize"); + }; + /** @brief Size of the thread pool to handle incoming requests from the Central System */ + unsigned int incomingRequestsFromCsThreadPoolSize() const override + { + return get("IncomingRequestsFromCsThreadPoolSize"); + }; + /** @brief Disconnect from Charge Point on Central System disconnection */ + bool disconnectFromCpWhenCsDisconnected() const override { return getBool("DisconnectFromCpWhenCsDisconnected"); } + + private: + /** @brief Configuration file */ + ocpp::helpers::IniFile& m_config; + + /** @brief Get a boolean parameter */ + bool getBool(const std::string& param) const { return m_config.get(STACK_PARAMS, param).toBool(); } + /** @brief Get a floating point parameter */ + double getFloat(const std::string& param) const { return m_config.get(STACK_PARAMS, param).toFloat(); } + /** @brief Get a string parameter */ + std::string getString(const std::string& param) const { return m_config.get(STACK_PARAMS, param); } + /** @brief Get a value which can be created from an unsigned integer */ + template + T get(const std::string& param) const + { + return T(m_config.get(STACK_PARAMS, param).toUInt()); + } +}; + +#endif // LOCALCONTROLLERCONFIG_H diff --git a/examples/ocpp20/common/config/LocalControllerDemoConfig.h b/examples/ocpp20/common/config/LocalControllerDemoConfig.h new file mode 100644 index 00000000..c24eacb8 --- /dev/null +++ b/examples/ocpp20/common/config/LocalControllerDemoConfig.h @@ -0,0 +1,49 @@ +/* +MIT License + +Copyright (c) 2020 Cedric Jimenez + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + +#ifndef LOCALCONTROLLERDEMOCONFIG_H +#define LOCALCONTROLLERDEMOCONFIG_H + +#include "IniFile.h" +#include "LocalControllerConfig.h" + +/** @brief Configuration of the Local Controller demo */ +class LocalControllerDemoConfig +{ + public: + /** @brief Constructor */ + LocalControllerDemoConfig(const std::string& config_file) : m_config(config_file), m_stack_config(m_config) { } + + /** @brief Stack internal configuration */ + LocalControllerConfig& stackConfig() { return m_stack_config; } + + private: + /** @brief Configuration file */ + ocpp::helpers::IniFile m_config; + + /** @brief Stack internal configuration */ + LocalControllerConfig m_stack_config; +}; + +#endif // LOCALCONTROLLERDEMOCONFIG_H diff --git a/examples/ocpp20/quick_start_basicchargepoint/CMakeLists.txt b/examples/ocpp20/quick_start_basicchargepoint/CMakeLists.txt new file mode 100644 index 00000000..08ef6f7a --- /dev/null +++ b/examples/ocpp20/quick_start_basicchargepoint/CMakeLists.txt @@ -0,0 +1,27 @@ +###################################################### +# Quick start charge point example project # +###################################################### + +# Executable target +add_executable(quick_start_basicchargepoint20 + main.cpp +) + +# Additionnal libraries path +target_link_directories(quick_start_basicchargepoint20 PRIVATE ${BIN_DIR}) + +# Dependencies +target_link_libraries(quick_start_basicchargepoint20 + examples_common20 +) + + +# Copy to binary directory +ADD_CUSTOM_COMMAND(TARGET quick_start_basicchargepoint20 + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_LIST_DIR}/config/quick_start_basicchargepoint20.ini ${BIN_DIR}/ +) +ADD_CUSTOM_COMMAND(TARGET quick_start_basicchargepoint20 + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_LIST_DIR}/config/quick_start_basicchargepoint20.json ${BIN_DIR}/ +) diff --git a/examples/ocpp20/quick_start_basicchargepoint/README.md b/examples/ocpp20/quick_start_basicchargepoint/README.md new file mode 100644 index 00000000..31c68d77 --- /dev/null +++ b/examples/ocpp20/quick_start_basicchargepoint/README.md @@ -0,0 +1,24 @@ +# Quick start Basic Charge Point OCPP 2.0.1 example + +## Description + +The Basic Charge Point implements only the use cases defined in OCPP 2.0.1 Part 0 Specification §4. + +This example simulates a charge point which start a charging session locally with an id tag. + +The charge point loops on its connectors. For each connector it simulates the following operations : + +* Id tag authorization +* Status notifications (Preparing, Charging, Finishing, Available) +* Transaction start/stop + +Each charging sessions lasts 30s and there is a 10s break between 2 charging sessions. + +## Command line + +quick_start_basicchargepoint [-t id_tag] [-w working_dir] [-r] [-d] + +* -t : Id tag to use (Default = AABBCCDDEEFF) +* -w : Working directory where to store the configuration file (Default = current directory) +* -r : Reset all the OCPP persistent data +* -d : Reset all the connector persistent data diff --git a/examples/ocpp20/quick_start_basicchargepoint/config/quick_start_basicchargepoint20.ini b/examples/ocpp20/quick_start_basicchargepoint/config/quick_start_basicchargepoint20.ini new file mode 100644 index 00000000..c3ce0130 --- /dev/null +++ b/examples/ocpp20/quick_start_basicchargepoint/config/quick_start_basicchargepoint20.ini @@ -0,0 +1,203 @@ +[ChargePoint] +DatabasePath=./quick_start_basicchargepoint20.db +DeviceModelPath=./quick_start_basicchargepoint20.json +JsonSchemasPath=../../schemas/ocpp20/ +ConnexionUrl=wss://127.0.0.1:9090/openocpp/ +Tlsv12CipherList=ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:PSK-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES128-GCM-SHA256:PSK-AES128-GCM-SHA256 +Tlsv13CipherList=TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384 +TlsServerCertificateCa=../../examples/certificates/open-ocpp_ca.crt +TlsClientCertificate=../../examples/certificates/open-ocpp_charge-point.crt +TlsClientCertificatePrivateKey=../../examples/certificates/open-ocpp_charge-point.key +TlsClientCertificatePrivateKeyPassphrase= +TlsAllowSelfSignedCertificates=false +TlsAllowExpiredCertificates=false +TlsAcceptNonTrustedCertificates=false +TlsSkipServerNameCheck=false +ChargePointIdentifier=ChargePointTest +ConnectionTimeout=2000 +RetryInterval=1000 +CallRequestTimeout=2000 +LogMaxEntriesCount=2000 +WebSocketPingInterval=10 +SecurityProfile=0 +BasicAuthPassword=P@ssw0rd! +ChargePointModel=Open OCPP CP +ChargePointVendor=Open OCPP +ChargePointSerialNumber=S/N0123456789 +FirmwareVersion=0.1 +Iccid= +Imsi= + +[TxCtrlr] +TxStopPoint=EVConnected,Authorized +TxStartPoint=PowerPathClosed +TxBeforeAcceptedEnabled=false +StopTxOnInvalidId=true +MaxEnergyOnInvalidId=0 +StopTxOnEVSideDisconnect=true +EVConnectionTimeOut=30 +[TariffCostCtrlr] +TotalCostFallbackMessage= +Enabled.Tariff=false +Enabled.Cost=false +Currency=eur +Available.Tariff=false +TariffFallbackMessage= +Available.Cost=false +[SmartChargingCtrlr] +RateUnit=A +ProfileStackLevel=100 +Phases3to1=false +NotifyChargingLimitWithSchedules=false +LimitChangeSignificance=0 +ExternalControlSignalsEnabled=false +Entries=100 +PeriodsPerSchedule=100 +Enabled=true +Available=true +ACPhaseSwitchingSupported=false +[SampledDataCtrlr] +TxEndedInterval=0 +TxEndedMeasurands= +SignReadings=false +TxUpdatedMeasurands= +Enabled=true +TxUpdatedInterval=0 +TxStartedMeasurands= +Available=false +[ReservationCtrlr] +NonEvseSpecific=false +Enabled=true +Available=true +[LocalAuthListCtrlr] +SupportsExpiryDateTime=true +Storage=1000000 +ItemsPerMessage=200 +Enabled=true +Entries=1000 +DisablePostAuthorize=true +BytesPerMessage=10000 +Available=true +[EVSE.EVSE 1.1] +SupplyPhases=3 +Power=22000 +PhaseRotation=RST +Available=true +AvailabilityState=Available +AllowReset=false +[SecurityCtrlr] +MaxCertificateChainSize=10000 +Identity=ChargePointTest +CertificateEntries=20 +CertSigningWaitMinimum=30 +CertSigningRepeatTimes=3 +BasicAuthPassword= +SecurityProfile=0 +OrganizationName= +AdditionalRootCertificateCheck=false +[AuthCacheCtrlr] +Storage=1000000 +Policy=LRU +LifeTime=86400 +Enabled=true +DisablePostAuthorize=false +Available=true +[OCPPCommCtrlr] +WebSocketPingInterval=10 +RetryBackOffRepeatTimes=10 +HeartbeatInterval=60 +MessageAttemptIntervalTransactionEvent.TransactionEvent=30 +UnlockOnEVSideDisconnect=true +ActiveNetworkProfile=0 +FieldLength..= +FileTransferProtocols=FTP,FTPS,HTTP,HTTPS +MessageAttemptsTransactionEvent.TransactionEvent= +RetryBackOffWaitMinimum=30 +OfflineThreshold=300 +NetworkConfigurationPriority=0,1,2 +NetworkProfileConnectionAttempts=3 +MessageTimeout.Default=10 +RetryBackOffRandomRange=30 +QueueAllMessages=false +ResetRetries=3 +[Connector.1.1] +SupplyPhases=3 +Power=22000 +PhaseRotation=RST +ConnectorType=cType2 +Available=true +AvailabilityState=true +[DeviceDataCtrlr] +ReportingValueSize= +ItemsPerMessage.GetReport=100 +BytesPerMessage.SetVariables=10000 +ConfigurationValueSize=1000 +BytesPerMessage.GetVariables=10000 +ItemsPerMessage.SetVariables=100 +ItemsPerMessage.GetVariables=100 +BytesPerMessage.GetReport=10000 +[AuthCtrlr] +OfflineTxForUnknownIdEnabled=false +LocalPreAuthorize=true +LocalAuthorizeOffline=true +MasterPassGroupId= +Enabled=true +DisableRemoteAuthorization=false +AuthorizeRemoteStart=true +AdditionalInfoItemsPerMessage=10 +[ChargingStation] +Available=true +AllowNewSessionsPendingFirmwareUpdate=false +[AlignedDataCtrlr] +TxEndedInterval=0 +TxEndedMeasurands= +SignReadings=false +PublicKeyWithSignedMeterValue= +Measurands= +RegisterValuesWithoutPhases=true +Interval=0 +Enabled=true +Available=true +[ISO15118Ctrlr] +V2GCertificateInstallationEnabled=true +RequestMeteringReceipt=false +PnCEnabled=false +ContractValidationOffline=false +ContractCertificateInstallationEnabled=true +CentralContractValidationAllowed=true +[CustomizationCtrlr] +CustomImplementationEnabled.= +[MonitoringCtrlr] +OfflineQueuingSeverity=0 +ItemsPerMessage.ClearVariableMonitoring=100 +Enabled=true +BytesPerMessage.SetVariableMonitoring=10000 +BytesPerMessage.ClearVariableMonitoring=10000 +Available=true +ItemsPerMessage.SetVariableMonitoring=100 +ActiveMonitoringLevel=0 +ActiveMonitoringBase=All +[AlignedDataCtrlr.1] +SendDuringIdle=false +[DisplayMessageCtrlr] +SupportedPriorities=AlwaysFront +SupportedFormats=ASCII,UTF8 +Enabled=true +DisplayMessages=10 +Available=true +[ClockCtrlr] +TimeZone=Europe/Paris +TimeSource=Heartbeat +TimeOffset=+01:00 +dateTime= +TimeAdjustmentReportingThreshold=5 +NtpSource=manual +NtpServerUri.1= +NextTimeOffsetTransitionDateTime= +[ISO15118Ctrlr.1] +SeccId= +ProtocolAgreed= +ProtocolSupportedByEV= +OrganizationName= +ISO15118EvseId= +CountryName= \ No newline at end of file diff --git a/examples/ocpp20/quick_start_basicchargepoint/config/quick_start_basicchargepoint20.json b/examples/ocpp20/quick_start_basicchargepoint/config/quick_start_basicchargepoint20.json new file mode 100644 index 00000000..a35745d2 --- /dev/null +++ b/examples/ocpp20/quick_start_basicchargepoint/config/quick_start_basicchargepoint20.json @@ -0,0 +1,2035 @@ +{ + "components": [ + { + "name": "AlignedDataCtrlr", + "variables": [ + { + "name": "Enabled", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "Available", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "Measurands", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "MemberList", + "max_limit": 100 + }, + "required": true + }, + { + "name": "Interval", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "integer", + "unit": "s" + }, + "required": true + }, + { + "name": "SignReadings", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "TxEndedMeasurands", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "MemberList", + "max_limit": 100 + }, + "required": true + }, + { + "name": "TxEndedInterval", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "integer", + "unit": "s" + }, + "required": true + }, + { + "name": "PublicKeyWithSignedMeterValue", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "OptionList", + "values_list": "Never,OncePerTransaction,EveryMeterValue" + }, + "required": false + }, + { + "name": "RegisterValuesWithoutPhases", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + } + ] + }, + { + "name": "AlignedDataCtrlr", + "evse": 1, + "variables": [ + { + "name": "SendDuringIdle", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + } + ] + }, + { + "name": "AuthCacheCtrlr", + "variables": [ + { + "name": "Enabled", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "Available", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "LifeTime", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "integer", + "unit": "s" + }, + "required": false + }, + { + "name": "Storage", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer", + "max_limit": 1000000 + }, + "required": false + }, + { + "name": "Policy", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "OptionList", + "values_list": "LRU,LFU,FIFO,CUSTOM" + }, + "required": false + }, + { + "name": "DisablePostAuthorize", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + } + ] + }, + { + "name": "AuthCtrlr", + "variables": [ + { + "name": "Enabled", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "AdditionalInfoItemsPerMessage", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": false + }, + { + "name": "OfflineTxForUnknownIdEnabled", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "AuthorizeRemoteStart", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": true + }, + { + "name": "LocalAuthorizeOffline", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": true + }, + { + "name": "LocalPreAuthorize", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": true + }, + { + "name": "MasterPassGroupId", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "string", + "max_limit": 36 + }, + "required": false + }, + { + "name": "DisableRemoteAuthorization", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + } + ] + }, + { + "name": "ClockCtrlr", + "variables": [ + { + "name": "dateTime", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "dateTime" + }, + "required": true + }, + { + "name": "NtpSource", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "OptionList", + "values_list": "DHCP,manual" + }, + "required": false + }, + { + "name": "NtpServerUri", + "instance": "1", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "string" + }, + "required": false + }, + { + "name": "TimeOffset", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "string" + }, + "required": false + }, + { + "name": "NextTimeOffsetTransitionDateTime", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "dateTime" + }, + "required": false + }, + { + "name": "TimeOffset", + "instance": "1", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "string" + }, + "required": false + }, + { + "name": "TimeSource", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "SequenceList", + "values_list": "Heartbeat,NTP,GPS,RealTimeClock,MobileNetwork,RadioTimeTransmitter" + }, + "required": true + }, + { + "name": "TimeZone", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "string" + }, + "required": false + }, + { + "name": "TimeAdjustmentReportingThreshold", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "integer", + "unit": "s" + }, + "required": false + } + ] + }, + { + "name": "CustomizationCtrlr", + "variables": [ + { + "name": "CustomImplementationEnabled", + "instance": "", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + } + ] + }, + { + "name": "DeviceDataCtrlr", + "variables": [ + { + "name": "ItemsPerMessage", + "instance": "GetReport", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": true + }, + { + "name": "ItemsPerMessage", + "instance": "GetVariables", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": true + }, + { + "name": "BytesPerMessage", + "instance": "GetReport", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": true + }, + { + "name": "BytesPerMessage", + "instance": "GetVariables", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": true + }, + { + "name": "ConfigurationValueSize", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer", + "max_limit": 1000 + }, + "required": false + }, + { + "name": "ReportingValueSize", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer", + "max_limit": 2500 + }, + "required": false + }, + { + "name": "ItemsPerMessage", + "instance": "SetVariables", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": true + }, + { + "name": "BytesPerMessage", + "instance": "SetVariables", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": true + } + ] + }, + { + "name": "DisplayMessageCtrlr", + "variables": [ + { + "name": "Enabled", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "Available", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "DisplayMessages", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer", + "max_limit": 10 + }, + "required": true + }, + { + "name": "SupportedFormats", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "MemberList", + "values_list": "ASCII,HTML,URI,UTF8" + }, + "required": true + }, + { + "name": "SupportedPriorities", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "MemberList", + "values_list": "AlwaysFront,InFront,NormalCycle" + }, + "required": true + } + ] + }, + { + "name": "ISO15118Ctrlr", + "variables": [ + { + "name": "CentralContractValidationAllowed", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "ContractValidationOffline", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": true + }, + { + "name": "PnCEnabled", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "V2GCertificateInstallationEnabled", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "ContractCertificateInstallationEnabled", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "RequestMeteringReceipt", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + } + ] + }, + { + "name": "ISO15118Ctrlr", + "evse": 1, + "variables": [ + { + "name": "ProtocolSupportedByEV", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "string" + }, + "required": false + }, + { + "name": "ProtocolAgreed", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "string" + }, + "required": false + }, + { + "name": "SeccId", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "string" + }, + "required": false + }, + { + "name": "CountryName", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "string" + }, + "required": false + }, + { + "name": "OrganizationName", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "string" + }, + "required": false + }, + { + "name": "ISO15118EvseId", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "string" + }, + "required": false + } + ] + }, + { + "name": "LocalAuthListCtrlr", + "variables": [ + { + "name": "Enabled", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "Entries", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer", + "max_limit": 10000 + }, + "required": false + }, + { + "name": "Available", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "ItemsPerMessage", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": false + }, + { + "name": "BytesPerMessage", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": false + }, + { + "name": "Storage", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer", + "max_limit": 1000000 + }, + "required": false + }, + { + "name": "DisablePostAuthorize", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "SupportsExpiryDateTime", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + } + ] + }, + { + "name": "MonitoringCtrlr", + "variables": [ + { + "name": "Enabled", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "Available", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "ItemsPerMessage", + "instance": "ClearVariableMonitoring", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": false + }, + { + "name": "ItemsPerMessage", + "instance": "SetVariableMonitoring", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": true + }, + { + "name": "BytesPerMessage", + "instance": "ClearVariableMonitoring", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": false + }, + { + "name": "BytesPerMessage", + "instance": "SetVariableMonitoring", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": true + }, + { + "name": "OfflineQueuingSeverity", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": false + }, + { + "name": "ActiveMonitoringBase", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "OptionList", + "values_list": "All,FactoryDefault,HardwiredOnly" + }, + "required": false + }, + { + "name": "ActiveMonitoringLevel", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer", + "min_limit": 0, + "max_limit": 9 + }, + "required": false + } + ] + }, + { + "name": "OCPPCommCtrlr", + "variables": [ + { + "name": "ActiveNetworkProfile", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": false + }, + { + "name": "MessageTimeout", + "instance": "Default", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer", + "unit": "s" + }, + "required": true + }, + { + "name": "FileTransferProtocols", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "MemberList" + }, + "required": true + }, + { + "name": "HeartbeatInterval", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "integer", + "unit": "s", + "min_limit": 1 + }, + "required": false + }, + { + "name": "NetworkConfigurationPriority", + "attributes": + { + "mutability": "ReadWrite", + "type": "Actual" + }, + "characteristics": + { + "data_type": "SequenceList", + "values_list": "" + }, + "required": true + }, + { + "name": "NetworkProfileConnectionAttempts", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": true + }, + { + "name": "OfflineThreshold", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "integer", + "unit": "s", + "min_limit": 1 + }, + "required": true + }, + { + "name": "QueueAllMessages", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "MessageAttemptsTransactionEvent", + "instance": "TransactionEvent", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": true + }, + { + "name": "MessageAttemptIntervalTransactionEvent", + "instance": "TransactionEvent", + "attributes": + { + "mutability": "ReadWrite", + "type": "Actual" + }, + "characteristics": + { + "data_type": "integer", + "unit": "s" + }, + "required": true + }, + { + "name": "UnlockOnEVSideDisconnect", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": true + }, + { + "name": "ResetRetries", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": true + }, + { + "name": "FieldLength", + "instance": ".", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": false + }, + { + "name": "RetryBackOffRepeatTimes", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": true + }, + { + "name": "RetryBackOffRandomRange", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "integer", + "unit": "s" + }, + "required": true + }, + { + "name": "RetryBackOffWaitMinimum", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "integer", + "unit": "s" + }, + "required": true + }, + { + "name": "WebSocketPingInterval", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "integer", + "unit": "s" + }, + "required": true + } + ] + }, + { + "name": "ReservationCtrlr", + "variables": [ + { + "name": "Enabled", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "Available", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "NonEvseSpecific", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + } + ] + }, + { + "name": "SampledDataCtrlr", + "variables": [ + { + "name": "Enabled", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "Available", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "SignReadings", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "TxEndedMeasurands", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "MemberList", + "max_limit": 100 + }, + "required": true + }, + { + "name": "TxEndedInterval", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "integer", + "unit": "s" + }, + "required": true + }, + { + "name": "TxStartedMeasurands", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "MemberList", + "max_limit": 100 + }, + "required": true + }, + { + "name": "TxUpdatedMeasurands", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "MemberList", + "max_limit": 100 + }, + "required": true + }, + { + "name": "TxUpdatedInterval", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "integer", + "unit": "s" + }, + "required": true + } + ] + }, + { + "name": "SecurityCtrlr", + "variables": [ + { + "name": "BasicAuthPassword", + "attributes": + { + "mutability": "WriteOnly" + }, + "characteristics": + { + "data_type": "string", + "max_limit": 40 + }, + "required": false + }, + { + "name": "Identity", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "string", + "max_limit": 48 + }, + "required": false + }, + { + "name": "OrganizationName", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "string" + }, + "required": true + }, + { + "name": "CertificateEntries", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer", + "max_limit": 20 + }, + "required": true + }, + { + "name": "SecurityProfile", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": true + }, + { + "name": "AdditionalRootCertificateCheck", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "MaxCertificateChainSize", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer", + "max_limit": 10000 + }, + "required": false + }, + { + "name": "CertSigningWaitMinimum", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "integer", + "unit": "s" + }, + "required": false + }, + { + "name": "CertSigningRepeatTimes", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": false + } + ] + }, + { + "name": "SmartChargingCtrlr", + "variables": [ + { + "name": "Enabled", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "Available", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "ACPhaseSwitchingSupported", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "ProfileStackLevel", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": true + }, + { + "name": "RateUnit", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "MemberList", + "values_list": "A,W" + }, + "required": true + }, + { + "name": "PeriodsPerSchedule", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": true + }, + { + "name": "ExternalControlSignalsEnabled", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "NotifyChargingLimitWithSchedules", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "Phases3to1", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "Entries", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer", + "max_limit": 100 + }, + "required": true + }, + { + "name": "LimitChangeSignificance", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "decimal" + }, + "required": true + } + ] + }, + { + "name": "TariffCostCtrlr", + "variables": [ + { + "name": "Enabled", + "instance": "Tariff", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "Available", + "instance": "Tariff", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "TariffFallbackMessage", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "string", + "max_limit": 255 + }, + "required": true + }, + { + "name": "Enabled", + "instance": "Cost", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "Available", + "instance": "Cost", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "TotalCostFallbackMessage", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "string", + "max_limit": 255 + }, + "required": true + }, + { + "name": "Currency", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "string", + "max_limit": 3 + }, + "required": true + } + ] + }, + { + "name": "TxCtrlr", + "variables": [ + { + "name": "EVConnectionTimeOut", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "integer", + "unit": "s" + }, + "required": true + }, + { + "name": "StopTxOnEVSideDisconnect", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": true + }, + { + "name": "TxBeforeAcceptedEnabled", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "TxStartPoint", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "MemberList", + "values_list": "ParkingBayOccupancy,EVConnected,Authorized,PowerPathClosed,EnergyTransfer,DataSigned" + }, + "required": true + }, + { + "name": "TxStopPoint", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "MemberList", + "values_list": "ParkingBayOccupancy,EVConnected,Authorized,PowerPathClosed,EnergyTransfer,DataSigned" + }, + "required": true + }, + { + "name": "MaxEnergyOnInvalidId", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "integer", + "unit": "Wh" + }, + "required": false + }, + { + "name": "StopTxOnInvalidId", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": true + } + ] + }, + { + "name": "ChargingStation", + "variables": [ + { + "name": "AllowNewSessionsPendingFirmwareUpdate", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "Available", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": true + }, + { + "name": "AvailabilityState", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "OptionList", + "values_list": "Available,Occupied,Reserved,Unavailable,Faulted" + }, + "required": true + } + ] + }, + { + "name": "EVSE", + "instance": "EVSE 1", + "evse": 1, + "variables": [ + { + "name": "Available", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": true + }, + { + "name": "AvailabilityState", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "OptionList", + "values_list": "Available,Occupied,Reserved,Unavailable,Faulted" + }, + "required": true + }, + { + "name": "AllowReset", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "PhaseRotation", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "string" + }, + "required": false + }, + { + "name": "SupplyPhases", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": true + }, + { + "name": "Power", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "decimal" + }, + "required": true + } + ] + }, + { + "name": "Connector", + "evse": 1, + "connector": 1, + "variables": [ + { + "name": "Available", + + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": true + }, + { + "name": "AvailabilityState", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "OptionList", + "values_list": "Available,Occupied,Reserved,Unavailable,Faulted" + }, + "required": true + }, + { + "name": "ConnectorType", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "string", + "values_list": "cCCS1,cCCS2,cG105,cTesla,cType1,cType2,s309-1P-16A,s309-1P-32A,s309-3P-16A,s309-3P-32A,sBS1361,sCEE-7-7,sType2,sType3,Other1PhMax16A,Other1PhOver16A,Other3Ph,Pan,wInductive,wResonant,Undetermined,Unknown,cGBT,cChaoJi,OppCharge" + }, + "required": true + }, + { + "name": "PhaseRotation", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "string" + }, + "required": false + }, + { + "name": "SupplyPhases", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": true + }, + { + "name": "Power", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "decimal" + }, + "required": true + } + ] + } + ] +} \ No newline at end of file diff --git a/examples/ocpp20/quick_start_basicchargepoint/main.cpp b/examples/ocpp20/quick_start_basicchargepoint/main.cpp new file mode 100644 index 00000000..a172f694 --- /dev/null +++ b/examples/ocpp20/quick_start_basicchargepoint/main.cpp @@ -0,0 +1,162 @@ +/* +MIT License + +Copyright (c) 2020 Cedric Jimenez + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + +#include "ChargePointDemoConfig.h" +#include "DefaultBasicChargePointEventsHandler.h" +#include "DeviceModelManager20.h" +#include "IBasicChargePoint20.h" + +#include +#include +#include +#include +#include + +using namespace ocpp::chargepoint::ocpp20; +using namespace ocpp::types; +using namespace ocpp::types::ocpp20; +// using namespace ocpp::messages; +// using namespace ocpp::messages::ocpp20; + +/** @brief Entry point */ +int main(int argc, char* argv[]) +{ + // Default parameters + std::string id_tag = "AABBCCDDEEFF"; + std::string working_dir = ""; + bool reset_all = false; + bool reset_connectors = false; + + // Check parameters + if (argc > 1) + { + const char* param = nullptr; + bool bad_param = false; + argv++; + while ((argc != 1) && !bad_param) + { + if (strcmp(*argv, "-h") == 0) + { + bad_param = true; + } + else if ((strcmp(*argv, "-t") == 0) && (argc > 1)) + { + argv++; + argc--; + id_tag = *argv; + } + else if ((strcmp(*argv, "-w") == 0) && (argc > 1)) + { + argv++; + argc--; + working_dir = *argv; + } + else if (strcmp(*argv, "-r") == 0) + { + reset_all = true; + } + else if (strcmp(*argv, "-d") == 0) + { + reset_connectors = true; + } + else + { + param = *argv; + bad_param = true; + } + + // Next param + argc--; + argv++; + } + if (bad_param) + { + if (param) + { + std::cout << "Invalid parameter : " << param << std::endl; + } + std::cout << "Usage : quick_start_chargepoint20 [-t id_tag] [-w working_dir] [-r] [-d]" << std::endl; + std::cout << " -t : Id tag to use (Default = AABBCCDDEEFF)" << std::endl; + std::cout << " -w : Working directory where to store the configuration file (Default = current directory)" << std::endl; + std::cout << " -r : Reset all the OCPP persistent data" << std::endl; + std::cout << " -d : Reset all the connector persistent data" << std::endl; + return 1; + } + } + + std::cout << "Starting charge point with :" << std::endl; + std::cout << " - id_tag = " << id_tag << std::endl; + std::cout << " - working_dir = " << working_dir << std::endl; + + // Configuration + std::filesystem::path path(working_dir); + path /= "quick_start_basicchargepoint20.ini"; + ChargePointDemoConfig config(path.string()); + + // Device model + std::filesystem::path device_model_path(working_dir); + device_model_path /= "quick_start_basicchargepoint20.json"; + DeviceModelManager device_model_mgr(config.stackConfig()); + if (device_model_mgr.init()) + { + if (!device_model_mgr.load(device_model_path)) + { + std::cout << "Unable to load device model : " << device_model_mgr.lastError() << std::endl; + } + } + else + { + std::cout << "Unable to initialize device model loader : " << device_model_mgr.lastError() << std::endl; + } + + // Event handler + DefaultBasicChargePointEventsHandler event_handler(config, working_dir); + device_model_mgr.registerListener(event_handler); + config.save(); + + // Instanciate charge point + std::unique_ptr charge_point = IBasicChargePoint20::create(config.stackConfig(), device_model_mgr, event_handler); + if (reset_connectors) + { + charge_point->resetConnectorData(); + } + if (reset_all) + { + charge_point->resetData(); + } + //event_handler.setChargePoint(*charge_point.get()); + charge_point->start(BootReasonEnumType::PowerUp); + + // From now on the stack is alive :) + + // App loop + while (true) + { + std::this_thread::sleep_for(std::chrono::seconds(2)); + + charge_point->statusNotification(1u, 1u, ConnectorStatusEnumType::Occupied); + } + + return 0; +} diff --git a/examples/ocpp20/quick_start_centralsystem/CMakeLists.txt b/examples/ocpp20/quick_start_centralsystem/CMakeLists.txt new file mode 100644 index 00000000..115b12ba --- /dev/null +++ b/examples/ocpp20/quick_start_centralsystem/CMakeLists.txt @@ -0,0 +1,24 @@ +###################################################### +# Quick start central system example project # +###################################################### + +# Executable target +add_executable(quick_start_centralsystem20 + main.cpp +) + +# Additionnal libraries path +target_link_directories(quick_start_centralsystem20 PRIVATE ${BIN_DIR}) + +# Dependencies +target_link_libraries(quick_start_centralsystem20 + examples_common20 + centralsystem20 +) + + +# Copy to binary directory +ADD_CUSTOM_COMMAND(TARGET quick_start_centralsystem20 + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_LIST_DIR}/config/quick_start_centralsystem20.ini ${BIN_DIR}/ +) diff --git a/examples/ocpp20/quick_start_centralsystem/README.md b/examples/ocpp20/quick_start_centralsystem/README.md new file mode 100644 index 00000000..269e670e --- /dev/null +++ b/examples/ocpp20/quick_start_centralsystem/README.md @@ -0,0 +1,20 @@ +# Quick start Central System OCPP2.0.1 example + +## Description + +This example simulates a central system which accepts any charge point. + +The central system loops on its connected charge points. For each charge point it simulates the following operations : + +* Get configuration +* Set heartbeat interval to 10s +* Trigger messages : status notification, meter values, heartbeat + +There is a 10s break between 2 charge points communication. + +## Command line + +quick_start_centralsystem20 [-w working_dir] [-r] + +* -w : Working directory where to store the configuration file (Default = current directory) +* -r : Reset all the OCPP persistent data diff --git a/examples/ocpp20/quick_start_centralsystem/config/quick_start_centralsystem20.ini b/examples/ocpp20/quick_start_centralsystem/config/quick_start_centralsystem20.ini new file mode 100644 index 00000000..86923436 --- /dev/null +++ b/examples/ocpp20/quick_start_centralsystem/config/quick_start_centralsystem20.ini @@ -0,0 +1,19 @@ +[CentralSystem] +DatabasePath=./quick_start_centralsystem20.db +JsonSchemasPath=../../schemas/ocpp20/ +ListenUrl=wss://127.0.0.1:9090/openocpp/ +CallRequestTimeout=2000 +WebSocketPingInterval=30 +BootNotificationRetryInterval=30 +HeartbeatInterval=3600 +HttpBasicAuthent=false +Tlsv12CipherList=ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:PSK-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES128-GCM-SHA256:PSK-AES128-GCM-SHA256 +Tlsv13CipherList=TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384 +TlsEcdhCurve=prime256v1 +TlsServerCertificate=../../examples/certificates/open-ocpp_central-system.crt +TlsServerCertificatePrivateKey=../../examples/certificates/open-ocpp_central-system.key +TlsServerCertificatePrivateKeyPassphrase= +TlsServerCertificateCa=../../examples/certificates/open-ocpp_ca.crt +TlsClientCertificateAuthent=true +LogMaxEntriesCount=2000 +IncomingRequestsFromCpThreadPoolSize=10 diff --git a/examples/ocpp20/quick_start_centralsystem/main.cpp b/examples/ocpp20/quick_start_centralsystem/main.cpp new file mode 100644 index 00000000..fe4df572 --- /dev/null +++ b/examples/ocpp20/quick_start_centralsystem/main.cpp @@ -0,0 +1,206 @@ +/* +MIT License + +Copyright (c) 2020 Cedric Jimenez + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + +#include "CentralSystemDemoConfig.h" +#include "DefaultCentralSystemEventsHandler.h" +#include "ICentralSystem20.h" + +#include +#include +#include +#include + +using namespace ocpp::centralsystem::ocpp20; +using namespace ocpp::types; +using namespace ocpp::types::ocpp20; +using namespace ocpp::messages; +using namespace ocpp::messages::ocpp20; + +/** @brief Entry point */ +int main(int argc, char* argv[]) +{ + // Default parameters + std::string working_dir = ""; + bool reset_all = false; + + // Check parameters + if (argc > 1) + { + const char* param = nullptr; + bool bad_param = false; + argv++; + while ((argc != 1) && !bad_param) + { + if (strcmp(*argv, "-h") == 0) + { + bad_param = true; + } + else if ((strcmp(*argv, "-w") == 0) && (argc > 1)) + { + argv++; + argc--; + working_dir = *argv; + } + else if (strcmp(*argv, "-r") == 0) + { + reset_all = true; + } + else + { + param = *argv; + bad_param = true; + } + + // Next param + argc--; + argv++; + } + if (bad_param) + { + if (param) + { + std::cout << "Invalid parameter : " << param << std::endl; + } + std::cout << "Usage : quick_start_centralsystem20 [-w working_dir] [-r]" << std::endl; + std::cout << " -w : Working directory where to store the configuration file (Default = current directory)" << std::endl; + std::cout << " -r : Reset all the OCPP persistent data" << std::endl; + return 1; + } + } + + std::cout << "Starting central system with :" << std::endl; + std::cout << " - working_dir = " << working_dir << std::endl; + + // Configuration + std::filesystem::path path(working_dir); + path /= "quick_start_centralsystem20.ini"; + CentralSystemDemoConfig config(path.string()); + + // Event handler + DefaultCentralSystemEventsHandler event_handler(config); + + // Instanciate central system + std::unique_ptr central_system = ICentralSystem20::create(config.stackConfig(), event_handler); + if (reset_all) + { + central_system->resetData(); + } + central_system->start(); + + // From now on the stack is alive :) + + // App loop + while (true) + { + // Wait for at least 1 connected charge point + while (event_handler.chargePoints().size() == 0) + { + std::this_thread::sleep_for(std::chrono::milliseconds(250)); + } + std::this_thread::sleep_for(std::chrono::seconds(1)); + + // For each connected charge point + auto connected_chargepoints = event_handler.chargePoints(); + for (auto& iter_chargepoint : connected_chargepoints) + { + { + std::string error; + std::string error_msg; + auto chargepoint = iter_chargepoint.second->proxy(); + + std::cout << "---------------------------------------------" << std::endl; + std::cout << "Charge point : " << chargepoint->identifier() << std::endl; + std::cout << "---------------------------------------------" << std::endl; + + std::cout << "Read whole charge point configuration..." << std::endl; + GetBaseReportReq get_base_report_req; + GetBaseReportConf get_base_report_conf; + get_base_report_req.requestId = std::chrono::system_clock::now().time_since_epoch().count(); + get_base_report_req.reportBase = ReportBaseEnumType::ConfigurationInventory; + if (!chargepoint->call(get_base_report_req, get_base_report_conf, error, error_msg)) + { + std::cout << "Failed : error = " << error << " error_msg = " << error_msg << std::endl; + } + + std::cout << "Configure heartbeat interval..." << std::endl; + SetVariablesReq set_vars_req; + SetVariablesConf set_vars_conf; + SetVariableDataType var; + var.variable.name.assign("HeartbeatInterval"); + var.component.name.assign("OCPPCommCtrlr"); + var.attributeValue.assign("10"); + set_vars_req.setVariableData.push_back(std::move(var)); + if (chargepoint->call(set_vars_req, set_vars_conf, error, error_msg)) + { + std::cout << "Done!" << std::endl; + } + else + { + std::cout << "Failed : error = " << error << " error_msg = " << error_msg << std::endl; + } + + std::cout << "Trigger status notification..." << std::endl; + TriggerMessageReq trigger_msg_req; + TriggerMessageConf trigger_msg_conf; + trigger_msg_req.requestedMessage = MessageTriggerEnumType::StatusNotification; + if (chargepoint->call(trigger_msg_req, trigger_msg_conf, error, error_msg)) + { + std::cout << "Done!" << std::endl; + } + else + { + std::cout << "Failed : error = " << error << " error_msg = " << error_msg << std::endl; + } + + std::cout << "Trigger meter values on evse 1..." << std::endl; + trigger_msg_req.evse.value().id = 1; + trigger_msg_req.requestedMessage = MessageTriggerEnumType::MeterValues; + if (chargepoint->call(trigger_msg_req, trigger_msg_conf, error, error_msg)) + { + std::cout << "Done!" << std::endl; + } + else + { + std::cout << "Failed : error = " << error << " error_msg = " << error_msg << std::endl; + } + + std::cout << "Trigger heartbeat..." << std::endl; + trigger_msg_req.evse.clear(); + trigger_msg_req.requestedMessage = MessageTriggerEnumType::Heartbeat; + if (chargepoint->call(trigger_msg_req, trigger_msg_conf, error, error_msg)) + { + std::cout << "Done!" << std::endl; + } + else + { + std::cout << "Failed : error = " << error << " error_msg = " << error_msg << std::endl; + } + } + + std::this_thread::sleep_for(std::chrono::seconds(10)); + } + } + + return 0; +} diff --git a/examples/ocpp20/quick_start_chargepoint/CMakeLists.txt b/examples/ocpp20/quick_start_chargepoint/CMakeLists.txt new file mode 100644 index 00000000..0786885d --- /dev/null +++ b/examples/ocpp20/quick_start_chargepoint/CMakeLists.txt @@ -0,0 +1,27 @@ +###################################################### +# Quick start charge point example project # +###################################################### + +# Executable target +add_executable(quick_start_chargepoint20 + main.cpp +) + +# Additionnal libraries path +target_link_directories(quick_start_chargepoint20 PRIVATE ${BIN_DIR}) + +# Dependencies +target_link_libraries(quick_start_chargepoint20 + examples_common20 +) + + +# Copy to binary directory +ADD_CUSTOM_COMMAND(TARGET quick_start_chargepoint20 + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_LIST_DIR}/config/quick_start_chargepoint20.ini ${BIN_DIR}/ +) +ADD_CUSTOM_COMMAND(TARGET quick_start_chargepoint20 + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_LIST_DIR}/config/quick_start_chargepoint20.json ${BIN_DIR}/ +) diff --git a/examples/ocpp20/quick_start_chargepoint/README.md b/examples/ocpp20/quick_start_chargepoint/README.md new file mode 100644 index 00000000..9e6ff363 --- /dev/null +++ b/examples/ocpp20/quick_start_chargepoint/README.md @@ -0,0 +1,21 @@ +# Quick start Charge Point OCPP 2.0.1 example + +## Description + +This example simulates a charge point which start a charging session locally with an id tag. + +The charge point loops on its connectors. For each connector it simulates the following operations : + +* Id tag authorization +* Status notifications (Preparing, Charging, Finishing, Available) +* Transaction start/stop + +Each charging sessions lasts 30s and there is a 10s break between 2 charging sessions. + +## Command line + +quick_start_chargepoint [-t id_tag] [-w working_dir] [-r] [-d] + +* -t : Id tag to use (Default = AABBCCDDEEFF) +* -w : Working directory where to store the configuration file (Default = current directory) +* -r : Reset all the OCPP persistent data diff --git a/examples/ocpp20/quick_start_chargepoint/config/quick_start_chargepoint20.ini b/examples/ocpp20/quick_start_chargepoint/config/quick_start_chargepoint20.ini new file mode 100644 index 00000000..62744e1a --- /dev/null +++ b/examples/ocpp20/quick_start_chargepoint/config/quick_start_chargepoint20.ini @@ -0,0 +1,202 @@ +[ChargePoint] +DatabasePath=./quick_start_chargepoint20.db +JsonSchemasPath=../../schemas/ocpp20/ +ConnexionUrl=wss://127.0.0.1:9090/openocpp/ +Tlsv12CipherList=ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:PSK-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES128-GCM-SHA256:PSK-AES128-GCM-SHA256 +Tlsv13CipherList=TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384 +TlsServerCertificateCa=../../examples/certificates/open-ocpp_ca.crt +TlsClientCertificate=../../examples/certificates/open-ocpp_charge-point.crt +TlsClientCertificatePrivateKey=../../examples/certificates/open-ocpp_charge-point.key +TlsClientCertificatePrivateKeyPassphrase= +TlsAllowSelfSignedCertificates=false +TlsAllowExpiredCertificates=false +TlsAcceptNonTrustedCertificates=false +TlsSkipServerNameCheck=false +ChargePointIdentifier=ChargePointTest +ConnectionTimeout=2000 +RetryInterval=1000 +CallRequestTimeout=2000 +LogMaxEntriesCount=2000 +WebSocketPingInterval=10 +SecurityProfile=0 +BasicAuthPassword=P@ssw0rd! +ChargePointModel=Open OCPP CP +ChargePointVendor=Open OCPP +ChargePointSerialNumber=S/N0123456789 +FirmwareVersion=0.1 +Iccid= +Imsi= + +[TxCtrlr] +TxStopPoint=EVConnected,Authorized +TxStartPoint=PowerPathClosed +TxBeforeAcceptedEnabled=false +StopTxOnInvalidId=true +MaxEnergyOnInvalidId=0 +StopTxOnEVSideDisconnect=true +EVConnectionTimeOut=30 +[TariffCostCtrlr] +TotalCostFallbackMessage= +Enabled.Tariff=false +Enabled.Cost=false +Currency=eur +Available.Tariff=false +TariffFallbackMessage= +Available.Cost=false +[SmartChargingCtrlr] +RateUnit=A +ProfileStackLevel=100 +Phases3to1=false +NotifyChargingLimitWithSchedules=false +LimitChangeSignificance=0 +ExternalControlSignalsEnabled=false +Entries=100 +PeriodsPerSchedule=100 +Enabled=true +Available=true +ACPhaseSwitchingSupported=false +[SampledDataCtrlr] +TxEndedInterval=0 +TxEndedMeasurands= +SignReadings=false +TxUpdatedMeasurands= +Enabled=true +TxUpdatedInterval=0 +TxStartedMeasurands= +Available=false +[ReservationCtrlr] +NonEvseSpecific=false +Enabled=true +Available=true +[LocalAuthListCtrlr] +SupportsExpiryDateTime=true +Storage=1000000 +ItemsPerMessage=200 +Enabled=true +Entries=1000 +DisablePostAuthorize=true +BytesPerMessage=10000 +Available=true +[EVSE.EVSE 1.1] +SupplyPhases=3 +Power=22000 +PhaseRotation=RST +Available=true +AvailabilityState=Available +AllowReset=false +[SecurityCtrlr] +MaxCertificateChainSize=10000 +Identity=ChargePointTest +CertificateEntries=20 +CertSigningWaitMinimum=30 +CertSigningRepeatTimes=3 +BasicAuthPassword= +SecurityProfile=0 +OrganizationName= +AdditionalRootCertificateCheck=false +[AuthCacheCtrlr] +Storage=1000000 +Policy=LRU +LifeTime=86400 +Enabled=true +DisablePostAuthorize=false +Available=true +[OCPPCommCtrlr] +WebSocketPingInterval=10 +RetryBackOffRepeatTimes=10 +HeartbeatInterval=60 +MessageAttemptIntervalTransactionEvent.TransactionEvent=30 +UnlockOnEVSideDisconnect=true +ActiveNetworkProfile=0 +FieldLength..= +FileTransferProtocols=FTP,FTPS,HTTP,HTTPS +MessageAttemptsTransactionEvent.TransactionEvent= +RetryBackOffWaitMinimum=30 +OfflineThreshold=300 +NetworkConfigurationPriority=0,1,2 +NetworkProfileConnectionAttempts=3 +MessageTimeout.Default=10 +RetryBackOffRandomRange=30 +QueueAllMessages=false +ResetRetries=3 +[Connector.1.1] +SupplyPhases=3 +Power=22000 +PhaseRotation=RST +ConnectorType=cType2 +Available=true +AvailabilityState=true +[DeviceDataCtrlr] +ReportingValueSize= +ItemsPerMessage.GetReport=100 +BytesPerMessage.SetVariables=10000 +ConfigurationValueSize=1000 +BytesPerMessage.GetVariables=10000 +ItemsPerMessage.SetVariables=100 +ItemsPerMessage.GetVariables=100 +BytesPerMessage.GetReport=10000 +[AuthCtrlr] +OfflineTxForUnknownIdEnabled=false +LocalPreAuthorize=true +LocalAuthorizeOffline=true +MasterPassGroupId= +Enabled=true +DisableRemoteAuthorization=false +AuthorizeRemoteStart=true +AdditionalInfoItemsPerMessage=10 +[ChargingStation] +Available=true +AllowNewSessionsPendingFirmwareUpdate=false +[AlignedDataCtrlr] +TxEndedInterval=0 +TxEndedMeasurands= +SignReadings=false +PublicKeyWithSignedMeterValue= +Measurands= +RegisterValuesWithoutPhases=true +Interval=0 +Enabled=true +Available=true +[ISO15118Ctrlr] +V2GCertificateInstallationEnabled=true +RequestMeteringReceipt=false +PnCEnabled=false +ContractValidationOffline=false +ContractCertificateInstallationEnabled=true +CentralContractValidationAllowed=true +[CustomizationCtrlr] +CustomImplementationEnabled.= +[MonitoringCtrlr] +OfflineQueuingSeverity=0 +ItemsPerMessage.ClearVariableMonitoring=100 +Enabled=true +BytesPerMessage.SetVariableMonitoring=10000 +BytesPerMessage.ClearVariableMonitoring=10000 +Available=true +ItemsPerMessage.SetVariableMonitoring=100 +ActiveMonitoringLevel=0 +ActiveMonitoringBase=All +[AlignedDataCtrlr.1] +SendDuringIdle=false +[DisplayMessageCtrlr] +SupportedPriorities=AlwaysFront +SupportedFormats=ASCII,UTF8 +Enabled=true +DisplayMessages=10 +Available=true +[ClockCtrlr] +TimeZone=Europe/Paris +TimeSource=Heartbeat +TimeOffset=+01:00 +dateTime= +TimeAdjustmentReportingThreshold=5 +NtpSource=manual +NtpServerUri.1= +NextTimeOffsetTransitionDateTime= +[ISO15118Ctrlr.1] +SeccId= +ProtocolAgreed= +ProtocolSupportedByEV= +OrganizationName= +ISO15118EvseId= +CountryName= \ No newline at end of file diff --git a/examples/ocpp20/quick_start_chargepoint/config/quick_start_chargepoint20.json b/examples/ocpp20/quick_start_chargepoint/config/quick_start_chargepoint20.json new file mode 100644 index 00000000..0b341df3 --- /dev/null +++ b/examples/ocpp20/quick_start_chargepoint/config/quick_start_chargepoint20.json @@ -0,0 +1,2022 @@ +{ + "components": [ + { + "name": "AlignedDataCtrlr", + "variables": [ + { + "name": "Enabled", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "Available", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "Measurands", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "MemberList", + "max_limit": 100 + }, + "required": true + }, + { + "name": "Interval", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "integer", + "unit": "s" + }, + "required": true + }, + { + "name": "SignReadings", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "TxEndedMeasurands", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "MemberList", + "max_limit": 100 + }, + "required": true + }, + { + "name": "TxEndedInterval", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "integer", + "unit": "s" + }, + "required": true + }, + { + "name": "PublicKeyWithSignedMeterValue", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "OptionList", + "values_list": "Never,OncePerTransaction,EveryMeterValue" + }, + "required": false + }, + { + "name": "RegisterValuesWithoutPhases", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + } + ] + }, + { + "name": "AlignedDataCtrlr", + "evse": 1, + "variables": [ + { + "name": "SendDuringIdle", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + } + ] + }, + { + "name": "AuthCacheCtrlr", + "variables": [ + { + "name": "Enabled", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "Available", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "LifeTime", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "integer", + "unit": "s" + }, + "required": false + }, + { + "name": "Storage", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer", + "max_limit": 1000000 + }, + "required": false + }, + { + "name": "Policy", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "OptionList", + "values_list": "LRU,LFU,FIFO,CUSTOM" + }, + "required": false + }, + { + "name": "DisablePostAuthorize", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + } + ] + }, + { + "name": "AuthCtrlr", + "variables": [ + { + "name": "Enabled", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "AdditionalInfoItemsPerMessage", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": false + }, + { + "name": "OfflineTxForUnknownIdEnabled", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "AuthorizeRemoteStart", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": true + }, + { + "name": "LocalAuthorizeOffline", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": true + }, + { + "name": "LocalPreAuthorize", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": true + }, + { + "name": "MasterPassGroupId", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "string", + "max_limit": 36 + }, + "required": false + }, + { + "name": "DisableRemoteAuthorization", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + } + ] + }, + { + "name": "ClockCtrlr", + "variables": [ + { + "name": "dateTime", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "dateTime" + }, + "required": true + }, + { + "name": "NtpSource", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "OptionList", + "values_list": "DHCP,manual" + }, + "required": false + }, + { + "name": "NtpServerUri", + "instance": "1", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "string" + }, + "required": false + }, + { + "name": "TimeOffset", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "string" + }, + "required": false + }, + { + "name": "NextTimeOffsetTransitionDateTime", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "dateTime" + }, + "required": false + }, + { + "name": "TimeOffset", + "instance": "1", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "string" + }, + "required": false + }, + { + "name": "TimeSource", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "SequenceList", + "values_list": "Heartbeat,NTP,GPS,RealTimeClock,MobileNetwork,RadioTimeTransmitter" + }, + "required": true + }, + { + "name": "TimeZone", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "string" + }, + "required": false + }, + { + "name": "TimeAdjustmentReportingThreshold", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "integer", + "unit": "s" + }, + "required": false + } + ] + }, + { + "name": "CustomizationCtrlr", + "variables": [ + { + "name": "CustomImplementationEnabled", + "instance": "", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + } + ] + }, + { + "name": "DeviceDataCtrlr", + "variables": [ + { + "name": "ItemsPerMessage", + "instance": "GetReport", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": true + }, + { + "name": "ItemsPerMessage", + "instance": "GetVariables", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": true + }, + { + "name": "BytesPerMessage", + "instance": "GetReport", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": true + }, + { + "name": "BytesPerMessage", + "instance": "GetVariables", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": true + }, + { + "name": "ConfigurationValueSize", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer", + "max_limit": 1000 + }, + "required": false + }, + { + "name": "ReportingValueSize", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer", + "max_limit": 2500 + }, + "required": false + }, + { + "name": "ItemsPerMessage", + "instance": "SetVariables", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": true + }, + { + "name": "BytesPerMessage", + "instance": "SetVariables", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": true + } + ] + }, + { + "name": "DisplayMessageCtrlr", + "variables": [ + { + "name": "Enabled", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "Available", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "DisplayMessages", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer", + "max_limit": 10 + }, + "required": true + }, + { + "name": "SupportedFormats", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "MemberList", + "values_list": "ASCII,HTML,URI,UTF8" + }, + "required": true + }, + { + "name": "SupportedPriorities", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "MemberList", + "values_list": "AlwaysFront,InFront,NormalCycle" + }, + "required": true + } + ] + }, + { + "name": "ISO15118Ctrlr", + "variables": [ + { + "name": "CentralContractValidationAllowed", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "ContractValidationOffline", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": true + }, + { + "name": "PnCEnabled", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "V2GCertificateInstallationEnabled", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "ContractCertificateInstallationEnabled", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "RequestMeteringReceipt", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + } + ] + }, + { + "name": "ISO15118Ctrlr", + "evse": 1, + "variables": [ + { + "name": "ProtocolSupportedByEV", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "string" + }, + "required": false + }, + { + "name": "ProtocolAgreed", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "string" + }, + "required": false + }, + { + "name": "SeccId", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "string" + }, + "required": false + }, + { + "name": "CountryName", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "string" + }, + "required": false + }, + { + "name": "OrganizationName", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "string" + }, + "required": false + }, + { + "name": "ISO15118EvseId", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "string" + }, + "required": false + } + ] + }, + { + "name": "LocalAuthListCtrlr", + "variables": [ + { + "name": "Enabled", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "Entries", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer", + "max_limit": 10000 + }, + "required": false + }, + { + "name": "Available", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "ItemsPerMessage", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": false + }, + { + "name": "BytesPerMessage", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": false + }, + { + "name": "Storage", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer", + "max_limit": 1000000 + }, + "required": false + }, + { + "name": "DisablePostAuthorize", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "SupportsExpiryDateTime", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + } + ] + }, + { + "name": "MonitoringCtrlr", + "variables": [ + { + "name": "Enabled", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "Available", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "ItemsPerMessage", + "instance": "ClearVariableMonitoring", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": false + }, + { + "name": "ItemsPerMessage", + "instance": "SetVariableMonitoring", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": true + }, + { + "name": "BytesPerMessage", + "instance": "ClearVariableMonitoring", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": false + }, + { + "name": "BytesPerMessage", + "instance": "SetVariableMonitoring", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": true + }, + { + "name": "OfflineQueuingSeverity", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": false + }, + { + "name": "ActiveMonitoringBase", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "OptionList", + "values_list": "All,FactoryDefault,HardwiredOnly" + }, + "required": false + }, + { + "name": "ActiveMonitoringLevel", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer", + "min_limit": 0, + "max_limit": 9 + }, + "required": false + } + ] + }, + { + "name": "OCPPCommCtrlr", + "variables": [ + { + "name": "ActiveNetworkProfile", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": false + }, + { + "name": "MessageTimeout", + "instance": "Default", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer", + "unit": "s" + }, + "required": true + }, + { + "name": "FileTransferProtocols", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "MemberList" + }, + "required": true + }, + { + "name": "HeartbeatInterval", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "integer", + "unit": "s", + "min_limit": 1 + }, + "required": false + }, + { + "name": "NetworkConfigurationPriority", + "attributes": + { + "mutability": "ReadWrite", + "type": "Actual" + }, + "characteristics": + { + "data_type": "SequenceList", + "values_list": "" + }, + "required": true + }, + { + "name": "NetworkProfileConnectionAttempts", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": true + }, + { + "name": "OfflineThreshold", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "integer", + "unit": "s", + "min_limit": 1 + }, + "required": true + }, + { + "name": "QueueAllMessages", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "MessageAttemptsTransactionEvent", + "instance": "TransactionEvent", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": true + }, + { + "name": "MessageAttemptIntervalTransactionEvent", + "instance": "TransactionEvent", + "attributes": + { + "mutability": "ReadWrite", + "type": "Actual" + }, + "characteristics": + { + "data_type": "integer", + "unit": "s" + }, + "required": true + }, + { + "name": "UnlockOnEVSideDisconnect", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": true + }, + { + "name": "ResetRetries", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": true + }, + { + "name": "FieldLength", + "instance": ".", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": false + }, + { + "name": "RetryBackOffRepeatTimes", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": true + }, + { + "name": "RetryBackOffRandomRange", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "integer", + "unit": "s" + }, + "required": true + }, + { + "name": "RetryBackOffWaitMinimum", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "integer", + "unit": "s" + }, + "required": true + }, + { + "name": "WebSocketPingInterval", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "integer", + "unit": "s" + }, + "required": true + } + ] + }, + { + "name": "ReservationCtrlr", + "variables": [ + { + "name": "Enabled", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "Available", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "NonEvseSpecific", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + } + ] + }, + { + "name": "SampledDataCtrlr", + "variables": [ + { + "name": "Enabled", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "Available", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "SignReadings", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "TxEndedMeasurands", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "MemberList", + "max_limit": 100 + }, + "required": true + }, + { + "name": "TxEndedInterval", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "integer", + "unit": "s" + }, + "required": true + }, + { + "name": "TxStartedMeasurands", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "MemberList", + "max_limit": 100 + }, + "required": true + }, + { + "name": "TxUpdatedMeasurands", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "MemberList", + "max_limit": 100 + }, + "required": true + }, + { + "name": "TxUpdatedInterval", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "integer", + "unit": "s" + }, + "required": true + } + ] + }, + { + "name": "SecurityCtrlr", + "variables": [ + { + "name": "BasicAuthPassword", + "attributes": + { + "mutability": "WriteOnly" + }, + "characteristics": + { + "data_type": "string", + "max_limit": 40 + }, + "required": false + }, + { + "name": "Identity", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "string", + "max_limit": 48 + }, + "required": false + }, + { + "name": "OrganizationName", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "string" + }, + "required": true + }, + { + "name": "CertificateEntries", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer", + "max_limit": 20 + }, + "required": true + }, + { + "name": "SecurityProfile", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": true + }, + { + "name": "AdditionalRootCertificateCheck", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "MaxCertificateChainSize", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer", + "max_limit": 10000 + }, + "required": false + }, + { + "name": "CertSigningWaitMinimum", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "integer", + "unit": "s" + }, + "required": false + }, + { + "name": "CertSigningRepeatTimes", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": false + } + ] + }, + { + "name": "SmartChargingCtrlr", + "variables": [ + { + "name": "Enabled", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "Available", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "ACPhaseSwitchingSupported", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "ProfileStackLevel", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": true + }, + { + "name": "RateUnit", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "MemberList", + "values_list": "A,W" + }, + "required": true + }, + { + "name": "PeriodsPerSchedule", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": true + }, + { + "name": "ExternalControlSignalsEnabled", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "NotifyChargingLimitWithSchedules", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "Phases3to1", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "Entries", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer", + "max_limit": 100 + }, + "required": true + }, + { + "name": "LimitChangeSignificance", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "decimal" + }, + "required": true + } + ] + }, + { + "name": "TariffCostCtrlr", + "variables": [ + { + "name": "Enabled", + "instance": "Tariff", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "Available", + "instance": "Tariff", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "TariffFallbackMessage", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "string", + "max_limit": 255 + }, + "required": true + }, + { + "name": "Enabled", + "instance": "Cost", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "Available", + "instance": "Cost", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "TotalCostFallbackMessage", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "string", + "max_limit": 255 + }, + "required": true + }, + { + "name": "Currency", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "string", + "max_limit": 3 + }, + "required": true + } + ] + }, + { + "name": "TxCtrlr", + "variables": [ + { + "name": "EVConnectionTimeOut", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "integer", + "unit": "s" + }, + "required": true + }, + { + "name": "StopTxOnEVSideDisconnect", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": true + }, + { + "name": "TxBeforeAcceptedEnabled", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "TxStartPoint", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "MemberList", + "values_list": "ParkingBayOccupancy,EVConnected,Authorized,PowerPathClosed,EnergyTransfer,DataSigned" + }, + "required": true + }, + { + "name": "TxStopPoint", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "MemberList", + "values_list": "ParkingBayOccupancy,EVConnected,Authorized,PowerPathClosed,EnergyTransfer,DataSigned" + }, + "required": true + }, + { + "name": "MaxEnergyOnInvalidId", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "integer", + "unit": "Wh" + }, + "required": false + }, + { + "name": "StopTxOnInvalidId", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": true + } + ] + }, + { + "name": "ChargingStation", + "variables": [ + { + "name": "AllowNewSessionsPendingFirmwareUpdate", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "Available", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": true + } + ] + }, + { + "name": "EVSE", + "instance": "EVSE 1", + "evse": 1, + "variables": [ + { + "name": "Available", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": true + }, + { + "name": "AvailabilityState", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "OptionList", + "values_list": "Available,Occupied,Reserved,Unavailable,Faulted" + }, + "required": true + }, + { + "name": "AllowReset", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "PhaseRotation", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "string" + }, + "required": false + }, + { + "name": "SupplyPhases", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": true + }, + { + "name": "Power", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "decimal" + }, + "required": true + } + ] + }, + { + "name": "Connector", + "evse": 1, + "connector": 1, + "variables": [ + { + "name": "Available", + + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": true + }, + { + "name": "AvailabilityState", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "OptionList", + "values_list": "Available,Occupied,Reserved,Unavailable,Faulted" + }, + "required": true + }, + { + "name": "ConnectorType", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "string", + "values_list": "cCCS1,cCCS2,cG105,cTesla,cType1,cType2,s309-1P-16A,s309-1P-32A,s309-3P-16A,s309-3P-32A,sBS1361,sCEE-7-7,sType2,sType3,Other1PhMax16A,Other1PhOver16A,Other3Ph,Pan,wInductive,wResonant,Undetermined,Unknown,cGBT,cChaoJi,OppCharge" + }, + "required": true + }, + { + "name": "PhaseRotation", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "string" + }, + "required": false + }, + { + "name": "SupplyPhases", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": true + }, + { + "name": "Power", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "decimal" + }, + "required": true + } + ] + } + ] +} \ No newline at end of file diff --git a/examples/ocpp20/quick_start_chargepoint/main.cpp b/examples/ocpp20/quick_start_chargepoint/main.cpp new file mode 100644 index 00000000..a8735f70 --- /dev/null +++ b/examples/ocpp20/quick_start_chargepoint/main.cpp @@ -0,0 +1,313 @@ +/* +MIT License + +Copyright (c) 2020 Cedric Jimenez + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + +#include "ChargePointDemoConfig.h" +#include "DefaultChargePointEventsHandler.h" +#include "DeviceModelManager20.h" +#include "IChargePoint20.h" + +#include +#include +#include +#include +#include + +using namespace ocpp::chargepoint::ocpp20; +using namespace ocpp::types; +using namespace ocpp::types::ocpp20; +using namespace ocpp::messages; +using namespace ocpp::messages::ocpp20; + +/** @brief Entry point */ +int main(int argc, char* argv[]) +{ + // Default parameters + std::string id_tag = "AABBCCDDEEFF"; + std::string working_dir = ""; + bool reset_all = false; + + // Check parameters + if (argc > 1) + { + const char* param = nullptr; + bool bad_param = false; + argv++; + while ((argc != 1) && !bad_param) + { + if (strcmp(*argv, "-h") == 0) + { + bad_param = true; + } + else if ((strcmp(*argv, "-t") == 0) && (argc > 1)) + { + argv++; + argc--; + id_tag = *argv; + } + else if ((strcmp(*argv, "-w") == 0) && (argc > 1)) + { + argv++; + argc--; + working_dir = *argv; + } + else if (strcmp(*argv, "-r") == 0) + { + reset_all = true; + } + else + { + param = *argv; + bad_param = true; + } + + // Next param + argc--; + argv++; + } + if (bad_param) + { + if (param) + { + std::cout << "Invalid parameter : " << param << std::endl; + } + std::cout << "Usage : quick_start_chargepoint20 [-t id_tag] [-w working_dir] [-r] [-d]" << std::endl; + std::cout << " -t : Id tag to use (Default = AABBCCDDEEFF)" << std::endl; + std::cout << " -w : Working directory where to store the configuration file (Default = current directory)" << std::endl; + std::cout << " -r : Reset all the OCPP persistent data" << std::endl; + return 1; + } + } + + std::cout << "Starting charge point with :" << std::endl; + std::cout << " - id_tag = " << id_tag << std::endl; + std::cout << " - working_dir = " << working_dir << std::endl; + + // Configuration + std::filesystem::path path(working_dir); + path /= "quick_start_chargepoint20.ini"; + ChargePointDemoConfig config(path.string()); + + // Device model + std::filesystem::path device_model_path(working_dir); + device_model_path /= "quick_start_chargepoint20.json"; + DeviceModelManager device_model_mgr(config.stackConfig()); + if (device_model_mgr.init()) + { + if (!device_model_mgr.load(device_model_path)) + { + std::cout << "Unable to load device model : " << device_model_mgr.lastError() << std::endl; + } + } + else + { + std::cout << "Unable to initialize device model loader : " << device_model_mgr.lastError() << std::endl; + } + + // Event handler + DefaultChargePointEventsHandler event_handler(config, device_model_mgr, working_dir); + + // Instanciate charge point + std::unique_ptr charge_point = IChargePoint20::create(config.stackConfig(), event_handler); + if (reset_all) + { + charge_point->resetData(); + } + event_handler.setChargePoint(*charge_point.get()); + charge_point->start(); + + // From now on the stack is alive :) + + // App loop + std::string error; + std::string error_msg; + + auto last_boot_notif = std::chrono::steady_clock::time_point(); + std::chrono::seconds hb_boot_notif_interval = std::chrono::seconds(10); + RegistrationStatusEnumType registration_status = RegistrationStatusEnumType::Rejected; + + unsigned int transaction_id = std::chrono::system_clock::now().time_since_epoch().count(); + + while (true) + { + // Wait to be connected to the Central System + std::cout << "Waiting connection to Central System..." << std::endl; + while (!event_handler.isConnected()) + { + std::this_thread::sleep_for(std::chrono::milliseconds(100u)); + } + std::cout << "Connected to Central System!" << std::endl; + + // Wait to be accepted by Central System + while (registration_status != RegistrationStatusEnumType::Accepted) + { + // Send boot notification message periodically + auto now = std::chrono::steady_clock::now(); + if ((now - last_boot_notif) >= hb_boot_notif_interval) + { + std::cout << "Sending BootNotification request..." << std::endl; + + BootNotificationReq boot_notif_req; + BootNotificationConf boot_notif_conf; + boot_notif_req.reason = BootReasonEnumType::PowerUp; + boot_notif_req.chargingStation.vendorName.assign(config.stackConfig().chargePointVendor()); + boot_notif_req.chargingStation.model.assign(config.stackConfig().chargePointModel()); + boot_notif_req.chargingStation.firmwareVersion.value().assign(config.stackConfig().firmwareVersion()); + if (!config.stackConfig().iccid().empty()) + { + boot_notif_req.chargingStation.modem.value().iccid.value().assign(config.stackConfig().iccid()); + } + if (!config.stackConfig().imsi().empty()) + { + boot_notif_req.chargingStation.modem.value().imsi.value().assign(config.stackConfig().imsi()); + } + if (charge_point->call(boot_notif_req, boot_notif_conf, error, error_msg)) + { + registration_status = boot_notif_conf.status; + hb_boot_notif_interval = std::chrono::seconds(boot_notif_conf.interval); + } + else + { + std::cout << "Failed : error = " << error << " error_msg = " << error_msg << std::endl; + } + last_boot_notif = std::chrono::steady_clock::now(); + } + else + { + std::this_thread::sleep_for(std::chrono::milliseconds(100u)); + } + } + + // Test loop + while (event_handler.isConnected()) + { + // For each evse + for (unsigned int evse_id = 1u; evse_id <= 2u; evse_id++) + { + // For each connector + for (unsigned int connector_id = 1u; connector_id <= 3u; connector_id++) + { + // Ask for authorization on a tag + std::cout << "Checking for id tag " << id_tag << " authorization..." << std::endl; + AuthorizeReq authorize_req; + AuthorizeConf authorize_conf; + authorize_req.idToken.idToken.assign(id_tag); + authorize_req.idToken.type = IdTokenEnumType::ISO14443; + if (charge_point->call(authorize_req, authorize_conf, error, error_msg)) + { + if (authorize_conf.idTokenInfo.status == AuthorizationStatusEnumType::Accepted) + { + std::cout << "Id tag authorized" << std::endl; + + // Occupied state + StatusNotificationReq status_req; + StatusNotificationConf status_conf; + status_req.timestamp = DateTime::now(); + status_req.connectorStatus = ConnectorStatusEnumType::Occupied; + status_req.evseId = evse_id; + status_req.connectorId = connector_id; + charge_point->call(status_req, status_conf, error, error_msg); + std::this_thread::sleep_for(std::chrono::seconds(1u)); + + // Try to start charging session + transaction_id++; + + TransactionEventReq tx_event_req; + TransactionEventConf tx_event_conf; + tx_event_req.seqNo = 1; + tx_event_req.eventType = TransactionEventEnumType::Started; + tx_event_req.timestamp = DateTime::now(); + tx_event_req.triggerReason = TriggerReasonEnumType::Authorized; + tx_event_req.evse.value().id = evse_id; + tx_event_req.evse.value().connectorId = connector_id; + tx_event_req.transactionInfo.transactionId.assign(std::to_string(transaction_id)); + tx_event_req.transactionInfo.chargingState.value() = ChargingStateEnumType::EVConnected; + tx_event_req.idToken.value().idToken.assign(id_tag); + tx_event_req.idToken.value().type = IdTokenEnumType::ISO14443; + if (charge_point->call(tx_event_req, tx_event_conf, error, error_msg)) + { + if (!tx_event_conf.idTokenInfo.isSet() || + (tx_event_conf.idTokenInfo.value().status == AuthorizationStatusEnumType::Accepted)) + { + std::cout << "Transaction authorized, start charging" << std::endl; + + // Charging state + tx_event_req.seqNo++; + tx_event_req.eventType = TransactionEventEnumType::Updated; + tx_event_req.timestamp = DateTime::now(); + tx_event_req.triggerReason = TriggerReasonEnumType::CablePluggedIn; + tx_event_req.transactionInfo.chargingState.value() = ChargingStateEnumType::Charging; + tx_event_req.idToken.clear(); + charge_point->call(tx_event_req, tx_event_conf, error, error_msg); + std::this_thread::sleep_for(std::chrono::seconds(30u)); + + // End transaction + tx_event_req.seqNo++; + tx_event_req.eventType = TransactionEventEnumType::Ended; + tx_event_req.timestamp = DateTime::now(); + tx_event_req.triggerReason = TriggerReasonEnumType::EnergyLimitReached; + tx_event_req.transactionInfo.chargingState.value() = ChargingStateEnumType::Idle; + charge_point->call(tx_event_req, tx_event_conf, error, error_msg); + + std::this_thread::sleep_for(std::chrono::seconds(1u)); + } + else + { + std::cout << "Transaction not authorized by Central System : " + << AuthorizationStatusEnumTypeHelper.toString(tx_event_conf.idTokenInfo.value().status) + << std::endl; + } + } + else + { + std::cout << "Failed : error = " << error << " error_msg = " << error_msg << std::endl; + } + + // Available state + status_req.timestamp = DateTime::now(); + status_req.connectorStatus = ConnectorStatusEnumType::Available; + charge_point->call(status_req, status_conf, error, error_msg); + } + else + { + std::cout << "Id tag not authorized by Central System : " + << AuthorizationStatusEnumTypeHelper.toString(authorize_conf.idTokenInfo.status) << std::endl; + } + } + else + { + std::cout << "Failed : error = " << error << " error_msg = " << error_msg << std::endl; + } + + // Wait before next charging session + if (event_handler.isConnected()) + { + std::this_thread::sleep_for(std::chrono::seconds(10u)); + } + } + } + } + } + + return 0; +} diff --git a/examples/ocpp20/quick_start_localcontroller/CMakeLists.txt b/examples/ocpp20/quick_start_localcontroller/CMakeLists.txt new file mode 100644 index 00000000..be86f72c --- /dev/null +++ b/examples/ocpp20/quick_start_localcontroller/CMakeLists.txt @@ -0,0 +1,24 @@ +###################################################### +# Quick start local controller example project # +###################################################### + +# Executable target +add_executable(quick_start_localcontroller20 + main.cpp +) + +# Additionnal libraries path +target_link_directories(quick_start_localcontroller20 PRIVATE ${BIN_DIR}) + +# Dependencies +target_link_libraries(quick_start_localcontroller20 + examples_common20 + localcontroller20 +) + + +# Copy to binary directory +ADD_CUSTOM_COMMAND(TARGET quick_start_localcontroller20 + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_LIST_DIR}/config/quick_start_localcontroller20.ini ${BIN_DIR}/ +) diff --git a/examples/ocpp20/quick_start_localcontroller/README.md b/examples/ocpp20/quick_start_localcontroller/README.md new file mode 100644 index 00000000..3020c325 --- /dev/null +++ b/examples/ocpp20/quick_start_localcontroller/README.md @@ -0,0 +1,29 @@ +# Quick start Local Controller OCPP2.0.1 example + +## Description + +This example simulates a local controller which accepts any charge point and forwards all the requests from the Central System to the Charge Point and from the Charge Point to the Central System. + +The local controller loops on its connected charge points. For each charge point it simulates the following operations : + +* Get configuration +* Set heartbeat interval to 10s +* Trigger messages : status notification, meter values, heartbeat + +There is a 10s break between 2 charge points communication. + +## Command line + +quick_start_localcontroller20 [-w working_dir] [-r] + +* -w : Working directory where to store the configuration file (Default = current directory) +* -r : Reset all the OCPP persistent data + +## Quick start with existing examples + +1. Modify the ListenUrl parameter in the configuration file of the Quick Start Central System example to : ```ListenUrl=wss://127.0.0.1:8081/openocpp/``` +2. Start the Quick Start Central System Example +3. Start the Quick Start Local Controller Example +4. Start the Quick Start Charge Point Example + +The Charge Point will be connected to the Central System through the Local Controller. diff --git a/examples/ocpp20/quick_start_localcontroller/config/quick_start_localcontroller20.ini b/examples/ocpp20/quick_start_localcontroller/config/quick_start_localcontroller20.ini new file mode 100644 index 00000000..a49cc257 --- /dev/null +++ b/examples/ocpp20/quick_start_localcontroller/config/quick_start_localcontroller20.ini @@ -0,0 +1,23 @@ +[LocalController] +DatabasePath=./quick_start_localcontroller20.db +JsonSchemasPath=../../schemas/ocpp20/ +ListenUrl=wss://127.0.0.1:9090/openocpp/ +ConnexionUrl=wss://127.0.0.1:9091/openocpp/ +CallRequestTimeout=2000 +WebSocketPingInterval=30 +HttpBasicAuthent=false +Tlsv12CipherList=ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:PSK-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES128-GCM-SHA256:PSK-AES128-GCM-SHA256 +Tlsv13CipherList=TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384 +TlsEcdhCurve=prime256v1 +TlsServerCertificate=../../examples/certificates/open-ocpp_central-system.crt +TlsServerCertificatePrivateKey=../../examples/certificates/open-ocpp_central-system.key +TlsServerCertificatePrivateKeyPassphrase= +TlsServerCertificateCa=../../examples/certificates/open-ocpp_ca.crt +TlsClientCertificateAuthent=true +TlsClientCertificate=../../examples/certificates/open-ocpp_charge-point.crt +TlsClientCertificatePrivateKey=../../examples/certificates/open-ocpp_charge-point.key +TlsClientCertificatePrivateKeyPassphrase= +LogMaxEntriesCount=2000 +IncomingRequestsFromCpThreadPoolSize=10 +IncomingRequestsFromCsThreadPoolSize=10 +DisconnectFromCpWhenCsDisconnected=true diff --git a/examples/ocpp20/quick_start_localcontroller/main.cpp b/examples/ocpp20/quick_start_localcontroller/main.cpp new file mode 100644 index 00000000..1c0b9e54 --- /dev/null +++ b/examples/ocpp20/quick_start_localcontroller/main.cpp @@ -0,0 +1,210 @@ +/* +MIT License + +Copyright (c) 2020 Cedric Jimenez + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + +#include "DefaultLocalControllerEventsHandler.h" +#include "ILocalController20.h" +#include "LocalControllerDemoConfig.h" +#include "WebsocketFactory.h" + +#include +#include +#include +#include + +using namespace ocpp::localcontroller::ocpp20; +using namespace ocpp::messages; +using namespace ocpp::messages::ocpp20; +using namespace ocpp::types; +using namespace ocpp::types::ocpp20; + +/** @brief Entry point */ +int main(int argc, char* argv[]) +{ + // Default parameters + std::string working_dir = ""; + bool reset_all = false; + + // Check parameters + if (argc > 1) + { + const char* param = nullptr; + bool bad_param = false; + argv++; + while ((argc != 1) && !bad_param) + { + if (strcmp(*argv, "-h") == 0) + { + bad_param = true; + } + else if ((strcmp(*argv, "-w") == 0) && (argc > 1)) + { + argv++; + argc--; + working_dir = *argv; + } + else if (strcmp(*argv, "-r") == 0) + { + reset_all = true; + } + else + { + param = *argv; + bad_param = true; + } + + // Next param + argc--; + argv++; + } + if (bad_param) + { + if (param) + { + std::cout << "Invalid parameter : " << param << std::endl; + } + std::cout << "Usage : quick_start_localcontroller20 [-w working_dir] [-r]" << std::endl; + std::cout << " -w : Working directory where to store the configuration file (Default = current directory)" << std::endl; + std::cout << " -r : Reset all the OCPP persistent data" << std::endl; + return 1; + } + } + + std::cout << "Starting local controller with :" << std::endl; + std::cout << " - working_dir = " << working_dir << std::endl; + + // Configuration + std::filesystem::path path(working_dir); + path /= "quick_start_localcontroller20.ini"; + LocalControllerDemoConfig config(path.string()); + + // Event handler + DefaultLocalControllerEventsHandler event_handler(config.stackConfig()); + + // Configure websocket pools => mandatory for local controller + ocpp::websockets::WebsocketFactory::setClientPoolCount(2u); + ocpp::websockets::WebsocketFactory::startClientPools(); + + // Instanciate local controller + std::unique_ptr local_controller = ILocalController20::create(config.stackConfig(), event_handler); + if (reset_all) + { + local_controller->resetData(); + } + local_controller->start(); + + // From now on the stack is alive :) + + // App loop + while (true) + { + // Wait for at least 1 connected charge point + while (event_handler.chargePoints().size() == 0) + { + std::this_thread::sleep_for(std::chrono::milliseconds(250)); + } + std::this_thread::sleep_for(std::chrono::seconds(1)); + + // For each connected charge point + for (auto& iter_chargepoint : event_handler.chargePoints()) + { + { + std::string error; + std::string error_msg; + auto chargepoint = iter_chargepoint.second->proxy(); + + std::cout << "---------------------------------------------" << std::endl; + std::cout << "Charge point : " << chargepoint->identifier() << std::endl; + std::cout << "---------------------------------------------" << std::endl; + + std::cout << "Read whole charge point configuration..." << std::endl; + GetBaseReportReq get_base_report_req; + GetBaseReportConf get_base_report_conf; + get_base_report_req.requestId = std::chrono::system_clock::now().time_since_epoch().count(); + get_base_report_req.reportBase = ReportBaseEnumType::ConfigurationInventory; + if (!chargepoint->call(get_base_report_req, get_base_report_conf, error, error_msg)) + { + std::cout << "Failed : error = " << error << " error_msg = " << error_msg << std::endl; + } + + std::cout << "Configure heartbeat interval..." << std::endl; + SetVariablesReq set_vars_req; + SetVariablesConf set_vars_conf; + SetVariableDataType var; + var.variable.name.assign("HeartbeatInterval"); + var.component.name.assign("OCPPCommCtrlr"); + var.attributeValue.assign("10"); + set_vars_req.setVariableData.push_back(std::move(var)); + if (chargepoint->call(set_vars_req, set_vars_conf, error, error_msg)) + { + std::cout << "Done!" << std::endl; + } + else + { + std::cout << "Failed : error = " << error << " error_msg = " << error_msg << std::endl; + } + + std::cout << "Trigger status notification..." << std::endl; + TriggerMessageReq trigger_msg_req; + TriggerMessageConf trigger_msg_conf; + trigger_msg_req.requestedMessage = MessageTriggerEnumType::StatusNotification; + if (chargepoint->call(trigger_msg_req, trigger_msg_conf, error, error_msg)) + { + std::cout << "Done!" << std::endl; + } + else + { + std::cout << "Failed : error = " << error << " error_msg = " << error_msg << std::endl; + } + + std::cout << "Trigger meter values on evse 1..." << std::endl; + trigger_msg_req.evse.value().id = 1; + trigger_msg_req.requestedMessage = MessageTriggerEnumType::MeterValues; + if (chargepoint->call(trigger_msg_req, trigger_msg_conf, error, error_msg)) + { + std::cout << "Done!" << std::endl; + } + else + { + std::cout << "Failed : error = " << error << " error_msg = " << error_msg << std::endl; + } + + std::cout << "Trigger heartbeat..." << std::endl; + trigger_msg_req.evse.clear(); + trigger_msg_req.requestedMessage = MessageTriggerEnumType::Heartbeat; + if (chargepoint->call(trigger_msg_req, trigger_msg_conf, error, error_msg)) + { + std::cout << "Done!" << std::endl; + } + else + { + std::cout << "Failed : error = " << error << " error_msg = " << error_msg << std::endl; + } + } + + std::this_thread::sleep_for(std::chrono::seconds(10)); + } + } + + return 0; +} diff --git a/schemas/Authorize.json b/schemas/ocpp16/Authorize.json similarity index 100% rename from schemas/Authorize.json rename to schemas/ocpp16/Authorize.json diff --git a/schemas/AuthorizeResponse.json b/schemas/ocpp16/AuthorizeResponse.json similarity index 100% rename from schemas/AuthorizeResponse.json rename to schemas/ocpp16/AuthorizeResponse.json diff --git a/schemas/BootNotification.json b/schemas/ocpp16/BootNotification.json similarity index 100% rename from schemas/BootNotification.json rename to schemas/ocpp16/BootNotification.json diff --git a/schemas/BootNotificationResponse.json b/schemas/ocpp16/BootNotificationResponse.json similarity index 100% rename from schemas/BootNotificationResponse.json rename to schemas/ocpp16/BootNotificationResponse.json diff --git a/schemas/CancelReservation.json b/schemas/ocpp16/CancelReservation.json similarity index 100% rename from schemas/CancelReservation.json rename to schemas/ocpp16/CancelReservation.json diff --git a/schemas/CancelReservationResponse.json b/schemas/ocpp16/CancelReservationResponse.json similarity index 100% rename from schemas/CancelReservationResponse.json rename to schemas/ocpp16/CancelReservationResponse.json diff --git a/schemas/CertificateSigned.json b/schemas/ocpp16/CertificateSigned.json old mode 100755 new mode 100644 similarity index 100% rename from schemas/CertificateSigned.json rename to schemas/ocpp16/CertificateSigned.json diff --git a/schemas/CertificateSignedResponse.json b/schemas/ocpp16/CertificateSignedResponse.json old mode 100755 new mode 100644 similarity index 100% rename from schemas/CertificateSignedResponse.json rename to schemas/ocpp16/CertificateSignedResponse.json diff --git a/schemas/ChangeAvailability.json b/schemas/ocpp16/ChangeAvailability.json similarity index 100% rename from schemas/ChangeAvailability.json rename to schemas/ocpp16/ChangeAvailability.json diff --git a/schemas/ChangeAvailabilityResponse.json b/schemas/ocpp16/ChangeAvailabilityResponse.json similarity index 100% rename from schemas/ChangeAvailabilityResponse.json rename to schemas/ocpp16/ChangeAvailabilityResponse.json diff --git a/schemas/ChangeConfiguration.json b/schemas/ocpp16/ChangeConfiguration.json similarity index 100% rename from schemas/ChangeConfiguration.json rename to schemas/ocpp16/ChangeConfiguration.json diff --git a/schemas/ChangeConfigurationResponse.json b/schemas/ocpp16/ChangeConfigurationResponse.json similarity index 100% rename from schemas/ChangeConfigurationResponse.json rename to schemas/ocpp16/ChangeConfigurationResponse.json diff --git a/schemas/ClearCache.json b/schemas/ocpp16/ClearCache.json similarity index 100% rename from schemas/ClearCache.json rename to schemas/ocpp16/ClearCache.json diff --git a/schemas/ClearCacheResponse.json b/schemas/ocpp16/ClearCacheResponse.json similarity index 100% rename from schemas/ClearCacheResponse.json rename to schemas/ocpp16/ClearCacheResponse.json diff --git a/schemas/ClearChargingProfile.json b/schemas/ocpp16/ClearChargingProfile.json similarity index 100% rename from schemas/ClearChargingProfile.json rename to schemas/ocpp16/ClearChargingProfile.json diff --git a/schemas/ClearChargingProfileResponse.json b/schemas/ocpp16/ClearChargingProfileResponse.json similarity index 100% rename from schemas/ClearChargingProfileResponse.json rename to schemas/ocpp16/ClearChargingProfileResponse.json diff --git a/schemas/DataTransfer.json b/schemas/ocpp16/DataTransfer.json similarity index 100% rename from schemas/DataTransfer.json rename to schemas/ocpp16/DataTransfer.json diff --git a/schemas/DataTransferResponse.json b/schemas/ocpp16/DataTransferResponse.json similarity index 100% rename from schemas/DataTransferResponse.json rename to schemas/ocpp16/DataTransferResponse.json diff --git a/schemas/DeleteCertificate.json b/schemas/ocpp16/DeleteCertificate.json old mode 100755 new mode 100644 similarity index 100% rename from schemas/DeleteCertificate.json rename to schemas/ocpp16/DeleteCertificate.json diff --git a/schemas/DeleteCertificateResponse.json b/schemas/ocpp16/DeleteCertificateResponse.json old mode 100755 new mode 100644 similarity index 100% rename from schemas/DeleteCertificateResponse.json rename to schemas/ocpp16/DeleteCertificateResponse.json diff --git a/schemas/DiagnosticsStatusNotification.json b/schemas/ocpp16/DiagnosticsStatusNotification.json similarity index 100% rename from schemas/DiagnosticsStatusNotification.json rename to schemas/ocpp16/DiagnosticsStatusNotification.json diff --git a/schemas/DiagnosticsStatusNotificationResponse.json b/schemas/ocpp16/DiagnosticsStatusNotificationResponse.json similarity index 100% rename from schemas/DiagnosticsStatusNotificationResponse.json rename to schemas/ocpp16/DiagnosticsStatusNotificationResponse.json diff --git a/schemas/ExtendedTriggerMessage.json b/schemas/ocpp16/ExtendedTriggerMessage.json old mode 100755 new mode 100644 similarity index 100% rename from schemas/ExtendedTriggerMessage.json rename to schemas/ocpp16/ExtendedTriggerMessage.json diff --git a/schemas/ExtendedTriggerMessageResponse.json b/schemas/ocpp16/ExtendedTriggerMessageResponse.json old mode 100755 new mode 100644 similarity index 100% rename from schemas/ExtendedTriggerMessageResponse.json rename to schemas/ocpp16/ExtendedTriggerMessageResponse.json diff --git a/schemas/FirmwareStatusNotification.json b/schemas/ocpp16/FirmwareStatusNotification.json similarity index 100% rename from schemas/FirmwareStatusNotification.json rename to schemas/ocpp16/FirmwareStatusNotification.json diff --git a/schemas/FirmwareStatusNotificationResponse.json b/schemas/ocpp16/FirmwareStatusNotificationResponse.json similarity index 100% rename from schemas/FirmwareStatusNotificationResponse.json rename to schemas/ocpp16/FirmwareStatusNotificationResponse.json diff --git a/schemas/GetCompositeSchedule.json b/schemas/ocpp16/GetCompositeSchedule.json similarity index 100% rename from schemas/GetCompositeSchedule.json rename to schemas/ocpp16/GetCompositeSchedule.json diff --git a/schemas/GetCompositeScheduleResponse.json b/schemas/ocpp16/GetCompositeScheduleResponse.json similarity index 100% rename from schemas/GetCompositeScheduleResponse.json rename to schemas/ocpp16/GetCompositeScheduleResponse.json diff --git a/schemas/GetConfiguration.json b/schemas/ocpp16/GetConfiguration.json similarity index 100% rename from schemas/GetConfiguration.json rename to schemas/ocpp16/GetConfiguration.json diff --git a/schemas/GetConfigurationResponse.json b/schemas/ocpp16/GetConfigurationResponse.json similarity index 100% rename from schemas/GetConfigurationResponse.json rename to schemas/ocpp16/GetConfigurationResponse.json diff --git a/schemas/GetDiagnostics.json b/schemas/ocpp16/GetDiagnostics.json similarity index 100% rename from schemas/GetDiagnostics.json rename to schemas/ocpp16/GetDiagnostics.json diff --git a/schemas/GetDiagnosticsResponse.json b/schemas/ocpp16/GetDiagnosticsResponse.json similarity index 100% rename from schemas/GetDiagnosticsResponse.json rename to schemas/ocpp16/GetDiagnosticsResponse.json diff --git a/schemas/GetInstalledCertificateIds.json b/schemas/ocpp16/GetInstalledCertificateIds.json old mode 100755 new mode 100644 similarity index 100% rename from schemas/GetInstalledCertificateIds.json rename to schemas/ocpp16/GetInstalledCertificateIds.json diff --git a/schemas/GetInstalledCertificateIdsResponse.json b/schemas/ocpp16/GetInstalledCertificateIdsResponse.json old mode 100755 new mode 100644 similarity index 100% rename from schemas/GetInstalledCertificateIdsResponse.json rename to schemas/ocpp16/GetInstalledCertificateIdsResponse.json diff --git a/schemas/GetLocalListVersion.json b/schemas/ocpp16/GetLocalListVersion.json similarity index 100% rename from schemas/GetLocalListVersion.json rename to schemas/ocpp16/GetLocalListVersion.json diff --git a/schemas/GetLocalListVersionResponse.json b/schemas/ocpp16/GetLocalListVersionResponse.json similarity index 100% rename from schemas/GetLocalListVersionResponse.json rename to schemas/ocpp16/GetLocalListVersionResponse.json diff --git a/schemas/GetLog.json b/schemas/ocpp16/GetLog.json old mode 100755 new mode 100644 similarity index 100% rename from schemas/GetLog.json rename to schemas/ocpp16/GetLog.json diff --git a/schemas/GetLogResponse.json b/schemas/ocpp16/GetLogResponse.json old mode 100755 new mode 100644 similarity index 100% rename from schemas/GetLogResponse.json rename to schemas/ocpp16/GetLogResponse.json diff --git a/schemas/Heartbeat.json b/schemas/ocpp16/Heartbeat.json similarity index 100% rename from schemas/Heartbeat.json rename to schemas/ocpp16/Heartbeat.json diff --git a/schemas/HeartbeatResponse.json b/schemas/ocpp16/HeartbeatResponse.json similarity index 100% rename from schemas/HeartbeatResponse.json rename to schemas/ocpp16/HeartbeatResponse.json diff --git a/schemas/InstallCertificate.json b/schemas/ocpp16/InstallCertificate.json old mode 100755 new mode 100644 similarity index 100% rename from schemas/InstallCertificate.json rename to schemas/ocpp16/InstallCertificate.json diff --git a/schemas/InstallCertificateResponse.json b/schemas/ocpp16/InstallCertificateResponse.json old mode 100755 new mode 100644 similarity index 100% rename from schemas/InstallCertificateResponse.json rename to schemas/ocpp16/InstallCertificateResponse.json diff --git a/schemas/LogStatusNotification.json b/schemas/ocpp16/LogStatusNotification.json old mode 100755 new mode 100644 similarity index 100% rename from schemas/LogStatusNotification.json rename to schemas/ocpp16/LogStatusNotification.json diff --git a/schemas/LogStatusNotificationResponse.json b/schemas/ocpp16/LogStatusNotificationResponse.json old mode 100755 new mode 100644 similarity index 100% rename from schemas/LogStatusNotificationResponse.json rename to schemas/ocpp16/LogStatusNotificationResponse.json diff --git a/schemas/MeterValues.json b/schemas/ocpp16/MeterValues.json similarity index 100% rename from schemas/MeterValues.json rename to schemas/ocpp16/MeterValues.json diff --git a/schemas/MeterValuesResponse.json b/schemas/ocpp16/MeterValuesResponse.json similarity index 100% rename from schemas/MeterValuesResponse.json rename to schemas/ocpp16/MeterValuesResponse.json diff --git a/schemas/RemoteStartTransaction.json b/schemas/ocpp16/RemoteStartTransaction.json similarity index 100% rename from schemas/RemoteStartTransaction.json rename to schemas/ocpp16/RemoteStartTransaction.json diff --git a/schemas/RemoteStartTransactionResponse.json b/schemas/ocpp16/RemoteStartTransactionResponse.json similarity index 100% rename from schemas/RemoteStartTransactionResponse.json rename to schemas/ocpp16/RemoteStartTransactionResponse.json diff --git a/schemas/RemoteStopTransaction.json b/schemas/ocpp16/RemoteStopTransaction.json similarity index 100% rename from schemas/RemoteStopTransaction.json rename to schemas/ocpp16/RemoteStopTransaction.json diff --git a/schemas/RemoteStopTransactionResponse.json b/schemas/ocpp16/RemoteStopTransactionResponse.json similarity index 100% rename from schemas/RemoteStopTransactionResponse.json rename to schemas/ocpp16/RemoteStopTransactionResponse.json diff --git a/schemas/ReserveNow.json b/schemas/ocpp16/ReserveNow.json similarity index 100% rename from schemas/ReserveNow.json rename to schemas/ocpp16/ReserveNow.json diff --git a/schemas/ReserveNowResponse.json b/schemas/ocpp16/ReserveNowResponse.json similarity index 100% rename from schemas/ReserveNowResponse.json rename to schemas/ocpp16/ReserveNowResponse.json diff --git a/schemas/Reset.json b/schemas/ocpp16/Reset.json similarity index 100% rename from schemas/Reset.json rename to schemas/ocpp16/Reset.json diff --git a/schemas/ResetResponse.json b/schemas/ocpp16/ResetResponse.json similarity index 100% rename from schemas/ResetResponse.json rename to schemas/ocpp16/ResetResponse.json diff --git a/schemas/SecurityEventNotification.json b/schemas/ocpp16/SecurityEventNotification.json old mode 100755 new mode 100644 similarity index 100% rename from schemas/SecurityEventNotification.json rename to schemas/ocpp16/SecurityEventNotification.json diff --git a/schemas/SecurityEventNotificationResponse.json b/schemas/ocpp16/SecurityEventNotificationResponse.json old mode 100755 new mode 100644 similarity index 100% rename from schemas/SecurityEventNotificationResponse.json rename to schemas/ocpp16/SecurityEventNotificationResponse.json diff --git a/schemas/SendLocalList.json b/schemas/ocpp16/SendLocalList.json similarity index 100% rename from schemas/SendLocalList.json rename to schemas/ocpp16/SendLocalList.json diff --git a/schemas/SendLocalListResponse.json b/schemas/ocpp16/SendLocalListResponse.json similarity index 100% rename from schemas/SendLocalListResponse.json rename to schemas/ocpp16/SendLocalListResponse.json diff --git a/schemas/SetChargingProfile.json b/schemas/ocpp16/SetChargingProfile.json similarity index 100% rename from schemas/SetChargingProfile.json rename to schemas/ocpp16/SetChargingProfile.json diff --git a/schemas/SetChargingProfileResponse.json b/schemas/ocpp16/SetChargingProfileResponse.json similarity index 100% rename from schemas/SetChargingProfileResponse.json rename to schemas/ocpp16/SetChargingProfileResponse.json diff --git a/schemas/SignCertificate.json b/schemas/ocpp16/SignCertificate.json old mode 100755 new mode 100644 similarity index 100% rename from schemas/SignCertificate.json rename to schemas/ocpp16/SignCertificate.json diff --git a/schemas/SignCertificateResponse.json b/schemas/ocpp16/SignCertificateResponse.json old mode 100755 new mode 100644 similarity index 100% rename from schemas/SignCertificateResponse.json rename to schemas/ocpp16/SignCertificateResponse.json diff --git a/schemas/SignedFirmwareStatusNotification.json b/schemas/ocpp16/SignedFirmwareStatusNotification.json old mode 100755 new mode 100644 similarity index 100% rename from schemas/SignedFirmwareStatusNotification.json rename to schemas/ocpp16/SignedFirmwareStatusNotification.json diff --git a/schemas/SignedFirmwareStatusNotificationResponse.json b/schemas/ocpp16/SignedFirmwareStatusNotificationResponse.json old mode 100755 new mode 100644 similarity index 100% rename from schemas/SignedFirmwareStatusNotificationResponse.json rename to schemas/ocpp16/SignedFirmwareStatusNotificationResponse.json diff --git a/schemas/SignedUpdateFirmware.json b/schemas/ocpp16/SignedUpdateFirmware.json old mode 100755 new mode 100644 similarity index 100% rename from schemas/SignedUpdateFirmware.json rename to schemas/ocpp16/SignedUpdateFirmware.json diff --git a/schemas/SignedUpdateFirmwareResponse.json b/schemas/ocpp16/SignedUpdateFirmwareResponse.json old mode 100755 new mode 100644 similarity index 100% rename from schemas/SignedUpdateFirmwareResponse.json rename to schemas/ocpp16/SignedUpdateFirmwareResponse.json diff --git a/schemas/StartTransaction.json b/schemas/ocpp16/StartTransaction.json similarity index 100% rename from schemas/StartTransaction.json rename to schemas/ocpp16/StartTransaction.json diff --git a/schemas/StartTransactionResponse.json b/schemas/ocpp16/StartTransactionResponse.json similarity index 100% rename from schemas/StartTransactionResponse.json rename to schemas/ocpp16/StartTransactionResponse.json diff --git a/schemas/StatusNotification.json b/schemas/ocpp16/StatusNotification.json similarity index 100% rename from schemas/StatusNotification.json rename to schemas/ocpp16/StatusNotification.json diff --git a/schemas/StatusNotificationResponse.json b/schemas/ocpp16/StatusNotificationResponse.json similarity index 100% rename from schemas/StatusNotificationResponse.json rename to schemas/ocpp16/StatusNotificationResponse.json diff --git a/schemas/StopTransaction.json b/schemas/ocpp16/StopTransaction.json similarity index 100% rename from schemas/StopTransaction.json rename to schemas/ocpp16/StopTransaction.json diff --git a/schemas/StopTransactionResponse.json b/schemas/ocpp16/StopTransactionResponse.json similarity index 100% rename from schemas/StopTransactionResponse.json rename to schemas/ocpp16/StopTransactionResponse.json diff --git a/schemas/TriggerMessage.json b/schemas/ocpp16/TriggerMessage.json similarity index 100% rename from schemas/TriggerMessage.json rename to schemas/ocpp16/TriggerMessage.json diff --git a/schemas/TriggerMessageResponse.json b/schemas/ocpp16/TriggerMessageResponse.json similarity index 100% rename from schemas/TriggerMessageResponse.json rename to schemas/ocpp16/TriggerMessageResponse.json diff --git a/schemas/UnlockConnector.json b/schemas/ocpp16/UnlockConnector.json similarity index 100% rename from schemas/UnlockConnector.json rename to schemas/ocpp16/UnlockConnector.json diff --git a/schemas/UnlockConnectorResponse.json b/schemas/ocpp16/UnlockConnectorResponse.json similarity index 100% rename from schemas/UnlockConnectorResponse.json rename to schemas/ocpp16/UnlockConnectorResponse.json diff --git a/schemas/UpdateFirmware.json b/schemas/ocpp16/UpdateFirmware.json similarity index 100% rename from schemas/UpdateFirmware.json rename to schemas/ocpp16/UpdateFirmware.json diff --git a/schemas/UpdateFirmwareResponse.json b/schemas/ocpp16/UpdateFirmwareResponse.json similarity index 100% rename from schemas/UpdateFirmwareResponse.json rename to schemas/ocpp16/UpdateFirmwareResponse.json diff --git a/schemas/ocpp20/AuthorizeRequest.json b/schemas/ocpp20/AuthorizeRequest.json new file mode 100644 index 00000000..5d88d2df --- /dev/null +++ b/schemas/ocpp20/AuthorizeRequest.json @@ -0,0 +1,171 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:AuthorizeRequest", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "HashAlgorithmEnumType": { + "description": "Used algorithms for the hashes provided.\r\n", + "javaType": "HashAlgorithmEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "SHA256", + "SHA384", + "SHA512" + ] + }, + "IdTokenEnumType": { + "description": "Enumeration of possible idToken types.\r\n", + "javaType": "IdTokenEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Central", + "eMAID", + "ISO14443", + "ISO15693", + "KeyCode", + "Local", + "MacAddress", + "NoAuthorization" + ] + }, + "AdditionalInfoType": { + "description": "Contains a case insensitive identifier to use for the authorization and the type of authorization to support multiple forms of identifiers.\r\n", + "javaType": "AdditionalInfo", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "additionalIdToken": { + "description": "This field specifies the additional IdToken.\r\n", + "type": "string", + "maxLength": 36 + }, + "type": { + "description": "This defines the type of the additionalIdToken. This is a custom type, so the implementation needs to be agreed upon by all involved parties.\r\n", + "type": "string", + "maxLength": 50 + } + }, + "required": [ + "additionalIdToken", + "type" + ] + }, + "IdTokenType": { + "description": "Contains a case insensitive identifier to use for the authorization and the type of authorization to support multiple forms of identifiers.\r\n", + "javaType": "IdToken", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "additionalInfo": { + "type": "array", + "additionalItems": false, + "items": { + "$ref": "#/definitions/AdditionalInfoType" + }, + "minItems": 1 + }, + "idToken": { + "description": "IdToken is case insensitive. Might hold the hidden id of an RFID tag, but can for example also contain a UUID.\r\n", + "type": "string", + "maxLength": 36 + }, + "type": { + "$ref": "#/definitions/IdTokenEnumType" + } + }, + "required": [ + "idToken", + "type" + ] + }, + "OCSPRequestDataType": { + "javaType": "OCSPRequestData", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "hashAlgorithm": { + "$ref": "#/definitions/HashAlgorithmEnumType" + }, + "issuerNameHash": { + "description": "Hashed value of the Issuer DN (Distinguished Name).\r\n\r\n", + "type": "string", + "maxLength": 128 + }, + "issuerKeyHash": { + "description": "Hashed value of the issuers public key\r\n", + "type": "string", + "maxLength": 128 + }, + "serialNumber": { + "description": "The serial number of the certificate.\r\n", + "type": "string", + "maxLength": 40 + }, + "responderURL": { + "description": "This contains the responder URL (Case insensitive). \r\n\r\n", + "type": "string", + "maxLength": 512 + } + }, + "required": [ + "hashAlgorithm", + "issuerNameHash", + "issuerKeyHash", + "serialNumber", + "responderURL" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "idToken": { + "$ref": "#/definitions/IdTokenType" + }, + "certificate": { + "description": "The X.509 certificated presented by EV and encoded in PEM format.\r\n", + "type": "string", + "maxLength": 5500 + }, + "iso15118CertificateHashData": { + "type": "array", + "additionalItems": false, + "items": { + "$ref": "#/definitions/OCSPRequestDataType" + }, + "minItems": 1, + "maxItems": 4 + } + }, + "required": [ + "idToken" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/AuthorizeResponse.json b/schemas/ocpp20/AuthorizeResponse.json new file mode 100644 index 00000000..3de6f333 --- /dev/null +++ b/schemas/ocpp20/AuthorizeResponse.json @@ -0,0 +1,233 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:AuthorizeResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "AuthorizationStatusEnumType": { + "description": "ID_ Token. Status. Authorization_ Status\r\nurn:x-oca:ocpp:uid:1:569372\r\nCurrent status of the ID Token.\r\n", + "javaType": "AuthorizationStatusEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Accepted", + "Blocked", + "ConcurrentTx", + "Expired", + "Invalid", + "NoCredit", + "NotAllowedTypeEVSE", + "NotAtThisLocation", + "NotAtThisTime", + "Unknown" + ] + }, + "AuthorizeCertificateStatusEnumType": { + "description": "Certificate status information. \r\n- if all certificates are valid: return 'Accepted'.\r\n- if one of the certificates was revoked, return 'CertificateRevoked'.\r\n", + "javaType": "AuthorizeCertificateStatusEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Accepted", + "SignatureError", + "CertificateExpired", + "CertificateRevoked", + "NoCertificateAvailable", + "CertChainError", + "ContractCancelled" + ] + }, + "IdTokenEnumType": { + "description": "Enumeration of possible idToken types.\r\n", + "javaType": "IdTokenEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Central", + "eMAID", + "ISO14443", + "ISO15693", + "KeyCode", + "Local", + "MacAddress", + "NoAuthorization" + ] + }, + "MessageFormatEnumType": { + "description": "Message_ Content. Format. Message_ Format_ Code\r\nurn:x-enexis:ecdm:uid:1:570848\r\nFormat of the message.\r\n", + "javaType": "MessageFormatEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "ASCII", + "HTML", + "URI", + "UTF8" + ] + }, + "AdditionalInfoType": { + "description": "Contains a case insensitive identifier to use for the authorization and the type of authorization to support multiple forms of identifiers.\r\n", + "javaType": "AdditionalInfo", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "additionalIdToken": { + "description": "This field specifies the additional IdToken.\r\n", + "type": "string", + "maxLength": 36 + }, + "type": { + "description": "This defines the type of the additionalIdToken. This is a custom type, so the implementation needs to be agreed upon by all involved parties.\r\n", + "type": "string", + "maxLength": 50 + } + }, + "required": [ + "additionalIdToken", + "type" + ] + }, + "IdTokenInfoType": { + "description": "ID_ Token\r\nurn:x-oca:ocpp:uid:2:233247\r\nContains status information about an identifier.\r\nIt is advised to not stop charging for a token that expires during charging, as ExpiryDate is only used for caching purposes. If ExpiryDate is not given, the status has no end date.\r\n", + "javaType": "IdTokenInfo", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "status": { + "$ref": "#/definitions/AuthorizationStatusEnumType" + }, + "cacheExpiryDateTime": { + "description": "ID_ Token. Expiry. Date_ Time\r\nurn:x-oca:ocpp:uid:1:569373\r\nDate and Time after which the token must be considered invalid.\r\n", + "type": "string", + "format": "date-time" + }, + "chargingPriority": { + "description": "Priority from a business point of view. Default priority is 0, The range is from -9 to 9. Higher values indicate a higher priority. The chargingPriority in <<transactioneventresponse,TransactionEventResponse>> overrules this one. \r\n", + "type": "integer" + }, + "language1": { + "description": "ID_ Token. Language1. Language_ Code\r\nurn:x-oca:ocpp:uid:1:569374\r\nPreferred user interface language of identifier user. Contains a language code as defined in <<ref-RFC5646,[RFC5646]>>.\r\n\r\n", + "type": "string", + "maxLength": 8 + }, + "evseId": { + "description": "Only used when the IdToken is only valid for one or more specific EVSEs, not for the entire Charging Station.\r\n\r\n", + "type": "array", + "additionalItems": false, + "items": { + "type": "integer" + }, + "minItems": 1 + }, + "groupIdToken": { + "$ref": "#/definitions/IdTokenType" + }, + "language2": { + "description": "ID_ Token. Language2. Language_ Code\r\nurn:x-oca:ocpp:uid:1:569375\r\nSecond preferred user interface language of identifier user. Don’t use when language1 is omitted, has to be different from language1. Contains a language code as defined in <<ref-RFC5646,[RFC5646]>>.\r\n", + "type": "string", + "maxLength": 8 + }, + "personalMessage": { + "$ref": "#/definitions/MessageContentType" + } + }, + "required": [ + "status" + ] + }, + "IdTokenType": { + "description": "Contains a case insensitive identifier to use for the authorization and the type of authorization to support multiple forms of identifiers.\r\n", + "javaType": "IdToken", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "additionalInfo": { + "type": "array", + "additionalItems": false, + "items": { + "$ref": "#/definitions/AdditionalInfoType" + }, + "minItems": 1 + }, + "idToken": { + "description": "IdToken is case insensitive. Might hold the hidden id of an RFID tag, but can for example also contain a UUID.\r\n", + "type": "string", + "maxLength": 36 + }, + "type": { + "$ref": "#/definitions/IdTokenEnumType" + } + }, + "required": [ + "idToken", + "type" + ] + }, + "MessageContentType": { + "description": "Message_ Content\r\nurn:x-enexis:ecdm:uid:2:234490\r\nContains message details, for a message to be displayed on a Charging Station.\r\n\r\n", + "javaType": "MessageContent", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "format": { + "$ref": "#/definitions/MessageFormatEnumType" + }, + "language": { + "description": "Message_ Content. Language. Language_ Code\r\nurn:x-enexis:ecdm:uid:1:570849\r\nMessage language identifier. Contains a language code as defined in <<ref-RFC5646,[RFC5646]>>.\r\n", + "type": "string", + "maxLength": 8 + }, + "content": { + "description": "Message_ Content. Content. Message\r\nurn:x-enexis:ecdm:uid:1:570852\r\nMessage contents.\r\n\r\n", + "type": "string", + "maxLength": 512 + } + }, + "required": [ + "format", + "content" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "idTokenInfo": { + "$ref": "#/definitions/IdTokenInfoType" + }, + "certificateStatus": { + "$ref": "#/definitions/AuthorizeCertificateStatusEnumType" + } + }, + "required": [ + "idTokenInfo" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/BootNotificationRequest.json b/schemas/ocpp20/BootNotificationRequest.json new file mode 100644 index 00000000..86aee135 --- /dev/null +++ b/schemas/ocpp20/BootNotificationRequest.json @@ -0,0 +1,114 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:BootNotificationRequest", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "BootReasonEnumType": { + "description": "This contains the reason for sending this message to the CSMS.\r\n", + "javaType": "BootReasonEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "ApplicationReset", + "FirmwareUpdate", + "LocalReset", + "PowerUp", + "RemoteReset", + "ScheduledReset", + "Triggered", + "Unknown", + "Watchdog" + ] + }, + "ChargingStationType": { + "description": "Charge_ Point\r\nurn:x-oca:ocpp:uid:2:233122\r\nThe physical system where an Electrical Vehicle (EV) can be charged.\r\n", + "javaType": "ChargingStation", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "serialNumber": { + "description": "Device. Serial_ Number. Serial_ Number\r\nurn:x-oca:ocpp:uid:1:569324\r\nVendor-specific device identifier.\r\n", + "type": "string", + "maxLength": 25 + }, + "model": { + "description": "Device. Model. CI20_ Text\r\nurn:x-oca:ocpp:uid:1:569325\r\nDefines the model of the device.\r\n", + "type": "string", + "maxLength": 20 + }, + "modem": { + "$ref": "#/definitions/ModemType" + }, + "vendorName": { + "description": "Identifies the vendor (not necessarily in a unique manner).\r\n", + "type": "string", + "maxLength": 50 + }, + "firmwareVersion": { + "description": "This contains the firmware version of the Charging Station.\r\n\r\n", + "type": "string", + "maxLength": 50 + } + }, + "required": [ + "model", + "vendorName" + ] + }, + "ModemType": { + "description": "Wireless_ Communication_ Module\r\nurn:x-oca:ocpp:uid:2:233306\r\nDefines parameters required for initiating and maintaining wireless communication with other devices.\r\n", + "javaType": "Modem", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "iccid": { + "description": "Wireless_ Communication_ Module. ICCID. CI20_ Text\r\nurn:x-oca:ocpp:uid:1:569327\r\nThis contains the ICCID of the modem’s SIM card.\r\n", + "type": "string", + "maxLength": 20 + }, + "imsi": { + "description": "Wireless_ Communication_ Module. IMSI. CI20_ Text\r\nurn:x-oca:ocpp:uid:1:569328\r\nThis contains the IMSI of the modem’s SIM card.\r\n", + "type": "string", + "maxLength": 20 + } + } + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "chargingStation": { + "$ref": "#/definitions/ChargingStationType" + }, + "reason": { + "$ref": "#/definitions/BootReasonEnumType" + } + }, + "required": [ + "reason", + "chargingStation" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/BootNotificationResponse.json b/schemas/ocpp20/BootNotificationResponse.json new file mode 100644 index 00000000..9ca29d49 --- /dev/null +++ b/schemas/ocpp20/BootNotificationResponse.json @@ -0,0 +1,83 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:BootNotificationResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "RegistrationStatusEnumType": { + "description": "This contains whether the Charging Station has been registered\r\nwithin the CSMS.\r\n", + "javaType": "RegistrationStatusEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Accepted", + "Pending", + "Rejected" + ] + }, + "StatusInfoType": { + "description": "Element providing more information about the status.\r\n", + "javaType": "StatusInfo", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "reasonCode": { + "description": "A predefined code for the reason why the status is returned in this response. The string is case-insensitive.\r\n", + "type": "string", + "maxLength": 20 + }, + "additionalInfo": { + "description": "Additional text to provide detailed information.\r\n", + "type": "string", + "maxLength": 512 + } + }, + "required": [ + "reasonCode" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "currentTime": { + "description": "This contains the CSMS’s current time.\r\n", + "type": "string", + "format": "date-time" + }, + "interval": { + "description": "When <<cmn_registrationstatusenumtype,Status>> is Accepted, this contains the heartbeat interval in seconds. If the CSMS returns something other than Accepted, the value of the interval field indicates the minimum wait time before sending a next BootNotification request.\r\n", + "type": "integer" + }, + "status": { + "$ref": "#/definitions/RegistrationStatusEnumType" + }, + "statusInfo": { + "$ref": "#/definitions/StatusInfoType" + } + }, + "required": [ + "currentTime", + "interval", + "status" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/CancelReservationRequest.json b/schemas/ocpp20/CancelReservationRequest.json new file mode 100644 index 00000000..48d79b18 --- /dev/null +++ b/schemas/ocpp20/CancelReservationRequest.json @@ -0,0 +1,35 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:CancelReservationRequest", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "reservationId": { + "description": "Id of the reservation to cancel.\r\n", + "type": "integer" + } + }, + "required": [ + "reservationId" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/CancelReservationResponse.json b/schemas/ocpp20/CancelReservationResponse.json new file mode 100644 index 00000000..4605b850 --- /dev/null +++ b/schemas/ocpp20/CancelReservationResponse.json @@ -0,0 +1,71 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:CancelReservationResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "CancelReservationStatusEnumType": { + "description": "This indicates the success or failure of the canceling of a reservation by CSMS.\r\n", + "javaType": "CancelReservationStatusEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Accepted", + "Rejected" + ] + }, + "StatusInfoType": { + "description": "Element providing more information about the status.\r\n", + "javaType": "StatusInfo", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "reasonCode": { + "description": "A predefined code for the reason why the status is returned in this response. The string is case-insensitive.\r\n", + "type": "string", + "maxLength": 20 + }, + "additionalInfo": { + "description": "Additional text to provide detailed information.\r\n", + "type": "string", + "maxLength": 512 + } + }, + "required": [ + "reasonCode" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "status": { + "$ref": "#/definitions/CancelReservationStatusEnumType" + }, + "statusInfo": { + "$ref": "#/definitions/StatusInfoType" + } + }, + "required": [ + "status" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/CertificateSignedRequest.json b/schemas/ocpp20/CertificateSignedRequest.json new file mode 100644 index 00000000..d8eeab0f --- /dev/null +++ b/schemas/ocpp20/CertificateSignedRequest.json @@ -0,0 +1,49 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:CertificateSignedRequest", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "CertificateSigningUseEnumType": { + "description": "Indicates the type of the signed certificate that is returned. When omitted the certificate is used for both the 15118 connection (if implemented) and the Charging Station to CSMS connection. This field is required when a typeOfCertificate was included in the <<signcertificaterequest,SignCertificateRequest>> that requested this certificate to be signed AND both the 15118 connection and the Charging Station connection are implemented.\r\n\r\n", + "javaType": "CertificateSigningUseEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "ChargingStationCertificate", + "V2GCertificate" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "certificateChain": { + "description": "The signed PEM encoded X.509 certificate. This can also contain the necessary sub CA certificates. In that case, the order of the bundle should follow the certificate chain, starting from the leaf certificate.\r\n\r\nThe Configuration Variable <<configkey-max-certificate-chain-size,MaxCertificateChainSize>> can be used to limit the maximum size of this field.\r\n", + "type": "string", + "maxLength": 10000 + }, + "certificateType": { + "$ref": "#/definitions/CertificateSigningUseEnumType" + } + }, + "required": [ + "certificateChain" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/CertificateSignedResponse.json b/schemas/ocpp20/CertificateSignedResponse.json new file mode 100644 index 00000000..b6d059f9 --- /dev/null +++ b/schemas/ocpp20/CertificateSignedResponse.json @@ -0,0 +1,71 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:CertificateSignedResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "CertificateSignedStatusEnumType": { + "description": "Returns whether certificate signing has been accepted, otherwise rejected.\r\n", + "javaType": "CertificateSignedStatusEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Accepted", + "Rejected" + ] + }, + "StatusInfoType": { + "description": "Element providing more information about the status.\r\n", + "javaType": "StatusInfo", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "reasonCode": { + "description": "A predefined code for the reason why the status is returned in this response. The string is case-insensitive.\r\n", + "type": "string", + "maxLength": 20 + }, + "additionalInfo": { + "description": "Additional text to provide detailed information.\r\n", + "type": "string", + "maxLength": 512 + } + }, + "required": [ + "reasonCode" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "status": { + "$ref": "#/definitions/CertificateSignedStatusEnumType" + }, + "statusInfo": { + "$ref": "#/definitions/StatusInfoType" + } + }, + "required": [ + "status" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/ChangeAvailabilityRequest.json b/schemas/ocpp20/ChangeAvailabilityRequest.json new file mode 100644 index 00000000..3324260a --- /dev/null +++ b/schemas/ocpp20/ChangeAvailabilityRequest.json @@ -0,0 +1,69 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:ChangeAvailabilityRequest", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "OperationalStatusEnumType": { + "description": "This contains the type of availability change that the Charging Station should perform.\r\n\r\n", + "javaType": "OperationalStatusEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Inoperative", + "Operative" + ] + }, + "EVSEType": { + "description": "EVSE\r\nurn:x-oca:ocpp:uid:2:233123\r\nElectric Vehicle Supply Equipment\r\n", + "javaType": "EVSE", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "id": { + "description": "Identified_ Object. MRID. Numeric_ Identifier\r\nurn:x-enexis:ecdm:uid:1:569198\r\nEVSE Identifier. This contains a number (> 0) designating an EVSE of the Charging Station.\r\n", + "type": "integer" + }, + "connectorId": { + "description": "An id to designate a specific connector (on an EVSE) by connector index number.\r\n", + "type": "integer" + } + }, + "required": [ + "id" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "evse": { + "$ref": "#/definitions/EVSEType" + }, + "operationalStatus": { + "$ref": "#/definitions/OperationalStatusEnumType" + } + }, + "required": [ + "operationalStatus" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/ChangeAvailabilityResponse.json b/schemas/ocpp20/ChangeAvailabilityResponse.json new file mode 100644 index 00000000..075ee5d9 --- /dev/null +++ b/schemas/ocpp20/ChangeAvailabilityResponse.json @@ -0,0 +1,72 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:ChangeAvailabilityResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "ChangeAvailabilityStatusEnumType": { + "description": "This indicates whether the Charging Station is able to perform the availability change.\r\n", + "javaType": "ChangeAvailabilityStatusEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Accepted", + "Rejected", + "Scheduled" + ] + }, + "StatusInfoType": { + "description": "Element providing more information about the status.\r\n", + "javaType": "StatusInfo", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "reasonCode": { + "description": "A predefined code for the reason why the status is returned in this response. The string is case-insensitive.\r\n", + "type": "string", + "maxLength": 20 + }, + "additionalInfo": { + "description": "Additional text to provide detailed information.\r\n", + "type": "string", + "maxLength": 512 + } + }, + "required": [ + "reasonCode" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "status": { + "$ref": "#/definitions/ChangeAvailabilityStatusEnumType" + }, + "statusInfo": { + "$ref": "#/definitions/StatusInfoType" + } + }, + "required": [ + "status" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/ClearCacheRequest.json b/schemas/ocpp20/ClearCacheRequest.json new file mode 100644 index 00000000..d9498ffe --- /dev/null +++ b/schemas/ocpp20/ClearCacheRequest.json @@ -0,0 +1,28 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:ClearCacheRequest", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + } + } +} \ No newline at end of file diff --git a/schemas/ocpp20/ClearCacheResponse.json b/schemas/ocpp20/ClearCacheResponse.json new file mode 100644 index 00000000..3a2460de --- /dev/null +++ b/schemas/ocpp20/ClearCacheResponse.json @@ -0,0 +1,71 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:ClearCacheResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "ClearCacheStatusEnumType": { + "description": "Accepted if the Charging Station has executed the request, otherwise rejected.\r\n", + "javaType": "ClearCacheStatusEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Accepted", + "Rejected" + ] + }, + "StatusInfoType": { + "description": "Element providing more information about the status.\r\n", + "javaType": "StatusInfo", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "reasonCode": { + "description": "A predefined code for the reason why the status is returned in this response. The string is case-insensitive.\r\n", + "type": "string", + "maxLength": 20 + }, + "additionalInfo": { + "description": "Additional text to provide detailed information.\r\n", + "type": "string", + "maxLength": 512 + } + }, + "required": [ + "reasonCode" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "status": { + "$ref": "#/definitions/ClearCacheStatusEnumType" + }, + "statusInfo": { + "$ref": "#/definitions/StatusInfoType" + } + }, + "required": [ + "status" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/ClearChargingProfileRequest.json b/schemas/ocpp20/ClearChargingProfileRequest.json new file mode 100644 index 00000000..f205ac60 --- /dev/null +++ b/schemas/ocpp20/ClearChargingProfileRequest.json @@ -0,0 +1,69 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:ClearChargingProfileRequest", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "ChargingProfilePurposeEnumType": { + "description": "Charging_ Profile. Charging_ Profile_ Purpose. Charging_ Profile_ Purpose_ Code\r\nurn:x-oca:ocpp:uid:1:569231\r\nSpecifies to purpose of the charging profiles that will be cleared, if they meet the other criteria in the request.\r\n", + "javaType": "ChargingProfilePurposeEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "ChargingStationExternalConstraints", + "ChargingStationMaxProfile", + "TxDefaultProfile", + "TxProfile" + ] + }, + "ClearChargingProfileType": { + "description": "Charging_ Profile\r\nurn:x-oca:ocpp:uid:2:233255\r\nA ChargingProfile consists of a ChargingSchedule, describing the amount of power or current that can be delivered per time interval.\r\n", + "javaType": "ClearChargingProfile", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "evseId": { + "description": "Identified_ Object. MRID. Numeric_ Identifier\r\nurn:x-enexis:ecdm:uid:1:569198\r\nSpecifies the id of the EVSE for which to clear charging profiles. An evseId of zero (0) specifies the charging profile for the overall Charging Station. Absence of this parameter means the clearing applies to all charging profiles that match the other criteria in the request.\r\n\r\n", + "type": "integer" + }, + "chargingProfilePurpose": { + "$ref": "#/definitions/ChargingProfilePurposeEnumType" + }, + "stackLevel": { + "description": "Charging_ Profile. Stack_ Level. Counter\r\nurn:x-oca:ocpp:uid:1:569230\r\nSpecifies the stackLevel for which charging profiles will be cleared, if they meet the other criteria in the request.\r\n", + "type": "integer" + } + } + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "chargingProfileId": { + "description": "The Id of the charging profile to clear.\r\n", + "type": "integer" + }, + "chargingProfileCriteria": { + "$ref": "#/definitions/ClearChargingProfileType" + } + } +} \ No newline at end of file diff --git a/schemas/ocpp20/ClearChargingProfileResponse.json b/schemas/ocpp20/ClearChargingProfileResponse.json new file mode 100644 index 00000000..0fb0d8bc --- /dev/null +++ b/schemas/ocpp20/ClearChargingProfileResponse.json @@ -0,0 +1,71 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:ClearChargingProfileResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "ClearChargingProfileStatusEnumType": { + "description": "Indicates if the Charging Station was able to execute the request.\r\n", + "javaType": "ClearChargingProfileStatusEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Accepted", + "Unknown" + ] + }, + "StatusInfoType": { + "description": "Element providing more information about the status.\r\n", + "javaType": "StatusInfo", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "reasonCode": { + "description": "A predefined code for the reason why the status is returned in this response. The string is case-insensitive.\r\n", + "type": "string", + "maxLength": 20 + }, + "additionalInfo": { + "description": "Additional text to provide detailed information.\r\n", + "type": "string", + "maxLength": 512 + } + }, + "required": [ + "reasonCode" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "status": { + "$ref": "#/definitions/ClearChargingProfileStatusEnumType" + }, + "statusInfo": { + "$ref": "#/definitions/StatusInfoType" + } + }, + "required": [ + "status" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/ClearDisplayMessageRequest.json b/schemas/ocpp20/ClearDisplayMessageRequest.json new file mode 100644 index 00000000..c278ae9b --- /dev/null +++ b/schemas/ocpp20/ClearDisplayMessageRequest.json @@ -0,0 +1,35 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:ClearDisplayMessageRequest", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "id": { + "description": "Id of the message that SHALL be removed from the Charging Station.\r\n", + "type": "integer" + } + }, + "required": [ + "id" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/ClearDisplayMessageResponse.json b/schemas/ocpp20/ClearDisplayMessageResponse.json new file mode 100644 index 00000000..754f749e --- /dev/null +++ b/schemas/ocpp20/ClearDisplayMessageResponse.json @@ -0,0 +1,71 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:ClearDisplayMessageResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "ClearMessageStatusEnumType": { + "description": "Returns whether the Charging Station has been able to remove the message.\r\n", + "javaType": "ClearMessageStatusEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Accepted", + "Unknown" + ] + }, + "StatusInfoType": { + "description": "Element providing more information about the status.\r\n", + "javaType": "StatusInfo", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "reasonCode": { + "description": "A predefined code for the reason why the status is returned in this response. The string is case-insensitive.\r\n", + "type": "string", + "maxLength": 20 + }, + "additionalInfo": { + "description": "Additional text to provide detailed information.\r\n", + "type": "string", + "maxLength": 512 + } + }, + "required": [ + "reasonCode" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "status": { + "$ref": "#/definitions/ClearMessageStatusEnumType" + }, + "statusInfo": { + "$ref": "#/definitions/StatusInfoType" + } + }, + "required": [ + "status" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/ClearVariableMonitoringRequest.json b/schemas/ocpp20/ClearVariableMonitoringRequest.json new file mode 100644 index 00000000..ab89ec1e --- /dev/null +++ b/schemas/ocpp20/ClearVariableMonitoringRequest.json @@ -0,0 +1,40 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:ClearVariableMonitoringRequest", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "id": { + "description": "List of the monitors to be cleared, identified by there Id.\r\n", + "type": "array", + "additionalItems": false, + "items": { + "type": "integer" + }, + "minItems": 1 + } + }, + "required": [ + "id" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/ClearVariableMonitoringResponse.json b/schemas/ocpp20/ClearVariableMonitoringResponse.json new file mode 100644 index 00000000..9563d075 --- /dev/null +++ b/schemas/ocpp20/ClearVariableMonitoringResponse.json @@ -0,0 +1,98 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:ClearVariableMonitoringResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "ClearMonitoringStatusEnumType": { + "description": "Result of the clear request for this monitor, identified by its Id.\r\n\r\n", + "javaType": "ClearMonitoringStatusEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Accepted", + "Rejected", + "NotFound" + ] + }, + "ClearMonitoringResultType": { + "javaType": "ClearMonitoringResult", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "status": { + "$ref": "#/definitions/ClearMonitoringStatusEnumType" + }, + "id": { + "description": "Id of the monitor of which a clear was requested.\r\n\r\n", + "type": "integer" + }, + "statusInfo": { + "$ref": "#/definitions/StatusInfoType" + } + }, + "required": [ + "status", + "id" + ] + }, + "StatusInfoType": { + "description": "Element providing more information about the status.\r\n", + "javaType": "StatusInfo", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "reasonCode": { + "description": "A predefined code for the reason why the status is returned in this response. The string is case-insensitive.\r\n", + "type": "string", + "maxLength": 20 + }, + "additionalInfo": { + "description": "Additional text to provide detailed information.\r\n", + "type": "string", + "maxLength": 512 + } + }, + "required": [ + "reasonCode" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "clearMonitoringResult": { + "type": "array", + "additionalItems": false, + "items": { + "$ref": "#/definitions/ClearMonitoringResultType" + }, + "minItems": 1 + } + }, + "required": [ + "clearMonitoringResult" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/ClearedChargingLimitRequest.json b/schemas/ocpp20/ClearedChargingLimitRequest.json new file mode 100644 index 00000000..d9e89651 --- /dev/null +++ b/schemas/ocpp20/ClearedChargingLimitRequest.json @@ -0,0 +1,50 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:ClearedChargingLimitRequest", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "ChargingLimitSourceEnumType": { + "description": "Source of the charging limit.\r\n", + "javaType": "ChargingLimitSourceEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "EMS", + "Other", + "SO", + "CSO" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "chargingLimitSource": { + "$ref": "#/definitions/ChargingLimitSourceEnumType" + }, + "evseId": { + "description": "EVSE Identifier.\r\n", + "type": "integer" + } + }, + "required": [ + "chargingLimitSource" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/ClearedChargingLimitResponse.json b/schemas/ocpp20/ClearedChargingLimitResponse.json new file mode 100644 index 00000000..d5d493af --- /dev/null +++ b/schemas/ocpp20/ClearedChargingLimitResponse.json @@ -0,0 +1,28 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:ClearedChargingLimitResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + } + } +} \ No newline at end of file diff --git a/schemas/ocpp20/CostUpdatedRequest.json b/schemas/ocpp20/CostUpdatedRequest.json new file mode 100644 index 00000000..48e7e4e5 --- /dev/null +++ b/schemas/ocpp20/CostUpdatedRequest.json @@ -0,0 +1,41 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:CostUpdatedRequest", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "totalCost": { + "description": "Current total cost, based on the information known by the CSMS, of the transaction including taxes. In the currency configured with the configuration Variable: [<<configkey-currency, Currency>>]\r\n\r\n", + "type": "number" + }, + "transactionId": { + "description": "Transaction Id of the transaction the current cost are asked for.\r\n\r\n", + "type": "string", + "maxLength": 36 + } + }, + "required": [ + "totalCost", + "transactionId" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/CostUpdatedResponse.json b/schemas/ocpp20/CostUpdatedResponse.json new file mode 100644 index 00000000..fd8cdb7b --- /dev/null +++ b/schemas/ocpp20/CostUpdatedResponse.json @@ -0,0 +1,28 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:CostUpdatedResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + } + } +} \ No newline at end of file diff --git a/schemas/ocpp20/CustomerInformationRequest.json b/schemas/ocpp20/CustomerInformationRequest.json new file mode 100644 index 00000000..537f4c39 --- /dev/null +++ b/schemas/ocpp20/CustomerInformationRequest.json @@ -0,0 +1,173 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:CustomerInformationRequest", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "HashAlgorithmEnumType": { + "description": "Used algorithms for the hashes provided.\r\n", + "javaType": "HashAlgorithmEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "SHA256", + "SHA384", + "SHA512" + ] + }, + "IdTokenEnumType": { + "description": "Enumeration of possible idToken types.\r\n", + "javaType": "IdTokenEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Central", + "eMAID", + "ISO14443", + "ISO15693", + "KeyCode", + "Local", + "MacAddress", + "NoAuthorization" + ] + }, + "AdditionalInfoType": { + "description": "Contains a case insensitive identifier to use for the authorization and the type of authorization to support multiple forms of identifiers.\r\n", + "javaType": "AdditionalInfo", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "additionalIdToken": { + "description": "This field specifies the additional IdToken.\r\n", + "type": "string", + "maxLength": 36 + }, + "type": { + "description": "This defines the type of the additionalIdToken. This is a custom type, so the implementation needs to be agreed upon by all involved parties.\r\n", + "type": "string", + "maxLength": 50 + } + }, + "required": [ + "additionalIdToken", + "type" + ] + }, + "CertificateHashDataType": { + "javaType": "CertificateHashData", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "hashAlgorithm": { + "$ref": "#/definitions/HashAlgorithmEnumType" + }, + "issuerNameHash": { + "description": "Hashed value of the Issuer DN (Distinguished Name).\r\n\r\n", + "type": "string", + "maxLength": 128 + }, + "issuerKeyHash": { + "description": "Hashed value of the issuers public key\r\n", + "type": "string", + "maxLength": 128 + }, + "serialNumber": { + "description": "The serial number of the certificate.\r\n", + "type": "string", + "maxLength": 40 + } + }, + "required": [ + "hashAlgorithm", + "issuerNameHash", + "issuerKeyHash", + "serialNumber" + ] + }, + "IdTokenType": { + "description": "Contains a case insensitive identifier to use for the authorization and the type of authorization to support multiple forms of identifiers.\r\n", + "javaType": "IdToken", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "additionalInfo": { + "type": "array", + "additionalItems": false, + "items": { + "$ref": "#/definitions/AdditionalInfoType" + }, + "minItems": 1 + }, + "idToken": { + "description": "IdToken is case insensitive. Might hold the hidden id of an RFID tag, but can for example also contain a UUID.\r\n", + "type": "string", + "maxLength": 36 + }, + "type": { + "$ref": "#/definitions/IdTokenEnumType" + } + }, + "required": [ + "idToken", + "type" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "customerCertificate": { + "$ref": "#/definitions/CertificateHashDataType" + }, + "idToken": { + "$ref": "#/definitions/IdTokenType" + }, + "requestId": { + "description": "The Id of the request.\r\n\r\n", + "type": "integer" + }, + "report": { + "description": "Flag indicating whether the Charging Station should return NotifyCustomerInformationRequest messages containing information about the customer referred to.\r\n", + "type": "boolean" + }, + "clear": { + "description": "Flag indicating whether the Charging Station should clear all information about the customer referred to.\r\n", + "type": "boolean" + }, + "customerIdentifier": { + "description": "A (e.g. vendor specific) identifier of the customer this request refers to. This field contains a custom identifier other than IdToken and Certificate.\r\nOne of the possible identifiers (customerIdentifier, customerIdToken or customerCertificate) should be in the request message.\r\n", + "type": "string", + "maxLength": 64 + } + }, + "required": [ + "requestId", + "report", + "clear" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/CustomerInformationResponse.json b/schemas/ocpp20/CustomerInformationResponse.json new file mode 100644 index 00000000..bf4049ae --- /dev/null +++ b/schemas/ocpp20/CustomerInformationResponse.json @@ -0,0 +1,72 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:CustomerInformationResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "CustomerInformationStatusEnumType": { + "description": "Indicates whether the request was accepted.\r\n", + "javaType": "CustomerInformationStatusEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Accepted", + "Rejected", + "Invalid" + ] + }, + "StatusInfoType": { + "description": "Element providing more information about the status.\r\n", + "javaType": "StatusInfo", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "reasonCode": { + "description": "A predefined code for the reason why the status is returned in this response. The string is case-insensitive.\r\n", + "type": "string", + "maxLength": 20 + }, + "additionalInfo": { + "description": "Additional text to provide detailed information.\r\n", + "type": "string", + "maxLength": 512 + } + }, + "required": [ + "reasonCode" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "status": { + "$ref": "#/definitions/CustomerInformationStatusEnumType" + }, + "statusInfo": { + "$ref": "#/definitions/StatusInfoType" + } + }, + "required": [ + "status" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/DataTransferRequest.json b/schemas/ocpp20/DataTransferRequest.json new file mode 100644 index 00000000..fb66fd5c --- /dev/null +++ b/schemas/ocpp20/DataTransferRequest.json @@ -0,0 +1,44 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:DataTransferRequest", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "messageId": { + "description": "May be used to indicate a specific message or implementation.\r\n", + "type": "string", + "maxLength": 50 + }, + "data": { + "description": "Data without specified length or format. This needs to be decided by both parties (Open to implementation).\r\n" + }, + "vendorId": { + "description": "This identifies the Vendor specific implementation\r\n\r\n", + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/DataTransferResponse.json b/schemas/ocpp20/DataTransferResponse.json new file mode 100644 index 00000000..dd638ce7 --- /dev/null +++ b/schemas/ocpp20/DataTransferResponse.json @@ -0,0 +1,76 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:DataTransferResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "DataTransferStatusEnumType": { + "description": "This indicates the success or failure of the data transfer.\r\n", + "javaType": "DataTransferStatusEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Accepted", + "Rejected", + "UnknownMessageId", + "UnknownVendorId" + ] + }, + "StatusInfoType": { + "description": "Element providing more information about the status.\r\n", + "javaType": "StatusInfo", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "reasonCode": { + "description": "A predefined code for the reason why the status is returned in this response. The string is case-insensitive.\r\n", + "type": "string", + "maxLength": 20 + }, + "additionalInfo": { + "description": "Additional text to provide detailed information.\r\n", + "type": "string", + "maxLength": 512 + } + }, + "required": [ + "reasonCode" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "status": { + "$ref": "#/definitions/DataTransferStatusEnumType" + }, + "statusInfo": { + "$ref": "#/definitions/StatusInfoType" + }, + "data": { + "description": "Data without specified length or format, in response to request.\r\n" + } + }, + "required": [ + "status" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/DeleteCertificateRequest.json b/schemas/ocpp20/DeleteCertificateRequest.json new file mode 100644 index 00000000..70b8b1b1 --- /dev/null +++ b/schemas/ocpp20/DeleteCertificateRequest.json @@ -0,0 +1,79 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:DeleteCertificateRequest", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "HashAlgorithmEnumType": { + "description": "Used algorithms for the hashes provided.\r\n", + "javaType": "HashAlgorithmEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "SHA256", + "SHA384", + "SHA512" + ] + }, + "CertificateHashDataType": { + "javaType": "CertificateHashData", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "hashAlgorithm": { + "$ref": "#/definitions/HashAlgorithmEnumType" + }, + "issuerNameHash": { + "description": "Hashed value of the Issuer DN (Distinguished Name).\r\n\r\n", + "type": "string", + "maxLength": 128 + }, + "issuerKeyHash": { + "description": "Hashed value of the issuers public key\r\n", + "type": "string", + "maxLength": 128 + }, + "serialNumber": { + "description": "The serial number of the certificate.\r\n", + "type": "string", + "maxLength": 40 + } + }, + "required": [ + "hashAlgorithm", + "issuerNameHash", + "issuerKeyHash", + "serialNumber" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "certificateHashData": { + "$ref": "#/definitions/CertificateHashDataType" + } + }, + "required": [ + "certificateHashData" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/DeleteCertificateResponse.json b/schemas/ocpp20/DeleteCertificateResponse.json new file mode 100644 index 00000000..d5d71df4 --- /dev/null +++ b/schemas/ocpp20/DeleteCertificateResponse.json @@ -0,0 +1,72 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:DeleteCertificateResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "DeleteCertificateStatusEnumType": { + "description": "Charging Station indicates if it can process the request.\r\n", + "javaType": "DeleteCertificateStatusEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Accepted", + "Failed", + "NotFound" + ] + }, + "StatusInfoType": { + "description": "Element providing more information about the status.\r\n", + "javaType": "StatusInfo", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "reasonCode": { + "description": "A predefined code for the reason why the status is returned in this response. The string is case-insensitive.\r\n", + "type": "string", + "maxLength": 20 + }, + "additionalInfo": { + "description": "Additional text to provide detailed information.\r\n", + "type": "string", + "maxLength": 512 + } + }, + "required": [ + "reasonCode" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "status": { + "$ref": "#/definitions/DeleteCertificateStatusEnumType" + }, + "statusInfo": { + "$ref": "#/definitions/StatusInfoType" + } + }, + "required": [ + "status" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/FirmwareStatusNotificationRequest.json b/schemas/ocpp20/FirmwareStatusNotificationRequest.json new file mode 100644 index 00000000..879534f8 --- /dev/null +++ b/schemas/ocpp20/FirmwareStatusNotificationRequest.json @@ -0,0 +1,60 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:FirmwareStatusNotificationRequest", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "FirmwareStatusEnumType": { + "description": "This contains the progress status of the firmware installation.\r\n", + "javaType": "FirmwareStatusEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Downloaded", + "DownloadFailed", + "Downloading", + "DownloadScheduled", + "DownloadPaused", + "Idle", + "InstallationFailed", + "Installing", + "Installed", + "InstallRebooting", + "InstallScheduled", + "InstallVerificationFailed", + "InvalidSignature", + "SignatureVerified" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "status": { + "$ref": "#/definitions/FirmwareStatusEnumType" + }, + "requestId": { + "description": "The request id that was provided in the\r\nUpdateFirmwareRequest that started this firmware update.\r\nThis field is mandatory, unless the message was triggered by a TriggerMessageRequest AND there is no firmware update ongoing.\r\n", + "type": "integer" + } + }, + "required": [ + "status" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/FirmwareStatusNotificationResponse.json b/schemas/ocpp20/FirmwareStatusNotificationResponse.json new file mode 100644 index 00000000..18673b02 --- /dev/null +++ b/schemas/ocpp20/FirmwareStatusNotificationResponse.json @@ -0,0 +1,28 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:FirmwareStatusNotificationResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + } + } +} \ No newline at end of file diff --git a/schemas/ocpp20/Get15118EVCertificateRequest.json b/schemas/ocpp20/Get15118EVCertificateRequest.json new file mode 100644 index 00000000..df24ff3b --- /dev/null +++ b/schemas/ocpp20/Get15118EVCertificateRequest.json @@ -0,0 +1,56 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:Get15118EVCertificateRequest", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "CertificateActionEnumType": { + "description": "Defines whether certificate needs to be installed or updated.\r\n", + "javaType": "CertificateActionEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Install", + "Update" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "iso15118SchemaVersion": { + "description": "Schema version currently used for the 15118 session between EV and Charging Station. Needed for parsing of the EXI stream by the CSMS.\r\n\r\n", + "type": "string", + "maxLength": 50 + }, + "action": { + "$ref": "#/definitions/CertificateActionEnumType" + }, + "exiRequest": { + "description": "Raw CertificateInstallationReq request from EV, Base64 encoded.\r\n", + "type": "string", + "maxLength": 5600 + } + }, + "required": [ + "iso15118SchemaVersion", + "action", + "exiRequest" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/Get15118EVCertificateResponse.json b/schemas/ocpp20/Get15118EVCertificateResponse.json new file mode 100644 index 00000000..20251dfd --- /dev/null +++ b/schemas/ocpp20/Get15118EVCertificateResponse.json @@ -0,0 +1,77 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:Get15118EVCertificateResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "Iso15118EVCertificateStatusEnumType": { + "description": "Indicates whether the message was processed properly.\r\n", + "javaType": "Iso15118EVCertificateStatusEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Accepted", + "Failed" + ] + }, + "StatusInfoType": { + "description": "Element providing more information about the status.\r\n", + "javaType": "StatusInfo", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "reasonCode": { + "description": "A predefined code for the reason why the status is returned in this response. The string is case-insensitive.\r\n", + "type": "string", + "maxLength": 20 + }, + "additionalInfo": { + "description": "Additional text to provide detailed information.\r\n", + "type": "string", + "maxLength": 512 + } + }, + "required": [ + "reasonCode" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "status": { + "$ref": "#/definitions/Iso15118EVCertificateStatusEnumType" + }, + "statusInfo": { + "$ref": "#/definitions/StatusInfoType" + }, + "exiResponse": { + "description": "Raw CertificateInstallationRes response for the EV, Base64 encoded.\r\n", + "type": "string", + "maxLength": 5600 + } + }, + "required": [ + "status", + "exiResponse" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/GetBaseReportRequest.json b/schemas/ocpp20/GetBaseReportRequest.json new file mode 100644 index 00000000..d59d2b29 --- /dev/null +++ b/schemas/ocpp20/GetBaseReportRequest.json @@ -0,0 +1,50 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:GetBaseReportRequest", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "ReportBaseEnumType": { + "description": "This field specifies the report base.\r\n", + "javaType": "ReportBaseEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "ConfigurationInventory", + "FullInventory", + "SummaryInventory" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "requestId": { + "description": "The Id of the request.\r\n", + "type": "integer" + }, + "reportBase": { + "$ref": "#/definitions/ReportBaseEnumType" + } + }, + "required": [ + "requestId", + "reportBase" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/GetBaseReportResponse.json b/schemas/ocpp20/GetBaseReportResponse.json new file mode 100644 index 00000000..8abe9402 --- /dev/null +++ b/schemas/ocpp20/GetBaseReportResponse.json @@ -0,0 +1,73 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:GetBaseReportResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "GenericDeviceModelStatusEnumType": { + "description": "This indicates whether the Charging Station is able to accept this request.\r\n", + "javaType": "GenericDeviceModelStatusEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Accepted", + "Rejected", + "NotSupported", + "EmptyResultSet" + ] + }, + "StatusInfoType": { + "description": "Element providing more information about the status.\r\n", + "javaType": "StatusInfo", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "reasonCode": { + "description": "A predefined code for the reason why the status is returned in this response. The string is case-insensitive.\r\n", + "type": "string", + "maxLength": 20 + }, + "additionalInfo": { + "description": "Additional text to provide detailed information.\r\n", + "type": "string", + "maxLength": 512 + } + }, + "required": [ + "reasonCode" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "status": { + "$ref": "#/definitions/GenericDeviceModelStatusEnumType" + }, + "statusInfo": { + "$ref": "#/definitions/StatusInfoType" + } + }, + "required": [ + "status" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/GetCertificateStatusRequest.json b/schemas/ocpp20/GetCertificateStatusRequest.json new file mode 100644 index 00000000..d9a8a0bc --- /dev/null +++ b/schemas/ocpp20/GetCertificateStatusRequest.json @@ -0,0 +1,85 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:GetCertificateStatusRequest", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "HashAlgorithmEnumType": { + "description": "Used algorithms for the hashes provided.\r\n", + "javaType": "HashAlgorithmEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "SHA256", + "SHA384", + "SHA512" + ] + }, + "OCSPRequestDataType": { + "javaType": "OCSPRequestData", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "hashAlgorithm": { + "$ref": "#/definitions/HashAlgorithmEnumType" + }, + "issuerNameHash": { + "description": "Hashed value of the Issuer DN (Distinguished Name).\r\n\r\n", + "type": "string", + "maxLength": 128 + }, + "issuerKeyHash": { + "description": "Hashed value of the issuers public key\r\n", + "type": "string", + "maxLength": 128 + }, + "serialNumber": { + "description": "The serial number of the certificate.\r\n", + "type": "string", + "maxLength": 40 + }, + "responderURL": { + "description": "This contains the responder URL (Case insensitive). \r\n\r\n", + "type": "string", + "maxLength": 512 + } + }, + "required": [ + "hashAlgorithm", + "issuerNameHash", + "issuerKeyHash", + "serialNumber", + "responderURL" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "ocspRequestData": { + "$ref": "#/definitions/OCSPRequestDataType" + } + }, + "required": [ + "ocspRequestData" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/GetCertificateStatusResponse.json b/schemas/ocpp20/GetCertificateStatusResponse.json new file mode 100644 index 00000000..e8ef4c85 --- /dev/null +++ b/schemas/ocpp20/GetCertificateStatusResponse.json @@ -0,0 +1,76 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:GetCertificateStatusResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "GetCertificateStatusEnumType": { + "description": "This indicates whether the charging station was able to retrieve the OCSP certificate status.\r\n", + "javaType": "GetCertificateStatusEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Accepted", + "Failed" + ] + }, + "StatusInfoType": { + "description": "Element providing more information about the status.\r\n", + "javaType": "StatusInfo", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "reasonCode": { + "description": "A predefined code for the reason why the status is returned in this response. The string is case-insensitive.\r\n", + "type": "string", + "maxLength": 20 + }, + "additionalInfo": { + "description": "Additional text to provide detailed information.\r\n", + "type": "string", + "maxLength": 512 + } + }, + "required": [ + "reasonCode" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "status": { + "$ref": "#/definitions/GetCertificateStatusEnumType" + }, + "statusInfo": { + "$ref": "#/definitions/StatusInfoType" + }, + "ocspResult": { + "description": "OCSPResponse class as defined in <<ref-ocpp_security_24, IETF RFC 6960>>. DER encoded (as defined in <<ref-ocpp_security_24, IETF RFC 6960>>), and then base64 encoded. MAY only be omitted when status is not Accepted.\r\n", + "type": "string", + "maxLength": 5500 + } + }, + "required": [ + "status" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/GetChargingProfilesRequest.json b/schemas/ocpp20/GetChargingProfilesRequest.json new file mode 100644 index 00000000..a0365539 --- /dev/null +++ b/schemas/ocpp20/GetChargingProfilesRequest.json @@ -0,0 +1,103 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:GetChargingProfilesRequest", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "ChargingLimitSourceEnumType": { + "javaType": "ChargingLimitSourceEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "EMS", + "Other", + "SO", + "CSO" + ] + }, + "ChargingProfilePurposeEnumType": { + "description": "Charging_ Profile. Charging_ Profile_ Purpose. Charging_ Profile_ Purpose_ Code\r\nurn:x-oca:ocpp:uid:1:569231\r\nDefines the purpose of the schedule transferred by this profile\r\n", + "javaType": "ChargingProfilePurposeEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "ChargingStationExternalConstraints", + "ChargingStationMaxProfile", + "TxDefaultProfile", + "TxProfile" + ] + }, + "ChargingProfileCriterionType": { + "description": "Charging_ Profile\r\nurn:x-oca:ocpp:uid:2:233255\r\nA ChargingProfile consists of ChargingSchedule, describing the amount of power or current that can be delivered per time interval.\r\n", + "javaType": "ChargingProfileCriterion", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "chargingProfilePurpose": { + "$ref": "#/definitions/ChargingProfilePurposeEnumType" + }, + "stackLevel": { + "description": "Charging_ Profile. Stack_ Level. Counter\r\nurn:x-oca:ocpp:uid:1:569230\r\nValue determining level in hierarchy stack of profiles. Higher values have precedence over lower values. Lowest level is 0.\r\n", + "type": "integer" + }, + "chargingProfileId": { + "description": "List of all the chargingProfileIds requested. Any ChargingProfile that matches one of these profiles will be reported. If omitted, the Charging Station SHALL not filter on chargingProfileId. This field SHALL NOT contain more ids than set in <<configkey-charging-profile-entries,ChargingProfileEntries.maxLimit>>\r\n\r\n", + "type": "array", + "additionalItems": false, + "items": { + "type": "integer" + }, + "minItems": 1 + }, + "chargingLimitSource": { + "description": "For which charging limit sources, charging profiles SHALL be reported. If omitted, the Charging Station SHALL not filter on chargingLimitSource.\r\n", + "type": "array", + "additionalItems": false, + "items": { + "$ref": "#/definitions/ChargingLimitSourceEnumType" + }, + "minItems": 1, + "maxItems": 4 + } + } + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "requestId": { + "description": "Reference identification that is to be used by the Charging Station in the <<reportchargingprofilesrequest, ReportChargingProfilesRequest>> when provided.\r\n", + "type": "integer" + }, + "evseId": { + "description": "For which EVSE installed charging profiles SHALL be reported. If 0, only charging profiles installed on the Charging Station itself (the grid connection) SHALL be reported. If omitted, all installed charging profiles SHALL be reported.\r\n", + "type": "integer" + }, + "chargingProfile": { + "$ref": "#/definitions/ChargingProfileCriterionType" + } + }, + "required": [ + "requestId", + "chargingProfile" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/GetChargingProfilesResponse.json b/schemas/ocpp20/GetChargingProfilesResponse.json new file mode 100644 index 00000000..a77ae711 --- /dev/null +++ b/schemas/ocpp20/GetChargingProfilesResponse.json @@ -0,0 +1,71 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:GetChargingProfilesResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "GetChargingProfileStatusEnumType": { + "description": "This indicates whether the Charging Station is able to process this request and will send <<reportchargingprofilesrequest, ReportChargingProfilesRequest>> messages.\r\n", + "javaType": "GetChargingProfileStatusEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Accepted", + "NoProfiles" + ] + }, + "StatusInfoType": { + "description": "Element providing more information about the status.\r\n", + "javaType": "StatusInfo", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "reasonCode": { + "description": "A predefined code for the reason why the status is returned in this response. The string is case-insensitive.\r\n", + "type": "string", + "maxLength": 20 + }, + "additionalInfo": { + "description": "Additional text to provide detailed information.\r\n", + "type": "string", + "maxLength": 512 + } + }, + "required": [ + "reasonCode" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "status": { + "$ref": "#/definitions/GetChargingProfileStatusEnumType" + }, + "statusInfo": { + "$ref": "#/definitions/StatusInfoType" + } + }, + "required": [ + "status" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/GetCompositeScheduleRequest.json b/schemas/ocpp20/GetCompositeScheduleRequest.json new file mode 100644 index 00000000..1ced49b0 --- /dev/null +++ b/schemas/ocpp20/GetCompositeScheduleRequest.json @@ -0,0 +1,53 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:GetCompositeScheduleRequest", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "ChargingRateUnitEnumType": { + "description": "Can be used to force a power or current profile.\r\n\r\n", + "javaType": "ChargingRateUnitEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "W", + "A" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "duration": { + "description": "Length of the requested schedule in seconds.\r\n\r\n", + "type": "integer" + }, + "chargingRateUnit": { + "$ref": "#/definitions/ChargingRateUnitEnumType" + }, + "evseId": { + "description": "The ID of the EVSE for which the schedule is requested. When evseid=0, the Charging Station will calculate the expected consumption for the grid connection.\r\n", + "type": "integer" + } + }, + "required": [ + "duration", + "evseId" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/GetCompositeScheduleResponse.json b/schemas/ocpp20/GetCompositeScheduleResponse.json new file mode 100644 index 00000000..580637d8 --- /dev/null +++ b/schemas/ocpp20/GetCompositeScheduleResponse.json @@ -0,0 +1,157 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:GetCompositeScheduleResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "ChargingRateUnitEnumType": { + "description": "The unit of measure Limit is\r\nexpressed in.\r\n", + "javaType": "ChargingRateUnitEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "W", + "A" + ] + }, + "GenericStatusEnumType": { + "description": "The Charging Station will indicate if it was\r\nable to process the request\r\n", + "javaType": "GenericStatusEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Accepted", + "Rejected" + ] + }, + "ChargingSchedulePeriodType": { + "description": "Charging_ Schedule_ Period\r\nurn:x-oca:ocpp:uid:2:233257\r\nCharging schedule period structure defines a time period in a charging schedule.\r\n", + "javaType": "ChargingSchedulePeriod", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "startPeriod": { + "description": "Charging_ Schedule_ Period. Start_ Period. Elapsed_ Time\r\nurn:x-oca:ocpp:uid:1:569240\r\nStart of the period, in seconds from the start of schedule. The value of StartPeriod also defines the stop time of the previous period.\r\n", + "type": "integer" + }, + "limit": { + "description": "Charging_ Schedule_ Period. Limit. Measure\r\nurn:x-oca:ocpp:uid:1:569241\r\nCharging rate limit during the schedule period, in the applicable chargingRateUnit, for example in Amperes (A) or Watts (W). Accepts at most one digit fraction (e.g. 8.1).\r\n", + "type": "number" + }, + "numberPhases": { + "description": "Charging_ Schedule_ Period. Number_ Phases. Counter\r\nurn:x-oca:ocpp:uid:1:569242\r\nThe number of phases that can be used for charging. If a number of phases is needed, numberPhases=3 will be assumed unless another number is given.\r\n", + "type": "integer" + }, + "phaseToUse": { + "description": "Values: 1..3, Used if numberPhases=1 and if the EVSE is capable of switching the phase connected to the EV, i.e. ACPhaseSwitchingSupported is defined and true. It’s not allowed unless both conditions above are true. If both conditions are true, and phaseToUse is omitted, the Charging Station / EVSE will make the selection on its own.\r\n\r\n", + "type": "integer" + } + }, + "required": [ + "startPeriod", + "limit" + ] + }, + "CompositeScheduleType": { + "description": "Composite_ Schedule\r\nurn:x-oca:ocpp:uid:2:233362\r\n", + "javaType": "CompositeSchedule", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "chargingSchedulePeriod": { + "type": "array", + "additionalItems": false, + "items": { + "$ref": "#/definitions/ChargingSchedulePeriodType" + }, + "minItems": 1 + }, + "evseId": { + "description": "The ID of the EVSE for which the\r\nschedule is requested. When evseid=0, the\r\nCharging Station calculated the expected\r\nconsumption for the grid connection.\r\n", + "type": "integer" + }, + "duration": { + "description": "Duration of the schedule in seconds.\r\n", + "type": "integer" + }, + "scheduleStart": { + "description": "Composite_ Schedule. Start. Date_ Time\r\nurn:x-oca:ocpp:uid:1:569456\r\nDate and time at which the schedule becomes active. All time measurements within the schedule are relative to this timestamp.\r\n", + "type": "string", + "format": "date-time" + }, + "chargingRateUnit": { + "$ref": "#/definitions/ChargingRateUnitEnumType" + } + }, + "required": [ + "evseId", + "duration", + "scheduleStart", + "chargingRateUnit", + "chargingSchedulePeriod" + ] + }, + "StatusInfoType": { + "description": "Element providing more information about the status.\r\n", + "javaType": "StatusInfo", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "reasonCode": { + "description": "A predefined code for the reason why the status is returned in this response. The string is case-insensitive.\r\n", + "type": "string", + "maxLength": 20 + }, + "additionalInfo": { + "description": "Additional text to provide detailed information.\r\n", + "type": "string", + "maxLength": 512 + } + }, + "required": [ + "reasonCode" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "status": { + "$ref": "#/definitions/GenericStatusEnumType" + }, + "statusInfo": { + "$ref": "#/definitions/StatusInfoType" + }, + "schedule": { + "$ref": "#/definitions/CompositeScheduleType" + } + }, + "required": [ + "status" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/GetDisplayMessagesRequest.json b/schemas/ocpp20/GetDisplayMessagesRequest.json new file mode 100644 index 00000000..9f2bbdc6 --- /dev/null +++ b/schemas/ocpp20/GetDisplayMessagesRequest.json @@ -0,0 +1,73 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:GetDisplayMessagesRequest", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "MessagePriorityEnumType": { + "description": "If provided the Charging Station shall return Display Messages with the given priority only.\r\n", + "javaType": "MessagePriorityEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "AlwaysFront", + "InFront", + "NormalCycle" + ] + }, + "MessageStateEnumType": { + "description": "If provided the Charging Station shall return Display Messages with the given state only. \r\n", + "javaType": "MessageStateEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Charging", + "Faulted", + "Idle", + "Unavailable" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "id": { + "description": "If provided the Charging Station shall return Display Messages of the given ids. This field SHALL NOT contain more ids than set in <<configkey-number-of-display-messages,NumberOfDisplayMessages.maxLimit>>\r\n\r\n", + "type": "array", + "additionalItems": false, + "items": { + "type": "integer" + }, + "minItems": 1 + }, + "requestId": { + "description": "The Id of this request.\r\n", + "type": "integer" + }, + "priority": { + "$ref": "#/definitions/MessagePriorityEnumType" + }, + "state": { + "$ref": "#/definitions/MessageStateEnumType" + } + }, + "required": [ + "requestId" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/GetDisplayMessagesResponse.json b/schemas/ocpp20/GetDisplayMessagesResponse.json new file mode 100644 index 00000000..3d9f9060 --- /dev/null +++ b/schemas/ocpp20/GetDisplayMessagesResponse.json @@ -0,0 +1,71 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:GetDisplayMessagesResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "GetDisplayMessagesStatusEnumType": { + "description": "Indicates if the Charging Station has Display Messages that match the request criteria in the <<getdisplaymessagesrequest,GetDisplayMessagesRequest>>\r\n", + "javaType": "GetDisplayMessagesStatusEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Accepted", + "Unknown" + ] + }, + "StatusInfoType": { + "description": "Element providing more information about the status.\r\n", + "javaType": "StatusInfo", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "reasonCode": { + "description": "A predefined code for the reason why the status is returned in this response. The string is case-insensitive.\r\n", + "type": "string", + "maxLength": 20 + }, + "additionalInfo": { + "description": "Additional text to provide detailed information.\r\n", + "type": "string", + "maxLength": 512 + } + }, + "required": [ + "reasonCode" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "status": { + "$ref": "#/definitions/GetDisplayMessagesStatusEnumType" + }, + "statusInfo": { + "$ref": "#/definitions/StatusInfoType" + } + }, + "required": [ + "status" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/GetInstalledCertificateIdsRequest.json b/schemas/ocpp20/GetInstalledCertificateIdsRequest.json new file mode 100644 index 00000000..b9b52344 --- /dev/null +++ b/schemas/ocpp20/GetInstalledCertificateIdsRequest.json @@ -0,0 +1,49 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:GetInstalledCertificateIdsRequest", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "GetCertificateIdUseEnumType": { + "javaType": "GetCertificateIdUseEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "V2GRootCertificate", + "MORootCertificate", + "CSMSRootCertificate", + "V2GCertificateChain", + "ManufacturerRootCertificate" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "certificateType": { + "description": "Indicates the type of certificates requested. When omitted, all certificate types are requested.\r\n", + "type": "array", + "additionalItems": false, + "items": { + "$ref": "#/definitions/GetCertificateIdUseEnumType" + }, + "minItems": 1 + } + } +} \ No newline at end of file diff --git a/schemas/ocpp20/GetInstalledCertificateIdsResponse.json b/schemas/ocpp20/GetInstalledCertificateIdsResponse.json new file mode 100644 index 00000000..a6558746 --- /dev/null +++ b/schemas/ocpp20/GetInstalledCertificateIdsResponse.json @@ -0,0 +1,166 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:GetInstalledCertificateIdsResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "GetCertificateIdUseEnumType": { + "description": "Indicates the type of the requested certificate(s).\r\n", + "javaType": "GetCertificateIdUseEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "V2GRootCertificate", + "MORootCertificate", + "CSMSRootCertificate", + "V2GCertificateChain", + "ManufacturerRootCertificate" + ] + }, + "GetInstalledCertificateStatusEnumType": { + "description": "Charging Station indicates if it can process the request.\r\n", + "javaType": "GetInstalledCertificateStatusEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Accepted", + "NotFound" + ] + }, + "HashAlgorithmEnumType": { + "description": "Used algorithms for the hashes provided.\r\n", + "javaType": "HashAlgorithmEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "SHA256", + "SHA384", + "SHA512" + ] + }, + "CertificateHashDataChainType": { + "javaType": "CertificateHashDataChain", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "certificateHashData": { + "$ref": "#/definitions/CertificateHashDataType" + }, + "certificateType": { + "$ref": "#/definitions/GetCertificateIdUseEnumType" + }, + "childCertificateHashData": { + "type": "array", + "additionalItems": false, + "items": { + "$ref": "#/definitions/CertificateHashDataType" + }, + "minItems": 1, + "maxItems": 4 + } + }, + "required": [ + "certificateType", + "certificateHashData" + ] + }, + "CertificateHashDataType": { + "javaType": "CertificateHashData", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "hashAlgorithm": { + "$ref": "#/definitions/HashAlgorithmEnumType" + }, + "issuerNameHash": { + "description": "Hashed value of the Issuer DN (Distinguished Name).\r\n\r\n", + "type": "string", + "maxLength": 128 + }, + "issuerKeyHash": { + "description": "Hashed value of the issuers public key\r\n", + "type": "string", + "maxLength": 128 + }, + "serialNumber": { + "description": "The serial number of the certificate.\r\n", + "type": "string", + "maxLength": 40 + } + }, + "required": [ + "hashAlgorithm", + "issuerNameHash", + "issuerKeyHash", + "serialNumber" + ] + }, + "StatusInfoType": { + "description": "Element providing more information about the status.\r\n", + "javaType": "StatusInfo", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "reasonCode": { + "description": "A predefined code for the reason why the status is returned in this response. The string is case-insensitive.\r\n", + "type": "string", + "maxLength": 20 + }, + "additionalInfo": { + "description": "Additional text to provide detailed information.\r\n", + "type": "string", + "maxLength": 512 + } + }, + "required": [ + "reasonCode" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "status": { + "$ref": "#/definitions/GetInstalledCertificateStatusEnumType" + }, + "statusInfo": { + "$ref": "#/definitions/StatusInfoType" + }, + "certificateHashDataChain": { + "type": "array", + "additionalItems": false, + "items": { + "$ref": "#/definitions/CertificateHashDataChainType" + }, + "minItems": 1 + } + }, + "required": [ + "status" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/GetLocalListVersionRequest.json b/schemas/ocpp20/GetLocalListVersionRequest.json new file mode 100644 index 00000000..cf65d0c0 --- /dev/null +++ b/schemas/ocpp20/GetLocalListVersionRequest.json @@ -0,0 +1,28 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:GetLocalListVersionRequest", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + } + } +} \ No newline at end of file diff --git a/schemas/ocpp20/GetLocalListVersionResponse.json b/schemas/ocpp20/GetLocalListVersionResponse.json new file mode 100644 index 00000000..418d4a3f --- /dev/null +++ b/schemas/ocpp20/GetLocalListVersionResponse.json @@ -0,0 +1,35 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:GetLocalListVersionResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "versionNumber": { + "description": "This contains the current version number of the local authorization list in the Charging Station.\r\n", + "type": "integer" + } + }, + "required": [ + "versionNumber" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/GetLogRequest.json b/schemas/ocpp20/GetLogRequest.json new file mode 100644 index 00000000..4d57dd0c --- /dev/null +++ b/schemas/ocpp20/GetLogRequest.json @@ -0,0 +1,90 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:GetLogRequest", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "LogEnumType": { + "description": "This contains the type of log file that the Charging Station\r\nshould send.\r\n", + "javaType": "LogEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "DiagnosticsLog", + "SecurityLog" + ] + }, + "LogParametersType": { + "description": "Log\r\nurn:x-enexis:ecdm:uid:2:233373\r\nGeneric class for the configuration of logging entries.\r\n", + "javaType": "LogParameters", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "remoteLocation": { + "description": "Log. Remote_ Location. URI\r\nurn:x-enexis:ecdm:uid:1:569484\r\nThe URL of the location at the remote system where the log should be stored.\r\n", + "type": "string", + "maxLength": 512 + }, + "oldestTimestamp": { + "description": "Log. Oldest_ Timestamp. Date_ Time\r\nurn:x-enexis:ecdm:uid:1:569477\r\nThis contains the date and time of the oldest logging information to include in the diagnostics.\r\n", + "type": "string", + "format": "date-time" + }, + "latestTimestamp": { + "description": "Log. Latest_ Timestamp. Date_ Time\r\nurn:x-enexis:ecdm:uid:1:569482\r\nThis contains the date and time of the latest logging information to include in the diagnostics.\r\n", + "type": "string", + "format": "date-time" + } + }, + "required": [ + "remoteLocation" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "log": { + "$ref": "#/definitions/LogParametersType" + }, + "logType": { + "$ref": "#/definitions/LogEnumType" + }, + "requestId": { + "description": "The Id of this request\r\n", + "type": "integer" + }, + "retries": { + "description": "This specifies how many times the Charging Station must try to upload the log before giving up. If this field is not present, it is left to Charging Station to decide how many times it wants to retry.\r\n", + "type": "integer" + }, + "retryInterval": { + "description": "The interval in seconds after which a retry may be attempted. If this field is not present, it is left to Charging Station to decide how long to wait between attempts.\r\n", + "type": "integer" + } + }, + "required": [ + "logType", + "requestId", + "log" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/GetLogResponse.json b/schemas/ocpp20/GetLogResponse.json new file mode 100644 index 00000000..fda74cd8 --- /dev/null +++ b/schemas/ocpp20/GetLogResponse.json @@ -0,0 +1,77 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:GetLogResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "LogStatusEnumType": { + "description": "This field indicates whether the Charging Station was able to accept the request.\r\n", + "javaType": "LogStatusEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Accepted", + "Rejected", + "AcceptedCanceled" + ] + }, + "StatusInfoType": { + "description": "Element providing more information about the status.\r\n", + "javaType": "StatusInfo", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "reasonCode": { + "description": "A predefined code for the reason why the status is returned in this response. The string is case-insensitive.\r\n", + "type": "string", + "maxLength": 20 + }, + "additionalInfo": { + "description": "Additional text to provide detailed information.\r\n", + "type": "string", + "maxLength": 512 + } + }, + "required": [ + "reasonCode" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "status": { + "$ref": "#/definitions/LogStatusEnumType" + }, + "statusInfo": { + "$ref": "#/definitions/StatusInfoType" + }, + "filename": { + "description": "This contains the name of the log file that will be uploaded. This field is not present when no logging information is available.\r\n", + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "status" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/GetMonitoringReportRequest.json b/schemas/ocpp20/GetMonitoringReportRequest.json new file mode 100644 index 00000000..b2bb432d --- /dev/null +++ b/schemas/ocpp20/GetMonitoringReportRequest.json @@ -0,0 +1,156 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:GetMonitoringReportRequest", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "MonitoringCriterionEnumType": { + "javaType": "MonitoringCriterionEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "ThresholdMonitoring", + "DeltaMonitoring", + "PeriodicMonitoring" + ] + }, + "ComponentType": { + "description": "A physical or logical component\r\n", + "javaType": "Component", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "evse": { + "$ref": "#/definitions/EVSEType" + }, + "name": { + "description": "Name of the component. Name should be taken from the list of standardized component names whenever possible. Case Insensitive. strongly advised to use Camel Case.\r\n", + "type": "string", + "maxLength": 50 + }, + "instance": { + "description": "Name of instance in case the component exists as multiple instances. Case Insensitive. strongly advised to use Camel Case.\r\n", + "type": "string", + "maxLength": 50 + } + }, + "required": [ + "name" + ] + }, + "ComponentVariableType": { + "description": "Class to report components, variables and variable attributes and characteristics.\r\n", + "javaType": "ComponentVariable", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "component": { + "$ref": "#/definitions/ComponentType" + }, + "variable": { + "$ref": "#/definitions/VariableType" + } + }, + "required": [ + "component" + ] + }, + "EVSEType": { + "description": "EVSE\r\nurn:x-oca:ocpp:uid:2:233123\r\nElectric Vehicle Supply Equipment\r\n", + "javaType": "EVSE", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "id": { + "description": "Identified_ Object. MRID. Numeric_ Identifier\r\nurn:x-enexis:ecdm:uid:1:569198\r\nEVSE Identifier. This contains a number (> 0) designating an EVSE of the Charging Station.\r\n", + "type": "integer" + }, + "connectorId": { + "description": "An id to designate a specific connector (on an EVSE) by connector index number.\r\n", + "type": "integer" + } + }, + "required": [ + "id" + ] + }, + "VariableType": { + "description": "Reference key to a component-variable.\r\n", + "javaType": "Variable", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "name": { + "description": "Name of the variable. Name should be taken from the list of standardized variable names whenever possible. Case Insensitive. strongly advised to use Camel Case.\r\n", + "type": "string", + "maxLength": 50 + }, + "instance": { + "description": "Name of instance in case the variable exists as multiple instances. Case Insensitive. strongly advised to use Camel Case.\r\n", + "type": "string", + "maxLength": 50 + } + }, + "required": [ + "name" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "componentVariable": { + "type": "array", + "additionalItems": false, + "items": { + "$ref": "#/definitions/ComponentVariableType" + }, + "minItems": 1 + }, + "requestId": { + "description": "The Id of the request.\r\n", + "type": "integer" + }, + "monitoringCriteria": { + "description": "This field contains criteria for components for which a monitoring report is requested\r\n", + "type": "array", + "additionalItems": false, + "items": { + "$ref": "#/definitions/MonitoringCriterionEnumType" + }, + "minItems": 1, + "maxItems": 3 + } + }, + "required": [ + "requestId" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/GetMonitoringReportResponse.json b/schemas/ocpp20/GetMonitoringReportResponse.json new file mode 100644 index 00000000..9a672fac --- /dev/null +++ b/schemas/ocpp20/GetMonitoringReportResponse.json @@ -0,0 +1,73 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:GetMonitoringReportResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "GenericDeviceModelStatusEnumType": { + "description": "This field indicates whether the Charging Station was able to accept the request.\r\n", + "javaType": "GenericDeviceModelStatusEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Accepted", + "Rejected", + "NotSupported", + "EmptyResultSet" + ] + }, + "StatusInfoType": { + "description": "Element providing more information about the status.\r\n", + "javaType": "StatusInfo", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "reasonCode": { + "description": "A predefined code for the reason why the status is returned in this response. The string is case-insensitive.\r\n", + "type": "string", + "maxLength": 20 + }, + "additionalInfo": { + "description": "Additional text to provide detailed information.\r\n", + "type": "string", + "maxLength": 512 + } + }, + "required": [ + "reasonCode" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "status": { + "$ref": "#/definitions/GenericDeviceModelStatusEnumType" + }, + "statusInfo": { + "$ref": "#/definitions/StatusInfoType" + } + }, + "required": [ + "status" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/GetReportRequest.json b/schemas/ocpp20/GetReportRequest.json new file mode 100644 index 00000000..fb457c29 --- /dev/null +++ b/schemas/ocpp20/GetReportRequest.json @@ -0,0 +1,157 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:GetReportRequest", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "ComponentCriterionEnumType": { + "javaType": "ComponentCriterionEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Active", + "Available", + "Enabled", + "Problem" + ] + }, + "ComponentType": { + "description": "A physical or logical component\r\n", + "javaType": "Component", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "evse": { + "$ref": "#/definitions/EVSEType" + }, + "name": { + "description": "Name of the component. Name should be taken from the list of standardized component names whenever possible. Case Insensitive. strongly advised to use Camel Case.\r\n", + "type": "string", + "maxLength": 50 + }, + "instance": { + "description": "Name of instance in case the component exists as multiple instances. Case Insensitive. strongly advised to use Camel Case.\r\n", + "type": "string", + "maxLength": 50 + } + }, + "required": [ + "name" + ] + }, + "ComponentVariableType": { + "description": "Class to report components, variables and variable attributes and characteristics.\r\n", + "javaType": "ComponentVariable", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "component": { + "$ref": "#/definitions/ComponentType" + }, + "variable": { + "$ref": "#/definitions/VariableType" + } + }, + "required": [ + "component" + ] + }, + "EVSEType": { + "description": "EVSE\r\nurn:x-oca:ocpp:uid:2:233123\r\nElectric Vehicle Supply Equipment\r\n", + "javaType": "EVSE", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "id": { + "description": "Identified_ Object. MRID. Numeric_ Identifier\r\nurn:x-enexis:ecdm:uid:1:569198\r\nEVSE Identifier. This contains a number (> 0) designating an EVSE of the Charging Station.\r\n", + "type": "integer" + }, + "connectorId": { + "description": "An id to designate a specific connector (on an EVSE) by connector index number.\r\n", + "type": "integer" + } + }, + "required": [ + "id" + ] + }, + "VariableType": { + "description": "Reference key to a component-variable.\r\n", + "javaType": "Variable", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "name": { + "description": "Name of the variable. Name should be taken from the list of standardized variable names whenever possible. Case Insensitive. strongly advised to use Camel Case.\r\n", + "type": "string", + "maxLength": 50 + }, + "instance": { + "description": "Name of instance in case the variable exists as multiple instances. Case Insensitive. strongly advised to use Camel Case.\r\n", + "type": "string", + "maxLength": 50 + } + }, + "required": [ + "name" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "componentVariable": { + "type": "array", + "additionalItems": false, + "items": { + "$ref": "#/definitions/ComponentVariableType" + }, + "minItems": 1 + }, + "requestId": { + "description": "The Id of the request.\r\n", + "type": "integer" + }, + "componentCriteria": { + "description": "This field contains criteria for components for which a report is requested\r\n", + "type": "array", + "additionalItems": false, + "items": { + "$ref": "#/definitions/ComponentCriterionEnumType" + }, + "minItems": 1, + "maxItems": 4 + } + }, + "required": [ + "requestId" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/GetReportResponse.json b/schemas/ocpp20/GetReportResponse.json new file mode 100644 index 00000000..0678eb0f --- /dev/null +++ b/schemas/ocpp20/GetReportResponse.json @@ -0,0 +1,73 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:GetReportResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "GenericDeviceModelStatusEnumType": { + "description": "This field indicates whether the Charging Station was able to accept the request.\r\n", + "javaType": "GenericDeviceModelStatusEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Accepted", + "Rejected", + "NotSupported", + "EmptyResultSet" + ] + }, + "StatusInfoType": { + "description": "Element providing more information about the status.\r\n", + "javaType": "StatusInfo", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "reasonCode": { + "description": "A predefined code for the reason why the status is returned in this response. The string is case-insensitive.\r\n", + "type": "string", + "maxLength": 20 + }, + "additionalInfo": { + "description": "Additional text to provide detailed information.\r\n", + "type": "string", + "maxLength": 512 + } + }, + "required": [ + "reasonCode" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "status": { + "$ref": "#/definitions/GenericDeviceModelStatusEnumType" + }, + "statusInfo": { + "$ref": "#/definitions/StatusInfoType" + } + }, + "required": [ + "status" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/GetTransactionStatusRequest.json b/schemas/ocpp20/GetTransactionStatusRequest.json new file mode 100644 index 00000000..8ec8d099 --- /dev/null +++ b/schemas/ocpp20/GetTransactionStatusRequest.json @@ -0,0 +1,33 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:GetTransactionStatusRequest", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "transactionId": { + "description": "The Id of the transaction for which the status is requested.\r\n", + "type": "string", + "maxLength": 36 + } + } +} \ No newline at end of file diff --git a/schemas/ocpp20/GetTransactionStatusResponse.json b/schemas/ocpp20/GetTransactionStatusResponse.json new file mode 100644 index 00000000..b7119c4a --- /dev/null +++ b/schemas/ocpp20/GetTransactionStatusResponse.json @@ -0,0 +1,39 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:GetTransactionStatusResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "ongoingIndicator": { + "description": "Whether the transaction is still ongoing.\r\n", + "type": "boolean" + }, + "messagesInQueue": { + "description": "Whether there are still message to be delivered.\r\n", + "type": "boolean" + } + }, + "required": [ + "messagesInQueue" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/GetVariablesRequest.json b/schemas/ocpp20/GetVariablesRequest.json new file mode 100644 index 00000000..467c10a5 --- /dev/null +++ b/schemas/ocpp20/GetVariablesRequest.json @@ -0,0 +1,149 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:GetVariablesRequest", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "AttributeEnumType": { + "description": "Attribute type for which value is requested. When absent, default Actual is assumed.\r\n", + "javaType": "AttributeEnum", + "type": "string", + "default": "Actual", + "additionalProperties": false, + "enum": [ + "Actual", + "Target", + "MinSet", + "MaxSet" + ] + }, + "ComponentType": { + "description": "A physical or logical component\r\n", + "javaType": "Component", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "evse": { + "$ref": "#/definitions/EVSEType" + }, + "name": { + "description": "Name of the component. Name should be taken from the list of standardized component names whenever possible. Case Insensitive. strongly advised to use Camel Case.\r\n", + "type": "string", + "maxLength": 50 + }, + "instance": { + "description": "Name of instance in case the component exists as multiple instances. Case Insensitive. strongly advised to use Camel Case.\r\n", + "type": "string", + "maxLength": 50 + } + }, + "required": [ + "name" + ] + }, + "EVSEType": { + "description": "EVSE\r\nurn:x-oca:ocpp:uid:2:233123\r\nElectric Vehicle Supply Equipment\r\n", + "javaType": "EVSE", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "id": { + "description": "Identified_ Object. MRID. Numeric_ Identifier\r\nurn:x-enexis:ecdm:uid:1:569198\r\nEVSE Identifier. This contains a number (> 0) designating an EVSE of the Charging Station.\r\n", + "type": "integer" + }, + "connectorId": { + "description": "An id to designate a specific connector (on an EVSE) by connector index number.\r\n", + "type": "integer" + } + }, + "required": [ + "id" + ] + }, + "GetVariableDataType": { + "description": "Class to hold parameters for GetVariables request.\r\n", + "javaType": "GetVariableData", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "attributeType": { + "$ref": "#/definitions/AttributeEnumType" + }, + "component": { + "$ref": "#/definitions/ComponentType" + }, + "variable": { + "$ref": "#/definitions/VariableType" + } + }, + "required": [ + "component", + "variable" + ] + }, + "VariableType": { + "description": "Reference key to a component-variable.\r\n", + "javaType": "Variable", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "name": { + "description": "Name of the variable. Name should be taken from the list of standardized variable names whenever possible. Case Insensitive. strongly advised to use Camel Case.\r\n", + "type": "string", + "maxLength": 50 + }, + "instance": { + "description": "Name of instance in case the variable exists as multiple instances. Case Insensitive. strongly advised to use Camel Case.\r\n", + "type": "string", + "maxLength": 50 + } + }, + "required": [ + "name" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "getVariableData": { + "type": "array", + "additionalItems": false, + "items": { + "$ref": "#/definitions/GetVariableDataType" + }, + "minItems": 1 + } + }, + "required": [ + "getVariableData" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/GetVariablesResponse.json b/schemas/ocpp20/GetVariablesResponse.json new file mode 100644 index 00000000..c77a664f --- /dev/null +++ b/schemas/ocpp20/GetVariablesResponse.json @@ -0,0 +1,198 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:GetVariablesResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "AttributeEnumType": { + "description": "Attribute type for which value is requested. When absent, default Actual is assumed.\r\n", + "javaType": "AttributeEnum", + "type": "string", + "default": "Actual", + "additionalProperties": false, + "enum": [ + "Actual", + "Target", + "MinSet", + "MaxSet" + ] + }, + "GetVariableStatusEnumType": { + "description": "Result status of getting the variable.\r\n\r\n", + "javaType": "GetVariableStatusEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Accepted", + "Rejected", + "UnknownComponent", + "UnknownVariable", + "NotSupportedAttributeType" + ] + }, + "ComponentType": { + "description": "A physical or logical component\r\n", + "javaType": "Component", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "evse": { + "$ref": "#/definitions/EVSEType" + }, + "name": { + "description": "Name of the component. Name should be taken from the list of standardized component names whenever possible. Case Insensitive. strongly advised to use Camel Case.\r\n", + "type": "string", + "maxLength": 50 + }, + "instance": { + "description": "Name of instance in case the component exists as multiple instances. Case Insensitive. strongly advised to use Camel Case.\r\n", + "type": "string", + "maxLength": 50 + } + }, + "required": [ + "name" + ] + }, + "EVSEType": { + "description": "EVSE\r\nurn:x-oca:ocpp:uid:2:233123\r\nElectric Vehicle Supply Equipment\r\n", + "javaType": "EVSE", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "id": { + "description": "Identified_ Object. MRID. Numeric_ Identifier\r\nurn:x-enexis:ecdm:uid:1:569198\r\nEVSE Identifier. This contains a number (> 0) designating an EVSE of the Charging Station.\r\n", + "type": "integer" + }, + "connectorId": { + "description": "An id to designate a specific connector (on an EVSE) by connector index number.\r\n", + "type": "integer" + } + }, + "required": [ + "id" + ] + }, + "GetVariableResultType": { + "description": "Class to hold results of GetVariables request.\r\n", + "javaType": "GetVariableResult", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "attributeStatusInfo": { + "$ref": "#/definitions/StatusInfoType" + }, + "attributeStatus": { + "$ref": "#/definitions/GetVariableStatusEnumType" + }, + "attributeType": { + "$ref": "#/definitions/AttributeEnumType" + }, + "attributeValue": { + "description": "Value of requested attribute type of component-variable. This field can only be empty when the given status is NOT accepted.\r\n\r\nThe Configuration Variable <<configkey-reporting-value-size,ReportingValueSize>> can be used to limit GetVariableResult.attributeValue, VariableAttribute.value and EventData.actualValue. The max size of these values will always remain equal. \r\n\r\n", + "type": "string", + "maxLength": 2500 + }, + "component": { + "$ref": "#/definitions/ComponentType" + }, + "variable": { + "$ref": "#/definitions/VariableType" + } + }, + "required": [ + "attributeStatus", + "component", + "variable" + ] + }, + "StatusInfoType": { + "description": "Element providing more information about the status.\r\n", + "javaType": "StatusInfo", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "reasonCode": { + "description": "A predefined code for the reason why the status is returned in this response. The string is case-insensitive.\r\n", + "type": "string", + "maxLength": 20 + }, + "additionalInfo": { + "description": "Additional text to provide detailed information.\r\n", + "type": "string", + "maxLength": 512 + } + }, + "required": [ + "reasonCode" + ] + }, + "VariableType": { + "description": "Reference key to a component-variable.\r\n", + "javaType": "Variable", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "name": { + "description": "Name of the variable. Name should be taken from the list of standardized variable names whenever possible. Case Insensitive. strongly advised to use Camel Case.\r\n", + "type": "string", + "maxLength": 50 + }, + "instance": { + "description": "Name of instance in case the variable exists as multiple instances. Case Insensitive. strongly advised to use Camel Case.\r\n", + "type": "string", + "maxLength": 50 + } + }, + "required": [ + "name" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "getVariableResult": { + "type": "array", + "additionalItems": false, + "items": { + "$ref": "#/definitions/GetVariableResultType" + }, + "minItems": 1 + } + }, + "required": [ + "getVariableResult" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/HeartbeatRequest.json b/schemas/ocpp20/HeartbeatRequest.json new file mode 100644 index 00000000..8d9d5c8a --- /dev/null +++ b/schemas/ocpp20/HeartbeatRequest.json @@ -0,0 +1,28 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:HeartbeatRequest", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + } + } +} \ No newline at end of file diff --git a/schemas/ocpp20/HeartbeatResponse.json b/schemas/ocpp20/HeartbeatResponse.json new file mode 100644 index 00000000..58ada994 --- /dev/null +++ b/schemas/ocpp20/HeartbeatResponse.json @@ -0,0 +1,36 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:HeartbeatResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "currentTime": { + "description": "Contains the current time of the CSMS.\r\n", + "type": "string", + "format": "date-time" + } + }, + "required": [ + "currentTime" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/InstallCertificateRequest.json b/schemas/ocpp20/InstallCertificateRequest.json new file mode 100644 index 00000000..220390d2 --- /dev/null +++ b/schemas/ocpp20/InstallCertificateRequest.json @@ -0,0 +1,52 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:InstallCertificateRequest", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "InstallCertificateUseEnumType": { + "description": "Indicates the certificate type that is sent.\r\n", + "javaType": "InstallCertificateUseEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "V2GRootCertificate", + "MORootCertificate", + "CSMSRootCertificate", + "ManufacturerRootCertificate" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "certificateType": { + "$ref": "#/definitions/InstallCertificateUseEnumType" + }, + "certificate": { + "description": "A PEM encoded X.509 certificate.\r\n", + "type": "string", + "maxLength": 5500 + } + }, + "required": [ + "certificateType", + "certificate" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/InstallCertificateResponse.json b/schemas/ocpp20/InstallCertificateResponse.json new file mode 100644 index 00000000..8ac83c98 --- /dev/null +++ b/schemas/ocpp20/InstallCertificateResponse.json @@ -0,0 +1,72 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:InstallCertificateResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "InstallCertificateStatusEnumType": { + "description": "Charging Station indicates if installation was successful.\r\n", + "javaType": "InstallCertificateStatusEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Accepted", + "Rejected", + "Failed" + ] + }, + "StatusInfoType": { + "description": "Element providing more information about the status.\r\n", + "javaType": "StatusInfo", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "reasonCode": { + "description": "A predefined code for the reason why the status is returned in this response. The string is case-insensitive.\r\n", + "type": "string", + "maxLength": 20 + }, + "additionalInfo": { + "description": "Additional text to provide detailed information.\r\n", + "type": "string", + "maxLength": 512 + } + }, + "required": [ + "reasonCode" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "status": { + "$ref": "#/definitions/InstallCertificateStatusEnumType" + }, + "statusInfo": { + "$ref": "#/definitions/StatusInfoType" + } + }, + "required": [ + "status" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/LogStatusNotificationRequest.json b/schemas/ocpp20/LogStatusNotificationRequest.json new file mode 100644 index 00000000..4f5108f7 --- /dev/null +++ b/schemas/ocpp20/LogStatusNotificationRequest.json @@ -0,0 +1,54 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:LogStatusNotificationRequest", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "UploadLogStatusEnumType": { + "description": "This contains the status of the log upload.\r\n", + "javaType": "UploadLogStatusEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "BadMessage", + "Idle", + "NotSupportedOperation", + "PermissionDenied", + "Uploaded", + "UploadFailure", + "Uploading", + "AcceptedCanceled" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "status": { + "$ref": "#/definitions/UploadLogStatusEnumType" + }, + "requestId": { + "description": "The request id that was provided in GetLogRequest that started this log upload. This field is mandatory,\r\nunless the message was triggered by a TriggerMessageRequest AND there is no log upload ongoing.\r\n", + "type": "integer" + } + }, + "required": [ + "status" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/LogStatusNotificationResponse.json b/schemas/ocpp20/LogStatusNotificationResponse.json new file mode 100644 index 00000000..d431f9ba --- /dev/null +++ b/schemas/ocpp20/LogStatusNotificationResponse.json @@ -0,0 +1,28 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:LogStatusNotificationResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + } + } +} \ No newline at end of file diff --git a/schemas/ocpp20/MeterValuesRequest.json b/schemas/ocpp20/MeterValuesRequest.json new file mode 100644 index 00000000..c6ac310b --- /dev/null +++ b/schemas/ocpp20/MeterValuesRequest.json @@ -0,0 +1,251 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:MeterValuesRequest", + "description": "Request_ Body\r\nurn:x-enexis:ecdm:uid:2:234744\r\n", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "LocationEnumType": { + "description": "Sampled_ Value. Location. Location_ Code\r\nurn:x-oca:ocpp:uid:1:569265\r\nIndicates where the measured value has been sampled. Default = \"Outlet\"\r\n\r\n", + "javaType": "LocationEnum", + "type": "string", + "default": "Outlet", + "additionalProperties": false, + "enum": [ + "Body", + "Cable", + "EV", + "Inlet", + "Outlet" + ] + }, + "MeasurandEnumType": { + "description": "Sampled_ Value. Measurand. Measurand_ Code\r\nurn:x-oca:ocpp:uid:1:569263\r\nType of measurement. Default = \"Energy.Active.Import.Register\"\r\n", + "javaType": "MeasurandEnum", + "type": "string", + "default": "Energy.Active.Import.Register", + "additionalProperties": false, + "enum": [ + "Current.Export", + "Current.Import", + "Current.Offered", + "Energy.Active.Export.Register", + "Energy.Active.Import.Register", + "Energy.Reactive.Export.Register", + "Energy.Reactive.Import.Register", + "Energy.Active.Export.Interval", + "Energy.Active.Import.Interval", + "Energy.Active.Net", + "Energy.Reactive.Export.Interval", + "Energy.Reactive.Import.Interval", + "Energy.Reactive.Net", + "Energy.Apparent.Net", + "Energy.Apparent.Import", + "Energy.Apparent.Export", + "Frequency", + "Power.Active.Export", + "Power.Active.Import", + "Power.Factor", + "Power.Offered", + "Power.Reactive.Export", + "Power.Reactive.Import", + "SoC", + "Voltage" + ] + }, + "PhaseEnumType": { + "description": "Sampled_ Value. Phase. Phase_ Code\r\nurn:x-oca:ocpp:uid:1:569264\r\nIndicates how the measured value is to be interpreted. For instance between L1 and neutral (L1-N) Please note that not all values of phase are applicable to all Measurands. When phase is absent, the measured value is interpreted as an overall value.\r\n", + "javaType": "PhaseEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "L1", + "L2", + "L3", + "N", + "L1-N", + "L2-N", + "L3-N", + "L1-L2", + "L2-L3", + "L3-L1" + ] + }, + "ReadingContextEnumType": { + "description": "Sampled_ Value. Context. Reading_ Context_ Code\r\nurn:x-oca:ocpp:uid:1:569261\r\nType of detail value: start, end or sample. Default = \"Sample.Periodic\"\r\n", + "javaType": "ReadingContextEnum", + "type": "string", + "default": "Sample.Periodic", + "additionalProperties": false, + "enum": [ + "Interruption.Begin", + "Interruption.End", + "Other", + "Sample.Clock", + "Sample.Periodic", + "Transaction.Begin", + "Transaction.End", + "Trigger" + ] + }, + "MeterValueType": { + "description": "Meter_ Value\r\nurn:x-oca:ocpp:uid:2:233265\r\nCollection of one or more sampled values in MeterValuesRequest and TransactionEvent. All sampled values in a MeterValue are sampled at the same point in time.\r\n", + "javaType": "MeterValue", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "sampledValue": { + "type": "array", + "additionalItems": false, + "items": { + "$ref": "#/definitions/SampledValueType" + }, + "minItems": 1 + }, + "timestamp": { + "description": "Meter_ Value. Timestamp. Date_ Time\r\nurn:x-oca:ocpp:uid:1:569259\r\nTimestamp for measured value(s).\r\n", + "type": "string", + "format": "date-time" + } + }, + "required": [ + "timestamp", + "sampledValue" + ] + }, + "SampledValueType": { + "description": "Sampled_ Value\r\nurn:x-oca:ocpp:uid:2:233266\r\nSingle sampled value in MeterValues. Each value can be accompanied by optional fields.\r\n\r\nTo save on mobile data usage, default values of all of the optional fields are such that. The value without any additional fields will be interpreted, as a register reading of active import energy in Wh (Watt-hour) units.\r\n", + "javaType": "SampledValue", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "value": { + "description": "Sampled_ Value. Value. Measure\r\nurn:x-oca:ocpp:uid:1:569260\r\nIndicates the measured value.\r\n\r\n", + "type": "number" + }, + "context": { + "$ref": "#/definitions/ReadingContextEnumType" + }, + "measurand": { + "$ref": "#/definitions/MeasurandEnumType" + }, + "phase": { + "$ref": "#/definitions/PhaseEnumType" + }, + "location": { + "$ref": "#/definitions/LocationEnumType" + }, + "signedMeterValue": { + "$ref": "#/definitions/SignedMeterValueType" + }, + "unitOfMeasure": { + "$ref": "#/definitions/UnitOfMeasureType" + } + }, + "required": [ + "value" + ] + }, + "SignedMeterValueType": { + "description": "Represent a signed version of the meter value.\r\n", + "javaType": "SignedMeterValue", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "signedMeterData": { + "description": "Base64 encoded, contains the signed data which might contain more then just the meter value. It can contain information like timestamps, reference to a customer etc.\r\n", + "type": "string", + "maxLength": 2500 + }, + "signingMethod": { + "description": "Method used to create the digital signature.\r\n", + "type": "string", + "maxLength": 50 + }, + "encodingMethod": { + "description": "Method used to encode the meter values before applying the digital signature algorithm.\r\n", + "type": "string", + "maxLength": 50 + }, + "publicKey": { + "description": "Base64 encoded, sending depends on configuration variable _PublicKeyWithSignedMeterValue_.\r\n", + "type": "string", + "maxLength": 2500 + } + }, + "required": [ + "signedMeterData", + "signingMethod", + "encodingMethod", + "publicKey" + ] + }, + "UnitOfMeasureType": { + "description": "Represents a UnitOfMeasure with a multiplier\r\n", + "javaType": "UnitOfMeasure", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "unit": { + "description": "Unit of the value. Default = \"Wh\" if the (default) measurand is an \"Energy\" type.\r\nThis field SHALL use a value from the list Standardized Units of Measurements in Part 2 Appendices. \r\nIf an applicable unit is available in that list, otherwise a \"custom\" unit might be used.\r\n", + "type": "string", + "default": "Wh", + "maxLength": 20 + }, + "multiplier": { + "description": "Multiplier, this value represents the exponent to base 10. I.e. multiplier 3 means 10 raised to the 3rd power. Default is 0.\r\n", + "type": "integer", + "default": 0 + } + } + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "evseId": { + "description": "Request_ Body. EVSEID. Numeric_ Identifier\r\nurn:x-enexis:ecdm:uid:1:571101\r\nThis contains a number (>0) designating an EVSE of the Charging Station. ‘0’ (zero) is used to designate the main power meter.\r\n", + "type": "integer" + }, + "meterValue": { + "type": "array", + "additionalItems": false, + "items": { + "$ref": "#/definitions/MeterValueType" + }, + "minItems": 1 + } + }, + "required": [ + "evseId", + "meterValue" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/MeterValuesResponse.json b/schemas/ocpp20/MeterValuesResponse.json new file mode 100644 index 00000000..dce99622 --- /dev/null +++ b/schemas/ocpp20/MeterValuesResponse.json @@ -0,0 +1,28 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:MeterValuesResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + } + } +} \ No newline at end of file diff --git a/schemas/ocpp20/NotifyChargingLimitRequest.json b/schemas/ocpp20/NotifyChargingLimitRequest.json new file mode 100644 index 00000000..49c08424 --- /dev/null +++ b/schemas/ocpp20/NotifyChargingLimitRequest.json @@ -0,0 +1,323 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:NotifyChargingLimitRequest", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "ChargingLimitSourceEnumType": { + "description": "Charging_ Limit. Charging_ Limit_ Source. Charging_ Limit_ Source_ Code\r\nurn:x-enexis:ecdm:uid:1:570845\r\nRepresents the source of the charging limit.\r\n", + "javaType": "ChargingLimitSourceEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "EMS", + "Other", + "SO", + "CSO" + ] + }, + "ChargingRateUnitEnumType": { + "description": "Charging_ Schedule. Charging_ Rate_ Unit. Charging_ Rate_ Unit_ Code\r\nurn:x-oca:ocpp:uid:1:569238\r\nThe unit of measure Limit is expressed in.\r\n", + "javaType": "ChargingRateUnitEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "W", + "A" + ] + }, + "CostKindEnumType": { + "description": "Cost. Cost_ Kind. Cost_ Kind_ Code\r\nurn:x-oca:ocpp:uid:1:569243\r\nThe kind of cost referred to in the message element amount\r\n", + "javaType": "CostKindEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "CarbonDioxideEmission", + "RelativePricePercentage", + "RenewableGenerationPercentage" + ] + }, + "ChargingLimitType": { + "description": "Charging_ Limit\r\nurn:x-enexis:ecdm:uid:2:234489\r\n", + "javaType": "ChargingLimit", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "chargingLimitSource": { + "$ref": "#/definitions/ChargingLimitSourceEnumType" + }, + "isGridCritical": { + "description": "Charging_ Limit. Is_ Grid_ Critical. Indicator\r\nurn:x-enexis:ecdm:uid:1:570847\r\nIndicates whether the charging limit is critical for the grid.\r\n", + "type": "boolean" + } + }, + "required": [ + "chargingLimitSource" + ] + }, + "ChargingSchedulePeriodType": { + "description": "Charging_ Schedule_ Period\r\nurn:x-oca:ocpp:uid:2:233257\r\nCharging schedule period structure defines a time period in a charging schedule.\r\n", + "javaType": "ChargingSchedulePeriod", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "startPeriod": { + "description": "Charging_ Schedule_ Period. Start_ Period. Elapsed_ Time\r\nurn:x-oca:ocpp:uid:1:569240\r\nStart of the period, in seconds from the start of schedule. The value of StartPeriod also defines the stop time of the previous period.\r\n", + "type": "integer" + }, + "limit": { + "description": "Charging_ Schedule_ Period. Limit. Measure\r\nurn:x-oca:ocpp:uid:1:569241\r\nCharging rate limit during the schedule period, in the applicable chargingRateUnit, for example in Amperes (A) or Watts (W). Accepts at most one digit fraction (e.g. 8.1).\r\n", + "type": "number" + }, + "numberPhases": { + "description": "Charging_ Schedule_ Period. Number_ Phases. Counter\r\nurn:x-oca:ocpp:uid:1:569242\r\nThe number of phases that can be used for charging. If a number of phases is needed, numberPhases=3 will be assumed unless another number is given.\r\n", + "type": "integer" + }, + "phaseToUse": { + "description": "Values: 1..3, Used if numberPhases=1 and if the EVSE is capable of switching the phase connected to the EV, i.e. ACPhaseSwitchingSupported is defined and true. It’s not allowed unless both conditions above are true. If both conditions are true, and phaseToUse is omitted, the Charging Station / EVSE will make the selection on its own.\r\n\r\n", + "type": "integer" + } + }, + "required": [ + "startPeriod", + "limit" + ] + }, + "ChargingScheduleType": { + "description": "Charging_ Schedule\r\nurn:x-oca:ocpp:uid:2:233256\r\nCharging schedule structure defines a list of charging periods, as used in: GetCompositeSchedule.conf and ChargingProfile. \r\n", + "javaType": "ChargingSchedule", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "id": { + "description": "Identifies the ChargingSchedule.\r\n", + "type": "integer" + }, + "startSchedule": { + "description": "Charging_ Schedule. Start_ Schedule. Date_ Time\r\nurn:x-oca:ocpp:uid:1:569237\r\nStarting point of an absolute schedule. If absent the schedule will be relative to start of charging.\r\n", + "type": "string", + "format": "date-time" + }, + "duration": { + "description": "Charging_ Schedule. Duration. Elapsed_ Time\r\nurn:x-oca:ocpp:uid:1:569236\r\nDuration of the charging schedule in seconds. If the duration is left empty, the last period will continue indefinitely or until end of the transaction if chargingProfilePurpose = TxProfile.\r\n", + "type": "integer" + }, + "chargingRateUnit": { + "$ref": "#/definitions/ChargingRateUnitEnumType" + }, + "chargingSchedulePeriod": { + "type": "array", + "additionalItems": false, + "items": { + "$ref": "#/definitions/ChargingSchedulePeriodType" + }, + "minItems": 1, + "maxItems": 1024 + }, + "minChargingRate": { + "description": "Charging_ Schedule. Min_ Charging_ Rate. Numeric\r\nurn:x-oca:ocpp:uid:1:569239\r\nMinimum charging rate supported by the EV. The unit of measure is defined by the chargingRateUnit. This parameter is intended to be used by a local smart charging algorithm to optimize the power allocation for in the case a charging process is inefficient at lower charging rates. Accepts at most one digit fraction (e.g. 8.1)\r\n", + "type": "number" + }, + "salesTariff": { + "$ref": "#/definitions/SalesTariffType" + } + }, + "required": [ + "id", + "chargingRateUnit", + "chargingSchedulePeriod" + ] + }, + "ConsumptionCostType": { + "description": "Consumption_ Cost\r\nurn:x-oca:ocpp:uid:2:233259\r\n", + "javaType": "ConsumptionCost", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "startValue": { + "description": "Consumption_ Cost. Start_ Value. Numeric\r\nurn:x-oca:ocpp:uid:1:569246\r\nThe lowest level of consumption that defines the starting point of this consumption block. The block interval extends to the start of the next interval.\r\n", + "type": "number" + }, + "cost": { + "type": "array", + "additionalItems": false, + "items": { + "$ref": "#/definitions/CostType" + }, + "minItems": 1, + "maxItems": 3 + } + }, + "required": [ + "startValue", + "cost" + ] + }, + "CostType": { + "description": "Cost\r\nurn:x-oca:ocpp:uid:2:233258\r\n", + "javaType": "Cost", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "costKind": { + "$ref": "#/definitions/CostKindEnumType" + }, + "amount": { + "description": "Cost. Amount. Amount\r\nurn:x-oca:ocpp:uid:1:569244\r\nThe estimated or actual cost per kWh\r\n", + "type": "integer" + }, + "amountMultiplier": { + "description": "Cost. Amount_ Multiplier. Integer\r\nurn:x-oca:ocpp:uid:1:569245\r\nValues: -3..3, The amountMultiplier defines the exponent to base 10 (dec). The final value is determined by: amount * 10 ^ amountMultiplier\r\n", + "type": "integer" + } + }, + "required": [ + "costKind", + "amount" + ] + }, + "RelativeTimeIntervalType": { + "description": "Relative_ Timer_ Interval\r\nurn:x-oca:ocpp:uid:2:233270\r\n", + "javaType": "RelativeTimeInterval", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "start": { + "description": "Relative_ Timer_ Interval. Start. Elapsed_ Time\r\nurn:x-oca:ocpp:uid:1:569279\r\nStart of the interval, in seconds from NOW.\r\n", + "type": "integer" + }, + "duration": { + "description": "Relative_ Timer_ Interval. Duration. Elapsed_ Time\r\nurn:x-oca:ocpp:uid:1:569280\r\nDuration of the interval, in seconds.\r\n", + "type": "integer" + } + }, + "required": [ + "start" + ] + }, + "SalesTariffEntryType": { + "description": "Sales_ Tariff_ Entry\r\nurn:x-oca:ocpp:uid:2:233271\r\n", + "javaType": "SalesTariffEntry", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "relativeTimeInterval": { + "$ref": "#/definitions/RelativeTimeIntervalType" + }, + "ePriceLevel": { + "description": "Sales_ Tariff_ Entry. E_ Price_ Level. Unsigned_ Integer\r\nurn:x-oca:ocpp:uid:1:569281\r\nDefines the price level of this SalesTariffEntry (referring to NumEPriceLevels). Small values for the EPriceLevel represent a cheaper TariffEntry. Large values for the EPriceLevel represent a more expensive TariffEntry.\r\n", + "type": "integer", + "minimum": 0.0 + }, + "consumptionCost": { + "type": "array", + "additionalItems": false, + "items": { + "$ref": "#/definitions/ConsumptionCostType" + }, + "minItems": 1, + "maxItems": 3 + } + }, + "required": [ + "relativeTimeInterval" + ] + }, + "SalesTariffType": { + "description": "Sales_ Tariff\r\nurn:x-oca:ocpp:uid:2:233272\r\nNOTE: This dataType is based on dataTypes from <<ref-ISOIEC15118-2,ISO 15118-2>>.\r\n", + "javaType": "SalesTariff", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "id": { + "description": "Identified_ Object. MRID. Numeric_ Identifier\r\nurn:x-enexis:ecdm:uid:1:569198\r\nSalesTariff identifier used to identify one sales tariff. An SAID remains a unique identifier for one schedule throughout a charging session.\r\n", + "type": "integer" + }, + "salesTariffDescription": { + "description": "Sales_ Tariff. Sales. Tariff_ Description\r\nurn:x-oca:ocpp:uid:1:569283\r\nA human readable title/short description of the sales tariff e.g. for HMI display purposes.\r\n", + "type": "string", + "maxLength": 32 + }, + "numEPriceLevels": { + "description": "Sales_ Tariff. Num_ E_ Price_ Levels. Counter\r\nurn:x-oca:ocpp:uid:1:569284\r\nDefines the overall number of distinct price levels used across all provided SalesTariff elements.\r\n", + "type": "integer" + }, + "salesTariffEntry": { + "type": "array", + "additionalItems": false, + "items": { + "$ref": "#/definitions/SalesTariffEntryType" + }, + "minItems": 1, + "maxItems": 1024 + } + }, + "required": [ + "id", + "salesTariffEntry" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "chargingSchedule": { + "type": "array", + "additionalItems": false, + "items": { + "$ref": "#/definitions/ChargingScheduleType" + }, + "minItems": 1 + }, + "evseId": { + "description": "The charging schedule contained in this notification applies to an EVSE. evseId must be > 0.\r\n", + "type": "integer" + }, + "chargingLimit": { + "$ref": "#/definitions/ChargingLimitType" + } + }, + "required": [ + "chargingLimit" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/NotifyChargingLimitResponse.json b/schemas/ocpp20/NotifyChargingLimitResponse.json new file mode 100644 index 00000000..8c770181 --- /dev/null +++ b/schemas/ocpp20/NotifyChargingLimitResponse.json @@ -0,0 +1,28 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:NotifyChargingLimitResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + } + } +} \ No newline at end of file diff --git a/schemas/ocpp20/NotifyCustomerInformationRequest.json b/schemas/ocpp20/NotifyCustomerInformationRequest.json new file mode 100644 index 00000000..0e4acf46 --- /dev/null +++ b/schemas/ocpp20/NotifyCustomerInformationRequest.json @@ -0,0 +1,57 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:NotifyCustomerInformationRequest", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "data": { + "description": "(Part of) the requested data. No format specified in which the data is returned. Should be human readable.\r\n", + "type": "string", + "maxLength": 512 + }, + "tbc": { + "description": "“to be continued” indicator. Indicates whether another part of the monitoringData follows in an upcoming notifyMonitoringReportRequest message. Default value when omitted is false.\r\n", + "type": "boolean", + "default": false + }, + "seqNo": { + "description": "Sequence number of this message. First message starts at 0.\r\n", + "type": "integer" + }, + "generatedAt": { + "description": " Timestamp of the moment this message was generated at the Charging Station.\r\n", + "type": "string", + "format": "date-time" + }, + "requestId": { + "description": "The Id of the request.\r\n\r\n", + "type": "integer" + } + }, + "required": [ + "data", + "seqNo", + "generatedAt", + "requestId" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/NotifyCustomerInformationResponse.json b/schemas/ocpp20/NotifyCustomerInformationResponse.json new file mode 100644 index 00000000..e3f13f80 --- /dev/null +++ b/schemas/ocpp20/NotifyCustomerInformationResponse.json @@ -0,0 +1,28 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:NotifyCustomerInformationResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + } + } +} \ No newline at end of file diff --git a/schemas/ocpp20/NotifyDisplayMessagesRequest.json b/schemas/ocpp20/NotifyDisplayMessagesRequest.json new file mode 100644 index 00000000..b87648cc --- /dev/null +++ b/schemas/ocpp20/NotifyDisplayMessagesRequest.json @@ -0,0 +1,207 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:NotifyDisplayMessagesRequest", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "MessageFormatEnumType": { + "description": "Message_ Content. Format. Message_ Format_ Code\r\nurn:x-enexis:ecdm:uid:1:570848\r\nFormat of the message.\r\n", + "javaType": "MessageFormatEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "ASCII", + "HTML", + "URI", + "UTF8" + ] + }, + "MessagePriorityEnumType": { + "description": "Message_ Info. Priority. Message_ Priority_ Code\r\nurn:x-enexis:ecdm:uid:1:569253\r\nWith what priority should this message be shown\r\n", + "javaType": "MessagePriorityEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "AlwaysFront", + "InFront", + "NormalCycle" + ] + }, + "MessageStateEnumType": { + "description": "Message_ Info. State. Message_ State_ Code\r\nurn:x-enexis:ecdm:uid:1:569254\r\nDuring what state should this message be shown. When omitted this message should be shown in any state of the Charging Station.\r\n", + "javaType": "MessageStateEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Charging", + "Faulted", + "Idle", + "Unavailable" + ] + }, + "ComponentType": { + "description": "A physical or logical component\r\n", + "javaType": "Component", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "evse": { + "$ref": "#/definitions/EVSEType" + }, + "name": { + "description": "Name of the component. Name should be taken from the list of standardized component names whenever possible. Case Insensitive. strongly advised to use Camel Case.\r\n", + "type": "string", + "maxLength": 50 + }, + "instance": { + "description": "Name of instance in case the component exists as multiple instances. Case Insensitive. strongly advised to use Camel Case.\r\n", + "type": "string", + "maxLength": 50 + } + }, + "required": [ + "name" + ] + }, + "EVSEType": { + "description": "EVSE\r\nurn:x-oca:ocpp:uid:2:233123\r\nElectric Vehicle Supply Equipment\r\n", + "javaType": "EVSE", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "id": { + "description": "Identified_ Object. MRID. Numeric_ Identifier\r\nurn:x-enexis:ecdm:uid:1:569198\r\nEVSE Identifier. This contains a number (> 0) designating an EVSE of the Charging Station.\r\n", + "type": "integer" + }, + "connectorId": { + "description": "An id to designate a specific connector (on an EVSE) by connector index number.\r\n", + "type": "integer" + } + }, + "required": [ + "id" + ] + }, + "MessageContentType": { + "description": "Message_ Content\r\nurn:x-enexis:ecdm:uid:2:234490\r\nContains message details, for a message to be displayed on a Charging Station.\r\n\r\n", + "javaType": "MessageContent", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "format": { + "$ref": "#/definitions/MessageFormatEnumType" + }, + "language": { + "description": "Message_ Content. Language. Language_ Code\r\nurn:x-enexis:ecdm:uid:1:570849\r\nMessage language identifier. Contains a language code as defined in <<ref-RFC5646,[RFC5646]>>.\r\n", + "type": "string", + "maxLength": 8 + }, + "content": { + "description": "Message_ Content. Content. Message\r\nurn:x-enexis:ecdm:uid:1:570852\r\nMessage contents.\r\n\r\n", + "type": "string", + "maxLength": 512 + } + }, + "required": [ + "format", + "content" + ] + }, + "MessageInfoType": { + "description": "Message_ Info\r\nurn:x-enexis:ecdm:uid:2:233264\r\nContains message details, for a message to be displayed on a Charging Station.\r\n", + "javaType": "MessageInfo", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "display": { + "$ref": "#/definitions/ComponentType" + }, + "id": { + "description": "Identified_ Object. MRID. Numeric_ Identifier\r\nurn:x-enexis:ecdm:uid:1:569198\r\nMaster resource identifier, unique within an exchange context. It is defined within the OCPP context as a positive Integer value (greater or equal to zero).\r\n", + "type": "integer" + }, + "priority": { + "$ref": "#/definitions/MessagePriorityEnumType" + }, + "state": { + "$ref": "#/definitions/MessageStateEnumType" + }, + "startDateTime": { + "description": "Message_ Info. Start. Date_ Time\r\nurn:x-enexis:ecdm:uid:1:569256\r\nFrom what date-time should this message be shown. If omitted: directly.\r\n", + "type": "string", + "format": "date-time" + }, + "endDateTime": { + "description": "Message_ Info. End. Date_ Time\r\nurn:x-enexis:ecdm:uid:1:569257\r\nUntil what date-time should this message be shown, after this date/time this message SHALL be removed.\r\n", + "type": "string", + "format": "date-time" + }, + "transactionId": { + "description": "During which transaction shall this message be shown.\r\nMessage SHALL be removed by the Charging Station after transaction has\r\nended.\r\n", + "type": "string", + "maxLength": 36 + }, + "message": { + "$ref": "#/definitions/MessageContentType" + } + }, + "required": [ + "id", + "priority", + "message" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "messageInfo": { + "type": "array", + "additionalItems": false, + "items": { + "$ref": "#/definitions/MessageInfoType" + }, + "minItems": 1 + }, + "requestId": { + "description": "The id of the <<getdisplaymessagesrequest,GetDisplayMessagesRequest>> that requested this message.\r\n", + "type": "integer" + }, + "tbc": { + "description": "\"to be continued\" indicator. Indicates whether another part of the report follows in an upcoming NotifyDisplayMessagesRequest message. Default value when omitted is false.\r\n", + "type": "boolean", + "default": false + } + }, + "required": [ + "requestId" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/NotifyDisplayMessagesResponse.json b/schemas/ocpp20/NotifyDisplayMessagesResponse.json new file mode 100644 index 00000000..91174d0f --- /dev/null +++ b/schemas/ocpp20/NotifyDisplayMessagesResponse.json @@ -0,0 +1,28 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:NotifyDisplayMessagesResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + } + } +} \ No newline at end of file diff --git a/schemas/ocpp20/NotifyEVChargingNeedsRequest.json b/schemas/ocpp20/NotifyEVChargingNeedsRequest.json new file mode 100644 index 00000000..cd6b5945 --- /dev/null +++ b/schemas/ocpp20/NotifyEVChargingNeedsRequest.json @@ -0,0 +1,169 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:NotifyEVChargingNeedsRequest", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "EnergyTransferModeEnumType": { + "description": "Charging_ Needs. Requested. Energy_ Transfer_ Mode_ Code\r\nurn:x-oca:ocpp:uid:1:569209\r\nMode of energy transfer requested by the EV.\r\n", + "javaType": "EnergyTransferModeEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "DC", + "AC_single_phase", + "AC_two_phase", + "AC_three_phase" + ] + }, + "ACChargingParametersType": { + "description": "AC_ Charging_ Parameters\r\nurn:x-oca:ocpp:uid:2:233250\r\nEV AC charging parameters.\r\n\r\n", + "javaType": "ACChargingParameters", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "energyAmount": { + "description": "AC_ Charging_ Parameters. Energy_ Amount. Energy_ Amount\r\nurn:x-oca:ocpp:uid:1:569211\r\nAmount of energy requested (in Wh). This includes energy required for preconditioning.\r\n", + "type": "integer" + }, + "evMinCurrent": { + "description": "AC_ Charging_ Parameters. EV_ Min. Current\r\nurn:x-oca:ocpp:uid:1:569212\r\nMinimum current (amps) supported by the electric vehicle (per phase).\r\n", + "type": "integer" + }, + "evMaxCurrent": { + "description": "AC_ Charging_ Parameters. EV_ Max. Current\r\nurn:x-oca:ocpp:uid:1:569213\r\nMaximum current (amps) supported by the electric vehicle (per phase). Includes cable capacity.\r\n", + "type": "integer" + }, + "evMaxVoltage": { + "description": "AC_ Charging_ Parameters. EV_ Max. Voltage\r\nurn:x-oca:ocpp:uid:1:569214\r\nMaximum voltage supported by the electric vehicle\r\n", + "type": "integer" + } + }, + "required": [ + "energyAmount", + "evMinCurrent", + "evMaxCurrent", + "evMaxVoltage" + ] + }, + "ChargingNeedsType": { + "description": "Charging_ Needs\r\nurn:x-oca:ocpp:uid:2:233249\r\n", + "javaType": "ChargingNeeds", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "acChargingParameters": { + "$ref": "#/definitions/ACChargingParametersType" + }, + "dcChargingParameters": { + "$ref": "#/definitions/DCChargingParametersType" + }, + "requestedEnergyTransfer": { + "$ref": "#/definitions/EnergyTransferModeEnumType" + }, + "departureTime": { + "description": "Charging_ Needs. Departure_ Time. Date_ Time\r\nurn:x-oca:ocpp:uid:1:569223\r\nEstimated departure time of the EV.\r\n", + "type": "string", + "format": "date-time" + } + }, + "required": [ + "requestedEnergyTransfer" + ] + }, + "DCChargingParametersType": { + "description": "DC_ Charging_ Parameters\r\nurn:x-oca:ocpp:uid:2:233251\r\nEV DC charging parameters\r\n\r\n\r\n", + "javaType": "DCChargingParameters", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "evMaxCurrent": { + "description": "DC_ Charging_ Parameters. EV_ Max. Current\r\nurn:x-oca:ocpp:uid:1:569215\r\nMaximum current (amps) supported by the electric vehicle. Includes cable capacity.\r\n", + "type": "integer" + }, + "evMaxVoltage": { + "description": "DC_ Charging_ Parameters. EV_ Max. Voltage\r\nurn:x-oca:ocpp:uid:1:569216\r\nMaximum voltage supported by the electric vehicle\r\n", + "type": "integer" + }, + "energyAmount": { + "description": "DC_ Charging_ Parameters. Energy_ Amount. Energy_ Amount\r\nurn:x-oca:ocpp:uid:1:569217\r\nAmount of energy requested (in Wh). This inludes energy required for preconditioning.\r\n", + "type": "integer" + }, + "evMaxPower": { + "description": "DC_ Charging_ Parameters. EV_ Max. Power\r\nurn:x-oca:ocpp:uid:1:569218\r\nMaximum power (in W) supported by the electric vehicle. Required for DC charging.\r\n", + "type": "integer" + }, + "stateOfCharge": { + "description": "DC_ Charging_ Parameters. State_ Of_ Charge. Numeric\r\nurn:x-oca:ocpp:uid:1:569219\r\nEnergy available in the battery (in percent of the battery capacity)\r\n", + "type": "integer", + "minimum": 0.0, + "maximum": 100.0 + }, + "evEnergyCapacity": { + "description": "DC_ Charging_ Parameters. EV_ Energy_ Capacity. Numeric\r\nurn:x-oca:ocpp:uid:1:569220\r\nCapacity of the electric vehicle battery (in Wh)\r\n", + "type": "integer" + }, + "fullSoC": { + "description": "DC_ Charging_ Parameters. Full_ SOC. Percentage\r\nurn:x-oca:ocpp:uid:1:569221\r\nPercentage of SoC at which the EV considers the battery fully charged. (possible values: 0 - 100)\r\n", + "type": "integer", + "minimum": 0.0, + "maximum": 100.0 + }, + "bulkSoC": { + "description": "DC_ Charging_ Parameters. Bulk_ SOC. Percentage\r\nurn:x-oca:ocpp:uid:1:569222\r\nPercentage of SoC at which the EV considers a fast charging process to end. (possible values: 0 - 100)\r\n", + "type": "integer", + "minimum": 0.0, + "maximum": 100.0 + } + }, + "required": [ + "evMaxCurrent", + "evMaxVoltage" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "maxScheduleTuples": { + "description": "Contains the maximum schedule tuples the car supports per schedule.\r\n", + "type": "integer" + }, + "chargingNeeds": { + "$ref": "#/definitions/ChargingNeedsType" + }, + "evseId": { + "description": "Defines the EVSE and connector to which the EV is connected. EvseId may not be 0.\r\n", + "type": "integer" + } + }, + "required": [ + "evseId", + "chargingNeeds" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/NotifyEVChargingNeedsResponse.json b/schemas/ocpp20/NotifyEVChargingNeedsResponse.json new file mode 100644 index 00000000..79e2d24f --- /dev/null +++ b/schemas/ocpp20/NotifyEVChargingNeedsResponse.json @@ -0,0 +1,72 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:NotifyEVChargingNeedsResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "NotifyEVChargingNeedsStatusEnumType": { + "description": "Returns whether the CSMS has been able to process the message successfully. It does not imply that the evChargingNeeds can be met with the current charging profile.\r\n", + "javaType": "NotifyEVChargingNeedsStatusEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Accepted", + "Rejected", + "Processing" + ] + }, + "StatusInfoType": { + "description": "Element providing more information about the status.\r\n", + "javaType": "StatusInfo", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "reasonCode": { + "description": "A predefined code for the reason why the status is returned in this response. The string is case-insensitive.\r\n", + "type": "string", + "maxLength": 20 + }, + "additionalInfo": { + "description": "Additional text to provide detailed information.\r\n", + "type": "string", + "maxLength": 512 + } + }, + "required": [ + "reasonCode" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "status": { + "$ref": "#/definitions/NotifyEVChargingNeedsStatusEnumType" + }, + "statusInfo": { + "$ref": "#/definitions/StatusInfoType" + } + }, + "required": [ + "status" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/NotifyEVChargingScheduleRequest.json b/schemas/ocpp20/NotifyEVChargingScheduleRequest.json new file mode 100644 index 00000000..aa851dd0 --- /dev/null +++ b/schemas/ocpp20/NotifyEVChargingScheduleRequest.json @@ -0,0 +1,289 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:NotifyEVChargingScheduleRequest", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "ChargingRateUnitEnumType": { + "description": "Charging_ Schedule. Charging_ Rate_ Unit. Charging_ Rate_ Unit_ Code\r\nurn:x-oca:ocpp:uid:1:569238\r\nThe unit of measure Limit is expressed in.\r\n", + "javaType": "ChargingRateUnitEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "W", + "A" + ] + }, + "CostKindEnumType": { + "description": "Cost. Cost_ Kind. Cost_ Kind_ Code\r\nurn:x-oca:ocpp:uid:1:569243\r\nThe kind of cost referred to in the message element amount\r\n", + "javaType": "CostKindEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "CarbonDioxideEmission", + "RelativePricePercentage", + "RenewableGenerationPercentage" + ] + }, + "ChargingSchedulePeriodType": { + "description": "Charging_ Schedule_ Period\r\nurn:x-oca:ocpp:uid:2:233257\r\nCharging schedule period structure defines a time period in a charging schedule.\r\n", + "javaType": "ChargingSchedulePeriod", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "startPeriod": { + "description": "Charging_ Schedule_ Period. Start_ Period. Elapsed_ Time\r\nurn:x-oca:ocpp:uid:1:569240\r\nStart of the period, in seconds from the start of schedule. The value of StartPeriod also defines the stop time of the previous period.\r\n", + "type": "integer" + }, + "limit": { + "description": "Charging_ Schedule_ Period. Limit. Measure\r\nurn:x-oca:ocpp:uid:1:569241\r\nCharging rate limit during the schedule period, in the applicable chargingRateUnit, for example in Amperes (A) or Watts (W). Accepts at most one digit fraction (e.g. 8.1).\r\n", + "type": "number" + }, + "numberPhases": { + "description": "Charging_ Schedule_ Period. Number_ Phases. Counter\r\nurn:x-oca:ocpp:uid:1:569242\r\nThe number of phases that can be used for charging. If a number of phases is needed, numberPhases=3 will be assumed unless another number is given.\r\n", + "type": "integer" + }, + "phaseToUse": { + "description": "Values: 1..3, Used if numberPhases=1 and if the EVSE is capable of switching the phase connected to the EV, i.e. ACPhaseSwitchingSupported is defined and true. It’s not allowed unless both conditions above are true. If both conditions are true, and phaseToUse is omitted, the Charging Station / EVSE will make the selection on its own.\r\n\r\n", + "type": "integer" + } + }, + "required": [ + "startPeriod", + "limit" + ] + }, + "ChargingScheduleType": { + "description": "Charging_ Schedule\r\nurn:x-oca:ocpp:uid:2:233256\r\nCharging schedule structure defines a list of charging periods, as used in: GetCompositeSchedule.conf and ChargingProfile. \r\n", + "javaType": "ChargingSchedule", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "id": { + "description": "Identifies the ChargingSchedule.\r\n", + "type": "integer" + }, + "startSchedule": { + "description": "Charging_ Schedule. Start_ Schedule. Date_ Time\r\nurn:x-oca:ocpp:uid:1:569237\r\nStarting point of an absolute schedule. If absent the schedule will be relative to start of charging.\r\n", + "type": "string", + "format": "date-time" + }, + "duration": { + "description": "Charging_ Schedule. Duration. Elapsed_ Time\r\nurn:x-oca:ocpp:uid:1:569236\r\nDuration of the charging schedule in seconds. If the duration is left empty, the last period will continue indefinitely or until end of the transaction if chargingProfilePurpose = TxProfile.\r\n", + "type": "integer" + }, + "chargingRateUnit": { + "$ref": "#/definitions/ChargingRateUnitEnumType" + }, + "chargingSchedulePeriod": { + "type": "array", + "additionalItems": false, + "items": { + "$ref": "#/definitions/ChargingSchedulePeriodType" + }, + "minItems": 1, + "maxItems": 1024 + }, + "minChargingRate": { + "description": "Charging_ Schedule. Min_ Charging_ Rate. Numeric\r\nurn:x-oca:ocpp:uid:1:569239\r\nMinimum charging rate supported by the EV. The unit of measure is defined by the chargingRateUnit. This parameter is intended to be used by a local smart charging algorithm to optimize the power allocation for in the case a charging process is inefficient at lower charging rates. Accepts at most one digit fraction (e.g. 8.1)\r\n", + "type": "number" + }, + "salesTariff": { + "$ref": "#/definitions/SalesTariffType" + } + }, + "required": [ + "id", + "chargingRateUnit", + "chargingSchedulePeriod" + ] + }, + "ConsumptionCostType": { + "description": "Consumption_ Cost\r\nurn:x-oca:ocpp:uid:2:233259\r\n", + "javaType": "ConsumptionCost", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "startValue": { + "description": "Consumption_ Cost. Start_ Value. Numeric\r\nurn:x-oca:ocpp:uid:1:569246\r\nThe lowest level of consumption that defines the starting point of this consumption block. The block interval extends to the start of the next interval.\r\n", + "type": "number" + }, + "cost": { + "type": "array", + "additionalItems": false, + "items": { + "$ref": "#/definitions/CostType" + }, + "minItems": 1, + "maxItems": 3 + } + }, + "required": [ + "startValue", + "cost" + ] + }, + "CostType": { + "description": "Cost\r\nurn:x-oca:ocpp:uid:2:233258\r\n", + "javaType": "Cost", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "costKind": { + "$ref": "#/definitions/CostKindEnumType" + }, + "amount": { + "description": "Cost. Amount. Amount\r\nurn:x-oca:ocpp:uid:1:569244\r\nThe estimated or actual cost per kWh\r\n", + "type": "integer" + }, + "amountMultiplier": { + "description": "Cost. Amount_ Multiplier. Integer\r\nurn:x-oca:ocpp:uid:1:569245\r\nValues: -3..3, The amountMultiplier defines the exponent to base 10 (dec). The final value is determined by: amount * 10 ^ amountMultiplier\r\n", + "type": "integer" + } + }, + "required": [ + "costKind", + "amount" + ] + }, + "RelativeTimeIntervalType": { + "description": "Relative_ Timer_ Interval\r\nurn:x-oca:ocpp:uid:2:233270\r\n", + "javaType": "RelativeTimeInterval", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "start": { + "description": "Relative_ Timer_ Interval. Start. Elapsed_ Time\r\nurn:x-oca:ocpp:uid:1:569279\r\nStart of the interval, in seconds from NOW.\r\n", + "type": "integer" + }, + "duration": { + "description": "Relative_ Timer_ Interval. Duration. Elapsed_ Time\r\nurn:x-oca:ocpp:uid:1:569280\r\nDuration of the interval, in seconds.\r\n", + "type": "integer" + } + }, + "required": [ + "start" + ] + }, + "SalesTariffEntryType": { + "description": "Sales_ Tariff_ Entry\r\nurn:x-oca:ocpp:uid:2:233271\r\n", + "javaType": "SalesTariffEntry", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "relativeTimeInterval": { + "$ref": "#/definitions/RelativeTimeIntervalType" + }, + "ePriceLevel": { + "description": "Sales_ Tariff_ Entry. E_ Price_ Level. Unsigned_ Integer\r\nurn:x-oca:ocpp:uid:1:569281\r\nDefines the price level of this SalesTariffEntry (referring to NumEPriceLevels). Small values for the EPriceLevel represent a cheaper TariffEntry. Large values for the EPriceLevel represent a more expensive TariffEntry.\r\n", + "type": "integer", + "minimum": 0.0 + }, + "consumptionCost": { + "type": "array", + "additionalItems": false, + "items": { + "$ref": "#/definitions/ConsumptionCostType" + }, + "minItems": 1, + "maxItems": 3 + } + }, + "required": [ + "relativeTimeInterval" + ] + }, + "SalesTariffType": { + "description": "Sales_ Tariff\r\nurn:x-oca:ocpp:uid:2:233272\r\nNOTE: This dataType is based on dataTypes from <<ref-ISOIEC15118-2,ISO 15118-2>>.\r\n", + "javaType": "SalesTariff", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "id": { + "description": "Identified_ Object. MRID. Numeric_ Identifier\r\nurn:x-enexis:ecdm:uid:1:569198\r\nSalesTariff identifier used to identify one sales tariff. An SAID remains a unique identifier for one schedule throughout a charging session.\r\n", + "type": "integer" + }, + "salesTariffDescription": { + "description": "Sales_ Tariff. Sales. Tariff_ Description\r\nurn:x-oca:ocpp:uid:1:569283\r\nA human readable title/short description of the sales tariff e.g. for HMI display purposes.\r\n", + "type": "string", + "maxLength": 32 + }, + "numEPriceLevels": { + "description": "Sales_ Tariff. Num_ E_ Price_ Levels. Counter\r\nurn:x-oca:ocpp:uid:1:569284\r\nDefines the overall number of distinct price levels used across all provided SalesTariff elements.\r\n", + "type": "integer" + }, + "salesTariffEntry": { + "type": "array", + "additionalItems": false, + "items": { + "$ref": "#/definitions/SalesTariffEntryType" + }, + "minItems": 1, + "maxItems": 1024 + } + }, + "required": [ + "id", + "salesTariffEntry" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "timeBase": { + "description": "Periods contained in the charging profile are relative to this point in time.\r\n", + "type": "string", + "format": "date-time" + }, + "chargingSchedule": { + "$ref": "#/definitions/ChargingScheduleType" + }, + "evseId": { + "description": "The charging schedule contained in this notification applies to an EVSE. EvseId must be > 0.\r\n", + "type": "integer" + } + }, + "required": [ + "timeBase", + "evseId", + "chargingSchedule" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/NotifyEVChargingScheduleResponse.json b/schemas/ocpp20/NotifyEVChargingScheduleResponse.json new file mode 100644 index 00000000..189a6f72 --- /dev/null +++ b/schemas/ocpp20/NotifyEVChargingScheduleResponse.json @@ -0,0 +1,71 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:NotifyEVChargingScheduleResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "GenericStatusEnumType": { + "description": "Returns whether the CSMS has been able to process the message successfully. It does not imply any approval of the charging schedule.\r\n", + "javaType": "GenericStatusEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Accepted", + "Rejected" + ] + }, + "StatusInfoType": { + "description": "Element providing more information about the status.\r\n", + "javaType": "StatusInfo", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "reasonCode": { + "description": "A predefined code for the reason why the status is returned in this response. The string is case-insensitive.\r\n", + "type": "string", + "maxLength": 20 + }, + "additionalInfo": { + "description": "Additional text to provide detailed information.\r\n", + "type": "string", + "maxLength": 512 + } + }, + "required": [ + "reasonCode" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "status": { + "$ref": "#/definitions/GenericStatusEnumType" + }, + "statusInfo": { + "$ref": "#/definitions/StatusInfoType" + } + }, + "required": [ + "status" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/NotifyEventRequest.json b/schemas/ocpp20/NotifyEventRequest.json new file mode 100644 index 00000000..dd261981 --- /dev/null +++ b/schemas/ocpp20/NotifyEventRequest.json @@ -0,0 +1,224 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:NotifyEventRequest", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "EventNotificationEnumType": { + "description": "Specifies the event notification type of the message.\r\n\r\n", + "javaType": "EventNotificationEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "HardWiredNotification", + "HardWiredMonitor", + "PreconfiguredMonitor", + "CustomMonitor" + ] + }, + "EventTriggerEnumType": { + "description": "Type of monitor that triggered this event, e.g. exceeding a threshold value.\r\n\r\n", + "javaType": "EventTriggerEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Alerting", + "Delta", + "Periodic" + ] + }, + "ComponentType": { + "description": "A physical or logical component\r\n", + "javaType": "Component", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "evse": { + "$ref": "#/definitions/EVSEType" + }, + "name": { + "description": "Name of the component. Name should be taken from the list of standardized component names whenever possible. Case Insensitive. strongly advised to use Camel Case.\r\n", + "type": "string", + "maxLength": 50 + }, + "instance": { + "description": "Name of instance in case the component exists as multiple instances. Case Insensitive. strongly advised to use Camel Case.\r\n", + "type": "string", + "maxLength": 50 + } + }, + "required": [ + "name" + ] + }, + "EventDataType": { + "description": "Class to report an event notification for a component-variable.\r\n", + "javaType": "EventData", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "eventId": { + "description": "Identifies the event. This field can be referred to as a cause by other events.\r\n\r\n", + "type": "integer" + }, + "timestamp": { + "description": "Timestamp of the moment the report was generated.\r\n", + "type": "string", + "format": "date-time" + }, + "trigger": { + "$ref": "#/definitions/EventTriggerEnumType" + }, + "cause": { + "description": "Refers to the Id of an event that is considered to be the cause for this event.\r\n\r\n", + "type": "integer" + }, + "actualValue": { + "description": "Actual value (_attributeType_ Actual) of the variable.\r\n\r\nThe Configuration Variable <<configkey-reporting-value-size,ReportingValueSize>> can be used to limit GetVariableResult.attributeValue, VariableAttribute.value and EventData.actualValue. The max size of these values will always remain equal. \r\n\r\n", + "type": "string", + "maxLength": 2500 + }, + "techCode": { + "description": "Technical (error) code as reported by component.\r\n", + "type": "string", + "maxLength": 50 + }, + "techInfo": { + "description": "Technical detail information as reported by component.\r\n", + "type": "string", + "maxLength": 500 + }, + "cleared": { + "description": "_Cleared_ is set to true to report the clearing of a monitored situation, i.e. a 'return to normal'. \r\n\r\n", + "type": "boolean" + }, + "transactionId": { + "description": "If an event notification is linked to a specific transaction, this field can be used to specify its transactionId.\r\n", + "type": "string", + "maxLength": 36 + }, + "component": { + "$ref": "#/definitions/ComponentType" + }, + "variableMonitoringId": { + "description": "Identifies the VariableMonitoring which triggered the event.\r\n", + "type": "integer" + }, + "eventNotificationType": { + "$ref": "#/definitions/EventNotificationEnumType" + }, + "variable": { + "$ref": "#/definitions/VariableType" + } + }, + "required": [ + "eventId", + "timestamp", + "trigger", + "actualValue", + "eventNotificationType", + "component", + "variable" + ] + }, + "EVSEType": { + "description": "EVSE\r\nurn:x-oca:ocpp:uid:2:233123\r\nElectric Vehicle Supply Equipment\r\n", + "javaType": "EVSE", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "id": { + "description": "Identified_ Object. MRID. Numeric_ Identifier\r\nurn:x-enexis:ecdm:uid:1:569198\r\nEVSE Identifier. This contains a number (> 0) designating an EVSE of the Charging Station.\r\n", + "type": "integer" + }, + "connectorId": { + "description": "An id to designate a specific connector (on an EVSE) by connector index number.\r\n", + "type": "integer" + } + }, + "required": [ + "id" + ] + }, + "VariableType": { + "description": "Reference key to a component-variable.\r\n", + "javaType": "Variable", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "name": { + "description": "Name of the variable. Name should be taken from the list of standardized variable names whenever possible. Case Insensitive. strongly advised to use Camel Case.\r\n", + "type": "string", + "maxLength": 50 + }, + "instance": { + "description": "Name of instance in case the variable exists as multiple instances. Case Insensitive. strongly advised to use Camel Case.\r\n", + "type": "string", + "maxLength": 50 + } + }, + "required": [ + "name" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "generatedAt": { + "description": "Timestamp of the moment this message was generated at the Charging Station.\r\n", + "type": "string", + "format": "date-time" + }, + "tbc": { + "description": "“to be continued” indicator. Indicates whether another part of the report follows in an upcoming notifyEventRequest message. Default value when omitted is false. \r\n", + "type": "boolean", + "default": false + }, + "seqNo": { + "description": "Sequence number of this message. First message starts at 0.\r\n", + "type": "integer" + }, + "eventData": { + "type": "array", + "additionalItems": false, + "items": { + "$ref": "#/definitions/EventDataType" + }, + "minItems": 1 + } + }, + "required": [ + "generatedAt", + "seqNo", + "eventData" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/NotifyEventResponse.json b/schemas/ocpp20/NotifyEventResponse.json new file mode 100644 index 00000000..9b254922 --- /dev/null +++ b/schemas/ocpp20/NotifyEventResponse.json @@ -0,0 +1,28 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:NotifyEventResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + } + } +} \ No newline at end of file diff --git a/schemas/ocpp20/NotifyMonitoringReportRequest.json b/schemas/ocpp20/NotifyMonitoringReportRequest.json new file mode 100644 index 00000000..bc64d067 --- /dev/null +++ b/schemas/ocpp20/NotifyMonitoringReportRequest.json @@ -0,0 +1,212 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:NotifyMonitoringReportRequest", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "MonitorEnumType": { + "description": "The type of this monitor, e.g. a threshold, delta or periodic monitor. \r\n", + "javaType": "MonitorEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "UpperThreshold", + "LowerThreshold", + "Delta", + "Periodic", + "PeriodicClockAligned" + ] + }, + "ComponentType": { + "description": "A physical or logical component\r\n", + "javaType": "Component", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "evse": { + "$ref": "#/definitions/EVSEType" + }, + "name": { + "description": "Name of the component. Name should be taken from the list of standardized component names whenever possible. Case Insensitive. strongly advised to use Camel Case.\r\n", + "type": "string", + "maxLength": 50 + }, + "instance": { + "description": "Name of instance in case the component exists as multiple instances. Case Insensitive. strongly advised to use Camel Case.\r\n", + "type": "string", + "maxLength": 50 + } + }, + "required": [ + "name" + ] + }, + "EVSEType": { + "description": "EVSE\r\nurn:x-oca:ocpp:uid:2:233123\r\nElectric Vehicle Supply Equipment\r\n", + "javaType": "EVSE", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "id": { + "description": "Identified_ Object. MRID. Numeric_ Identifier\r\nurn:x-enexis:ecdm:uid:1:569198\r\nEVSE Identifier. This contains a number (> 0) designating an EVSE of the Charging Station.\r\n", + "type": "integer" + }, + "connectorId": { + "description": "An id to designate a specific connector (on an EVSE) by connector index number.\r\n", + "type": "integer" + } + }, + "required": [ + "id" + ] + }, + "MonitoringDataType": { + "description": "Class to hold parameters of SetVariableMonitoring request.\r\n", + "javaType": "MonitoringData", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "component": { + "$ref": "#/definitions/ComponentType" + }, + "variable": { + "$ref": "#/definitions/VariableType" + }, + "variableMonitoring": { + "type": "array", + "additionalItems": false, + "items": { + "$ref": "#/definitions/VariableMonitoringType" + }, + "minItems": 1 + } + }, + "required": [ + "component", + "variable", + "variableMonitoring" + ] + }, + "VariableMonitoringType": { + "description": "A monitoring setting for a variable.\r\n", + "javaType": "VariableMonitoring", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "id": { + "description": "Identifies the monitor.\r\n", + "type": "integer" + }, + "transaction": { + "description": "Monitor only active when a transaction is ongoing on a component relevant to this transaction. \r\n", + "type": "boolean" + }, + "value": { + "description": "Value for threshold or delta monitoring.\r\nFor Periodic or PeriodicClockAligned this is the interval in seconds.\r\n", + "type": "number" + }, + "type": { + "$ref": "#/definitions/MonitorEnumType" + }, + "severity": { + "description": "The severity that will be assigned to an event that is triggered by this monitor. The severity range is 0-9, with 0 as the highest and 9 as the lowest severity level.\r\n\r\nThe severity levels have the following meaning: +\r\n*0-Danger* +\r\nIndicates lives are potentially in danger. Urgent attention is needed and action should be taken immediately. +\r\n*1-Hardware Failure* +\r\nIndicates that the Charging Station is unable to continue regular operations due to Hardware issues. Action is required. +\r\n*2-System Failure* +\r\nIndicates that the Charging Station is unable to continue regular operations due to software or minor hardware issues. Action is required. +\r\n*3-Critical* +\r\nIndicates a critical error. Action is required. +\r\n*4-Error* +\r\nIndicates a non-urgent error. Action is required. +\r\n*5-Alert* +\r\nIndicates an alert event. Default severity for any type of monitoring event. +\r\n*6-Warning* +\r\nIndicates a warning event. Action may be required. +\r\n*7-Notice* +\r\nIndicates an unusual event. No immediate action is required. +\r\n*8-Informational* +\r\nIndicates a regular operational event. May be used for reporting, measuring throughput, etc. No action is required. +\r\n*9-Debug* +\r\nIndicates information useful to developers for debugging, not useful during operations.\r\n", + "type": "integer" + } + }, + "required": [ + "id", + "transaction", + "value", + "type", + "severity" + ] + }, + "VariableType": { + "description": "Reference key to a component-variable.\r\n", + "javaType": "Variable", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "name": { + "description": "Name of the variable. Name should be taken from the list of standardized variable names whenever possible. Case Insensitive. strongly advised to use Camel Case.\r\n", + "type": "string", + "maxLength": 50 + }, + "instance": { + "description": "Name of instance in case the variable exists as multiple instances. Case Insensitive. strongly advised to use Camel Case.\r\n", + "type": "string", + "maxLength": 50 + } + }, + "required": [ + "name" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "monitor": { + "type": "array", + "additionalItems": false, + "items": { + "$ref": "#/definitions/MonitoringDataType" + }, + "minItems": 1 + }, + "requestId": { + "description": "The id of the GetMonitoringRequest that requested this report.\r\n\r\n", + "type": "integer" + }, + "tbc": { + "description": "“to be continued” indicator. Indicates whether another part of the monitoringData follows in an upcoming notifyMonitoringReportRequest message. Default value when omitted is false.\r\n", + "type": "boolean", + "default": false + }, + "seqNo": { + "description": "Sequence number of this message. First message starts at 0.\r\n", + "type": "integer" + }, + "generatedAt": { + "description": "Timestamp of the moment this message was generated at the Charging Station.\r\n", + "type": "string", + "format": "date-time" + } + }, + "required": [ + "requestId", + "seqNo", + "generatedAt" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/NotifyMonitoringReportResponse.json b/schemas/ocpp20/NotifyMonitoringReportResponse.json new file mode 100644 index 00000000..74a60bbe --- /dev/null +++ b/schemas/ocpp20/NotifyMonitoringReportResponse.json @@ -0,0 +1,28 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:NotifyMonitoringReportResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + } + } +} \ No newline at end of file diff --git a/schemas/ocpp20/NotifyReportRequest.json b/schemas/ocpp20/NotifyReportRequest.json new file mode 100644 index 00000000..b35c286c --- /dev/null +++ b/schemas/ocpp20/NotifyReportRequest.json @@ -0,0 +1,279 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:NotifyReportRequest", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "AttributeEnumType": { + "description": "Attribute: Actual, MinSet, MaxSet, etc.\r\nDefaults to Actual if absent.\r\n", + "javaType": "AttributeEnum", + "type": "string", + "default": "Actual", + "additionalProperties": false, + "enum": [ + "Actual", + "Target", + "MinSet", + "MaxSet" + ] + }, + "DataEnumType": { + "description": "Data type of this variable.\r\n", + "javaType": "DataEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "string", + "decimal", + "integer", + "dateTime", + "boolean", + "OptionList", + "SequenceList", + "MemberList" + ] + }, + "MutabilityEnumType": { + "description": "Defines the mutability of this attribute. Default is ReadWrite when omitted.\r\n", + "javaType": "MutabilityEnum", + "type": "string", + "default": "ReadWrite", + "additionalProperties": false, + "enum": [ + "ReadOnly", + "WriteOnly", + "ReadWrite" + ] + }, + "ComponentType": { + "description": "A physical or logical component\r\n", + "javaType": "Component", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "evse": { + "$ref": "#/definitions/EVSEType" + }, + "name": { + "description": "Name of the component. Name should be taken from the list of standardized component names whenever possible. Case Insensitive. strongly advised to use Camel Case.\r\n", + "type": "string", + "maxLength": 50 + }, + "instance": { + "description": "Name of instance in case the component exists as multiple instances. Case Insensitive. strongly advised to use Camel Case.\r\n", + "type": "string", + "maxLength": 50 + } + }, + "required": [ + "name" + ] + }, + "EVSEType": { + "description": "EVSE\r\nurn:x-oca:ocpp:uid:2:233123\r\nElectric Vehicle Supply Equipment\r\n", + "javaType": "EVSE", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "id": { + "description": "Identified_ Object. MRID. Numeric_ Identifier\r\nurn:x-enexis:ecdm:uid:1:569198\r\nEVSE Identifier. This contains a number (> 0) designating an EVSE of the Charging Station.\r\n", + "type": "integer" + }, + "connectorId": { + "description": "An id to designate a specific connector (on an EVSE) by connector index number.\r\n", + "type": "integer" + } + }, + "required": [ + "id" + ] + }, + "ReportDataType": { + "description": "Class to report components, variables and variable attributes and characteristics.\r\n", + "javaType": "ReportData", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "component": { + "$ref": "#/definitions/ComponentType" + }, + "variable": { + "$ref": "#/definitions/VariableType" + }, + "variableAttribute": { + "type": "array", + "additionalItems": false, + "items": { + "$ref": "#/definitions/VariableAttributeType" + }, + "minItems": 1, + "maxItems": 4 + }, + "variableCharacteristics": { + "$ref": "#/definitions/VariableCharacteristicsType" + } + }, + "required": [ + "component", + "variable", + "variableAttribute" + ] + }, + "VariableAttributeType": { + "description": "Attribute data of a variable.\r\n", + "javaType": "VariableAttribute", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "type": { + "$ref": "#/definitions/AttributeEnumType" + }, + "value": { + "description": "Value of the attribute. May only be omitted when mutability is set to 'WriteOnly'.\r\n\r\nThe Configuration Variable <<configkey-reporting-value-size,ReportingValueSize>> can be used to limit GetVariableResult.attributeValue, VariableAttribute.value and EventData.actualValue. The max size of these values will always remain equal. \r\n", + "type": "string", + "maxLength": 2500 + }, + "mutability": { + "$ref": "#/definitions/MutabilityEnumType" + }, + "persistent": { + "description": "If true, value will be persistent across system reboots or power down. Default when omitted is false.\r\n", + "type": "boolean", + "default": false + }, + "constant": { + "description": "If true, value that will never be changed by the Charging Station at runtime. Default when omitted is false.\r\n", + "type": "boolean", + "default": false + } + } + }, + "VariableCharacteristicsType": { + "description": "Fixed read-only parameters of a variable.\r\n", + "javaType": "VariableCharacteristics", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "unit": { + "description": "Unit of the variable. When the transmitted value has a unit, this field SHALL be included.\r\n", + "type": "string", + "maxLength": 16 + }, + "dataType": { + "$ref": "#/definitions/DataEnumType" + }, + "minLimit": { + "description": "Minimum possible value of this variable.\r\n", + "type": "number" + }, + "maxLimit": { + "description": "Maximum possible value of this variable. When the datatype of this Variable is String, OptionList, SequenceList or MemberList, this field defines the maximum length of the (CSV) string.\r\n", + "type": "number" + }, + "valuesList": { + "description": "Allowed values when variable is Option/Member/SequenceList. \r\n\r\n* OptionList: The (Actual) Variable value must be a single value from the reported (CSV) enumeration list.\r\n\r\n* MemberList: The (Actual) Variable value may be an (unordered) (sub-)set of the reported (CSV) valid values list.\r\n\r\n* SequenceList: The (Actual) Variable value may be an ordered (priority, etc) (sub-)set of the reported (CSV) valid values.\r\n\r\nThis is a comma separated list.\r\n\r\nThe Configuration Variable <<configkey-configuration-value-size,ConfigurationValueSize>> can be used to limit SetVariableData.attributeValue and VariableCharacteristics.valueList. The max size of these values will always remain equal. \r\n\r\n", + "type": "string", + "maxLength": 1000 + }, + "supportsMonitoring": { + "description": "Flag indicating if this variable supports monitoring. \r\n", + "type": "boolean" + } + }, + "required": [ + "dataType", + "supportsMonitoring" + ] + }, + "VariableType": { + "description": "Reference key to a component-variable.\r\n", + "javaType": "Variable", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "name": { + "description": "Name of the variable. Name should be taken from the list of standardized variable names whenever possible. Case Insensitive. strongly advised to use Camel Case.\r\n", + "type": "string", + "maxLength": 50 + }, + "instance": { + "description": "Name of instance in case the variable exists as multiple instances. Case Insensitive. strongly advised to use Camel Case.\r\n", + "type": "string", + "maxLength": 50 + } + }, + "required": [ + "name" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "requestId": { + "description": "The id of the GetReportRequest or GetBaseReportRequest that requested this report\r\n", + "type": "integer" + }, + "generatedAt": { + "description": "Timestamp of the moment this message was generated at the Charging Station.\r\n", + "type": "string", + "format": "date-time" + }, + "reportData": { + "type": "array", + "additionalItems": false, + "items": { + "$ref": "#/definitions/ReportDataType" + }, + "minItems": 1 + }, + "tbc": { + "description": "“to be continued” indicator. Indicates whether another part of the report follows in an upcoming notifyReportRequest message. Default value when omitted is false.\r\n\r\n", + "type": "boolean", + "default": false + }, + "seqNo": { + "description": "Sequence number of this message. First message starts at 0.\r\n", + "type": "integer" + } + }, + "required": [ + "requestId", + "generatedAt", + "seqNo" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/NotifyReportResponse.json b/schemas/ocpp20/NotifyReportResponse.json new file mode 100644 index 00000000..ea51f822 --- /dev/null +++ b/schemas/ocpp20/NotifyReportResponse.json @@ -0,0 +1,28 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:NotifyReportResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + } + } +} \ No newline at end of file diff --git a/schemas/ocpp20/PublishFirmwareRequest.json b/schemas/ocpp20/PublishFirmwareRequest.json new file mode 100644 index 00000000..e9af77b6 --- /dev/null +++ b/schemas/ocpp20/PublishFirmwareRequest.json @@ -0,0 +1,55 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:PublishFirmwareRequest", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "location": { + "description": "This contains a string containing a URI pointing to a\r\nlocation from which to retrieve the firmware.\r\n", + "type": "string", + "maxLength": 512 + }, + "retries": { + "description": "This specifies how many times Charging Station must try\r\nto download the firmware before giving up. If this field is not\r\npresent, it is left to Charging Station to decide how many times it wants to retry.\r\n", + "type": "integer" + }, + "checksum": { + "description": "The MD5 checksum over the entire firmware file as a hexadecimal string of length 32. \r\n", + "type": "string", + "maxLength": 32 + }, + "requestId": { + "description": "The Id of the request.\r\n", + "type": "integer" + }, + "retryInterval": { + "description": "The interval in seconds\r\nafter which a retry may be\r\nattempted. If this field is not\r\npresent, it is left to Charging\r\nStation to decide how long to wait\r\nbetween attempts.\r\n", + "type": "integer" + } + }, + "required": [ + "location", + "checksum", + "requestId" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/PublishFirmwareResponse.json b/schemas/ocpp20/PublishFirmwareResponse.json new file mode 100644 index 00000000..a77bc37f --- /dev/null +++ b/schemas/ocpp20/PublishFirmwareResponse.json @@ -0,0 +1,71 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:PublishFirmwareResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "GenericStatusEnumType": { + "description": "Indicates whether the request was accepted.\r\n", + "javaType": "GenericStatusEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Accepted", + "Rejected" + ] + }, + "StatusInfoType": { + "description": "Element providing more information about the status.\r\n", + "javaType": "StatusInfo", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "reasonCode": { + "description": "A predefined code for the reason why the status is returned in this response. The string is case-insensitive.\r\n", + "type": "string", + "maxLength": 20 + }, + "additionalInfo": { + "description": "Additional text to provide detailed information.\r\n", + "type": "string", + "maxLength": 512 + } + }, + "required": [ + "reasonCode" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "status": { + "$ref": "#/definitions/GenericStatusEnumType" + }, + "statusInfo": { + "$ref": "#/definitions/StatusInfoType" + } + }, + "required": [ + "status" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/PublishFirmwareStatusNotificationRequest.json b/schemas/ocpp20/PublishFirmwareStatusNotificationRequest.json new file mode 100644 index 00000000..d0ae6d7f --- /dev/null +++ b/schemas/ocpp20/PublishFirmwareStatusNotificationRequest.json @@ -0,0 +1,66 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:PublishFirmwareStatusNotificationRequest", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "PublishFirmwareStatusEnumType": { + "description": "This contains the progress status of the publishfirmware\r\ninstallation.\r\n", + "javaType": "PublishFirmwareStatusEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Idle", + "DownloadScheduled", + "Downloading", + "Downloaded", + "Published", + "DownloadFailed", + "DownloadPaused", + "InvalidChecksum", + "ChecksumVerified", + "PublishFailed" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "status": { + "$ref": "#/definitions/PublishFirmwareStatusEnumType" + }, + "location": { + "description": "Required if status is Published. Can be multiple URI’s, if the Local Controller supports e.g. HTTP, HTTPS, and FTP.\r\n", + "type": "array", + "additionalItems": false, + "items": { + "type": "string", + "maxLength": 512 + }, + "minItems": 1 + }, + "requestId": { + "description": "The request id that was\r\nprovided in the\r\nPublishFirmwareRequest which\r\ntriggered this action.\r\n", + "type": "integer" + } + }, + "required": [ + "status" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/PublishFirmwareStatusNotificationResponse.json b/schemas/ocpp20/PublishFirmwareStatusNotificationResponse.json new file mode 100644 index 00000000..96d23237 --- /dev/null +++ b/schemas/ocpp20/PublishFirmwareStatusNotificationResponse.json @@ -0,0 +1,28 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:PublishFirmwareStatusNotificationResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + } + } +} \ No newline at end of file diff --git a/schemas/ocpp20/ReportChargingProfilesRequest.json b/schemas/ocpp20/ReportChargingProfilesRequest.json new file mode 100644 index 00000000..54e8e84c --- /dev/null +++ b/schemas/ocpp20/ReportChargingProfilesRequest.json @@ -0,0 +1,406 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:ReportChargingProfilesRequest", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "ChargingLimitSourceEnumType": { + "description": "Source that has installed this charging profile.\r\n", + "javaType": "ChargingLimitSourceEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "EMS", + "Other", + "SO", + "CSO" + ] + }, + "ChargingProfileKindEnumType": { + "description": "Charging_ Profile. Charging_ Profile_ Kind. Charging_ Profile_ Kind_ Code\r\nurn:x-oca:ocpp:uid:1:569232\r\nIndicates the kind of schedule.\r\n", + "javaType": "ChargingProfileKindEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Absolute", + "Recurring", + "Relative" + ] + }, + "ChargingProfilePurposeEnumType": { + "description": "Charging_ Profile. Charging_ Profile_ Purpose. Charging_ Profile_ Purpose_ Code\r\nurn:x-oca:ocpp:uid:1:569231\r\nDefines the purpose of the schedule transferred by this profile\r\n", + "javaType": "ChargingProfilePurposeEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "ChargingStationExternalConstraints", + "ChargingStationMaxProfile", + "TxDefaultProfile", + "TxProfile" + ] + }, + "ChargingRateUnitEnumType": { + "description": "Charging_ Schedule. Charging_ Rate_ Unit. Charging_ Rate_ Unit_ Code\r\nurn:x-oca:ocpp:uid:1:569238\r\nThe unit of measure Limit is expressed in.\r\n", + "javaType": "ChargingRateUnitEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "W", + "A" + ] + }, + "CostKindEnumType": { + "description": "Cost. Cost_ Kind. Cost_ Kind_ Code\r\nurn:x-oca:ocpp:uid:1:569243\r\nThe kind of cost referred to in the message element amount\r\n", + "javaType": "CostKindEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "CarbonDioxideEmission", + "RelativePricePercentage", + "RenewableGenerationPercentage" + ] + }, + "RecurrencyKindEnumType": { + "description": "Charging_ Profile. Recurrency_ Kind. Recurrency_ Kind_ Code\r\nurn:x-oca:ocpp:uid:1:569233\r\nIndicates the start point of a recurrence.\r\n", + "javaType": "RecurrencyKindEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Daily", + "Weekly" + ] + }, + "ChargingProfileType": { + "description": "Charging_ Profile\r\nurn:x-oca:ocpp:uid:2:233255\r\nA ChargingProfile consists of ChargingSchedule, describing the amount of power or current that can be delivered per time interval.\r\n", + "javaType": "ChargingProfile", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "id": { + "description": "Identified_ Object. MRID. Numeric_ Identifier\r\nurn:x-enexis:ecdm:uid:1:569198\r\nId of ChargingProfile.\r\n", + "type": "integer" + }, + "stackLevel": { + "description": "Charging_ Profile. Stack_ Level. Counter\r\nurn:x-oca:ocpp:uid:1:569230\r\nValue determining level in hierarchy stack of profiles. Higher values have precedence over lower values. Lowest level is 0.\r\n", + "type": "integer" + }, + "chargingProfilePurpose": { + "$ref": "#/definitions/ChargingProfilePurposeEnumType" + }, + "chargingProfileKind": { + "$ref": "#/definitions/ChargingProfileKindEnumType" + }, + "recurrencyKind": { + "$ref": "#/definitions/RecurrencyKindEnumType" + }, + "validFrom": { + "description": "Charging_ Profile. Valid_ From. Date_ Time\r\nurn:x-oca:ocpp:uid:1:569234\r\nPoint in time at which the profile starts to be valid. If absent, the profile is valid as soon as it is received by the Charging Station.\r\n", + "type": "string", + "format": "date-time" + }, + "validTo": { + "description": "Charging_ Profile. Valid_ To. Date_ Time\r\nurn:x-oca:ocpp:uid:1:569235\r\nPoint in time at which the profile stops to be valid. If absent, the profile is valid until it is replaced by another profile.\r\n", + "type": "string", + "format": "date-time" + }, + "chargingSchedule": { + "type": "array", + "additionalItems": false, + "items": { + "$ref": "#/definitions/ChargingScheduleType" + }, + "minItems": 1, + "maxItems": 3 + }, + "transactionId": { + "description": "SHALL only be included if ChargingProfilePurpose is set to TxProfile. The transactionId is used to match the profile to a specific transaction.\r\n", + "type": "string", + "maxLength": 36 + } + }, + "required": [ + "id", + "stackLevel", + "chargingProfilePurpose", + "chargingProfileKind", + "chargingSchedule" + ] + }, + "ChargingSchedulePeriodType": { + "description": "Charging_ Schedule_ Period\r\nurn:x-oca:ocpp:uid:2:233257\r\nCharging schedule period structure defines a time period in a charging schedule.\r\n", + "javaType": "ChargingSchedulePeriod", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "startPeriod": { + "description": "Charging_ Schedule_ Period. Start_ Period. Elapsed_ Time\r\nurn:x-oca:ocpp:uid:1:569240\r\nStart of the period, in seconds from the start of schedule. The value of StartPeriod also defines the stop time of the previous period.\r\n", + "type": "integer" + }, + "limit": { + "description": "Charging_ Schedule_ Period. Limit. Measure\r\nurn:x-oca:ocpp:uid:1:569241\r\nCharging rate limit during the schedule period, in the applicable chargingRateUnit, for example in Amperes (A) or Watts (W). Accepts at most one digit fraction (e.g. 8.1).\r\n", + "type": "number" + }, + "numberPhases": { + "description": "Charging_ Schedule_ Period. Number_ Phases. Counter\r\nurn:x-oca:ocpp:uid:1:569242\r\nThe number of phases that can be used for charging. If a number of phases is needed, numberPhases=3 will be assumed unless another number is given.\r\n", + "type": "integer" + }, + "phaseToUse": { + "description": "Values: 1..3, Used if numberPhases=1 and if the EVSE is capable of switching the phase connected to the EV, i.e. ACPhaseSwitchingSupported is defined and true. It’s not allowed unless both conditions above are true. If both conditions are true, and phaseToUse is omitted, the Charging Station / EVSE will make the selection on its own.\r\n\r\n", + "type": "integer" + } + }, + "required": [ + "startPeriod", + "limit" + ] + }, + "ChargingScheduleType": { + "description": "Charging_ Schedule\r\nurn:x-oca:ocpp:uid:2:233256\r\nCharging schedule structure defines a list of charging periods, as used in: GetCompositeSchedule.conf and ChargingProfile. \r\n", + "javaType": "ChargingSchedule", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "id": { + "description": "Identifies the ChargingSchedule.\r\n", + "type": "integer" + }, + "startSchedule": { + "description": "Charging_ Schedule. Start_ Schedule. Date_ Time\r\nurn:x-oca:ocpp:uid:1:569237\r\nStarting point of an absolute schedule. If absent the schedule will be relative to start of charging.\r\n", + "type": "string", + "format": "date-time" + }, + "duration": { + "description": "Charging_ Schedule. Duration. Elapsed_ Time\r\nurn:x-oca:ocpp:uid:1:569236\r\nDuration of the charging schedule in seconds. If the duration is left empty, the last period will continue indefinitely or until end of the transaction if chargingProfilePurpose = TxProfile.\r\n", + "type": "integer" + }, + "chargingRateUnit": { + "$ref": "#/definitions/ChargingRateUnitEnumType" + }, + "chargingSchedulePeriod": { + "type": "array", + "additionalItems": false, + "items": { + "$ref": "#/definitions/ChargingSchedulePeriodType" + }, + "minItems": 1, + "maxItems": 1024 + }, + "minChargingRate": { + "description": "Charging_ Schedule. Min_ Charging_ Rate. Numeric\r\nurn:x-oca:ocpp:uid:1:569239\r\nMinimum charging rate supported by the EV. The unit of measure is defined by the chargingRateUnit. This parameter is intended to be used by a local smart charging algorithm to optimize the power allocation for in the case a charging process is inefficient at lower charging rates. Accepts at most one digit fraction (e.g. 8.1)\r\n", + "type": "number" + }, + "salesTariff": { + "$ref": "#/definitions/SalesTariffType" + } + }, + "required": [ + "id", + "chargingRateUnit", + "chargingSchedulePeriod" + ] + }, + "ConsumptionCostType": { + "description": "Consumption_ Cost\r\nurn:x-oca:ocpp:uid:2:233259\r\n", + "javaType": "ConsumptionCost", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "startValue": { + "description": "Consumption_ Cost. Start_ Value. Numeric\r\nurn:x-oca:ocpp:uid:1:569246\r\nThe lowest level of consumption that defines the starting point of this consumption block. The block interval extends to the start of the next interval.\r\n", + "type": "number" + }, + "cost": { + "type": "array", + "additionalItems": false, + "items": { + "$ref": "#/definitions/CostType" + }, + "minItems": 1, + "maxItems": 3 + } + }, + "required": [ + "startValue", + "cost" + ] + }, + "CostType": { + "description": "Cost\r\nurn:x-oca:ocpp:uid:2:233258\r\n", + "javaType": "Cost", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "costKind": { + "$ref": "#/definitions/CostKindEnumType" + }, + "amount": { + "description": "Cost. Amount. Amount\r\nurn:x-oca:ocpp:uid:1:569244\r\nThe estimated or actual cost per kWh\r\n", + "type": "integer" + }, + "amountMultiplier": { + "description": "Cost. Amount_ Multiplier. Integer\r\nurn:x-oca:ocpp:uid:1:569245\r\nValues: -3..3, The amountMultiplier defines the exponent to base 10 (dec). The final value is determined by: amount * 10 ^ amountMultiplier\r\n", + "type": "integer" + } + }, + "required": [ + "costKind", + "amount" + ] + }, + "RelativeTimeIntervalType": { + "description": "Relative_ Timer_ Interval\r\nurn:x-oca:ocpp:uid:2:233270\r\n", + "javaType": "RelativeTimeInterval", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "start": { + "description": "Relative_ Timer_ Interval. Start. Elapsed_ Time\r\nurn:x-oca:ocpp:uid:1:569279\r\nStart of the interval, in seconds from NOW.\r\n", + "type": "integer" + }, + "duration": { + "description": "Relative_ Timer_ Interval. Duration. Elapsed_ Time\r\nurn:x-oca:ocpp:uid:1:569280\r\nDuration of the interval, in seconds.\r\n", + "type": "integer" + } + }, + "required": [ + "start" + ] + }, + "SalesTariffEntryType": { + "description": "Sales_ Tariff_ Entry\r\nurn:x-oca:ocpp:uid:2:233271\r\n", + "javaType": "SalesTariffEntry", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "relativeTimeInterval": { + "$ref": "#/definitions/RelativeTimeIntervalType" + }, + "ePriceLevel": { + "description": "Sales_ Tariff_ Entry. E_ Price_ Level. Unsigned_ Integer\r\nurn:x-oca:ocpp:uid:1:569281\r\nDefines the price level of this SalesTariffEntry (referring to NumEPriceLevels). Small values for the EPriceLevel represent a cheaper TariffEntry. Large values for the EPriceLevel represent a more expensive TariffEntry.\r\n", + "type": "integer", + "minimum": 0.0 + }, + "consumptionCost": { + "type": "array", + "additionalItems": false, + "items": { + "$ref": "#/definitions/ConsumptionCostType" + }, + "minItems": 1, + "maxItems": 3 + } + }, + "required": [ + "relativeTimeInterval" + ] + }, + "SalesTariffType": { + "description": "Sales_ Tariff\r\nurn:x-oca:ocpp:uid:2:233272\r\nNOTE: This dataType is based on dataTypes from <<ref-ISOIEC15118-2,ISO 15118-2>>.\r\n", + "javaType": "SalesTariff", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "id": { + "description": "Identified_ Object. MRID. Numeric_ Identifier\r\nurn:x-enexis:ecdm:uid:1:569198\r\nSalesTariff identifier used to identify one sales tariff. An SAID remains a unique identifier for one schedule throughout a charging session.\r\n", + "type": "integer" + }, + "salesTariffDescription": { + "description": "Sales_ Tariff. Sales. Tariff_ Description\r\nurn:x-oca:ocpp:uid:1:569283\r\nA human readable title/short description of the sales tariff e.g. for HMI display purposes.\r\n", + "type": "string", + "maxLength": 32 + }, + "numEPriceLevels": { + "description": "Sales_ Tariff. Num_ E_ Price_ Levels. Counter\r\nurn:x-oca:ocpp:uid:1:569284\r\nDefines the overall number of distinct price levels used across all provided SalesTariff elements.\r\n", + "type": "integer" + }, + "salesTariffEntry": { + "type": "array", + "additionalItems": false, + "items": { + "$ref": "#/definitions/SalesTariffEntryType" + }, + "minItems": 1, + "maxItems": 1024 + } + }, + "required": [ + "id", + "salesTariffEntry" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "requestId": { + "description": "Id used to match the <<getchargingprofilesrequest, GetChargingProfilesRequest>> message with the resulting ReportChargingProfilesRequest messages. When the CSMS provided a requestId in the <<getchargingprofilesrequest, GetChargingProfilesRequest>>, this field SHALL contain the same value.\r\n", + "type": "integer" + }, + "chargingLimitSource": { + "$ref": "#/definitions/ChargingLimitSourceEnumType" + }, + "chargingProfile": { + "type": "array", + "additionalItems": false, + "items": { + "$ref": "#/definitions/ChargingProfileType" + }, + "minItems": 1 + }, + "tbc": { + "description": "To Be Continued. Default value when omitted: false. false indicates that there are no further messages as part of this report.\r\n", + "type": "boolean", + "default": false + }, + "evseId": { + "description": "The evse to which the charging profile applies. If evseId = 0, the message contains an overall limit for the Charging Station.\r\n", + "type": "integer" + } + }, + "required": [ + "requestId", + "chargingLimitSource", + "evseId", + "chargingProfile" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/ReportChargingProfilesResponse.json b/schemas/ocpp20/ReportChargingProfilesResponse.json new file mode 100644 index 00000000..10b19ae1 --- /dev/null +++ b/schemas/ocpp20/ReportChargingProfilesResponse.json @@ -0,0 +1,28 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:ReportChargingProfilesResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + } + } +} \ No newline at end of file diff --git a/schemas/ocpp20/RequestStartTransactionRequest.json b/schemas/ocpp20/RequestStartTransactionRequest.json new file mode 100644 index 00000000..4fad2e14 --- /dev/null +++ b/schemas/ocpp20/RequestStartTransactionRequest.json @@ -0,0 +1,457 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:RequestStartTransactionRequest", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "ChargingProfileKindEnumType": { + "description": "Charging_ Profile. Charging_ Profile_ Kind. Charging_ Profile_ Kind_ Code\r\nurn:x-oca:ocpp:uid:1:569232\r\nIndicates the kind of schedule.\r\n", + "javaType": "ChargingProfileKindEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Absolute", + "Recurring", + "Relative" + ] + }, + "ChargingProfilePurposeEnumType": { + "description": "Charging_ Profile. Charging_ Profile_ Purpose. Charging_ Profile_ Purpose_ Code\r\nurn:x-oca:ocpp:uid:1:569231\r\nDefines the purpose of the schedule transferred by this profile\r\n", + "javaType": "ChargingProfilePurposeEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "ChargingStationExternalConstraints", + "ChargingStationMaxProfile", + "TxDefaultProfile", + "TxProfile" + ] + }, + "ChargingRateUnitEnumType": { + "description": "Charging_ Schedule. Charging_ Rate_ Unit. Charging_ Rate_ Unit_ Code\r\nurn:x-oca:ocpp:uid:1:569238\r\nThe unit of measure Limit is expressed in.\r\n", + "javaType": "ChargingRateUnitEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "W", + "A" + ] + }, + "CostKindEnumType": { + "description": "Cost. Cost_ Kind. Cost_ Kind_ Code\r\nurn:x-oca:ocpp:uid:1:569243\r\nThe kind of cost referred to in the message element amount\r\n", + "javaType": "CostKindEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "CarbonDioxideEmission", + "RelativePricePercentage", + "RenewableGenerationPercentage" + ] + }, + "IdTokenEnumType": { + "description": "Enumeration of possible idToken types.\r\n", + "javaType": "IdTokenEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Central", + "eMAID", + "ISO14443", + "ISO15693", + "KeyCode", + "Local", + "MacAddress", + "NoAuthorization" + ] + }, + "RecurrencyKindEnumType": { + "description": "Charging_ Profile. Recurrency_ Kind. Recurrency_ Kind_ Code\r\nurn:x-oca:ocpp:uid:1:569233\r\nIndicates the start point of a recurrence.\r\n", + "javaType": "RecurrencyKindEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Daily", + "Weekly" + ] + }, + "AdditionalInfoType": { + "description": "Contains a case insensitive identifier to use for the authorization and the type of authorization to support multiple forms of identifiers.\r\n", + "javaType": "AdditionalInfo", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "additionalIdToken": { + "description": "This field specifies the additional IdToken.\r\n", + "type": "string", + "maxLength": 36 + }, + "type": { + "description": "This defines the type of the additionalIdToken. This is a custom type, so the implementation needs to be agreed upon by all involved parties.\r\n", + "type": "string", + "maxLength": 50 + } + }, + "required": [ + "additionalIdToken", + "type" + ] + }, + "ChargingProfileType": { + "description": "Charging_ Profile\r\nurn:x-oca:ocpp:uid:2:233255\r\nA ChargingProfile consists of ChargingSchedule, describing the amount of power or current that can be delivered per time interval.\r\n", + "javaType": "ChargingProfile", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "id": { + "description": "Identified_ Object. MRID. Numeric_ Identifier\r\nurn:x-enexis:ecdm:uid:1:569198\r\nId of ChargingProfile.\r\n", + "type": "integer" + }, + "stackLevel": { + "description": "Charging_ Profile. Stack_ Level. Counter\r\nurn:x-oca:ocpp:uid:1:569230\r\nValue determining level in hierarchy stack of profiles. Higher values have precedence over lower values. Lowest level is 0.\r\n", + "type": "integer" + }, + "chargingProfilePurpose": { + "$ref": "#/definitions/ChargingProfilePurposeEnumType" + }, + "chargingProfileKind": { + "$ref": "#/definitions/ChargingProfileKindEnumType" + }, + "recurrencyKind": { + "$ref": "#/definitions/RecurrencyKindEnumType" + }, + "validFrom": { + "description": "Charging_ Profile. Valid_ From. Date_ Time\r\nurn:x-oca:ocpp:uid:1:569234\r\nPoint in time at which the profile starts to be valid. If absent, the profile is valid as soon as it is received by the Charging Station.\r\n", + "type": "string", + "format": "date-time" + }, + "validTo": { + "description": "Charging_ Profile. Valid_ To. Date_ Time\r\nurn:x-oca:ocpp:uid:1:569235\r\nPoint in time at which the profile stops to be valid. If absent, the profile is valid until it is replaced by another profile.\r\n", + "type": "string", + "format": "date-time" + }, + "chargingSchedule": { + "type": "array", + "additionalItems": false, + "items": { + "$ref": "#/definitions/ChargingScheduleType" + }, + "minItems": 1, + "maxItems": 3 + }, + "transactionId": { + "description": "SHALL only be included if ChargingProfilePurpose is set to TxProfile. The transactionId is used to match the profile to a specific transaction.\r\n", + "type": "string", + "maxLength": 36 + } + }, + "required": [ + "id", + "stackLevel", + "chargingProfilePurpose", + "chargingProfileKind", + "chargingSchedule" + ] + }, + "ChargingSchedulePeriodType": { + "description": "Charging_ Schedule_ Period\r\nurn:x-oca:ocpp:uid:2:233257\r\nCharging schedule period structure defines a time period in a charging schedule.\r\n", + "javaType": "ChargingSchedulePeriod", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "startPeriod": { + "description": "Charging_ Schedule_ Period. Start_ Period. Elapsed_ Time\r\nurn:x-oca:ocpp:uid:1:569240\r\nStart of the period, in seconds from the start of schedule. The value of StartPeriod also defines the stop time of the previous period.\r\n", + "type": "integer" + }, + "limit": { + "description": "Charging_ Schedule_ Period. Limit. Measure\r\nurn:x-oca:ocpp:uid:1:569241\r\nCharging rate limit during the schedule period, in the applicable chargingRateUnit, for example in Amperes (A) or Watts (W). Accepts at most one digit fraction (e.g. 8.1).\r\n", + "type": "number" + }, + "numberPhases": { + "description": "Charging_ Schedule_ Period. Number_ Phases. Counter\r\nurn:x-oca:ocpp:uid:1:569242\r\nThe number of phases that can be used for charging. If a number of phases is needed, numberPhases=3 will be assumed unless another number is given.\r\n", + "type": "integer" + }, + "phaseToUse": { + "description": "Values: 1..3, Used if numberPhases=1 and if the EVSE is capable of switching the phase connected to the EV, i.e. ACPhaseSwitchingSupported is defined and true. It’s not allowed unless both conditions above are true. If both conditions are true, and phaseToUse is omitted, the Charging Station / EVSE will make the selection on its own.\r\n\r\n", + "type": "integer" + } + }, + "required": [ + "startPeriod", + "limit" + ] + }, + "ChargingScheduleType": { + "description": "Charging_ Schedule\r\nurn:x-oca:ocpp:uid:2:233256\r\nCharging schedule structure defines a list of charging periods, as used in: GetCompositeSchedule.conf and ChargingProfile. \r\n", + "javaType": "ChargingSchedule", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "id": { + "description": "Identifies the ChargingSchedule.\r\n", + "type": "integer" + }, + "startSchedule": { + "description": "Charging_ Schedule. Start_ Schedule. Date_ Time\r\nurn:x-oca:ocpp:uid:1:569237\r\nStarting point of an absolute schedule. If absent the schedule will be relative to start of charging.\r\n", + "type": "string", + "format": "date-time" + }, + "duration": { + "description": "Charging_ Schedule. Duration. Elapsed_ Time\r\nurn:x-oca:ocpp:uid:1:569236\r\nDuration of the charging schedule in seconds. If the duration is left empty, the last period will continue indefinitely or until end of the transaction if chargingProfilePurpose = TxProfile.\r\n", + "type": "integer" + }, + "chargingRateUnit": { + "$ref": "#/definitions/ChargingRateUnitEnumType" + }, + "chargingSchedulePeriod": { + "type": "array", + "additionalItems": false, + "items": { + "$ref": "#/definitions/ChargingSchedulePeriodType" + }, + "minItems": 1, + "maxItems": 1024 + }, + "minChargingRate": { + "description": "Charging_ Schedule. Min_ Charging_ Rate. Numeric\r\nurn:x-oca:ocpp:uid:1:569239\r\nMinimum charging rate supported by the EV. The unit of measure is defined by the chargingRateUnit. This parameter is intended to be used by a local smart charging algorithm to optimize the power allocation for in the case a charging process is inefficient at lower charging rates. Accepts at most one digit fraction (e.g. 8.1)\r\n", + "type": "number" + }, + "salesTariff": { + "$ref": "#/definitions/SalesTariffType" + } + }, + "required": [ + "id", + "chargingRateUnit", + "chargingSchedulePeriod" + ] + }, + "ConsumptionCostType": { + "description": "Consumption_ Cost\r\nurn:x-oca:ocpp:uid:2:233259\r\n", + "javaType": "ConsumptionCost", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "startValue": { + "description": "Consumption_ Cost. Start_ Value. Numeric\r\nurn:x-oca:ocpp:uid:1:569246\r\nThe lowest level of consumption that defines the starting point of this consumption block. The block interval extends to the start of the next interval.\r\n", + "type": "number" + }, + "cost": { + "type": "array", + "additionalItems": false, + "items": { + "$ref": "#/definitions/CostType" + }, + "minItems": 1, + "maxItems": 3 + } + }, + "required": [ + "startValue", + "cost" + ] + }, + "CostType": { + "description": "Cost\r\nurn:x-oca:ocpp:uid:2:233258\r\n", + "javaType": "Cost", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "costKind": { + "$ref": "#/definitions/CostKindEnumType" + }, + "amount": { + "description": "Cost. Amount. Amount\r\nurn:x-oca:ocpp:uid:1:569244\r\nThe estimated or actual cost per kWh\r\n", + "type": "integer" + }, + "amountMultiplier": { + "description": "Cost. Amount_ Multiplier. Integer\r\nurn:x-oca:ocpp:uid:1:569245\r\nValues: -3..3, The amountMultiplier defines the exponent to base 10 (dec). The final value is determined by: amount * 10 ^ amountMultiplier\r\n", + "type": "integer" + } + }, + "required": [ + "costKind", + "amount" + ] + }, + "IdTokenType": { + "description": "Contains a case insensitive identifier to use for the authorization and the type of authorization to support multiple forms of identifiers.\r\n", + "javaType": "IdToken", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "additionalInfo": { + "type": "array", + "additionalItems": false, + "items": { + "$ref": "#/definitions/AdditionalInfoType" + }, + "minItems": 1 + }, + "idToken": { + "description": "IdToken is case insensitive. Might hold the hidden id of an RFID tag, but can for example also contain a UUID.\r\n", + "type": "string", + "maxLength": 36 + }, + "type": { + "$ref": "#/definitions/IdTokenEnumType" + } + }, + "required": [ + "idToken", + "type" + ] + }, + "RelativeTimeIntervalType": { + "description": "Relative_ Timer_ Interval\r\nurn:x-oca:ocpp:uid:2:233270\r\n", + "javaType": "RelativeTimeInterval", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "start": { + "description": "Relative_ Timer_ Interval. Start. Elapsed_ Time\r\nurn:x-oca:ocpp:uid:1:569279\r\nStart of the interval, in seconds from NOW.\r\n", + "type": "integer" + }, + "duration": { + "description": "Relative_ Timer_ Interval. Duration. Elapsed_ Time\r\nurn:x-oca:ocpp:uid:1:569280\r\nDuration of the interval, in seconds.\r\n", + "type": "integer" + } + }, + "required": [ + "start" + ] + }, + "SalesTariffEntryType": { + "description": "Sales_ Tariff_ Entry\r\nurn:x-oca:ocpp:uid:2:233271\r\n", + "javaType": "SalesTariffEntry", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "relativeTimeInterval": { + "$ref": "#/definitions/RelativeTimeIntervalType" + }, + "ePriceLevel": { + "description": "Sales_ Tariff_ Entry. E_ Price_ Level. Unsigned_ Integer\r\nurn:x-oca:ocpp:uid:1:569281\r\nDefines the price level of this SalesTariffEntry (referring to NumEPriceLevels). Small values for the EPriceLevel represent a cheaper TariffEntry. Large values for the EPriceLevel represent a more expensive TariffEntry.\r\n", + "type": "integer", + "minimum": 0.0 + }, + "consumptionCost": { + "type": "array", + "additionalItems": false, + "items": { + "$ref": "#/definitions/ConsumptionCostType" + }, + "minItems": 1, + "maxItems": 3 + } + }, + "required": [ + "relativeTimeInterval" + ] + }, + "SalesTariffType": { + "description": "Sales_ Tariff\r\nurn:x-oca:ocpp:uid:2:233272\r\nNOTE: This dataType is based on dataTypes from <<ref-ISOIEC15118-2,ISO 15118-2>>.\r\n", + "javaType": "SalesTariff", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "id": { + "description": "Identified_ Object. MRID. Numeric_ Identifier\r\nurn:x-enexis:ecdm:uid:1:569198\r\nSalesTariff identifier used to identify one sales tariff. An SAID remains a unique identifier for one schedule throughout a charging session.\r\n", + "type": "integer" + }, + "salesTariffDescription": { + "description": "Sales_ Tariff. Sales. Tariff_ Description\r\nurn:x-oca:ocpp:uid:1:569283\r\nA human readable title/short description of the sales tariff e.g. for HMI display purposes.\r\n", + "type": "string", + "maxLength": 32 + }, + "numEPriceLevels": { + "description": "Sales_ Tariff. Num_ E_ Price_ Levels. Counter\r\nurn:x-oca:ocpp:uid:1:569284\r\nDefines the overall number of distinct price levels used across all provided SalesTariff elements.\r\n", + "type": "integer" + }, + "salesTariffEntry": { + "type": "array", + "additionalItems": false, + "items": { + "$ref": "#/definitions/SalesTariffEntryType" + }, + "minItems": 1, + "maxItems": 1024 + } + }, + "required": [ + "id", + "salesTariffEntry" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "evseId": { + "description": "Number of the EVSE on which to start the transaction. EvseId SHALL be > 0\r\n", + "type": "integer" + }, + "groupIdToken": { + "$ref": "#/definitions/IdTokenType" + }, + "idToken": { + "$ref": "#/definitions/IdTokenType" + }, + "remoteStartId": { + "description": "Id given by the server to this start request. The Charging Station might return this in the <<transactioneventrequest, TransactionEventRequest>>, letting the server know which transaction was started for this request. Use to start a transaction.\r\n", + "type": "integer" + }, + "chargingProfile": { + "$ref": "#/definitions/ChargingProfileType" + } + }, + "required": [ + "remoteStartId", + "idToken" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/RequestStartTransactionResponse.json b/schemas/ocpp20/RequestStartTransactionResponse.json new file mode 100644 index 00000000..e5b2b330 --- /dev/null +++ b/schemas/ocpp20/RequestStartTransactionResponse.json @@ -0,0 +1,76 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:RequestStartTransactionResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "RequestStartStopStatusEnumType": { + "description": "Status indicating whether the Charging Station accepts the request to start a transaction.\r\n", + "javaType": "RequestStartStopStatusEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Accepted", + "Rejected" + ] + }, + "StatusInfoType": { + "description": "Element providing more information about the status.\r\n", + "javaType": "StatusInfo", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "reasonCode": { + "description": "A predefined code for the reason why the status is returned in this response. The string is case-insensitive.\r\n", + "type": "string", + "maxLength": 20 + }, + "additionalInfo": { + "description": "Additional text to provide detailed information.\r\n", + "type": "string", + "maxLength": 512 + } + }, + "required": [ + "reasonCode" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "status": { + "$ref": "#/definitions/RequestStartStopStatusEnumType" + }, + "statusInfo": { + "$ref": "#/definitions/StatusInfoType" + }, + "transactionId": { + "description": "When the transaction was already started by the Charging Station before the RequestStartTransactionRequest was received, for example: cable plugged in first. This contains the transactionId of the already started transaction.\r\n", + "type": "string", + "maxLength": 36 + } + }, + "required": [ + "status" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/RequestStopTransactionRequest.json b/schemas/ocpp20/RequestStopTransactionRequest.json new file mode 100644 index 00000000..d4af9f5e --- /dev/null +++ b/schemas/ocpp20/RequestStopTransactionRequest.json @@ -0,0 +1,36 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:RequestStopTransactionRequest", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "transactionId": { + "description": "The identifier of the transaction which the Charging Station is requested to stop.\r\n", + "type": "string", + "maxLength": 36 + } + }, + "required": [ + "transactionId" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/RequestStopTransactionResponse.json b/schemas/ocpp20/RequestStopTransactionResponse.json new file mode 100644 index 00000000..a711e731 --- /dev/null +++ b/schemas/ocpp20/RequestStopTransactionResponse.json @@ -0,0 +1,71 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:RequestStopTransactionResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "RequestStartStopStatusEnumType": { + "description": "Status indicating whether Charging Station accepts the request to stop a transaction.\r\n", + "javaType": "RequestStartStopStatusEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Accepted", + "Rejected" + ] + }, + "StatusInfoType": { + "description": "Element providing more information about the status.\r\n", + "javaType": "StatusInfo", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "reasonCode": { + "description": "A predefined code for the reason why the status is returned in this response. The string is case-insensitive.\r\n", + "type": "string", + "maxLength": 20 + }, + "additionalInfo": { + "description": "Additional text to provide detailed information.\r\n", + "type": "string", + "maxLength": 512 + } + }, + "required": [ + "reasonCode" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "status": { + "$ref": "#/definitions/RequestStartStopStatusEnumType" + }, + "statusInfo": { + "$ref": "#/definitions/StatusInfoType" + } + }, + "required": [ + "status" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/ReservationStatusUpdateRequest.json b/schemas/ocpp20/ReservationStatusUpdateRequest.json new file mode 100644 index 00000000..7591b3e4 --- /dev/null +++ b/schemas/ocpp20/ReservationStatusUpdateRequest.json @@ -0,0 +1,49 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:ReservationStatusUpdateRequest", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "ReservationUpdateStatusEnumType": { + "description": "The updated reservation status.\r\n", + "javaType": "ReservationUpdateStatusEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Expired", + "Removed" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "reservationId": { + "description": "The ID of the reservation.\r\n", + "type": "integer" + }, + "reservationUpdateStatus": { + "$ref": "#/definitions/ReservationUpdateStatusEnumType" + } + }, + "required": [ + "reservationId", + "reservationUpdateStatus" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/ReservationStatusUpdateResponse.json b/schemas/ocpp20/ReservationStatusUpdateResponse.json new file mode 100644 index 00000000..f4eecc14 --- /dev/null +++ b/schemas/ocpp20/ReservationStatusUpdateResponse.json @@ -0,0 +1,28 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:ReservationStatusUpdateResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + } + } +} \ No newline at end of file diff --git a/schemas/ocpp20/ReserveNowRequest.json b/schemas/ocpp20/ReserveNowRequest.json new file mode 100644 index 00000000..3d17f3c1 --- /dev/null +++ b/schemas/ocpp20/ReserveNowRequest.json @@ -0,0 +1,157 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:ReserveNowRequest", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "ConnectorEnumType": { + "description": "This field specifies the connector type.\r\n", + "javaType": "ConnectorEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "cCCS1", + "cCCS2", + "cG105", + "cTesla", + "cType1", + "cType2", + "s309-1P-16A", + "s309-1P-32A", + "s309-3P-16A", + "s309-3P-32A", + "sBS1361", + "sCEE-7-7", + "sType2", + "sType3", + "Other1PhMax16A", + "Other1PhOver16A", + "Other3Ph", + "Pan", + "wInductive", + "wResonant", + "Undetermined", + "Unknown" + ] + }, + "IdTokenEnumType": { + "description": "Enumeration of possible idToken types.\r\n", + "javaType": "IdTokenEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Central", + "eMAID", + "ISO14443", + "ISO15693", + "KeyCode", + "Local", + "MacAddress", + "NoAuthorization" + ] + }, + "AdditionalInfoType": { + "description": "Contains a case insensitive identifier to use for the authorization and the type of authorization to support multiple forms of identifiers.\r\n", + "javaType": "AdditionalInfo", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "additionalIdToken": { + "description": "This field specifies the additional IdToken.\r\n", + "type": "string", + "maxLength": 36 + }, + "type": { + "description": "This defines the type of the additionalIdToken. This is a custom type, so the implementation needs to be agreed upon by all involved parties.\r\n", + "type": "string", + "maxLength": 50 + } + }, + "required": [ + "additionalIdToken", + "type" + ] + }, + "IdTokenType": { + "description": "Contains a case insensitive identifier to use for the authorization and the type of authorization to support multiple forms of identifiers.\r\n", + "javaType": "IdToken", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "additionalInfo": { + "type": "array", + "additionalItems": false, + "items": { + "$ref": "#/definitions/AdditionalInfoType" + }, + "minItems": 1 + }, + "idToken": { + "description": "IdToken is case insensitive. Might hold the hidden id of an RFID tag, but can for example also contain a UUID.\r\n", + "type": "string", + "maxLength": 36 + }, + "type": { + "$ref": "#/definitions/IdTokenEnumType" + } + }, + "required": [ + "idToken", + "type" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "id": { + "description": "Id of reservation.\r\n", + "type": "integer" + }, + "expiryDateTime": { + "description": "Date and time at which the reservation expires.\r\n", + "type": "string", + "format": "date-time" + }, + "connectorType": { + "$ref": "#/definitions/ConnectorEnumType" + }, + "idToken": { + "$ref": "#/definitions/IdTokenType" + }, + "evseId": { + "description": "This contains ID of the evse to be reserved.\r\n", + "type": "integer" + }, + "groupIdToken": { + "$ref": "#/definitions/IdTokenType" + } + }, + "required": [ + "id", + "expiryDateTime", + "idToken" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/ReserveNowResponse.json b/schemas/ocpp20/ReserveNowResponse.json new file mode 100644 index 00000000..d6a6f81d --- /dev/null +++ b/schemas/ocpp20/ReserveNowResponse.json @@ -0,0 +1,74 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:ReserveNowResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "ReserveNowStatusEnumType": { + "description": "This indicates the success or failure of the reservation.\r\n", + "javaType": "ReserveNowStatusEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Accepted", + "Faulted", + "Occupied", + "Rejected", + "Unavailable" + ] + }, + "StatusInfoType": { + "description": "Element providing more information about the status.\r\n", + "javaType": "StatusInfo", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "reasonCode": { + "description": "A predefined code for the reason why the status is returned in this response. The string is case-insensitive.\r\n", + "type": "string", + "maxLength": 20 + }, + "additionalInfo": { + "description": "Additional text to provide detailed information.\r\n", + "type": "string", + "maxLength": 512 + } + }, + "required": [ + "reasonCode" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "status": { + "$ref": "#/definitions/ReserveNowStatusEnumType" + }, + "statusInfo": { + "$ref": "#/definitions/StatusInfoType" + } + }, + "required": [ + "status" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/ResetRequest.json b/schemas/ocpp20/ResetRequest.json new file mode 100644 index 00000000..f2cbe73e --- /dev/null +++ b/schemas/ocpp20/ResetRequest.json @@ -0,0 +1,48 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:ResetRequest", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "ResetEnumType": { + "description": "This contains the type of reset that the Charging Station or EVSE should perform.\r\n", + "javaType": "ResetEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Immediate", + "OnIdle" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "type": { + "$ref": "#/definitions/ResetEnumType" + }, + "evseId": { + "description": "This contains the ID of a specific EVSE that needs to be reset, instead of the entire Charging Station.\r\n", + "type": "integer" + } + }, + "required": [ + "type" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/ResetResponse.json b/schemas/ocpp20/ResetResponse.json new file mode 100644 index 00000000..4917ed09 --- /dev/null +++ b/schemas/ocpp20/ResetResponse.json @@ -0,0 +1,72 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:ResetResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "ResetStatusEnumType": { + "description": "This indicates whether the Charging Station is able to perform the reset.\r\n", + "javaType": "ResetStatusEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Accepted", + "Rejected", + "Scheduled" + ] + }, + "StatusInfoType": { + "description": "Element providing more information about the status.\r\n", + "javaType": "StatusInfo", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "reasonCode": { + "description": "A predefined code for the reason why the status is returned in this response. The string is case-insensitive.\r\n", + "type": "string", + "maxLength": 20 + }, + "additionalInfo": { + "description": "Additional text to provide detailed information.\r\n", + "type": "string", + "maxLength": 512 + } + }, + "required": [ + "reasonCode" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "status": { + "$ref": "#/definitions/ResetStatusEnumType" + }, + "statusInfo": { + "$ref": "#/definitions/StatusInfoType" + } + }, + "required": [ + "status" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/SecurityEventNotificationRequest.json b/schemas/ocpp20/SecurityEventNotificationRequest.json new file mode 100644 index 00000000..fd1fee47 --- /dev/null +++ b/schemas/ocpp20/SecurityEventNotificationRequest.json @@ -0,0 +1,47 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:SecurityEventNotificationRequest", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "type": { + "description": "Type of the security event. This value should be taken from the Security events list.\r\n", + "type": "string", + "maxLength": 50 + }, + "timestamp": { + "description": "Date and time at which the event occurred.\r\n", + "type": "string", + "format": "date-time" + }, + "techInfo": { + "description": "Additional information about the occurred security event.\r\n", + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "type", + "timestamp" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/SecurityEventNotificationResponse.json b/schemas/ocpp20/SecurityEventNotificationResponse.json new file mode 100644 index 00000000..edce9169 --- /dev/null +++ b/schemas/ocpp20/SecurityEventNotificationResponse.json @@ -0,0 +1,28 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:SecurityEventNotificationResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + } + } +} \ No newline at end of file diff --git a/schemas/ocpp20/SendLocalListRequest.json b/schemas/ocpp20/SendLocalListRequest.json new file mode 100644 index 00000000..0394497d --- /dev/null +++ b/schemas/ocpp20/SendLocalListRequest.json @@ -0,0 +1,258 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:SendLocalListRequest", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "AuthorizationStatusEnumType": { + "description": "ID_ Token. Status. Authorization_ Status\r\nurn:x-oca:ocpp:uid:1:569372\r\nCurrent status of the ID Token.\r\n", + "javaType": "AuthorizationStatusEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Accepted", + "Blocked", + "ConcurrentTx", + "Expired", + "Invalid", + "NoCredit", + "NotAllowedTypeEVSE", + "NotAtThisLocation", + "NotAtThisTime", + "Unknown" + ] + }, + "IdTokenEnumType": { + "description": "Enumeration of possible idToken types.\r\n", + "javaType": "IdTokenEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Central", + "eMAID", + "ISO14443", + "ISO15693", + "KeyCode", + "Local", + "MacAddress", + "NoAuthorization" + ] + }, + "MessageFormatEnumType": { + "description": "Message_ Content. Format. Message_ Format_ Code\r\nurn:x-enexis:ecdm:uid:1:570848\r\nFormat of the message.\r\n", + "javaType": "MessageFormatEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "ASCII", + "HTML", + "URI", + "UTF8" + ] + }, + "UpdateEnumType": { + "description": "This contains the type of update (full or differential) of this request.\r\n", + "javaType": "UpdateEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Differential", + "Full" + ] + }, + "AdditionalInfoType": { + "description": "Contains a case insensitive identifier to use for the authorization and the type of authorization to support multiple forms of identifiers.\r\n", + "javaType": "AdditionalInfo", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "additionalIdToken": { + "description": "This field specifies the additional IdToken.\r\n", + "type": "string", + "maxLength": 36 + }, + "type": { + "description": "This defines the type of the additionalIdToken. This is a custom type, so the implementation needs to be agreed upon by all involved parties.\r\n", + "type": "string", + "maxLength": 50 + } + }, + "required": [ + "additionalIdToken", + "type" + ] + }, + "AuthorizationData": { + "description": "Contains the identifier to use for authorization.\r\n", + "javaType": "AuthorizationData", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "idToken": { + "$ref": "#/definitions/IdTokenType" + }, + "idTokenInfo": { + "$ref": "#/definitions/IdTokenInfoType" + } + }, + "required": [ + "idToken" + ] + }, + "IdTokenInfoType": { + "description": "ID_ Token\r\nurn:x-oca:ocpp:uid:2:233247\r\nContains status information about an identifier.\r\nIt is advised to not stop charging for a token that expires during charging, as ExpiryDate is only used for caching purposes. If ExpiryDate is not given, the status has no end date.\r\n", + "javaType": "IdTokenInfo", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "status": { + "$ref": "#/definitions/AuthorizationStatusEnumType" + }, + "cacheExpiryDateTime": { + "description": "ID_ Token. Expiry. Date_ Time\r\nurn:x-oca:ocpp:uid:1:569373\r\nDate and Time after which the token must be considered invalid.\r\n", + "type": "string", + "format": "date-time" + }, + "chargingPriority": { + "description": "Priority from a business point of view. Default priority is 0, The range is from -9 to 9. Higher values indicate a higher priority. The chargingPriority in <<transactioneventresponse,TransactionEventResponse>> overrules this one. \r\n", + "type": "integer" + }, + "language1": { + "description": "ID_ Token. Language1. Language_ Code\r\nurn:x-oca:ocpp:uid:1:569374\r\nPreferred user interface language of identifier user. Contains a language code as defined in <<ref-RFC5646,[RFC5646]>>.\r\n\r\n", + "type": "string", + "maxLength": 8 + }, + "evseId": { + "description": "Only used when the IdToken is only valid for one or more specific EVSEs, not for the entire Charging Station.\r\n\r\n", + "type": "array", + "additionalItems": false, + "items": { + "type": "integer" + }, + "minItems": 1 + }, + "groupIdToken": { + "$ref": "#/definitions/IdTokenType" + }, + "language2": { + "description": "ID_ Token. Language2. Language_ Code\r\nurn:x-oca:ocpp:uid:1:569375\r\nSecond preferred user interface language of identifier user. Don’t use when language1 is omitted, has to be different from language1. Contains a language code as defined in <<ref-RFC5646,[RFC5646]>>.\r\n", + "type": "string", + "maxLength": 8 + }, + "personalMessage": { + "$ref": "#/definitions/MessageContentType" + } + }, + "required": [ + "status" + ] + }, + "IdTokenType": { + "description": "Contains a case insensitive identifier to use for the authorization and the type of authorization to support multiple forms of identifiers.\r\n", + "javaType": "IdToken", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "additionalInfo": { + "type": "array", + "additionalItems": false, + "items": { + "$ref": "#/definitions/AdditionalInfoType" + }, + "minItems": 1 + }, + "idToken": { + "description": "IdToken is case insensitive. Might hold the hidden id of an RFID tag, but can for example also contain a UUID.\r\n", + "type": "string", + "maxLength": 36 + }, + "type": { + "$ref": "#/definitions/IdTokenEnumType" + } + }, + "required": [ + "idToken", + "type" + ] + }, + "MessageContentType": { + "description": "Message_ Content\r\nurn:x-enexis:ecdm:uid:2:234490\r\nContains message details, for a message to be displayed on a Charging Station.\r\n\r\n", + "javaType": "MessageContent", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "format": { + "$ref": "#/definitions/MessageFormatEnumType" + }, + "language": { + "description": "Message_ Content. Language. Language_ Code\r\nurn:x-enexis:ecdm:uid:1:570849\r\nMessage language identifier. Contains a language code as defined in <<ref-RFC5646,[RFC5646]>>.\r\n", + "type": "string", + "maxLength": 8 + }, + "content": { + "description": "Message_ Content. Content. Message\r\nurn:x-enexis:ecdm:uid:1:570852\r\nMessage contents.\r\n\r\n", + "type": "string", + "maxLength": 512 + } + }, + "required": [ + "format", + "content" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "localAuthorizationList": { + "type": "array", + "additionalItems": false, + "items": { + "$ref": "#/definitions/AuthorizationData" + }, + "minItems": 1 + }, + "versionNumber": { + "description": "In case of a full update this is the version number of the full list. In case of a differential update it is the version number of the list after the update has been applied.\r\n", + "type": "integer" + }, + "updateType": { + "$ref": "#/definitions/UpdateEnumType" + } + }, + "required": [ + "versionNumber", + "updateType" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/SendLocalListResponse.json b/schemas/ocpp20/SendLocalListResponse.json new file mode 100644 index 00000000..87da525b --- /dev/null +++ b/schemas/ocpp20/SendLocalListResponse.json @@ -0,0 +1,72 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:SendLocalListResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "SendLocalListStatusEnumType": { + "description": "This indicates whether the Charging Station has successfully received and applied the update of the Local Authorization List.\r\n", + "javaType": "SendLocalListStatusEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Accepted", + "Failed", + "VersionMismatch" + ] + }, + "StatusInfoType": { + "description": "Element providing more information about the status.\r\n", + "javaType": "StatusInfo", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "reasonCode": { + "description": "A predefined code for the reason why the status is returned in this response. The string is case-insensitive.\r\n", + "type": "string", + "maxLength": 20 + }, + "additionalInfo": { + "description": "Additional text to provide detailed information.\r\n", + "type": "string", + "maxLength": 512 + } + }, + "required": [ + "reasonCode" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "status": { + "$ref": "#/definitions/SendLocalListStatusEnumType" + }, + "statusInfo": { + "$ref": "#/definitions/StatusInfoType" + } + }, + "required": [ + "status" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/SetChargingProfileRequest.json b/schemas/ocpp20/SetChargingProfileRequest.json new file mode 100644 index 00000000..680e0e34 --- /dev/null +++ b/schemas/ocpp20/SetChargingProfileRequest.json @@ -0,0 +1,375 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:SetChargingProfileRequest", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "ChargingProfileKindEnumType": { + "description": "Charging_ Profile. Charging_ Profile_ Kind. Charging_ Profile_ Kind_ Code\r\nurn:x-oca:ocpp:uid:1:569232\r\nIndicates the kind of schedule.\r\n", + "javaType": "ChargingProfileKindEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Absolute", + "Recurring", + "Relative" + ] + }, + "ChargingProfilePurposeEnumType": { + "description": "Charging_ Profile. Charging_ Profile_ Purpose. Charging_ Profile_ Purpose_ Code\r\nurn:x-oca:ocpp:uid:1:569231\r\nDefines the purpose of the schedule transferred by this profile\r\n", + "javaType": "ChargingProfilePurposeEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "ChargingStationExternalConstraints", + "ChargingStationMaxProfile", + "TxDefaultProfile", + "TxProfile" + ] + }, + "ChargingRateUnitEnumType": { + "description": "Charging_ Schedule. Charging_ Rate_ Unit. Charging_ Rate_ Unit_ Code\r\nurn:x-oca:ocpp:uid:1:569238\r\nThe unit of measure Limit is expressed in.\r\n", + "javaType": "ChargingRateUnitEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "W", + "A" + ] + }, + "CostKindEnumType": { + "description": "Cost. Cost_ Kind. Cost_ Kind_ Code\r\nurn:x-oca:ocpp:uid:1:569243\r\nThe kind of cost referred to in the message element amount\r\n", + "javaType": "CostKindEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "CarbonDioxideEmission", + "RelativePricePercentage", + "RenewableGenerationPercentage" + ] + }, + "RecurrencyKindEnumType": { + "description": "Charging_ Profile. Recurrency_ Kind. Recurrency_ Kind_ Code\r\nurn:x-oca:ocpp:uid:1:569233\r\nIndicates the start point of a recurrence.\r\n", + "javaType": "RecurrencyKindEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Daily", + "Weekly" + ] + }, + "ChargingProfileType": { + "description": "Charging_ Profile\r\nurn:x-oca:ocpp:uid:2:233255\r\nA ChargingProfile consists of ChargingSchedule, describing the amount of power or current that can be delivered per time interval.\r\n", + "javaType": "ChargingProfile", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "id": { + "description": "Identified_ Object. MRID. Numeric_ Identifier\r\nurn:x-enexis:ecdm:uid:1:569198\r\nId of ChargingProfile.\r\n", + "type": "integer" + }, + "stackLevel": { + "description": "Charging_ Profile. Stack_ Level. Counter\r\nurn:x-oca:ocpp:uid:1:569230\r\nValue determining level in hierarchy stack of profiles. Higher values have precedence over lower values. Lowest level is 0.\r\n", + "type": "integer" + }, + "chargingProfilePurpose": { + "$ref": "#/definitions/ChargingProfilePurposeEnumType" + }, + "chargingProfileKind": { + "$ref": "#/definitions/ChargingProfileKindEnumType" + }, + "recurrencyKind": { + "$ref": "#/definitions/RecurrencyKindEnumType" + }, + "validFrom": { + "description": "Charging_ Profile. Valid_ From. Date_ Time\r\nurn:x-oca:ocpp:uid:1:569234\r\nPoint in time at which the profile starts to be valid. If absent, the profile is valid as soon as it is received by the Charging Station.\r\n", + "type": "string", + "format": "date-time" + }, + "validTo": { + "description": "Charging_ Profile. Valid_ To. Date_ Time\r\nurn:x-oca:ocpp:uid:1:569235\r\nPoint in time at which the profile stops to be valid. If absent, the profile is valid until it is replaced by another profile.\r\n", + "type": "string", + "format": "date-time" + }, + "chargingSchedule": { + "type": "array", + "additionalItems": false, + "items": { + "$ref": "#/definitions/ChargingScheduleType" + }, + "minItems": 1, + "maxItems": 3 + }, + "transactionId": { + "description": "SHALL only be included if ChargingProfilePurpose is set to TxProfile. The transactionId is used to match the profile to a specific transaction.\r\n", + "type": "string", + "maxLength": 36 + } + }, + "required": [ + "id", + "stackLevel", + "chargingProfilePurpose", + "chargingProfileKind", + "chargingSchedule" + ] + }, + "ChargingSchedulePeriodType": { + "description": "Charging_ Schedule_ Period\r\nurn:x-oca:ocpp:uid:2:233257\r\nCharging schedule period structure defines a time period in a charging schedule.\r\n", + "javaType": "ChargingSchedulePeriod", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "startPeriod": { + "description": "Charging_ Schedule_ Period. Start_ Period. Elapsed_ Time\r\nurn:x-oca:ocpp:uid:1:569240\r\nStart of the period, in seconds from the start of schedule. The value of StartPeriod also defines the stop time of the previous period.\r\n", + "type": "integer" + }, + "limit": { + "description": "Charging_ Schedule_ Period. Limit. Measure\r\nurn:x-oca:ocpp:uid:1:569241\r\nCharging rate limit during the schedule period, in the applicable chargingRateUnit, for example in Amperes (A) or Watts (W). Accepts at most one digit fraction (e.g. 8.1).\r\n", + "type": "number" + }, + "numberPhases": { + "description": "Charging_ Schedule_ Period. Number_ Phases. Counter\r\nurn:x-oca:ocpp:uid:1:569242\r\nThe number of phases that can be used for charging. If a number of phases is needed, numberPhases=3 will be assumed unless another number is given.\r\n", + "type": "integer" + }, + "phaseToUse": { + "description": "Values: 1..3, Used if numberPhases=1 and if the EVSE is capable of switching the phase connected to the EV, i.e. ACPhaseSwitchingSupported is defined and true. It’s not allowed unless both conditions above are true. If both conditions are true, and phaseToUse is omitted, the Charging Station / EVSE will make the selection on its own.\r\n\r\n", + "type": "integer" + } + }, + "required": [ + "startPeriod", + "limit" + ] + }, + "ChargingScheduleType": { + "description": "Charging_ Schedule\r\nurn:x-oca:ocpp:uid:2:233256\r\nCharging schedule structure defines a list of charging periods, as used in: GetCompositeSchedule.conf and ChargingProfile. \r\n", + "javaType": "ChargingSchedule", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "id": { + "description": "Identifies the ChargingSchedule.\r\n", + "type": "integer" + }, + "startSchedule": { + "description": "Charging_ Schedule. Start_ Schedule. Date_ Time\r\nurn:x-oca:ocpp:uid:1:569237\r\nStarting point of an absolute schedule. If absent the schedule will be relative to start of charging.\r\n", + "type": "string", + "format": "date-time" + }, + "duration": { + "description": "Charging_ Schedule. Duration. Elapsed_ Time\r\nurn:x-oca:ocpp:uid:1:569236\r\nDuration of the charging schedule in seconds. If the duration is left empty, the last period will continue indefinitely or until end of the transaction if chargingProfilePurpose = TxProfile.\r\n", + "type": "integer" + }, + "chargingRateUnit": { + "$ref": "#/definitions/ChargingRateUnitEnumType" + }, + "chargingSchedulePeriod": { + "type": "array", + "additionalItems": false, + "items": { + "$ref": "#/definitions/ChargingSchedulePeriodType" + }, + "minItems": 1, + "maxItems": 1024 + }, + "minChargingRate": { + "description": "Charging_ Schedule. Min_ Charging_ Rate. Numeric\r\nurn:x-oca:ocpp:uid:1:569239\r\nMinimum charging rate supported by the EV. The unit of measure is defined by the chargingRateUnit. This parameter is intended to be used by a local smart charging algorithm to optimize the power allocation for in the case a charging process is inefficient at lower charging rates. Accepts at most one digit fraction (e.g. 8.1)\r\n", + "type": "number" + }, + "salesTariff": { + "$ref": "#/definitions/SalesTariffType" + } + }, + "required": [ + "id", + "chargingRateUnit", + "chargingSchedulePeriod" + ] + }, + "ConsumptionCostType": { + "description": "Consumption_ Cost\r\nurn:x-oca:ocpp:uid:2:233259\r\n", + "javaType": "ConsumptionCost", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "startValue": { + "description": "Consumption_ Cost. Start_ Value. Numeric\r\nurn:x-oca:ocpp:uid:1:569246\r\nThe lowest level of consumption that defines the starting point of this consumption block. The block interval extends to the start of the next interval.\r\n", + "type": "number" + }, + "cost": { + "type": "array", + "additionalItems": false, + "items": { + "$ref": "#/definitions/CostType" + }, + "minItems": 1, + "maxItems": 3 + } + }, + "required": [ + "startValue", + "cost" + ] + }, + "CostType": { + "description": "Cost\r\nurn:x-oca:ocpp:uid:2:233258\r\n", + "javaType": "Cost", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "costKind": { + "$ref": "#/definitions/CostKindEnumType" + }, + "amount": { + "description": "Cost. Amount. Amount\r\nurn:x-oca:ocpp:uid:1:569244\r\nThe estimated or actual cost per kWh\r\n", + "type": "integer" + }, + "amountMultiplier": { + "description": "Cost. Amount_ Multiplier. Integer\r\nurn:x-oca:ocpp:uid:1:569245\r\nValues: -3..3, The amountMultiplier defines the exponent to base 10 (dec). The final value is determined by: amount * 10 ^ amountMultiplier\r\n", + "type": "integer" + } + }, + "required": [ + "costKind", + "amount" + ] + }, + "RelativeTimeIntervalType": { + "description": "Relative_ Timer_ Interval\r\nurn:x-oca:ocpp:uid:2:233270\r\n", + "javaType": "RelativeTimeInterval", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "start": { + "description": "Relative_ Timer_ Interval. Start. Elapsed_ Time\r\nurn:x-oca:ocpp:uid:1:569279\r\nStart of the interval, in seconds from NOW.\r\n", + "type": "integer" + }, + "duration": { + "description": "Relative_ Timer_ Interval. Duration. Elapsed_ Time\r\nurn:x-oca:ocpp:uid:1:569280\r\nDuration of the interval, in seconds.\r\n", + "type": "integer" + } + }, + "required": [ + "start" + ] + }, + "SalesTariffEntryType": { + "description": "Sales_ Tariff_ Entry\r\nurn:x-oca:ocpp:uid:2:233271\r\n", + "javaType": "SalesTariffEntry", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "relativeTimeInterval": { + "$ref": "#/definitions/RelativeTimeIntervalType" + }, + "ePriceLevel": { + "description": "Sales_ Tariff_ Entry. E_ Price_ Level. Unsigned_ Integer\r\nurn:x-oca:ocpp:uid:1:569281\r\nDefines the price level of this SalesTariffEntry (referring to NumEPriceLevels). Small values for the EPriceLevel represent a cheaper TariffEntry. Large values for the EPriceLevel represent a more expensive TariffEntry.\r\n", + "type": "integer", + "minimum": 0.0 + }, + "consumptionCost": { + "type": "array", + "additionalItems": false, + "items": { + "$ref": "#/definitions/ConsumptionCostType" + }, + "minItems": 1, + "maxItems": 3 + } + }, + "required": [ + "relativeTimeInterval" + ] + }, + "SalesTariffType": { + "description": "Sales_ Tariff\r\nurn:x-oca:ocpp:uid:2:233272\r\nNOTE: This dataType is based on dataTypes from <<ref-ISOIEC15118-2,ISO 15118-2>>.\r\n", + "javaType": "SalesTariff", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "id": { + "description": "Identified_ Object. MRID. Numeric_ Identifier\r\nurn:x-enexis:ecdm:uid:1:569198\r\nSalesTariff identifier used to identify one sales tariff. An SAID remains a unique identifier for one schedule throughout a charging session.\r\n", + "type": "integer" + }, + "salesTariffDescription": { + "description": "Sales_ Tariff. Sales. Tariff_ Description\r\nurn:x-oca:ocpp:uid:1:569283\r\nA human readable title/short description of the sales tariff e.g. for HMI display purposes.\r\n", + "type": "string", + "maxLength": 32 + }, + "numEPriceLevels": { + "description": "Sales_ Tariff. Num_ E_ Price_ Levels. Counter\r\nurn:x-oca:ocpp:uid:1:569284\r\nDefines the overall number of distinct price levels used across all provided SalesTariff elements.\r\n", + "type": "integer" + }, + "salesTariffEntry": { + "type": "array", + "additionalItems": false, + "items": { + "$ref": "#/definitions/SalesTariffEntryType" + }, + "minItems": 1, + "maxItems": 1024 + } + }, + "required": [ + "id", + "salesTariffEntry" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "evseId": { + "description": "For TxDefaultProfile an evseId=0 applies the profile to each individual evse. For ChargingStationMaxProfile and ChargingStationExternalConstraints an evseId=0 contains an overal limit for the whole Charging Station.\r\n", + "type": "integer" + }, + "chargingProfile": { + "$ref": "#/definitions/ChargingProfileType" + } + }, + "required": [ + "evseId", + "chargingProfile" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/SetChargingProfileResponse.json b/schemas/ocpp20/SetChargingProfileResponse.json new file mode 100644 index 00000000..f7eff517 --- /dev/null +++ b/schemas/ocpp20/SetChargingProfileResponse.json @@ -0,0 +1,71 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:SetChargingProfileResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "ChargingProfileStatusEnumType": { + "description": "Returns whether the Charging Station has been able to process the message successfully. This does not guarantee the schedule will be followed to the letter. There might be other constraints the Charging Station may need to take into account.\r\n", + "javaType": "ChargingProfileStatusEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Accepted", + "Rejected" + ] + }, + "StatusInfoType": { + "description": "Element providing more information about the status.\r\n", + "javaType": "StatusInfo", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "reasonCode": { + "description": "A predefined code for the reason why the status is returned in this response. The string is case-insensitive.\r\n", + "type": "string", + "maxLength": 20 + }, + "additionalInfo": { + "description": "Additional text to provide detailed information.\r\n", + "type": "string", + "maxLength": 512 + } + }, + "required": [ + "reasonCode" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "status": { + "$ref": "#/definitions/ChargingProfileStatusEnumType" + }, + "statusInfo": { + "$ref": "#/definitions/StatusInfoType" + } + }, + "required": [ + "status" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/SetDisplayMessageRequest.json b/schemas/ocpp20/SetDisplayMessageRequest.json new file mode 100644 index 00000000..c3452aec --- /dev/null +++ b/schemas/ocpp20/SetDisplayMessageRequest.json @@ -0,0 +1,193 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:SetDisplayMessageRequest", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "MessageFormatEnumType": { + "description": "Message_ Content. Format. Message_ Format_ Code\r\nurn:x-enexis:ecdm:uid:1:570848\r\nFormat of the message.\r\n", + "javaType": "MessageFormatEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "ASCII", + "HTML", + "URI", + "UTF8" + ] + }, + "MessagePriorityEnumType": { + "description": "Message_ Info. Priority. Message_ Priority_ Code\r\nurn:x-enexis:ecdm:uid:1:569253\r\nWith what priority should this message be shown\r\n", + "javaType": "MessagePriorityEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "AlwaysFront", + "InFront", + "NormalCycle" + ] + }, + "MessageStateEnumType": { + "description": "Message_ Info. State. Message_ State_ Code\r\nurn:x-enexis:ecdm:uid:1:569254\r\nDuring what state should this message be shown. When omitted this message should be shown in any state of the Charging Station.\r\n", + "javaType": "MessageStateEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Charging", + "Faulted", + "Idle", + "Unavailable" + ] + }, + "ComponentType": { + "description": "A physical or logical component\r\n", + "javaType": "Component", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "evse": { + "$ref": "#/definitions/EVSEType" + }, + "name": { + "description": "Name of the component. Name should be taken from the list of standardized component names whenever possible. Case Insensitive. strongly advised to use Camel Case.\r\n", + "type": "string", + "maxLength": 50 + }, + "instance": { + "description": "Name of instance in case the component exists as multiple instances. Case Insensitive. strongly advised to use Camel Case.\r\n", + "type": "string", + "maxLength": 50 + } + }, + "required": [ + "name" + ] + }, + "EVSEType": { + "description": "EVSE\r\nurn:x-oca:ocpp:uid:2:233123\r\nElectric Vehicle Supply Equipment\r\n", + "javaType": "EVSE", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "id": { + "description": "Identified_ Object. MRID. Numeric_ Identifier\r\nurn:x-enexis:ecdm:uid:1:569198\r\nEVSE Identifier. This contains a number (> 0) designating an EVSE of the Charging Station.\r\n", + "type": "integer" + }, + "connectorId": { + "description": "An id to designate a specific connector (on an EVSE) by connector index number.\r\n", + "type": "integer" + } + }, + "required": [ + "id" + ] + }, + "MessageContentType": { + "description": "Message_ Content\r\nurn:x-enexis:ecdm:uid:2:234490\r\nContains message details, for a message to be displayed on a Charging Station.\r\n\r\n", + "javaType": "MessageContent", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "format": { + "$ref": "#/definitions/MessageFormatEnumType" + }, + "language": { + "description": "Message_ Content. Language. Language_ Code\r\nurn:x-enexis:ecdm:uid:1:570849\r\nMessage language identifier. Contains a language code as defined in <<ref-RFC5646,[RFC5646]>>.\r\n", + "type": "string", + "maxLength": 8 + }, + "content": { + "description": "Message_ Content. Content. Message\r\nurn:x-enexis:ecdm:uid:1:570852\r\nMessage contents.\r\n\r\n", + "type": "string", + "maxLength": 512 + } + }, + "required": [ + "format", + "content" + ] + }, + "MessageInfoType": { + "description": "Message_ Info\r\nurn:x-enexis:ecdm:uid:2:233264\r\nContains message details, for a message to be displayed on a Charging Station.\r\n", + "javaType": "MessageInfo", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "display": { + "$ref": "#/definitions/ComponentType" + }, + "id": { + "description": "Identified_ Object. MRID. Numeric_ Identifier\r\nurn:x-enexis:ecdm:uid:1:569198\r\nMaster resource identifier, unique within an exchange context. It is defined within the OCPP context as a positive Integer value (greater or equal to zero).\r\n", + "type": "integer" + }, + "priority": { + "$ref": "#/definitions/MessagePriorityEnumType" + }, + "state": { + "$ref": "#/definitions/MessageStateEnumType" + }, + "startDateTime": { + "description": "Message_ Info. Start. Date_ Time\r\nurn:x-enexis:ecdm:uid:1:569256\r\nFrom what date-time should this message be shown. If omitted: directly.\r\n", + "type": "string", + "format": "date-time" + }, + "endDateTime": { + "description": "Message_ Info. End. Date_ Time\r\nurn:x-enexis:ecdm:uid:1:569257\r\nUntil what date-time should this message be shown, after this date/time this message SHALL be removed.\r\n", + "type": "string", + "format": "date-time" + }, + "transactionId": { + "description": "During which transaction shall this message be shown.\r\nMessage SHALL be removed by the Charging Station after transaction has\r\nended.\r\n", + "type": "string", + "maxLength": 36 + }, + "message": { + "$ref": "#/definitions/MessageContentType" + } + }, + "required": [ + "id", + "priority", + "message" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "message": { + "$ref": "#/definitions/MessageInfoType" + } + }, + "required": [ + "message" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/SetDisplayMessageResponse.json b/schemas/ocpp20/SetDisplayMessageResponse.json new file mode 100644 index 00000000..e06ec517 --- /dev/null +++ b/schemas/ocpp20/SetDisplayMessageResponse.json @@ -0,0 +1,75 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:SetDisplayMessageResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "DisplayMessageStatusEnumType": { + "description": "This indicates whether the Charging Station is able to display the message.\r\n", + "javaType": "DisplayMessageStatusEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Accepted", + "NotSupportedMessageFormat", + "Rejected", + "NotSupportedPriority", + "NotSupportedState", + "UnknownTransaction" + ] + }, + "StatusInfoType": { + "description": "Element providing more information about the status.\r\n", + "javaType": "StatusInfo", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "reasonCode": { + "description": "A predefined code for the reason why the status is returned in this response. The string is case-insensitive.\r\n", + "type": "string", + "maxLength": 20 + }, + "additionalInfo": { + "description": "Additional text to provide detailed information.\r\n", + "type": "string", + "maxLength": 512 + } + }, + "required": [ + "reasonCode" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "status": { + "$ref": "#/definitions/DisplayMessageStatusEnumType" + }, + "statusInfo": { + "$ref": "#/definitions/StatusInfoType" + } + }, + "required": [ + "status" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/SetMonitoringBaseRequest.json b/schemas/ocpp20/SetMonitoringBaseRequest.json new file mode 100644 index 00000000..cbcac330 --- /dev/null +++ b/schemas/ocpp20/SetMonitoringBaseRequest.json @@ -0,0 +1,45 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:SetMonitoringBaseRequest", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "MonitoringBaseEnumType": { + "description": "Specify which monitoring base will be set\r\n", + "javaType": "MonitoringBaseEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "All", + "FactoryDefault", + "HardWiredOnly" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "monitoringBase": { + "$ref": "#/definitions/MonitoringBaseEnumType" + } + }, + "required": [ + "monitoringBase" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/SetMonitoringBaseResponse.json b/schemas/ocpp20/SetMonitoringBaseResponse.json new file mode 100644 index 00000000..534a38eb --- /dev/null +++ b/schemas/ocpp20/SetMonitoringBaseResponse.json @@ -0,0 +1,73 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:SetMonitoringBaseResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "GenericDeviceModelStatusEnumType": { + "description": "Indicates whether the Charging Station was able to accept the request.\r\n", + "javaType": "GenericDeviceModelStatusEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Accepted", + "Rejected", + "NotSupported", + "EmptyResultSet" + ] + }, + "StatusInfoType": { + "description": "Element providing more information about the status.\r\n", + "javaType": "StatusInfo", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "reasonCode": { + "description": "A predefined code for the reason why the status is returned in this response. The string is case-insensitive.\r\n", + "type": "string", + "maxLength": 20 + }, + "additionalInfo": { + "description": "Additional text to provide detailed information.\r\n", + "type": "string", + "maxLength": 512 + } + }, + "required": [ + "reasonCode" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "status": { + "$ref": "#/definitions/GenericDeviceModelStatusEnumType" + }, + "statusInfo": { + "$ref": "#/definitions/StatusInfoType" + } + }, + "required": [ + "status" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/SetMonitoringLevelRequest.json b/schemas/ocpp20/SetMonitoringLevelRequest.json new file mode 100644 index 00000000..0214be00 --- /dev/null +++ b/schemas/ocpp20/SetMonitoringLevelRequest.json @@ -0,0 +1,35 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:SetMonitoringLevelRequest", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "severity": { + "description": "The Charging Station SHALL only report events with a severity number lower than or equal to this severity.\r\nThe severity range is 0-9, with 0 as the highest and 9 as the lowest severity level.\r\n\r\nThe severity levels have the following meaning: +\r\n*0-Danger* +\r\nIndicates lives are potentially in danger. Urgent attention is needed and action should be taken immediately. +\r\n*1-Hardware Failure* +\r\nIndicates that the Charging Station is unable to continue regular operations due to Hardware issues. Action is required. +\r\n*2-System Failure* +\r\nIndicates that the Charging Station is unable to continue regular operations due to software or minor hardware issues. Action is required. +\r\n*3-Critical* +\r\nIndicates a critical error. Action is required. +\r\n*4-Error* +\r\nIndicates a non-urgent error. Action is required. +\r\n*5-Alert* +\r\nIndicates an alert event. Default severity for any type of monitoring event. +\r\n*6-Warning* +\r\nIndicates a warning event. Action may be required. +\r\n*7-Notice* +\r\nIndicates an unusual event. No immediate action is required. +\r\n*8-Informational* +\r\nIndicates a regular operational event. May be used for reporting, measuring throughput, etc. No action is required. +\r\n*9-Debug* +\r\nIndicates information useful to developers for debugging, not useful during operations.\r\n\r\n\r\n", + "type": "integer" + } + }, + "required": [ + "severity" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/SetMonitoringLevelResponse.json b/schemas/ocpp20/SetMonitoringLevelResponse.json new file mode 100644 index 00000000..6f132db3 --- /dev/null +++ b/schemas/ocpp20/SetMonitoringLevelResponse.json @@ -0,0 +1,71 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:SetMonitoringLevelResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "GenericStatusEnumType": { + "description": "Indicates whether the Charging Station was able to accept the request.\r\n", + "javaType": "GenericStatusEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Accepted", + "Rejected" + ] + }, + "StatusInfoType": { + "description": "Element providing more information about the status.\r\n", + "javaType": "StatusInfo", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "reasonCode": { + "description": "A predefined code for the reason why the status is returned in this response. The string is case-insensitive.\r\n", + "type": "string", + "maxLength": 20 + }, + "additionalInfo": { + "description": "Additional text to provide detailed information.\r\n", + "type": "string", + "maxLength": 512 + } + }, + "required": [ + "reasonCode" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "status": { + "$ref": "#/definitions/GenericStatusEnumType" + }, + "statusInfo": { + "$ref": "#/definitions/StatusInfoType" + } + }, + "required": [ + "status" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/SetNetworkProfileRequest.json b/schemas/ocpp20/SetNetworkProfileRequest.json new file mode 100644 index 00000000..903a30b2 --- /dev/null +++ b/schemas/ocpp20/SetNetworkProfileRequest.json @@ -0,0 +1,241 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:SetNetworkProfileRequest", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "APNAuthenticationEnumType": { + "description": "APN. APN_ Authentication. APN_ Authentication_ Code\r\nurn:x-oca:ocpp:uid:1:568828\r\nAuthentication method.\r\n", + "javaType": "APNAuthenticationEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "CHAP", + "NONE", + "PAP", + "AUTO" + ] + }, + "OCPPInterfaceEnumType": { + "description": "Applicable Network Interface.\r\n", + "javaType": "OCPPInterfaceEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Wired0", + "Wired1", + "Wired2", + "Wired3", + "Wireless0", + "Wireless1", + "Wireless2", + "Wireless3" + ] + }, + "OCPPTransportEnumType": { + "description": "Communication_ Function. OCPP_ Transport. OCPP_ Transport_ Code\r\nurn:x-oca:ocpp:uid:1:569356\r\nDefines the transport protocol (e.g. SOAP or JSON). Note: SOAP is not supported in OCPP 2.0, but is supported by other versions of OCPP.\r\n", + "javaType": "OCPPTransportEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "JSON", + "SOAP" + ] + }, + "OCPPVersionEnumType": { + "description": "Communication_ Function. OCPP_ Version. OCPP_ Version_ Code\r\nurn:x-oca:ocpp:uid:1:569355\r\nDefines the OCPP version used for this communication function.\r\n", + "javaType": "OCPPVersionEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "OCPP12", + "OCPP15", + "OCPP16", + "OCPP20" + ] + }, + "VPNEnumType": { + "description": "VPN. Type. VPN_ Code\r\nurn:x-oca:ocpp:uid:1:569277\r\nType of VPN\r\n", + "javaType": "VPNEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "IKEv2", + "IPSec", + "L2TP", + "PPTP" + ] + }, + "APNType": { + "description": "APN\r\nurn:x-oca:ocpp:uid:2:233134\r\nCollection of configuration data needed to make a data-connection over a cellular network.\r\n\r\nNOTE: When asking a GSM modem to dial in, it is possible to specify which mobile operator should be used. This can be done with the mobile country code (MCC) in combination with a mobile network code (MNC). Example: If your preferred network is Vodafone Netherlands, the MCC=204 and the MNC=04 which means the key PreferredNetwork = 20404 Some modems allows to specify a preferred network, which means, if this network is not available, a different network is used. If you specify UseOnlyPreferredNetwork and this network is not available, the modem will not dial in.\r\n", + "javaType": "APN", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "apn": { + "description": "APN. APN. URI\r\nurn:x-oca:ocpp:uid:1:568814\r\nThe Access Point Name as an URL.\r\n", + "type": "string", + "maxLength": 512 + }, + "apnUserName": { + "description": "APN. APN. User_ Name\r\nurn:x-oca:ocpp:uid:1:568818\r\nAPN username.\r\n", + "type": "string", + "maxLength": 20 + }, + "apnPassword": { + "description": "APN. APN. Password\r\nurn:x-oca:ocpp:uid:1:568819\r\nAPN Password.\r\n", + "type": "string", + "maxLength": 20 + }, + "simPin": { + "description": "APN. SIMPIN. PIN_ Code\r\nurn:x-oca:ocpp:uid:1:568821\r\nSIM card pin code.\r\n", + "type": "integer" + }, + "preferredNetwork": { + "description": "APN. Preferred_ Network. Mobile_ Network_ ID\r\nurn:x-oca:ocpp:uid:1:568822\r\nPreferred network, written as MCC and MNC concatenated. See note.\r\n", + "type": "string", + "maxLength": 6 + }, + "useOnlyPreferredNetwork": { + "description": "APN. Use_ Only_ Preferred_ Network. Indicator\r\nurn:x-oca:ocpp:uid:1:568824\r\nDefault: false. Use only the preferred Network, do\r\nnot dial in when not available. See Note.\r\n", + "type": "boolean", + "default": false + }, + "apnAuthentication": { + "$ref": "#/definitions/APNAuthenticationEnumType" + } + }, + "required": [ + "apn", + "apnAuthentication" + ] + }, + "NetworkConnectionProfileType": { + "description": "Communication_ Function\r\nurn:x-oca:ocpp:uid:2:233304\r\nThe NetworkConnectionProfile defines the functional and technical parameters of a communication link.\r\n", + "javaType": "NetworkConnectionProfile", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "apn": { + "$ref": "#/definitions/APNType" + }, + "ocppVersion": { + "$ref": "#/definitions/OCPPVersionEnumType" + }, + "ocppTransport": { + "$ref": "#/definitions/OCPPTransportEnumType" + }, + "ocppCsmsUrl": { + "description": "Communication_ Function. OCPP_ Central_ System_ URL. URI\r\nurn:x-oca:ocpp:uid:1:569357\r\nURL of the CSMS(s) that this Charging Station communicates with.\r\n", + "type": "string", + "maxLength": 512 + }, + "messageTimeout": { + "description": "Duration in seconds before a message send by the Charging Station via this network connection times-out.\r\nThe best setting depends on the underlying network and response times of the CSMS.\r\nIf you are looking for a some guideline: use 30 seconds as a starting point.\r\n", + "type": "integer" + }, + "securityProfile": { + "description": "This field specifies the security profile used when connecting to the CSMS with this NetworkConnectionProfile.\r\n", + "type": "integer" + }, + "ocppInterface": { + "$ref": "#/definitions/OCPPInterfaceEnumType" + }, + "vpn": { + "$ref": "#/definitions/VPNType" + } + }, + "required": [ + "ocppVersion", + "ocppTransport", + "ocppCsmsUrl", + "messageTimeout", + "securityProfile", + "ocppInterface" + ] + }, + "VPNType": { + "description": "VPN\r\nurn:x-oca:ocpp:uid:2:233268\r\nVPN Configuration settings\r\n", + "javaType": "VPN", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "server": { + "description": "VPN. Server. URI\r\nurn:x-oca:ocpp:uid:1:569272\r\nVPN Server Address\r\n", + "type": "string", + "maxLength": 512 + }, + "user": { + "description": "VPN. User. User_ Name\r\nurn:x-oca:ocpp:uid:1:569273\r\nVPN User\r\n", + "type": "string", + "maxLength": 20 + }, + "group": { + "description": "VPN. Group. Group_ Name\r\nurn:x-oca:ocpp:uid:1:569274\r\nVPN group.\r\n", + "type": "string", + "maxLength": 20 + }, + "password": { + "description": "VPN. Password. Password\r\nurn:x-oca:ocpp:uid:1:569275\r\nVPN Password.\r\n", + "type": "string", + "maxLength": 20 + }, + "key": { + "description": "VPN. Key. VPN_ Key\r\nurn:x-oca:ocpp:uid:1:569276\r\nVPN shared secret.\r\n", + "type": "string", + "maxLength": 255 + }, + "type": { + "$ref": "#/definitions/VPNEnumType" + } + }, + "required": [ + "server", + "user", + "password", + "key", + "type" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "configurationSlot": { + "description": "Slot in which the configuration should be stored.\r\n", + "type": "integer" + }, + "connectionData": { + "$ref": "#/definitions/NetworkConnectionProfileType" + } + }, + "required": [ + "configurationSlot", + "connectionData" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/SetNetworkProfileResponse.json b/schemas/ocpp20/SetNetworkProfileResponse.json new file mode 100644 index 00000000..c3944322 --- /dev/null +++ b/schemas/ocpp20/SetNetworkProfileResponse.json @@ -0,0 +1,72 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:SetNetworkProfileResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "SetNetworkProfileStatusEnumType": { + "description": "Result of operation.\r\n", + "javaType": "SetNetworkProfileStatusEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Accepted", + "Rejected", + "Failed" + ] + }, + "StatusInfoType": { + "description": "Element providing more information about the status.\r\n", + "javaType": "StatusInfo", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "reasonCode": { + "description": "A predefined code for the reason why the status is returned in this response. The string is case-insensitive.\r\n", + "type": "string", + "maxLength": 20 + }, + "additionalInfo": { + "description": "Additional text to provide detailed information.\r\n", + "type": "string", + "maxLength": 512 + } + }, + "required": [ + "reasonCode" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "status": { + "$ref": "#/definitions/SetNetworkProfileStatusEnumType" + }, + "statusInfo": { + "$ref": "#/definitions/StatusInfoType" + } + }, + "required": [ + "status" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/SetVariableMonitoringRequest.json b/schemas/ocpp20/SetVariableMonitoringRequest.json new file mode 100644 index 00000000..e5df2a14 --- /dev/null +++ b/schemas/ocpp20/SetVariableMonitoringRequest.json @@ -0,0 +1,169 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:SetVariableMonitoringRequest", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "MonitorEnumType": { + "description": "The type of this monitor, e.g. a threshold, delta or periodic monitor. \r\n\r\n", + "javaType": "MonitorEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "UpperThreshold", + "LowerThreshold", + "Delta", + "Periodic", + "PeriodicClockAligned" + ] + }, + "ComponentType": { + "description": "A physical or logical component\r\n", + "javaType": "Component", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "evse": { + "$ref": "#/definitions/EVSEType" + }, + "name": { + "description": "Name of the component. Name should be taken from the list of standardized component names whenever possible. Case Insensitive. strongly advised to use Camel Case.\r\n", + "type": "string", + "maxLength": 50 + }, + "instance": { + "description": "Name of instance in case the component exists as multiple instances. Case Insensitive. strongly advised to use Camel Case.\r\n", + "type": "string", + "maxLength": 50 + } + }, + "required": [ + "name" + ] + }, + "EVSEType": { + "description": "EVSE\r\nurn:x-oca:ocpp:uid:2:233123\r\nElectric Vehicle Supply Equipment\r\n", + "javaType": "EVSE", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "id": { + "description": "Identified_ Object. MRID. Numeric_ Identifier\r\nurn:x-enexis:ecdm:uid:1:569198\r\nEVSE Identifier. This contains a number (> 0) designating an EVSE of the Charging Station.\r\n", + "type": "integer" + }, + "connectorId": { + "description": "An id to designate a specific connector (on an EVSE) by connector index number.\r\n", + "type": "integer" + } + }, + "required": [ + "id" + ] + }, + "SetMonitoringDataType": { + "description": "Class to hold parameters of SetVariableMonitoring request.\r\n", + "javaType": "SetMonitoringData", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "id": { + "description": "An id SHALL only be given to replace an existing monitor. The Charging Station handles the generation of id's for new monitors.\r\n\r\n", + "type": "integer" + }, + "transaction": { + "description": "Monitor only active when a transaction is ongoing on a component relevant to this transaction. Default = false.\r\n\r\n", + "type": "boolean", + "default": false + }, + "value": { + "description": "Value for threshold or delta monitoring.\r\nFor Periodic or PeriodicClockAligned this is the interval in seconds.\r\n\r\n", + "type": "number" + }, + "type": { + "$ref": "#/definitions/MonitorEnumType" + }, + "severity": { + "description": "The severity that will be assigned to an event that is triggered by this monitor. The severity range is 0-9, with 0 as the highest and 9 as the lowest severity level.\r\n\r\nThe severity levels have the following meaning: +\r\n*0-Danger* +\r\nIndicates lives are potentially in danger. Urgent attention is needed and action should be taken immediately. +\r\n*1-Hardware Failure* +\r\nIndicates that the Charging Station is unable to continue regular operations due to Hardware issues. Action is required. +\r\n*2-System Failure* +\r\nIndicates that the Charging Station is unable to continue regular operations due to software or minor hardware issues. Action is required. +\r\n*3-Critical* +\r\nIndicates a critical error. Action is required. +\r\n*4-Error* +\r\nIndicates a non-urgent error. Action is required. +\r\n*5-Alert* +\r\nIndicates an alert event. Default severity for any type of monitoring event. +\r\n*6-Warning* +\r\nIndicates a warning event. Action may be required. +\r\n*7-Notice* +\r\nIndicates an unusual event. No immediate action is required. +\r\n*8-Informational* +\r\nIndicates a regular operational event. May be used for reporting, measuring throughput, etc. No action is required. +\r\n*9-Debug* +\r\nIndicates information useful to developers for debugging, not useful during operations.\r\n\r\n", + "type": "integer" + }, + "component": { + "$ref": "#/definitions/ComponentType" + }, + "variable": { + "$ref": "#/definitions/VariableType" + } + }, + "required": [ + "value", + "type", + "severity", + "component", + "variable" + ] + }, + "VariableType": { + "description": "Reference key to a component-variable.\r\n", + "javaType": "Variable", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "name": { + "description": "Name of the variable. Name should be taken from the list of standardized variable names whenever possible. Case Insensitive. strongly advised to use Camel Case.\r\n", + "type": "string", + "maxLength": 50 + }, + "instance": { + "description": "Name of instance in case the variable exists as multiple instances. Case Insensitive. strongly advised to use Camel Case.\r\n", + "type": "string", + "maxLength": 50 + } + }, + "required": [ + "name" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "setMonitoringData": { + "type": "array", + "additionalItems": false, + "items": { + "$ref": "#/definitions/SetMonitoringDataType" + }, + "minItems": 1 + } + }, + "required": [ + "setMonitoringData" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/SetVariableMonitoringResponse.json b/schemas/ocpp20/SetVariableMonitoringResponse.json new file mode 100644 index 00000000..192ec488 --- /dev/null +++ b/schemas/ocpp20/SetVariableMonitoringResponse.json @@ -0,0 +1,204 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:SetVariableMonitoringResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "MonitorEnumType": { + "description": "The type of this monitor, e.g. a threshold, delta or periodic monitor. \r\n\r\n", + "javaType": "MonitorEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "UpperThreshold", + "LowerThreshold", + "Delta", + "Periodic", + "PeriodicClockAligned" + ] + }, + "SetMonitoringStatusEnumType": { + "description": "Status is OK if a value could be returned. Otherwise this will indicate the reason why a value could not be returned.\r\n", + "javaType": "SetMonitoringStatusEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Accepted", + "UnknownComponent", + "UnknownVariable", + "UnsupportedMonitorType", + "Rejected", + "Duplicate" + ] + }, + "ComponentType": { + "description": "A physical or logical component\r\n", + "javaType": "Component", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "evse": { + "$ref": "#/definitions/EVSEType" + }, + "name": { + "description": "Name of the component. Name should be taken from the list of standardized component names whenever possible. Case Insensitive. strongly advised to use Camel Case.\r\n", + "type": "string", + "maxLength": 50 + }, + "instance": { + "description": "Name of instance in case the component exists as multiple instances. Case Insensitive. strongly advised to use Camel Case.\r\n", + "type": "string", + "maxLength": 50 + } + }, + "required": [ + "name" + ] + }, + "EVSEType": { + "description": "EVSE\r\nurn:x-oca:ocpp:uid:2:233123\r\nElectric Vehicle Supply Equipment\r\n", + "javaType": "EVSE", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "id": { + "description": "Identified_ Object. MRID. Numeric_ Identifier\r\nurn:x-enexis:ecdm:uid:1:569198\r\nEVSE Identifier. This contains a number (> 0) designating an EVSE of the Charging Station.\r\n", + "type": "integer" + }, + "connectorId": { + "description": "An id to designate a specific connector (on an EVSE) by connector index number.\r\n", + "type": "integer" + } + }, + "required": [ + "id" + ] + }, + "SetMonitoringResultType": { + "description": "Class to hold result of SetVariableMonitoring request.\r\n", + "javaType": "SetMonitoringResult", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "id": { + "description": "Id given to the VariableMonitor by the Charging Station. The Id is only returned when status is accepted. Installed VariableMonitors should have unique id's but the id's of removed Installed monitors should have unique id's but the id's of removed monitors MAY be reused.\r\n", + "type": "integer" + }, + "statusInfo": { + "$ref": "#/definitions/StatusInfoType" + }, + "status": { + "$ref": "#/definitions/SetMonitoringStatusEnumType" + }, + "type": { + "$ref": "#/definitions/MonitorEnumType" + }, + "component": { + "$ref": "#/definitions/ComponentType" + }, + "variable": { + "$ref": "#/definitions/VariableType" + }, + "severity": { + "description": "The severity that will be assigned to an event that is triggered by this monitor. The severity range is 0-9, with 0 as the highest and 9 as the lowest severity level.\r\n\r\nThe severity levels have the following meaning: +\r\n*0-Danger* +\r\nIndicates lives are potentially in danger. Urgent attention is needed and action should be taken immediately. +\r\n*1-Hardware Failure* +\r\nIndicates that the Charging Station is unable to continue regular operations due to Hardware issues. Action is required. +\r\n*2-System Failure* +\r\nIndicates that the Charging Station is unable to continue regular operations due to software or minor hardware issues. Action is required. +\r\n*3-Critical* +\r\nIndicates a critical error. Action is required. +\r\n*4-Error* +\r\nIndicates a non-urgent error. Action is required. +\r\n*5-Alert* +\r\nIndicates an alert event. Default severity for any type of monitoring event. +\r\n*6-Warning* +\r\nIndicates a warning event. Action may be required. +\r\n*7-Notice* +\r\nIndicates an unusual event. No immediate action is required. +\r\n*8-Informational* +\r\nIndicates a regular operational event. May be used for reporting, measuring throughput, etc. No action is required. +\r\n*9-Debug* +\r\nIndicates information useful to developers for debugging, not useful during operations.\r\n\r\n", + "type": "integer" + } + }, + "required": [ + "status", + "type", + "severity", + "component", + "variable" + ] + }, + "StatusInfoType": { + "description": "Element providing more information about the status.\r\n", + "javaType": "StatusInfo", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "reasonCode": { + "description": "A predefined code for the reason why the status is returned in this response. The string is case-insensitive.\r\n", + "type": "string", + "maxLength": 20 + }, + "additionalInfo": { + "description": "Additional text to provide detailed information.\r\n", + "type": "string", + "maxLength": 512 + } + }, + "required": [ + "reasonCode" + ] + }, + "VariableType": { + "description": "Reference key to a component-variable.\r\n", + "javaType": "Variable", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "name": { + "description": "Name of the variable. Name should be taken from the list of standardized variable names whenever possible. Case Insensitive. strongly advised to use Camel Case.\r\n", + "type": "string", + "maxLength": 50 + }, + "instance": { + "description": "Name of instance in case the variable exists as multiple instances. Case Insensitive. strongly advised to use Camel Case.\r\n", + "type": "string", + "maxLength": 50 + } + }, + "required": [ + "name" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "setMonitoringResult": { + "type": "array", + "additionalItems": false, + "items": { + "$ref": "#/definitions/SetMonitoringResultType" + }, + "minItems": 1 + } + }, + "required": [ + "setMonitoringResult" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/SetVariablesRequest.json b/schemas/ocpp20/SetVariablesRequest.json new file mode 100644 index 00000000..895d7b98 --- /dev/null +++ b/schemas/ocpp20/SetVariablesRequest.json @@ -0,0 +1,154 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:SetVariablesRequest", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "AttributeEnumType": { + "description": "Type of attribute: Actual, Target, MinSet, MaxSet. Default is Actual when omitted.\r\n", + "javaType": "AttributeEnum", + "type": "string", + "default": "Actual", + "additionalProperties": false, + "enum": [ + "Actual", + "Target", + "MinSet", + "MaxSet" + ] + }, + "ComponentType": { + "description": "A physical or logical component\r\n", + "javaType": "Component", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "evse": { + "$ref": "#/definitions/EVSEType" + }, + "name": { + "description": "Name of the component. Name should be taken from the list of standardized component names whenever possible. Case Insensitive. strongly advised to use Camel Case.\r\n", + "type": "string", + "maxLength": 50 + }, + "instance": { + "description": "Name of instance in case the component exists as multiple instances. Case Insensitive. strongly advised to use Camel Case.\r\n", + "type": "string", + "maxLength": 50 + } + }, + "required": [ + "name" + ] + }, + "EVSEType": { + "description": "EVSE\r\nurn:x-oca:ocpp:uid:2:233123\r\nElectric Vehicle Supply Equipment\r\n", + "javaType": "EVSE", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "id": { + "description": "Identified_ Object. MRID. Numeric_ Identifier\r\nurn:x-enexis:ecdm:uid:1:569198\r\nEVSE Identifier. This contains a number (> 0) designating an EVSE of the Charging Station.\r\n", + "type": "integer" + }, + "connectorId": { + "description": "An id to designate a specific connector (on an EVSE) by connector index number.\r\n", + "type": "integer" + } + }, + "required": [ + "id" + ] + }, + "SetVariableDataType": { + "javaType": "SetVariableData", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "attributeType": { + "$ref": "#/definitions/AttributeEnumType" + }, + "attributeValue": { + "description": "Value to be assigned to attribute of variable.\r\n\r\nThe Configuration Variable <<configkey-configuration-value-size,ConfigurationValueSize>> can be used to limit SetVariableData.attributeValue and VariableCharacteristics.valueList. The max size of these values will always remain equal. \r\n", + "type": "string", + "maxLength": 1000 + }, + "component": { + "$ref": "#/definitions/ComponentType" + }, + "variable": { + "$ref": "#/definitions/VariableType" + } + }, + "required": [ + "attributeValue", + "component", + "variable" + ] + }, + "VariableType": { + "description": "Reference key to a component-variable.\r\n", + "javaType": "Variable", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "name": { + "description": "Name of the variable. Name should be taken from the list of standardized variable names whenever possible. Case Insensitive. strongly advised to use Camel Case.\r\n", + "type": "string", + "maxLength": 50 + }, + "instance": { + "description": "Name of instance in case the variable exists as multiple instances. Case Insensitive. strongly advised to use Camel Case.\r\n", + "type": "string", + "maxLength": 50 + } + }, + "required": [ + "name" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "setVariableData": { + "type": "array", + "additionalItems": false, + "items": { + "$ref": "#/definitions/SetVariableDataType" + }, + "minItems": 1 + } + }, + "required": [ + "setVariableData" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/SetVariablesResponse.json b/schemas/ocpp20/SetVariablesResponse.json new file mode 100644 index 00000000..c3fb2bf5 --- /dev/null +++ b/schemas/ocpp20/SetVariablesResponse.json @@ -0,0 +1,193 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:SetVariablesResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "AttributeEnumType": { + "description": "Type of attribute: Actual, Target, MinSet, MaxSet. Default is Actual when omitted.\r\n", + "javaType": "AttributeEnum", + "type": "string", + "default": "Actual", + "additionalProperties": false, + "enum": [ + "Actual", + "Target", + "MinSet", + "MaxSet" + ] + }, + "SetVariableStatusEnumType": { + "description": "Result status of setting the variable.\r\n", + "javaType": "SetVariableStatusEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Accepted", + "Rejected", + "UnknownComponent", + "UnknownVariable", + "NotSupportedAttributeType", + "RebootRequired" + ] + }, + "ComponentType": { + "description": "A physical or logical component\r\n", + "javaType": "Component", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "evse": { + "$ref": "#/definitions/EVSEType" + }, + "name": { + "description": "Name of the component. Name should be taken from the list of standardized component names whenever possible. Case Insensitive. strongly advised to use Camel Case.\r\n", + "type": "string", + "maxLength": 50 + }, + "instance": { + "description": "Name of instance in case the component exists as multiple instances. Case Insensitive. strongly advised to use Camel Case.\r\n", + "type": "string", + "maxLength": 50 + } + }, + "required": [ + "name" + ] + }, + "EVSEType": { + "description": "EVSE\r\nurn:x-oca:ocpp:uid:2:233123\r\nElectric Vehicle Supply Equipment\r\n", + "javaType": "EVSE", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "id": { + "description": "Identified_ Object. MRID. Numeric_ Identifier\r\nurn:x-enexis:ecdm:uid:1:569198\r\nEVSE Identifier. This contains a number (> 0) designating an EVSE of the Charging Station.\r\n", + "type": "integer" + }, + "connectorId": { + "description": "An id to designate a specific connector (on an EVSE) by connector index number.\r\n", + "type": "integer" + } + }, + "required": [ + "id" + ] + }, + "SetVariableResultType": { + "javaType": "SetVariableResult", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "attributeType": { + "$ref": "#/definitions/AttributeEnumType" + }, + "attributeStatus": { + "$ref": "#/definitions/SetVariableStatusEnumType" + }, + "attributeStatusInfo": { + "$ref": "#/definitions/StatusInfoType" + }, + "component": { + "$ref": "#/definitions/ComponentType" + }, + "variable": { + "$ref": "#/definitions/VariableType" + } + }, + "required": [ + "attributeStatus", + "component", + "variable" + ] + }, + "StatusInfoType": { + "description": "Element providing more information about the status.\r\n", + "javaType": "StatusInfo", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "reasonCode": { + "description": "A predefined code for the reason why the status is returned in this response. The string is case-insensitive.\r\n", + "type": "string", + "maxLength": 20 + }, + "additionalInfo": { + "description": "Additional text to provide detailed information.\r\n", + "type": "string", + "maxLength": 512 + } + }, + "required": [ + "reasonCode" + ] + }, + "VariableType": { + "description": "Reference key to a component-variable.\r\n", + "javaType": "Variable", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "name": { + "description": "Name of the variable. Name should be taken from the list of standardized variable names whenever possible. Case Insensitive. strongly advised to use Camel Case.\r\n", + "type": "string", + "maxLength": 50 + }, + "instance": { + "description": "Name of instance in case the variable exists as multiple instances. Case Insensitive. strongly advised to use Camel Case.\r\n", + "type": "string", + "maxLength": 50 + } + }, + "required": [ + "name" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "setVariableResult": { + "type": "array", + "additionalItems": false, + "items": { + "$ref": "#/definitions/SetVariableResultType" + }, + "minItems": 1 + } + }, + "required": [ + "setVariableResult" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/SignCertificateRequest.json b/schemas/ocpp20/SignCertificateRequest.json new file mode 100644 index 00000000..d0256cf3 --- /dev/null +++ b/schemas/ocpp20/SignCertificateRequest.json @@ -0,0 +1,49 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:SignCertificateRequest", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "CertificateSigningUseEnumType": { + "description": "Indicates the type of certificate that is to be signed. When omitted the certificate is to be used for both the 15118 connection (if implemented) and the Charging Station to CSMS connection.\r\n\r\n", + "javaType": "CertificateSigningUseEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "ChargingStationCertificate", + "V2GCertificate" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "csr": { + "description": "The Charging Station SHALL send the public key in form of a Certificate Signing Request (CSR) as described in RFC 2986 [22] and then PEM encoded, using the <<signcertificaterequest,SignCertificateRequest>> message.\r\n", + "type": "string", + "maxLength": 5500 + }, + "certificateType": { + "$ref": "#/definitions/CertificateSigningUseEnumType" + } + }, + "required": [ + "csr" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/SignCertificateResponse.json b/schemas/ocpp20/SignCertificateResponse.json new file mode 100644 index 00000000..302eb769 --- /dev/null +++ b/schemas/ocpp20/SignCertificateResponse.json @@ -0,0 +1,71 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:SignCertificateResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "GenericStatusEnumType": { + "description": "Specifies whether the CSMS can process the request.\r\n", + "javaType": "GenericStatusEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Accepted", + "Rejected" + ] + }, + "StatusInfoType": { + "description": "Element providing more information about the status.\r\n", + "javaType": "StatusInfo", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "reasonCode": { + "description": "A predefined code for the reason why the status is returned in this response. The string is case-insensitive.\r\n", + "type": "string", + "maxLength": 20 + }, + "additionalInfo": { + "description": "Additional text to provide detailed information.\r\n", + "type": "string", + "maxLength": 512 + } + }, + "required": [ + "reasonCode" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "status": { + "$ref": "#/definitions/GenericStatusEnumType" + }, + "statusInfo": { + "$ref": "#/definitions/StatusInfoType" + } + }, + "required": [ + "status" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/StatusNotificationRequest.json b/schemas/ocpp20/StatusNotificationRequest.json new file mode 100644 index 00000000..d47cfdff --- /dev/null +++ b/schemas/ocpp20/StatusNotificationRequest.json @@ -0,0 +1,63 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:StatusNotificationRequest", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "ConnectorStatusEnumType": { + "description": "This contains the current status of the Connector.\r\n", + "javaType": "ConnectorStatusEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Available", + "Occupied", + "Reserved", + "Unavailable", + "Faulted" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "timestamp": { + "description": "The time for which the status is reported. If absent time of receipt of the message will be assumed.\r\n", + "type": "string", + "format": "date-time" + }, + "connectorStatus": { + "$ref": "#/definitions/ConnectorStatusEnumType" + }, + "evseId": { + "description": "The id of the EVSE to which the connector belongs for which the the status is reported.\r\n", + "type": "integer" + }, + "connectorId": { + "description": "The id of the connector within the EVSE for which the status is reported.\r\n", + "type": "integer" + } + }, + "required": [ + "timestamp", + "connectorStatus", + "evseId", + "connectorId" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/StatusNotificationResponse.json b/schemas/ocpp20/StatusNotificationResponse.json new file mode 100644 index 00000000..4a682ed5 --- /dev/null +++ b/schemas/ocpp20/StatusNotificationResponse.json @@ -0,0 +1,28 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:StatusNotificationResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + } + } +} \ No newline at end of file diff --git a/schemas/ocpp20/TransactionEventRequest.json b/schemas/ocpp20/TransactionEventRequest.json new file mode 100644 index 00000000..acf691ac --- /dev/null +++ b/schemas/ocpp20/TransactionEventRequest.json @@ -0,0 +1,497 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:TransactionEventRequest", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "ChargingStateEnumType": { + "description": "Transaction. State. Transaction_ State_ Code\r\nurn:x-oca:ocpp:uid:1:569419\r\nCurrent charging state, is required when state\r\nhas changed.\r\n", + "javaType": "ChargingStateEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Charging", + "EVConnected", + "SuspendedEV", + "SuspendedEVSE", + "Idle" + ] + }, + "IdTokenEnumType": { + "description": "Enumeration of possible idToken types.\r\n", + "javaType": "IdTokenEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Central", + "eMAID", + "ISO14443", + "ISO15693", + "KeyCode", + "Local", + "MacAddress", + "NoAuthorization" + ] + }, + "LocationEnumType": { + "description": "Sampled_ Value. Location. Location_ Code\r\nurn:x-oca:ocpp:uid:1:569265\r\nIndicates where the measured value has been sampled. Default = \"Outlet\"\r\n\r\n", + "javaType": "LocationEnum", + "type": "string", + "default": "Outlet", + "additionalProperties": false, + "enum": [ + "Body", + "Cable", + "EV", + "Inlet", + "Outlet" + ] + }, + "MeasurandEnumType": { + "description": "Sampled_ Value. Measurand. Measurand_ Code\r\nurn:x-oca:ocpp:uid:1:569263\r\nType of measurement. Default = \"Energy.Active.Import.Register\"\r\n", + "javaType": "MeasurandEnum", + "type": "string", + "default": "Energy.Active.Import.Register", + "additionalProperties": false, + "enum": [ + "Current.Export", + "Current.Import", + "Current.Offered", + "Energy.Active.Export.Register", + "Energy.Active.Import.Register", + "Energy.Reactive.Export.Register", + "Energy.Reactive.Import.Register", + "Energy.Active.Export.Interval", + "Energy.Active.Import.Interval", + "Energy.Active.Net", + "Energy.Reactive.Export.Interval", + "Energy.Reactive.Import.Interval", + "Energy.Reactive.Net", + "Energy.Apparent.Net", + "Energy.Apparent.Import", + "Energy.Apparent.Export", + "Frequency", + "Power.Active.Export", + "Power.Active.Import", + "Power.Factor", + "Power.Offered", + "Power.Reactive.Export", + "Power.Reactive.Import", + "SoC", + "Voltage" + ] + }, + "PhaseEnumType": { + "description": "Sampled_ Value. Phase. Phase_ Code\r\nurn:x-oca:ocpp:uid:1:569264\r\nIndicates how the measured value is to be interpreted. For instance between L1 and neutral (L1-N) Please note that not all values of phase are applicable to all Measurands. When phase is absent, the measured value is interpreted as an overall value.\r\n", + "javaType": "PhaseEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "L1", + "L2", + "L3", + "N", + "L1-N", + "L2-N", + "L3-N", + "L1-L2", + "L2-L3", + "L3-L1" + ] + }, + "ReadingContextEnumType": { + "description": "Sampled_ Value. Context. Reading_ Context_ Code\r\nurn:x-oca:ocpp:uid:1:569261\r\nType of detail value: start, end or sample. Default = \"Sample.Periodic\"\r\n", + "javaType": "ReadingContextEnum", + "type": "string", + "default": "Sample.Periodic", + "additionalProperties": false, + "enum": [ + "Interruption.Begin", + "Interruption.End", + "Other", + "Sample.Clock", + "Sample.Periodic", + "Transaction.Begin", + "Transaction.End", + "Trigger" + ] + }, + "ReasonEnumType": { + "description": "Transaction. Stopped_ Reason. EOT_ Reason_ Code\r\nurn:x-oca:ocpp:uid:1:569413\r\nThis contains the reason why the transaction was stopped. MAY only be omitted when Reason is \"Local\".\r\n", + "javaType": "ReasonEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "DeAuthorized", + "EmergencyStop", + "EnergyLimitReached", + "EVDisconnected", + "GroundFault", + "ImmediateReset", + "Local", + "LocalOutOfCredit", + "MasterPass", + "Other", + "OvercurrentFault", + "PowerLoss", + "PowerQuality", + "Reboot", + "Remote", + "SOCLimitReached", + "StoppedByEV", + "TimeLimitReached", + "Timeout" + ] + }, + "TransactionEventEnumType": { + "description": "This contains the type of this event.\r\nThe first TransactionEvent of a transaction SHALL contain: \"Started\" The last TransactionEvent of a transaction SHALL contain: \"Ended\" All others SHALL contain: \"Updated\"\r\n", + "javaType": "TransactionEventEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Ended", + "Started", + "Updated" + ] + }, + "TriggerReasonEnumType": { + "description": "Reason the Charging Station sends this message to the CSMS\r\n", + "javaType": "TriggerReasonEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Authorized", + "CablePluggedIn", + "ChargingRateChanged", + "ChargingStateChanged", + "Deauthorized", + "EnergyLimitReached", + "EVCommunicationLost", + "EVConnectTimeout", + "MeterValueClock", + "MeterValuePeriodic", + "TimeLimitReached", + "Trigger", + "UnlockCommand", + "StopAuthorized", + "EVDeparted", + "EVDetected", + "RemoteStop", + "RemoteStart", + "AbnormalCondition", + "SignedDataReceived", + "ResetCommand" + ] + }, + "AdditionalInfoType": { + "description": "Contains a case insensitive identifier to use for the authorization and the type of authorization to support multiple forms of identifiers.\r\n", + "javaType": "AdditionalInfo", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "additionalIdToken": { + "description": "This field specifies the additional IdToken.\r\n", + "type": "string", + "maxLength": 36 + }, + "type": { + "description": "This defines the type of the additionalIdToken. This is a custom type, so the implementation needs to be agreed upon by all involved parties.\r\n", + "type": "string", + "maxLength": 50 + } + }, + "required": [ + "additionalIdToken", + "type" + ] + }, + "EVSEType": { + "description": "EVSE\r\nurn:x-oca:ocpp:uid:2:233123\r\nElectric Vehicle Supply Equipment\r\n", + "javaType": "EVSE", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "id": { + "description": "Identified_ Object. MRID. Numeric_ Identifier\r\nurn:x-enexis:ecdm:uid:1:569198\r\nEVSE Identifier. This contains a number (> 0) designating an EVSE of the Charging Station.\r\n", + "type": "integer" + }, + "connectorId": { + "description": "An id to designate a specific connector (on an EVSE) by connector index number.\r\n", + "type": "integer" + } + }, + "required": [ + "id" + ] + }, + "IdTokenType": { + "description": "Contains a case insensitive identifier to use for the authorization and the type of authorization to support multiple forms of identifiers.\r\n", + "javaType": "IdToken", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "additionalInfo": { + "type": "array", + "additionalItems": false, + "items": { + "$ref": "#/definitions/AdditionalInfoType" + }, + "minItems": 1 + }, + "idToken": { + "description": "IdToken is case insensitive. Might hold the hidden id of an RFID tag, but can for example also contain a UUID.\r\n", + "type": "string", + "maxLength": 36 + }, + "type": { + "$ref": "#/definitions/IdTokenEnumType" + } + }, + "required": [ + "idToken", + "type" + ] + }, + "MeterValueType": { + "description": "Meter_ Value\r\nurn:x-oca:ocpp:uid:2:233265\r\nCollection of one or more sampled values in MeterValuesRequest and TransactionEvent. All sampled values in a MeterValue are sampled at the same point in time.\r\n", + "javaType": "MeterValue", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "sampledValue": { + "type": "array", + "additionalItems": false, + "items": { + "$ref": "#/definitions/SampledValueType" + }, + "minItems": 1 + }, + "timestamp": { + "description": "Meter_ Value. Timestamp. Date_ Time\r\nurn:x-oca:ocpp:uid:1:569259\r\nTimestamp for measured value(s).\r\n", + "type": "string", + "format": "date-time" + } + }, + "required": [ + "timestamp", + "sampledValue" + ] + }, + "SampledValueType": { + "description": "Sampled_ Value\r\nurn:x-oca:ocpp:uid:2:233266\r\nSingle sampled value in MeterValues. Each value can be accompanied by optional fields.\r\n\r\nTo save on mobile data usage, default values of all of the optional fields are such that. The value without any additional fields will be interpreted, as a register reading of active import energy in Wh (Watt-hour) units.\r\n", + "javaType": "SampledValue", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "value": { + "description": "Sampled_ Value. Value. Measure\r\nurn:x-oca:ocpp:uid:1:569260\r\nIndicates the measured value.\r\n\r\n", + "type": "number" + }, + "context": { + "$ref": "#/definitions/ReadingContextEnumType" + }, + "measurand": { + "$ref": "#/definitions/MeasurandEnumType" + }, + "phase": { + "$ref": "#/definitions/PhaseEnumType" + }, + "location": { + "$ref": "#/definitions/LocationEnumType" + }, + "signedMeterValue": { + "$ref": "#/definitions/SignedMeterValueType" + }, + "unitOfMeasure": { + "$ref": "#/definitions/UnitOfMeasureType" + } + }, + "required": [ + "value" + ] + }, + "SignedMeterValueType": { + "description": "Represent a signed version of the meter value.\r\n", + "javaType": "SignedMeterValue", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "signedMeterData": { + "description": "Base64 encoded, contains the signed data which might contain more then just the meter value. It can contain information like timestamps, reference to a customer etc.\r\n", + "type": "string", + "maxLength": 2500 + }, + "signingMethod": { + "description": "Method used to create the digital signature.\r\n", + "type": "string", + "maxLength": 50 + }, + "encodingMethod": { + "description": "Method used to encode the meter values before applying the digital signature algorithm.\r\n", + "type": "string", + "maxLength": 50 + }, + "publicKey": { + "description": "Base64 encoded, sending depends on configuration variable _PublicKeyWithSignedMeterValue_.\r\n", + "type": "string", + "maxLength": 2500 + } + }, + "required": [ + "signedMeterData", + "signingMethod", + "encodingMethod", + "publicKey" + ] + }, + "TransactionType": { + "description": "Transaction\r\nurn:x-oca:ocpp:uid:2:233318\r\n", + "javaType": "Transaction", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "transactionId": { + "description": "This contains the Id of the transaction.\r\n", + "type": "string", + "maxLength": 36 + }, + "chargingState": { + "$ref": "#/definitions/ChargingStateEnumType" + }, + "timeSpentCharging": { + "description": "Transaction. Time_ Spent_ Charging. Elapsed_ Time\r\nurn:x-oca:ocpp:uid:1:569415\r\nContains the total time that energy flowed from EVSE to EV during the transaction (in seconds). Note that timeSpentCharging is smaller or equal to the duration of the transaction.\r\n", + "type": "integer" + }, + "stoppedReason": { + "$ref": "#/definitions/ReasonEnumType" + }, + "remoteStartId": { + "description": "The ID given to remote start request (<<requeststarttransactionrequest, RequestStartTransactionRequest>>. This enables to CSMS to match the started transaction to the given start request.\r\n", + "type": "integer" + } + }, + "required": [ + "transactionId" + ] + }, + "UnitOfMeasureType": { + "description": "Represents a UnitOfMeasure with a multiplier\r\n", + "javaType": "UnitOfMeasure", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "unit": { + "description": "Unit of the value. Default = \"Wh\" if the (default) measurand is an \"Energy\" type.\r\nThis field SHALL use a value from the list Standardized Units of Measurements in Part 2 Appendices. \r\nIf an applicable unit is available in that list, otherwise a \"custom\" unit might be used.\r\n", + "type": "string", + "default": "Wh", + "maxLength": 20 + }, + "multiplier": { + "description": "Multiplier, this value represents the exponent to base 10. I.e. multiplier 3 means 10 raised to the 3rd power. Default is 0.\r\n", + "type": "integer", + "default": 0 + } + } + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "eventType": { + "$ref": "#/definitions/TransactionEventEnumType" + }, + "meterValue": { + "type": "array", + "additionalItems": false, + "items": { + "$ref": "#/definitions/MeterValueType" + }, + "minItems": 1 + }, + "timestamp": { + "description": "The date and time at which this transaction event occurred.\r\n", + "type": "string", + "format": "date-time" + }, + "triggerReason": { + "$ref": "#/definitions/TriggerReasonEnumType" + }, + "seqNo": { + "description": "Incremental sequence number, helps with determining if all messages of a transaction have been received.\r\n", + "type": "integer" + }, + "offline": { + "description": "Indication that this transaction event happened when the Charging Station was offline. Default = false, meaning: the event occurred when the Charging Station was online.\r\n", + "type": "boolean", + "default": false + }, + "numberOfPhasesUsed": { + "description": "If the Charging Station is able to report the number of phases used, then it SHALL provide it. When omitted the CSMS may be able to determine the number of phases used via device management.\r\n", + "type": "integer" + }, + "cableMaxCurrent": { + "description": "The maximum current of the connected cable in Ampere (A).\r\n", + "type": "integer" + }, + "reservationId": { + "description": "This contains the Id of the reservation that terminates as a result of this transaction.\r\n", + "type": "integer" + }, + "transactionInfo": { + "$ref": "#/definitions/TransactionType" + }, + "evse": { + "$ref": "#/definitions/EVSEType" + }, + "idToken": { + "$ref": "#/definitions/IdTokenType" + } + }, + "required": [ + "eventType", + "timestamp", + "triggerReason", + "seqNo", + "transactionInfo" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/TransactionEventResponse.json b/schemas/ocpp20/TransactionEventResponse.json new file mode 100644 index 00000000..303f9e15 --- /dev/null +++ b/schemas/ocpp20/TransactionEventResponse.json @@ -0,0 +1,223 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:TransactionEventResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "AuthorizationStatusEnumType": { + "description": "ID_ Token. Status. Authorization_ Status\r\nurn:x-oca:ocpp:uid:1:569372\r\nCurrent status of the ID Token.\r\n", + "javaType": "AuthorizationStatusEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Accepted", + "Blocked", + "ConcurrentTx", + "Expired", + "Invalid", + "NoCredit", + "NotAllowedTypeEVSE", + "NotAtThisLocation", + "NotAtThisTime", + "Unknown" + ] + }, + "IdTokenEnumType": { + "description": "Enumeration of possible idToken types.\r\n", + "javaType": "IdTokenEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Central", + "eMAID", + "ISO14443", + "ISO15693", + "KeyCode", + "Local", + "MacAddress", + "NoAuthorization" + ] + }, + "MessageFormatEnumType": { + "description": "Message_ Content. Format. Message_ Format_ Code\r\nurn:x-enexis:ecdm:uid:1:570848\r\nFormat of the message.\r\n", + "javaType": "MessageFormatEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "ASCII", + "HTML", + "URI", + "UTF8" + ] + }, + "AdditionalInfoType": { + "description": "Contains a case insensitive identifier to use for the authorization and the type of authorization to support multiple forms of identifiers.\r\n", + "javaType": "AdditionalInfo", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "additionalIdToken": { + "description": "This field specifies the additional IdToken.\r\n", + "type": "string", + "maxLength": 36 + }, + "type": { + "description": "This defines the type of the additionalIdToken. This is a custom type, so the implementation needs to be agreed upon by all involved parties.\r\n", + "type": "string", + "maxLength": 50 + } + }, + "required": [ + "additionalIdToken", + "type" + ] + }, + "IdTokenInfoType": { + "description": "ID_ Token\r\nurn:x-oca:ocpp:uid:2:233247\r\nContains status information about an identifier.\r\nIt is advised to not stop charging for a token that expires during charging, as ExpiryDate is only used for caching purposes. If ExpiryDate is not given, the status has no end date.\r\n", + "javaType": "IdTokenInfo", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "status": { + "$ref": "#/definitions/AuthorizationStatusEnumType" + }, + "cacheExpiryDateTime": { + "description": "ID_ Token. Expiry. Date_ Time\r\nurn:x-oca:ocpp:uid:1:569373\r\nDate and Time after which the token must be considered invalid.\r\n", + "type": "string", + "format": "date-time" + }, + "chargingPriority": { + "description": "Priority from a business point of view. Default priority is 0, The range is from -9 to 9. Higher values indicate a higher priority. The chargingPriority in <<transactioneventresponse,TransactionEventResponse>> overrules this one. \r\n", + "type": "integer" + }, + "language1": { + "description": "ID_ Token. Language1. Language_ Code\r\nurn:x-oca:ocpp:uid:1:569374\r\nPreferred user interface language of identifier user. Contains a language code as defined in <<ref-RFC5646,[RFC5646]>>.\r\n\r\n", + "type": "string", + "maxLength": 8 + }, + "evseId": { + "description": "Only used when the IdToken is only valid for one or more specific EVSEs, not for the entire Charging Station.\r\n\r\n", + "type": "array", + "additionalItems": false, + "items": { + "type": "integer" + }, + "minItems": 1 + }, + "groupIdToken": { + "$ref": "#/definitions/IdTokenType" + }, + "language2": { + "description": "ID_ Token. Language2. Language_ Code\r\nurn:x-oca:ocpp:uid:1:569375\r\nSecond preferred user interface language of identifier user. Don’t use when language1 is omitted, has to be different from language1. Contains a language code as defined in <<ref-RFC5646,[RFC5646]>>.\r\n", + "type": "string", + "maxLength": 8 + }, + "personalMessage": { + "$ref": "#/definitions/MessageContentType" + } + }, + "required": [ + "status" + ] + }, + "IdTokenType": { + "description": "Contains a case insensitive identifier to use for the authorization and the type of authorization to support multiple forms of identifiers.\r\n", + "javaType": "IdToken", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "additionalInfo": { + "type": "array", + "additionalItems": false, + "items": { + "$ref": "#/definitions/AdditionalInfoType" + }, + "minItems": 1 + }, + "idToken": { + "description": "IdToken is case insensitive. Might hold the hidden id of an RFID tag, but can for example also contain a UUID.\r\n", + "type": "string", + "maxLength": 36 + }, + "type": { + "$ref": "#/definitions/IdTokenEnumType" + } + }, + "required": [ + "idToken", + "type" + ] + }, + "MessageContentType": { + "description": "Message_ Content\r\nurn:x-enexis:ecdm:uid:2:234490\r\nContains message details, for a message to be displayed on a Charging Station.\r\n\r\n", + "javaType": "MessageContent", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "format": { + "$ref": "#/definitions/MessageFormatEnumType" + }, + "language": { + "description": "Message_ Content. Language. Language_ Code\r\nurn:x-enexis:ecdm:uid:1:570849\r\nMessage language identifier. Contains a language code as defined in <<ref-RFC5646,[RFC5646]>>.\r\n", + "type": "string", + "maxLength": 8 + }, + "content": { + "description": "Message_ Content. Content. Message\r\nurn:x-enexis:ecdm:uid:1:570852\r\nMessage contents.\r\n\r\n", + "type": "string", + "maxLength": 512 + } + }, + "required": [ + "format", + "content" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "totalCost": { + "description": "SHALL only be sent when charging has ended. Final total cost of this transaction, including taxes. In the currency configured with the Configuration Variable: <<configkey-currency,`Currency`>>. When omitted, the transaction was NOT free. To indicate a free transaction, the CSMS SHALL send 0.00.\r\n\r\n", + "type": "number" + }, + "chargingPriority": { + "description": "Priority from a business point of view. Default priority is 0, The range is from -9 to 9. Higher values indicate a higher priority. The chargingPriority in <<transactioneventresponse,TransactionEventResponse>> is temporarily, so it may not be set in the <<cmn_idtokeninfotype,IdTokenInfoType>> afterwards. Also the chargingPriority in <<transactioneventresponse,TransactionEventResponse>> overrules the one in <<cmn_idtokeninfotype,IdTokenInfoType>>. \r\n", + "type": "integer" + }, + "idTokenInfo": { + "$ref": "#/definitions/IdTokenInfoType" + }, + "updatedPersonalMessage": { + "$ref": "#/definitions/MessageContentType" + } + } +} \ No newline at end of file diff --git a/schemas/ocpp20/TriggerMessageRequest.json b/schemas/ocpp20/TriggerMessageRequest.json new file mode 100644 index 00000000..6e4f2398 --- /dev/null +++ b/schemas/ocpp20/TriggerMessageRequest.json @@ -0,0 +1,78 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:TriggerMessageRequest", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "MessageTriggerEnumType": { + "description": "Type of message to be triggered.\r\n", + "javaType": "MessageTriggerEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "BootNotification", + "LogStatusNotification", + "FirmwareStatusNotification", + "Heartbeat", + "MeterValues", + "SignChargingStationCertificate", + "SignV2GCertificate", + "StatusNotification", + "TransactionEvent", + "SignCombinedCertificate", + "PublishFirmwareStatusNotification" + ] + }, + "EVSEType": { + "description": "EVSE\r\nurn:x-oca:ocpp:uid:2:233123\r\nElectric Vehicle Supply Equipment\r\n", + "javaType": "EVSE", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "id": { + "description": "Identified_ Object. MRID. Numeric_ Identifier\r\nurn:x-enexis:ecdm:uid:1:569198\r\nEVSE Identifier. This contains a number (> 0) designating an EVSE of the Charging Station.\r\n", + "type": "integer" + }, + "connectorId": { + "description": "An id to designate a specific connector (on an EVSE) by connector index number.\r\n", + "type": "integer" + } + }, + "required": [ + "id" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "evse": { + "$ref": "#/definitions/EVSEType" + }, + "requestedMessage": { + "$ref": "#/definitions/MessageTriggerEnumType" + } + }, + "required": [ + "requestedMessage" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/TriggerMessageResponse.json b/schemas/ocpp20/TriggerMessageResponse.json new file mode 100644 index 00000000..ae88e5e2 --- /dev/null +++ b/schemas/ocpp20/TriggerMessageResponse.json @@ -0,0 +1,72 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:TriggerMessageResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "TriggerMessageStatusEnumType": { + "description": "Indicates whether the Charging Station will send the requested notification or not.\r\n", + "javaType": "TriggerMessageStatusEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Accepted", + "Rejected", + "NotImplemented" + ] + }, + "StatusInfoType": { + "description": "Element providing more information about the status.\r\n", + "javaType": "StatusInfo", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "reasonCode": { + "description": "A predefined code for the reason why the status is returned in this response. The string is case-insensitive.\r\n", + "type": "string", + "maxLength": 20 + }, + "additionalInfo": { + "description": "Additional text to provide detailed information.\r\n", + "type": "string", + "maxLength": 512 + } + }, + "required": [ + "reasonCode" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "status": { + "$ref": "#/definitions/TriggerMessageStatusEnumType" + }, + "statusInfo": { + "$ref": "#/definitions/StatusInfoType" + } + }, + "required": [ + "status" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/UnlockConnectorRequest.json b/schemas/ocpp20/UnlockConnectorRequest.json new file mode 100644 index 00000000..91629252 --- /dev/null +++ b/schemas/ocpp20/UnlockConnectorRequest.json @@ -0,0 +1,40 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:UnlockConnectorRequest", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "evseId": { + "description": "This contains the identifier of the EVSE for which a connector needs to be unlocked.\r\n", + "type": "integer" + }, + "connectorId": { + "description": "This contains the identifier of the connector that needs to be unlocked.\r\n", + "type": "integer" + } + }, + "required": [ + "evseId", + "connectorId" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/UnlockConnectorResponse.json b/schemas/ocpp20/UnlockConnectorResponse.json new file mode 100644 index 00000000..79d8b6e0 --- /dev/null +++ b/schemas/ocpp20/UnlockConnectorResponse.json @@ -0,0 +1,73 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:UnlockConnectorResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "UnlockStatusEnumType": { + "description": "This indicates whether the Charging Station has unlocked the connector.\r\n", + "javaType": "UnlockStatusEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Unlocked", + "UnlockFailed", + "OngoingAuthorizedTransaction", + "UnknownConnector" + ] + }, + "StatusInfoType": { + "description": "Element providing more information about the status.\r\n", + "javaType": "StatusInfo", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "reasonCode": { + "description": "A predefined code for the reason why the status is returned in this response. The string is case-insensitive.\r\n", + "type": "string", + "maxLength": 20 + }, + "additionalInfo": { + "description": "Additional text to provide detailed information.\r\n", + "type": "string", + "maxLength": 512 + } + }, + "required": [ + "reasonCode" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "status": { + "$ref": "#/definitions/UnlockStatusEnumType" + }, + "statusInfo": { + "$ref": "#/definitions/StatusInfoType" + } + }, + "required": [ + "status" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/UnpublishFirmwareRequest.json b/schemas/ocpp20/UnpublishFirmwareRequest.json new file mode 100644 index 00000000..5f463250 --- /dev/null +++ b/schemas/ocpp20/UnpublishFirmwareRequest.json @@ -0,0 +1,36 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:UnpublishFirmwareRequest", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "checksum": { + "description": "The MD5 checksum over the entire firmware file as a hexadecimal string of length 32. \r\n", + "type": "string", + "maxLength": 32 + } + }, + "required": [ + "checksum" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/UnpublishFirmwareResponse.json b/schemas/ocpp20/UnpublishFirmwareResponse.json new file mode 100644 index 00000000..6e078087 --- /dev/null +++ b/schemas/ocpp20/UnpublishFirmwareResponse.json @@ -0,0 +1,45 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:UnpublishFirmwareResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "UnpublishFirmwareStatusEnumType": { + "description": "Indicates whether the Local Controller succeeded in unpublishing the firmware.\r\n", + "javaType": "UnpublishFirmwareStatusEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "DownloadOngoing", + "NoFirmware", + "Unpublished" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "status": { + "$ref": "#/definitions/UnpublishFirmwareStatusEnumType" + } + }, + "required": [ + "status" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/UpdateFirmwareRequest.json b/schemas/ocpp20/UpdateFirmwareRequest.json new file mode 100644 index 00000000..2c008d29 --- /dev/null +++ b/schemas/ocpp20/UpdateFirmwareRequest.json @@ -0,0 +1,87 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:UpdateFirmwareRequest", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "FirmwareType": { + "description": "Firmware\r\nurn:x-enexis:ecdm:uid:2:233291\r\nRepresents a copy of the firmware that can be loaded/updated on the Charging Station.\r\n", + "javaType": "Firmware", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "location": { + "description": "Firmware. Location. URI\r\nurn:x-enexis:ecdm:uid:1:569460\r\nURI defining the origin of the firmware.\r\n", + "type": "string", + "maxLength": 512 + }, + "retrieveDateTime": { + "description": "Firmware. Retrieve. Date_ Time\r\nurn:x-enexis:ecdm:uid:1:569461\r\nDate and time at which the firmware shall be retrieved.\r\n", + "type": "string", + "format": "date-time" + }, + "installDateTime": { + "description": "Firmware. Install. Date_ Time\r\nurn:x-enexis:ecdm:uid:1:569462\r\nDate and time at which the firmware shall be installed.\r\n", + "type": "string", + "format": "date-time" + }, + "signingCertificate": { + "description": "Certificate with which the firmware was signed.\r\nPEM encoded X.509 certificate.\r\n", + "type": "string", + "maxLength": 5500 + }, + "signature": { + "description": "Firmware. Signature. Signature\r\nurn:x-enexis:ecdm:uid:1:569464\r\nBase64 encoded firmware signature.\r\n", + "type": "string", + "maxLength": 800 + } + }, + "required": [ + "location", + "retrieveDateTime" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "retries": { + "description": "This specifies how many times Charging Station must try to download the firmware before giving up. If this field is not present, it is left to Charging Station to decide how many times it wants to retry.\r\n", + "type": "integer" + }, + "retryInterval": { + "description": "The interval in seconds after which a retry may be attempted. If this field is not present, it is left to Charging Station to decide how long to wait between attempts.\r\n", + "type": "integer" + }, + "requestId": { + "description": "The Id of this request\r\n", + "type": "integer" + }, + "firmware": { + "$ref": "#/definitions/FirmwareType" + } + }, + "required": [ + "requestId", + "firmware" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/UpdateFirmwareResponse.json b/schemas/ocpp20/UpdateFirmwareResponse.json new file mode 100644 index 00000000..9a201a92 --- /dev/null +++ b/schemas/ocpp20/UpdateFirmwareResponse.json @@ -0,0 +1,74 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:2:2020:3:UpdateFirmwareResponse", + "comment": "OCPP 2.0.1 FINAL", + "definitions": { + "CustomDataType": { + "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.", + "javaType": "CustomData", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "vendorId" + ] + }, + "UpdateFirmwareStatusEnumType": { + "description": "This field indicates whether the Charging Station was able to accept the request.\r\n\r\n", + "javaType": "UpdateFirmwareStatusEnum", + "type": "string", + "additionalProperties": false, + "enum": [ + "Accepted", + "Rejected", + "AcceptedCanceled", + "InvalidCertificate", + "RevokedCertificate" + ] + }, + "StatusInfoType": { + "description": "Element providing more information about the status.\r\n", + "javaType": "StatusInfo", + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "reasonCode": { + "description": "A predefined code for the reason why the status is returned in this response. The string is case-insensitive.\r\n", + "type": "string", + "maxLength": 20 + }, + "additionalInfo": { + "description": "Additional text to provide detailed information.\r\n", + "type": "string", + "maxLength": 512 + } + }, + "required": [ + "reasonCode" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "customData": { + "$ref": "#/definitions/CustomDataType" + }, + "status": { + "$ref": "#/definitions/UpdateFirmwareStatusEnumType" + }, + "statusInfo": { + "$ref": "#/definitions/StatusInfoType" + } + }, + "required": [ + "status" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/device_model_schema.json b/schemas/ocpp20/device_model_schema.json new file mode 100755 index 00000000..38866d95 --- /dev/null +++ b/schemas/ocpp20/device_model_schema.json @@ -0,0 +1,225 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "urn:OpenOCPP:2.0.1:DeviceModel", + "comment": "OCPP 2.0.1 Device Model", + "definitions": + { + "ComponentType": + { + "$comment": "Defines a component in the device model", + "type": "object", + "additionalProperties": false, + "properties": + { + "name": + { + "$comment": "Name of the component", + "type": "string", + "minLength": 1, + "maxLength": 50 + }, + "evse": + { + "$comment": "Id of the EVSE associated with the variable", + "type": "integer", + "minimum": 1 + }, + "connector": + { + "$comment": "Id of the connector associated with the variable", + "type": "integer", + "minimum": 1 + }, + "instance": + { + "$comment": "Instance of the variable", + "type": "string", + "minLength": 1, + "maxLength": 50 + }, + "variables": + { + "$comment": "List of the variables included in the components", + "type": "array", + "items": { + "$ref": "#/definitions/VariableType" + }, + "minItems": 1 + } + }, + "required": [ + "name", + "variables" + ] + }, + "VariableType": + { + "$comment": "Defines a variable of a component in the device model", + "type": "object", + "additionalProperties": false, + "properties": + { + "name": + { + "$comment": "Name of the variable", + "type": "string", + "minLength": 1, + "maxLength": 50 + }, + "instance": + { + "$comment": "Instance of the variable", + "type": "string", + "minLength": 1, + "maxLength": 50 + }, + "attributes": + { + "$comment": "Attributes of the variable", + "type": "object", + "additionalProperties": false, + "properties": + { + "type": + { + "$ref": "#/definitions/AttributeEnumType", + "default": "actual" + }, + "mutability": + { + "$ref": "#/definitions/MutabilityEnumType" + }, + "persistent": + { + "$comment": "If true, value will be persistent across system reboots or power down", + "type": "boolean", + "default": true + }, + "constant": + { + "$comment": "If true, value that will never be changed by the Charging Station at runtime", + "type": "boolean", + "default": false + } + }, + "required": [ + "mutability" + ] + }, + "characteristics": + { + "$comment": "Characteristics of the variable", + "type": "object", + "additionalProperties": false, + "properties": + { + "data_type": + { + "$ref": "#/definitions/DataTypeEnumType" + }, + "unit": + { + "$comment": "Unit of the variable", + "type": "string", + "minLength": 1, + "maxLength": 16 + }, + "min_limit": + { + "$comment": "Minimum possible value of the variable", + "type": "number" + }, + "max_limit": + { + "$comment": "Maximum possible value of the variable. When the data_type of this Variable is String, OptionList, SequenceList or MemberList, this field defines the maximum length of the (CSV) string.", + "type": "number" + }, + "values_list": + { + "$comment": "Mandatory when dataType = OptionList, MemberList or SequenceList. valuesList specifies the allowed values for the type", + "type": "string", + "minLength": 0, + "maxLength": 1000 + }, + "supports_monitoring": + { + "$comment": "Flag indicating if this variable supports monitoring", + "type": "boolean", + "default": true + } + }, + "required": [ + "data_type" + ] + }, + "required": + { + "$comment": "Flag indicating if this variable is mandatory by the OCPP standard. Ignored by the Open OCPP stack.", + "type": "boolean" + } + }, + "required": [ + "name", + "attributes", + "characteristics" + ] + }, + "AttributeEnumType": + { + "$comment": "Mutability of a variable", + "type": "string", + "additionalProperties": false, + "enum": [ + "Actual", + "Target", + "MinSet", + "MaxSet" + ] + }, + "MutabilityEnumType": + { + "$comment": "Mutability of a variable", + "type": "string", + "additionalProperties": false, + "enum": [ + "ReadOnly", + "WriteOnly", + "ReadWrite" + ] + }, + "DataTypeEnumType": + { + "$comment": "Data type of a variable", + "type": "string", + "additionalProperties": false, + "enum": [ + "string", + "decimal", + "integer", + "dateTime", + "boolean", + "OptionList", + "SequenceList", + "MemberList" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": + { + "components": + { + "$comment": "List of components", + "type": "array", + "items": + { + "$ref": "#/definitions/ComponentType" + }, + "minItems": 1 + } + }, + "required": [ + "components" + ] +} \ No newline at end of file diff --git a/schemas/ocpp20/list.json b/schemas/ocpp20/list.json new file mode 100644 index 00000000..7daceacc --- /dev/null +++ b/schemas/ocpp20/list.json @@ -0,0 +1,71 @@ +{ + "from_csms": [ + "CancelReservation", + "CertificateSigned", + "ChangeAvailability", + "ClearCache", + "ClearChargingProfile", + "ClearDisplayMessage", + "ClearVariableMonitoring", + "CustomerInformation", + "DataTransfer", + "DeleteCertificate", + "Get15118EVCertificate", + "GetBaseReport", + "GetCertificateStatus", + "GetChargingProfiles", + "GetCompositeSchedule", + "GetDisplayMessages", + "GetInstalledCertificateIds", + "GetLocalListVersion", + "GetLog", + "GetMonitoringReport", + "GetReport", + "GetTransactionStatus", + "GetVariables", + "InstallCertificate", + "PublishFirmware", + "RequestStartTransaction", + "RequestStopTransaction", + "ReserveNow", + "Reset", + "SendLocalList", + "SetChargingProfile", + "SetDisplayMessage", + "SetMonitoringBase", + "SetMonitoringLevel", + "SetNetworkProfile", + "SetVariableMonitoring", + "SetVariables", + "TriggerMessage", + "UnlockConnector", + "UnpublishFirmware", + "UpdateFirmware" + ], + "from_cs": [ + "BootNotification", + "Authorize", + "ClearedChargingLimit", + "CostUpdated", + "DataTransfer", + "FirmwareStatusNotification", + "Heartbeat", + "LogStatusNotification", + "MeterValues", + "NotifyChargingLimit", + "NotifyCustomerInformation", + "NotifyDisplayMessages", + "NotifyEVChargingNeeds", + "NotifyEVChargingSchedule", + "NotifyEvent", + "NotifyMonitoringReport", + "NotifyReport", + "PublishFirmwareStatusNotification", + "ReportChargingProfiles", + "ReservationStatusUpdate", + "SecurityEventNotification", + "SignCertificate", + "StatusNotification", + "TransactionEvent" + ] +} \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6ac08978..3944f771 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,10 +1,8 @@ # Subdirectories -add_subdirectory(centralsystem) -add_subdirectory(chargepoint) -add_subdirectory(config) -add_subdirectory(localcontroller) add_subdirectory(messages) +add_subdirectory(ocpp16) +add_subdirectory(ocpp20) add_subdirectory(rpc) add_subdirectory(tools) add_subdirectory(types) diff --git a/src/localcontroller/centralsystem/CentralSystemProxy.h b/src/localcontroller/centralsystem/CentralSystemProxy.h deleted file mode 100644 index bef9a768..00000000 --- a/src/localcontroller/centralsystem/CentralSystemProxy.h +++ /dev/null @@ -1,504 +0,0 @@ -/* -Copyright (c) 2020 Cedric Jimenez -This file is part of OpenOCPP. - -OpenOCPP is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation, either version 2.1 of the License, or -(at your option) any later version. - -OpenOCPP is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with OpenOCPP. If not, see . -*/ - -#ifndef OPENOCPP_CENTRALSYSTEMPROXY_H -#define OPENOCPP_CENTRALSYSTEMPROXY_H - -#include "CentralSystemHandler.h" -#include "GenericMessageSender.h" -#include "ICentralSystemProxy.h" -#include "MessageDispatcher.h" -#include "MessagesValidator.h" -#include "RpcClient.h" -#include "UserMessageHandler.h" - -namespace ocpp -{ -namespace config -{ -class ILocalControllerConfig; -} // namespace config -namespace rpc -{ -class RpcPool; -} // namespace rpc - -namespace localcontroller -{ - -/** @brief Central system proxy */ -class CentralSystemProxy : public ICentralSystemProxy, - public ocpp::rpc::IRpc::IListener, - public ocpp::rpc::IRpc::ISpy, - public ocpp::rpc::RpcClient::IListener -{ - public: - /** - * @brief Constructor - * @param identifier Charge point's identifier - * @param messages_validator JSON schemas needed to validate payloads - * @param messages_converter Converter from/to OCPP to/from JSON messages - * @param stack_config Stack configuration - * @param rpc_pool RPC pool - */ - CentralSystemProxy(const std::string& identifier, - const ocpp::messages::MessagesValidator& messages_validator, - ocpp::messages::MessagesConverter& messages_converter, - const ocpp::config::ILocalControllerConfig& stack_config, - ocpp::rpc::RpcPool& rpc_pool); - - /** @brief Destructor */ - virtual ~CentralSystemProxy(); - - /** - * @brief Set the proxy to forward requests to the charge point - * @param central_system Proxy to forward requests to the charge point - */ - void setChargePointProxy(std::weak_ptr charge_point) - { - m_charge_point = charge_point; - m_handler.setChargePointProxy(charge_point); - } - - /** @copydoc const std::string& ICentralSystemProxy::disconnect() const */ - const std::string& identifier() const override { return m_identifier; } - - /** @copydoc void ICentralSystemProxy::setTimeout(std::chrono::milliseconds) */ - void setTimeout(std::chrono::milliseconds timeout) override; - - /** @copydoc bool ICentralSystemProxy::connect(const std::string&, - const ocpp::websockets::IWebsocketClient::Credentials&, - std::chrono::milliseconds, - std::chrono::milliseconds, - std::chrono::milliseconds) */ - bool connect(const std::string& url, - const ocpp::websockets::IWebsocketClient::Credentials& credentials, - std::chrono::milliseconds connect_timeout, - std::chrono::milliseconds retry_interval, - std::chrono::milliseconds ping_interval) override; - - /** @copydoc void ICentralSystemProxy::disconnect() */ - void disconnect() override; - - /** @brief Indicate if the connection with the central system is active */ - bool isConnected() const override; - - /** @copydoc void ICentralSystemProxy::registerListener(ILocalControllerProxyEventsHandler&) */ - void registerListener(ILocalControllerProxyEventsHandler& listener) override { m_listener = &listener; } - - /** @copydoc bool ICentralSystemProxy::call(const ocpp::messages::BootNotificationReq&, - * ocpp::messages::BootNotificationConf&, - * std::string&, - * std::string&) */ - bool call(const ocpp::messages::BootNotificationReq& request, - ocpp::messages::BootNotificationConf& response, - std::string& error, - std::string& message) override; - - /** @copydoc bool ICentralSystemProxy::call(const ocpp::messages::StatusNotificationReq&, - * ocpp::messages::StatusNotificationConf&, - * std::string&, - * std::string&) */ - bool call(const ocpp::messages::StatusNotificationReq& request, - ocpp::messages::StatusNotificationConf& response, - std::string& error, - std::string& message) override; - - /** @copydoc bool ICentralSystemProxy::call(const ocpp::messages::AuthorizeReq&, - * ocpp::messages::AuthorizeConf&, - * std::string&, - * std::string&) */ - bool call(const ocpp::messages::AuthorizeReq& request, - ocpp::messages::AuthorizeConf& response, - std::string& error, - std::string& message) override; - - /** @copydoc bool ICentralSystemProxy::call(const ocpp::messages::StartTransactionReq&, - * ocpp::messages::StartTransactionConf&, - * std::string&, - * std::string&) */ - bool call(const ocpp::messages::StartTransactionReq& request, - ocpp::messages::StartTransactionConf& response, - std::string& error, - std::string& message) override; - - /** @copydoc bool ICentralSystemProxy::call(const ocpp::messages::StopTransactionReq&, - * ocpp::messages::StopTransactionConf&, - * std::string&, - * std::string&) */ - bool call(const ocpp::messages::StopTransactionReq& request, - ocpp::messages::StopTransactionConf& response, - std::string& error, - std::string& message) override; - - /** @copydoc bool ICentralSystemProxy::call(const ocpp::messages::DataTransferReq&, - * ocpp::messages::DataTransferConf&, - * std::string&, - * std::string&) */ - bool call(const ocpp::messages::DataTransferReq& request, - ocpp::messages::DataTransferConf& response, - std::string& error, - std::string& message) override; - - /** @copydoc bool ICentralSystemProxy::call(const ocpp::messages::MeterValuesReq&, - * ocpp::messages::MeterValuesConf&, - * std::string&, - * std::string&) */ - bool call(const ocpp::messages::MeterValuesReq& request, - ocpp::messages::MeterValuesConf& response, - std::string& error, - std::string& message) override; - - /** @copydoc bool ICentralSystemProxy::call(const ocpp::messages::DiagnosticsStatusNotificationReq&, - * ocpp::messages::DiagnosticsStatusNotificationConf&, - * std::string&, - * std::string&) */ - bool call(const ocpp::messages::DiagnosticsStatusNotificationReq& request, - ocpp::messages::DiagnosticsStatusNotificationConf& response, - std::string& error, - std::string& message) override; - - /** @copydoc bool ICentralSystemProxy::call(const ocpp::messages::FirmwareStatusNotificationReq&, - * ocpp::messages::FirmwareStatusNotificationConf&, - * std::string&, - * std::string&) */ - bool call(const ocpp::messages::FirmwareStatusNotificationReq& request, - ocpp::messages::FirmwareStatusNotificationConf& response, - std::string& error, - std::string& message) override; - - /** @copydoc bool ICentralSystemProxy::call(const ocpp::messages::HeartbeatReq&, - * ocpp::messages::HeartbeatConf&, - * std::string&, - * std::string&) */ - bool call(const ocpp::messages::HeartbeatReq& request, - ocpp::messages::HeartbeatConf& response, - std::string& error, - std::string& message) override; - - // Security extensions - - /** @copydoc bool ICentralSystemProxy::call(const ocpp::messages::SecurityEventNotificationReq&, - * ocpp::messages::SecurityEventNotificationConf&, - * std::string&, - * std::string&) */ - bool call(const ocpp::messages::SecurityEventNotificationReq& request, - ocpp::messages::SecurityEventNotificationConf& response, - std::string& error, - std::string& message) override; - - /** @copydoc bool ICentralSystemProxy::call(const ocpp::messages::SignCertificateReq&, - * ocpp::messages::SignCertificateConf&, - * std::string&, - * std::string&) */ - bool call(const ocpp::messages::SignCertificateReq& request, - ocpp::messages::SignCertificateConf& response, - std::string& error, - std::string& message) override; - - /** @copydoc bool ICentralSystemProxy::call(const ocpp::messages::LogStatusNotificationReq&, - * ocpp::messages::LogStatusNotificationConf&, - * std::string&, - * std::string&) */ - bool call(const ocpp::messages::LogStatusNotificationReq& request, - ocpp::messages::LogStatusNotificationConf& response, - std::string& error, - std::string& message) override; - - /** @copydoc bool ICentralSystemProxy::call(const ocpp::messages::SignedFirmwareStatusNotificationReq&, - * ocpp::messages::SignedFirmwareStatusNotificationConf&, - * std::string&, - * std::string&) */ - bool call(const ocpp::messages::SignedFirmwareStatusNotificationReq& request, - ocpp::messages::SignedFirmwareStatusNotificationConf& response, - std::string& error, - std::string& message) override; - - /** @copydoc bool ICentralSystemProxy::registerHandler( - std::function) */ - bool registerHandler( - std::function - handler) override; - - /** @copydoc bool ICentralSystemProxy::registerHandler( - std::function) */ - bool registerHandler( - std::function handler) - override; - - /** @copydoc bool ICentralSystemProxy::registerHandler( - std::function) */ - bool registerHandler( - std::function handler) - override; - - /** @copydoc bool ICentralSystemProxy::registerHandler( - std::function) */ - bool registerHandler( - std::function handler) - override; - - /** @copydoc bool ICentralSystemProxy::registerHandler( - std::function) */ - bool registerHandler( - std::function handler) - override; - - /** @copydoc bool ICentralSystemProxy::registerHandler( - std::function) */ - bool registerHandler( - std::function handler) - override; - - /** @copydoc bool ICentralSystemProxy::registerHandler( - std::function) */ - bool registerHandler( - std::function handler) - override; - - /** @copydoc bool ICentralSystemProxy::registerHandler( - std::function) */ - bool registerHandler( - std::function - handler) override; - - /** @copydoc bool ICentralSystemProxy::registerHandler( - std::function) */ - bool registerHandler( - std::function - handler) override; - - /** @copydoc bool ICentralSystemProxy::registerHandler( - std::function) */ - bool registerHandler( - std::function handler) - override; - - /** @copydoc bool ICentralSystemProxy::registerHandler( - std::function) */ - bool registerHandler( - std::function< - bool(const ocpp::messages::RemoteStartTransactionReq&, ocpp::messages::RemoteStartTransactionConf&, std::string&, std::string&)> - handler) override; - - /** @copydoc bool ICentralSystemProxy::registerHandler( - std::function) */ - bool registerHandler( - std::function< - bool(const ocpp::messages::RemoteStopTransactionReq&, ocpp::messages::RemoteStopTransactionConf&, std::string&, std::string&)> - handler) override; - - /** @copydoc bool ICentralSystemProxy::registerHandler( - std::function) */ - bool registerHandler( - std::function handler) - override; - - /** @copydoc bool ICentralSystemProxy::registerHandler( - std::function) */ - bool registerHandler( - std::function handler) override; - - /** @copydoc bool ICentralSystemProxy::registerHandler( - std::function) */ - bool registerHandler( - std::function - handler) override; - - /** @copydoc bool ICentralSystemProxy::registerHandler( - std::function) */ - bool registerHandler( - std::function handler) - override; - - /** @copydoc bool ICentralSystemProxy::registerHandler( - std::function) */ - bool registerHandler( - std::function - handler) override; - - /** @copydoc bool ICentralSystemProxy::registerHandler( - std::function) */ - bool registerHandler( - std::function - handler) override; - - /** @copydoc bool ICentralSystemProxy::registerHandler( - std::function) */ - bool registerHandler( - std::function - handler) override; - - /** @copydoc bool ICentralSystemProxy::registerHandler( - std::function) */ - bool registerHandler( - std::function - handler) override; - - /** @copydoc bool ICentralSystemProxy::registerHandler( - std::function) */ - bool registerHandler( - std::function - handler) override; - - /** @copydoc bool ICentralSystemProxy::registerHandler( - std::function) */ - bool registerHandler( - std::function< - bool(const ocpp::messages::ExtendedTriggerMessageReq&, ocpp::messages::ExtendedTriggerMessageConf&, std::string&, std::string&)> - handler) override; - - /** @copydoc bool ICentralSystemProxy::registerHandler( - std::function) */ - bool registerHandler(std::function handler) override; - - /** @copydoc bool ICentralSystemProxy::registerHandler( - std::function) */ - bool registerHandler( - std::function handler) override; - - /** @copydoc bool ICentralSystemProxy::registerHandler( - std::function) */ - bool registerHandler( - std::function handler) - override; - - /** @copydoc bool ICentralSystemProxy::registerHandler( - std::function) */ - bool registerHandler( - std::function handler) - override; - - // IRpc::IListener interface - - /** @copydoc void IRpc::IListener::rpcDisconnected() */ - void rpcDisconnected() override; - - /** @copydoc void IRpc::IListener::rpcError() */ - void rpcError() override; - - /** @copydoc bool IRpc::IListener::rpcCallReceived(const std::string&, - const rapidjson::Value&, - rapidjson::Document&, - std::string&, - std::string&) */ - bool rpcCallReceived(const std::string& action, - const rapidjson::Value& payload, - rapidjson::Document& response, - std::string& error_code, - std::string& error_message) override; - - // IRpc::ISpy interface - - /** @copydoc void IRpc::ISpy::rcpMessageReceived(const std::string& msg) */ - void rcpMessageReceived(const std::string& msg) override; - - /** @copydoc void IRpc::ISpy::rcpMessageSent(const std::string& msg) */ - void rcpMessageSent(const std::string& msg) override; - - // RpcClient::IListener interface - - /** @brief Called when connection is successfull */ - void rpcClientConnected() override; - - /** @brief Called when connection failed */ - void rpcClientFailed() override; - - private: - /** @brief Charge point's identifier */ - std::string m_identifier; - /** @brief Stack configuration */ - const ocpp::config::ILocalControllerConfig& m_stack_config; - /** @brief Client websocket */ - std::unique_ptr m_websocket; - /** @brief RPC connection */ - ocpp::rpc::RpcClient m_rpc; - /** @brief Messages converter */ - ocpp::messages::MessagesConverter& m_messages_converter; - /** @brief Message dispatcher */ - ocpp::messages::MessageDispatcher m_msg_dispatcher; - /** @brief Message sender */ - ocpp::messages::GenericMessageSender m_msg_sender; - /** @brief Request handler */ - CentralSystemHandler m_handler; - /** @brief Proxy to forward requests to the charge point */ - std::weak_ptr m_charge_point; - /** @brief Listener to the proxy events */ - ILocalControllerProxyEventsHandler* m_listener; - /** @brief User message handlers */ - std::vector> m_user_handlers; - - /** - * @brief Execute a call request - * @param action RPC action for the request - * @param request Request payload - * @param response Response payload - * @param error Error (Empty if not a CallError) - * @param message Error message (Empty if not a CallError) - * @return true if the request has been sent and a response has been received, false otherwise - */ - template - bool call(const std::string& action, const RequestType& request, ResponseType& response, std::string& error, std::string& message) - { - bool ret = true; - - LOG_DEBUG << "[" << m_identifier << "] - " << action; - - ocpp::messages::CallResult res = m_msg_sender.call(action, request, response, error, message); - if (res != ocpp::messages::CallResult::Ok) - { - LOG_ERROR << "[" << m_identifier << "] - " << action << " => " - << (res == ocpp::messages::CallResult::Failed ? "Timeout" : "Error"); - ret = false; - } - - return ret; - } - - /** - * @brief Register a user handler for an incoming request - * @param action RPC action for the request - * @param handler Handler function - * @return true if the handler has been registered, false otherwise - */ - template - bool registerHandler(const std::string& action, - std::function handler) - { - UserMessageHandler* msg_handler = - new UserMessageHandler(action, m_messages_converter, handler); - m_user_handlers.push_back(std::shared_ptr(msg_handler)); - return m_msg_dispatcher.registerHandler(action, *msg_handler, true); - } -}; - -} // namespace localcontroller -} // namespace ocpp - -#endif // OPENOCPP_CENTRALSYSTEMPROXY_H diff --git a/src/messages/CMakeLists.txt b/src/messages/CMakeLists.txt index 59908062..f168dc57 100644 --- a/src/messages/CMakeLists.txt +++ b/src/messages/CMakeLists.txt @@ -6,64 +6,7 @@ # Library target add_library(messages OBJECT MessageDispatcher.cpp - MessagesConverter.cpp - MessagesValidator.cpp - - Authorize.cpp - BootNotification.cpp - CancelReservation.cpp - CertificateSigned.cpp - ChangeAvailability.cpp - ChangeConfiguration.cpp - ClearCache.cpp - ClearChargingProfile.cpp - DataTransfer.cpp - DeleteCertificate.cpp - DiagnosticsStatusNotification.cpp - ExtendedTriggerMessage.cpp - FirmwareStatusNotification.cpp - GetConfiguration.cpp - Get15118EVCertificate.cpp - GetCertificateStatus.cpp - GetCompositeSchedule.cpp - GetDiagnostics.cpp - GetInstalledCertificateIds.cpp - GetLocalListVersion.cpp - GetLog.cpp - Heartbeat.cpp - InstallCertificate.cpp - Iso15118Authorize.cpp - Iso15118GetInstalledCertificateIds.cpp - Iso15118InstallCertificate.cpp - Iso15118TriggerMessage.cpp - LogStatusNotification.cpp - MeterValues.cpp - RemoteStartTransaction.cpp - RemoteStopTransaction.cpp - ReserveNow.cpp - Reset.cpp - SecurityEventNotification.cpp - SendLocalList.cpp - SetChargingProfile.cpp - SignCertificate.cpp - SignedFirmwareStatusNotification.cpp - SignedUpdateFirmware.cpp - StartTransaction.cpp - StatusNotification.cpp - StopTransaction.cpp - TriggerMessage.cpp - UnlockConnector.cpp - UpdateFirmware.cpp - - types/AuthorizationDataConverter.cpp - types/CertificateHashDataChainTypeConverter.cpp - types/CertificateHashDataTypeConverter.cpp - types/ChargingProfileConverter.cpp - types/ChargingScheduleConverter.cpp - types/IdTagInfoConverter.cpp - types/IdTokenInfoTypeConverter.cpp - types/MeterValueConverter.cpp - types/OcspRequestDataTypeConverter.cpp + GenericMessageSender.cpp ) # Exported includes diff --git a/src/messages/GenericMessageSender.cpp b/src/messages/GenericMessageSender.cpp new file mode 100644 index 00000000..f74c225d --- /dev/null +++ b/src/messages/GenericMessageSender.cpp @@ -0,0 +1,31 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +#include "GenericMessageSender.h" + +namespace ocpp +{ +namespace messages +{ + +/** @brief Helper to convert a CallResult enum to string */ +const ocpp::types::EnumToStringFromString CallResultHelper = { + {CallResult::Ok, "Ok"}, {CallResult::Delayed, "Delayed"}, {CallResult::Failed, "Failed"}, {CallResult::Error, "Error"}}; + +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/messages/GenericMessageSender.h b/src/messages/GenericMessageSender.h index 9f927ec5..6e92cca7 100644 --- a/src/messages/GenericMessageSender.h +++ b/src/messages/GenericMessageSender.h @@ -19,11 +19,12 @@ along with OpenOCPP. If not, see . #ifndef OPENOCPP_GENERICMESSAGESENDER_H #define OPENOCPP_GENERICMESSAGESENDER_H +#include "EnumToStringFromString.h" +#include "GenericMessagesConverter.h" +#include "IMessagesValidator.h" #include "IRequestFifo.h" #include "IRpc.h" #include "Logger.h" -#include "MessagesConverter.h" -#include "MessagesValidator.h" namespace ocpp { @@ -43,14 +44,17 @@ enum class CallResult Error }; +/** @brief Helper to convert a CallResult enum to string */ +extern const ocpp::types::EnumToStringFromString CallResultHelper; + /** @brief Generic message sender with C++ data type to JSON conversion */ class GenericMessageSender { public: /** @brief Constructor */ GenericMessageSender(ocpp::rpc::IRpc& rpc, - MessagesConverter& messages_converter, - const MessagesValidator& messages_validator, + GenericMessagesConverter& messages_converter, + const IMessagesValidator& messages_validator, std::chrono::milliseconds timeout) : m_rpc(rpc), m_messages_converter(messages_converter), m_messages_validator(messages_validator), m_timeout(timeout) { @@ -135,8 +139,7 @@ class GenericMessageSender if (req_converter && resp_converter) { // Convert request - rapidjson::Document payload; - payload.Parse("{}"); + rapidjson::Document payload(rapidjson::kObjectType); req_converter->setAllocator(&payload.GetAllocator()); if (req_converter->toJson(request, payload)) { @@ -260,9 +263,9 @@ class GenericMessageSender /** @brief RPC */ ocpp::rpc::IRpc& m_rpc; /** @brief Messages converter */ - MessagesConverter& m_messages_converter; + GenericMessagesConverter& m_messages_converter; /** @brief Messages validator */ - const MessagesValidator& m_messages_validator; + const IMessagesValidator& m_messages_validator; /** @brief Request timeout */ std::chrono::milliseconds m_timeout; }; diff --git a/src/messages/IMessageConverter.h b/src/messages/IMessageConverter.h index 0636aaa1..f6c22b21 100644 --- a/src/messages/IMessageConverter.h +++ b/src/messages/IMessageConverter.h @@ -287,14 +287,14 @@ class IMessageConverter * @param MessageType Message type name */ #define MESSAGE_CONVERTERS(MessageType) \ - class MessageType##ReqConverter : public IMessageConverter \ + class MessageType##ReqConverter : public ocpp::messages::IMessageConverter \ { \ public: \ IMessageConverter* clone() const override { return new MessageType##ReqConverter(); } \ bool fromJson(const rapidjson::Value& json, MessageType##Req& data, std::string& error_code, std::string& error_message) override; \ bool toJson(const MessageType##Req& data, rapidjson::Document& json) override; \ }; \ - class MessageType##ConfConverter : public IMessageConverter \ + class MessageType##ConfConverter : public ocpp::messages::IMessageConverter \ { \ public: \ IMessageConverter* clone() const override { return new MessageType##ConfConverter(); } \ diff --git a/src/messages/IMessagesValidator.h b/src/messages/IMessagesValidator.h new file mode 100644 index 00000000..80331dc7 --- /dev/null +++ b/src/messages/IMessagesValidator.h @@ -0,0 +1,50 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +#ifndef OPENOCPP_IMESSAGESVALIDATOR_H +#define OPENOCPP_IMESSAGESVALIDATOR_H + +#include "JsonValidator.h" + +#include + +namespace ocpp +{ +namespace messages +{ + +/** @brief Interface for the message validators implementations */ +class IMessagesValidator +{ + public: + /** @brief Destructor */ + virtual ~IMessagesValidator() { } + + /** + * @brief Get the message validator corresponding to a given action + * @param action Action corresponding to the message + * @param is_req Indicate if the validator if for the request or the response + * @return Message validator if it exists, nullptr otherwise + */ + virtual ocpp::json::JsonValidator* getValidator(const std::string& action, bool is_req) const = 0; +}; + +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_IMESSAGESVALIDATOR_H diff --git a/src/messages/MessageDispatcher.cpp b/src/messages/MessageDispatcher.cpp index 8174366a..3841535b 100644 --- a/src/messages/MessageDispatcher.cpp +++ b/src/messages/MessageDispatcher.cpp @@ -17,10 +17,10 @@ along with OpenOCPP. If not, see . */ #include "MessageDispatcher.h" +#include "IMessagesValidator.h" #include "IRpc.h" #include "JsonValidator.h" #include "Logger.h" -#include "MessagesValidator.h" #include @@ -30,7 +30,7 @@ namespace messages { /** @brief Constructor */ -MessageDispatcher::MessageDispatcher(const MessagesValidator& messages_validator) : m_messages_validator(messages_validator), m_handlers() +MessageDispatcher::MessageDispatcher(const IMessagesValidator& messages_validator) : m_messages_validator(messages_validator), m_handlers() { } diff --git a/src/messages/MessageDispatcher.h b/src/messages/MessageDispatcher.h index 2d0d8958..4f575439 100644 --- a/src/messages/MessageDispatcher.h +++ b/src/messages/MessageDispatcher.h @@ -33,7 +33,7 @@ class JsonValidator; namespace messages { -class MessagesValidator; +class IMessagesValidator; /** @brief Messages dispatcher */ class MessageDispatcher : public IMessageDispatcher @@ -42,7 +42,7 @@ class MessageDispatcher : public IMessageDispatcher /** @brief Constructor * @param messages_validator JSON schemas needed to validate payloads */ - MessageDispatcher(const MessagesValidator& messages_validator); + MessageDispatcher(const IMessagesValidator& messages_validator); /** @brief Destructor */ virtual ~MessageDispatcher(); @@ -63,7 +63,7 @@ class MessageDispatcher : public IMessageDispatcher private: /** @brief JSON schemas needed to validate payloads */ - const MessagesValidator& m_messages_validator; + const IMessagesValidator& m_messages_validator; /** @brief Handlers */ std::unordered_map> m_handlers; }; diff --git a/src/localcontroller/UserMessageHandler.h b/src/messages/UserMessageHandler.h similarity index 78% rename from src/localcontroller/UserMessageHandler.h rename to src/messages/UserMessageHandler.h index a29fbc8a..08e7a6b0 100644 --- a/src/localcontroller/UserMessageHandler.h +++ b/src/messages/UserMessageHandler.h @@ -25,22 +25,20 @@ along with OpenOCPP. If not, see . namespace ocpp { -namespace localcontroller +namespace messages { /** @brief User message handler */ template -class UserMessageHandler : public ocpp::messages::GenericMessageHandler +class UserMessageHandler : public GenericMessageHandler { public: /** @brief Message handler function*/ typedef std::function HandlerFunc; /** @brief Constructor */ - UserMessageHandler(const std::string& action, - const ocpp::messages::GenericMessagesConverter& messages_converter, - HandlerFunc user_handler) - : ocpp::messages::GenericMessageHandler(action, messages_converter), m_user_handler(user_handler) + UserMessageHandler(const std::string& action, const GenericMessagesConverter& messages_converter, HandlerFunc user_handler) + : GenericMessageHandler(action, messages_converter), m_user_handler(user_handler) { } @@ -65,7 +63,7 @@ class UserMessageHandler : public ocpp::messages::GenericMessageHandler. #include using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { diff --git a/src/centralsystem/CentralSystem.h b/src/ocpp16/centralsystem/CentralSystem.h similarity index 97% rename from src/centralsystem/CentralSystem.h rename to src/ocpp16/centralsystem/CentralSystem.h index 29a33e95..eed330b3 100644 --- a/src/centralsystem/CentralSystem.h +++ b/src/ocpp16/centralsystem/CentralSystem.h @@ -101,9 +101,9 @@ class CentralSystem : public ICentralSystem, public ocpp::rpc::RpcServer::IListe std::unique_ptr m_internal_config; /** @brief Messages converter */ - ocpp::messages::MessagesConverter m_messages_converter; + ocpp::messages::ocpp16::MessagesConverter m_messages_converter; /** @brief Messages validator */ - ocpp::messages::MessagesValidator m_messages_validator; + ocpp::messages::ocpp16::MessagesValidator m_messages_validator; /** @brief Websocket server */ std::unique_ptr m_ws_server; diff --git a/src/centralsystem/chargepoint/ChargePointHandler.cpp b/src/ocpp16/centralsystem/chargepoint/ChargePointHandler.cpp similarity index 86% rename from src/centralsystem/chargepoint/ChargePointHandler.cpp rename to src/ocpp16/centralsystem/chargepoint/ChargePointHandler.cpp index 75140ce2..66ca080d 100644 --- a/src/centralsystem/chargepoint/ChargePointHandler.cpp +++ b/src/ocpp16/centralsystem/chargepoint/ChargePointHandler.cpp @@ -24,7 +24,9 @@ along with OpenOCPP. If not, see . #include "MessageDispatcher.h" using namespace ocpp::messages; +using namespace ocpp::messages::ocpp16; using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { @@ -32,10 +34,10 @@ namespace centralsystem { /** @brief Constructor */ -ChargePointHandler::ChargePointHandler(const std::string& identifier, - const ocpp::messages::MessagesConverter& messages_converter, - ocpp::messages::MessageDispatcher& msg_dispatcher, - const ocpp::config::ICentralSystemConfig& stack_config) +ChargePointHandler::ChargePointHandler(const std::string& identifier, + const ocpp::messages::ocpp16::MessagesConverter& messages_converter, + ocpp::messages::MessageDispatcher& msg_dispatcher, + const ocpp::config::ICentralSystemConfig& stack_config) : GenericMessageHandler(AUTHORIZE_ACTION, messages_converter), GenericMessageHandler(BOOT_NOTIFICATION_ACTION, messages_converter), GenericMessageHandler(DATA_TRANSFER_ACTION, messages_converter), @@ -99,10 +101,10 @@ ChargePointHandler::~ChargePointHandler() { } * std::string& error_code, * std::string& error_message) */ -bool ChargePointHandler::handleMessage(const ocpp::messages::AuthorizeReq& request, - ocpp::messages::AuthorizeConf& response, - std::string& error_code, - std::string& error_message) +bool ChargePointHandler::handleMessage(const ocpp::messages::ocpp16::AuthorizeReq& request, + ocpp::messages::ocpp16::AuthorizeConf& response, + std::string& error_code, + std::string& error_message) { bool ret = false; (void)error_message; @@ -130,10 +132,10 @@ bool ChargePointHandler::handleMessage(const ocpp::messages::AuthorizeReq& reque * std::string& error_code, * std::string& error_message) */ -bool ChargePointHandler::handleMessage(const ocpp::messages::BootNotificationReq& request, - ocpp::messages::BootNotificationConf& response, - std::string& error_code, - std::string& error_message) +bool ChargePointHandler::handleMessage(const ocpp::messages::ocpp16::BootNotificationReq& request, + ocpp::messages::ocpp16::BootNotificationConf& response, + std::string& error_code, + std::string& error_message) { bool ret = false; (void)error_message; @@ -179,10 +181,10 @@ bool ChargePointHandler::handleMessage(const ocpp::messages::BootNotificationReq * std::string& error_code, * std::string& error_message) */ -bool ChargePointHandler::handleMessage(const ocpp::messages::DataTransferReq& request, - ocpp::messages::DataTransferConf& response, - std::string& error_code, - std::string& error_message) +bool ChargePointHandler::handleMessage(const ocpp::messages::ocpp16::DataTransferReq& request, + ocpp::messages::ocpp16::DataTransferConf& response, + std::string& error_code, + std::string& error_message) { bool ret = false; (void)error_message; @@ -262,10 +264,10 @@ bool ChargePointHandler::handleMessage(const ocpp::messages::DataTransferReq& re * std::string& error_code, * std::string& error_message) */ -bool ChargePointHandler::handleMessage(const ocpp::messages::DiagnosticsStatusNotificationReq& request, - ocpp::messages::DiagnosticsStatusNotificationConf& response, - std::string& error_code, - std::string& error_message) +bool ChargePointHandler::handleMessage(const ocpp::messages::ocpp16::DiagnosticsStatusNotificationReq& request, + ocpp::messages::ocpp16::DiagnosticsStatusNotificationConf& response, + std::string& error_code, + std::string& error_message) { bool ret = false; (void)error_message; @@ -295,10 +297,10 @@ bool ChargePointHandler::handleMessage(const ocpp::messages::DiagnosticsStatusNo * std::string& error_code, * std::string& error_message) */ -bool ChargePointHandler::handleMessage(const ocpp::messages::FirmwareStatusNotificationReq& request, - ocpp::messages::FirmwareStatusNotificationConf& response, - std::string& error_code, - std::string& error_message) +bool ChargePointHandler::handleMessage(const ocpp::messages::ocpp16::FirmwareStatusNotificationReq& request, + ocpp::messages::ocpp16::FirmwareStatusNotificationConf& response, + std::string& error_code, + std::string& error_message) { bool ret = false; (void)error_message; @@ -328,10 +330,10 @@ bool ChargePointHandler::handleMessage(const ocpp::messages::FirmwareStatusNotif * std::string& error_code, * std::string& error_message) */ -bool ChargePointHandler::handleMessage(const ocpp::messages::HeartbeatReq& request, - ocpp::messages::HeartbeatConf& response, - std::string& error_code, - std::string& error_message) +bool ChargePointHandler::handleMessage(const ocpp::messages::ocpp16::HeartbeatReq& request, + ocpp::messages::ocpp16::HeartbeatConf& response, + std::string& error_code, + std::string& error_message) { (void)error_code; (void)error_message; @@ -358,10 +360,10 @@ bool ChargePointHandler::handleMessage(const ocpp::messages::HeartbeatReq& reque * std::string& error_code, * std::string& error_message) */ -bool ChargePointHandler::handleMessage(const ocpp::messages::MeterValuesReq& request, - ocpp::messages::MeterValuesConf& response, - std::string& error_code, - std::string& error_message) +bool ChargePointHandler::handleMessage(const ocpp::messages::ocpp16::MeterValuesReq& request, + ocpp::messages::ocpp16::MeterValuesConf& response, + std::string& error_code, + std::string& error_message) { bool ret = false; (void)error_message; @@ -392,10 +394,10 @@ bool ChargePointHandler::handleMessage(const ocpp::messages::MeterValuesReq& req * std::string& error_code, * std::string& error_message) */ -bool ChargePointHandler::handleMessage(const ocpp::messages::StartTransactionReq& request, - ocpp::messages::StartTransactionConf& response, - std::string& error_code, - std::string& error_message) +bool ChargePointHandler::handleMessage(const ocpp::messages::ocpp16::StartTransactionReq& request, + ocpp::messages::ocpp16::StartTransactionConf& response, + std::string& error_code, + std::string& error_message) { bool ret = false; (void)error_message; @@ -429,10 +431,10 @@ bool ChargePointHandler::handleMessage(const ocpp::messages::StartTransactionReq * std::string& error_code, * std::string& error_message) */ -bool ChargePointHandler::handleMessage(const ocpp::messages::StatusNotificationReq& request, - ocpp::messages::StatusNotificationConf& response, - std::string& error_code, - std::string& error_message) +bool ChargePointHandler::handleMessage(const ocpp::messages::ocpp16::StatusNotificationReq& request, + ocpp::messages::ocpp16::StatusNotificationConf& response, + std::string& error_code, + std::string& error_message) { bool ret = false; (void)error_message; @@ -469,10 +471,10 @@ bool ChargePointHandler::handleMessage(const ocpp::messages::StatusNotificationR * std::string& error_code, * std::string& error_message) */ -bool ChargePointHandler::handleMessage(const ocpp::messages::StopTransactionReq& request, - ocpp::messages::StopTransactionConf& response, - std::string& error_code, - std::string& error_message) +bool ChargePointHandler::handleMessage(const ocpp::messages::ocpp16::StopTransactionReq& request, + ocpp::messages::ocpp16::StopTransactionConf& response, + std::string& error_code, + std::string& error_message) { bool ret = false; (void)error_message; @@ -511,10 +513,10 @@ bool ChargePointHandler::handleMessage(const ocpp::messages::StopTransactionReq& * std::string& error_code, * std::string& error_message) */ -bool ChargePointHandler::handleMessage(const ocpp::messages::LogStatusNotificationReq& request, - ocpp::messages::LogStatusNotificationConf& response, - std::string& error_code, - std::string& error_message) +bool ChargePointHandler::handleMessage(const ocpp::messages::ocpp16::LogStatusNotificationReq& request, + ocpp::messages::ocpp16::LogStatusNotificationConf& response, + std::string& error_code, + std::string& error_message) { bool ret = false; (void)error_message; @@ -545,10 +547,10 @@ bool ChargePointHandler::handleMessage(const ocpp::messages::LogStatusNotificati * std::string& error_code, * std::string& error_message) */ -bool ChargePointHandler::handleMessage(const ocpp::messages::SecurityEventNotificationReq& request, - ocpp::messages::SecurityEventNotificationConf& response, - std::string& error_code, - std::string& error_message) +bool ChargePointHandler::handleMessage(const ocpp::messages::ocpp16::SecurityEventNotificationReq& request, + ocpp::messages::ocpp16::SecurityEventNotificationConf& response, + std::string& error_code, + std::string& error_message) { bool ret = false; (void)error_message; @@ -579,10 +581,10 @@ bool ChargePointHandler::handleMessage(const ocpp::messages::SecurityEventNotifi * std::string& error_code, * std::string& error_message) */ -bool ChargePointHandler::handleMessage(const ocpp::messages::SignCertificateReq& request, - ocpp::messages::SignCertificateConf& response, - std::string& error_code, - std::string& error_message) +bool ChargePointHandler::handleMessage(const ocpp::messages::ocpp16::SignCertificateReq& request, + ocpp::messages::ocpp16::SignCertificateConf& response, + std::string& error_code, + std::string& error_message) { bool ret = false; (void)error_message; @@ -622,10 +624,10 @@ bool ChargePointHandler::handleMessage(const ocpp::messages::SignCertificateReq& * std::string& error_code, * std::string& error_message) */ -bool ChargePointHandler::handleMessage(const ocpp::messages::SignedFirmwareStatusNotificationReq& request, - ocpp::messages::SignedFirmwareStatusNotificationConf& response, - std::string& error_code, - std::string& error_message) +bool ChargePointHandler::handleMessage(const ocpp::messages::ocpp16::SignedFirmwareStatusNotificationReq& request, + ocpp::messages::ocpp16::SignedFirmwareStatusNotificationConf& response, + std::string& error_code, + std::string& error_message) { bool ret = false; (void)error_message; @@ -654,7 +656,8 @@ bool ChargePointHandler::handleMessage(const ocpp::messages::SignedFirmwareStatu // ISO 15118 PnC extensions /** @brief Handle an Iso15118Authorize request */ -void ChargePointHandler::handleMessage(const ocpp::messages::Iso15118AuthorizeReq& request, ocpp::messages::Iso15118AuthorizeConf& response) +void ChargePointHandler::handleMessage(const ocpp::messages::ocpp16::Iso15118AuthorizeReq& request, + ocpp::messages::ocpp16::Iso15118AuthorizeConf& response) { LOG_INFO << "[" << m_identifier << "] - [ISO15118] Authorize requested : idToken = " << request.idToken.str() << " - certificate = " << (request.certificate.isSet() ? std::to_string(request.certificate.value().size()) : "not set"); @@ -678,8 +681,8 @@ void ChargePointHandler::handleMessage(const ocpp::messages::Iso15118AuthorizeRe } /** @brief Handle a Get15118EVCertificate request */ -void ChargePointHandler::handleMessage(const ocpp::messages::Get15118EVCertificateReq& request, - ocpp::messages::Get15118EVCertificateConf& response) +void ChargePointHandler::handleMessage(const ocpp::messages::ocpp16::Get15118EVCertificateReq& request, + ocpp::messages::ocpp16::Get15118EVCertificateConf& response) { LOG_INFO << "[" << m_identifier << "] - [ISO15118] Get EV certificate requested : action = " << CertificateActionEnumTypeHelper.toString(request.action) @@ -698,8 +701,8 @@ void ChargePointHandler::handleMessage(const ocpp::messages::Get15118EVCertifica } /** @brief Handle a GetCertificateStatus request */ -void ChargePointHandler::handleMessage(const ocpp::messages::GetCertificateStatusReq& request, - ocpp::messages::GetCertificateStatusConf& response) +void ChargePointHandler::handleMessage(const ocpp::messages::ocpp16::GetCertificateStatusReq& request, + ocpp::messages::ocpp16::GetCertificateStatusConf& response) { LOG_INFO << "[" << m_identifier << "] - [ISO15118] Get certificate status requested : hashAlgorithm = " << HashAlgorithmEnumTypeHelper.toString(request.ocspRequestData.hashAlgorithm) @@ -724,7 +727,8 @@ void ChargePointHandler::handleMessage(const ocpp::messages::GetCertificateStatu } /** @brief Handle a SignCertificate request */ -void ChargePointHandler::handleMessage(const ocpp::messages::SignCertificateReq& request, ocpp::messages::SignCertificateConf& response) +void ChargePointHandler::handleMessage(const ocpp::messages::ocpp16::SignCertificateReq& request, + ocpp::messages::ocpp16::SignCertificateConf& response) { LOG_INFO << "[" << m_identifier << "] - [ISO15118] Sign certificate requested : csr size = " << request.csr.size(); diff --git a/src/centralsystem/chargepoint/ChargePointHandler.h b/src/ocpp16/centralsystem/chargepoint/ChargePointHandler.h similarity index 68% rename from src/centralsystem/chargepoint/ChargePointHandler.h rename to src/ocpp16/centralsystem/chargepoint/ChargePointHandler.h index 20cc1bdf..8f05b808 100644 --- a/src/centralsystem/chargepoint/ChargePointHandler.h +++ b/src/ocpp16/centralsystem/chargepoint/ChargePointHandler.h @@ -59,25 +59,29 @@ class IChargePointRequestHandler; /** @brief Handler for charge point requests */ class ChargePointHandler - : public ocpp::messages::GenericMessageHandler, - public ocpp::messages::GenericMessageHandler, - public ocpp::messages::GenericMessageHandler, - public ocpp::messages::GenericMessageHandler, - public ocpp::messages::GenericMessageHandler, - public ocpp::messages::GenericMessageHandler, - public ocpp::messages::GenericMessageHandler, - public ocpp::messages::GenericMessageHandler, - public ocpp::messages::GenericMessageHandler, - public ocpp::messages::GenericMessageHandler, + : public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, // Security extensions - public ocpp::messages::GenericMessageHandler, - public ocpp::messages::GenericMessageHandler, - public ocpp::messages::GenericMessageHandler, - public ocpp::messages::GenericMessageHandler + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler { public: /** @@ -87,10 +91,10 @@ class ChargePointHandler * @param msg_dispatcher Message dispatcher * @param stack_config Stack configuration */ - ChargePointHandler(const std::string& identifier, - const ocpp::messages::MessagesConverter& messages_converter, - ocpp::messages::MessageDispatcher& msg_dispatcher, - const ocpp::config::ICentralSystemConfig& stack_config); + ChargePointHandler(const std::string& identifier, + const ocpp::messages::ocpp16::MessagesConverter& messages_converter, + ocpp::messages::MessageDispatcher& msg_dispatcher, + const ocpp::config::ICentralSystemConfig& stack_config); /** @brief Destructor */ virtual ~ChargePointHandler(); @@ -104,100 +108,100 @@ class ChargePointHandler * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::AuthorizeReq& request, - ocpp::messages::AuthorizeConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::AuthorizeReq& request, + ocpp::messages::ocpp16::AuthorizeConf& response, + std::string& error_code, + std::string& error_message) override; /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, * ResponseType& response, * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::BootNotificationReq& request, - ocpp::messages::BootNotificationConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::BootNotificationReq& request, + ocpp::messages::ocpp16::BootNotificationConf& response, + std::string& error_code, + std::string& error_message) override; /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, * ResponseType& response, * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::DataTransferReq& request, - ocpp::messages::DataTransferConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::DataTransferReq& request, + ocpp::messages::ocpp16::DataTransferConf& response, + std::string& error_code, + std::string& error_message) override; /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, * ResponseType& response, * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::DiagnosticsStatusNotificationReq& request, - ocpp::messages::DiagnosticsStatusNotificationConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::DiagnosticsStatusNotificationReq& request, + ocpp::messages::ocpp16::DiagnosticsStatusNotificationConf& response, + std::string& error_code, + std::string& error_message) override; /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, * ResponseType& response, * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::FirmwareStatusNotificationReq& request, - ocpp::messages::FirmwareStatusNotificationConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::FirmwareStatusNotificationReq& request, + ocpp::messages::ocpp16::FirmwareStatusNotificationConf& response, + std::string& error_code, + std::string& error_message) override; /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, * ResponseType& response, * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::HeartbeatReq& request, - ocpp::messages::HeartbeatConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::HeartbeatReq& request, + ocpp::messages::ocpp16::HeartbeatConf& response, + std::string& error_code, + std::string& error_message) override; /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, * ResponseType& response, * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::MeterValuesReq& request, - ocpp::messages::MeterValuesConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::MeterValuesReq& request, + ocpp::messages::ocpp16::MeterValuesConf& response, + std::string& error_code, + std::string& error_message) override; /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, * ResponseType& response, * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::StartTransactionReq& request, - ocpp::messages::StartTransactionConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::StartTransactionReq& request, + ocpp::messages::ocpp16::StartTransactionConf& response, + std::string& error_code, + std::string& error_message) override; /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, * ResponseType& response, * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::StatusNotificationReq& request, - ocpp::messages::StatusNotificationConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::StatusNotificationReq& request, + ocpp::messages::ocpp16::StatusNotificationConf& response, + std::string& error_code, + std::string& error_message) override; /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, * ResponseType& response, * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::StopTransactionReq& request, - ocpp::messages::StopTransactionConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::StopTransactionReq& request, + ocpp::messages::ocpp16::StopTransactionConf& response, + std::string& error_code, + std::string& error_message) override; // Security extensions @@ -206,40 +210,40 @@ class ChargePointHandler * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::LogStatusNotificationReq& request, - ocpp::messages::LogStatusNotificationConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::LogStatusNotificationReq& request, + ocpp::messages::ocpp16::LogStatusNotificationConf& response, + std::string& error_code, + std::string& error_message) override; /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, * ResponseType& response, * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::SecurityEventNotificationReq& request, - ocpp::messages::SecurityEventNotificationConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::SecurityEventNotificationReq& request, + ocpp::messages::ocpp16::SecurityEventNotificationConf& response, + std::string& error_code, + std::string& error_message) override; /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, * ResponseType& response, * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::SignCertificateReq& request, - ocpp::messages::SignCertificateConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::SignCertificateReq& request, + ocpp::messages::ocpp16::SignCertificateConf& response, + std::string& error_code, + std::string& error_message) override; /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, * ResponseType& response, * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::SignedFirmwareStatusNotificationReq& request, - ocpp::messages::SignedFirmwareStatusNotificationConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::SignedFirmwareStatusNotificationReq& request, + ocpp::messages::ocpp16::SignedFirmwareStatusNotificationConf& response, + std::string& error_code, + std::string& error_message) override; private: /** @brief Charge point's identifier */ @@ -261,11 +265,13 @@ class ChargePointHandler * @return Response status (see DataTransferStatus enum) */ template - ocpp::types::DataTransferStatus handleMessage(const std::string& type_id, const std::string& request_data, std::string& response_data) + ocpp::types::ocpp16::DataTransferStatus handleMessage(const std::string& type_id, + const std::string& request_data, + std::string& response_data) { - ocpp::types::DataTransferStatus status = ocpp::types::DataTransferStatus::Rejected; - auto req_converter = m_messages_converter.getRequestConverter(type_id); - auto resp_converter = m_messages_converter.getResponseConverter(type_id); + ocpp::types::ocpp16::DataTransferStatus status = ocpp::types::ocpp16::DataTransferStatus::Rejected; + auto req_converter = m_messages_converter.getRequestConverter(type_id); + auto resp_converter = m_messages_converter.getResponseConverter(type_id); try { // Parse JSON @@ -284,8 +290,7 @@ class ChargePointHandler handleMessage(req, resp); // Convert response to JSON - rapidjson::Document response; - response.Parse("{}"); + rapidjson::Document response(rapidjson::kObjectType); resp_converter->setAllocator(&response.GetAllocator()); if (resp_converter->toJson(resp, response)) { @@ -296,7 +301,7 @@ class ChargePointHandler response.Accept(writer); response_data = buffer.GetString(); - status = ocpp::types::DataTransferStatus::Accepted; + status = ocpp::types::ocpp16::DataTransferStatus::Accepted; } } else @@ -317,13 +322,16 @@ class ChargePointHandler } /** @brief Handle an Iso15118Authorize request */ - void handleMessage(const ocpp::messages::Iso15118AuthorizeReq& request, ocpp::messages::Iso15118AuthorizeConf& response); + void handleMessage(const ocpp::messages::ocpp16::Iso15118AuthorizeReq& request, + ocpp::messages::ocpp16::Iso15118AuthorizeConf& response); /** @brief Handle a Get15118EVCertificate request */ - void handleMessage(const ocpp::messages::Get15118EVCertificateReq& request, ocpp::messages::Get15118EVCertificateConf& response); + void handleMessage(const ocpp::messages::ocpp16::Get15118EVCertificateReq& request, + ocpp::messages::ocpp16::Get15118EVCertificateConf& response); /** @brief Handle a GetCertificateStatus request */ - void handleMessage(const ocpp::messages::GetCertificateStatusReq& request, ocpp::messages::GetCertificateStatusConf& response); + void handleMessage(const ocpp::messages::ocpp16::GetCertificateStatusReq& request, + ocpp::messages::ocpp16::GetCertificateStatusConf& response); /** @brief Handle a SignCertificate request */ - void handleMessage(const ocpp::messages::SignCertificateReq& request, ocpp::messages::SignCertificateConf& response); + void handleMessage(const ocpp::messages::ocpp16::SignCertificateReq& request, ocpp::messages::ocpp16::SignCertificateConf& response); }; } // namespace centralsystem diff --git a/src/centralsystem/chargepoint/ChargePointProxy.cpp b/src/ocpp16/centralsystem/chargepoint/ChargePointProxy.cpp similarity index 86% rename from src/centralsystem/chargepoint/ChargePointProxy.cpp rename to src/ocpp16/centralsystem/chargepoint/ChargePointProxy.cpp index 45184de0..83d0aa17 100644 --- a/src/centralsystem/chargepoint/ChargePointProxy.cpp +++ b/src/ocpp16/centralsystem/chargepoint/ChargePointProxy.cpp @@ -48,8 +48,10 @@ along with OpenOCPP. If not, see . #include "UnlockConnector.h" #include "UpdateFirmware.h" -using namespace ocpp::types; using namespace ocpp::messages; +using namespace ocpp::messages::ocpp16; +using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { @@ -57,12 +59,12 @@ namespace centralsystem { /** @brief Constructor */ -ChargePointProxy::ChargePointProxy(ICentralSystem& central_system, - const std::string& identifier, - std::shared_ptr rpc, - const ocpp::messages::MessagesValidator& messages_validator, - ocpp::messages::MessagesConverter& messages_converter, - const ocpp::config::ICentralSystemConfig& stack_config) +ChargePointProxy::ChargePointProxy(ICentralSystem& central_system, + const std::string& identifier, + std::shared_ptr rpc, + const ocpp::messages::ocpp16::MessagesValidator& messages_validator, + ocpp::messages::ocpp16::MessagesConverter& messages_converter, + const ocpp::config::ICentralSystemConfig& stack_config) : m_central_system(central_system), m_identifier(identifier), m_rpc(rpc), @@ -144,8 +146,9 @@ bool ChargePointProxy::cancelReservation(int reservation_id) return ret; } -/** @copydoc ocpp::types::AvailabilityStatus ICentralSystem::IChargePoint::changeAvailability(unsigned int, ocpp::types::AvailabilityType) */ -ocpp::types::AvailabilityStatus ChargePointProxy::changeAvailability(unsigned int connector_id, ocpp::types::AvailabilityType availability) +/** @copydoc ocpp::types::ocpp16::AvailabilityStatus ICentralSystem::IChargePoint::changeAvailability(unsigned int, ocpp::types::ocpp16::AvailabilityType) */ +ocpp::types::ocpp16::AvailabilityStatus ChargePointProxy::changeAvailability(unsigned int connector_id, + ocpp::types::ocpp16::AvailabilityType availability) { AvailabilityStatus ret = AvailabilityStatus::Rejected; @@ -173,8 +176,8 @@ ocpp::types::AvailabilityStatus ChargePointProxy::changeAvailability(unsigned in return ret; } -/** @copydoc ocpp::types::ConfigurationStatus ICentralSystem::IChargePoint::changeConfiguration(const std::string&, const std::string&) */ -ocpp::types::ConfigurationStatus ChargePointProxy::changeConfiguration(const std::string& key, const std::string& value) +/** @copydoc ocpp::types::ocpp16::ConfigurationStatus ICentralSystem::IChargePoint::changeConfiguration(const std::string&, const std::string&) */ +ocpp::types::ocpp16::ConfigurationStatus ChargePointProxy::changeConfiguration(const std::string& key, const std::string& value) { ConfigurationStatus ret = ConfigurationStatus::Rejected; @@ -229,12 +232,12 @@ bool ChargePointProxy::clearCache() /** @copydoc bool ICentralSystem::IChargePoint::clearChargingProfile(const ocpp::types::Optional&, const ocpp::types::Optional&, - const ocpp::types::Optional&, + const ocpp::types::Optional&, const ocpp::types::Optional&) */ -bool ChargePointProxy::clearChargingProfile(const ocpp::types::Optional& profile_id, - const ocpp::types::Optional& connector_id, - const ocpp::types::Optional& purpose, - const ocpp::types::Optional& stack_level) +bool ChargePointProxy::clearChargingProfile(const ocpp::types::Optional& profile_id, + const ocpp::types::Optional& connector_id, + const ocpp::types::Optional& purpose, + const ocpp::types::Optional& stack_level) { bool ret = false; @@ -269,13 +272,13 @@ bool ChargePointProxy::clearChargingProfile(const ocpp::types::Optional& /** @copydoc bool ICentralSystem::IChargePoint::dataTransfer(const std::string&, const std::string&, const std::string&, - ocpp::types::DataTransferStatus&, + ocpp::types::ocpp16::DataTransferStatus&, std::string&) */ -bool ChargePointProxy::dataTransfer(const std::string& vendor_id, - const std::string& message_id, - const std::string& request_data, - ocpp::types::DataTransferStatus& status, - std::string& response_data) +bool ChargePointProxy::dataTransfer(const std::string& vendor_id, + const std::string& message_id, + const std::string& request_data, + ocpp::types::ocpp16::DataTransferStatus& status, + std::string& response_data) { bool ret = false; @@ -315,16 +318,16 @@ bool ChargePointProxy::dataTransfer(const std::string& vendor_id, /** @copydoc bool ICentralSystem::IChargePoint::getCompositeSchedule(unsigned int, std::chrono::seconds, - const ocpp::types::Optional&, + const ocpp::types::Optional&, ocpp::types::Optional&, ocpp::types::Optional&, - ocpp::types::Optional&) */ -bool ChargePointProxy::getCompositeSchedule(unsigned int connector_id, - std::chrono::seconds duration, - const ocpp::types::Optional& unit, - ocpp::types::Optional& schedule_connector_id, - ocpp::types::Optional& schedule_start, - ocpp::types::Optional& schedule) + ocpp::types::Optional&) */ +bool ChargePointProxy::getCompositeSchedule(unsigned int connector_id, + std::chrono::seconds duration, + const ocpp::types::Optional& unit, + ocpp::types::Optional& schedule_connector_id, + ocpp::types::Optional& schedule_start, + ocpp::types::Optional& schedule) { bool ret = false; @@ -361,11 +364,11 @@ bool ChargePointProxy::getCompositeSchedule(unsigned int } /** @copydoc bool ICentralSystem::IChargePoint::getConfiguration(const std::vector&, - std::vector&, + std::vector&, std::vector&) */ -bool ChargePointProxy::getConfiguration(const std::vector& keys, - std::vector& config_keys, - std::vector& unknown_keys) +bool ChargePointProxy::getConfiguration(const std::vector& keys, + std::vector& config_keys, + std::vector& unknown_keys) { bool ret = false; @@ -489,10 +492,10 @@ bool ChargePointProxy::getLocalListVersion(int& version) /** @copydoc bool ICentralSystem::IChargePoint::remoteStartTransaction(const ocpp::types::Optional&, const std::string&, - const ocpp::types::Optional&) */ -bool ChargePointProxy::remoteStartTransaction(const ocpp::types::Optional& connector_id, - const std::string& id_tag, - const ocpp::types::Optional& profile) + const ocpp::types::Optional&) */ +bool ChargePointProxy::remoteStartTransaction(const ocpp::types::Optional& connector_id, + const std::string& id_tag, + const ocpp::types::Optional& profile) { bool ret = false; @@ -549,16 +552,16 @@ bool ChargePointProxy::remoteStopTransaction(int transaction_id) return ret; } -/** @copydoc ocpp::types::ReservationStatus ICentralSystem::IChargePoint::reserveNow(unsigned int, +/** @copydoc ocpp::types::ocpp16::ReservationStatus ICentralSystem::IChargePoint::reserveNow(unsigned int, const ocpp::types::DateTime&, const std::string&, const std::string&, int)*/ -ocpp::types::ReservationStatus ChargePointProxy::reserveNow(unsigned int connector_id, - const ocpp::types::DateTime& expiry_date, - const std::string& id_tag, - const std::string& parent_id_tag, - int reservation_id) +ocpp::types::ocpp16::ReservationStatus ChargePointProxy::reserveNow(unsigned int connector_id, + const ocpp::types::DateTime& expiry_date, + const std::string& id_tag, + const std::string& parent_id_tag, + int reservation_id) { ReservationStatus ret = ReservationStatus::Rejected; @@ -592,8 +595,8 @@ ocpp::types::ReservationStatus ChargePointProxy::reserveNow(unsigned int return ret; } -/** @copydoc bool ICentralSystem::IChargePoint::reset(ocpp::types::ResetType) */ -bool ChargePointProxy::reset(ocpp::types::ResetType type) +/** @copydoc bool ICentralSystem::IChargePoint::reset(ocpp::types::ocpp16::ResetType) */ +bool ChargePointProxy::reset(ocpp::types::ocpp16::ResetType type) { bool ret = false; @@ -619,12 +622,11 @@ bool ChargePointProxy::reset(ocpp::types::ResetType type) return ret; } -/** @copydoc ocpp::types::UpdateStatus ICentralSystem::IChargePoint::sendLocalList(int, - const std::vector&, - ocpp::types::UpdateType) */ -ocpp::types::UpdateStatus ChargePointProxy::sendLocalList(int version, - const std::vector& authorization_list, - ocpp::types::UpdateType update_type) +/** @copydoc ocpp::types::ocpp16::UpdateStatus ICentralSystem::IChargePoint::sendLocalList(int, + const std::vector&, + ocpp::types::ocpp16::UpdateType) */ +ocpp::types::ocpp16::UpdateStatus ChargePointProxy::sendLocalList( + int version, const std::vector& authorization_list, ocpp::types::ocpp16::UpdateType update_type) { UpdateStatus ret = UpdateStatus::Failed; @@ -654,10 +656,10 @@ ocpp::types::UpdateStatus ChargePointProxy::sendLocalList(int return ret; } -/** @copydoc ocpp::types::ChargingProfileStatus ICentralSystem::IChargePoint::setChargingProfile(unsigned int, - const ocpp::types::ChargingProfile&) */ -ocpp::types::ChargingProfileStatus ChargePointProxy::setChargingProfile(unsigned int connector_id, - const ocpp::types::ChargingProfile& profile) +/** @copydoc ocpp::types::ocpp16::ChargingProfileStatus ICentralSystem::IChargePoint::setChargingProfile(unsigned int, + const ocpp::types::ocpp16::ChargingProfile&) */ +ocpp::types::ocpp16::ChargingProfileStatus ChargePointProxy::setChargingProfile(unsigned int connector_id, + const ocpp::types::ocpp16::ChargingProfile& profile) { ChargingProfileStatus ret = ChargingProfileStatus::Rejected; @@ -686,10 +688,10 @@ ocpp::types::ChargingProfileStatus ChargePointProxy::setChargingProfile(unsigned return ret; } -/** @copydoc ocpp::types::TriggerMessageStatus ICentralSystem::IChargePoint::triggerMessage(ocpp::types::MessageTrigger, +/** @copydoc ocpp::types::ocpp16::TriggerMessageStatus ICentralSystem::IChargePoint::triggerMessage(ocpp::types::ocpp16::MessageTrigger, const ocpp::types::Optional) */ -ocpp::types::TriggerMessageStatus ChargePointProxy::triggerMessage(ocpp::types::MessageTrigger message, - const ocpp::types::Optional connector_id) +ocpp::types::ocpp16::TriggerMessageStatus ChargePointProxy::triggerMessage(ocpp::types::ocpp16::MessageTrigger message, + const ocpp::types::Optional connector_id) { TriggerMessageStatus ret = TriggerMessageStatus::Rejected; @@ -717,8 +719,8 @@ ocpp::types::TriggerMessageStatus ChargePointProxy::triggerMessage(ocpp::types:: return ret; } -/** @copydoc ocpp::types::UnlockStatus ICentralSystem::IChargePoint::unlockConnector(unsigned int) */ -ocpp::types::UnlockStatus ChargePointProxy::unlockConnector(unsigned int connector_id) +/** @copydoc ocpp::types::ocpp16::UnlockStatus ICentralSystem::IChargePoint::unlockConnector(unsigned int) */ +ocpp::types::ocpp16::UnlockStatus ChargePointProxy::unlockConnector(unsigned int connector_id) { UnlockStatus ret = UnlockStatus::UnlockFailed; @@ -814,8 +816,9 @@ bool ChargePointProxy::certificateSigned(const ocpp::x509::Certificate& certific return ret; } -/** @copydoc ocpp::types::DeleteCertificateStatusEnumType ICentralSystem::IChargePoint::deleteCertificate(const ocpp::types::CertificateHashDataType&) */ -ocpp::types::DeleteCertificateStatusEnumType ChargePointProxy::deleteCertificate(const ocpp::types::CertificateHashDataType& certificate) +/** @copydoc ocpp::types::ocpp16::DeleteCertificateStatusEnumType ICentralSystem::IChargePoint::deleteCertificate(const ocpp::types::ocpp16::CertificateHashDataType&) */ +ocpp::types::ocpp16::DeleteCertificateStatusEnumType ChargePointProxy::deleteCertificate( + const ocpp::types::ocpp16::CertificateHashDataType& certificate) { DeleteCertificateStatusEnumType ret = DeleteCertificateStatusEnumType::Failed; @@ -842,10 +845,10 @@ ocpp::types::DeleteCertificateStatusEnumType ChargePointProxy::deleteCertificate return ret; } -/** @copydoc ocpp::types::TriggerMessageStatusEnumType ICentralSystem::IChargePoint::extendedTriggerMessage(ocpp::types::MessageTriggerEnumType, +/** @copydoc ocpp::types::ocpp16::TriggerMessageStatusEnumType ICentralSystem::IChargePoint::extendedTriggerMessage(ocpp::types::ocpp16::MessageTriggerEnumType, const ocpp::types::Optional) */ -ocpp::types::TriggerMessageStatusEnumType ChargePointProxy::extendedTriggerMessage(ocpp::types::MessageTriggerEnumType message, - const ocpp::types::Optional connector_id) +ocpp::types::ocpp16::TriggerMessageStatusEnumType ChargePointProxy::extendedTriggerMessage( + ocpp::types::ocpp16::MessageTriggerEnumType message, const ocpp::types::Optional connector_id) { TriggerMessageStatusEnumType ret = TriggerMessageStatusEnumType::Rejected; @@ -874,10 +877,10 @@ ocpp::types::TriggerMessageStatusEnumType ChargePointProxy::extendedTriggerMessa return ret; } -/** @copydoc bool ICentralSystem::IChargePoint::getInstalledCertificateIds(ocpp::types::CertificateUseEnumType, - std::vector&) */ -bool ChargePointProxy::getInstalledCertificateIds(ocpp::types::CertificateUseEnumType type, - std::vector& certificates) +/** @copydoc bool ICentralSystem::IChargePoint::getInstalledCertificateIds(ocpp::types::ocpp16::CertificateUseEnumType, + std::vector&) */ +bool ChargePointProxy::getInstalledCertificateIds(ocpp::types::ocpp16::CertificateUseEnumType type, + std::vector& certificates) { bool ret = false; @@ -907,7 +910,7 @@ bool ChargePointProxy::getInstalledCertificateIds(ocpp::types::CertificateUseEnu return ret; } -/** @copydoc bool ICentralSystem::IChargePoint::getLog(ocpp::types::LogEnumType, +/** @copydoc bool ICentralSystem::IChargePoint::getLog(ocpp::types::ocpp16::LogEnumType, int, const std::string&, const ocpp::types::Optional&, @@ -915,7 +918,7 @@ bool ChargePointProxy::getInstalledCertificateIds(ocpp::types::CertificateUseEnu const ocpp::types::Optional&, const ocpp::types::Optional&, std::string&) */ -bool ChargePointProxy::getLog(ocpp::types::LogEnumType type, +bool ChargePointProxy::getLog(ocpp::types::ocpp16::LogEnumType type, int request_id, const std::string& uri, const ocpp::types::Optional& retries, @@ -963,10 +966,10 @@ bool ChargePointProxy::getLog(ocpp::types::LogEnumType return ret; } -/** @copydoc ocpp::types::CertificateStatusEnumType ICentralSystem::installCertificate(ocpp::types::CertificateUseEnumType, +/** @copydoc ocpp::types::ocpp16::CertificateStatusEnumType ICentralSystem::installCertificate(ocpp::types::ocpp16::CertificateUseEnumType, const ocpp::x509::Certificate&) */ -ocpp::types::CertificateStatusEnumType ChargePointProxy::installCertificate(ocpp::types::CertificateUseEnumType type, - const ocpp::x509::Certificate& certificate) +ocpp::types::ocpp16::CertificateStatusEnumType ChargePointProxy::installCertificate(ocpp::types::ocpp16::CertificateUseEnumType type, + const ocpp::x509::Certificate& certificate) { CertificateStatusEnumType ret = CertificateStatusEnumType::Rejected; @@ -994,7 +997,7 @@ ocpp::types::CertificateStatusEnumType ChargePointProxy::installCertificate(ocpp return ret; } -/** @copydoc ocpp::types::UpdateFirmwareStatusEnumType ICentralSystem::signedUpdateFirmware( +/** @copydoc ocpp::types::ocpp16::UpdateFirmwareStatusEnumType ICentralSystem::signedUpdateFirmware( int, const std::string&, const ocpp::types::Optional&, @@ -1003,7 +1006,7 @@ ocpp::types::CertificateStatusEnumType ChargePointProxy::installCertificate(ocpp const ocpp::types::Optional&, const ocpp::x509::Certificate&, const std::string&) */ -ocpp::types::UpdateFirmwareStatusEnumType ChargePointProxy::signedUpdateFirmware( +ocpp::types::ocpp16::UpdateFirmwareStatusEnumType ChargePointProxy::signedUpdateFirmware( int request_id, const std::string& uri, const ocpp::types::Optional& retries, @@ -1083,10 +1086,10 @@ bool ChargePointProxy::iso15118CertificateSigned(const ocpp::x509::Certificate& return ret; } -/** @copydoc ocpp::types::DeleteCertificateStatusEnumType ICentralSystem::IChargePoint::iso15118DeleteCertificate( - const ocpp::types::CertificateHashDataType&) */ -ocpp::types::DeleteCertificateStatusEnumType ChargePointProxy::iso15118DeleteCertificate( - const ocpp::types::CertificateHashDataType& certificate) +/** @copydoc ocpp::types::ocpp16::DeleteCertificateStatusEnumType ICentralSystem::IChargePoint::iso15118DeleteCertificate( + const ocpp::types::ocpp16::CertificateHashDataType&) */ +ocpp::types::ocpp16::DeleteCertificateStatusEnumType ChargePointProxy::iso15118DeleteCertificate( + const ocpp::types::ocpp16::CertificateHashDataType& certificate) { DeleteCertificateStatusEnumType ret = DeleteCertificateStatusEnumType::Failed; @@ -1113,10 +1116,10 @@ ocpp::types::DeleteCertificateStatusEnumType ChargePointProxy::iso15118DeleteCer return ret; } -/** @copydoc bool ICentralSystem::IChargePoint::iso15118GetInstalledCertificateIds(ocpp::types::GetCertificateIdUseEnumType, - std::vector&) */ -bool ChargePointProxy::iso15118GetInstalledCertificateIds(const std::vector& types, - std::vector& certificates) +/** @copydoc bool ICentralSystem::IChargePoint::iso15118GetInstalledCertificateIds(ocpp::types::ocpp16::GetCertificateIdUseEnumType, + std::vector&) */ +bool ChargePointProxy::iso15118GetInstalledCertificateIds(const std::vector& types, + std::vector& certificates) { bool ret = false; @@ -1145,11 +1148,11 @@ bool ChargePointProxy::iso15118GetInstalledCertificateIds(const std::vector rpc, - const ocpp::messages::MessagesValidator& messages_validator, - ocpp::messages::MessagesConverter& messages_converter, - const ocpp::config::ICentralSystemConfig& stack_config); + ChargePointProxy(ICentralSystem& central_system, + const std::string& identifier, + std::shared_ptr rpc, + const ocpp::messages::ocpp16::MessagesValidator& messages_validator, + ocpp::messages::ocpp16::MessagesConverter& messages_converter, + const ocpp::config::ICentralSystemConfig& stack_config); /** @brief Destructor */ virtual ~ChargePointProxy(); @@ -86,54 +86,55 @@ class ChargePointProxy : public ICentralSystem::IChargePoint, public ocpp::rpc:: /** @copydoc bool ICentralSystem::IChargePoint::cancelReservation(int) */ bool cancelReservation(int reservation_id) override; - /** @copydoc ocpp::types::AvailabilityStatus ICentralSystem::IChargePoint::changeAvailability(unsigned int, ocpp::types::AvailabilityType) */ - ocpp::types::AvailabilityStatus changeAvailability(unsigned int connector_id, ocpp::types::AvailabilityType availability) override; + /** @copydoc ocpp::types::ocpp16::AvailabilityStatus ICentralSystem::IChargePoint::changeAvailability(unsigned int, ocpp::types::ocpp16::AvailabilityType) */ + ocpp::types::ocpp16::AvailabilityStatus changeAvailability(unsigned int connector_id, + ocpp::types::ocpp16::AvailabilityType availability) override; - /** @copydoc ocpp::types::ConfigurationStatus ICentralSystem::IChargePoint::changeConfiguration(const std::string&, const std::string&) */ - ocpp::types::ConfigurationStatus changeConfiguration(const std::string& key, const std::string& value) override; + /** @copydoc ocpp::types::ocpp16::ConfigurationStatus ICentralSystem::IChargePoint::changeConfiguration(const std::string&, const std::string&) */ + ocpp::types::ocpp16::ConfigurationStatus changeConfiguration(const std::string& key, const std::string& value) override; /** @copydoc bool ICentralSystem::IChargePoint::clearCache() */ bool clearCache() override; /** @copydoc bool ICentralSystem::IChargePoint::clearChargingProfile(const ocpp::types::Optional&, const ocpp::types::Optional&, - const ocpp::types::Optional&, + const ocpp::types::Optional&, const ocpp::types::Optional&) */ - bool clearChargingProfile(const ocpp::types::Optional& profile_id, - const ocpp::types::Optional& connector_id, - const ocpp::types::Optional& purpose, - const ocpp::types::Optional& stack_level) override; + bool clearChargingProfile(const ocpp::types::Optional& profile_id, + const ocpp::types::Optional& connector_id, + const ocpp::types::Optional& purpose, + const ocpp::types::Optional& stack_level) override; /** @copydoc bool ICentralSystem::IChargePoint::dataTransfer(const std::string&, const std::string&, const std::string&, - ocpp::types::DataTransferStatus&, + ocpp::types::ocpp16::DataTransferStatus&, std::string&) */ - bool dataTransfer(const std::string& vendor_id, - const std::string& message_id, - const std::string& request_data, - ocpp::types::DataTransferStatus& status, - std::string& response_data) override; + bool dataTransfer(const std::string& vendor_id, + const std::string& message_id, + const std::string& request_data, + ocpp::types::ocpp16::DataTransferStatus& status, + std::string& response_data) override; /** @copydoc bool ICentralSystem::IChargePoint::getCompositeSchedule(unsigned int, std::chrono::seconds, - const ocpp::types::Optional&, + const ocpp::types::Optional&, ocpp::types::Optional&, ocpp::types::Optional&, - ocpp::types::Optional&) */ - bool getCompositeSchedule(unsigned int connector_id, - std::chrono::seconds duration, - const ocpp::types::Optional& unit, - ocpp::types::Optional& schedule_connector_id, - ocpp::types::Optional& schedule_start, - ocpp::types::Optional& schedule) override; + ocpp::types::Optional&) */ + bool getCompositeSchedule(unsigned int connector_id, + std::chrono::seconds duration, + const ocpp::types::Optional& unit, + ocpp::types::Optional& schedule_connector_id, + ocpp::types::Optional& schedule_start, + ocpp::types::Optional& schedule) override; /** @copydoc bool ICentralSystem::IChargePoint::getConfiguration(const std::vector&, - std::vector&, + std::vector&, std::vector&) */ - bool getConfiguration(const std::vector& keys, - std::vector& config_keys, - std::vector& unknown_keys) override; + bool getConfiguration(const std::vector& keys, + std::vector& config_keys, + std::vector& unknown_keys) override; /** @copydoc bool ICentralSystem::IChargePoint::getDiagnostics(const std::string&, const ocpp::types::Optional&, @@ -153,46 +154,47 @@ class ChargePointProxy : public ICentralSystem::IChargePoint, public ocpp::rpc:: /** @copydoc bool ICentralSystem::IChargePoint::remoteStartTransaction(const ocpp::types::Optional&, const std::string&, - const ocpp::types::Optional&) */ - bool remoteStartTransaction(const ocpp::types::Optional& connector_id, - const std::string& id_tag, - const ocpp::types::Optional& profile) override; + const ocpp::types::Optional&) */ + bool remoteStartTransaction(const ocpp::types::Optional& connector_id, + const std::string& id_tag, + const ocpp::types::Optional& profile) override; /** @copydoc bool ICentralSystem::IChargePoint::remoteStopTransaction(int) */ bool remoteStopTransaction(int transaction_id) override; - /** @copydoc ocpp::types::ReservationStatus ICentralSystem::IChargePoint::reserveNow(unsigned int, + /** @copydoc ocpp::types::ocpp16::ReservationStatus ICentralSystem::IChargePoint::reserveNow(unsigned int, const ocpp::types::DateTime&, const std::string&, const std::string&, int)*/ - ocpp::types::ReservationStatus reserveNow(unsigned int connector_id, - const ocpp::types::DateTime& expiry_date, - const std::string& id_tag, - const std::string& parent_id_tag, - int reservation_id) override; - - /** @copydoc bool ICentralSystem::IChargePoint::reset(ocpp::types::ResetType) */ - bool reset(ocpp::types::ResetType type) override; - - /** @copydoc ocpp::types::UpdateStatus ICentralSystem::IChargePoint::sendLocalList(int, - const std::vector&, - ocpp::types::UpdateType) */ - ocpp::types::UpdateStatus sendLocalList(int version, - const std::vector& authorization_list, - ocpp::types::UpdateType update_type) override; - - /** @copydoc ocpp::types::ChargingProfileStatus ICentralSystem::IChargePoint::setChargingProfile(unsigned int, - const ocpp::types::ChargingProfile&) */ - ocpp::types::ChargingProfileStatus setChargingProfile(unsigned int connector_id, const ocpp::types::ChargingProfile& profile) override; - - /** @copydoc ocpp::types::TriggerMessageStatus ICentralSystem::IChargePoint::triggerMessage(ocpp::types::MessageTrigger, + ocpp::types::ocpp16::ReservationStatus reserveNow(unsigned int connector_id, + const ocpp::types::DateTime& expiry_date, + const std::string& id_tag, + const std::string& parent_id_tag, + int reservation_id) override; + + /** @copydoc bool ICentralSystem::IChargePoint::reset(ocpp::types::ocpp16::ResetType) */ + bool reset(ocpp::types::ocpp16::ResetType type) override; + + /** @copydoc ocpp::types::ocpp16::UpdateStatus ICentralSystem::IChargePoint::sendLocalList(int, + const std::vector&, + ocpp::types::ocpp16::UpdateType) */ + ocpp::types::ocpp16::UpdateStatus sendLocalList(int version, + const std::vector& authorization_list, + ocpp::types::ocpp16::UpdateType update_type) override; + + /** @copydoc ocpp::types::ocpp16::ChargingProfileStatus ICentralSystem::IChargePoint::setChargingProfile(unsigned int, + const ocpp::types::ocpp16::ChargingProfile&) */ + ocpp::types::ocpp16::ChargingProfileStatus setChargingProfile(unsigned int connector_id, + const ocpp::types::ocpp16::ChargingProfile& profile) override; + + /** @copydoc ocpp::types::ocpp16::TriggerMessageStatus ICentralSystem::IChargePoint::triggerMessage(ocpp::types::ocpp16::MessageTrigger, const ocpp::types::Optional) */ - ocpp::types::TriggerMessageStatus triggerMessage(ocpp::types::MessageTrigger message, - const ocpp::types::Optional connector_id) override; + ocpp::types::ocpp16::TriggerMessageStatus triggerMessage(ocpp::types::ocpp16::MessageTrigger message, + const ocpp::types::Optional connector_id) override; - /** @copydoc ocpp::types::UnlockStatus ICentralSystem::IChargePoint::unlockConnector(unsigned int) */ - ocpp::types::UnlockStatus unlockConnector(unsigned int connector_id) override; + /** @copydoc ocpp::types::ocpp16::UnlockStatus ICentralSystem::IChargePoint::unlockConnector(unsigned int) */ + ocpp::types::ocpp16::UnlockStatus unlockConnector(unsigned int connector_id) override; /** @copydoc bool ICentralSystem::IChargePoint::updateFirmware(const std::string&, const ocpp::types::Optional&, @@ -208,20 +210,21 @@ class ChargePointProxy : public ICentralSystem::IChargePoint, public ocpp::rpc:: /** @copydoc bool ICentralSystem::IChargePoint::certificateSigned(const ocpp::x509::Certificate&) */ bool certificateSigned(const ocpp::x509::Certificate& certificate_chain) override; - /** @copydoc ocpp::types::DeleteCertificateStatusEnumType ICentralSystem::IChargePoint::deleteCertificate(const ocpp::types::CertificateHashDataType&) */ - ocpp::types::DeleteCertificateStatusEnumType deleteCertificate(const ocpp::types::CertificateHashDataType& certificate) override; + /** @copydoc ocpp::types::ocpp16::DeleteCertificateStatusEnumType ICentralSystem::IChargePoint::deleteCertificate(const ocpp::types::ocpp16::CertificateHashDataType&) */ + ocpp::types::ocpp16::DeleteCertificateStatusEnumType deleteCertificate( + const ocpp::types::ocpp16::CertificateHashDataType& certificate) override; - /** @copydoc ocpp::types::TriggerMessageStatusEnumType ICentralSystem::IChargePoint::extendedTriggerMessage(ocpp::types::MessageTriggerEnumType, + /** @copydoc ocpp::types::ocpp16::TriggerMessageStatusEnumType ICentralSystem::IChargePoint::extendedTriggerMessage(ocpp::types::ocpp16::MessageTriggerEnumType, const ocpp::types::Optional) */ - ocpp::types::TriggerMessageStatusEnumType extendedTriggerMessage(ocpp::types::MessageTriggerEnumType message, - const ocpp::types::Optional connector_id) override; + ocpp::types::ocpp16::TriggerMessageStatusEnumType extendedTriggerMessage( + ocpp::types::ocpp16::MessageTriggerEnumType message, const ocpp::types::Optional connector_id) override; - /** @copydoc bool ICentralSystem::IChargePoint::getInstalledCertificateIds(ocpp::types::CertificateUseEnumType, - std::vector&) */ - bool getInstalledCertificateIds(ocpp::types::CertificateUseEnumType type, - std::vector& certificates) override; + /** @copydoc bool ICentralSystem::IChargePoint::getInstalledCertificateIds(ocpp::types::ocpp16::CertificateUseEnumType, + std::vector&) */ + bool getInstalledCertificateIds(ocpp::types::ocpp16::CertificateUseEnumType type, + std::vector& certificates) override; - /** @copydoc bool ICentralSystem::IChargePoint::getLog(ocpp::types::LogEnumType, + /** @copydoc bool ICentralSystem::IChargePoint::getLog(ocpp::types::ocpp16::LogEnumType, int, const std::string&, const ocpp::types::Optional&, @@ -229,7 +232,7 @@ class ChargePointProxy : public ICentralSystem::IChargePoint, public ocpp::rpc:: const ocpp::types::Optional&, const ocpp::types::Optional&, std::string&) */ - bool getLog(ocpp::types::LogEnumType type, + bool getLog(ocpp::types::ocpp16::LogEnumType type, int request_id, const std::string& uri, const ocpp::types::Optional& retries, @@ -238,12 +241,12 @@ class ChargePointProxy : public ICentralSystem::IChargePoint, public ocpp::rpc:: const ocpp::types::Optional& stop, std::string& log_filename) override; - /** @copydoc ocpp::types::CertificateStatusEnumType ICentralSystem::installCertificate(ocpp::types::CertificateUseEnumType, + /** @copydoc ocpp::types::ocpp16::CertificateStatusEnumType ICentralSystem::installCertificate(ocpp::types::ocpp16::CertificateUseEnumType, const ocpp::x509::Certificate&) */ - ocpp::types::CertificateStatusEnumType installCertificate(ocpp::types::CertificateUseEnumType type, - const ocpp::x509::Certificate& certificate) override; + ocpp::types::ocpp16::CertificateStatusEnumType installCertificate(ocpp::types::ocpp16::CertificateUseEnumType type, + const ocpp::x509::Certificate& certificate) override; - /** @copydoc ocpp::types::UpdateFirmwareStatusEnumType ICentralSystem::signedUpdateFirmware( + /** @copydoc ocpp::types::ocpp16::UpdateFirmwareStatusEnumType ICentralSystem::signedUpdateFirmware( int, const std::string&, const ocpp::types::Optional&, @@ -252,35 +255,36 @@ class ChargePointProxy : public ICentralSystem::IChargePoint, public ocpp::rpc:: const ocpp::types::Optional&, const ocpp::x509::Certificate&, const std::string&) */ - ocpp::types::UpdateFirmwareStatusEnumType signedUpdateFirmware(int request_id, - const std::string& uri, - const ocpp::types::Optional& retries, - const ocpp::types::DateTime& retrieve_date, - const ocpp::types::Optional& retry_interval, - const ocpp::types::Optional& install_date, - const ocpp::x509::Certificate& signing_certificate, - const std::string& signature) override; + ocpp::types::ocpp16::UpdateFirmwareStatusEnumType signedUpdateFirmware( + int request_id, + const std::string& uri, + const ocpp::types::Optional& retries, + const ocpp::types::DateTime& retrieve_date, + const ocpp::types::Optional& retry_interval, + const ocpp::types::Optional& install_date, + const ocpp::x509::Certificate& signing_certificate, + const std::string& signature) override; // ISO 15118 PnC extensions /** @copydoc bool ICentralSystem::IChargePoint::iso15118CertificateSigned(const ocpp::x509::Certificate&) */ bool iso15118CertificateSigned(const ocpp::x509::Certificate& certificate_chain) override; - /** @copydoc ocpp::types::DeleteCertificateStatusEnumType ICentralSystem::IChargePoint::iso15118DeleteCertificate( - const ocpp::types::CertificateHashDataType&) */ - ocpp::types::DeleteCertificateStatusEnumType iso15118DeleteCertificate( - const ocpp::types::CertificateHashDataType& certificate) override; + /** @copydoc ocpp::types::ocpp16::DeleteCertificateStatusEnumType ICentralSystem::IChargePoint::iso15118DeleteCertificate( + const ocpp::types::ocpp16::CertificateHashDataType&) */ + ocpp::types::ocpp16::DeleteCertificateStatusEnumType iso15118DeleteCertificate( + const ocpp::types::ocpp16::CertificateHashDataType& certificate) override; - /** @copydoc bool ICentralSystem::IChargePoint::iso15118GetInstalledCertificateIds(const std::vector&, - std::vector&) */ - bool iso15118GetInstalledCertificateIds(const std::vector& types, - std::vector& certificates) override; + /** @copydoc bool ICentralSystem::IChargePoint::iso15118GetInstalledCertificateIds(const std::vector&, + std::vector&) */ + bool iso15118GetInstalledCertificateIds(const std::vector& types, + std::vector& certificates) override; - /** @copydoc ocpp::types::InstallCertificateStatusEnumType ICentralSystem::IChargePoint::iso15118CertificateSigned( - ocpp::types::InstallCertificateUseEnumType, + /** @copydoc ocpp::types::ocpp16::InstallCertificateStatusEnumType ICentralSystem::IChargePoint::iso15118CertificateSigned( + ocpp::types::ocpp16::InstallCertificateUseEnumType, const ocpp::x509::Certificate&) */ - ocpp::types::InstallCertificateStatusEnumType iso15118InstallCertificate(ocpp::types::InstallCertificateUseEnumType type, - const ocpp::x509::Certificate& certificate) override; + ocpp::types::ocpp16::InstallCertificateStatusEnumType iso15118InstallCertificate( + ocpp::types::ocpp16::InstallCertificateUseEnumType type, const ocpp::x509::Certificate& certificate) override; /** @copydoc bool ICentralSystem::IChargePoint::iso15118TriggerSignCertificate() */ bool iso15118TriggerSignCertificate() override; @@ -318,10 +322,10 @@ class ChargePointProxy : public ICentralSystem::IChargePoint, public ocpp::rpc:: std::shared_ptr& rpcClient() { return m_rpc; } /** @brief Messages validator */ - const ocpp::messages::MessagesValidator& messagesValidator() { return m_messages_validator; } + const ocpp::messages::ocpp16::MessagesValidator& messagesValidator() { return m_messages_validator; } /** @brief Messages converters */ - ocpp::messages::MessagesConverter& messagesConverter() { return m_messages_converter; } + ocpp::messages::ocpp16::MessagesConverter& messagesConverter() { return m_messages_converter; } private: /** @brief Central System instance associated to the charge point */ @@ -337,9 +341,9 @@ class ChargePointProxy : public ICentralSystem::IChargePoint, public ocpp::rpc:: /** @brief Request handler */ ChargePointHandler m_handler; /** @brief Messages validator */ - const ocpp::messages::MessagesValidator& m_messages_validator; + const ocpp::messages::ocpp16::MessagesValidator& m_messages_validator; /** @brief Messages converters */ - ocpp::messages::MessagesConverter& m_messages_converter; + ocpp::messages::ocpp16::MessagesConverter& m_messages_converter; /** @brief User request handler */ IChargePointRequestHandler* m_user_handler; @@ -361,25 +365,24 @@ class ChargePointProxy : public ICentralSystem::IChargePoint, public ocpp::rpc:: auto resp_converter = m_messages_converter.getResponseConverter(type_id); // Prepare request - ocpp::messages::DataTransferReq req; - req.vendorId.assign(ocpp::messages::ISO15118_VENDOR_ID); + ocpp::messages::ocpp16::DataTransferReq req; + req.vendorId.assign(ocpp::messages::ocpp16::ISO15118_VENDOR_ID); req.messageId.value().assign(action); // Convert request to JSON - rapidjson::Document json_req; + rapidjson::Document json_req(rapidjson::kObjectType); rapidjson::StringBuffer buffer; rapidjson::Writer writer(buffer); - json_req.Parse("{}"); req_converter->setAllocator(&json_req.GetAllocator()); req_converter->toJson(request, json_req); json_req.Accept(writer); req.data.value() = buffer.GetString(); // Send request - ocpp::messages::DataTransferConf resp; - if (m_msg_sender.call(ocpp::messages::DATA_TRANSFER_ACTION, req, resp) == ocpp::messages::CallResult::Ok) + ocpp::messages::ocpp16::DataTransferConf resp; + if (m_msg_sender.call(ocpp::messages::ocpp16::DATA_TRANSFER_ACTION, req, resp) == ocpp::messages::CallResult::Ok) { - if (resp.status == ocpp::types::DataTransferStatus::Accepted) + if (resp.status == ocpp::types::ocpp16::DataTransferStatus::Accepted) { try { @@ -405,7 +408,7 @@ class ChargePointProxy : public ICentralSystem::IChargePoint, public ocpp::rpc:: } else { - LOG_ERROR << "[ISO15118] Data transfer error : " << ocpp::types::DataTransferStatusHelper.toString(resp.status); + LOG_ERROR << "[ISO15118] Data transfer error : " << ocpp::types::ocpp16::DataTransferStatusHelper.toString(resp.status); } } diff --git a/src/centralsystem/config/InternalConfigKeys.h b/src/ocpp16/centralsystem/config/InternalConfigKeys.h similarity index 100% rename from src/centralsystem/config/InternalConfigKeys.h rename to src/ocpp16/centralsystem/config/InternalConfigKeys.h diff --git a/src/centralsystem/interface/ICentralSystem.h b/src/ocpp16/centralsystem/interface/ICentralSystem.h similarity index 82% rename from src/centralsystem/interface/ICentralSystem.h rename to src/ocpp16/centralsystem/interface/ICentralSystem.h index 8cf485ab..d7ff40df 100644 --- a/src/centralsystem/interface/ICentralSystem.h +++ b/src/ocpp16/centralsystem/interface/ICentralSystem.h @@ -165,8 +165,8 @@ class ICentralSystem * @param availability Availability state (see AvailabilityType documentation) * @return Operation status (see AvailabilityStatus documentation) */ - virtual ocpp::types::AvailabilityStatus changeAvailability(unsigned int connector_id, - ocpp::types::AvailabilityType availability) = 0; + virtual ocpp::types::ocpp16::AvailabilityStatus changeAvailability(unsigned int connector_id, + ocpp::types::ocpp16::AvailabilityType availability) = 0; /** * @brief Change the value of a configuration key @@ -174,7 +174,7 @@ class ICentralSystem * @param value New value * @return Operation status (see ConfigurationStatus documentation) */ - virtual ocpp::types::ConfigurationStatus changeConfiguration(const std::string& key, const std::string& value) = 0; + virtual ocpp::types::ocpp16::ConfigurationStatus changeConfiguration(const std::string& key, const std::string& value) = 0; /** * @brief Clear the authentication cache @@ -190,10 +190,10 @@ class ICentralSystem * @param stack_level Stack level of the charging profile * @return true if at least one charging profile has been cleared, false otherwise */ - virtual bool clearChargingProfile(const ocpp::types::Optional& profile_id, - const ocpp::types::Optional& connector_id, - const ocpp::types::Optional& purpose, - const ocpp::types::Optional& stack_level) = 0; + virtual bool clearChargingProfile(const ocpp::types::Optional& profile_id, + const ocpp::types::Optional& connector_id, + const ocpp::types::Optional& purpose, + const ocpp::types::Optional& stack_level) = 0; /** * @brief Send a data transfer request @@ -204,11 +204,11 @@ class ICentralSystem * @param response_data Data associated with the response * @return true if the data transfer has been done, false otherwise */ - virtual bool dataTransfer(const std::string& vendor_id, - const std::string& message_id, - const std::string& request_data, - ocpp::types::DataTransferStatus& status, - std::string& response_data) = 0; + virtual bool dataTransfer(const std::string& vendor_id, + const std::string& message_id, + const std::string& request_data, + ocpp::types::ocpp16::DataTransferStatus& status, + std::string& response_data) = 0; /** * @brief Get a smart charging composite schedule * @param connector_id Id of the connector for which the schedule is requested @@ -219,12 +219,12 @@ class ICentralSystem * @param schedule Computed composite schedule * @return true if the composite schedule has been computed, false otherwise */ - virtual bool getCompositeSchedule(unsigned int connector_id, - std::chrono::seconds duration, - const ocpp::types::Optional& unit, - ocpp::types::Optional& schedule_connector_id, - ocpp::types::Optional& schedule_start, - ocpp::types::Optional& schedule) = 0; + virtual bool getCompositeSchedule(unsigned int connector_id, + std::chrono::seconds duration, + const ocpp::types::Optional& unit, + ocpp::types::Optional& schedule_connector_id, + ocpp::types::Optional& schedule_start, + ocpp::types::Optional& schedule) = 0; /** * @brief Get the value of the configuration keys @@ -233,9 +233,9 @@ class ICentralSystem * @param unknown_keys Unknown configuration keys * @return true if the configuration has been retrieved, false otherwise */ - virtual bool getConfiguration(const std::vector& keys, - std::vector& config_keys, - std::vector& unknown_keys) = 0; + virtual bool getConfiguration(const std::vector& keys, + std::vector& config_keys, + std::vector& unknown_keys) = 0; /** * @brief Get the diagnostic file @@ -268,9 +268,9 @@ class ICentralSystem * @param profile Profile to be used for the requested transaction * @return true if the request has been accepted, false otherwise */ - virtual bool remoteStartTransaction(const ocpp::types::Optional& connector_id, - const std::string& id_tag, - const ocpp::types::Optional& profile) = 0; + virtual bool remoteStartTransaction(const ocpp::types::Optional& connector_id, + const std::string& id_tag, + const ocpp::types::Optional& profile) = 0; /** * @brief Send a remote stop transaction request @@ -288,18 +288,18 @@ class ICentralSystem * @param reservation_id Unique id for this reservation * @return Operation status (see ReservationStatus documentation) */ - virtual ocpp::types::ReservationStatus reserveNow(unsigned int connector_id, - const ocpp::types::DateTime& expiry_date, - const std::string& id_tag, - const std::string& parent_id_tag, - int reservation_id) = 0; + virtual ocpp::types::ocpp16::ReservationStatus reserveNow(unsigned int connector_id, + const ocpp::types::DateTime& expiry_date, + const std::string& id_tag, + const std::string& parent_id_tag, + int reservation_id) = 0; /** * @brief Reset the charge point * @param type Type of reset * @return true if the request has been accepted, false otherwise */ - virtual bool reset(ocpp::types::ResetType type) = 0; + virtual bool reset(ocpp::types::ocpp16::ResetType type) = 0; /** * @brief Send or upgrade a local authorization list @@ -308,9 +308,10 @@ class ICentralSystem * @param update_type Update type * @return Operation status (see UpdateStatus documentation) */ - virtual ocpp::types::UpdateStatus sendLocalList(int version, - const std::vector& authorization_list, - ocpp::types::UpdateType update_type) = 0; + virtual ocpp::types::ocpp16::UpdateStatus sendLocalList( + int version, + const std::vector& authorization_list, + ocpp::types::ocpp16::UpdateType update_type) = 0; /** * @brief Set a charging profile in the charge point @@ -318,8 +319,8 @@ class ICentralSystem * @param profile Charging profile to apply * @return Operation status (see ChargingProfileStatus documentation) */ - virtual ocpp::types::ChargingProfileStatus setChargingProfile(unsigned int connector_id, - const ocpp::types::ChargingProfile& profile) = 0; + virtual ocpp::types::ocpp16::ChargingProfileStatus setChargingProfile(unsigned int connector_id, + const ocpp::types::ocpp16::ChargingProfile& profile) = 0; /** * @brief Request the send of a specific message @@ -327,15 +328,15 @@ class ICentralSystem * @param connector_id Id of the connector on which the message applies * @return Operation status (see TriggerMessageStatus documentation) */ - virtual ocpp::types::TriggerMessageStatus triggerMessage(ocpp::types::MessageTrigger message, - const ocpp::types::Optional connector_id) = 0; + virtual ocpp::types::ocpp16::TriggerMessageStatus triggerMessage(ocpp::types::ocpp16::MessageTrigger message, + const ocpp::types::Optional connector_id) = 0; /** * @brief Unlock a connector * @param connector_id Id of the connector to unlock * @return Operation status (see UnlockStatus documentation) */ - virtual ocpp::types::UnlockStatus unlockConnector(unsigned int connector_id) = 0; + virtual ocpp::types::ocpp16::UnlockStatus unlockConnector(unsigned int connector_id) = 0; /** * @brief Update the firmware of the charge point @@ -364,7 +365,8 @@ class ICentralSystem * @param certificate Certificate information * @return Operation status (see DeleteCertificateStatusEnumType documentation) */ - virtual ocpp::types::DeleteCertificateStatusEnumType deleteCertificate(const ocpp::types::CertificateHashDataType& certificate) = 0; + virtual ocpp::types::ocpp16::DeleteCertificateStatusEnumType deleteCertificate( + const ocpp::types::ocpp16::CertificateHashDataType& certificate) = 0; /** * @brief Request the send of a specific message @@ -372,8 +374,8 @@ class ICentralSystem * @param connector_id Id of the connector on which the message applies * @return Operation status (see TriggerMessageStatus documentation) */ - virtual ocpp::types::TriggerMessageStatusEnumType extendedTriggerMessage( - ocpp::types::MessageTriggerEnumType message, const ocpp::types::Optional connector_id) = 0; + virtual ocpp::types::ocpp16::TriggerMessageStatusEnumType extendedTriggerMessage( + ocpp::types::ocpp16::MessageTriggerEnumType message, const ocpp::types::Optional connector_id) = 0; /** * @brief Get the list of installed CA certificates @@ -381,8 +383,8 @@ class ICentralSystem * @param certificates Certificates information * @return true is the list has been retrieved, false otherwise */ - virtual bool getInstalledCertificateIds(ocpp::types::CertificateUseEnumType type, - std::vector& certificates) = 0; + virtual bool getInstalledCertificateIds(ocpp::types::ocpp16::CertificateUseEnumType type, + std::vector& certificates) = 0; /** * @brief Get the log file * @param type Type of log to retrieve @@ -395,7 +397,7 @@ class ICentralSystem * @param log_filename Name of the diagnostic file which will be uploaded * @return true if the operation has started, false otherwise */ - virtual bool getLog(ocpp::types::LogEnumType type, + virtual bool getLog(ocpp::types::ocpp16::LogEnumType type, int request_id, const std::string& uri, const ocpp::types::Optional& retries, @@ -410,8 +412,8 @@ class ICentralSystem * @param certificate CA certificate to install * @return Operation status (see CertificateStatusEnumType documentation) */ - virtual ocpp::types::CertificateStatusEnumType installCertificate(ocpp::types::CertificateUseEnumType type, - const ocpp::x509::Certificate& certificate) = 0; + virtual ocpp::types::ocpp16::CertificateStatusEnumType installCertificate(ocpp::types::ocpp16::CertificateUseEnumType type, + const ocpp::x509::Certificate& certificate) = 0; /** * @brief Update the firmware of the charge point @@ -425,7 +427,7 @@ class ICentralSystem * @param signature Base64 encoded firmware signature * @return Operation status (see UpdateFirmwareStatusEnumType documentation) */ - virtual ocpp::types::UpdateFirmwareStatusEnumType signedUpdateFirmware( + virtual ocpp::types::ocpp16::UpdateFirmwareStatusEnumType signedUpdateFirmware( int request_id, const std::string& uri, const ocpp::types::Optional& retries, @@ -449,8 +451,8 @@ class ICentralSystem * @param certificate Certificate information * @return Operation status (see DeleteCertificateStatusEnumType documentation) */ - virtual ocpp::types::DeleteCertificateStatusEnumType iso15118DeleteCertificate( - const ocpp::types::CertificateHashDataType& certificate) = 0; + virtual ocpp::types::ocpp16::DeleteCertificateStatusEnumType iso15118DeleteCertificate( + const ocpp::types::ocpp16::CertificateHashDataType& certificate) = 0; /** * @brief Get the list of installed ISO15118 CA certificates @@ -458,8 +460,8 @@ class ICentralSystem * @param certificates Certificates information * @return true is the list has been retrieved, false otherwise */ - virtual bool iso15118GetInstalledCertificateIds(const std::vector& types, - std::vector& certificates) = 0; + virtual bool iso15118GetInstalledCertificateIds(const std::vector& types, + std::vector& certificates) = 0; /** * @brief Install an ISO15118 CA certificate @@ -467,8 +469,8 @@ class ICentralSystem * @param certificate CA certificate to install * @return Operation status (see InstallCertificateStatusEnumType documentation) */ - virtual ocpp::types::InstallCertificateStatusEnumType iso15118InstallCertificate(ocpp::types::InstallCertificateUseEnumType type, - const ocpp::x509::Certificate& certificate) = 0; + virtual ocpp::types::ocpp16::InstallCertificateStatusEnumType iso15118InstallCertificate( + ocpp::types::ocpp16::InstallCertificateUseEnumType type, const ocpp::x509::Certificate& certificate) = 0; /** * @brief Request the send of an ISO15118 SignCertificate request from the charge point diff --git a/src/centralsystem/interface/ICentralSystemConfig.h b/src/ocpp16/centralsystem/interface/ICentralSystemConfig.h similarity index 100% rename from src/centralsystem/interface/ICentralSystemConfig.h rename to src/ocpp16/centralsystem/interface/ICentralSystemConfig.h diff --git a/src/centralsystem/interface/ICentralSystemEventsHandler.h b/src/ocpp16/centralsystem/interface/ICentralSystemEventsHandler.h similarity index 100% rename from src/centralsystem/interface/ICentralSystemEventsHandler.h rename to src/ocpp16/centralsystem/interface/ICentralSystemEventsHandler.h diff --git a/src/centralsystem/interface/IChargePointRequestHandler.h b/src/ocpp16/centralsystem/interface/IChargePointRequestHandler.h similarity index 71% rename from src/centralsystem/interface/IChargePointRequestHandler.h rename to src/ocpp16/centralsystem/interface/IChargePointRequestHandler.h index 956d03c1..9eab7c81 100644 --- a/src/centralsystem/interface/IChargePointRequestHandler.h +++ b/src/ocpp16/centralsystem/interface/IChargePointRequestHandler.h @@ -54,7 +54,7 @@ class IChargePointRequestHandler * @param id_tag Id tag to check * @return Authorization informations for the id tag (see IdTagInfo documentation) */ - virtual ocpp::types::IdTagInfo authorize(const std::string& id_tag) = 0; + virtual ocpp::types::ocpp16::IdTagInfo authorize(const std::string& id_tag) = 0; /** * @brief Called to get registration status on boot notification reception @@ -68,14 +68,14 @@ class IChargePointRequestHandler * @param meter_type Type of the main electrical meter of the Charge Point * @return Registration status of the charge point (see RegistrationStatus documentation) */ - virtual ocpp::types::RegistrationStatus bootNotification(const std::string& model, - const std::string& serial_number, - const std::string& vendor, - const std::string& firmware_version, - const std::string& iccid, - const std::string& imsi, - const std::string& meter_serial_number, - const std::string& meter_type) = 0; + virtual ocpp::types::ocpp16::RegistrationStatus bootNotification(const std::string& model, + const std::string& serial_number, + const std::string& vendor, + const std::string& firmware_version, + const std::string& iccid, + const std::string& imsi, + const std::string& meter_serial_number, + const std::string& meter_type) = 0; /** * @brief Called when a data transfer request has been received @@ -85,22 +85,22 @@ class IChargePointRequestHandler * @param response_data Data associated with the response * @return Response status (see DataTransferStatus documentation) */ - virtual ocpp::types::DataTransferStatus dataTransfer(const std::string& vendor_id, - const std::string& message_id, - const std::string& request_data, - std::string& response_data) = 0; + virtual ocpp::types::ocpp16::DataTransferStatus dataTransfer(const std::string& vendor_id, + const std::string& message_id, + const std::string& request_data, + std::string& response_data) = 0; /** * @brief Called when a diagnostic status notification has been received * @param status Diagnostic status */ - virtual void diagnosticStatusNotification(ocpp::types::DiagnosticsStatus status) = 0; + virtual void diagnosticStatusNotification(ocpp::types::ocpp16::DiagnosticsStatus status) = 0; /** * @brief Called when a firmware status notification has been received * @param status Firmware status */ - virtual void firmwareStatusNotification(ocpp::types::FirmwareStatus status) = 0; + virtual void firmwareStatusNotification(ocpp::types::ocpp16::FirmwareStatus status) = 0; /** * @brief Called when meter values have been received @@ -108,9 +108,9 @@ class IChargePointRequestHandler * @param transaction_id Id of the transaction concerned by the meter values * @param meter_values Meter values */ - virtual void meterValues(unsigned int connector_id, - const ocpp::types::Optional& transaction_id, - const std::vector& meter_values) = 0; + virtual void meterValues(unsigned int connector_id, + const ocpp::types::Optional& transaction_id, + const std::vector& meter_values) = 0; /** * @brief Called to get an authorization to start a transaction @@ -122,12 +122,12 @@ class IChargePointRequestHandler * @param transaction_id Id of the transaction * @return Authorization informations for the id tag (see IdTagInfo documentation) */ - virtual ocpp::types::IdTagInfo startTransaction(unsigned int connector_id, - const std::string& id_tag, - int meter_start, - const ocpp::types::Optional& reservation_id, - const ocpp::types::DateTime& timestamp, - int& transaction_id) = 0; + virtual ocpp::types::ocpp16::IdTagInfo startTransaction(unsigned int connector_id, + const std::string& id_tag, + int meter_start, + const ocpp::types::Optional& reservation_id, + const ocpp::types::DateTime& timestamp, + int& transaction_id) = 0; /** * @brief Called when a status notification has been received @@ -139,13 +139,13 @@ class IChargePointRequestHandler * @param vendor_id Vendor specific implementation identifier * @param vendor_error Vendor specific error code */ - virtual void statusNotification(unsigned int connector_id, - ocpp::types::ChargePointErrorCode error_code, - const std::string& info, - ocpp::types::ChargePointStatus status, - const ocpp::types::DateTime& timestamp, - const std::string& vendor_id, - const std::string& vendor_error) = 0; + virtual void statusNotification(unsigned int connector_id, + ocpp::types::ocpp16::ChargePointErrorCode error_code, + const std::string& info, + ocpp::types::ocpp16::ChargePointStatus status, + const ocpp::types::DateTime& timestamp, + const std::string& vendor_id, + const std::string& vendor_error) = 0; /** * @brief Called when an end of transaction has been received @@ -157,12 +157,13 @@ class IChargePointRequestHandler * @param transaction_data Transaction related meter values * @return Authorization informations for the id tag (see IdTagInfo documentation) */ - virtual ocpp::types::Optional stopTransaction(const std::string& id_tag, - int meter_stop, - const ocpp::types::DateTime& timestamp, - int transaction_id, - ocpp::types::Reason reason, - const std::vector& transaction_data) = 0; + virtual ocpp::types::Optional stopTransaction( + const std::string& id_tag, + int meter_stop, + const ocpp::types::DateTime& timestamp, + int transaction_id, + ocpp::types::ocpp16::Reason reason, + const std::vector& transaction_data) = 0; // Security extensions @@ -171,7 +172,8 @@ class IChargePointRequestHandler * @param status Log status * @param request_id Request id of the correspondin GetLog request */ - virtual void logStatusNotification(ocpp::types::UploadLogStatusEnumType status, const ocpp::types::Optional& request_id) = 0; + virtual void logStatusNotification(ocpp::types::ocpp16::UploadLogStatusEnumType status, + const ocpp::types::Optional& request_id) = 0; /** * @brief Called when a security event notification has been received @@ -193,8 +195,8 @@ class IChargePointRequestHandler * @param status Firmware update status * @param request_id Request id of the correspondin GetLog request */ - virtual void signedFirmwareUpdateStatusNotification(ocpp::types::FirmwareStatusEnumType status, - const ocpp::types::Optional& request_id) = 0; + virtual void signedFirmwareUpdateStatusNotification(ocpp::types::ocpp16::FirmwareStatusEnumType status, + const ocpp::types::Optional& request_id) = 0; // ISO 15118 PnC extensions @@ -208,11 +210,11 @@ class IChargePointRequestHandler * return 'CertificateRevoked * @return Authorization status (see AuthorizationStatus type) */ - virtual ocpp::types::IdTokenInfoType iso15118Authorize( - const ocpp::x509::Certificate& certificate, - const std::string& id_token, - const std::vector& cert_hash_data, - ocpp::types::Optional& cert_status) = 0; + virtual ocpp::types::ocpp16::IdTokenInfoType iso15118Authorize( + const ocpp::x509::Certificate& certificate, + const std::string& id_token, + const std::vector& cert_hash_data, + ocpp::types::Optional& cert_status) = 0; /** * @brief Called when the Charge Point wants to get or update an ISO15118 EV certificate @@ -222,10 +224,11 @@ class IChargePointRequestHandler * @param exi_response Raw CertificateInstallationRes response for the EV, Base64 encoded * @return Operation status (see Iso15118EVCertificateStatusEnumType enum) */ - virtual ocpp::types::Iso15118EVCertificateStatusEnumType iso15118GetEVCertificate(const std::string& iso15118_schema_version, - ocpp::types::CertificateActionEnumType action, - const std::string& exi_request, - std::string& exi_response) = 0; + virtual ocpp::types::ocpp16::Iso15118EVCertificateStatusEnumType iso15118GetEVCertificate( + const std::string& iso15118_schema_version, + ocpp::types::ocpp16::CertificateActionEnumType action, + const std::string& exi_request, + std::string& exi_response) = 0; /** * @brief Called when the CHarge Point wants to get the validity status of an ISO15118 certificate @@ -233,8 +236,8 @@ class IChargePointRequestHandler * @param ocsp_result OCSPResponse class as defined in IETF RFC 6960. DER encoded (as defined in IETF RFC 6960), and then base64 encoded * @return Operation status (see GetCertificateStatusEnumType enum) */ - virtual ocpp::types::GetCertificateStatusEnumType iso15118GetCertificateStatus(const ocpp::types::OcspRequestDataType& ocsp_request, - std::string& ocsp_result) = 0; + virtual ocpp::types::ocpp16::GetCertificateStatusEnumType iso15118GetCertificateStatus( + const ocpp::types::ocpp16::OcspRequestDataType& ocsp_request, std::string& ocsp_result) = 0; /** * @brief Called when a request to sign a new ISO15118 client certificat has been received diff --git a/src/chargepoint/CMakeLists.txt b/src/ocpp16/chargepoint/CMakeLists.txt similarity index 99% rename from src/chargepoint/CMakeLists.txt rename to src/ocpp16/chargepoint/CMakeLists.txt index 5e6a8f74..61fa3a75 100644 --- a/src/chargepoint/CMakeLists.txt +++ b/src/ocpp16/chargepoint/CMakeLists.txt @@ -53,7 +53,7 @@ target_include_directories(chargepoint PRIVATE authent target_link_libraries(chargepoint PUBLIC config database - messages + messages16 rpc helpers log diff --git a/src/chargepoint/ChargePoint.cpp b/src/ocpp16/chargepoint/ChargePoint.cpp similarity index 92% rename from src/chargepoint/ChargePoint.cpp rename to src/ocpp16/chargepoint/ChargePoint.cpp index 628617a9..68de92ca 100644 --- a/src/chargepoint/ChargePoint.cpp +++ b/src/ocpp16/chargepoint/ChargePoint.cpp @@ -45,6 +45,7 @@ along with OpenOCPP. If not, see . #include using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { @@ -425,8 +426,8 @@ bool ChargePoint::reconnect() return ret; } -/** @copydoc ocpp::types::RegistrationStatus IChargePoint::getRegistrationStatus() */ -ocpp::types::RegistrationStatus ChargePoint::getRegistrationStatus() +/** @copydoc ocpp::types::ocpp16::RegistrationStatus IChargePoint::getRegistrationStatus() */ +ocpp::types::ocpp16::RegistrationStatus ChargePoint::getRegistrationStatus() { RegistrationStatus ret = RegistrationStatus::Rejected; @@ -438,8 +439,8 @@ ocpp::types::RegistrationStatus ChargePoint::getRegistrationStatus() return ret; } -/** @copydoc ocpp::types::ChargePointStatus IChargePoint::getConnectorStatus(unsigned int) */ -ocpp::types::ChargePointStatus ChargePoint::getConnectorStatus(unsigned int connector_id) +/** @copydoc ocpp::types::ocpp16::ChargePointStatus IChargePoint::getConnectorStatus(unsigned int) */ +ocpp::types::ocpp16::ChargePointStatus ChargePoint::getConnectorStatus(unsigned int connector_id) { ChargePointStatus status = ChargePointStatus::Unavailable; @@ -457,17 +458,17 @@ ocpp::types::ChargePointStatus ChargePoint::getConnectorStatus(unsigned int conn } /** @copydoc bool IChargePoint::statusNotification(unsigned int, - * ocpp::types::ChargePointStatus, - * ocpp::types::ChargePointErrorCode, + * ocpp::types::ocpp16::ChargePointStatus, + * ocpp::types::ocpp16::ChargePointErrorCode, * const std::string&, * const std::string&, * const std::string&) */ -bool ChargePoint::statusNotification(unsigned int connector_id, - ocpp::types::ChargePointStatus status, - ocpp::types::ChargePointErrorCode error_code, - const std::string& info, - const std::string& vendor_id, - const std::string& vendor_error) +bool ChargePoint::statusNotification(unsigned int connector_id, + ocpp::types::ocpp16::ChargePointStatus status, + ocpp::types::ocpp16::ChargePointErrorCode error_code, + const std::string& info, + const std::string& vendor_id, + const std::string& vendor_error) { bool ret = false; @@ -483,8 +484,10 @@ bool ChargePoint::statusNotification(unsigned int connector return ret; } -/** @copydoc ocpp::types::AuthorizationStatus IChargePoint::authorize(unsigned int, const std::string&, std::string&) */ -ocpp::types::AuthorizationStatus ChargePoint::authorize(unsigned int connector_id, const std::string& id_tag, std::string& parent_id) +/** @copydoc ocpp::types::ocpp16::AuthorizationStatus IChargePoint::authorize(unsigned int, const std::string&, std::string&) */ +ocpp::types::ocpp16::AuthorizationStatus ChargePoint::authorize(unsigned int connector_id, + const std::string& id_tag, + std::string& parent_id) { AuthorizationStatus ret = AuthorizationStatus::Invalid; @@ -543,8 +546,8 @@ ocpp::types::AuthorizationStatus ChargePoint::authorize(unsigned int connector_i return ret; } -/** @copydoc ocpp::types::AuthorizationStatus IChargePoint::startTransaction(unsigned int, const std::string&, int&) */ -ocpp::types::AuthorizationStatus ChargePoint::startTransaction(unsigned int connector_id, const std::string& id_tag, int& transaction_id) +/** @copydoc ocpp::types::ocpp16::AuthorizationStatus IChargePoint::startTransaction(unsigned int, const std::string&, int&) */ +AuthorizationStatus ChargePoint::startTransaction(unsigned int connector_id, const std::string& id_tag, int& transaction_id) { AuthorizationStatus ret = AuthorizationStatus::Invalid; @@ -567,8 +570,8 @@ ocpp::types::AuthorizationStatus ChargePoint::startTransaction(unsigned int conn return ret; } -/** @copydoc bool IChargePoint::stopTransaction(unsigned int, const std::string&, ocpp::types::Reason) */ -bool ChargePoint::stopTransaction(unsigned int connector_id, const std::string& id_tag, ocpp::types::Reason reason) +/** @copydoc bool IChargePoint::stopTransaction(unsigned int, const std::string&, ocpp::types::ocpp16::Reason) */ +bool ChargePoint::stopTransaction(unsigned int connector_id, const std::string& id_tag, ocpp::types::ocpp16::Reason reason) { bool ret = false; @@ -594,13 +597,13 @@ bool ChargePoint::stopTransaction(unsigned int connector_id, const std::string& /** @copydoc bool IChargePoint::dataTransfer(const std::string&, const std::string&, const std::string&, - ocpp::types::DataTransferStatus&, + ocpp::types::ocpp16::DataTransferStatus&, std::string& ) */ -bool ChargePoint::dataTransfer(const std::string& vendor_id, - const std::string& message_id, - const std::string& request_data, - ocpp::types::DataTransferStatus& status, - std::string& response_data) +bool ChargePoint::dataTransfer(const std::string& vendor_id, + const std::string& message_id, + const std::string& request_data, + ocpp::types::ocpp16::DataTransferStatus& status, + std::string& response_data) { bool ret = false; @@ -623,8 +626,8 @@ bool ChargePoint::dataTransfer(const std::string& vendor_id, return ret; } -/** @copydoc bool IChargePoint::sendMeterValues(unsigned int, const std::vector&) */ -bool ChargePoint::sendMeterValues(unsigned int connector_id, const std::vector& values) +/** @copydoc bool IChargePoint::sendMeterValues(unsigned int, const std::vector&) */ +bool ChargePoint::sendMeterValues(unsigned int connector_id, const std::vector& values) { bool ret = false; @@ -648,13 +651,13 @@ bool ChargePoint::sendMeterValues(unsigned int connector_id, const std::vector&, - ocpp::types::Optional&, - ocpp::types::ChargingRateUnitType) */ -bool ChargePoint::getSetpoint(unsigned int connector_id, - ocpp::types::Optional& charge_point_setpoint, - ocpp::types::Optional& connector_setpoint, - ocpp::types::ChargingRateUnitType unit) + ocpp::types::Optional&, + ocpp::types::Optional&, + ocpp::types::ocpp16::ChargingRateUnitType) */ +bool ChargePoint::getSetpoint(unsigned int connector_id, + ocpp::types::Optional& charge_point_setpoint, + ocpp::types::Optional& connector_setpoint, + ocpp::types::ocpp16::ChargingRateUnitType unit) { bool ret = false; @@ -770,8 +773,8 @@ bool ChargePoint::signCertificate() return ret; } -/** @copydoc bool IChargePoint::notifySignedUpdateFirmwareStatus(ocpp::types::FirmwareStatusEnumType) */ -bool ChargePoint::notifySignedUpdateFirmwareStatus(ocpp::types::FirmwareStatusEnumType status) +/** @copydoc bool IChargePoint::notifySignedUpdateFirmwareStatus(ocpp::types::ocpp16::FirmwareStatusEnumType) */ +bool ChargePoint::notifySignedUpdateFirmwareStatus(ocpp::types::ocpp16::FirmwareStatusEnumType status) { bool ret = false; @@ -796,15 +799,15 @@ bool ChargePoint::notifySignedUpdateFirmwareStatus(ocpp::types::FirmwareStatusEn // ISO 15118 PnC extensions -/** @copydoc ocpp::types::AuthorizationStatus iso15118Authorize(const ocpp::x509::Certificate&, +/** @copydoc ocpp::types::ocpp16::AuthorizationStatus iso15118Authorize(const ocpp::x509::Certificate&, const std::string&, - const std::vector&, - ocpp::types::Optional&) */ -ocpp::types::AuthorizationStatus ChargePoint::iso15118Authorize( - const ocpp::x509::Certificate& certificate, - const std::string& id_token, - const std::vector& cert_hash_data, - ocpp::types::Optional& cert_status) + const std::vector&, + ocpp::types::Optional&) */ +ocpp::types::ocpp16::AuthorizationStatus ChargePoint::iso15118Authorize( + const ocpp::x509::Certificate& certificate, + const std::string& id_token, + const std::vector& cert_hash_data, + ocpp::types::Optional& cert_status) { AuthorizationStatus ret = AuthorizationStatus::Invalid; @@ -828,13 +831,13 @@ ocpp::types::AuthorizationStatus ChargePoint::iso15118Authorize( } /** @copydoc bool IChargePoint::iso15118GetEVCertificate(const std::string&, - ocpp::types::CertificateActionEnumType, + ocpp::types::ocpp16::CertificateActionEnumType, const std::string&, std::string&) */ -bool ChargePoint::iso15118GetEVCertificate(const std::string& iso15118_schema_version, - ocpp::types::CertificateActionEnumType action, - const std::string& exi_request, - std::string& exi_response) +bool ChargePoint::iso15118GetEVCertificate(const std::string& iso15118_schema_version, + ocpp::types::ocpp16::CertificateActionEnumType action, + const std::string& exi_request, + std::string& exi_response) { bool ret = false; @@ -858,8 +861,8 @@ bool ChargePoint::iso15118GetEVCertificate(const std::string& return ret; } -/** @copydoc bool IChargePoint::iso15118GetCertificateStatus(const ocpp::types::OcspRequestDataType&, std::string&) */ -bool ChargePoint::iso15118GetCertificateStatus(const ocpp::types::OcspRequestDataType& ocsp_request, std::string& ocsp_result) +/** @copydoc bool IChargePoint::iso15118GetCertificateStatus(const ocpp::types::ocpp16::OcspRequestDataType&, std::string&) */ +bool ChargePoint::iso15118GetCertificateStatus(const ocpp::types::ocpp16::OcspRequestDataType& ocsp_request, std::string& ocsp_result) { bool ret = false; @@ -1155,7 +1158,7 @@ bool ChargePoint::doConnect() // Reset registration status m_internal_config.setKey(LAST_REGISTRATION_STATUS_KEY, RegistrationStatusHelper.toString(RegistrationStatus::Rejected)); - + // Notify that the connection URL has changed m_events_handler.connectionUrlChanged(connection_url); @@ -1231,7 +1234,8 @@ bool ChargePoint::doConnect() */ ConfigManager& ChargePoint::getConfigManager(void) const { - if (!m_config_manager) { + if (!m_config_manager) + { throw std::runtime_error("Stack is not started!"); } return *m_config_manager.get(); @@ -1244,7 +1248,8 @@ ConfigManager& ChargePoint::getConfigManager(void) const */ StatusManager& ChargePoint::getStatusManager(void) const { - if (!m_status_manager) { + if (!m_status_manager) + { throw std::runtime_error("Stack is not started!"); } return *m_status_manager.get(); @@ -1257,7 +1262,8 @@ StatusManager& ChargePoint::getStatusManager(void) const */ AuthentManager& ChargePoint::getAuthentManager(void) const { - if (!m_authent_manager) { + if (!m_authent_manager) + { throw std::runtime_error("Stack is not started!"); } return *m_authent_manager.get(); @@ -1270,7 +1276,8 @@ AuthentManager& ChargePoint::getAuthentManager(void) const */ TransactionManager& ChargePoint::getTransactionManager(void) const { - if (!m_transaction_manager) { + if (!m_transaction_manager) + { throw std::runtime_error("Stack is not started!"); } return *m_transaction_manager.get(); @@ -1283,7 +1290,8 @@ TransactionManager& ChargePoint::getTransactionManager(void) const */ TriggerMessageManager& ChargePoint::getTriggerManager(void) const { - if (!m_trigger_manager) { + if (!m_trigger_manager) + { throw std::runtime_error("Stack is not started!"); } return *m_trigger_manager.get(); @@ -1296,7 +1304,8 @@ TriggerMessageManager& ChargePoint::getTriggerManager(void) const */ ReservationManager& ChargePoint::getReservationManager(void) const { - if (!m_reservation_manager) { + if (!m_reservation_manager) + { throw std::runtime_error("Stack is not started!"); } return *m_reservation_manager.get(); @@ -1309,7 +1318,8 @@ ReservationManager& ChargePoint::getReservationManager(void) const */ DataTransferManager& ChargePoint::getDataTransferManager(void) const { - if (!m_data_transfer_manager) { + if (!m_data_transfer_manager) + { throw std::runtime_error("Stack is not started!"); } return *m_data_transfer_manager.get(); @@ -1322,7 +1332,8 @@ DataTransferManager& ChargePoint::getDataTransferManager(void) const */ MeterValuesManager& ChargePoint::getMeterValuesManager(void) const { - if (!m_meter_values_manager) { + if (!m_meter_values_manager) + { throw std::runtime_error("Stack is not started!"); } return *m_meter_values_manager.get(); @@ -1335,7 +1346,8 @@ MeterValuesManager& ChargePoint::getMeterValuesManager(void) const */ SmartChargingManager& ChargePoint::getSmartChargingManager(void) const { - if (!m_smart_charging_manager) { + if (!m_smart_charging_manager) + { throw std::runtime_error("Stack is not started!"); } return *m_smart_charging_manager.get(); @@ -1348,7 +1360,8 @@ SmartChargingManager& ChargePoint::getSmartChargingManager(void) const */ MaintenanceManager& ChargePoint::getMaintenanceManager(void) const { - if (!m_maintenance_manager) { + if (!m_maintenance_manager) + { throw std::runtime_error("Stack is not started!"); } return *m_maintenance_manager.get(); @@ -1361,7 +1374,8 @@ MaintenanceManager& ChargePoint::getMaintenanceManager(void) const */ RequestFifoManager& ChargePoint::getRequestsFifoManager(void) const { - if (!m_requests_fifo_manager) { + if (!m_requests_fifo_manager) + { throw std::runtime_error("Stack is not started!"); } return *m_requests_fifo_manager.get(); @@ -1374,7 +1388,8 @@ RequestFifoManager& ChargePoint::getRequestsFifoManager(void) const */ Iso15118Manager& ChargePoint::getIso15118Manager(void) const { - if (!m_iso15118_manager) { + if (!m_iso15118_manager) + { throw std::runtime_error("Stack is not started!"); } return *m_iso15118_manager.get(); diff --git a/src/chargepoint/ChargePoint.h b/src/ocpp16/chargepoint/ChargePoint.h similarity index 77% rename from src/chargepoint/ChargePoint.h rename to src/ocpp16/chargepoint/ChargePoint.h index b5b63cc1..e834b118 100644 --- a/src/chargepoint/ChargePoint.h +++ b/src/ocpp16/chargepoint/ChargePoint.h @@ -105,56 +105,60 @@ class ChargePoint : public IChargePoint, /** @copydoc bool IChargePoint::reconnect() */ bool reconnect() override; - /** @copydoc ocpp::types::RegistrationStatus IChargePoint::getRegistrationStatus() */ - ocpp::types::RegistrationStatus getRegistrationStatus() override; + /** @copydoc ocpp::types::ocpp16::RegistrationStatus IChargePoint::getRegistrationStatus() */ + ocpp::types::ocpp16::RegistrationStatus getRegistrationStatus() override; - /** @copydoc ocpp::types::ChargePointStatus IChargePoint::getConnectorStatus(unsigned int) */ - ocpp::types::ChargePointStatus getConnectorStatus(unsigned int connector_id) override; + /** @copydoc ocpp::types::ocpp16::ChargePointStatus IChargePoint::getConnectorStatus(unsigned int) */ + ocpp::types::ocpp16::ChargePointStatus getConnectorStatus(unsigned int connector_id) override; /** @copydoc bool IChargePoint::statusNotification(unsigned int, - * ocpp::types::ChargePointStatus, - * ocpp::types::ChargePointErrorCode, + * ocpp::types::ocpp16::ChargePointStatus, + * ocpp::types::ocpp16::ChargePointErrorCode, * const std::string&, * const std::string&, * const std::string&) */ - bool statusNotification(unsigned int connector_id, - ocpp::types::ChargePointStatus status, - ocpp::types::ChargePointErrorCode error_code, - const std::string& info, - const std::string& vendor_id, - const std::string& vendor_error) override; - - /** @copydoc ocpp::types::AuthorizationStatus IChargePoint::authorize(unsigned int, const std::string&, std::string&) */ - ocpp::types::AuthorizationStatus authorize(unsigned int connector_id, const std::string& id_tag, std::string& parent_id) override; - - /** @copydoc ocpp::types::AuthorizationStatus IChargePoint::startTransaction(unsigned int, const std::string&, int&) */ - ocpp::types::AuthorizationStatus startTransaction(unsigned int connector_id, const std::string& id_tag, int& transaction_id) override; - - /** @copydoc bool IChargePoint::stopTransaction(unsigned int, const std::string&, ocpp::types::Reason) */ - bool stopTransaction(unsigned int connector_id, const std::string& id_tag, ocpp::types::Reason reason) override; + bool statusNotification(unsigned int connector_id, + ocpp::types::ocpp16::ChargePointStatus status, + ocpp::types::ocpp16::ChargePointErrorCode error_code, + const std::string& info, + const std::string& vendor_id, + const std::string& vendor_error) override; + + /** @copydoc ocpp::types::ocpp16::AuthorizationStatus IChargePoint::authorize(unsigned int, const std::string&, std::string&) */ + ocpp::types::ocpp16::AuthorizationStatus authorize(unsigned int connector_id, + const std::string& id_tag, + std::string& parent_id) override; + + /** @copydoc ocpp::types::ocpp16::AuthorizationStatus IChargePoint::startTransaction(unsigned int, const std::string&, int&) */ + ocpp::types::ocpp16::AuthorizationStatus startTransaction(unsigned int connector_id, + const std::string& id_tag, + int& transaction_id) override; + + /** @copydoc bool IChargePoint::stopTransaction(unsigned int, const std::string&, ocpp::types::ocpp16::Reason) */ + bool stopTransaction(unsigned int connector_id, const std::string& id_tag, ocpp::types::ocpp16::Reason reason) override; /** @copydoc bool IChargePoint::dataTransfer(const std::string&, const std::string&, const std::string&, - ocpp::types::DataTransferStatus&, + ocpp::types::ocpp16::DataTransferStatus&, std::string& ) */ - bool dataTransfer(const std::string& vendor_id, - const std::string& message_id, - const std::string& request_data, - ocpp::types::DataTransferStatus& status, - std::string& response_data) override; + bool dataTransfer(const std::string& vendor_id, + const std::string& message_id, + const std::string& request_data, + ocpp::types::ocpp16::DataTransferStatus& status, + std::string& response_data) override; - /** @copydoc bool IChargePoint::sendMeterValues(unsigned int, const std::vector&) */ - bool sendMeterValues(unsigned int connector_id, const std::vector& values) override; + /** @copydoc bool IChargePoint::sendMeterValues(unsigned int, const std::vector&) */ + bool sendMeterValues(unsigned int connector_id, const std::vector& values) override; /** @copydoc bool IChargePoint::getSetpoint(unsigned int, - ocpp::types::Optional&, - ocpp::types::Optional&, - ocpp::types::ChargingRateUnitType) */ - bool getSetpoint(unsigned int connector_id, - ocpp::types::Optional& charge_point_setpoint, - ocpp::types::Optional& connector_setpoint, - ocpp::types::ChargingRateUnitType unit) override; + ocpp::types::Optional&, + ocpp::types::Optional&, + ocpp::types::ocpp16::ChargingRateUnitType) */ + bool getSetpoint(unsigned int connector_id, + ocpp::types::Optional& charge_point_setpoint, + ocpp::types::Optional& connector_setpoint, + ocpp::types::ocpp16::ChargingRateUnitType unit) override; /** @copydoc bool IChargePoint::notifyFirmwareUpdateStatus(bool) */ bool notifyFirmwareUpdateStatus(bool success) override; @@ -173,32 +177,32 @@ class ChargePoint : public IChargePoint, /** @copydoc bool IChargePoint::signCertificate() */ bool signCertificate() override; - /** @copydoc bool IChargePoint::notifySignedUpdateFirmwareStatus(ocpp::types::FirmwareStatusEnumType) */ - bool notifySignedUpdateFirmwareStatus(ocpp::types::FirmwareStatusEnumType status) override; + /** @copydoc bool IChargePoint::notifySignedUpdateFirmwareStatus(ocpp::types::ocpp16::FirmwareStatusEnumType) */ + bool notifySignedUpdateFirmwareStatus(ocpp::types::ocpp16::FirmwareStatusEnumType status) override; // ISO 15118 PnC extensions - /** @copydoc ocpp::types::AuthorizationStatus iso15118Authorize(const ocpp::x509::Certificate&, + /** @copydoc ocpp::types::ocpp16::AuthorizationStatus iso15118Authorize(const ocpp::x509::Certificate&, const std::string&, - const std::vector&, - ocpp::types::Optional&) */ - ocpp::types::AuthorizationStatus iso15118Authorize( - const ocpp::x509::Certificate& certificate, - const std::string& id_token, - const std::vector& cert_hash_data, - ocpp::types::Optional& cert_status) override; + const std::vector&, + ocpp::types::Optional&) */ + ocpp::types::ocpp16::AuthorizationStatus iso15118Authorize( + const ocpp::x509::Certificate& certificate, + const std::string& id_token, + const std::vector& cert_hash_data, + ocpp::types::Optional& cert_status) override; /** @copydoc bool IChargePoint::iso15118GetEVCertificate(const std::string&, - ocpp::types::CertificateActionEnumType, + ocpp::types::ocpp16::CertificateActionEnumType, const std::string&, std::string&) */ - bool iso15118GetEVCertificate(const std::string& iso15118_schema_version, - ocpp::types::CertificateActionEnumType action, - const std::string& exi_request, - std::string& exi_response) override; + bool iso15118GetEVCertificate(const std::string& iso15118_schema_version, + ocpp::types::ocpp16::CertificateActionEnumType action, + const std::string& exi_request, + std::string& exi_response) override; - /** @copydoc bool IChargePoint::iso15118GetCertificateStatus(const ocpp::types::OcspRequestDataType&, std::string&) */ - bool iso15118GetCertificateStatus(const ocpp::types::OcspRequestDataType& ocsp_request, std::string& ocsp_result) override; + /** @copydoc bool IChargePoint::iso15118GetCertificateStatus(const ocpp::types::ocpp16::OcspRequestDataType&, std::string&) */ + bool iso15118GetCertificateStatus(const ocpp::types::ocpp16::OcspRequestDataType& ocsp_request, std::string& ocsp_result) override; /** @copydoc bool IChargePoint::iso15118SignCertificate(const ocpp::x509::CertificateRequest&) */ bool iso15118SignCertificate(const ocpp::x509::CertificateRequest& csr) override; @@ -262,9 +266,9 @@ class ChargePoint : public IChargePoint, ocpp::config::InternalConfigManager m_internal_config; /** @brief Messages converter */ - ocpp::messages::MessagesConverter m_messages_converter; + ocpp::messages::ocpp16::MessagesConverter m_messages_converter; /** @brief Messaes validator */ - ocpp::messages::MessagesValidator m_messages_validator; + ocpp::messages::ocpp16::MessagesValidator m_messages_validator; /** @brief Requests FIFO */ RequestFifo m_requests_fifo; /** @brief Security manager */ @@ -345,14 +349,12 @@ class ChargePoint : public IChargePoint, */ IChargePointEventsHandler& getEventsHandler(void) const { return m_events_handler; } - /** * @brief Get connectors of the charge point * @return Connectors of the charge point */ Connectors& getConnectors(void) { return m_connectors; } - /** * @brief Get the configuration manager of the charge point * @return The configuration manager of the charge point diff --git a/src/chargepoint/authent/AuthentCache.cpp b/src/ocpp16/chargepoint/authent/AuthentCache.cpp similarity index 96% rename from src/chargepoint/authent/AuthentCache.cpp rename to src/ocpp16/chargepoint/authent/AuthentCache.cpp index f594c976..68d81b62 100644 --- a/src/chargepoint/authent/AuthentCache.cpp +++ b/src/ocpp16/chargepoint/authent/AuthentCache.cpp @@ -25,8 +25,10 @@ along with OpenOCPP. If not, see . #include using namespace ocpp::database; -using namespace ocpp::types; using namespace ocpp::messages; +using namespace ocpp::messages::ocpp16; +using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { @@ -60,10 +62,10 @@ AuthentCache::~AuthentCache() { } * std::string& error_code, * std::string& error_message) */ -bool AuthentCache::handleMessage(const ocpp::messages::ClearCacheReq& request, - ocpp::messages::ClearCacheConf& response, - std::string& error_code, - std::string& error_message) +bool AuthentCache::handleMessage(const ocpp::messages::ocpp16::ClearCacheReq& request, + ocpp::messages::ocpp16::ClearCacheConf& response, + std::string& error_code, + std::string& error_message) { (void)request; (void)error_code; @@ -87,7 +89,7 @@ bool AuthentCache::handleMessage(const ocpp::messages::ClearCacheReq& request, } /** @brief Look for a tag id in the cache */ -bool AuthentCache::check(const std::string& id_tag, ocpp::types::IdTagInfo& tag_info) +bool AuthentCache::check(const std::string& id_tag, ocpp::types::ocpp16::IdTagInfo& tag_info) { bool ret = false; @@ -144,7 +146,7 @@ bool AuthentCache::check(const std::string& id_tag, ocpp::types::IdTagInfo& tag_ } /** @brief Update a tag id entry in the cache */ -void AuthentCache::update(const std::string& id_tag, const ocpp::types::IdTagInfo& tag_info) +void AuthentCache::update(const std::string& id_tag, const ocpp::types::ocpp16::IdTagInfo& tag_info) { // Look for the entry if (m_find_query) diff --git a/src/chargepoint/authent/AuthentCache.h b/src/ocpp16/chargepoint/authent/AuthentCache.h similarity index 84% rename from src/chargepoint/authent/AuthentCache.h rename to src/ocpp16/chargepoint/authent/AuthentCache.h index 55eca9b5..835eb15a 100644 --- a/src/chargepoint/authent/AuthentCache.h +++ b/src/ocpp16/chargepoint/authent/AuthentCache.h @@ -44,7 +44,8 @@ namespace chargepoint { /** @brief Handle charge point authentication cache */ -class AuthentCache : public ocpp::messages::GenericMessageHandler +class AuthentCache + : public ocpp::messages::GenericMessageHandler { public: /** @brief Constructor */ @@ -64,10 +65,10 @@ class AuthentCache : public ocpp::messages::GenericMessageHandler. #include using namespace ocpp::database; -using namespace ocpp::types; using namespace ocpp::messages; +using namespace ocpp::messages::ocpp16; +using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { @@ -79,10 +81,10 @@ AuthentLocalList::~AuthentLocalList() { } * std::string& error_code, * std::string& error_message) */ -bool AuthentLocalList::handleMessage(const ocpp::messages::GetLocalListVersionReq& request, - ocpp::messages::GetLocalListVersionConf& response, - std::string& error_code, - std::string& error_message) +bool AuthentLocalList::handleMessage(const ocpp::messages::ocpp16::GetLocalListVersionReq& request, + ocpp::messages::ocpp16::GetLocalListVersionConf& response, + std::string& error_code, + std::string& error_message) { (void)request; (void)error_code; @@ -108,10 +110,10 @@ bool AuthentLocalList::handleMessage(const ocpp::messages::GetLocalListVersionRe * std::string& error_code, * std::string& error_message) */ -bool AuthentLocalList::handleMessage(const ocpp::messages::SendLocalListReq& request, - ocpp::messages::SendLocalListConf& response, - std::string& error_code, - std::string& error_message) +bool AuthentLocalList::handleMessage(const ocpp::messages::ocpp16::SendLocalListReq& request, + ocpp::messages::ocpp16::SendLocalListConf& response, + std::string& error_code, + std::string& error_message) { (void)request; (void)response; @@ -199,7 +201,7 @@ bool AuthentLocalList::handleMessage(const ocpp::messages::SendLocalListReq& req } /** @brief Look for a tag id in the local list */ -bool AuthentLocalList::check(const std::string& id_tag, ocpp::types::IdTagInfo& tag_info) +bool AuthentLocalList::check(const std::string& id_tag, ocpp::types::ocpp16::IdTagInfo& tag_info) { bool ret = false; @@ -282,7 +284,7 @@ void AuthentLocalList::initDatabaseTable() } /** @brief Perform the full update of the local list */ -bool AuthentLocalList::performFullUpdate(const std::vector& authorization_datas) +bool AuthentLocalList::performFullUpdate(const std::vector& authorization_datas) { bool ret = true; @@ -359,7 +361,7 @@ bool AuthentLocalList::performFullUpdate(const std::vector& authorization_datas) +bool AuthentLocalList::performPartialUpdate(const std::vector& authorization_datas) { bool ret = true; diff --git a/src/chargepoint/authent/AuthentLocalList.h b/src/ocpp16/chargepoint/authent/AuthentLocalList.h similarity index 80% rename from src/chargepoint/authent/AuthentLocalList.h rename to src/ocpp16/chargepoint/authent/AuthentLocalList.h index 5083758a..c8f228e0 100644 --- a/src/chargepoint/authent/AuthentLocalList.h +++ b/src/ocpp16/chargepoint/authent/AuthentLocalList.h @@ -45,8 +45,9 @@ namespace chargepoint /** @brief Handle charge point authentication local list */ class AuthentLocalList - : public ocpp::messages::GenericMessageHandler, - public ocpp::messages::GenericMessageHandler + : public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler { public: /** @brief Constructor */ @@ -66,20 +67,20 @@ class AuthentLocalList * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::GetLocalListVersionReq& request, - ocpp::messages::GetLocalListVersionConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::GetLocalListVersionReq& request, + ocpp::messages::ocpp16::GetLocalListVersionConf& response, + std::string& error_code, + std::string& error_message) override; /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, * ResponseType& response, * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::SendLocalListReq& request, - ocpp::messages::SendLocalListConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::SendLocalListReq& request, + ocpp::messages::ocpp16::SendLocalListConf& response, + std::string& error_code, + std::string& error_message) override; // AuthentLocalList interface @@ -89,7 +90,7 @@ class AuthentLocalList * @param tag_info Information for this id * @return true if the id has been found in the local list, false otherwise */ - bool check(const std::string& id_tag, ocpp::types::IdTagInfo& tag_info); + bool check(const std::string& id_tag, ocpp::types::ocpp16::IdTagInfo& tag_info); private: /** @brief Standard OCPP configuration */ @@ -114,9 +115,9 @@ class AuthentLocalList /** @brief Initialize the database table */ void initDatabaseTable(); /** @brief Perform the full update of the local list */ - bool performFullUpdate(const std::vector& authorization_datas); + bool performFullUpdate(const std::vector& authorization_datas); /** @brief Perform the partial update of the local list */ - bool performPartialUpdate(const std::vector& authorization_datas); + bool performPartialUpdate(const std::vector& authorization_datas); }; } // namespace chargepoint diff --git a/src/chargepoint/authent/AuthentManager.cpp b/src/ocpp16/chargepoint/authent/AuthentManager.cpp similarity index 92% rename from src/chargepoint/authent/AuthentManager.cpp rename to src/ocpp16/chargepoint/authent/AuthentManager.cpp index cdf794a5..72987125 100644 --- a/src/chargepoint/authent/AuthentManager.cpp +++ b/src/ocpp16/chargepoint/authent/AuthentManager.cpp @@ -26,8 +26,10 @@ along with OpenOCPP. If not, see . #include "IOcppConfig.h" #include "Logger.h" -using namespace ocpp::types; using namespace ocpp::messages; +using namespace ocpp::messages::ocpp16; +using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { @@ -56,8 +58,8 @@ AuthentManager::~AuthentManager() delete &m_local_list; } -/** @copydoc ocpp::types::AuthorizationStatus IAuthentManager::authorize(const std::string&, std::string&) */ -ocpp::types::AuthorizationStatus AuthentManager::authorize(const std::string& id_tag, std::string& parent_id) +/** @copydoc ocpp::types::ocpp16::AuthorizationStatus IAuthentManager::authorize(const std::string&, std::string&) */ +ocpp::types::ocpp16::AuthorizationStatus AuthentManager::authorize(const std::string& id_tag, std::string& parent_id) { bool retry; AuthorizationStatus status; @@ -168,8 +170,8 @@ ocpp::types::AuthorizationStatus AuthentManager::authorize(const std::string& id return status; } -/** @copydoc void IAuthentManager::update(const std::string& id_tag, const ocpp::types::IdTagInfo&) */ -void AuthentManager::update(const std::string& id_tag, const ocpp::types::IdTagInfo& tag_info) +/** @copydoc void IAuthentManager::update(const std::string& id_tag, const ocpp::types::ocpp16::IdTagInfo&) */ +void AuthentManager::update(const std::string& id_tag, const ocpp::types::ocpp16::IdTagInfo& tag_info) { // Check if the cache is enabled if (m_ocpp_config.authorizationCacheEnabled()) @@ -189,8 +191,8 @@ void AuthentManager::update(const std::string& id_tag, const ocpp::types::IdTagI } } -/** @copydoc ocpp::types::AuthorizationStatus IAuthentManager::iso15118Authorize(const std::string&) */ -ocpp::types::AuthorizationStatus AuthentManager::iso15118Authorize(const std::string& token_id) +/** @copydoc ocpp::types::ocpp16::AuthorizationStatus IAuthentManager::iso15118Authorize(const std::string&) */ +ocpp::types::ocpp16::AuthorizationStatus AuthentManager::iso15118Authorize(const std::string& token_id) { AuthorizationStatus status = AuthorizationStatus::Invalid; @@ -242,8 +244,8 @@ ocpp::types::AuthorizationStatus AuthentManager::iso15118Authorize(const std::st return status; } -/** @copydoc void IAuthentManager::iso15118Update(const std::string&, const ocpp::types::IdTokenInfoType&) */ -void AuthentManager::iso15118Update(const std::string& token_id, const ocpp::types::IdTokenInfoType& token_info) +/** @copydoc void IAuthentManager::iso15118Update(const std::string&, const ocpp::types::ocpp16::IdTokenInfoType&) */ +void AuthentManager::iso15118Update(const std::string& token_id, const ocpp::types::ocpp16::IdTokenInfoType& token_info) { // Check if the cache is enabled if (m_ocpp_config.authorizationCacheEnabled()) diff --git a/src/chargepoint/authent/AuthentManager.h b/src/ocpp16/chargepoint/authent/AuthentManager.h similarity index 78% rename from src/chargepoint/authent/AuthentManager.h rename to src/ocpp16/chargepoint/authent/AuthentManager.h index e4aa5463..f47089bd 100644 --- a/src/chargepoint/authent/AuthentManager.h +++ b/src/ocpp16/chargepoint/authent/AuthentManager.h @@ -64,17 +64,17 @@ class AuthentManager : public IAuthentManager /** @brief Destructor */ virtual ~AuthentManager(); - /** @copydoc ocpp::types::AuthorizationStatus IAuthentManager::authorize(const std::string&, std::string&) */ - ocpp::types::AuthorizationStatus authorize(const std::string& id_tag, std::string& parent_id) override; + /** @copydoc ocpp::types::ocpp16::AuthorizationStatus IAuthentManager::authorize(const std::string&, std::string&) */ + ocpp::types::ocpp16::AuthorizationStatus authorize(const std::string& id_tag, std::string& parent_id) override; - /** @copydoc void IAuthentManager::update(const std::string& id_tag, const ocpp::types::IdTagInfo&) */ - void update(const std::string& id_tag, const ocpp::types::IdTagInfo& tag_info) override; + /** @copydoc void IAuthentManager::update(const std::string& id_tag, const ocpp::types::ocpp16::IdTagInfo&) */ + void update(const std::string& id_tag, const ocpp::types::ocpp16::IdTagInfo& tag_info) override; - /** @copydoc ocpp::types::AuthorizationStatus IAuthentManager::iso15118Authorize(const std::string&) */ - ocpp::types::AuthorizationStatus iso15118Authorize(const std::string& token_id) override; + /** @copydoc ocpp::types::ocpp16::AuthorizationStatus IAuthentManager::iso15118Authorize(const std::string&) */ + ocpp::types::ocpp16::AuthorizationStatus iso15118Authorize(const std::string& token_id) override; - /** @copydoc void IAuthentManager::iso15118Update(const std::string&, const ocpp::types::IdTokenInfoType&) */ - void iso15118Update(const std::string& token_id, const ocpp::types::IdTokenInfoType& token_info) override; + /** @copydoc void IAuthentManager::iso15118Update(const std::string&, const ocpp::types::ocpp16::IdTokenInfoType&) */ + void iso15118Update(const std::string& token_id, const ocpp::types::ocpp16::IdTokenInfoType& token_info) override; private: /** @brief Standard OCPP configuration */ diff --git a/src/chargepoint/authent/IAuthentManager.h b/src/ocpp16/chargepoint/authent/IAuthentManager.h similarity index 85% rename from src/chargepoint/authent/IAuthentManager.h rename to src/ocpp16/chargepoint/authent/IAuthentManager.h index 2d34206b..92efad01 100644 --- a/src/chargepoint/authent/IAuthentManager.h +++ b/src/ocpp16/chargepoint/authent/IAuthentManager.h @@ -41,28 +41,28 @@ class IAuthentManager * @param parent_id If of the user's parent tag * @return Authorization status (see AuthorizationStatus enum) */ - virtual ocpp::types::AuthorizationStatus authorize(const std::string& id_tag, std::string& parent_id) = 0; + virtual ocpp::types::ocpp16::AuthorizationStatus authorize(const std::string& id_tag, std::string& parent_id) = 0; /** * @brief Update a tag information * @param id_tag Id of the tag to update * @param id_tag_info New tag informations */ - virtual void update(const std::string& id_tag, const ocpp::types::IdTagInfo& tag_info) = 0; + virtual void update(const std::string& id_tag, const ocpp::types::ocpp16::IdTagInfo& tag_info) = 0; /** * @brief Ask for authorization of an ISO15118 operation * @param token_id Token id of the user's * @return Authorization status (see AuthorizationStatus enum) */ - virtual ocpp::types::AuthorizationStatus iso15118Authorize(const std::string& token_id) = 0; + virtual ocpp::types::ocpp16::AuthorizationStatus iso15118Authorize(const std::string& token_id) = 0; /** * @brief Update an ISO15118 token information * @param token_id Id of the token to update * @param token_info New token informations */ - virtual void iso15118Update(const std::string& token_id, const ocpp::types::IdTokenInfoType& token_info) = 0; + virtual void iso15118Update(const std::string& token_id, const ocpp::types::ocpp16::IdTokenInfoType& token_info) = 0; }; } // namespace chargepoint diff --git a/src/chargepoint/config/ConfigManager.cpp b/src/ocpp16/chargepoint/config/ConfigManager.cpp similarity index 88% rename from src/chargepoint/config/ConfigManager.cpp rename to src/ocpp16/chargepoint/config/ConfigManager.cpp index d55763e2..02459568 100644 --- a/src/chargepoint/config/ConfigManager.cpp +++ b/src/ocpp16/chargepoint/config/ConfigManager.cpp @@ -20,7 +20,9 @@ along with OpenOCPP. If not, see . #include "IOcppConfig.h" using namespace ocpp::messages; +using namespace ocpp::messages::ocpp16; using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { @@ -65,10 +67,10 @@ void ConfigManager::registerConfigChangedListener(const std::string& key, IConfi * std::string& error_code, * std::string& error_message) */ -bool ConfigManager::handleMessage(const ocpp::messages::GetConfigurationReq& request, - ocpp::messages::GetConfigurationConf& response, - std::string& error_code, - std::string& error_message) +bool ConfigManager::handleMessage(const ocpp::messages::ocpp16::GetConfigurationReq& request, + ocpp::messages::ocpp16::GetConfigurationConf& response, + std::string& error_code, + std::string& error_message) { (void)error_code; (void)error_message; @@ -83,10 +85,10 @@ bool ConfigManager::handleMessage(const ocpp::messages::GetConfigurationReq& req * std::string& error_code, * std::string& error_message) */ -bool ConfigManager::handleMessage(const ocpp::messages::ChangeConfigurationReq& request, - ocpp::messages::ChangeConfigurationConf& response, - std::string& error_code, - std::string& error_message) +bool ConfigManager::handleMessage(const ocpp::messages::ocpp16::ChangeConfigurationReq& request, + ocpp::messages::ocpp16::ChangeConfigurationConf& response, + std::string& error_code, + std::string& error_message) { (void)error_code; (void)error_message; diff --git a/src/chargepoint/config/ConfigManager.h b/src/ocpp16/chargepoint/config/ConfigManager.h similarity index 78% rename from src/chargepoint/config/ConfigManager.h rename to src/ocpp16/chargepoint/config/ConfigManager.h index 3ceff5de..6efbefd7 100644 --- a/src/chargepoint/config/ConfigManager.h +++ b/src/ocpp16/chargepoint/config/ConfigManager.h @@ -40,10 +40,11 @@ namespace chargepoint { /** @brief Handle charge point configuration requests */ -class ConfigManager - : public IConfigManager, - public ocpp::messages::GenericMessageHandler, - public ocpp::messages::GenericMessageHandler +class ConfigManager : public IConfigManager, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler { public: /** @brief Constructor */ @@ -69,20 +70,20 @@ class ConfigManager * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::GetConfigurationReq& request, - ocpp::messages::GetConfigurationConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::GetConfigurationReq& request, + ocpp::messages::ocpp16::GetConfigurationConf& response, + std::string& error_code, + std::string& error_message) override; /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, * ResponseType& response, * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::ChangeConfigurationReq& request, - ocpp::messages::ChangeConfigurationConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::ChangeConfigurationReq& request, + ocpp::messages::ocpp16::ChangeConfigurationConf& response, + std::string& error_code, + std::string& error_message) override; private: /** @brief Standard OCPP configuration */ diff --git a/src/chargepoint/config/IConfigManager.h b/src/ocpp16/chargepoint/config/IConfigManager.h similarity index 93% rename from src/chargepoint/config/IConfigManager.h rename to src/ocpp16/chargepoint/config/IConfigManager.h index f9a1fc14..aea48d45 100644 --- a/src/chargepoint/config/IConfigManager.h +++ b/src/ocpp16/chargepoint/config/IConfigManager.h @@ -40,7 +40,8 @@ class IConfigManager virtual ~IConfigManager() { } /** @brief Configuration value check function */ - typedef std::function ConfigurationValueCheckFunc; + typedef std::function + ConfigurationValueCheckFunc; /** * @brief Register a check function for a specific configuration value before it is modified diff --git a/src/chargepoint/config/InternalConfigKeys.h b/src/ocpp16/chargepoint/config/InternalConfigKeys.h similarity index 100% rename from src/chargepoint/config/InternalConfigKeys.h rename to src/ocpp16/chargepoint/config/InternalConfigKeys.h diff --git a/src/chargepoint/connector/Connector.h b/src/ocpp16/chargepoint/connector/Connector.h similarity index 88% rename from src/chargepoint/connector/Connector.h rename to src/ocpp16/chargepoint/connector/Connector.h index 5db9d6ab..82a06917 100644 --- a/src/chargepoint/connector/Connector.h +++ b/src/ocpp16/chargepoint/connector/Connector.h @@ -38,9 +38,9 @@ struct Connector Connector(unsigned int _id, ocpp::helpers::ITimerPool& timer_pool) : id(_id), mutex(), - availability(ocpp::types::AvailabilityType::Operative), - status(ocpp::types::ChargePointStatus::Available), - error_code(ocpp::types::ChargePointErrorCode::NoError), + availability(ocpp::types::ocpp16::AvailabilityType::Operative), + status(ocpp::types::ocpp16::ChargePointStatus::Available), + error_code(ocpp::types::ocpp16::ChargePointErrorCode::NoError), status_timestamp(ocpp::types::DateTime::now()), info(), vendor_id(), @@ -68,11 +68,11 @@ struct Connector // Status notification data /** @brief Availability */ - ocpp::types::AvailabilityType availability; + ocpp::types::ocpp16::AvailabilityType availability; /** @brief Status */ - ocpp::types::ChargePointStatus status; + ocpp::types::ocpp16::ChargePointStatus status; /** @brief Error code */ - ocpp::types::ChargePointErrorCode error_code; + ocpp::types::ocpp16::ChargePointErrorCode error_code; /** @brief Timestamp of the last status notification */ ocpp::types::DateTime status_timestamp; /** @brief Info */ @@ -84,7 +84,7 @@ struct Connector /** @brief Timer for status duration */ ocpp::helpers::Timer status_timer; /** @brief Last status notified to the central system */ - ocpp::types::ChargePointStatus last_notified_status; + ocpp::types::ocpp16::ChargePointStatus last_notified_status; // Transaction data diff --git a/src/chargepoint/connector/Connectors.cpp b/src/ocpp16/chargepoint/connector/Connectors.cpp similarity index 99% rename from src/chargepoint/connector/Connectors.cpp rename to src/ocpp16/chargepoint/connector/Connectors.cpp index 3e7a9d95..d85ef8d4 100644 --- a/src/chargepoint/connector/Connectors.cpp +++ b/src/ocpp16/chargepoint/connector/Connectors.cpp @@ -21,6 +21,7 @@ along with OpenOCPP. If not, see . #include "Logger.h" using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { diff --git a/src/chargepoint/connector/Connectors.h b/src/ocpp16/chargepoint/connector/Connectors.h similarity index 100% rename from src/chargepoint/connector/Connectors.h rename to src/ocpp16/chargepoint/connector/Connectors.h diff --git a/src/chargepoint/datatransfer/DataTransferManager.cpp b/src/ocpp16/chargepoint/datatransfer/DataTransferManager.cpp similarity index 88% rename from src/chargepoint/datatransfer/DataTransferManager.cpp rename to src/ocpp16/chargepoint/datatransfer/DataTransferManager.cpp index c13be016..44a2a6d6 100644 --- a/src/chargepoint/datatransfer/DataTransferManager.cpp +++ b/src/ocpp16/chargepoint/datatransfer/DataTransferManager.cpp @@ -20,8 +20,10 @@ along with OpenOCPP. If not, see . #include "GenericMessageSender.h" #include "IChargePointEventsHandler.h" -using namespace ocpp::types; using namespace ocpp::messages; +using namespace ocpp::messages::ocpp16; +using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { @@ -45,11 +47,11 @@ DataTransferManager::DataTransferManager(IChargePointEventsHandler& DataTransferManager::~DataTransferManager() { } /** @brief Send a data transfer request */ -bool DataTransferManager::dataTransfer(const std::string& vendor_id, - const std::string& message_id, - const std::string& request_data, - ocpp::types::DataTransferStatus& status, - std::string& response_data) +bool DataTransferManager::dataTransfer(const std::string& vendor_id, + const std::string& message_id, + const std::string& request_data, + ocpp::types::ocpp16::DataTransferStatus& status, + std::string& response_data) { bool ret = false; @@ -89,10 +91,10 @@ void DataTransferManager::registerHandler(const std::string& vendor_id, IDataTra * std::string& error_code, * std::string& error_message) */ -bool DataTransferManager::handleMessage(const ocpp::messages::DataTransferReq& request, - ocpp::messages::DataTransferConf& response, - std::string& error_code, - std::string& error_message) +bool DataTransferManager::handleMessage(const ocpp::messages::ocpp16::DataTransferReq& request, + ocpp::messages::ocpp16::DataTransferConf& response, + std::string& error_code, + std::string& error_message) { (void)error_code; (void)error_message; diff --git a/src/chargepoint/datatransfer/DataTransferManager.h b/src/ocpp16/chargepoint/datatransfer/DataTransferManager.h similarity index 77% rename from src/chargepoint/datatransfer/DataTransferManager.h rename to src/ocpp16/chargepoint/datatransfer/DataTransferManager.h index a99bd9fc..56d799d2 100644 --- a/src/chargepoint/datatransfer/DataTransferManager.h +++ b/src/ocpp16/chargepoint/datatransfer/DataTransferManager.h @@ -42,8 +42,9 @@ namespace chargepoint class IChargePointEventsHandler; /** @brief Handle charge point data transfer requests */ -class DataTransferManager : public IDataTransferManager, - public ocpp::messages::GenericMessageHandler +class DataTransferManager + : public IDataTransferManager, + public ocpp::messages::GenericMessageHandler { public: /** @brief Constructor */ @@ -64,11 +65,11 @@ class DataTransferManager : public IDataTransferManager, * @param response_data Data associated with the response * @return true if the data transfer has been done, false otherwise */ - bool dataTransfer(const std::string& vendor_id, - const std::string& message_id, - const std::string& request_data, - ocpp::types::DataTransferStatus& status, - std::string& response_data); + bool dataTransfer(const std::string& vendor_id, + const std::string& message_id, + const std::string& request_data, + ocpp::types::ocpp16::DataTransferStatus& status, + std::string& response_data); // IDataTransferManager interface @@ -82,10 +83,10 @@ class DataTransferManager : public IDataTransferManager, * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::DataTransferReq& request, - ocpp::messages::DataTransferConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::DataTransferReq& request, + ocpp::messages::ocpp16::DataTransferConf& response, + std::string& error_code, + std::string& error_message) override; private: /** @brief User defined events handler */ diff --git a/src/chargepoint/datatransfer/IDataTransferManager.h b/src/ocpp16/chargepoint/datatransfer/IDataTransferManager.h similarity index 90% rename from src/chargepoint/datatransfer/IDataTransferManager.h rename to src/ocpp16/chargepoint/datatransfer/IDataTransferManager.h index 4ca517bd..3667fb8d 100644 --- a/src/chargepoint/datatransfer/IDataTransferManager.h +++ b/src/ocpp16/chargepoint/datatransfer/IDataTransferManager.h @@ -60,10 +60,10 @@ class IDataTransferManager * @param response_data Data associated with the response * @return Response status (see DataTransferStatus enum) */ - virtual ocpp::types::DataTransferStatus onDataTransferRequest(const std::string& vendor_id, - const std::string& message_id, - const std::string& request_data, - std::string& response_data) = 0; + virtual ocpp::types::ocpp16::DataTransferStatus onDataTransferRequest(const std::string& vendor_id, + const std::string& message_id, + const std::string& request_data, + std::string& response_data) = 0; }; }; diff --git a/src/chargepoint/interface/IChargePoint.h b/src/ocpp16/chargepoint/interface/IChargePoint.h similarity index 79% rename from src/chargepoint/interface/IChargePoint.h rename to src/ocpp16/chargepoint/interface/IChargePoint.h index 895a87fd..cb07ae30 100644 --- a/src/chargepoint/interface/IChargePoint.h +++ b/src/ocpp16/chargepoint/interface/IChargePoint.h @@ -119,14 +119,14 @@ class IChargePoint * @brief Get the registration status of the charge point * @return Registration of the charge point */ - virtual ocpp::types::RegistrationStatus getRegistrationStatus() = 0; + virtual ocpp::types::ocpp16::RegistrationStatus getRegistrationStatus() = 0; /** * @brief Get the status of a connector * @param connector_id Id of the connector * @return Status of the connector */ - virtual ocpp::types::ChargePointStatus getConnectorStatus(unsigned int connector_id) = 0; + virtual ocpp::types::ocpp16::ChargePointStatus getConnectorStatus(unsigned int connector_id) = 0; /** * @brief Notify a new status for a connector @@ -138,12 +138,13 @@ class IChargePoint * @param vendor_error Vendor specific error code * @return true if the status has been notified, false otherwise */ - virtual bool statusNotification(unsigned int connector_id, - ocpp::types::ChargePointStatus status, - ocpp::types::ChargePointErrorCode error_code = ocpp::types::ChargePointErrorCode::NoError, - const std::string& info = "", - const std::string& vendor_id = "", - const std::string& vendor_error = "") = 0; + virtual bool statusNotification( + unsigned int connector_id, + ocpp::types::ocpp16::ChargePointStatus status, + ocpp::types::ocpp16::ChargePointErrorCode error_code = ocpp::types::ocpp16::ChargePointErrorCode::NoError, + const std::string& info = "", + const std::string& vendor_id = "", + const std::string& vendor_error = "") = 0; /** * @brief Ask for authorization of an operation on a connector @@ -152,16 +153,20 @@ class IChargePoint * @param parent_id If of the user's parent tag * @return Authorization status (see AuthorizationStatus enum) */ - virtual ocpp::types::AuthorizationStatus authorize(unsigned int connector_id, const std::string& id_tag, std::string& parent_id) = 0; + virtual ocpp::types::ocpp16::AuthorizationStatus authorize(unsigned int connector_id, + const std::string& id_tag, + std::string& parent_id) = 0; /** * @brief Start a transaction * @param connector_id Id of the connector * @param id_tag Id of the user * @param transaction_id Id of the transaction - * @return ocpp::types::AuthorizationStatus (see AuthorizationStatus enum) + * @return Authorization status (see AuthorizationStatus enum) */ - virtual ocpp::types::AuthorizationStatus startTransaction(unsigned int connector_id, const std::string& id_tag, int& transaction_id) = 0; + virtual ocpp::types::ocpp16::AuthorizationStatus startTransaction(unsigned int connector_id, + const std::string& id_tag, + int& transaction_id) = 0; /** * @brief Stop a transaction @@ -170,7 +175,7 @@ class IChargePoint * @param reason Stop reason * @return true if a corresponding transaction exist and has been stopped, false otherwise */ - virtual bool stopTransaction(unsigned int connector_id, const std::string& id_tag, ocpp::types::Reason reason) = 0; + virtual bool stopTransaction(unsigned int connector_id, const std::string& id_tag, ocpp::types::ocpp16::Reason reason) = 0; /** * @brief Send a data transfer request @@ -181,11 +186,11 @@ class IChargePoint * @param response_data Data associated with the response * @return true if the data transfer has been done, false otherwise */ - virtual bool dataTransfer(const std::string& vendor_id, - const std::string& message_id, - const std::string& request_data, - ocpp::types::DataTransferStatus& status, - std::string& response_data) = 0; + virtual bool dataTransfer(const std::string& vendor_id, + const std::string& message_id, + const std::string& request_data, + ocpp::types::ocpp16::DataTransferStatus& status, + std::string& response_data) = 0; /** * @brief Send meter values to Central System for a given connector @@ -193,7 +198,7 @@ class IChargePoint * @param values Meter values to send * @return true if the meter values have been sent, false otherwise */ - virtual bool sendMeterValues(unsigned int connector_id, const std::vector& values) = 0; + virtual bool sendMeterValues(unsigned int connector_id, const std::vector& values) = 0; /** * @brief Get the smart charging setpoints for a connector and the whole charge point @@ -203,10 +208,10 @@ class IChargePoint * @param unit Setpoint unit (A or W) * @return true if the setpoints have been computed, false otherwise */ - virtual bool getSetpoint(unsigned int connector_id, - ocpp::types::Optional& charge_point_setpoint, - ocpp::types::Optional& connector_setpoint, - ocpp::types::ChargingRateUnitType unit = ocpp::types::ChargingRateUnitType::A) = 0; + virtual bool getSetpoint(unsigned int connector_id, + ocpp::types::Optional& charge_point_setpoint, + ocpp::types::Optional& connector_setpoint, + ocpp::types::ocpp16::ChargingRateUnitType unit = ocpp::types::ocpp16::ChargingRateUnitType::A) = 0; /** * @brief Notify the end of a firmware update operation @@ -254,7 +259,7 @@ class IChargePoint * @param status Installation status (see FirmwareStatusEnumType documentation) * @return true if the notification has been sent, false otherwise */ - virtual bool notifySignedUpdateFirmwareStatus(ocpp::types::FirmwareStatusEnumType status) = 0; + virtual bool notifySignedUpdateFirmwareStatus(ocpp::types::ocpp16::FirmwareStatusEnumType status) = 0; // ISO 15118 PnC extensions @@ -268,11 +273,11 @@ class IChargePoint * return 'CertificateRevoked * @return Authorization status (see AuthorizationStatus type) */ - virtual ocpp::types::AuthorizationStatus iso15118Authorize( - const ocpp::x509::Certificate& certificate, - const std::string& id_token, - const std::vector& cert_hash_data, - ocpp::types::Optional& cert_status) = 0; + virtual ocpp::types::ocpp16::AuthorizationStatus iso15118Authorize( + const ocpp::x509::Certificate& certificate, + const std::string& id_token, + const std::vector& cert_hash_data, + ocpp::types::Optional& cert_status) = 0; /** * @brief Get or update an ISO15118 EV certificate @@ -282,10 +287,10 @@ class IChargePoint * @param exi_response Raw CertificateInstallationRes response for the EV, Base64 encoded * @return true if the processing of the message has been successful and an EXI response has been included, false otherwise */ - virtual bool iso15118GetEVCertificate(const std::string& iso15118_schema_version, - ocpp::types::CertificateActionEnumType action, - const std::string& exi_request, - std::string& exi_response) = 0; + virtual bool iso15118GetEVCertificate(const std::string& iso15118_schema_version, + ocpp::types::ocpp16::CertificateActionEnumType action, + const std::string& exi_request, + std::string& exi_response) = 0; /** * @brief Get the status of an ISO15118 certificate @@ -293,7 +298,7 @@ class IChargePoint * @param ocsp_result OCSPResponse class as defined in IETF RFC 6960. DER encoded (as defined in IETF RFC 6960), and then base64 encoded * @return true if the status of the certificate has been successfully retrieved, false otherwise */ - virtual bool iso15118GetCertificateStatus(const ocpp::types::OcspRequestDataType& ocsp_request, std::string& ocsp_result) = 0; + virtual bool iso15118GetCertificateStatus(const ocpp::types::ocpp16::OcspRequestDataType& ocsp_request, std::string& ocsp_result) = 0; /** * @brief Send a CSR request to sign an ISO15118 certificate diff --git a/src/chargepoint/interface/IChargePointConfig.h b/src/ocpp16/chargepoint/interface/IChargePointConfig.h similarity index 100% rename from src/chargepoint/interface/IChargePointConfig.h rename to src/ocpp16/chargepoint/interface/IChargePointConfig.h diff --git a/src/chargepoint/interface/IChargePointEventsHandler.h b/src/ocpp16/chargepoint/interface/IChargePointEventsHandler.h similarity index 82% rename from src/chargepoint/interface/IChargePointEventsHandler.h rename to src/ocpp16/chargepoint/interface/IChargePointEventsHandler.h index cd71639e..52ef013c 100644 --- a/src/chargepoint/interface/IChargePointEventsHandler.h +++ b/src/ocpp16/chargepoint/interface/IChargePointEventsHandler.h @@ -49,7 +49,7 @@ class IChargePointEventsHandler * @brief Called when the first attempt to connect to the central system has failed * @param status Previous registration status (if Accepted, some offline operations are allowed) */ - virtual void connectionFailed(ocpp::types::RegistrationStatus status) = 0; + virtual void connectionFailed(ocpp::types::ocpp16::RegistrationStatus status) = 0; /** * @brief Called when the charge point connection status has changed @@ -62,7 +62,7 @@ class IChargePointEventsHandler * @param status Registration status * @param datetime Date and time of the central system */ - virtual void bootNotification(ocpp::types::RegistrationStatus status, const ocpp::types::DateTime& datetime) = 0; + virtual void bootNotification(ocpp::types::ocpp16::RegistrationStatus status, const ocpp::types::DateTime& datetime) = 0; /** * @brief Called when the date and time must be adjusted with the one of the central system @@ -75,8 +75,8 @@ class IChargePointEventsHandler * @param availability Requested availability * @return Status of the requested availability change (see AvailabilityStatus) */ - virtual ocpp::types::AvailabilityStatus changeAvailabilityRequested(unsigned int connector_id, - ocpp::types::AvailabilityType availability) = 0; + virtual ocpp::types::ocpp16::AvailabilityStatus changeAvailabilityRequested(unsigned int connector_id, + ocpp::types::ocpp16::AvailabilityType availability) = 0; /** * @brief Called to retrieve the meter value in Wh for a connector at the start or at the end of a transaction @@ -106,10 +106,10 @@ class IChargePointEventsHandler * @param response_data Data associated with the response * @return Response status (see DataTransferStatus enum) */ - virtual ocpp::types::DataTransferStatus dataTransferRequested(const std::string& vendor_id, - const std::string& message_id, - const std::string& request_data, - std::string& response_data) = 0; + virtual ocpp::types::ocpp16::DataTransferStatus dataTransferRequested(const std::string& vendor_id, + const std::string& message_id, + const std::string& request_data, + std::string& response_data) = 0; /** * @brief Get a meter value associated to a connector @@ -118,9 +118,10 @@ class IChargePointEventsHandler * @param meter_value Meter value to fill (the context and measurand fields of SampleValues doesn't need to be filled) * @return true if the meter value can be retrived, false otherwise */ - virtual bool getMeterValue(unsigned int connector_id, - const std::pair>& measurand, - ocpp::types::MeterValue& meter_value) = 0; + virtual bool getMeterValue( + unsigned int connector_id, + const std::pair>& measurand, + ocpp::types::ocpp16::MeterValue& meter_value) = 0; /** * @brief Called when a remote start transaction request has been received @@ -151,21 +152,23 @@ class IChargePointEventsHandler * @param schedule Schedule containing the local limitations for the requested duration * @return true if a schedule has been defined, false if there are no local limitations for the requested duration */ - virtual bool getLocalLimitationsSchedule(unsigned int connector_id, unsigned int duration, ocpp::types::ChargingSchedule& schedule) = 0; + virtual bool getLocalLimitationsSchedule(unsigned int connector_id, + unsigned int duration, + ocpp::types::ocpp16::ChargingSchedule& schedule) = 0; /** * @brief Called on a reset request from the Central System * @param reset_type Type of reset * @return true if the request is accepted, false otherwise */ - virtual bool resetRequested(ocpp::types::ResetType reset_type) = 0; + virtual bool resetRequested(ocpp::types::ocpp16::ResetType reset_type) = 0; /** * @brief Called on an unlock connector request from the Central System * @param connector_id Id of the concerned connector * @return Unlock status (see UnlockStatus documentation) */ - virtual ocpp::types::UnlockStatus unlockConnectorRequested(unsigned int connector_id) = 0; + virtual ocpp::types::ocpp16::UnlockStatus unlockConnectorRequested(unsigned int connector_id) = 0; /** * @brief Called on a diagnostic request @@ -218,8 +221,8 @@ class IChargePointEventsHandler * @param certificate CA certificate to install * @return Installation status (see CertificateStatusEnumType enum) */ - virtual ocpp::types::CertificateStatusEnumType caCertificateReceived(ocpp::types::CertificateUseEnumType type, - const ocpp::x509::Certificate& certificate) = 0; + virtual ocpp::types::ocpp16::CertificateStatusEnumType caCertificateReceived(ocpp::types::ocpp16::CertificateUseEnumType type, + const ocpp::x509::Certificate& certificate) = 0; /** * @brief Called when a charge point certificate has been received and must be installed @@ -238,10 +241,11 @@ class IChargePointEventsHandler * @param serial_number Serial number of the certificate * @return Deletion status (see DeleteCertificateStatusEnumType enum) */ - virtual ocpp::types::DeleteCertificateStatusEnumType deleteCertificate(ocpp::types::HashAlgorithmEnumType hash_algorithm, - const std::string& issuer_name_hash, - const std::string& issuer_key_hash, - const std::string& serial_number) = 0; + virtual ocpp::types::ocpp16::DeleteCertificateStatusEnumType deleteCertificate( + ocpp::types::ocpp16::HashAlgorithmEnumType hash_algorithm, + const std::string& issuer_name_hash, + const std::string& issuer_key_hash, + const std::string& serial_number) = 0; /** * @brief Called to generate a CSR in PEM format which will be used by the Central System @@ -257,7 +261,8 @@ class IChargePointEventsHandler * @param type Type of CA certificate * @param certificates Installed certificates */ - virtual void getInstalledCertificates(ocpp::types::CertificateUseEnumType type, std::vector& certificates) = 0; + virtual void getInstalledCertificates(ocpp::types::ocpp16::CertificateUseEnumType type, + std::vector& certificates) = 0; /** * @brief Called on a log request @@ -269,7 +274,7 @@ class IChargePointEventsHandler * @return Path to the generated log file to upload to the Central System, or empty * string if no log are available */ - virtual std::string getLog(ocpp::types::LogEnumType type, + virtual std::string getLog(ocpp::types::ocpp16::LogEnumType type, const ocpp::types::Optional& start_time, const ocpp::types::Optional& stop_time) = 0; @@ -293,7 +298,7 @@ class IChargePointEventsHandler * @param signing_certificate Certificate to check * @return Check status (see UpdateFirmwareStatusEnumType enum) */ - virtual ocpp::types::UpdateFirmwareStatusEnumType checkFirmwareSigningCertificate( + virtual ocpp::types::ocpp16::UpdateFirmwareStatusEnumType checkFirmwareSigningCertificate( const ocpp::x509::Certificate& signing_certificate) = 0; // ISO 15118 PnC extensions @@ -320,10 +325,11 @@ class IChargePointEventsHandler * @param serial_number Serial number of the certificate * @return Deletion status (see DeleteCertificateStatusEnumType enum) */ - virtual ocpp::types::DeleteCertificateStatusEnumType iso15118DeleteCertificate(ocpp::types::HashAlgorithmEnumType hash_algorithm, - const std::string& issuer_name_hash, - const std::string& issuer_key_hash, - const std::string& serial_number) = 0; + virtual ocpp::types::ocpp16::DeleteCertificateStatusEnumType iso15118DeleteCertificate( + ocpp::types::ocpp16::HashAlgorithmEnumType hash_algorithm, + const std::string& issuer_name_hash, + const std::string& issuer_key_hash, + const std::string& serial_number) = 0; /** * @brief Called to get the list of installed ISO15118 certificates @@ -338,7 +344,8 @@ class IChargePointEventsHandler bool mo_root_certificate, bool v2g_certificate_chain, bool oem_root_certificate, - std::vector>>& + std::vector< + std::tuple>>& certificates) = 0; /** @@ -347,8 +354,8 @@ class IChargePointEventsHandler * @param certificate certificate to install * @return Installation status (see InstallCertificateStatusEnumType enum) */ - virtual ocpp::types::InstallCertificateStatusEnumType iso15118CertificateReceived(ocpp::types::InstallCertificateUseEnumType type, - const ocpp::x509::Certificate& certificate) = 0; + virtual ocpp::types::ocpp16::InstallCertificateStatusEnumType iso15118CertificateReceived( + ocpp::types::ocpp16::InstallCertificateUseEnumType type, const ocpp::x509::Certificate& certificate) = 0; /** * @brief Called to generate a CSR in PEM format which will be used by the Central System diff --git a/src/chargepoint/iso15118/Iso15118Manager.cpp b/src/ocpp16/chargepoint/iso15118/Iso15118Manager.cpp similarity index 89% rename from src/chargepoint/iso15118/Iso15118Manager.cpp rename to src/ocpp16/chargepoint/iso15118/Iso15118Manager.cpp index 0c9269f8..bece0074 100644 --- a/src/chargepoint/iso15118/Iso15118Manager.cpp +++ b/src/ocpp16/chargepoint/iso15118/Iso15118Manager.cpp @@ -38,8 +38,10 @@ along with OpenOCPP. If not, see . #include using namespace ocpp::x509; -using namespace ocpp::types; using namespace ocpp::messages; +using namespace ocpp::messages::ocpp16; +using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { @@ -74,11 +76,11 @@ Iso15118Manager::Iso15118Manager(ocpp::config::IOcppConfig& Iso15118Manager::~Iso15118Manager() { } /** @brief Authorize an ISO15118 transaction */ -ocpp::types::AuthorizationStatus Iso15118Manager::authorize( - const ocpp::x509::Certificate& certificate, - const std::string& id_token, - const std::vector& cert_hash_data, - ocpp::types::Optional& cert_status) +ocpp::types::ocpp16::AuthorizationStatus Iso15118Manager::authorize( + const ocpp::x509::Certificate& certificate, + const std::string& id_token, + const std::vector& cert_hash_data, + ocpp::types::Optional& cert_status) { LOG_INFO << "[ISO15118] Authorize : token = " << id_token; @@ -136,10 +138,11 @@ ocpp::types::AuthorizationStatus Iso15118Manager::authorize( } /** @brief Get or update an ISO15118 EV certificate */ -ocpp::types::Iso15118EVCertificateStatusEnumType Iso15118Manager::get15118EVCertificate(const std::string& iso15118_schema_version, - ocpp::types::CertificateActionEnumType action, - const std::string& exi_request, - std::string& exi_response) +ocpp::types::ocpp16::Iso15118EVCertificateStatusEnumType Iso15118Manager::get15118EVCertificate( + const std::string& iso15118_schema_version, + ocpp::types::ocpp16::CertificateActionEnumType action, + const std::string& exi_request, + std::string& exi_response) { LOG_INFO << "[ISO15118] Get EV certificate : schema version = " << iso15118_schema_version << " - action = " << CertificateActionEnumTypeHelper.toString(action); @@ -167,8 +170,8 @@ ocpp::types::Iso15118EVCertificateStatusEnumType Iso15118Manager::get15118EVCert } /** @brief Get the status of an ISO15118 certificate */ -ocpp::types::GetCertificateStatusEnumType Iso15118Manager::getCertificateStatus(const ocpp::types::OcspRequestDataType& ocsp_request, - std::string& ocsp_result) +ocpp::types::ocpp16::GetCertificateStatusEnumType Iso15118Manager::getCertificateStatus( + const ocpp::types::ocpp16::OcspRequestDataType& ocsp_request, std::string& ocsp_result) { LOG_INFO << "[ISO15118] Get certificate status : serial number = " << ocsp_request.serialNumber.c_str() << " - responder = " << ocsp_request.responderURL.c_str(); @@ -209,14 +212,14 @@ bool Iso15118Manager::signCertificate(const ocpp::x509::CertificateRequest& csr) // IDataTransferManager::IDataTransferHandler interface -/** @copydoc ocpp::types::DataTransferStatus IDataTransferHandler::onDataTransferRequest(const std::string&, +/** @copydoc ocpp::types::ocpp16::DataTransferStatus IDataTransferHandler::onDataTransferRequest(const std::string&, const std::string&, const std::string&, std::string&) */ -ocpp::types::DataTransferStatus Iso15118Manager::onDataTransferRequest(const std::string& vendor_id, - const std::string& message_id, - const std::string& request_data, - std::string& response_data) +ocpp::types::ocpp16::DataTransferStatus Iso15118Manager::onDataTransferRequest(const std::string& vendor_id, + const std::string& message_id, + const std::string& request_data, + std::string& response_data) { (void)vendor_id; (void)request_data; @@ -273,7 +276,8 @@ ocpp::types::DataTransferStatus Iso15118Manager::onDataTransferRequest(const std } /** @brief Handle a CertificateSigned request */ -void Iso15118Manager::handle(const ocpp::messages::CertificateSignedReq& request, ocpp::messages::CertificateSignedConf& response) +void Iso15118Manager::handle(const ocpp::messages::ocpp16::CertificateSignedReq& request, + ocpp::messages::ocpp16::CertificateSignedConf& response) { LOG_INFO << "[ISO15118] Certificate signed message received : certificate size = " << request.certificateChain.size(); @@ -309,7 +313,8 @@ void Iso15118Manager::handle(const ocpp::messages::CertificateSignedReq& request } /** @brief Handle a DeleteCertificate request */ -void Iso15118Manager::handle(const ocpp::messages::DeleteCertificateReq& request, ocpp::messages::DeleteCertificateConf& response) +void Iso15118Manager::handle(const ocpp::messages::ocpp16::DeleteCertificateReq& request, + ocpp::messages::ocpp16::DeleteCertificateConf& response) { LOG_INFO << "[ISO15118] Delete certificate request received : hashAlgorithm = " << HashAlgorithmEnumTypeHelper.toString(request.certificateHashData.hashAlgorithm) @@ -327,8 +332,8 @@ void Iso15118Manager::handle(const ocpp::messages::DeleteCertificateReq& request } /** @brief Handle an Iso15118GetInstalledCertificateIds request */ -void Iso15118Manager::handle(const ocpp::messages::Iso15118GetInstalledCertificateIdsReq& request, - ocpp::messages::Iso15118GetInstalledCertificateIdsConf& response) +void Iso15118Manager::handle(const ocpp::messages::ocpp16::Iso15118GetInstalledCertificateIdsReq& request, + ocpp::messages::ocpp16::Iso15118GetInstalledCertificateIdsConf& response) { LOG_INFO << "[ISO15118] Get installed certificate ids request received : certificateType count = " << request.certificateType.size(); @@ -407,8 +412,8 @@ void Iso15118Manager::handle(const ocpp::messages::Iso15118GetInstalledCertifica } /** @brief Handle an InstallCertificate request */ -void Iso15118Manager::handle(const ocpp::messages::Iso15118InstallCertificateReq& request, - ocpp::messages::Iso15118InstallCertificateConf& response) +void Iso15118Manager::handle(const ocpp::messages::ocpp16::Iso15118InstallCertificateReq& request, + ocpp::messages::ocpp16::Iso15118InstallCertificateConf& response) { LOG_INFO << "[ISO15118] Install certificate request received : certificateType = " << InstallCertificateUseEnumTypeHelper.toString(request.certificateType) @@ -429,7 +434,8 @@ void Iso15118Manager::handle(const ocpp::messages::Iso15118InstallCertificateReq } /** @brief Handle a TriggerMessage request */ -void Iso15118Manager::handle(const ocpp::messages::Iso15118TriggerMessageReq& request, ocpp::messages::Iso15118TriggerMessageConf& response) +void Iso15118Manager::handle(const ocpp::messages::ocpp16::Iso15118TriggerMessageReq& request, + ocpp::messages::ocpp16::Iso15118TriggerMessageConf& response) { (void)request; @@ -454,7 +460,7 @@ void Iso15118Manager::handle(const ocpp::messages::Iso15118TriggerMessageReq& re } /** @brief Fill the hash information of a certificat */ -void Iso15118Manager::fillHashInfo(const ocpp::x509::Certificate& certificate, ocpp::types::CertificateHashDataType& info) +void Iso15118Manager::fillHashInfo(const ocpp::x509::Certificate& certificate, ocpp::types::ocpp16::CertificateHashDataType& info) { // Compute hashes with SHA-256 algorithm Sha2 sha256; diff --git a/src/chargepoint/iso15118/Iso15118Manager.h b/src/ocpp16/chargepoint/iso15118/Iso15118Manager.h similarity index 75% rename from src/chargepoint/iso15118/Iso15118Manager.h rename to src/ocpp16/chargepoint/iso15118/Iso15118Manager.h index 87f42f0c..995e30ad 100644 --- a/src/chargepoint/iso15118/Iso15118Manager.h +++ b/src/ocpp16/chargepoint/iso15118/Iso15118Manager.h @@ -43,6 +43,8 @@ class IOcppConfig; } // namespace config namespace messages { +namespace ocpp16 +{ struct CertificateSignedReq; struct CertificateSignedConf; struct DeleteCertificateReq; @@ -53,6 +55,7 @@ struct Iso15118InstallCertificateReq; struct Iso15118InstallCertificateConf; struct Iso15118TriggerMessageReq; struct Iso15118TriggerMessageConf; +} // namespace ocpp16 } // namespace messages namespace helpers { @@ -95,10 +98,11 @@ class Iso15118Manager : public IDataTransferManager::IDataTransferHandler * return 'CertificateRevoked * @return Authorization status (see AuthorizationStatus type) */ - ocpp::types::AuthorizationStatus authorize(const ocpp::x509::Certificate& certificate, - const std::string& id_token, - const std::vector& cert_hash_data, - ocpp::types::Optional& cert_status); + ocpp::types::ocpp16::AuthorizationStatus authorize( + const ocpp::x509::Certificate& certificate, + const std::string& id_token, + const std::vector& cert_hash_data, + ocpp::types::Optional& cert_status); /** * @brief Get or update an ISO15118 EV certificate * @param iso15118_schema_version Schema version currently used for the 15118 session between EV and Charge Point @@ -107,10 +111,10 @@ class Iso15118Manager : public IDataTransferManager::IDataTransferHandler * @param exi_response Raw CertificateInstallationRes response for the EV, Base64 encoded * @return Operation status (see Iso15118EVCertificateStatusEnumType enum) */ - ocpp::types::Iso15118EVCertificateStatusEnumType get15118EVCertificate(const std::string& iso15118_schema_version, - ocpp::types::CertificateActionEnumType action, - const std::string& exi_request, - std::string& exi_response); + ocpp::types::ocpp16::Iso15118EVCertificateStatusEnumType get15118EVCertificate(const std::string& iso15118_schema_version, + ocpp::types::ocpp16::CertificateActionEnumType action, + const std::string& exi_request, + std::string& exi_response); /** * @brief Get the status of an ISO15118 certificate @@ -118,8 +122,8 @@ class Iso15118Manager : public IDataTransferManager::IDataTransferHandler * @param ocsp_result OCSPResponse class as defined in IETF RFC 6960. DER encoded (as defined in IETF RFC 6960), and then base64 encoded * @return Operation status (see GetCertificateStatusEnumType enum) */ - ocpp::types::GetCertificateStatusEnumType getCertificateStatus(const ocpp::types::OcspRequestDataType& ocsp_request, - std::string& ocsp_result); + ocpp::types::ocpp16::GetCertificateStatusEnumType getCertificateStatus(const ocpp::types::ocpp16::OcspRequestDataType& ocsp_request, + std::string& ocsp_result); /** * @brief Send a CSR request to sign an ISO15118 certificate @@ -130,14 +134,14 @@ class Iso15118Manager : public IDataTransferManager::IDataTransferHandler // IDataTransferManager::IDataTransferHandler interface - /** @copydoc ocpp::types::DataTransferStatus IDataTransferHandler::onDataTransferRequest(const std::string&, + /** @copydoc ocpp::types::ocpp16::DataTransferStatus IDataTransferHandler::onDataTransferRequest(const std::string&, const std::string&, const std::string&, std::string&) */ - ocpp::types::DataTransferStatus onDataTransferRequest(const std::string& vendor_id, - const std::string& message_id, - const std::string& request_data, - std::string& response_data) override; + ocpp::types::ocpp16::DataTransferStatus onDataTransferRequest(const std::string& vendor_id, + const std::string& message_id, + const std::string& request_data, + std::string& response_data) override; private: /** @brief Standard OCPP configuration */ @@ -179,25 +183,24 @@ class Iso15118Manager : public IDataTransferManager::IDataTransferHandler auto resp_converter = m_messages_converter.getResponseConverter(type_id); // Prepare request - ocpp::messages::DataTransferReq req; - req.vendorId.assign(ocpp::messages::ISO15118_VENDOR_ID); + ocpp::messages::ocpp16::DataTransferReq req; + req.vendorId.assign(ocpp::messages::ocpp16::ISO15118_VENDOR_ID); req.messageId.value().assign(action); // Convert request to JSON - rapidjson::Document json_req; + rapidjson::Document json_req(rapidjson::kObjectType); rapidjson::StringBuffer buffer; rapidjson::Writer writer(buffer); - json_req.Parse("{}"); req_converter->setAllocator(&json_req.GetAllocator()); req_converter->toJson(request, json_req); json_req.Accept(writer); req.data.value() = buffer.GetString(); // Send request - ocpp::messages::DataTransferConf resp; - if (m_msg_sender.call(ocpp::messages::DATA_TRANSFER_ACTION, req, resp) == ocpp::messages::CallResult::Ok) + ocpp::messages::ocpp16::DataTransferConf resp; + if (m_msg_sender.call(ocpp::messages::ocpp16::DATA_TRANSFER_ACTION, req, resp) == ocpp::messages::CallResult::Ok) { - if (resp.status == ocpp::types::DataTransferStatus::Accepted) + if (resp.status == ocpp::types::ocpp16::DataTransferStatus::Accepted) { try { @@ -223,7 +226,7 @@ class Iso15118Manager : public IDataTransferManager::IDataTransferHandler } else { - LOG_ERROR << "[ISO15118] Data transfer error : " << ocpp::types::DataTransferStatusHelper.toString(resp.status); + LOG_ERROR << "[ISO15118] Data transfer error : " << ocpp::types::ocpp16::DataTransferStatusHelper.toString(resp.status); } } @@ -238,11 +241,11 @@ class Iso15118Manager : public IDataTransferManager::IDataTransferHandler * @return Response status (see DataTransferStatus enum) */ template - ocpp::types::DataTransferStatus handle(const std::string& type_id, const std::string& request_data, std::string& response_data) + ocpp::types::ocpp16::DataTransferStatus handle(const std::string& type_id, const std::string& request_data, std::string& response_data) { - ocpp::types::DataTransferStatus status = ocpp::types::DataTransferStatus::Rejected; - auto req_converter = m_messages_converter.getRequestConverter(type_id); - auto resp_converter = m_messages_converter.getResponseConverter(type_id); + ocpp::types::ocpp16::DataTransferStatus status = ocpp::types::ocpp16::DataTransferStatus::Rejected; + auto req_converter = m_messages_converter.getRequestConverter(type_id); + auto resp_converter = m_messages_converter.getResponseConverter(type_id); try { // Parse JSON @@ -261,8 +264,7 @@ class Iso15118Manager : public IDataTransferManager::IDataTransferHandler handle(req, resp); // Convert response to JSON - rapidjson::Document response; - response.Parse("{}"); + rapidjson::Document response(rapidjson::kObjectType); resp_converter->setAllocator(&response.GetAllocator()); if (resp_converter->toJson(resp, response)) { @@ -273,7 +275,7 @@ class Iso15118Manager : public IDataTransferManager::IDataTransferHandler response.Accept(writer); response_data = buffer.GetString(); - status = ocpp::types::DataTransferStatus::Accepted; + status = ocpp::types::ocpp16::DataTransferStatus::Accepted; } } else @@ -294,19 +296,21 @@ class Iso15118Manager : public IDataTransferManager::IDataTransferHandler } /** @brief Handle a CertificateSigned request */ - void handle(const ocpp::messages::CertificateSignedReq& request, ocpp::messages::CertificateSignedConf& response); + void handle(const ocpp::messages::ocpp16::CertificateSignedReq& request, ocpp::messages::ocpp16::CertificateSignedConf& response); /** @brief Handle a DeleteCertificate request */ - void handle(const ocpp::messages::DeleteCertificateReq& request, ocpp::messages::DeleteCertificateConf& response); + void handle(const ocpp::messages::ocpp16::DeleteCertificateReq& request, ocpp::messages::ocpp16::DeleteCertificateConf& response); /** @brief Handle an Iso15118GetInstalledCertificateIds request */ - void handle(const ocpp::messages::Iso15118GetInstalledCertificateIdsReq& request, - ocpp::messages::Iso15118GetInstalledCertificateIdsConf& response); + void handle(const ocpp::messages::ocpp16::Iso15118GetInstalledCertificateIdsReq& request, + ocpp::messages::ocpp16::Iso15118GetInstalledCertificateIdsConf& response); /** @brief Handle an InstallCertificate request */ - void handle(const ocpp::messages::Iso15118InstallCertificateReq& request, ocpp::messages::Iso15118InstallCertificateConf& response); + void handle(const ocpp::messages::ocpp16::Iso15118InstallCertificateReq& request, + ocpp::messages::ocpp16::Iso15118InstallCertificateConf& response); /** @brief Handle a TriggerMessage request */ - void handle(const ocpp::messages::Iso15118TriggerMessageReq& request, ocpp::messages::Iso15118TriggerMessageConf& response); + void handle(const ocpp::messages::ocpp16::Iso15118TriggerMessageReq& request, + ocpp::messages::ocpp16::Iso15118TriggerMessageConf& response); /** @brief Fill the hash information of a certificat */ - void fillHashInfo(const ocpp::x509::Certificate& certificate, ocpp::types::CertificateHashDataType& info); + void fillHashInfo(const ocpp::x509::Certificate& certificate, ocpp::types::ocpp16::CertificateHashDataType& info); /** @brief Send a CSR request to sign an ISO15118 certificate */ bool sendSignCertificate(); diff --git a/src/chargepoint/maintenance/MaintenanceManager.cpp b/src/ocpp16/chargepoint/maintenance/MaintenanceManager.cpp similarity index 94% rename from src/chargepoint/maintenance/MaintenanceManager.cpp rename to src/ocpp16/chargepoint/maintenance/MaintenanceManager.cpp index 24a2e19f..41370cf9 100644 --- a/src/chargepoint/maintenance/MaintenanceManager.cpp +++ b/src/ocpp16/chargepoint/maintenance/MaintenanceManager.cpp @@ -36,8 +36,10 @@ along with OpenOCPP. If not, see . #include -using namespace ocpp::types; using namespace ocpp::messages; +using namespace ocpp::messages::ocpp16; +using namespace ocpp::types; +using namespace ocpp::types::ocpp16; using namespace ocpp::x509; namespace ocpp @@ -146,7 +148,7 @@ bool MaintenanceManager::notifyFirmwareUpdateStatus(bool success) } /** @brief Notify the end of a signed firmware update operation */ -bool MaintenanceManager::notifySignedUpdateFirmwareStatus(ocpp::types::FirmwareStatusEnumType status) +bool MaintenanceManager::notifySignedUpdateFirmwareStatus(ocpp::types::ocpp16::FirmwareStatusEnumType status) { // Update status m_signed_firmware_status = status; @@ -162,8 +164,9 @@ bool MaintenanceManager::notifySignedUpdateFirmwareStatus(ocpp::types::FirmwareS return ret; } -/** @copydoc bool ITriggerMessageHandler::onTriggerMessage(ocpp::types::MessageTrigger, const ocpp::types::Optional&) */ -bool MaintenanceManager::onTriggerMessage(ocpp::types::MessageTrigger message, const ocpp::types::Optional& connector_id) +/** @copydoc bool ITriggerMessageHandler::onTriggerMessage(ocpp::types::ocpp16::MessageTrigger, const ocpp::types::Optional&) */ +bool MaintenanceManager::onTriggerMessage(ocpp::types::ocpp16::MessageTrigger message, + const ocpp::types::Optional& connector_id) { bool ret = true; (void)connector_id; @@ -203,9 +206,9 @@ bool MaintenanceManager::onTriggerMessage(ocpp::types::MessageTrigger message, c return ret; } -/** @copydoc bool ITriggerMessageHandler::onTriggerMessage(ocpp::types::MessageTriggerEnumType, const ocpp::types::Optional&) */ -bool MaintenanceManager::onTriggerMessage(ocpp::types::MessageTriggerEnumType message, - const ocpp::types::Optional& connector_id) +/** @copydoc bool ITriggerMessageHandler::onTriggerMessage(ocpp::types::ocpp16::MessageTriggerEnumType, const ocpp::types::Optional&) */ +bool MaintenanceManager::onTriggerMessage(ocpp::types::ocpp16::MessageTriggerEnumType message, + const ocpp::types::Optional& connector_id) { bool ret = true; (void)connector_id; @@ -250,10 +253,10 @@ bool MaintenanceManager::onTriggerMessage(ocpp::types::MessageTriggerEnumType * std::string& error_code, * std::string& error_message) */ -bool MaintenanceManager::handleMessage(const ocpp::messages::ResetReq& request, - ocpp::messages::ResetConf& response, - std::string& error_code, - std::string& error_message) +bool MaintenanceManager::handleMessage(const ocpp::messages::ocpp16::ResetReq& request, + ocpp::messages::ocpp16::ResetConf& response, + std::string& error_code, + std::string& error_message) { (void)error_code; (void)error_message; @@ -280,10 +283,10 @@ bool MaintenanceManager::handleMessage(const ocpp::messages::ResetReq& request, * std::string& error_code, * std::string& error_message) */ -bool MaintenanceManager::handleMessage(const ocpp::messages::UnlockConnectorReq& request, - ocpp::messages::UnlockConnectorConf& response, - std::string& error_code, - std::string& error_message) +bool MaintenanceManager::handleMessage(const ocpp::messages::ocpp16::UnlockConnectorReq& request, + ocpp::messages::ocpp16::UnlockConnectorConf& response, + std::string& error_code, + std::string& error_message) { (void)error_code; (void)error_message; @@ -312,10 +315,10 @@ bool MaintenanceManager::handleMessage(const ocpp::messages::UnlockConnectorReq& * std::string& error_code, * std::string& error_message) */ -bool MaintenanceManager::handleMessage(const ocpp::messages::GetDiagnosticsReq& request, - ocpp::messages::GetDiagnosticsConf& response, - std::string& error_code, - std::string& error_message) +bool MaintenanceManager::handleMessage(const ocpp::messages::ocpp16::GetDiagnosticsReq& request, + ocpp::messages::ocpp16::GetDiagnosticsConf& response, + std::string& error_code, + std::string& error_message) { (void)error_code; (void)error_message; @@ -358,10 +361,10 @@ bool MaintenanceManager::handleMessage(const ocpp::messages::GetDiagnosticsReq& * std::string& error_code, * std::string& error_message) */ -bool MaintenanceManager::handleMessage(const ocpp::messages::UpdateFirmwareReq& request, - ocpp::messages::UpdateFirmwareConf& response, - std::string& error_code, - std::string& error_message) +bool MaintenanceManager::handleMessage(const ocpp::messages::ocpp16::UpdateFirmwareReq& request, + ocpp::messages::ocpp16::UpdateFirmwareConf& response, + std::string& error_code, + std::string& error_message) { (void)error_code; (void)error_message; @@ -396,10 +399,10 @@ bool MaintenanceManager::handleMessage(const ocpp::messages::UpdateFirmwareReq& * std::string& error_code, * std::string& error_message) */ -bool MaintenanceManager::handleMessage(const ocpp::messages::GetLogReq& request, - ocpp::messages::GetLogConf& response, - std::string& error_code, - std::string& error_message) +bool MaintenanceManager::handleMessage(const ocpp::messages::ocpp16::GetLogReq& request, + ocpp::messages::ocpp16::GetLogConf& response, + std::string& error_code, + std::string& error_message) { (void)error_code; (void)error_message; @@ -466,10 +469,10 @@ bool MaintenanceManager::handleMessage(const ocpp::messages::GetLogReq& request, * std::string& error_code, * std::string& error_message) */ -bool MaintenanceManager::handleMessage(const ocpp::messages::SignedUpdateFirmwareReq& request, - ocpp::messages::SignedUpdateFirmwareConf& response, - std::string& error_code, - std::string& error_message) +bool MaintenanceManager::handleMessage(const ocpp::messages::ocpp16::SignedUpdateFirmwareReq& request, + ocpp::messages::ocpp16::SignedUpdateFirmwareConf& response, + std::string& error_code, + std::string& error_message) { (void)error_code; (void)error_message; @@ -740,7 +743,7 @@ bool MaintenanceManager::sendFirmwareStatusNotification() // Security extensions /** @brief Process the upload of the logs */ -void MaintenanceManager::processGetLog(ocpp::types::LogEnumType type, +void MaintenanceManager::processGetLog(ocpp::types::ocpp16::LogEnumType type, std::string location, ocpp::types::Optional retries, ocpp::types::Optional retry_interval, diff --git a/src/chargepoint/maintenance/MaintenanceManager.h b/src/ocpp16/chargepoint/maintenance/MaintenanceManager.h similarity index 79% rename from src/chargepoint/maintenance/MaintenanceManager.h rename to src/ocpp16/chargepoint/maintenance/MaintenanceManager.h index df931a19..5715f106 100644 --- a/src/chargepoint/maintenance/MaintenanceManager.h +++ b/src/ocpp16/chargepoint/maintenance/MaintenanceManager.h @@ -66,13 +66,14 @@ class IChargePointEventsHandler; class MaintenanceManager : public ITriggerMessageManager::ITriggerMessageHandler, public ITriggerMessageManager::IExtendedTriggerMessageHandler, - public ocpp::messages::GenericMessageHandler, - public ocpp::messages::GenericMessageHandler, - public ocpp::messages::GenericMessageHandler, - public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, // Security extensions - public ocpp::messages::GenericMessageHandler, - public ocpp::messages::GenericMessageHandler + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler { public: /** @brief Constructor */ @@ -103,15 +104,16 @@ class MaintenanceManager * @param status Installation status (see FirmwareStatusEnumType documentation) * @return true if the notification has been sent, false otherwise */ - bool notifySignedUpdateFirmwareStatus(ocpp::types::FirmwareStatusEnumType status); + bool notifySignedUpdateFirmwareStatus(ocpp::types::ocpp16::FirmwareStatusEnumType status); // ITriggerMessageManager::ITriggerMessageHandler interface - /** @copydoc bool ITriggerMessageHandler::onTriggerMessage(ocpp::types::MessageTrigger, const ocpp::types::Optional&) */ - bool onTriggerMessage(ocpp::types::MessageTrigger message, const ocpp::types::Optional& connector_id) override; + /** @copydoc bool ITriggerMessageHandler::onTriggerMessage(ocpp::types::ocpp16::MessageTrigger, const ocpp::types::Optional&) */ + bool onTriggerMessage(ocpp::types::ocpp16::MessageTrigger message, const ocpp::types::Optional& connector_id) override; - /** @copydoc bool ITriggerMessageHandler::onTriggerMessage(ocpp::types::MessageTriggerEnumType, const ocpp::types::Optional&) */ - bool onTriggerMessage(ocpp::types::MessageTriggerEnumType message, const ocpp::types::Optional& connector_id) override; + /** @copydoc bool ITriggerMessageHandler::onTriggerMessage(ocpp::types::ocpp16::MessageTriggerEnumType, const ocpp::types::Optional&) */ + bool onTriggerMessage(ocpp::types::ocpp16::MessageTriggerEnumType message, + const ocpp::types::Optional& connector_id) override; // GenericMessageHandler interface @@ -120,40 +122,40 @@ class MaintenanceManager * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::ResetReq& request, - ocpp::messages::ResetConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::ResetReq& request, + ocpp::messages::ocpp16::ResetConf& response, + std::string& error_code, + std::string& error_message) override; /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, * ResponseType& response, * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::UnlockConnectorReq& request, - ocpp::messages::UnlockConnectorConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::UnlockConnectorReq& request, + ocpp::messages::ocpp16::UnlockConnectorConf& response, + std::string& error_code, + std::string& error_message) override; /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, * ResponseType& response, * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::GetDiagnosticsReq& request, - ocpp::messages::GetDiagnosticsConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::GetDiagnosticsReq& request, + ocpp::messages::ocpp16::GetDiagnosticsConf& response, + std::string& error_code, + std::string& error_message) override; /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, * ResponseType& response, * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::UpdateFirmwareReq& request, - ocpp::messages::UpdateFirmwareConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::UpdateFirmwareReq& request, + ocpp::messages::ocpp16::UpdateFirmwareConf& response, + std::string& error_code, + std::string& error_message) override; // Security extensions @@ -162,20 +164,20 @@ class MaintenanceManager * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::GetLogReq& request, - ocpp::messages::GetLogConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::GetLogReq& request, + ocpp::messages::ocpp16::GetLogConf& response, + std::string& error_code, + std::string& error_message) override; /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, * ResponseType& response, * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::SignedUpdateFirmwareReq& request, - ocpp::messages::SignedUpdateFirmwareConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::SignedUpdateFirmwareReq& request, + ocpp::messages::ocpp16::SignedUpdateFirmwareConf& response, + std::string& error_code, + std::string& error_message) override; private: /** @brief Stack configuration */ @@ -196,18 +198,18 @@ class MaintenanceManager /** @brief Diagnostics thread */ std::thread* m_diagnostics_thread; /** @brief Diagnostics status */ - ocpp::types::DiagnosticsStatus m_diagnostics_status; + ocpp::types::ocpp16::DiagnosticsStatus m_diagnostics_status; /** @brief Logs status */ - ocpp::types::UploadLogStatusEnumType m_logs_status; + ocpp::types::ocpp16::UploadLogStatusEnumType m_logs_status; /** @brief Logs request id */ ocpp::types::Optional m_logs_request_id; /** @brief Firmware update thread */ std::thread* m_firmware_thread; /** @brief Firmware update status */ - ocpp::types::FirmwareStatus m_firmware_status; + ocpp::types::ocpp16::FirmwareStatus m_firmware_status; /** @brief Signed firmware update status */ - ocpp::types::FirmwareStatusEnumType m_signed_firmware_status; + ocpp::types::ocpp16::FirmwareStatusEnumType m_signed_firmware_status; /** @brief Signed firmware update request id */ ocpp::types::Optional m_firmware_request_id; @@ -232,7 +234,7 @@ class MaintenanceManager // Security extensions /** @brief Process the upload of the logs */ - void processGetLog(ocpp::types::LogEnumType type, + void processGetLog(ocpp::types::ocpp16::LogEnumType type, std::string location, ocpp::types::Optional retries, ocpp::types::Optional retry_interval, diff --git a/src/chargepoint/metervalues/IMeterValuesManager.h b/src/ocpp16/chargepoint/metervalues/IMeterValuesManager.h similarity index 94% rename from src/chargepoint/metervalues/IMeterValuesManager.h rename to src/ocpp16/chargepoint/metervalues/IMeterValuesManager.h index eac64347..c8a0ab4b 100644 --- a/src/chargepoint/metervalues/IMeterValuesManager.h +++ b/src/ocpp16/chargepoint/metervalues/IMeterValuesManager.h @@ -41,7 +41,7 @@ class IMeterValuesManager * @param values Meter values to send * @return true if the meter values have been sent, false otherwise */ - virtual bool sendMeterValues(unsigned int connector_id, const std::vector& values) = 0; + virtual bool sendMeterValues(unsigned int connector_id, const std::vector& values) = 0; /** * @brief Start sending sampled meter values for a given connector @@ -60,7 +60,7 @@ class IMeterValuesManager * @param connector_id Id of the connector * @param meter_values Transaction meter values */ - virtual void getTxStopMeterValues(unsigned int connector_id, std::vector& meter_values) = 0; + virtual void getTxStopMeterValues(unsigned int connector_id, std::vector& meter_values) = 0; }; } // namespace chargepoint diff --git a/src/chargepoint/metervalues/MeterValuesManager.cpp b/src/ocpp16/chargepoint/metervalues/MeterValuesManager.cpp similarity index 92% rename from src/chargepoint/metervalues/MeterValuesManager.cpp rename to src/ocpp16/chargepoint/metervalues/MeterValuesManager.cpp index 659212fb..8bd6e071 100644 --- a/src/chargepoint/metervalues/MeterValuesManager.cpp +++ b/src/ocpp16/chargepoint/metervalues/MeterValuesManager.cpp @@ -31,8 +31,10 @@ along with OpenOCPP. If not, see . #include -using namespace ocpp::types; using namespace ocpp::messages; +using namespace ocpp::messages::ocpp16; +using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { @@ -97,8 +99,8 @@ MeterValuesManager::~MeterValuesManager() } } -/** @copydoc bool IMeterValuesManager::sendMeterValues(unsigned int, const std::vector&) */ -bool MeterValuesManager::sendMeterValues(unsigned int connector_id, const std::vector& values) +/** @copydoc bool IMeterValuesManager::sendMeterValues(unsigned int, const std::vector&) */ +bool MeterValuesManager::sendMeterValues(unsigned int connector_id, const std::vector& values) { bool ret = false; @@ -150,8 +152,8 @@ void MeterValuesManager::stopSampledMeterValues(unsigned int connector_id) } } -/** @copydoc void IMeterValuesManager::getTxStopMeterValues(unsigned int, std::vector&) */ -void MeterValuesManager::getTxStopMeterValues(unsigned int connector_id, std::vector& meter_values) +/** @copydoc void IMeterValuesManager::getTxStopMeterValues(unsigned int, std::vector&) */ +void MeterValuesManager::getTxStopMeterValues(unsigned int connector_id, std::vector& meter_values) { // Get connector Connector* connector = m_connectors.getConnector(connector_id); @@ -186,8 +188,9 @@ void MeterValuesManager::getTxStopMeterValues(unsigned int connector_id, std::ve } } -/** @copydoc bool ITriggerMessageManager::ITriggerMessageHandler::onTriggerMessage(ocpp::types::MessageTrigger message, const ocpp::types::Optional&) */ -bool MeterValuesManager::onTriggerMessage(ocpp::types::MessageTrigger message, const ocpp::types::Optional& connector_id) +/** @copydoc bool ITriggerMessageManager::ITriggerMessageHandler::onTriggerMessage(ocpp::types::ocpp16::MessageTrigger message, const ocpp::types::Optional&) */ +bool MeterValuesManager::onTriggerMessage(ocpp::types::ocpp16::MessageTrigger message, + const ocpp::types::Optional& connector_id) { bool ret = false; if (message == MessageTrigger::MeterValues) @@ -209,9 +212,9 @@ bool MeterValuesManager::onTriggerMessage(ocpp::types::MessageTrigger message, c return ret; } -/** @copydoc bool ITriggerMessageManager::ITriggerMessageHandler::onTriggerMessage(ocpp::types::MessageTriggerEnumType message, const ocpp::types::Optional&) */ -bool MeterValuesManager::onTriggerMessage(ocpp::types::MessageTriggerEnumType message, - const ocpp::types::Optional& connector_id) +/** @copydoc bool ITriggerMessageManager::ITriggerMessageHandler::onTriggerMessage(ocpp::types::ocpp16::MessageTriggerEnumType message, const ocpp::types::Optional&) */ +bool MeterValuesManager::onTriggerMessage(ocpp::types::ocpp16::MessageTriggerEnumType message, + const ocpp::types::Optional& connector_id) { bool ret = false; if (message == MessageTriggerEnumType::MeterValues) @@ -248,12 +251,13 @@ void MeterValuesManager::configurationValueChanged(const std::string& key) connector->meter_values_timer.stop(); LOG_INFO << "Meter values disabled on connector " << connector->id; } - else if (connector->status == ocpp::types::ChargePointStatus::Charging) + else if (connector->status == ocpp::types::ocpp16::ChargePointStatus::Charging) { configureMeterValueSampleTimer(connector->id, interval); } } - }else if (key == "clockaligneddatainterval") + } + else if (key == "clockaligneddatainterval") { // Check new value std::chrono::seconds interval = m_ocpp_config.clockAlignedDataInterval(); @@ -277,7 +281,8 @@ void MeterValuesManager::configureMeterValueSampleTimer(const unsigned int conne { Connector* connector = m_connectors.getConnector(connector_id); - if (!connector) { + if (!connector) + { return; } @@ -480,7 +485,7 @@ void MeterValuesManager::processTriggered(unsigned int connector_id) /** @brief Send a meter value request for a given measurand list on a connector */ void MeterValuesManager::sendMeterValues(unsigned int connector_id, const std::vector>>& measurands, - ocpp::types::ReadingContext context, + ocpp::types::ocpp16::ReadingContext context, const ocpp::types::Optional& transaction_id) { // Prepare request @@ -507,8 +512,8 @@ void MeterValuesManager::sendMeterValues(unsigned int } /** @brief Compute the measurand list from a CSL configuration string */ -std::vector>> MeterValuesManager::computeMeasurandList( - const std::string& meter_values, const unsigned int max_count) +std::vector>> MeterValuesManager:: + computeMeasurandList(const std::string& meter_values, const unsigned int max_count) { std::string trimmed_meter_values(meter_values); ocpp::helpers::replace(trimmed_meter_values, " ", ""); @@ -555,10 +560,10 @@ std::vector>>& measurands, - ocpp::types::MeterValue& meter_value, - ocpp::types::ReadingContext context) + unsigned int connector_id, + const std::vector>>& measurands, + ocpp::types::ocpp16::MeterValue& meter_value, + ocpp::types::ocpp16::ReadingContext context) { meter_value.timestamp = DateTime::now(); meter_value.sampledValue.clear(); @@ -635,12 +640,11 @@ void MeterValuesManager::initDatabaseTable() } /** @brief Serialize a meter value to a string */ -std::string MeterValuesManager::serialize(const ocpp::types::MeterValue& meter_value) +std::string MeterValuesManager::serialize(const ocpp::types::ocpp16::MeterValue& meter_value) { std::string meter_value_str; - rapidjson::Document meter_value_json; - meter_value_json.Parse("{}"); + rapidjson::Document meter_value_json(rapidjson::kObjectType); MeterValueConverter meter_value_converter; meter_value_converter.setAllocator(&meter_value_json.GetAllocator()); meter_value_converter.toJson(meter_value, meter_value_json); @@ -653,7 +657,7 @@ std::string MeterValuesManager::serialize(const ocpp::types::MeterValue& meter_v } /** @brief Deserialize a meter value from a string */ -bool MeterValuesManager::deserialize(const std::string& meter_value_str, ocpp::types::MeterValue& meter_value) +bool MeterValuesManager::deserialize(const std::string& meter_value_str, ocpp::types::ocpp16::MeterValue& meter_value) { std::string error_code; std::string error_message; diff --git a/src/chargepoint/metervalues/MeterValuesManager.h b/src/ocpp16/chargepoint/metervalues/MeterValuesManager.h similarity index 79% rename from src/chargepoint/metervalues/MeterValuesManager.h rename to src/ocpp16/chargepoint/metervalues/MeterValuesManager.h index ae5ee765..91e9b1c6 100644 --- a/src/chargepoint/metervalues/MeterValuesManager.h +++ b/src/ocpp16/chargepoint/metervalues/MeterValuesManager.h @@ -76,8 +76,8 @@ class MeterValuesManager : public IMeterValuesManager, // IMeterValuesManager interface - /** @copydoc bool IMeterValuesManager::sendMeterValues(unsigned int, const std::vector&) */ - bool sendMeterValues(unsigned int connector_id, const std::vector& values) override; + /** @copydoc bool IMeterValuesManager::sendMeterValues(unsigned int, const std::vector&) */ + bool sendMeterValues(unsigned int connector_id, const std::vector& values) override; /** @copydoc void IMeterValuesManager::startSampledMeterValues(unsigned int) */ void startSampledMeterValues(unsigned int connector_id) override; @@ -85,18 +85,19 @@ class MeterValuesManager : public IMeterValuesManager, /** @copydoc void IMeterValuesManager::stopSampledMeterValues(unsigned int) */ void stopSampledMeterValues(unsigned int connector_id) override; - /** @copydoc void IMeterValuesManager::getTxStopMeterValues(unsigned int, std::vector&) */ - void getTxStopMeterValues(unsigned int connector_id, std::vector& meter_values) override; + /** @copydoc void IMeterValuesManager::getTxStopMeterValues(unsigned int, std::vector&) */ + void getTxStopMeterValues(unsigned int connector_id, std::vector& meter_values) override; // ITriggerMessageManager::ITriggerMessageHandler interface - /** @copydoc bool ITriggerMessageManager::ITriggerMessageHandler::onTriggerMessage(ocpp::types::MessageTrigger message, + /** @copydoc bool ITriggerMessageManager::ITriggerMessageHandler::onTriggerMessage(ocpp::types::ocpp16::MessageTrigger message, * const ocpp::types::Optional&) */ - bool onTriggerMessage(ocpp::types::MessageTrigger message, const ocpp::types::Optional& connector_id) override; + bool onTriggerMessage(ocpp::types::ocpp16::MessageTrigger message, const ocpp::types::Optional& connector_id) override; - /** @copydoc bool ITriggerMessageManager::ITriggerMessageHandler::onTriggerMessage(ocpp::types::MessageTriggerEnumType message, + /** @copydoc bool ITriggerMessageManager::ITriggerMessageHandler::onTriggerMessage(ocpp::types::ocpp16::MessageTriggerEnumType message, * const ocpp::types::Optional&) */ - bool onTriggerMessage(ocpp::types::MessageTriggerEnumType message, const ocpp::types::Optional& connector_id) override; + bool onTriggerMessage(ocpp::types::ocpp16::MessageTriggerEnumType message, + const ocpp::types::Optional& connector_id) override; // IConfigChangedListener interface @@ -146,27 +147,29 @@ class MeterValuesManager : public IMeterValuesManager, void processTriggered(unsigned int connector_id); /** @brief Send a meter value request for a given measurand list on a connector */ - void sendMeterValues(unsigned int connector_id, - const std::vector>>& measurands, - ocpp::types::ReadingContext context, - const ocpp::types::Optional& transaction_id = ocpp::types::Optional()); + void sendMeterValues( + unsigned int connector_id, + const std::vector>>& measurands, + ocpp::types::ocpp16::ReadingContext context, + const ocpp::types::Optional& transaction_id = ocpp::types::Optional()); /** @brief Compute the measurand list from a CSL configuration string */ - std::vector>> computeMeasurandList( + std::vector>> computeMeasurandList( const std::string& meter_values, const unsigned int max_count); /** @brief Fill a meter value element */ - bool fillMeterValue(unsigned int connector_id, - const std::vector>>& measurands, - ocpp::types::MeterValue& meter_value, - ocpp::types::ReadingContext context); + bool fillMeterValue( + unsigned int connector_id, + const std::vector>>& measurands, + ocpp::types::ocpp16::MeterValue& meter_value, + ocpp::types::ocpp16::ReadingContext context); /** @brief Initialize the database table */ void initDatabaseTable(); /** @brief Serialize a meter value to a string */ - std::string serialize(const ocpp::types::MeterValue& meter_value); + std::string serialize(const ocpp::types::ocpp16::MeterValue& meter_value); /** @brief Deserialize a meter value from a string */ - bool deserialize(const std::string& meter_value_str, ocpp::types::MeterValue& meter_value); + bool deserialize(const std::string& meter_value_str, ocpp::types::ocpp16::MeterValue& meter_value); }; } // namespace chargepoint diff --git a/src/chargepoint/requestfifo/RequestFifo.cpp b/src/ocpp16/chargepoint/requestfifo/RequestFifo.cpp similarity index 100% rename from src/chargepoint/requestfifo/RequestFifo.cpp rename to src/ocpp16/chargepoint/requestfifo/RequestFifo.cpp diff --git a/src/chargepoint/requestfifo/RequestFifo.h b/src/ocpp16/chargepoint/requestfifo/RequestFifo.h similarity index 100% rename from src/chargepoint/requestfifo/RequestFifo.h rename to src/ocpp16/chargepoint/requestfifo/RequestFifo.h diff --git a/src/chargepoint/requestfifo/RequestFifoManager.cpp b/src/ocpp16/chargepoint/requestfifo/RequestFifoManager.cpp similarity index 99% rename from src/chargepoint/requestfifo/RequestFifoManager.cpp rename to src/ocpp16/chargepoint/requestfifo/RequestFifoManager.cpp index 8f032b70..ad6817e3 100644 --- a/src/chargepoint/requestfifo/RequestFifoManager.cpp +++ b/src/ocpp16/chargepoint/requestfifo/RequestFifoManager.cpp @@ -30,8 +30,10 @@ along with OpenOCPP. If not, see . #include "StopTransaction.h" #include "WorkerThreadPool.h" -using namespace ocpp::types; using namespace ocpp::messages; +using namespace ocpp::messages::ocpp16; +using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { diff --git a/src/chargepoint/requestfifo/RequestFifoManager.h b/src/ocpp16/chargepoint/requestfifo/RequestFifoManager.h similarity index 100% rename from src/chargepoint/requestfifo/RequestFifoManager.h rename to src/ocpp16/chargepoint/requestfifo/RequestFifoManager.h diff --git a/src/chargepoint/reservation/ReservationManager.cpp b/src/ocpp16/chargepoint/reservation/ReservationManager.cpp similarity index 94% rename from src/chargepoint/reservation/ReservationManager.cpp rename to src/ocpp16/chargepoint/reservation/ReservationManager.cpp index e4698e55..1747499e 100644 --- a/src/chargepoint/reservation/ReservationManager.cpp +++ b/src/ocpp16/chargepoint/reservation/ReservationManager.cpp @@ -28,8 +28,10 @@ along with OpenOCPP. If not, see . #include #include -using namespace ocpp::types; using namespace ocpp::messages; +using namespace ocpp::messages::ocpp16; +using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { @@ -93,7 +95,7 @@ void ReservationManager::clearReservation(unsigned int connector_id) } /** @brief Indicate if a transaction is allowed on a connector using a specific id tag */ -ocpp::types::AuthorizationStatus ReservationManager::isTransactionAllowed(unsigned int connector_id, const std::string& id_tag) +ocpp::types::ocpp16::AuthorizationStatus ReservationManager::isTransactionAllowed(unsigned int connector_id, const std::string& id_tag) { AuthorizationStatus ret = AuthorizationStatus::Invalid; @@ -173,10 +175,10 @@ ocpp::types::AuthorizationStatus ReservationManager::isTransactionAllowed(unsign * std::string& error_code, * std::string& error_message) */ -bool ReservationManager::handleMessage(const ocpp::messages::ReserveNowReq& request, - ocpp::messages::ReserveNowConf& response, - std::string& error_code, - std::string& error_message) +bool ReservationManager::handleMessage(const ocpp::messages::ocpp16::ReserveNowReq& request, + ocpp::messages::ocpp16::ReserveNowConf& response, + std::string& error_code, + std::string& error_message) { bool ret = false; @@ -283,10 +285,10 @@ bool ReservationManager::handleMessage(const ocpp::messages::ReserveNowReq& requ * std::string& error_code, * std::string& error_message) */ -bool ReservationManager::handleMessage(const ocpp::messages::CancelReservationReq& request, - ocpp::messages::CancelReservationConf& response, - std::string& error_code, - std::string& error_message) +bool ReservationManager::handleMessage(const ocpp::messages::ocpp16::CancelReservationReq& request, + ocpp::messages::ocpp16::CancelReservationConf& response, + std::string& error_code, + std::string& error_message) { (void)error_code; (void)error_message; diff --git a/src/chargepoint/reservation/ReservationManager.h b/src/ocpp16/chargepoint/reservation/ReservationManager.h similarity index 83% rename from src/chargepoint/reservation/ReservationManager.h rename to src/ocpp16/chargepoint/reservation/ReservationManager.h index 0384cd40..70424e7f 100644 --- a/src/chargepoint/reservation/ReservationManager.h +++ b/src/ocpp16/chargepoint/reservation/ReservationManager.h @@ -53,8 +53,9 @@ class IChargePointEventsHandler; /** @brief Handle charge point reservation requests */ class ReservationManager - : public ocpp::messages::GenericMessageHandler, - public ocpp::messages::GenericMessageHandler + : public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler { public: /** @brief Constructor */ @@ -81,9 +82,9 @@ class ReservationManager * @brief Indicate if a transaction is allowed on a connector using a specific id tag * @param connector_id Id of the connector * @param id_tag Id of the user - * @return ocpp::types::AuthorizationStatus (see AuthorizationStatus enum) + * @return ocpp::types::ocpp16::AuthorizationStatus (see AuthorizationStatus enum) */ - ocpp::types::AuthorizationStatus isTransactionAllowed(unsigned int connector_id, const std::string& id_tag); + ocpp::types::ocpp16::AuthorizationStatus isTransactionAllowed(unsigned int connector_id, const std::string& id_tag); // GenericMessageHandler interface @@ -92,20 +93,20 @@ class ReservationManager * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::ReserveNowReq& request, - ocpp::messages::ReserveNowConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::ReserveNowReq& request, + ocpp::messages::ocpp16::ReserveNowConf& response, + std::string& error_code, + std::string& error_message) override; /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, * ResponseType& response, * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::CancelReservationReq& request, - ocpp::messages::CancelReservationConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::CancelReservationReq& request, + ocpp::messages::ocpp16::CancelReservationConf& response, + std::string& error_code, + std::string& error_message) override; private: /** @brief Standard OCPP configuration */ diff --git a/src/chargepoint/security/CaCertificatesDatabase.cpp b/src/ocpp16/chargepoint/security/CaCertificatesDatabase.cpp similarity index 90% rename from src/chargepoint/security/CaCertificatesDatabase.cpp rename to src/ocpp16/chargepoint/security/CaCertificatesDatabase.cpp index 950a81d7..65e64957 100644 --- a/src/chargepoint/security/CaCertificatesDatabase.cpp +++ b/src/ocpp16/chargepoint/security/CaCertificatesDatabase.cpp @@ -27,6 +27,7 @@ along with OpenOCPP. If not, see . using namespace ocpp::database; using namespace ocpp::types; +using namespace ocpp::types::ocpp16; using namespace ocpp::x509; namespace ocpp @@ -95,8 +96,8 @@ void CaCertificatesDatabase::initDatabaseTable() } /** @brief Delete an installed CA certificate */ -ocpp::types::DeleteCertificateStatusEnumType CaCertificatesDatabase::deleteCertificate( - const ocpp::types::CertificateHashDataType& certificate) +ocpp::types::ocpp16::DeleteCertificateStatusEnumType CaCertificatesDatabase::deleteCertificate( + const ocpp::types::ocpp16::CertificateHashDataType& certificate) { DeleteCertificateStatusEnumType ret = DeleteCertificateStatusEnumType::NotFound; @@ -137,8 +138,8 @@ ocpp::types::DeleteCertificateStatusEnumType CaCertificatesDatabase::deleteCerti } /** @brief Get the list of certificates */ -void CaCertificatesDatabase::getCertificateList(ocpp::types::CertificateUseEnumType type, - std::vector& certificates) +void CaCertificatesDatabase::getCertificateList(ocpp::types::ocpp16::CertificateUseEnumType type, + std::vector& certificates) { if (m_list_query) { @@ -166,7 +167,7 @@ void CaCertificatesDatabase::getCertificateList(ocpp::types::CertificateUseEnumT } /** @brief Get the list of valid certificates in PEM encoded data format */ -std::string CaCertificatesDatabase::getCertificateListPem(ocpp::types::CertificateUseEnumType type) +std::string CaCertificatesDatabase::getCertificateListPem(ocpp::types::ocpp16::CertificateUseEnumType type) { std::string ca_certificates_pem; @@ -193,7 +194,7 @@ std::string CaCertificatesDatabase::getCertificateListPem(ocpp::types::Certifica } /** @brief Get the number of installed certificates */ -unsigned int CaCertificatesDatabase::getCertificateCount(ocpp::types::CertificateUseEnumType type, bool check_validity) +unsigned int CaCertificatesDatabase::getCertificateCount(ocpp::types::ocpp16::CertificateUseEnumType type, bool check_validity) { unsigned int ret = 0; @@ -229,9 +230,9 @@ unsigned int CaCertificatesDatabase::getCertificateCount(ocpp::types::Certificat } /** @brief Add a new certificate */ -bool CaCertificatesDatabase::addCertificate(ocpp::types::CertificateUseEnumType type, - const ocpp::x509::Certificate& certificate, - const ocpp::types::CertificateHashDataType& hash_data) +bool CaCertificatesDatabase::addCertificate(ocpp::types::ocpp16::CertificateUseEnumType type, + const ocpp::x509::Certificate& certificate, + const ocpp::types::ocpp16::CertificateHashDataType& hash_data) { bool ret = false; @@ -272,7 +273,9 @@ bool CaCertificatesDatabase::addCertificate(ocpp::types::CertificateUseEnumType } /** @brief Look for a certificate */ -bool CaCertificatesDatabase::findCertificate(const ocpp::types::CertificateHashDataType& certificate, unsigned int& id, bool& in_use) +bool CaCertificatesDatabase::findCertificate(const ocpp::types::ocpp16::CertificateHashDataType& certificate, + unsigned int& id, + bool& in_use) { bool found = false; diff --git a/src/chargepoint/security/CaCertificatesDatabase.h b/src/ocpp16/chargepoint/security/CaCertificatesDatabase.h similarity index 80% rename from src/chargepoint/security/CaCertificatesDatabase.h rename to src/ocpp16/chargepoint/security/CaCertificatesDatabase.h index bacedc7e..fa0eed51 100644 --- a/src/chargepoint/security/CaCertificatesDatabase.h +++ b/src/ocpp16/chargepoint/security/CaCertificatesDatabase.h @@ -62,21 +62,22 @@ class CaCertificatesDatabase * @param certificate Certificate information * @return Operation status (see DeleteCertificateStatusEnumType documentation) */ - ocpp::types::DeleteCertificateStatusEnumType deleteCertificate(const ocpp::types::CertificateHashDataType& certificate); + ocpp::types::ocpp16::DeleteCertificateStatusEnumType deleteCertificate(const ocpp::types::ocpp16::CertificateHashDataType& certificate); /** * @brief Get the list of certificates * @param type Type of certificates * @param certificates List of certificates to fill */ - void getCertificateList(ocpp::types::CertificateUseEnumType type, std::vector& certificates); + void getCertificateList(ocpp::types::ocpp16::CertificateUseEnumType type, + std::vector& certificates); /** * @brief Get the list of valid certificates in PEM encoded data format * @param type Type of certificates * @return List of valid certificates in PEM encoded data format */ - std::string getCertificateListPem(ocpp::types::CertificateUseEnumType type); + std::string getCertificateListPem(ocpp::types::ocpp16::CertificateUseEnumType type); /** * @brief Get the number of installed certificates @@ -84,7 +85,7 @@ class CaCertificatesDatabase * @param check_validity Check the validity of the certificates * @return Number of installed certificates */ - unsigned int getCertificateCount(ocpp::types::CertificateUseEnumType type, bool check_validity); + unsigned int getCertificateCount(ocpp::types::ocpp16::CertificateUseEnumType type, bool check_validity); /** * @brief Add a new certificate @@ -93,9 +94,9 @@ class CaCertificatesDatabase * @param hash_data Certificate information * @return true if the certificate has been added, false otherwise */ - bool addCertificate(ocpp::types::CertificateUseEnumType type, - const ocpp::x509::Certificate& certificate, - const ocpp::types::CertificateHashDataType& hash_data); + bool addCertificate(ocpp::types::ocpp16::CertificateUseEnumType type, + const ocpp::x509::Certificate& certificate, + const ocpp::types::ocpp16::CertificateHashDataType& hash_data); private: /** @brief Stack configuration */ @@ -115,7 +116,7 @@ class CaCertificatesDatabase std::unique_ptr m_insert_query; /** @brief Look for a certificate */ - bool findCertificate(const ocpp::types::CertificateHashDataType& certificate, unsigned int& id, bool& in_use); + bool findCertificate(const ocpp::types::ocpp16::CertificateHashDataType& certificate, unsigned int& id, bool& in_use); }; } // namespace chargepoint diff --git a/src/chargepoint/security/CpCertificatesDatabase.cpp b/src/ocpp16/chargepoint/security/CpCertificatesDatabase.cpp similarity index 100% rename from src/chargepoint/security/CpCertificatesDatabase.cpp rename to src/ocpp16/chargepoint/security/CpCertificatesDatabase.cpp diff --git a/src/chargepoint/security/CpCertificatesDatabase.h b/src/ocpp16/chargepoint/security/CpCertificatesDatabase.h similarity index 100% rename from src/chargepoint/security/CpCertificatesDatabase.h rename to src/ocpp16/chargepoint/security/CpCertificatesDatabase.h diff --git a/src/chargepoint/security/ISecurityManager.h b/src/ocpp16/chargepoint/security/ISecurityManager.h similarity index 96% rename from src/chargepoint/security/ISecurityManager.h rename to src/ocpp16/chargepoint/security/ISecurityManager.h index aaf6e0fc..92b5446a 100644 --- a/src/chargepoint/security/ISecurityManager.h +++ b/src/ocpp16/chargepoint/security/ISecurityManager.h @@ -70,7 +70,7 @@ class ISecurityManager * @param type Type of certificate * @return Installed CA certificates as PEM encoded data */ - virtual std::string getCaCertificates(ocpp::types::CertificateUseEnumType type) = 0; + virtual std::string getCaCertificates(ocpp::types::ocpp16::CertificateUseEnumType type) = 0; }; } // namespace chargepoint diff --git a/src/chargepoint/security/SecurityLogsDatabase.cpp b/src/ocpp16/chargepoint/security/SecurityLogsDatabase.cpp similarity index 100% rename from src/chargepoint/security/SecurityLogsDatabase.cpp rename to src/ocpp16/chargepoint/security/SecurityLogsDatabase.cpp diff --git a/src/chargepoint/security/SecurityLogsDatabase.h b/src/ocpp16/chargepoint/security/SecurityLogsDatabase.h similarity index 100% rename from src/chargepoint/security/SecurityLogsDatabase.h rename to src/ocpp16/chargepoint/security/SecurityLogsDatabase.h diff --git a/src/chargepoint/security/SecurityManager.cpp b/src/ocpp16/chargepoint/security/SecurityManager.cpp similarity index 94% rename from src/chargepoint/security/SecurityManager.cpp rename to src/ocpp16/chargepoint/security/SecurityManager.cpp index b481a539..527b532b 100644 --- a/src/chargepoint/security/SecurityManager.cpp +++ b/src/ocpp16/chargepoint/security/SecurityManager.cpp @@ -35,8 +35,10 @@ along with OpenOCPP. If not, see . #include -using namespace ocpp::types; using namespace ocpp::messages; +using namespace ocpp::messages::ocpp16; +using namespace ocpp::types; +using namespace ocpp::types::ocpp16; using namespace ocpp::x509; namespace ocpp @@ -317,8 +319,7 @@ bool SecurityManager::logSecurityEvent(const std::string& type, const std::strin else { // Stack is not started, queue the notification - rapidjson::Document payload; - payload.Parse("{}"); + rapidjson::Document payload(rapidjson::kObjectType); m_security_event_req_converter->setAllocator(&payload.GetAllocator()); if (m_security_event_req_converter->toJson(request, payload)) { @@ -360,16 +361,17 @@ bool SecurityManager::exportSecurityEvents(const std::string& return m_security_logs_db.exportSecurityEvents(filepath, start_time, stop_time); } -/** @copydoc std::string ISecurityManager::getCaCertificates(ocpp::types::CertificateUseEnumType) */ -std::string SecurityManager::getCaCertificates(ocpp::types::CertificateUseEnumType type) +/** @copydoc std::string ISecurityManager::getCaCertificates(ocpp::types::ocpp16::CertificateUseEnumType) */ +std::string SecurityManager::getCaCertificates(ocpp::types::ocpp16::CertificateUseEnumType type) { return m_ca_certificates_db.getCertificateListPem(type); } // ITriggerMessageManager::ITriggerMessageHandler interface -/** @copydoc bool ITriggerMessageHandler::onTriggerMessage(ocpp::types::MessageTriggerEnumType, const ocpp::types::Optional&) */ -bool SecurityManager::onTriggerMessage(ocpp::types::MessageTriggerEnumType message, const ocpp::types::Optional& connector_id) +/** @copydoc bool ITriggerMessageHandler::onTriggerMessage(ocpp::types::ocpp16::MessageTriggerEnumType, const ocpp::types::Optional&) */ +bool SecurityManager::onTriggerMessage(ocpp::types::ocpp16::MessageTriggerEnumType message, + const ocpp::types::Optional& connector_id) { bool ret = false; (void)connector_id; @@ -414,10 +416,10 @@ bool SecurityManager::onTriggerMessage(ocpp::types::MessageTriggerEnumType messa * std::string& error_code, * std::string& error_message) */ -bool SecurityManager::handleMessage(const ocpp::messages::CertificateSignedReq& request, - ocpp::messages::CertificateSignedConf& response, - std::string& error_code, - std::string& error_message) +bool SecurityManager::handleMessage(const ocpp::messages::ocpp16::CertificateSignedReq& request, + ocpp::messages::ocpp16::CertificateSignedConf& response, + std::string& error_code, + std::string& error_message) { bool ret = true; bool send_security_event = true; @@ -498,10 +500,10 @@ bool SecurityManager::handleMessage(const ocpp::messages::CertificateSignedReq& * std::string& error_code, * std::string& error_message) */ -bool SecurityManager::handleMessage(const ocpp::messages::DeleteCertificateReq& request, - ocpp::messages::DeleteCertificateConf& response, - std::string& error_code, - std::string& error_message) +bool SecurityManager::handleMessage(const ocpp::messages::ocpp16::DeleteCertificateReq& request, + ocpp::messages::ocpp16::DeleteCertificateConf& response, + std::string& error_code, + std::string& error_message) { bool ret = true; @@ -538,10 +540,10 @@ bool SecurityManager::handleMessage(const ocpp::messages::DeleteCertificateReq& * std::string& error_code, * std::string& error_message) */ -bool SecurityManager::handleMessage(const ocpp::messages::GetInstalledCertificateIdsReq& request, - ocpp::messages::GetInstalledCertificateIdsConf& response, - std::string& error_code, - std::string& error_message) +bool SecurityManager::handleMessage(const ocpp::messages::ocpp16::GetInstalledCertificateIdsReq& request, + ocpp::messages::ocpp16::GetInstalledCertificateIdsConf& response, + std::string& error_code, + std::string& error_message) { bool ret = true; @@ -598,10 +600,10 @@ bool SecurityManager::handleMessage(const ocpp::messages::GetInstalledCertificat * std::string& error_code, * std::string& error_message) */ -bool SecurityManager::handleMessage(const ocpp::messages::InstallCertificateReq& request, - ocpp::messages::InstallCertificateConf& response, - std::string& error_code, - std::string& error_message) +bool SecurityManager::handleMessage(const ocpp::messages::ocpp16::InstallCertificateReq& request, + ocpp::messages::ocpp16::InstallCertificateConf& response, + std::string& error_code, + std::string& error_message) { bool ret = true; @@ -666,7 +668,7 @@ bool SecurityManager::handleMessage(const ocpp::messages::InstallCertificateReq& } /** @brief Specific configuration check for parameter : AuthorizationKey */ -ocpp::types::ConfigurationStatus SecurityManager::checkAuthorizationKeyParameter(const std::string& key, const std::string& value) +ocpp::types::ocpp16::ConfigurationStatus SecurityManager::checkAuthorizationKeyParameter(const std::string& key, const std::string& value) { (void)key; ConfigurationStatus ret = ConfigurationStatus::Rejected; @@ -686,7 +688,7 @@ ocpp::types::ConfigurationStatus SecurityManager::checkAuthorizationKeyParameter } /** @brief Specific configuration check for parameter : SecurityProfile */ -ocpp::types::ConfigurationStatus SecurityManager::checkSecurityProfileParameter(const std::string& key, const std::string& value) +ocpp::types::ocpp16::ConfigurationStatus SecurityManager::checkSecurityProfileParameter(const std::string& key, const std::string& value) { (void)key; ConfigurationStatus ret = ConfigurationStatus::Rejected; @@ -770,7 +772,7 @@ ocpp::types::ConfigurationStatus SecurityManager::checkSecurityProfileParameter( } /** @brief Fill the hash information of a certificat */ -void SecurityManager::fillHashInfo(const ocpp::x509::Certificate& certificate, ocpp::types::CertificateHashDataType& info) +void SecurityManager::fillHashInfo(const ocpp::x509::Certificate& certificate, ocpp::types::ocpp16::CertificateHashDataType& info) { // Compute hashes with SHA-256 algorithm Sha2 sha256; diff --git a/src/chargepoint/security/SecurityManager.h b/src/ocpp16/chargepoint/security/SecurityManager.h similarity index 75% rename from src/chargepoint/security/SecurityManager.h rename to src/ocpp16/chargepoint/security/SecurityManager.h index 1a2a224e..d17ddbc7 100644 --- a/src/chargepoint/security/SecurityManager.h +++ b/src/ocpp16/chargepoint/security/SecurityManager.h @@ -43,7 +43,10 @@ namespace messages { class IRequestFifo; class GenericMessageSender; +namespace ocpp16 +{ struct SecurityEventNotificationReq; +} // namespace ocpp16 } // namespace messages namespace helpers { @@ -58,14 +61,16 @@ class IChargePoint; class IChargePointEventsHandler; /** @brief Handle security operations for the charge point */ -class SecurityManager - : public ISecurityManager, - public ITriggerMessageManager::IExtendedTriggerMessageHandler, - public ocpp::messages::GenericMessageHandler, - public ocpp::messages::GenericMessageHandler, - public ocpp::messages::GenericMessageHandler, - public ocpp::messages::GenericMessageHandler +class SecurityManager : public ISecurityManager, + public ITriggerMessageManager::IExtendedTriggerMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler { public: /** @brief Constructor */ @@ -128,13 +133,14 @@ class SecurityManager const ocpp::types::Optional& start_time, const ocpp::types::Optional& stop_time) override; - /** @copydoc std::string ISecurityManager::getCaCertificates(ocpp::types::CertificateUseEnumType) */ - std::string getCaCertificates(ocpp::types::CertificateUseEnumType type) override; + /** @copydoc std::string ISecurityManager::getCaCertificates(ocpp::types::ocpp16::CertificateUseEnumType) */ + std::string getCaCertificates(ocpp::types::ocpp16::CertificateUseEnumType type) override; // ITriggerMessageManager::ITriggerMessageHandler interface - /** @copydoc bool ITriggerMessageHandler::onTriggerMessage(ocpp::types::MessageTriggerEnumType, const ocpp::types::Optional&) */ - bool onTriggerMessage(ocpp::types::MessageTriggerEnumType message, const ocpp::types::Optional& connector_id) override; + /** @copydoc bool ITriggerMessageHandler::onTriggerMessage(ocpp::types::ocpp16::MessageTriggerEnumType, const ocpp::types::Optional&) */ + bool onTriggerMessage(ocpp::types::ocpp16::MessageTriggerEnumType message, + const ocpp::types::Optional& connector_id) override; // GenericMessageHandler interface @@ -143,40 +149,40 @@ class SecurityManager * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::CertificateSignedReq& request, - ocpp::messages::CertificateSignedConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::CertificateSignedReq& request, + ocpp::messages::ocpp16::CertificateSignedConf& response, + std::string& error_code, + std::string& error_message) override; /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, * ResponseType& response, * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::DeleteCertificateReq& request, - ocpp::messages::DeleteCertificateConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::DeleteCertificateReq& request, + ocpp::messages::ocpp16::DeleteCertificateConf& response, + std::string& error_code, + std::string& error_message) override; /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, * ResponseType& response, * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::GetInstalledCertificateIdsReq& request, - ocpp::messages::GetInstalledCertificateIdsConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::GetInstalledCertificateIdsReq& request, + ocpp::messages::ocpp16::GetInstalledCertificateIdsConf& response, + std::string& error_code, + std::string& error_message) override; /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, * ResponseType& response, * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::InstallCertificateReq& request, - ocpp::messages::InstallCertificateConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::InstallCertificateReq& request, + ocpp::messages::ocpp16::InstallCertificateConf& response, + std::string& error_code, + std::string& error_message) override; private: /** @brief Stack configuration */ @@ -190,7 +196,7 @@ class SecurityManager /** @brief Transaction related requests FIFO */ ocpp::messages::IRequestFifo& m_requests_fifo; /** @brief Message converter for SecurityEventNotificationReq */ - std::unique_ptr> m_security_event_req_converter; + std::unique_ptr> m_security_event_req_converter; /** @brief Charge Point */ IChargePoint& m_charge_point; @@ -205,12 +211,12 @@ class SecurityManager ocpp::messages::GenericMessageSender* m_msg_sender; /** @brief Specific configuration check for parameter : AuthorizationKey */ - ocpp::types::ConfigurationStatus checkAuthorizationKeyParameter(const std::string& key, const std::string& value); + ocpp::types::ocpp16::ConfigurationStatus checkAuthorizationKeyParameter(const std::string& key, const std::string& value); /** @brief Specific configuration check for parameter : SecurityProfile */ - ocpp::types::ConfigurationStatus checkSecurityProfileParameter(const std::string& key, const std::string& value); + ocpp::types::ocpp16::ConfigurationStatus checkSecurityProfileParameter(const std::string& key, const std::string& value); /** @brief Fill the hash information of a certificat */ - void fillHashInfo(const ocpp::x509::Certificate& certificate, ocpp::types::CertificateHashDataType& info); + void fillHashInfo(const ocpp::x509::Certificate& certificate, ocpp::types::ocpp16::CertificateHashDataType& info); }; } // namespace chargepoint diff --git a/src/chargepoint/smartcharging/ISmartChargingManager.h b/src/ocpp16/chargepoint/smartcharging/ISmartChargingManager.h similarity index 88% rename from src/chargepoint/smartcharging/ISmartChargingManager.h rename to src/ocpp16/chargepoint/smartcharging/ISmartChargingManager.h index 4478e27a..1d0c6c77 100644 --- a/src/chargepoint/smartcharging/ISmartChargingManager.h +++ b/src/ocpp16/chargepoint/smartcharging/ISmartChargingManager.h @@ -42,10 +42,10 @@ class ISmartChargingManager * @param unit Setpoint unit (A or W) * @return true if the setpoints have been computed, false otherwise */ - virtual bool getSetpoint(unsigned int connector_id, - ocpp::types::Optional& charge_point_setpoint, - ocpp::types::Optional& connector_setpoint, - ocpp::types::ChargingRateUnitType unit = ocpp::types::ChargingRateUnitType::A) = 0; + virtual bool getSetpoint(unsigned int connector_id, + ocpp::types::Optional& charge_point_setpoint, + ocpp::types::Optional& connector_setpoint, + ocpp::types::ocpp16::ChargingRateUnitType unit = ocpp::types::ocpp16::ChargingRateUnitType::A) = 0; /** * @brief Install a TxProfile charging profile on a connector @@ -53,7 +53,7 @@ class ISmartChargingManager * @param profile Charging profile to install * @return true if the charging profile has been installed, false otherwise */ - virtual bool installTxProfile(unsigned int connector_id, const ocpp::types::ChargingProfile& profile) = 0; + virtual bool installTxProfile(unsigned int connector_id, const ocpp::types::ocpp16::ChargingProfile& profile) = 0; /** * @brief Assign the pending TxProfile of a connector to a transaction diff --git a/src/chargepoint/smartcharging/ProfileDatabase.cpp b/src/ocpp16/chargepoint/smartcharging/ProfileDatabase.cpp similarity index 95% rename from src/chargepoint/smartcharging/ProfileDatabase.cpp rename to src/ocpp16/chargepoint/smartcharging/ProfileDatabase.cpp index af2c394a..aee03ef5 100644 --- a/src/chargepoint/smartcharging/ProfileDatabase.cpp +++ b/src/ocpp16/chargepoint/smartcharging/ProfileDatabase.cpp @@ -27,8 +27,10 @@ along with OpenOCPP. If not, see . #include using namespace ocpp::database; -using namespace ocpp::types; using namespace ocpp::messages; +using namespace ocpp::messages::ocpp16; +using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { @@ -54,10 +56,10 @@ ProfileDatabase::~ProfileDatabase() { } /** @brief Clear one or multiple charging profiles with match criteria * (if none specified, all the profiles are cleared) */ -bool ProfileDatabase::clear(ocpp::types::Optional id, - ocpp::types::Optional connector_id, - ocpp::types::Optional purpose, - ocpp::types::Optional level) +bool ProfileDatabase::clear(ocpp::types::Optional id, + ocpp::types::Optional connector_id, + ocpp::types::Optional purpose, + ocpp::types::Optional level) { bool ret = false; @@ -172,7 +174,7 @@ bool ProfileDatabase::clear(ocpp::types::Optional } /** @brief Install a charging profile */ -bool ProfileDatabase::install(unsigned int connector_id, const ocpp::types::ChargingProfile& profile) +bool ProfileDatabase::install(unsigned int connector_id, const ocpp::types::ocpp16::ChargingProfile& profile) { bool ret = false; @@ -350,12 +352,11 @@ void ProfileDatabase::load() } /** @brief Serialize a profile to a string */ -std::string ProfileDatabase::serialize(const ocpp::types::ChargingProfile& profile) +std::string ProfileDatabase::serialize(const ocpp::types::ocpp16::ChargingProfile& profile) { std::string profile_str; - rapidjson::Document profile_json; - profile_json.Parse("{}"); + rapidjson::Document profile_json(rapidjson::kObjectType); ChargingProfileConverter charging_profile_converter; charging_profile_converter.setAllocator(&profile_json.GetAllocator()); charging_profile_converter.toJson(profile, profile_json); @@ -369,7 +370,7 @@ std::string ProfileDatabase::serialize(const ocpp::types::ChargingProfile& profi } /** @brief Deserialize a profile from a string */ -bool ProfileDatabase::deserialize(const std::string& profile_str, ocpp::types::ChargingProfile& profile) +bool ProfileDatabase::deserialize(const std::string& profile_str, ocpp::types::ocpp16::ChargingProfile& profile) { std::string error_code; std::string error_message; diff --git a/src/chargepoint/smartcharging/ProfileDatabase.h b/src/ocpp16/chargepoint/smartcharging/ProfileDatabase.h similarity index 88% rename from src/chargepoint/smartcharging/ProfileDatabase.h rename to src/ocpp16/chargepoint/smartcharging/ProfileDatabase.h index dc8b5490..a4f4032b 100644 --- a/src/chargepoint/smartcharging/ProfileDatabase.h +++ b/src/ocpp16/chargepoint/smartcharging/ProfileDatabase.h @@ -50,7 +50,7 @@ class ProfileDatabase // ProfileDatabase interface /** @brief Stores a profile alongside its target connector */ - typedef std::pair ChargingProfileInfo; + typedef std::pair ChargingProfileInfo; /** @brief Allow sorting of profiles by stack level and connector id*/ struct ChargingProfileInfoLess { @@ -71,10 +71,10 @@ class ProfileDatabase * @param level Specifies the stackLevel for which charging profiles will be cleared * @return true if at least 1 profile matched the criteria, false otherwise */ - bool clear(ocpp::types::Optional id, - ocpp::types::Optional connector_id = ocpp::types::Optional(), - ocpp::types::Optional purpose = - ocpp::types::Optional(), + bool clear(ocpp::types::Optional id, + ocpp::types::Optional connector_id = ocpp::types::Optional(), + ocpp::types::Optional purpose = + ocpp::types::Optional(), ocpp::types::Optional level = ocpp::types::Optional()); /** @@ -83,7 +83,7 @@ class ProfileDatabase * @param profile Charging profile to install * @return true if the charging profile has been installed, false otherwise */ - bool install(unsigned int connector_id, const ocpp::types::ChargingProfile& profile); + bool install(unsigned int connector_id, const ocpp::types::ocpp16::ChargingProfile& profile); /** * @brief Assign the pending TxProfile of a connector to a transaction @@ -126,9 +126,9 @@ class ProfileDatabase void load(); /** @brief Serialize a profile to a string */ - std::string serialize(const ocpp::types::ChargingProfile& profile); + std::string serialize(const ocpp::types::ocpp16::ChargingProfile& profile); /** @brief Deserialize a profile from a string */ - bool deserialize(const std::string& profile_str, ocpp::types::ChargingProfile& profile); + bool deserialize(const std::string& profile_str, ocpp::types::ocpp16::ChargingProfile& profile); }; } // namespace chargepoint diff --git a/src/chargepoint/smartcharging/SmartChargingManager.cpp b/src/ocpp16/chargepoint/smartcharging/SmartChargingManager.cpp similarity index 93% rename from src/chargepoint/smartcharging/SmartChargingManager.cpp rename to src/ocpp16/chargepoint/smartcharging/SmartChargingManager.cpp index ebe2600e..fbf3c8d8 100644 --- a/src/chargepoint/smartcharging/SmartChargingManager.cpp +++ b/src/ocpp16/chargepoint/smartcharging/SmartChargingManager.cpp @@ -27,8 +27,10 @@ along with OpenOCPP. If not, see . #include -using namespace ocpp::types; using namespace ocpp::messages; +using namespace ocpp::messages::ocpp16; +using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { @@ -74,13 +76,13 @@ SmartChargingManager::SmartChargingManager(const ocpp::config::IChargePointConfi SmartChargingManager::~SmartChargingManager() { } /** @copydoc bool ISmartChargingManager::getSetpoint(unsigned int, - ocpp::types::Optional&, - ocpp::types::Optional&, - ocpp::types::ChargingRateUnitType) */ -bool SmartChargingManager::getSetpoint(unsigned int connector_id, - ocpp::types::Optional& charge_point_setpoint, - ocpp::types::Optional& connector_setpoint, - ocpp::types::ChargingRateUnitType unit) + ocpp::types::Optional&, + ocpp::types::Optional&, + ocpp::types::ocpp16::ChargingRateUnitType) */ +bool SmartChargingManager::getSetpoint(unsigned int connector_id, + ocpp::types::Optional& charge_point_setpoint, + ocpp::types::Optional& connector_setpoint, + ocpp::types::ocpp16::ChargingRateUnitType unit) { bool ret = false; @@ -129,8 +131,8 @@ bool SmartChargingManager::getSetpoint(unsigned int return ret; } -/** @copydoc bool ISmartChargingManager::installTxProfile(unsigned int, const ocpp::types::ChargingProfile&) */ -bool SmartChargingManager::installTxProfile(unsigned int connector_id, const ocpp::types::ChargingProfile& profile) +/** @copydoc bool ISmartChargingManager::installTxProfile(unsigned int, const ocpp::types::ocpp16::ChargingProfile&) */ +bool SmartChargingManager::installTxProfile(unsigned int connector_id, const ocpp::types::ocpp16::ChargingProfile& profile) { bool ret = false; @@ -178,10 +180,10 @@ void SmartChargingManager::clearTxProfiles(unsigned int connector_id) * std::string& error_code, * std::string& error_message) */ -bool SmartChargingManager::handleMessage(const ocpp::messages::ClearChargingProfileReq& request, - ocpp::messages::ClearChargingProfileConf& response, - std::string& error_code, - std::string& error_message) +bool SmartChargingManager::handleMessage(const ocpp::messages::ocpp16::ClearChargingProfileReq& request, + ocpp::messages::ocpp16::ClearChargingProfileConf& response, + std::string& error_code, + std::string& error_message) { (void)error_code; (void)error_message; @@ -216,10 +218,10 @@ bool SmartChargingManager::handleMessage(const ocpp::messages::ClearChargingProf * std::string& error_code, * std::string& error_message) */ -bool SmartChargingManager::handleMessage(const ocpp::messages::SetChargingProfileReq& request, - ocpp::messages::SetChargingProfileConf& response, - std::string& error_code, - std::string& error_message) +bool SmartChargingManager::handleMessage(const ocpp::messages::ocpp16::SetChargingProfileReq& request, + ocpp::messages::ocpp16::SetChargingProfileConf& response, + std::string& error_code, + std::string& error_message) { bool ret = false; @@ -359,24 +361,24 @@ bool SmartChargingManager::handleMessage(const ocpp::messages::SetChargingProfil * std::string& error_code, * std::string& error_message) */ -bool SmartChargingManager::handleMessage(const ocpp::messages::GetCompositeScheduleReq& request, - ocpp::messages::GetCompositeScheduleConf& response, - std::string& error_code, - std::string& error_message) +bool SmartChargingManager::handleMessage(const ocpp::messages::ocpp16::GetCompositeScheduleReq& request, + ocpp::messages::ocpp16::GetCompositeScheduleConf& response, + std::string& error_code, + std::string& error_message) { (void)error_code; (void)error_message; - ocpp::types::ChargingRateUnitType charging_rate_unit; + ocpp::types::ocpp16::ChargingRateUnitType charging_rate_unit; if (!request.chargingRateUnit.isSet()) { if (m_ocpp_config.chargingScheduleAllowedChargingRateUnit().find("Power") != std::string::npos) { - charging_rate_unit = types::ChargingRateUnitType::W; + charging_rate_unit = ocpp::types::ocpp16::ChargingRateUnitType::W; } else { - charging_rate_unit = types::ChargingRateUnitType::A; + charging_rate_unit = ocpp::types::ocpp16::ChargingRateUnitType::A; } } else @@ -562,10 +564,10 @@ void SmartChargingManager::cleanupProfiles() } /** @brief Compute the setpoint of a given connector with a profile list */ -void SmartChargingManager::computeSetpoint(Connector* connector, - ocpp::types::Optional& connector_setpoint, - ocpp::types::ChargingRateUnitType unit, - const ProfileDatabase::ChargingProfileList& profiles_list) +void SmartChargingManager::computeSetpoint(Connector* connector, + ocpp::types::Optional& connector_setpoint, + ocpp::types::ocpp16::ChargingRateUnitType unit, + const ProfileDatabase::ChargingProfileList& profiles_list) { for (const auto& profile : profiles_list) { @@ -587,10 +589,10 @@ void SmartChargingManager::computeSetpoint(Connector* } /** @brief Check if the given profile is active */ -bool SmartChargingManager::isProfileActive(Connector* connector, - const ocpp::types::ChargingProfile& profile, - size_t& period, - const ocpp::types::DateTime& time_point) +bool SmartChargingManager::isProfileActive(Connector* connector, + const ocpp::types::ocpp16::ChargingProfile& profile, + size_t& period, + const ocpp::types::DateTime& time_point) { bool ret = false; @@ -629,10 +631,10 @@ bool SmartChargingManager::isProfileActive(Connector* c } /** @brief Fill a setpoint structure with a charging profile and a charging schedule period */ -void SmartChargingManager::fillSetpoint(ocpp::types::SmartChargingSetpoint& setpoint, - ocpp::types::ChargingRateUnitType unit, - const ocpp::types::ChargingProfile& profile, - const ocpp::types::ChargingSchedulePeriod& period) +void SmartChargingManager::fillSetpoint(ocpp::types::ocpp16::SmartChargingSetpoint& setpoint, + ocpp::types::ocpp16::ChargingRateUnitType unit, + const ocpp::types::ocpp16::ChargingProfile& profile, + const ocpp::types::ocpp16::ChargingSchedulePeriod& period) { setpoint.min_charging_rate = profile.chargingSchedule.minChargingRate; if (period.numberPhases.isSet()) @@ -658,7 +660,7 @@ void SmartChargingManager::fillSetpoint(ocpp::types::SmartChargingSetpoint& } /** @brief Convert charging rate units */ -float SmartChargingManager::convertToUnit(float value, ocpp::types::ChargingRateUnitType unit, unsigned int number_phases) +float SmartChargingManager::convertToUnit(float value, ocpp::types::ocpp16::ChargingRateUnitType unit, unsigned int number_phases) { float ret; if (unit == ChargingRateUnitType::A) @@ -673,7 +675,7 @@ float SmartChargingManager::convertToUnit(float value, ocpp::types::ChargingRate } /** @brief Indicate if a charging profile is valid at a given point in time */ -bool SmartChargingManager::isProfileValid(const ocpp::types::ChargingProfile& profile, const ocpp::types::DateTime& time_point) +bool SmartChargingManager::isProfileValid(const ocpp::types::ocpp16::ChargingProfile& profile, const ocpp::types::DateTime& time_point) { bool ret = false; if ((!profile.validFrom.isSet() || (time_point >= profile.validFrom)) && (!profile.validTo.isSet() || (time_point <= profile.validTo))) @@ -684,7 +686,7 @@ bool SmartChargingManager::isProfileValid(const ocpp::types::ChargingProfile& pr } /** @brief Get the kind of charging profile */ -ocpp::types::ChargingProfileKindType SmartChargingManager::getProfileKind(const ocpp::types::ChargingProfile& profile) +ocpp::types::ocpp16::ChargingProfileKindType SmartChargingManager::getProfileKind(const ocpp::types::ocpp16::ChargingProfile& profile) { ChargingProfileKindType kind = profile.chargingProfileKind; if (kind == ChargingProfileKindType::Absolute) @@ -700,10 +702,10 @@ ocpp::types::ChargingProfileKindType SmartChargingManager::getProfileKind(const } /** @brief Get the start time of a charging profile schedule */ -ocpp::types::DateTime SmartChargingManager::getProfileStartTime(Connector* connector, - const ocpp::types::ChargingProfile& profile, - ocpp::types::ChargingProfileKindType kind, - const ocpp::types::DateTime& time_point) +ocpp::types::DateTime SmartChargingManager::getProfileStartTime(Connector* connector, + const ocpp::types::ocpp16::ChargingProfile& profile, + ocpp::types::ocpp16::ChargingProfileKindType kind, + const ocpp::types::DateTime& time_point) { DateTime start_of_schedule; switch (kind) @@ -785,10 +787,10 @@ ocpp::types::DateTime SmartChargingManager::getProfileStartTime(Connector* } /** @brief Get the composite schedule periods corresponding to a charging profile */ -std::vector SmartChargingManager::getProfilePeriods(Connector* connector, - const ocpp::types::ChargingProfile& profile, - const ocpp::types::DateTime& time_point, - unsigned int duration) +std::vector SmartChargingManager::getProfilePeriods(Connector* connector, + const ocpp::types::ocpp16::ChargingProfile& profile, + const ocpp::types::DateTime& time_point, + unsigned int duration) { std::vector periods; diff --git a/src/chargepoint/smartcharging/SmartChargingManager.h b/src/ocpp16/chargepoint/smartcharging/SmartChargingManager.h similarity index 67% rename from src/chargepoint/smartcharging/SmartChargingManager.h rename to src/ocpp16/chargepoint/smartcharging/SmartChargingManager.h index fb930720..2e38e1d6 100644 --- a/src/chargepoint/smartcharging/SmartChargingManager.h +++ b/src/ocpp16/chargepoint/smartcharging/SmartChargingManager.h @@ -57,11 +57,13 @@ struct Connector; class IChargePointEventsHandler; /** @brief Handle smart charging for the charge point */ -class SmartChargingManager - : public ISmartChargingManager, - public ocpp::messages::GenericMessageHandler, - public ocpp::messages::GenericMessageHandler, - public ocpp::messages::GenericMessageHandler +class SmartChargingManager : public ISmartChargingManager, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler { public: @@ -82,16 +84,16 @@ class SmartChargingManager // ISmartChargingManager interface /** @copydoc bool ISmartChargingManager::getSetpoint(unsigned int, - ocpp::types::Optional&, - ocpp::types::Optional&, - ocpp::types::ChargingRateUnitType) */ - bool getSetpoint(unsigned int connector_id, - ocpp::types::Optional& charge_point_setpoint, - ocpp::types::Optional& connector_setpoint, - ocpp::types::ChargingRateUnitType unit) override; + ocpp::types::Optional&, + ocpp::types::Optional&, + ocpp::types::ocpp16::ChargingRateUnitType) */ + bool getSetpoint(unsigned int connector_id, + ocpp::types::Optional& charge_point_setpoint, + ocpp::types::Optional& connector_setpoint, + ocpp::types::ocpp16::ChargingRateUnitType unit) override; - /** @copydoc bool ISmartChargingManager::installTxProfile(unsigned int, const ocpp::types::ChargingProfile&) */ - bool installTxProfile(unsigned int connector_id, const ocpp::types::ChargingProfile& profile) override; + /** @copydoc bool ISmartChargingManager::installTxProfile(unsigned int, const ocpp::types::ocpp16::ChargingProfile&) */ + bool installTxProfile(unsigned int connector_id, const ocpp::types::ocpp16::ChargingProfile& profile) override; /** @copydoc void ISmartChargingManager::assignPendingTxProfiles(unsigned int), unsigned int) */ void assignPendingTxProfiles(unsigned int connector_id, int transaction_id) override; @@ -106,30 +108,30 @@ class SmartChargingManager * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::ClearChargingProfileReq& request, - ocpp::messages::ClearChargingProfileConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::ClearChargingProfileReq& request, + ocpp::messages::ocpp16::ClearChargingProfileConf& response, + std::string& error_code, + std::string& error_message) override; /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, * ResponseType& response, * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::SetChargingProfileReq& request, - ocpp::messages::SetChargingProfileConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::SetChargingProfileReq& request, + ocpp::messages::ocpp16::SetChargingProfileConf& response, + std::string& error_code, + std::string& error_message) override; /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, * ResponseType& response, * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::GetCompositeScheduleReq& request, - ocpp::messages::GetCompositeScheduleConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::GetCompositeScheduleReq& request, + ocpp::messages::ocpp16::GetCompositeScheduleConf& response, + std::string& error_code, + std::string& error_message) override; private: /** @brief Stack configuration */ @@ -161,7 +163,7 @@ class SmartChargingManager /** @brief Setpoint for the period */ float setpoint; /** @brief Unit of the setpoint for the period */ - ocpp::types::ChargingRateUnitType unit; + ocpp::types::ocpp16::ChargingRateUnitType unit; /** @brief Number of phases */ unsigned int nb_phases; }; @@ -170,43 +172,43 @@ class SmartChargingManager void cleanupProfiles(); /** @brief Compute the setpoint of a given connector with a profile list */ - void computeSetpoint(Connector* connector, - ocpp::types::Optional& connector_setpoint, - ocpp::types::ChargingRateUnitType unit, - const ProfileDatabase::ChargingProfileList& profiles_list); + void computeSetpoint(Connector* connector, + ocpp::types::Optional& connector_setpoint, + ocpp::types::ocpp16::ChargingRateUnitType unit, + const ProfileDatabase::ChargingProfileList& profiles_list); /** @brief Check if the given profile is active */ - bool isProfileActive(Connector* connector, - const ocpp::types::ChargingProfile& profile, - size_t& period, - const ocpp::types::DateTime& time_point); + bool isProfileActive(Connector* connector, + const ocpp::types::ocpp16::ChargingProfile& profile, + size_t& period, + const ocpp::types::DateTime& time_point); /** @brief Fill a setpoint structure with a charging profile and a charging schedule period */ - void fillSetpoint(ocpp::types::SmartChargingSetpoint& setpoint, - ocpp::types::ChargingRateUnitType unit, - const ocpp::types::ChargingProfile& profile, - const ocpp::types::ChargingSchedulePeriod& period); + void fillSetpoint(ocpp::types::ocpp16::SmartChargingSetpoint& setpoint, + ocpp::types::ocpp16::ChargingRateUnitType unit, + const ocpp::types::ocpp16::ChargingProfile& profile, + const ocpp::types::ocpp16::ChargingSchedulePeriod& period); /** @brief Convert charging rate units */ - float convertToUnit(float value, ocpp::types::ChargingRateUnitType unit, unsigned int number_phases); + float convertToUnit(float value, ocpp::types::ocpp16::ChargingRateUnitType unit, unsigned int number_phases); /** @brief Indicate if a charging profile is valid at a given point in time */ - bool isProfileValid(const ocpp::types::ChargingProfile& profile, const ocpp::types::DateTime& time_point); + bool isProfileValid(const ocpp::types::ocpp16::ChargingProfile& profile, const ocpp::types::DateTime& time_point); /** @brief Get the kind of charging profile */ - ocpp::types::ChargingProfileKindType getProfileKind(const ocpp::types::ChargingProfile& profile); + ocpp::types::ocpp16::ChargingProfileKindType getProfileKind(const ocpp::types::ocpp16::ChargingProfile& profile); /** @brief Get the start time of a charging profile schedule */ - ocpp::types::DateTime getProfileStartTime(Connector* connector, - const ocpp::types::ChargingProfile& profile, - ocpp::types::ChargingProfileKindType kind, - const ocpp::types::DateTime& time_point); + ocpp::types::DateTime getProfileStartTime(Connector* connector, + const ocpp::types::ocpp16::ChargingProfile& profile, + ocpp::types::ocpp16::ChargingProfileKindType kind, + const ocpp::types::DateTime& time_point); /** @brief Get the composite schedule periods corresponding to a charging profile */ - std::vector getProfilePeriods(Connector* connector, - const ocpp::types::ChargingProfile& profile, - const ocpp::types::DateTime& time_point, - unsigned int duration); + std::vector getProfilePeriods(Connector* connector, + const ocpp::types::ocpp16::ChargingProfile& profile, + const ocpp::types::DateTime& time_point, + unsigned int duration); /** @brief Merge charging profiles periods */ std::vector mergeProfilePeriods(const std::vector& ref_periods, const std::vector& new_periods); diff --git a/src/chargepoint/status/IStatusManager.h b/src/ocpp16/chargepoint/status/IStatusManager.h similarity index 73% rename from src/chargepoint/status/IStatusManager.h rename to src/ocpp16/chargepoint/status/IStatusManager.h index a3d1a39d..5314ce04 100644 --- a/src/chargepoint/status/IStatusManager.h +++ b/src/ocpp16/chargepoint/status/IStatusManager.h @@ -35,13 +35,13 @@ class IStatusManager * @brief Get the registration status with the central system * @return Registration status (see RegistrationStatus enum) */ - virtual ocpp::types::RegistrationStatus getRegistrationStatus() = 0; + virtual ocpp::types::ocpp16::RegistrationStatus getRegistrationStatus() = 0; /** * @brief Force the registration status with the central system * @param status New registration status */ - virtual void forceRegistrationStatus(ocpp::types::RegistrationStatus status) = 0; + virtual void forceRegistrationStatus(ocpp::types::ocpp16::RegistrationStatus status) = 0; /** * @brief Update the charge point connection status @@ -59,12 +59,13 @@ class IStatusManager * @param vendor_error Vendor specific error code * @return true if the status has been notified, false otherwise */ - virtual bool updateConnectorStatus(unsigned int connector_id, - ocpp::types::ChargePointStatus status, - ocpp::types::ChargePointErrorCode error_code = ocpp::types::ChargePointErrorCode::NoError, - const std::string& info = "", - const std::string& vendor_id = "", - const std::string& vendor_error = "") = 0; + virtual bool updateConnectorStatus( + unsigned int connector_id, + ocpp::types::ocpp16::ChargePointStatus status, + ocpp::types::ocpp16::ChargePointErrorCode error_code = ocpp::types::ocpp16::ChargePointErrorCode::NoError, + const std::string& info = "", + const std::string& vendor_id = "", + const std::string& vendor_error = "") = 0; /** @brief Reset the hearbeat timer */ virtual void resetHeartBeatTimer() = 0; diff --git a/src/chargepoint/status/StatusManager.cpp b/src/ocpp16/chargepoint/status/StatusManager.cpp similarity index 90% rename from src/chargepoint/status/StatusManager.cpp rename to src/ocpp16/chargepoint/status/StatusManager.cpp index f343456f..b2e86e89 100644 --- a/src/chargepoint/status/StatusManager.cpp +++ b/src/ocpp16/chargepoint/status/StatusManager.cpp @@ -33,8 +33,10 @@ along with OpenOCPP. If not, see . #include #include -using namespace ocpp::types; using namespace ocpp::messages; +using namespace ocpp::messages::ocpp16; +using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { @@ -71,12 +73,12 @@ StatusManager::StatusManager(const ocpp::config::IChargePointConfig& sta m_boot_notification_timer.setCallback([this] { m_worker_pool.run(std::bind(&StatusManager::bootNotificationProcess, this)); }); m_heartbeat_timer.setCallback([this] { m_worker_pool.run(std::bind(&StatusManager::heartBeatProcess, this)); }); - trigger_manager.registerHandler(ocpp::types::MessageTrigger::BootNotification, *this); - trigger_manager.registerHandler(ocpp::types::MessageTrigger::Heartbeat, *this); - trigger_manager.registerHandler(ocpp::types::MessageTrigger::StatusNotification, *this); - trigger_manager.registerHandler(ocpp::types::MessageTriggerEnumType::BootNotification, *this); - trigger_manager.registerHandler(ocpp::types::MessageTriggerEnumType::Heartbeat, *this); - trigger_manager.registerHandler(ocpp::types::MessageTriggerEnumType::StatusNotification, *this); + trigger_manager.registerHandler(ocpp::types::ocpp16::MessageTrigger::BootNotification, *this); + trigger_manager.registerHandler(ocpp::types::ocpp16::MessageTrigger::Heartbeat, *this); + trigger_manager.registerHandler(ocpp::types::ocpp16::MessageTrigger::StatusNotification, *this); + trigger_manager.registerHandler(ocpp::types::ocpp16::MessageTriggerEnumType::BootNotification, *this); + trigger_manager.registerHandler(ocpp::types::ocpp16::MessageTriggerEnumType::Heartbeat, *this); + trigger_manager.registerHandler(ocpp::types::ocpp16::MessageTriggerEnumType::StatusNotification, *this); msg_dispatcher.registerHandler(CHANGE_AVAILABILITY_ACTION, *this); } @@ -84,8 +86,8 @@ StatusManager::StatusManager(const ocpp::config::IChargePointConfig& sta /** @brief Destructor */ StatusManager::~StatusManager() { } -/** @copydoc void IStatusManager::forceRegistrationStatus(ocpp::types::RegistrationStatus) */ -void StatusManager::forceRegistrationStatus(ocpp::types::RegistrationStatus status) +/** @copydoc void IStatusManager::forceRegistrationStatus(ocpp::types::ocpp16::RegistrationStatus) */ +void StatusManager::forceRegistrationStatus(ocpp::types::ocpp16::RegistrationStatus status) { m_registration_status = status; m_force_boot_notification = true; @@ -126,18 +128,18 @@ void StatusManager::updateConnectionStatus(bool is_connected) } /** @copydoc bool IStatusManager::updateConnectorStatus(unsigned int, - * ocpp::types::ChargePointStatus, - * ocpp::types::ChargePointErrorCode, + * ocpp::types::ocpp16::ChargePointStatus, + * ocpp::types::ocpp16::ChargePointErrorCode, * const std::string&, * const std::string&, * const std::string&) */ -bool StatusManager::updateConnectorStatus(unsigned int connector_id, - ocpp::types::ChargePointStatus status, - ocpp::types::ChargePointErrorCode error_code, - const std::string& info, - const std::string& vendor_id, - const std::string& vendor_error) +bool StatusManager::updateConnectorStatus(unsigned int connector_id, + ocpp::types::ocpp16::ChargePointStatus status, + ocpp::types::ocpp16::ChargePointErrorCode error_code, + const std::string& info, + const std::string& vendor_id, + const std::string& vendor_error) { bool ret = false; @@ -202,8 +204,8 @@ void StatusManager::resetHeartBeatTimer() // ITriggerMessageHandler interfaces -/** @copydoc bool ITriggerMessageHandler::onTriggerMessage(ocpp::types::MessageTrigger, const ocpp::types::Optional&) */ -bool StatusManager::onTriggerMessage(ocpp::types::MessageTrigger message, const ocpp::types::Optional& connector_id) +/** @copydoc bool ITriggerMessageHandler::onTriggerMessage(ocpp::types::ocpp16::MessageTrigger, const ocpp::types::Optional&) */ +bool StatusManager::onTriggerMessage(ocpp::types::ocpp16::MessageTrigger message, const ocpp::types::Optional& connector_id) { bool ret = true; switch (message) @@ -272,8 +274,9 @@ bool StatusManager::onTriggerMessage(ocpp::types::MessageTrigger message, const return ret; } -/** @copydoc bool ITriggerMessageHandler::onTriggerMessage(ocpp::types::MessageTriggerEnumType, const ocpp::types::Optional&) */ -bool StatusManager::onTriggerMessage(ocpp::types::MessageTriggerEnumType message, const ocpp::types::Optional& connector_id) +/** @copydoc bool ITriggerMessageHandler::onTriggerMessage(ocpp::types::ocpp16::MessageTriggerEnumType, const ocpp::types::Optional&) */ +bool StatusManager::onTriggerMessage(ocpp::types::ocpp16::MessageTriggerEnumType message, + const ocpp::types::Optional& connector_id) { bool ret = true; switch (message) @@ -349,10 +352,10 @@ bool StatusManager::onTriggerMessage(ocpp::types::MessageTriggerEnumType message * std::string& error_code, * std::string& error_message) */ -bool StatusManager::handleMessage(const ocpp::messages::ChangeAvailabilityReq& request, - ocpp::messages::ChangeAvailabilityConf& response, - std::string& error_code, - std::string& error_message) +bool StatusManager::handleMessage(const ocpp::messages::ocpp16::ChangeAvailabilityReq& request, + ocpp::messages::ocpp16::ChangeAvailabilityConf& response, + std::string& error_code, + std::string& error_message) { bool ret = false; @@ -377,9 +380,9 @@ bool StatusManager::handleMessage(const ocpp::messages::ChangeAvailabilityReq& r Connector* connector = m_connectors.getConnector(connector_id); if (connector) { - std::lock_guard lock(connector->mutex); - connector->availability = static_cast(request.type); - m_connectors.saveConnector(connector->id); + std::lock_guard lock(connector->mutex); + connector->availability = static_cast(request.type); + m_connectors.saveConnector(connector->id); } // In the case the ChangeAvailability.req contains ConnectorId = 0, the status change applies to the Charge Point and all Connectors. diff --git a/src/chargepoint/status/StatusManager.h b/src/ocpp16/chargepoint/status/StatusManager.h similarity index 75% rename from src/chargepoint/status/StatusManager.h rename to src/ocpp16/chargepoint/status/StatusManager.h index b3c525db..1830d3dd 100644 --- a/src/chargepoint/status/StatusManager.h +++ b/src/ocpp16/chargepoint/status/StatusManager.h @@ -51,11 +51,11 @@ class Connectors; class IChargePointEventsHandler; /** @brief Handle charge point status (boot notification, status notification, heartbeat) */ -class StatusManager - : public IStatusManager, - public ITriggerMessageManager::ITriggerMessageHandler, - public ITriggerMessageManager::IExtendedTriggerMessageHandler, - public ocpp::messages::GenericMessageHandler +class StatusManager : public IStatusManager, + public ITriggerMessageManager::ITriggerMessageHandler, + public ITriggerMessageManager::IExtendedTriggerMessageHandler, + public ocpp::messages::GenericMessageHandler { public: /** @brief Constructor */ @@ -76,39 +76,40 @@ class StatusManager // IStatusManager interface - /** @copydoc ocpp::types::RegistrationStatus IStatusManager::getRegistrationStatus() */ - ocpp::types::RegistrationStatus getRegistrationStatus() override { return m_registration_status; } + /** @copydoc ocpp::types::ocpp16::RegistrationStatus IStatusManager::getRegistrationStatus() */ + ocpp::types::ocpp16::RegistrationStatus getRegistrationStatus() override { return m_registration_status; } - /** @copydoc void IStatusManager::forceRegistrationStatus(ocpp::types::RegistrationStatus) */ - void forceRegistrationStatus(ocpp::types::RegistrationStatus status) override; + /** @copydoc void IStatusManager::forceRegistrationStatus(ocpp::types::ocpp16::RegistrationStatus) */ + void forceRegistrationStatus(ocpp::types::ocpp16::RegistrationStatus status) override; /** @copydoc void IStatusManager::updateConnectionStatus(bool) */ void updateConnectionStatus(bool is_connected) override; /** @copydoc bool IStatusManager::updateConnectorStatus(unsigned int, - * ocpp::types::ChargePointStatus, - * ocpp::types::ChargePointErrorCode, + * ocpp::types::ocpp16::ChargePointStatus, + * ocpp::types::ocpp16::ChargePointErrorCode, * const std::string&, * const std::string&, * const std::string&) */ - bool updateConnectorStatus(unsigned int connector_id, - ocpp::types::ChargePointStatus status, - ocpp::types::ChargePointErrorCode error_code = ocpp::types::ChargePointErrorCode::NoError, - const std::string& info = "", - const std::string& vendor_id = "", - const std::string& vendor_error = "") override; + bool updateConnectorStatus(unsigned int connector_id, + ocpp::types::ocpp16::ChargePointStatus status, + ocpp::types::ocpp16::ChargePointErrorCode error_code = ocpp::types::ocpp16::ChargePointErrorCode::NoError, + const std::string& info = "", + const std::string& vendor_id = "", + const std::string& vendor_error = "") override; /** @copydoc void IStatusManager::resetHeartBeatTimer() */ void resetHeartBeatTimer() override; // ITriggerMessageHandler interfaces - /** @copydoc bool ITriggerMessageHandler::onTriggerMessage(ocpp::types::MessageTrigger, const ocpp::types::Optional&) */ - bool onTriggerMessage(ocpp::types::MessageTrigger message, const ocpp::types::Optional& connector_id) override; + /** @copydoc bool ITriggerMessageHandler::onTriggerMessage(ocpp::types::ocpp16::MessageTrigger, const ocpp::types::Optional&) */ + bool onTriggerMessage(ocpp::types::ocpp16::MessageTrigger message, const ocpp::types::Optional& connector_id) override; - /** @copydoc bool ITriggerMessageHandler::onTriggerMessage(ocpp::types::MessageTriggerEnumType, const ocpp::types::Optional&) */ - bool onTriggerMessage(ocpp::types::MessageTriggerEnumType message, const ocpp::types::Optional& connector_id) override; + /** @copydoc bool ITriggerMessageHandler::onTriggerMessage(ocpp::types::ocpp16::MessageTriggerEnumType, const ocpp::types::Optional&) */ + bool onTriggerMessage(ocpp::types::ocpp16::MessageTriggerEnumType message, + const ocpp::types::Optional& connector_id) override; // GenericMessageHandler interface @@ -117,10 +118,10 @@ class StatusManager * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::ChangeAvailabilityReq& request, - ocpp::messages::ChangeAvailabilityConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::ChangeAvailabilityReq& request, + ocpp::messages::ocpp16::ChangeAvailabilityConf& response, + std::string& error_code, + std::string& error_message) override; private: /** @brief Stack configuration */ @@ -139,7 +140,7 @@ class StatusManager ocpp::messages::GenericMessageSender& m_msg_sender; /** @brief Registration status */ - ocpp::types::RegistrationStatus m_registration_status; + ocpp::types::ocpp16::RegistrationStatus m_registration_status; /** @brief Indicate if the boot notification message must be inconditionnaly sent on connection */ bool m_force_boot_notification; /** @brief Indicate if the boot notification message has been sent */ diff --git a/src/chargepoint/transaction/TransactionManager.cpp b/src/ocpp16/chargepoint/transaction/TransactionManager.cpp similarity index 95% rename from src/chargepoint/transaction/TransactionManager.cpp rename to src/ocpp16/chargepoint/transaction/TransactionManager.cpp index 51b25720..c4b7a382 100644 --- a/src/chargepoint/transaction/TransactionManager.cpp +++ b/src/ocpp16/chargepoint/transaction/TransactionManager.cpp @@ -30,8 +30,10 @@ along with OpenOCPP. If not, see . #include "StartTransaction.h" #include "StopTransaction.h" -using namespace ocpp::types; using namespace ocpp::messages; +using namespace ocpp::messages::ocpp16; +using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { @@ -75,7 +77,7 @@ TransactionManager::TransactionManager(ocpp::config::IOcppConfig& TransactionManager::~TransactionManager() { } /** @brief Start a transaction */ -ocpp::types::AuthorizationStatus TransactionManager::startTransaction(unsigned int connector_id, const std::string& id_tag, int& transaction_id) +AuthorizationStatus TransactionManager::startTransaction(unsigned int connector_id, const std::string& id_tag, int& transaction_id) { AuthorizationStatus ret = AuthorizationStatus::Invalid; @@ -201,7 +203,7 @@ ocpp::types::AuthorizationStatus TransactionManager::startTransaction(unsigned i } /** @brief Stop a transaction */ -bool TransactionManager::stopTransaction(unsigned int connector_id, const std::string& id_tag, ocpp::types::Reason reason) +bool TransactionManager::stopTransaction(unsigned int connector_id, const std::string& id_tag, ocpp::types::ocpp16::Reason reason) { bool ret = false; @@ -269,10 +271,10 @@ bool TransactionManager::stopTransaction(unsigned int connector_id, const std::s * std::string& error_code, * std::string& error_message) */ -bool TransactionManager::handleMessage(const ocpp::messages::RemoteStartTransactionReq& request, - ocpp::messages::RemoteStartTransactionConf& response, - std::string& error_code, - std::string& error_message) +bool TransactionManager::handleMessage(const ocpp::messages::ocpp16::RemoteStartTransactionReq& request, + ocpp::messages::ocpp16::RemoteStartTransactionConf& response, + std::string& error_code, + std::string& error_message) { (void)error_code; (void)error_message; @@ -338,10 +340,10 @@ bool TransactionManager::handleMessage(const ocpp::messages::RemoteStartTransact * std::string& error_code, * std::string& error_message) */ -bool TransactionManager::handleMessage(const ocpp::messages::RemoteStopTransactionReq& request, - ocpp::messages::RemoteStopTransactionConf& response, - std::string& error_code, - std::string& error_message) +bool TransactionManager::handleMessage(const ocpp::messages::ocpp16::RemoteStopTransactionReq& request, + ocpp::messages::ocpp16::RemoteStopTransactionConf& response, + std::string& error_code, + std::string& error_message) { (void)error_code; (void)error_message; diff --git a/src/chargepoint/transaction/TransactionManager.h b/src/ocpp16/chargepoint/transaction/TransactionManager.h similarity index 81% rename from src/chargepoint/transaction/TransactionManager.h rename to src/ocpp16/chargepoint/transaction/TransactionManager.h index b73f2344..34a8a5bf 100644 --- a/src/chargepoint/transaction/TransactionManager.h +++ b/src/ocpp16/chargepoint/transaction/TransactionManager.h @@ -52,9 +52,10 @@ class ISmartChargingManager; class IStatusManager; /** @brief Handle charge point transaction requests */ -class TransactionManager - : public ocpp::messages::GenericMessageHandler, - public ocpp::messages::GenericMessageHandler +class TransactionManager : public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler { public: /** @brief Constructor */ @@ -79,9 +80,9 @@ class TransactionManager * @param connector_id Id of the connector * @param id_tag Id of the user * @param transaction_id Id of the transaction - * @return ocpp::types::AuthorizationStatus (see AuthorizationStatus enum) + * @return Authorization status (see AuthorizationStatus enum) */ - ocpp::types::AuthorizationStatus startTransaction(unsigned int connector_id, const std::string& id_tag, int& transaction_id); + ocpp::types::ocpp16::AuthorizationStatus startTransaction(unsigned int connector_id, const std::string& id_tag, int& transaction_id); /** * @brief Stop a transaction @@ -90,7 +91,7 @@ class TransactionManager * @param reason Stop reason * @return true if a corresponding transaction exist and has been stopped, false otherwise */ - bool stopTransaction(unsigned int connector_id, const std::string& id_tag, ocpp::types::Reason reason); + bool stopTransaction(unsigned int connector_id, const std::string& id_tag, ocpp::types::ocpp16::Reason reason); // GenericMessageHandler interface @@ -99,20 +100,20 @@ class TransactionManager * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::RemoteStartTransactionReq& request, - ocpp::messages::RemoteStartTransactionConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::RemoteStartTransactionReq& request, + ocpp::messages::ocpp16::RemoteStartTransactionConf& response, + std::string& error_code, + std::string& error_message) override; /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, * ResponseType& response, * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::RemoteStopTransactionReq& request, - ocpp::messages::RemoteStopTransactionConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::RemoteStopTransactionReq& request, + ocpp::messages::ocpp16::RemoteStopTransactionConf& response, + std::string& error_code, + std::string& error_message) override; private: /** @brief Standard OCPP configuration */ diff --git a/src/chargepoint/trigger/ITriggerMessageManager.h b/src/ocpp16/chargepoint/trigger/ITriggerMessageManager.h similarity index 84% rename from src/chargepoint/trigger/ITriggerMessageManager.h rename to src/ocpp16/chargepoint/trigger/ITriggerMessageManager.h index ed0a9371..ac21df07 100644 --- a/src/chargepoint/trigger/ITriggerMessageManager.h +++ b/src/ocpp16/chargepoint/trigger/ITriggerMessageManager.h @@ -43,14 +43,14 @@ class ITriggerMessageManager * @param message Type of trigger message requested * @param handler Handler to register */ - virtual void registerHandler(ocpp::types::MessageTrigger message, ITriggerMessageHandler& handler) = 0; + virtual void registerHandler(ocpp::types::ocpp16::MessageTrigger message, ITriggerMessageHandler& handler) = 0; /** * @brief Register a handler for a specific extended trigger request * @param message Type of trigger message requested * @param handler Handler to register */ - virtual void registerHandler(ocpp::types::MessageTriggerEnumType message, IExtendedTriggerMessageHandler& handler) = 0; + virtual void registerHandler(ocpp::types::ocpp16::MessageTriggerEnumType message, IExtendedTriggerMessageHandler& handler) = 0; /** @brief Interface for standard trigger message handlers implementations */ class ITriggerMessageHandler @@ -65,7 +65,8 @@ class ITriggerMessageManager * @param connector_id Id of the connector concerned by the request * @return true if the requested message can be sent, false otherwise */ - virtual bool onTriggerMessage(ocpp::types::MessageTrigger message, const ocpp::types::Optional& connector_id) = 0; + virtual bool onTriggerMessage(ocpp::types::ocpp16::MessageTrigger message, + const ocpp::types::Optional& connector_id) = 0; }; /** @brief Interface for extended trigger message handlers implementations */ @@ -81,8 +82,8 @@ class ITriggerMessageManager * @param connector_id Id of the connector concerned by the request * @return true if the requested message can be sent, false otherwise */ - virtual bool onTriggerMessage(ocpp::types::MessageTriggerEnumType message, - const ocpp::types::Optional& connector_id) = 0; + virtual bool onTriggerMessage(ocpp::types::ocpp16::MessageTriggerEnumType message, + const ocpp::types::Optional& connector_id) = 0; }; }; diff --git a/src/chargepoint/trigger/TriggerMessageManager.cpp b/src/ocpp16/chargepoint/trigger/TriggerMessageManager.cpp similarity index 88% rename from src/chargepoint/trigger/TriggerMessageManager.cpp rename to src/ocpp16/chargepoint/trigger/TriggerMessageManager.cpp index 172b6e30..78f2dcb6 100644 --- a/src/chargepoint/trigger/TriggerMessageManager.cpp +++ b/src/ocpp16/chargepoint/trigger/TriggerMessageManager.cpp @@ -22,7 +22,9 @@ along with OpenOCPP. If not, see . #include "Logger.h" using namespace ocpp::messages; +using namespace ocpp::messages::ocpp16; using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { namespace chargepoint @@ -47,14 +49,14 @@ TriggerMessageManager::TriggerMessageManager(Connectors& /** @brief Destructor */ TriggerMessageManager::~TriggerMessageManager() { } -/** @copydoc void ITriggerMessageManager::registerHandler(ocpp::types::MessageTrigger, ITriggerMessageHandler&) */ -void TriggerMessageManager::registerHandler(ocpp::types::MessageTrigger message, ITriggerMessageHandler& handler) +/** @copydoc void ITriggerMessageManager::registerHandler(ocpp::types::ocpp16::MessageTrigger, ITriggerMessageHandler&) */ +void TriggerMessageManager::registerHandler(ocpp::types::ocpp16::MessageTrigger message, ITriggerMessageHandler& handler) { m_standard_handlers[message] = &handler; } -/** @copydoc void ITriggerMessageManager::registerHandler(ocpp::types::MessageTriggerEnumType, IExtendedTriggerMessageHandler&) */ -void TriggerMessageManager::registerHandler(ocpp::types::MessageTriggerEnumType message, IExtendedTriggerMessageHandler& handler) +/** @copydoc void ITriggerMessageManager::registerHandler(ocpp::types::ocpp16::MessageTriggerEnumType, IExtendedTriggerMessageHandler&) */ +void TriggerMessageManager::registerHandler(ocpp::types::ocpp16::MessageTriggerEnumType message, IExtendedTriggerMessageHandler& handler) { m_extended_handlers[message] = &handler; } @@ -64,10 +66,10 @@ void TriggerMessageManager::registerHandler(ocpp::types::MessageTriggerEnumType * std::string& error_code, * std::string& error_message) */ -bool TriggerMessageManager::handleMessage(const ocpp::messages::TriggerMessageReq& request, - ocpp::messages::TriggerMessageConf& response, - std::string& error_code, - std::string& error_message) +bool TriggerMessageManager::handleMessage(const ocpp::messages::ocpp16::TriggerMessageReq& request, + ocpp::messages::ocpp16::TriggerMessageConf& response, + std::string& error_code, + std::string& error_message) { bool ret = true; @@ -116,10 +118,10 @@ bool TriggerMessageManager::handleMessage(const ocpp::messages::TriggerMessageRe * std::string& error_code, * std::string& error_message) */ -bool TriggerMessageManager::handleMessage(const ocpp::messages::ExtendedTriggerMessageReq& request, - ocpp::messages::ExtendedTriggerMessageConf& response, - std::string& error_code, - std::string& error_message) +bool TriggerMessageManager::handleMessage(const ocpp::messages::ocpp16::ExtendedTriggerMessageReq& request, + ocpp::messages::ocpp16::ExtendedTriggerMessageConf& response, + std::string& error_code, + std::string& error_message) { bool ret = true; diff --git a/src/chargepoint/trigger/TriggerMessageManager.h b/src/ocpp16/chargepoint/trigger/TriggerMessageManager.h similarity index 74% rename from src/chargepoint/trigger/TriggerMessageManager.h rename to src/ocpp16/chargepoint/trigger/TriggerMessageManager.h index 05a75f5e..5c169f3b 100644 --- a/src/chargepoint/trigger/TriggerMessageManager.h +++ b/src/ocpp16/chargepoint/trigger/TriggerMessageManager.h @@ -43,8 +43,9 @@ class Connectors; /** @brief Manage TriggerMessage requests */ class TriggerMessageManager : public ITriggerMessageManager, - public ocpp::messages::GenericMessageHandler, - public ocpp::messages::GenericMessageHandler + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler { public: /** @brief Constructor */ @@ -57,11 +58,11 @@ class TriggerMessageManager // ITriggerMessageManager interface - /** @copydoc void ITriggerMessageManager::registerHandler(ocpp::types::MessageTrigger, ITriggerMessageHandler&) */ - void registerHandler(ocpp::types::MessageTrigger message, ITriggerMessageHandler& handler) override; + /** @copydoc void ITriggerMessageManager::registerHandler(ocpp::types::ocpp16::MessageTrigger, ITriggerMessageHandler&) */ + void registerHandler(ocpp::types::ocpp16::MessageTrigger message, ITriggerMessageHandler& handler) override; - /** @copydoc void ITriggerMessageManager::registerHandler(ocpp::types::MessageTriggerEnumType, IExtendedTriggerMessageHandler&) */ - void registerHandler(ocpp::types::MessageTriggerEnumType message, IExtendedTriggerMessageHandler& handler) override; + /** @copydoc void ITriggerMessageManager::registerHandler(ocpp::types::ocpp16::MessageTriggerEnumType, IExtendedTriggerMessageHandler&) */ + void registerHandler(ocpp::types::ocpp16::MessageTriggerEnumType message, IExtendedTriggerMessageHandler& handler) override; // GenericMessageHandler interface @@ -70,10 +71,10 @@ class TriggerMessageManager * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::TriggerMessageReq& request, - ocpp::messages::TriggerMessageConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::TriggerMessageReq& request, + ocpp::messages::ocpp16::TriggerMessageConf& response, + std::string& error_code, + std::string& error_message) override; // Security extensions @@ -82,20 +83,20 @@ class TriggerMessageManager * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::ExtendedTriggerMessageReq& request, - ocpp::messages::ExtendedTriggerMessageConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::ExtendedTriggerMessageReq& request, + ocpp::messages::ocpp16::ExtendedTriggerMessageConf& response, + std::string& error_code, + std::string& error_message) override; private: /** @brief Charge point's connectors */ Connectors& m_connectors; /** @brief Handlers for standard trigger messages */ - std::map m_standard_handlers; + std::map m_standard_handlers; /** @brief Handlers for extended trigger messages */ - std::map m_extended_handlers; + std::map m_extended_handlers; }; } // namespace chargepoint diff --git a/src/config/CMakeLists.txt b/src/ocpp16/config/CMakeLists.txt similarity index 100% rename from src/config/CMakeLists.txt rename to src/ocpp16/config/CMakeLists.txt diff --git a/src/config/IInternalConfigManager.h b/src/ocpp16/config/IInternalConfigManager.h similarity index 100% rename from src/config/IInternalConfigManager.h rename to src/ocpp16/config/IInternalConfigManager.h diff --git a/src/config/IOcppConfig.h b/src/ocpp16/config/IOcppConfig.h similarity index 98% rename from src/config/IOcppConfig.h rename to src/ocpp16/config/IOcppConfig.h index 2912ff62..c60b9ec5 100644 --- a/src/config/IOcppConfig.h +++ b/src/ocpp16/config/IOcppConfig.h @@ -51,7 +51,7 @@ class IOcppConfig * @param unknown_values List of unknown parameters in the [keys] list */ virtual void getConfiguration(const std::vector>& keys, - std::vector& values, + std::vector& values, std::vector>& unknown_values) = 0; /** @@ -60,7 +60,7 @@ class IOcppConfig * @param value New value * @return Status of the operation (see ConfigurationStatus) */ - virtual ocpp::types::ConfigurationStatus setConfiguration(const std::string& key, const std::string& value) = 0; + virtual ocpp::types::ocpp16::ConfigurationStatus setConfiguration(const std::string& key, const std::string& value) = 0; // // Specific getters diff --git a/src/config/InternalConfigManager.cpp b/src/ocpp16/config/InternalConfigManager.cpp similarity index 100% rename from src/config/InternalConfigManager.cpp rename to src/ocpp16/config/InternalConfigManager.cpp diff --git a/src/config/InternalConfigManager.h b/src/ocpp16/config/InternalConfigManager.h similarity index 100% rename from src/config/InternalConfigManager.h rename to src/ocpp16/config/InternalConfigManager.h diff --git a/src/localcontroller/CMakeLists.txt b/src/ocpp16/localcontroller/CMakeLists.txt similarity index 100% rename from src/localcontroller/CMakeLists.txt rename to src/ocpp16/localcontroller/CMakeLists.txt diff --git a/src/localcontroller/LocalController.cpp b/src/ocpp16/localcontroller/LocalController.cpp similarity index 99% rename from src/localcontroller/LocalController.cpp rename to src/ocpp16/localcontroller/LocalController.cpp index 4685ad3b..40dbefb2 100644 --- a/src/localcontroller/LocalController.cpp +++ b/src/ocpp16/localcontroller/LocalController.cpp @@ -33,6 +33,7 @@ along with OpenOCPP. If not, see . #include using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { diff --git a/src/localcontroller/LocalController.h b/src/ocpp16/localcontroller/LocalController.h similarity index 97% rename from src/localcontroller/LocalController.h rename to src/ocpp16/localcontroller/LocalController.h index 4dccbd72..a830b326 100644 --- a/src/localcontroller/LocalController.h +++ b/src/ocpp16/localcontroller/LocalController.h @@ -101,9 +101,9 @@ class LocalController : public ILocalController, public ocpp::rpc::RpcServer::IL std::unique_ptr m_internal_config; /** @brief Messages converter */ - ocpp::messages::MessagesConverter m_messages_converter; + ocpp::messages::ocpp16::MessagesConverter m_messages_converter; /** @brief Messages validator */ - ocpp::messages::MessagesValidator m_messages_validator; + ocpp::messages::ocpp16::MessagesValidator m_messages_validator; /** @brief Websocket server */ std::unique_ptr m_ws_server; diff --git a/src/localcontroller/centralsystem/CentralSystemHandler.cpp b/src/ocpp16/localcontroller/centralsystem/CentralSystemHandler.cpp similarity index 79% rename from src/localcontroller/centralsystem/CentralSystemHandler.cpp rename to src/ocpp16/localcontroller/centralsystem/CentralSystemHandler.cpp index 15f7cb71..7283c855 100644 --- a/src/localcontroller/centralsystem/CentralSystemHandler.cpp +++ b/src/ocpp16/localcontroller/centralsystem/CentralSystemHandler.cpp @@ -22,7 +22,9 @@ along with OpenOCPP. If not, see . #include "MessagesConverter.h" using namespace ocpp::messages; +using namespace ocpp::messages::ocpp16; using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { @@ -31,9 +33,9 @@ namespace localcontroller { /** @brief Constructor */ -CentralSystemHandler::CentralSystemHandler(const std::string& identifier, - const ocpp::messages::MessagesConverter& messages_converter, - ocpp::messages::MessageDispatcher& msg_dispatcher) +CentralSystemHandler::CentralSystemHandler(const std::string& identifier, + const ocpp::messages::ocpp16::MessagesConverter& messages_converter, + ocpp::messages::MessageDispatcher& msg_dispatcher) : GenericMessageHandler(CANCEL_RESERVATION_ACTION, messages_converter), GenericMessageHandler(CHANGE_AVAILABILITY_ACTION, messages_converter), GenericMessageHandler(CHANGE_CONFIGURATION_ACTION, messages_converter), @@ -127,10 +129,10 @@ CentralSystemHandler::~CentralSystemHandler() { } * std::string& error_code, * std::string& error_message) */ -bool CentralSystemHandler::handleMessage(const ocpp::messages::CancelReservationReq& request, - ocpp::messages::CancelReservationConf& response, - std::string& error_code, - std::string& error_message) +bool CentralSystemHandler::handleMessage(const ocpp::messages::ocpp16::CancelReservationReq& request, + ocpp::messages::ocpp16::CancelReservationConf& response, + std::string& error_code, + std::string& error_message) { return forward(CANCEL_RESERVATION_ACTION, request, response, error_code, error_message); } @@ -140,10 +142,10 @@ bool CentralSystemHandler::handleMessage(const ocpp::messages::CancelReservation * std::string& error_code, * std::string& error_message) */ -bool CentralSystemHandler::handleMessage(const ocpp::messages::ChangeAvailabilityReq& request, - ocpp::messages::ChangeAvailabilityConf& response, - std::string& error_code, - std::string& error_message) +bool CentralSystemHandler::handleMessage(const ocpp::messages::ocpp16::ChangeAvailabilityReq& request, + ocpp::messages::ocpp16::ChangeAvailabilityConf& response, + std::string& error_code, + std::string& error_message) { return forward(CHANGE_AVAILABILITY_ACTION, request, response, error_code, error_message); } @@ -153,10 +155,10 @@ bool CentralSystemHandler::handleMessage(const ocpp::messages::ChangeAvailabilit * std::string& error_code, * std::string& error_message) */ -bool CentralSystemHandler::handleMessage(const ocpp::messages::ChangeConfigurationReq& request, - ocpp::messages::ChangeConfigurationConf& response, - std::string& error_code, - std::string& error_message) +bool CentralSystemHandler::handleMessage(const ocpp::messages::ocpp16::ChangeConfigurationReq& request, + ocpp::messages::ocpp16::ChangeConfigurationConf& response, + std::string& error_code, + std::string& error_message) { return forward(CHANGE_CONFIGURATION_ACTION, request, response, error_code, error_message); } @@ -166,10 +168,10 @@ bool CentralSystemHandler::handleMessage(const ocpp::messages::ChangeConfigurati * std::string& error_code, * std::string& error_message) */ -bool CentralSystemHandler::handleMessage(const ocpp::messages::ClearCacheReq& request, - ocpp::messages::ClearCacheConf& response, - std::string& error_code, - std::string& error_message) +bool CentralSystemHandler::handleMessage(const ocpp::messages::ocpp16::ClearCacheReq& request, + ocpp::messages::ocpp16::ClearCacheConf& response, + std::string& error_code, + std::string& error_message) { return forward(CLEAR_CACHE_ACTION, request, response, error_code, error_message); } @@ -179,10 +181,10 @@ bool CentralSystemHandler::handleMessage(const ocpp::messages::ClearCacheReq& re * std::string& error_code, * std::string& error_message) */ -bool CentralSystemHandler::handleMessage(const ocpp::messages::ClearChargingProfileReq& request, - ocpp::messages::ClearChargingProfileConf& response, - std::string& error_code, - std::string& error_message) +bool CentralSystemHandler::handleMessage(const ocpp::messages::ocpp16::ClearChargingProfileReq& request, + ocpp::messages::ocpp16::ClearChargingProfileConf& response, + std::string& error_code, + std::string& error_message) { return forward(CLEAR_CHARGING_PROFILE_ACTION, request, response, error_code, error_message); } @@ -192,10 +194,10 @@ bool CentralSystemHandler::handleMessage(const ocpp::messages::ClearChargingProf * std::string& error_code, * std::string& error_message) */ -bool CentralSystemHandler::handleMessage(const ocpp::messages::DataTransferReq& request, - ocpp::messages::DataTransferConf& response, - std::string& error_code, - std::string& error_message) +bool CentralSystemHandler::handleMessage(const ocpp::messages::ocpp16::DataTransferReq& request, + ocpp::messages::ocpp16::DataTransferConf& response, + std::string& error_code, + std::string& error_message) { return forward(DATA_TRANSFER_ACTION, request, response, error_code, error_message); } @@ -205,10 +207,10 @@ bool CentralSystemHandler::handleMessage(const ocpp::messages::DataTransferReq& * std::string& error_code, * std::string& error_message) */ -bool CentralSystemHandler::handleMessage(const ocpp::messages::GetCompositeScheduleReq& request, - ocpp::messages::GetCompositeScheduleConf& response, - std::string& error_code, - std::string& error_message) +bool CentralSystemHandler::handleMessage(const ocpp::messages::ocpp16::GetCompositeScheduleReq& request, + ocpp::messages::ocpp16::GetCompositeScheduleConf& response, + std::string& error_code, + std::string& error_message) { return forward(GET_COMPOSITE_SCHEDULE_ACTION, request, response, error_code, error_message); } @@ -218,10 +220,10 @@ bool CentralSystemHandler::handleMessage(const ocpp::messages::GetCompositeSched * std::string& error_code, * std::string& error_message) */ -bool CentralSystemHandler::handleMessage(const ocpp::messages::GetConfigurationReq& request, - ocpp::messages::GetConfigurationConf& response, - std::string& error_code, - std::string& error_message) +bool CentralSystemHandler::handleMessage(const ocpp::messages::ocpp16::GetConfigurationReq& request, + ocpp::messages::ocpp16::GetConfigurationConf& response, + std::string& error_code, + std::string& error_message) { return forward(GET_CONFIGURATION_ACTION, request, response, error_code, error_message); } @@ -231,10 +233,10 @@ bool CentralSystemHandler::handleMessage(const ocpp::messages::GetConfigurationR * std::string& error_code, * std::string& error_message) */ -bool CentralSystemHandler::handleMessage(const ocpp::messages::GetDiagnosticsReq& request, - ocpp::messages::GetDiagnosticsConf& response, - std::string& error_code, - std::string& error_message) +bool CentralSystemHandler::handleMessage(const ocpp::messages::ocpp16::GetDiagnosticsReq& request, + ocpp::messages::ocpp16::GetDiagnosticsConf& response, + std::string& error_code, + std::string& error_message) { return forward(GET_DIAGNOSTICS_ACTION, request, response, error_code, error_message); } @@ -244,10 +246,10 @@ bool CentralSystemHandler::handleMessage(const ocpp::messages::GetDiagnosticsReq * std::string& error_code, * std::string& error_message) */ -bool CentralSystemHandler::handleMessage(const ocpp::messages::GetLocalListVersionReq& request, - ocpp::messages::GetLocalListVersionConf& response, - std::string& error_code, - std::string& error_message) +bool CentralSystemHandler::handleMessage(const ocpp::messages::ocpp16::GetLocalListVersionReq& request, + ocpp::messages::ocpp16::GetLocalListVersionConf& response, + std::string& error_code, + std::string& error_message) { return forward(GET_LOCAL_LIST_VERSION_ACTION, request, response, error_code, error_message); } @@ -257,10 +259,10 @@ bool CentralSystemHandler::handleMessage(const ocpp::messages::GetLocalListVersi * std::string& error_code, * std::string& error_message) */ -bool CentralSystemHandler::handleMessage(const ocpp::messages::RemoteStartTransactionReq& request, - ocpp::messages::RemoteStartTransactionConf& response, - std::string& error_code, - std::string& error_message) +bool CentralSystemHandler::handleMessage(const ocpp::messages::ocpp16::RemoteStartTransactionReq& request, + ocpp::messages::ocpp16::RemoteStartTransactionConf& response, + std::string& error_code, + std::string& error_message) { return forward(REMOTE_START_TRANSACTION_ACTION, request, response, error_code, error_message); } @@ -270,10 +272,10 @@ bool CentralSystemHandler::handleMessage(const ocpp::messages::RemoteStartTransa * std::string& error_code, * std::string& error_message) */ -bool CentralSystemHandler::handleMessage(const ocpp::messages::RemoteStopTransactionReq& request, - ocpp::messages::RemoteStopTransactionConf& response, - std::string& error_code, - std::string& error_message) +bool CentralSystemHandler::handleMessage(const ocpp::messages::ocpp16::RemoteStopTransactionReq& request, + ocpp::messages::ocpp16::RemoteStopTransactionConf& response, + std::string& error_code, + std::string& error_message) { return forward(REMOTE_STOP_TRANSACTION_ACTION, request, response, error_code, error_message); } @@ -283,10 +285,10 @@ bool CentralSystemHandler::handleMessage(const ocpp::messages::RemoteStopTransac * std::string& error_code, * std::string& error_message) */ -bool CentralSystemHandler::handleMessage(const ocpp::messages::ReserveNowReq& request, - ocpp::messages::ReserveNowConf& response, - std::string& error_code, - std::string& error_message) +bool CentralSystemHandler::handleMessage(const ocpp::messages::ocpp16::ReserveNowReq& request, + ocpp::messages::ocpp16::ReserveNowConf& response, + std::string& error_code, + std::string& error_message) { return forward(RESERVE_NOW_ACTION, request, response, error_code, error_message); } @@ -296,10 +298,10 @@ bool CentralSystemHandler::handleMessage(const ocpp::messages::ReserveNowReq& re * std::string& error_code, * std::string& error_message) */ -bool CentralSystemHandler::handleMessage(const ocpp::messages::ResetReq& request, - ocpp::messages::ResetConf& response, - std::string& error_code, - std::string& error_message) +bool CentralSystemHandler::handleMessage(const ocpp::messages::ocpp16::ResetReq& request, + ocpp::messages::ocpp16::ResetConf& response, + std::string& error_code, + std::string& error_message) { return forward(RESET_ACTION, request, response, error_code, error_message); } @@ -309,10 +311,10 @@ bool CentralSystemHandler::handleMessage(const ocpp::messages::ResetReq& request * std::string& error_code, * std::string& error_message) */ -bool CentralSystemHandler::handleMessage(const ocpp::messages::SendLocalListReq& request, - ocpp::messages::SendLocalListConf& response, - std::string& error_code, - std::string& error_message) +bool CentralSystemHandler::handleMessage(const ocpp::messages::ocpp16::SendLocalListReq& request, + ocpp::messages::ocpp16::SendLocalListConf& response, + std::string& error_code, + std::string& error_message) { return forward(SEND_LOCAL_LIST_ACTION, request, response, error_code, error_message); } @@ -322,10 +324,10 @@ bool CentralSystemHandler::handleMessage(const ocpp::messages::SendLocalListReq& * std::string& error_code, * std::string& error_message) */ -bool CentralSystemHandler::handleMessage(const ocpp::messages::SetChargingProfileReq& request, - ocpp::messages::SetChargingProfileConf& response, - std::string& error_code, - std::string& error_message) +bool CentralSystemHandler::handleMessage(const ocpp::messages::ocpp16::SetChargingProfileReq& request, + ocpp::messages::ocpp16::SetChargingProfileConf& response, + std::string& error_code, + std::string& error_message) { return forward(SET_CHARGING_PROFILE_ACTION, request, response, error_code, error_message); } @@ -335,10 +337,10 @@ bool CentralSystemHandler::handleMessage(const ocpp::messages::SetChargingProfil * std::string& error_code, * std::string& error_message) */ -bool CentralSystemHandler::handleMessage(const ocpp::messages::TriggerMessageReq& request, - ocpp::messages::TriggerMessageConf& response, - std::string& error_code, - std::string& error_message) +bool CentralSystemHandler::handleMessage(const ocpp::messages::ocpp16::TriggerMessageReq& request, + ocpp::messages::ocpp16::TriggerMessageConf& response, + std::string& error_code, + std::string& error_message) { return forward(TRIGGER_MESSAGE_ACTION, request, response, error_code, error_message); } @@ -348,10 +350,10 @@ bool CentralSystemHandler::handleMessage(const ocpp::messages::TriggerMessageReq * std::string& error_code, * std::string& error_message) */ -bool CentralSystemHandler::handleMessage(const ocpp::messages::UnlockConnectorReq& request, - ocpp::messages::UnlockConnectorConf& response, - std::string& error_code, - std::string& error_message) +bool CentralSystemHandler::handleMessage(const ocpp::messages::ocpp16::UnlockConnectorReq& request, + ocpp::messages::ocpp16::UnlockConnectorConf& response, + std::string& error_code, + std::string& error_message) { return forward(UNLOCK_CONNECTOR_ACTION, request, response, error_code, error_message); } @@ -361,10 +363,10 @@ bool CentralSystemHandler::handleMessage(const ocpp::messages::UnlockConnectorRe * std::string& error_code, * std::string& error_message) */ -bool CentralSystemHandler::handleMessage(const ocpp::messages::UpdateFirmwareReq& request, - ocpp::messages::UpdateFirmwareConf& response, - std::string& error_code, - std::string& error_message) +bool CentralSystemHandler::handleMessage(const ocpp::messages::ocpp16::UpdateFirmwareReq& request, + ocpp::messages::ocpp16::UpdateFirmwareConf& response, + std::string& error_code, + std::string& error_message) { return forward(UPDATE_FIRMWARE_ACTION, request, response, error_code, error_message); } @@ -376,10 +378,10 @@ bool CentralSystemHandler::handleMessage(const ocpp::messages::UpdateFirmwareReq * std::string& error_code, * std::string& error_message) */ -bool CentralSystemHandler::handleMessage(const ocpp::messages::CertificateSignedReq& request, - ocpp::messages::CertificateSignedConf& response, - std::string& error_code, - std::string& error_message) +bool CentralSystemHandler::handleMessage(const ocpp::messages::ocpp16::CertificateSignedReq& request, + ocpp::messages::ocpp16::CertificateSignedConf& response, + std::string& error_code, + std::string& error_message) { return forward(CERTIFICATE_SIGNED_ACTION, request, response, error_code, error_message); } @@ -389,10 +391,10 @@ bool CentralSystemHandler::handleMessage(const ocpp::messages::CertificateSigned * std::string& error_code, * std::string& error_message) */ -bool CentralSystemHandler::handleMessage(const ocpp::messages::DeleteCertificateReq& request, - ocpp::messages::DeleteCertificateConf& response, - std::string& error_code, - std::string& error_message) +bool CentralSystemHandler::handleMessage(const ocpp::messages::ocpp16::DeleteCertificateReq& request, + ocpp::messages::ocpp16::DeleteCertificateConf& response, + std::string& error_code, + std::string& error_message) { return forward(DELETE_CERTIFICATE_ACTION, request, response, error_code, error_message); } @@ -402,10 +404,10 @@ bool CentralSystemHandler::handleMessage(const ocpp::messages::DeleteCertificate * std::string& error_code, * std::string& error_message) */ -bool CentralSystemHandler::handleMessage(const ocpp::messages::ExtendedTriggerMessageReq& request, - ocpp::messages::ExtendedTriggerMessageConf& response, - std::string& error_code, - std::string& error_message) +bool CentralSystemHandler::handleMessage(const ocpp::messages::ocpp16::ExtendedTriggerMessageReq& request, + ocpp::messages::ocpp16::ExtendedTriggerMessageConf& response, + std::string& error_code, + std::string& error_message) { return forward(EXTENDED_TRIGGER_MESSAGE_ACTION, request, response, error_code, error_message); } @@ -415,10 +417,10 @@ bool CentralSystemHandler::handleMessage(const ocpp::messages::ExtendedTriggerMe * std::string& error_code, * std::string& error_message) */ -bool CentralSystemHandler::handleMessage(const ocpp::messages::GetInstalledCertificateIdsReq& request, - ocpp::messages::GetInstalledCertificateIdsConf& response, - std::string& error_code, - std::string& error_message) +bool CentralSystemHandler::handleMessage(const ocpp::messages::ocpp16::GetInstalledCertificateIdsReq& request, + ocpp::messages::ocpp16::GetInstalledCertificateIdsConf& response, + std::string& error_code, + std::string& error_message) { return forward(GET_INSTALLED_CERTIFICATE_IDS_ACTION, request, response, error_code, error_message); } @@ -428,10 +430,10 @@ bool CentralSystemHandler::handleMessage(const ocpp::messages::GetInstalledCerti * std::string& error_code, * std::string& error_message) */ -bool CentralSystemHandler::handleMessage(const ocpp::messages::GetLogReq& request, - ocpp::messages::GetLogConf& response, - std::string& error_code, - std::string& error_message) +bool CentralSystemHandler::handleMessage(const ocpp::messages::ocpp16::GetLogReq& request, + ocpp::messages::ocpp16::GetLogConf& response, + std::string& error_code, + std::string& error_message) { return forward(GET_LOG_ACTION, request, response, error_code, error_message); } @@ -441,10 +443,10 @@ bool CentralSystemHandler::handleMessage(const ocpp::messages::GetLogReq& reques * std::string& error_code, * std::string& error_message) */ -bool CentralSystemHandler::handleMessage(const ocpp::messages::InstallCertificateReq& request, - ocpp::messages::InstallCertificateConf& response, - std::string& error_code, - std::string& error_message) +bool CentralSystemHandler::handleMessage(const ocpp::messages::ocpp16::InstallCertificateReq& request, + ocpp::messages::ocpp16::InstallCertificateConf& response, + std::string& error_code, + std::string& error_message) { return forward(INSTALL_CERTIFICATE_ACTION, request, response, error_code, error_message); } @@ -454,10 +456,10 @@ bool CentralSystemHandler::handleMessage(const ocpp::messages::InstallCertificat * std::string& error_code, * std::string& error_message) */ -bool CentralSystemHandler::handleMessage(const ocpp::messages::SignedUpdateFirmwareReq& request, - ocpp::messages::SignedUpdateFirmwareConf& response, - std::string& error_code, - std::string& error_message) +bool CentralSystemHandler::handleMessage(const ocpp::messages::ocpp16::SignedUpdateFirmwareReq& request, + ocpp::messages::ocpp16::SignedUpdateFirmwareConf& response, + std::string& error_code, + std::string& error_message) { return forward(SIGNED_UPDATE_FIRMWARE_ACTION, request, response, error_code, error_message); } diff --git a/src/localcontroller/centralsystem/CentralSystemHandler.h b/src/ocpp16/localcontroller/centralsystem/CentralSystemHandler.h similarity index 71% rename from src/localcontroller/centralsystem/CentralSystemHandler.h rename to src/ocpp16/localcontroller/centralsystem/CentralSystemHandler.h index 587ace43..ebf2a6d3 100644 --- a/src/localcontroller/centralsystem/CentralSystemHandler.h +++ b/src/ocpp16/localcontroller/centralsystem/CentralSystemHandler.h @@ -59,7 +59,10 @@ class ILocalControllerConfig; namespace messages { class MessageDispatcher; +namespace ocpp16 +{ class MessagesConverter; +} // namespace ocpp16 } // namespace messages namespace localcontroller @@ -67,34 +70,49 @@ namespace localcontroller /** @brief Handler for central system requests */ class CentralSystemHandler - : public ocpp::messages::GenericMessageHandler, - public ocpp::messages::GenericMessageHandler, - public ocpp::messages::GenericMessageHandler, - public ocpp::messages::GenericMessageHandler, - public ocpp::messages::GenericMessageHandler, - public ocpp::messages::GenericMessageHandler, - public ocpp::messages::GenericMessageHandler, - public ocpp::messages::GenericMessageHandler, - public ocpp::messages::GenericMessageHandler, - public ocpp::messages::GenericMessageHandler, - public ocpp::messages::GenericMessageHandler, - public ocpp::messages::GenericMessageHandler, - public ocpp::messages::GenericMessageHandler, - public ocpp::messages::GenericMessageHandler, - public ocpp::messages::GenericMessageHandler, - public ocpp::messages::GenericMessageHandler, - public ocpp::messages::GenericMessageHandler, - public ocpp::messages::GenericMessageHandler, - public ocpp::messages::GenericMessageHandler, + : public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, // Security extensions - public ocpp::messages::GenericMessageHandler, - public ocpp::messages::GenericMessageHandler, - public ocpp::messages::GenericMessageHandler, - public ocpp::messages::GenericMessageHandler, - public ocpp::messages::GenericMessageHandler, - public ocpp::messages::GenericMessageHandler, - public ocpp::messages::GenericMessageHandler + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler { public: /** @@ -104,9 +122,9 @@ class CentralSystemHandler * @param msg_dispatcher Message dispatcher * @param stack_config Stack configuration */ - CentralSystemHandler(const std::string& identifier, - const ocpp::messages::MessagesConverter& messages_converter, - ocpp::messages::MessageDispatcher& msg_dispatcher); + CentralSystemHandler(const std::string& identifier, + const ocpp::messages::ocpp16::MessagesConverter& messages_converter, + ocpp::messages::MessageDispatcher& msg_dispatcher); /** @brief Destructor */ virtual ~CentralSystemHandler(); @@ -124,190 +142,190 @@ class CentralSystemHandler * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::CancelReservationReq& request, - ocpp::messages::CancelReservationConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::CancelReservationReq& request, + ocpp::messages::ocpp16::CancelReservationConf& response, + std::string& error_code, + std::string& error_message) override; /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, * ResponseType& response, * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::ChangeAvailabilityReq& request, - ocpp::messages::ChangeAvailabilityConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::ChangeAvailabilityReq& request, + ocpp::messages::ocpp16::ChangeAvailabilityConf& response, + std::string& error_code, + std::string& error_message) override; /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, * ResponseType& response, * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::ChangeConfigurationReq& request, - ocpp::messages::ChangeConfigurationConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::ChangeConfigurationReq& request, + ocpp::messages::ocpp16::ChangeConfigurationConf& response, + std::string& error_code, + std::string& error_message) override; /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, * ResponseType& response, * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::ClearCacheReq& request, - ocpp::messages::ClearCacheConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::ClearCacheReq& request, + ocpp::messages::ocpp16::ClearCacheConf& response, + std::string& error_code, + std::string& error_message) override; /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, * ResponseType& response, * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::ClearChargingProfileReq& request, - ocpp::messages::ClearChargingProfileConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::ClearChargingProfileReq& request, + ocpp::messages::ocpp16::ClearChargingProfileConf& response, + std::string& error_code, + std::string& error_message) override; /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, * ResponseType& response, * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::DataTransferReq& request, - ocpp::messages::DataTransferConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::DataTransferReq& request, + ocpp::messages::ocpp16::DataTransferConf& response, + std::string& error_code, + std::string& error_message) override; /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, * ResponseType& response, * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::GetCompositeScheduleReq& request, - ocpp::messages::GetCompositeScheduleConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::GetCompositeScheduleReq& request, + ocpp::messages::ocpp16::GetCompositeScheduleConf& response, + std::string& error_code, + std::string& error_message) override; /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, * ResponseType& response, * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::GetConfigurationReq& request, - ocpp::messages::GetConfigurationConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::GetConfigurationReq& request, + ocpp::messages::ocpp16::GetConfigurationConf& response, + std::string& error_code, + std::string& error_message) override; /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, * ResponseType& response, * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::GetDiagnosticsReq& request, - ocpp::messages::GetDiagnosticsConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::GetDiagnosticsReq& request, + ocpp::messages::ocpp16::GetDiagnosticsConf& response, + std::string& error_code, + std::string& error_message) override; /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, * ResponseType& response, * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::GetLocalListVersionReq& request, - ocpp::messages::GetLocalListVersionConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::GetLocalListVersionReq& request, + ocpp::messages::ocpp16::GetLocalListVersionConf& response, + std::string& error_code, + std::string& error_message) override; /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, * ResponseType& response, * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::RemoteStartTransactionReq& request, - ocpp::messages::RemoteStartTransactionConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::RemoteStartTransactionReq& request, + ocpp::messages::ocpp16::RemoteStartTransactionConf& response, + std::string& error_code, + std::string& error_message) override; /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, * ResponseType& response, * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::RemoteStopTransactionReq& request, - ocpp::messages::RemoteStopTransactionConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::RemoteStopTransactionReq& request, + ocpp::messages::ocpp16::RemoteStopTransactionConf& response, + std::string& error_code, + std::string& error_message) override; /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, * ResponseType& response, * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::ReserveNowReq& request, - ocpp::messages::ReserveNowConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::ReserveNowReq& request, + ocpp::messages::ocpp16::ReserveNowConf& response, + std::string& error_code, + std::string& error_message) override; /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, * ResponseType& response, * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::ResetReq& request, - ocpp::messages::ResetConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::ResetReq& request, + ocpp::messages::ocpp16::ResetConf& response, + std::string& error_code, + std::string& error_message) override; /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, * ResponseType& response, * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::SendLocalListReq& request, - ocpp::messages::SendLocalListConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::SendLocalListReq& request, + ocpp::messages::ocpp16::SendLocalListConf& response, + std::string& error_code, + std::string& error_message) override; /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, * ResponseType& response, * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::SetChargingProfileReq& request, - ocpp::messages::SetChargingProfileConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::SetChargingProfileReq& request, + ocpp::messages::ocpp16::SetChargingProfileConf& response, + std::string& error_code, + std::string& error_message) override; /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, * ResponseType& response, * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::TriggerMessageReq& request, - ocpp::messages::TriggerMessageConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::TriggerMessageReq& request, + ocpp::messages::ocpp16::TriggerMessageConf& response, + std::string& error_code, + std::string& error_message) override; /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, * ResponseType& response, * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::UnlockConnectorReq& request, - ocpp::messages::UnlockConnectorConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::UnlockConnectorReq& request, + ocpp::messages::ocpp16::UnlockConnectorConf& response, + std::string& error_code, + std::string& error_message) override; /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, * ResponseType& response, * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::UpdateFirmwareReq& request, - ocpp::messages::UpdateFirmwareConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::UpdateFirmwareReq& request, + ocpp::messages::ocpp16::UpdateFirmwareConf& response, + std::string& error_code, + std::string& error_message) override; // Security extensions @@ -316,70 +334,70 @@ class CentralSystemHandler * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::CertificateSignedReq& request, - ocpp::messages::CertificateSignedConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::CertificateSignedReq& request, + ocpp::messages::ocpp16::CertificateSignedConf& response, + std::string& error_code, + std::string& error_message) override; /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, * ResponseType& response, * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::DeleteCertificateReq& request, - ocpp::messages::DeleteCertificateConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::DeleteCertificateReq& request, + ocpp::messages::ocpp16::DeleteCertificateConf& response, + std::string& error_code, + std::string& error_message) override; /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, * ResponseType& response, * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::ExtendedTriggerMessageReq& request, - ocpp::messages::ExtendedTriggerMessageConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::ExtendedTriggerMessageReq& request, + ocpp::messages::ocpp16::ExtendedTriggerMessageConf& response, + std::string& error_code, + std::string& error_message) override; /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, * ResponseType& response, * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::GetInstalledCertificateIdsReq& request, - ocpp::messages::GetInstalledCertificateIdsConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::GetInstalledCertificateIdsReq& request, + ocpp::messages::ocpp16::GetInstalledCertificateIdsConf& response, + std::string& error_code, + std::string& error_message) override; /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, * ResponseType& response, * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::GetLogReq& request, - ocpp::messages::GetLogConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::GetLogReq& request, + ocpp::messages::ocpp16::GetLogConf& response, + std::string& error_code, + std::string& error_message) override; /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, * ResponseType& response, * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::InstallCertificateReq& request, - ocpp::messages::InstallCertificateConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::InstallCertificateReq& request, + ocpp::messages::ocpp16::InstallCertificateConf& response, + std::string& error_code, + std::string& error_message) override; /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, * ResponseType& response, * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::SignedUpdateFirmwareReq& request, - ocpp::messages::SignedUpdateFirmwareConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::SignedUpdateFirmwareReq& request, + ocpp::messages::ocpp16::SignedUpdateFirmwareConf& response, + std::string& error_code, + std::string& error_message) override; private: /** @brief Charge point's identifier */ diff --git a/src/localcontroller/centralsystem/CentralSystemProxy.cpp b/src/ocpp16/localcontroller/centralsystem/CentralSystemProxy.cpp similarity index 52% rename from src/localcontroller/centralsystem/CentralSystemProxy.cpp rename to src/ocpp16/localcontroller/centralsystem/CentralSystemProxy.cpp index d036bd7a..8d81b74a 100644 --- a/src/localcontroller/centralsystem/CentralSystemProxy.cpp +++ b/src/ocpp16/localcontroller/centralsystem/CentralSystemProxy.cpp @@ -23,8 +23,10 @@ along with OpenOCPP. If not, see . #include -using namespace ocpp::types; using namespace ocpp::messages; +using namespace ocpp::messages::ocpp16; +using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { @@ -32,11 +34,11 @@ namespace localcontroller { /** @brief Constructor */ -CentralSystemProxy::CentralSystemProxy(const std::string& identifier, - const ocpp::messages::MessagesValidator& messages_validator, - ocpp::messages::MessagesConverter& messages_converter, - const ocpp::config::ILocalControllerConfig& stack_config, - ocpp::rpc::RpcPool& rpc_pool) +CentralSystemProxy::CentralSystemProxy(const std::string& identifier, + const ocpp::messages::ocpp16::MessagesValidator& messages_validator, + ocpp::messages::ocpp16::MessagesConverter& messages_converter, + const ocpp::config::ILocalControllerConfig& stack_config, + ocpp::rpc::RpcPool& rpc_pool) : m_identifier(identifier), m_stack_config(stack_config), m_websocket(ocpp::websockets::WebsocketFactory::newClientFromPool()), @@ -107,410 +109,433 @@ bool CentralSystemProxy::isConnected() const return m_rpc.isConnected(); } -/** @copydoc bool ICentralSystemProxy::call(const ocpp::messages::BootNotificationReq&, - * ocpp::messages::BootNotificationConf&, +/** @copydoc bool ICentralSystemProxy::call(const ocpp::messages::ocpp16::BootNotificationReq&, + * ocpp::messages::ocpp16::BootNotificationConf&, * std::string&, * std::string&) */ -bool CentralSystemProxy::call(const ocpp::messages::BootNotificationReq& request, - ocpp::messages::BootNotificationConf& response, - std::string& error, - std::string& message) +bool CentralSystemProxy::call(const ocpp::messages::ocpp16::BootNotificationReq& request, + ocpp::messages::ocpp16::BootNotificationConf& response, + std::string& error, + std::string& message) { return call(BOOT_NOTIFICATION_ACTION, request, response, error, message); } -/** @copydoc bool ICentralSystemProxy::call(const ocpp::messages::StatusNotificationReq&, - * ocpp::messages::StatusNotificationConf&, +/** @copydoc bool ICentralSystemProxy::call(const ocpp::messages::ocpp16::StatusNotificationReq&, + * ocpp::messages::ocpp16::StatusNotificationConf&, * std::string&, * std::string&) */ -bool CentralSystemProxy::call(const ocpp::messages::StatusNotificationReq& request, - ocpp::messages::StatusNotificationConf& response, - std::string& error, - std::string& message) +bool CentralSystemProxy::call(const ocpp::messages::ocpp16::StatusNotificationReq& request, + ocpp::messages::ocpp16::StatusNotificationConf& response, + std::string& error, + std::string& message) { return call(STATUS_NOTIFICATION_ACTION, request, response, error, message); } -/** @copydoc bool ICentralSystemProxy::call(const ocpp::messages::AuthorizeReq&, - * ocpp::messages::AuthorizeConf&, +/** @copydoc bool ICentralSystemProxy::call(const ocpp::messages::ocpp16::AuthorizeReq&, + * ocpp::messages::ocpp16::AuthorizeConf&, * std::string&, * std::string&) */ -bool CentralSystemProxy::call(const ocpp::messages::AuthorizeReq& request, - ocpp::messages::AuthorizeConf& response, - std::string& error, - std::string& message) +bool CentralSystemProxy::call(const ocpp::messages::ocpp16::AuthorizeReq& request, + ocpp::messages::ocpp16::AuthorizeConf& response, + std::string& error, + std::string& message) { return call(AUTHORIZE_ACTION, request, response, error, message); } -/** @copydoc bool ICentralSystemProxy::call(const ocpp::messages::StartTransactionReq&, - * ocpp::messages::StartTransactionConf&, +/** @copydoc bool ICentralSystemProxy::call(const ocpp::messages::ocpp16::StartTransactionReq&, + * ocpp::messages::ocpp16::StartTransactionConf&, * std::string&, * std::string&) */ -bool CentralSystemProxy::call(const ocpp::messages::StartTransactionReq& request, - ocpp::messages::StartTransactionConf& response, - std::string& error, - std::string& message) +bool CentralSystemProxy::call(const ocpp::messages::ocpp16::StartTransactionReq& request, + ocpp::messages::ocpp16::StartTransactionConf& response, + std::string& error, + std::string& message) { return call(START_TRANSACTION_ACTION, request, response, error, message); } -/** @copydoc bool ICentralSystemProxy::call(const ocpp::messages::StopTransactionReq&, - * ocpp::messages::StopTransactionConf&, +/** @copydoc bool ICentralSystemProxy::call(const ocpp::messages::ocpp16::StopTransactionReq&, + * ocpp::messages::ocpp16::StopTransactionConf&, * std::string&, * std::string&) */ -bool CentralSystemProxy::call(const ocpp::messages::StopTransactionReq& request, - ocpp::messages::StopTransactionConf& response, - std::string& error, - std::string& message) +bool CentralSystemProxy::call(const ocpp::messages::ocpp16::StopTransactionReq& request, + ocpp::messages::ocpp16::StopTransactionConf& response, + std::string& error, + std::string& message) { return call(STOP_TRANSACTION_ACTION, request, response, error, message); } -/** @copydoc bool ICentralSystemProxy::call(const ocpp::messages::DataTransferReq&, - * ocpp::messages::DataTransferConf&, +/** @copydoc bool ICentralSystemProxy::call(const ocpp::messages::ocpp16::DataTransferReq&, + * ocpp::messages::ocpp16::DataTransferConf&, * std::string&, * std::string&) */ -bool CentralSystemProxy::call(const ocpp::messages::DataTransferReq& request, - ocpp::messages::DataTransferConf& response, - std::string& error, - std::string& message) +bool CentralSystemProxy::call(const ocpp::messages::ocpp16::DataTransferReq& request, + ocpp::messages::ocpp16::DataTransferConf& response, + std::string& error, + std::string& message) { return call(DATA_TRANSFER_ACTION, request, response, error, message); } -/** @copydoc bool ICentralSystemProxy::call(const ocpp::messages::MeterValuesReq&, - * ocpp::messages::MeterValuesConf&, +/** @copydoc bool ICentralSystemProxy::call(const ocpp::messages::ocpp16::MeterValuesReq&, + * ocpp::messages::ocpp16::MeterValuesConf&, * std::string&, * std::string&) */ -bool CentralSystemProxy::call(const ocpp::messages::MeterValuesReq& request, - ocpp::messages::MeterValuesConf& response, - std::string& error, - std::string& message) +bool CentralSystemProxy::call(const ocpp::messages::ocpp16::MeterValuesReq& request, + ocpp::messages::ocpp16::MeterValuesConf& response, + std::string& error, + std::string& message) { return call(METER_VALUES_ACTION, request, response, error, message); } -/** @copydoc bool ICentralSystemProxy::call(const ocpp::messages::DiagnosticsStatusNotificationReq&, - * ocpp::messages::DiagnosticsStatusNotificationConf&, +/** @copydoc bool ICentralSystemProxy::call(const ocpp::messages::ocpp16::DiagnosticsStatusNotificationReq&, + * ocpp::messages::ocpp16::DiagnosticsStatusNotificationConf&, * std::string&, * std::string&) */ -bool CentralSystemProxy::call(const ocpp::messages::DiagnosticsStatusNotificationReq& request, - ocpp::messages::DiagnosticsStatusNotificationConf& response, - std::string& error, - std::string& message) +bool CentralSystemProxy::call(const ocpp::messages::ocpp16::DiagnosticsStatusNotificationReq& request, + ocpp::messages::ocpp16::DiagnosticsStatusNotificationConf& response, + std::string& error, + std::string& message) { return call(DIAGNOSTIC_STATUS_NOTIFICATION_ACTION, request, response, error, message); } -/** @copydoc bool ICentralSystemProxy::call(const ocpp::messages::FirmwareStatusNotificationReq&, - * ocpp::messages::FirmwareStatusNotificationConf&, +/** @copydoc bool ICentralSystemProxy::call(const ocpp::messages::ocpp16::FirmwareStatusNotificationReq&, + * ocpp::messages::ocpp16::FirmwareStatusNotificationConf&, * std::string&, * std::string&) */ -bool CentralSystemProxy::call(const ocpp::messages::FirmwareStatusNotificationReq& request, - ocpp::messages::FirmwareStatusNotificationConf& response, - std::string& error, - std::string& message) +bool CentralSystemProxy::call(const ocpp::messages::ocpp16::FirmwareStatusNotificationReq& request, + ocpp::messages::ocpp16::FirmwareStatusNotificationConf& response, + std::string& error, + std::string& message) { return call(FIRMWARE_STATUS_NOTIFICATION_ACTION, request, response, error, message); } -/** @copydoc bool ICentralSystemProxy::call(const ocpp::messages::HeartbeatReq&, - * ocpp::messages::HeartbeatConf&, +/** @copydoc bool ICentralSystemProxy::call(const ocpp::messages::ocpp16::HeartbeatReq&, + * ocpp::messages::ocpp16::HeartbeatConf&, * std::string&, * std::string&) */ -bool CentralSystemProxy::call(const ocpp::messages::HeartbeatReq& request, - ocpp::messages::HeartbeatConf& response, - std::string& error, - std::string& message) +bool CentralSystemProxy::call(const ocpp::messages::ocpp16::HeartbeatReq& request, + ocpp::messages::ocpp16::HeartbeatConf& response, + std::string& error, + std::string& message) { return call(HEARTBEAT_ACTION, request, response, error, message); } // Security extensions -/** @copydoc bool ICentralSystemProxy::call(const ocpp::messages::SecurityEventNotificationReq&, - * ocpp::messages::SecurityEventNotificationConf&, +/** @copydoc bool ICentralSystemProxy::call(const ocpp::messages::ocpp16::SecurityEventNotificationReq&, + * ocpp::messages::ocpp16::SecurityEventNotificationConf&, * std::string&, * std::string&) */ -bool CentralSystemProxy::call(const ocpp::messages::SecurityEventNotificationReq& request, - ocpp::messages::SecurityEventNotificationConf& response, - std::string& error, - std::string& message) +bool CentralSystemProxy::call(const ocpp::messages::ocpp16::SecurityEventNotificationReq& request, + ocpp::messages::ocpp16::SecurityEventNotificationConf& response, + std::string& error, + std::string& message) { return call(SECURITY_EVENT_NOTIFICATION_ACTION, request, response, error, message); } -/** @copydoc bool ICentralSystemProxy::call(const ocpp::messages::SignCertificateReq&, - * ocpp::messages::SignCertificateConf&, +/** @copydoc bool ICentralSystemProxy::call(const ocpp::messages::ocpp16::SignCertificateReq&, + * ocpp::messages::ocpp16::SignCertificateConf&, * std::string&, * std::string&) */ -bool CentralSystemProxy::call(const ocpp::messages::SignCertificateReq& request, - ocpp::messages::SignCertificateConf& response, - std::string& error, - std::string& message) +bool CentralSystemProxy::call(const ocpp::messages::ocpp16::SignCertificateReq& request, + ocpp::messages::ocpp16::SignCertificateConf& response, + std::string& error, + std::string& message) { return call(SIGN_CERTIFICATE_ACTION, request, response, error, message); } -/** @copydoc bool ICentralSystemProxy::call(const ocpp::messages::LogStatusNotificationReq&, - * ocpp::messages::LogStatusNotificationConf&, +/** @copydoc bool ICentralSystemProxy::call(const ocpp::messages::ocpp16::LogStatusNotificationReq&, + * ocpp::messages::ocpp16::LogStatusNotificationConf&, * std::string&, * std::string&) */ -bool CentralSystemProxy::call(const ocpp::messages::LogStatusNotificationReq& request, - ocpp::messages::LogStatusNotificationConf& response, - std::string& error, - std::string& message) +bool CentralSystemProxy::call(const ocpp::messages::ocpp16::LogStatusNotificationReq& request, + ocpp::messages::ocpp16::LogStatusNotificationConf& response, + std::string& error, + std::string& message) { return call(LOG_STATUS_NOTIFICATION_ACTION, request, response, error, message); } -/** @copydoc bool ICentralSystemProxy::call(const ocpp::messages::SignedFirmwareStatusNotificationReq&, - * ocpp::messages::SignedFirmwareStatusNotificationConf&, +/** @copydoc bool ICentralSystemProxy::call(const ocpp::messages::ocpp16::SignedFirmwareStatusNotificationReq&, + * ocpp::messages::ocpp16::SignedFirmwareStatusNotificationConf&, * std::string&, * std::string&) */ -bool CentralSystemProxy::call(const ocpp::messages::SignedFirmwareStatusNotificationReq& request, - ocpp::messages::SignedFirmwareStatusNotificationConf& response, - std::string& error, - std::string& message) +bool CentralSystemProxy::call(const ocpp::messages::ocpp16::SignedFirmwareStatusNotificationReq& request, + ocpp::messages::ocpp16::SignedFirmwareStatusNotificationConf& response, + std::string& error, + std::string& message) { return call(SIGNED_FIRMWARE_STATUS_NOTIFICATION_ACTION, request, response, error, message); } /** @copydoc bool ICentralSystemProxy::registerHandler( - std::function) */ + std::function) */ bool CentralSystemProxy::registerHandler( - std::function + std::function handler) { return registerHandler(CANCEL_RESERVATION_ACTION, handler); } /** @copydoc bool ICentralSystemProxy::registerHandler( - std::function) */ + std::function) */ bool CentralSystemProxy::registerHandler( - std::function + std::function handler) { return registerHandler(CHANGE_AVAILABILITY_ACTION, handler); } /** @copydoc bool ICentralSystemProxy::registerHandler( - std::function) */ -bool CentralSystemProxy::registerHandler( - std::function - handler) + std::function) */ +bool CentralSystemProxy::registerHandler(std::function handler) { return registerHandler(CHANGE_CONFIGURATION_ACTION, handler); } /** @copydoc bool ICentralSystemProxy::registerHandler( - std::function) */ + std::function) */ bool CentralSystemProxy::registerHandler( - std::function handler) + std::function + handler) { return registerHandler(CLEAR_CACHE_ACTION, handler); } /** @copydoc bool ICentralSystemProxy::registerHandler( - std::function) */ -bool CentralSystemProxy::registerHandler( - std::function handler) + std::function) */ +bool CentralSystemProxy::registerHandler(std::function handler) { return registerHandler(CLEAR_CHARGING_PROFILE_ACTION, handler); } /** @copydoc bool ICentralSystemProxy::registerHandler( - std::function) */ + std::function) */ bool CentralSystemProxy::registerHandler( - std::function handler) + std::function handler) { return registerHandler(DATA_TRANSFER_ACTION, handler); } /** @copydoc bool ICentralSystemProxy::registerHandler( - std::function) */ -bool CentralSystemProxy::registerHandler( - std::function handler) + std::function) */ +bool CentralSystemProxy::registerHandler(std::function handler) { return registerHandler(GET_COMPOSITE_SCHEDULE_ACTION, handler); } /** @copydoc bool ICentralSystemProxy::registerHandler( - std::function) */ + std::function) */ bool CentralSystemProxy::registerHandler( - std::function + std::function< + bool(const ocpp::messages::ocpp16::GetConfigurationReq&, ocpp::messages::ocpp16::GetConfigurationConf&, std::string&, std::string&)> handler) { return registerHandler(GET_CONFIGURATION_ACTION, handler); } /** @copydoc bool ICentralSystemProxy::registerHandler( - std::function) */ + std::function) */ bool CentralSystemProxy::registerHandler( - std::function handler) + std::function handler) { return registerHandler(GET_DIAGNOSTICS_ACTION, handler); } /** @copydoc bool ICentralSystemProxy::registerHandler( - std::function) */ -bool CentralSystemProxy::registerHandler( - std::function - handler) + std::function) */ +bool CentralSystemProxy::registerHandler(std::function handler) { return registerHandler(GET_LOCAL_LIST_VERSION_ACTION, handler); } /** @copydoc bool ICentralSystemProxy::registerHandler( - std::function) */ -bool CentralSystemProxy::registerHandler( - std::function handler) + std::function) */ +bool CentralSystemProxy::registerHandler(std::function handler) { return registerHandler(REMOTE_START_TRANSACTION_ACTION, handler); } /** @copydoc bool ICentralSystemProxy::registerHandler( - std::function) */ -bool CentralSystemProxy::registerHandler( - std::function handler) + std::function) */ +bool CentralSystemProxy::registerHandler(std::function handler) { return registerHandler(REMOTE_STOP_TRANSACTION_ACTION, handler); } /** @copydoc bool ICentralSystemProxy::registerHandler( - std::function) */ + std::function) */ bool CentralSystemProxy::registerHandler( - std::function handler) + std::function + handler) { return registerHandler(RESERVE_NOW_ACTION, handler); } /** @copydoc bool ICentralSystemProxy::registerHandler( - std::function) */ + std::function) */ bool CentralSystemProxy::registerHandler( - std::function handler) + std::function handler) { return registerHandler(RESET_ACTION, handler); } /** @copydoc bool ICentralSystemProxy::registerHandler( - std::function) */ + std::function) */ bool CentralSystemProxy::registerHandler( - std::function handler) + std::function handler) { return registerHandler(SEND_LOCAL_LIST_ACTION, handler); } /** @copydoc bool ICentralSystemProxy::registerHandler( - std::function) */ + std::function) */ bool CentralSystemProxy::registerHandler( - std::function + std::function handler) { return registerHandler(SET_CHARGING_PROFILE_ACTION, handler); } /** @copydoc bool ICentralSystemProxy::registerHandler( - std::function) */ + std::function) */ bool CentralSystemProxy::registerHandler( - std::function handler) + std::function handler) { return registerHandler(TRIGGER_MESSAGE_ACTION, handler); } /** @copydoc bool ICentralSystemProxy::registerHandler( - std::function) */ + std::function) */ bool CentralSystemProxy::registerHandler( - std::function + std::function< + bool(const ocpp::messages::ocpp16::UnlockConnectorReq&, ocpp::messages::ocpp16::UnlockConnectorConf&, std::string&, std::string&)> handler) { return registerHandler(UNLOCK_CONNECTOR_ACTION, handler); } /** @copydoc bool ICentralSystemProxy::registerHandler( - std::function) */ + std::function) */ bool CentralSystemProxy::registerHandler( - std::function handler) + std::function handler) { return registerHandler(UPDATE_FIRMWARE_ACTION, handler); } /** @copydoc bool ICentralSystemProxy::registerHandler( - std::function) */ + std::function) */ bool CentralSystemProxy::registerHandler( - std::function + std::function handler) { return registerHandler(CERTIFICATE_SIGNED_ACTION, handler); } /** @copydoc bool ICentralSystemProxy::registerHandler( - std::function) */ + std::function) */ bool CentralSystemProxy::registerHandler( - std::function + std::function handler) { return registerHandler(DELETE_CERTIFICATE_ACTION, handler); } /** @copydoc bool ICentralSystemProxy::registerHandler( - std::function) */ -bool CentralSystemProxy::registerHandler( - std::function handler) + std::function) */ +bool CentralSystemProxy::registerHandler(std::function handler) { return registerHandler(EXTENDED_TRIGGER_MESSAGE_ACTION, handler); } /** @copydoc bool ICentralSystemProxy::registerHandler( - std::function) */ -bool CentralSystemProxy::registerHandler( - std::function - handler) + std::function) */ +bool CentralSystemProxy::registerHandler(std::function handler) { return registerHandler(GET_INSTALLED_CERTIFICATE_IDS_ACTION, handler); } /** @copydoc bool ICentralSystemProxy::registerHandler( - std::function) */ + std::function) */ bool CentralSystemProxy::registerHandler( - std::function handler) + std::function handler) { return registerHandler(GET_LOG_ACTION, handler); } /** @copydoc bool ICentralSystemProxy::registerHandler( - std::function) */ + std::function) */ bool CentralSystemProxy::registerHandler( - std::function + std::function handler) { return registerHandler(INSTALL_CERTIFICATE_ACTION, handler); } /** @copydoc bool ICentralSystemProxy::registerHandler( - std::function) */ -bool CentralSystemProxy::registerHandler( - std::function handler) + std::function) */ +bool CentralSystemProxy::registerHandler(std::function handler) { return registerHandler(SIGNED_UPDATE_FIRMWARE_ACTION, handler); diff --git a/src/ocpp16/localcontroller/centralsystem/CentralSystemProxy.h b/src/ocpp16/localcontroller/centralsystem/CentralSystemProxy.h new file mode 100644 index 00000000..ead1f6c6 --- /dev/null +++ b/src/ocpp16/localcontroller/centralsystem/CentralSystemProxy.h @@ -0,0 +1,519 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +#ifndef OPENOCPP_CENTRALSYSTEMPROXY_H +#define OPENOCPP_CENTRALSYSTEMPROXY_H + +#include "CentralSystemHandler.h" +#include "GenericMessageSender.h" +#include "ICentralSystemProxy.h" +#include "MessageDispatcher.h" +#include "MessagesConverter.h" +#include "MessagesValidator.h" +#include "RpcClient.h" +#include "UserMessageHandler.h" + +namespace ocpp +{ +namespace config +{ +class ILocalControllerConfig; +} // namespace config +namespace rpc +{ +class RpcPool; +} // namespace rpc + +namespace localcontroller +{ + +/** @brief Central system proxy */ +class CentralSystemProxy : public ICentralSystemProxy, + public ocpp::rpc::IRpc::IListener, + public ocpp::rpc::IRpc::ISpy, + public ocpp::rpc::RpcClient::IListener +{ + public: + /** + * @brief Constructor + * @param identifier Charge point's identifier + * @param messages_validator JSON schemas needed to validate payloads + * @param messages_converter Converter from/to OCPP to/from JSON messages + * @param stack_config Stack configuration + * @param rpc_pool RPC pool + */ + CentralSystemProxy(const std::string& identifier, + const ocpp::messages::ocpp16::MessagesValidator& messages_validator, + ocpp::messages::ocpp16::MessagesConverter& messages_converter, + const ocpp::config::ILocalControllerConfig& stack_config, + ocpp::rpc::RpcPool& rpc_pool); + + /** @brief Destructor */ + virtual ~CentralSystemProxy(); + + /** + * @brief Set the proxy to forward requests to the charge point + * @param central_system Proxy to forward requests to the charge point + */ + void setChargePointProxy(std::weak_ptr charge_point) + { + m_charge_point = charge_point; + m_handler.setChargePointProxy(charge_point); + } + + /** @copydoc const std::string& ICentralSystemProxy::disconnect() const */ + const std::string& identifier() const override { return m_identifier; } + + /** @copydoc void ICentralSystemProxy::setTimeout(std::chrono::milliseconds) */ + void setTimeout(std::chrono::milliseconds timeout) override; + + /** @copydoc bool ICentralSystemProxy::connect(const std::string&, + const ocpp::websockets::IWebsocketClient::Credentials&, + std::chrono::milliseconds, + std::chrono::milliseconds, + std::chrono::milliseconds) */ + bool connect(const std::string& url, + const ocpp::websockets::IWebsocketClient::Credentials& credentials, + std::chrono::milliseconds connect_timeout, + std::chrono::milliseconds retry_interval, + std::chrono::milliseconds ping_interval) override; + + /** @copydoc void ICentralSystemProxy::disconnect() */ + void disconnect() override; + + /** @brief Indicate if the connection with the central system is active */ + bool isConnected() const override; + + /** @copydoc void ICentralSystemProxy::registerListener(ILocalControllerProxyEventsHandler&) */ + void registerListener(ILocalControllerProxyEventsHandler& listener) override { m_listener = &listener; } + + /** @copydoc bool ICentralSystemProxy::call(const ocpp::messages::ocpp16::BootNotificationReq&, + * ocpp::messages::ocpp16::BootNotificationConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp16::BootNotificationReq& request, + ocpp::messages::ocpp16::BootNotificationConf& response, + std::string& error, + std::string& message) override; + + /** @copydoc bool ICentralSystemProxy::call(const ocpp::messages::ocpp16::StatusNotificationReq&, + * ocpp::messages::ocpp16::StatusNotificationConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp16::StatusNotificationReq& request, + ocpp::messages::ocpp16::StatusNotificationConf& response, + std::string& error, + std::string& message) override; + + /** @copydoc bool ICentralSystemProxy::call(const ocpp::messages::ocpp16::AuthorizeReq&, + * ocpp::messages::ocpp16::AuthorizeConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp16::AuthorizeReq& request, + ocpp::messages::ocpp16::AuthorizeConf& response, + std::string& error, + std::string& message) override; + + /** @copydoc bool ICentralSystemProxy::call(const ocpp::messages::ocpp16::StartTransactionReq&, + * ocpp::messages::ocpp16::StartTransactionConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp16::StartTransactionReq& request, + ocpp::messages::ocpp16::StartTransactionConf& response, + std::string& error, + std::string& message) override; + + /** @copydoc bool ICentralSystemProxy::call(const ocpp::messages::ocpp16::StopTransactionReq&, + * ocpp::messages::ocpp16::StopTransactionConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp16::StopTransactionReq& request, + ocpp::messages::ocpp16::StopTransactionConf& response, + std::string& error, + std::string& message) override; + + /** @copydoc bool ICentralSystemProxy::call(const ocpp::messages::ocpp16::DataTransferReq&, + * ocpp::messages::ocpp16::DataTransferConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp16::DataTransferReq& request, + ocpp::messages::ocpp16::DataTransferConf& response, + std::string& error, + std::string& message) override; + + /** @copydoc bool ICentralSystemProxy::call(const ocpp::messages::ocpp16::MeterValuesReq&, + * ocpp::messages::ocpp16::MeterValuesConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp16::MeterValuesReq& request, + ocpp::messages::ocpp16::MeterValuesConf& response, + std::string& error, + std::string& message) override; + + /** @copydoc bool ICentralSystemProxy::call(const ocpp::messages::ocpp16::DiagnosticsStatusNotificationReq&, + * ocpp::messages::ocpp16::DiagnosticsStatusNotificationConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp16::DiagnosticsStatusNotificationReq& request, + ocpp::messages::ocpp16::DiagnosticsStatusNotificationConf& response, + std::string& error, + std::string& message) override; + + /** @copydoc bool ICentralSystemProxy::call(const ocpp::messages::ocpp16::FirmwareStatusNotificationReq&, + * ocpp::messages::ocpp16::FirmwareStatusNotificationConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp16::FirmwareStatusNotificationReq& request, + ocpp::messages::ocpp16::FirmwareStatusNotificationConf& response, + std::string& error, + std::string& message) override; + + /** @copydoc bool ICentralSystemProxy::call(const ocpp::messages::ocpp16::HeartbeatReq&, + * ocpp::messages::ocpp16::HeartbeatConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp16::HeartbeatReq& request, + ocpp::messages::ocpp16::HeartbeatConf& response, + std::string& error, + std::string& message) override; + + // Security extensions + + /** @copydoc bool ICentralSystemProxy::call(const ocpp::messages::ocpp16::SecurityEventNotificationReq&, + * ocpp::messages::ocpp16::SecurityEventNotificationConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp16::SecurityEventNotificationReq& request, + ocpp::messages::ocpp16::SecurityEventNotificationConf& response, + std::string& error, + std::string& message) override; + + /** @copydoc bool ICentralSystemProxy::call(const ocpp::messages::ocpp16::SignCertificateReq&, + * ocpp::messages::ocpp16::SignCertificateConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp16::SignCertificateReq& request, + ocpp::messages::ocpp16::SignCertificateConf& response, + std::string& error, + std::string& message) override; + + /** @copydoc bool ICentralSystemProxy::call(const ocpp::messages::ocpp16::LogStatusNotificationReq&, + * ocpp::messages::ocpp16::LogStatusNotificationConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp16::LogStatusNotificationReq& request, + ocpp::messages::ocpp16::LogStatusNotificationConf& response, + std::string& error, + std::string& message) override; + + /** @copydoc bool ICentralSystemProxy::call(const ocpp::messages::ocpp16::SignedFirmwareStatusNotificationReq&, + * ocpp::messages::ocpp16::SignedFirmwareStatusNotificationConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp16::SignedFirmwareStatusNotificationReq& request, + ocpp::messages::ocpp16::SignedFirmwareStatusNotificationConf& response, + std::string& error, + std::string& message) override; + + /** @copydoc bool ICentralSystemProxy::registerHandler( + std::function) */ + bool registerHandler(std::function handler) override; + + /** @copydoc bool ICentralSystemProxy::registerHandler( + std::function) */ + bool registerHandler(std::function handler) override; + + /** @copydoc bool ICentralSystemProxy::registerHandler( + std::function) */ + bool registerHandler(std::function handler) override; + + /** @copydoc bool ICentralSystemProxy::registerHandler( + std::function) */ + bool registerHandler( + std::function handler) + override; + + /** @copydoc bool ICentralSystemProxy::registerHandler( + std::function) */ + bool registerHandler(std::function handler) override; + + /** @copydoc bool ICentralSystemProxy::registerHandler( + std::function) */ + bool registerHandler( + std::function handler) + override; + + /** @copydoc bool ICentralSystemProxy::registerHandler( + std::function) */ + bool registerHandler(std::function handler) override; + + /** @copydoc bool ICentralSystemProxy::registerHandler( + std::function) */ + bool registerHandler( + std::function + handler) override; + + /** @copydoc bool ICentralSystemProxy::registerHandler( + std::function) */ + bool registerHandler( + std::function< + bool(const ocpp::messages::ocpp16::GetDiagnosticsReq&, ocpp::messages::ocpp16::GetDiagnosticsConf&, std::string&, std::string&)> + handler) override; + + /** @copydoc bool ICentralSystemProxy::registerHandler( + std::function) */ + bool registerHandler(std::function handler) override; + + /** @copydoc bool ICentralSystemProxy::registerHandler( + std::function) */ + bool registerHandler(std::function handler) override; + + /** @copydoc bool ICentralSystemProxy::registerHandler( + std::function) */ + bool registerHandler(std::function handler) override; + + /** @copydoc bool ICentralSystemProxy::registerHandler( + std::function) */ + bool registerHandler( + std::function handler) + override; + + /** @copydoc bool ICentralSystemProxy::registerHandler( + std::function) */ + bool registerHandler( + std::function + handler) override; + + /** @copydoc bool ICentralSystemProxy::registerHandler( + std::function) */ + bool registerHandler( + std::function< + bool(const ocpp::messages::ocpp16::SendLocalListReq&, ocpp::messages::ocpp16::SendLocalListConf&, std::string&, std::string&)> + handler) override; + + /** @copydoc bool ICentralSystemProxy::registerHandler( + std::function) */ + bool registerHandler(std::function handler) override; + + /** @copydoc bool ICentralSystemProxy::registerHandler( + std::function) */ + bool registerHandler( + std::function< + bool(const ocpp::messages::ocpp16::TriggerMessageReq&, ocpp::messages::ocpp16::TriggerMessageConf&, std::string&, std::string&)> + handler) override; + + /** @copydoc bool ICentralSystemProxy::registerHandler( + std::function) */ + bool registerHandler( + std::function + handler) override; + + /** @copydoc bool ICentralSystemProxy::registerHandler( + std::function) */ + bool registerHandler( + std::function< + bool(const ocpp::messages::ocpp16::UpdateFirmwareReq&, ocpp::messages::ocpp16::UpdateFirmwareConf&, std::string&, std::string&)> + handler) override; + + /** @copydoc bool ICentralSystemProxy::registerHandler( + std::function) */ + bool registerHandler(std::function handler) override; + + /** @copydoc bool ICentralSystemProxy::registerHandler( + std::function) */ + bool registerHandler(std::function handler) override; + + /** @copydoc bool ICentralSystemProxy::registerHandler( + std::function) */ + bool registerHandler(std::function handler) override; + + /** @copydoc bool ICentralSystemProxy::registerHandler( + std::function) */ + bool registerHandler(std::function handler) override; + + /** @copydoc bool ICentralSystemProxy::registerHandler( + std::function) */ + bool registerHandler( + std::function + handler) override; + + /** @copydoc bool ICentralSystemProxy::registerHandler( + std::function) */ + bool registerHandler(std::function handler) override; + + /** @copydoc bool ICentralSystemProxy::registerHandler( + std::function) */ + bool registerHandler(std::function handler) override; + + // IRpc::IListener interface + + /** @copydoc void IRpc::IListener::rpcDisconnected() */ + void rpcDisconnected() override; + + /** @copydoc void IRpc::IListener::rpcError() */ + void rpcError() override; + + /** @copydoc bool IRpc::IListener::rpcCallReceived(const std::string&, + const rapidjson::Value&, + rapidjson::Document&, + std::string&, + std::string&) */ + bool rpcCallReceived(const std::string& action, + const rapidjson::Value& payload, + rapidjson::Document& response, + std::string& error_code, + std::string& error_message) override; + + // IRpc::ISpy interface + + /** @copydoc void IRpc::ISpy::rcpMessageReceived(const std::string& msg) */ + void rcpMessageReceived(const std::string& msg) override; + + /** @copydoc void IRpc::ISpy::rcpMessageSent(const std::string& msg) */ + void rcpMessageSent(const std::string& msg) override; + + // RpcClient::IListener interface + + /** @brief Called when connection is successfull */ + void rpcClientConnected() override; + + /** @brief Called when connection failed */ + void rpcClientFailed() override; + + private: + /** @brief Charge point's identifier */ + std::string m_identifier; + /** @brief Stack configuration */ + const ocpp::config::ILocalControllerConfig& m_stack_config; + /** @brief Client websocket */ + std::unique_ptr m_websocket; + /** @brief RPC connection */ + ocpp::rpc::RpcClient m_rpc; + /** @brief Messages converter */ + ocpp::messages::ocpp16::MessagesConverter& m_messages_converter; + /** @brief Message dispatcher */ + ocpp::messages::MessageDispatcher m_msg_dispatcher; + /** @brief Message sender */ + ocpp::messages::GenericMessageSender m_msg_sender; + /** @brief Request handler */ + CentralSystemHandler m_handler; + /** @brief Proxy to forward requests to the charge point */ + std::weak_ptr m_charge_point; + /** @brief Listener to the proxy events */ + ILocalControllerProxyEventsHandler* m_listener; + /** @brief User message handlers */ + std::vector> m_user_handlers; + + /** + * @brief Execute a call request + * @param action RPC action for the request + * @param request Request payload + * @param response Response payload + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + template + bool call(const std::string& action, const RequestType& request, ResponseType& response, std::string& error, std::string& message) + { + bool ret = true; + + LOG_DEBUG << "[" << m_identifier << "] - " << action; + + ocpp::messages::CallResult res = m_msg_sender.call(action, request, response, error, message); + if (res != ocpp::messages::CallResult::Ok) + { + LOG_ERROR << "[" << m_identifier << "] - " << action << " => " + << (res == ocpp::messages::CallResult::Failed ? "Timeout" : "Error"); + ret = false; + } + + return ret; + } + + /** + * @brief Register a user handler for an incoming request + * @param action RPC action for the request + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + template + bool registerHandler(const std::string& action, + std::function handler) + { + ocpp::messages::UserMessageHandler* msg_handler = + new ocpp::messages::UserMessageHandler(action, m_messages_converter, handler); + m_user_handlers.push_back(std::shared_ptr(msg_handler)); + return m_msg_dispatcher.registerHandler(action, *msg_handler, true); + } +}; + +} // namespace localcontroller +} // namespace ocpp + +#endif // OPENOCPP_CENTRALSYSTEMPROXY_H diff --git a/src/localcontroller/chargepoint/ChargePointHandler.cpp b/src/ocpp16/localcontroller/chargepoint/ChargePointHandler.cpp similarity index 79% rename from src/localcontroller/chargepoint/ChargePointHandler.cpp rename to src/ocpp16/localcontroller/chargepoint/ChargePointHandler.cpp index bb4f0fb4..259fd6eb 100644 --- a/src/localcontroller/chargepoint/ChargePointHandler.cpp +++ b/src/ocpp16/localcontroller/chargepoint/ChargePointHandler.cpp @@ -22,7 +22,9 @@ along with OpenOCPP. If not, see . #include "MessagesConverter.h" using namespace ocpp::messages; +using namespace ocpp::messages::ocpp16; using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { @@ -30,10 +32,10 @@ namespace localcontroller { /** @brief Constructor */ -ChargePointHandler::ChargePointHandler(const std::string& identifier, - const ocpp::messages::MessagesConverter& messages_converter, - ocpp::messages::MessageDispatcher& msg_dispatcher, - ICentralSystemProxy& central_system) +ChargePointHandler::ChargePointHandler(const std::string& identifier, + const ocpp::messages::ocpp16::MessagesConverter& messages_converter, + ocpp::messages::MessageDispatcher& msg_dispatcher, + ICentralSystemProxy& central_system) : GenericMessageHandler(AUTHORIZE_ACTION, messages_converter), GenericMessageHandler(BOOT_NOTIFICATION_ACTION, messages_converter), GenericMessageHandler(DATA_TRANSFER_ACTION, messages_converter), @@ -101,10 +103,10 @@ ChargePointHandler::~ChargePointHandler() { } * std::string& error_code, * std::string& error_message) */ -bool ChargePointHandler::handleMessage(const ocpp::messages::AuthorizeReq& request, - ocpp::messages::AuthorizeConf& response, - std::string& error_code, - std::string& error_message) +bool ChargePointHandler::handleMessage(const ocpp::messages::ocpp16::AuthorizeReq& request, + ocpp::messages::ocpp16::AuthorizeConf& response, + std::string& error_code, + std::string& error_message) { return forward(AUTHORIZE_ACTION, request, response, error_code, error_message); } @@ -114,10 +116,10 @@ bool ChargePointHandler::handleMessage(const ocpp::messages::AuthorizeReq& reque * std::string& error_code, * std::string& error_message) */ -bool ChargePointHandler::handleMessage(const ocpp::messages::BootNotificationReq& request, - ocpp::messages::BootNotificationConf& response, - std::string& error_code, - std::string& error_message) +bool ChargePointHandler::handleMessage(const ocpp::messages::ocpp16::BootNotificationReq& request, + ocpp::messages::ocpp16::BootNotificationConf& response, + std::string& error_code, + std::string& error_message) { return forward(BOOT_NOTIFICATION_ACTION, request, response, error_code, error_message); } @@ -127,10 +129,10 @@ bool ChargePointHandler::handleMessage(const ocpp::messages::BootNotificationReq * std::string& error_code, * std::string& error_message) */ -bool ChargePointHandler::handleMessage(const ocpp::messages::DataTransferReq& request, - ocpp::messages::DataTransferConf& response, - std::string& error_code, - std::string& error_message) +bool ChargePointHandler::handleMessage(const ocpp::messages::ocpp16::DataTransferReq& request, + ocpp::messages::ocpp16::DataTransferConf& response, + std::string& error_code, + std::string& error_message) { return forward(DATA_TRANSFER_ACTION, request, response, error_code, error_message); } @@ -140,10 +142,10 @@ bool ChargePointHandler::handleMessage(const ocpp::messages::DataTransferReq& re * std::string& error_code, * std::string& error_message) */ -bool ChargePointHandler::handleMessage(const ocpp::messages::DiagnosticsStatusNotificationReq& request, - ocpp::messages::DiagnosticsStatusNotificationConf& response, - std::string& error_code, - std::string& error_message) +bool ChargePointHandler::handleMessage(const ocpp::messages::ocpp16::DiagnosticsStatusNotificationReq& request, + ocpp::messages::ocpp16::DiagnosticsStatusNotificationConf& response, + std::string& error_code, + std::string& error_message) { return forward(DIAGNOSTIC_STATUS_NOTIFICATION_ACTION, request, response, error_code, error_message); } @@ -153,10 +155,10 @@ bool ChargePointHandler::handleMessage(const ocpp::messages::DiagnosticsStatusNo * std::string& error_code, * std::string& error_message) */ -bool ChargePointHandler::handleMessage(const ocpp::messages::FirmwareStatusNotificationReq& request, - ocpp::messages::FirmwareStatusNotificationConf& response, - std::string& error_code, - std::string& error_message) +bool ChargePointHandler::handleMessage(const ocpp::messages::ocpp16::FirmwareStatusNotificationReq& request, + ocpp::messages::ocpp16::FirmwareStatusNotificationConf& response, + std::string& error_code, + std::string& error_message) { return forward(FIRMWARE_STATUS_NOTIFICATION_ACTION, request, response, error_code, error_message); } @@ -166,10 +168,10 @@ bool ChargePointHandler::handleMessage(const ocpp::messages::FirmwareStatusNotif * std::string& error_code, * std::string& error_message) */ -bool ChargePointHandler::handleMessage(const ocpp::messages::HeartbeatReq& request, - ocpp::messages::HeartbeatConf& response, - std::string& error_code, - std::string& error_message) +bool ChargePointHandler::handleMessage(const ocpp::messages::ocpp16::HeartbeatReq& request, + ocpp::messages::ocpp16::HeartbeatConf& response, + std::string& error_code, + std::string& error_message) { return forward(HEARTBEAT_ACTION, request, response, error_code, error_message); } @@ -179,10 +181,10 @@ bool ChargePointHandler::handleMessage(const ocpp::messages::HeartbeatReq& reque * std::string& error_code, * std::string& error_message) */ -bool ChargePointHandler::handleMessage(const ocpp::messages::MeterValuesReq& request, - ocpp::messages::MeterValuesConf& response, - std::string& error_code, - std::string& error_message) +bool ChargePointHandler::handleMessage(const ocpp::messages::ocpp16::MeterValuesReq& request, + ocpp::messages::ocpp16::MeterValuesConf& response, + std::string& error_code, + std::string& error_message) { return forward(METER_VALUES_ACTION, request, response, error_code, error_message); } @@ -192,10 +194,10 @@ bool ChargePointHandler::handleMessage(const ocpp::messages::MeterValuesReq& req * std::string& error_code, * std::string& error_message) */ -bool ChargePointHandler::handleMessage(const ocpp::messages::StartTransactionReq& request, - ocpp::messages::StartTransactionConf& response, - std::string& error_code, - std::string& error_message) +bool ChargePointHandler::handleMessage(const ocpp::messages::ocpp16::StartTransactionReq& request, + ocpp::messages::ocpp16::StartTransactionConf& response, + std::string& error_code, + std::string& error_message) { return forward(START_TRANSACTION_ACTION, request, response, error_code, error_message); } @@ -205,10 +207,10 @@ bool ChargePointHandler::handleMessage(const ocpp::messages::StartTransactionReq * std::string& error_code, * std::string& error_message) */ -bool ChargePointHandler::handleMessage(const ocpp::messages::StatusNotificationReq& request, - ocpp::messages::StatusNotificationConf& response, - std::string& error_code, - std::string& error_message) +bool ChargePointHandler::handleMessage(const ocpp::messages::ocpp16::StatusNotificationReq& request, + ocpp::messages::ocpp16::StatusNotificationConf& response, + std::string& error_code, + std::string& error_message) { return forward(STATUS_NOTIFICATION_ACTION, request, response, error_code, error_message); } @@ -218,10 +220,10 @@ bool ChargePointHandler::handleMessage(const ocpp::messages::StatusNotificationR * std::string& error_code, * std::string& error_message) */ -bool ChargePointHandler::handleMessage(const ocpp::messages::StopTransactionReq& request, - ocpp::messages::StopTransactionConf& response, - std::string& error_code, - std::string& error_message) +bool ChargePointHandler::handleMessage(const ocpp::messages::ocpp16::StopTransactionReq& request, + ocpp::messages::ocpp16::StopTransactionConf& response, + std::string& error_code, + std::string& error_message) { return forward(STOP_TRANSACTION_ACTION, request, response, error_code, error_message); } @@ -233,10 +235,10 @@ bool ChargePointHandler::handleMessage(const ocpp::messages::StopTransactionReq& * std::string& error_code, * std::string& error_message) */ -bool ChargePointHandler::handleMessage(const ocpp::messages::LogStatusNotificationReq& request, - ocpp::messages::LogStatusNotificationConf& response, - std::string& error_code, - std::string& error_message) +bool ChargePointHandler::handleMessage(const ocpp::messages::ocpp16::LogStatusNotificationReq& request, + ocpp::messages::ocpp16::LogStatusNotificationConf& response, + std::string& error_code, + std::string& error_message) { return forward(LOG_STATUS_NOTIFICATION_ACTION, request, response, error_code, error_message); } @@ -246,10 +248,10 @@ bool ChargePointHandler::handleMessage(const ocpp::messages::LogStatusNotificati * std::string& error_code, * std::string& error_message) */ -bool ChargePointHandler::handleMessage(const ocpp::messages::SecurityEventNotificationReq& request, - ocpp::messages::SecurityEventNotificationConf& response, - std::string& error_code, - std::string& error_message) +bool ChargePointHandler::handleMessage(const ocpp::messages::ocpp16::SecurityEventNotificationReq& request, + ocpp::messages::ocpp16::SecurityEventNotificationConf& response, + std::string& error_code, + std::string& error_message) { return forward(SECURITY_EVENT_NOTIFICATION_ACTION, request, response, error_code, error_message); } @@ -259,10 +261,10 @@ bool ChargePointHandler::handleMessage(const ocpp::messages::SecurityEventNotifi * std::string& error_code, * std::string& error_message) */ -bool ChargePointHandler::handleMessage(const ocpp::messages::SignCertificateReq& request, - ocpp::messages::SignCertificateConf& response, - std::string& error_code, - std::string& error_message) +bool ChargePointHandler::handleMessage(const ocpp::messages::ocpp16::SignCertificateReq& request, + ocpp::messages::ocpp16::SignCertificateConf& response, + std::string& error_code, + std::string& error_message) { return forward(SIGN_CERTIFICATE_ACTION, request, response, error_code, error_message); } @@ -272,10 +274,10 @@ bool ChargePointHandler::handleMessage(const ocpp::messages::SignCertificateReq& * std::string& error_code, * std::string& error_message) */ -bool ChargePointHandler::handleMessage(const ocpp::messages::SignedFirmwareStatusNotificationReq& request, - ocpp::messages::SignedFirmwareStatusNotificationConf& response, - std::string& error_code, - std::string& error_message) +bool ChargePointHandler::handleMessage(const ocpp::messages::ocpp16::SignedFirmwareStatusNotificationReq& request, + ocpp::messages::ocpp16::SignedFirmwareStatusNotificationConf& response, + std::string& error_code, + std::string& error_message) { return forward(SIGNED_FIRMWARE_STATUS_NOTIFICATION_ACTION, request, response, error_code, error_message); } diff --git a/src/localcontroller/chargepoint/ChargePointHandler.h b/src/ocpp16/localcontroller/chargepoint/ChargePointHandler.h similarity index 72% rename from src/localcontroller/chargepoint/ChargePointHandler.h rename to src/ocpp16/localcontroller/chargepoint/ChargePointHandler.h index cf159155..10aaf2e6 100644 --- a/src/localcontroller/chargepoint/ChargePointHandler.h +++ b/src/ocpp16/localcontroller/chargepoint/ChargePointHandler.h @@ -47,7 +47,10 @@ class ILocalControllerConfig; namespace messages { class MessageDispatcher; +namespace ocpp16 +{ class MessagesConverter; +} // namespace ocpp16 } // namespace messages namespace localcontroller @@ -55,25 +58,29 @@ namespace localcontroller /** @brief Handler for charge point requests */ class ChargePointHandler - : public ocpp::messages::GenericMessageHandler, - public ocpp::messages::GenericMessageHandler, - public ocpp::messages::GenericMessageHandler, - public ocpp::messages::GenericMessageHandler, - public ocpp::messages::GenericMessageHandler, - public ocpp::messages::GenericMessageHandler, - public ocpp::messages::GenericMessageHandler, - public ocpp::messages::GenericMessageHandler, - public ocpp::messages::GenericMessageHandler, - public ocpp::messages::GenericMessageHandler, + : public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, // Security extensions - public ocpp::messages::GenericMessageHandler, - public ocpp::messages::GenericMessageHandler, - public ocpp::messages::GenericMessageHandler, - public ocpp::messages::GenericMessageHandler + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler { public: /** @@ -83,10 +90,10 @@ class ChargePointHandler * @param msg_dispatcher Message dispatcher * @param stack_config Stack configuration */ - ChargePointHandler(const std::string& identifier, - const ocpp::messages::MessagesConverter& messages_converter, - ocpp::messages::MessageDispatcher& msg_dispatcher, - ICentralSystemProxy& central_system); + ChargePointHandler(const std::string& identifier, + const ocpp::messages::ocpp16::MessagesConverter& messages_converter, + ocpp::messages::MessageDispatcher& msg_dispatcher, + ICentralSystemProxy& central_system); /** @brief Destructor */ virtual ~ChargePointHandler(); @@ -98,100 +105,100 @@ class ChargePointHandler * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::AuthorizeReq& request, - ocpp::messages::AuthorizeConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::AuthorizeReq& request, + ocpp::messages::ocpp16::AuthorizeConf& response, + std::string& error_code, + std::string& error_message) override; /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, * ResponseType& response, * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::BootNotificationReq& request, - ocpp::messages::BootNotificationConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::BootNotificationReq& request, + ocpp::messages::ocpp16::BootNotificationConf& response, + std::string& error_code, + std::string& error_message) override; /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, * ResponseType& response, * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::DataTransferReq& request, - ocpp::messages::DataTransferConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::DataTransferReq& request, + ocpp::messages::ocpp16::DataTransferConf& response, + std::string& error_code, + std::string& error_message) override; /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, * ResponseType& response, * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::DiagnosticsStatusNotificationReq& request, - ocpp::messages::DiagnosticsStatusNotificationConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::DiagnosticsStatusNotificationReq& request, + ocpp::messages::ocpp16::DiagnosticsStatusNotificationConf& response, + std::string& error_code, + std::string& error_message) override; /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, * ResponseType& response, * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::FirmwareStatusNotificationReq& request, - ocpp::messages::FirmwareStatusNotificationConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::FirmwareStatusNotificationReq& request, + ocpp::messages::ocpp16::FirmwareStatusNotificationConf& response, + std::string& error_code, + std::string& error_message) override; /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, * ResponseType& response, * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::HeartbeatReq& request, - ocpp::messages::HeartbeatConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::HeartbeatReq& request, + ocpp::messages::ocpp16::HeartbeatConf& response, + std::string& error_code, + std::string& error_message) override; /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, * ResponseType& response, * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::MeterValuesReq& request, - ocpp::messages::MeterValuesConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::MeterValuesReq& request, + ocpp::messages::ocpp16::MeterValuesConf& response, + std::string& error_code, + std::string& error_message) override; /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, * ResponseType& response, * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::StartTransactionReq& request, - ocpp::messages::StartTransactionConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::StartTransactionReq& request, + ocpp::messages::ocpp16::StartTransactionConf& response, + std::string& error_code, + std::string& error_message) override; /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, * ResponseType& response, * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::StatusNotificationReq& request, - ocpp::messages::StatusNotificationConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::StatusNotificationReq& request, + ocpp::messages::ocpp16::StatusNotificationConf& response, + std::string& error_code, + std::string& error_message) override; /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, * ResponseType& response, * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::StopTransactionReq& request, - ocpp::messages::StopTransactionConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::StopTransactionReq& request, + ocpp::messages::ocpp16::StopTransactionConf& response, + std::string& error_code, + std::string& error_message) override; // Security extensions @@ -200,40 +207,40 @@ class ChargePointHandler * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::LogStatusNotificationReq& request, - ocpp::messages::LogStatusNotificationConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::LogStatusNotificationReq& request, + ocpp::messages::ocpp16::LogStatusNotificationConf& response, + std::string& error_code, + std::string& error_message) override; /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, * ResponseType& response, * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::SecurityEventNotificationReq& request, - ocpp::messages::SecurityEventNotificationConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::SecurityEventNotificationReq& request, + ocpp::messages::ocpp16::SecurityEventNotificationConf& response, + std::string& error_code, + std::string& error_message) override; /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, * ResponseType& response, * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::SignCertificateReq& request, - ocpp::messages::SignCertificateConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::SignCertificateReq& request, + ocpp::messages::ocpp16::SignCertificateConf& response, + std::string& error_code, + std::string& error_message) override; /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, * ResponseType& response, * std::string& error_code, * std::string& error_message) */ - bool handleMessage(const ocpp::messages::SignedFirmwareStatusNotificationReq& request, - ocpp::messages::SignedFirmwareStatusNotificationConf& response, - std::string& error_code, - std::string& error_message) override; + bool handleMessage(const ocpp::messages::ocpp16::SignedFirmwareStatusNotificationReq& request, + ocpp::messages::ocpp16::SignedFirmwareStatusNotificationConf& response, + std::string& error_code, + std::string& error_message) override; private: /** @brief Charge point's identifier */ diff --git a/src/localcontroller/chargepoint/ChargePointProxy.cpp b/src/ocpp16/localcontroller/chargepoint/ChargePointProxy.cpp similarity index 58% rename from src/localcontroller/chargepoint/ChargePointProxy.cpp rename to src/ocpp16/localcontroller/chargepoint/ChargePointProxy.cpp index c59dc7fe..a8a9abe5 100644 --- a/src/localcontroller/chargepoint/ChargePointProxy.cpp +++ b/src/ocpp16/localcontroller/chargepoint/ChargePointProxy.cpp @@ -22,8 +22,10 @@ along with OpenOCPP. If not, see . #include "ILocalControllerConfig.h" #include "MessagesConverter.h" -using namespace ocpp::types; using namespace ocpp::messages; +using namespace ocpp::messages::ocpp16; +using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { @@ -65,12 +67,12 @@ std::shared_ptr IChargePointProxy::createFrom( } /** @brief Constructor */ -ChargePointProxy::ChargePointProxy(const std::string& identifier, - std::shared_ptr rpc, - const ocpp::messages::MessagesValidator& messages_validator, - ocpp::messages::MessagesConverter& messages_converter, - const ocpp::config::ILocalControllerConfig& stack_config, - std::shared_ptr central_system) +ChargePointProxy::ChargePointProxy(const std::string& identifier, + std::shared_ptr rpc, + const ocpp::messages::ocpp16::MessagesValidator& messages_validator, + ocpp::messages::ocpp16::MessagesConverter& messages_converter, + const ocpp::config::ILocalControllerConfig& stack_config, + std::shared_ptr central_system) : m_identifier(identifier), m_rpc(rpc), m_messages_converter(messages_converter), @@ -121,351 +123,354 @@ void ChargePointProxy::disconnect() // OCPP operations -/** @copydoc bool IChargePointProxy::call(const ocpp::messages::CancelReservationReq&, - * ocpp::messages::CancelReservationConf&, +/** @copydoc bool IChargePointProxy::call(const ocpp::messages::ocpp16::CancelReservationReq&, + * ocpp::messages::ocpp16::CancelReservationConf&, * std::string&, * std::string&) */ -bool ChargePointProxy::call(const ocpp::messages::CancelReservationReq& request, - ocpp::messages::CancelReservationConf& response, - std::string& error, - std::string& message) +bool ChargePointProxy::call(const ocpp::messages::ocpp16::CancelReservationReq& request, + ocpp::messages::ocpp16::CancelReservationConf& response, + std::string& error, + std::string& message) { return call(CANCEL_RESERVATION_ACTION, request, response, error, message); } -/** @copydoc bool IChargePointProxy::call(const ocpp::messages::ChangeAvailabilityReq&, - * ocpp::messages::ChangeAvailabilityConf&, +/** @copydoc bool IChargePointProxy::call(const ocpp::messages::ocpp16::ChangeAvailabilityReq&, + * ocpp::messages::ocpp16::ChangeAvailabilityConf&, * std::string&, * std::string&) */ -bool ChargePointProxy::call(const ocpp::messages::ChangeAvailabilityReq& request, - ocpp::messages::ChangeAvailabilityConf& response, - std::string& error, - std::string& message) +bool ChargePointProxy::call(const ocpp::messages::ocpp16::ChangeAvailabilityReq& request, + ocpp::messages::ocpp16::ChangeAvailabilityConf& response, + std::string& error, + std::string& message) { return call(CHANGE_AVAILABILITY_ACTION, request, response, error, message); } -/** @copydoc bool IChargePointProxy::call(const ocpp::messages::ChangeConfigurationReq&, - * ocpp::messages::ChangeConfigurationConf&, +/** @copydoc bool IChargePointProxy::call(const ocpp::messages::ocpp16::ChangeConfigurationReq&, + * ocpp::messages::ocpp16::ChangeConfigurationConf&, * std::string&, * std::string&) */ -bool ChargePointProxy::call(const ocpp::messages::ChangeConfigurationReq& request, - ocpp::messages::ChangeConfigurationConf& response, - std::string& error, - std::string& message) +bool ChargePointProxy::call(const ocpp::messages::ocpp16::ChangeConfigurationReq& request, + ocpp::messages::ocpp16::ChangeConfigurationConf& response, + std::string& error, + std::string& message) { return call(CHANGE_CONFIGURATION_ACTION, request, response, error, message); } -/** @copydoc bool IChargePointProxy::call(const ocpp::messages::ClearCacheReq&, - * ocpp::messages::ClearCacheConf&, +/** @copydoc bool IChargePointProxy::call(const ocpp::messages::ocpp16::ClearCacheReq&, + * ocpp::messages::ocpp16::ClearCacheConf&, * std::string&, * std::string&) */ -bool ChargePointProxy::call(const ocpp::messages::ClearCacheReq& request, - ocpp::messages::ClearCacheConf& response, - std::string& error, - std::string& message) +bool ChargePointProxy::call(const ocpp::messages::ocpp16::ClearCacheReq& request, + ocpp::messages::ocpp16::ClearCacheConf& response, + std::string& error, + std::string& message) { return call(CLEAR_CACHE_ACTION, request, response, error, message); } -/** @copydoc bool IChargePointProxy::call(const ocpp::messages::ClearChargingProfileReq&, +/** @copydoc bool IChargePointProxy::call(const ocpp::messages::ocpp16::ClearChargingProfileReq&, * cpp::messages::ClearChargingProfileConf&, * std::string&, * std::string&) */ -bool ChargePointProxy::call(const ocpp::messages::ClearChargingProfileReq& request, - ocpp::messages::ClearChargingProfileConf& response, - std::string& error, - std::string& message) +bool ChargePointProxy::call(const ocpp::messages::ocpp16::ClearChargingProfileReq& request, + ocpp::messages::ocpp16::ClearChargingProfileConf& response, + std::string& error, + std::string& message) { return call(CLEAR_CHARGING_PROFILE_ACTION, request, response, error, message); } -/** @copydoc bool IChargePointProxy::call(const ocpp::messages::DataTransferReq&, - * ocpp::messages::DataTransferConf&, +/** @copydoc bool IChargePointProxy::call(const ocpp::messages::ocpp16::DataTransferReq&, + * ocpp::messages::ocpp16::DataTransferConf&, * std::string&, * std::string&) */ -bool ChargePointProxy::call(const ocpp::messages::DataTransferReq& request, - ocpp::messages::DataTransferConf& response, - std::string& error, - std::string& message) +bool ChargePointProxy::call(const ocpp::messages::ocpp16::DataTransferReq& request, + ocpp::messages::ocpp16::DataTransferConf& response, + std::string& error, + std::string& message) { return call(DATA_TRANSFER_ACTION, request, response, error, message); } -/** @copydoc bool IChargePointProxy::call(const ocpp::messages::GetCompositeScheduleReq&, - * ocpp::messages::GetCompositeScheduleConf&, +/** @copydoc bool IChargePointProxy::call(const ocpp::messages::ocpp16::GetCompositeScheduleReq&, + * ocpp::messages::ocpp16::GetCompositeScheduleConf&, * std::string&, * std::string&) */ -bool ChargePointProxy::call(const ocpp::messages::GetCompositeScheduleReq& request, - ocpp::messages::GetCompositeScheduleConf& response, - std::string& error, - std::string& message) +bool ChargePointProxy::call(const ocpp::messages::ocpp16::GetCompositeScheduleReq& request, + ocpp::messages::ocpp16::GetCompositeScheduleConf& response, + std::string& error, + std::string& message) { return call(GET_COMPOSITE_SCHEDULE_ACTION, request, response, error, message); } -/** @copydoc bool IChargePointProxy::call(const ocpp::messages::GetConfigurationReq&, - * ocpp::messages::GetConfigurationConf&, +/** @copydoc bool IChargePointProxy::call(const ocpp::messages::ocpp16::GetConfigurationReq&, + * ocpp::messages::ocpp16::GetConfigurationConf&, * std::string&, * std::string&) */ -bool ChargePointProxy::call(const ocpp::messages::GetConfigurationReq& request, - ocpp::messages::GetConfigurationConf& response, - std::string& error, - std::string& message) +bool ChargePointProxy::call(const ocpp::messages::ocpp16::GetConfigurationReq& request, + ocpp::messages::ocpp16::GetConfigurationConf& response, + std::string& error, + std::string& message) { return call(GET_CONFIGURATION_ACTION, request, response, error, message); } -/** @copydoc bool IChargePointProxy::call(const ocpp::messages::GetDiagnosticsReq&, - * ocpp::messages::GetDiagnosticsConf&, +/** @copydoc bool IChargePointProxy::call(const ocpp::messages::ocpp16::GetDiagnosticsReq&, + * ocpp::messages::ocpp16::GetDiagnosticsConf&, * std::string&, * std::string&) */ -bool ChargePointProxy::call(const ocpp::messages::GetDiagnosticsReq& request, - ocpp::messages::GetDiagnosticsConf& response, - std::string& error, - std::string& message) +bool ChargePointProxy::call(const ocpp::messages::ocpp16::GetDiagnosticsReq& request, + ocpp::messages::ocpp16::GetDiagnosticsConf& response, + std::string& error, + std::string& message) { return call(GET_DIAGNOSTICS_ACTION, request, response, error, message); } -/** @copydoc bool IChargePointProxy::call(const ocpp::messages::GetLocalListVersionReq&, - * ocpp::messages::GetLocalListVersionConf&, +/** @copydoc bool IChargePointProxy::call(const ocpp::messages::ocpp16::GetLocalListVersionReq&, + * ocpp::messages::ocpp16::GetLocalListVersionConf&, * std::string&, * std::string&) */ -bool ChargePointProxy::call(const ocpp::messages::GetLocalListVersionReq& request, - ocpp::messages::GetLocalListVersionConf& response, - std::string& error, - std::string& message) +bool ChargePointProxy::call(const ocpp::messages::ocpp16::GetLocalListVersionReq& request, + ocpp::messages::ocpp16::GetLocalListVersionConf& response, + std::string& error, + std::string& message) { return call(GET_LOCAL_LIST_VERSION_ACTION, request, response, error, message); } -/** @copydoc bool IChargePointProxy::call(const ocpp::messages::RemoteStartTransactionReq&, - * ocpp::messages::RemoteStartTransactionConf&, +/** @copydoc bool IChargePointProxy::call(const ocpp::messages::ocpp16::RemoteStartTransactionReq&, + * ocpp::messages::ocpp16::RemoteStartTransactionConf&, * std::string&, * std::string&) */ -bool ChargePointProxy::call(const ocpp::messages::RemoteStartTransactionReq& request, - ocpp::messages::RemoteStartTransactionConf& response, - std::string& error, - std::string& message) +bool ChargePointProxy::call(const ocpp::messages::ocpp16::RemoteStartTransactionReq& request, + ocpp::messages::ocpp16::RemoteStartTransactionConf& response, + std::string& error, + std::string& message) { return call(REMOTE_START_TRANSACTION_ACTION, request, response, error, message); } -/** @copydoc bool IChargePointProxy::call(const ocpp::messages::RemoteStopTransactionReq&, - * ocpp::messages::RemoteStopTransactionConf&, +/** @copydoc bool IChargePointProxy::call(const ocpp::messages::ocpp16::RemoteStopTransactionReq&, + * ocpp::messages::ocpp16::RemoteStopTransactionConf&, * std::string&, * std::string&) */ -bool ChargePointProxy::call(const ocpp::messages::RemoteStopTransactionReq& request, - ocpp::messages::RemoteStopTransactionConf& response, - std::string& error, - std::string& message) +bool ChargePointProxy::call(const ocpp::messages::ocpp16::RemoteStopTransactionReq& request, + ocpp::messages::ocpp16::RemoteStopTransactionConf& response, + std::string& error, + std::string& message) { return call(REMOTE_STOP_TRANSACTION_ACTION, request, response, error, message); } -/** @copydoc bool IChargePointProxy::call(const ocpp::messages::ReserveNowReq&, - * ocpp::messages::ReserveNowConf&, +/** @copydoc bool IChargePointProxy::call(const ocpp::messages::ocpp16::ReserveNowReq&, + * ocpp::messages::ocpp16::ReserveNowConf&, * std::string&, * std::string&) */ -bool ChargePointProxy::call(const ocpp::messages::ReserveNowReq& request, - ocpp::messages::ReserveNowConf& response, - std::string& error, - std::string& message) +bool ChargePointProxy::call(const ocpp::messages::ocpp16::ReserveNowReq& request, + ocpp::messages::ocpp16::ReserveNowConf& response, + std::string& error, + std::string& message) { return call(RESERVE_NOW_ACTION, request, response, error, message); } -/** @copydoc bool IChargePointProxy::call(const ocpp::messages::ResetReq&, - * ocpp::messages::ResetConf&, +/** @copydoc bool IChargePointProxy::call(const ocpp::messages::ocpp16::ResetReq&, + * ocpp::messages::ocpp16::ResetConf&, * std::string&, * std::string&) */ -bool ChargePointProxy::call(const ocpp::messages::ResetReq& request, - ocpp::messages::ResetConf& response, - std::string& error, - std::string& message) +bool ChargePointProxy::call(const ocpp::messages::ocpp16::ResetReq& request, + ocpp::messages::ocpp16::ResetConf& response, + std::string& error, + std::string& message) { return call(RESET_ACTION, request, response, error, message); } -/** @copydoc bool IChargePointProxy::call(const ocpp::messages::SendLocalListReq&, - * ocpp::messages::SendLocalListConf&, +/** @copydoc bool IChargePointProxy::call(const ocpp::messages::ocpp16::SendLocalListReq&, + * ocpp::messages::ocpp16::SendLocalListConf&, * std::string&, * std::string&) */ -bool ChargePointProxy::call(const ocpp::messages::SendLocalListReq& request, - ocpp::messages::SendLocalListConf& response, - std::string& error, - std::string& message) +bool ChargePointProxy::call(const ocpp::messages::ocpp16::SendLocalListReq& request, + ocpp::messages::ocpp16::SendLocalListConf& response, + std::string& error, + std::string& message) { return call(SEND_LOCAL_LIST_ACTION, request, response, error, message); } -/** @copydoc bool IChargePointProxy::call(const ocpp::messages::SetChargingProfileReq&, - * ocpp::messages::SetChargingProfileConf&, +/** @copydoc bool IChargePointProxy::call(const ocpp::messages::ocpp16::SetChargingProfileReq&, + * ocpp::messages::ocpp16::SetChargingProfileConf&, * std::string&, * std::string&) */ -bool ChargePointProxy::call(const ocpp::messages::SetChargingProfileReq& request, - ocpp::messages::SetChargingProfileConf& response, - std::string& error, - std::string& message) +bool ChargePointProxy::call(const ocpp::messages::ocpp16::SetChargingProfileReq& request, + ocpp::messages::ocpp16::SetChargingProfileConf& response, + std::string& error, + std::string& message) { return call(SET_CHARGING_PROFILE_ACTION, request, response, error, message); } -/** @copydoc bool IChargePointProxy::call(const ocpp::messages::TriggerMessageReq&, +/** @copydoc bool IChargePointProxy::call(const ocpp::messages::ocpp16::TriggerMessageReq&, * opp::messages::TriggerMessageConf&, * std::string&, * std::string&) */ -bool ChargePointProxy::call(const ocpp::messages::TriggerMessageReq& request, - ocpp::messages::TriggerMessageConf& response, - std::string& error, - std::string& message) +bool ChargePointProxy::call(const ocpp::messages::ocpp16::TriggerMessageReq& request, + ocpp::messages::ocpp16::TriggerMessageConf& response, + std::string& error, + std::string& message) { return call(TRIGGER_MESSAGE_ACTION, request, response, error, message); } -/** @copydoc bool IChargePointProxy::call(const ocpp::messages::UnlockConnectorReq&, - * ocpp::messages::UnlockConnectorConf&, +/** @copydoc bool IChargePointProxy::call(const ocpp::messages::ocpp16::UnlockConnectorReq&, + * ocpp::messages::ocpp16::UnlockConnectorConf&, * std::string&, * std::string&) */ -bool ChargePointProxy::call(const ocpp::messages::UnlockConnectorReq& request, - ocpp::messages::UnlockConnectorConf& response, - std::string& error, - std::string& message) +bool ChargePointProxy::call(const ocpp::messages::ocpp16::UnlockConnectorReq& request, + ocpp::messages::ocpp16::UnlockConnectorConf& response, + std::string& error, + std::string& message) { return call(UNLOCK_CONNECTOR_ACTION, request, response, error, message); } -/** @copydoc bool IChargePointProxy::call(const ocpp::messages::UpdateFirmwareReq&, - * ocpp::messages::UpdateFirmwareConf&, +/** @copydoc bool IChargePointProxy::call(const ocpp::messages::ocpp16::UpdateFirmwareReq&, + * ocpp::messages::ocpp16::UpdateFirmwareConf&, * std::string&, * std::string&) */ -bool ChargePointProxy::call(const ocpp::messages::UpdateFirmwareReq& request, - ocpp::messages::UpdateFirmwareConf& response, - std::string& error, - std::string& message) +bool ChargePointProxy::call(const ocpp::messages::ocpp16::UpdateFirmwareReq& request, + ocpp::messages::ocpp16::UpdateFirmwareConf& response, + std::string& error, + std::string& message) { return call(UPDATE_FIRMWARE_ACTION, request, response, error, message); } // Security extensions -/** @copydoc bool IChargePointProxy::call(const ocpp::messages::CertificateSignedReq&, - * ocpp::messages::CertificateSignedConf&, +/** @copydoc bool IChargePointProxy::call(const ocpp::messages::ocpp16::CertificateSignedReq&, + * ocpp::messages::ocpp16::CertificateSignedConf&, * std::string&, * std::string&) */ -bool ChargePointProxy::call(const ocpp::messages::CertificateSignedReq& request, - ocpp::messages::CertificateSignedConf& response, - std::string& error, - std::string& message) +bool ChargePointProxy::call(const ocpp::messages::ocpp16::CertificateSignedReq& request, + ocpp::messages::ocpp16::CertificateSignedConf& response, + std::string& error, + std::string& message) { return call(CERTIFICATE_SIGNED_ACTION, request, response, error, message); } -/** @copydoc bool IChargePointProxy::call(const ocpp::messages::DeleteCertificateReq&, - * ocpp::messages::DeleteCertificateConf&, +/** @copydoc bool IChargePointProxy::call(const ocpp::messages::ocpp16::DeleteCertificateReq&, + * ocpp::messages::ocpp16::DeleteCertificateConf&, * std::string&, * std::string&) */ -bool ChargePointProxy::call(const ocpp::messages::DeleteCertificateReq& request, - ocpp::messages::DeleteCertificateConf& response, - std::string& error, - std::string& message) +bool ChargePointProxy::call(const ocpp::messages::ocpp16::DeleteCertificateReq& request, + ocpp::messages::ocpp16::DeleteCertificateConf& response, + std::string& error, + std::string& message) { return call(DELETE_CERTIFICATE_ACTION, request, response, error, message); } -/** @copydoc bool IChargePointProxy::call(const ocpp::messages::ExtendedTriggerMessageReq&, - * ocpp::messages::ExtendedTriggerMessageConf&, +/** @copydoc bool IChargePointProxy::call(const ocpp::messages::ocpp16::ExtendedTriggerMessageReq&, + * ocpp::messages::ocpp16::ExtendedTriggerMessageConf&, * std::string&, * std::string&) */ -bool ChargePointProxy::call(const ocpp::messages::ExtendedTriggerMessageReq& request, - ocpp::messages::ExtendedTriggerMessageConf& response, - std::string& error, - std::string& message) +bool ChargePointProxy::call(const ocpp::messages::ocpp16::ExtendedTriggerMessageReq& request, + ocpp::messages::ocpp16::ExtendedTriggerMessageConf& response, + std::string& error, + std::string& message) { return call(EXTENDED_TRIGGER_MESSAGE_ACTION, request, response, error, message); } -/** @copydoc bool IChargePointProxy::call(const ocpp::messages::GetInstalledCertificateIdsReq&, - * ocpp::messages::GetInstalledCertificateIdsConf&, +/** @copydoc bool IChargePointProxy::call(const ocpp::messages::ocpp16::GetInstalledCertificateIdsReq&, + * ocpp::messages::ocpp16::GetInstalledCertificateIdsConf&, * std::string&, * std::string&) */ -bool ChargePointProxy::call(const ocpp::messages::GetInstalledCertificateIdsReq& request, - ocpp::messages::GetInstalledCertificateIdsConf& response, - std::string& error, - std::string& message) +bool ChargePointProxy::call(const ocpp::messages::ocpp16::GetInstalledCertificateIdsReq& request, + ocpp::messages::ocpp16::GetInstalledCertificateIdsConf& response, + std::string& error, + std::string& message) { return call(GET_INSTALLED_CERTIFICATE_IDS_ACTION, request, response, error, message); } -/** @copydoc bool IChargePointProxy::call(const ocpp::messages::GetLogReq&, - * ocpp::messages::GetLogConf&, +/** @copydoc bool IChargePointProxy::call(const ocpp::messages::ocpp16::GetLogReq&, + * ocpp::messages::ocpp16::GetLogConf&, * std::string&, * std::string&) */ -bool ChargePointProxy::call(const ocpp::messages::GetLogReq& request, - ocpp::messages::GetLogConf& response, - std::string& error, - std::string& message) +bool ChargePointProxy::call(const ocpp::messages::ocpp16::GetLogReq& request, + ocpp::messages::ocpp16::GetLogConf& response, + std::string& error, + std::string& message) { return call(GET_LOG_ACTION, request, response, error, message); } -/** @copydoc bool IChargePointProxy::call(const ocpp::messages::InstallCertificateReq&, - * ocpp::messages::InstallCertificateConf&, +/** @copydoc bool IChargePointProxy::call(const ocpp::messages::ocpp16::InstallCertificateReq&, + * ocpp::messages::ocpp16::InstallCertificateConf&, * std::string&, * std::string&) */ -bool ChargePointProxy::call(const ocpp::messages::InstallCertificateReq& request, - ocpp::messages::InstallCertificateConf& response, - std::string& error, - std::string& message) +bool ChargePointProxy::call(const ocpp::messages::ocpp16::InstallCertificateReq& request, + ocpp::messages::ocpp16::InstallCertificateConf& response, + std::string& error, + std::string& message) { return call(INSTALL_CERTIFICATE_ACTION, request, response, error, message); } -/** @copydoc bool IChargePointProxy::call(const ocpp::messages::SignedUpdateFirmwareReq&, - * ocpp::messages::SignedUpdateFirmwareConf&, +/** @copydoc bool IChargePointProxy::call(const ocpp::messages::ocpp16::SignedUpdateFirmwareReq&, + * ocpp::messages::ocpp16::SignedUpdateFirmwareConf&, * std::string&, * std::string&) */ -bool ChargePointProxy::call(const ocpp::messages::SignedUpdateFirmwareReq& request, - ocpp::messages::SignedUpdateFirmwareConf& response, - std::string& error, - std::string& message) +bool ChargePointProxy::call(const ocpp::messages::ocpp16::SignedUpdateFirmwareReq& request, + ocpp::messages::ocpp16::SignedUpdateFirmwareConf& response, + std::string& error, + std::string& message) { return call(SIGNED_UPDATE_FIRMWARE_ACTION, request, response, error, message); } /** @copydoc bool IChargePointProxy::registerHandler( - std::function) */ + std::function) */ bool ChargePointProxy::registerHandler( - std::function handler) + std::function + handler) { return registerHandler(AUTHORIZE_ACTION, handler); } /** @copydoc bool IChargePointProxy::registerHandler( - std::function) */ + std::function) */ bool ChargePointProxy::registerHandler( - std::function + std::function< + bool(const ocpp::messages::ocpp16::BootNotificationReq&, ocpp::messages::ocpp16::BootNotificationConf&, std::string&, std::string&)> handler) { return registerHandler(BOOT_NOTIFICATION_ACTION, handler); } /** @copydoc bool IChargePointProxy::registerHandler( - std::function) */ + std::function) */ bool ChargePointProxy::registerHandler( - std::function handler) + std::function handler) { return registerHandler(DATA_TRANSFER_ACTION, handler); } /** @copydoc bool IChargePointProxy::registerHandler( - std::function) */ -bool ChargePointProxy::registerHandler(std::function) */ +bool ChargePointProxy::registerHandler(std::function handler) { @@ -473,94 +478,101 @@ bool ChargePointProxy::registerHandler(std::function) */ -bool ChargePointProxy::registerHandler( - std::function - handler) + std::function) */ +bool ChargePointProxy::registerHandler(std::function handler) { return registerHandler(FIRMWARE_STATUS_NOTIFICATION_ACTION, handler); } /** @copydoc bool IChargePointProxy::registerHandler( - std::function) */ + std::function) */ bool ChargePointProxy::registerHandler( - std::function handler) + std::function + handler) { return registerHandler(HEARTBEAT_ACTION, handler); } /** @copydoc bool IChargePointProxy::registerHandler( - std::function) */ + std::function) */ bool ChargePointProxy::registerHandler( - std::function handler) + std::function + handler) { return registerHandler(METER_VALUES_ACTION, handler); } /** @copydoc bool IChargePointProxy::registerHandler( - std::function) */ + std::function) */ bool ChargePointProxy::registerHandler( - std::function + std::function< + bool(const ocpp::messages::ocpp16::StartTransactionReq&, ocpp::messages::ocpp16::StartTransactionConf&, std::string&, std::string&)> handler) { return registerHandler(START_TRANSACTION_ACTION, handler); } /** @copydoc bool IChargePointProxy::registerHandler( - std::function) */ + std::function) */ bool ChargePointProxy::registerHandler( - std::function + std::function handler) { return registerHandler(STATUS_NOTIFICATION_ACTION, handler); } /** @copydoc bool IChargePointProxy::registerHandler( - std::function) */ + std::function) */ bool ChargePointProxy::registerHandler( - std::function + std::function< + bool(const ocpp::messages::ocpp16::StopTransactionReq&, ocpp::messages::ocpp16::StopTransactionConf&, std::string&, std::string&)> handler) { return registerHandler(STOP_TRANSACTION_ACTION, handler); } /** @copydoc bool IChargePointProxy::registerHandler( - std::function) */ -bool ChargePointProxy::registerHandler( - std::function handler) + std::function) */ +bool ChargePointProxy::registerHandler(std::function handler) { return registerHandler(LOG_STATUS_NOTIFICATION_ACTION, handler); } /** @copydoc bool IChargePointProxy::registerHandler( - std::function) */ -bool ChargePointProxy::registerHandler( - std::function - handler) + std::function) */ +bool ChargePointProxy::registerHandler(std::function handler) { return registerHandler(SECURITY_EVENT_NOTIFICATION_ACTION, handler); } /** @copydoc bool IChargePointProxy::registerHandler( - std::function) */ + std::function) */ bool ChargePointProxy::registerHandler( - std::function + std::function< + bool(const ocpp::messages::ocpp16::SignCertificateReq&, ocpp::messages::ocpp16::SignCertificateConf&, std::string&, std::string&)> handler) { return registerHandler(SIGN_CERTIFICATE_ACTION, handler); } /** @copydoc bool IChargePointProxy::registerHandler( - std::function) */ -bool ChargePointProxy::registerHandler(std::function) */ +bool ChargePointProxy::registerHandler(std::function handler) { diff --git a/src/localcontroller/chargepoint/ChargePointProxy.h b/src/ocpp16/localcontroller/chargepoint/ChargePointProxy.h similarity index 50% rename from src/localcontroller/chargepoint/ChargePointProxy.h rename to src/ocpp16/localcontroller/chargepoint/ChargePointProxy.h index 4d565064..3454ae1b 100644 --- a/src/localcontroller/chargepoint/ChargePointProxy.h +++ b/src/ocpp16/localcontroller/chargepoint/ChargePointProxy.h @@ -50,12 +50,12 @@ class ChargePointProxy : public IChargePointProxy, public ocpp::rpc::IRpc::IList * @param stack_config Stack configuration * @param central_system Proxy to forward requests to the central system */ - ChargePointProxy(const std::string& identifier, - std::shared_ptr rpc, - const ocpp::messages::MessagesValidator& messages_validator, - ocpp::messages::MessagesConverter& messages_converter, - const ocpp::config::ILocalControllerConfig& stack_config, - std::shared_ptr central_system); + ChargePointProxy(const std::string& identifier, + std::shared_ptr rpc, + const ocpp::messages::ocpp16::MessagesValidator& messages_validator, + ocpp::messages::ocpp16::MessagesConverter& messages_converter, + const ocpp::config::ILocalControllerConfig& stack_config, + std::shared_ptr central_system); /** @brief Destructor */ virtual ~ChargePointProxy(); @@ -85,333 +85,339 @@ class ChargePointProxy : public IChargePointProxy, public ocpp::rpc::IRpc::IList // OCPP operations - /** @copydoc bool IChargePointProxy::call(const ocpp::messages::CancelReservationReq&, - * ocpp::messages::CancelReservationConf&, + /** @copydoc bool IChargePointProxy::call(const ocpp::messages::ocpp16::CancelReservationReq&, + * ocpp::messages::ocpp16::CancelReservationConf&, * std::string&, * std::string&) */ - bool call(const ocpp::messages::CancelReservationReq& request, - ocpp::messages::CancelReservationConf& response, - std::string& error, - std::string& message) override; + bool call(const ocpp::messages::ocpp16::CancelReservationReq& request, + ocpp::messages::ocpp16::CancelReservationConf& response, + std::string& error, + std::string& message) override; - /** @copydoc bool IChargePointProxy::call(const ocpp::messages::ChangeAvailabilityReq&, - * ocpp::messages::ChangeAvailabilityConf&, + /** @copydoc bool IChargePointProxy::call(const ocpp::messages::ocpp16::ChangeAvailabilityReq&, + * ocpp::messages::ocpp16::ChangeAvailabilityConf&, * std::string&, * std::string&) */ - bool call(const ocpp::messages::ChangeAvailabilityReq& request, - ocpp::messages::ChangeAvailabilityConf& response, - std::string& error, - std::string& message) override; + bool call(const ocpp::messages::ocpp16::ChangeAvailabilityReq& request, + ocpp::messages::ocpp16::ChangeAvailabilityConf& response, + std::string& error, + std::string& message) override; - /** @copydoc bool IChargePointProxy::call(const ocpp::messages::ChangeConfigurationReq&, - * ocpp::messages::ChangeConfigurationConf&, + /** @copydoc bool IChargePointProxy::call(const ocpp::messages::ocpp16::ChangeConfigurationReq&, + * ocpp::messages::ocpp16::ChangeConfigurationConf&, * std::string&, * std::string&) */ - bool call(const ocpp::messages::ChangeConfigurationReq& request, - ocpp::messages::ChangeConfigurationConf& response, - std::string& error, - std::string& message) override; + bool call(const ocpp::messages::ocpp16::ChangeConfigurationReq& request, + ocpp::messages::ocpp16::ChangeConfigurationConf& response, + std::string& error, + std::string& message) override; - /** @copydoc bool IChargePointProxy::call(const ocpp::messages::ClearCacheReq&, - * ocpp::messages::ClearCacheConf&, + /** @copydoc bool IChargePointProxy::call(const ocpp::messages::ocpp16::ClearCacheReq&, + * ocpp::messages::ocpp16::ClearCacheConf&, * std::string&, * std::string&) */ - bool call(const ocpp::messages::ClearCacheReq& request, - ocpp::messages::ClearCacheConf& response, - std::string& error, - std::string& message) override; + bool call(const ocpp::messages::ocpp16::ClearCacheReq& request, + ocpp::messages::ocpp16::ClearCacheConf& response, + std::string& error, + std::string& message) override; - /** @copydoc bool IChargePointProxy::call(const ocpp::messages::ClearChargingProfileReq&, + /** @copydoc bool IChargePointProxy::call(const ocpp::messages::ocpp16::ClearChargingProfileReq&, * cpp::messages::ClearChargingProfileConf&, * std::string&, * std::string&) */ - bool call(const ocpp::messages::ClearChargingProfileReq& request, - ocpp::messages::ClearChargingProfileConf& response, - std::string& error, - std::string& message) override; - - /** @copydoc bool IChargePointProxy::call(const ocpp::messages::DataTransferReq&, - * ocpp::messages::DataTransferConf&, - * std::string&, - * std::string&) */ - bool call(const ocpp::messages::DataTransferReq& request, - ocpp::messages::DataTransferConf& response, - std::string& error, - std::string& message) override; + bool call(const ocpp::messages::ocpp16::ClearChargingProfileReq& request, + ocpp::messages::ocpp16::ClearChargingProfileConf& response, + std::string& error, + std::string& message) override; - /** @copydoc bool IChargePointProxy::call(const ocpp::messages::GetCompositeScheduleReq&, - * ocpp::messages::GetCompositeScheduleConf&, + /** @copydoc bool IChargePointProxy::call(const ocpp::messages::ocpp16::DataTransferReq&, + * ocpp::messages::ocpp16::DataTransferConf&, * std::string&, * std::string&) */ - bool call(const ocpp::messages::GetCompositeScheduleReq& request, - ocpp::messages::GetCompositeScheduleConf& response, + bool call(const ocpp::messages::ocpp16::DataTransferReq& request, + ocpp::messages::ocpp16::DataTransferConf& response, std::string& error, std::string& message) override; - /** @copydoc bool IChargePointProxy::call(const ocpp::messages::GetConfigurationReq&, - * ocpp::messages::GetConfigurationConf&, + /** @copydoc bool IChargePointProxy::call(const ocpp::messages::ocpp16::GetCompositeScheduleReq&, + * ocpp::messages::ocpp16::GetCompositeScheduleConf&, * std::string&, * std::string&) */ - bool call(const ocpp::messages::GetConfigurationReq& request, - ocpp::messages::GetConfigurationConf& response, - std::string& error, - std::string& message) override; + bool call(const ocpp::messages::ocpp16::GetCompositeScheduleReq& request, + ocpp::messages::ocpp16::GetCompositeScheduleConf& response, + std::string& error, + std::string& message) override; - /** @copydoc bool IChargePointProxy::call(const ocpp::messages::GetDiagnosticsReq&, - * ocpp::messages::GetDiagnosticsConf&, + /** @copydoc bool IChargePointProxy::call(const ocpp::messages::ocpp16::GetConfigurationReq&, + * ocpp::messages::ocpp16::GetConfigurationConf&, * std::string&, * std::string&) */ - bool call(const ocpp::messages::GetDiagnosticsReq& request, - ocpp::messages::GetDiagnosticsConf& response, - std::string& error, - std::string& message) override; + bool call(const ocpp::messages::ocpp16::GetConfigurationReq& request, + ocpp::messages::ocpp16::GetConfigurationConf& response, + std::string& error, + std::string& message) override; - /** @copydoc bool IChargePointProxy::call(const ocpp::messages::GetLocalListVersionReq&, - * ocpp::messages::GetLocalListVersionConf&, + /** @copydoc bool IChargePointProxy::call(const ocpp::messages::ocpp16::GetDiagnosticsReq&, + * ocpp::messages::ocpp16::GetDiagnosticsConf&, * std::string&, * std::string&) */ - bool call(const ocpp::messages::GetLocalListVersionReq& request, - ocpp::messages::GetLocalListVersionConf& response, - std::string& error, - std::string& message) override; + bool call(const ocpp::messages::ocpp16::GetDiagnosticsReq& request, + ocpp::messages::ocpp16::GetDiagnosticsConf& response, + std::string& error, + std::string& message) override; - /** @copydoc bool IChargePointProxy::call(const ocpp::messages::RemoteStartTransactionReq&, - * ocpp::messages::RemoteStartTransactionConf&, + /** @copydoc bool IChargePointProxy::call(const ocpp::messages::ocpp16::GetLocalListVersionReq&, + * ocpp::messages::ocpp16::GetLocalListVersionConf&, * std::string&, * std::string&) */ - bool call(const ocpp::messages::RemoteStartTransactionReq& request, - ocpp::messages::RemoteStartTransactionConf& response, - std::string& error, - std::string& message) override; + bool call(const ocpp::messages::ocpp16::GetLocalListVersionReq& request, + ocpp::messages::ocpp16::GetLocalListVersionConf& response, + std::string& error, + std::string& message) override; - /** @copydoc bool IChargePointProxy::call(const ocpp::messages::RemoteStopTransactionReq&, - * ocpp::messages::RemoteStopTransactionConf&, + /** @copydoc bool IChargePointProxy::call(const ocpp::messages::ocpp16::RemoteStartTransactionReq&, + * ocpp::messages::ocpp16::RemoteStartTransactionConf&, * std::string&, * std::string&) */ - bool call(const ocpp::messages::RemoteStopTransactionReq& request, - ocpp::messages::RemoteStopTransactionConf& response, - std::string& error, - std::string& message) override; + bool call(const ocpp::messages::ocpp16::RemoteStartTransactionReq& request, + ocpp::messages::ocpp16::RemoteStartTransactionConf& response, + std::string& error, + std::string& message) override; - /** @copydoc bool IChargePointProxy::call(const ocpp::messages::ReserveNowReq&, - * ocpp::messages::ReserveNowConf&, + /** @copydoc bool IChargePointProxy::call(const ocpp::messages::ocpp16::RemoteStopTransactionReq&, + * ocpp::messages::ocpp16::RemoteStopTransactionConf&, * std::string&, * std::string&) */ - bool call(const ocpp::messages::ReserveNowReq& request, - ocpp::messages::ReserveNowConf& response, - std::string& error, - std::string& message) override; + bool call(const ocpp::messages::ocpp16::RemoteStopTransactionReq& request, + ocpp::messages::ocpp16::RemoteStopTransactionConf& response, + std::string& error, + std::string& message) override; - /** @copydoc bool IChargePointProxy::call(const ocpp::messages::ResetReq&, - * ocpp::messages::ResetConf&, + /** @copydoc bool IChargePointProxy::call(const ocpp::messages::ocpp16::ReserveNowReq&, + * ocpp::messages::ocpp16::ReserveNowConf&, * std::string&, * std::string&) */ - bool call(const ocpp::messages::ResetReq& request, - ocpp::messages::ResetConf& response, - std::string& error, - std::string& message) override; + bool call(const ocpp::messages::ocpp16::ReserveNowReq& request, + ocpp::messages::ocpp16::ReserveNowConf& response, + std::string& error, + std::string& message) override; - /** @copydoc bool IChargePointProxy::call(const ocpp::messages::SendLocalListReq&, - * ocpp::messages::SendLocalListConf&, + /** @copydoc bool IChargePointProxy::call(const ocpp::messages::ocpp16::ResetReq&, + * ocpp::messages::ocpp16::ResetConf&, * std::string&, * std::string&) */ - bool call(const ocpp::messages::SendLocalListReq& request, - ocpp::messages::SendLocalListConf& response, + bool call(const ocpp::messages::ocpp16::ResetReq& request, + ocpp::messages::ocpp16::ResetConf& response, std::string& error, std::string& message) override; - /** @copydoc bool IChargePointProxy::call(const ocpp::messages::SetChargingProfileReq&, - * ocpp::messages::SetChargingProfileConf&, + /** @copydoc bool IChargePointProxy::call(const ocpp::messages::ocpp16::SendLocalListReq&, + * ocpp::messages::ocpp16::SendLocalListConf&, * std::string&, * std::string&) */ - bool call(const ocpp::messages::SetChargingProfileReq& request, - ocpp::messages::SetChargingProfileConf& response, - std::string& error, - std::string& message) override; + bool call(const ocpp::messages::ocpp16::SendLocalListReq& request, + ocpp::messages::ocpp16::SendLocalListConf& response, + std::string& error, + std::string& message) override; - /** @copydoc bool IChargePointProxy::call(const ocpp::messages::TriggerMessageReq&, + /** @copydoc bool IChargePointProxy::call(const ocpp::messages::ocpp16::SetChargingProfileReq&, + * ocpp::messages::ocpp16::SetChargingProfileConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp16::SetChargingProfileReq& request, + ocpp::messages::ocpp16::SetChargingProfileConf& response, + std::string& error, + std::string& message) override; + + /** @copydoc bool IChargePointProxy::call(const ocpp::messages::ocpp16::TriggerMessageReq&, * opp::messages::TriggerMessageConf&, * std::string&, * std::string&) */ - bool call(const ocpp::messages::TriggerMessageReq& request, - ocpp::messages::TriggerMessageConf& response, - std::string& error, - std::string& message) override; + bool call(const ocpp::messages::ocpp16::TriggerMessageReq& request, + ocpp::messages::ocpp16::TriggerMessageConf& response, + std::string& error, + std::string& message) override; - /** @copydoc bool IChargePointProxy::call(const ocpp::messages::UnlockConnectorReq&, - * ocpp::messages::UnlockConnectorConf&, + /** @copydoc bool IChargePointProxy::call(const ocpp::messages::ocpp16::UnlockConnectorReq&, + * ocpp::messages::ocpp16::UnlockConnectorConf&, * std::string&, * std::string&) */ - bool call(const ocpp::messages::UnlockConnectorReq& request, - ocpp::messages::UnlockConnectorConf& response, - std::string& error, - std::string& message) override; + bool call(const ocpp::messages::ocpp16::UnlockConnectorReq& request, + ocpp::messages::ocpp16::UnlockConnectorConf& response, + std::string& error, + std::string& message) override; - /** @copydoc bool IChargePointProxy::call(const ocpp::messages::UpdateFirmwareReq&, - * ocpp::messages::UpdateFirmwareConf&, + /** @copydoc bool IChargePointProxy::call(const ocpp::messages::ocpp16::UpdateFirmwareReq&, + * ocpp::messages::ocpp16::UpdateFirmwareConf&, * std::string&, * std::string&) */ - bool call(const ocpp::messages::UpdateFirmwareReq& request, - ocpp::messages::UpdateFirmwareConf& response, - std::string& error, - std::string& message) override; + bool call(const ocpp::messages::ocpp16::UpdateFirmwareReq& request, + ocpp::messages::ocpp16::UpdateFirmwareConf& response, + std::string& error, + std::string& message) override; // Security extensions - /** @copydoc bool IChargePointProxy::call(const ocpp::messages::CertificateSignedReq&, - * ocpp::messages::CertificateSignedConf&, + /** @copydoc bool IChargePointProxy::call(const ocpp::messages::ocpp16::CertificateSignedReq&, + * ocpp::messages::ocpp16::CertificateSignedConf&, * std::string&, * std::string&) */ - bool call(const ocpp::messages::CertificateSignedReq& request, - ocpp::messages::CertificateSignedConf& response, - std::string& error, - std::string& message) override; + bool call(const ocpp::messages::ocpp16::CertificateSignedReq& request, + ocpp::messages::ocpp16::CertificateSignedConf& response, + std::string& error, + std::string& message) override; - /** @copydoc bool IChargePointProxy::call(const ocpp::messages::DeleteCertificateReq&, - * ocpp::messages::DeleteCertificateConf&, + /** @copydoc bool IChargePointProxy::call(const ocpp::messages::ocpp16::DeleteCertificateReq&, + * ocpp::messages::ocpp16::DeleteCertificateConf&, * std::string&, * std::string&) */ - bool call(const ocpp::messages::DeleteCertificateReq& request, - ocpp::messages::DeleteCertificateConf& response, - std::string& error, - std::string& message) override; + bool call(const ocpp::messages::ocpp16::DeleteCertificateReq& request, + ocpp::messages::ocpp16::DeleteCertificateConf& response, + std::string& error, + std::string& message) override; - /** @copydoc bool IChargePointProxy::call(const ocpp::messages::ExtendedTriggerMessageReq&, - * ocpp::messages::ExtendedTriggerMessageConf&, + /** @copydoc bool IChargePointProxy::call(const ocpp::messages::ocpp16::ExtendedTriggerMessageReq&, + * ocpp::messages::ocpp16::ExtendedTriggerMessageConf&, * std::string&, * std::string&) */ - bool call(const ocpp::messages::ExtendedTriggerMessageReq& request, - ocpp::messages::ExtendedTriggerMessageConf& response, - std::string& error, - std::string& message) override; + bool call(const ocpp::messages::ocpp16::ExtendedTriggerMessageReq& request, + ocpp::messages::ocpp16::ExtendedTriggerMessageConf& response, + std::string& error, + std::string& message) override; - /** @copydoc bool IChargePointProxy::call(const ocpp::messages::GetInstalledCertificateIdsReq&, - * ocpp::messages::GetInstalledCertificateIdsConf&, + /** @copydoc bool IChargePointProxy::call(const ocpp::messages::ocpp16::GetInstalledCertificateIdsReq&, + * ocpp::messages::ocpp16::GetInstalledCertificateIdsConf&, * std::string&, * std::string&) */ - bool call(const ocpp::messages::GetInstalledCertificateIdsReq& request, - ocpp::messages::GetInstalledCertificateIdsConf& response, - std::string& error, - std::string& message) override; + bool call(const ocpp::messages::ocpp16::GetInstalledCertificateIdsReq& request, + ocpp::messages::ocpp16::GetInstalledCertificateIdsConf& response, + std::string& error, + std::string& message) override; - /** @copydoc bool IChargePointProxy::call(const ocpp::messages::GetLogReq&, - * ocpp::messages::GetLogConf&, + /** @copydoc bool IChargePointProxy::call(const ocpp::messages::ocpp16::GetLogReq&, + * ocpp::messages::ocpp16::GetLogConf&, * std::string&, * std::string&) */ - bool call(const ocpp::messages::GetLogReq& request, - ocpp::messages::GetLogConf& response, - std::string& error, - std::string& message) override; + bool call(const ocpp::messages::ocpp16::GetLogReq& request, + ocpp::messages::ocpp16::GetLogConf& response, + std::string& error, + std::string& message) override; - /** @copydoc bool IChargePointProxy::call(const ocpp::messages::InstallCertificateReq&, - * ocpp::messages::InstallCertificateConf&, + /** @copydoc bool IChargePointProxy::call(const ocpp::messages::ocpp16::InstallCertificateReq&, + * ocpp::messages::ocpp16::InstallCertificateConf&, * std::string&, * std::string&) */ - bool call(const ocpp::messages::InstallCertificateReq& request, - ocpp::messages::InstallCertificateConf& response, - std::string& error, - std::string& message) override; + bool call(const ocpp::messages::ocpp16::InstallCertificateReq& request, + ocpp::messages::ocpp16::InstallCertificateConf& response, + std::string& error, + std::string& message) override; - /** @copydoc bool IChargePointProxy::call(const ocpp::messages::SignedUpdateFirmwareReq&, - * ocpp::messages::SignedUpdateFirmwareConf&, + /** @copydoc bool IChargePointProxy::call(const ocpp::messages::ocpp16::SignedUpdateFirmwareReq&, + * ocpp::messages::ocpp16::SignedUpdateFirmwareConf&, * std::string&, * std::string&) */ - bool call(const ocpp::messages::SignedUpdateFirmwareReq& request, - ocpp::messages::SignedUpdateFirmwareConf& response, - std::string& error, - std::string& message) override; + bool call(const ocpp::messages::ocpp16::SignedUpdateFirmwareReq& request, + ocpp::messages::ocpp16::SignedUpdateFirmwareConf& response, + std::string& error, + std::string& message) override; /** @copydoc bool IChargePointProxy::registerHandler( - std::function) */ + std::function) */ bool registerHandler( - std::function handler) - override; + std::function + handler) override; /** @copydoc bool IChargePointProxy::registerHandler( - std::function) */ + std::function) */ bool registerHandler( - std::function + std::function handler) override; /** @copydoc bool IChargePointProxy::registerHandler( - std::function) */ + std::function) */ bool registerHandler( - std::function handler) + std::function handler) override; /** @copydoc bool IChargePointProxy::registerHandler( - std::function) */ - bool registerHandler(std::function) */ + bool registerHandler(std::function handler) override; /** @copydoc bool IChargePointProxy::registerHandler( - std::function) */ - bool registerHandler(std::function) */ + bool registerHandler(std::function handler) override; /** @copydoc bool IChargePointProxy::registerHandler( - std::function) */ + std::function) */ bool registerHandler( - std::function handler) - override; + std::function + handler) override; /** @copydoc bool IChargePointProxy::registerHandler( - std::function) */ + std::function) */ bool registerHandler( - std::function handler) + std::function handler) override; /** @copydoc bool IChargePointProxy::registerHandler( - std::function) */ + std::function) */ bool registerHandler( - std::function + std::function handler) override; /** @copydoc bool IChargePointProxy::registerHandler( - std::function) */ - bool registerHandler( - std::function handler) - override; + std::function) */ + bool registerHandler(std::function handler) override; /** @copydoc bool IChargePointProxy::registerHandler( - std::function) */ + std::function) */ bool registerHandler( - std::function + std::function handler) override; /** @copydoc bool IChargePointProxy::registerHandler( - std::function) */ - bool registerHandler( - std::function< - bool(const ocpp::messages::LogStatusNotificationReq&, ocpp::messages::LogStatusNotificationConf&, std::string&, std::string&)> - handler) override; + std::function) */ + bool registerHandler(std::function handler) override; /** @copydoc bool IChargePointProxy::registerHandler( - std::function) */ - bool registerHandler(std::function) */ + bool registerHandler(std::function handler) override; /** @copydoc bool IChargePointProxy::registerHandler( - std::function) */ + std::function) */ bool registerHandler( - std::function + std::function handler) override; /** @copydoc bool IChargePointProxy::registerHandler( - std::function) */ - bool registerHandler(std::function) */ + bool registerHandler(std::function handler) override; @@ -448,7 +454,7 @@ class ChargePointProxy : public IChargePointProxy, public ocpp::rpc::IRpc::IList /** @brief RPC connection */ std::shared_ptr m_rpc; /** @brief Messages converter */ - ocpp::messages::MessagesConverter& m_messages_converter; + ocpp::messages::ocpp16::MessagesConverter& m_messages_converter; /** @brief Message dispatcher */ ocpp::messages::MessageDispatcher m_msg_dispatcher; /** @brief Message sender */ @@ -499,8 +505,8 @@ class ChargePointProxy : public IChargePointProxy, public ocpp::rpc::IRpc::IList bool registerHandler(const std::string& action, std::function handler) { - UserMessageHandler* msg_handler = - new UserMessageHandler(action, m_messages_converter, handler); + ocpp::messages::UserMessageHandler* msg_handler = + new ocpp::messages::UserMessageHandler(action, m_messages_converter, handler); m_user_handlers.push_back(std::shared_ptr(msg_handler)); return m_msg_dispatcher.registerHandler(action, *msg_handler, true); } diff --git a/src/localcontroller/config/InternalConfigKeys.h b/src/ocpp16/localcontroller/config/InternalConfigKeys.h similarity index 100% rename from src/localcontroller/config/InternalConfigKeys.h rename to src/ocpp16/localcontroller/config/InternalConfigKeys.h diff --git a/src/localcontroller/interface/ICentralSystemProxy.h b/src/ocpp16/localcontroller/interface/ICentralSystemProxy.h similarity index 63% rename from src/localcontroller/interface/ICentralSystemProxy.h rename to src/ocpp16/localcontroller/interface/ICentralSystemProxy.h index ce2c8e26..0b9f8ad7 100644 --- a/src/localcontroller/interface/ICentralSystemProxy.h +++ b/src/ocpp16/localcontroller/interface/ICentralSystemProxy.h @@ -125,10 +125,10 @@ class ICentralSystemProxy * @param message Error message (Empty if not a CallError) * @return true if the request has been sent and a response has been received, false otherwise */ - virtual bool call(const ocpp::messages::BootNotificationReq& request, - ocpp::messages::BootNotificationConf& response, - std::string& error, - std::string& message) = 0; + virtual bool call(const ocpp::messages::ocpp16::BootNotificationReq& request, + ocpp::messages::ocpp16::BootNotificationConf& response, + std::string& error, + std::string& message) = 0; /** * @brief Notify a new status for a connector @@ -138,10 +138,10 @@ class ICentralSystemProxy * @param message Error message (Empty if not a CallError) * @return true if the request has been sent and a response has been received, false otherwise */ - virtual bool call(const ocpp::messages::StatusNotificationReq& request, - ocpp::messages::StatusNotificationConf& response, - std::string& error, - std::string& message) = 0; + virtual bool call(const ocpp::messages::ocpp16::StatusNotificationReq& request, + ocpp::messages::ocpp16::StatusNotificationConf& response, + std::string& error, + std::string& message) = 0; /** * @brief Ask for authorization of an operation on a connector @@ -151,10 +151,10 @@ class ICentralSystemProxy * @param message Error message (Empty if not a CallError) * @return true if the request has been sent and a response has been received, false otherwise */ - virtual bool call(const ocpp::messages::AuthorizeReq& request, - ocpp::messages::AuthorizeConf& response, - std::string& error, - std::string& message) = 0; + virtual bool call(const ocpp::messages::ocpp16::AuthorizeReq& request, + ocpp::messages::ocpp16::AuthorizeConf& response, + std::string& error, + std::string& message) = 0; /** * @brief Start a transaction @@ -164,10 +164,10 @@ class ICentralSystemProxy * @param message Error message (Empty if not a CallError) * @return true if the request has been sent and a response has been received, false otherwise */ - virtual bool call(const ocpp::messages::StartTransactionReq& request, - ocpp::messages::StartTransactionConf& response, - std::string& error, - std::string& message) = 0; + virtual bool call(const ocpp::messages::ocpp16::StartTransactionReq& request, + ocpp::messages::ocpp16::StartTransactionConf& response, + std::string& error, + std::string& message) = 0; /** * @brief Stop a transaction @@ -177,10 +177,10 @@ class ICentralSystemProxy * @param message Error message (Empty if not a CallError) * @return true if the request has been sent and a response has been received, false otherwise */ - virtual bool call(const ocpp::messages::StopTransactionReq& request, - ocpp::messages::StopTransactionConf& response, - std::string& error, - std::string& message) = 0; + virtual bool call(const ocpp::messages::ocpp16::StopTransactionReq& request, + ocpp::messages::ocpp16::StopTransactionConf& response, + std::string& error, + std::string& message) = 0; /** * @brief Send a data transfer request @@ -190,10 +190,10 @@ class ICentralSystemProxy * @param message Error message (Empty if not a CallError) * @return true if the request has been sent and a response has been received, false otherwise */ - virtual bool call(const ocpp::messages::DataTransferReq& request, - ocpp::messages::DataTransferConf& response, - std::string& error, - std::string& message) = 0; + virtual bool call(const ocpp::messages::ocpp16::DataTransferReq& request, + ocpp::messages::ocpp16::DataTransferConf& response, + std::string& error, + std::string& message) = 0; /** * @brief Send meter values to Central System for a given connector @@ -203,10 +203,10 @@ class ICentralSystemProxy * @param message Error message (Empty if not a CallError) * @return true if the request has been sent and a response has been received, false otherwise */ - virtual bool call(const ocpp::messages::MeterValuesReq& request, - ocpp::messages::MeterValuesConf& response, - std::string& error, - std::string& message) = 0; + virtual bool call(const ocpp::messages::ocpp16::MeterValuesReq& request, + ocpp::messages::ocpp16::MeterValuesConf& response, + std::string& error, + std::string& message) = 0; /** * @brief Notify the status of a get diagnostics operation @@ -216,10 +216,10 @@ class ICentralSystemProxy * @param message Error message (Empty if not a CallError) * @return true if the request has been sent and a response has been received, false otherwise */ - virtual bool call(const ocpp::messages::DiagnosticsStatusNotificationReq& request, - ocpp::messages::DiagnosticsStatusNotificationConf& response, - std::string& error, - std::string& message) = 0; + virtual bool call(const ocpp::messages::ocpp16::DiagnosticsStatusNotificationReq& request, + ocpp::messages::ocpp16::DiagnosticsStatusNotificationConf& response, + std::string& error, + std::string& message) = 0; /** * @brief Notify the status of a firmware update operation @@ -229,10 +229,10 @@ class ICentralSystemProxy * @param message Error message (Empty if not a CallError) * @return true if the request has been sent and a response has been received, false otherwise */ - virtual bool call(const ocpp::messages::FirmwareStatusNotificationReq& request, - ocpp::messages::FirmwareStatusNotificationConf& response, - std::string& error, - std::string& message) = 0; + virtual bool call(const ocpp::messages::ocpp16::FirmwareStatusNotificationReq& request, + ocpp::messages::ocpp16::FirmwareStatusNotificationConf& response, + std::string& error, + std::string& message) = 0; /** * @brief Send a heartbeat @@ -242,10 +242,10 @@ class ICentralSystemProxy * @param message Error message (Empty if not a CallError) * @return true if the request has been sent and a response has been received, false otherwise */ - virtual bool call(const ocpp::messages::HeartbeatReq& request, - ocpp::messages::HeartbeatConf& response, - std::string& error, - std::string& message) = 0; + virtual bool call(const ocpp::messages::ocpp16::HeartbeatReq& request, + ocpp::messages::ocpp16::HeartbeatConf& response, + std::string& error, + std::string& message) = 0; // Security extensions @@ -257,10 +257,10 @@ class ICentralSystemProxy * @param message Error message (Empty if not a CallError) * @return true if the request has been sent and a response has been received, false otherwise */ - virtual bool call(const ocpp::messages::SecurityEventNotificationReq& request, - ocpp::messages::SecurityEventNotificationConf& response, - std::string& error, - std::string& message) = 0; + virtual bool call(const ocpp::messages::ocpp16::SecurityEventNotificationReq& request, + ocpp::messages::ocpp16::SecurityEventNotificationConf& response, + std::string& error, + std::string& message) = 0; /** * @brief Send a CSR request to sign a certificate @@ -270,10 +270,10 @@ class ICentralSystemProxy * @param message Error message (Empty if not a CallError) * @return true if the request has been sent and a response has been received, false otherwise */ - virtual bool call(const ocpp::messages::SignCertificateReq& request, - ocpp::messages::SignCertificateConf& response, - std::string& error, - std::string& message) = 0; + virtual bool call(const ocpp::messages::ocpp16::SignCertificateReq& request, + ocpp::messages::ocpp16::SignCertificateConf& response, + std::string& error, + std::string& message) = 0; /** * @brief Notify the status of a get logs operation @@ -283,10 +283,10 @@ class ICentralSystemProxy * @param message Error message (Empty if not a CallError) * @return true if the request has been sent and a response has been received, false otherwise */ - virtual bool call(const ocpp::messages::LogStatusNotificationReq& request, - ocpp::messages::LogStatusNotificationConf& response, - std::string& error, - std::string& message) = 0; + virtual bool call(const ocpp::messages::ocpp16::LogStatusNotificationReq& request, + ocpp::messages::ocpp16::LogStatusNotificationConf& response, + std::string& error, + std::string& message) = 0; /** * @brief Notify the status of a signed firmware update operation @@ -296,39 +296,40 @@ class ICentralSystemProxy * @param message Error message (Empty if not a CallError) * @return true if the request has been sent and a response has been received, false otherwise */ - virtual bool call(const ocpp::messages::SignedFirmwareStatusNotificationReq& request, - ocpp::messages::SignedFirmwareStatusNotificationConf& response, - std::string& error, - std::string& message) = 0; + virtual bool call(const ocpp::messages::ocpp16::SignedFirmwareStatusNotificationReq& request, + ocpp::messages::ocpp16::SignedFirmwareStatusNotificationConf& response, + std::string& error, + std::string& message) = 0; /** * @brief Register a handler for the CancelReservation request * @param handler Handler function * @return true if the handler has been registered, false otherwise */ - virtual bool registerHandler( - std::function - handler) = 0; + virtual bool registerHandler(std::function handler) = 0; /** * @brief Register a handler for the ChangeAvailability request * @param handler Handler function * @return true if the handler has been registered, false otherwise */ - virtual bool registerHandler( - std::function< - bool(const ocpp::messages::ChangeAvailabilityReq&, ocpp::messages::ChangeAvailabilityConf&, std::string&, std::string&)> - handler) = 0; + virtual bool registerHandler(std::function handler) = 0; /** * @brief Register a handler for the ChangeConfiguration request * @param handler Handler function * @return true if the handler has been registered, false otherwise */ - virtual bool registerHandler( - std::function< - bool(const ocpp::messages::ChangeConfigurationReq&, ocpp::messages::ChangeConfigurationConf&, std::string&, std::string&)> - handler) = 0; + virtual bool registerHandler(std::function handler) = 0; /** * @brief Register a handler for the ClearCache request @@ -336,17 +337,19 @@ class ICentralSystemProxy * @return true if the handler has been registered, false otherwise */ virtual bool registerHandler( - std::function handler) = 0; + std::function< + bool(const ocpp::messages::ocpp16::ClearCacheReq&, ocpp::messages::ocpp16::ClearCacheConf&, std::string&, std::string&)> + handler) = 0; /** * @brief Register a handler for the ClearChargingProfile request * @param handler Handler function * @return true if the handler has been registered, false otherwise */ - virtual bool registerHandler( - std::function< - bool(const ocpp::messages::ClearChargingProfileReq&, ocpp::messages::ClearChargingProfileConf&, std::string&, std::string&)> - handler) = 0; + virtual bool registerHandler(std::function handler) = 0; /** * @brief Register a handler for the DataTransfer request @@ -354,7 +357,8 @@ class ICentralSystemProxy * @return true if the handler has been registered, false otherwise */ virtual bool registerHandler( - std::function + std::function< + bool(const ocpp::messages::ocpp16::DataTransferReq&, ocpp::messages::ocpp16::DataTransferConf&, std::string&, std::string&)> handler) = 0; /** @@ -362,10 +366,10 @@ class ICentralSystemProxy * @param handler Handler function * @return true if the handler has been registered, false otherwise */ - virtual bool registerHandler( - std::function< - bool(const ocpp::messages::GetCompositeScheduleReq&, ocpp::messages::GetCompositeScheduleConf&, std::string&, std::string&)> - handler) = 0; + virtual bool registerHandler(std::function handler) = 0; /** * @brief Register a handler for the GetConfiguration request @@ -373,7 +377,8 @@ class ICentralSystemProxy * @return true if the handler has been registered, false otherwise */ virtual bool registerHandler( - std::function + std::function handler) = 0; /** @@ -382,7 +387,8 @@ class ICentralSystemProxy * @return true if the handler has been registered, false otherwise */ virtual bool registerHandler( - std::function + std::function< + bool(const ocpp::messages::ocpp16::GetDiagnosticsReq&, ocpp::messages::ocpp16::GetDiagnosticsConf&, std::string&, std::string&)> handler) = 0; /** @@ -390,30 +396,30 @@ class ICentralSystemProxy * @param handler Handler function * @return true if the handler has been registered, false otherwise */ - virtual bool registerHandler( - std::function< - bool(const ocpp::messages::GetLocalListVersionReq&, ocpp::messages::GetLocalListVersionConf&, std::string&, std::string&)> - handler) = 0; + virtual bool registerHandler(std::function handler) = 0; /** * @brief Register a handler for the RemoteStartTransaction request * @param handler Handler function * @return true if the handler has been registered, false otherwise */ - virtual bool registerHandler( - std::function< - bool(const ocpp::messages::RemoteStartTransactionReq&, ocpp::messages::RemoteStartTransactionConf&, std::string&, std::string&)> - handler) = 0; + virtual bool registerHandler(std::function handler) = 0; /** * @brief Register a handler for the RemoteStopTransaction request * @param handler Handler function * @return true if the handler has been registered, false otherwise */ - virtual bool registerHandler( - std::function< - bool(const ocpp::messages::RemoteStopTransactionReq&, ocpp::messages::RemoteStopTransactionConf&, std::string&, std::string&)> - handler) = 0; + virtual bool registerHandler(std::function handler) = 0; /** * @brief Register a handler for the ReserveNow request @@ -421,7 +427,9 @@ class ICentralSystemProxy * @return true if the handler has been registered, false otherwise */ virtual bool registerHandler( - std::function handler) = 0; + std::function< + bool(const ocpp::messages::ocpp16::ReserveNowReq&, ocpp::messages::ocpp16::ReserveNowConf&, std::string&, std::string&)> + handler) = 0; /** * @brief Register a handler for the Reset request @@ -429,7 +437,8 @@ class ICentralSystemProxy * @return true if the handler has been registered, false otherwise */ virtual bool registerHandler( - std::function handler) = 0; + std::function + handler) = 0; /** * @brief Register a handler for the SendLocalList request @@ -437,7 +446,8 @@ class ICentralSystemProxy * @return true if the handler has been registered, false otherwise */ virtual bool registerHandler( - std::function + std::function< + bool(const ocpp::messages::ocpp16::SendLocalListReq&, ocpp::messages::ocpp16::SendLocalListConf&, std::string&, std::string&)> handler) = 0; /** @@ -445,10 +455,10 @@ class ICentralSystemProxy * @param handler Handler function * @return true if the handler has been registered, false otherwise */ - virtual bool registerHandler( - std::function< - bool(const ocpp::messages::SetChargingProfileReq&, ocpp::messages::SetChargingProfileConf&, std::string&, std::string&)> - handler) = 0; + virtual bool registerHandler(std::function handler) = 0; /** * @brief Register a handler for the TriggerMessage request @@ -456,7 +466,8 @@ class ICentralSystemProxy * @return true if the handler has been registered, false otherwise */ virtual bool registerHandler( - std::function + std::function< + bool(const ocpp::messages::ocpp16::TriggerMessageReq&, ocpp::messages::ocpp16::TriggerMessageConf&, std::string&, std::string&)> handler) = 0; /** @@ -465,7 +476,8 @@ class ICentralSystemProxy * @return true if the handler has been registered, false otherwise */ virtual bool registerHandler( - std::function + std::function handler) = 0; /** @@ -474,7 +486,8 @@ class ICentralSystemProxy * @return true if the handler has been registered, false otherwise */ virtual bool registerHandler( - std::function + std::function< + bool(const ocpp::messages::ocpp16::UpdateFirmwareReq&, ocpp::messages::ocpp16::UpdateFirmwareConf&, std::string&, std::string&)> handler) = 0; /** @@ -482,36 +495,38 @@ class ICentralSystemProxy * @param handler Handler function * @return true if the handler has been registered, false otherwise */ - virtual bool registerHandler( - std::function - handler) = 0; + virtual bool registerHandler(std::function handler) = 0; /** * @brief Register a handler for the DeleteCertificate request * @param handler Handler function * @return true if the handler has been registered, false otherwise */ - virtual bool registerHandler( - std::function - handler) = 0; + virtual bool registerHandler(std::function handler) = 0; /** * @brief Register a handler for the ExtendedTriggerMessage request * @param handler Handler function * @return true if the handler has been registered, false otherwise */ - virtual bool registerHandler( - std::function< - bool(const ocpp::messages::ExtendedTriggerMessageReq&, ocpp::messages::ExtendedTriggerMessageConf&, std::string&, std::string&)> - handler) = 0; + virtual bool registerHandler(std::function handler) = 0; /** * @brief Register a handler for the GetInstalledCertificateIds request * @param handler Handler function * @return true if the handler has been registered, false otherwise */ - virtual bool registerHandler(std::function handler) = 0; @@ -521,27 +536,28 @@ class ICentralSystemProxy * @return true if the handler has been registered, false otherwise */ virtual bool registerHandler( - std::function handler) = 0; + std::function + handler) = 0; /** * @brief Register a handler for the InstallCertificate request * @param handler Handler function * @return true if the handler has been registered, false otherwise */ - virtual bool registerHandler( - std::function< - bool(const ocpp::messages::InstallCertificateReq&, ocpp::messages::InstallCertificateConf&, std::string&, std::string&)> - handler) = 0; + virtual bool registerHandler(std::function handler) = 0; /** * @brief Register a handler for the SignedUpdateFirmware request * @param handler Handler function * @return true if the handler has been registered, false otherwise */ - virtual bool registerHandler( - std::function< - bool(const ocpp::messages::SignedUpdateFirmwareReq&, ocpp::messages::SignedUpdateFirmwareConf&, std::string&, std::string&)> - handler) = 0; + virtual bool registerHandler(std::function handler) = 0; }; } // namespace localcontroller diff --git a/src/localcontroller/interface/IChargePointProxy.h b/src/ocpp16/localcontroller/interface/IChargePointProxy.h similarity index 71% rename from src/localcontroller/interface/IChargePointProxy.h rename to src/ocpp16/localcontroller/interface/IChargePointProxy.h index 6ca8c4d4..e7c35334 100644 --- a/src/localcontroller/interface/IChargePointProxy.h +++ b/src/ocpp16/localcontroller/interface/IChargePointProxy.h @@ -120,10 +120,10 @@ class IChargePointProxy * @param message Error message (Empty if not a CallError) * @return true if the request has been sent and a response has been received, false otherwise */ - virtual bool call(const ocpp::messages::CancelReservationReq& request, - ocpp::messages::CancelReservationConf& response, - std::string& error, - std::string& message) = 0; + virtual bool call(const ocpp::messages::ocpp16::CancelReservationReq& request, + ocpp::messages::ocpp16::CancelReservationConf& response, + std::string& error, + std::string& message) = 0; /** * @brief Change the availability state of a connector @@ -133,10 +133,10 @@ class IChargePointProxy * @param message Error message (Empty if not a CallError) * @return true if the request has been sent and a response has been received, false otherwise */ - virtual bool call(const ocpp::messages::ChangeAvailabilityReq& request, - ocpp::messages::ChangeAvailabilityConf& response, - std::string& error, - std::string& message) = 0; + virtual bool call(const ocpp::messages::ocpp16::ChangeAvailabilityReq& request, + ocpp::messages::ocpp16::ChangeAvailabilityConf& response, + std::string& error, + std::string& message) = 0; /** * @brief Change the value of a configuration key @@ -146,10 +146,10 @@ class IChargePointProxy * @param message Error message (Empty if not a CallError) * @return true if the request has been sent and a response has been received, false otherwise */ - virtual bool call(const ocpp::messages::ChangeConfigurationReq& request, - ocpp::messages::ChangeConfigurationConf& response, - std::string& error, - std::string& message) = 0; + virtual bool call(const ocpp::messages::ocpp16::ChangeConfigurationReq& request, + ocpp::messages::ocpp16::ChangeConfigurationConf& response, + std::string& error, + std::string& message) = 0; /** * @brief Clear the authentication cache @@ -159,10 +159,10 @@ class IChargePointProxy * @param message Error message (Empty if not a CallError) * @return true if the request has been sent and a response has been received, false otherwise */ - virtual bool call(const ocpp::messages::ClearCacheReq& request, - ocpp::messages::ClearCacheConf& response, - std::string& error, - std::string& message) = 0; + virtual bool call(const ocpp::messages::ocpp16::ClearCacheReq& request, + ocpp::messages::ocpp16::ClearCacheConf& response, + std::string& error, + std::string& message) = 0; /** * @brief Clear 1 or more charging profiles @@ -172,10 +172,10 @@ class IChargePointProxy * @param message Error message (Empty if not a CallError) * @return true if the request has been sent and a response has been received, false otherwise */ - virtual bool call(const ocpp::messages::ClearChargingProfileReq& request, - ocpp::messages::ClearChargingProfileConf& response, - std::string& error, - std::string& message) = 0; + virtual bool call(const ocpp::messages::ocpp16::ClearChargingProfileReq& request, + ocpp::messages::ocpp16::ClearChargingProfileConf& response, + std::string& error, + std::string& message) = 0; /** * @brief Send a data transfer request @@ -185,10 +185,10 @@ class IChargePointProxy * @param message Error message (Empty if not a CallError) * @return true if the request has been sent and a response has been received, false otherwise */ - virtual bool call(const ocpp::messages::DataTransferReq& request, - ocpp::messages::DataTransferConf& response, - std::string& error, - std::string& message) = 0; + virtual bool call(const ocpp::messages::ocpp16::DataTransferReq& request, + ocpp::messages::ocpp16::DataTransferConf& response, + std::string& error, + std::string& message) = 0; /** * @brief Get a smart charging composite schedule @@ -198,10 +198,10 @@ class IChargePointProxy * @param message Error message (Empty if not a CallError) * @return true if the request has been sent and a response has been received, false otherwise */ - virtual bool call(const ocpp::messages::GetCompositeScheduleReq& request, - ocpp::messages::GetCompositeScheduleConf& response, - std::string& error, - std::string& message) = 0; + virtual bool call(const ocpp::messages::ocpp16::GetCompositeScheduleReq& request, + ocpp::messages::ocpp16::GetCompositeScheduleConf& response, + std::string& error, + std::string& message) = 0; /** * @brief Get the value of the configuration keys @@ -211,10 +211,10 @@ class IChargePointProxy * @param message Error message (Empty if not a CallError) * @return true if the request has been sent and a response has been received, false otherwise */ - virtual bool call(const ocpp::messages::GetConfigurationReq& request, - ocpp::messages::GetConfigurationConf& response, - std::string& error, - std::string& message) = 0; + virtual bool call(const ocpp::messages::ocpp16::GetConfigurationReq& request, + ocpp::messages::ocpp16::GetConfigurationConf& response, + std::string& error, + std::string& message) = 0; /** * @brief Get the diagnostic file @@ -224,10 +224,10 @@ class IChargePointProxy * @param message Error message (Empty if not a CallError) * @return true if the request has been sent and a response has been received, false otherwise */ - virtual bool call(const ocpp::messages::GetDiagnosticsReq& request, - ocpp::messages::GetDiagnosticsConf& response, - std::string& error, - std::string& message) = 0; + virtual bool call(const ocpp::messages::ocpp16::GetDiagnosticsReq& request, + ocpp::messages::ocpp16::GetDiagnosticsConf& response, + std::string& error, + std::string& message) = 0; /** * @brief Get the version of the local authorization list @@ -237,10 +237,10 @@ class IChargePointProxy * @param message Error message (Empty if not a CallError) * @return true if the request has been sent and a response has been received, false otherwise */ - virtual bool call(const ocpp::messages::GetLocalListVersionReq& request, - ocpp::messages::GetLocalListVersionConf& response, - std::string& error, - std::string& message) = 0; + virtual bool call(const ocpp::messages::ocpp16::GetLocalListVersionReq& request, + ocpp::messages::ocpp16::GetLocalListVersionConf& response, + std::string& error, + std::string& message) = 0; /** * @brief Send a remote start transaction request @@ -250,10 +250,10 @@ class IChargePointProxy * @param message Error message (Empty if not a CallError) * @return true if the request has been sent and a response has been received, false otherwise */ - virtual bool call(const ocpp::messages::RemoteStartTransactionReq& request, - ocpp::messages::RemoteStartTransactionConf& response, - std::string& error, - std::string& message) = 0; + virtual bool call(const ocpp::messages::ocpp16::RemoteStartTransactionReq& request, + ocpp::messages::ocpp16::RemoteStartTransactionConf& response, + std::string& error, + std::string& message) = 0; /** * @brief Send a remote stop transaction request @@ -263,10 +263,10 @@ class IChargePointProxy * @param message Error message (Empty if not a CallError) * @return true if the request has been sent and a response has been received, false otherwise */ - virtual bool call(const ocpp::messages::RemoteStopTransactionReq& request, - ocpp::messages::RemoteStopTransactionConf& response, - std::string& error, - std::string& message) = 0; + virtual bool call(const ocpp::messages::ocpp16::RemoteStopTransactionReq& request, + ocpp::messages::ocpp16::RemoteStopTransactionConf& response, + std::string& error, + std::string& message) = 0; /** * @brief Reserve a connector @@ -276,10 +276,10 @@ class IChargePointProxy * @param message Error message (Empty if not a CallError) * @return true if the request has been sent and a response has been received, false otherwise */ - virtual bool call(const ocpp::messages::ReserveNowReq& request, - ocpp::messages::ReserveNowConf& response, - std::string& error, - std::string& message) = 0; + virtual bool call(const ocpp::messages::ocpp16::ReserveNowReq& request, + ocpp::messages::ocpp16::ReserveNowConf& response, + std::string& error, + std::string& message) = 0; /** * @brief Reset the charge point @@ -289,10 +289,10 @@ class IChargePointProxy * @param message Error message (Empty if not a CallError) * @return true if the request has been sent and a response has been received, false otherwise */ - virtual bool call(const ocpp::messages::ResetReq& request, - ocpp::messages::ResetConf& response, - std::string& error, - std::string& message) = 0; + virtual bool call(const ocpp::messages::ocpp16::ResetReq& request, + ocpp::messages::ocpp16::ResetConf& response, + std::string& error, + std::string& message) = 0; /** * @brief Send or upgrade a local authorization list @@ -302,10 +302,10 @@ class IChargePointProxy * @param message Error message (Empty if not a CallError) * @return true if the request has been sent and a response has been received, false otherwise */ - virtual bool call(const ocpp::messages::SendLocalListReq& request, - ocpp::messages::SendLocalListConf& response, - std::string& error, - std::string& message) = 0; + virtual bool call(const ocpp::messages::ocpp16::SendLocalListReq& request, + ocpp::messages::ocpp16::SendLocalListConf& response, + std::string& error, + std::string& message) = 0; /** * @brief Set a charging profile in the charge point @@ -315,10 +315,10 @@ class IChargePointProxy * @param message Error message (Empty if not a CallError) * @return true if the request has been sent and a response has been received, false otherwise */ - virtual bool call(const ocpp::messages::SetChargingProfileReq& request, - ocpp::messages::SetChargingProfileConf& response, - std::string& error, - std::string& message) = 0; + virtual bool call(const ocpp::messages::ocpp16::SetChargingProfileReq& request, + ocpp::messages::ocpp16::SetChargingProfileConf& response, + std::string& error, + std::string& message) = 0; /** * @brief Request the send of a specific message @@ -328,10 +328,10 @@ class IChargePointProxy * @param message Error message (Empty if not a CallError) * @return true if the request has been sent and a response has been received, false otherwise */ - virtual bool call(const ocpp::messages::TriggerMessageReq& request, - ocpp::messages::TriggerMessageConf& response, - std::string& error, - std::string& message) = 0; + virtual bool call(const ocpp::messages::ocpp16::TriggerMessageReq& request, + ocpp::messages::ocpp16::TriggerMessageConf& response, + std::string& error, + std::string& message) = 0; /** * @brief Unlock a connector @@ -341,10 +341,10 @@ class IChargePointProxy * @param message Error message (Empty if not a CallError) * @return true if the request has been sent and a response has been received, false otherwise */ - virtual bool call(const ocpp::messages::UnlockConnectorReq& request, - ocpp::messages::UnlockConnectorConf& response, - std::string& error, - std::string& message) = 0; + virtual bool call(const ocpp::messages::ocpp16::UnlockConnectorReq& request, + ocpp::messages::ocpp16::UnlockConnectorConf& response, + std::string& error, + std::string& message) = 0; /** * @brief Update the firmware of the charge point @@ -354,10 +354,10 @@ class IChargePointProxy * @param message Error message (Empty if not a CallError) * @return true if the request has been sent and a response has been received, false otherwise */ - virtual bool call(const ocpp::messages::UpdateFirmwareReq& request, - ocpp::messages::UpdateFirmwareConf& response, - std::string& error, - std::string& message) = 0; + virtual bool call(const ocpp::messages::ocpp16::UpdateFirmwareReq& request, + ocpp::messages::ocpp16::UpdateFirmwareConf& response, + std::string& error, + std::string& message) = 0; // Security extensions @@ -369,10 +369,10 @@ class IChargePointProxy * @param message Error message (Empty if not a CallError) * @return true if the request has been sent and a response has been received, false otherwise */ - virtual bool call(const ocpp::messages::CertificateSignedReq& request, - ocpp::messages::CertificateSignedConf& response, - std::string& error, - std::string& message) = 0; + virtual bool call(const ocpp::messages::ocpp16::CertificateSignedReq& request, + ocpp::messages::ocpp16::CertificateSignedConf& response, + std::string& error, + std::string& message) = 0; /** * @brief Delete an installed CA certificate @@ -382,10 +382,10 @@ class IChargePointProxy * @param message Error message (Empty if not a CallError) * @return true if the request has been sent and a response has been received, false otherwise */ - virtual bool call(const ocpp::messages::DeleteCertificateReq& request, - ocpp::messages::DeleteCertificateConf& response, - std::string& error, - std::string& message) = 0; + virtual bool call(const ocpp::messages::ocpp16::DeleteCertificateReq& request, + ocpp::messages::ocpp16::DeleteCertificateConf& response, + std::string& error, + std::string& message) = 0; /** * @brief Request the send of a specific message @@ -395,10 +395,10 @@ class IChargePointProxy * @param message Error message (Empty if not a CallError) * @return true if the request has been sent and a response has been received, false otherwise */ - virtual bool call(const ocpp::messages::ExtendedTriggerMessageReq& request, - ocpp::messages::ExtendedTriggerMessageConf& response, - std::string& error, - std::string& message) = 0; + virtual bool call(const ocpp::messages::ocpp16::ExtendedTriggerMessageReq& request, + ocpp::messages::ocpp16::ExtendedTriggerMessageConf& response, + std::string& error, + std::string& message) = 0; /** * @brief Get the list of installed CA certificates @@ -408,10 +408,10 @@ class IChargePointProxy * @param message Error message (Empty if not a CallError) * @return true if the request has been sent and a response has been received, false otherwise */ - virtual bool call(const ocpp::messages::GetInstalledCertificateIdsReq& request, - ocpp::messages::GetInstalledCertificateIdsConf& response, - std::string& error, - std::string& message) = 0; + virtual bool call(const ocpp::messages::ocpp16::GetInstalledCertificateIdsReq& request, + ocpp::messages::ocpp16::GetInstalledCertificateIdsConf& response, + std::string& error, + std::string& message) = 0; /** * @brief Get the log file @@ -421,10 +421,10 @@ class IChargePointProxy * @param message Error message (Empty if not a CallError) * @return true if the request has been sent and a response has been received, false otherwise */ - virtual bool call(const ocpp::messages::GetLogReq& request, - ocpp::messages::GetLogConf& response, - std::string& error, - std::string& message) = 0; + virtual bool call(const ocpp::messages::ocpp16::GetLogReq& request, + ocpp::messages::ocpp16::GetLogConf& response, + std::string& error, + std::string& message) = 0; /** * @brief Install a CA certificate @@ -434,10 +434,10 @@ class IChargePointProxy * @param message Error message (Empty if not a CallError) * @return true if the request has been sent and a response has been received, false otherwise */ - virtual bool call(const ocpp::messages::InstallCertificateReq& request, - ocpp::messages::InstallCertificateConf& response, - std::string& error, - std::string& message) = 0; + virtual bool call(const ocpp::messages::ocpp16::InstallCertificateReq& request, + ocpp::messages::ocpp16::InstallCertificateConf& response, + std::string& error, + std::string& message) = 0; /** * @brief Update the firmware of the charge point @@ -447,10 +447,10 @@ class IChargePointProxy * @param message Error message (Empty if not a CallError) * @return true if the request has been sent and a response has been received, false otherwise */ - virtual bool call(const ocpp::messages::SignedUpdateFirmwareReq& request, - ocpp::messages::SignedUpdateFirmwareConf& response, - std::string& error, - std::string& message) = 0; + virtual bool call(const ocpp::messages::ocpp16::SignedUpdateFirmwareReq& request, + ocpp::messages::ocpp16::SignedUpdateFirmwareConf& response, + std::string& error, + std::string& message) = 0; /** * @brief Register a handler for the Authorize request @@ -458,7 +458,8 @@ class IChargePointProxy * @return true if the handler has been registered, false otherwise */ virtual bool registerHandler( - std::function handler) = 0; + std::function + handler) = 0; /** * @brief Register a handler for the BootNotification request @@ -466,7 +467,8 @@ class IChargePointProxy * @return true if the handler has been registered, false otherwise */ virtual bool registerHandler( - std::function + std::function handler) = 0; /** @@ -475,7 +477,8 @@ class IChargePointProxy * @return true if the handler has been registered, false otherwise */ virtual bool registerHandler( - std::function + std::function< + bool(const ocpp::messages::ocpp16::DataTransferReq&, ocpp::messages::ocpp16::DataTransferConf&, std::string&, std::string&)> handler) = 0; /** @@ -483,8 +486,8 @@ class IChargePointProxy * @param handler Handler function * @return true if the handler has been registered, false otherwise */ - virtual bool registerHandler(std::function handler) = 0; @@ -493,8 +496,8 @@ class IChargePointProxy * @param handler Handler function * @return true if the handler has been registered, false otherwise */ - virtual bool registerHandler(std::function handler) = 0; @@ -504,7 +507,8 @@ class IChargePointProxy * @return true if the handler has been registered, false otherwise */ virtual bool registerHandler( - std::function handler) = 0; + std::function + handler) = 0; /** * @brief Register a handler for the MeterValues request @@ -512,7 +516,8 @@ class IChargePointProxy * @return true if the handler has been registered, false otherwise */ virtual bool registerHandler( - std::function + std::function< + bool(const ocpp::messages::ocpp16::MeterValuesReq&, ocpp::messages::ocpp16::MeterValuesConf&, std::string&, std::string&)> handler) = 0; /** @@ -521,7 +526,8 @@ class IChargePointProxy * @return true if the handler has been registered, false otherwise */ virtual bool registerHandler( - std::function + std::function handler) = 0; /** @@ -529,10 +535,10 @@ class IChargePointProxy * @param handler Handler function * @return true if the handler has been registered, false otherwise */ - virtual bool registerHandler( - std::function< - bool(const ocpp::messages::StatusNotificationReq&, ocpp::messages::StatusNotificationConf&, std::string&, std::string&)> - handler) = 0; + virtual bool registerHandler(std::function handler) = 0; /** * @brief Register a handler for the StopTransaction request @@ -540,7 +546,8 @@ class IChargePointProxy * @return true if the handler has been registered, false otherwise */ virtual bool registerHandler( - std::function + std::function handler) = 0; /** @@ -548,18 +555,18 @@ class IChargePointProxy * @param handler Handler function * @return true if the handler has been registered, false otherwise */ - virtual bool registerHandler( - std::function< - bool(const ocpp::messages::LogStatusNotificationReq&, ocpp::messages::LogStatusNotificationConf&, std::string&, std::string&)> - handler) = 0; + virtual bool registerHandler(std::function handler) = 0; /** * @brief Register a handler for the SecurityEventNotification request * @param handler Handler function * @return true if the handler has been registered, false otherwise */ - virtual bool registerHandler(std::function handler) = 0; @@ -569,7 +576,8 @@ class IChargePointProxy * @return true if the handler has been registered, false otherwise */ virtual bool registerHandler( - std::function + std::function handler) = 0; /** @@ -577,8 +585,8 @@ class IChargePointProxy * @param handler Handler function * @return true if the handler has been registered, false otherwise */ - virtual bool registerHandler(std::function handler) = 0; }; diff --git a/src/localcontroller/interface/ILocalController.h b/src/ocpp16/localcontroller/interface/ILocalController.h similarity index 100% rename from src/localcontroller/interface/ILocalController.h rename to src/ocpp16/localcontroller/interface/ILocalController.h diff --git a/src/localcontroller/interface/ILocalControllerConfig.h b/src/ocpp16/localcontroller/interface/ILocalControllerConfig.h similarity index 100% rename from src/localcontroller/interface/ILocalControllerConfig.h rename to src/ocpp16/localcontroller/interface/ILocalControllerConfig.h diff --git a/src/localcontroller/interface/ILocalControllerEventsHandler.h b/src/ocpp16/localcontroller/interface/ILocalControllerEventsHandler.h similarity index 100% rename from src/localcontroller/interface/ILocalControllerEventsHandler.h rename to src/ocpp16/localcontroller/interface/ILocalControllerEventsHandler.h diff --git a/src/localcontroller/interface/ILocalControllerProxyEventsHandler.h b/src/ocpp16/localcontroller/interface/ILocalControllerProxyEventsHandler.h similarity index 100% rename from src/localcontroller/interface/ILocalControllerProxyEventsHandler.h rename to src/ocpp16/localcontroller/interface/ILocalControllerProxyEventsHandler.h diff --git a/src/messages/Authorize.cpp b/src/ocpp16/messages/Authorize.cpp similarity index 92% rename from src/messages/Authorize.cpp rename to src/ocpp16/messages/Authorize.cpp index 66970064..687c9462 100644 --- a/src/messages/Authorize.cpp +++ b/src/ocpp16/messages/Authorize.cpp @@ -21,20 +21,26 @@ along with OpenOCPP. If not, see . #include "IdTagInfoConverter.h" using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { namespace types { +namespace ocpp16 +{ /** @brief Helper to convert a AuthorizationStatus enum to string */ const EnumToStringFromString AuthorizationStatusHelper = {{AuthorizationStatus::Accepted, "Accepted"}, {AuthorizationStatus::Blocked, "Blocked"}, {AuthorizationStatus::ConcurrentTx, "ConcurrentTx"}, {AuthorizationStatus::Expired, "Expired"}, {AuthorizationStatus::Invalid, "Invalid"}}; +} // namespace ocpp16 } // namespace types namespace messages { +namespace ocpp16 +{ /** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, DataType&, std::string&, std::string&) */ bool AuthorizeReqConverter::fromJson(const rapidjson::Value& json, AuthorizeReq& data, std::string& error_code, std::string& error_message) @@ -68,12 +74,12 @@ bool AuthorizeConfConverter::toJson(const AuthorizeConf& data, rapidjson::Docume { IdTagInfoConverter id_tag_info_converter; id_tag_info_converter.setAllocator(allocator); - rapidjson::Document id_tag_info; - id_tag_info.Parse("{}"); - bool ret = id_tag_info_converter.toJson(data.idTagInfo, id_tag_info); + rapidjson::Document id_tag_info(rapidjson::kObjectType); + bool ret = id_tag_info_converter.toJson(data.idTagInfo, id_tag_info); json.AddMember(rapidjson::StringRef("idTagInfo"), id_tag_info.Move(), *allocator); return ret; } +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/Authorize.h b/src/ocpp16/messages/Authorize.h similarity index 91% rename from src/messages/Authorize.h rename to src/ocpp16/messages/Authorize.h index 9f798b4f..b202f1bf 100644 --- a/src/messages/Authorize.h +++ b/src/ocpp16/messages/Authorize.h @@ -26,6 +26,8 @@ namespace ocpp { namespace messages { +namespace ocpp16 +{ /** @brief Action corresponding to the Authorize messages */ static const std::string AUTHORIZE_ACTION = "Authorize"; @@ -34,7 +36,7 @@ static const std::string AUTHORIZE_ACTION = "Authorize"; struct AuthorizeReq { /** @brief Required. This contains the identifier that needs to be authorized */ - ocpp::types::IdToken idTag; + ocpp::types::ocpp16::IdToken idTag; }; /** @brief Authorize.conf message */ @@ -42,12 +44,13 @@ struct AuthorizeConf { /** @brief Required. This contains information about authorization status, expiry and parent id */ - ocpp::types::IdTagInfo idTagInfo; + ocpp::types::ocpp16::IdTagInfo idTagInfo; }; // Message converters MESSAGE_CONVERTERS(Authorize) +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/BootNotification.cpp b/src/ocpp16/messages/BootNotification.cpp similarity index 97% rename from src/messages/BootNotification.cpp rename to src/ocpp16/messages/BootNotification.cpp index a060e98e..9c725092 100644 --- a/src/messages/BootNotification.cpp +++ b/src/ocpp16/messages/BootNotification.cpp @@ -20,17 +20,23 @@ along with OpenOCPP. If not, see . #include "IRpc.h" using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { namespace types { +namespace ocpp16 +{ /** @brief Helper to convert a RegistrationStatus enum to string */ const EnumToStringFromString RegistrationStatusHelper = { {RegistrationStatus::Accepted, "Accepted"}, {RegistrationStatus::Pending, "Pending"}, {RegistrationStatus::Rejected, "Rejected"}}; +} // namespace ocpp16 } // namespace types namespace messages { +namespace ocpp16 +{ /** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, DataType&, std::string&, std::string&) */ bool BootNotificationReqConverter::fromJson(const rapidjson::Value& json, @@ -96,5 +102,6 @@ bool BootNotificationConfConverter::toJson(const BootNotificationConf& data, rap return true; } +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/BootNotification.h b/src/ocpp16/messages/BootNotification.h similarity index 97% rename from src/messages/BootNotification.h rename to src/ocpp16/messages/BootNotification.h index 8e87b10c..f4af123d 100644 --- a/src/messages/BootNotification.h +++ b/src/ocpp16/messages/BootNotification.h @@ -24,11 +24,15 @@ along with OpenOCPP. If not, see . #include "Enums.h" #include "IMessageConverter.h" #include "Optional.h" + #include + namespace ocpp { namespace messages { +namespace ocpp16 +{ /** @brief Action corresponding to the BootNotification messages */ static const std::string BOOT_NOTIFICATION_ACTION = "BootNotification"; @@ -75,12 +79,13 @@ struct BootNotificationConf unsigned int interval; /** @brief Required. This contains whether the Charge Point has been registered within the System Central */ - ocpp::types::RegistrationStatus status; + ocpp::types::ocpp16::RegistrationStatus status; }; // Message converters MESSAGE_CONVERTERS(BootNotification) +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/ocpp16/messages/CMakeLists.txt b/src/ocpp16/messages/CMakeLists.txt new file mode 100644 index 00000000..6a74ed55 --- /dev/null +++ b/src/ocpp16/messages/CMakeLists.txt @@ -0,0 +1,72 @@ +###################################################### +# OCPP 1.6 messages library # +###################################################### + + +# Library target +add_library(messages16 OBJECT + MessagesConverter.cpp + MessagesValidator.cpp + + Authorize.cpp + BootNotification.cpp + CancelReservation.cpp + CertificateSigned.cpp + ChangeAvailability.cpp + ChangeConfiguration.cpp + ClearCache.cpp + ClearChargingProfile.cpp + DataTransfer.cpp + DeleteCertificate.cpp + DiagnosticsStatusNotification.cpp + ExtendedTriggerMessage.cpp + FirmwareStatusNotification.cpp + GetConfiguration.cpp + Get15118EVCertificate.cpp + GetCertificateStatus.cpp + GetCompositeSchedule.cpp + GetDiagnostics.cpp + GetInstalledCertificateIds.cpp + GetLocalListVersion.cpp + GetLog.cpp + Heartbeat.cpp + InstallCertificate.cpp + Iso15118Authorize.cpp + Iso15118GetInstalledCertificateIds.cpp + Iso15118InstallCertificate.cpp + Iso15118TriggerMessage.cpp + LogStatusNotification.cpp + MeterValues.cpp + RemoteStartTransaction.cpp + RemoteStopTransaction.cpp + ReserveNow.cpp + Reset.cpp + SecurityEventNotification.cpp + SendLocalList.cpp + SetChargingProfile.cpp + SignCertificate.cpp + SignedFirmwareStatusNotification.cpp + SignedUpdateFirmware.cpp + StartTransaction.cpp + StatusNotification.cpp + StopTransaction.cpp + TriggerMessage.cpp + UnlockConnector.cpp + UpdateFirmware.cpp + + types/AuthorizationDataConverter.cpp + types/CertificateHashDataChainTypeConverter.cpp + types/CertificateHashDataTypeConverter.cpp + types/ChargingProfileConverter.cpp + types/ChargingScheduleConverter.cpp + types/IdTagInfoConverter.cpp + types/IdTokenInfoTypeConverter.cpp + types/MeterValueConverter.cpp + types/OcspRequestDataTypeConverter.cpp +) + +# Exported includes +target_include_directories(messages16 PUBLIC . types) + +# Dependencies +target_link_libraries(messages16 PUBLIC types16 messages) diff --git a/src/messages/CancelReservation.cpp b/src/ocpp16/messages/CancelReservation.cpp similarity index 96% rename from src/messages/CancelReservation.cpp rename to src/ocpp16/messages/CancelReservation.cpp index 244252f9..34796ae1 100644 --- a/src/messages/CancelReservation.cpp +++ b/src/ocpp16/messages/CancelReservation.cpp @@ -20,18 +20,24 @@ along with OpenOCPP. If not, see . #include "IRpc.h" using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { namespace types { +namespace ocpp16 +{ /** @brief Helper to convert a enum class CancelReservationStatus enum to string */ const EnumToStringFromString CancelReservationStatusHelper = {{CancelReservationStatus::Accepted, "Accepted"}, {CancelReservationStatus::Rejected, "Rejected"}}; +} // namespace ocpp16 } // namespace types namespace messages { +namespace ocpp16 +{ /** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, DataType&, std::string&, std::string&) */ bool CancelReservationReqConverter::fromJson(const rapidjson::Value& json, @@ -71,5 +77,6 @@ bool CancelReservationConfConverter::toJson(const CancelReservationConf& data, r return true; } +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/CancelReservation.h b/src/ocpp16/messages/CancelReservation.h similarity index 94% rename from src/messages/CancelReservation.h rename to src/ocpp16/messages/CancelReservation.h index 3f7793f5..e82e5f84 100644 --- a/src/messages/CancelReservation.h +++ b/src/ocpp16/messages/CancelReservation.h @@ -28,6 +28,8 @@ namespace ocpp { namespace messages { +namespace ocpp16 +{ /** @brief Action corresponding to the CancelReservation messages */ static const std::string CANCEL_RESERVATION_ACTION = "CancelReservation"; @@ -44,12 +46,13 @@ struct CancelReservationConf { /** @brief Required. This indicates the success or failure of the cancelling of a reservation by Central System */ - ocpp::types::CancelReservationStatus status; + ocpp::types::ocpp16::CancelReservationStatus status; }; // Message converters MESSAGE_CONVERTERS(CancelReservation) +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/CertificateSigned.cpp b/src/ocpp16/messages/CertificateSigned.cpp similarity index 96% rename from src/messages/CertificateSigned.cpp rename to src/ocpp16/messages/CertificateSigned.cpp index dd81bbb1..b6c7dede 100644 --- a/src/messages/CertificateSigned.cpp +++ b/src/ocpp16/messages/CertificateSigned.cpp @@ -20,18 +20,24 @@ along with OpenOCPP. If not, see . #include "IRpc.h" using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { namespace types { +namespace ocpp16 +{ /** @brief Helper to convert a enum class CertificateSignedStatusEnumType enum to string */ const EnumToStringFromString CertificateSignedStatusEnumTypeHelper = { {CertificateSignedStatusEnumType::Accepted, "Accepted"}, {CertificateSignedStatusEnumType::Rejected, "Rejected"}}; +} // namespace ocpp16 } // namespace types namespace messages { +namespace ocpp16 +{ /** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, DataType&, std::string&, std::string&) */ bool CertificateSignedReqConverter::fromJson(const rapidjson::Value& json, @@ -71,5 +77,6 @@ bool CertificateSignedConfConverter::toJson(const CertificateSignedConf& data, r return true; } +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/CertificateSigned.h b/src/ocpp16/messages/CertificateSigned.h similarity index 94% rename from src/messages/CertificateSigned.h rename to src/ocpp16/messages/CertificateSigned.h index 23ca880d..bf80310e 100644 --- a/src/messages/CertificateSigned.h +++ b/src/ocpp16/messages/CertificateSigned.h @@ -27,6 +27,8 @@ namespace ocpp { namespace messages { +namespace ocpp16 +{ /** @brief Action corresponding to the CertificateSigned messages */ static const std::string CERTIFICATE_SIGNED_ACTION = "CertificateSigned"; @@ -45,12 +47,13 @@ struct CertificateSignedConf { /** @brief Required. Returns whether certificate signing has been accepted, otherwise rejected */ - ocpp::types::CertificateSignedStatusEnumType status; + ocpp::types::ocpp16::CertificateSignedStatusEnumType status; }; // Message converters MESSAGE_CONVERTERS(CertificateSigned) +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/ChangeAvailability.cpp b/src/ocpp16/messages/ChangeAvailability.cpp similarity index 96% rename from src/messages/ChangeAvailability.cpp rename to src/ocpp16/messages/ChangeAvailability.cpp index 2010c7de..721f0d2d 100644 --- a/src/messages/ChangeAvailability.cpp +++ b/src/ocpp16/messages/ChangeAvailability.cpp @@ -20,11 +20,14 @@ along with OpenOCPP. If not, see . #include "IRpc.h" using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { namespace types { +namespace ocpp16 +{ /** @brief Helper to convert a AvailabilityType enum to string */ const EnumToStringFromString AvailabilityTypeHelper = {{AvailabilityType::Inoperative, "Inoperative"}, {AvailabilityType::Operative, "Operative"}}; @@ -33,9 +36,12 @@ const EnumToStringFromString AvailabilityTypeHelper = {{Availa const EnumToStringFromString AvailabilityStatusHelper = { {AvailabilityStatus::Accepted, "Accepted"}, {AvailabilityStatus::Rejected, "Rejected"}, {AvailabilityStatus::Scheduled, "Scheduled"}}; +} // namespace ocpp16 } // namespace types namespace messages { +namespace ocpp16 +{ /** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, DataType&, std::string&, std::string&) */ bool ChangeAvailabilityReqConverter::fromJson(const rapidjson::Value& json, @@ -80,5 +86,6 @@ bool ChangeAvailabilityConfConverter::toJson(const ChangeAvailabilityConf& data, return true; } +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/ChangeAvailability.h b/src/ocpp16/messages/ChangeAvailability.h similarity index 92% rename from src/messages/ChangeAvailability.h rename to src/ocpp16/messages/ChangeAvailability.h index 858daed0..cc67d7de 100644 --- a/src/messages/ChangeAvailability.h +++ b/src/ocpp16/messages/ChangeAvailability.h @@ -28,6 +28,8 @@ namespace ocpp { namespace messages { +namespace ocpp16 +{ /** @brief Action corresponding to the ChangeAvailability messages */ static const std::string CHANGE_AVAILABILITY_ACTION = "ChangeAvailability"; @@ -41,7 +43,7 @@ struct ChangeAvailabilityReq unsigned int connectorId; /** @brief Required. This contains the type of availability change that the Charge Point should perform. */ - ocpp::types::AvailabilityType type; + ocpp::types::ocpp16::AvailabilityType type; }; /** @brief ChangeAvailability.conf message */ @@ -49,12 +51,13 @@ struct ChangeAvailabilityConf { /** @brief Required. This indicates whether the Charge Point is able to perform the availability change */ - ocpp::types::AvailabilityStatus status; + ocpp::types::ocpp16::AvailabilityStatus status; }; // Message converters MESSAGE_CONVERTERS(ChangeAvailability) +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/ChangeConfiguration.cpp b/src/ocpp16/messages/ChangeConfiguration.cpp similarity index 96% rename from src/messages/ChangeConfiguration.cpp rename to src/ocpp16/messages/ChangeConfiguration.cpp index 953e7de9..455eab1d 100644 --- a/src/messages/ChangeConfiguration.cpp +++ b/src/ocpp16/messages/ChangeConfiguration.cpp @@ -20,21 +20,26 @@ along with OpenOCPP. If not, see . #include "IRpc.h" using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { namespace types { +namespace ocpp16 +{ /** @brief Helper to convert a ConfigurationStatus enum to string */ const EnumToStringFromString ConfigurationStatusHelper = {{ConfigurationStatus::Accepted, "Accepted"}, {ConfigurationStatus::Rejected, "Rejected"}, {ConfigurationStatus::RebootRequired, "RebootRequired"}, {ConfigurationStatus::NotSupported, "NotSupported"}}; +} // namespace ocpp16 } // namespace types namespace messages { - +namespace ocpp16 +{ /** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, DataType&, std::string&, std::string&) */ bool ChangeConfigurationReqConverter::fromJson(const rapidjson::Value& json, ChangeConfigurationReq& data, @@ -75,5 +80,6 @@ bool ChangeConfigurationConfConverter::toJson(const ChangeConfigurationConf& dat return true; } +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/ChangeConfiguration.h b/src/ocpp16/messages/ChangeConfiguration.h similarity index 94% rename from src/messages/ChangeConfiguration.h rename to src/ocpp16/messages/ChangeConfiguration.h index 8558bbd1..7d3f27a8 100644 --- a/src/messages/ChangeConfiguration.h +++ b/src/ocpp16/messages/ChangeConfiguration.h @@ -27,6 +27,8 @@ namespace ocpp { namespace messages { +namespace ocpp16 +{ /** @brief Action corresponding to the ChangeConfiguration messages */ static const std::string CHANGE_CONFIGURATION_ACTION = "ChangeConfiguration"; @@ -44,12 +46,13 @@ struct ChangeConfigurationReq struct ChangeConfigurationConf { /** @brief Required. Returns whether configuration change has been accepted */ - ocpp::types::ConfigurationStatus status; + ocpp::types::ocpp16::ConfigurationStatus status; }; // Message converters MESSAGE_CONVERTERS(ChangeConfiguration) +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/ClearCache.cpp b/src/ocpp16/messages/ClearCache.cpp similarity index 95% rename from src/messages/ClearCache.cpp rename to src/ocpp16/messages/ClearCache.cpp index 036bae76..bc821fa9 100644 --- a/src/messages/ClearCache.cpp +++ b/src/ocpp16/messages/ClearCache.cpp @@ -20,19 +20,24 @@ along with OpenOCPP. If not, see . #include "IRpc.h" using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { - namespace types { +namespace ocpp16 +{ /** @brief Helper to convert a ClearCacheStatus enum to string */ const EnumToStringFromString ClearCacheStatusHelper = {{ClearCacheStatus::Accepted, "Accepted"}, {ClearCacheStatus::Rejected, "Rejected"}}; +} // namespace ocpp16 } // namespace types namespace messages { +namespace ocpp16 +{ /** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, DataType&, std::string&, std::string&) */ bool ClearCacheReqConverter::fromJson(const rapidjson::Value& json, @@ -74,5 +79,6 @@ bool ClearCacheConfConverter::toJson(const ClearCacheConf& data, rapidjson::Docu return true; } +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/ClearCache.h b/src/ocpp16/messages/ClearCache.h similarity index 93% rename from src/messages/ClearCache.h rename to src/ocpp16/messages/ClearCache.h index 17ff00e8..86c1ff21 100644 --- a/src/messages/ClearCache.h +++ b/src/ocpp16/messages/ClearCache.h @@ -26,6 +26,8 @@ namespace ocpp { namespace messages { +namespace ocpp16 +{ /** @brief Action corresponding to the ClearCache messages */ static const std::string CLEAR_CACHE_ACTION = "ClearCache"; @@ -41,12 +43,13 @@ struct ClearCacheConf { /** @brief Required. Accepted if the Charge Point has executed the request, otherwise rejected */ - ocpp::types::ClearCacheStatus status; + ocpp::types::ocpp16::ClearCacheStatus status; }; // Message converters MESSAGE_CONVERTERS(ClearCache) +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/ClearChargingProfile.cpp b/src/ocpp16/messages/ClearChargingProfile.cpp similarity index 97% rename from src/messages/ClearChargingProfile.cpp rename to src/ocpp16/messages/ClearChargingProfile.cpp index 8f90c30a..ac89ef2e 100644 --- a/src/messages/ClearChargingProfile.cpp +++ b/src/ocpp16/messages/ClearChargingProfile.cpp @@ -20,11 +20,14 @@ along with OpenOCPP. If not, see . #include "IRpc.h" using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { namespace types { +namespace ocpp16 +{ /** @brief Helper to convert a enum class ChargingProfilePurposeType enum to string */ const EnumToStringFromString ChargingProfilePurposeTypeHelper = { @@ -36,9 +39,12 @@ const EnumToStringFromString ChargingProfilePurposeT const EnumToStringFromString ClearChargingProfileStatusHelper = { {ClearChargingProfileStatus::Accepted, "Accepted"}, {ClearChargingProfileStatus::Unknown, "Unknown"}}; +} // namespace ocpp16 } // namespace types namespace messages { +namespace ocpp16 +{ /** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, DataType&, std::string&, std::string&) */ bool ClearChargingProfileReqConverter::fromJson(const rapidjson::Value& json, @@ -92,5 +98,6 @@ bool ClearChargingProfileConfConverter::toJson(const ClearChargingProfileConf& d return true; } +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/ClearChargingProfile.h b/src/ocpp16/messages/ClearChargingProfile.h similarity index 92% rename from src/messages/ClearChargingProfile.h rename to src/ocpp16/messages/ClearChargingProfile.h index 448fcae7..c2faa810 100644 --- a/src/messages/ClearChargingProfile.h +++ b/src/ocpp16/messages/ClearChargingProfile.h @@ -26,6 +26,8 @@ namespace ocpp { namespace messages { +namespace ocpp16 +{ /** @brief Action corresponding to the ClearChargingProfile messages */ static const std::string CLEAR_CHARGING_PROFILE_ACTION = "ClearChargingProfile"; @@ -43,7 +45,7 @@ struct ClearChargingProfileReq ocpp::types::Optional connectorId; /** @brief Optional. Specifies to purpose of the charging profiles that will be cleared, if they meet the other criteria in the request */ - ocpp::types::Optional chargingProfilePurpose; + ocpp::types::Optional chargingProfilePurpose; /** @brief Optional. specifies the stackLevel for which charging profiles will be cleared, if they meet the other criteria in the request */ ocpp::types::Optional stackLevel; @@ -54,12 +56,13 @@ struct ClearChargingProfileConf { /** @brief Required. Indicates if the Charge Point was able to execute the request */ - ocpp::types::ClearChargingProfileStatus status; + ocpp::types::ocpp16::ClearChargingProfileStatus status; }; // Message converters MESSAGE_CONVERTERS(ClearChargingProfile) +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/DataTransfer.cpp b/src/ocpp16/messages/DataTransfer.cpp similarity index 96% rename from src/messages/DataTransfer.cpp rename to src/ocpp16/messages/DataTransfer.cpp index 093e0082..a3450fdc 100644 --- a/src/messages/DataTransfer.cpp +++ b/src/ocpp16/messages/DataTransfer.cpp @@ -20,20 +20,26 @@ along with OpenOCPP. If not, see . #include "IRpc.h" using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { namespace types { +namespace ocpp16 +{ /** @brief Helper to convert a enum class DataTransferStatus enum to string */ const EnumToStringFromString DataTransferStatusHelper = {{DataTransferStatus::Accepted, "Accepted"}, {DataTransferStatus::Rejected, "Rejected"}, {DataTransferStatus::UnknownMessageId, "UnknownMessageId"}, {DataTransferStatus::UnknownVendorId, "UnknownVendorId"}}; +} // namespace ocpp16 } // namespace types namespace messages { +namespace ocpp16 +{ /** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, DataType&, std::string&, std::string&) */ bool DataTransferReqConverter::fromJson(const rapidjson::Value& json, @@ -79,5 +85,6 @@ bool DataTransferConfConverter::toJson(const DataTransferConf& data, rapidjson:: return true; } +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/DataTransfer.h b/src/ocpp16/messages/DataTransfer.h similarity index 95% rename from src/messages/DataTransfer.h rename to src/ocpp16/messages/DataTransfer.h index b3fa54fb..c5b8f30f 100644 --- a/src/messages/DataTransfer.h +++ b/src/ocpp16/messages/DataTransfer.h @@ -28,6 +28,8 @@ namespace ocpp { namespace messages { +namespace ocpp16 +{ /** @brief Action corresponding to the DataTransfer messages */ static const std::string DATA_TRANSFER_ACTION = "DataTransfer"; @@ -47,7 +49,7 @@ struct DataTransferReq struct DataTransferConf { /** @brief Required. This indicates the success or failure of the data transfer */ - ocpp::types::DataTransferStatus status; + ocpp::types::ocpp16::DataTransferStatus status; /** @brief Optional. Data in response to request */ ocpp::types::Optional data; }; @@ -55,6 +57,7 @@ struct DataTransferConf // Message converters MESSAGE_CONVERTERS(DataTransfer) +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/DeleteCertificate.cpp b/src/ocpp16/messages/DeleteCertificate.cpp similarity index 92% rename from src/messages/DeleteCertificate.cpp rename to src/ocpp16/messages/DeleteCertificate.cpp index 8561f496..a9a0ec07 100644 --- a/src/messages/DeleteCertificate.cpp +++ b/src/ocpp16/messages/DeleteCertificate.cpp @@ -21,20 +21,26 @@ along with OpenOCPP. If not, see . #include "IRpc.h" using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { namespace types { +namespace ocpp16 +{ /** @brief Helper to convert a enum class DeleteCertificateStatusEnumType enum to string */ const EnumToStringFromString DeleteCertificateStatusEnumTypeHelper = { {DeleteCertificateStatusEnumType::Accepted, "Accepted"}, {DeleteCertificateStatusEnumType::Failed, "Failed"}, {DeleteCertificateStatusEnumType::NotFound, "NotFound"}}; +} // namespace ocpp16 } // namespace types namespace messages { +namespace ocpp16 +{ /** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, DataType&, std::string&, std::string&) */ bool DeleteCertificateReqConverter::fromJson(const rapidjson::Value& json, @@ -51,9 +57,8 @@ bool DeleteCertificateReqConverter::toJson(const DeleteCertificateReq& data, rap { CertificateHashDataTypeConverter certificate_hash_converter; certificate_hash_converter.setAllocator(allocator); - rapidjson::Document value; - value.Parse("{}"); - bool ret = certificate_hash_converter.toJson(data.certificateHashData, value); + rapidjson::Document value(rapidjson::kObjectType); + bool ret = certificate_hash_converter.toJson(data.certificateHashData, value); json.AddMember(rapidjson::StringRef("certificateHashData"), value.Move(), *allocator); return ret; } @@ -77,5 +82,6 @@ bool DeleteCertificateConfConverter::toJson(const DeleteCertificateConf& data, r return true; } +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/DeleteCertificate.h b/src/ocpp16/messages/DeleteCertificate.h similarity index 89% rename from src/messages/DeleteCertificate.h rename to src/ocpp16/messages/DeleteCertificate.h index eaaccc9b..ad8eaa1e 100644 --- a/src/messages/DeleteCertificate.h +++ b/src/ocpp16/messages/DeleteCertificate.h @@ -27,6 +27,8 @@ namespace ocpp { namespace messages { +namespace ocpp16 +{ /** @brief Action corresponding to the DeleteCertificate messages */ static const std::string DELETE_CERTIFICATE_ACTION = "DeleteCertificate"; @@ -35,19 +37,20 @@ static const std::string DELETE_CERTIFICATE_ACTION = "DeleteCertificate"; struct DeleteCertificateReq { /** @brief Required. Indicates the certificate of which deletion is requested */ - ocpp::types::CertificateHashDataType certificateHashData; + ocpp::types::ocpp16::CertificateHashDataType certificateHashData; }; /** @brief DeleteCertificate.conf message */ struct DeleteCertificateConf { /** @brief Required. Charge Point indicates if it can process the request */ - ocpp::types::DeleteCertificateStatusEnumType status; + ocpp::types::ocpp16::DeleteCertificateStatusEnumType status; }; // Message converters MESSAGE_CONVERTERS(DeleteCertificate) +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/DiagnosticsStatusNotification.cpp b/src/ocpp16/messages/DiagnosticsStatusNotification.cpp similarity index 96% rename from src/messages/DiagnosticsStatusNotification.cpp rename to src/ocpp16/messages/DiagnosticsStatusNotification.cpp index c8d4cbab..13673297 100644 --- a/src/messages/DiagnosticsStatusNotification.cpp +++ b/src/ocpp16/messages/DiagnosticsStatusNotification.cpp @@ -20,22 +20,27 @@ along with OpenOCPP. If not, see . #include "IRpc.h" using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { namespace types { +namespace ocpp16 +{ /** @brief Helper to convert a enum class DiagnosticsStatus enum to string */ const EnumToStringFromString DiagnosticsStatusHelper = {{DiagnosticsStatus::Idle, "Idle"}, {DiagnosticsStatus::Uploaded, "Uploaded"}, {DiagnosticsStatus::UploadFailed, "UploadFailed"}, {DiagnosticsStatus::Uploading, "Uploading"}}; +} // namespace ocpp16 } // namespace types namespace messages { - +namespace ocpp16 +{ /** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, DataType&, std::string&, std::string&) */ bool DiagnosticsStatusNotificationReqConverter::fromJson(const rapidjson::Value& json, DiagnosticsStatusNotificationReq& data, @@ -76,5 +81,6 @@ bool DiagnosticsStatusNotificationConfConverter::toJson(const DiagnosticsStatusN return true; } +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/DiagnosticsStatusNotification.h b/src/ocpp16/messages/DiagnosticsStatusNotification.h similarity index 94% rename from src/messages/DiagnosticsStatusNotification.h rename to src/ocpp16/messages/DiagnosticsStatusNotification.h index 4ed67338..ad288029 100644 --- a/src/messages/DiagnosticsStatusNotification.h +++ b/src/ocpp16/messages/DiagnosticsStatusNotification.h @@ -26,6 +26,8 @@ namespace ocpp { namespace messages { +namespace ocpp16 +{ /** @brief Action corresponding to the DiagnosticsStatusNotification messages */ static const std::string DIAGNOSTIC_STATUS_NOTIFICATION_ACTION = "DiagnosticsStatusNotification"; @@ -34,7 +36,7 @@ static const std::string DIAGNOSTIC_STATUS_NOTIFICATION_ACTION = "DiagnosticsSta struct DiagnosticsStatusNotificationReq { /** @brief Required. This contains the status of the diagnostics upload */ - ocpp::types::DiagnosticsStatus status; + ocpp::types::ocpp16::DiagnosticsStatus status; }; /** @brief DiagnosticsStatusNotification.conf message */ @@ -46,6 +48,7 @@ struct DiagnosticsStatusNotificationConf // Message converters MESSAGE_CONVERTERS(DiagnosticsStatusNotification) +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/ExtendedTriggerMessage.cpp b/src/ocpp16/messages/ExtendedTriggerMessage.cpp similarity index 97% rename from src/messages/ExtendedTriggerMessage.cpp rename to src/ocpp16/messages/ExtendedTriggerMessage.cpp index d6e3443d..44d3dd51 100644 --- a/src/messages/ExtendedTriggerMessage.cpp +++ b/src/ocpp16/messages/ExtendedTriggerMessage.cpp @@ -20,11 +20,14 @@ along with OpenOCPP. If not, see . #include "IRpc.h" using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { namespace types { +namespace ocpp16 +{ /** @brief Helper to convert a MessageTriggerEnumType enum to string */ const EnumToStringFromString MessageTriggerEnumTypeHelper = { {MessageTriggerEnumType::BootNotification, "BootNotification"}, @@ -41,9 +44,12 @@ const EnumToStringFromString TriggerMessageStatusE {TriggerMessageStatusEnumType::NotImplemented, "NotImplemented"}, {TriggerMessageStatusEnumType::Rejected, "Rejected"}}; +} // namespace ocpp16 } // namespace types namespace messages { +namespace ocpp16 +{ /** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, DataType&, std::string&, std::string&) */ bool ExtendedTriggerMessageReqConverter::fromJson(const rapidjson::Value& json, @@ -89,5 +95,6 @@ bool ExtendedTriggerMessageConfConverter::toJson(const ExtendedTriggerMessageCon return true; } +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/ExtendedTriggerMessage.h b/src/ocpp16/messages/ExtendedTriggerMessage.h similarity index 91% rename from src/messages/ExtendedTriggerMessage.h rename to src/ocpp16/messages/ExtendedTriggerMessage.h index f5be66ae..a237f407 100644 --- a/src/messages/ExtendedTriggerMessage.h +++ b/src/ocpp16/messages/ExtendedTriggerMessage.h @@ -28,6 +28,8 @@ namespace ocpp { namespace messages { +namespace ocpp16 +{ /** @brief Action corresponding to the ExtendedTriggerMessage messages */ static const std::string EXTENDED_TRIGGER_MESSAGE_ACTION = "ExtendedTriggerMessage"; @@ -36,7 +38,7 @@ static const std::string EXTENDED_TRIGGER_MESSAGE_ACTION = "ExtendedTriggerMessa struct ExtendedTriggerMessageReq { /** @brief Required. Type of the message to be triggered */ - ocpp::types::MessageTriggerEnumType requestedMessage; + ocpp::types::ocpp16::MessageTriggerEnumType requestedMessage; /** @brief Optional. Only filled in when request applies to a specific connector */ ocpp::types::Optional connectorId; }; @@ -46,12 +48,13 @@ struct ExtendedTriggerMessageConf { /** @brief Required. Indicates whether the Charge Point will send the requested notification or not */ - ocpp::types::TriggerMessageStatusEnumType status; + ocpp::types::ocpp16::TriggerMessageStatusEnumType status; }; // Message converters MESSAGE_CONVERTERS(ExtendedTriggerMessage) +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/FirmwareStatusNotification.cpp b/src/ocpp16/messages/FirmwareStatusNotification.cpp similarity index 96% rename from src/messages/FirmwareStatusNotification.cpp rename to src/ocpp16/messages/FirmwareStatusNotification.cpp index 4f230a0c..9b4a06d7 100644 --- a/src/messages/FirmwareStatusNotification.cpp +++ b/src/ocpp16/messages/FirmwareStatusNotification.cpp @@ -21,11 +21,14 @@ along with OpenOCPP. If not, see . #include "IRpc.h" using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { namespace types { +namespace ocpp16 +{ /** @brief Helper to convert a enum class FirmwareStatus enum to string */ const EnumToStringFromString FirmwareStatusHelper = {{FirmwareStatus::Downloaded, "Downloaded"}, {FirmwareStatus::DownloadFailed, "DownloadFailed"}, @@ -35,11 +38,13 @@ const EnumToStringFromString FirmwareStatusHelper = {{FirmwareSt {FirmwareStatus::Installing, "Installing"}, {FirmwareStatus::Installed, "Installed"}}; +} // namespace ocpp16 } // namespace types namespace messages { - +namespace ocpp16 +{ /** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, DataType&, std::string&, std::string&) */ bool FirmwareStatusNotificationReqConverter::fromJson(const rapidjson::Value& json, FirmwareStatusNotificationReq& data, @@ -80,5 +85,6 @@ bool FirmwareStatusNotificationConfConverter::toJson(const FirmwareStatusNotific return true; } +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/FirmwareStatusNotification.h b/src/ocpp16/messages/FirmwareStatusNotification.h similarity index 94% rename from src/messages/FirmwareStatusNotification.h rename to src/ocpp16/messages/FirmwareStatusNotification.h index d6f4aaf9..7cf82949 100644 --- a/src/messages/FirmwareStatusNotification.h +++ b/src/ocpp16/messages/FirmwareStatusNotification.h @@ -26,6 +26,8 @@ namespace ocpp { namespace messages { +namespace ocpp16 +{ /** @brief Action corresponding to the FirmwareStatusNotification messages */ static const std::string FIRMWARE_STATUS_NOTIFICATION_ACTION = "FirmwareStatusNotification"; @@ -34,7 +36,7 @@ static const std::string FIRMWARE_STATUS_NOTIFICATION_ACTION = "FirmwareStatusNo struct FirmwareStatusNotificationReq { /** @brief Required. This contains the progress status of the firmware installation */ - ocpp::types::FirmwareStatus status; + ocpp::types::ocpp16::FirmwareStatus status; }; /** @brief FirmwareStatusNotification.conf message */ @@ -46,6 +48,7 @@ struct FirmwareStatusNotificationConf // Message converters MESSAGE_CONVERTERS(FirmwareStatusNotification) +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/Get15118EVCertificate.cpp b/src/ocpp16/messages/Get15118EVCertificate.cpp similarity index 97% rename from src/messages/Get15118EVCertificate.cpp rename to src/ocpp16/messages/Get15118EVCertificate.cpp index 2cdb21c9..48dfa999 100644 --- a/src/messages/Get15118EVCertificate.cpp +++ b/src/ocpp16/messages/Get15118EVCertificate.cpp @@ -20,11 +20,14 @@ along with OpenOCPP. If not, see . #include "IRpc.h" using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { namespace types { +namespace ocpp16 +{ /** @brief Helper to convert a enum class CertificateActionEnumType enum to string */ const EnumToStringFromString CertificateActionEnumTypeHelper = {{CertificateActionEnumType::Install, "Install"}, {CertificateActionEnumType::Update, "Update"}}; @@ -33,9 +36,12 @@ const EnumToStringFromString CertificateActionEnumTyp const EnumToStringFromString Iso15118EVCertificateStatusEnumTypeHelper = { {Iso15118EVCertificateStatusEnumType::Accepted, "Accepted"}, {Iso15118EVCertificateStatusEnumType::Failed, "Failed"}}; +} // namespace ocpp16 } // namespace types namespace messages { +namespace ocpp16 +{ /** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, DataType&, std::string&, std::string&) */ bool Get15118EVCertificateReqConverter::fromJson(const rapidjson::Value& json, @@ -81,5 +87,6 @@ bool Get15118EVCertificateConfConverter::toJson(const Get15118EVCertificateConf& return true; } +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/Get15118EVCertificate.h b/src/ocpp16/messages/Get15118EVCertificate.h similarity index 92% rename from src/messages/Get15118EVCertificate.h rename to src/ocpp16/messages/Get15118EVCertificate.h index b2f79920..48c2fcd3 100644 --- a/src/messages/Get15118EVCertificate.h +++ b/src/ocpp16/messages/Get15118EVCertificate.h @@ -27,6 +27,8 @@ namespace ocpp { namespace messages { +namespace ocpp16 +{ /** @brief Action corresponding to the Get15118EVCertificate messages */ static const std::string GET_15118_EV_CERTIFICATE_ACTION = "Get15118EVCertificate"; @@ -39,7 +41,7 @@ struct Get15118EVCertificateReq stream by the Central System */ ocpp::types::CiStringType<50u> iso15118SchemaVersion; /** @brief Required. Defines whether certificate needs to be installed or updated */ - ocpp::types::CertificateActionEnumType action; + ocpp::types::ocpp16::CertificateActionEnumType action; /** @brief Required. Raw CertificateInstallationReq request from EV, Base64 encoded */ ocpp::types::CiStringType<5600u> exiRequest; }; @@ -48,7 +50,7 @@ struct Get15118EVCertificateReq struct Get15118EVCertificateConf { /** @brief Required. Indicates whether the message was processed properly */ - ocpp::types::Iso15118EVCertificateStatusEnumType status; + ocpp::types::ocpp16::Iso15118EVCertificateStatusEnumType status; /** @brief Required. Raw CertificateInstallationRes response for the EV, Base64 encoded */ ocpp::types::CiStringType<5600u> exiResponse; }; @@ -56,6 +58,7 @@ struct Get15118EVCertificateConf // Message converters MESSAGE_CONVERTERS(Get15118EVCertificate) +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/GetCertificateStatus.cpp b/src/ocpp16/messages/GetCertificateStatus.cpp similarity index 93% rename from src/messages/GetCertificateStatus.cpp rename to src/ocpp16/messages/GetCertificateStatus.cpp index 2aa7365b..9a3d1170 100644 --- a/src/messages/GetCertificateStatus.cpp +++ b/src/ocpp16/messages/GetCertificateStatus.cpp @@ -22,17 +22,23 @@ along with OpenOCPP. If not, see . #include "OcspRequestDataTypeConverter.h" using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { namespace types { +namespace ocpp16 +{ /** @brief Helper to convert a GetCertificateStatusEnumType enum to string */ const EnumToStringFromString GetCertificateStatusEnumTypeHelper = { {GetCertificateStatusEnumType::Accepted, "Accepted"}, {GetCertificateStatusEnumType::Failed, "Failed"}}; +} // namespace ocpp16 } // namespace types namespace messages { +namespace ocpp16 +{ /** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, DataType&, std::string&, std::string&) */ bool GetCertificateStatusReqConverter::fromJson(const rapidjson::Value& json, @@ -52,9 +58,8 @@ bool GetCertificateStatusReqConverter::toJson(const GetCertificateStatusReq& dat OcspRequestDataTypeConverter ocsp_request_converter; ocsp_request_converter.setAllocator(allocator); - rapidjson::Document value; - value.Parse("{}"); - bool ret = ocsp_request_converter.toJson(data.ocspRequestData, value); + rapidjson::Document value(rapidjson::kObjectType); + bool ret = ocsp_request_converter.toJson(data.ocspRequestData, value); if (ret) { json.AddMember(rapidjson::StringRef("ocspRequestData"), value.Move(), *allocator); @@ -83,5 +88,6 @@ bool GetCertificateStatusConfConverter::toJson(const GetCertificateStatusConf& d return true; } +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/GetCertificateStatus.h b/src/ocpp16/messages/GetCertificateStatus.h similarity index 92% rename from src/messages/GetCertificateStatus.h rename to src/ocpp16/messages/GetCertificateStatus.h index b42cd193..bcbb5161 100644 --- a/src/messages/GetCertificateStatus.h +++ b/src/ocpp16/messages/GetCertificateStatus.h @@ -29,6 +29,8 @@ namespace ocpp { namespace messages { +namespace ocpp16 +{ /** @brief Action corresponding to the GetCertificateStatus messages */ static const std::string GET_CERTIFICATE_STATUS_ACTION = "GetCertificateStatus"; @@ -37,14 +39,14 @@ static const std::string GET_CERTIFICATE_STATUS_ACTION = "GetCertificateStatus"; struct GetCertificateStatusReq { /** @brief Required. Indicates the certificate of which the status is requested */ - ocpp::types::OcspRequestDataType ocspRequestData; + ocpp::types::ocpp16::OcspRequestDataType ocspRequestData; }; /** @brief GetCertificateStatus.conf message */ struct GetCertificateStatusConf { /** @brief Required. This indicates whether the charging station was able to retrieve the OCSP certificate status */ - ocpp::types::GetCertificateStatusEnumType status; + ocpp::types::ocpp16::GetCertificateStatusEnumType status; /** @brief Optional. OCSPResponse class as defined in IETF RFC 6960. DER encoded (as defined in IETF RFC 6960), and then base64 encoded. MAY only be omitted when status is not Accepted */ @@ -54,6 +56,7 @@ struct GetCertificateStatusConf // Message converters MESSAGE_CONVERTERS(GetCertificateStatus) +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/GetCompositeSchedule.cpp b/src/ocpp16/messages/GetCompositeSchedule.cpp similarity index 96% rename from src/messages/GetCompositeSchedule.cpp rename to src/ocpp16/messages/GetCompositeSchedule.cpp index 8365c3ec..6f38aca6 100644 --- a/src/messages/GetCompositeSchedule.cpp +++ b/src/ocpp16/messages/GetCompositeSchedule.cpp @@ -21,20 +21,25 @@ along with OpenOCPP. If not, see . #include "IRpc.h" using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { namespace types { +namespace ocpp16 +{ /** @brief Helper to convert a enum class GetCompositeScheduleStatus enum to string */ const EnumToStringFromString GetCompositeScheduleStatusHelper = { {GetCompositeScheduleStatus::Accepted, "Accepted"}, {GetCompositeScheduleStatus::Rejected, "Rejected"}}; +} // namespace ocpp16 } // namespace types namespace messages { - +namespace ocpp16 +{ /** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, DataType&, std::string&, std::string&) */ bool GetCompositeScheduleReqConverter::fromJson(const rapidjson::Value& json, GetCompositeScheduleReq& data, @@ -99,13 +104,13 @@ bool GetCompositeScheduleConfConverter::toJson(const GetCompositeScheduleConf& d ChargingScheduleConverter charging_schedule_converter; charging_schedule_converter.setAllocator(allocator); - rapidjson::Document value; - value.Parse("{}"); + rapidjson::Document value(rapidjson::kObjectType); ret = charging_schedule_converter.toJson(data.chargingSchedule, value); json.AddMember(rapidjson::StringRef("chargingSchedule"), value.Move(), *allocator); } return ret; } +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/GetCompositeSchedule.h b/src/ocpp16/messages/GetCompositeSchedule.h similarity index 90% rename from src/messages/GetCompositeSchedule.h rename to src/ocpp16/messages/GetCompositeSchedule.h index 036a36fe..5bcec2bc 100644 --- a/src/messages/GetCompositeSchedule.h +++ b/src/ocpp16/messages/GetCompositeSchedule.h @@ -28,6 +28,8 @@ namespace ocpp { namespace messages { +namespace ocpp16 +{ /** @brief Action corresponding to the GetCompositeSchedule messages */ static const std::string GET_COMPOSITE_SCHEDULE_ACTION = "GetCompositeSchedule"; @@ -42,7 +44,7 @@ struct GetCompositeScheduleReq /** @brief Required. Time in seconds. length of requested schedule */ unsigned int duration; /** @brief Optional. Can be used to force a power or current profile */ - ocpp::types::Optional chargingRateUnit; + ocpp::types::Optional chargingRateUnit; }; /** @brief GetCompositeSchedule.conf message */ @@ -50,7 +52,7 @@ struct GetCompositeScheduleConf { /** @brief Required. Status of the request. The Charge Point will indicate if it was able to process the request */ - ocpp::types::GetCompositeScheduleStatus status; + ocpp::types::ocpp16::GetCompositeScheduleStatus status; /** @brief Optional. The charging schedule contained in this notification applies to a Connector */ ocpp::types::Optional connectorId; @@ -61,12 +63,13 @@ struct GetCompositeScheduleConf /** @brief Optional. Planned Composite Charging Schedule, the energy consumption over time. Always relative to ScheduleStart. If status is "Rejected", this field may be absent */ - ocpp::types::Optional chargingSchedule; + ocpp::types::Optional chargingSchedule; }; // Message converters MESSAGE_CONVERTERS(GetCompositeSchedule) +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/GetConfiguration.cpp b/src/ocpp16/messages/GetConfiguration.cpp similarity index 97% rename from src/messages/GetConfiguration.cpp rename to src/ocpp16/messages/GetConfiguration.cpp index 59dd38bb..5d4c90f1 100644 --- a/src/messages/GetConfiguration.cpp +++ b/src/ocpp16/messages/GetConfiguration.cpp @@ -20,12 +20,14 @@ along with OpenOCPP. If not, see . #include "IRpc.h" using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { namespace messages { - +namespace ocpp16 +{ /** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, DataType&, std::string&, std::string&) */ bool GetConfigurationReqConverter::fromJson(const rapidjson::Value& json, GetConfigurationReq& data, @@ -108,8 +110,7 @@ bool GetConfigurationConfConverter::toJson(const GetConfigurationConf& data, rap rapidjson::Document::AllocatorType& _allocator = json.GetAllocator(); for (const KeyValue& key : data.configurationKey.value()) { - rapidjson::Document value; - value.Parse("{}"); + rapidjson::Document value(rapidjson::kObjectType); fill(value, "key", key.key); fill(value, "readonly", key.readonly); fill(value, "value", key.value); @@ -132,5 +133,6 @@ bool GetConfigurationConfConverter::toJson(const GetConfigurationConf& data, rap return true; } +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/GetConfiguration.h b/src/ocpp16/messages/GetConfiguration.h similarity index 92% rename from src/messages/GetConfiguration.h rename to src/ocpp16/messages/GetConfiguration.h index 07b9e943..60e8163b 100644 --- a/src/messages/GetConfiguration.h +++ b/src/ocpp16/messages/GetConfiguration.h @@ -29,6 +29,8 @@ namespace ocpp { namespace messages { +namespace ocpp16 +{ /** @brief Action corresponding to the GetConfiguration messages */ static const std::string GET_CONFIGURATION_ACTION = "GetConfiguration"; @@ -44,7 +46,7 @@ struct GetConfigurationReq struct GetConfigurationConf { /** @brief Optional. List of requested or known keys */ - ocpp::types::Optional> configurationKey; + ocpp::types::Optional> configurationKey; /** @brief Optional. Requested keys that are unknown */ ocpp::types::Optional>> unknownKey; }; @@ -52,6 +54,7 @@ struct GetConfigurationConf // Message converters MESSAGE_CONVERTERS(GetConfiguration) +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/GetDiagnostics.cpp b/src/ocpp16/messages/GetDiagnostics.cpp similarity index 98% rename from src/messages/GetDiagnostics.cpp rename to src/ocpp16/messages/GetDiagnostics.cpp index 67e65e27..73e8868f 100644 --- a/src/messages/GetDiagnostics.cpp +++ b/src/ocpp16/messages/GetDiagnostics.cpp @@ -26,7 +26,8 @@ namespace ocpp { namespace messages { - +namespace ocpp16 +{ /** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, DataType&, std::string&, std::string&) */ bool GetDiagnosticsReqConverter::fromJson(const rapidjson::Value& json, GetDiagnosticsReq& data, @@ -78,5 +79,6 @@ bool GetDiagnosticsConfConverter::toJson(const GetDiagnosticsConf& data, rapidjs return true; } +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/GetDiagnostics.h b/src/ocpp16/messages/GetDiagnostics.h similarity index 98% rename from src/messages/GetDiagnostics.h rename to src/ocpp16/messages/GetDiagnostics.h index 25ea31ba..ef51554b 100644 --- a/src/messages/GetDiagnostics.h +++ b/src/ocpp16/messages/GetDiagnostics.h @@ -29,6 +29,8 @@ namespace ocpp { namespace messages { +namespace ocpp16 +{ /** @brief Action corresponding to the GetDiagnostics messages */ static const std::string GET_DIAGNOSTICS_ACTION = "GetDiagnostics"; @@ -67,6 +69,7 @@ struct GetDiagnosticsConf // Message converters MESSAGE_CONVERTERS(GetDiagnostics) +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/GetInstalledCertificateIds.cpp b/src/ocpp16/messages/GetInstalledCertificateIds.cpp similarity index 96% rename from src/messages/GetInstalledCertificateIds.cpp rename to src/ocpp16/messages/GetInstalledCertificateIds.cpp index 8b08e173..56441313 100644 --- a/src/messages/GetInstalledCertificateIds.cpp +++ b/src/ocpp16/messages/GetInstalledCertificateIds.cpp @@ -21,11 +21,14 @@ along with OpenOCPP. If not, see . #include "IRpc.h" using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { namespace types { +namespace ocpp16 +{ /** @brief Helper to convert a enum class CertificateUseEnumType enum to string */ const EnumToStringFromString CertificateUseEnumTypeHelper = { {CertificateUseEnumType::CentralSystemRootCertificate, "CentralSystemRootCertificate"}, @@ -35,9 +38,12 @@ const EnumToStringFromString CertificateUseEnumTypeHelpe const EnumToStringFromString GetInstalledCertificateStatusEnumTypeHelper = { {GetInstalledCertificateStatusEnumType::Accepted, "Accepted"}, {GetInstalledCertificateStatusEnumType::NotFound, "NotFound"}}; +} // namespace ocpp16 } // namespace types namespace messages { +namespace ocpp16 +{ /** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, DataType&, std::string&, std::string&) */ bool GetInstalledCertificateIdsReqConverter::fromJson(const rapidjson::Value& json, @@ -92,8 +98,7 @@ bool GetInstalledCertificateIdsConfConverter::toJson(const GetInstalledCertifica certificate_hash_converter.setAllocator(allocator); for (const CertificateHashDataType& certificate_hash : data.certificateHashData) { - rapidjson::Document value; - value.Parse("{}"); + rapidjson::Document value(rapidjson::kObjectType); ret = ret && certificate_hash_converter.toJson(certificate_hash, value); certificateHashData.PushBack(value.Move(), *allocator); } @@ -102,5 +107,6 @@ bool GetInstalledCertificateIdsConfConverter::toJson(const GetInstalledCertifica return ret; } +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/GetInstalledCertificateIds.h b/src/ocpp16/messages/GetInstalledCertificateIds.h similarity index 87% rename from src/messages/GetInstalledCertificateIds.h rename to src/ocpp16/messages/GetInstalledCertificateIds.h index 333cee0d..b273af93 100644 --- a/src/messages/GetInstalledCertificateIds.h +++ b/src/ocpp16/messages/GetInstalledCertificateIds.h @@ -29,6 +29,8 @@ namespace ocpp { namespace messages { +namespace ocpp16 +{ /** @brief Action corresponding to the GetInstalledCertificateIds messages */ static const std::string GET_INSTALLED_CERTIFICATE_IDS_ACTION = "GetInstalledCertificateIds"; @@ -37,22 +39,23 @@ static const std::string GET_INSTALLED_CERTIFICATE_IDS_ACTION = "GetInstalledCer struct GetInstalledCertificateIdsReq { /** @brief Required. Indicates the type of certificates requested */ - ocpp::types::CertificateUseEnumType certificateType; + ocpp::types::ocpp16::CertificateUseEnumType certificateType; }; /** @brief GetInstalledCertificateIds.conf message */ struct GetInstalledCertificateIdsConf { /** @brief Required. Charge Point indicates if it can process the request */ - ocpp::types::GetInstalledCertificateStatusEnumType status; + ocpp::types::ocpp16::GetInstalledCertificateStatusEnumType status; /** @brief Optional. The Charge Point includes the Certificate information for each available certificate */ - std::vector certificateHashData; + std::vector certificateHashData; }; // Message converters MESSAGE_CONVERTERS(GetInstalledCertificateIds) +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/GetLocalListVersion.cpp b/src/ocpp16/messages/GetLocalListVersion.cpp similarity index 98% rename from src/messages/GetLocalListVersion.cpp rename to src/ocpp16/messages/GetLocalListVersion.cpp index 87646abc..1fec2cfc 100644 --- a/src/messages/GetLocalListVersion.cpp +++ b/src/ocpp16/messages/GetLocalListVersion.cpp @@ -25,7 +25,8 @@ namespace ocpp { namespace messages { - +namespace ocpp16 +{ /** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, DataType&, std::string&, std::string&) */ bool GetLocalListVersionReqConverter::fromJson(const rapidjson::Value& json, GetLocalListVersionReq& data, @@ -66,5 +67,6 @@ bool GetLocalListVersionConfConverter::toJson(const GetLocalListVersionConf& dat return true; } +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/GetLocalListVersion.h b/src/ocpp16/messages/GetLocalListVersion.h similarity index 97% rename from src/messages/GetLocalListVersion.h rename to src/ocpp16/messages/GetLocalListVersion.h index e5bccbf0..bc54f750 100644 --- a/src/messages/GetLocalListVersion.h +++ b/src/ocpp16/messages/GetLocalListVersion.h @@ -25,6 +25,8 @@ namespace ocpp { namespace messages { +namespace ocpp16 +{ /** @brief Action corresponding to the GetLocalListVersion messages */ static const std::string GET_LOCAL_LIST_VERSION_ACTION = "GetLocalListVersion"; @@ -46,6 +48,7 @@ struct GetLocalListVersionConf // Message converters MESSAGE_CONVERTERS(GetLocalListVersion) +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/GetLog.cpp b/src/ocpp16/messages/GetLog.cpp similarity index 96% rename from src/messages/GetLog.cpp rename to src/ocpp16/messages/GetLog.cpp index d39f91cf..324b98c3 100644 --- a/src/messages/GetLog.cpp +++ b/src/ocpp16/messages/GetLog.cpp @@ -21,11 +21,14 @@ along with OpenOCPP. If not, see . #include "Url.h" using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { namespace types { +namespace ocpp16 +{ /** @brief Helper to convert a LogEnumType enum to string */ const EnumToStringFromString LogEnumTypeHelper = {{LogEnumType::DiagnosticsLog, "DiagnosticsLog"}, @@ -35,9 +38,12 @@ const EnumToStringFromString LogStatusEnumTypeHelper = {{LogS {LogStatusEnumType::Rejected, "Rejected"}, {LogStatusEnumType::AcceptedCanceled, "AcceptedCanceled"}}; +} // namespace ocpp16 } // namespace types namespace messages { +namespace ocpp16 +{ /** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, DataType&, std::string&, std::string&) */ bool GetLogReqConverter::fromJson(const rapidjson::Value& json, GetLogReq& data, std::string& error_code, std::string& error_message) @@ -69,8 +75,7 @@ bool GetLogReqConverter::toJson(const GetLogReq& data, rapidjson::Document& json fill(json, "retries", data.retries); fill(json, "retryInterval", data.retryInterval); - rapidjson::Document log; - log.Parse("{}"); + rapidjson::Document log(rapidjson::kObjectType); fill(log, "remoteLocation", data.log.remoteLocation); fill(log, "oldestTimestamp", data.log.oldestTimestamp); fill(log, "latestTimestamp", data.log.latestTimestamp); @@ -96,5 +101,6 @@ bool GetLogConfConverter::toJson(const GetLogConf& data, rapidjson::Document& js return true; } +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/GetLog.h b/src/ocpp16/messages/GetLog.h similarity index 92% rename from src/messages/GetLog.h rename to src/ocpp16/messages/GetLog.h index 853817b2..cff9dd78 100644 --- a/src/messages/GetLog.h +++ b/src/ocpp16/messages/GetLog.h @@ -28,6 +28,8 @@ namespace ocpp { namespace messages { +namespace ocpp16 +{ /** @brief Action corresponding to the GetLog messages */ static const std::string GET_LOG_ACTION = "GetLog"; @@ -36,7 +38,7 @@ static const std::string GET_LOG_ACTION = "GetLog"; struct GetLogReq { /** @brief Required. This contains the type of log file that the Charge Point should send */ - ocpp::types::LogEnumType logType; + ocpp::types::ocpp16::LogEnumType logType; /** @brief Required. The Id of this request */ int requestId; /** @brief Optional. This specifies how many times the Charge Point must try to upload the @@ -49,7 +51,7 @@ struct GetLogReq ocpp::types::Optional retryInterval; /** @brief Required. This field specifies the requested log and the location to which the log should be sent */ - ocpp::types::LogParametersType log; + ocpp::types::ocpp16::LogParametersType log; }; /** @brief GetLog.conf message */ @@ -57,7 +59,7 @@ struct GetLogConf { /** @brief Required. This field indicates whether the Charge Point was able to accept the request */ - ocpp::types::LogStatusEnumType status; + ocpp::types::ocpp16::LogStatusEnumType status; /** @brief Optional. This contains the name of the log file that will be uploaded. This field is not present when no logging information is available. */ ocpp::types::CiStringType<255> fileName; @@ -66,6 +68,7 @@ struct GetLogConf // Message converters MESSAGE_CONVERTERS(GetLog) +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/Heartbeat.cpp b/src/ocpp16/messages/Heartbeat.cpp similarity index 98% rename from src/messages/Heartbeat.cpp rename to src/ocpp16/messages/Heartbeat.cpp index ce4d38a2..59fe4b15 100644 --- a/src/messages/Heartbeat.cpp +++ b/src/ocpp16/messages/Heartbeat.cpp @@ -25,7 +25,8 @@ namespace ocpp { namespace messages { - +namespace ocpp16 +{ /** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, DataType&, std::string&, std::string&) */ bool HeartbeatReqConverter::fromJson(const rapidjson::Value& json, HeartbeatReq& data, std::string& error_code, std::string& error_message) { @@ -65,5 +66,6 @@ bool HeartbeatConfConverter::toJson(const HeartbeatConf& data, rapidjson::Docume return true; } +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/Heartbeat.h b/src/ocpp16/messages/Heartbeat.h similarity index 97% rename from src/messages/Heartbeat.h rename to src/ocpp16/messages/Heartbeat.h index 134dec2e..711b718e 100644 --- a/src/messages/Heartbeat.h +++ b/src/ocpp16/messages/Heartbeat.h @@ -26,6 +26,8 @@ namespace ocpp { namespace messages { +namespace ocpp16 +{ /** @brief Action corresponding to the Heartbeat messages */ static const std::string HEARTBEAT_ACTION = "Heartbeat"; @@ -46,6 +48,7 @@ struct HeartbeatConf // Message converters MESSAGE_CONVERTERS(Heartbeat) +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/InstallCertificate.cpp b/src/ocpp16/messages/InstallCertificate.cpp similarity index 96% rename from src/messages/InstallCertificate.cpp rename to src/ocpp16/messages/InstallCertificate.cpp index cf244f49..ef3f34a6 100644 --- a/src/messages/InstallCertificate.cpp +++ b/src/ocpp16/messages/InstallCertificate.cpp @@ -20,11 +20,14 @@ along with OpenOCPP. If not, see . #include "IRpc.h" using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { namespace types { +namespace ocpp16 +{ /** @brief Helper to convert a enum class CertificateStatusEnumType enum to string */ const EnumToStringFromString CertificateStatusEnumTypeHelper = { @@ -32,9 +35,12 @@ const EnumToStringFromString CertificateStatusEnumTyp {CertificateStatusEnumType::Failed, "Failed"}, {CertificateStatusEnumType::Rejected, "Rejected"}}; +} // namespace ocpp16 } // namespace types namespace messages { +namespace ocpp16 +{ /** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, DataType&, std::string&, std::string&) */ bool InstallCertificateReqConverter::fromJson(const rapidjson::Value& json, @@ -76,5 +82,6 @@ bool InstallCertificateConfConverter::toJson(const InstallCertificateConf& data, return true; } +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/InstallCertificate.h b/src/ocpp16/messages/InstallCertificate.h similarity index 90% rename from src/messages/InstallCertificate.h rename to src/ocpp16/messages/InstallCertificate.h index 1d7bee07..5e8146f3 100644 --- a/src/messages/InstallCertificate.h +++ b/src/ocpp16/messages/InstallCertificate.h @@ -29,6 +29,8 @@ namespace ocpp { namespace messages { +namespace ocpp16 +{ /** @brief Action corresponding to the InstallCertificate messages */ static const std::string INSTALL_CERTIFICATE_ACTION = "InstallCertificate"; @@ -37,7 +39,7 @@ static const std::string INSTALL_CERTIFICATE_ACTION = "InstallCertificate"; struct InstallCertificateReq { /** @brief Required. Indicates the certificate type that is sent */ - ocpp::types::CertificateUseEnumType certificateType; + ocpp::types::ocpp16::CertificateUseEnumType certificateType; /** @brief Required. An PEM encoded X.509 certificate */ ocpp::types::CiStringType<5500u> certificate; }; @@ -46,12 +48,13 @@ struct InstallCertificateReq struct InstallCertificateConf { /** @brief Required. Charge Point indicates if installation was successful */ - ocpp::types::CertificateStatusEnumType status; + ocpp::types::ocpp16::CertificateStatusEnumType status; }; // Message converters MESSAGE_CONVERTERS(InstallCertificate) +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/Iso15118.h b/src/ocpp16/messages/Iso15118.h similarity index 96% rename from src/messages/Iso15118.h rename to src/ocpp16/messages/Iso15118.h index d24ae595..0697ddfe 100644 --- a/src/messages/Iso15118.h +++ b/src/ocpp16/messages/Iso15118.h @@ -25,10 +25,13 @@ namespace ocpp { namespace messages { +namespace ocpp16 +{ /** @brief Vendor id for ISO 15118 PnC extensions messages */ static const std::string ISO15118_VENDOR_ID = "org.openchargealliance.iso15118pnc"; +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/Iso15118Authorize.cpp b/src/ocpp16/messages/Iso15118Authorize.cpp similarity index 94% rename from src/messages/Iso15118Authorize.cpp rename to src/ocpp16/messages/Iso15118Authorize.cpp index f5caf86e..1023b517 100644 --- a/src/messages/Iso15118Authorize.cpp +++ b/src/ocpp16/messages/Iso15118Authorize.cpp @@ -22,11 +22,14 @@ along with OpenOCPP. If not, see . #include "OcspRequestDataTypeConverter.h" using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { namespace types { +namespace ocpp16 +{ /** @brief Helper to convert a AuthorizeCertificateStatusEnumType enum to string */ const EnumToStringFromString AuthorizeCertificateStatusEnumTypeHelper = { {AuthorizeCertificateStatusEnumType::Accepted, "Accepted"}, @@ -36,9 +39,12 @@ const EnumToStringFromString AuthorizeCertif {AuthorizeCertificateStatusEnumType::ContractCancelled, "ContractCancelled"}, {AuthorizeCertificateStatusEnumType::NoCertificateAvailable, "NoCertificateAvailable"}, {AuthorizeCertificateStatusEnumType::SignatureError, "SignatureError"}}; +} // namespace ocpp16 } // namespace types namespace messages { +namespace ocpp16 +{ /** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, DataType&, std::string&, std::string&) */ bool Iso15118AuthorizeReqConverter::fromJson(const rapidjson::Value& json, @@ -79,8 +85,7 @@ bool Iso15118AuthorizeReqConverter::toJson(const Iso15118AuthorizeReq& data, rap certificate_hash_converter.setAllocator(allocator); for (const OcspRequestDataType& certificate_hash : data.iso15118CertificateHashData) { - rapidjson::Document value; - value.Parse("{}"); + rapidjson::Document value(rapidjson::kObjectType); ret = ret && certificate_hash_converter.toJson(certificate_hash, value); certificateHashData.PushBack(value.Move(), *allocator); } @@ -109,9 +114,8 @@ bool Iso15118AuthorizeConfConverter::toJson(const Iso15118AuthorizeConf& data, r { IdTokenInfoTypeConverter id_token_info_converter; id_token_info_converter.setAllocator(allocator); - rapidjson::Document id_token_info; - id_token_info.Parse("{}"); - bool ret = id_token_info_converter.toJson(data.idTokenInfo, id_token_info); + rapidjson::Document id_token_info(rapidjson::kObjectType); + bool ret = id_token_info_converter.toJson(data.idTokenInfo, id_token_info); json.AddMember(rapidjson::StringRef("idTokenInfo"), id_token_info.Move(), *allocator); if (data.certificateStatus.isSet()) { @@ -120,5 +124,6 @@ bool Iso15118AuthorizeConfConverter::toJson(const Iso15118AuthorizeConf& data, r return ret; } +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/Iso15118Authorize.h b/src/ocpp16/messages/Iso15118Authorize.h similarity index 86% rename from src/messages/Iso15118Authorize.h rename to src/ocpp16/messages/Iso15118Authorize.h index 26786b1f..d3570c69 100644 --- a/src/messages/Iso15118Authorize.h +++ b/src/ocpp16/messages/Iso15118Authorize.h @@ -31,6 +31,8 @@ namespace ocpp { namespace messages { +namespace ocpp16 +{ /** @brief Action corresponding to the Iso15118Authorize messages */ static const std::string ISO15118_AUTHORIZE_ACTION = "Authorize"; @@ -41,9 +43,9 @@ struct Iso15118AuthorizeReq /** @brief Optional. The X.509 certificated presented by EV and encoded in PEM format */ ocpp::types::Optional> certificate; /** @brief Required. This contains the identifier that needs to be authorized */ - ocpp::types::IdToken idToken; + ocpp::types::ocpp16::IdToken idToken; /** @brief Optional. Contains the information needed to verify the EV Contract Certificate via OCSP */ - std::vector iso15118CertificateHashData; + std::vector iso15118CertificateHashData; }; /** @brief Iso15118Authorize.conf message */ @@ -52,15 +54,16 @@ struct Iso15118AuthorizeConf /** @brief Optional. Certificate status information. - if all certificates are valid: return 'Accepted'. - if one of the certificates was revoked, return 'CertificateRevoked' */ - ocpp::types::Optional certificateStatus; + ocpp::types::Optional certificateStatus; /** @brief Required. This contains information about authorization status, expiry and group id */ - ocpp::types::IdTokenInfoType idTokenInfo; + ocpp::types::ocpp16::IdTokenInfoType idTokenInfo; }; // Message converters MESSAGE_CONVERTERS(Iso15118Authorize) +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/Iso15118GetInstalledCertificateIds.cpp b/src/ocpp16/messages/Iso15118GetInstalledCertificateIds.cpp similarity index 97% rename from src/messages/Iso15118GetInstalledCertificateIds.cpp rename to src/ocpp16/messages/Iso15118GetInstalledCertificateIds.cpp index 89d6d8d9..cec960ac 100644 --- a/src/messages/Iso15118GetInstalledCertificateIds.cpp +++ b/src/ocpp16/messages/Iso15118GetInstalledCertificateIds.cpp @@ -21,12 +21,14 @@ along with OpenOCPP. If not, see . #include "IRpc.h" using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { namespace messages { - +namespace ocpp16 +{ /** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, DataType&, std::string&, std::string&) */ bool Iso15118GetInstalledCertificateIdsReqConverter::fromJson(const rapidjson::Value& json, Iso15118GetInstalledCertificateIdsReq& data, @@ -96,8 +98,7 @@ bool Iso15118GetInstalledCertificateIdsConfConverter::toJson(const Iso15118GetIn certificate_hash_converter.setAllocator(allocator); for (const CertificateHashDataChainType& certificate_hash : data.certificateHashDataChain) { - rapidjson::Document value; - value.Parse("{}"); + rapidjson::Document value(rapidjson::kObjectType); ret = ret && certificate_hash_converter.toJson(certificate_hash, value); certificateHashDataChain.PushBack(value.Move(), *allocator); } @@ -106,5 +107,6 @@ bool Iso15118GetInstalledCertificateIdsConfConverter::toJson(const Iso15118GetIn return ret; } +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/Iso15118GetInstalledCertificateIds.h b/src/ocpp16/messages/Iso15118GetInstalledCertificateIds.h similarity index 86% rename from src/messages/Iso15118GetInstalledCertificateIds.h rename to src/ocpp16/messages/Iso15118GetInstalledCertificateIds.h index 683941a8..c32d4eb8 100644 --- a/src/messages/Iso15118GetInstalledCertificateIds.h +++ b/src/ocpp16/messages/Iso15118GetInstalledCertificateIds.h @@ -29,6 +29,8 @@ namespace ocpp { namespace messages { +namespace ocpp16 +{ /** @brief Action corresponding to the Iso15118GetInstalledCertificateIds messages */ static const std::string ISO15118_GET_INSTALLED_CERTIFICATE_IDS_ACTION = "GetInstalledCertificateIds"; @@ -37,22 +39,23 @@ static const std::string ISO15118_GET_INSTALLED_CERTIFICATE_IDS_ACTION = "GetIns struct Iso15118GetInstalledCertificateIdsReq { /** @brief Optional. Indicates the type of certificates requested. When omitted, all certificate types are requested */ - std::vector certificateType; + std::vector certificateType; }; /** @brief Iso15118GetInstalledCertificateIds.conf message */ struct Iso15118GetInstalledCertificateIdsConf { /** @brief Required. Charge Point indicates if it can process the request */ - ocpp::types::GetInstalledCertificateStatusEnumType status; + ocpp::types::ocpp16::GetInstalledCertificateStatusEnumType status; /** @brief Optional. The Charge Point includes the Certificate information for each available certificate */ - std::vector certificateHashDataChain; + std::vector certificateHashDataChain; }; // Message converters MESSAGE_CONVERTERS(Iso15118GetInstalledCertificateIds) +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/Iso15118InstallCertificate.cpp b/src/ocpp16/messages/Iso15118InstallCertificate.cpp similarity index 97% rename from src/messages/Iso15118InstallCertificate.cpp rename to src/ocpp16/messages/Iso15118InstallCertificate.cpp index 38579306..4fea1644 100644 --- a/src/messages/Iso15118InstallCertificate.cpp +++ b/src/ocpp16/messages/Iso15118InstallCertificate.cpp @@ -20,11 +20,14 @@ along with OpenOCPP. If not, see . #include "IRpc.h" using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { namespace types { +namespace ocpp16 +{ /** @brief Helper to convert a enum class InstallCertificateUseEnumType enum to string */ const EnumToStringFromString InstallCertificateUseEnumTypeHelper = { @@ -38,9 +41,12 @@ const EnumToStringFromString InstallCertificat {InstallCertificateStatusEnumType::Failed, "Failed"}, {InstallCertificateStatusEnumType::Rejected, "Rejected"}}; +} // namespace ocpp16 } // namespace types namespace messages { +namespace ocpp16 +{ /** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, DataType&, std::string&, std::string&) */ bool Iso15118InstallCertificateReqConverter::fromJson(const rapidjson::Value& json, @@ -82,5 +88,6 @@ bool Iso15118InstallCertificateConfConverter::toJson(const Iso15118InstallCertif return true; } +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/Iso15118InstallCertificate.h b/src/ocpp16/messages/Iso15118InstallCertificate.h similarity index 90% rename from src/messages/Iso15118InstallCertificate.h rename to src/ocpp16/messages/Iso15118InstallCertificate.h index e8f25713..8fc0cfac 100644 --- a/src/messages/Iso15118InstallCertificate.h +++ b/src/ocpp16/messages/Iso15118InstallCertificate.h @@ -29,6 +29,8 @@ namespace ocpp { namespace messages { +namespace ocpp16 +{ /** @brief Action corresponding to the Iso15118InstallCertificate messages */ static const std::string ISO15118_INSTALL_CERTIFICATE_ACTION = "InstallCertificate"; @@ -37,7 +39,7 @@ static const std::string ISO15118_INSTALL_CERTIFICATE_ACTION = "InstallCertifica struct Iso15118InstallCertificateReq { /** @brief Required. Indicates the certificate type that is sent */ - ocpp::types::InstallCertificateUseEnumType certificateType; + ocpp::types::ocpp16::InstallCertificateUseEnumType certificateType; /** @brief Required. An PEM encoded X.509 certificate */ ocpp::types::CiStringType<5500u> certificate; }; @@ -46,12 +48,13 @@ struct Iso15118InstallCertificateReq struct Iso15118InstallCertificateConf { /** @brief Required. Charge Point indicates if installation was successful */ - ocpp::types::InstallCertificateStatusEnumType status; + ocpp::types::ocpp16::InstallCertificateStatusEnumType status; }; // Message converters MESSAGE_CONVERTERS(Iso15118InstallCertificate) +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/Iso15118TriggerMessage.cpp b/src/ocpp16/messages/Iso15118TriggerMessage.cpp similarity index 97% rename from src/messages/Iso15118TriggerMessage.cpp rename to src/ocpp16/messages/Iso15118TriggerMessage.cpp index e7b0d0bd..6aac1ee0 100644 --- a/src/messages/Iso15118TriggerMessage.cpp +++ b/src/ocpp16/messages/Iso15118TriggerMessage.cpp @@ -20,12 +20,14 @@ along with OpenOCPP. If not, see . #include "IRpc.h" using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { namespace messages { - +namespace ocpp16 +{ /** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, DataType&, std::string&, std::string&) */ bool Iso15118TriggerMessageReqConverter::fromJson(const rapidjson::Value& json, Iso15118TriggerMessageReq& data, @@ -66,5 +68,6 @@ bool Iso15118TriggerMessageConfConverter::toJson(const Iso15118TriggerMessageCon return true; } +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/Iso15118TriggerMessage.h b/src/ocpp16/messages/Iso15118TriggerMessage.h similarity index 93% rename from src/messages/Iso15118TriggerMessage.h rename to src/ocpp16/messages/Iso15118TriggerMessage.h index f52e357a..745d8986 100644 --- a/src/messages/Iso15118TriggerMessage.h +++ b/src/ocpp16/messages/Iso15118TriggerMessage.h @@ -26,6 +26,8 @@ namespace ocpp { namespace messages { +namespace ocpp16 +{ /** @brief Action corresponding to the Iso15118TriggerMessage messages */ static const std::string ISO15118_TRIGGER_MESSAGE_ACTION = "TriggerMessage"; @@ -41,12 +43,13 @@ struct Iso15118TriggerMessageConf { /** @brief Required. Indicates whether the Charge Point will send the requested notification or not */ - ocpp::types::TriggerMessageStatusEnumType status; + ocpp::types::ocpp16::TriggerMessageStatusEnumType status; }; // Message converters MESSAGE_CONVERTERS(Iso15118TriggerMessage) +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/LogStatusNotification.cpp b/src/ocpp16/messages/LogStatusNotification.cpp similarity index 96% rename from src/messages/LogStatusNotification.cpp rename to src/ocpp16/messages/LogStatusNotification.cpp index 19252923..4d9c685f 100644 --- a/src/messages/LogStatusNotification.cpp +++ b/src/ocpp16/messages/LogStatusNotification.cpp @@ -20,11 +20,14 @@ along with OpenOCPP. If not, see . #include "IRpc.h" using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { namespace types { +namespace ocpp16 +{ /** @brief Helper to convert a enum class UploadLogStatusEnumType enum to string */ const EnumToStringFromString UploadLogStatusEnumTypeHelper = { {UploadLogStatusEnumType::BadMessage, "BadMessage"}, @@ -35,11 +38,13 @@ const EnumToStringFromString UploadLogStatusEnumTypeHel {UploadLogStatusEnumType::UploadFailure, "UploadFailure"}, {UploadLogStatusEnumType::Uploading, "Uploading"}}; +} // namespace ocpp16 } // namespace types namespace messages { - +namespace ocpp16 +{ /** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, DataType&, std::string&, std::string&) */ bool LogStatusNotificationReqConverter::fromJson(const rapidjson::Value& json, LogStatusNotificationReq& data, @@ -82,5 +87,6 @@ bool LogStatusNotificationConfConverter::toJson(const LogStatusNotificationConf& return true; } +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/LogStatusNotification.h b/src/ocpp16/messages/LogStatusNotification.h similarity index 94% rename from src/messages/LogStatusNotification.h rename to src/ocpp16/messages/LogStatusNotification.h index e6d6cecf..6cac6a0e 100644 --- a/src/messages/LogStatusNotification.h +++ b/src/ocpp16/messages/LogStatusNotification.h @@ -27,6 +27,8 @@ namespace ocpp { namespace messages { +namespace ocpp16 +{ /** @brief Action corresponding to the LogStatusNotification messages */ static const std::string LOG_STATUS_NOTIFICATION_ACTION = "LogStatusNotification"; @@ -35,7 +37,7 @@ static const std::string LOG_STATUS_NOTIFICATION_ACTION = "LogStatusNotification struct LogStatusNotificationReq { /** @brief Required. This contains the status of the log upload */ - ocpp::types::UploadLogStatusEnumType status; + ocpp::types::ocpp16::UploadLogStatusEnumType status; /** @brief Optional. The request id that was provided in the GetLog.req that started this log upload */ ocpp::types::Optional requestId; @@ -50,6 +52,7 @@ struct LogStatusNotificationConf // Message converters MESSAGE_CONVERTERS(LogStatusNotification) +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/MessagesConverter.cpp b/src/ocpp16/messages/MessagesConverter.cpp similarity index 99% rename from src/messages/MessagesConverter.cpp rename to src/ocpp16/messages/MessagesConverter.cpp index 26a173b0..b55ed7b9 100644 --- a/src/messages/MessagesConverter.cpp +++ b/src/ocpp16/messages/MessagesConverter.cpp @@ -78,6 +78,9 @@ namespace ocpp { namespace messages { +namespace ocpp16 +{ + /** @brief Constructor */ MessagesConverter::MessagesConverter() { @@ -179,5 +182,6 @@ MessagesConverter::~MessagesConverter() DELETE_CONVERTER(UpdateFirmware); } +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/MessagesConverter.h b/src/ocpp16/messages/MessagesConverter.h similarity index 96% rename from src/messages/MessagesConverter.h rename to src/ocpp16/messages/MessagesConverter.h index 1a912bf7..3141a5b7 100644 --- a/src/messages/MessagesConverter.h +++ b/src/ocpp16/messages/MessagesConverter.h @@ -25,6 +25,8 @@ namespace ocpp { namespace messages { +namespace ocpp16 +{ /** @brief Stores all the needed message converters */ class MessagesConverter : public GenericMessagesConverter @@ -36,6 +38,7 @@ class MessagesConverter : public GenericMessagesConverter virtual ~MessagesConverter(); }; +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/MessagesValidator.cpp b/src/ocpp16/messages/MessagesValidator.cpp similarity index 99% rename from src/messages/MessagesValidator.cpp rename to src/ocpp16/messages/MessagesValidator.cpp index 7a150abe..0e97d63c 100644 --- a/src/messages/MessagesValidator.cpp +++ b/src/ocpp16/messages/MessagesValidator.cpp @@ -63,6 +63,9 @@ namespace ocpp { namespace messages { +namespace ocpp16 +{ + /** @brief Constructor */ MessagesValidator::MessagesValidator() : m_req_validators(), m_resp_validators() { } @@ -189,5 +192,6 @@ bool MessagesValidator::addValidator(const std::filesystem::path& validator_path return ret; } +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/MessagesValidator.h b/src/ocpp16/messages/MessagesValidator.h similarity index 83% rename from src/messages/MessagesValidator.h rename to src/ocpp16/messages/MessagesValidator.h index 3d24e466..e9bd24bc 100644 --- a/src/messages/MessagesValidator.h +++ b/src/ocpp16/messages/MessagesValidator.h @@ -19,20 +19,21 @@ along with OpenOCPP. If not, see . #ifndef OPENOCPP_MESSAGESVALIDATOR_H #define OPENOCPP_MESSAGESVALIDATOR_H -#include "JsonValidator.h" +#include "IMessagesValidator.h" #include #include -#include #include namespace ocpp { namespace messages { +namespace ocpp16 +{ /** @brief Stores all the needed message validators */ -class MessagesValidator +class MessagesValidator : public IMessagesValidator { public: /** @brief Constructor */ @@ -46,13 +47,8 @@ class MessagesValidator */ bool load(const std::string& schemas_path); - /** - * @brief Get the message validator corresponding to a given action - * @param action Action corresponding to the message - * @param is_req Indicate if the validator if for the request or the response - * @return Message validator if it exists, nullptr otherwise - */ - ocpp::json::JsonValidator* getValidator(const std::string& action, bool is_req) const; + /** @copydoc ocpp::json::JsonValidator* IMessagesValidator::getValidator(const std::string&, bool) const */ + ocpp::json::JsonValidator* getValidator(const std::string& action, bool is_req) const override; private: /** @brief Messages validators for requests */ @@ -66,6 +62,7 @@ class MessagesValidator bool addValidator(const std::filesystem::path& validator_path, const std::string& action, bool is_req); }; +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/MeterValues.cpp b/src/ocpp16/messages/MeterValues.cpp similarity index 98% rename from src/messages/MeterValues.cpp rename to src/ocpp16/messages/MeterValues.cpp index 5d488930..84885048 100644 --- a/src/messages/MeterValues.cpp +++ b/src/ocpp16/messages/MeterValues.cpp @@ -21,11 +21,14 @@ along with OpenOCPP. If not, see . #include "MeterValueConverter.h" using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { namespace types { +namespace ocpp16 +{ /** @brief Helper to convert a ReadingContext enum to string */ const EnumToStringFromString ReadingContextHelper = {{ReadingContext::InterruptionBegin, "Interruption.Begin"}, {ReadingContext::InterruptionEnd, "Interruption.End"}, @@ -91,11 +94,13 @@ const EnumToStringFromString UnitOfMeasureHelper = {{UnitOfMeasur {UnitOfMeasure::varh, "varh"}, {UnitOfMeasure::W, "W"}, {UnitOfMeasure::Wh, "Wh"}}; +} // namespace ocpp16 } // namespace types namespace messages { - +namespace ocpp16 +{ /** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, DataType&, std::string&, std::string&) */ bool MeterValuesReqConverter::fromJson(const rapidjson::Value& json, MeterValuesReq& data, @@ -129,8 +134,7 @@ bool MeterValuesReqConverter::toJson(const MeterValuesReq& data, rapidjson::Docu metervalue_converter.setAllocator(allocator); for (const MeterValue& meter_value : data.meterValue) { - rapidjson::Document value; - value.Parse("{}"); + rapidjson::Document value(rapidjson::kObjectType); ret = ret && metervalue_converter.toJson(meter_value, value); meterValue.PushBack(value.Move(), *allocator); } @@ -160,5 +164,6 @@ bool MeterValuesConfConverter::toJson(const MeterValuesConf& data, rapidjson::Do return true; } +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/MeterValues.h b/src/ocpp16/messages/MeterValues.h similarity index 94% rename from src/messages/MeterValues.h rename to src/ocpp16/messages/MeterValues.h index 4d731529..fa60f142 100644 --- a/src/messages/MeterValues.h +++ b/src/ocpp16/messages/MeterValues.h @@ -30,6 +30,8 @@ namespace ocpp { namespace messages { +namespace ocpp16 +{ /** @brief Action corresponding to the MeterValues messages */ static const std::string METER_VALUES_ACTION = "MeterValues"; @@ -43,7 +45,7 @@ struct MeterValuesReq /** @brief Optional. The transaction to which these meter samples are related */ ocpp::types::Optional transactionId; /** @brief Required. The sampled meter values with timestamps */ - std::vector meterValue; + std::vector meterValue; }; /** @brief MeterValues.conf message */ @@ -55,6 +57,7 @@ struct MeterValuesConf // Message converters MESSAGE_CONVERTERS(MeterValues) +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/RemoteStartTransaction.cpp b/src/ocpp16/messages/RemoteStartTransaction.cpp similarity index 95% rename from src/messages/RemoteStartTransaction.cpp rename to src/ocpp16/messages/RemoteStartTransaction.cpp index 4320fd6c..95deb22f 100644 --- a/src/messages/RemoteStartTransaction.cpp +++ b/src/ocpp16/messages/RemoteStartTransaction.cpp @@ -21,20 +21,25 @@ along with OpenOCPP. If not, see . #include "IRpc.h" using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { namespace types { +namespace ocpp16 +{ /** @brief Helper to convert a enum class RemoteStartStopStatus enum to string */ const EnumToStringFromString RemoteStartStopStatusHelper = {{RemoteStartStopStatus::Accepted, "Accepted"}, {RemoteStartStopStatus::Rejected, "Rejected"}}; +} // namespace ocpp16 } // namespace types namespace messages { - +namespace ocpp16 +{ /** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, DataType&, std::string&, std::string&) */ bool RemoteStartTransactionReqConverter::fromJson(const rapidjson::Value& json, RemoteStartTransactionReq& data, @@ -70,9 +75,7 @@ bool RemoteStartTransactionReqConverter::toJson(const RemoteStartTransactionReq& ChargingProfileConverter charging_profile_converter; charging_profile_converter.setAllocator(allocator); - rapidjson::Document chargingProfile; - chargingProfile.Parse("{}"); - + rapidjson::Document chargingProfile(rapidjson::kObjectType); ret = charging_profile_converter.toJson(data.chargingProfile, chargingProfile); json.AddMember(rapidjson::StringRef("chargingProfile"), chargingProfile.Move(), *allocator); } @@ -99,5 +102,6 @@ bool RemoteStartTransactionConfConverter::toJson(const RemoteStartTransactionCon return true; } +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/RemoteStartTransaction.h b/src/ocpp16/messages/RemoteStartTransaction.h similarity index 90% rename from src/messages/RemoteStartTransaction.h rename to src/ocpp16/messages/RemoteStartTransaction.h index 74497850..8b7d0d67 100644 --- a/src/messages/RemoteStartTransaction.h +++ b/src/ocpp16/messages/RemoteStartTransaction.h @@ -29,6 +29,8 @@ namespace ocpp { namespace messages { +namespace ocpp16 +{ /** @brief Action corresponding to the RemoteStartTransaction messages */ static const std::string REMOTE_START_TRANSACTION_ACTION = "RemoteStartTransaction"; @@ -40,10 +42,10 @@ struct RemoteStartTransactionReq connectorId SHALL be > 0 */ ocpp::types::Optional connectorId; /** @brief Required. The identifier that Charge Point must use to start a transaction */ - ocpp::types::IdToken idTag; + ocpp::types::ocpp16::IdToken idTag; /** @brief Optional. Charging Profile to be used by the Charge Point for the requested transaction. ChargingProfilePurpose MUST be set to TxProfile */ - ocpp::types::Optional chargingProfile; + ocpp::types::Optional chargingProfile; }; /** @brief RemoteStopTransaction.conf message */ @@ -51,12 +53,13 @@ struct RemoteStartTransactionConf { /** @brief Required. Status indicating whether Charge Point accepts the request to start a transaction */ - ocpp::types::RemoteStartStopStatus status; + ocpp::types::ocpp16::RemoteStartStopStatus status; }; // Message converters MESSAGE_CONVERTERS(RemoteStartTransaction) +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/RemoteStopTransaction.cpp b/src/ocpp16/messages/RemoteStopTransaction.cpp similarity index 97% rename from src/messages/RemoteStopTransaction.cpp rename to src/ocpp16/messages/RemoteStopTransaction.cpp index 3fac4347..61bc7152 100644 --- a/src/messages/RemoteStopTransaction.cpp +++ b/src/ocpp16/messages/RemoteStopTransaction.cpp @@ -20,12 +20,14 @@ along with OpenOCPP. If not, see . #include "IRpc.h" using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { namespace messages { - +namespace ocpp16 +{ /** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, DataType&, std::string&, std::string&) */ bool RemoteStopTransactionReqConverter::fromJson(const rapidjson::Value& json, RemoteStopTransactionReq& data, @@ -64,5 +66,6 @@ bool RemoteStopTransactionConfConverter::toJson(const RemoteStopTransactionConf& return true; } +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/RemoteStopTransaction.h b/src/ocpp16/messages/RemoteStopTransaction.h similarity index 94% rename from src/messages/RemoteStopTransaction.h rename to src/ocpp16/messages/RemoteStopTransaction.h index 4d1097c9..5a1ad509 100644 --- a/src/messages/RemoteStopTransaction.h +++ b/src/ocpp16/messages/RemoteStopTransaction.h @@ -26,6 +26,8 @@ namespace ocpp { namespace messages { +namespace ocpp16 +{ /** @brief Action corresponding to the RemoteStopTransaction messages */ static const std::string REMOTE_STOP_TRANSACTION_ACTION = "RemoteStopTransaction"; @@ -43,12 +45,13 @@ struct RemoteStopTransactionConf { /** @brief Required. Status indicating whether Charge Point accepts the request to stop a transaction */ - ocpp::types::RemoteStartStopStatus status; + ocpp::types::ocpp16::RemoteStartStopStatus status; }; // Message converters MESSAGE_CONVERTERS(RemoteStopTransaction) +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/ReserveNow.cpp b/src/ocpp16/messages/ReserveNow.cpp similarity index 96% rename from src/messages/ReserveNow.cpp rename to src/ocpp16/messages/ReserveNow.cpp index 5259ce1b..973c5249 100644 --- a/src/messages/ReserveNow.cpp +++ b/src/ocpp16/messages/ReserveNow.cpp @@ -20,11 +20,14 @@ along with OpenOCPP. If not, see . #include "IRpc.h" using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { namespace types { +namespace ocpp16 +{ /** @brief Helper to convert a enum class ReservationStatus enum to string */ const EnumToStringFromString ReservationStatusHelper = {{ReservationStatus::Accepted, "Accepted"}, {ReservationStatus::Faulted, "Faulted"}, @@ -32,9 +35,12 @@ const EnumToStringFromString ReservationStatusHelper = {{Rese {ReservationStatus::Rejected, "Rejected"}, {ReservationStatus::Unavailable, "Unavailable"}}; +} // namespace ocpp16 } // namespace types namespace messages { +namespace ocpp16 +{ /** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, DataType&, std::string&, std::string&) */ bool ReserveNowReqConverter::fromJson(const rapidjson::Value& json, @@ -85,5 +91,6 @@ bool ReserveNowConfConverter::toJson(const ReserveNowConf& data, rapidjson::Docu return true; } +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/ReserveNow.h b/src/ocpp16/messages/ReserveNow.h similarity index 90% rename from src/messages/ReserveNow.h rename to src/ocpp16/messages/ReserveNow.h index 397e160f..5ee34322 100644 --- a/src/messages/ReserveNow.h +++ b/src/ocpp16/messages/ReserveNow.h @@ -30,6 +30,8 @@ namespace ocpp { namespace messages { +namespace ocpp16 +{ /** @brief Action corresponding to the ReserveNow messages */ static const std::string RESERVE_NOW_ACTION = "ReserveNow"; @@ -44,9 +46,9 @@ struct ReserveNowReq means that the reservation is not for a specific connector */ ocpp::types::DateTime expiryDate; /** @brief Required. The identifier for which the Charge Point has to reserve a connector */ - ocpp::types::IdToken idTag; + ocpp::types::ocpp16::IdToken idTag; /** @brief Optional. The parent idTag */ - ocpp::types::Optional parentIdTag; + ocpp::types::Optional parentIdTag; /** @brief Required. Unique id for this reservation */ int reservationId; }; @@ -55,12 +57,13 @@ struct ReserveNowReq struct ReserveNowConf { /** @brief Required. This indicates the success or failure of the reservation */ - ocpp::types::ReservationStatus status; + ocpp::types::ocpp16::ReservationStatus status; }; // Message converters MESSAGE_CONVERTERS(ReserveNow) +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/Reset.cpp b/src/ocpp16/messages/Reset.cpp similarity index 95% rename from src/messages/Reset.cpp rename to src/ocpp16/messages/Reset.cpp index 58ceb3d9..409c42e9 100644 --- a/src/messages/Reset.cpp +++ b/src/ocpp16/messages/Reset.cpp @@ -20,21 +20,25 @@ along with OpenOCPP. If not, see . #include "IRpc.h" using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { - namespace types { +namespace ocpp16 +{ /** @brief Helper to convert a ResetType enum to string */ const EnumToStringFromString ResetTypeHelper = {{ResetType::Hard, "Hard"}, {ResetType::Soft, "Soft"}}; /** @brief Helper to convert a ResetStatus enum to string */ const EnumToStringFromString ResetStatusHelper = {{ResetStatus::Accepted, "Accepted"}, {ResetStatus::Rejected, "Rejected"}}; +} // namespace ocpp16 } // namespace types namespace messages { - +namespace ocpp16 +{ /** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, DataType&, std::string&, std::string&) */ bool ResetReqConverter::fromJson(const rapidjson::Value& json, ResetReq& data, std::string& error_code, std::string& error_message) { @@ -67,5 +71,6 @@ bool ResetConfConverter::toJson(const ResetConf& data, rapidjson::Document& json return true; } +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/Reset.h b/src/ocpp16/messages/Reset.h similarity index 91% rename from src/messages/Reset.h rename to src/ocpp16/messages/Reset.h index 48616b32..08459a78 100644 --- a/src/messages/Reset.h +++ b/src/ocpp16/messages/Reset.h @@ -26,6 +26,8 @@ namespace ocpp { namespace messages { +namespace ocpp16 +{ /** @brief Action corresponding to the Reset messages */ static const std::string RESET_ACTION = "Reset"; @@ -34,19 +36,20 @@ static const std::string RESET_ACTION = "Reset"; struct ResetReq { /** @brief Required. This contains the type of reset that the Charge Point should perform. */ - ocpp::types::ResetType type; + ocpp::types::ocpp16::ResetType type; }; /** @brief Reset.conf message */ struct ResetConf { /** @brief Required. This indicates whether the Charge Point is able to perform the reset */ - ocpp::types::ResetStatus status; + ocpp::types::ocpp16::ResetStatus status; }; // Message converters MESSAGE_CONVERTERS(Reset) +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/SecurityEventNotification.cpp b/src/ocpp16/messages/SecurityEventNotification.cpp similarity index 98% rename from src/messages/SecurityEventNotification.cpp rename to src/ocpp16/messages/SecurityEventNotification.cpp index 299d3aa9..023abc32 100644 --- a/src/messages/SecurityEventNotification.cpp +++ b/src/ocpp16/messages/SecurityEventNotification.cpp @@ -25,7 +25,8 @@ namespace ocpp { namespace messages { - +namespace ocpp16 +{ /** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, DataType&, std::string&, std::string&) */ bool SecurityEventNotificationReqConverter::fromJson(const rapidjson::Value& json, SecurityEventNotificationReq& data, @@ -72,5 +73,6 @@ bool SecurityEventNotificationConfConverter::toJson(const SecurityEventNotificat return true; } +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/SecurityEventNotification.h b/src/ocpp16/messages/SecurityEventNotification.h similarity index 97% rename from src/messages/SecurityEventNotification.h rename to src/ocpp16/messages/SecurityEventNotification.h index 328b227b..a33d33cf 100644 --- a/src/messages/SecurityEventNotification.h +++ b/src/ocpp16/messages/SecurityEventNotification.h @@ -28,6 +28,8 @@ namespace ocpp { namespace messages { +namespace ocpp16 +{ /** @brief Action corresponding to the SecurityEventNotification messages */ static const std::string SECURITY_EVENT_NOTIFICATION_ACTION = "SecurityEventNotification"; @@ -52,6 +54,7 @@ struct SecurityEventNotificationConf // Message converters MESSAGE_CONVERTERS(SecurityEventNotification) +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/SendLocalList.cpp b/src/ocpp16/messages/SendLocalList.cpp similarity index 96% rename from src/messages/SendLocalList.cpp rename to src/ocpp16/messages/SendLocalList.cpp index a23958e8..4055fcd1 100644 --- a/src/messages/SendLocalList.cpp +++ b/src/ocpp16/messages/SendLocalList.cpp @@ -21,11 +21,14 @@ along with OpenOCPP. If not, see . #include "IRpc.h" using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { namespace types { +namespace ocpp16 +{ /** @brief Helper to convert a UpdateType enum to string */ const EnumToStringFromString UpdateTypeHelper = {{UpdateType::Differential, "Differential"}, {UpdateType::Full, "Full"}}; @@ -34,9 +37,12 @@ const EnumToStringFromString UpdateStatusHelper = {{UpdateStatus:: {UpdateStatus::Failed, "Failed"}, {UpdateStatus::NotSupported, "NotSupported"}, {UpdateStatus::VersionMismatch, "VersionMismatch"}}; +} // namespace ocpp16 } // namespace types namespace messages { +namespace ocpp16 +{ /** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, DataType&, std::string&, std::string&) */ bool SendLocalListReqConverter::fromJson(const rapidjson::Value& json, @@ -75,8 +81,7 @@ bool SendLocalListReqConverter::toJson(const SendLocalListReq& data, rapidjson:: rapidjson::Value localAuthorizationList(rapidjson::kArrayType); for (const AuthorizationData& authorization_data : data.localAuthorizationList) { - rapidjson::Document value; - value.Parse("{}"); + rapidjson::Document value(rapidjson::kObjectType); ret = ret && authorization_data_converter.toJson(authorization_data, value); localAuthorizationList.PushBack(value.Move(), *allocator); } @@ -105,5 +110,6 @@ bool SendLocalListConfConverter::toJson(const SendLocalListConf& data, rapidjson return true; } +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/SendLocalList.h b/src/ocpp16/messages/SendLocalList.h similarity index 91% rename from src/messages/SendLocalList.h rename to src/ocpp16/messages/SendLocalList.h index 6498db87..0d18b613 100644 --- a/src/messages/SendLocalList.h +++ b/src/ocpp16/messages/SendLocalList.h @@ -29,6 +29,8 @@ namespace ocpp { namespace messages { +namespace ocpp16 +{ /** @brief Action corresponding to the SendLocalList messages */ static const std::string SEND_LOCAL_LIST_ACTION = "SendLocalList"; @@ -46,10 +48,10 @@ struct SendLocalListReq authorization list in the Charge Point. Maximum number of AuthorizationData elements is available in the configuration key: SendLocalListMaxLength */ - std::vector localAuthorizationList; + std::vector localAuthorizationList; /** @brief Required. This contains the type of update (full or differential) of this request */ - ocpp::types::UpdateType updateType; + ocpp::types::ocpp16::UpdateType updateType; }; /** @brief SendLocalList.conf message */ @@ -57,12 +59,13 @@ struct SendLocalListConf { /** @brief Required. This indicates whether the Charge Point has successfully received and applied the update of the local authorization list */ - ocpp::types::UpdateStatus status; + ocpp::types::ocpp16::UpdateStatus status; }; // Message converters MESSAGE_CONVERTERS(SendLocalList) +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/SetChargingProfile.cpp b/src/ocpp16/messages/SetChargingProfile.cpp similarity index 94% rename from src/messages/SetChargingProfile.cpp rename to src/ocpp16/messages/SetChargingProfile.cpp index cd9e9d38..56f7d451 100644 --- a/src/messages/SetChargingProfile.cpp +++ b/src/ocpp16/messages/SetChargingProfile.cpp @@ -21,11 +21,14 @@ along with OpenOCPP. If not, see . #include "IRpc.h" using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { namespace types { +namespace ocpp16 +{ /** @brief Helper to convert a enum class ChargingProfileStatus enum to string */ const EnumToStringFromString ChargingProfileStatusHelper = {{ChargingProfileStatus::Accepted, "Accepted"}, @@ -45,9 +48,12 @@ const EnumToStringFromString RecurrencyKindTypeHelper = {{Re const EnumToStringFromString ChargingRateUnitTypeHelper = {{ChargingRateUnitType::W, "W"}, {ChargingRateUnitType::A, "A"}}; +} // namespace ocpp16 } // namespace types namespace messages { +namespace ocpp16 +{ /** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, DataType&, std::string&, std::string&) */ bool SetChargingProfileReqConverter::fromJson(const rapidjson::Value& json, @@ -79,10 +85,8 @@ bool SetChargingProfileReqConverter::toJson(const SetChargingProfileReq& data, r ChargingProfileConverter charging_profile_converter; charging_profile_converter.setAllocator(allocator); - rapidjson::Document csChargingProfiles; - csChargingProfiles.Parse("{}"); - - bool ret = charging_profile_converter.toJson(data.csChargingProfiles, csChargingProfiles); + rapidjson::Document csChargingProfiles(rapidjson::kObjectType); + bool ret = charging_profile_converter.toJson(data.csChargingProfiles, csChargingProfiles); json.AddMember(rapidjson::StringRef("csChargingProfiles"), csChargingProfiles.Move(), *allocator); return ret; @@ -108,5 +112,6 @@ bool SetChargingProfileConfConverter::toJson(const SetChargingProfileConf& data, return true; } +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/SetChargingProfile.h b/src/ocpp16/messages/SetChargingProfile.h similarity index 92% rename from src/messages/SetChargingProfile.h rename to src/ocpp16/messages/SetChargingProfile.h index 98f01165..e6666b1a 100644 --- a/src/messages/SetChargingProfile.h +++ b/src/ocpp16/messages/SetChargingProfile.h @@ -27,6 +27,8 @@ namespace ocpp { namespace messages { +namespace ocpp16 +{ /** @brief Action corresponding to the SetChargingProfile messages */ static const std::string SET_CHARGING_PROFILE_ACTION = "SetChargingProfile"; @@ -38,7 +40,7 @@ struct SetChargingProfileReq the message contains an overall limit for the Charge Point */ unsigned int connectorId; /** @brief Required. The charging profile to be set at the Charge Point */ - ocpp::types::ChargingProfile csChargingProfiles; + ocpp::types::ocpp16::ChargingProfile csChargingProfiles; }; /** @brief SetChargingProfile.conf message */ @@ -48,12 +50,13 @@ struct SetChargingProfileConf message successfully. This does not guarantee the schedule will be followed to the letter. There might be other constraints the Charge Point may need to take into account */ - ocpp::types::ChargingProfileStatus status; + ocpp::types::ocpp16::ChargingProfileStatus status; }; // Message converters MESSAGE_CONVERTERS(SetChargingProfile) +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/SignCertificate.cpp b/src/ocpp16/messages/SignCertificate.cpp similarity index 96% rename from src/messages/SignCertificate.cpp rename to src/ocpp16/messages/SignCertificate.cpp index 1525327d..64b1356f 100644 --- a/src/messages/SignCertificate.cpp +++ b/src/ocpp16/messages/SignCertificate.cpp @@ -20,19 +20,25 @@ along with OpenOCPP. If not, see . #include "IRpc.h" using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { namespace types { +namespace ocpp16 +{ /** @brief Helper to convert a enum class GenericStatusEnumType enum to string */ const EnumToStringFromString GenericStatusEnumTypeHelper = {{GenericStatusEnumType::Accepted, "Accepted"}, {GenericStatusEnumType::Rejected, "Rejected"}}; +} // namespace ocpp16 } // namespace types namespace messages { +namespace ocpp16 +{ /** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, DataType&, std::string&, std::string&) */ bool SignCertificateReqConverter::fromJson(const rapidjson::Value& json, @@ -72,5 +78,6 @@ bool SignCertificateConfConverter::toJson(const SignCertificateConf& data, rapid return true; } +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/SignCertificate.h b/src/ocpp16/messages/SignCertificate.h similarity index 94% rename from src/messages/SignCertificate.h rename to src/ocpp16/messages/SignCertificate.h index bd6567f7..e95ad656 100644 --- a/src/messages/SignCertificate.h +++ b/src/ocpp16/messages/SignCertificate.h @@ -27,6 +27,8 @@ namespace ocpp { namespace messages { +namespace ocpp16 +{ /** @brief Action corresponding to the SignCertificate messages */ static const std::string SIGN_CERTIFICATE_ACTION = "SignCertificate"; @@ -44,12 +46,13 @@ struct SignCertificateReq struct SignCertificateConf { /** @brief Required. Specifies whether the Central System can process the request */ - ocpp::types::GenericStatusEnumType status; + ocpp::types::ocpp16::GenericStatusEnumType status; }; // Message converters MESSAGE_CONVERTERS(SignCertificate) +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/SignedFirmwareStatusNotification.cpp b/src/ocpp16/messages/SignedFirmwareStatusNotification.cpp similarity index 97% rename from src/messages/SignedFirmwareStatusNotification.cpp rename to src/ocpp16/messages/SignedFirmwareStatusNotification.cpp index 4b03c3d2..fce0f0ac 100644 --- a/src/messages/SignedFirmwareStatusNotification.cpp +++ b/src/ocpp16/messages/SignedFirmwareStatusNotification.cpp @@ -20,11 +20,14 @@ along with OpenOCPP. If not, see . #include "IRpc.h" using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { namespace types { +namespace ocpp16 +{ /** @brief Helper to convert a enum class FirmwareStatusEnumType enum to string */ const EnumToStringFromString FirmwareStatusEnumTypeHelper = { {FirmwareStatusEnumType::Downloaded, "Downloaded"}, @@ -42,11 +45,13 @@ const EnumToStringFromString FirmwareStatusEnumTypeHelpe {FirmwareStatusEnumType::InvalidSignature, "InvalidSignature"}, {FirmwareStatusEnumType::SignatureVerified, "SignatureVerified"}}; +} // namespace ocpp16 } // namespace types namespace messages { - +namespace ocpp16 +{ /** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, DataType&, std::string&, std::string&) */ bool SignedFirmwareStatusNotificationReqConverter::fromJson(const rapidjson::Value& json, SignedFirmwareStatusNotificationReq& data, @@ -89,5 +94,6 @@ bool SignedFirmwareStatusNotificationConfConverter::toJson(const SignedFirmwareS return true; } +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/SignedFirmwareStatusNotification.h b/src/ocpp16/messages/SignedFirmwareStatusNotification.h similarity index 95% rename from src/messages/SignedFirmwareStatusNotification.h rename to src/ocpp16/messages/SignedFirmwareStatusNotification.h index 19643323..851f7da9 100644 --- a/src/messages/SignedFirmwareStatusNotification.h +++ b/src/ocpp16/messages/SignedFirmwareStatusNotification.h @@ -27,6 +27,8 @@ namespace ocpp { namespace messages { +namespace ocpp16 +{ /** @brief Action corresponding to the SignedFirmwareStatusNotification messages */ static const std::string SIGNED_FIRMWARE_STATUS_NOTIFICATION_ACTION = "SignedFirmwareStatusNotification"; @@ -35,7 +37,7 @@ static const std::string SIGNED_FIRMWARE_STATUS_NOTIFICATION_ACTION = "SignedFir struct SignedFirmwareStatusNotificationReq { /** @brief Required. This contains the progress status of the firmware installation */ - ocpp::types::FirmwareStatusEnumType status; + ocpp::types::ocpp16::FirmwareStatusEnumType status; /** @brief Optional. The request id that was provided in the SignedUpdateFirmware.req that started this firmware update. This field is mandatory, unless the message was triggered by a TriggerMessage.req or the ExtendedTriggerMessage.req AND @@ -52,6 +54,7 @@ struct SignedFirmwareStatusNotificationConf // Message converters MESSAGE_CONVERTERS(SignedFirmwareStatusNotification) +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/SignedUpdateFirmware.cpp b/src/ocpp16/messages/SignedUpdateFirmware.cpp similarity index 96% rename from src/messages/SignedUpdateFirmware.cpp rename to src/ocpp16/messages/SignedUpdateFirmware.cpp index eb82bb97..ed218750 100644 --- a/src/messages/SignedUpdateFirmware.cpp +++ b/src/ocpp16/messages/SignedUpdateFirmware.cpp @@ -21,11 +21,14 @@ along with OpenOCPP. If not, see . #include "Url.h" using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { namespace types { +namespace ocpp16 +{ /** @brief Helper to convert a UpdateFirmwareStatusEnumType enum to string */ const EnumToStringFromString UpdateFirmwareStatusEnumTypeHelper = { @@ -35,9 +38,12 @@ const EnumToStringFromString UpdateFirmwareStatusE {UpdateFirmwareStatusEnumType::InvalidCertificate, "InvalidCertificate"}, {UpdateFirmwareStatusEnumType::RevokedCertificate, "RevokedCertificate"}}; +} // namespace ocpp16 } // namespace types namespace messages { +namespace ocpp16 +{ /** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, DataType&, std::string&, std::string&) */ bool SignedUpdateFirmwareReqConverter::fromJson(const rapidjson::Value& json, @@ -72,8 +78,7 @@ bool SignedUpdateFirmwareReqConverter::toJson(const SignedUpdateFirmwareReq& dat fill(json, "retries", data.retries); fill(json, "retryInterval", data.retryInterval); - rapidjson::Document firmware; - firmware.Parse("{}"); + rapidjson::Document firmware(rapidjson::kObjectType); fill(firmware, "location", data.firmware.location); fill(firmware, "retrieveDateTime", data.firmware.retrieveDateTime); fill(firmware, "installDateTime", data.firmware.installDateTime); @@ -102,5 +107,6 @@ bool SignedUpdateFirmwareConfConverter::toJson(const SignedUpdateFirmwareConf& d return true; } +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/SignedUpdateFirmware.h b/src/ocpp16/messages/SignedUpdateFirmware.h similarity index 93% rename from src/messages/SignedUpdateFirmware.h rename to src/ocpp16/messages/SignedUpdateFirmware.h index 5e2d9455..fd415d11 100644 --- a/src/messages/SignedUpdateFirmware.h +++ b/src/ocpp16/messages/SignedUpdateFirmware.h @@ -28,6 +28,8 @@ namespace ocpp { namespace messages { +namespace ocpp16 +{ /** @brief Action corresponding to the SignedUpdateFirmware messages */ static const std::string SIGNED_UPDATE_FIRMWARE_ACTION = "SignedUpdateFirmware"; @@ -47,19 +49,20 @@ struct SignedUpdateFirmwareReq int requestId; /** @brief Required.Specifies the firmware to be updated on the Charge Point */ - ocpp::types::FirmwareType firmware; + ocpp::types::ocpp16::FirmwareType firmware; }; /** @brief SignedUpdateFirmware.conf message */ struct SignedUpdateFirmwareConf { /** @brief Required. This field indicates whether the Charge Point was able to accept the request */ - ocpp::types::UpdateFirmwareStatusEnumType status; + ocpp::types::ocpp16::UpdateFirmwareStatusEnumType status; }; // Message converters MESSAGE_CONVERTERS(SignedUpdateFirmware) +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/StartTransaction.cpp b/src/ocpp16/messages/StartTransaction.cpp similarity index 94% rename from src/messages/StartTransaction.cpp rename to src/ocpp16/messages/StartTransaction.cpp index 21def2be..3a001571 100644 --- a/src/messages/StartTransaction.cpp +++ b/src/ocpp16/messages/StartTransaction.cpp @@ -21,12 +21,14 @@ along with OpenOCPP. If not, see . #include "IdTagInfoConverter.h" using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { namespace messages { - +namespace ocpp16 +{ /** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, DataType&, std::string&, std::string&) */ bool StartTransactionReqConverter::fromJson(const rapidjson::Value& json, StartTransactionReq& data, @@ -82,13 +84,13 @@ bool StartTransactionConfConverter::toJson(const StartTransactionConf& data, rap IdTagInfoConverter id_tag_info_converter; id_tag_info_converter.setAllocator(allocator); - rapidjson::Document id_tag_info; - id_tag_info.Parse("{}"); - bool ret = id_tag_info_converter.toJson(data.idTagInfo, id_tag_info); + rapidjson::Document id_tag_info(rapidjson::kObjectType); + bool ret = id_tag_info_converter.toJson(data.idTagInfo, id_tag_info); json.AddMember(rapidjson::StringRef("idTagInfo"), id_tag_info.Move(), *allocator); fill(json, "transactionId", data.transactionId); return ret; } +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/StartTransaction.h b/src/ocpp16/messages/StartTransaction.h similarity index 94% rename from src/messages/StartTransaction.h rename to src/ocpp16/messages/StartTransaction.h index eae06565..69788b13 100644 --- a/src/messages/StartTransaction.h +++ b/src/ocpp16/messages/StartTransaction.h @@ -27,6 +27,8 @@ namespace ocpp { namespace messages { +namespace ocpp16 +{ /** @brief Action corresponding to the StartTransaction messages */ static const std::string START_TRANSACTION_ACTION = "StartTransaction"; @@ -37,7 +39,7 @@ struct StartTransactionReq /** @brief Required. This identifies which connector of the Charge Point is used */ unsigned int connectorId; /** @brief Required. This contains the identifier for which a transaction has to be started */ - ocpp::types::IdToken idTag; + ocpp::types::ocpp16::IdToken idTag; /** @brief Required. This contains the meter value in Wh for the connector at start of the transaction */ int meterStart; @@ -53,7 +55,7 @@ struct StartTransactionConf { /** @brief Required. This contains information about authorization status, expiry and parent id */ - ocpp::types::IdTagInfo idTagInfo; + ocpp::types::ocpp16::IdTagInfo idTagInfo; /** @brief Required. This contains the transaction id supplied by the Central System */ int transactionId; }; @@ -61,6 +63,7 @@ struct StartTransactionConf // Message converters MESSAGE_CONVERTERS(StartTransaction) +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/StatusNotification.cpp b/src/ocpp16/messages/StatusNotification.cpp similarity index 98% rename from src/messages/StatusNotification.cpp rename to src/ocpp16/messages/StatusNotification.cpp index ca9f41bb..e5985670 100644 --- a/src/messages/StatusNotification.cpp +++ b/src/ocpp16/messages/StatusNotification.cpp @@ -20,11 +20,14 @@ along with OpenOCPP. If not, see . #include "IRpc.h" using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { namespace types { +namespace ocpp16 +{ /** @brief Helper to convert a ChargePointErrorCode enum to string */ const EnumToStringFromString ChargePointErrorCodeHelper = { {ChargePointErrorCode::ConnectorLockFailure, "ConnectorLockFailure"}, @@ -55,9 +58,12 @@ const EnumToStringFromString ChargePointStatusHelper = {{Char {ChargePointStatus::SuspendedEVSE, "SuspendedEVSE"}, {ChargePointStatus::Unavailable, "Unavailable"}}; +} // namespace ocpp16 } // namespace types namespace messages { +namespace ocpp16 +{ /** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, DataType&, std::string&, std::string&) */ bool StatusNotificationReqConverter::fromJson(const rapidjson::Value& json, @@ -117,5 +123,6 @@ bool StatusNotificationConfConverter::toJson(const StatusNotificationConf& data, return true; } +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/StatusNotification.h b/src/ocpp16/messages/StatusNotification.h similarity index 94% rename from src/messages/StatusNotification.h rename to src/ocpp16/messages/StatusNotification.h index 08587e41..045958ff 100644 --- a/src/messages/StatusNotification.h +++ b/src/ocpp16/messages/StatusNotification.h @@ -28,6 +28,8 @@ namespace ocpp { namespace messages { +namespace ocpp16 +{ /** @brief Action corresponding to the StatusNotification messages */ static const std::string STATUS_NOTIFICATION_ACTION = "StatusNotification"; @@ -41,11 +43,11 @@ struct StatusNotificationReq unsigned int connectorId; /** @brief Required. This contains the error code reported by the Charge Point */ - ocpp::types::ChargePointErrorCode errorCode; + ocpp::types::ocpp16::ChargePointErrorCode errorCode; /** @brief Optional. Additional free format information related to the error */ ocpp::types::Optional> info; /** @brief Required. This contains the current status of the Charge Point */ - ocpp::types::ChargePointStatus status; + ocpp::types::ocpp16::ChargePointStatus status; /** @brief Optional. The time for which the status is reported. If absent time of receipt of the message will be assumed */ ocpp::types::Optional timestamp; @@ -64,6 +66,7 @@ struct StatusNotificationConf // Message converters MESSAGE_CONVERTERS(StatusNotification) +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/StopTransaction.cpp b/src/ocpp16/messages/StopTransaction.cpp similarity index 95% rename from src/messages/StopTransaction.cpp rename to src/ocpp16/messages/StopTransaction.cpp index 50468c9a..f9ba977c 100644 --- a/src/messages/StopTransaction.cpp +++ b/src/ocpp16/messages/StopTransaction.cpp @@ -22,12 +22,14 @@ along with OpenOCPP. If not, see . #include "MeterValueConverter.h" using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { - namespace types { +namespace ocpp16 +{ /** @brief Helper to convert a Reason enum to string */ const EnumToStringFromString ReasonHelper = {{Reason::DeAuthorized, "DeAuthorized"}, @@ -42,11 +44,13 @@ const EnumToStringFromString ReasonHelper = {{Reason::DeAuthorized, "DeA {Reason::SoftReset, "SoftReset"}, {Reason::UnlockCommand, "UnlockCommand"}}; +} // namespace ocpp16 } // namespace types namespace messages { - +namespace ocpp16 +{ /** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, DataType&, std::string&, std::string&) */ bool StopTransactionReqConverter::fromJson(const rapidjson::Value& json, StopTransactionReq& data, @@ -98,8 +102,7 @@ bool StopTransactionReqConverter::toJson(const StopTransactionReq& data, rapidjs metervalue_converter.setAllocator(allocator); for (const MeterValue& meter_value : data.transactionData) { - rapidjson::Document value; - value.Parse("{}"); + rapidjson::Document value(rapidjson::kObjectType); ret = ret && metervalue_converter.toJson(meter_value, value); transactionData.PushBack(value.Move(), *allocator); } @@ -132,13 +135,13 @@ bool StopTransactionConfConverter::toJson(const StopTransactionConf& data, rapid IdTagInfoConverter id_tag_info_converter; id_tag_info_converter.setAllocator(allocator); - rapidjson::Document id_tag_info; - id_tag_info.Parse("{}"); + rapidjson::Document id_tag_info(rapidjson::kObjectType); ret = id_tag_info_converter.toJson(data.idTagInfo, id_tag_info); json.AddMember(rapidjson::StringRef("idTagInfo"), id_tag_info.Move(), *allocator); } return ret; } +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/StopTransaction.h b/src/ocpp16/messages/StopTransaction.h similarity index 89% rename from src/messages/StopTransaction.h rename to src/ocpp16/messages/StopTransaction.h index 5e184915..645df907 100644 --- a/src/messages/StopTransaction.h +++ b/src/ocpp16/messages/StopTransaction.h @@ -31,6 +31,8 @@ namespace ocpp { namespace messages { +namespace ocpp16 +{ /** @brief Action corresponding to the StopTransaction messages */ static const std::string STOP_TRANSACTION_ACTION = "StopTransaction"; @@ -41,7 +43,7 @@ struct StopTransactionReq /** @brief Optional. This contains the identifier which requested to stop the charging. It is optional because a Charge Point may terminate charging without the presence of an idTag, e.g. in case of a reset. A Charge Point SHALL send the idTag if known */ - ocpp::types::Optional idTag; + ocpp::types::Optional idTag; /** @brief Required. This contains the meter value in Wh for the connector at end of the transaction */ int meterStop; @@ -52,9 +54,9 @@ struct StopTransactionReq int transactionId; /** @brief Optional. This contains the reason why the transaction was stopped. MAY only be omitted when the Reason is "Local". */ - ocpp::types::Optional reason; + ocpp::types::Optional reason; /** @brief Optional. This contains transaction usage details relevant for billing purposes */ - std::vector transactionData; + std::vector transactionData; }; /** @brief StopTransaction.conf message */ @@ -63,12 +65,13 @@ struct StopTransactionConf /** @brief Optional. This contains information about authorization status, expiry and parent id. It is optional, because a transaction may have been stopped without an identifier */ - ocpp::types::Optional idTagInfo; + ocpp::types::Optional idTagInfo; }; // Message converters MESSAGE_CONVERTERS(StopTransaction) +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/TriggerMessage.cpp b/src/ocpp16/messages/TriggerMessage.cpp similarity index 97% rename from src/messages/TriggerMessage.cpp rename to src/ocpp16/messages/TriggerMessage.cpp index 226ae7bf..4933128a 100644 --- a/src/messages/TriggerMessage.cpp +++ b/src/ocpp16/messages/TriggerMessage.cpp @@ -20,11 +20,14 @@ along with OpenOCPP. If not, see . #include "IRpc.h" using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { namespace types { +namespace ocpp16 +{ /** @brief Helper to convert a MessageTrigger enum to string */ const EnumToStringFromString MessageTriggerHelper = { {MessageTrigger::BootNotification, "BootNotification"}, @@ -39,9 +42,12 @@ const EnumToStringFromString TriggerMessageStatusHelper = {TriggerMessageStatus::NotImplemented, "NotImplemented"}, {TriggerMessageStatus::Rejected, "Rejected"}}; +} // namespace ocpp16 } // namespace types namespace messages { +namespace ocpp16 +{ /** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, DataType&, std::string&, std::string&) */ bool TriggerMessageReqConverter::fromJson(const rapidjson::Value& json, @@ -86,5 +92,6 @@ bool TriggerMessageConfConverter::toJson(const TriggerMessageConf& data, rapidjs return true; } +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/TriggerMessage.h b/src/ocpp16/messages/TriggerMessage.h similarity index 91% rename from src/messages/TriggerMessage.h rename to src/ocpp16/messages/TriggerMessage.h index 8a355334..af2afc05 100644 --- a/src/messages/TriggerMessage.h +++ b/src/ocpp16/messages/TriggerMessage.h @@ -28,6 +28,8 @@ namespace ocpp { namespace messages { +namespace ocpp16 +{ /** @brief Action corresponding to the TriggerMessage messages */ static const std::string TRIGGER_MESSAGE_ACTION = "TriggerMessage"; @@ -36,7 +38,7 @@ static const std::string TRIGGER_MESSAGE_ACTION = "TriggerMessage"; struct TriggerMessageReq { /** @brief Required. This contains the message requested by the Central System */ - ocpp::types::MessageTrigger requestedMessage; + ocpp::types::ocpp16::MessageTrigger requestedMessage; /** @brief Optional. Only filled in when request applies to a specific connector */ ocpp::types::Optional connectorId; }; @@ -46,12 +48,13 @@ struct TriggerMessageConf { /** @brief Required. Indicates whether the Charge Point will send the requested notification or not */ - ocpp::types::TriggerMessageStatus status; + ocpp::types::ocpp16::TriggerMessageStatus status; }; // Message converters MESSAGE_CONVERTERS(TriggerMessage) +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/UnlockConnector.cpp b/src/ocpp16/messages/UnlockConnector.cpp similarity index 96% rename from src/messages/UnlockConnector.cpp rename to src/ocpp16/messages/UnlockConnector.cpp index 81b1c096..38b642fa 100644 --- a/src/messages/UnlockConnector.cpp +++ b/src/ocpp16/messages/UnlockConnector.cpp @@ -20,22 +20,26 @@ along with OpenOCPP. If not, see . #include "IRpc.h" using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { - namespace types { +namespace ocpp16 +{ /** @brief Helper to convert a UnlockStatus enum to string */ const EnumToStringFromString UnlockStatusHelper = { {UnlockStatus::Unlocked, "Unlocked"}, {UnlockStatus::UnlockFailed, "UnlockFailed"}, {UnlockStatus::NotSupported, "NotSupported"}}; +} // namespace ocpp16 } // namespace types namespace messages { - +namespace ocpp16 +{ /** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, DataType&, std::string&, std::string&) */ bool UnlockConnectorReqConverter::fromJson(const rapidjson::Value& json, UnlockConnectorReq& data, @@ -77,5 +81,6 @@ bool UnlockConnectorConfConverter::toJson(const UnlockConnectorConf& data, rapid return true; } +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/UnlockConnector.h b/src/ocpp16/messages/UnlockConnector.h similarity index 94% rename from src/messages/UnlockConnector.h rename to src/ocpp16/messages/UnlockConnector.h index e547b10f..5b5c3e55 100644 --- a/src/messages/UnlockConnector.h +++ b/src/ocpp16/messages/UnlockConnector.h @@ -26,6 +26,8 @@ namespace ocpp { namespace messages { +namespace ocpp16 +{ /** @brief Action corresponding to the UnlockConnector messages */ static const std::string UNLOCK_CONNECTOR_ACTION = "UnlockConnector"; @@ -41,12 +43,13 @@ struct UnlockConnectorReq struct UnlockConnectorConf { /** @brief Required. This indicates whether the Charge Point has unlocked the connector */ - ocpp::types::UnlockStatus status; + ocpp::types::ocpp16::UnlockStatus status; }; // Message converters MESSAGE_CONVERTERS(UnlockConnector) +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/UpdateFirmware.cpp b/src/ocpp16/messages/UpdateFirmware.cpp similarity index 98% rename from src/messages/UpdateFirmware.cpp rename to src/ocpp16/messages/UpdateFirmware.cpp index 31c02bfc..42174119 100644 --- a/src/messages/UpdateFirmware.cpp +++ b/src/ocpp16/messages/UpdateFirmware.cpp @@ -26,7 +26,8 @@ namespace ocpp { namespace messages { - +namespace ocpp16 +{ /** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, DataType&, std::string&, std::string&) */ bool UpdateFirmwareReqConverter::fromJson(const rapidjson::Value& json, UpdateFirmwareReq& data, @@ -78,5 +79,6 @@ bool UpdateFirmwareConfConverter::toJson(const UpdateFirmwareConf& data, rapidjs return true; } +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/UpdateFirmware.h b/src/ocpp16/messages/UpdateFirmware.h similarity index 98% rename from src/messages/UpdateFirmware.h rename to src/ocpp16/messages/UpdateFirmware.h index 8118238d..b3309d0f 100644 --- a/src/messages/UpdateFirmware.h +++ b/src/ocpp16/messages/UpdateFirmware.h @@ -28,6 +28,8 @@ namespace ocpp { namespace messages { +namespace ocpp16 +{ /** @brief Action corresponding to the UpdateFirmware messages */ static const std::string UPDATE_FIRMWARE_ACTION = "UpdateFirmware"; @@ -60,6 +62,7 @@ struct UpdateFirmwareConf // Message converters MESSAGE_CONVERTERS(UpdateFirmware) +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/types/AuthorizationDataConverter.cpp b/src/ocpp16/messages/types/AuthorizationDataConverter.cpp similarity index 74% rename from src/messages/types/AuthorizationDataConverter.cpp rename to src/ocpp16/messages/types/AuthorizationDataConverter.cpp index 688b97e4..d3a2c568 100644 --- a/src/messages/types/AuthorizationDataConverter.cpp +++ b/src/ocpp16/messages/types/AuthorizationDataConverter.cpp @@ -22,20 +22,23 @@ along with OpenOCPP. If not, see . #include "IdTagInfoConverter.h" using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { namespace messages { +namespace ocpp16 +{ -/** @bcopydoc bool IMessageConverter::fromJson(const rapidjson::Value&, - * ocpp::types::AuthorizationData&, +/** @bcopydoc bool IMessageConverter::fromJson(const rapidjson::Value&, + * ocpp::types::ocpp16::AuthorizationData&, * std::string&, * std::string&) */ -bool AuthorizationDataConverter::fromJson(const rapidjson::Value& json, - ocpp::types::AuthorizationData& data, - std::string& error_code, - std::string& error_message) +bool AuthorizationDataConverter::fromJson(const rapidjson::Value& json, + ocpp::types::ocpp16::AuthorizationData& data, + std::string& error_code, + std::string& error_message) { bool ret = true; extract(json, "idTag", data.idTag); @@ -47,9 +50,9 @@ bool AuthorizationDataConverter::fromJson(const rapidjson::Value& json, return ret; } -/** @copydoc bool IMessageConverter::toJson(const ocpp::types::AuthorizationData&, +/** @copydoc bool IMessageConverter::toJson(const ocpp::types::ocpp16::AuthorizationData&, * rapidjson::Document&) */ -bool AuthorizationDataConverter::toJson(const ocpp::types::AuthorizationData& data, rapidjson::Document& json) +bool AuthorizationDataConverter::toJson(const ocpp::types::ocpp16::AuthorizationData& data, rapidjson::Document& json) { bool ret = true; fill(json, "idTag", data.idTag); @@ -57,13 +60,13 @@ bool AuthorizationDataConverter::toJson(const ocpp::types::AuthorizationData& da { IdTagInfoConverter id_tag_info_converter; id_tag_info_converter.setAllocator(allocator); - rapidjson::Document value; - value.Parse("{}"); + rapidjson::Document value(rapidjson::kObjectType); ret = id_tag_info_converter.toJson(data.idTagInfo, value); json.AddMember(rapidjson::StringRef("idTagInfo"), value.Move(), *allocator); } return ret; } +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/types/AuthorizationDataConverter.h b/src/ocpp16/messages/types/AuthorizationDataConverter.h similarity index 58% rename from src/messages/types/AuthorizationDataConverter.h rename to src/ocpp16/messages/types/AuthorizationDataConverter.h index 633a2e10..4406b740 100644 --- a/src/messages/types/AuthorizationDataConverter.h +++ b/src/ocpp16/messages/types/AuthorizationDataConverter.h @@ -26,28 +26,31 @@ namespace ocpp { namespace messages { +namespace ocpp16 +{ /** @brief Converter class for AuthorizationData type */ -class AuthorizationDataConverter : public IMessageConverter +class AuthorizationDataConverter : public IMessageConverter { public: - /** @copydoc IMessageConverter* IMessageConverter::clone() const */ - IMessageConverter* clone() const override { return new AuthorizationDataConverter(); } + /** @copydoc IMessageConverter* IMessageConverter::clone() const */ + IMessageConverter* clone() const override { return new AuthorizationDataConverter(); } - /** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, - * ocpp::types::AuthorizationData&, + /** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, + * ocpp::types::ocpp16::AuthorizationData&, * std::string&, * std::string&) */ - bool fromJson(const rapidjson::Value& json, - ocpp::types::AuthorizationData& data, - std::string& error_code, - std::string& error_message) override; + bool fromJson(const rapidjson::Value& json, + ocpp::types::ocpp16::AuthorizationData& data, + std::string& error_code, + std::string& error_message) override; - /** @copydoc bool IMessageConverter::toJson(const ocpp::types::AuthorizationData&, + /** @copydoc bool IMessageConverter::toJson(const ocpp::types::ocpp16::AuthorizationData&, * rapidjson::Document&) */ - bool toJson(const ocpp::types::AuthorizationData& data, rapidjson::Document& json) override; + bool toJson(const ocpp::types::ocpp16::AuthorizationData& data, rapidjson::Document& json) override; }; +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/types/CertificateHashDataChainTypeConverter.cpp b/src/ocpp16/messages/types/CertificateHashDataChainTypeConverter.cpp similarity index 80% rename from src/messages/types/CertificateHashDataChainTypeConverter.cpp rename to src/ocpp16/messages/types/CertificateHashDataChainTypeConverter.cpp index 4fd98cb3..e4f89059 100644 --- a/src/messages/types/CertificateHashDataChainTypeConverter.cpp +++ b/src/ocpp16/messages/types/CertificateHashDataChainTypeConverter.cpp @@ -22,11 +22,14 @@ along with OpenOCPP. If not, see . #include "IRpc.h" using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { namespace types { +namespace ocpp16 +{ /** @brief Helper to convert a enum class GetCertificateIdUseEnumType enum to string */ const EnumToStringFromString GetCertificateIdUseEnumTypeHelper = { @@ -34,19 +37,22 @@ const EnumToStringFromString GetCertificateIdUseEnu {GetCertificateIdUseEnumType::V2GCertificateChain, "V2GCertificateChain"}, {GetCertificateIdUseEnumType::V2GRootCertificate, "V2GRootCertificate"}, {GetCertificateIdUseEnumType::OEMRootCertificate, "OEMRootCertificate"}}; +} // namespace ocpp16 } // namespace types namespace messages { +namespace ocpp16 +{ -/** @bcopydoc bool IMessageConverter::fromJson(const rapidjson::Value&, - * ocpp::types::CertificateHashDataChainType&, +/** @bcopydoc bool IMessageConverter::fromJson(const rapidjson::Value&, + * ocpp::types::ocpp16::CertificateHashDataChainType&, * std::string&, * std::string&) */ -bool CertificateHashDataChainTypeConverter::fromJson(const rapidjson::Value& json, - ocpp::types::CertificateHashDataChainType& data, - std::string& error_code, - std::string& error_message) +bool CertificateHashDataChainTypeConverter::fromJson(const rapidjson::Value& json, + ocpp::types::ocpp16::CertificateHashDataChainType& data, + std::string& error_code, + std::string& error_message) { CertificateHashDataTypeConverter certificate_hash_data_type_converter; @@ -67,17 +73,16 @@ bool CertificateHashDataChainTypeConverter::fromJson(const rapidjson::Value& return ret; } -/** @copydoc bool IMessageConverter::toJson(const ocpp::types::CertificateHashDataChainType&, +/** @copydoc bool IMessageConverter::toJson(const ocpp::types::ocpp16::CertificateHashDataChainType&, * rapidjson::Document&) */ -bool CertificateHashDataChainTypeConverter::toJson(const ocpp::types::CertificateHashDataChainType& data, rapidjson::Document& json) +bool CertificateHashDataChainTypeConverter::toJson(const ocpp::types::ocpp16::CertificateHashDataChainType& data, rapidjson::Document& json) { fill(json, "certificateType", GetCertificateIdUseEnumTypeHelper.toString(data.certificateType)); CertificateHashDataTypeConverter certificate_hash_data_type_converter; certificate_hash_data_type_converter.setAllocator(allocator); - rapidjson::Document hash_data; - hash_data.Parse("{}"); - bool ret = certificate_hash_data_type_converter.toJson(data.certificateHashData, hash_data); + rapidjson::Document hash_data(rapidjson::kObjectType); + bool ret = certificate_hash_data_type_converter.toJson(data.certificateHashData, hash_data); if (ret) { json.AddMember(rapidjson::StringRef("certificateHashData"), hash_data.Move(), *allocator); @@ -85,8 +90,7 @@ bool CertificateHashDataChainTypeConverter::toJson(const ocpp::types::Certificat rapidjson::Value childCertificateHashData(rapidjson::kArrayType); for (const auto& child_certificate : data.childCertificateHashData) { - rapidjson::Document value; - value.Parse("{}"); + rapidjson::Document value(rapidjson::kObjectType); ret = ret && certificate_hash_data_type_converter.toJson(child_certificate, value); if (ret) { @@ -98,5 +102,6 @@ bool CertificateHashDataChainTypeConverter::toJson(const ocpp::types::Certificat return ret; } +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/types/CertificateHashDataChainTypeConverter.h b/src/ocpp16/messages/types/CertificateHashDataChainTypeConverter.h similarity index 58% rename from src/messages/types/CertificateHashDataChainTypeConverter.h rename to src/ocpp16/messages/types/CertificateHashDataChainTypeConverter.h index 1aef62aa..a39a24e6 100644 --- a/src/messages/types/CertificateHashDataChainTypeConverter.h +++ b/src/ocpp16/messages/types/CertificateHashDataChainTypeConverter.h @@ -26,31 +26,34 @@ namespace ocpp { namespace messages { +namespace ocpp16 +{ /** @brief Converter class for CertificateHashDataChainType type */ -class CertificateHashDataChainTypeConverter : public IMessageConverter +class CertificateHashDataChainTypeConverter : public IMessageConverter { public: - /** @copydoc IMessageConverter* IMessageConverter::clone() const */ - IMessageConverter* clone() const override + /** @copydoc IMessageConverter* IMessageConverter::clone() const */ + IMessageConverter* clone() const override { return new CertificateHashDataChainTypeConverter(); } - /** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, - * ocpp::types::CertificateHashDataChainType&, + /** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, + * ocpp::types::ocpp16::CertificateHashDataChainType&, * std::string&, * std::string&) */ - bool fromJson(const rapidjson::Value& json, - ocpp::types::CertificateHashDataChainType& data, - std::string& error_code, - std::string& error_message) override; + bool fromJson(const rapidjson::Value& json, + ocpp::types::ocpp16::CertificateHashDataChainType& data, + std::string& error_code, + std::string& error_message) override; - /** @copydoc bool IMessageConverter::toJson(const ocpp::types::CertificateHashDataChainType&, + /** @copydoc bool IMessageConverter::toJson(const ocpp::types::ocpp16::CertificateHashDataChainType&, * rapidjson::Document&) */ - bool toJson(const ocpp::types::CertificateHashDataChainType& data, rapidjson::Document& json) override; + bool toJson(const ocpp::types::ocpp16::CertificateHashDataChainType& data, rapidjson::Document& json) override; }; +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/types/CertificateHashDataTypeConverter.cpp b/src/ocpp16/messages/types/CertificateHashDataTypeConverter.cpp similarity index 77% rename from src/messages/types/CertificateHashDataTypeConverter.cpp rename to src/ocpp16/messages/types/CertificateHashDataTypeConverter.cpp index c9f9c72d..c7dab528 100644 --- a/src/messages/types/CertificateHashDataTypeConverter.cpp +++ b/src/ocpp16/messages/types/CertificateHashDataTypeConverter.cpp @@ -21,27 +21,33 @@ along with OpenOCPP. If not, see . #include "IRpc.h" using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { namespace types { +namespace ocpp16 +{ /** @brief Helper to convert a enum class HashAlgorithmEnumType enum to string */ const EnumToStringFromString HashAlgorithmEnumTypeHelper = { {HashAlgorithmEnumType::SHA256, "SHA256"}, {HashAlgorithmEnumType::SHA384, "SHA384"}, {HashAlgorithmEnumType::SHA512, "SHA512"}}; +} // namespace ocpp16 } // namespace types namespace messages { +namespace ocpp16 +{ -/** @bcopydoc bool IMessageConverter::fromJson(const rapidjson::Value&, - * ocpp::types::CertificateHashDataType&, +/** @bcopydoc bool IMessageConverter::fromJson(const rapidjson::Value&, + * ocpp::types::ocpp16::CertificateHashDataType&, * std::string&, * std::string&) */ -bool CertificateHashDataTypeConverter::fromJson(const rapidjson::Value& json, - ocpp::types::CertificateHashDataType& data, - std::string& error_code, - std::string& error_message) +bool CertificateHashDataTypeConverter::fromJson(const rapidjson::Value& json, + ocpp::types::ocpp16::CertificateHashDataType& data, + std::string& error_code, + std::string& error_message) { (void)error_code; (void)error_message; @@ -52,9 +58,9 @@ bool CertificateHashDataTypeConverter::fromJson(const rapidjson::Value& return true; } -/** @copydoc bool IMessageConverter::toJson(const ocpp::types::CertificateHashDataType&, +/** @copydoc bool IMessageConverter::toJson(const ocpp::types::ocpp16::CertificateHashDataType&, * rapidjson::Document&) */ -bool CertificateHashDataTypeConverter::toJson(const ocpp::types::CertificateHashDataType& data, rapidjson::Document& json) +bool CertificateHashDataTypeConverter::toJson(const ocpp::types::ocpp16::CertificateHashDataType& data, rapidjson::Document& json) { fill(json, "hashAlgorithm", HashAlgorithmEnumTypeHelper.toString(data.hashAlgorithm)); fill(json, "issuerKeyHash", data.issuerKeyHash); @@ -63,5 +69,6 @@ bool CertificateHashDataTypeConverter::toJson(const ocpp::types::CertificateHash return true; } +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/types/CertificateHashDataTypeConverter.h b/src/ocpp16/messages/types/CertificateHashDataTypeConverter.h similarity index 56% rename from src/messages/types/CertificateHashDataTypeConverter.h rename to src/ocpp16/messages/types/CertificateHashDataTypeConverter.h index e05385f1..74bb4e4f 100644 --- a/src/messages/types/CertificateHashDataTypeConverter.h +++ b/src/ocpp16/messages/types/CertificateHashDataTypeConverter.h @@ -26,28 +26,34 @@ namespace ocpp { namespace messages { +namespace ocpp16 +{ /** @brief Converter class for CertificateHashDataType type */ -class CertificateHashDataTypeConverter : public IMessageConverter +class CertificateHashDataTypeConverter : public IMessageConverter { public: - /** @copydoc IMessageConverter* IMessageConverter::clone() const */ - IMessageConverter* clone() const override { return new CertificateHashDataTypeConverter(); } - - /** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, - * ocpp::types::CertificateHashDataType&, + /** @copydoc IMessageConverter* IMessageConverter::clone() const */ + IMessageConverter* clone() const override + { + return new CertificateHashDataTypeConverter(); + } + + /** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, + * ocpp::types::ocpp16::CertificateHashDataType&, * std::string&, * std::string&) */ - bool fromJson(const rapidjson::Value& json, - ocpp::types::CertificateHashDataType& data, - std::string& error_code, - std::string& error_message) override; + bool fromJson(const rapidjson::Value& json, + ocpp::types::ocpp16::CertificateHashDataType& data, + std::string& error_code, + std::string& error_message) override; - /** @copydoc bool IMessageConverter::toJson(const ocpp::types::CertificateHashDataType&, + /** @copydoc bool IMessageConverter::toJson(const ocpp::types::ocpp16::CertificateHashDataType&, * rapidjson::Document&) */ - bool toJson(const ocpp::types::CertificateHashDataType& data, rapidjson::Document& json) override; + bool toJson(const ocpp::types::ocpp16::CertificateHashDataType& data, rapidjson::Document& json) override; }; +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/types/ChargingProfileConverter.cpp b/src/ocpp16/messages/types/ChargingProfileConverter.cpp similarity index 80% rename from src/messages/types/ChargingProfileConverter.cpp rename to src/ocpp16/messages/types/ChargingProfileConverter.cpp index e9d9a463..ecc75b3d 100644 --- a/src/messages/types/ChargingProfileConverter.cpp +++ b/src/ocpp16/messages/types/ChargingProfileConverter.cpp @@ -22,20 +22,23 @@ along with OpenOCPP. If not, see . #include "IRpc.h" using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { namespace messages { +namespace ocpp16 +{ -/** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, - * ocpp::types::ChargingProfile&, +/** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, + * ocpp::types::ocpp16::ChargingProfile&, * std::string&, * std::string&) */ -bool ChargingProfileConverter::fromJson(const rapidjson::Value& json, - ocpp::types::ChargingProfile& data, - std::string& error_code, - std::string& error_message) +bool ChargingProfileConverter::fromJson(const rapidjson::Value& json, + ocpp::types::ocpp16::ChargingProfile& data, + std::string& error_code, + std::string& error_message) { bool ret; extract(json, "chargingProfileId", data.chargingProfileId); @@ -60,9 +63,9 @@ bool ChargingProfileConverter::fromJson(const rapidjson::Value& json, return ret; } -/** @copydoc bool IMessageConverter::toJson(const ocpp::types::ChargingProfile&, +/** @copydoc bool IMessageConverter::toJson(const ocpp::types::ocpp16::ChargingProfile&, * rapidjson::Document&) */ -bool ChargingProfileConverter::toJson(const ocpp::types::ChargingProfile& data, rapidjson::Document& json) +bool ChargingProfileConverter::toJson(const ocpp::types::ocpp16::ChargingProfile& data, rapidjson::Document& json) { fill(json, "chargingProfileId", data.chargingProfileId); fill(json, "transactionId", data.transactionId); @@ -78,13 +81,13 @@ bool ChargingProfileConverter::toJson(const ocpp::types::ChargingProfile& data, ChargingScheduleConverter charging_schedule_converter; charging_schedule_converter.setAllocator(allocator); - rapidjson::Document charging_schedule; - charging_schedule.Parse("{}"); - bool ret = charging_schedule_converter.toJson(data.chargingSchedule, charging_schedule); + rapidjson::Document charging_schedule(rapidjson::kObjectType); + bool ret = charging_schedule_converter.toJson(data.chargingSchedule, charging_schedule); json.AddMember(rapidjson::StringRef("chargingSchedule"), charging_schedule.Move(), *allocator); return ret; } +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/types/ChargingProfileConverter.h b/src/ocpp16/messages/types/ChargingProfileConverter.h similarity index 58% rename from src/messages/types/ChargingProfileConverter.h rename to src/ocpp16/messages/types/ChargingProfileConverter.h index 05d6677e..00a3f79f 100644 --- a/src/messages/types/ChargingProfileConverter.h +++ b/src/ocpp16/messages/types/ChargingProfileConverter.h @@ -26,28 +26,31 @@ namespace ocpp { namespace messages { +namespace ocpp16 +{ /** @brief Converter class for ChargingProfile type */ -class ChargingProfileConverter : public IMessageConverter +class ChargingProfileConverter : public IMessageConverter { public: - /** @copydoc IMessageConverter* IMessageConverter::clone() const */ - IMessageConverter* clone() const override { return new ChargingProfileConverter(); } + /** @copydoc IMessageConverter* IMessageConverter::clone() const */ + IMessageConverter* clone() const override { return new ChargingProfileConverter(); } - /** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, - * ocpp::types::ChargingProfile&, + /** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, + * ocpp::types::ocpp16::ChargingProfile&, * std::string&, * std::string&) */ - bool fromJson(const rapidjson::Value& json, - ocpp::types::ChargingProfile& data, - std::string& error_code, - std::string& error_message) override; + bool fromJson(const rapidjson::Value& json, + ocpp::types::ocpp16::ChargingProfile& data, + std::string& error_code, + std::string& error_message) override; - /** @copydoc bool IMessageConverter::toJson(const ocpp::types::ChargingProfile&, + /** @copydoc bool IMessageConverter::toJson(const ocpp::types::ocpp16::ChargingProfile&, * rapidjson::Document&) */ - bool toJson(const ocpp::types::ChargingProfile& data, rapidjson::Document& json) override; + bool toJson(const ocpp::types::ocpp16::ChargingProfile& data, rapidjson::Document& json) override; }; +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/types/ChargingScheduleConverter.cpp b/src/ocpp16/messages/types/ChargingScheduleConverter.cpp similarity index 83% rename from src/messages/types/ChargingScheduleConverter.cpp rename to src/ocpp16/messages/types/ChargingScheduleConverter.cpp index 8df8705f..956363fa 100644 --- a/src/messages/types/ChargingScheduleConverter.cpp +++ b/src/ocpp16/messages/types/ChargingScheduleConverter.cpp @@ -21,20 +21,23 @@ along with OpenOCPP. If not, see . #include "IRpc.h" using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { namespace messages { +namespace ocpp16 +{ -/** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, - * ocpp::types::ChargingSchedule&, +/** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, + * ocpp::types::ocpp16::ChargingSchedule&, * std::string&, * std::string&) */ -bool ChargingScheduleConverter::fromJson(const rapidjson::Value& json, - ocpp::types::ChargingSchedule& data, - std::string& error_code, - std::string& error_message) +bool ChargingScheduleConverter::fromJson(const rapidjson::Value& json, + ocpp::types::ocpp16::ChargingSchedule& data, + std::string& error_code, + std::string& error_message) { bool ret = extract(json, "startSchedule", data.startSchedule, error_message); extract(json, "duration", data.duration); @@ -67,9 +70,9 @@ bool ChargingScheduleConverter::fromJson(const rapidjson::Value& json, return ret; } -/** @copydoc bool IMessageConverter::toJson(const ocpp::types::ChargingSchedule&, +/** @copydoc bool IMessageConverter::toJson(const ocpp::types::ocpp16::ChargingSchedule&, * rapidjson::Document&) */ -bool ChargingScheduleConverter::toJson(const ocpp::types::ChargingSchedule& data, rapidjson::Document& json) +bool ChargingScheduleConverter::toJson(const ocpp::types::ocpp16::ChargingSchedule& data, rapidjson::Document& json) { fill(json, "startSchedule", data.startSchedule); fill(json, "duration", data.duration); @@ -79,8 +82,7 @@ bool ChargingScheduleConverter::toJson(const ocpp::types::ChargingSchedule& data rapidjson::Value chargingSchedulePeriod(rapidjson::kArrayType); for (const ChargingSchedulePeriod& schedule_period : data.chargingSchedulePeriod) { - rapidjson::Document value; - value.Parse("{}"); + rapidjson::Document value(rapidjson::kObjectType); fill(value, "startPeriod", schedule_period.startPeriod); fill(value, "limit", schedule_period.limit); fill(value, "numberPhases", schedule_period.numberPhases); @@ -91,5 +93,6 @@ bool ChargingScheduleConverter::toJson(const ocpp::types::ChargingSchedule& data return true; } +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/types/ChargingScheduleConverter.h b/src/ocpp16/messages/types/ChargingScheduleConverter.h similarity index 58% rename from src/messages/types/ChargingScheduleConverter.h rename to src/ocpp16/messages/types/ChargingScheduleConverter.h index 86685b3e..42bbc627 100644 --- a/src/messages/types/ChargingScheduleConverter.h +++ b/src/ocpp16/messages/types/ChargingScheduleConverter.h @@ -26,28 +26,31 @@ namespace ocpp { namespace messages { +namespace ocpp16 +{ /** @brief Converter class for ChargingSchedule type */ -class ChargingScheduleConverter : public IMessageConverter +class ChargingScheduleConverter : public IMessageConverter { public: - /** @copydoc IMessageConverter* IMessageConverter::clone() const */ - IMessageConverter* clone() const override { return new ChargingScheduleConverter(); } + /** @copydoc IMessageConverter* IMessageConverter::clone() const */ + IMessageConverter* clone() const override { return new ChargingScheduleConverter(); } - /** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, - * ocpp::types::ChargingSchedule&, + /** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, + * ocpp::types::ocpp16::ChargingSchedule&, * std::string&, * std::string&) */ - bool fromJson(const rapidjson::Value& json, - ocpp::types::ChargingSchedule& data, - std::string& error_code, - std::string& error_message) override; + bool fromJson(const rapidjson::Value& json, + ocpp::types::ocpp16::ChargingSchedule& data, + std::string& error_code, + std::string& error_message) override; - /** @copydoc bool IMessageConverter::toJson(const ocpp::types::ChargingSchedule&, + /** @copydoc bool IMessageConverter::toJson(const ocpp::types::ocpp16::ChargingSchedule&, * rapidjson::Document&) */ - bool toJson(const ocpp::types::ChargingSchedule& data, rapidjson::Document& json) override; + bool toJson(const ocpp::types::ocpp16::ChargingSchedule& data, rapidjson::Document& json) override; }; +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/types/IdTagInfoConverter.cpp b/src/ocpp16/messages/types/IdTagInfoConverter.cpp similarity index 70% rename from src/messages/types/IdTagInfoConverter.cpp rename to src/ocpp16/messages/types/IdTagInfoConverter.cpp index 3039ddfc..8ff92a2b 100644 --- a/src/messages/types/IdTagInfoConverter.cpp +++ b/src/ocpp16/messages/types/IdTagInfoConverter.cpp @@ -21,20 +21,23 @@ along with OpenOCPP. If not, see . #include "IRpc.h" using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { namespace messages { +namespace ocpp16 +{ -/** @bcopydoc bool IMessageConverter::fromJson(const rapidjson::Value&, - * ocpp::types::IdTagInfo&, +/** @bcopydoc bool IMessageConverter::fromJson(const rapidjson::Value&, + * ocpp::types::ocpp16::IdTagInfo&, * std::string&, * std::string&) */ -bool IdTagInfoConverter::fromJson(const rapidjson::Value& json, - ocpp::types::IdTagInfo& data, - std::string& error_code, - std::string& error_message) +bool IdTagInfoConverter::fromJson(const rapidjson::Value& json, + ocpp::types::ocpp16::IdTagInfo& data, + std::string& error_code, + std::string& error_message) { bool ret; ret = extract(json, "expiryDate", data.expiryDate, error_message); @@ -47,9 +50,9 @@ bool IdTagInfoConverter::fromJson(const rapidjson::Value& json, return ret; } -/** @copydoc bool IMessageConverter::toJson(const ocpp::types::IdTagInfo&, +/** @copydoc bool IMessageConverter::toJson(const ocpp::types::ocpp16::IdTagInfo&, * rapidjson::Document&) */ -bool IdTagInfoConverter::toJson(const ocpp::types::IdTagInfo& data, rapidjson::Document& json) +bool IdTagInfoConverter::toJson(const ocpp::types::ocpp16::IdTagInfo& data, rapidjson::Document& json) { fill(json, "expiryDate", data.expiryDate); fill(json, "parentIdTag", data.parentIdTag); @@ -57,5 +60,6 @@ bool IdTagInfoConverter::toJson(const ocpp::types::IdTagInfo& data, rapidjson::D return true; } +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/types/IdTagInfoConverter.h b/src/ocpp16/messages/types/IdTagInfoConverter.h similarity index 60% rename from src/messages/types/IdTagInfoConverter.h rename to src/ocpp16/messages/types/IdTagInfoConverter.h index 40bc3451..6959fa71 100644 --- a/src/messages/types/IdTagInfoConverter.h +++ b/src/ocpp16/messages/types/IdTagInfoConverter.h @@ -26,25 +26,31 @@ namespace ocpp { namespace messages { +namespace ocpp16 +{ /** @brief Converter class for IdTagInfo type */ -class IdTagInfoConverter : public IMessageConverter +class IdTagInfoConverter : public IMessageConverter { public: - /** @copydoc IMessageConverter* IMessageConverter::clone() const */ - IMessageConverter* clone() const override { return new IdTagInfoConverter(); } + /** @copydoc IMessageConverter* IMessageConverter::clone() const */ + IMessageConverter* clone() const override { return new IdTagInfoConverter(); } - /** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, - * ocpp::types::IdTagInfo&, + /** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, + * ocpp::types::ocpp16::IdTagInfo&, * std::string&, * std::string&) */ - bool fromJson(const rapidjson::Value& json, ocpp::types::IdTagInfo& data, std::string& error_code, std::string& error_message) override; + bool fromJson(const rapidjson::Value& json, + ocpp::types::ocpp16::IdTagInfo& data, + std::string& error_code, + std::string& error_message) override; - /** @copydoc bool IMessageConverter::toJson(const ocpp::types::IdTagInfo&, + /** @copydoc bool IMessageConverter::toJson(const ocpp::types::ocpp16::IdTagInfo&, * rapidjson::Document&) */ - bool toJson(const ocpp::types::IdTagInfo& data, rapidjson::Document& json) override; + bool toJson(const ocpp::types::ocpp16::IdTagInfo& data, rapidjson::Document& json) override; }; +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/types/IdTokenInfoTypeConverter.cpp b/src/ocpp16/messages/types/IdTokenInfoTypeConverter.cpp similarity index 75% rename from src/messages/types/IdTokenInfoTypeConverter.cpp rename to src/ocpp16/messages/types/IdTokenInfoTypeConverter.cpp index b5aa3859..53a349be 100644 --- a/src/messages/types/IdTokenInfoTypeConverter.cpp +++ b/src/ocpp16/messages/types/IdTokenInfoTypeConverter.cpp @@ -21,20 +21,23 @@ along with OpenOCPP. If not, see . #include "IRpc.h" using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { namespace messages { +namespace ocpp16 +{ -/** @bcopydoc bool IMessageConverter::fromJson(const rapidjson::Value&, - * ocpp::types::IdTokenInfoType&, +/** @bcopydoc bool IMessageConverter::fromJson(const rapidjson::Value&, + * ocpp::types::ocpp16::IdTokenInfoType&, * std::string&, * std::string&) */ -bool IdTokenInfoTypeConverter::fromJson(const rapidjson::Value& json, - ocpp::types::IdTokenInfoType& data, - std::string& error_code, - std::string& error_message) +bool IdTokenInfoTypeConverter::fromJson(const rapidjson::Value& json, + ocpp::types::ocpp16::IdTokenInfoType& data, + std::string& error_code, + std::string& error_message) { data.status = AuthorizationStatusHelper.fromString(json["status"].GetString()); bool ret = extract(json, "cacheExpiryDateTime", data.cacheExpiryDateTime, error_message); @@ -45,9 +48,9 @@ bool IdTokenInfoTypeConverter::fromJson(const rapidjson::Value& json, return ret; } -/** @copydoc bool IMessageConverter::toJson(const ocpp::types::IdTokenInfoType&, +/** @copydoc bool IMessageConverter::toJson(const ocpp::types::ocpp16::IdTokenInfoType&, * rapidjson::Document&) */ -bool IdTokenInfoTypeConverter::toJson(const ocpp::types::IdTokenInfoType& data, rapidjson::Document& json) +bool IdTokenInfoTypeConverter::toJson(const ocpp::types::ocpp16::IdTokenInfoType& data, rapidjson::Document& json) { fill(json, "status", AuthorizationStatusHelper.toString(data.status)); if (data.cacheExpiryDateTime.isSet()) @@ -57,5 +60,6 @@ bool IdTokenInfoTypeConverter::toJson(const ocpp::types::IdTokenInfoType& data, return true; } +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/types/IdTokenInfoTypeConverter.h b/src/ocpp16/messages/types/IdTokenInfoTypeConverter.h similarity index 58% rename from src/messages/types/IdTokenInfoTypeConverter.h rename to src/ocpp16/messages/types/IdTokenInfoTypeConverter.h index 45769985..cadf936a 100644 --- a/src/messages/types/IdTokenInfoTypeConverter.h +++ b/src/ocpp16/messages/types/IdTokenInfoTypeConverter.h @@ -26,28 +26,31 @@ namespace ocpp { namespace messages { +namespace ocpp16 +{ /** @brief Converter class for IdTokenInfoType type */ -class IdTokenInfoTypeConverter : public IMessageConverter +class IdTokenInfoTypeConverter : public IMessageConverter { public: - /** @copydoc IMessageConverter* IMessageConverter::clone() const */ - IMessageConverter* clone() const override { return new IdTokenInfoTypeConverter(); } + /** @copydoc IMessageConverter* IMessageConverter::clone() const */ + IMessageConverter* clone() const override { return new IdTokenInfoTypeConverter(); } - /** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, - * ocpp::types::IdTokenInfoType&, + /** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, + * ocpp::types::ocpp16::IdTokenInfoType&, * std::string&, * std::string&) */ - bool fromJson(const rapidjson::Value& json, - ocpp::types::IdTokenInfoType& data, - std::string& error_code, - std::string& error_message) override; + bool fromJson(const rapidjson::Value& json, + ocpp::types::ocpp16::IdTokenInfoType& data, + std::string& error_code, + std::string& error_message) override; - /** @copydoc bool IMessageConverter::toJson(const ocpp::types::IdTokenInfoType&, + /** @copydoc bool IMessageConverter::toJson(const ocpp::types::ocpp16::IdTokenInfoType&, * rapidjson::Document&) */ - bool toJson(const ocpp::types::IdTokenInfoType& data, rapidjson::Document& json) override; + bool toJson(const ocpp::types::ocpp16::IdTokenInfoType& data, rapidjson::Document& json) override; }; +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/types/MeterValueConverter.cpp b/src/ocpp16/messages/types/MeterValueConverter.cpp similarity index 83% rename from src/messages/types/MeterValueConverter.cpp rename to src/ocpp16/messages/types/MeterValueConverter.cpp index d4bff890..7fdaa6b1 100644 --- a/src/messages/types/MeterValueConverter.cpp +++ b/src/ocpp16/messages/types/MeterValueConverter.cpp @@ -20,20 +20,23 @@ along with OpenOCPP. If not, see . #include "IRpc.h" using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { namespace messages { +namespace ocpp16 +{ -/** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, - * ocpp::types::MeterValue&, +/** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, + * ocpp::types::ocpp16::MeterValue&, * std::string&, * std::string&) */ -bool MeterValueConverter::fromJson(const rapidjson::Value& json, - ocpp::types::MeterValue& data, - std::string& error_code, - std::string& error_message) +bool MeterValueConverter::fromJson(const rapidjson::Value& json, + ocpp::types::ocpp16::MeterValue& data, + std::string& error_code, + std::string& error_message) { bool ret = extract(json, "timestamp", data.timestamp, error_message); @@ -77,17 +80,16 @@ bool MeterValueConverter::fromJson(const rapidjson::Value& json, return ret; } -/** @copydoc bool IMessageConverter::toJson(const ocpp::types::MeterValue&, +/** @copydoc bool IMessageConverter::toJson(const ocpp::types::ocpp16::MeterValue&, * rapidjson::Document&) */ -bool MeterValueConverter::toJson(const ocpp::types::MeterValue& data, rapidjson::Document& json) +bool MeterValueConverter::toJson(const ocpp::types::ocpp16::MeterValue& data, rapidjson::Document& json) { fill(json, "timestamp", data.timestamp); rapidjson::Value sampledValue(rapidjson::kArrayType); for (const SampledValue& sampled_value : data.sampledValue) { - rapidjson::Document sampled; - sampled.Parse("{}"); + rapidjson::Document sampled(rapidjson::kObjectType); fill(sampled, "value", sampled_value.value); if (sampled_value.context.isSet()) { @@ -120,5 +122,6 @@ bool MeterValueConverter::toJson(const ocpp::types::MeterValue& data, rapidjson: return true; } +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/types/MeterValueConverter.h b/src/ocpp16/messages/types/MeterValueConverter.h similarity index 60% rename from src/messages/types/MeterValueConverter.h rename to src/ocpp16/messages/types/MeterValueConverter.h index 8ea80791..2c5188fe 100644 --- a/src/messages/types/MeterValueConverter.h +++ b/src/ocpp16/messages/types/MeterValueConverter.h @@ -26,28 +26,31 @@ namespace ocpp { namespace messages { +namespace ocpp16 +{ /** @brief Converter class for MeterValue type */ -class MeterValueConverter : public IMessageConverter +class MeterValueConverter : public IMessageConverter { public: - /** @copydoc IMessageConverter* IMessageConverter::clone() const */ - IMessageConverter* clone() const override { return new MeterValueConverter(); } + /** @copydoc IMessageConverter* IMessageConverter::clone() const */ + IMessageConverter* clone() const override { return new MeterValueConverter(); } - /** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, - * ocpp::types::MeterValue&, + /** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, + * ocpp::types::ocpp16::MeterValue&, * std::string&, * std::string&) */ - bool fromJson(const rapidjson::Value& json, - ocpp::types::MeterValue& data, - std::string& error_code, - std::string& error_message) override; + bool fromJson(const rapidjson::Value& json, + ocpp::types::ocpp16::MeterValue& data, + std::string& error_code, + std::string& error_message) override; - /** @copydoc bool IMessageConverter::toJson(const ocpp::types::MeterValue&, + /** @copydoc bool IMessageConverter::toJson(const ocpp::types::ocpp16::MeterValue&, * rapidjson::Document&) */ - bool toJson(const ocpp::types::MeterValue& data, rapidjson::Document& json) override; + bool toJson(const ocpp::types::ocpp16::MeterValue& data, rapidjson::Document& json) override; }; +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/types/OcspRequestDataTypeConverter.cpp b/src/ocpp16/messages/types/OcspRequestDataTypeConverter.cpp similarity index 75% rename from src/messages/types/OcspRequestDataTypeConverter.cpp rename to src/ocpp16/messages/types/OcspRequestDataTypeConverter.cpp index bd718aaa..12a4d155 100644 --- a/src/messages/types/OcspRequestDataTypeConverter.cpp +++ b/src/ocpp16/messages/types/OcspRequestDataTypeConverter.cpp @@ -21,20 +21,23 @@ along with OpenOCPP. If not, see . #include "IRpc.h" using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { namespace messages { +namespace ocpp16 +{ -/** @bcopydoc bool IMessageConverter::fromJson(const rapidjson::Value&, - * ocpp::types::OcspRequestDataType&, +/** @bcopydoc bool IMessageConverter::fromJson(const rapidjson::Value&, + * ocpp::types::ocpp16::OcspRequestDataType&, * std::string&, * std::string&) */ -bool OcspRequestDataTypeConverter::fromJson(const rapidjson::Value& json, - ocpp::types::OcspRequestDataType& data, - std::string& error_code, - std::string& error_message) +bool OcspRequestDataTypeConverter::fromJson(const rapidjson::Value& json, + ocpp::types::ocpp16::OcspRequestDataType& data, + std::string& error_code, + std::string& error_message) { (void)error_code; (void)error_message; @@ -46,9 +49,9 @@ bool OcspRequestDataTypeConverter::fromJson(const rapidjson::Value& js return true; } -/** @copydoc bool IMessageConverter::toJson(const ocpp::types::OcspRequestDataType&, +/** @copydoc bool IMessageConverter::toJson(const ocpp::types::ocpp16::OcspRequestDataType&, * rapidjson::Document&) */ -bool OcspRequestDataTypeConverter::toJson(const ocpp::types::OcspRequestDataType& data, rapidjson::Document& json) +bool OcspRequestDataTypeConverter::toJson(const ocpp::types::ocpp16::OcspRequestDataType& data, rapidjson::Document& json) { fill(json, "hashAlgorithm", HashAlgorithmEnumTypeHelper.toString(data.hashAlgorithm)); fill(json, "issuerKeyHash", data.issuerKeyHash); @@ -58,5 +61,6 @@ bool OcspRequestDataTypeConverter::toJson(const ocpp::types::OcspRequestDataType return true; } +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/messages/types/OcspRequestDataTypeConverter.h b/src/ocpp16/messages/types/OcspRequestDataTypeConverter.h similarity index 58% rename from src/messages/types/OcspRequestDataTypeConverter.h rename to src/ocpp16/messages/types/OcspRequestDataTypeConverter.h index 73a6d01a..97a2f7c1 100644 --- a/src/messages/types/OcspRequestDataTypeConverter.h +++ b/src/ocpp16/messages/types/OcspRequestDataTypeConverter.h @@ -26,28 +26,31 @@ namespace ocpp { namespace messages { +namespace ocpp16 +{ /** @brief Converter class for OcspRequestDataType type */ -class OcspRequestDataTypeConverter : public IMessageConverter +class OcspRequestDataTypeConverter : public IMessageConverter { public: - /** @copydoc IMessageConverter* IMessageConverter::clone() const */ - IMessageConverter* clone() const override { return new OcspRequestDataTypeConverter(); } + /** @copydoc IMessageConverter* IMessageConverter::clone() const */ + IMessageConverter* clone() const override { return new OcspRequestDataTypeConverter(); } - /** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, - * ocpp::types::OcspRequestDataType&, + /** @copydoc bool IMessageConverter::fromJson(const rapidjson::Value&, + * ocpp::types::ocpp16::OcspRequestDataType&, * std::string&, * std::string&) */ - bool fromJson(const rapidjson::Value& json, - ocpp::types::OcspRequestDataType& data, - std::string& error_code, - std::string& error_message) override; + bool fromJson(const rapidjson::Value& json, + ocpp::types::ocpp16::OcspRequestDataType& data, + std::string& error_code, + std::string& error_message) override; - /** @copydoc bool IMessageConverter::toJson(const ocpp::types::OcspRequestDataType&, + /** @copydoc bool IMessageConverter::toJson(const ocpp::types::ocpp16::OcspRequestDataType&, * rapidjson::Document&) */ - bool toJson(const ocpp::types::OcspRequestDataType& data, rapidjson::Document& json) override; + bool toJson(const ocpp::types::ocpp16::OcspRequestDataType& data, rapidjson::Document& json) override; }; +} // namespace ocpp16 } // namespace messages } // namespace ocpp diff --git a/src/types/AuthorizationData.h b/src/ocpp16/types/AuthorizationData.h similarity index 97% rename from src/types/AuthorizationData.h rename to src/ocpp16/types/AuthorizationData.h index 9ca02d4b..778cb2ef 100644 --- a/src/types/AuthorizationData.h +++ b/src/ocpp16/types/AuthorizationData.h @@ -27,6 +27,8 @@ namespace ocpp { namespace types { +namespace ocpp16 +{ /** @brief Elements that constitute an entry of a Local Authorization List update. */ struct AuthorizationData @@ -41,6 +43,7 @@ struct AuthorizationData Optional idTagInfo; }; +} // namespace ocpp16 } // namespace types } // namespace ocpp diff --git a/src/ocpp16/types/CMakeLists.txt b/src/ocpp16/types/CMakeLists.txt new file mode 100644 index 00000000..21867590 --- /dev/null +++ b/src/ocpp16/types/CMakeLists.txt @@ -0,0 +1,9 @@ +###################################################### +# OCPP 1.6 types library # +###################################################### + + +# This is an header only library +add_library(types16 INTERFACE) +target_include_directories(types16 INTERFACE .) +target_link_libraries(types16 INTERFACE types) \ No newline at end of file diff --git a/src/types/CertificateHashDataChainType.h b/src/ocpp16/types/CertificateHashDataChainType.h similarity index 97% rename from src/types/CertificateHashDataChainType.h rename to src/ocpp16/types/CertificateHashDataChainType.h index 4e3314dc..1dddc5cd 100644 --- a/src/types/CertificateHashDataChainType.h +++ b/src/ocpp16/types/CertificateHashDataChainType.h @@ -28,6 +28,8 @@ namespace ocpp { namespace types { +namespace ocpp16 +{ /** @brief CertificateHashDataChainType is used by: GetInstalledCertificateIds.conf */ struct CertificateHashDataChainType @@ -40,6 +42,7 @@ struct CertificateHashDataChainType std::vector childCertificateHashData; }; +} // namespace ocpp16 } // namespace types } // namespace ocpp diff --git a/src/types/CertificateHashDataType.h b/src/ocpp16/types/CertificateHashDataType.h similarity index 97% rename from src/types/CertificateHashDataType.h rename to src/ocpp16/types/CertificateHashDataType.h index 872e53fc..2884902c 100644 --- a/src/types/CertificateHashDataType.h +++ b/src/ocpp16/types/CertificateHashDataType.h @@ -26,6 +26,8 @@ namespace ocpp { namespace types { +namespace ocpp16 +{ /** @brief CertificateHashDataType is used by: DeleteCertificate.req, GetInstalledCertificateIds.conf */ struct CertificateHashDataType @@ -40,6 +42,7 @@ struct CertificateHashDataType CiStringType<40u> serialNumber; }; +} // namespace ocpp16 } // namespace types } // namespace ocpp diff --git a/src/types/ChargingProfile.h b/src/ocpp16/types/ChargingProfile.h similarity index 98% rename from src/types/ChargingProfile.h rename to src/ocpp16/types/ChargingProfile.h index a667dae2..7cf7bd86 100644 --- a/src/types/ChargingProfile.h +++ b/src/ocpp16/types/ChargingProfile.h @@ -28,6 +28,8 @@ namespace ocpp { namespace types { +namespace ocpp16 +{ /** @brief A ChargingProfile consists of a ChargingSchedule, describing the amount of power or current that can be delivered per time interval */ @@ -58,6 +60,7 @@ struct ChargingProfile ChargingSchedule chargingSchedule; }; +} // namespace ocpp16 } // namespace types } // namespace ocpp diff --git a/src/types/ChargingSchedule.h b/src/ocpp16/types/ChargingSchedule.h similarity index 98% rename from src/types/ChargingSchedule.h rename to src/ocpp16/types/ChargingSchedule.h index 819289d3..a6307f12 100644 --- a/src/types/ChargingSchedule.h +++ b/src/ocpp16/types/ChargingSchedule.h @@ -30,6 +30,8 @@ namespace ocpp { namespace types { +namespace ocpp16 +{ /** @brief Charging schedule structure defines a list of charging periods, as used in: GetCompositeSchedule.conf and ChargingProfile */ @@ -56,6 +58,7 @@ struct ChargingSchedule Optional minChargingRate; }; +} // namespace ocpp16 } // namespace types } // namespace ocpp diff --git a/src/types/ChargingSchedulePeriod.h b/src/ocpp16/types/ChargingSchedulePeriod.h similarity index 97% rename from src/types/ChargingSchedulePeriod.h rename to src/ocpp16/types/ChargingSchedulePeriod.h index 561b76b6..d4ad4cc0 100644 --- a/src/types/ChargingSchedulePeriod.h +++ b/src/ocpp16/types/ChargingSchedulePeriod.h @@ -29,6 +29,8 @@ namespace ocpp { namespace types { +namespace ocpp16 +{ /** @brief Charging schedule period structure defines a time period in a charging schedule, as used in: ChargingSchedule */ struct ChargingSchedulePeriod @@ -45,6 +47,7 @@ struct ChargingSchedulePeriod Optional numberPhases; }; +} // namespace ocpp16 } // namespace types } // namespace ocpp diff --git a/src/types/Enums.h b/src/ocpp16/types/Enums.h similarity index 99% rename from src/types/Enums.h rename to src/ocpp16/types/Enums.h index 4058f8a7..abf55a21 100644 --- a/src/types/Enums.h +++ b/src/ocpp16/types/Enums.h @@ -25,6 +25,8 @@ namespace ocpp { namespace types { +namespace ocpp16 +{ /** @brief Result of registration in response to BootNotification.req */ enum class RegistrationStatus @@ -1086,6 +1088,7 @@ enum class Iso15118EVCertificateStatusEnumType /** @brief Helper to convert a Iso15118EVCertificateStatusEnumType enum to string */ extern const EnumToStringFromString Iso15118EVCertificateStatusEnumTypeHelper; +} // namespace ocpp16 } // namespace types } // namespace ocpp diff --git a/src/types/FirmwareType.h b/src/ocpp16/types/FirmwareType.h similarity index 97% rename from src/types/FirmwareType.h rename to src/ocpp16/types/FirmwareType.h index 6259eddd..f1c0fd6d 100644 --- a/src/types/FirmwareType.h +++ b/src/ocpp16/types/FirmwareType.h @@ -27,6 +27,8 @@ namespace ocpp { namespace types { +namespace ocpp16 +{ /** @brief Represents a copy of the firmware that can be loaded/updated on the Charge Point. FirmwareType is used by: SignedUpdateFirmware.req */ @@ -44,6 +46,7 @@ struct FirmwareType CiStringType<800> signature; }; +} // namespace ocpp16 } // namespace types } // namespace ocpp diff --git a/src/types/IdTagInfo.h b/src/ocpp16/types/IdTagInfo.h similarity index 97% rename from src/types/IdTagInfo.h rename to src/ocpp16/types/IdTagInfo.h index 229e4762..21373a3c 100644 --- a/src/types/IdTagInfo.h +++ b/src/ocpp16/types/IdTagInfo.h @@ -29,6 +29,8 @@ namespace ocpp { namespace types { +namespace ocpp16 +{ /** @brief Contains status information about an identifier. It is returned in Authorize, Start Transaction and Stop Transaction responses. @@ -46,6 +48,7 @@ struct IdTagInfo AuthorizationStatus status; }; +} // namespace ocpp16 } // namespace types } // namespace ocpp diff --git a/src/types/IdToken.h b/src/ocpp16/types/IdToken.h similarity index 96% rename from src/types/IdToken.h rename to src/ocpp16/types/IdToken.h index 50263daf..04253577 100644 --- a/src/types/IdToken.h +++ b/src/ocpp16/types/IdToken.h @@ -25,11 +25,14 @@ namespace ocpp { namespace types { +namespace ocpp16 +{ /** @brief Contains the identifier to use for authorization. It is a case insensitive string. In future releases this may become a complex type to support multiple forms of identifiers */ typedef CiStringType<20u> IdToken; +} // namespace ocpp16 } // namespace types } // namespace ocpp diff --git a/src/types/IdTokenInfoType.h b/src/ocpp16/types/IdTokenInfoType.h similarity index 96% rename from src/types/IdTokenInfoType.h rename to src/ocpp16/types/IdTokenInfoType.h index b2ece74e..69403a1d 100644 --- a/src/types/IdTokenInfoType.h +++ b/src/ocpp16/types/IdTokenInfoType.h @@ -27,6 +27,8 @@ namespace ocpp { namespace types { +namespace ocpp16 +{ /** @brief Contains status information about an identifier */ struct IdTokenInfoType @@ -37,6 +39,7 @@ struct IdTokenInfoType Optional cacheExpiryDateTime; }; +} // namespace ocpp16 } // namespace types } // namespace ocpp diff --git a/src/types/KeyValue.h b/src/ocpp16/types/KeyValue.h similarity index 97% rename from src/types/KeyValue.h rename to src/ocpp16/types/KeyValue.h index 84925e07..7d10f1e4 100644 --- a/src/types/KeyValue.h +++ b/src/ocpp16/types/KeyValue.h @@ -26,6 +26,8 @@ namespace ocpp { namespace types { +namespace ocpp16 +{ /** @brief Contains information about a specific configuration key. It is returned in GetConfiguration.conf */ struct KeyValue @@ -38,6 +40,7 @@ struct KeyValue Optional> value; }; +} // namespace ocpp16 } // namespace types } // namespace ocpp diff --git a/src/types/LogParametersType.h b/src/ocpp16/types/LogParametersType.h similarity index 97% rename from src/types/LogParametersType.h rename to src/ocpp16/types/LogParametersType.h index c5bfe6fc..bcb88fea 100644 --- a/src/types/LogParametersType.h +++ b/src/ocpp16/types/LogParametersType.h @@ -27,6 +27,8 @@ namespace ocpp { namespace types { +namespace ocpp16 +{ /** @brief Class for detailed information the retrieval of logging entries. LogParametersType is used by: GetLog.req */ @@ -43,6 +45,7 @@ struct LogParametersType Optional latestTimestamp; }; +} // namespace ocpp16 } // namespace types } // namespace ocpp diff --git a/src/types/MeterValue.h b/src/ocpp16/types/MeterValue.h similarity index 97% rename from src/types/MeterValue.h rename to src/ocpp16/types/MeterValue.h index 62fc67f5..5c987103 100644 --- a/src/types/MeterValue.h +++ b/src/ocpp16/types/MeterValue.h @@ -29,6 +29,8 @@ namespace ocpp { namespace types { +namespace ocpp16 +{ /** @brief Collection of one or more sampled values in MeterValues.req and StopTransaction.req. All sampled values in a MeterValue are sampled at the same point in time */ @@ -40,6 +42,7 @@ struct MeterValue std::vector sampledValue; }; +} // namespace ocpp16 } // namespace types } // namespace ocpp diff --git a/src/types/OcspRequestDataType.h b/src/ocpp16/types/OcspRequestDataType.h similarity index 97% rename from src/types/OcspRequestDataType.h rename to src/ocpp16/types/OcspRequestDataType.h index 1070b3c0..f811c1e7 100644 --- a/src/types/OcspRequestDataType.h +++ b/src/ocpp16/types/OcspRequestDataType.h @@ -26,6 +26,8 @@ namespace ocpp { namespace types { +namespace ocpp16 +{ /** @brief OcspRequestDataType is used by: Authorize.req, GetCertificateStatus.req */ struct OcspRequestDataType @@ -42,6 +44,7 @@ struct OcspRequestDataType CiStringType<512u> responderURL; }; +} // namespace ocpp16 } // namespace types } // namespace ocpp diff --git a/src/types/SampledValue.h b/src/ocpp16/types/SampledValue.h similarity index 98% rename from src/types/SampledValue.h rename to src/ocpp16/types/SampledValue.h index 917493df..824b41df 100644 --- a/src/types/SampledValue.h +++ b/src/ocpp16/types/SampledValue.h @@ -28,6 +28,8 @@ namespace ocpp { namespace types { +namespace ocpp16 +{ /** @brief Single sampled value in MeterValues. Each value can be accompanied by optional fields */ struct SampledValue @@ -55,6 +57,7 @@ struct SampledValue Optional unit; }; +} // namespace ocpp16 } // namespace types } // namespace ocpp diff --git a/src/types/SecurityEvent.h b/src/ocpp16/types/SecurityEvent.h similarity index 99% rename from src/types/SecurityEvent.h rename to src/ocpp16/types/SecurityEvent.h index 666b905b..a6d7a75f 100644 --- a/src/types/SecurityEvent.h +++ b/src/ocpp16/types/SecurityEvent.h @@ -23,6 +23,8 @@ namespace ocpp { namespace types { +namespace ocpp16 +{ // Standard OCPP security events @@ -66,6 +68,7 @@ static constexpr const char* SECEVT_INVALID_TLS_VERSION = "InvalidTLSVersion"; /** @brief The Central System did only allow connections using TLS cipher suites that are not allowed by the security specification */ static constexpr const char* SECEVT_INVALID_TLS_CIPHER_SUITE = "InvalidTLSCipherSuite"; +} // namespace ocpp16 } // namespace types } // namespace ocpp diff --git a/src/types/SmartChargingSetpoint.h b/src/ocpp16/types/SmartChargingSetpoint.h similarity index 96% rename from src/types/SmartChargingSetpoint.h rename to src/ocpp16/types/SmartChargingSetpoint.h index 4614b4c2..72ee3c7a 100644 --- a/src/types/SmartChargingSetpoint.h +++ b/src/ocpp16/types/SmartChargingSetpoint.h @@ -25,6 +25,8 @@ namespace ocpp { namespace types { +namespace ocpp16 +{ /** @brief Setpoint computed by OCPP smart charging */ struct SmartChargingSetpoint @@ -37,6 +39,7 @@ struct SmartChargingSetpoint Optional min_charging_rate; }; +} // namespace ocpp16 } // namespace types } // namespace ocpp diff --git a/src/ocpp20/CMakeLists.txt b/src/ocpp20/CMakeLists.txt new file mode 100644 index 00000000..91ead8c6 --- /dev/null +++ b/src/ocpp20/CMakeLists.txt @@ -0,0 +1,7 @@ + +# Subdirectories +add_subdirectory(chargepoint) +add_subdirectory(centralsystem) +add_subdirectory(localcontroller) +add_subdirectory(messages) +add_subdirectory(types) diff --git a/src/ocpp20/centralsystem/CMakeLists.txt b/src/ocpp20/centralsystem/CMakeLists.txt new file mode 100644 index 00000000..7749b3c5 --- /dev/null +++ b/src/ocpp20/centralsystem/CMakeLists.txt @@ -0,0 +1,31 @@ +###################################################### +# OCPP 2.0 centralsystem library # +###################################################### + + +# Library target +add_library(centralsystem20 OBJECT + CentralSystem20.cpp + + chargepoint/ChargePointHandler20.cpp + chargepoint/ChargePointProxy20.cpp +) + +# Exported includes +target_include_directories(centralsystem20 PUBLIC interface) + +# Private includes +target_include_directories(centralsystem20 PRIVATE chargepoint + config) + +# Dependencies +target_link_libraries(centralsystem20 + config + database + messages20 + rpc + helpers + log + version + x509 +) diff --git a/src/ocpp20/centralsystem/CentralSystem20.cpp b/src/ocpp20/centralsystem/CentralSystem20.cpp new file mode 100644 index 00000000..43f996c1 --- /dev/null +++ b/src/ocpp20/centralsystem/CentralSystem20.cpp @@ -0,0 +1,378 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +#include "CentralSystem20.h" +#include "ChargePointProxy20.h" +#include "DateTime.h" +#include "ICentralSystemEventsHandler20.h" +#include "InternalConfigKeys.h" +#include "Logger.h" +#include "TimerPool.h" +#include "Version.h" +#include "WebsocketFactory.h" +#include "WorkerThreadPool.h" + +#include +#include +#include + +using namespace ocpp::types; +using namespace ocpp::types::ocpp20; + +namespace ocpp +{ +namespace centralsystem +{ +namespace ocpp20 +{ + +/** @brief Instanciate a central system */ +std::unique_ptr ICentralSystem20::create(const ocpp::config::ICentralSystemConfig20& stack_config, + ICentralSystemEventsHandler20& events_handler) +{ + std::shared_ptr timer_pool(new ocpp::helpers::TimerPool()); + std::shared_ptr worker_pool = + std::make_shared(2u); // 1 asynchronous timer operations + 1 for asynchronous jobs/responses + return std::unique_ptr(new CentralSystem20(stack_config, events_handler, timer_pool, worker_pool)); +} + +/** @brief Instanciate a central system with the provided timer and worker pools */ +std::unique_ptr ICentralSystem20::create(const ocpp::config::ICentralSystemConfig20& stack_config, + ICentralSystemEventsHandler20& events_handler, + std::shared_ptr timer_pool, + std::shared_ptr worker_pool) +{ + return std::unique_ptr(new CentralSystem20(stack_config, events_handler, timer_pool, worker_pool)); +} + +/** @brief Constructor */ +CentralSystem20::CentralSystem20(const ocpp::config::ICentralSystemConfig20& stack_config, + ICentralSystemEventsHandler20& events_handler, + std::shared_ptr timer_pool, + std::shared_ptr worker_pool) + : m_stack_config(stack_config), + m_events_handler(events_handler), + m_timer_pool(timer_pool), + m_worker_pool(worker_pool), + m_database(), + m_internal_config(), + m_messages_converter(), + m_messages_validator(), + m_ws_server(), + m_rpc_server(), + m_uptime_timer(), + m_uptime(0), + m_total_uptime(0) +{ + // Open database + if (!m_stack_config.databasePath().empty()) + { + m_database = std::make_unique(); + m_internal_config = std::make_unique(*m_database); + if (m_database->open(m_stack_config.databasePath())) + { + // Register logger + if (m_stack_config.logMaxEntriesCount() != 0) + { + ocpp::log::Logger::registerDefaultLogger(*m_database, m_stack_config.logMaxEntriesCount()); + } + + // Initialize the database + initDatabase(); + } + else + { + LOG_ERROR << "Unable to open database"; + } + } + + // Uptime timer + if (m_timer_pool && m_worker_pool && m_internal_config) + { + m_uptime_timer = std::make_unique(*m_timer_pool, "Uptime timer"); + m_uptime_timer->setCallback(std::bind(&CentralSystem20::processUptime, this)); + } + + // Random numbers + std::srand(static_cast(time(nullptr))); +} + +/** @brief Destructor */ +CentralSystem20::~CentralSystem20() +{ + stop(); +} + +/** @copydoc bool ICentralSystem20::resetData() */ +bool CentralSystem20::resetData() +{ + bool ret = false; + + // Check if it is already started + if (!m_rpc_server) + { + LOG_INFO << "Reset all data"; + + // Unregister logger + if (m_stack_config.logMaxEntriesCount() != 0) + { + ocpp::log::Logger::unregisterDefaultLogger(); + } + + // Close database to invalid existing connexions + if (m_database) + { + m_database->close(); + + // Delete database + if (std::filesystem::remove(m_stack_config.databasePath())) + { + // Open database + if (m_database->open(m_stack_config.databasePath())) + { + // Register logger + if (m_stack_config.logMaxEntriesCount() != 0) + { + ocpp::log::Logger::registerDefaultLogger(*m_database, m_stack_config.logMaxEntriesCount()); + } + + // Re-initialize with default values + m_total_uptime = 0; + initDatabase(); + } + else + { + LOG_ERROR << "Unable to open database"; + } + } + else + { + LOG_ERROR << "Unable to delete database"; + } + } + } + + return ret; +} + +/** @copydoc bool ICentralSystem20::start() */ +bool CentralSystem20::start() +{ + bool ret = false; + + // Check if it is already started + if (!m_rpc_server) + { + LOG_INFO << "Starting OCPP stack v" << OPEN_OCPP_VERSION << " - Listen URL : " << m_stack_config.listenUrl(); + + // Load validator + ret = m_messages_validator.load(m_stack_config.jsonSchemasPath()); + if (ret) + { + // Start uptime counter + if (m_uptime_timer) + { + m_uptime = 0; + m_internal_config->setKey(START_DATE_KEY, DateTime::now().str()); + m_uptime_timer->start(std::chrono::seconds(1u)); + } + + // Allocate resources + m_ws_server = std::unique_ptr(ocpp::websockets::WebsocketFactory::newServer()); + m_rpc_server = std::make_unique(*m_ws_server, "ocpp2.0.1"); + m_rpc_server->registerServerListener(*this); + + // Configure websocket link + ocpp::websockets::IWebsocketServer::Credentials credentials; + credentials.http_basic_authent = m_stack_config.httpBasicAuthent(); + credentials.tls12_cipher_list = m_stack_config.tlsv12CipherList(); + credentials.tls13_cipher_list = m_stack_config.tlsv13CipherList(); + credentials.ecdh_curve = m_stack_config.tlsEcdhCurve(); + credentials.server_certificate = m_stack_config.tlsServerCertificate(); + credentials.server_certificate_private_key = m_stack_config.tlsServerCertificatePrivateKey(); + credentials.server_certificate_private_key_passphrase = m_stack_config.tlsServerCertificatePrivateKeyPassphrase(); + credentials.server_certificate_ca = m_stack_config.tlsServerCertificateCa(); + credentials.client_certificate_authent = m_stack_config.tlsClientCertificateAuthent(); + credentials.encoded_pem_certificates = false; + + // Start listening + ret = m_rpc_server->start(m_stack_config.listenUrl(), + credentials, + m_stack_config.webSocketPingInterval(), + m_stack_config.incomingRequestsFromCpThreadPoolSize()); + } + else + { + LOG_ERROR << "Unable to load all the messages validators"; + } + } + else + { + LOG_ERROR << "Stack already started"; + } + + return ret; +} + +/** @copydoc bool ICentralSystem20::stop() */ +bool CentralSystem20::stop() +{ + bool ret = false; + + // Check if it is already started + if (m_rpc_server) + { + LOG_INFO << "Stopping OCPP stack"; + + // Stop uptime counter + if (m_uptime_timer) + { + m_uptime_timer->stop(); + saveUptime(); + } + + // Stop connection + ret = m_rpc_server->stop(); + + // Free resources + m_ws_server.reset(); + m_rpc_server.reset(); + + // Close database + if (m_database) + { + m_database->close(); + } + } + else + { + LOG_ERROR << "Stack already stopped"; + } + + return ret; +} + +/** @copydoc bool RpcServer::IListener::rpcAcceptConnection(const char*) */ +bool CentralSystem20::rpcAcceptConnection(const char* ip_address) +{ + // Notify connection => no additional processing is done here + // to keep this callback has fast as possible + return m_events_handler.acceptConnection(ip_address); +} + +/** @copydoc bool RpcServer::IListener::rpcCheckCredentials(const std::string&, const std::string&, const std::string&) */ +bool CentralSystem20::rpcCheckCredentials(const std::string& chargepoint_id, const std::string& user, const std::string& password) +{ + bool ret = false; + LOG_INFO << "Check credentials for Charge Point [" << chargepoint_id << "]"; + + // OCPP protocol force to have user = chargepoint_id + if (user == chargepoint_id) + { + // Check password + ret = m_events_handler.checkCredentials(chargepoint_id, password); + } + return ret; +} + +/** @copydoc void RpcServer::IListener::rpcClientConnected(const std::string&, std::shared_ptr) */ +void CentralSystem20::rpcClientConnected(const std::string& chargepoint_id, std::shared_ptr client) +{ + LOG_INFO << "Connection from Charge Point [" << chargepoint_id << "]"; + + // Instanciate proxy + std::shared_ptr chargepoint( + new ChargePointProxy20(*this, chargepoint_id, client, m_messages_validator, m_messages_converter, m_stack_config)); + + // Notify connection + m_events_handler.chargePointConnected(chargepoint); +} + +/** @copydoc void RpcServer::IListener::rpcClientFailedToConnect(const char*) */ +void CentralSystem20::rpcClientFailedToConnect(const char* ip_address) +{ + // Notify failure => no additional processing is done here + // to keep this callback has fast as possible + return m_events_handler.clientFailedToConnect(ip_address); +} + +/** @copydoc void RpcServer::IListener::rpcServerError() */ +void CentralSystem20::rpcServerError() +{ + LOG_ERROR << "Critical server error"; +} + +/** @brief Initialize the database */ +void CentralSystem20::initDatabase() +{ + // Initialize internal configuration + m_internal_config->initDatabaseTable(); + + // Internal keys + if (!m_internal_config->keyExist(STACK_VERSION_KEY)) + { + m_internal_config->createKey(STACK_VERSION_KEY, OPEN_OCPP_VERSION); + } + else + { + m_internal_config->setKey(STACK_VERSION_KEY, OPEN_OCPP_VERSION); + } + if (!m_internal_config->keyExist(START_DATE_KEY)) + { + m_internal_config->createKey(START_DATE_KEY, ""); + } + if (!m_internal_config->keyExist(UPTIME_KEY)) + { + m_internal_config->createKey(UPTIME_KEY, "0"); + } + if (!m_internal_config->keyExist(TOTAL_UPTIME_KEY)) + { + m_internal_config->createKey(TOTAL_UPTIME_KEY, "0"); + } + else + { + std::string value; + m_internal_config->getKey(TOTAL_UPTIME_KEY, value); + m_total_uptime = static_cast(std::atoi(value.c_str())); + } +} + +/** @brief Process uptime */ +void CentralSystem20::processUptime() +{ + // Increase counters + m_uptime++; + m_total_uptime++; + + // Save counters + if ((m_uptime % 15u) == 0) + { + m_worker_pool->run(std::bind(&CentralSystem20::saveUptime, this)); + } +} + +/** @brief Save the uptime counter in database */ +void CentralSystem20::saveUptime() +{ + m_internal_config->setKey(UPTIME_KEY, std::to_string(m_uptime)); + m_internal_config->setKey(TOTAL_UPTIME_KEY, std::to_string(m_total_uptime)); +} + +} // namespace ocpp20 +} // namespace centralsystem +} // namespace ocpp diff --git a/src/ocpp20/centralsystem/CentralSystem20.h b/src/ocpp20/centralsystem/CentralSystem20.h new file mode 100644 index 00000000..16bc19ac --- /dev/null +++ b/src/ocpp20/centralsystem/CentralSystem20.h @@ -0,0 +1,134 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +#ifndef OPENOCPP_OCPP20_CENTRALSYSTEM_H +#define OPENOCPP_OCPP20_CENTRALSYSTEM_H + +#include "Database.h" +#include "ICentralSystem20.h" +#include "InternalConfigManager.h" +#include "MessagesConverter20.h" +#include "MessagesValidator20.h" +#include "RpcServer.h" +#include "Timer.h" + +#include + +namespace ocpp +{ +namespace centralsystem +{ +namespace ocpp20 +{ + +/** @brief Central system implementation */ +class CentralSystem20 : public ICentralSystem20, public ocpp::rpc::RpcServer::IListener +{ + public: + /** @brief Constructor */ + CentralSystem20(const ocpp::config::ICentralSystemConfig20& stack_config, + ICentralSystemEventsHandler20& events_handler, + std::shared_ptr timer_pool, + std::shared_ptr worker_pool); + + /** @brief Destructor */ + virtual ~CentralSystem20(); + + // ICentralSystem interface + + /** @copydoc const ocpp::config::ICentralSystemConfig20& ICentralSystem20::getConfig() */ + const ocpp::config::ICentralSystemConfig20& getConfig() override { return m_stack_config; } + + /** @copydoc ocpp::helpers::ITimerPool& ICentralSystem20::getTimerPool() */ + ocpp::helpers::ITimerPool& getTimerPool() override { return *m_timer_pool.get(); } + + /** @copydoc ocpp::helpers::WorkerThreadPool& ICentralSystem20::getWorkerPool() */ + ocpp::helpers::WorkerThreadPool& getWorkerPool() override { return *m_worker_pool.get(); } + + /** @copydoc bool ICentralSystem20::resetData() */ + bool resetData() override; + + /** @copydoc bool ICentralSystem20::start() */ + bool start() override; + + /** @copydoc bool ICentralSystem20::stop() */ + bool stop() override; + + // RpcServer::IListener interface + + /** @copydoc bool RpcServer::IListener::rpcAcceptConnection(const char*) */ + bool rpcAcceptConnection(const char* ip_address) override; + + /** @copydoc bool RpcServer::IListener::rpcCheckCredentials(const std::string&, const std::string&, const std::string&) */ + bool rpcCheckCredentials(const std::string& chargepoint_id, const std::string& user, const std::string& password) override; + + /** @copydoc void RpcServer::IListener::rpcClientConnected(const std::string&, std::shared_ptr) */ + void rpcClientConnected(const std::string& chargepoint_id, std::shared_ptr client) override; + + /** @copydoc void RpcServer::IListener::rpcClientFailedToConnect(const char*) */ + void rpcClientFailedToConnect(const char* ip_address) override; + + /** @copydoc void RpcServer::IListener::rpcServerError() */ + void rpcServerError() override; + + private: + /** @brief Stack configuration */ + const ocpp::config::ICentralSystemConfig20& m_stack_config; + /** @brief User defined events handler */ + ICentralSystemEventsHandler20& m_events_handler; + + /** @brief Timer pool */ + std::shared_ptr m_timer_pool; + /** @brief Worker thread pool */ + std::shared_ptr m_worker_pool; + + /** @brief Database */ + std::unique_ptr m_database; + /** @brief Internal configuration manager */ + std::unique_ptr m_internal_config; + + /** @brief Messages converter */ + ocpp::messages::ocpp20::MessagesConverter20 m_messages_converter; + /** @brief Messages validator */ + ocpp::messages::ocpp20::MessagesValidator20 m_messages_validator; + + /** @brief Websocket server */ + std::unique_ptr m_ws_server; + /** @brief RPC server */ + std::unique_ptr m_rpc_server; + + /** @brief Uptime timer */ + std::unique_ptr m_uptime_timer; + /** @brief Uptime in seconds */ + unsigned int m_uptime; + /** @brief Total uptime in seconds */ + unsigned int m_total_uptime; + + /** @brief Initialize the database */ + void initDatabase(); + /** @brief Process uptime */ + void processUptime(); + /** @brief Save the uptime counter in database */ + void saveUptime(); +}; + +} // namespace ocpp20 +} // namespace centralsystem +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_CENTRALSYSTEM_H diff --git a/src/ocpp20/centralsystem/chargepoint/ChargePointHandler20.cpp b/src/ocpp20/centralsystem/chargepoint/ChargePointHandler20.cpp new file mode 100644 index 00000000..414d60c2 --- /dev/null +++ b/src/ocpp20/centralsystem/chargepoint/ChargePointHandler20.cpp @@ -0,0 +1,800 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* Generated by json2cpp */ + +#include "ChargePointHandler20.h" +#include "ICentralSystemConfig20.h" +#include "IChargePointRequestHandler20.h" +#include "IRpc.h" +#include "MessageDispatcher.h" + +using namespace ocpp::messages; +using namespace ocpp::messages::ocpp20; +using namespace ocpp::types; +using namespace ocpp::types::ocpp20; + +namespace ocpp +{ +namespace centralsystem +{ +namespace ocpp20 +{ + +/** @brief Constructor */ +ChargePointHandler20::ChargePointHandler20(const std::string& identifier, + const ocpp::messages::ocpp20::MessagesConverter20& messages_converter, + ocpp::messages::MessageDispatcher& msg_dispatcher) + : GenericMessageHandler(BOOTNOTIFICATION_ACTION, messages_converter), + GenericMessageHandler(AUTHORIZE_ACTION, messages_converter), + GenericMessageHandler(CLEAREDCHARGINGLIMIT_ACTION, messages_converter), + GenericMessageHandler(COSTUPDATED_ACTION, messages_converter), + GenericMessageHandler(DATATRANSFER_ACTION, messages_converter), + GenericMessageHandler(FIRMWARESTATUSNOTIFICATION_ACTION, + messages_converter), + GenericMessageHandler(HEARTBEAT_ACTION, messages_converter), + GenericMessageHandler(LOGSTATUSNOTIFICATION_ACTION, messages_converter), + GenericMessageHandler(METERVALUES_ACTION, messages_converter), + GenericMessageHandler(NOTIFYCHARGINGLIMIT_ACTION, messages_converter), + GenericMessageHandler(NOTIFYCUSTOMERINFORMATION_ACTION, + messages_converter), + GenericMessageHandler(NOTIFYDISPLAYMESSAGES_ACTION, messages_converter), + GenericMessageHandler(NOTIFYEVCHARGINGNEEDS_ACTION, messages_converter), + GenericMessageHandler(NOTIFYEVCHARGINGSCHEDULE_ACTION, messages_converter), + GenericMessageHandler(NOTIFYEVENT_ACTION, messages_converter), + GenericMessageHandler(NOTIFYMONITORINGREPORT_ACTION, messages_converter), + GenericMessageHandler(NOTIFYREPORT_ACTION, messages_converter), + GenericMessageHandler( + PUBLISHFIRMWARESTATUSNOTIFICATION_ACTION, messages_converter), + GenericMessageHandler(REPORTCHARGINGPROFILES_ACTION, messages_converter), + GenericMessageHandler(RESERVATIONSTATUSUPDATE_ACTION, messages_converter), + GenericMessageHandler(SECURITYEVENTNOTIFICATION_ACTION, + messages_converter), + GenericMessageHandler(SIGNCERTIFICATE_ACTION, messages_converter), + GenericMessageHandler(STATUSNOTIFICATION_ACTION, messages_converter), + GenericMessageHandler(TRANSACTIONEVENT_ACTION, messages_converter), + + m_identifier(identifier), + m_handler(nullptr) +{ + msg_dispatcher.registerHandler(BOOTNOTIFICATION_ACTION, + *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(AUTHORIZE_ACTION, *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(CLEAREDCHARGINGLIMIT_ACTION, + *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(COSTUPDATED_ACTION, *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(DATATRANSFER_ACTION, *dynamic_cast*>(this)); + msg_dispatcher.registerHandler( + FIRMWARESTATUSNOTIFICATION_ACTION, + *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(HEARTBEAT_ACTION, *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(LOGSTATUSNOTIFICATION_ACTION, + *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(METERVALUES_ACTION, *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(NOTIFYCHARGINGLIMIT_ACTION, + *dynamic_cast*>(this)); + msg_dispatcher.registerHandler( + NOTIFYCUSTOMERINFORMATION_ACTION, + *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(NOTIFYDISPLAYMESSAGES_ACTION, + *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(NOTIFYEVCHARGINGNEEDS_ACTION, + *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(NOTIFYEVCHARGINGSCHEDULE_ACTION, + *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(NOTIFYEVENT_ACTION, *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(NOTIFYMONITORINGREPORT_ACTION, + *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(NOTIFYREPORT_ACTION, *dynamic_cast*>(this)); + msg_dispatcher.registerHandler( + PUBLISHFIRMWARESTATUSNOTIFICATION_ACTION, + *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(REPORTCHARGINGPROFILES_ACTION, + *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(RESERVATIONSTATUSUPDATE_ACTION, + *dynamic_cast*>(this)); + msg_dispatcher.registerHandler( + SECURITYEVENTNOTIFICATION_ACTION, + *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(SIGNCERTIFICATE_ACTION, + *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(STATUSNOTIFICATION_ACTION, + *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(TRANSACTIONEVENT_ACTION, + *dynamic_cast*>(this)); +} +/** @brief Destructor */ +ChargePointHandler20::~ChargePointHandler20() { } + +// OCPP handlers +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePointHandler20::handleMessage(const ocpp::messages::ocpp20::BootNotificationReq& request, + ocpp::messages::ocpp20::BootNotificationConf& response, + std::string& error_code, + std::string& error_message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - BootNotification requested"; + + // Notify request + if (m_handler) + { + ret = m_handler->onBootNotification(request, response, error_code, error_message); + + LOG_INFO << "[" << m_identifier << "] - BootNotification handled"; + } + else + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_INTERNAL; + } + + return ret; +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePointHandler20::handleMessage(const ocpp::messages::ocpp20::AuthorizeReq& request, + ocpp::messages::ocpp20::AuthorizeConf& response, + std::string& error_code, + std::string& error_message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - Authorize requested"; + + // Notify request + if (m_handler) + { + ret = m_handler->onAuthorize(request, response, error_code, error_message); + + LOG_INFO << "[" << m_identifier << "] - Authorize handled"; + } + else + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_INTERNAL; + } + + return ret; +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePointHandler20::handleMessage(const ocpp::messages::ocpp20::ClearedChargingLimitReq& request, + ocpp::messages::ocpp20::ClearedChargingLimitConf& response, + std::string& error_code, + std::string& error_message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - ClearedChargingLimit requested"; + + // Notify request + if (m_handler) + { + ret = m_handler->onClearedChargingLimit(request, response, error_code, error_message); + + LOG_INFO << "[" << m_identifier << "] - ClearedChargingLimit handled"; + } + else + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_INTERNAL; + } + + return ret; +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePointHandler20::handleMessage(const ocpp::messages::ocpp20::CostUpdatedReq& request, + ocpp::messages::ocpp20::CostUpdatedConf& response, + std::string& error_code, + std::string& error_message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - CostUpdated requested"; + + // Notify request + if (m_handler) + { + ret = m_handler->onCostUpdated(request, response, error_code, error_message); + + LOG_INFO << "[" << m_identifier << "] - CostUpdated handled"; + } + else + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_INTERNAL; + } + + return ret; +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePointHandler20::handleMessage(const ocpp::messages::ocpp20::DataTransferReq& request, + ocpp::messages::ocpp20::DataTransferConf& response, + std::string& error_code, + std::string& error_message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - DataTransfer requested"; + + // Notify request + if (m_handler) + { + ret = m_handler->onDataTransfer(request, response, error_code, error_message); + + LOG_INFO << "[" << m_identifier << "] - DataTransfer handled"; + } + else + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_INTERNAL; + } + + return ret; +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePointHandler20::handleMessage(const ocpp::messages::ocpp20::FirmwareStatusNotificationReq& request, + ocpp::messages::ocpp20::FirmwareStatusNotificationConf& response, + std::string& error_code, + std::string& error_message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - FirmwareStatusNotification requested"; + + // Notify request + if (m_handler) + { + ret = m_handler->onFirmwareStatusNotification(request, response, error_code, error_message); + + LOG_INFO << "[" << m_identifier << "] - FirmwareStatusNotification handled"; + } + else + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_INTERNAL; + } + + return ret; +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePointHandler20::handleMessage(const ocpp::messages::ocpp20::HeartbeatReq& request, + ocpp::messages::ocpp20::HeartbeatConf& response, + std::string& error_code, + std::string& error_message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - Heartbeat requested"; + + // Notify request + if (m_handler) + { + ret = m_handler->onHeartbeat(request, response, error_code, error_message); + + LOG_INFO << "[" << m_identifier << "] - Heartbeat handled"; + } + else + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_INTERNAL; + } + + return ret; +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePointHandler20::handleMessage(const ocpp::messages::ocpp20::LogStatusNotificationReq& request, + ocpp::messages::ocpp20::LogStatusNotificationConf& response, + std::string& error_code, + std::string& error_message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - LogStatusNotification requested"; + + // Notify request + if (m_handler) + { + ret = m_handler->onLogStatusNotification(request, response, error_code, error_message); + + LOG_INFO << "[" << m_identifier << "] - LogStatusNotification handled"; + } + else + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_INTERNAL; + } + + return ret; +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePointHandler20::handleMessage(const ocpp::messages::ocpp20::MeterValuesReq& request, + ocpp::messages::ocpp20::MeterValuesConf& response, + std::string& error_code, + std::string& error_message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - MeterValues requested"; + + // Notify request + if (m_handler) + { + ret = m_handler->onMeterValues(request, response, error_code, error_message); + + LOG_INFO << "[" << m_identifier << "] - MeterValues handled"; + } + else + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_INTERNAL; + } + + return ret; +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePointHandler20::handleMessage(const ocpp::messages::ocpp20::NotifyChargingLimitReq& request, + ocpp::messages::ocpp20::NotifyChargingLimitConf& response, + std::string& error_code, + std::string& error_message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - NotifyChargingLimit requested"; + + // Notify request + if (m_handler) + { + ret = m_handler->onNotifyChargingLimit(request, response, error_code, error_message); + + LOG_INFO << "[" << m_identifier << "] - NotifyChargingLimit handled"; + } + else + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_INTERNAL; + } + + return ret; +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePointHandler20::handleMessage(const ocpp::messages::ocpp20::NotifyCustomerInformationReq& request, + ocpp::messages::ocpp20::NotifyCustomerInformationConf& response, + std::string& error_code, + std::string& error_message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - NotifyCustomerInformation requested"; + + // Notify request + if (m_handler) + { + ret = m_handler->onNotifyCustomerInformation(request, response, error_code, error_message); + + LOG_INFO << "[" << m_identifier << "] - NotifyCustomerInformation handled"; + } + else + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_INTERNAL; + } + + return ret; +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePointHandler20::handleMessage(const ocpp::messages::ocpp20::NotifyDisplayMessagesReq& request, + ocpp::messages::ocpp20::NotifyDisplayMessagesConf& response, + std::string& error_code, + std::string& error_message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - NotifyDisplayMessages requested"; + + // Notify request + if (m_handler) + { + ret = m_handler->onNotifyDisplayMessages(request, response, error_code, error_message); + + LOG_INFO << "[" << m_identifier << "] - NotifyDisplayMessages handled"; + } + else + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_INTERNAL; + } + + return ret; +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePointHandler20::handleMessage(const ocpp::messages::ocpp20::NotifyEVChargingNeedsReq& request, + ocpp::messages::ocpp20::NotifyEVChargingNeedsConf& response, + std::string& error_code, + std::string& error_message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - NotifyEVChargingNeeds requested"; + + // Notify request + if (m_handler) + { + ret = m_handler->onNotifyEVChargingNeeds(request, response, error_code, error_message); + + LOG_INFO << "[" << m_identifier << "] - NotifyEVChargingNeeds handled"; + } + else + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_INTERNAL; + } + + return ret; +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePointHandler20::handleMessage(const ocpp::messages::ocpp20::NotifyEVChargingScheduleReq& request, + ocpp::messages::ocpp20::NotifyEVChargingScheduleConf& response, + std::string& error_code, + std::string& error_message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - NotifyEVChargingSchedule requested"; + + // Notify request + if (m_handler) + { + ret = m_handler->onNotifyEVChargingSchedule(request, response, error_code, error_message); + + LOG_INFO << "[" << m_identifier << "] - NotifyEVChargingSchedule handled"; + } + else + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_INTERNAL; + } + + return ret; +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePointHandler20::handleMessage(const ocpp::messages::ocpp20::NotifyEventReq& request, + ocpp::messages::ocpp20::NotifyEventConf& response, + std::string& error_code, + std::string& error_message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - NotifyEvent requested"; + + // Notify request + if (m_handler) + { + ret = m_handler->onNotifyEvent(request, response, error_code, error_message); + + LOG_INFO << "[" << m_identifier << "] - NotifyEvent handled"; + } + else + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_INTERNAL; + } + + return ret; +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePointHandler20::handleMessage(const ocpp::messages::ocpp20::NotifyMonitoringReportReq& request, + ocpp::messages::ocpp20::NotifyMonitoringReportConf& response, + std::string& error_code, + std::string& error_message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - NotifyMonitoringReport requested"; + + // Notify request + if (m_handler) + { + ret = m_handler->onNotifyMonitoringReport(request, response, error_code, error_message); + + LOG_INFO << "[" << m_identifier << "] - NotifyMonitoringReport handled"; + } + else + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_INTERNAL; + } + + return ret; +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePointHandler20::handleMessage(const ocpp::messages::ocpp20::NotifyReportReq& request, + ocpp::messages::ocpp20::NotifyReportConf& response, + std::string& error_code, + std::string& error_message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - NotifyReport requested"; + + // Notify request + if (m_handler) + { + ret = m_handler->onNotifyReport(request, response, error_code, error_message); + + LOG_INFO << "[" << m_identifier << "] - NotifyReport handled"; + } + else + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_INTERNAL; + } + + return ret; +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePointHandler20::handleMessage(const ocpp::messages::ocpp20::PublishFirmwareStatusNotificationReq& request, + ocpp::messages::ocpp20::PublishFirmwareStatusNotificationConf& response, + std::string& error_code, + std::string& error_message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - PublishFirmwareStatusNotification requested"; + + // Notify request + if (m_handler) + { + ret = m_handler->onPublishFirmwareStatusNotification(request, response, error_code, error_message); + + LOG_INFO << "[" << m_identifier << "] - PublishFirmwareStatusNotification handled"; + } + else + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_INTERNAL; + } + + return ret; +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePointHandler20::handleMessage(const ocpp::messages::ocpp20::ReportChargingProfilesReq& request, + ocpp::messages::ocpp20::ReportChargingProfilesConf& response, + std::string& error_code, + std::string& error_message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - ReportChargingProfiles requested"; + + // Notify request + if (m_handler) + { + ret = m_handler->onReportChargingProfiles(request, response, error_code, error_message); + + LOG_INFO << "[" << m_identifier << "] - ReportChargingProfiles handled"; + } + else + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_INTERNAL; + } + + return ret; +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePointHandler20::handleMessage(const ocpp::messages::ocpp20::ReservationStatusUpdateReq& request, + ocpp::messages::ocpp20::ReservationStatusUpdateConf& response, + std::string& error_code, + std::string& error_message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - ReservationStatusUpdate requested"; + + // Notify request + if (m_handler) + { + ret = m_handler->onReservationStatusUpdate(request, response, error_code, error_message); + + LOG_INFO << "[" << m_identifier << "] - ReservationStatusUpdate handled"; + } + else + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_INTERNAL; + } + + return ret; +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePointHandler20::handleMessage(const ocpp::messages::ocpp20::SecurityEventNotificationReq& request, + ocpp::messages::ocpp20::SecurityEventNotificationConf& response, + std::string& error_code, + std::string& error_message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - SecurityEventNotification requested"; + + // Notify request + if (m_handler) + { + ret = m_handler->onSecurityEventNotification(request, response, error_code, error_message); + + LOG_INFO << "[" << m_identifier << "] - SecurityEventNotification handled"; + } + else + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_INTERNAL; + } + + return ret; +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePointHandler20::handleMessage(const ocpp::messages::ocpp20::SignCertificateReq& request, + ocpp::messages::ocpp20::SignCertificateConf& response, + std::string& error_code, + std::string& error_message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - SignCertificate requested"; + + // Notify request + if (m_handler) + { + ret = m_handler->onSignCertificate(request, response, error_code, error_message); + + LOG_INFO << "[" << m_identifier << "] - SignCertificate handled"; + } + else + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_INTERNAL; + } + + return ret; +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePointHandler20::handleMessage(const ocpp::messages::ocpp20::StatusNotificationReq& request, + ocpp::messages::ocpp20::StatusNotificationConf& response, + std::string& error_code, + std::string& error_message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - StatusNotification requested"; + + // Notify request + if (m_handler) + { + ret = m_handler->onStatusNotification(request, response, error_code, error_message); + + LOG_INFO << "[" << m_identifier << "] - StatusNotification handled"; + } + else + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_INTERNAL; + } + + return ret; +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePointHandler20::handleMessage(const ocpp::messages::ocpp20::TransactionEventReq& request, + ocpp::messages::ocpp20::TransactionEventConf& response, + std::string& error_code, + std::string& error_message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - TransactionEvent requested"; + + // Notify request + if (m_handler) + { + ret = m_handler->onTransactionEvent(request, response, error_code, error_message); + + LOG_INFO << "[" << m_identifier << "] - TransactionEvent handled"; + } + else + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_INTERNAL; + } + + return ret; +} + +} // namespace ocpp20 +} // namespace centralsystem +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/centralsystem/chargepoint/ChargePointHandler20.h b/src/ocpp20/centralsystem/chargepoint/ChargePointHandler20.h new file mode 100644 index 00000000..8cbceb34 --- /dev/null +++ b/src/ocpp20/centralsystem/chargepoint/ChargePointHandler20.h @@ -0,0 +1,361 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +#ifndef OPENOCPP_OCPP20_CS_CHARGEPOINTHANDLER20_H +#define OPENOCPP_OCPP20_CS_CHARGEPOINTHANDLER20_H + +#include "Authorize20.h" +#include "BootNotification20.h" +#include "ClearedChargingLimit20.h" +#include "CostUpdated20.h" +#include "DataTransfer20.h" +#include "FirmwareStatusNotification20.h" +#include "GenericMessageHandler.h" +#include "Heartbeat20.h" +#include "LogStatusNotification20.h" +#include "Logger.h" +#include "MessagesConverter20.h" +#include "MeterValues20.h" +#include "NotifyChargingLimit20.h" +#include "NotifyCustomerInformation20.h" +#include "NotifyDisplayMessages20.h" +#include "NotifyEVChargingNeeds20.h" +#include "NotifyEVChargingSchedule20.h" +#include "NotifyEvent20.h" +#include "NotifyMonitoringReport20.h" +#include "NotifyReport20.h" +#include "PublishFirmwareStatusNotification20.h" +#include "ReportChargingProfiles20.h" +#include "ReservationStatusUpdate20.h" +#include "SecurityEventNotification20.h" +#include "SignCertificate20.h" +#include "StatusNotification20.h" +#include "TransactionEvent20.h" + +namespace ocpp +{ +namespace config +{ +class ICentralSystemConfig20; +} // namespace config +namespace messages +{ +class MessageDispatcher; + +namespace ocpp20 +{ +class MessagesConverter20; +} // namespace ocpp20 +} // namespace messages + +namespace centralsystem +{ +namespace ocpp20 +{ + +class IChargePointRequestHandler20; + +/** @brief Handler for charge point requests */ +class ChargePointHandler20 + : public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler +{ + public: + /** + * @brief Constructor + * @param identifier Charge point's identifier + * @param messages_converter Converter from/to OCPP to/from JSON messages + * @param msg_dispatcher Message dispatcher + */ + ChargePointHandler20(const std::string& identifier, + const ocpp::messages::ocpp20::MessagesConverter20& messages_converter, + ocpp::messages::MessageDispatcher& msg_dispatcher); + /** @brief Destructor */ + virtual ~ChargePointHandler20(); + + /** @brief Register the event handler */ + void registerHandler(IChargePointRequestHandler20& handler) { m_handler = &handler; } + + // OCPP handlers + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::BootNotificationReq& request, + ocpp::messages::ocpp20::BootNotificationConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::AuthorizeReq& request, + ocpp::messages::ocpp20::AuthorizeConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::ClearedChargingLimitReq& request, + ocpp::messages::ocpp20::ClearedChargingLimitConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::CostUpdatedReq& request, + ocpp::messages::ocpp20::CostUpdatedConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::DataTransferReq& request, + ocpp::messages::ocpp20::DataTransferConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::FirmwareStatusNotificationReq& request, + ocpp::messages::ocpp20::FirmwareStatusNotificationConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::HeartbeatReq& request, + ocpp::messages::ocpp20::HeartbeatConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::LogStatusNotificationReq& request, + ocpp::messages::ocpp20::LogStatusNotificationConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::MeterValuesReq& request, + ocpp::messages::ocpp20::MeterValuesConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::NotifyChargingLimitReq& request, + ocpp::messages::ocpp20::NotifyChargingLimitConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::NotifyCustomerInformationReq& request, + ocpp::messages::ocpp20::NotifyCustomerInformationConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::NotifyDisplayMessagesReq& request, + ocpp::messages::ocpp20::NotifyDisplayMessagesConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::NotifyEVChargingNeedsReq& request, + ocpp::messages::ocpp20::NotifyEVChargingNeedsConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::NotifyEVChargingScheduleReq& request, + ocpp::messages::ocpp20::NotifyEVChargingScheduleConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::NotifyEventReq& request, + ocpp::messages::ocpp20::NotifyEventConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::NotifyMonitoringReportReq& request, + ocpp::messages::ocpp20::NotifyMonitoringReportConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::NotifyReportReq& request, + ocpp::messages::ocpp20::NotifyReportConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::PublishFirmwareStatusNotificationReq& request, + ocpp::messages::ocpp20::PublishFirmwareStatusNotificationConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::ReportChargingProfilesReq& request, + ocpp::messages::ocpp20::ReportChargingProfilesConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::ReservationStatusUpdateReq& request, + ocpp::messages::ocpp20::ReservationStatusUpdateConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::SecurityEventNotificationReq& request, + ocpp::messages::ocpp20::SecurityEventNotificationConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::SignCertificateReq& request, + ocpp::messages::ocpp20::SignCertificateConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::StatusNotificationReq& request, + ocpp::messages::ocpp20::StatusNotificationConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::TransactionEventReq& request, + ocpp::messages::ocpp20::TransactionEventConf& response, + std::string& error_code, + std::string& error_message) override; + + private: + /** @brief Charge point's identifier */ + const std::string m_identifier; + /** @brief Request handler */ + IChargePointRequestHandler20* m_handler; +}; + +} // namespace ocpp20 +} // namespace centralsystem +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_CS_CHARGEPOINTHANDLER20_H \ No newline at end of file diff --git a/src/ocpp20/centralsystem/chargepoint/ChargePointProxy20.cpp b/src/ocpp20/centralsystem/chargepoint/ChargePointProxy20.cpp new file mode 100644 index 00000000..d092f669 --- /dev/null +++ b/src/ocpp20/centralsystem/chargepoint/ChargePointProxy20.cpp @@ -0,0 +1,1291 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* Generated by json2cpp */ + +#include "ChargePointProxy20.h" + +using namespace ocpp::messages; +using namespace ocpp::messages::ocpp20; +using namespace ocpp::types; +using namespace ocpp::types::ocpp20; + +namespace ocpp +{ +namespace centralsystem +{ +namespace ocpp20 +{ + +/** @brief Constructor */ +ChargePointProxy20::ChargePointProxy20(ICentralSystem20& central_system, + const std::string& identifier, + std::shared_ptr rpc, + const ocpp::messages::ocpp20::MessagesValidator20& messages_validator, + ocpp::messages::ocpp20::MessagesConverter20& messages_converter, + const ocpp::config::ICentralSystemConfig20& stack_config) + : m_central_system(central_system), + m_identifier(identifier), + m_rpc(rpc), + m_msg_dispatcher(messages_validator), + m_msg_sender(*m_rpc, messages_converter, messages_validator, stack_config.callRequestTimeout()), + m_handler(m_identifier, messages_converter, m_msg_dispatcher), + m_messages_validator(messages_validator), + m_messages_converter(messages_converter) +{ + m_rpc->registerSpy(*this); + m_rpc->registerListener(*this); +} + +/** @brief Destructor */ +ChargePointProxy20::~ChargePointProxy20() +{ + unregisterFromRpcSpy(); +} + +/** @brief Unregister to the IRpc::ISpy interface messages */ +void ChargePointProxy20::unregisterFromRpcSpy() +{ + m_rpc->unregisterSpy(*this); +} + +// ICentralSystem20::IChargePoint20 interface + +/** @copydoc const std::string& ICentralSystem20::IChargePoint20::ipAddress() const */ +const std::string& ChargePointProxy20::ipAddress() const +{ + return m_rpc->ipAddress(); +} + +/** @copydoc void ICentralSystem20::IChargePoint20::setTimeout(std::chrono::milliseconds) */ +void ChargePointProxy20::setTimeout(std::chrono::milliseconds timeout) +{ + m_msg_sender.setTimeout(timeout); +} + +/** @copydoc void ICentralSystem20::IChargePoint20::disconnect() */ +void ChargePointProxy20::disconnect() +{ + m_rpc->disconnect(true); +} + +/** @copydoc void ICentralSystem20::IChargePoint20::registerHandler(IChargePointRequestHandler20&) */ +void ChargePointProxy20::registerHandler(IChargePointRequestHandler20& handler) +{ + m_user_handler = &handler; + m_handler.registerHandler(handler); +} + +// OCPP operations +/** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::CancelReservationReq&, + ocpp::messages::ocpp20::CancelReservationConf&, + std::string&, + std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::CancelReservationReq& request, + ocpp::messages::ocpp20::CancelReservationConf& response, + std::string& error, + std::string& message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - CancelReservation"; + + // Send request + CallResult res = m_msg_sender.call(CANCELRESERVATION_ACTION, request, response, error, message); + if (res == CallResult::Ok) + { + LOG_INFO << "[" << m_identifier << "] - Call done : CancelReservation"; + ret = true; + } + else + { + LOG_ERROR << "[" << m_identifier << "] - Call failed : " << CallResultHelper.toString(res); + } + + return ret; +} +/** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::CertificateSignedReq&, + ocpp::messages::ocpp20::CertificateSignedConf&, + std::string&, + std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::CertificateSignedReq& request, + ocpp::messages::ocpp20::CertificateSignedConf& response, + std::string& error, + std::string& message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - CertificateSigned"; + + // Send request + CallResult res = m_msg_sender.call(CERTIFICATESIGNED_ACTION, request, response, error, message); + if (res == CallResult::Ok) + { + LOG_INFO << "[" << m_identifier << "] - Call done : CertificateSigned"; + ret = true; + } + else + { + LOG_ERROR << "[" << m_identifier << "] - Call failed : " << CallResultHelper.toString(res); + } + + return ret; +} +/** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::ChangeAvailabilityReq&, + ocpp::messages::ocpp20::ChangeAvailabilityConf&, + std::string&, + std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::ChangeAvailabilityReq& request, + ocpp::messages::ocpp20::ChangeAvailabilityConf& response, + std::string& error, + std::string& message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - ChangeAvailability"; + + // Send request + CallResult res = m_msg_sender.call(CHANGEAVAILABILITY_ACTION, request, response, error, message); + if (res == CallResult::Ok) + { + LOG_INFO << "[" << m_identifier << "] - Call done : ChangeAvailability"; + ret = true; + } + else + { + LOG_ERROR << "[" << m_identifier << "] - Call failed : " << CallResultHelper.toString(res); + } + + return ret; +} +/** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::ClearCacheReq&, + ocpp::messages::ocpp20::ClearCacheConf&, + std::string&, + std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::ClearCacheReq& request, + ocpp::messages::ocpp20::ClearCacheConf& response, + std::string& error, + std::string& message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - ClearCache"; + + // Send request + CallResult res = m_msg_sender.call(CLEARCACHE_ACTION, request, response, error, message); + if (res == CallResult::Ok) + { + LOG_INFO << "[" << m_identifier << "] - Call done : ClearCache"; + ret = true; + } + else + { + LOG_ERROR << "[" << m_identifier << "] - Call failed : " << CallResultHelper.toString(res); + } + + return ret; +} +/** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::ClearChargingProfileReq&, + ocpp::messages::ocpp20::ClearChargingProfileConf&, + std::string&, + std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::ClearChargingProfileReq& request, + ocpp::messages::ocpp20::ClearChargingProfileConf& response, + std::string& error, + std::string& message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - ClearChargingProfile"; + + // Send request + CallResult res = m_msg_sender.call(CLEARCHARGINGPROFILE_ACTION, request, response, error, message); + if (res == CallResult::Ok) + { + LOG_INFO << "[" << m_identifier << "] - Call done : ClearChargingProfile"; + ret = true; + } + else + { + LOG_ERROR << "[" << m_identifier << "] - Call failed : " << CallResultHelper.toString(res); + } + + return ret; +} +/** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::ClearDisplayMessageReq&, + ocpp::messages::ocpp20::ClearDisplayMessageConf&, + std::string&, + std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::ClearDisplayMessageReq& request, + ocpp::messages::ocpp20::ClearDisplayMessageConf& response, + std::string& error, + std::string& message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - ClearDisplayMessage"; + + // Send request + CallResult res = m_msg_sender.call(CLEARDISPLAYMESSAGE_ACTION, request, response, error, message); + if (res == CallResult::Ok) + { + LOG_INFO << "[" << m_identifier << "] - Call done : ClearDisplayMessage"; + ret = true; + } + else + { + LOG_ERROR << "[" << m_identifier << "] - Call failed : " << CallResultHelper.toString(res); + } + + return ret; +} +/** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::ClearVariableMonitoringReq&, + ocpp::messages::ocpp20::ClearVariableMonitoringConf&, + std::string&, + std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::ClearVariableMonitoringReq& request, + ocpp::messages::ocpp20::ClearVariableMonitoringConf& response, + std::string& error, + std::string& message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - ClearVariableMonitoring"; + + // Send request + CallResult res = m_msg_sender.call(CLEARVARIABLEMONITORING_ACTION, request, response, error, message); + if (res == CallResult::Ok) + { + LOG_INFO << "[" << m_identifier << "] - Call done : ClearVariableMonitoring"; + ret = true; + } + else + { + LOG_ERROR << "[" << m_identifier << "] - Call failed : " << CallResultHelper.toString(res); + } + + return ret; +} +/** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::CustomerInformationReq&, + ocpp::messages::ocpp20::CustomerInformationConf&, + std::string&, + std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::CustomerInformationReq& request, + ocpp::messages::ocpp20::CustomerInformationConf& response, + std::string& error, + std::string& message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - CustomerInformation"; + + // Send request + CallResult res = m_msg_sender.call(CUSTOMERINFORMATION_ACTION, request, response, error, message); + if (res == CallResult::Ok) + { + LOG_INFO << "[" << m_identifier << "] - Call done : CustomerInformation"; + ret = true; + } + else + { + LOG_ERROR << "[" << m_identifier << "] - Call failed : " << CallResultHelper.toString(res); + } + + return ret; +} +/** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::DataTransferReq&, + ocpp::messages::ocpp20::DataTransferConf&, + std::string&, + std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::DataTransferReq& request, + ocpp::messages::ocpp20::DataTransferConf& response, + std::string& error, + std::string& message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - DataTransfer"; + + // Send request + CallResult res = m_msg_sender.call(DATATRANSFER_ACTION, request, response, error, message); + if (res == CallResult::Ok) + { + LOG_INFO << "[" << m_identifier << "] - Call done : DataTransfer"; + ret = true; + } + else + { + LOG_ERROR << "[" << m_identifier << "] - Call failed : " << CallResultHelper.toString(res); + } + + return ret; +} +/** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::DeleteCertificateReq&, + ocpp::messages::ocpp20::DeleteCertificateConf&, + std::string&, + std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::DeleteCertificateReq& request, + ocpp::messages::ocpp20::DeleteCertificateConf& response, + std::string& error, + std::string& message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - DeleteCertificate"; + + // Send request + CallResult res = m_msg_sender.call(DELETECERTIFICATE_ACTION, request, response, error, message); + if (res == CallResult::Ok) + { + LOG_INFO << "[" << m_identifier << "] - Call done : DeleteCertificate"; + ret = true; + } + else + { + LOG_ERROR << "[" << m_identifier << "] - Call failed : " << CallResultHelper.toString(res); + } + + return ret; +} +/** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::Get15118EVCertificateReq&, + ocpp::messages::ocpp20::Get15118EVCertificateConf&, + std::string&, + std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::Get15118EVCertificateReq& request, + ocpp::messages::ocpp20::Get15118EVCertificateConf& response, + std::string& error, + std::string& message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - Get15118EVCertificate"; + + // Send request + CallResult res = m_msg_sender.call(GET15118EVCERTIFICATE_ACTION, request, response, error, message); + if (res == CallResult::Ok) + { + LOG_INFO << "[" << m_identifier << "] - Call done : Get15118EVCertificate"; + ret = true; + } + else + { + LOG_ERROR << "[" << m_identifier << "] - Call failed : " << CallResultHelper.toString(res); + } + + return ret; +} +/** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::GetBaseReportReq&, + ocpp::messages::ocpp20::GetBaseReportConf&, + std::string&, + std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::GetBaseReportReq& request, + ocpp::messages::ocpp20::GetBaseReportConf& response, + std::string& error, + std::string& message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - GetBaseReport"; + + // Send request + CallResult res = m_msg_sender.call(GETBASEREPORT_ACTION, request, response, error, message); + if (res == CallResult::Ok) + { + LOG_INFO << "[" << m_identifier << "] - Call done : GetBaseReport"; + ret = true; + } + else + { + LOG_ERROR << "[" << m_identifier << "] - Call failed : " << CallResultHelper.toString(res); + } + + return ret; +} +/** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::GetCertificateStatusReq&, + ocpp::messages::ocpp20::GetCertificateStatusConf&, + std::string&, + std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::GetCertificateStatusReq& request, + ocpp::messages::ocpp20::GetCertificateStatusConf& response, + std::string& error, + std::string& message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - GetCertificateStatus"; + + // Send request + CallResult res = m_msg_sender.call(GETCERTIFICATESTATUS_ACTION, request, response, error, message); + if (res == CallResult::Ok) + { + LOG_INFO << "[" << m_identifier << "] - Call done : GetCertificateStatus"; + ret = true; + } + else + { + LOG_ERROR << "[" << m_identifier << "] - Call failed : " << CallResultHelper.toString(res); + } + + return ret; +} +/** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::GetChargingProfilesReq&, + ocpp::messages::ocpp20::GetChargingProfilesConf&, + std::string&, + std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::GetChargingProfilesReq& request, + ocpp::messages::ocpp20::GetChargingProfilesConf& response, + std::string& error, + std::string& message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - GetChargingProfiles"; + + // Send request + CallResult res = m_msg_sender.call(GETCHARGINGPROFILES_ACTION, request, response, error, message); + if (res == CallResult::Ok) + { + LOG_INFO << "[" << m_identifier << "] - Call done : GetChargingProfiles"; + ret = true; + } + else + { + LOG_ERROR << "[" << m_identifier << "] - Call failed : " << CallResultHelper.toString(res); + } + + return ret; +} +/** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::GetCompositeScheduleReq&, + ocpp::messages::ocpp20::GetCompositeScheduleConf&, + std::string&, + std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::GetCompositeScheduleReq& request, + ocpp::messages::ocpp20::GetCompositeScheduleConf& response, + std::string& error, + std::string& message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - GetCompositeSchedule"; + + // Send request + CallResult res = m_msg_sender.call(GETCOMPOSITESCHEDULE_ACTION, request, response, error, message); + if (res == CallResult::Ok) + { + LOG_INFO << "[" << m_identifier << "] - Call done : GetCompositeSchedule"; + ret = true; + } + else + { + LOG_ERROR << "[" << m_identifier << "] - Call failed : " << CallResultHelper.toString(res); + } + + return ret; +} +/** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::GetDisplayMessagesReq&, + ocpp::messages::ocpp20::GetDisplayMessagesConf&, + std::string&, + std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::GetDisplayMessagesReq& request, + ocpp::messages::ocpp20::GetDisplayMessagesConf& response, + std::string& error, + std::string& message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - GetDisplayMessages"; + + // Send request + CallResult res = m_msg_sender.call(GETDISPLAYMESSAGES_ACTION, request, response, error, message); + if (res == CallResult::Ok) + { + LOG_INFO << "[" << m_identifier << "] - Call done : GetDisplayMessages"; + ret = true; + } + else + { + LOG_ERROR << "[" << m_identifier << "] - Call failed : " << CallResultHelper.toString(res); + } + + return ret; +} +/** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::GetInstalledCertificateIdsReq&, + ocpp::messages::ocpp20::GetInstalledCertificateIdsConf&, + std::string&, + std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::GetInstalledCertificateIdsReq& request, + ocpp::messages::ocpp20::GetInstalledCertificateIdsConf& response, + std::string& error, + std::string& message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - GetInstalledCertificateIds"; + + // Send request + CallResult res = m_msg_sender.call(GETINSTALLEDCERTIFICATEIDS_ACTION, request, response, error, message); + if (res == CallResult::Ok) + { + LOG_INFO << "[" << m_identifier << "] - Call done : GetInstalledCertificateIds"; + ret = true; + } + else + { + LOG_ERROR << "[" << m_identifier << "] - Call failed : " << CallResultHelper.toString(res); + } + + return ret; +} +/** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::GetLocalListVersionReq&, + ocpp::messages::ocpp20::GetLocalListVersionConf&, + std::string&, + std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::GetLocalListVersionReq& request, + ocpp::messages::ocpp20::GetLocalListVersionConf& response, + std::string& error, + std::string& message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - GetLocalListVersion"; + + // Send request + CallResult res = m_msg_sender.call(GETLOCALLISTVERSION_ACTION, request, response, error, message); + if (res == CallResult::Ok) + { + LOG_INFO << "[" << m_identifier << "] - Call done : GetLocalListVersion"; + ret = true; + } + else + { + LOG_ERROR << "[" << m_identifier << "] - Call failed : " << CallResultHelper.toString(res); + } + + return ret; +} +/** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::GetLogReq&, + ocpp::messages::ocpp20::GetLogConf&, + std::string&, + std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::GetLogReq& request, + ocpp::messages::ocpp20::GetLogConf& response, + std::string& error, + std::string& message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - GetLog"; + + // Send request + CallResult res = m_msg_sender.call(GETLOG_ACTION, request, response, error, message); + if (res == CallResult::Ok) + { + LOG_INFO << "[" << m_identifier << "] - Call done : GetLog"; + ret = true; + } + else + { + LOG_ERROR << "[" << m_identifier << "] - Call failed : " << CallResultHelper.toString(res); + } + + return ret; +} +/** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::GetMonitoringReportReq&, + ocpp::messages::ocpp20::GetMonitoringReportConf&, + std::string&, + std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::GetMonitoringReportReq& request, + ocpp::messages::ocpp20::GetMonitoringReportConf& response, + std::string& error, + std::string& message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - GetMonitoringReport"; + + // Send request + CallResult res = m_msg_sender.call(GETMONITORINGREPORT_ACTION, request, response, error, message); + if (res == CallResult::Ok) + { + LOG_INFO << "[" << m_identifier << "] - Call done : GetMonitoringReport"; + ret = true; + } + else + { + LOG_ERROR << "[" << m_identifier << "] - Call failed : " << CallResultHelper.toString(res); + } + + return ret; +} +/** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::GetReportReq&, + ocpp::messages::ocpp20::GetReportConf&, + std::string&, + std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::GetReportReq& request, + ocpp::messages::ocpp20::GetReportConf& response, + std::string& error, + std::string& message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - GetReport"; + + // Send request + CallResult res = m_msg_sender.call(GETREPORT_ACTION, request, response, error, message); + if (res == CallResult::Ok) + { + LOG_INFO << "[" << m_identifier << "] - Call done : GetReport"; + ret = true; + } + else + { + LOG_ERROR << "[" << m_identifier << "] - Call failed : " << CallResultHelper.toString(res); + } + + return ret; +} +/** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::GetTransactionStatusReq&, + ocpp::messages::ocpp20::GetTransactionStatusConf&, + std::string&, + std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::GetTransactionStatusReq& request, + ocpp::messages::ocpp20::GetTransactionStatusConf& response, + std::string& error, + std::string& message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - GetTransactionStatus"; + + // Send request + CallResult res = m_msg_sender.call(GETTRANSACTIONSTATUS_ACTION, request, response, error, message); + if (res == CallResult::Ok) + { + LOG_INFO << "[" << m_identifier << "] - Call done : GetTransactionStatus"; + ret = true; + } + else + { + LOG_ERROR << "[" << m_identifier << "] - Call failed : " << CallResultHelper.toString(res); + } + + return ret; +} +/** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::GetVariablesReq&, + ocpp::messages::ocpp20::GetVariablesConf&, + std::string&, + std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::GetVariablesReq& request, + ocpp::messages::ocpp20::GetVariablesConf& response, + std::string& error, + std::string& message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - GetVariables"; + + // Send request + CallResult res = m_msg_sender.call(GETVARIABLES_ACTION, request, response, error, message); + if (res == CallResult::Ok) + { + LOG_INFO << "[" << m_identifier << "] - Call done : GetVariables"; + ret = true; + } + else + { + LOG_ERROR << "[" << m_identifier << "] - Call failed : " << CallResultHelper.toString(res); + } + + return ret; +} +/** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::InstallCertificateReq&, + ocpp::messages::ocpp20::InstallCertificateConf&, + std::string&, + std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::InstallCertificateReq& request, + ocpp::messages::ocpp20::InstallCertificateConf& response, + std::string& error, + std::string& message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - InstallCertificate"; + + // Send request + CallResult res = m_msg_sender.call(INSTALLCERTIFICATE_ACTION, request, response, error, message); + if (res == CallResult::Ok) + { + LOG_INFO << "[" << m_identifier << "] - Call done : InstallCertificate"; + ret = true; + } + else + { + LOG_ERROR << "[" << m_identifier << "] - Call failed : " << CallResultHelper.toString(res); + } + + return ret; +} +/** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::PublishFirmwareReq&, + ocpp::messages::ocpp20::PublishFirmwareConf&, + std::string&, + std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::PublishFirmwareReq& request, + ocpp::messages::ocpp20::PublishFirmwareConf& response, + std::string& error, + std::string& message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - PublishFirmware"; + + // Send request + CallResult res = m_msg_sender.call(PUBLISHFIRMWARE_ACTION, request, response, error, message); + if (res == CallResult::Ok) + { + LOG_INFO << "[" << m_identifier << "] - Call done : PublishFirmware"; + ret = true; + } + else + { + LOG_ERROR << "[" << m_identifier << "] - Call failed : " << CallResultHelper.toString(res); + } + + return ret; +} +/** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::RequestStartTransactionReq&, + ocpp::messages::ocpp20::RequestStartTransactionConf&, + std::string&, + std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::RequestStartTransactionReq& request, + ocpp::messages::ocpp20::RequestStartTransactionConf& response, + std::string& error, + std::string& message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - RequestStartTransaction"; + + // Send request + CallResult res = m_msg_sender.call(REQUESTSTARTTRANSACTION_ACTION, request, response, error, message); + if (res == CallResult::Ok) + { + LOG_INFO << "[" << m_identifier << "] - Call done : RequestStartTransaction"; + ret = true; + } + else + { + LOG_ERROR << "[" << m_identifier << "] - Call failed : " << CallResultHelper.toString(res); + } + + return ret; +} +/** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::RequestStopTransactionReq&, + ocpp::messages::ocpp20::RequestStopTransactionConf&, + std::string&, + std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::RequestStopTransactionReq& request, + ocpp::messages::ocpp20::RequestStopTransactionConf& response, + std::string& error, + std::string& message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - RequestStopTransaction"; + + // Send request + CallResult res = m_msg_sender.call(REQUESTSTOPTRANSACTION_ACTION, request, response, error, message); + if (res == CallResult::Ok) + { + LOG_INFO << "[" << m_identifier << "] - Call done : RequestStopTransaction"; + ret = true; + } + else + { + LOG_ERROR << "[" << m_identifier << "] - Call failed : " << CallResultHelper.toString(res); + } + + return ret; +} +/** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::ReserveNowReq&, + ocpp::messages::ocpp20::ReserveNowConf&, + std::string&, + std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::ReserveNowReq& request, + ocpp::messages::ocpp20::ReserveNowConf& response, + std::string& error, + std::string& message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - ReserveNow"; + + // Send request + CallResult res = m_msg_sender.call(RESERVENOW_ACTION, request, response, error, message); + if (res == CallResult::Ok) + { + LOG_INFO << "[" << m_identifier << "] - Call done : ReserveNow"; + ret = true; + } + else + { + LOG_ERROR << "[" << m_identifier << "] - Call failed : " << CallResultHelper.toString(res); + } + + return ret; +} +/** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::ResetReq&, + ocpp::messages::ocpp20::ResetConf&, + std::string&, + std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::ResetReq& request, + ocpp::messages::ocpp20::ResetConf& response, + std::string& error, + std::string& message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - Reset"; + + // Send request + CallResult res = m_msg_sender.call(RESET_ACTION, request, response, error, message); + if (res == CallResult::Ok) + { + LOG_INFO << "[" << m_identifier << "] - Call done : Reset"; + ret = true; + } + else + { + LOG_ERROR << "[" << m_identifier << "] - Call failed : " << CallResultHelper.toString(res); + } + + return ret; +} +/** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::SendLocalListReq&, + ocpp::messages::ocpp20::SendLocalListConf&, + std::string&, + std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::SendLocalListReq& request, + ocpp::messages::ocpp20::SendLocalListConf& response, + std::string& error, + std::string& message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - SendLocalList"; + + // Send request + CallResult res = m_msg_sender.call(SENDLOCALLIST_ACTION, request, response, error, message); + if (res == CallResult::Ok) + { + LOG_INFO << "[" << m_identifier << "] - Call done : SendLocalList"; + ret = true; + } + else + { + LOG_ERROR << "[" << m_identifier << "] - Call failed : " << CallResultHelper.toString(res); + } + + return ret; +} +/** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::SetChargingProfileReq&, + ocpp::messages::ocpp20::SetChargingProfileConf&, + std::string&, + std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::SetChargingProfileReq& request, + ocpp::messages::ocpp20::SetChargingProfileConf& response, + std::string& error, + std::string& message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - SetChargingProfile"; + + // Send request + CallResult res = m_msg_sender.call(SETCHARGINGPROFILE_ACTION, request, response, error, message); + if (res == CallResult::Ok) + { + LOG_INFO << "[" << m_identifier << "] - Call done : SetChargingProfile"; + ret = true; + } + else + { + LOG_ERROR << "[" << m_identifier << "] - Call failed : " << CallResultHelper.toString(res); + } + + return ret; +} +/** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::SetDisplayMessageReq&, + ocpp::messages::ocpp20::SetDisplayMessageConf&, + std::string&, + std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::SetDisplayMessageReq& request, + ocpp::messages::ocpp20::SetDisplayMessageConf& response, + std::string& error, + std::string& message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - SetDisplayMessage"; + + // Send request + CallResult res = m_msg_sender.call(SETDISPLAYMESSAGE_ACTION, request, response, error, message); + if (res == CallResult::Ok) + { + LOG_INFO << "[" << m_identifier << "] - Call done : SetDisplayMessage"; + ret = true; + } + else + { + LOG_ERROR << "[" << m_identifier << "] - Call failed : " << CallResultHelper.toString(res); + } + + return ret; +} +/** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::SetMonitoringBaseReq&, + ocpp::messages::ocpp20::SetMonitoringBaseConf&, + std::string&, + std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::SetMonitoringBaseReq& request, + ocpp::messages::ocpp20::SetMonitoringBaseConf& response, + std::string& error, + std::string& message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - SetMonitoringBase"; + + // Send request + CallResult res = m_msg_sender.call(SETMONITORINGBASE_ACTION, request, response, error, message); + if (res == CallResult::Ok) + { + LOG_INFO << "[" << m_identifier << "] - Call done : SetMonitoringBase"; + ret = true; + } + else + { + LOG_ERROR << "[" << m_identifier << "] - Call failed : " << CallResultHelper.toString(res); + } + + return ret; +} +/** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::SetMonitoringLevelReq&, + ocpp::messages::ocpp20::SetMonitoringLevelConf&, + std::string&, + std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::SetMonitoringLevelReq& request, + ocpp::messages::ocpp20::SetMonitoringLevelConf& response, + std::string& error, + std::string& message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - SetMonitoringLevel"; + + // Send request + CallResult res = m_msg_sender.call(SETMONITORINGLEVEL_ACTION, request, response, error, message); + if (res == CallResult::Ok) + { + LOG_INFO << "[" << m_identifier << "] - Call done : SetMonitoringLevel"; + ret = true; + } + else + { + LOG_ERROR << "[" << m_identifier << "] - Call failed : " << CallResultHelper.toString(res); + } + + return ret; +} +/** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::SetNetworkProfileReq&, + ocpp::messages::ocpp20::SetNetworkProfileConf&, + std::string&, + std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::SetNetworkProfileReq& request, + ocpp::messages::ocpp20::SetNetworkProfileConf& response, + std::string& error, + std::string& message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - SetNetworkProfile"; + + // Send request + CallResult res = m_msg_sender.call(SETNETWORKPROFILE_ACTION, request, response, error, message); + if (res == CallResult::Ok) + { + LOG_INFO << "[" << m_identifier << "] - Call done : SetNetworkProfile"; + ret = true; + } + else + { + LOG_ERROR << "[" << m_identifier << "] - Call failed : " << CallResultHelper.toString(res); + } + + return ret; +} +/** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::SetVariableMonitoringReq&, + ocpp::messages::ocpp20::SetVariableMonitoringConf&, + std::string&, + std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::SetVariableMonitoringReq& request, + ocpp::messages::ocpp20::SetVariableMonitoringConf& response, + std::string& error, + std::string& message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - SetVariableMonitoring"; + + // Send request + CallResult res = m_msg_sender.call(SETVARIABLEMONITORING_ACTION, request, response, error, message); + if (res == CallResult::Ok) + { + LOG_INFO << "[" << m_identifier << "] - Call done : SetVariableMonitoring"; + ret = true; + } + else + { + LOG_ERROR << "[" << m_identifier << "] - Call failed : " << CallResultHelper.toString(res); + } + + return ret; +} +/** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::SetVariablesReq&, + ocpp::messages::ocpp20::SetVariablesConf&, + std::string&, + std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::SetVariablesReq& request, + ocpp::messages::ocpp20::SetVariablesConf& response, + std::string& error, + std::string& message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - SetVariables"; + + // Send request + CallResult res = m_msg_sender.call(SETVARIABLES_ACTION, request, response, error, message); + if (res == CallResult::Ok) + { + LOG_INFO << "[" << m_identifier << "] - Call done : SetVariables"; + ret = true; + } + else + { + LOG_ERROR << "[" << m_identifier << "] - Call failed : " << CallResultHelper.toString(res); + } + + return ret; +} +/** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::TriggerMessageReq&, + ocpp::messages::ocpp20::TriggerMessageConf&, + std::string&, + std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::TriggerMessageReq& request, + ocpp::messages::ocpp20::TriggerMessageConf& response, + std::string& error, + std::string& message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - TriggerMessage"; + + // Send request + CallResult res = m_msg_sender.call(TRIGGERMESSAGE_ACTION, request, response, error, message); + if (res == CallResult::Ok) + { + LOG_INFO << "[" << m_identifier << "] - Call done : TriggerMessage"; + ret = true; + } + else + { + LOG_ERROR << "[" << m_identifier << "] - Call failed : " << CallResultHelper.toString(res); + } + + return ret; +} +/** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::UnlockConnectorReq&, + ocpp::messages::ocpp20::UnlockConnectorConf&, + std::string&, + std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::UnlockConnectorReq& request, + ocpp::messages::ocpp20::UnlockConnectorConf& response, + std::string& error, + std::string& message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - UnlockConnector"; + + // Send request + CallResult res = m_msg_sender.call(UNLOCKCONNECTOR_ACTION, request, response, error, message); + if (res == CallResult::Ok) + { + LOG_INFO << "[" << m_identifier << "] - Call done : UnlockConnector"; + ret = true; + } + else + { + LOG_ERROR << "[" << m_identifier << "] - Call failed : " << CallResultHelper.toString(res); + } + + return ret; +} +/** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::UnpublishFirmwareReq&, + ocpp::messages::ocpp20::UnpublishFirmwareConf&, + std::string&, + std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::UnpublishFirmwareReq& request, + ocpp::messages::ocpp20::UnpublishFirmwareConf& response, + std::string& error, + std::string& message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - UnpublishFirmware"; + + // Send request + CallResult res = m_msg_sender.call(UNPUBLISHFIRMWARE_ACTION, request, response, error, message); + if (res == CallResult::Ok) + { + LOG_INFO << "[" << m_identifier << "] - Call done : UnpublishFirmware"; + ret = true; + } + else + { + LOG_ERROR << "[" << m_identifier << "] - Call failed : " << CallResultHelper.toString(res); + } + + return ret; +} +/** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::UpdateFirmwareReq&, + ocpp::messages::ocpp20::UpdateFirmwareConf&, + std::string&, + std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::UpdateFirmwareReq& request, + ocpp::messages::ocpp20::UpdateFirmwareConf& response, + std::string& error, + std::string& message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - UpdateFirmware"; + + // Send request + CallResult res = m_msg_sender.call(UPDATEFIRMWARE_ACTION, request, response, error, message); + if (res == CallResult::Ok) + { + LOG_INFO << "[" << m_identifier << "] - Call done : UpdateFirmware"; + ret = true; + } + else + { + LOG_ERROR << "[" << m_identifier << "] - Call failed : " << CallResultHelper.toString(res); + } + + return ret; +} + +// IRpc::IListener interface + +/** @copydoc void IRpc::IListener::rpcDisconnected() */ +void ChargePointProxy20::rpcDisconnected() +{ + LOG_WARNING << "[" << m_identifier << "] - Disconnected"; + if (m_user_handler) + { + m_user_handler->disconnected(); + } +} + +/** @copydoc void IRpc::IListener::rpcError() */ +void ChargePointProxy20::rpcError() +{ + LOG_ERROR << "[" << m_identifier << "] - Connection error"; +} + +/** @copydoc bool IRpc::IListener::rpcCallReceived(const std::string&, + const rapidjson::Value&, + rapidjson::Document&, + std::string&, + std::string&) */ +bool ChargePointProxy20::rpcCallReceived(const std::string& action, + const rapidjson::Value& payload, + rapidjson::Document& response, + std::string& error_code, + std::string& error_message) +{ + return m_msg_dispatcher.dispatchMessage(action, payload, response, error_code, error_message); +} + +// IRpc::ISpy interface + +/** @copydoc void IRpc::ISpy::rcpMessageReceived(const std::string& msg) */ +void ChargePointProxy20::rcpMessageReceived(const std::string& msg) +{ + LOG_COM << "[" << m_identifier << "] - RX : " << msg; +} + +void ChargePointProxy20::rcpMessageSent(const std::string& msg) +{ + LOG_COM << "[" << m_identifier << "] - TX : " << msg; +} + +} // namespace ocpp20 +} // namespace centralsystem +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/centralsystem/chargepoint/ChargePointProxy20.h b/src/ocpp20/centralsystem/chargepoint/ChargePointProxy20.h new file mode 100644 index 00000000..735c5f44 --- /dev/null +++ b/src/ocpp20/centralsystem/chargepoint/ChargePointProxy20.h @@ -0,0 +1,521 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* Generated by json2cpp */ + +#ifndef OPENOCPP_OCPP20_CS_CHARGEPOINTPROXY20_H +#define OPENOCPP_OCPP20_CS_CHARGEPOINTPROXY20_H + +#include "ChargePointHandler20.h" +#include "GenericMessageSender.h" +#include "ICentralSystem20.h" +#include "Logger.h" +#include "MessageDispatcher.h" +#include "MessagesConverter20.h" +#include "MessagesValidator20.h" +#include "RpcServer.h" + +#include + +namespace ocpp +{ +namespace centralsystem +{ +namespace ocpp20 +{ + +/** @brief Charge point proxy */ +class ChargePointProxy20 : public ICentralSystem20::IChargePoint20, public ocpp::rpc::IRpc::IListener, public ocpp::rpc::IRpc::ISpy +{ + public: + /** + * @brief Constructor + * @param central_system Central System instance associated to the charge point + * @param identifier Charge point's identifier + * @param rpc RPC connection with the charge point + * @param messages_validator JSON schemas needed to validate payloads + * @param messages_converter Converter from/to OCPP to/from JSON messages + * @param stack_config Stack configuration + */ + ChargePointProxy20(ICentralSystem20& central_system, + const std::string& identifier, + std::shared_ptr rpc, + const ocpp::messages::ocpp20::MessagesValidator20& messages_validator, + ocpp::messages::ocpp20::MessagesConverter20& messages_converter, + const ocpp::config::ICentralSystemConfig20& stack_config); + /** @brief Destructor */ + virtual ~ChargePointProxy20(); + + /** @brief Unregister to the IRpc::ISpy interface messages */ + void unregisterFromRpcSpy(); + + // ICentralSystem20::IChargePoint20 interface + + /** @copydoc ICentralSystem20& ICentralSystem20::IChargePoint20::centralSystem() */ + ICentralSystem20& centralSystem() override { return m_central_system; } + + /** @copydoc const std::string& ICentralSystem20::IChargePoint::ipAddress() const */ + const std::string& ipAddress() const override; + + /** @copydoc const std::string& ICentralSystem20::IChargePoint::identifier() const */ + const std::string& identifier() const override { return m_identifier; } + + /** @copydoc void ICentralSystem20::IChargePoint::setTimeout(std::chrono::milliseconds) */ + void setTimeout(std::chrono::milliseconds timeout) override; + + /** @copydoc void ICentralSystem20::IChargePoint::disconnect() */ + void disconnect() override; + + /** @copydoc void ICentralSystem20::IChargePoint20::registerHandler(IChargePointRequestHandler20&) */ + void registerHandler(IChargePointRequestHandler20& handler) override; + + // OCPP operations + /** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::CancelReservationReq&, + ocpp::messages::ocpp20::CancelReservationConf&, + std::string&, + std::string&) */ + bool call(const ocpp::messages::ocpp20::CancelReservationReq& request, + ocpp::messages::ocpp20::CancelReservationConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::CertificateSignedReq&, + ocpp::messages::ocpp20::CertificateSignedConf&, + std::string&, + std::string&) */ + bool call(const ocpp::messages::ocpp20::CertificateSignedReq& request, + ocpp::messages::ocpp20::CertificateSignedConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::ChangeAvailabilityReq&, + ocpp::messages::ocpp20::ChangeAvailabilityConf&, + std::string&, + std::string&) */ + bool call(const ocpp::messages::ocpp20::ChangeAvailabilityReq& request, + ocpp::messages::ocpp20::ChangeAvailabilityConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::ClearCacheReq&, + ocpp::messages::ocpp20::ClearCacheConf&, + std::string&, + std::string&) */ + bool call(const ocpp::messages::ocpp20::ClearCacheReq& request, + ocpp::messages::ocpp20::ClearCacheConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::ClearChargingProfileReq&, + ocpp::messages::ocpp20::ClearChargingProfileConf&, + std::string&, + std::string&) */ + bool call(const ocpp::messages::ocpp20::ClearChargingProfileReq& request, + ocpp::messages::ocpp20::ClearChargingProfileConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::ClearDisplayMessageReq&, + ocpp::messages::ocpp20::ClearDisplayMessageConf&, + std::string&, + std::string&) */ + bool call(const ocpp::messages::ocpp20::ClearDisplayMessageReq& request, + ocpp::messages::ocpp20::ClearDisplayMessageConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::ClearVariableMonitoringReq&, + ocpp::messages::ocpp20::ClearVariableMonitoringConf&, + std::string&, + std::string&) */ + bool call(const ocpp::messages::ocpp20::ClearVariableMonitoringReq& request, + ocpp::messages::ocpp20::ClearVariableMonitoringConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::CustomerInformationReq&, + ocpp::messages::ocpp20::CustomerInformationConf&, + std::string&, + std::string&) */ + bool call(const ocpp::messages::ocpp20::CustomerInformationReq& request, + ocpp::messages::ocpp20::CustomerInformationConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::DataTransferReq&, + ocpp::messages::ocpp20::DataTransferConf&, + std::string&, + std::string&) */ + bool call(const ocpp::messages::ocpp20::DataTransferReq& request, + ocpp::messages::ocpp20::DataTransferConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::DeleteCertificateReq&, + ocpp::messages::ocpp20::DeleteCertificateConf&, + std::string&, + std::string&) */ + bool call(const ocpp::messages::ocpp20::DeleteCertificateReq& request, + ocpp::messages::ocpp20::DeleteCertificateConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::Get15118EVCertificateReq&, + ocpp::messages::ocpp20::Get15118EVCertificateConf&, + std::string&, + std::string&) */ + bool call(const ocpp::messages::ocpp20::Get15118EVCertificateReq& request, + ocpp::messages::ocpp20::Get15118EVCertificateConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::GetBaseReportReq&, + ocpp::messages::ocpp20::GetBaseReportConf&, + std::string&, + std::string&) */ + bool call(const ocpp::messages::ocpp20::GetBaseReportReq& request, + ocpp::messages::ocpp20::GetBaseReportConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::GetCertificateStatusReq&, + ocpp::messages::ocpp20::GetCertificateStatusConf&, + std::string&, + std::string&) */ + bool call(const ocpp::messages::ocpp20::GetCertificateStatusReq& request, + ocpp::messages::ocpp20::GetCertificateStatusConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::GetChargingProfilesReq&, + ocpp::messages::ocpp20::GetChargingProfilesConf&, + std::string&, + std::string&) */ + bool call(const ocpp::messages::ocpp20::GetChargingProfilesReq& request, + ocpp::messages::ocpp20::GetChargingProfilesConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::GetCompositeScheduleReq&, + ocpp::messages::ocpp20::GetCompositeScheduleConf&, + std::string&, + std::string&) */ + bool call(const ocpp::messages::ocpp20::GetCompositeScheduleReq& request, + ocpp::messages::ocpp20::GetCompositeScheduleConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::GetDisplayMessagesReq&, + ocpp::messages::ocpp20::GetDisplayMessagesConf&, + std::string&, + std::string&) */ + bool call(const ocpp::messages::ocpp20::GetDisplayMessagesReq& request, + ocpp::messages::ocpp20::GetDisplayMessagesConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::GetInstalledCertificateIdsReq&, + ocpp::messages::ocpp20::GetInstalledCertificateIdsConf&, + std::string&, + std::string&) */ + bool call(const ocpp::messages::ocpp20::GetInstalledCertificateIdsReq& request, + ocpp::messages::ocpp20::GetInstalledCertificateIdsConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::GetLocalListVersionReq&, + ocpp::messages::ocpp20::GetLocalListVersionConf&, + std::string&, + std::string&) */ + bool call(const ocpp::messages::ocpp20::GetLocalListVersionReq& request, + ocpp::messages::ocpp20::GetLocalListVersionConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::GetLogReq&, + ocpp::messages::ocpp20::GetLogConf&, + std::string&, + std::string&) */ + bool call(const ocpp::messages::ocpp20::GetLogReq& request, + ocpp::messages::ocpp20::GetLogConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::GetMonitoringReportReq&, + ocpp::messages::ocpp20::GetMonitoringReportConf&, + std::string&, + std::string&) */ + bool call(const ocpp::messages::ocpp20::GetMonitoringReportReq& request, + ocpp::messages::ocpp20::GetMonitoringReportConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::GetReportReq&, + ocpp::messages::ocpp20::GetReportConf&, + std::string&, + std::string&) */ + bool call(const ocpp::messages::ocpp20::GetReportReq& request, + ocpp::messages::ocpp20::GetReportConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::GetTransactionStatusReq&, + ocpp::messages::ocpp20::GetTransactionStatusConf&, + std::string&, + std::string&) */ + bool call(const ocpp::messages::ocpp20::GetTransactionStatusReq& request, + ocpp::messages::ocpp20::GetTransactionStatusConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::GetVariablesReq&, + ocpp::messages::ocpp20::GetVariablesConf&, + std::string&, + std::string&) */ + bool call(const ocpp::messages::ocpp20::GetVariablesReq& request, + ocpp::messages::ocpp20::GetVariablesConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::InstallCertificateReq&, + ocpp::messages::ocpp20::InstallCertificateConf&, + std::string&, + std::string&) */ + bool call(const ocpp::messages::ocpp20::InstallCertificateReq& request, + ocpp::messages::ocpp20::InstallCertificateConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::PublishFirmwareReq&, + ocpp::messages::ocpp20::PublishFirmwareConf&, + std::string&, + std::string&) */ + bool call(const ocpp::messages::ocpp20::PublishFirmwareReq& request, + ocpp::messages::ocpp20::PublishFirmwareConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::RequestStartTransactionReq&, + ocpp::messages::ocpp20::RequestStartTransactionConf&, + std::string&, + std::string&) */ + bool call(const ocpp::messages::ocpp20::RequestStartTransactionReq& request, + ocpp::messages::ocpp20::RequestStartTransactionConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::RequestStopTransactionReq&, + ocpp::messages::ocpp20::RequestStopTransactionConf&, + std::string&, + std::string&) */ + bool call(const ocpp::messages::ocpp20::RequestStopTransactionReq& request, + ocpp::messages::ocpp20::RequestStopTransactionConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::ReserveNowReq&, + ocpp::messages::ocpp20::ReserveNowConf&, + std::string&, + std::string&) */ + bool call(const ocpp::messages::ocpp20::ReserveNowReq& request, + ocpp::messages::ocpp20::ReserveNowConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::ResetReq&, + ocpp::messages::ocpp20::ResetConf&, + std::string&, + std::string&) */ + bool call(const ocpp::messages::ocpp20::ResetReq& request, + ocpp::messages::ocpp20::ResetConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::SendLocalListReq&, + ocpp::messages::ocpp20::SendLocalListConf&, + std::string&, + std::string&) */ + bool call(const ocpp::messages::ocpp20::SendLocalListReq& request, + ocpp::messages::ocpp20::SendLocalListConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::SetChargingProfileReq&, + ocpp::messages::ocpp20::SetChargingProfileConf&, + std::string&, + std::string&) */ + bool call(const ocpp::messages::ocpp20::SetChargingProfileReq& request, + ocpp::messages::ocpp20::SetChargingProfileConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::SetDisplayMessageReq&, + ocpp::messages::ocpp20::SetDisplayMessageConf&, + std::string&, + std::string&) */ + bool call(const ocpp::messages::ocpp20::SetDisplayMessageReq& request, + ocpp::messages::ocpp20::SetDisplayMessageConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::SetMonitoringBaseReq&, + ocpp::messages::ocpp20::SetMonitoringBaseConf&, + std::string&, + std::string&) */ + bool call(const ocpp::messages::ocpp20::SetMonitoringBaseReq& request, + ocpp::messages::ocpp20::SetMonitoringBaseConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::SetMonitoringLevelReq&, + ocpp::messages::ocpp20::SetMonitoringLevelConf&, + std::string&, + std::string&) */ + bool call(const ocpp::messages::ocpp20::SetMonitoringLevelReq& request, + ocpp::messages::ocpp20::SetMonitoringLevelConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::SetNetworkProfileReq&, + ocpp::messages::ocpp20::SetNetworkProfileConf&, + std::string&, + std::string&) */ + bool call(const ocpp::messages::ocpp20::SetNetworkProfileReq& request, + ocpp::messages::ocpp20::SetNetworkProfileConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::SetVariableMonitoringReq&, + ocpp::messages::ocpp20::SetVariableMonitoringConf&, + std::string&, + std::string&) */ + bool call(const ocpp::messages::ocpp20::SetVariableMonitoringReq& request, + ocpp::messages::ocpp20::SetVariableMonitoringConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::SetVariablesReq&, + ocpp::messages::ocpp20::SetVariablesConf&, + std::string&, + std::string&) */ + bool call(const ocpp::messages::ocpp20::SetVariablesReq& request, + ocpp::messages::ocpp20::SetVariablesConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::TriggerMessageReq&, + ocpp::messages::ocpp20::TriggerMessageConf&, + std::string&, + std::string&) */ + bool call(const ocpp::messages::ocpp20::TriggerMessageReq& request, + ocpp::messages::ocpp20::TriggerMessageConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::UnlockConnectorReq&, + ocpp::messages::ocpp20::UnlockConnectorConf&, + std::string&, + std::string&) */ + bool call(const ocpp::messages::ocpp20::UnlockConnectorReq& request, + ocpp::messages::ocpp20::UnlockConnectorConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::UnpublishFirmwareReq&, + ocpp::messages::ocpp20::UnpublishFirmwareConf&, + std::string&, + std::string&) */ + bool call(const ocpp::messages::ocpp20::UnpublishFirmwareReq& request, + ocpp::messages::ocpp20::UnpublishFirmwareConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystem20::IChargePoint20::call( + const ocpp::messages::ocpp20::UpdateFirmwareReq&, + ocpp::messages::ocpp20::UpdateFirmwareConf&, + std::string&, + std::string&) */ + bool call(const ocpp::messages::ocpp20::UpdateFirmwareReq& request, + ocpp::messages::ocpp20::UpdateFirmwareConf& response, + std::string& error, + std::string& message) override; + + // IRpc::IListener interface + + /** @copydoc void IRpc::IListener::rpcDisconnected() */ + void rpcDisconnected() override; + + /** @copydoc void IRpc::IListener::rpcError() */ + void rpcError() override; + + /** @copydoc bool IRpc::IListener::rpcCallReceived(const std::string&, + const rapidjson::Value&, + rapidjson::Document&, + std::string&, + std::string&) */ + bool rpcCallReceived(const std::string& action, + const rapidjson::Value& payload, + rapidjson::Document& response, + std::string& error_code, + std::string& error_message) override; + + // IRpc::ISpy interface + + /** @copydoc void IRpc::ISpy::rcpMessageReceived(const std::string& msg) */ + void rcpMessageReceived(const std::string& msg) override; + + /** @copydoc void IRpc::ISpy::rcpMessageSent(const std::string& msg) */ + void rcpMessageSent(const std::string& msg) override; + + // Accessors + + /** @brief RPC connection */ + std::shared_ptr& rpcClient() { return m_rpc; } + + /** @brief Messages validator */ + const ocpp::messages::ocpp20::MessagesValidator20& messagesValidator() { return m_messages_validator; } + + /** @brief Messages converters */ + ocpp::messages::ocpp20::MessagesConverter20& messagesConverter() { return m_messages_converter; } + + private: + /** @brief Central System instance associated to the charge point */ + ICentralSystem20& m_central_system; + /** @brief Charge point's identifier */ + std::string m_identifier; + /** @brief RPC connection */ + std::shared_ptr m_rpc; + /** @brief Message dispatcher */ + ocpp::messages::MessageDispatcher m_msg_dispatcher; + /** @brief Message sender */ + ocpp::messages::GenericMessageSender m_msg_sender; + /** @brief Request handler */ + ChargePointHandler20 m_handler; + /** @brief Messages validator */ + const ocpp::messages::ocpp20::MessagesValidator20& m_messages_validator; + /** @brief Messages converters */ + ocpp::messages::ocpp20::MessagesConverter20& m_messages_converter; + /** @brief User request handler */ + IChargePointRequestHandler20* m_user_handler; +}; + +} // namespace ocpp20 +} // namespace centralsystem +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_CS_CHARGEPOINTPROXY20_H \ No newline at end of file diff --git a/src/ocpp20/centralsystem/config/InternalConfigKeys.h b/src/ocpp20/centralsystem/config/InternalConfigKeys.h new file mode 100644 index 00000000..ebcf841e --- /dev/null +++ b/src/ocpp20/centralsystem/config/InternalConfigKeys.h @@ -0,0 +1,42 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +#ifndef OPENOCPP_OCPP20_INTERNALCONFIGKEYS_H +#define OPENOCPP_OCPP20_INTERNALCONFIGKEYS_H + +namespace ocpp +{ +namespace centralsystem +{ +namespace ocpp20 +{ + +/** @brief Configuration key : stack version */ +static constexpr const char* STACK_VERSION_KEY = "StackVersion"; +/** @brief Configuration key : last start date */ +static constexpr const char* START_DATE_KEY = "LastSessionStartDate"; +/** @brief Configuration key : uptime */ +static constexpr const char* UPTIME_KEY = "LastSessionUpTime"; +/** @brief Configuration key : total uptime */ +static constexpr const char* TOTAL_UPTIME_KEY = "TotalUpTime"; + +} // namespace ocpp20 +} // namespace centralsystem +} // namespace ocpp + +#endif // OPENOCPP_INTERNALCONFIGKEYS_H diff --git a/src/ocpp20/centralsystem/interface/ICentralSystem20.h b/src/ocpp20/centralsystem/interface/ICentralSystem20.h new file mode 100644 index 00000000..166a5bb8 --- /dev/null +++ b/src/ocpp20/centralsystem/interface/ICentralSystem20.h @@ -0,0 +1,691 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* Generated by json2cpp */ + +#ifndef OPENOCPP_OCPP20_ICENTRALSYSTEM20_H +#define OPENOCPP_OCPP20_ICENTRALSYSTEM20_H + +#include "CancelReservation20.h" +#include "CertificateSigned20.h" +#include "ChangeAvailability20.h" +#include "ClearCache20.h" +#include "ClearChargingProfile20.h" +#include "ClearDisplayMessage20.h" +#include "ClearVariableMonitoring20.h" +#include "CustomerInformation20.h" +#include "DataTransfer20.h" +#include "DeleteCertificate20.h" +#include "Get15118EVCertificate20.h" +#include "GetBaseReport20.h" +#include "GetCertificateStatus20.h" +#include "GetChargingProfiles20.h" +#include "GetCompositeSchedule20.h" +#include "GetDisplayMessages20.h" +#include "GetInstalledCertificateIds20.h" +#include "GetLocalListVersion20.h" +#include "GetLog20.h" +#include "GetMonitoringReport20.h" +#include "GetReport20.h" +#include "GetTransactionStatus20.h" +#include "GetVariables20.h" +#include "ICentralSystemConfig20.h" +#include "IChargePointRequestHandler20.h" +#include "InstallCertificate20.h" +#include "PublishFirmware20.h" +#include "RequestStartTransaction20.h" +#include "RequestStopTransaction20.h" +#include "ReserveNow20.h" +#include "Reset20.h" +#include "SendLocalList20.h" +#include "SetChargingProfile20.h" +#include "SetDisplayMessage20.h" +#include "SetMonitoringBase20.h" +#include "SetMonitoringLevel20.h" +#include "SetNetworkProfile20.h" +#include "SetVariableMonitoring20.h" +#include "SetVariables20.h" +#include "TriggerMessage20.h" +#include "UnlockConnector20.h" +#include "UnpublishFirmware20.h" +#include "UpdateFirmware20.h" + +#include + +namespace ocpp +{ +namespace helpers +{ +class ITimerPool; +class WorkerThreadPool; +} // namespace helpers +namespace database +{ +class Database; +} // namespace database + +namespace centralsystem +{ +namespace ocpp20 +{ + +class ICentralSystemEventsHandler20; + +/** @brief Interface for central system implementations */ +class ICentralSystem20 +{ + public: + /** + * @brief Instanciate a central system + * @param stack_config Stack configuration + * @param event_handler Stack event handler + */ + static std::unique_ptr create(const ocpp::config::ICentralSystemConfig20& stack_config, + ICentralSystemEventsHandler20& events_handler); + + /** + * @brief Instanciate a central system with the provided timer and worker pools + * To use when you have to instanciate multiple Central System / Charge Point + * => Allow to reduce thread and memory usage + * @param stack_config Stack configuration + * @param event_handler Stack event handler + * @param timer_pool Timer pool + * @param worker_pool Worker thread pool + */ + static std::unique_ptr create(const ocpp::config::ICentralSystemConfig20& stack_config, + ICentralSystemEventsHandler20& events_handler, + std::shared_ptr timer_pool, + std::shared_ptr worker_pool); + + /** @brief Destructor */ + virtual ~ICentralSystem20() { } + + /** + * @brief Get the configuration associated to the central system + * @return Configuration associated to the central system + */ + virtual const ocpp::config::ICentralSystemConfig20& getConfig() = 0; + + /** + * @brief Get the timer pool associated to the central system + * @return Timer pool associated to the central system + */ + virtual ocpp::helpers::ITimerPool& getTimerPool() = 0; + + /** + * @brief Get the worker pool associated to the central system + * @return Worker pool associated to the central system + */ + virtual ocpp::helpers::WorkerThreadPool& getWorkerPool() = 0; + + /** + * @brief Reset the central system's internal data (can be done only when the central system is stopped) + * @return true if the data has been reset, false otherwise + */ + virtual bool resetData() = 0; + + /** + * @brief Start the central system + * @return true if the central system has been started, false otherwise + */ + virtual bool start() = 0; + + /** + * @brief Stop the central system + * @return true if the central system has been stopped, false otherwise + */ + virtual bool stop() = 0; + + /** @brief Interface for charge point proxy implementations */ + class IChargePoint20 + { + public: + /** @brief Destructor */ + virtual ~IChargePoint20() { } + + /** + * @brief Get the central system instance associated to the charge point + * @return Central system instance associated to the charge point + */ + virtual ICentralSystem20& centralSystem() = 0; + + /** + * @brief Get the IP address of the charge point + * @return IP address of the charge point + */ + virtual const std::string& ipAddress() const = 0; + + /** + * @brief Get the charge point identifier + * @return charge point identifier + */ + virtual const std::string& identifier() const = 0; + + /** + * @brief Set the call request timeout + * @param timeout New timeout value + */ + virtual void setTimeout(std::chrono::milliseconds timeout) = 0; + + /** @brief Disconnect the charge point */ + virtual void disconnect() = 0; + + /** @brief Register the event handler */ + virtual void registerHandler(IChargePointRequestHandler20& handler) = 0; + + // OCPP operations + /** + * @brief Send a CancelReservation message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::CancelReservationReq& request, + ocpp::messages::ocpp20::CancelReservationConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a CertificateSigned message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::CertificateSignedReq& request, + ocpp::messages::ocpp20::CertificateSignedConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a ChangeAvailability message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::ChangeAvailabilityReq& request, + ocpp::messages::ocpp20::ChangeAvailabilityConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a ClearCache message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::ClearCacheReq& request, + ocpp::messages::ocpp20::ClearCacheConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a ClearChargingProfile message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::ClearChargingProfileReq& request, + ocpp::messages::ocpp20::ClearChargingProfileConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a ClearDisplayMessage message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::ClearDisplayMessageReq& request, + ocpp::messages::ocpp20::ClearDisplayMessageConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a ClearVariableMonitoring message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::ClearVariableMonitoringReq& request, + ocpp::messages::ocpp20::ClearVariableMonitoringConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a CustomerInformation message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::CustomerInformationReq& request, + ocpp::messages::ocpp20::CustomerInformationConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a DataTransfer message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::DataTransferReq& request, + ocpp::messages::ocpp20::DataTransferConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a DeleteCertificate message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::DeleteCertificateReq& request, + ocpp::messages::ocpp20::DeleteCertificateConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a Get15118EVCertificate message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::Get15118EVCertificateReq& request, + ocpp::messages::ocpp20::Get15118EVCertificateConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a GetBaseReport message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::GetBaseReportReq& request, + ocpp::messages::ocpp20::GetBaseReportConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a GetCertificateStatus message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::GetCertificateStatusReq& request, + ocpp::messages::ocpp20::GetCertificateStatusConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a GetChargingProfiles message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::GetChargingProfilesReq& request, + ocpp::messages::ocpp20::GetChargingProfilesConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a GetCompositeSchedule message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::GetCompositeScheduleReq& request, + ocpp::messages::ocpp20::GetCompositeScheduleConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a GetDisplayMessages message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::GetDisplayMessagesReq& request, + ocpp::messages::ocpp20::GetDisplayMessagesConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a GetInstalledCertificateIds message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::GetInstalledCertificateIdsReq& request, + ocpp::messages::ocpp20::GetInstalledCertificateIdsConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a GetLocalListVersion message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::GetLocalListVersionReq& request, + ocpp::messages::ocpp20::GetLocalListVersionConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a GetLog message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::GetLogReq& request, + ocpp::messages::ocpp20::GetLogConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a GetMonitoringReport message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::GetMonitoringReportReq& request, + ocpp::messages::ocpp20::GetMonitoringReportConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a GetReport message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::GetReportReq& request, + ocpp::messages::ocpp20::GetReportConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a GetTransactionStatus message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::GetTransactionStatusReq& request, + ocpp::messages::ocpp20::GetTransactionStatusConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a GetVariables message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::GetVariablesReq& request, + ocpp::messages::ocpp20::GetVariablesConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a InstallCertificate message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::InstallCertificateReq& request, + ocpp::messages::ocpp20::InstallCertificateConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a PublishFirmware message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::PublishFirmwareReq& request, + ocpp::messages::ocpp20::PublishFirmwareConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a RequestStartTransaction message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::RequestStartTransactionReq& request, + ocpp::messages::ocpp20::RequestStartTransactionConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a RequestStopTransaction message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::RequestStopTransactionReq& request, + ocpp::messages::ocpp20::RequestStopTransactionConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a ReserveNow message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::ReserveNowReq& request, + ocpp::messages::ocpp20::ReserveNowConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a Reset message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::ResetReq& request, + ocpp::messages::ocpp20::ResetConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a SendLocalList message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::SendLocalListReq& request, + ocpp::messages::ocpp20::SendLocalListConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a SetChargingProfile message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::SetChargingProfileReq& request, + ocpp::messages::ocpp20::SetChargingProfileConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a SetDisplayMessage message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::SetDisplayMessageReq& request, + ocpp::messages::ocpp20::SetDisplayMessageConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a SetMonitoringBase message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::SetMonitoringBaseReq& request, + ocpp::messages::ocpp20::SetMonitoringBaseConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a SetMonitoringLevel message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::SetMonitoringLevelReq& request, + ocpp::messages::ocpp20::SetMonitoringLevelConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a SetNetworkProfile message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::SetNetworkProfileReq& request, + ocpp::messages::ocpp20::SetNetworkProfileConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a SetVariableMonitoring message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::SetVariableMonitoringReq& request, + ocpp::messages::ocpp20::SetVariableMonitoringConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a SetVariables message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::SetVariablesReq& request, + ocpp::messages::ocpp20::SetVariablesConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a TriggerMessage message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::TriggerMessageReq& request, + ocpp::messages::ocpp20::TriggerMessageConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a UnlockConnector message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::UnlockConnectorReq& request, + ocpp::messages::ocpp20::UnlockConnectorConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a UnpublishFirmware message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::UnpublishFirmwareReq& request, + ocpp::messages::ocpp20::UnpublishFirmwareConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a UpdateFirmware message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::UpdateFirmwareReq& request, + ocpp::messages::ocpp20::UpdateFirmwareConf& response, + std::string& error, + std::string& message) = 0; + }; +}; + +} // namespace ocpp20 +} // namespace centralsystem +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_ICENTRALSYSTEM20_H \ No newline at end of file diff --git a/src/ocpp20/centralsystem/interface/ICentralSystemConfig20.h b/src/ocpp20/centralsystem/interface/ICentralSystemConfig20.h new file mode 100644 index 00000000..4ada98a3 --- /dev/null +++ b/src/ocpp20/centralsystem/interface/ICentralSystemConfig20.h @@ -0,0 +1,85 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +#ifndef OPENOCPP_OCPP20_ICENTRALSYSTEMCONFIG20_H +#define OPENOCPP_OCPP20_ICENTRALSYSTEMCONFIG20_H + +#include +#include + +namespace ocpp +{ +namespace config +{ + +/** @brief Interface to retrieve stack internal configuration for the Central System role */ +class ICentralSystemConfig20 +{ + public: + /** @brief Destructor */ + virtual ~ICentralSystemConfig20() { } + + // Paths + + /** @brief Path to the database to store persistent data */ + virtual std::string databasePath() const = 0; + /** @brief Path to the JSON schemas to validate the messages */ + virtual std::string jsonSchemasPath() const = 0; + + // Communication parameters + + /** @brief Listen URL */ + virtual std::string listenUrl() const = 0; + /** @brief Call request timeout */ + virtual std::chrono::milliseconds callRequestTimeout() const = 0; + /** @brief Websocket PING interval */ + virtual std::chrono::seconds webSocketPingInterval() const = 0; + /** @brief Enable HTTP basic authentication */ + virtual bool httpBasicAuthent() const = 0; + /** @brief Cipher list to use for TLSv1.2 connections */ + virtual std::string tlsv12CipherList() const = 0; + /** @brief Cipher list to use for TLSv1.3 connections */ + virtual std::string tlsv13CipherList() const = 0; + /** @brief ECDH curve to use for TLS connections */ + virtual std::string tlsEcdhCurve() const = 0; + /** @brief Server certificate */ + virtual std::string tlsServerCertificate() const = 0; + /** @brief Server certificate's private key */ + virtual std::string tlsServerCertificatePrivateKey() const = 0; + /** @brief Server certificate's private key passphrase */ + virtual std::string tlsServerCertificatePrivateKeyPassphrase() const = 0; + /** @brief Certification Authority signing chain for the server certificate */ + virtual std::string tlsServerCertificateCa() const = 0; + /** @brief Enable client authentication using certificate */ + virtual bool tlsClientCertificateAuthent() const = 0; + + // Log + + /** @brief Maximum number of entries in the log (0 = no logs in database) */ + virtual unsigned int logMaxEntriesCount() const = 0; + + // Behavior + + /** @brief Size of the thread pool to handle incoming requests from the Charge Points */ + virtual unsigned int incomingRequestsFromCpThreadPoolSize() const = 0; +}; + +} // namespace config +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_ICENTRALSYSTEMCONFIG20_H diff --git a/src/ocpp20/centralsystem/interface/ICentralSystemEventsHandler20.h b/src/ocpp20/centralsystem/interface/ICentralSystemEventsHandler20.h new file mode 100644 index 00000000..24a3aea9 --- /dev/null +++ b/src/ocpp20/centralsystem/interface/ICentralSystemEventsHandler20.h @@ -0,0 +1,70 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +#ifndef OPENOCPP_OCPP20_ICENTRALSYSTEMEVENTSHANDLER20_H +#define OPENOCPP_OCPP20_ICENTRALSYSTEMEVENTSHANDLER20_H + +#include "ICentralSystem20.h" + +namespace ocpp +{ +namespace centralsystem +{ +namespace ocpp20 +{ + +/** @brief Interface for central system event handlers implementations */ +class ICentralSystemEventsHandler20 +{ + public: + /** @brief Destructor */ + virtual ~ICentralSystemEventsHandler20() { } + + /** + * @brief Called to accept an incoming connection + * @param ip_address IP address of the client + * @return true if the incoming connection must be accepted, false otherwise + */ + virtual bool acceptConnection(const char* ip_address) = 0; + + /** + * @brief Called when connection fails to established + * @param ip_address IP address of the client + */ + virtual void clientFailedToConnect(const char* ip_address) = 0; + + /** + * @brief Called to check the charge point credentials for HTTP basic authentication + * @param chargepoint_id Charge Point identifier + * @param password Password + * @return true if the credentials are valid, false otherwise + */ + virtual bool checkCredentials(const std::string& chargepoint_id, const std::string& password) = 0; + + /** + * @brief Called when a charge point is connected + * @param chargepoint Charge point connection + */ + virtual void chargePointConnected(std::shared_ptr chargepoint) = 0; +}; + +} // namespace ocpp20 +} // namespace centralsystem +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_ICENTRALSYSTEMEVENTSHANDLER20_H diff --git a/src/ocpp20/centralsystem/interface/IChargePointRequestHandler20.h b/src/ocpp20/centralsystem/interface/IChargePointRequestHandler20.h new file mode 100644 index 00000000..8f41217d --- /dev/null +++ b/src/ocpp20/centralsystem/interface/IChargePointRequestHandler20.h @@ -0,0 +1,360 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* Generated by json2cpp */ + +#ifndef OPENOCPP_OCPP20_ICHARGEPOINTREQUESTHANDLER20_H +#define OPENOCPP_OCPP20_ICHARGEPOINTREQUESTHANDLER20_H +#include "Authorize20.h" +#include "BootNotification20.h" +#include "ClearedChargingLimit20.h" +#include "CostUpdated20.h" +#include "DataTransfer20.h" +#include "FirmwareStatusNotification20.h" +#include "Heartbeat20.h" +#include "LogStatusNotification20.h" +#include "MeterValues20.h" +#include "NotifyChargingLimit20.h" +#include "NotifyCustomerInformation20.h" +#include "NotifyDisplayMessages20.h" +#include "NotifyEVChargingNeeds20.h" +#include "NotifyEVChargingSchedule20.h" +#include "NotifyEvent20.h" +#include "NotifyMonitoringReport20.h" +#include "NotifyReport20.h" +#include "PublishFirmwareStatusNotification20.h" +#include "ReportChargingProfiles20.h" +#include "ReservationStatusUpdate20.h" +#include "SecurityEventNotification20.h" +#include "SignCertificate20.h" +#include "StatusNotification20.h" +#include "TransactionEvent20.h" + +#include + +namespace ocpp +{ +namespace centralsystem +{ +namespace ocpp20 +{ + +/** @brief Interface for charge point requests implementations */ +class IChargePointRequestHandler20 +{ + public: + /** @brief Destructor */ + virtual ~IChargePointRequestHandler20() { } + + /** @brief Called to notify the disconnection of the charge point */ + virtual void disconnected() = 0; + /** + * @brief Called on reception of a BootNotification request from the charge point + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been handled and a response must be sent, false otherwise + */ + virtual bool onBootNotification(const ocpp::messages::ocpp20::BootNotificationReq& request, + ocpp::messages::ocpp20::BootNotificationConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Called on reception of a Authorize request from the charge point + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been handled and a response must be sent, false otherwise + */ + virtual bool onAuthorize(const ocpp::messages::ocpp20::AuthorizeReq& request, + ocpp::messages::ocpp20::AuthorizeConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Called on reception of a ClearedChargingLimit request from the charge point + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been handled and a response must be sent, false otherwise + */ + virtual bool onClearedChargingLimit(const ocpp::messages::ocpp20::ClearedChargingLimitReq& request, + ocpp::messages::ocpp20::ClearedChargingLimitConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Called on reception of a CostUpdated request from the charge point + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been handled and a response must be sent, false otherwise + */ + virtual bool onCostUpdated(const ocpp::messages::ocpp20::CostUpdatedReq& request, + ocpp::messages::ocpp20::CostUpdatedConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Called on reception of a DataTransfer request from the charge point + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been handled and a response must be sent, false otherwise + */ + virtual bool onDataTransfer(const ocpp::messages::ocpp20::DataTransferReq& request, + ocpp::messages::ocpp20::DataTransferConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Called on reception of a FirmwareStatusNotification request from the charge point + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been handled and a response must be sent, false otherwise + */ + virtual bool onFirmwareStatusNotification(const ocpp::messages::ocpp20::FirmwareStatusNotificationReq& request, + ocpp::messages::ocpp20::FirmwareStatusNotificationConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Called on reception of a Heartbeat request from the charge point + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been handled and a response must be sent, false otherwise + */ + virtual bool onHeartbeat(const ocpp::messages::ocpp20::HeartbeatReq& request, + ocpp::messages::ocpp20::HeartbeatConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Called on reception of a LogStatusNotification request from the charge point + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been handled and a response must be sent, false otherwise + */ + virtual bool onLogStatusNotification(const ocpp::messages::ocpp20::LogStatusNotificationReq& request, + ocpp::messages::ocpp20::LogStatusNotificationConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Called on reception of a MeterValues request from the charge point + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been handled and a response must be sent, false otherwise + */ + virtual bool onMeterValues(const ocpp::messages::ocpp20::MeterValuesReq& request, + ocpp::messages::ocpp20::MeterValuesConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Called on reception of a NotifyChargingLimit request from the charge point + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been handled and a response must be sent, false otherwise + */ + virtual bool onNotifyChargingLimit(const ocpp::messages::ocpp20::NotifyChargingLimitReq& request, + ocpp::messages::ocpp20::NotifyChargingLimitConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Called on reception of a NotifyCustomerInformation request from the charge point + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been handled and a response must be sent, false otherwise + */ + virtual bool onNotifyCustomerInformation(const ocpp::messages::ocpp20::NotifyCustomerInformationReq& request, + ocpp::messages::ocpp20::NotifyCustomerInformationConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Called on reception of a NotifyDisplayMessages request from the charge point + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been handled and a response must be sent, false otherwise + */ + virtual bool onNotifyDisplayMessages(const ocpp::messages::ocpp20::NotifyDisplayMessagesReq& request, + ocpp::messages::ocpp20::NotifyDisplayMessagesConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Called on reception of a NotifyEVChargingNeeds request from the charge point + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been handled and a response must be sent, false otherwise + */ + virtual bool onNotifyEVChargingNeeds(const ocpp::messages::ocpp20::NotifyEVChargingNeedsReq& request, + ocpp::messages::ocpp20::NotifyEVChargingNeedsConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Called on reception of a NotifyEVChargingSchedule request from the charge point + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been handled and a response must be sent, false otherwise + */ + virtual bool onNotifyEVChargingSchedule(const ocpp::messages::ocpp20::NotifyEVChargingScheduleReq& request, + ocpp::messages::ocpp20::NotifyEVChargingScheduleConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Called on reception of a NotifyEvent request from the charge point + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been handled and a response must be sent, false otherwise + */ + virtual bool onNotifyEvent(const ocpp::messages::ocpp20::NotifyEventReq& request, + ocpp::messages::ocpp20::NotifyEventConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Called on reception of a NotifyMonitoringReport request from the charge point + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been handled and a response must be sent, false otherwise + */ + virtual bool onNotifyMonitoringReport(const ocpp::messages::ocpp20::NotifyMonitoringReportReq& request, + ocpp::messages::ocpp20::NotifyMonitoringReportConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Called on reception of a NotifyReport request from the charge point + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been handled and a response must be sent, false otherwise + */ + virtual bool onNotifyReport(const ocpp::messages::ocpp20::NotifyReportReq& request, + ocpp::messages::ocpp20::NotifyReportConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Called on reception of a PublishFirmwareStatusNotification request from the charge point + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been handled and a response must be sent, false otherwise + */ + virtual bool onPublishFirmwareStatusNotification(const ocpp::messages::ocpp20::PublishFirmwareStatusNotificationReq& request, + ocpp::messages::ocpp20::PublishFirmwareStatusNotificationConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Called on reception of a ReportChargingProfiles request from the charge point + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been handled and a response must be sent, false otherwise + */ + virtual bool onReportChargingProfiles(const ocpp::messages::ocpp20::ReportChargingProfilesReq& request, + ocpp::messages::ocpp20::ReportChargingProfilesConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Called on reception of a ReservationStatusUpdate request from the charge point + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been handled and a response must be sent, false otherwise + */ + virtual bool onReservationStatusUpdate(const ocpp::messages::ocpp20::ReservationStatusUpdateReq& request, + ocpp::messages::ocpp20::ReservationStatusUpdateConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Called on reception of a SecurityEventNotification request from the charge point + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been handled and a response must be sent, false otherwise + */ + virtual bool onSecurityEventNotification(const ocpp::messages::ocpp20::SecurityEventNotificationReq& request, + ocpp::messages::ocpp20::SecurityEventNotificationConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Called on reception of a SignCertificate request from the charge point + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been handled and a response must be sent, false otherwise + */ + virtual bool onSignCertificate(const ocpp::messages::ocpp20::SignCertificateReq& request, + ocpp::messages::ocpp20::SignCertificateConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Called on reception of a StatusNotification request from the charge point + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been handled and a response must be sent, false otherwise + */ + virtual bool onStatusNotification(const ocpp::messages::ocpp20::StatusNotificationReq& request, + ocpp::messages::ocpp20::StatusNotificationConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Called on reception of a TransactionEvent request from the charge point + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been handled and a response must be sent, false otherwise + */ + virtual bool onTransactionEvent(const ocpp::messages::ocpp20::TransactionEventReq& request, + ocpp::messages::ocpp20::TransactionEventConf& response, + std::string& error, + std::string& message) = 0; +}; + +} // namespace ocpp20 +} // namespace centralsystem +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_ICHARGEPOINTREQUESTHANDLER20_H \ No newline at end of file diff --git a/src/ocpp20/chargepoint/BasicChargePoint20.cpp b/src/ocpp20/chargepoint/BasicChargePoint20.cpp new file mode 100644 index 00000000..0f09709c --- /dev/null +++ b/src/ocpp20/chargepoint/BasicChargePoint20.cpp @@ -0,0 +1,656 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +#include "BasicChargePoint20.h" +#include "InternalConfigKeys.h" +#include "Logger.h" +#include "MessageDispatcher.h" +#include "PrivateKey.h" +#include "StatusManager20.h" +#include "TimerPool.h" +#include "TriggerMessageManager20.h" +#include "Url.h" +#include "Version.h" +#include "WebsocketFactory.h" +#include "WorkerThreadPool.h" + +#include +#include +#include + +using namespace ocpp::types; +using namespace ocpp::types::ocpp20; +using namespace ocpp::messages; +using namespace ocpp::messages::ocpp20; + +namespace ocpp +{ +namespace chargepoint +{ +namespace ocpp20 +{ + +/** @brief Instanciate a charge point */ +std::unique_ptr IBasicChargePoint20::create(const ocpp::config::IChargePointConfig20& stack_config, + IDeviceModel& device_model, + IBasicChargePointEventsHandler& events_handler) +{ + std::shared_ptr timer_pool(new ocpp::helpers::TimerPool()); + std::shared_ptr worker_pool = + std::make_shared(2u); // 1 asynchronous timer operations + 1 for asynchronous jobs/responses + std::unique_ptr messages_converter(new MessagesConverter20()); + return std::unique_ptr( + new BasicChargePoint20(stack_config, device_model, events_handler, timer_pool, worker_pool, std::move(messages_converter))); +} + +/** @brief Instanciate a charge point with the provided timer and worker pools */ +std::unique_ptr IBasicChargePoint20::create(const ocpp::config::IChargePointConfig20& stack_config, + IDeviceModel& device_model, + IBasicChargePointEventsHandler& events_handler, + std::shared_ptr timer_pool, + std::shared_ptr worker_pool) +{ + std::unique_ptr messages_converter(new MessagesConverter20()); + return std::unique_ptr( + new BasicChargePoint20(stack_config, device_model, events_handler, timer_pool, worker_pool, std::move(messages_converter))); +} + +/** @brief Constructor */ +BasicChargePoint20::BasicChargePoint20(const ocpp::config::IChargePointConfig20& stack_config, + IDeviceModel& device_model, + IBasicChargePointEventsHandler& events_handler, + std::shared_ptr timer_pool, + std::shared_ptr worker_pool, + std::unique_ptr&& messages_converter) + : m_stack_config(stack_config), + m_device_model(device_model), + m_events_handler(events_handler), + m_timer_pool(timer_pool), + m_worker_pool(worker_pool), + m_database(), + m_internal_config(m_database), + m_connectors(m_device_model, m_database, *m_timer_pool.get()), + m_messages_converter(std::move(messages_converter)), + m_messages_validator(), + m_stop_in_progress(false), + m_reconnect_scheduled(false), + m_ws_client(), + m_rpc_client(), + m_msg_dispatcher(), + m_msg_sender(), + m_status_manager(), + m_trigger_manager(), + m_uptime_timer(*m_timer_pool.get(), "Uptime timer"), + m_uptime(0), + m_disconnected_time(0), + m_total_uptime(0), + m_total_disconnected_time(0) +{ + // Open database + if (m_stack_config.databasePath().empty() || m_database.open(m_stack_config.databasePath())) + { + // Register logger + if (m_stack_config.logMaxEntriesCount() != 0) + { + ocpp::log::Logger::registerDefaultLogger(m_database, m_stack_config.logMaxEntriesCount()); + } + + // Initialize the database + if (!m_stack_config.databasePath().empty()) + { + initDatabase(); + } + } + else + { + LOG_ERROR << "Unable to open database"; + } + + // Uptime timer + m_uptime_timer.setCallback(std::bind(&BasicChargePoint20::processUptime, this)); + + // Random numbers + std::srand(static_cast(time(nullptr))); +} + +/** @brief Destructor */ +BasicChargePoint20::~BasicChargePoint20() +{ + stop(); +} + +/** @copydoc bool IBasicChargePoint20::resetData() */ +bool BasicChargePoint20::resetData() +{ + bool ret = false; + + // Check if it is already started + if (!m_rpc_client) + { + LOG_INFO << "Reset all data"; + if (!m_stack_config.databasePath().empty()) + { + // Unregister logger + if (m_stack_config.logMaxEntriesCount() != 0) + { + ocpp::log::Logger::unregisterDefaultLogger(); + } + + // Close database to invalid existing connexions + m_database.close(); + + // Delete database + if (std::filesystem::remove(m_stack_config.databasePath())) + { + // Open database + if (m_database.open(m_stack_config.databasePath())) + { + // Register logger + if (m_stack_config.logMaxEntriesCount() != 0) + { + ocpp::log::Logger::registerDefaultLogger(m_database, m_stack_config.logMaxEntriesCount()); + } + + // Re-initialize with default values + m_total_uptime = 0; + m_total_disconnected_time = 0; + initDatabase(); + } + else + { + LOG_ERROR << "Unable to open database"; + } + } + else + { + LOG_ERROR << "Unable to delete database"; + } + } + else + { + ret = true; + } + } + + return ret; +} + +/** @copydoc bool IBasicChargePoint20::resetConnectorData() */ +bool BasicChargePoint20::resetConnectorData() +{ + bool ret = false; + + // Check if it is already started + if (!m_rpc_client) + { + // Reset connector data + //m_connectors.resetConnectors(); + ret = true; + } + + return ret; +} + +/** @copydoc bool IBasicChargePoint20::start(ocpp::types::ocpp20::BootReasonEnumType) */ +bool BasicChargePoint20::start(ocpp::types::ocpp20::BootReasonEnumType boot_reason) +{ + bool ret = false; + + // Check if it is already started + if (!m_rpc_client) + { + + LOG_INFO << "Starting OCPP stack v" << OPEN_OCPP_VERSION << " - Central System : " << m_stack_config.connexionUrl() + << " - Charge Point identifier : " << m_stack_config.chargePointIdentifier() + << " - Boot reason : " << BootReasonEnumTypeHelper.toString(boot_reason); + + // Load validator + ret = m_messages_validator.load(m_stack_config.jsonSchemasPath()); + if (ret) + { + // Start uptime counter + if (!m_stack_config.databasePath().empty()) + { + m_uptime = 0; + m_disconnected_time = 0; + m_internal_config.setKey(START_DATE_KEY, DateTime::now().str()); + m_uptime_timer.start(std::chrono::seconds(1u)); + } + + // Allocate resources + m_ws_client = std::unique_ptr(ocpp::websockets::WebsocketFactory::newClient()); + m_rpc_client = std::make_unique(*m_ws_client, "ocpp2.0.1"); + m_rpc_client->registerListener(*this); + m_rpc_client->registerClientListener(*this); + m_rpc_client->registerSpy(*this); + m_msg_dispatcher = std::make_unique(m_messages_validator); + m_msg_sender = std::make_unique( + *m_rpc_client, *m_messages_converter, m_messages_validator, m_stack_config.callRequestTimeout()); + + m_trigger_manager = std::make_unique(m_connectors, *m_messages_converter, *m_msg_dispatcher); + m_status_manager = std::make_unique(m_stack_config, + m_device_model, + m_events_handler, + m_internal_config, + *m_timer_pool, + *m_worker_pool, + m_connectors, + *m_msg_sender, + *m_trigger_manager, + boot_reason); + + // Start connection + m_stop_in_progress = false; + ret = doConnect(); + } + else + { + LOG_ERROR << "Unable to load all the messages validators"; + } + } + else + { + LOG_ERROR << "Stack already started"; + } + + return ret; +} + +/** @copydoc bool IBasicChargePoint20::stop() */ +bool BasicChargePoint20::stop() +{ + bool ret = false; + + // Check if it is already started + if (m_rpc_client && !m_stop_in_progress) + { + LOG_INFO << "Stopping OCPP stack"; + m_stop_in_progress = true; + + // Stop uptime counter + if (!m_stack_config.databasePath().empty()) + { + m_uptime_timer.stop(); + saveUptime(); + } + + // Stop connection + ret = m_rpc_client->stop(); + std::this_thread::sleep_for(std::chrono::milliseconds(300)); + + // Free resources + m_ws_client.reset(); + m_rpc_client.reset(); + m_msg_dispatcher.reset(); + m_msg_sender.reset(); + + // Stop managers + m_trigger_manager.reset(); + m_status_manager.reset(); + + // Close database + m_database.close(); + } + else + { + LOG_ERROR << "Stack already stopped"; + } + + return ret; +} + +/** @copydoc bool IBasicChargePoint20::reconnect() */ +bool BasicChargePoint20::reconnect() +{ + bool ret = false; + + // Check if it is started + if (m_rpc_client) + { + // Schedule of reconnexion + LOG_INFO << "Reconnect triggered"; + scheduleReconnect(); + ret = true; + } + else + { + LOG_ERROR << "Stack stopped"; + } + + return ret; +} + +/** @copydoc ocpp::types::ocpp20::RegistrationStatusEnumType IBasicChargePoint20::getRegistrationStatus() */ +ocpp::types::ocpp20::RegistrationStatusEnumType BasicChargePoint20::getRegistrationStatus() +{ + RegistrationStatusEnumType status = RegistrationStatusEnumType::Rejected; + + if (m_status_manager) + { + status = m_status_manager->getRegistrationStatus(); + } + else + { + LOG_ERROR << "Stack is not started"; + } + + return status; +} + +/** @copydoc ocpp::types::ocpp20::ConnectorStatusEnumType IBasicChargePoint20::getConnectorStatus(unsigned int, unsigned int) */ +ocpp::types::ocpp20::ConnectorStatusEnumType BasicChargePoint20::getConnectorStatus(unsigned int evse_id, unsigned int connector_id) +{ + ConnectorStatusEnumType status = ConnectorStatusEnumType::Unavailable; + + const Connector* connector = m_connectors.getConnector(evse_id, connector_id); + if (connector) + { + status = connector->status; + } + else + { + LOG_ERROR << "Invalid connector : EVSE = " << evse_id << ", connector = " << connector_id; + } + + return status; +} + +/** @copydoc bool IBasicChargePoint20::statusNotification(unsigned int, unsigned int, ocpp::types::ocpp20::ConnectorStatusEnumType) */ +bool BasicChargePoint20::statusNotification(unsigned int evse_id, + unsigned int connector_id, + ocpp::types::ocpp20::ConnectorStatusEnumType status) +{ + bool ret = false; + + if (m_status_manager) + { + ret = m_status_manager->updateConnectorStatus(evse_id, connector_id, status); + } + else + { + LOG_ERROR << "Stack is not started"; + } + + return ret; +} + +// RpcClient::IListener interface + +/** @copydoc void RpcClient::IListener::rpcClientConnected() */ +void BasicChargePoint20::rpcClientConnected() +{ + LOG_INFO << "Connected to Central System"; + m_status_manager->updateConnectionStatus(true); + m_events_handler.connectionStateChanged(true); +} + +/** @copydoc void RpcClient::IListener::rpcClientFailed() */ +void BasicChargePoint20::rpcClientFailed() +{ + LOG_ERROR << "Connection failed with Central System"; + + // Get last registration status to determine if offline actions + // are allowed + std::string last_status_string; + m_internal_config.getKey(LAST_REGISTRATION_STATUS_KEY, last_status_string); + RegistrationStatusEnumType last_status = RegistrationStatusEnumTypeHelper.fromString(last_status_string); + if (last_status == RegistrationStatusEnumType::Accepted) + { + LOG_INFO << "Last registration status was accepted, offline actions are allowed"; + m_status_manager->forceRegistrationStatus(RegistrationStatusEnumType::Accepted); + } + + // Notify failure + m_events_handler.connectionFailed(last_status); +} + +/** @copydoc void IRpc::IListener::rpcDisconnected() */ +void BasicChargePoint20::rpcDisconnected() +{ + // Check if stop is in progress + if (!m_stop_in_progress) + { + LOG_ERROR << "Connection lost with Central System"; + m_status_manager->updateConnectionStatus(false); + m_events_handler.connectionStateChanged(false); + } +} + +/** @copydoc void IRpc::IListener::rpcError() */ +void BasicChargePoint20::rpcError() +{ + LOG_ERROR << "Connection error with Central System"; +} + +/** @copydoc void IRpc::IListener::rpcCallReceived(const std::string&, + const rapidjson::Value&, + rapidjson::Document&, + std::string&, + std::string&) */ +bool BasicChargePoint20::rpcCallReceived(const std::string& action, + const rapidjson::Value& payload, + rapidjson::Document& response, + std::string& error_code, + std::string& error_message) +{ + bool ret = false; + + // Check if stop is in progress + if (!m_stop_in_progress) + { + ret = m_msg_dispatcher->dispatchMessage(action, payload, response, error_code, error_message); + } + + return ret; +} + +/** @copydoc void IRpc::ISpy::rcpMessageReceived(const std::string&) */ +void BasicChargePoint20::rcpMessageReceived(const std::string& msg) +{ + LOG_COM << "RX : " << msg; +} + +/** @copydoc void IRpc::ISpy::rcpMessageSent(const std::string&) */ +void BasicChargePoint20::rcpMessageSent(const std::string& msg) +{ + LOG_COM << "TX : " << msg; + m_status_manager->resetHeartBeatTimer(); +} + +/** @brief Initialize the database */ +void BasicChargePoint20::initDatabase() +{ + // Initialize internal configuration + m_internal_config.initDatabaseTable(); + m_connectors.initDatabaseTable(); + + // Internal keys + if (!m_internal_config.keyExist(STACK_VERSION_KEY)) + { + m_internal_config.createKey(STACK_VERSION_KEY, OPEN_OCPP_VERSION); + } + else + { + m_internal_config.setKey(STACK_VERSION_KEY, OPEN_OCPP_VERSION); + } + if (!m_internal_config.keyExist(START_DATE_KEY)) + { + m_internal_config.createKey(START_DATE_KEY, ""); + } + if (!m_internal_config.keyExist(UPTIME_KEY)) + { + m_internal_config.createKey(UPTIME_KEY, "0"); + } + if (!m_internal_config.keyExist(DISCONNECTED_TIME_KEY)) + { + m_internal_config.createKey(DISCONNECTED_TIME_KEY, "0"); + } + if (!m_internal_config.keyExist(TOTAL_UPTIME_KEY)) + { + m_internal_config.createKey(TOTAL_UPTIME_KEY, "0"); + } + else + { + std::string value; + m_internal_config.getKey(TOTAL_UPTIME_KEY, value); + m_total_uptime = static_cast(std::atoi(value.c_str())); + } + if (!m_internal_config.keyExist(TOTAL_DISCONNECTED_TIME_KEY)) + { + m_internal_config.createKey(TOTAL_DISCONNECTED_TIME_KEY, "0"); + } + else + { + std::string value; + m_internal_config.getKey(TOTAL_DISCONNECTED_TIME_KEY, value); + m_total_disconnected_time = static_cast(std::atoi(value.c_str())); + } + if (!m_internal_config.keyExist(LAST_CONNECTION_URL_KEY)) + { + m_internal_config.createKey(LAST_CONNECTION_URL_KEY, ""); + } + if (!m_internal_config.keyExist(LAST_REGISTRATION_STATUS_KEY)) + { + m_internal_config.createKey(LAST_REGISTRATION_STATUS_KEY, + RegistrationStatusEnumTypeHelper.toString(RegistrationStatusEnumType::Rejected)); + } +} + +/** @brief Process uptime */ +void BasicChargePoint20::processUptime() +{ + // Increase counters + m_uptime++; + m_total_uptime++; + if (m_rpc_client && !m_rpc_client->isConnected()) + { + m_disconnected_time++; + m_total_disconnected_time++; + } + + // Save counters + if ((m_uptime % 15u) == 0) + { + m_worker_pool->run(std::bind(&BasicChargePoint20::saveUptime, this)); + } +} + +/** @brief Save the uptime counter in database */ +void BasicChargePoint20::saveUptime() +{ + m_internal_config.setKey(UPTIME_KEY, std::to_string(m_uptime)); + m_internal_config.setKey(DISCONNECTED_TIME_KEY, std::to_string(m_disconnected_time)); + m_internal_config.setKey(TOTAL_UPTIME_KEY, std::to_string(m_total_uptime)); + m_internal_config.setKey(TOTAL_DISCONNECTED_TIME_KEY, std::to_string(m_total_disconnected_time)); +} + +/** @brief Schedule a reconnection to the Central System */ +void BasicChargePoint20::scheduleReconnect() +{ + // Check if a reconnection is not already scheduled + if (!m_reconnect_scheduled) + { + m_reconnect_scheduled = true; + m_worker_pool->run( + [this] + { + // Wait to let some time to configure other parameters + // => Needed when switching security profiles + std::this_thread::sleep_for(std::chrono::seconds(1u)); + doConnect(); + }); + } +} + +/** @brief Start the connection process to the Central System */ +bool BasicChargePoint20::doConnect() +{ + // Check if already connected + if (m_rpc_client->isConnected()) + { + // Close connection + m_rpc_client->stop(); + } + + // Get current security profile + unsigned int security_profile = m_stack_config.securityProfile(); + + // Build connection URL + std::string connection_url = m_stack_config.connexionUrl(); + if (connection_url[connection_url.size() - 1] != '/') + { + connection_url += "/"; + } + connection_url += ocpp::websockets::Url::encode(m_stack_config.chargePointIdentifier()); + + // Check if URL has changed since last connection + std::string last_url; + m_internal_config.getKey(LAST_CONNECTION_URL_KEY, last_url); + if (connection_url != last_url) + { + // Save URL + m_internal_config.setKey(LAST_CONNECTION_URL_KEY, connection_url); + + // Reset registration status + m_internal_config.setKey(LAST_REGISTRATION_STATUS_KEY, + RegistrationStatusEnumTypeHelper.toString(RegistrationStatusEnumType::Rejected)); + + LOG_INFO << "Connection URL has changed, reset registration status"; + } + + // Configure websocket link + ocpp::websockets::IWebsocketClient::Credentials credentials; + + std::string basic_auth_password = m_stack_config.basicAuthPassword(); + if (!basic_auth_password.empty() && (security_profile <= 2)) + { + credentials.user = m_stack_config.chargePointIdentifier(); + credentials.password = basic_auth_password; + } + if (security_profile != 1) + { + credentials.tls12_cipher_list = m_stack_config.tlsv12CipherList(); + credentials.tls13_cipher_list = m_stack_config.tlsv13CipherList(); + + // Use certificates prodivided by the user application + credentials.server_certificate_ca = m_stack_config.tlsServerCertificateCa(); + if ((security_profile == 0) || (security_profile == 3)) + { + credentials.client_certificate = m_stack_config.tlsClientCertificate(); + credentials.client_certificate_private_key = m_stack_config.tlsClientCertificatePrivateKey(); + credentials.client_certificate_private_key_passphrase = m_stack_config.tlsClientCertificatePrivateKeyPassphrase(); + } + credentials.allow_selfsigned_certificates = m_stack_config.tlsAllowSelfSignedCertificates(); + credentials.allow_expired_certificates = m_stack_config.tlsAllowExpiredCertificates(); + credentials.accept_untrusted_certificates = m_stack_config.tlsAcceptNonTrustedCertificates(); + credentials.skip_server_name_check = m_stack_config.tlsSkipServerNameCheck(); + credentials.encoded_pem_certificates = false; + } + + // Start connection process + m_reconnect_scheduled = false; + return m_rpc_client->start(connection_url, + credentials, + m_stack_config.connectionTimeout(), + m_stack_config.retryInterval(), + m_stack_config.webSocketPingInterval()); +} + +} // namespace ocpp20 +} // namespace chargepoint +} // namespace ocpp diff --git a/src/ocpp20/chargepoint/BasicChargePoint20.h b/src/ocpp20/chargepoint/BasicChargePoint20.h new file mode 100644 index 00000000..9b621b4c --- /dev/null +++ b/src/ocpp20/chargepoint/BasicChargePoint20.h @@ -0,0 +1,248 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +#ifndef OPENOCPP_OCPP20_BASICCHARGEPOINT20_H +#define OPENOCPP_OCPP20_BASICCHARGEPOINT20_H + +#include "Connectors20.h" +#include "GenericMessageHandler.h" +#include "GenericMessageSender.h" +#include "IBasicChargePoint20.h" +#include "IDeviceModel20.h" +#include "InternalConfigManager.h" +#include "Logger.h" +#include "MessagesConverter20.h" +#include "MessagesValidator20.h" +#include "RpcClient.h" +#include "Timer.h" + +#include +#include + +namespace ocpp +{ +// Forward declarations +namespace messages +{ +class MessageDispatcher; +class GenericMessageSender; +} // namespace messages +namespace websockets +{ +class IWebsocketClient; +} +namespace chargepoint +{ +namespace ocpp20 +{ + +// Forward declarations +class StatusManager; +class TriggerMessageManager; + +/** @brief Basic charge point implementation (only use cases defined in OCPP 2.0.1 Part 0 Specification §4) */ +class BasicChargePoint20 : public IBasicChargePoint20, + public ocpp::rpc::IRpc::IListener, + public ocpp::rpc::IRpc::ISpy, + public ocpp::rpc::RpcClient::IListener +{ + public: + /** @brief Constructor */ + BasicChargePoint20(const ocpp::config::IChargePointConfig20& stack_config, + IDeviceModel& device_model, + IBasicChargePointEventsHandler& events_handler, + std::shared_ptr timer_pool, + std::shared_ptr worker_pool, + std::unique_ptr&& messages_converter); + + /** @brief Destructor */ + virtual ~BasicChargePoint20(); + + // IBasicChargePoint20 interface + + /** @copydoc ocpp::helpers::ITimerPool& IBasicChargePoint20::getTimerPool() */ + ocpp::helpers::ITimerPool& getTimerPool() override { return *m_timer_pool.get(); } + + /** @copydoc ocpp::helpers::WorkerThreadPool& IBasicChargePoint20::getWorkerPool() */ + ocpp::helpers::WorkerThreadPool& getWorkerPool() override { return *m_worker_pool.get(); } + + /** @copydoc bool IBasicChargePoint20::resetData() */ + bool resetData() override; + + /** @copydoc bool IBasicChargePoint20::resetConnectorData() */ + bool resetConnectorData() override; + + /** @copydoc bool IBasicChargePoint20::start(ocpp::types::ocpp20::BootReasonEnumType) */ + bool start(ocpp::types::ocpp20::BootReasonEnumType boot_reason) override; + + /** @copydoc bool IBasicChargePoint20::stop() */ + bool stop() override; + + /** @copydoc bool IBasicChargePoint20::reconnect() */ + bool reconnect() override; + + /** @copydoc ocpp::types::ocpp20::RegistrationStatusEnumType IBasicChargePoint20::getRegistrationStatus() */ + ocpp::types::ocpp20::RegistrationStatusEnumType getRegistrationStatus() override; + + /** @copydoc ocpp::types::ocpp20::ConnectorStatusEnumType IBasicChargePoint20::getConnectorStatus(unsigned int, unsigned int) */ + ocpp::types::ocpp20::ConnectorStatusEnumType getConnectorStatus(unsigned int evse_id, unsigned int connector_id) override; + + /** @copydoc bool IBasicChargePoint20::statusNotification(unsigned int, unsigned int, ocpp::types::ocpp20::ConnectorStatusEnumType) */ + bool statusNotification(unsigned int evse_id, unsigned int connector_id, ocpp::types::ocpp20::ConnectorStatusEnumType status) override; + + // RpcClient::IListener interface + + /** @copydoc void RpcClient::IListener::rpcClientConnected() */ + void rpcClientConnected() override; + + /** @copydoc void RpcClient::IListener::rpcClientFailed() */ + void rpcClientFailed() override; + + // IRpc::IListener interface + + /** @copydoc void IRpc::IListener::rpcDisconnected() */ + void rpcDisconnected() override; + + /** @copydoc void IRpc::IListener::rpcError() */ + void rpcError() override; + + /** @copydoc void IRpc::IListener::rpcCallReceived(const std::string&, + const rapidjson::Value&, + rapidjson::Document&, + std::string&, + std::string&) */ + bool rpcCallReceived(const std::string& action, + const rapidjson::Value& payload, + rapidjson::Document& response, + std::string& error_code, + std::string& error_message) override; + + // IRpc::ISpy interface + + /** @copydoc void IRpc::ISpy::rcpMessageReceived(const std::string&) */ + void rcpMessageReceived(const std::string& msg) override; + + /** @copydoc void IRpc::ISpy::rcpMessageSent(const std::string&) */ + void rcpMessageSent(const std::string& msg) override; + + private: + /** @brief Stack configuration */ + const ocpp::config::IChargePointConfig20& m_stack_config; + /** @brief Device model */ + IDeviceModel& m_device_model; + /** @brief User defined events handler */ + IBasicChargePointEventsHandler& m_events_handler; + + /** @brief Timer pool */ + std::shared_ptr m_timer_pool; + /** @brief Worker thread pool */ + std::shared_ptr m_worker_pool; + + /** @brief Database */ + ocpp::database::Database m_database; + /** @brief Internal configuration manager */ + ocpp::config::InternalConfigManager m_internal_config; + /** @brief Connectors */ + Connectors m_connectors; + + /** @brief Messages converter */ + std::unique_ptr m_messages_converter; + /** @brief Messaes validator */ + ocpp::messages::ocpp20::MessagesValidator20 m_messages_validator; + /** @brief Indicate that a stop process is in progress */ + std::atomic m_stop_in_progress; + /** @brief Indicate that a reconnection process has been scheduled */ + std::atomic m_reconnect_scheduled; + + /** @brief Websocket s*/ + std::unique_ptr m_ws_client; + /** @brief RPC client */ + std::unique_ptr m_rpc_client; + /** @brief Message dispatcher */ + std::unique_ptr m_msg_dispatcher; + /** @brief Message sender */ + std::unique_ptr m_msg_sender; + + /** @brief Status manager */ + std::unique_ptr m_status_manager; + /** @brief Trigger messages manager */ + std::unique_ptr m_trigger_manager; + + /** @brief Uptime timer */ + ocpp::helpers::Timer m_uptime_timer; + /** @brief Uptime in seconds */ + unsigned int m_uptime; + /** @brief Disconnected time in seconds */ + unsigned int m_disconnected_time; + /** @brief Total uptime in seconds */ + unsigned int m_total_uptime; + /** @brief Total disconnected time in seconds */ + unsigned int m_total_disconnected_time; + + /** @brief Initialize the database */ + void initDatabase(); + /** @brief Process uptime */ + void processUptime(); + /** @brief Save the uptime counter in database */ + void saveUptime(); + + /** @brief Schedule a reconnection to the Central System */ + void scheduleReconnect(); + /** @brief Start the connection process to the Central System */ + bool doConnect(); + + /** + * @brief Execute a call request + * @param action RPC action for the request + * @param request Request payload + * @param response Response payload + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + template + bool call(const std::string& action, const RequestType& request, ResponseType& response, std::string& error, std::string& message) + { + bool ret = false; + + std::string identifier = m_stack_config.chargePointIdentifier(); + LOG_DEBUG << "[" << identifier << "] - " << action; + + if (m_msg_sender && !m_stop_in_progress) + { + ocpp::messages::CallResult res = m_msg_sender->call(action, request, response, error, message); + if (res != ocpp::messages::CallResult::Ok) + { + LOG_ERROR << "[" << identifier << "] - " << action << " => " + << (res == ocpp::messages::CallResult::Failed ? "Timeout" : "Error"); + } + else + { + ret = true; + } + } + + return ret; + } +}; + +} // namespace ocpp20 +} // namespace chargepoint +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_BASICCHARGEPOINT20_H diff --git a/src/ocpp20/chargepoint/CMakeLists.txt b/src/ocpp20/chargepoint/CMakeLists.txt new file mode 100644 index 00000000..e309cd84 --- /dev/null +++ b/src/ocpp20/chargepoint/CMakeLists.txt @@ -0,0 +1,33 @@ +###################################################### +# OCPP chargepoint library # +###################################################### + + +# Library target +add_library(chargepoint20 OBJECT + ChargePoint20.cpp + BasicChargePoint20.cpp + + connector/Connectors20.cpp + devicemodel/DeviceModelManager20.cpp + status/StatusManager20.cpp + trigger/TriggerMessageManager20.cpp +) + +# Exported includes +target_include_directories(chargepoint20 PUBLIC interface devicemodel connector) + +# Private includes +target_include_directories(chargepoint20 PRIVATE config status trigger) + +# Dependencies +target_link_libraries(chargepoint20 PUBLIC + config + database + messages20 + rpc + helpers + log + version + x509 +) diff --git a/src/ocpp20/chargepoint/ChargePoint20.cpp b/src/ocpp20/chargepoint/ChargePoint20.cpp new file mode 100644 index 00000000..13001061 --- /dev/null +++ b/src/ocpp20/chargepoint/ChargePoint20.cpp @@ -0,0 +1,1480 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +#include "ChargePoint20.h" +#include "InternalConfigKeys.h" +#include "Logger.h" +#include "MessageDispatcher.h" +#include "PrivateKey.h" +#include "TimerPool.h" +#include "Url.h" +#include "Version.h" +#include "WebsocketFactory.h" +#include "WorkerThreadPool.h" + +#include +#include +#include + +using namespace ocpp::types; +using namespace ocpp::types::ocpp20; +using namespace ocpp::messages; +using namespace ocpp::messages::ocpp20; + +namespace ocpp +{ +namespace chargepoint +{ +namespace ocpp20 +{ + +/** @brief Instanciate a charge point */ +std::unique_ptr IChargePoint20::create(const ocpp::config::IChargePointConfig20& stack_config, + IChargePointEventsHandler20& events_handler) +{ + std::shared_ptr timer_pool(new ocpp::helpers::TimerPool()); + std::shared_ptr worker_pool = + std::make_shared(2u); // 1 asynchronous timer operations + 1 for asynchronous jobs/responses + std::unique_ptr messages_converter(new MessagesConverter20()); + return std::unique_ptr( + new ChargePoint20(stack_config, events_handler, timer_pool, worker_pool, std::move(messages_converter))); +} + +/** @brief Instanciate a charge point with the provided timer and worker pools */ +std::unique_ptr IChargePoint20::create(const ocpp::config::IChargePointConfig20& stack_config, + IChargePointEventsHandler20& events_handler, + std::shared_ptr timer_pool, + std::shared_ptr worker_pool) +{ + std::unique_ptr messages_converter(new MessagesConverter20()); + return std::unique_ptr( + new ChargePoint20(stack_config, events_handler, timer_pool, worker_pool, std::move(messages_converter))); +} + +/** @brief Constructor */ +ChargePoint20::ChargePoint20(const ocpp::config::IChargePointConfig20& stack_config, + IChargePointEventsHandler20& events_handler, + std::shared_ptr timer_pool, + std::shared_ptr worker_pool, + std::unique_ptr&& messages_converter) + : GenericMessageHandler(CANCELRESERVATION_ACTION, *messages_converter), + GenericMessageHandler(CERTIFICATESIGNED_ACTION, *messages_converter), + GenericMessageHandler(CHANGEAVAILABILITY_ACTION, *messages_converter), + GenericMessageHandler(CLEARCACHE_ACTION, *messages_converter), + GenericMessageHandler(CLEARCHARGINGPROFILE_ACTION, *messages_converter), + GenericMessageHandler(CLEARDISPLAYMESSAGE_ACTION, *messages_converter), + GenericMessageHandler(CLEARVARIABLEMONITORING_ACTION, *messages_converter), + GenericMessageHandler(CUSTOMERINFORMATION_ACTION, *messages_converter), + GenericMessageHandler(DATATRANSFER_ACTION, *messages_converter), + GenericMessageHandler(DELETECERTIFICATE_ACTION, *messages_converter), + GenericMessageHandler(GET15118EVCERTIFICATE_ACTION, *messages_converter), + GenericMessageHandler(GETBASEREPORT_ACTION, *messages_converter), + GenericMessageHandler(GETCERTIFICATESTATUS_ACTION, *messages_converter), + GenericMessageHandler(GETCHARGINGPROFILES_ACTION, *messages_converter), + GenericMessageHandler(GETCOMPOSITESCHEDULE_ACTION, *messages_converter), + GenericMessageHandler(GETDISPLAYMESSAGES_ACTION, *messages_converter), + GenericMessageHandler(GETINSTALLEDCERTIFICATEIDS_ACTION, + *messages_converter), + GenericMessageHandler(GETLOCALLISTVERSION_ACTION, *messages_converter), + GenericMessageHandler(GETLOG_ACTION, *messages_converter), + GenericMessageHandler(GETMONITORINGREPORT_ACTION, *messages_converter), + GenericMessageHandler(GETREPORT_ACTION, *messages_converter), + GenericMessageHandler(GETTRANSACTIONSTATUS_ACTION, *messages_converter), + GenericMessageHandler(GETVARIABLES_ACTION, *messages_converter), + GenericMessageHandler(INSTALLCERTIFICATE_ACTION, *messages_converter), + GenericMessageHandler(PUBLISHFIRMWARE_ACTION, *messages_converter), + GenericMessageHandler(REQUESTSTARTTRANSACTION_ACTION, *messages_converter), + GenericMessageHandler(REQUESTSTOPTRANSACTION_ACTION, *messages_converter), + GenericMessageHandler(RESERVENOW_ACTION, *messages_converter), + GenericMessageHandler(RESET_ACTION, *messages_converter), + GenericMessageHandler(SENDLOCALLIST_ACTION, *messages_converter), + GenericMessageHandler(SETCHARGINGPROFILE_ACTION, *messages_converter), + GenericMessageHandler(SETDISPLAYMESSAGE_ACTION, *messages_converter), + GenericMessageHandler(SETMONITORINGBASE_ACTION, *messages_converter), + GenericMessageHandler(SETMONITORINGLEVEL_ACTION, *messages_converter), + GenericMessageHandler(SETNETWORKPROFILE_ACTION, *messages_converter), + GenericMessageHandler(SETVARIABLEMONITORING_ACTION, *messages_converter), + GenericMessageHandler(SETVARIABLES_ACTION, *messages_converter), + GenericMessageHandler(TRIGGERMESSAGE_ACTION, *messages_converter), + GenericMessageHandler(UNLOCKCONNECTOR_ACTION, *messages_converter), + GenericMessageHandler(UNPUBLISHFIRMWARE_ACTION, *messages_converter), + GenericMessageHandler(UPDATEFIRMWARE_ACTION, *messages_converter), + + m_stack_config(stack_config), + m_events_handler(events_handler), + m_timer_pool(timer_pool), + m_worker_pool(worker_pool), + m_database(), + m_internal_config(m_database), + m_messages_converter(std::move(messages_converter)), + m_messages_validator(), + m_stop_in_progress(false), + m_reconnect_scheduled(false), + m_ws_client(), + m_rpc_client(), + m_msg_dispatcher(), + m_msg_sender(), + m_uptime_timer(*m_timer_pool.get(), "Uptime timer"), + m_uptime(0), + m_disconnected_time(0), + m_total_uptime(0), + m_total_disconnected_time(0) +{ + // Open database + if (m_stack_config.databasePath().empty() || m_database.open(m_stack_config.databasePath())) + { + // Register logger + if (m_stack_config.logMaxEntriesCount() != 0) + { + ocpp::log::Logger::registerDefaultLogger(m_database, m_stack_config.logMaxEntriesCount()); + } + + // Initialize the database + if (!m_stack_config.databasePath().empty()) + { + initDatabase(); + } + } + else + { + LOG_ERROR << "Unable to open database"; + } + + // Uptime timer + m_uptime_timer.setCallback(std::bind(&ChargePoint20::processUptime, this)); + + // Random numbers + std::srand(static_cast(time(nullptr))); +} + +/** @brief Destructor */ +ChargePoint20::~ChargePoint20() +{ + stop(); +} + +/** @copydoc bool IChargePoint20::resetData() */ +bool ChargePoint20::resetData() +{ + bool ret = false; + + // Check if it is already started + if (!m_rpc_client) + { + LOG_INFO << "Reset all data"; + if (!m_stack_config.databasePath().empty()) + { + // Unregister logger + if (m_stack_config.logMaxEntriesCount() != 0) + { + ocpp::log::Logger::unregisterDefaultLogger(); + } + + // Close database to invalid existing connexions + m_database.close(); + + // Delete database + if (std::filesystem::remove(m_stack_config.databasePath())) + { + // Open database + if (m_database.open(m_stack_config.databasePath())) + { + // Register logger + if (m_stack_config.logMaxEntriesCount() != 0) + { + ocpp::log::Logger::registerDefaultLogger(m_database, m_stack_config.logMaxEntriesCount()); + } + + // Re-initialize with default values + m_total_uptime = 0; + m_total_disconnected_time = 0; + initDatabase(); + } + else + { + LOG_ERROR << "Unable to open database"; + } + } + else + { + LOG_ERROR << "Unable to delete database"; + } + } + else + { + ret = true; + } + } + + return ret; +} + +/** @copydoc bool IChargePoint20::start() */ +bool ChargePoint20::start() +{ + bool ret = false; + + // Check if it is already started + if (!m_rpc_client) + { + + LOG_INFO << "Starting OCPP stack v" << OPEN_OCPP_VERSION << " - Central System : " << m_stack_config.connexionUrl() + << " - Charge Point identifier : " << m_stack_config.chargePointIdentifier(); + + // Load validator + ret = m_messages_validator.load(m_stack_config.jsonSchemasPath()); + if (ret) + { + // Start uptime counter + if (!m_stack_config.databasePath().empty()) + { + m_uptime = 0; + m_disconnected_time = 0; + m_internal_config.setKey(START_DATE_KEY, DateTime::now().str()); + m_uptime_timer.start(std::chrono::seconds(1u)); + } + + // Allocate resources + m_ws_client = std::unique_ptr(ocpp::websockets::WebsocketFactory::newClient()); + m_rpc_client = std::make_unique(*m_ws_client, "ocpp2.0.1"); + m_rpc_client->registerListener(*this); + m_rpc_client->registerClientListener(*this); + m_rpc_client->registerSpy(*this); + m_msg_dispatcher = std::make_unique(m_messages_validator); + m_msg_sender = std::make_unique( + *m_rpc_client, *m_messages_converter, m_messages_validator, m_stack_config.callRequestTimeout()); + + // Register to Central System messages + m_msg_dispatcher->registerHandler(CANCELRESERVATION_ACTION, + *dynamic_cast*>(this)); + m_msg_dispatcher->registerHandler(CERTIFICATESIGNED_ACTION, + *dynamic_cast*>(this)); + m_msg_dispatcher->registerHandler(CHANGEAVAILABILITY_ACTION, + *dynamic_cast*>(this)); + m_msg_dispatcher->registerHandler(CLEARCACHE_ACTION, + *dynamic_cast*>(this)); + m_msg_dispatcher->registerHandler( + CLEARCHARGINGPROFILE_ACTION, + *dynamic_cast*>(this)); + m_msg_dispatcher->registerHandler(CLEARDISPLAYMESSAGE_ACTION, + *dynamic_cast*>(this)); + m_msg_dispatcher->registerHandler( + CLEARVARIABLEMONITORING_ACTION, + *dynamic_cast*>(this)); + m_msg_dispatcher->registerHandler(CUSTOMERINFORMATION_ACTION, + *dynamic_cast*>(this)); + m_msg_dispatcher->registerHandler(DATATRANSFER_ACTION, + *dynamic_cast*>(this)); + m_msg_dispatcher->registerHandler(DELETECERTIFICATE_ACTION, + *dynamic_cast*>(this)); + m_msg_dispatcher->registerHandler( + GET15118EVCERTIFICATE_ACTION, + *dynamic_cast*>(this)); + m_msg_dispatcher->registerHandler(GETBASEREPORT_ACTION, + *dynamic_cast*>(this)); + m_msg_dispatcher->registerHandler( + GETCERTIFICATESTATUS_ACTION, + *dynamic_cast*>(this)); + m_msg_dispatcher->registerHandler(GETCHARGINGPROFILES_ACTION, + *dynamic_cast*>(this)); + m_msg_dispatcher->registerHandler( + GETCOMPOSITESCHEDULE_ACTION, + *dynamic_cast*>(this)); + m_msg_dispatcher->registerHandler(GETDISPLAYMESSAGES_ACTION, + *dynamic_cast*>(this)); + m_msg_dispatcher->registerHandler( + GETINSTALLEDCERTIFICATEIDS_ACTION, + *dynamic_cast*>(this)); + m_msg_dispatcher->registerHandler(GETLOCALLISTVERSION_ACTION, + *dynamic_cast*>(this)); + m_msg_dispatcher->registerHandler(GETLOG_ACTION, *dynamic_cast*>(this)); + m_msg_dispatcher->registerHandler(GETMONITORINGREPORT_ACTION, + *dynamic_cast*>(this)); + m_msg_dispatcher->registerHandler(GETREPORT_ACTION, *dynamic_cast*>(this)); + m_msg_dispatcher->registerHandler( + GETTRANSACTIONSTATUS_ACTION, + *dynamic_cast*>(this)); + m_msg_dispatcher->registerHandler(GETVARIABLES_ACTION, + *dynamic_cast*>(this)); + m_msg_dispatcher->registerHandler(INSTALLCERTIFICATE_ACTION, + *dynamic_cast*>(this)); + m_msg_dispatcher->registerHandler(PUBLISHFIRMWARE_ACTION, + *dynamic_cast*>(this)); + m_msg_dispatcher->registerHandler( + REQUESTSTARTTRANSACTION_ACTION, + *dynamic_cast*>(this)); + m_msg_dispatcher->registerHandler( + REQUESTSTOPTRANSACTION_ACTION, + *dynamic_cast*>(this)); + m_msg_dispatcher->registerHandler(RESERVENOW_ACTION, + *dynamic_cast*>(this)); + m_msg_dispatcher->registerHandler(RESET_ACTION, *dynamic_cast*>(this)); + m_msg_dispatcher->registerHandler(SENDLOCALLIST_ACTION, + *dynamic_cast*>(this)); + m_msg_dispatcher->registerHandler(SETCHARGINGPROFILE_ACTION, + *dynamic_cast*>(this)); + m_msg_dispatcher->registerHandler(SETDISPLAYMESSAGE_ACTION, + *dynamic_cast*>(this)); + m_msg_dispatcher->registerHandler(SETMONITORINGBASE_ACTION, + *dynamic_cast*>(this)); + m_msg_dispatcher->registerHandler(SETMONITORINGLEVEL_ACTION, + *dynamic_cast*>(this)); + m_msg_dispatcher->registerHandler(SETNETWORKPROFILE_ACTION, + *dynamic_cast*>(this)); + m_msg_dispatcher->registerHandler( + SETVARIABLEMONITORING_ACTION, + *dynamic_cast*>(this)); + m_msg_dispatcher->registerHandler(SETVARIABLES_ACTION, + *dynamic_cast*>(this)); + m_msg_dispatcher->registerHandler(TRIGGERMESSAGE_ACTION, + *dynamic_cast*>(this)); + m_msg_dispatcher->registerHandler(UNLOCKCONNECTOR_ACTION, + *dynamic_cast*>(this)); + m_msg_dispatcher->registerHandler(UNPUBLISHFIRMWARE_ACTION, + *dynamic_cast*>(this)); + m_msg_dispatcher->registerHandler(UPDATEFIRMWARE_ACTION, + *dynamic_cast*>(this)); + + // Start connection + m_stop_in_progress = false; + ret = doConnect(); + } + else + { + LOG_ERROR << "Unable to load all the messages validators"; + } + } + else + { + LOG_ERROR << "Stack already started"; + } + + return ret; +} + +/** @copydoc bool IChargePoint20::stop() */ +bool ChargePoint20::stop() +{ + bool ret = false; + + // Check if it is already started + if (m_rpc_client && !m_stop_in_progress) + { + LOG_INFO << "Stopping OCPP stack"; + m_stop_in_progress = true; + + // Stop uptime counter + if (!m_stack_config.databasePath().empty()) + { + m_uptime_timer.stop(); + saveUptime(); + } + + // Stop connection + ret = m_rpc_client->stop(); + std::this_thread::sleep_for(std::chrono::milliseconds(300)); + + // Free resources + m_ws_client.reset(); + m_rpc_client.reset(); + m_msg_dispatcher.reset(); + m_msg_sender.reset(); + + // Close database + m_database.close(); + } + else + { + LOG_ERROR << "Stack already stopped"; + } + + return ret; +} + +/** @copydoc bool IChargePoint20::reconnect() */ +bool ChargePoint20::reconnect() +{ + bool ret = false; + + // Check if it is started + if (m_rpc_client) + { + // Schedule of reconnexion + LOG_INFO << "Reconnect triggered"; + scheduleReconnect(); + ret = true; + } + else + { + LOG_ERROR << "Stack stopped"; + } + + return ret; +} + +/** @copydoc void RpcClient::IListener::rpcClientConnected() */ +void ChargePoint20::rpcClientConnected() +{ + LOG_INFO << "Connected to Central System"; + m_events_handler.connectionStateChanged(true); +} + +/** @copydoc void RpcClient::IListener::rpcClientFailed() */ +void ChargePoint20::rpcClientFailed() +{ + LOG_ERROR << "Connection failed with Central System"; + m_events_handler.connectionFailed(); +} + +/** @copydoc void IRpc::IListener::rpcDisconnected() */ +void ChargePoint20::rpcDisconnected() +{ + // Check if stop is in progress + if (!m_stop_in_progress) + { + LOG_ERROR << "Connection lost with Central System"; + m_events_handler.connectionStateChanged(false); + } +} + +/** @copydoc void IRpc::IListener::rpcError() */ +void ChargePoint20::rpcError() +{ + LOG_ERROR << "Connection error with Central System"; +} + +/** @copydoc void IRpc::IListener::rpcCallReceived(const std::string&, + const rapidjson::Value&, + rapidjson::Document&, + std::string&, + std::string&) */ +bool ChargePoint20::rpcCallReceived(const std::string& action, + const rapidjson::Value& payload, + rapidjson::Document& response, + std::string& error_code, + std::string& error_message) +{ + bool ret = false; + + // Check if stop is in progress + if (!m_stop_in_progress) + { + ret = m_msg_dispatcher->dispatchMessage(action, payload, response, error_code, error_message); + } + + return ret; +} + +/** @copydoc void IRpc::ISpy::rcpMessageReceived(const std::string&) */ +void ChargePoint20::rcpMessageReceived(const std::string& msg) +{ + LOG_COM << "RX : " << msg; +} + +/** @copydoc void IRpc::ISpy::rcpMessageSent(const std::string&) */ +void ChargePoint20::rcpMessageSent(const std::string& msg) +{ + LOG_COM << "TX : " << msg; +} + +// OCPP operations + +/** @copydoc bool IChargePoint20::call(const ocpp::messages::ocpp20::BootNotificationReq&, + * ocpp::messages::ocpp20::BootNotificationConf&, + * std::string&, + * std::string&) */ +bool ChargePoint20::call(const ocpp::messages::ocpp20::BootNotificationReq& request, + ocpp::messages::ocpp20::BootNotificationConf& response, + std::string& error, + std::string& message) +{ + return call(BOOTNOTIFICATION_ACTION, request, response, error, message); +} + +/** @copydoc bool IChargePoint20::call(const ocpp::messages::ocpp20::AuthorizeReq&, + * ocpp::messages::ocpp20::AuthorizeConf&, + * std::string&, + * std::string&) */ +bool ChargePoint20::call(const ocpp::messages::ocpp20::AuthorizeReq& request, + ocpp::messages::ocpp20::AuthorizeConf& response, + std::string& error, + std::string& message) +{ + return call(AUTHORIZE_ACTION, request, response, error, message); +} + +/** @copydoc bool IChargePoint20::call(const ocpp::messages::ocpp20::ClearedChargingLimitReq&, + * ocpp::messages::ocpp20::ClearedChargingLimitConf&, + * std::string&, + * std::string&) */ +bool ChargePoint20::call(const ocpp::messages::ocpp20::ClearedChargingLimitReq& request, + ocpp::messages::ocpp20::ClearedChargingLimitConf& response, + std::string& error, + std::string& message) +{ + return call(CLEAREDCHARGINGLIMIT_ACTION, request, response, error, message); +} + +/** @copydoc bool IChargePoint20::call(const ocpp::messages::ocpp20::CostUpdatedReq&, + * ocpp::messages::ocpp20::CostUpdatedConf&, + * std::string&, + * std::string&) */ +bool ChargePoint20::call(const ocpp::messages::ocpp20::CostUpdatedReq& request, + ocpp::messages::ocpp20::CostUpdatedConf& response, + std::string& error, + std::string& message) +{ + return call(COSTUPDATED_ACTION, request, response, error, message); +} + +/** @copydoc bool IChargePoint20::call(const ocpp::messages::ocpp20::DataTransferReq&, + * ocpp::messages::ocpp20::DataTransferConf&, + * std::string&, + * std::string&) */ +bool ChargePoint20::call(const ocpp::messages::ocpp20::DataTransferReq& request, + ocpp::messages::ocpp20::DataTransferConf& response, + std::string& error, + std::string& message) +{ + return call(DATATRANSFER_ACTION, request, response, error, message); +} + +/** @copydoc bool IChargePoint20::call(const ocpp::messages::ocpp20::FirmwareStatusNotificationReq&, + * ocpp::messages::ocpp20::FirmwareStatusNotificationConf&, + * std::string&, + * std::string&) */ +bool ChargePoint20::call(const ocpp::messages::ocpp20::FirmwareStatusNotificationReq& request, + ocpp::messages::ocpp20::FirmwareStatusNotificationConf& response, + std::string& error, + std::string& message) +{ + return call(FIRMWARESTATUSNOTIFICATION_ACTION, request, response, error, message); +} + +/** @copydoc bool IChargePoint20::call(const ocpp::messages::ocpp20::HeartbeatReq&, + * ocpp::messages::ocpp20::HeartbeatConf&, + * std::string&, + * std::string&) */ +bool ChargePoint20::call(const ocpp::messages::ocpp20::HeartbeatReq& request, + ocpp::messages::ocpp20::HeartbeatConf& response, + std::string& error, + std::string& message) +{ + return call(HEARTBEAT_ACTION, request, response, error, message); +} + +/** @copydoc bool IChargePoint20::call(const ocpp::messages::ocpp20::LogStatusNotificationReq&, + * ocpp::messages::ocpp20::LogStatusNotificationConf&, + * std::string&, + * std::string&) */ +bool ChargePoint20::call(const ocpp::messages::ocpp20::LogStatusNotificationReq& request, + ocpp::messages::ocpp20::LogStatusNotificationConf& response, + std::string& error, + std::string& message) +{ + return call(LOGSTATUSNOTIFICATION_ACTION, request, response, error, message); +} + +/** @copydoc bool IChargePoint20::call(const ocpp::messages::ocpp20::MeterValuesReq&, + * ocpp::messages::ocpp20::MeterValuesConf&, + * std::string&, + * std::string&) */ +bool ChargePoint20::call(const ocpp::messages::ocpp20::MeterValuesReq& request, + ocpp::messages::ocpp20::MeterValuesConf& response, + std::string& error, + std::string& message) +{ + return call(METERVALUES_ACTION, request, response, error, message); +} + +/** @copydoc bool IChargePoint20::call(const ocpp::messages::ocpp20::NotifyChargingLimitReq&, + * ocpp::messages::ocpp20::NotifyChargingLimitConf&, + * std::string&, + * std::string&) */ +bool ChargePoint20::call(const ocpp::messages::ocpp20::NotifyChargingLimitReq& request, + ocpp::messages::ocpp20::NotifyChargingLimitConf& response, + std::string& error, + std::string& message) +{ + return call(NOTIFYCHARGINGLIMIT_ACTION, request, response, error, message); +} + +/** @copydoc bool IChargePoint20::call(const ocpp::messages::ocpp20::NotifyCustomerInformationReq&, + * ocpp::messages::ocpp20::NotifyCustomerInformationConf&, + * std::string&, + * std::string&) */ +bool ChargePoint20::call(const ocpp::messages::ocpp20::NotifyCustomerInformationReq& request, + ocpp::messages::ocpp20::NotifyCustomerInformationConf& response, + std::string& error, + std::string& message) +{ + return call(NOTIFYCUSTOMERINFORMATION_ACTION, request, response, error, message); +} + +/** @copydoc bool IChargePoint20::call(const ocpp::messages::ocpp20::NotifyDisplayMessagesReq&, + * ocpp::messages::ocpp20::NotifyDisplayMessagesConf&, + * std::string&, + * std::string&) */ +bool ChargePoint20::call(const ocpp::messages::ocpp20::NotifyDisplayMessagesReq& request, + ocpp::messages::ocpp20::NotifyDisplayMessagesConf& response, + std::string& error, + std::string& message) +{ + return call(NOTIFYDISPLAYMESSAGES_ACTION, request, response, error, message); +} + +/** @copydoc bool IChargePoint20::call(const ocpp::messages::ocpp20::NotifyEVChargingNeedsReq&, + * ocpp::messages::ocpp20::NotifyEVChargingNeedsConf&, + * std::string&, + * std::string&) */ +bool ChargePoint20::call(const ocpp::messages::ocpp20::NotifyEVChargingNeedsReq& request, + ocpp::messages::ocpp20::NotifyEVChargingNeedsConf& response, + std::string& error, + std::string& message) +{ + return call(NOTIFYEVCHARGINGNEEDS_ACTION, request, response, error, message); +} + +/** @copydoc bool IChargePoint20::call(const ocpp::messages::ocpp20::NotifyEVChargingScheduleReq&, + * ocpp::messages::ocpp20::NotifyEVChargingScheduleConf&, + * std::string&, + * std::string&) */ +bool ChargePoint20::call(const ocpp::messages::ocpp20::NotifyEVChargingScheduleReq& request, + ocpp::messages::ocpp20::NotifyEVChargingScheduleConf& response, + std::string& error, + std::string& message) +{ + return call(NOTIFYEVCHARGINGSCHEDULE_ACTION, request, response, error, message); +} + +/** @copydoc bool IChargePoint20::call(const ocpp::messages::ocpp20::NotifyEventReq&, + * ocpp::messages::ocpp20::NotifyEventConf&, + * std::string&, + * std::string&) */ +bool ChargePoint20::call(const ocpp::messages::ocpp20::NotifyEventReq& request, + ocpp::messages::ocpp20::NotifyEventConf& response, + std::string& error, + std::string& message) +{ + return call(NOTIFYEVENT_ACTION, request, response, error, message); +} + +/** @copydoc bool IChargePoint20::call(const ocpp::messages::ocpp20::NotifyMonitoringReportReq&, + * ocpp::messages::ocpp20::NotifyMonitoringReportConf&, + * std::string&, + * std::string&) */ +bool ChargePoint20::call(const ocpp::messages::ocpp20::NotifyMonitoringReportReq& request, + ocpp::messages::ocpp20::NotifyMonitoringReportConf& response, + std::string& error, + std::string& message) +{ + return call(NOTIFYMONITORINGREPORT_ACTION, request, response, error, message); +} + +/** @copydoc bool IChargePoint20::call(const ocpp::messages::ocpp20::NotifyReportReq&, + * ocpp::messages::ocpp20::NotifyReportConf&, + * std::string&, + * std::string&) */ +bool ChargePoint20::call(const ocpp::messages::ocpp20::NotifyReportReq& request, + ocpp::messages::ocpp20::NotifyReportConf& response, + std::string& error, + std::string& message) +{ + return call(NOTIFYREPORT_ACTION, request, response, error, message); +} + +/** @copydoc bool IChargePoint20::call(const ocpp::messages::ocpp20::PublishFirmwareStatusNotificationReq&, + * ocpp::messages::ocpp20::PublishFirmwareStatusNotificationConf&, + * std::string&, + * std::string&) */ +bool ChargePoint20::call(const ocpp::messages::ocpp20::PublishFirmwareStatusNotificationReq& request, + ocpp::messages::ocpp20::PublishFirmwareStatusNotificationConf& response, + std::string& error, + std::string& message) +{ + return call(PUBLISHFIRMWARESTATUSNOTIFICATION_ACTION, request, response, error, message); +} + +/** @copydoc bool IChargePoint20::call(const ocpp::messages::ocpp20::ReportChargingProfilesReq&, + * ocpp::messages::ocpp20::ReportChargingProfilesConf&, + * std::string&, + * std::string&) */ +bool ChargePoint20::call(const ocpp::messages::ocpp20::ReportChargingProfilesReq& request, + ocpp::messages::ocpp20::ReportChargingProfilesConf& response, + std::string& error, + std::string& message) +{ + return call(REPORTCHARGINGPROFILES_ACTION, request, response, error, message); +} + +/** @copydoc bool IChargePoint20::call(const ocpp::messages::ocpp20::ReservationStatusUpdateReq&, + * ocpp::messages::ocpp20::ReservationStatusUpdateConf&, + * std::string&, + * std::string&) */ +bool ChargePoint20::call(const ocpp::messages::ocpp20::ReservationStatusUpdateReq& request, + ocpp::messages::ocpp20::ReservationStatusUpdateConf& response, + std::string& error, + std::string& message) +{ + return call(RESERVATIONSTATUSUPDATE_ACTION, request, response, error, message); +} + +/** @copydoc bool IChargePoint20::call(const ocpp::messages::ocpp20::SecurityEventNotificationReq&, + * ocpp::messages::ocpp20::SecurityEventNotificationConf&, + * std::string&, + * std::string&) */ +bool ChargePoint20::call(const ocpp::messages::ocpp20::SecurityEventNotificationReq& request, + ocpp::messages::ocpp20::SecurityEventNotificationConf& response, + std::string& error, + std::string& message) +{ + return call(SECURITYEVENTNOTIFICATION_ACTION, request, response, error, message); +} + +/** @copydoc bool IChargePoint20::call(const ocpp::messages::ocpp20::SignCertificateReq&, + * ocpp::messages::ocpp20::SignCertificateConf&, + * std::string&, + * std::string&) */ +bool ChargePoint20::call(const ocpp::messages::ocpp20::SignCertificateReq& request, + ocpp::messages::ocpp20::SignCertificateConf& response, + std::string& error, + std::string& message) +{ + return call(SIGNCERTIFICATE_ACTION, request, response, error, message); +} + +/** @copydoc bool IChargePoint20::call(const ocpp::messages::ocpp20::StatusNotificationReq&, + * ocpp::messages::ocpp20::StatusNotificationConf&, + * std::string&, + * std::string&) */ +bool ChargePoint20::call(const ocpp::messages::ocpp20::StatusNotificationReq& request, + ocpp::messages::ocpp20::StatusNotificationConf& response, + std::string& error, + std::string& message) +{ + return call(STATUSNOTIFICATION_ACTION, request, response, error, message); +} + +/** @copydoc bool IChargePoint20::call(const ocpp::messages::ocpp20::TransactionEventReq&, + * ocpp::messages::ocpp20::TransactionEventConf&, + * std::string&, + * std::string&) */ +bool ChargePoint20::call(const ocpp::messages::ocpp20::TransactionEventReq& request, + ocpp::messages::ocpp20::TransactionEventConf& response, + std::string& error, + std::string& message) +{ + return call(TRANSACTIONEVENT_ACTION, request, response, error, message); +} + +// OCPP handlers + +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePoint20::handleMessage(const ocpp::messages::ocpp20::CancelReservationReq& request, + ocpp::messages::ocpp20::CancelReservationConf& response, + std::string& error_code, + std::string& error_message) +{ + return m_events_handler.onCancelReservation(request, response, error_code, error_message); +} + +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePoint20::handleMessage(const ocpp::messages::ocpp20::CertificateSignedReq& request, + ocpp::messages::ocpp20::CertificateSignedConf& response, + std::string& error_code, + std::string& error_message) +{ + return m_events_handler.onCertificateSigned(request, response, error_code, error_message); +} + +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePoint20::handleMessage(const ocpp::messages::ocpp20::ChangeAvailabilityReq& request, + ocpp::messages::ocpp20::ChangeAvailabilityConf& response, + std::string& error_code, + std::string& error_message) +{ + return m_events_handler.onChangeAvailability(request, response, error_code, error_message); +} + +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePoint20::handleMessage(const ocpp::messages::ocpp20::ClearCacheReq& request, + ocpp::messages::ocpp20::ClearCacheConf& response, + std::string& error_code, + std::string& error_message) +{ + return m_events_handler.onClearCache(request, response, error_code, error_message); +} + +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePoint20::handleMessage(const ocpp::messages::ocpp20::ClearChargingProfileReq& request, + ocpp::messages::ocpp20::ClearChargingProfileConf& response, + std::string& error_code, + std::string& error_message) +{ + return m_events_handler.onClearChargingProfile(request, response, error_code, error_message); +} + +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePoint20::handleMessage(const ocpp::messages::ocpp20::ClearDisplayMessageReq& request, + ocpp::messages::ocpp20::ClearDisplayMessageConf& response, + std::string& error_code, + std::string& error_message) +{ + return m_events_handler.onClearDisplayMessage(request, response, error_code, error_message); +} + +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePoint20::handleMessage(const ocpp::messages::ocpp20::ClearVariableMonitoringReq& request, + ocpp::messages::ocpp20::ClearVariableMonitoringConf& response, + std::string& error_code, + std::string& error_message) +{ + return m_events_handler.onClearVariableMonitoring(request, response, error_code, error_message); +} + +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePoint20::handleMessage(const ocpp::messages::ocpp20::CustomerInformationReq& request, + ocpp::messages::ocpp20::CustomerInformationConf& response, + std::string& error_code, + std::string& error_message) +{ + return m_events_handler.onCustomerInformation(request, response, error_code, error_message); +} + +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePoint20::handleMessage(const ocpp::messages::ocpp20::DataTransferReq& request, + ocpp::messages::ocpp20::DataTransferConf& response, + std::string& error_code, + std::string& error_message) +{ + return m_events_handler.onDataTransfer(request, response, error_code, error_message); +} + +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePoint20::handleMessage(const ocpp::messages::ocpp20::DeleteCertificateReq& request, + ocpp::messages::ocpp20::DeleteCertificateConf& response, + std::string& error_code, + std::string& error_message) +{ + return m_events_handler.onDeleteCertificate(request, response, error_code, error_message); +} + +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePoint20::handleMessage(const ocpp::messages::ocpp20::Get15118EVCertificateReq& request, + ocpp::messages::ocpp20::Get15118EVCertificateConf& response, + std::string& error_code, + std::string& error_message) +{ + return m_events_handler.onGet15118EVCertificate(request, response, error_code, error_message); +} + +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePoint20::handleMessage(const ocpp::messages::ocpp20::GetBaseReportReq& request, + ocpp::messages::ocpp20::GetBaseReportConf& response, + std::string& error_code, + std::string& error_message) +{ + return m_events_handler.onGetBaseReport(request, response, error_code, error_message); +} + +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePoint20::handleMessage(const ocpp::messages::ocpp20::GetCertificateStatusReq& request, + ocpp::messages::ocpp20::GetCertificateStatusConf& response, + std::string& error_code, + std::string& error_message) +{ + return m_events_handler.onGetCertificateStatus(request, response, error_code, error_message); +} + +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePoint20::handleMessage(const ocpp::messages::ocpp20::GetChargingProfilesReq& request, + ocpp::messages::ocpp20::GetChargingProfilesConf& response, + std::string& error_code, + std::string& error_message) +{ + return m_events_handler.onGetChargingProfiles(request, response, error_code, error_message); +} + +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePoint20::handleMessage(const ocpp::messages::ocpp20::GetCompositeScheduleReq& request, + ocpp::messages::ocpp20::GetCompositeScheduleConf& response, + std::string& error_code, + std::string& error_message) +{ + return m_events_handler.onGetCompositeSchedule(request, response, error_code, error_message); +} + +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePoint20::handleMessage(const ocpp::messages::ocpp20::GetDisplayMessagesReq& request, + ocpp::messages::ocpp20::GetDisplayMessagesConf& response, + std::string& error_code, + std::string& error_message) +{ + return m_events_handler.onGetDisplayMessages(request, response, error_code, error_message); +} + +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePoint20::handleMessage(const ocpp::messages::ocpp20::GetInstalledCertificateIdsReq& request, + ocpp::messages::ocpp20::GetInstalledCertificateIdsConf& response, + std::string& error_code, + std::string& error_message) +{ + return m_events_handler.onGetInstalledCertificateIds(request, response, error_code, error_message); +} + +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePoint20::handleMessage(const ocpp::messages::ocpp20::GetLocalListVersionReq& request, + ocpp::messages::ocpp20::GetLocalListVersionConf& response, + std::string& error_code, + std::string& error_message) +{ + return m_events_handler.onGetLocalListVersion(request, response, error_code, error_message); +} + +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePoint20::handleMessage(const ocpp::messages::ocpp20::GetLogReq& request, + ocpp::messages::ocpp20::GetLogConf& response, + std::string& error_code, + std::string& error_message) +{ + return m_events_handler.onGetLog(request, response, error_code, error_message); +} + +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePoint20::handleMessage(const ocpp::messages::ocpp20::GetMonitoringReportReq& request, + ocpp::messages::ocpp20::GetMonitoringReportConf& response, + std::string& error_code, + std::string& error_message) +{ + return m_events_handler.onGetMonitoringReport(request, response, error_code, error_message); +} + +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePoint20::handleMessage(const ocpp::messages::ocpp20::GetReportReq& request, + ocpp::messages::ocpp20::GetReportConf& response, + std::string& error_code, + std::string& error_message) +{ + return m_events_handler.onGetReport(request, response, error_code, error_message); +} + +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePoint20::handleMessage(const ocpp::messages::ocpp20::GetTransactionStatusReq& request, + ocpp::messages::ocpp20::GetTransactionStatusConf& response, + std::string& error_code, + std::string& error_message) +{ + return m_events_handler.onGetTransactionStatus(request, response, error_code, error_message); +} + +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePoint20::handleMessage(const ocpp::messages::ocpp20::GetVariablesReq& request, + ocpp::messages::ocpp20::GetVariablesConf& response, + std::string& error_code, + std::string& error_message) +{ + return m_events_handler.onGetVariables(request, response, error_code, error_message); +} + +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePoint20::handleMessage(const ocpp::messages::ocpp20::InstallCertificateReq& request, + ocpp::messages::ocpp20::InstallCertificateConf& response, + std::string& error_code, + std::string& error_message) +{ + return m_events_handler.onInstallCertificate(request, response, error_code, error_message); +} + +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePoint20::handleMessage(const ocpp::messages::ocpp20::PublishFirmwareReq& request, + ocpp::messages::ocpp20::PublishFirmwareConf& response, + std::string& error_code, + std::string& error_message) +{ + return m_events_handler.onPublishFirmware(request, response, error_code, error_message); +} + +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePoint20::handleMessage(const ocpp::messages::ocpp20::RequestStartTransactionReq& request, + ocpp::messages::ocpp20::RequestStartTransactionConf& response, + std::string& error_code, + std::string& error_message) +{ + return m_events_handler.onRequestStartTransaction(request, response, error_code, error_message); +} + +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePoint20::handleMessage(const ocpp::messages::ocpp20::RequestStopTransactionReq& request, + ocpp::messages::ocpp20::RequestStopTransactionConf& response, + std::string& error_code, + std::string& error_message) +{ + return m_events_handler.onRequestStopTransaction(request, response, error_code, error_message); +} + +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePoint20::handleMessage(const ocpp::messages::ocpp20::ReserveNowReq& request, + ocpp::messages::ocpp20::ReserveNowConf& response, + std::string& error_code, + std::string& error_message) +{ + return m_events_handler.onReserveNow(request, response, error_code, error_message); +} + +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePoint20::handleMessage(const ocpp::messages::ocpp20::ResetReq& request, + ocpp::messages::ocpp20::ResetConf& response, + std::string& error_code, + std::string& error_message) +{ + return m_events_handler.onReset(request, response, error_code, error_message); +} + +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePoint20::handleMessage(const ocpp::messages::ocpp20::SendLocalListReq& request, + ocpp::messages::ocpp20::SendLocalListConf& response, + std::string& error_code, + std::string& error_message) +{ + return m_events_handler.onSendLocalList(request, response, error_code, error_message); +} + +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePoint20::handleMessage(const ocpp::messages::ocpp20::SetChargingProfileReq& request, + ocpp::messages::ocpp20::SetChargingProfileConf& response, + std::string& error_code, + std::string& error_message) +{ + return m_events_handler.onSetChargingProfile(request, response, error_code, error_message); +} + +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePoint20::handleMessage(const ocpp::messages::ocpp20::SetDisplayMessageReq& request, + ocpp::messages::ocpp20::SetDisplayMessageConf& response, + std::string& error_code, + std::string& error_message) +{ + return m_events_handler.onSetDisplayMessage(request, response, error_code, error_message); +} + +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePoint20::handleMessage(const ocpp::messages::ocpp20::SetMonitoringBaseReq& request, + ocpp::messages::ocpp20::SetMonitoringBaseConf& response, + std::string& error_code, + std::string& error_message) +{ + return m_events_handler.onSetMonitoringBase(request, response, error_code, error_message); +} + +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePoint20::handleMessage(const ocpp::messages::ocpp20::SetMonitoringLevelReq& request, + ocpp::messages::ocpp20::SetMonitoringLevelConf& response, + std::string& error_code, + std::string& error_message) +{ + return m_events_handler.onSetMonitoringLevel(request, response, error_code, error_message); +} + +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePoint20::handleMessage(const ocpp::messages::ocpp20::SetNetworkProfileReq& request, + ocpp::messages::ocpp20::SetNetworkProfileConf& response, + std::string& error_code, + std::string& error_message) +{ + return m_events_handler.onSetNetworkProfile(request, response, error_code, error_message); +} + +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePoint20::handleMessage(const ocpp::messages::ocpp20::SetVariableMonitoringReq& request, + ocpp::messages::ocpp20::SetVariableMonitoringConf& response, + std::string& error_code, + std::string& error_message) +{ + return m_events_handler.onSetVariableMonitoring(request, response, error_code, error_message); +} + +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePoint20::handleMessage(const ocpp::messages::ocpp20::SetVariablesReq& request, + ocpp::messages::ocpp20::SetVariablesConf& response, + std::string& error_code, + std::string& error_message) +{ + return m_events_handler.onSetVariables(request, response, error_code, error_message); +} + +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePoint20::handleMessage(const ocpp::messages::ocpp20::TriggerMessageReq& request, + ocpp::messages::ocpp20::TriggerMessageConf& response, + std::string& error_code, + std::string& error_message) +{ + return m_events_handler.onTriggerMessage(request, response, error_code, error_message); +} + +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePoint20::handleMessage(const ocpp::messages::ocpp20::UnlockConnectorReq& request, + ocpp::messages::ocpp20::UnlockConnectorConf& response, + std::string& error_code, + std::string& error_message) +{ + return m_events_handler.onUnlockConnector(request, response, error_code, error_message); +} + +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePoint20::handleMessage(const ocpp::messages::ocpp20::UnpublishFirmwareReq& request, + ocpp::messages::ocpp20::UnpublishFirmwareConf& response, + std::string& error_code, + std::string& error_message) +{ + return m_events_handler.onUnpublishFirmware(request, response, error_code, error_message); +} + +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePoint20::handleMessage(const ocpp::messages::ocpp20::UpdateFirmwareReq& request, + ocpp::messages::ocpp20::UpdateFirmwareConf& response, + std::string& error_code, + std::string& error_message) +{ + return m_events_handler.onUpdateFirmware(request, response, error_code, error_message); +} + +/** @brief Initialize the database */ +void ChargePoint20::initDatabase() +{ + // Initialize internal configuration + m_internal_config.initDatabaseTable(); + + // Internal keys + if (!m_internal_config.keyExist(STACK_VERSION_KEY)) + { + m_internal_config.createKey(STACK_VERSION_KEY, OPEN_OCPP_VERSION); + } + else + { + m_internal_config.setKey(STACK_VERSION_KEY, OPEN_OCPP_VERSION); + } + if (!m_internal_config.keyExist(START_DATE_KEY)) + { + m_internal_config.createKey(START_DATE_KEY, ""); + } + if (!m_internal_config.keyExist(UPTIME_KEY)) + { + m_internal_config.createKey(UPTIME_KEY, "0"); + } + if (!m_internal_config.keyExist(DISCONNECTED_TIME_KEY)) + { + m_internal_config.createKey(DISCONNECTED_TIME_KEY, "0"); + } + if (!m_internal_config.keyExist(TOTAL_UPTIME_KEY)) + { + m_internal_config.createKey(TOTAL_UPTIME_KEY, "0"); + } + else + { + std::string value; + m_internal_config.getKey(TOTAL_UPTIME_KEY, value); + m_total_uptime = static_cast(std::atoi(value.c_str())); + } + if (!m_internal_config.keyExist(TOTAL_DISCONNECTED_TIME_KEY)) + { + m_internal_config.createKey(TOTAL_DISCONNECTED_TIME_KEY, "0"); + } + else + { + std::string value; + m_internal_config.getKey(TOTAL_DISCONNECTED_TIME_KEY, value); + m_total_disconnected_time = static_cast(std::atoi(value.c_str())); + } + if (!m_internal_config.keyExist(LAST_CONNECTION_URL_KEY)) + { + m_internal_config.createKey(LAST_CONNECTION_URL_KEY, ""); + } +} + +/** @brief Process uptime */ +void ChargePoint20::processUptime() +{ + // Increase counters + m_uptime++; + m_total_uptime++; + if (m_rpc_client && !m_rpc_client->isConnected()) + { + m_disconnected_time++; + m_total_disconnected_time++; + } + + // Save counters + if ((m_uptime % 15u) == 0) + { + m_worker_pool->run(std::bind(&ChargePoint20::saveUptime, this)); + } +} + +/** @brief Save the uptime counter in database */ +void ChargePoint20::saveUptime() +{ + m_internal_config.setKey(UPTIME_KEY, std::to_string(m_uptime)); + m_internal_config.setKey(DISCONNECTED_TIME_KEY, std::to_string(m_disconnected_time)); + m_internal_config.setKey(TOTAL_UPTIME_KEY, std::to_string(m_total_uptime)); + m_internal_config.setKey(TOTAL_DISCONNECTED_TIME_KEY, std::to_string(m_total_disconnected_time)); +} + +/** @brief Schedule a reconnection to the Central System */ +void ChargePoint20::scheduleReconnect() +{ + // Check if a reconnection is not already scheduled + if (!m_reconnect_scheduled) + { + m_reconnect_scheduled = true; + m_worker_pool->run( + [this] + { + // Wait to let some time to configure other parameters + // => Needed when switching security profiles + std::this_thread::sleep_for(std::chrono::seconds(1u)); + doConnect(); + }); + } +} + +/** @brief Start the connection process to the Central System */ +bool ChargePoint20::doConnect() +{ + // Check if already connected + if (m_rpc_client->isConnected()) + { + // Close connection + m_rpc_client->stop(); + } + + // Get current security profile + unsigned int security_profile = m_stack_config.securityProfile(); + + // Build connection URL + std::string connection_url = m_stack_config.connexionUrl(); + if (connection_url[connection_url.size() - 1] != '/') + { + connection_url += "/"; + } + connection_url += ocpp::websockets::Url::encode(m_stack_config.chargePointIdentifier()); + + // Configure websocket link + ocpp::websockets::IWebsocketClient::Credentials credentials; + + std::string basic_auth_password = m_stack_config.basicAuthPassword(); + if (!basic_auth_password.empty() && (security_profile <= 2)) + { + credentials.user = m_stack_config.chargePointIdentifier(); + credentials.password = basic_auth_password; + } + if (security_profile != 1) + { + credentials.tls12_cipher_list = m_stack_config.tlsv12CipherList(); + credentials.tls13_cipher_list = m_stack_config.tlsv13CipherList(); + + // Use certificates prodivided by the user application + credentials.server_certificate_ca = m_stack_config.tlsServerCertificateCa(); + if ((security_profile == 0) || (security_profile == 3)) + { + credentials.client_certificate = m_stack_config.tlsClientCertificate(); + credentials.client_certificate_private_key = m_stack_config.tlsClientCertificatePrivateKey(); + credentials.client_certificate_private_key_passphrase = m_stack_config.tlsClientCertificatePrivateKeyPassphrase(); + } + credentials.allow_selfsigned_certificates = m_stack_config.tlsAllowSelfSignedCertificates(); + credentials.allow_expired_certificates = m_stack_config.tlsAllowExpiredCertificates(); + credentials.accept_untrusted_certificates = m_stack_config.tlsAcceptNonTrustedCertificates(); + credentials.skip_server_name_check = m_stack_config.tlsSkipServerNameCheck(); + credentials.encoded_pem_certificates = false; + } + + // Start connection process + m_reconnect_scheduled = false; + return m_rpc_client->start(connection_url, + credentials, + m_stack_config.connectionTimeout(), + m_stack_config.retryInterval(), + m_stack_config.webSocketPingInterval()); +} + +} // namespace ocpp20 +} // namespace chargepoint +} // namespace ocpp diff --git a/src/ocpp20/chargepoint/ChargePoint20.h b/src/ocpp20/chargepoint/ChargePoint20.h new file mode 100644 index 00000000..bda22009 --- /dev/null +++ b/src/ocpp20/chargepoint/ChargePoint20.h @@ -0,0 +1,921 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +#ifndef OPENOCPP_OCPP20_CHARGEPOINT20_H +#define OPENOCPP_OCPP20_CHARGEPOINT20_H + +#include "GenericMessageHandler.h" +#include "GenericMessageSender.h" +#include "IChargePoint20.h" +#include "InternalConfigManager.h" +#include "Logger.h" +#include "MessagesConverter20.h" +#include "MessagesValidator20.h" +#include "RpcClient.h" +#include "Timer.h" + +#include +#include + +namespace ocpp +{ +// Forward declarations +namespace messages +{ +class MessageDispatcher; +class GenericMessageSender; +} // namespace messages +namespace websockets +{ +class IWebsocketClient; +} +namespace chargepoint +{ +namespace ocpp20 +{ + +/** @brief Charge point implementation */ +class ChargePoint20 + : public IChargePoint20, + public ocpp::rpc::IRpc::IListener, + public ocpp::rpc::IRpc::ISpy, + public ocpp::rpc::RpcClient::IListener, + + // Central System messages + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler +{ + public: + /** @brief Constructor */ + ChargePoint20(const ocpp::config::IChargePointConfig20& stack_config, + IChargePointEventsHandler20& events_handler, + std::shared_ptr timer_pool, + std::shared_ptr worker_pool, + std::unique_ptr&& messages_converter); + + /** @brief Destructor */ + virtual ~ChargePoint20(); + + // IChargePoint20 interface + + /** @copydoc ocpp::helpers::ITimerPool& IChargePoint20::getTimerPool() */ + ocpp::helpers::ITimerPool& getTimerPool() override { return *m_timer_pool.get(); } + + /** @copydoc ocpp::helpers::WorkerThreadPool& IChargePoint20::getWorkerPool() */ + ocpp::helpers::WorkerThreadPool& getWorkerPool() override { return *m_worker_pool.get(); } + + /** @copydoc bool IChargePoint20::resetData() */ + bool resetData() override; + + /** @copydoc bool IChargePoint20::start() */ + bool start() override; + + /** @copydoc bool IChargePoint20::stop() */ + bool stop() override; + + /** @copydoc bool IChargePoint20::reconnect() */ + bool reconnect() override; + + // RpcClient::IListener interface + + /** @copydoc void RpcClient::IListener::rpcClientConnected() */ + void rpcClientConnected() override; + + /** @copydoc void RpcClient::IListener::rpcClientFailed() */ + void rpcClientFailed() override; + + // IRpc::IListener interface + + /** @copydoc void IRpc::IListener::rpcDisconnected() */ + void rpcDisconnected() override; + + /** @copydoc void IRpc::IListener::rpcError() */ + void rpcError() override; + + /** @copydoc void IRpc::IListener::rpcCallReceived(const std::string&, + const rapidjson::Value&, + rapidjson::Document&, + std::string&, + std::string&) */ + bool rpcCallReceived(const std::string& action, + const rapidjson::Value& payload, + rapidjson::Document& response, + std::string& error_code, + std::string& error_message) override; + + // IRpc::ISpy interface + + /** @copydoc void IRpc::ISpy::rcpMessageReceived(const std::string&) */ + void rcpMessageReceived(const std::string& msg) override; + + /** @copydoc void IRpc::ISpy::rcpMessageSent(const std::string&) */ + void rcpMessageSent(const std::string& msg) override; + + // OCPP operations + + /** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::BootNotificationReq&, + * ocpp::messages::ocpp20::BootNotificationConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::BootNotificationReq& request, + ocpp::messages::ocpp20::BootNotificationConf& response, + std::string& error, + std::string& message) override; + + /** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::AuthorizeReq&, + * ocpp::messages::ocpp20::AuthorizeConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::AuthorizeReq& request, + ocpp::messages::ocpp20::AuthorizeConf& response, + std::string& error, + std::string& message) override; + + /** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::ClearedChargingLimitReq&, + * ocpp::messages::ocpp20::ClearedChargingLimitConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::ClearedChargingLimitReq& request, + ocpp::messages::ocpp20::ClearedChargingLimitConf& response, + std::string& error, + std::string& message) override; + + /** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::CostUpdatedReq&, + * ocpp::messages::ocpp20::CostUpdatedConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::CostUpdatedReq& request, + ocpp::messages::ocpp20::CostUpdatedConf& response, + std::string& error, + std::string& message) override; + + /** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::DataTransferReq&, + * ocpp::messages::ocpp20::DataTransferConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::DataTransferReq& request, + ocpp::messages::ocpp20::DataTransferConf& response, + std::string& error, + std::string& message) override; + + /** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::FirmwareStatusNotificationReq&, + * ocpp::messages::ocpp20::FirmwareStatusNotificationConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::FirmwareStatusNotificationReq& request, + ocpp::messages::ocpp20::FirmwareStatusNotificationConf& response, + std::string& error, + std::string& message) override; + + /** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::HeartbeatReq&, + * ocpp::messages::ocpp20::HeartbeatConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::HeartbeatReq& request, + ocpp::messages::ocpp20::HeartbeatConf& response, + std::string& error, + std::string& message) override; + + /** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::LogStatusNotificationReq&, + * ocpp::messages::ocpp20::LogStatusNotificationConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::LogStatusNotificationReq& request, + ocpp::messages::ocpp20::LogStatusNotificationConf& response, + std::string& error, + std::string& message) override; + + /** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::MeterValuesReq&, + * ocpp::messages::ocpp20::MeterValuesConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::MeterValuesReq& request, + ocpp::messages::ocpp20::MeterValuesConf& response, + std::string& error, + std::string& message) override; + + /** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::NotifyChargingLimitReq&, + * ocpp::messages::ocpp20::NotifyChargingLimitConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::NotifyChargingLimitReq& request, + ocpp::messages::ocpp20::NotifyChargingLimitConf& response, + std::string& error, + std::string& message) override; + + /** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::NotifyCustomerInformationReq&, + * ocpp::messages::ocpp20::NotifyCustomerInformationConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::NotifyCustomerInformationReq& request, + ocpp::messages::ocpp20::NotifyCustomerInformationConf& response, + std::string& error, + std::string& message) override; + + /** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::NotifyDisplayMessagesReq&, + * ocpp::messages::ocpp20::NotifyDisplayMessagesConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::NotifyDisplayMessagesReq& request, + ocpp::messages::ocpp20::NotifyDisplayMessagesConf& response, + std::string& error, + std::string& message) override; + + /** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::NotifyEVChargingNeedsReq&, + * ocpp::messages::ocpp20::NotifyEVChargingNeedsConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::NotifyEVChargingNeedsReq& request, + ocpp::messages::ocpp20::NotifyEVChargingNeedsConf& response, + std::string& error, + std::string& message) override; + + /** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::NotifyEVChargingScheduleReq&, + * ocpp::messages::ocpp20::NotifyEVChargingScheduleConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::NotifyEVChargingScheduleReq& request, + ocpp::messages::ocpp20::NotifyEVChargingScheduleConf& response, + std::string& error, + std::string& message) override; + + /** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::NotifyEventReq&, + * ocpp::messages::ocpp20::NotifyEventConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::NotifyEventReq& request, + ocpp::messages::ocpp20::NotifyEventConf& response, + std::string& error, + std::string& message) override; + + /** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::NotifyMonitoringReportReq&, + * ocpp::messages::ocpp20::NotifyMonitoringReportConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::NotifyMonitoringReportReq& request, + ocpp::messages::ocpp20::NotifyMonitoringReportConf& response, + std::string& error, + std::string& message) override; + + /** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::NotifyReportReq&, + * ocpp::messages::ocpp20::NotifyReportConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::NotifyReportReq& request, + ocpp::messages::ocpp20::NotifyReportConf& response, + std::string& error, + std::string& message) override; + + /** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::PublishFirmwareStatusNotificationReq&, + * ocpp::messages::ocpp20::PublishFirmwareStatusNotificationConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::PublishFirmwareStatusNotificationReq& request, + ocpp::messages::ocpp20::PublishFirmwareStatusNotificationConf& response, + std::string& error, + std::string& message) override; + + /** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::ReportChargingProfilesReq&, + * ocpp::messages::ocpp20::ReportChargingProfilesConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::ReportChargingProfilesReq& request, + ocpp::messages::ocpp20::ReportChargingProfilesConf& response, + std::string& error, + std::string& message) override; + + /** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::ReservationStatusUpdateReq&, + * ocpp::messages::ocpp20::ReservationStatusUpdateConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::ReservationStatusUpdateReq& request, + ocpp::messages::ocpp20::ReservationStatusUpdateConf& response, + std::string& error, + std::string& message) override; + + /** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::SecurityEventNotificationReq&, + * ocpp::messages::ocpp20::SecurityEventNotificationConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::SecurityEventNotificationReq& request, + ocpp::messages::ocpp20::SecurityEventNotificationConf& response, + std::string& error, + std::string& message) override; + + /** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::SignCertificateReq&, + * ocpp::messages::ocpp20::SignCertificateConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::SignCertificateReq& request, + ocpp::messages::ocpp20::SignCertificateConf& response, + std::string& error, + std::string& message) override; + + /** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::StatusNotificationReq&, + * ocpp::messages::ocpp20::StatusNotificationConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::StatusNotificationReq& request, + ocpp::messages::ocpp20::StatusNotificationConf& response, + std::string& error, + std::string& message) override; + + /** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::TransactionEventReq&, + * ocpp::messages::ocpp20::TransactionEventConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::TransactionEventReq& request, + ocpp::messages::ocpp20::TransactionEventConf& response, + std::string& error, + std::string& message) override; + + // OCPP handlers + + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::CancelReservationReq& request, + ocpp::messages::ocpp20::CancelReservationConf& response, + std::string& error_code, + std::string& error_message) override; + + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::CertificateSignedReq& request, + ocpp::messages::ocpp20::CertificateSignedConf& response, + std::string& error_code, + std::string& error_message) override; + + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::ChangeAvailabilityReq& request, + ocpp::messages::ocpp20::ChangeAvailabilityConf& response, + std::string& error_code, + std::string& error_message) override; + + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::ClearCacheReq& request, + ocpp::messages::ocpp20::ClearCacheConf& response, + std::string& error_code, + std::string& error_message) override; + + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::ClearChargingProfileReq& request, + ocpp::messages::ocpp20::ClearChargingProfileConf& response, + std::string& error_code, + std::string& error_message) override; + + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::ClearDisplayMessageReq& request, + ocpp::messages::ocpp20::ClearDisplayMessageConf& response, + std::string& error_code, + std::string& error_message) override; + + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::ClearVariableMonitoringReq& request, + ocpp::messages::ocpp20::ClearVariableMonitoringConf& response, + std::string& error_code, + std::string& error_message) override; + + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::CustomerInformationReq& request, + ocpp::messages::ocpp20::CustomerInformationConf& response, + std::string& error_code, + std::string& error_message) override; + + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::DataTransferReq& request, + ocpp::messages::ocpp20::DataTransferConf& response, + std::string& error_code, + std::string& error_message) override; + + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::DeleteCertificateReq& request, + ocpp::messages::ocpp20::DeleteCertificateConf& response, + std::string& error_code, + std::string& error_message) override; + + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::Get15118EVCertificateReq& request, + ocpp::messages::ocpp20::Get15118EVCertificateConf& response, + std::string& error_code, + std::string& error_message) override; + + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::GetBaseReportReq& request, + ocpp::messages::ocpp20::GetBaseReportConf& response, + std::string& error_code, + std::string& error_message) override; + + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::GetCertificateStatusReq& request, + ocpp::messages::ocpp20::GetCertificateStatusConf& response, + std::string& error_code, + std::string& error_message) override; + + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::GetChargingProfilesReq& request, + ocpp::messages::ocpp20::GetChargingProfilesConf& response, + std::string& error_code, + std::string& error_message) override; + + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::GetCompositeScheduleReq& request, + ocpp::messages::ocpp20::GetCompositeScheduleConf& response, + std::string& error_code, + std::string& error_message) override; + + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::GetDisplayMessagesReq& request, + ocpp::messages::ocpp20::GetDisplayMessagesConf& response, + std::string& error_code, + std::string& error_message) override; + + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::GetInstalledCertificateIdsReq& request, + ocpp::messages::ocpp20::GetInstalledCertificateIdsConf& response, + std::string& error_code, + std::string& error_message) override; + + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::GetLocalListVersionReq& request, + ocpp::messages::ocpp20::GetLocalListVersionConf& response, + std::string& error_code, + std::string& error_message) override; + + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::GetLogReq& request, + ocpp::messages::ocpp20::GetLogConf& response, + std::string& error_code, + std::string& error_message) override; + + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::GetMonitoringReportReq& request, + ocpp::messages::ocpp20::GetMonitoringReportConf& response, + std::string& error_code, + std::string& error_message) override; + + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::GetReportReq& request, + ocpp::messages::ocpp20::GetReportConf& response, + std::string& error_code, + std::string& error_message) override; + + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::GetTransactionStatusReq& request, + ocpp::messages::ocpp20::GetTransactionStatusConf& response, + std::string& error_code, + std::string& error_message) override; + + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::GetVariablesReq& request, + ocpp::messages::ocpp20::GetVariablesConf& response, + std::string& error_code, + std::string& error_message) override; + + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::InstallCertificateReq& request, + ocpp::messages::ocpp20::InstallCertificateConf& response, + std::string& error_code, + std::string& error_message) override; + + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::PublishFirmwareReq& request, + ocpp::messages::ocpp20::PublishFirmwareConf& response, + std::string& error_code, + std::string& error_message) override; + + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::RequestStartTransactionReq& request, + ocpp::messages::ocpp20::RequestStartTransactionConf& response, + std::string& error_code, + std::string& error_message) override; + + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::RequestStopTransactionReq& request, + ocpp::messages::ocpp20::RequestStopTransactionConf& response, + std::string& error_code, + std::string& error_message) override; + + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::ReserveNowReq& request, + ocpp::messages::ocpp20::ReserveNowConf& response, + std::string& error_code, + std::string& error_message) override; + + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::ResetReq& request, + ocpp::messages::ocpp20::ResetConf& response, + std::string& error_code, + std::string& error_message) override; + + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::SendLocalListReq& request, + ocpp::messages::ocpp20::SendLocalListConf& response, + std::string& error_code, + std::string& error_message) override; + + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::SetChargingProfileReq& request, + ocpp::messages::ocpp20::SetChargingProfileConf& response, + std::string& error_code, + std::string& error_message) override; + + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::SetDisplayMessageReq& request, + ocpp::messages::ocpp20::SetDisplayMessageConf& response, + std::string& error_code, + std::string& error_message) override; + + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::SetMonitoringBaseReq& request, + ocpp::messages::ocpp20::SetMonitoringBaseConf& response, + std::string& error_code, + std::string& error_message) override; + + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::SetMonitoringLevelReq& request, + ocpp::messages::ocpp20::SetMonitoringLevelConf& response, + std::string& error_code, + std::string& error_message) override; + + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::SetNetworkProfileReq& request, + ocpp::messages::ocpp20::SetNetworkProfileConf& response, + std::string& error_code, + std::string& error_message) override; + + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::SetVariableMonitoringReq& request, + ocpp::messages::ocpp20::SetVariableMonitoringConf& response, + std::string& error_code, + std::string& error_message) override; + + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::SetVariablesReq& request, + ocpp::messages::ocpp20::SetVariablesConf& response, + std::string& error_code, + std::string& error_message) override; + + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::TriggerMessageReq& request, + ocpp::messages::ocpp20::TriggerMessageConf& response, + std::string& error_code, + std::string& error_message) override; + + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::UnlockConnectorReq& request, + ocpp::messages::ocpp20::UnlockConnectorConf& response, + std::string& error_code, + std::string& error_message) override; + + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::UnpublishFirmwareReq& request, + ocpp::messages::ocpp20::UnpublishFirmwareConf& response, + std::string& error_code, + std::string& error_message) override; + + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::UpdateFirmwareReq& request, + ocpp::messages::ocpp20::UpdateFirmwareConf& response, + std::string& error_code, + std::string& error_message) override; + + private: + /** @brief Stack configuration */ + const ocpp::config::IChargePointConfig20& m_stack_config; + /** @brief User defined events handler */ + IChargePointEventsHandler20& m_events_handler; + + /** @brief Timer pool */ + std::shared_ptr m_timer_pool; + /** @brief Worker thread pool */ + std::shared_ptr m_worker_pool; + + /** @brief Database */ + ocpp::database::Database m_database; + /** @brief Internal configuration manager */ + ocpp::config::InternalConfigManager m_internal_config; + + /** @brief Messages converter */ + std::unique_ptr m_messages_converter; + /** @brief Messaes validator */ + ocpp::messages::ocpp20::MessagesValidator20 m_messages_validator; + /** @brief Indicate that a stop process is in progress */ + std::atomic m_stop_in_progress; + /** @brief Indicate that a reconnection process has been scheduled */ + std::atomic m_reconnect_scheduled; + + /** @brief Websocket s*/ + std::unique_ptr m_ws_client; + /** @brief RPC client */ + std::unique_ptr m_rpc_client; + /** @brief Message dispatcher */ + std::unique_ptr m_msg_dispatcher; + /** @brief Message sender */ + std::unique_ptr m_msg_sender; + + /** @brief Uptime timer */ + ocpp::helpers::Timer m_uptime_timer; + /** @brief Uptime in seconds */ + unsigned int m_uptime; + /** @brief Disconnected time in seconds */ + unsigned int m_disconnected_time; + /** @brief Total uptime in seconds */ + unsigned int m_total_uptime; + /** @brief Total disconnected time in seconds */ + unsigned int m_total_disconnected_time; + + /** @brief Initialize the database */ + void initDatabase(); + /** @brief Process uptime */ + void processUptime(); + /** @brief Save the uptime counter in database */ + void saveUptime(); + + /** @brief Schedule a reconnection to the Central System */ + void scheduleReconnect(); + /** @brief Start the connection process to the Central System */ + bool doConnect(); + + /** + * @brief Execute a call request + * @param action RPC action for the request + * @param request Request payload + * @param response Response payload + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + template + bool call(const std::string& action, const RequestType& request, ResponseType& response, std::string& error, std::string& message) + { + bool ret = false; + + std::string identifier = m_stack_config.chargePointIdentifier(); + LOG_DEBUG << "[" << identifier << "] - " << action; + + if (m_msg_sender && !m_stop_in_progress) + { + ocpp::messages::CallResult res = m_msg_sender->call(action, request, response, error, message); + if (res != ocpp::messages::CallResult::Ok) + { + LOG_ERROR << "[" << identifier << "] - " << action << " => " + << (res == ocpp::messages::CallResult::Failed ? "Timeout" : "Error"); + } + else + { + ret = true; + } + } + + return ret; + } +}; + +} // namespace ocpp20 +} // namespace chargepoint +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_CHARGEPOINT20_H diff --git a/src/ocpp20/chargepoint/config/InternalConfigKeys.h b/src/ocpp20/chargepoint/config/InternalConfigKeys.h new file mode 100644 index 00000000..768015ba --- /dev/null +++ b/src/ocpp20/chargepoint/config/InternalConfigKeys.h @@ -0,0 +1,50 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +#ifndef OPENOCPP_OCPP20_INTERNALCONFIGKEYS_H +#define OPENOCPP_OCPP20_INTERNALCONFIGKEYS_H + +namespace ocpp +{ +namespace chargepoint +{ +namespace ocpp20 +{ + +/** @brief Configuration key : stack version */ +static constexpr const char* STACK_VERSION_KEY = "StackVersion"; +/** @brief Configuration key : last start date */ +static constexpr const char* START_DATE_KEY = "LastSessionStartDate"; +/** @brief Configuration key : uptime */ +static constexpr const char* UPTIME_KEY = "LastSessionUpTime"; +/** @brief Configuration key : disconnected time */ +static constexpr const char* DISCONNECTED_TIME_KEY = "LastSessionDisconnectedTime"; +/** @brief Configuration key : total uptime */ +static constexpr const char* TOTAL_UPTIME_KEY = "TotalUpTime"; +/** @brief Configuration key : total disconnected time */ +static constexpr const char* TOTAL_DISCONNECTED_TIME_KEY = "TotalDisconnectedTime"; +/** @brief Configuration key : last connection URL */ +static constexpr const char* LAST_CONNECTION_URL_KEY = "LastConnectionUrl"; +/** @brief Configuration key : last registration status */ +static constexpr const char* LAST_REGISTRATION_STATUS_KEY = "LastRegistrationStatus"; + +} // namespace ocpp20 +} // namespace chargepoint +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_INTERNALCONFIGKEYS_H diff --git a/src/ocpp20/chargepoint/connector/Connector20.h b/src/ocpp20/chargepoint/connector/Connector20.h new file mode 100644 index 00000000..ed713dc0 --- /dev/null +++ b/src/ocpp20/chargepoint/connector/Connector20.h @@ -0,0 +1,68 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +#ifndef OPENOCPP_OCPP20_CONNECTOR20_H +#define OPENOCPP_OCPP20_CONNECTOR20_H + +#include "ConnectorStatusEnumType20.h" +#include "DateTime.h" + +#include +#include + +namespace ocpp +{ +namespace chargepoint +{ +namespace ocpp20 +{ + +/** @brief Contains the state of a connector in an EVSE of a Charge Point */ +struct Connector +{ + /** @brief Constructor */ + Connector(unsigned int _id, std::mutex& _mutex) + : id(_id), + mutex(_mutex), + status(ocpp::types::ocpp20::ConnectorStatusEnumType::Available), + status_timestamp(ocpp::types::DateTime::now()), + last_notified_status(status) + { + } + + /** @brief Id */ + unsigned int id; + + /** @brief Mutex to protect concurrent access */ + std::mutex& mutex; + + // Status notification data + + /** @brief Status */ + ocpp::types::ocpp20::ConnectorStatusEnumType status; + /** @brief Timestamp of the last status notification */ + ocpp::types::DateTime status_timestamp; + /** @brief Last status notified to the central system */ + ocpp::types::ocpp20::ConnectorStatusEnumType last_notified_status; +}; + +} // namespace ocpp20 +} // namespace chargepoint +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_CONNECTOR20_H diff --git a/src/ocpp20/chargepoint/connector/Connectors20.cpp b/src/ocpp20/chargepoint/connector/Connectors20.cpp new file mode 100644 index 00000000..0b94c905 --- /dev/null +++ b/src/ocpp20/chargepoint/connector/Connectors20.cpp @@ -0,0 +1,465 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +#include "Connectors20.h" +#include "Logger.h" + +using namespace ocpp::types; +using namespace ocpp::types::ocpp20; + +namespace ocpp +{ +namespace chargepoint +{ +namespace ocpp20 +{ + +/** @brief Constructor */ +Connectors::Connectors(IDeviceModel& device_model, ocpp::database::Database& database, ocpp::helpers::ITimerPool& timer_pool) + : m_device_model(device_model), + m_database(database), + m_timer_pool(timer_pool), + m_evses(), + m_evse_find_query(), + m_evse_insert_query(), + m_evse_update_query(), + m_connector_find_query(), + m_connector_insert_query(), + m_connector_update_query() +{ +} + +/** @brief Destructor */ +Connectors::~Connectors() +{ + releaseEvseLayout(); +} + +/** @copydoc Evse* IConnectors::getEvse(unsigned int) */ +Evse* Connectors::getEvse(unsigned int id) +{ + Evse* evse = nullptr; + if ((id > 0) && (id <= m_evses.size())) + { + evse = m_evses[id - 1u]; + } + return evse; +} + +/** @copydoc Evse* IConnectors::getEvse(unsigned int) */ +const Evse* Connectors::getEvse(unsigned int id) const +{ + Connectors* non_const_this = const_cast(this); + return non_const_this->getEvse(id); +} + +/** @copydoc Connector* IConnectors::getConnector(unsigned int, unsigned int) */ +Connector* Connectors::getConnector(unsigned int evse_id, unsigned int id) +{ + Connector* connector = nullptr; + Evse* evse = getEvse(evse_id); + if (evse) + { + if ((id > 0) && (id <= evse->connectors.size())) + { + connector = evse->connectors[id - 1u]; + } + } + return connector; +} + +/** @copydoc const std::vector* IConnectors::getConnectors(unsigned int) */ +const std::vector* Connectors::getConnectors(unsigned int id) const +{ + const std::vector* connectors = nullptr; + const Evse* evse = getEvse(id); + if (evse) + { + connectors = &evse->connectors; + } + return connectors; +} + +/** @copydoc bool IConnectors::saveEvse(unsigned int) */ +bool Connectors::saveEvse(unsigned int evse_id) +{ + bool ret = false; + + Evse* evse = getEvse(evse_id); + if (evse) + { + saveEvse(*evse); + ret = true; + } + + return ret; +} + +/** @copydoc bool IConnectors::saveConnector(unsigned int, unsigned int) */ +bool Connectors::saveConnector(unsigned int evse_id, unsigned int id) +{ + bool ret = false; + + Evse* evse = getEvse(evse_id); + Connector* connector = getConnector(evse_id, id); + if (evse && connector) + { + saveConnector(*evse, *connector); + ret = true; + } + + return ret; +} + +/** @copydoc void IConnectors::resetConnectors() */ +void Connectors::resetConnectors() +{ + // Delete all EVSE data in memory + releaseEvseLayout(); + + // Delete database data + auto query = m_database.query("DELETE FROM Evses WHERE TRUE;"); + if (query) + { + query->exec(); + } + query = m_database.query("DELETE FROM Connectors WHERE TRUE;"); + if (query) + { + query->exec(); + } + + // Load the EVSEs layout from the device model + loadEvsesLayout(); + + // Load the connectors state + loadConnectors(); +} + +/** @brief Initialize the database table */ +void Connectors::initDatabaseTable() +{ + // Delete all EVSE data in memory + releaseEvseLayout(); + + // Init EVSEs and connectors tables + initEvsesTable(); + initConnectorsTable(); + + // Load the EVSEs layout from the device model + loadEvsesLayout(); + + // Load the connectors state + loadConnectors(); +} + +/** @brief Release EVSE layout memory */ +void Connectors::releaseEvseLayout() +{ + for (auto& evse : m_evses) + { + for (auto& connector : evse->connectors) + { + delete connector; + } + delete evse; + } + m_evses.clear(); +} + +/** @brief Initialize the EVSE table */ +void Connectors::initEvsesTable() +{ + // Create database + auto query = m_database.query("CREATE TABLE IF NOT EXISTS Evses (" + "[id] INT UNSIGNED," + "[status] INT," + "[transaction_id] VARCHAR(36)," + "[transaction_id_offline] VARCHAR(36)," + "[transaction_start] BIGINT," + "[transaction_id_token] VARCHAR(36)," + "[transaction_group_id_token] VARCHAR(36)," + "PRIMARY KEY([id]));"); + if (query) + { + if (!query->exec()) + { + LOG_ERROR << "Could not create EVSEs table : " << query->lastError(); + } + } + + // Create parametrized queries + m_evse_find_query = m_database.query("SELECT * FROM Evses WHERE id=?;"); + m_evse_insert_query = m_database.query("INSERT INTO Evses VALUES (?, ?, ?, ?, ?, ?, ?);"); + m_evse_update_query = m_database.query("UPDATE Evses SET [status]=?, [transaction_id]=?, " + "[transaction_id_offline]=?, [transaction_start]=?, [transaction_id_token]=?, " + "[transaction_group_id_token]=? WHERE id=?;"); +} + +/** @brief Initialize the connectors table */ +void Connectors::initConnectorsTable() +{ + // Create database + auto query = m_database.query("CREATE TABLE IF NOT EXISTS Connectors (" + "[evse_id] INT UNSIGNED," + "[id] INT UNSIGNED," + "[status] INT," + "PRIMARY KEY([id],[evse_id]));"); + if (query) + { + if (!query->exec()) + { + LOG_ERROR << "Could not create connectors table : " << query->lastError(); + } + } + + // Create parametrized queries + m_connector_find_query = m_database.query("SELECT * FROM Connectors WHERE evse_id=? AND id=?;"); + m_connector_insert_query = m_database.query("INSERT INTO Connectors VALUES (?, ?, ?);"); + m_connector_update_query = m_database.query("UPDATE Connectors SET [status]=? WHERE evse_id=? AND id=?;"); +} + +/** @brief Load the EVSEs layout from the device model */ +void Connectors::loadEvsesLayout() +{ + // Load EVSEs + unsigned int evse_count = 0u; + bool end = false; + do + { + GetVariableDataType requested_var; + requested_var.component.name.assign("EVSE"); + requested_var.component.evse.value().id = evse_count + 1u; + requested_var.variable.name.assign("Available"); + GetVariableResultType var = m_device_model.getVariable(requested_var); + if ((var.attributeStatus == GetVariableStatusEnumType::Accepted) && (var.attributeValue.value().str() == "true")) + { + evse_count++; + } + else + { + end = true; + } + } while (!end); + + // Load connectors + for (unsigned evse_id = 1u; evse_id <= evse_count; evse_id++) + { + unsigned int connector_count = 0u; + end = false; + do + { + GetVariableDataType requested_var; + requested_var.component.name.assign("Connector"); + requested_var.component.evse.value().id = evse_id; + requested_var.component.evse.value().connectorId.value() = connector_count + 1u; + requested_var.variable.name.assign("Available"); + GetVariableResultType var = m_device_model.getVariable(requested_var); + if ((var.attributeStatus == GetVariableStatusEnumType::Accepted) && (var.attributeValue.value().str() == "true")) + { + connector_count++; + } + else + { + end = true; + } + } while (!end); + + m_evses.push_back(new Evse(evse_id, m_timer_pool, connector_count)); + } + + LOG_INFO << m_evses.size() << " EVSE(s) found in device model"; + for (const auto& evse : m_evses) + { + LOG_INFO << "EVSE " << evse->id << ": " << evse->connectors.size() << " connector(s)"; + } +} + +/** @brief Load the connectors states from the database */ +void Connectors::loadConnectors() +{ + // Check the number of EVSEs in database + unsigned int count = 0; + auto query = m_database.query("SELECT count(id) FROM Evses WHERE TRUE;"); + if (query && query->exec()) + { + count = query->getUInt32(0); + query->reset(); + } + if (count != m_evses.size()) + { + // Reset all database data + LOG_WARNING << count << " EVSE(s) found in database / " << m_evses.size() + << " EVSE(s) declared in device model, reset all connectors data in database"; + query = m_database.query("DELETE FROM Evses WHERE TRUE;"); + if (query) + { + query->exec(); + } + query = m_database.query("DELETE FROM Connectors WHERE TRUE;"); + if (query) + { + query->exec(); + } + } + + // Load EVSEs data from database + for (auto& evse : m_evses) + { + loadEvse(*evse); + } +} + +/** @brief Load the state of an EVSE from the database */ +void Connectors::loadEvse(Evse& evse) +{ + if (m_evse_find_query && m_evse_insert_query) + { + // Check if the EVSE exists in database + m_evse_find_query->bind(0, evse.id); + if (m_evse_find_query->exec() && m_evse_find_query->hasRows()) + { + // Check the number of connectors in database + unsigned int count = 0; + auto query = m_database.query("SELECT count(id) FROM Connectors WHERE evse_id=?;"); + if (query) + { + query->bind(0, evse.id); + if (query->exec()) + { + count = query->getUInt32(0); + } + } + if (count != evse.connectors.size()) + { + // Reset EVSE connector database data + LOG_WARNING << count << " connector(s) found in database for EVSE " << evse.id << " / " << evse.connectors.size() + << " connector(s) declared in device model, reset all connectors data in database for this EVSE"; + query = m_database.query("DELETE FROM Connectors WHERE evse_id=?;"); + if (query) + { + query->bind(0, evse.id); + query->exec(); + } + } + + // Load EVSE data + evse.status = static_cast(m_evse_find_query->getInt32(1u)); + evse.transaction_id = m_evse_find_query->getString(2u); + evse.transaction_id_offline = m_evse_find_query->getString(3u); + evse.transaction_start = static_cast(m_evse_find_query->getInt64(4u)); + evse.transaction_id_token = m_evse_find_query->getString(5u); + evse.transaction_group_id_token = m_evse_find_query->getString(6u); + } + else + { + // Create EVSE + m_evse_insert_query->bind(0u, evse.id); + m_evse_insert_query->bind(1u, static_cast(evse.status)); + m_evse_insert_query->bind(2u, evse.transaction_id); + m_evse_insert_query->bind(3u, evse.transaction_id_offline); + m_evse_insert_query->bind(4u, static_cast(evse.transaction_start)); + m_evse_insert_query->bind(5u, evse.transaction_id_token); + m_evse_insert_query->bind(6u, evse.transaction_group_id_token); + m_evse_insert_query->exec(); + m_evse_insert_query->reset(); + } + m_evse_find_query->reset(); + } + + // Load connectors data from database + for (auto& connector : evse.connectors) + { + loadConnector(evse, *connector); + } +} + +/** @brief Load the state of a connector from the database */ +void Connectors::loadConnector(Evse& evse, Connector& connector) +{ + if (m_connector_find_query && m_connector_insert_query) + { + // Check if the connector exists in database + m_connector_find_query->bind(0, evse.id); + m_connector_find_query->bind(1, connector.id); + if (m_connector_find_query->exec() && m_connector_find_query->hasRows()) + { + // Load connector data + connector.status = static_cast(m_connector_find_query->getInt32(2u)); + } + else + { + // Create connector + m_connector_insert_query->bind(0u, evse.id); + m_connector_insert_query->bind(1u, connector.id); + m_connector_insert_query->bind(2u, static_cast(connector.status)); + m_connector_insert_query->exec(); + m_connector_insert_query->reset(); + } + m_connector_find_query->reset(); + } +} + +/** @brief Save the state of an EVSE to the database */ +void Connectors::saveEvse(const Evse& evse) +{ + if (m_evse_update_query) + { + m_evse_update_query->bind(0u, static_cast(evse.status)); + m_evse_update_query->bind(1u, evse.transaction_id); + m_evse_update_query->bind(2u, evse.transaction_id_offline); + m_evse_update_query->bind(3u, static_cast(evse.transaction_start.timestamp())); + m_evse_update_query->bind(4u, evse.transaction_id_token); + m_evse_update_query->bind(5u, evse.transaction_group_id_token); + m_evse_update_query->bind(6u, evse.id); + if (m_evse_update_query->exec()) + { + LOG_DEBUG << "EVSE " << evse.id << " updated in database"; + } + else + { + LOG_ERROR << "Could not update EVSE " << evse.id << " : " << m_connector_update_query->lastError(); + } + m_evse_update_query->reset(); + } +} + +/** @brief Save the state of a connector to the database */ +void Connectors::saveConnector(const Evse& evse, const Connector& connector) +{ + if (m_connector_update_query) + { + m_connector_update_query->bind(0u, static_cast(connector.status)); + m_connector_update_query->bind(1u, evse.id); + m_connector_update_query->bind(2u, connector.id); + if (m_connector_update_query->exec()) + { + LOG_DEBUG << "EVSE " << evse.id << " Connector " << connector.id << " updated in database"; + } + else + { + LOG_ERROR << "Could not update EVSE " << evse.id << " Connector " << connector.id << " : " + << m_connector_update_query->lastError(); + } + m_connector_update_query->reset(); + } +} + +} // namespace ocpp20 +} // namespace chargepoint +} // namespace ocpp diff --git a/src/ocpp20/chargepoint/connector/Connectors20.h b/src/ocpp20/chargepoint/connector/Connectors20.h new file mode 100644 index 00000000..d530bc08 --- /dev/null +++ b/src/ocpp20/chargepoint/connector/Connectors20.h @@ -0,0 +1,123 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +#ifndef OPENOCPP_OCPP20_CONNECTORS20_H +#define OPENOCPP_OCPP20_CONNECTORS20_H + +#include "Database.h" +#include "IConnectors20.h" +#include "IDeviceModel20.h" + +namespace ocpp +{ +namespace chargepoint +{ +namespace ocpp20 +{ + +/** @brief Manage the EVSE and their connectors of a Charge Point */ +class Connectors : public IConnectors +{ + public: + /** @brief Constructor */ + Connectors(IDeviceModel& device_model, ocpp::database::Database& database, ocpp::helpers::ITimerPool& timer_pool); + + /** @brief Destructor */ + virtual ~Connectors(); + + /** @copydoc Evse* IConnectors::getEvse(unsigned int) */ + Evse* getEvse(unsigned int id) override; + + /** @copydoc Evse* IConnectors::getEvse(unsigned int) */ + const Evse* getEvse(unsigned int id) const override; + + /** @copydoc Connector* IConnectors::getConnector(unsigned int, unsigned int) */ + Connector* getConnector(unsigned int evse_id, unsigned int id) override; + + /** @copydoc const std::vector& IConnectors::getEvses() */ + const std::vector& getEvses() const override { return m_evses; } + + /** @copydoc const std::vector* IConnectors::getConnectors(unsigned int) */ + const std::vector* getConnectors(unsigned int id) const override; + + /** @copydoc bool IConnectors::saveEvse(unsigned int) */ + bool saveEvse(unsigned int evse_id) override; + + /** @copydoc bool IConnectors::saveConnector(unsigned int, unsigned int) */ + bool saveConnector(unsigned int evse_id, unsigned int id) override; + + /** @copydoc void IConnectors::resetConnectors() */ + void resetConnectors() override; + + /** @brief Initialize the database table */ + void initDatabaseTable(); + + private: + /** @brief Device model */ + IDeviceModel& m_device_model; + /** @brief Charge point's database */ + ocpp::database::Database& m_database; + /** @brief Timer pool */ + ocpp::helpers::ITimerPool& m_timer_pool; + + /** @brief List of available EVSEs */ + std::vector m_evses; + + /** @brief Query to look for an EVSE */ + std::unique_ptr m_evse_find_query; + /** @brief Query to insert an EVSE */ + std::unique_ptr m_evse_insert_query; + /** @brief Query to update an EVSE */ + std::unique_ptr m_evse_update_query; + + /** @brief Query to look for a connector */ + std::unique_ptr m_connector_find_query; + /** @brief Query to insert a connector */ + std::unique_ptr m_connector_insert_query; + /** @brief Query to update a connector */ + std::unique_ptr m_connector_update_query; + + /** @brief Release EVSE layout memory */ + void releaseEvseLayout(); + + /** @brief Initialize the EVSE table */ + void initEvsesTable(); + /** @brief Initialize the connectors table */ + void initConnectorsTable(); + + /** @brief Load the EVSEs layout from the device model */ + void loadEvsesLayout(); + /** @brief Load the connectors states from the database */ + void loadConnectors(); + + /** @brief Load the state of an EVSE from the database */ + void loadEvse(Evse& evse); + /** @brief Load the state of a connector from the database */ + void loadConnector(Evse& evse, Connector& connector); + + /** @brief Save the state of an EVSE to the database */ + void saveEvse(const Evse& evse); + /** @brief Save the state of a connector to the database */ + void saveConnector(const Evse& evse, const Connector& connector); +}; + +} // namespace ocpp20 +} // namespace chargepoint +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_CONNECTORS20_H diff --git a/src/ocpp20/chargepoint/connector/Evse20.h b/src/ocpp20/chargepoint/connector/Evse20.h new file mode 100644 index 00000000..7edd0cc9 --- /dev/null +++ b/src/ocpp20/chargepoint/connector/Evse20.h @@ -0,0 +1,94 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +#ifndef OPENOCPP_OCPP20_EVSE20_H +#define OPENOCPP_OCPP20_EVSE20_H + +#include "Connector20.h" +#include "Timer.h" + +namespace ocpp +{ +namespace chargepoint +{ +namespace ocpp20 +{ + +/** @brief Contains the state of an EVSE in a Charge Point */ +struct Evse +{ + /** @brief Constructor */ + Evse(unsigned int _id, ocpp::helpers::ITimerPool& timer_pool, unsigned int connectors_count) + : id(_id), + mutex(), + connectors(), + status(ocpp::types::ocpp20::ConnectorStatusEnumType::Available), + status_timestamp(ocpp::types::DateTime::now()), + transaction_id(), + transaction_id_offline(), + transaction_start(), + transaction_id_token(), + transaction_group_id_token(), + meter_values_timer(timer_pool) + { + for (unsigned int i = 1u; i <= connectors_count; i++) + { + connectors.push_back(new Connector(i, mutex)); + } + } + + /** @brief Id */ + unsigned int id; + + /** @brief Mutex to protect concurrent access */ + mutable std::mutex mutex; + + /** @brief Connectors */ + std::vector connectors; + + // Status notification data + + /** @brief Status */ + ocpp::types::ocpp20::ConnectorStatusEnumType status; + /** @brief Timestamp of the last status notification */ + ocpp::types::DateTime status_timestamp; + + // Transaction data + + /** @brief Current transaction id */ + std::string transaction_id; + /** @brief Transaction id for offline transactions */ + std::string transaction_id_offline; + /** @brief Start of transaction */ + ocpp::types::DateTime transaction_start; + /** @brief Identifier associated with the transaction */ + std::string transaction_id_token; + /** @brief Group identifier associated with the transaction */ + std::string transaction_group_id_token; + + // Meter values + + /** @brief Timer for sampled meter values */ + ocpp::helpers::Timer meter_values_timer; +}; + +} // namespace ocpp20 +} // namespace chargepoint +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_EVSE20_H diff --git a/src/ocpp20/chargepoint/connector/IConnectors20.h b/src/ocpp20/chargepoint/connector/IConnectors20.h new file mode 100644 index 00000000..ebf70d03 --- /dev/null +++ b/src/ocpp20/chargepoint/connector/IConnectors20.h @@ -0,0 +1,98 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +#ifndef OPENOCPP_OCPP20_ICONNECTORS20_H +#define OPENOCPP_OCPP20_ICONNECTORS20_H + +#include "Evse20.h" + +#include + +namespace ocpp +{ +namespace chargepoint +{ +namespace ocpp20 +{ + +/** @brief Interface for the component which manages the EVSE and their connectors of a Charge Point */ +class IConnectors +{ + public: + /** @brief Destructor */ + virtual ~IConnectors() { } + + /** + * @brief Get the EVSE with the specified id + * @param id Id of the EVSE + * @return Requested EVSE if it exists, nullptr otherwise + */ + virtual Evse* getEvse(unsigned int id) = 0; + + /** + * @brief Get the EVSE with the specified id + * @param id Id of the EVSE + * @return Requested EVSE if it exists, nullptr otherwise + */ + virtual const Evse* getEvse(unsigned int id) const = 0; + + /** + * @brief Get the connector with the specified id + * @param evse_id Id of the EVSE of the connector + * @param id Id of the connector + * @return Requested connector if it exists, nullptr otherwise + */ + virtual Connector* getConnector(unsigned int evse_id, unsigned int id) = 0; + + /** + * @brief Get the list of the EVSEs + * @return List of the EVSEs + */ + virtual const std::vector& getEvses() const = 0; + + /** + * @brief Get the list of the connectors of an EVSE + * @param id Id of the EVSE + * @return List of the connectors of the EVSE + */ + virtual const std::vector* getConnectors(unsigned int id) const = 0; + + /** + * @brief Save the state of an EVSE to the database + * @param evse_id Id of the EVSE + * @return true if the state has been saved, false otherwise + */ + virtual bool saveEvse(unsigned int evse_id) = 0; + + /** + * @brief Save the state of a connector to the database + * @param evse_id Id of the EVSE of the connector + * @param id Id of the connector + * @return true if the state has been saved, false otherwise + */ + virtual bool saveConnector(unsigned int evse_id, unsigned int id) = 0; + + /** @brief Reset the state of all the connectors */ + virtual void resetConnectors() = 0; +}; + +} // namespace ocpp20 +} // namespace chargepoint +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_ICONNECTORS20_H diff --git a/src/ocpp20/chargepoint/devicemodel/DeviceModelManager20.cpp b/src/ocpp20/chargepoint/devicemodel/DeviceModelManager20.cpp new file mode 100644 index 00000000..98e9c275 --- /dev/null +++ b/src/ocpp20/chargepoint/devicemodel/DeviceModelManager20.cpp @@ -0,0 +1,767 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +#include "DeviceModelManager20.h" +#include "StringHelpers.h" + +#include +#include + +using namespace ocpp::types; +using namespace ocpp::types::ocpp20; + +namespace ocpp +{ +namespace chargepoint +{ +namespace ocpp20 +{ + +/** @brief Constructor */ +DeviceModelManager::DeviceModelManager(const ocpp::config::IChargePointConfig20& stack_config) + : m_stack_config(stack_config), m_validator(), m_last_error(), m_device_model(), m_listener(nullptr) +{ +} + +/** @brief Destructor */ +DeviceModelManager::~DeviceModelManager() { } + +/** @brief Initialize the device model loader */ +bool DeviceModelManager::init() +{ + bool ret = false; + + // Initialize JSON schema validator + std::filesystem::path device_model_schema_path = m_stack_config.jsonSchemasPath(); + device_model_schema_path.append("device_model_schema.json"); + ret = m_validator.init(device_model_schema_path); + if (!ret) + { + m_last_error = m_validator.lastError(); + } + + return ret; +} + +/** @brief Load the device model from a file */ +bool DeviceModelManager::load(const std::string& device_model_file_path) +{ + bool ret = false; + + // Open the device model file + std::ifstream device_model_file; + device_model_file.open(device_model_file_path); + if (device_model_file.is_open()) + { + // Parse JSON contents + rapidjson::IStreamWrapper device_model_file_wrapper(device_model_file); + rapidjson::Document device_model_doc; + device_model_doc.ParseStream(device_model_file_wrapper); + rapidjson::ParseErrorCode error = device_model_doc.GetParseError(); + if (error == rapidjson::ParseErrorCode ::kParseErrorNone) + { + // Validate schema + ret = m_validator.isValid(device_model_doc); + if (ret) + { + // Load the device model + loadDeviceModel(device_model_doc); + } + else + { + m_last_error = m_validator.lastError(); + } + } + else + { + m_last_error = GetParseError_En(error); + } + } + else + { + m_last_error = "Unable to open device model file : " + device_model_file_path; + } + + return ret; +} + +/** @brief Save the device model to a file */ +bool DeviceModelManager::save(const std::string& device_model_file_path) +{ + bool ret = false; + + // Open the device model file + std::ofstream device_model_file; + device_model_file.open(device_model_file_path); + if (device_model_file.is_open()) + { + // Convert the device model to JSON + rapidjson::Document device_model_doc(rapidjson::kObjectType); + saveDeviceModel(device_model_doc); + + // Save JSON contents + rapidjson::OStreamWrapper device_model_file_wrapper(device_model_file); + rapidjson::Writer device_model_file_writer(device_model_file_wrapper); + ret = device_model_doc.Accept(device_model_file_writer); + if (!ret) + { + m_last_error = "Unable to write to device model file : " + device_model_file_path; + } + } + else + { + m_last_error = "Unable to open device model file : " + device_model_file_path; + } + + return ret; +} + +// IDeviceModel interface + +/** @brief Get a variable value in the device model */ +ocpp::types::ocpp20::GetVariableResultType DeviceModelManager::getVariable(const ocpp::types::ocpp20::GetVariableDataType& requested_var) +{ + GetVariableResultType result; + + // Get requested component + const Component* component = getComponent(requested_var.component); + if (component) + { + // Get the requested variable + bool not_supported_attribute_type = false; + const Variable* var = getVariable(*component, requested_var.attributeType, requested_var.variable, not_supported_attribute_type); + if (var) + { + // Notify request + result.component = requested_var.component; + if (component->evse.isSet()) + { + result.component.evse.value().id = component->evse; + if (component->connector.isSet()) + { + result.component.evse.value().connectorId.value() = component->connector.value(); + } + } + if (component->instance.isSet()) + { + result.component.instance.value().assign(component->instance.value()); + } + result.variable = requested_var.variable; + if (var->instance.isSet()) + { + result.variable.instance.value().assign(var->instance.value()); + } + result.attributeType = requested_var.attributeType; + result.attributeStatus = GetVariableStatusEnumType::Rejected; + if (m_listener) + { + m_listener->getVariable(result); + } + } + else + { + if (not_supported_attribute_type) + { + result.attributeStatus = GetVariableStatusEnumType::NotSupportedAttributeType; + } + else + { + result.attributeStatus = GetVariableStatusEnumType::UnknownVariable; + } + } + } + else + { + result.attributeStatus = GetVariableStatusEnumType::UnknownComponent; + } + + return result; +} + +/** @brief Set a variable value in the device model */ +ocpp::types::ocpp20::SetVariableResultType DeviceModelManager::setVariable(const ocpp::types::ocpp20::SetVariableDataType& requested_var) +{ + return setVariable(requested_var, true); +} + +/** @brief Update a variable value in the device model without value or mutability check */ +ocpp::types::ocpp20::SetVariableResultType DeviceModelManager::updateVariable(const ocpp::types::ocpp20::SetVariableDataType& requested_var) +{ + return setVariable(requested_var, false); +} + +/** @brief Load the device model from its JSON representation */ +void DeviceModelManager::loadDeviceModel(const rapidjson::Document& device_model_doc) +{ + // Clear device model + m_device_model.components.clear(); + + // For each component + const rapidjson::Value& components_json = device_model_doc["components"]; + for (auto it_comps = components_json.Begin(); it_comps != components_json.End(); ++it_comps) + { + Component component; + const rapidjson::Value& component_json = *it_comps; + + // Name + component.name = component_json["name"].GetString(); + + // EVSE id + if (component_json.HasMember("evse")) + { + component.evse.value() = component_json["evse"].GetUint(); + } + + // Connector id + if (component_json.HasMember("connector")) + { + component.connector.value() = component_json["connector"].GetUint(); + } + + // Instance + if (component_json.HasMember("instance")) + { + component.instance.value() = component_json["instance"].GetString(); + } + + // For each variable + const rapidjson::Value& variables_json = component_json["variables"]; + for (auto it_vars = variables_json.Begin(); it_vars != variables_json.End(); ++it_vars) + { + Variable var; + const rapidjson::Value& var_json = *it_vars; + + // Name + var.name = var_json["name"].GetString(); + + // Instance + if (var_json.HasMember("instance")) + { + var.instance.value() = var_json["instance"].GetString(); + } + + // Attributes + { + const rapidjson::Value& var_attributes_json = var_json["attributes"]; + + // Type + if (var_attributes_json.HasMember("type")) + { + var.attributes.type.value() = AttributeEnumTypeHelper.fromString(var_attributes_json["type"].GetString()); + } + else + { + var.attributes.type.value() = AttributeEnumType::Actual; + } + + // Mutability + var.attributes.mutability.value() = MutabilityEnumTypeHelper.fromString(var_attributes_json["mutability"].GetString()); + + // Persistent flag + if (var_attributes_json.HasMember("persistent")) + { + var.attributes.persistent.value() = var_attributes_json["persistent"].GetBool(); + } + else + { + var.attributes.persistent.value() = true; + } + + // Constant flag + if (var_attributes_json.HasMember("constant")) + { + var.attributes.constant.value() = var_attributes_json["constant"].GetBool(); + } + else + { + var.attributes.constant.value() = false; + } + } + + // Characteristics + { + const rapidjson::Value& var_chars_json = var_json["characteristics"]; + + // Data type + var.characteristics.dataType = DataEnumTypeHelper.fromString(var_chars_json["data_type"].GetString()); + + // Unit + if (var_chars_json.HasMember("unit")) + { + var.characteristics.unit.value().assign(var_chars_json["unit"].GetString()); + } + + // Min limit + if (var_chars_json.HasMember("min_limit")) + { + var.characteristics.minLimit.value() = var_chars_json["min_limit"].GetFloat(); + } + + // Max limit + if (var_chars_json.HasMember("max_limit")) + { + var.characteristics.maxLimit.value() = var_chars_json["max_limit"].GetFloat(); + } + + // Values list + if (var_chars_json.HasMember("values_list")) + { + var.characteristics.valuesList.value().assign(var_chars_json["values_list"].GetString()); + } + + // Supports monitoring flag + if (var_chars_json.HasMember("supports_monitoring")) + { + var.characteristics.supportsMonitoring = var_chars_json["supports_monitoring"].GetBool(); + } + else + { + var.characteristics.supportsMonitoring = true; + } + } + + // Add to list of variables + const Variable& cvar = var; + auto iter_var = component.variables.find(var.name); + if (iter_var != component.variables.end()) + { + + iter_var->second[cvar.instance.value()] = std::move(var); + } + else + { + std::map vars; + vars[cvar.instance.value()] = std::move(var); + component.variables[vars.begin()->second.name] = std::move(vars); + } + } + + // Add to list of components + auto iter_comp = m_device_model.components.find(component.name); + if (iter_comp != m_device_model.components.end()) + { + + iter_comp->second.push_back(std::move(component)); + } + else + { + std::vector comps; + comps.push_back(std::move(component)); + m_device_model.components[comps.front().name] = std::move(comps); + } + } +} + +/** @brief Save the device model to a JSON representation */ +void DeviceModelManager::saveDeviceModel(rapidjson::Document& device_model_doc) +{ + RAPIDJSON_DEFAULT_ALLOCATOR& allocator = device_model_doc.GetAllocator(); + + // Components + rapidjson::Value components_json(rapidjson::kArrayType); + + // For each component + for (const auto& [_, components] : m_device_model.components) + { + for (const auto& component : components) + { + rapidjson::Value component_json(rapidjson::kObjectType); + + // Name + component_json.AddMember(rapidjson::StringRef("name"), rapidjson::Value(component.name.c_str(), allocator).Move(), allocator); + + // EVSE id + if (component.evse.isSet()) + { + component_json.AddMember(rapidjson::StringRef("evse"), rapidjson::Value(component.evse.value()).Move(), allocator); + } + + // Connector id + if (component.connector.isSet()) + { + component_json.AddMember( + rapidjson::StringRef("connector"), rapidjson::Value(component.connector.value()).Move(), allocator); + } + + // Instance + if (component.instance.isSet()) + { + component_json.AddMember( + rapidjson::StringRef("instance"), rapidjson::Value(component.instance.value().c_str(), allocator).Move(), allocator); + } + + // For each variable + rapidjson::Value variables_json(rapidjson::kArrayType); + for (const auto& [_, vars] : component.variables) + { + for (const auto& [_, var] : vars) + { + rapidjson::Value var_json(rapidjson::kObjectType); + + // Name + var_json.AddMember(rapidjson::StringRef("name"), rapidjson::Value(var.name.c_str(), allocator).Move(), allocator); + + // Instance + if (var.instance.isSet()) + { + var_json.AddMember( + rapidjson::StringRef("instance"), rapidjson::Value(var.instance.value().c_str(), allocator).Move(), allocator); + } + + // Attributes + { + rapidjson::Value var_attributes_json(rapidjson::kObjectType); + + // Type + if (var.attributes.type.isSet()) + { + var_attributes_json.AddMember( + rapidjson::StringRef("type"), + rapidjson::Value(AttributeEnumTypeHelper.toString(var.attributes.type.value()).c_str(), allocator).Move(), + allocator); + } + + // Mutability + if (var.attributes.mutability.isSet()) + { + var_attributes_json.AddMember( + rapidjson::StringRef("mutability"), + rapidjson::Value(MutabilityEnumTypeHelper.toString(var.attributes.mutability.value()).c_str(), allocator) + .Move(), + allocator); + } + + // Persistent flag + if (var.attributes.persistent.isSet()) + { + var_attributes_json.AddMember( + rapidjson::StringRef("persistent"), rapidjson::Value(var.attributes.persistent.value()).Move(), allocator); + } + + // Constant flag + if (var.attributes.constant.isSet()) + { + var_attributes_json.AddMember( + rapidjson::StringRef("constant"), rapidjson::Value(var.attributes.constant.value()).Move(), allocator); + } + + var_json.AddMember(rapidjson::StringRef("attributes"), var_attributes_json.Move(), allocator); + } + + // Characteristics + { + rapidjson::Value var_chars_json(rapidjson::kObjectType); + + // Data type + var_chars_json.AddMember( + rapidjson::StringRef("data_type"), + rapidjson::Value(DataEnumTypeHelper.toString(var.characteristics.dataType).c_str(), allocator).Move(), + allocator); + + // Unit + if (var.characteristics.unit.isSet()) + { + var_chars_json.AddMember(rapidjson::StringRef("unit"), + rapidjson::Value(var.characteristics.unit.value().c_str(), allocator).Move(), + allocator); + } + + // Min limit + if (var.characteristics.minLimit.isSet()) + { + var_chars_json.AddMember(rapidjson::StringRef("min_limit"), + rapidjson::Value(var.characteristics.minLimit.value()).Move(), + allocator); + } + + // Max limit + if (var.characteristics.maxLimit.isSet()) + { + var_chars_json.AddMember(rapidjson::StringRef("max_limit"), + rapidjson::Value(var.characteristics.maxLimit.value()).Move(), + allocator); + } + + // Values list + if (var.characteristics.valuesList.isSet()) + { + var_chars_json.AddMember(rapidjson::StringRef("values_list"), + rapidjson::Value(var.characteristics.valuesList.value().c_str(), allocator).Move(), + allocator); + } + + // Supports monitoring flag + var_chars_json.AddMember(rapidjson::StringRef("supports_monitoring"), + rapidjson::Value(var.characteristics.supportsMonitoring).Move(), + allocator); + + var_json.AddMember(rapidjson::StringRef("characteristics"), var_chars_json.Move(), allocator); + } + + variables_json.PushBack(var_json.Move(), allocator); + } + } + component_json.AddMember(rapidjson::StringRef("variables"), variables_json.Move(), allocator); + + components_json.PushBack(component_json.Move(), allocator); + } + } + + device_model_doc.AddMember(rapidjson::StringRef("components"), components_json.Move(), allocator); +} + +/** @brief Look for a component in the device model */ +const Component* DeviceModelManager::getComponent(const ocpp::types::ocpp20::ComponentType& requested_component) +{ + const Component* component = nullptr; + + auto iter_comp = m_device_model.components.find(requested_component.name); + if (iter_comp != m_device_model.components.end()) + { + for (const auto& comp : iter_comp->second) + { + if ((!requested_component.instance.isSet() || (requested_component.instance.value() == comp.instance.value())) && + (!requested_component.evse.isSet() || + ((requested_component.evse.value().id == static_cast(comp.evse.value())) && + (!requested_component.evse.value().connectorId.isSet() || + (requested_component.evse.value().connectorId.value() == static_cast(comp.connector.value())))))) + { + component = ∁ + break; + } + } + } + + return component; +} + +/** @brief Look for a variable in the device model */ +const Variable* DeviceModelManager::getVariable(const Component& component, + const ocpp::types::Optional& attribute, + const ocpp::types::ocpp20::VariableType& requested_var, + bool& not_supported_attribute_type) + +{ + const Variable* var = nullptr; + not_supported_attribute_type = false; + + auto iter_var = component.variables.find(requested_var.name); + if (iter_var != component.variables.end()) + { + auto iter_instance = iter_var->second.find(requested_var.instance.value()); + if (iter_instance != iter_var->second.end()) + { + AttributeEnumType attribute_type = (attribute.isSet() ? attribute.value() : AttributeEnumType::Actual); + if (iter_instance->second.attributes.type.value() == attribute_type) + { + var = &iter_instance->second; + } + else + { + not_supported_attribute_type = true; + } + } + } + + return var; +} + +/** @brief Check the validity of the value to set to a variable */ +bool DeviceModelManager::isValidValue(const Variable& var, const std::string& value) +{ + bool ret = true; + + if (var.attributes.mutability.isSet() && (var.attributes.mutability.value() == MutabilityEnumType::ReadOnly)) + { + m_last_error = "Attempting to modify a Read-Only variable : " + var.name; + ret = false; + } + + if (var.characteristics.minLimit.isSet()) + { + switch (var.characteristics.dataType) + { + case DataEnumType::integer: + [[fallthrough]]; + case DataEnumType::decimal: + { + float float_value = static_cast(std::atof(value.c_str())); + if (float_value < var.characteristics.minLimit) + { + m_last_error = "Value is below the minimal limit : " + var.name; + ret = false; + } + } + break; + + default: + // Don't care + break; + } + } + + if (var.characteristics.maxLimit.isSet()) + { + switch (var.characteristics.dataType) + { + case DataEnumType::integer: + [[fallthrough]]; + case DataEnumType::decimal: + { + float float_value = static_cast(std::atof(value.c_str())); + if (float_value > var.characteristics.maxLimit) + { + m_last_error = "Value is above the maximal limit : " + var.name; + ret = false; + } + } + break; + + case DataEnumType::string: + [[fallthrough]]; + case DataEnumType::OptionList: + [[fallthrough]]; + case DataEnumType::MemberList: + [[fallthrough]]; + case DataEnumType::SequenceList: + { + size_t max_length = static_cast(var.characteristics.maxLimit); + if (value.size() > max_length) + { + m_last_error = "Value length is above the maximal limit : " + var.name; + ret = false; + } + } + break; + + default: + // Don't care + break; + } + } + + if (var.characteristics.valuesList.isSet() && !var.characteristics.valuesList.value().empty()) + { + switch (var.characteristics.dataType) + { + case DataEnumType::OptionList: + [[fallthrough]]; + case DataEnumType::MemberList: + [[fallthrough]]; + case DataEnumType::SequenceList: + { + auto allowed_values = ocpp::helpers::split(var.characteristics.valuesList.value(), ','); + bool found = false; + for (auto& allowed_value : allowed_values) + { + allowed_value = ocpp::helpers::trim(allowed_value); + if (value == allowed_value) + { + found = true; + break; + } + } + if (!found) + { + m_last_error = "Value is not in the values list : " + var.name; + ret = false; + } + } + break; + + default: + // Don't care + break; + } + } + + return ret; +} + +/** @brief Set a variable value in the device model */ +ocpp::types::ocpp20::SetVariableResultType DeviceModelManager::setVariable(const ocpp::types::ocpp20::SetVariableDataType& requested_var, + bool check_value) +{ + SetVariableResultType result; + + // Get requested component + const Component* component = getComponent(requested_var.component); + if (component) + { + // Get the requested variable + bool not_supported_attribute_type = false; + const Variable* var = getVariable(*component, requested_var.attributeType, requested_var.variable, not_supported_attribute_type); + if (var) + { + // Check value + result.component = requested_var.component; + result.variable = requested_var.variable; + result.attributeType = requested_var.attributeType; + result.attributeStatus = SetVariableStatusEnumType::Rejected; + if (!check_value || isValidValue(*var, requested_var.attributeValue.str())) + { + // Notify request + result.component = requested_var.component; + if (component->evse.isSet()) + { + result.component.evse.value().id = component->evse; + if (component->connector.isSet()) + { + result.component.evse.value().connectorId.value() = component->connector.value(); + } + } + if (component->instance.isSet()) + { + result.component.instance.value().assign(component->instance.value()); + } + result.variable = requested_var.variable; + if (var->instance.isSet()) + { + result.variable.instance.value().assign(var->instance.value()); + } + result.attributeType = requested_var.attributeType; + result.attributeStatus = SetVariableStatusEnumType::Rejected; + if (m_listener) + { + result.attributeStatus = m_listener->setVariable(requested_var); + } + } + } + else + { + if (not_supported_attribute_type) + { + result.attributeStatus = SetVariableStatusEnumType::NotSupportedAttributeType; + } + else + { + result.attributeStatus = SetVariableStatusEnumType::UnknownVariable; + } + } + } + else + { + result.attributeStatus = SetVariableStatusEnumType::UnknownComponent; + } + + return result; +} + +} // namespace ocpp20 +} // namespace chargepoint +} // namespace ocpp diff --git a/src/ocpp20/chargepoint/devicemodel/DeviceModelManager20.h b/src/ocpp20/chargepoint/devicemodel/DeviceModelManager20.h new file mode 100644 index 00000000..8d97bb03 --- /dev/null +++ b/src/ocpp20/chargepoint/devicemodel/DeviceModelManager20.h @@ -0,0 +1,117 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +#ifndef OPENOCPP_OCPP20_DEVICEMODELMANAGER20_H +#define OPENOCPP_OCPP20_DEVICEMODELMANAGER20_H + +#include "IChargePointConfig20.h" +#include "IDeviceModel20.h" +#include "JsonValidator.h" + +namespace ocpp +{ +namespace chargepoint +{ +namespace ocpp20 +{ + +/** @brief Handle of the device model operations */ +class DeviceModelManager : public IDeviceModel +{ + public: + /** @brief Constructor */ + DeviceModelManager(const ocpp::config::IChargePointConfig20& stack_config); + + /** @brief Destructor */ + virtual ~DeviceModelManager(); + + /** + * @brief Initialize the device model loader + * @return true if the initialization was succesful, fals otherwise + */ + bool init(); + + /** + * @brief Load the device model from a file + * @param device_model_file_path Path to the device model file + * @return true if the device model has been loaded, false otherwise + */ + bool load(const std::string& device_model_file_path); + + /** + * @brief Save the device model to a file + * @param device_model_file_path Path to the device model file + * @return true if the device model has been saved, false otherwise + */ + bool save(const std::string& device_model_file_path); + + /** @brief Get the last error message */ + const std::string& lastError() const { return m_last_error; } + + // IDeviceModel interface + + /** @brief Register a listener to device model events */ + void registerListener(IListener& listener) override { m_listener = &listener; } + + /** @brief Get the full device model */ + const DeviceModel& getModel() const override { return m_device_model; } + + /** @brief Get a variable value in the device model */ + ocpp::types::ocpp20::GetVariableResultType getVariable(const ocpp::types::ocpp20::GetVariableDataType& requested_var) override; + + /** @brief Set a variable value in the device model */ + ocpp::types::ocpp20::SetVariableResultType setVariable(const ocpp::types::ocpp20::SetVariableDataType& requested_var) override; + + /** @brief Update a variable value in the device model without value or mutability check */ + ocpp::types::ocpp20::SetVariableResultType updateVariable(const ocpp::types::ocpp20::SetVariableDataType& requested_var) override; + + private: + /** @brief Stack configuration */ + const ocpp::config::IChargePointConfig20& m_stack_config; + /** @brief JSON schema validator */ + ocpp::json::JsonValidator m_validator; + /** @brief Last error message */ + std::string m_last_error; + /** @brief Device model */ + DeviceModel m_device_model; + /** @brief Listener to device model events */ + IListener* m_listener; + + /** @brief Load the device model from its JSON representation */ + void loadDeviceModel(const rapidjson::Document& device_model_doc); + /** @brief Save the device model to a JSON representation */ + void saveDeviceModel(rapidjson::Document& device_model_doc); + + /** @brief Look for a component in the device model */ + const Component* getComponent(const ocpp::types::ocpp20::ComponentType& requested_component); + /** @brief Look for a variable in the device model */ + const Variable* getVariable(const Component& component, + const ocpp::types::Optional& attribute, + const ocpp::types::ocpp20::VariableType& requested_var, + bool& not_supported_attribute_type); + /** @brief Check the validity of the value to set to a variable */ + bool isValidValue(const Variable& var, const std::string& value); + /** @brief Set a variable value in the device model */ + ocpp::types::ocpp20::SetVariableResultType setVariable(const ocpp::types::ocpp20::SetVariableDataType& requested_var, bool check_value); +}; + +} // namespace ocpp20 +} // namespace chargepoint +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_DEVICEMODELMANAGER20_H diff --git a/src/ocpp20/chargepoint/devicemodel/IDeviceModel20.h b/src/ocpp20/chargepoint/devicemodel/IDeviceModel20.h new file mode 100644 index 00000000..ffac96e4 --- /dev/null +++ b/src/ocpp20/chargepoint/devicemodel/IDeviceModel20.h @@ -0,0 +1,117 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +#ifndef OPENOCPP_OCPP20_IDEVICEMODEL20_H +#define OPENOCPP_OCPP20_IDEVICEMODEL20_H + +#include "GetVariableDataType20.h" +#include "GetVariableResultType20.h" +#include "SetVariableDataType20.h" +#include "SetVariableResultType20.h" +#include "VariableAttributeType20.h" +#include "VariableCharacteristicsType20.h" + +#include +#include + +namespace ocpp +{ +namespace chargepoint +{ +namespace ocpp20 +{ + +/** @brief Variable */ +struct Variable +{ + /** @brief Name */ + std::string name; + /** @brief Instance */ + ocpp::types::Optional instance; + /** @brief Attributes */ + ocpp::types::ocpp20::VariableAttributeType attributes; + /** @brief Characteristics */ + ocpp::types::ocpp20::VariableCharacteristicsType characteristics; +}; + +/** @brief Component */ +struct Component +{ + /** @brief Name */ + std::string name; + /** @brief Instance */ + ocpp::types::Optional instance; + /** @brief EVSE id */ + ocpp::types::Optional evse; + /** @brief Connector id */ + ocpp::types::Optional connector; + /** @brief Variables */ + std::map> variables; +}; + +/** @brief Device model */ +struct DeviceModel +{ + /** @brief Components in the device model */ + std::map> components; +}; + +/** @brief Interface to interact with the device model */ +class IDeviceModel +{ + public: + // Forward declaration + class IListener; + + /** @brief Destructor */ + virtual ~IDeviceModel() { } + + /** @brief Register a listener to device model events */ + virtual void registerListener(IListener& listener) = 0; + + /** @brief Get the full device model */ + virtual const DeviceModel& getModel() const = 0; + + /** @brief Get a variable value in the device model */ + virtual ocpp::types::ocpp20::GetVariableResultType getVariable(const ocpp::types::ocpp20::GetVariableDataType& requested_var) = 0; + + /** @brief Set a variable value in the device model */ + virtual ocpp::types::ocpp20::SetVariableResultType setVariable(const ocpp::types::ocpp20::SetVariableDataType& requested_var) = 0; + + /** @brief Update a variable value in the device model without value or mutability check */ + virtual ocpp::types::ocpp20::SetVariableResultType updateVariable(const ocpp::types::ocpp20::SetVariableDataType& requested_var) = 0; + + /** @brief Interface to the listeners of the device model events */ + class IListener + { + public: + /** @brief Destructor */ + virtual ~IListener() { } + + /** @brief Called to retrieve the value of a variable */ + virtual void getVariable(ocpp::types::ocpp20::GetVariableResultType& var) = 0; + /** @brief Called to set the value of a variable */ + virtual ocpp::types::ocpp20::SetVariableStatusEnumType setVariable(const ocpp::types::ocpp20::SetVariableDataType& var) = 0; + }; +}; + +} // namespace ocpp20 +} // namespace chargepoint +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_IDEVICEMODEL20_H diff --git a/src/ocpp20/chargepoint/devicemodel/device_model.json b/src/ocpp20/chargepoint/devicemodel/device_model.json new file mode 100755 index 00000000..0b341df3 --- /dev/null +++ b/src/ocpp20/chargepoint/devicemodel/device_model.json @@ -0,0 +1,2022 @@ +{ + "components": [ + { + "name": "AlignedDataCtrlr", + "variables": [ + { + "name": "Enabled", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "Available", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "Measurands", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "MemberList", + "max_limit": 100 + }, + "required": true + }, + { + "name": "Interval", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "integer", + "unit": "s" + }, + "required": true + }, + { + "name": "SignReadings", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "TxEndedMeasurands", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "MemberList", + "max_limit": 100 + }, + "required": true + }, + { + "name": "TxEndedInterval", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "integer", + "unit": "s" + }, + "required": true + }, + { + "name": "PublicKeyWithSignedMeterValue", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "OptionList", + "values_list": "Never,OncePerTransaction,EveryMeterValue" + }, + "required": false + }, + { + "name": "RegisterValuesWithoutPhases", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + } + ] + }, + { + "name": "AlignedDataCtrlr", + "evse": 1, + "variables": [ + { + "name": "SendDuringIdle", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + } + ] + }, + { + "name": "AuthCacheCtrlr", + "variables": [ + { + "name": "Enabled", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "Available", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "LifeTime", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "integer", + "unit": "s" + }, + "required": false + }, + { + "name": "Storage", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer", + "max_limit": 1000000 + }, + "required": false + }, + { + "name": "Policy", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "OptionList", + "values_list": "LRU,LFU,FIFO,CUSTOM" + }, + "required": false + }, + { + "name": "DisablePostAuthorize", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + } + ] + }, + { + "name": "AuthCtrlr", + "variables": [ + { + "name": "Enabled", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "AdditionalInfoItemsPerMessage", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": false + }, + { + "name": "OfflineTxForUnknownIdEnabled", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "AuthorizeRemoteStart", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": true + }, + { + "name": "LocalAuthorizeOffline", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": true + }, + { + "name": "LocalPreAuthorize", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": true + }, + { + "name": "MasterPassGroupId", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "string", + "max_limit": 36 + }, + "required": false + }, + { + "name": "DisableRemoteAuthorization", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + } + ] + }, + { + "name": "ClockCtrlr", + "variables": [ + { + "name": "dateTime", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "dateTime" + }, + "required": true + }, + { + "name": "NtpSource", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "OptionList", + "values_list": "DHCP,manual" + }, + "required": false + }, + { + "name": "NtpServerUri", + "instance": "1", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "string" + }, + "required": false + }, + { + "name": "TimeOffset", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "string" + }, + "required": false + }, + { + "name": "NextTimeOffsetTransitionDateTime", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "dateTime" + }, + "required": false + }, + { + "name": "TimeOffset", + "instance": "1", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "string" + }, + "required": false + }, + { + "name": "TimeSource", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "SequenceList", + "values_list": "Heartbeat,NTP,GPS,RealTimeClock,MobileNetwork,RadioTimeTransmitter" + }, + "required": true + }, + { + "name": "TimeZone", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "string" + }, + "required": false + }, + { + "name": "TimeAdjustmentReportingThreshold", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "integer", + "unit": "s" + }, + "required": false + } + ] + }, + { + "name": "CustomizationCtrlr", + "variables": [ + { + "name": "CustomImplementationEnabled", + "instance": "", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + } + ] + }, + { + "name": "DeviceDataCtrlr", + "variables": [ + { + "name": "ItemsPerMessage", + "instance": "GetReport", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": true + }, + { + "name": "ItemsPerMessage", + "instance": "GetVariables", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": true + }, + { + "name": "BytesPerMessage", + "instance": "GetReport", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": true + }, + { + "name": "BytesPerMessage", + "instance": "GetVariables", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": true + }, + { + "name": "ConfigurationValueSize", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer", + "max_limit": 1000 + }, + "required": false + }, + { + "name": "ReportingValueSize", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer", + "max_limit": 2500 + }, + "required": false + }, + { + "name": "ItemsPerMessage", + "instance": "SetVariables", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": true + }, + { + "name": "BytesPerMessage", + "instance": "SetVariables", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": true + } + ] + }, + { + "name": "DisplayMessageCtrlr", + "variables": [ + { + "name": "Enabled", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "Available", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "DisplayMessages", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer", + "max_limit": 10 + }, + "required": true + }, + { + "name": "SupportedFormats", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "MemberList", + "values_list": "ASCII,HTML,URI,UTF8" + }, + "required": true + }, + { + "name": "SupportedPriorities", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "MemberList", + "values_list": "AlwaysFront,InFront,NormalCycle" + }, + "required": true + } + ] + }, + { + "name": "ISO15118Ctrlr", + "variables": [ + { + "name": "CentralContractValidationAllowed", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "ContractValidationOffline", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": true + }, + { + "name": "PnCEnabled", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "V2GCertificateInstallationEnabled", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "ContractCertificateInstallationEnabled", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "RequestMeteringReceipt", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + } + ] + }, + { + "name": "ISO15118Ctrlr", + "evse": 1, + "variables": [ + { + "name": "ProtocolSupportedByEV", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "string" + }, + "required": false + }, + { + "name": "ProtocolAgreed", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "string" + }, + "required": false + }, + { + "name": "SeccId", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "string" + }, + "required": false + }, + { + "name": "CountryName", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "string" + }, + "required": false + }, + { + "name": "OrganizationName", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "string" + }, + "required": false + }, + { + "name": "ISO15118EvseId", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "string" + }, + "required": false + } + ] + }, + { + "name": "LocalAuthListCtrlr", + "variables": [ + { + "name": "Enabled", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "Entries", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer", + "max_limit": 10000 + }, + "required": false + }, + { + "name": "Available", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "ItemsPerMessage", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": false + }, + { + "name": "BytesPerMessage", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": false + }, + { + "name": "Storage", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer", + "max_limit": 1000000 + }, + "required": false + }, + { + "name": "DisablePostAuthorize", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "SupportsExpiryDateTime", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + } + ] + }, + { + "name": "MonitoringCtrlr", + "variables": [ + { + "name": "Enabled", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "Available", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "ItemsPerMessage", + "instance": "ClearVariableMonitoring", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": false + }, + { + "name": "ItemsPerMessage", + "instance": "SetVariableMonitoring", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": true + }, + { + "name": "BytesPerMessage", + "instance": "ClearVariableMonitoring", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": false + }, + { + "name": "BytesPerMessage", + "instance": "SetVariableMonitoring", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": true + }, + { + "name": "OfflineQueuingSeverity", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": false + }, + { + "name": "ActiveMonitoringBase", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "OptionList", + "values_list": "All,FactoryDefault,HardwiredOnly" + }, + "required": false + }, + { + "name": "ActiveMonitoringLevel", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer", + "min_limit": 0, + "max_limit": 9 + }, + "required": false + } + ] + }, + { + "name": "OCPPCommCtrlr", + "variables": [ + { + "name": "ActiveNetworkProfile", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": false + }, + { + "name": "MessageTimeout", + "instance": "Default", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer", + "unit": "s" + }, + "required": true + }, + { + "name": "FileTransferProtocols", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "MemberList" + }, + "required": true + }, + { + "name": "HeartbeatInterval", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "integer", + "unit": "s", + "min_limit": 1 + }, + "required": false + }, + { + "name": "NetworkConfigurationPriority", + "attributes": + { + "mutability": "ReadWrite", + "type": "Actual" + }, + "characteristics": + { + "data_type": "SequenceList", + "values_list": "" + }, + "required": true + }, + { + "name": "NetworkProfileConnectionAttempts", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": true + }, + { + "name": "OfflineThreshold", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "integer", + "unit": "s", + "min_limit": 1 + }, + "required": true + }, + { + "name": "QueueAllMessages", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "MessageAttemptsTransactionEvent", + "instance": "TransactionEvent", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": true + }, + { + "name": "MessageAttemptIntervalTransactionEvent", + "instance": "TransactionEvent", + "attributes": + { + "mutability": "ReadWrite", + "type": "Actual" + }, + "characteristics": + { + "data_type": "integer", + "unit": "s" + }, + "required": true + }, + { + "name": "UnlockOnEVSideDisconnect", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": true + }, + { + "name": "ResetRetries", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": true + }, + { + "name": "FieldLength", + "instance": ".", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": false + }, + { + "name": "RetryBackOffRepeatTimes", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": true + }, + { + "name": "RetryBackOffRandomRange", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "integer", + "unit": "s" + }, + "required": true + }, + { + "name": "RetryBackOffWaitMinimum", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "integer", + "unit": "s" + }, + "required": true + }, + { + "name": "WebSocketPingInterval", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "integer", + "unit": "s" + }, + "required": true + } + ] + }, + { + "name": "ReservationCtrlr", + "variables": [ + { + "name": "Enabled", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "Available", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "NonEvseSpecific", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + } + ] + }, + { + "name": "SampledDataCtrlr", + "variables": [ + { + "name": "Enabled", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "Available", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "SignReadings", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "TxEndedMeasurands", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "MemberList", + "max_limit": 100 + }, + "required": true + }, + { + "name": "TxEndedInterval", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "integer", + "unit": "s" + }, + "required": true + }, + { + "name": "TxStartedMeasurands", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "MemberList", + "max_limit": 100 + }, + "required": true + }, + { + "name": "TxUpdatedMeasurands", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "MemberList", + "max_limit": 100 + }, + "required": true + }, + { + "name": "TxUpdatedInterval", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "integer", + "unit": "s" + }, + "required": true + } + ] + }, + { + "name": "SecurityCtrlr", + "variables": [ + { + "name": "BasicAuthPassword", + "attributes": + { + "mutability": "WriteOnly" + }, + "characteristics": + { + "data_type": "string", + "max_limit": 40 + }, + "required": false + }, + { + "name": "Identity", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "string", + "max_limit": 48 + }, + "required": false + }, + { + "name": "OrganizationName", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "string" + }, + "required": true + }, + { + "name": "CertificateEntries", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer", + "max_limit": 20 + }, + "required": true + }, + { + "name": "SecurityProfile", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": true + }, + { + "name": "AdditionalRootCertificateCheck", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "MaxCertificateChainSize", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer", + "max_limit": 10000 + }, + "required": false + }, + { + "name": "CertSigningWaitMinimum", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "integer", + "unit": "s" + }, + "required": false + }, + { + "name": "CertSigningRepeatTimes", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": false + } + ] + }, + { + "name": "SmartChargingCtrlr", + "variables": [ + { + "name": "Enabled", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "Available", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "ACPhaseSwitchingSupported", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "ProfileStackLevel", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": true + }, + { + "name": "RateUnit", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "MemberList", + "values_list": "A,W" + }, + "required": true + }, + { + "name": "PeriodsPerSchedule", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": true + }, + { + "name": "ExternalControlSignalsEnabled", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "NotifyChargingLimitWithSchedules", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "Phases3to1", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "Entries", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer", + "max_limit": 100 + }, + "required": true + }, + { + "name": "LimitChangeSignificance", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "decimal" + }, + "required": true + } + ] + }, + { + "name": "TariffCostCtrlr", + "variables": [ + { + "name": "Enabled", + "instance": "Tariff", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "Available", + "instance": "Tariff", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "TariffFallbackMessage", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "string", + "max_limit": 255 + }, + "required": true + }, + { + "name": "Enabled", + "instance": "Cost", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "Available", + "instance": "Cost", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "TotalCostFallbackMessage", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "string", + "max_limit": 255 + }, + "required": true + }, + { + "name": "Currency", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "string", + "max_limit": 3 + }, + "required": true + } + ] + }, + { + "name": "TxCtrlr", + "variables": [ + { + "name": "EVConnectionTimeOut", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "integer", + "unit": "s" + }, + "required": true + }, + { + "name": "StopTxOnEVSideDisconnect", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": true + }, + { + "name": "TxBeforeAcceptedEnabled", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "TxStartPoint", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "MemberList", + "values_list": "ParkingBayOccupancy,EVConnected,Authorized,PowerPathClosed,EnergyTransfer,DataSigned" + }, + "required": true + }, + { + "name": "TxStopPoint", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "MemberList", + "values_list": "ParkingBayOccupancy,EVConnected,Authorized,PowerPathClosed,EnergyTransfer,DataSigned" + }, + "required": true + }, + { + "name": "MaxEnergyOnInvalidId", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "integer", + "unit": "Wh" + }, + "required": false + }, + { + "name": "StopTxOnInvalidId", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": true + } + ] + }, + { + "name": "ChargingStation", + "variables": [ + { + "name": "AllowNewSessionsPendingFirmwareUpdate", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "Available", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": true + } + ] + }, + { + "name": "EVSE", + "instance": "EVSE 1", + "evse": 1, + "variables": [ + { + "name": "Available", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": true + }, + { + "name": "AvailabilityState", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "OptionList", + "values_list": "Available,Occupied,Reserved,Unavailable,Faulted" + }, + "required": true + }, + { + "name": "AllowReset", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": false + }, + { + "name": "PhaseRotation", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "string" + }, + "required": false + }, + { + "name": "SupplyPhases", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": true + }, + { + "name": "Power", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "decimal" + }, + "required": true + } + ] + }, + { + "name": "Connector", + "evse": 1, + "connector": 1, + "variables": [ + { + "name": "Available", + + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "boolean" + }, + "required": true + }, + { + "name": "AvailabilityState", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "OptionList", + "values_list": "Available,Occupied,Reserved,Unavailable,Faulted" + }, + "required": true + }, + { + "name": "ConnectorType", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "string", + "values_list": "cCCS1,cCCS2,cG105,cTesla,cType1,cType2,s309-1P-16A,s309-1P-32A,s309-3P-16A,s309-3P-32A,sBS1361,sCEE-7-7,sType2,sType3,Other1PhMax16A,Other1PhOver16A,Other3Ph,Pan,wInductive,wResonant,Undetermined,Unknown,cGBT,cChaoJi,OppCharge" + }, + "required": true + }, + { + "name": "PhaseRotation", + "attributes": + { + "mutability": "ReadWrite" + }, + "characteristics": + { + "data_type": "string" + }, + "required": false + }, + { + "name": "SupplyPhases", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "integer" + }, + "required": true + }, + { + "name": "Power", + "attributes": + { + "mutability": "ReadOnly" + }, + "characteristics": + { + "data_type": "decimal" + }, + "required": true + } + ] + } + ] +} \ No newline at end of file diff --git a/src/ocpp20/chargepoint/interface/IBasicChargePoint20.h b/src/ocpp20/chargepoint/interface/IBasicChargePoint20.h new file mode 100644 index 00000000..41887d94 --- /dev/null +++ b/src/ocpp20/chargepoint/interface/IBasicChargePoint20.h @@ -0,0 +1,155 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* Generated by json2cpp */ + +#ifndef OPENOCPP_OCPP20_IBASICCHARGEPOINT20_H +#define OPENOCPP_OCPP20_IBASICCHARGEPOINT20_H + +#include "BootNotification20.h" +#include "IBasicChargePointEventsHandler20.h" +#include "IChargePointConfig20.h" +#include "IDeviceModel20.h" +#include "StatusNotification20.h" + +#include + +namespace ocpp +{ +namespace helpers +{ +class ITimerPool; +class WorkerThreadPool; +} // namespace helpers +namespace database +{ +class Database; +} // namespace database + +namespace chargepoint +{ +namespace ocpp20 +{ + +/** @brief Interface for basic charge point implementations */ +class IBasicChargePoint20 +{ + public: + /** + * @brief Instanciate a charge point + * @param stack_config Stack configuration + * @param device_model Device model + * @param event_handler Stack event handler + */ + static std::unique_ptr create(const ocpp::config::IChargePointConfig20& stack_config, + IDeviceModel& device_model, + IBasicChargePointEventsHandler& events_handler); + + /** + * @brief Instanciate a charge point with the provided timer and worker pools + * To use when you have to instanciate multiple Central System / Charge Point + * => Allow to reduce thread and memory usage + * @param stack_config Stack configuration + * @param device_model Device model + * @param event_handler Stack event handler + * @param timer_pool Timer pool + * @param worker_pool Worker thread pool + */ + static std::unique_ptr create(const ocpp::config::IChargePointConfig20& stack_config, + IDeviceModel& device_model, + IBasicChargePointEventsHandler& events_handler, + std::shared_ptr timer_pool, + std::shared_ptr worker_pool); + + /** @brief Destructor */ + virtual ~IBasicChargePoint20() { } + + /** + * @brief Get the timer pool associated to the charge point + * @return Timer pool associated to the charge point + */ + virtual ocpp::helpers::ITimerPool& getTimerPool() = 0; + + /** + * @brief Get the worker pool associated to the charge point + * @return Worker pool associated to the charge point + */ + virtual ocpp::helpers::WorkerThreadPool& getWorkerPool() = 0; + + /** + * @brief Reset the charge point's internal data (can be done only when the charge point is stopped) + * @return true if the data has been reset, false otherwise + */ + virtual bool resetData() = 0; + + /** + * @brief Reset only connector related persistency data (can be done only when the charge point is stopped) + * @return true if the data has been reset, false otherwise + */ + virtual bool resetConnectorData() = 0; + + /** + * @brief Start the charge point + * @param boot_reason Boot notification reason + * @return true if the charge point has been started, false otherwise + */ + virtual bool start(ocpp::types::ocpp20::BootReasonEnumType boot_reason) = 0; + + /** + * @brief Stop the charge point + * @return true if the charge point has been stopped, false otherwise + */ + virtual bool stop() = 0; + + /** + * @brief Triggers a reconnexion of the charge point to the Central System + * @return true if the reconnexion has been scheduled, false otherwise + */ + virtual bool reconnect() = 0; + + /** + * @brief Get the registration status of the charge point + * @return Registration of the charge point + */ + virtual ocpp::types::ocpp20::RegistrationStatusEnumType getRegistrationStatus() = 0; + + /** + * @brief Get the status of a connector + * @param evse_id Id of the EVSE + * @param connector_id Id of the connector + * @return Status of the connector + */ + virtual ocpp::types::ocpp20::ConnectorStatusEnumType getConnectorStatus(unsigned int evse_id, unsigned int connector_id) = 0; + + /** + * @brief Notify a new status for a connector + * @param evse_id Id of the EVSE + * @param connector_id Id of the connector + * @param status Status of the connector + * @return true if the status has been notified, false otherwise + */ + virtual bool statusNotification(unsigned int evse_id, + unsigned int connector_id, + ocpp::types::ocpp20::ConnectorStatusEnumType status) = 0; +}; + +} // namespace ocpp20 +} // namespace chargepoint +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_IBASICCHARGEPOINT20_H \ No newline at end of file diff --git a/src/ocpp20/chargepoint/interface/IBasicChargePointEventsHandler20.h b/src/ocpp20/chargepoint/interface/IBasicChargePointEventsHandler20.h new file mode 100644 index 00000000..d7310c0b --- /dev/null +++ b/src/ocpp20/chargepoint/interface/IBasicChargePointEventsHandler20.h @@ -0,0 +1,68 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +#ifndef OPENOCPP_OCPP20_IBASICCHARGEPOINTEVENTSHANDLERCHARGEPOINT20_H +#define OPENOCPP_OCPP20_IBASICCHARGEPOINTEVENTSHANDLERCHARGEPOINT20_H + +#include "DateTime.h" +#include "RegistrationStatusEnumType20.h" + +namespace ocpp +{ +namespace chargepoint +{ +namespace ocpp20 +{ + +/** @brief Interface for charge point event handlers implementations */ +class IBasicChargePointEventsHandler +{ + public: + /** @brief Destructor */ + virtual ~IBasicChargePointEventsHandler() { } + + /** + * @brief Called when the first attempt to connect to the central system has failed + * @param status Previous registration status (if Accepted, some offline operations are allowed) + */ + virtual void connectionFailed(ocpp::types::ocpp20::RegistrationStatusEnumType status) = 0; + + /** + * @brief Called when the charge point connection status has changed + * @param isConnected true if the charge point is connected to the central system, false otherwise + */ + virtual void connectionStateChanged(bool isConnected) = 0; + + /** + * @brief Called on boot notification response from the central system + * @param status Registration status + * @param datetime Date and time of the central system + */ + virtual void bootNotification(ocpp::types::ocpp20::RegistrationStatusEnumType status, const ocpp::types::DateTime& datetime) = 0; + + /** + * @brief Called when the date and time must be adjusted with the one of the central system + */ + virtual void datetimeReceived(const ocpp::types::DateTime& datetime) = 0; +}; + +} // namespace ocpp20 +} // namespace chargepoint +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_IBASICCHARGEPOINTEVENTSHANDLERCHARGEPOINT20_H diff --git a/src/ocpp20/chargepoint/interface/IChargePoint20.h b/src/ocpp20/chargepoint/interface/IChargePoint20.h new file mode 100644 index 00000000..e5a0d256 --- /dev/null +++ b/src/ocpp20/chargepoint/interface/IChargePoint20.h @@ -0,0 +1,430 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* Generated by json2cpp */ + +#ifndef OPENOCPP_OCPP20_ICHARGEPOINT20_H +#define OPENOCPP_OCPP20_ICHARGEPOINT20_H + +#include "Authorize20.h" +#include "BootNotification20.h" +#include "ClearedChargingLimit20.h" +#include "CostUpdated20.h" +#include "DataTransfer20.h" +#include "FirmwareStatusNotification20.h" +#include "Heartbeat20.h" +#include "IChargePointConfig20.h" +#include "IChargePointEventsHandler20.h" +#include "LogStatusNotification20.h" +#include "MeterValues20.h" +#include "NotifyChargingLimit20.h" +#include "NotifyCustomerInformation20.h" +#include "NotifyDisplayMessages20.h" +#include "NotifyEVChargingNeeds20.h" +#include "NotifyEVChargingSchedule20.h" +#include "NotifyEvent20.h" +#include "NotifyMonitoringReport20.h" +#include "NotifyReport20.h" +#include "PublishFirmwareStatusNotification20.h" +#include "ReportChargingProfiles20.h" +#include "ReservationStatusUpdate20.h" +#include "SecurityEventNotification20.h" +#include "SignCertificate20.h" +#include "StatusNotification20.h" +#include "TransactionEvent20.h" + +#include + +namespace ocpp +{ +namespace helpers +{ +class ITimerPool; +class WorkerThreadPool; +} // namespace helpers +namespace database +{ +class Database; +} // namespace database + +namespace chargepoint +{ +namespace ocpp20 +{ + +/** @brief Interface for charge point implementations */ +class IChargePoint20 +{ + public: + /** + * @brief Instanciate a charge point + * @param stack_config Stack configuration + * @param event_handler Stack event handler + */ + static std::unique_ptr create(const ocpp::config::IChargePointConfig20& stack_config, + IChargePointEventsHandler20& events_handler); + + /** + * @brief Instanciate a charge point with the provided timer and worker pools + * To use when you have to instanciate multiple Central System / Charge Point + * => Allow to reduce thread and memory usage + * @param stack_config Stack configuration + * @param event_handler Stack event handler + * @param timer_pool Timer pool + * @param worker_pool Worker thread pool + */ + static std::unique_ptr create(const ocpp::config::IChargePointConfig20& stack_config, + IChargePointEventsHandler20& events_handler, + std::shared_ptr timer_pool, + std::shared_ptr worker_pool); + + /** @brief Destructor */ + virtual ~IChargePoint20() { } + + /** + * @brief Get the timer pool associated to the charge point + * @return Timer pool associated to the charge point + */ + virtual ocpp::helpers::ITimerPool& getTimerPool() = 0; + + /** + * @brief Get the worker pool associated to the charge point + * @return Worker pool associated to the charge point + */ + virtual ocpp::helpers::WorkerThreadPool& getWorkerPool() = 0; + + /** + * @brief Reset the charge point's internal data (can be done only when the charge point is stopped) + * @return true if the data has been reset, false otherwise + */ + virtual bool resetData() = 0; + + /** + * @brief Start the charge point + * @return true if the charge point has been started, false otherwise + */ + virtual bool start() = 0; + + /** + * @brief Stop the charge point + * @return true if the charge point has been stopped, false otherwise + */ + virtual bool stop() = 0; + + /** + * @brief Triggers a reconnexion of the charge point to the Central System + * @return true if the reconnexion has been scheduled, false otherwise + */ + virtual bool reconnect() = 0; + + // OCPP operations + /** + * @brief Send a BootNotification message to the central system + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::BootNotificationReq& request, + ocpp::messages::ocpp20::BootNotificationConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a Authorize message to the central system + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::AuthorizeReq& request, + ocpp::messages::ocpp20::AuthorizeConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a ClearedChargingLimit message to the central system + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::ClearedChargingLimitReq& request, + ocpp::messages::ocpp20::ClearedChargingLimitConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a CostUpdated message to the central system + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::CostUpdatedReq& request, + ocpp::messages::ocpp20::CostUpdatedConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a DataTransfer message to the central system + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::DataTransferReq& request, + ocpp::messages::ocpp20::DataTransferConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a FirmwareStatusNotification message to the central system + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::FirmwareStatusNotificationReq& request, + ocpp::messages::ocpp20::FirmwareStatusNotificationConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a Heartbeat message to the central system + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::HeartbeatReq& request, + ocpp::messages::ocpp20::HeartbeatConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a LogStatusNotification message to the central system + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::LogStatusNotificationReq& request, + ocpp::messages::ocpp20::LogStatusNotificationConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a MeterValues message to the central system + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::MeterValuesReq& request, + ocpp::messages::ocpp20::MeterValuesConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a NotifyChargingLimit message to the central system + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::NotifyChargingLimitReq& request, + ocpp::messages::ocpp20::NotifyChargingLimitConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a NotifyCustomerInformation message to the central system + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::NotifyCustomerInformationReq& request, + ocpp::messages::ocpp20::NotifyCustomerInformationConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a NotifyDisplayMessages message to the central system + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::NotifyDisplayMessagesReq& request, + ocpp::messages::ocpp20::NotifyDisplayMessagesConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a NotifyEVChargingNeeds message to the central system + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::NotifyEVChargingNeedsReq& request, + ocpp::messages::ocpp20::NotifyEVChargingNeedsConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a NotifyEVChargingSchedule message to the central system + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::NotifyEVChargingScheduleReq& request, + ocpp::messages::ocpp20::NotifyEVChargingScheduleConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a NotifyEvent message to the central system + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::NotifyEventReq& request, + ocpp::messages::ocpp20::NotifyEventConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a NotifyMonitoringReport message to the central system + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::NotifyMonitoringReportReq& request, + ocpp::messages::ocpp20::NotifyMonitoringReportConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a NotifyReport message to the central system + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::NotifyReportReq& request, + ocpp::messages::ocpp20::NotifyReportConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a PublishFirmwareStatusNotification message to the central system + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::PublishFirmwareStatusNotificationReq& request, + ocpp::messages::ocpp20::PublishFirmwareStatusNotificationConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a ReportChargingProfiles message to the central system + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::ReportChargingProfilesReq& request, + ocpp::messages::ocpp20::ReportChargingProfilesConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a ReservationStatusUpdate message to the central system + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::ReservationStatusUpdateReq& request, + ocpp::messages::ocpp20::ReservationStatusUpdateConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a SecurityEventNotification message to the central system + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::SecurityEventNotificationReq& request, + ocpp::messages::ocpp20::SecurityEventNotificationConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a SignCertificate message to the central system + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::SignCertificateReq& request, + ocpp::messages::ocpp20::SignCertificateConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a StatusNotification message to the central system + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::StatusNotificationReq& request, + ocpp::messages::ocpp20::StatusNotificationConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a TransactionEvent message to the central system + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::TransactionEventReq& request, + ocpp::messages::ocpp20::TransactionEventConf& response, + std::string& error, + std::string& message) = 0; +}; + +} // namespace ocpp20 +} // namespace chargepoint +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_ICHARGEPOINT20_H \ No newline at end of file diff --git a/src/ocpp20/chargepoint/interface/IChargePointConfig20.h b/src/ocpp20/chargepoint/interface/IChargePointConfig20.h new file mode 100644 index 00000000..216bca9c --- /dev/null +++ b/src/ocpp20/chargepoint/interface/IChargePointConfig20.h @@ -0,0 +1,120 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +#ifndef OPENOCPP_OCPP20_ICHARGEPOINTCONFIG20_H +#define OPENOCPP_OCPP20_ICHARGEPOINTCONFIG20_H + +#include +#include + +namespace ocpp +{ +namespace config +{ + +/** @brief Interface to retrieve stack internal configuration for the Charge Point role */ +class IChargePointConfig20 +{ + public: + /** @brief Destructor */ + virtual ~IChargePointConfig20() { } + + // Paths + + /** @brief Path to the database to store persistent data */ + virtual std::string databasePath() const = 0; + /** @brief Path to the JSON schemas to validate the messages */ + virtual std::string jsonSchemasPath() const = 0; + + // Communication parameters + + /** @brief Connection URL */ + virtual std::string connexionUrl() const = 0; + /** @brief Charge point identifier */ + virtual std::string chargePointIdentifier() const = 0; + /** @brief Connection timeout */ + virtual std::chrono::milliseconds connectionTimeout() const = 0; + /** @brief Retry interval */ + virtual std::chrono::milliseconds retryInterval() const = 0; + /** @brief Call request timeout */ + virtual std::chrono::milliseconds callRequestTimeout() const = 0; + /** @brief Websocket PING interval */ + virtual std::chrono::seconds webSocketPingInterval() const = 0; + /** @brief Cipher list to use for TLSv1.2 connections */ + virtual std::string tlsv12CipherList() const = 0; + /** @brief Cipher list to use for TLSv1.3 connections */ + virtual std::string tlsv13CipherList() const = 0; + /** @brief Certification Authority signing chain for the server certificate */ + virtual std::string tlsServerCertificateCa() const = 0; + /** @brief Client certificate */ + virtual std::string tlsClientCertificate() const = 0; + /** @brief Client certificate's private key */ + virtual std::string tlsClientCertificatePrivateKey() const = 0; + /** @brief Client certificate's private key passphrase */ + virtual std::string tlsClientCertificatePrivateKeyPassphrase() const = 0; + /** @brief Allow TLS connections using self-signed certificates + * (Warning : enabling this feature is not recommended in production) */ + virtual bool tlsAllowSelfSignedCertificates() const = 0; + /** @brief Allow TLS connections using expired certificates + * (Warning : enabling this feature is not recommended in production) */ + virtual bool tlsAllowExpiredCertificates() const = 0; + /** @brief Accept non trusted certificates for TLS connections + * (Warning : enabling this feature is not recommended in production) */ + virtual bool tlsAcceptNonTrustedCertificates() const = 0; + /** @brief Skip server name check in certificates for TLS connections + * (Warning : enabling this feature is not recommended in production) */ + virtual bool tlsSkipServerNameCheck() const = 0; + + // Charge point identification + + /** @brief Charge point model */ + virtual std::string chargePointModel() const = 0; + /** @brief Charge point serial number */ + virtual std::string chargePointSerialNumber() const = 0; + /** @brief Charge point vendor */ + virtual std::string chargePointVendor() const = 0; + /** @brief Firmware version */ + virtual std::string firmwareVersion() const = 0; + /** @brief ICCID of the moden's SIM card */ + virtual std::string iccid() const = 0; + /** @brief IMSI of the moden's SIM card */ + virtual std::string imsi() const = 0; + + // Log + + /** @brief Maximum number of entries in the log (0 = no logs in database) */ + virtual unsigned int logMaxEntriesCount() const = 0; + + // Security + + /** @brief Security profile to use for connection with the central system [0-3] */ + virtual unsigned int securityProfile() const = 0; + /** @brief The basic authentication password is used for HTTP Basic Authentication. The password SHALL be a randomly + chosen passwordString with a sufficiently high entropy, consisting of minimum 16 and maximum 40 characters + (alpha-numeric characters and the special characters allowed by passwordString). The password SHALL be sent + as a UTF-8 encoded string (NOT encoded into octet string or base64). This configuration variable is write-only, so + that it cannot be accidentally stored in plaintext by the CSMS when it reads out all configuration variables. + This configuration variable is required unless only "security profile 3 - TLS with client side certificates" is + implemented. */ + virtual std::string basicAuthPassword() const = 0; +}; + +} // namespace config +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_ICHARGEPOINTCONFIG20_H diff --git a/src/ocpp20/chargepoint/interface/IChargePointEventsHandler20.h b/src/ocpp20/chargepoint/interface/IChargePointEventsHandler20.h new file mode 100644 index 00000000..da258e3d --- /dev/null +++ b/src/ocpp20/chargepoint/interface/IChargePointEventsHandler20.h @@ -0,0 +1,587 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* Generated by json2cpp */ + +#ifndef OPENOCPP_OCPP20_ICHARGEPOINTEVENTSHANDLERCHARGEPOINT20_H +#define OPENOCPP_OCPP20_ICHARGEPOINTEVENTSHANDLERCHARGEPOINT20_H +#include "CancelReservation20.h" +#include "CertificateSigned20.h" +#include "ChangeAvailability20.h" +#include "ClearCache20.h" +#include "ClearChargingProfile20.h" +#include "ClearDisplayMessage20.h" +#include "ClearVariableMonitoring20.h" +#include "CustomerInformation20.h" +#include "DataTransfer20.h" +#include "DeleteCertificate20.h" +#include "Get15118EVCertificate20.h" +#include "GetBaseReport20.h" +#include "GetCertificateStatus20.h" +#include "GetChargingProfiles20.h" +#include "GetCompositeSchedule20.h" +#include "GetDisplayMessages20.h" +#include "GetInstalledCertificateIds20.h" +#include "GetLocalListVersion20.h" +#include "GetLog20.h" +#include "GetMonitoringReport20.h" +#include "GetReport20.h" +#include "GetTransactionStatus20.h" +#include "GetVariables20.h" +#include "InstallCertificate20.h" +#include "PublishFirmware20.h" +#include "RequestStartTransaction20.h" +#include "RequestStopTransaction20.h" +#include "ReserveNow20.h" +#include "Reset20.h" +#include "SendLocalList20.h" +#include "SetChargingProfile20.h" +#include "SetDisplayMessage20.h" +#include "SetMonitoringBase20.h" +#include "SetMonitoringLevel20.h" +#include "SetNetworkProfile20.h" +#include "SetVariableMonitoring20.h" +#include "SetVariables20.h" +#include "TriggerMessage20.h" +#include "UnlockConnector20.h" +#include "UnpublishFirmware20.h" +#include "UpdateFirmware20.h" + +namespace ocpp +{ +namespace chargepoint +{ +namespace ocpp20 +{ + +/** @brief Interface for charge point event handlers implementations */ +class IChargePointEventsHandler20 +{ + public: + /** @brief Destructor */ + virtual ~IChargePointEventsHandler20() { } + + /** @brief Called when the first attempt to connect to the central system has failed */ + virtual void connectionFailed() = 0; + + /** + * @brief Called when the charge point connection status has changed + * @param isConnected true if the charge point is connected to the central system, false otherwise + */ + virtual void connectionStateChanged(bool isConnected) = 0; + + // OCPP operations + /** + * @brief Called on reception of a CancelReservation message from the central system + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool onCancelReservation(const ocpp::messages::ocpp20::CancelReservationReq& request, + ocpp::messages::ocpp20::CancelReservationConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Called on reception of a CertificateSigned message from the central system + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool onCertificateSigned(const ocpp::messages::ocpp20::CertificateSignedReq& request, + ocpp::messages::ocpp20::CertificateSignedConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Called on reception of a ChangeAvailability message from the central system + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool onChangeAvailability(const ocpp::messages::ocpp20::ChangeAvailabilityReq& request, + ocpp::messages::ocpp20::ChangeAvailabilityConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Called on reception of a ClearCache message from the central system + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool onClearCache(const ocpp::messages::ocpp20::ClearCacheReq& request, + ocpp::messages::ocpp20::ClearCacheConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Called on reception of a ClearChargingProfile message from the central system + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool onClearChargingProfile(const ocpp::messages::ocpp20::ClearChargingProfileReq& request, + ocpp::messages::ocpp20::ClearChargingProfileConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Called on reception of a ClearDisplayMessage message from the central system + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool onClearDisplayMessage(const ocpp::messages::ocpp20::ClearDisplayMessageReq& request, + ocpp::messages::ocpp20::ClearDisplayMessageConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Called on reception of a ClearVariableMonitoring message from the central system + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool onClearVariableMonitoring(const ocpp::messages::ocpp20::ClearVariableMonitoringReq& request, + ocpp::messages::ocpp20::ClearVariableMonitoringConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Called on reception of a CustomerInformation message from the central system + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool onCustomerInformation(const ocpp::messages::ocpp20::CustomerInformationReq& request, + ocpp::messages::ocpp20::CustomerInformationConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Called on reception of a DataTransfer message from the central system + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool onDataTransfer(const ocpp::messages::ocpp20::DataTransferReq& request, + ocpp::messages::ocpp20::DataTransferConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Called on reception of a DeleteCertificate message from the central system + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool onDeleteCertificate(const ocpp::messages::ocpp20::DeleteCertificateReq& request, + ocpp::messages::ocpp20::DeleteCertificateConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Called on reception of a Get15118EVCertificate message from the central system + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool onGet15118EVCertificate(const ocpp::messages::ocpp20::Get15118EVCertificateReq& request, + ocpp::messages::ocpp20::Get15118EVCertificateConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Called on reception of a GetBaseReport message from the central system + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool onGetBaseReport(const ocpp::messages::ocpp20::GetBaseReportReq& request, + ocpp::messages::ocpp20::GetBaseReportConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Called on reception of a GetCertificateStatus message from the central system + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool onGetCertificateStatus(const ocpp::messages::ocpp20::GetCertificateStatusReq& request, + ocpp::messages::ocpp20::GetCertificateStatusConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Called on reception of a GetChargingProfiles message from the central system + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool onGetChargingProfiles(const ocpp::messages::ocpp20::GetChargingProfilesReq& request, + ocpp::messages::ocpp20::GetChargingProfilesConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Called on reception of a GetCompositeSchedule message from the central system + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool onGetCompositeSchedule(const ocpp::messages::ocpp20::GetCompositeScheduleReq& request, + ocpp::messages::ocpp20::GetCompositeScheduleConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Called on reception of a GetDisplayMessages message from the central system + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool onGetDisplayMessages(const ocpp::messages::ocpp20::GetDisplayMessagesReq& request, + ocpp::messages::ocpp20::GetDisplayMessagesConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Called on reception of a GetInstalledCertificateIds message from the central system + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool onGetInstalledCertificateIds(const ocpp::messages::ocpp20::GetInstalledCertificateIdsReq& request, + ocpp::messages::ocpp20::GetInstalledCertificateIdsConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Called on reception of a GetLocalListVersion message from the central system + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool onGetLocalListVersion(const ocpp::messages::ocpp20::GetLocalListVersionReq& request, + ocpp::messages::ocpp20::GetLocalListVersionConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Called on reception of a GetLog message from the central system + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool onGetLog(const ocpp::messages::ocpp20::GetLogReq& request, + ocpp::messages::ocpp20::GetLogConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Called on reception of a GetMonitoringReport message from the central system + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool onGetMonitoringReport(const ocpp::messages::ocpp20::GetMonitoringReportReq& request, + ocpp::messages::ocpp20::GetMonitoringReportConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Called on reception of a GetReport message from the central system + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool onGetReport(const ocpp::messages::ocpp20::GetReportReq& request, + ocpp::messages::ocpp20::GetReportConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Called on reception of a GetTransactionStatus message from the central system + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool onGetTransactionStatus(const ocpp::messages::ocpp20::GetTransactionStatusReq& request, + ocpp::messages::ocpp20::GetTransactionStatusConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Called on reception of a GetVariables message from the central system + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool onGetVariables(const ocpp::messages::ocpp20::GetVariablesReq& request, + ocpp::messages::ocpp20::GetVariablesConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Called on reception of a InstallCertificate message from the central system + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool onInstallCertificate(const ocpp::messages::ocpp20::InstallCertificateReq& request, + ocpp::messages::ocpp20::InstallCertificateConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Called on reception of a PublishFirmware message from the central system + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool onPublishFirmware(const ocpp::messages::ocpp20::PublishFirmwareReq& request, + ocpp::messages::ocpp20::PublishFirmwareConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Called on reception of a RequestStartTransaction message from the central system + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool onRequestStartTransaction(const ocpp::messages::ocpp20::RequestStartTransactionReq& request, + ocpp::messages::ocpp20::RequestStartTransactionConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Called on reception of a RequestStopTransaction message from the central system + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool onRequestStopTransaction(const ocpp::messages::ocpp20::RequestStopTransactionReq& request, + ocpp::messages::ocpp20::RequestStopTransactionConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Called on reception of a ReserveNow message from the central system + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool onReserveNow(const ocpp::messages::ocpp20::ReserveNowReq& request, + ocpp::messages::ocpp20::ReserveNowConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Called on reception of a Reset message from the central system + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool onReset(const ocpp::messages::ocpp20::ResetReq& request, + ocpp::messages::ocpp20::ResetConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Called on reception of a SendLocalList message from the central system + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool onSendLocalList(const ocpp::messages::ocpp20::SendLocalListReq& request, + ocpp::messages::ocpp20::SendLocalListConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Called on reception of a SetChargingProfile message from the central system + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool onSetChargingProfile(const ocpp::messages::ocpp20::SetChargingProfileReq& request, + ocpp::messages::ocpp20::SetChargingProfileConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Called on reception of a SetDisplayMessage message from the central system + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool onSetDisplayMessage(const ocpp::messages::ocpp20::SetDisplayMessageReq& request, + ocpp::messages::ocpp20::SetDisplayMessageConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Called on reception of a SetMonitoringBase message from the central system + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool onSetMonitoringBase(const ocpp::messages::ocpp20::SetMonitoringBaseReq& request, + ocpp::messages::ocpp20::SetMonitoringBaseConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Called on reception of a SetMonitoringLevel message from the central system + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool onSetMonitoringLevel(const ocpp::messages::ocpp20::SetMonitoringLevelReq& request, + ocpp::messages::ocpp20::SetMonitoringLevelConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Called on reception of a SetNetworkProfile message from the central system + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool onSetNetworkProfile(const ocpp::messages::ocpp20::SetNetworkProfileReq& request, + ocpp::messages::ocpp20::SetNetworkProfileConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Called on reception of a SetVariableMonitoring message from the central system + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool onSetVariableMonitoring(const ocpp::messages::ocpp20::SetVariableMonitoringReq& request, + ocpp::messages::ocpp20::SetVariableMonitoringConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Called on reception of a SetVariables message from the central system + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool onSetVariables(const ocpp::messages::ocpp20::SetVariablesReq& request, + ocpp::messages::ocpp20::SetVariablesConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Called on reception of a TriggerMessage message from the central system + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool onTriggerMessage(const ocpp::messages::ocpp20::TriggerMessageReq& request, + ocpp::messages::ocpp20::TriggerMessageConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Called on reception of a UnlockConnector message from the central system + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool onUnlockConnector(const ocpp::messages::ocpp20::UnlockConnectorReq& request, + ocpp::messages::ocpp20::UnlockConnectorConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Called on reception of a UnpublishFirmware message from the central system + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool onUnpublishFirmware(const ocpp::messages::ocpp20::UnpublishFirmwareReq& request, + ocpp::messages::ocpp20::UnpublishFirmwareConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Called on reception of a UpdateFirmware message from the central system + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool onUpdateFirmware(const ocpp::messages::ocpp20::UpdateFirmwareReq& request, + ocpp::messages::ocpp20::UpdateFirmwareConf& response, + std::string& error, + std::string& message) = 0; +}; + +} // namespace ocpp20 +} // namespace chargepoint +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_ICHARGEPOINTEVENTSHANDLERCHARGEPOINT20_H \ No newline at end of file diff --git a/src/ocpp20/chargepoint/status/IStatusManager20.h b/src/ocpp20/chargepoint/status/IStatusManager20.h new file mode 100644 index 00000000..600bff26 --- /dev/null +++ b/src/ocpp20/chargepoint/status/IStatusManager20.h @@ -0,0 +1,76 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +#ifndef OPENOCPP_OCPP20_ISTATUSMANAGER20_H +#define OPENOCPP_OCPP20_ISTATUSMANAGER20_H + +#include "BootNotification20.h" +#include "ConnectorStatusEnumType20.h" +#include "RegistrationStatusEnumType20.h" + +namespace ocpp +{ +namespace chargepoint +{ +namespace ocpp20 +{ + +class IStatusManager +{ + public: + /** @brief Destructor */ + virtual ~IStatusManager() { } + + /** + * @brief Get the registration status with the central system + * @return Registration status (see RegistrationStatusEnumType enum) + */ + virtual ocpp::types::ocpp20::RegistrationStatusEnumType getRegistrationStatus() = 0; + + /** + * @brief Force the registration status with the central system + * @param status New registration status + */ + virtual void forceRegistrationStatus(ocpp::types::ocpp20::RegistrationStatusEnumType status) = 0; + + /** + * @brief Update the charge point connection status + * @param is_connected true if the charge point is connected to the central system, false otherwise + */ + virtual void updateConnectionStatus(bool is_connected) = 0; + + /** + * @brief Update the status of a connector + * @param evse_id Id of the EVSE + * @param connector_id Id of the connector + * @param status Status of the connector + * @return true if the status has been notified, false otherwise + */ + virtual bool updateConnectorStatus(unsigned int evse_id, + unsigned int connector_id, + ocpp::types::ocpp20::ConnectorStatusEnumType status) = 0; + + /** @brief Reset the hearbeat timer */ + virtual void resetHeartBeatTimer() = 0; +}; + +} // namespace ocpp20 +} // namespace chargepoint +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_ISTATUSMANAGER20_H diff --git a/src/ocpp20/chargepoint/status/StatusManager20.cpp b/src/ocpp20/chargepoint/status/StatusManager20.cpp new file mode 100644 index 00000000..2bd1468f --- /dev/null +++ b/src/ocpp20/chargepoint/status/StatusManager20.cpp @@ -0,0 +1,580 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +#include "StatusManager20.h" +#include "BootNotification20.h" +#include "Connectors20.h" +#include "GenericMessageSender.h" +#include "Heartbeat20.h" +#include "IBasicChargePointEventsHandler20.h" +#include "IChargePointConfig20.h" +#include "IDeviceModel20.h" +#include "IInternalConfigManager.h" +#include "InternalConfigKeys.h" +#include "Logger.h" +#include "StatusNotification20.h" +#include "WorkerThreadPool.h" + +#include +#include + +using namespace ocpp::messages; +using namespace ocpp::messages::ocpp20; +using namespace ocpp::types; +using namespace ocpp::types::ocpp20; + +namespace ocpp +{ +namespace chargepoint +{ +namespace ocpp20 +{ + +/** @brief Mandatory heartbeat period */ +static const std::chrono::hours MANDATORY_HEARTBEAT_PERIOD(24); + +/** @brief Constructor */ +StatusManager::StatusManager(const ocpp::config::IChargePointConfig20& stack_config, + IDeviceModel& device_model, + IBasicChargePointEventsHandler& events_handler, + ocpp::config::IInternalConfigManager& internal_config, + ocpp::helpers::ITimerPool& timer_pool, + ocpp::helpers::WorkerThreadPool& worker_pool, + Connectors& connectors, + ocpp::messages::GenericMessageSender& msg_sender, + ITriggerMessageManager& trigger_manager, + ocpp::types::ocpp20::BootReasonEnumType boot_reason) + : m_stack_config(stack_config), + m_device_model(device_model), + m_events_handler(events_handler), + m_internal_config(internal_config), + m_worker_pool(worker_pool), + m_connectors(connectors), + m_msg_sender(msg_sender), + m_boot_reason(boot_reason), + m_registration_status(RegistrationStatusEnumType::Rejected), + m_force_boot_notification(false), + m_boot_notification_sent(false), + m_boot_notification_timer(timer_pool, "Boot notification"), + m_heartbeat_timer(timer_pool, "Heartbeat"), + m_heartbeat_interval(0), + m_next_heartbeat_timestamp(std::chrono::steady_clock::now() + MANDATORY_HEARTBEAT_PERIOD), + m_last_disconnect_timestamp() +{ + trigger_manager.registerHandler(MessageTriggerEnumType::BootNotification, *this); + trigger_manager.registerHandler(MessageTriggerEnumType::StatusNotification, *this); + trigger_manager.registerHandler(MessageTriggerEnumType::Heartbeat, *this); + + m_boot_notification_timer.setCallback([this] { m_worker_pool.run(std::bind(&StatusManager::bootNotificationProcess, this)); }); + m_heartbeat_timer.setCallback([this] { m_worker_pool.run(std::bind(&StatusManager::heartBeatProcess, this)); }); + + // Look for HeartBeatInterval variable in the device model + GetVariableDataType var_req; + var_req.component.name.assign("OCPPCommCtrlr"); + var_req.variable.name.assign("HeartbeatInterval"); + GetVariableResultType var_res = m_device_model.getVariable(var_req); + if (var_res.attributeStatus == GetVariableStatusEnumType::Accepted) + { + m_heartbeat_interval = std::chrono::seconds(std::atoi(var_res.attributeValue.value().c_str())); + } + else + { + LOG_WARNING << "OCPPCommCtrlr.HeartbeatInterval not present in the device model, using default value = 1h"; + m_heartbeat_interval = std::chrono::hours(1); + } +} + +/** @brief Destructor */ +StatusManager::~StatusManager() { } + +/** @copydoc void IStatusManager::forceRegistrationStatus(ocpp::types::ocpp20::RegistrationStatusEnumType) */ +void StatusManager::forceRegistrationStatus(ocpp::types::ocpp20::RegistrationStatusEnumType status) +{ + if (status != m_registration_status) + { + m_force_boot_notification = true; + m_boot_notification_sent = false; + } + m_registration_status = status; +} + +/** @copydoc void IStatusManager::updateConnectionStatus(bool) */ +void StatusManager::updateConnectionStatus(bool is_connected) +{ + if (is_connected) + { + // If not accepted by the central system, restart boot notification process + if (m_force_boot_notification || (m_registration_status != RegistrationStatusEnumType::Accepted)) + { + m_boot_notification_timer.start(std::chrono::milliseconds(1u), true); + } + else + { + // Look for OfflineThreshold variable in the device model + std::chrono::seconds offline_threshold(0); + GetVariableDataType var_req; + var_req.component.name.assign("OCPPCommCtrlr"); + var_req.variable.name.assign("OfflineThreshold"); + GetVariableResultType var_res = m_device_model.getVariable(var_req); + if (var_res.attributeStatus == GetVariableStatusEnumType::Accepted) + { + offline_threshold = std::chrono::seconds(std::atoi(var_res.attributeValue.value().c_str())); + } + else + { + LOG_WARNING << "OCPPCommCtrlr.OfflineThreshold not present in the device model"; + } + + bool notify_all_connectors; + if ((std::chrono::steady_clock::now() - m_last_disconnect_timestamp) >= offline_threshold) + { + // Notify status of all the connectors + notify_all_connectors = true; + } + else + { + // Only if the status of a connector has changed since the last notification + // to the central system, send the new connector status + notify_all_connectors = false; + } + + // Notify connectors status + for (const Evse* evse : m_connectors.getEvses()) + { + for (const Connector* connector : evse->connectors) + { + if (notify_all_connectors || (connector->status != connector->last_notified_status)) + { + statusNotificationProcess(evse->id, connector->id); + } + } + } + + // Restart heartbeat process + m_heartbeat_timer.start(m_heartbeat_interval); + } + } + else + { + // Stop boot notification and heartbeat processes + m_boot_notification_timer.stop(); + m_heartbeat_timer.stop(); + m_last_disconnect_timestamp = std::chrono::steady_clock::now(); + } +} + +/** @copydoc bool IStatusManager::updateConnectorStatus(unsigned int, + * unsigned int, + * ocpp::types::ocpp20::ConnectorStatusEnumType) + */ +bool StatusManager::updateConnectorStatus(unsigned int evse_id, + unsigned int connector_id, + ocpp::types::ocpp20::ConnectorStatusEnumType status) +{ + bool ret = false; + + // Get selected connector + Connector* connector = m_connectors.getConnector(evse_id, connector_id); + if (connector) + { + std::lock_guard lock(connector->mutex); + + // Check if status has changed + if (connector->status != status) + { + std::string status_str = ConnectorStatusEnumTypeHelper.toString(status); + LOG_INFO << "EVSE " << evse_id << " - Connector " << connector_id << " : " << ConnectorStatusEnumTypeHelper.toString(status); + + // Save new status + connector->status = status; + connector->status_timestamp = DateTime::now(); + m_connectors.saveConnector(evse_id, connector->id); + + // Update device model + SetVariableDataType var_req; + var_req.component.name.assign("Connector"); + var_req.component.evse.value().id = evse_id; + var_req.component.evse.value().connectorId = connector_id; + var_req.variable.name.assign("AvailabilityState"); + var_req.attributeValue.assign(status_str); + SetVariableResultType var_res = m_device_model.updateVariable(var_req); + if (var_res.attributeStatus != SetVariableStatusEnumType::Accepted) + { + LOG_WARNING << "Connector.AvailabilityState couldn't be updated in the device model, EVSE = " << evse_id + << " - Connector = " << connector_id; + } + + // Compute EVSE status + ConnectorStatusEnumType evse_status = ConnectorStatusEnumType::Available; + Evse* evse = m_connectors.getEvse(evse_id); + if (evse) + { + for (const Connector* connector : evse->connectors) + { + if (static_cast(connector->status) >= static_cast(evse_status)) + { + evse_status = connector->status; + } + } + if (evse_status != evse->status) + { + // Save new status + evse->status = evse_status; + evse->status_timestamp = DateTime::now(); + m_connectors.saveEvse(evse_id); + + // Update device model + var_req.component.name.assign("EVSE"); + var_req.component.evse.value().connectorId.clear(); + var_req.attributeValue.assign(status_str); + var_res = m_device_model.updateVariable(var_req); + if (var_res.attributeStatus != SetVariableStatusEnumType::Accepted) + { + LOG_WARNING << "EVSE.AvailabilityState couldn't be updated in the device model, EVSE = " << evse_id; + } + } + } + + // Check registration status + if (m_registration_status == RegistrationStatusEnumType::Accepted) + { + // Notify now + m_worker_pool.run(std::bind(&StatusManager::statusNotificationProcess, this, evse_id, connector_id)); + } + } + ret = true; + } + + return ret; +} + +/** @copydoc void IStatusManager::resetHeartBeatTimer() */ +void StatusManager::resetHeartBeatTimer() +{ + if (m_heartbeat_timer.isStarted() && !m_heartbeat_timer.isSingleShot()) + { + auto now = std::chrono::steady_clock::now(); + if ((now + m_heartbeat_interval) >= m_next_heartbeat_timestamp) + { + auto interval = m_next_heartbeat_timestamp - now; + m_heartbeat_timer.restart(std::chrono::duration_cast(interval), true); + } + else + { + m_heartbeat_timer.restart(m_heartbeat_interval); + } + } +} + +/** @copydoc bool ITriggerMessageManager::ITriggerMessageHandler::onTriggerMessage(ocpp::types::ocpp20::MessageTriggerEnumType, + * const ocpp::types::Optional&) + */ +bool StatusManager::onTriggerMessage(ocpp::types::ocpp20::MessageTriggerEnumType message, + const ocpp::types::Optional& evse) +{ + bool ret = true; + + switch (message) + { + case MessageTriggerEnumType::BootNotification: + { + m_worker_pool.run( + [this] + { + // To let some time for the trigger message reply + std::this_thread::sleep_for(std::chrono::milliseconds(250u)); + sendBootNotification(); + }); + } + break; + + case MessageTriggerEnumType::Heartbeat: + { + m_worker_pool.run( + [this] + { + // To let some time for the trigger message reply + std::this_thread::sleep_for(std::chrono::milliseconds(250u)); + heartBeatProcess(); + }); + } + break; + + case MessageTriggerEnumType::StatusNotification: + { + if (evse.isSet()) + { + if (evse.value().connectorId.isSet()) + { + m_worker_pool.run( + [this, evse_id = evse.value().id, connector_id = evse.value().connectorId.value()] + { + // To let some time for the trigger message reply + std::this_thread::sleep_for(std::chrono::milliseconds(250u)); + statusNotificationProcess(evse_id, connector_id); + }); + } + else + { + const Evse* req_evse = m_connectors.getEvse(evse.value().id); + if (req_evse) + { + for (const Connector* connector : req_evse->connectors) + { + m_worker_pool.run( + [this, evse_id = req_evse->id, connector_id = connector->id] + { + // To let some time for the trigger message reply + std::this_thread::sleep_for(std::chrono::milliseconds(250u)); + statusNotificationProcess(evse_id, connector_id); + }); + } + } + } + } + else + { + for (const Evse* evse : m_connectors.getEvses()) + { + for (const Connector* connector : evse->connectors) + { + m_worker_pool.run( + [this, evse_id = evse->id, connector_id = connector->id] + { + // To let some time for the trigger message reply + std::this_thread::sleep_for(std::chrono::milliseconds(250u)); + statusNotificationProcess(evse_id, connector_id); + }); + } + } + } + } + break; + + default: + ret = false; + break; + } + + return ret; +} + +/** @brief Boot notification process thread */ +void StatusManager::bootNotificationProcess() +{ + if (m_boot_notification_sent == false) + { + // Fill boot notification request + BootNotificationReq boot_req; + boot_req.reason = m_boot_reason; + boot_req.chargingStation.model.assign(m_stack_config.chargePointModel()); + boot_req.chargingStation.vendorName.assign(m_stack_config.chargePointVendor()); + if (!m_stack_config.chargePointSerialNumber().empty()) + { + boot_req.chargingStation.serialNumber.value().assign(m_stack_config.chargePointSerialNumber()); + } + if (!m_stack_config.firmwareVersion().empty()) + { + boot_req.chargingStation.firmwareVersion.value().assign(m_stack_config.firmwareVersion()); + } + if (!m_stack_config.imsi().empty()) + { + boot_req.chargingStation.modem.value().imsi.value().assign(m_stack_config.imsi()); + } + if (!m_stack_config.iccid().empty()) + { + boot_req.chargingStation.modem.value().iccid.value().assign(m_stack_config.iccid()); + } + + m_registration_status = RegistrationStatusEnumType::Rejected; + + // Send BootNotificationRequest + BootNotificationConf boot_conf; + CallResult result = m_msg_sender.call(BOOTNOTIFICATION_ACTION, boot_req, boot_conf); + if (result == CallResult::Ok) + { + if (boot_conf.status == RegistrationStatusEnumType::Accepted) + { + m_boot_notification_sent = true; + + // Send first status notifications + for (const Evse* evse : m_connectors.getEvses()) + { + for (const Connector* connector : evse->connectors) + { + statusNotificationProcess(evse->id, connector->id); + } + } + + // Configure hearbeat + std::chrono::seconds interval(boot_conf.interval); + m_heartbeat_interval = std::chrono::seconds(boot_conf.interval); + m_next_heartbeat_timestamp = std::chrono::steady_clock::now() + MANDATORY_HEARTBEAT_PERIOD; + m_heartbeat_timer.start(m_heartbeat_interval); + + // Update value in device model + SetVariableDataType var_req; + var_req.component.name.assign("OCPPCommCtrlr"); + var_req.variable.name.assign("HeartbeatInterval"); + var_req.attributeValue.assign(std::to_string(m_heartbeat_interval.count())); + SetVariableResultType var_res = m_device_model.setVariable(var_req); + if (var_res.attributeStatus != SetVariableStatusEnumType::Accepted) + { + LOG_WARNING << "OCPPCommCtrlr.HeartbeatInterval couldn't be updated in the device model"; + } + } + else + { + // Schedule next retry + m_boot_notification_timer.start(std::chrono::seconds(boot_conf.interval), true); + } + + m_registration_status = boot_conf.status; + std::string registration_status = RegistrationStatusEnumTypeHelper.toString(m_registration_status); + LOG_INFO << "Registration status : " << registration_status; + + // Save registration status + m_force_boot_notification = false; + m_internal_config.setKey(LAST_REGISTRATION_STATUS_KEY, registration_status); + + // Notify boot + m_events_handler.bootNotification(m_registration_status, boot_conf.currentTime); + } + else + { + // Schedule next retry + m_boot_notification_timer.start(m_stack_config.retryInterval(), true); + } + } + else + { + // If the status of a connector has changed since the last notification + // to the central system, send the new connector status + for (const Evse* evse : m_connectors.getEvses()) + { + for (const Connector* connector : evse->connectors) + { + if (connector->status != connector->last_notified_status) + { + statusNotificationProcess(evse->id, connector->id); + } + } + } + + // Configure hearbeat + m_heartbeat_timer.start(m_heartbeat_interval); + } +} + +/** @brief Heartbeat process */ +void StatusManager::heartBeatProcess() +{ + HeartbeatReq heartbeat_req; + HeartbeatConf heartbeat_conf; + CallResult result = m_msg_sender.call(HEARTBEAT_ACTION, heartbeat_req, heartbeat_conf); + if (result == CallResult::Ok) + { + LOG_INFO << "Heartbeat : " << heartbeat_conf.currentTime.str(); + + m_next_heartbeat_timestamp = std::chrono::steady_clock::now() + MANDATORY_HEARTBEAT_PERIOD; + m_events_handler.datetimeReceived(heartbeat_conf.currentTime); + if (m_heartbeat_timer.isSingleShot()) + { + m_heartbeat_timer.restart(m_heartbeat_interval); + } + } +} + +/** @brief Status notification process */ +void StatusManager::statusNotificationProcess(unsigned int evse_id, unsigned int connector_id) +{ + // Get connector + Connector* connector = m_connectors.getConnector(evse_id, connector_id); + if (connector) + { + // Send request + StatusNotificationReq status_req; + status_req.evseId = evse_id; + status_req.connectorId = connector->id; + status_req.connectorStatus = connector->status; + status_req.timestamp = connector->status_timestamp; + + StatusNotificationConf status_conf; + CallResult result = m_msg_sender.call(STATUSNOTIFICATION_ACTION, status_req, status_conf); + if (result == CallResult::Ok) + { + // Update last notified status + connector->last_notified_status = connector->status; + } + } +} + +/** @brief Send the boot notification message */ +void StatusManager::sendBootNotification() +{ + // Fill boot notification request + BootNotificationReq boot_req; + boot_req.reason = BootReasonEnumType::Triggered; + boot_req.chargingStation.model.assign(m_stack_config.chargePointModel()); + boot_req.chargingStation.vendorName.assign(m_stack_config.chargePointVendor()); + if (!m_stack_config.chargePointSerialNumber().empty()) + { + boot_req.chargingStation.serialNumber.value().assign(m_stack_config.chargePointSerialNumber()); + } + if (!m_stack_config.firmwareVersion().empty()) + { + boot_req.chargingStation.firmwareVersion.value().assign(m_stack_config.firmwareVersion()); + } + if (!m_stack_config.imsi().empty()) + { + boot_req.chargingStation.modem.value().imsi.value().assign(m_stack_config.imsi()); + } + if (!m_stack_config.iccid().empty()) + { + boot_req.chargingStation.modem.value().iccid.value().assign(m_stack_config.iccid()); + } + + // Send BootNotificationRequest + BootNotificationConf boot_conf; + CallResult result = m_msg_sender.call(BOOTNOTIFICATION_ACTION, boot_req, boot_conf); + if (result == CallResult::Ok) + { + // Save registration status + m_registration_status = boot_conf.status; + + // Restart hearbeat timer + std::chrono::seconds interval(boot_conf.interval); + m_heartbeat_interval = std::chrono::seconds(boot_conf.interval); + m_heartbeat_timer.restart(m_heartbeat_interval); + + // Save registration status + m_force_boot_notification = false; + m_internal_config.setKey(LAST_REGISTRATION_STATUS_KEY, RegistrationStatusEnumTypeHelper.toString(m_registration_status)); + if (m_registration_status == RegistrationStatusEnumType::Accepted) + { + // Cancel next retry + m_boot_notification_timer.stop(); + } + } + + return; +} + +} // namespace ocpp20 +} // namespace chargepoint +} // namespace ocpp diff --git a/src/ocpp20/chargepoint/status/StatusManager20.h b/src/ocpp20/chargepoint/status/StatusManager20.h new file mode 100644 index 00000000..a8b227d8 --- /dev/null +++ b/src/ocpp20/chargepoint/status/StatusManager20.h @@ -0,0 +1,151 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +#ifndef OPENOCPP_OCPP20_STATUSMANAGER20_H +#define OPENOCPP_OCPP20_STATUSMANAGER20_H + +#include "IStatusManager20.h" +#include "ITriggerMessageManager20.h" +#include "Timer.h" + +namespace ocpp +{ +// Forward declarations +namespace messages +{ +class GenericMessageSender; +} // namespace messages +namespace config +{ +class IChargePointConfig20; +class IInternalConfigManager; +} // namespace config +namespace helpers +{ +class WorkerThreadPool; +} // namespace helpers + +// Main namespace +namespace chargepoint +{ +namespace ocpp20 +{ + +class Connectors; +class IBasicChargePointEventsHandler; +class IDeviceModel; + +/** @brief Handle charge point status (boot notification, status notification, heartbeat) */ +class StatusManager : public IStatusManager, public ITriggerMessageManager::ITriggerMessageHandler +{ + public: + /** @brief Constructor */ + StatusManager(const ocpp::config::IChargePointConfig20& stack_config, + IDeviceModel& device_model, + IBasicChargePointEventsHandler& events_handler, + ocpp::config::IInternalConfigManager& internal_config, + ocpp::helpers::ITimerPool& timer_pool, + ocpp::helpers::WorkerThreadPool& worker_pool, + Connectors& connectors, + ocpp::messages::GenericMessageSender& msg_sender, + ITriggerMessageManager& trigger_manager, + ocpp::types::ocpp20::BootReasonEnumType boot_reason); + + /** @brief Destructor */ + virtual ~StatusManager(); + + // IStatusManager interface + + /** @copydoc ocpp::types::ocpp20::RegistrationStatusEnumType IStatusManager::getRegistrationStatus() */ + ocpp::types::ocpp20::RegistrationStatusEnumType getRegistrationStatus() override { return m_registration_status; } + + /** @copydoc void IStatusManager::forceRegistrationStatus(ocpp::types::ocpp20::RegistrationStatusEnumType) */ + void forceRegistrationStatus(ocpp::types::ocpp20::RegistrationStatusEnumType status) override; + + /** @copydoc void IStatusManager::updateConnectionStatus(bool) */ + void updateConnectionStatus(bool is_connected) override; + + /** @copydoc bool IStatusManager::updateConnectorStatus(unsigned int, + * unsigned int, + * ocpp::types::ocpp20::ConnectorStatusEnumType) + */ + bool updateConnectorStatus(unsigned int evse_id, + unsigned int connector_id, + ocpp::types::ocpp20::ConnectorStatusEnumType status) override; + + /** @copydoc void IStatusManager::resetHeartBeatTimer() */ + void resetHeartBeatTimer() override; + + // ITriggerMessageManager::ITriggerMessageHandler interface + + /** @copydoc bool ITriggerMessageManager::ITriggerMessageHandler::onTriggerMessage(ocpp::types::ocpp20::MessageTriggerEnumType, + * const ocpp::types::Optional&) + */ + bool onTriggerMessage(ocpp::types::ocpp20::MessageTriggerEnumType message, + const ocpp::types::Optional& evse) override; + + private: + /** @brief Stack configuration */ + const ocpp::config::IChargePointConfig20& m_stack_config; + /** @brief Device model */ + IDeviceModel& m_device_model; + /** @brief User defined events handler */ + IBasicChargePointEventsHandler& m_events_handler; + /** @brief Charge point's internal configuration */ + ocpp::config::IInternalConfigManager& m_internal_config; + /** @brief Worker thread pool */ + ocpp::helpers::WorkerThreadPool& m_worker_pool; + /** @brief Charge point's connectors */ + Connectors& m_connectors; + /** @brief Message sender */ + ocpp::messages::GenericMessageSender& m_msg_sender; + + /** @brief Boot reason */ + const ocpp::types::ocpp20::BootReasonEnumType m_boot_reason; + /** @brief Registration status */ + ocpp::types::ocpp20::RegistrationStatusEnumType m_registration_status; + /** @brief Indicate if the boot notification message must be inconditionnaly sent on connection */ + bool m_force_boot_notification; + /** @brief Indicate if the boot notification message has been sent */ + bool m_boot_notification_sent; + /** @brief Boot notification process timer */ + ocpp::helpers::Timer m_boot_notification_timer; + /** @brief Heartbeat timer */ + ocpp::helpers::Timer m_heartbeat_timer; + /** @brief Heartbeat interval */ + std::chrono::seconds m_heartbeat_interval; + /** @brief Next mandatory heartbeat timestamp */ + std::chrono::steady_clock::time_point m_next_heartbeat_timestamp; + /** @brief Last disconnection timestamp */ + std::chrono::steady_clock::time_point m_last_disconnect_timestamp; + + /** @brief Boot notification process */ + void bootNotificationProcess(); + /** @brief Heartbeat process */ + void heartBeatProcess(); + /** @brief Status notification process */ + void statusNotificationProcess(unsigned int evse_id, unsigned int connector_id); + /** @brief Send the boot notification message */ + void sendBootNotification(); +}; + +} // namespace ocpp20 +} // namespace chargepoint +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_STATUSMANAGER20_H diff --git a/src/ocpp20/chargepoint/trigger/ITriggerMessageManager20.h b/src/ocpp20/chargepoint/trigger/ITriggerMessageManager20.h new file mode 100644 index 00000000..15d9344f --- /dev/null +++ b/src/ocpp20/chargepoint/trigger/ITriggerMessageManager20.h @@ -0,0 +1,72 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +#ifndef OPENOCPP_OCPP20_ITRIGGERMESSAGEMANAGER20_H +#define OPENOCPP_OCPP20_ITRIGGERMESSAGEMANAGER20_H + +#include "EVSEType20.h" +#include "MessageTriggerEnumType20.h" +#include "Optional.h" + +namespace ocpp +{ +namespace chargepoint +{ +namespace ocpp20 +{ + +/** @brief Interface for TriggerMessage managers implementation */ +class ITriggerMessageManager +{ + public: + // Forward declaration + class ITriggerMessageHandler; + + /** @brief Destructor */ + virtual ~ITriggerMessageManager() { } + + /** + * @brief Register a handler for a specific message trigger request + * @param message Type of trigger message requested + * @param handler Handler to register + */ + virtual void registerHandler(ocpp::types::ocpp20::MessageTriggerEnumType message, ITriggerMessageHandler& handler) = 0; + + /** @brief Interface for trigger message handlers implementations */ + class ITriggerMessageHandler + { + public: + /** @brief Destructor */ + virtual ~ITriggerMessageHandler() { } + + /** + * @brief Called on reception of a trigger message request + * @param message Type of trigger message requested + * @param evse EVSE concerned by the request + * @return true if the requested message can be sent, false otherwise + */ + virtual bool onTriggerMessage(ocpp::types::ocpp20::MessageTriggerEnumType message, + const ocpp::types::Optional& evse) = 0; + }; +}; + +} // namespace ocpp20 +} // namespace chargepoint +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_ITRIGGERMESSAGEMANAGER20_H diff --git a/src/ocpp20/chargepoint/trigger/TriggerMessageManager20.cpp b/src/ocpp20/chargepoint/trigger/TriggerMessageManager20.cpp new file mode 100644 index 00000000..488c18e8 --- /dev/null +++ b/src/ocpp20/chargepoint/trigger/TriggerMessageManager20.cpp @@ -0,0 +1,129 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +#include "TriggerMessageManager20.h" +#include "IConnectors20.h" +#include "IRpc.h" +#include "Logger.h" + +using namespace ocpp::messages; +using namespace ocpp::messages::ocpp20; +using namespace ocpp::types; +using namespace ocpp::types::ocpp20; + +namespace ocpp +{ +namespace chargepoint +{ +namespace ocpp20 +{ + +/** @brief Constructor */ +TriggerMessageManager::TriggerMessageManager(IConnectors& connectors, + const ocpp::messages::GenericMessagesConverter& messages_converter, + ocpp::messages::IMessageDispatcher& msg_dispatcher) + : GenericMessageHandler(TRIGGERMESSAGE_ACTION, messages_converter), + m_connectors(connectors), + m_standard_handlers() +{ + msg_dispatcher.registerHandler(TRIGGERMESSAGE_ACTION, + *dynamic_cast*>(this)); +} + +/** @brief Destructor */ +TriggerMessageManager::~TriggerMessageManager() { } + +/** @copydoc void ITriggerMessageManager::registerHandler(ocpp::types::ocpp20::MessageTriggerEnumType, ITriggerMessageHandler&) */ +void TriggerMessageManager::registerHandler(ocpp::types::ocpp20::MessageTriggerEnumType message, ITriggerMessageHandler& handler) +{ + m_standard_handlers[message] = &handler; +} + +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool TriggerMessageManager::handleMessage(const ocpp::messages::ocpp20::TriggerMessageReq& request, + ocpp::messages::ocpp20::TriggerMessageConf& response, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + (void)error_code; + (void)error_message; + + std::string trigger_message = MessageTriggerEnumTypeHelper.toString(request.requestedMessage); + LOG_INFO << "Trigger message requested : " << trigger_message + << " - EVSE = " << (request.evse.isSet() ? std::to_string(request.evse.value().id) : "not set") << " - connectorId = " + << ((request.evse.isSet() && request.evse.value().connectorId.isSet()) + ? std::to_string(request.evse.value().connectorId.value()) + : "not set"); + + // Look for the corresponding handler + auto it = m_standard_handlers.find(request.requestedMessage); + if (it == m_standard_handlers.end()) + { + // No handler => not implemented + response.status = TriggerMessageStatusEnumType::NotImplemented; + LOG_WARNING << "Trigger message not implemented : " << trigger_message; + } + else + { + // Check EVSE/connector validity + response.status = TriggerMessageStatusEnumType::Accepted; + if (request.evse.isSet()) + { + if (m_connectors.getEvse(request.evse.value().id)) + { + if (request.evse.value().connectorId.isSet() && + !m_connectors.getConnector(request.evse.value().id, request.evse.value().connectorId.value())) + { + LOG_ERROR << "Trigger message, invalid connector id : EVSE id = " << request.evse.value().id + << " - Connector id = " << request.evse.value().connectorId.value(); + response.status = TriggerMessageStatusEnumType::Rejected; + } + } + else + { + LOG_ERROR << "Trigger message, invalid EVSE id : " << request.evse.value().id; + response.status = TriggerMessageStatusEnumType::Rejected; + } + } + if (response.status == TriggerMessageStatusEnumType::Accepted) + { + // Call handler + if (it->second->onTriggerMessage(request.requestedMessage, request.evse)) + { + LOG_INFO << "Trigger message accepted : " << trigger_message; + } + else + { + response.status = TriggerMessageStatusEnumType::Rejected; + LOG_WARNING << "Trigger message rejected : " << trigger_message; + } + } + } + + return ret; +} + +} // namespace ocpp20 +} // namespace chargepoint +} // namespace ocpp diff --git a/src/ocpp20/chargepoint/trigger/TriggerMessageManager20.h b/src/ocpp20/chargepoint/trigger/TriggerMessageManager20.h new file mode 100644 index 00000000..3f1f8854 --- /dev/null +++ b/src/ocpp20/chargepoint/trigger/TriggerMessageManager20.h @@ -0,0 +1,87 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +#ifndef OPENOCPP_OCPP20_TRIGGERMESSAGEMANAGER20_H +#define OPENOCPP_OCPP20_TRIGGERMESSAGEMANAGER20_H + +#include "GenericMessageHandler.h" +#include "ITriggerMessageManager20.h" +#include "TriggerMessage20.h" + +#include + +namespace ocpp +{ +// Forward declarations +namespace messages +{ +class IMessageDispatcher; +} // namespace messages + +// Main namespace +namespace chargepoint +{ +namespace ocpp20 +{ + +class IConnectors; + +/** @brief Manage TriggerMessage requests */ +class TriggerMessageManager + : public ITriggerMessageManager, + public ocpp::messages::GenericMessageHandler +{ + public: + /** @brief Constructor */ + TriggerMessageManager(IConnectors& connectors, + const ocpp::messages::GenericMessagesConverter& messages_converter, + ocpp::messages::IMessageDispatcher& msg_dispatcher); + + /** @brief Destructor */ + virtual ~TriggerMessageManager(); + + // ITriggerMessageManager interface + + /** @copydoc void ITriggerMessageManager::registerHandler(ocpp::types::ocpp20::MessageTriggerEnumType, ITriggerMessageHandler&) */ + void registerHandler(ocpp::types::ocpp20::MessageTriggerEnumType message, ITriggerMessageHandler& handler) override; + + // GenericMessageHandler interface + + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::TriggerMessageReq& request, + ocpp::messages::ocpp20::TriggerMessageConf& response, + std::string& error_code, + std::string& error_message) override; + + private: + /** @brief Charge point's connectors */ + IConnectors& m_connectors; + + /** @brief Handlers for trigger messages */ + std::map m_standard_handlers; +}; + +} // namespace ocpp20 +} // namespace chargepoint +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_TRIGGERMESSAGEMANAGER20_H diff --git a/src/ocpp20/localcontroller/CMakeLists.txt b/src/ocpp20/localcontroller/CMakeLists.txt new file mode 100644 index 00000000..21e4fd75 --- /dev/null +++ b/src/ocpp20/localcontroller/CMakeLists.txt @@ -0,0 +1,29 @@ +###################################################### +# OCPP 2.0 localcontroller library # +###################################################### + + +# Library target +add_library(localcontroller20 OBJECT + LocalController20.cpp + + centralsystem/CentralSystemHandler20.cpp + centralsystem/CentralSystemProxy20.cpp + + chargepoint/ChargePointHandler20.cpp + chargepoint/ChargePointProxy20.cpp +) + +# Exported includes +target_include_directories(localcontroller20 PUBLIC interface) + +# Private includes +target_include_directories(localcontroller20 PRIVATE . + centralsystem + chargepoint + config) + +# Dependencies +target_link_libraries(localcontroller20 + centralsystem20 +) diff --git a/src/ocpp20/localcontroller/LocalController20.cpp b/src/ocpp20/localcontroller/LocalController20.cpp new file mode 100644 index 00000000..334dc0fc --- /dev/null +++ b/src/ocpp20/localcontroller/LocalController20.cpp @@ -0,0 +1,391 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +#include "LocalController20.h" +#include "CentralSystemProxy20.h" +#include "ChargePointProxy20.h" +#include "DateTime.h" +#include "ILocalControllerEventsHandler20.h" +#include "InternalConfigKeys.h" +#include "Logger.h" +#include "TimerPool.h" +#include "Version.h" +#include "WebsocketFactory.h" +#include "WorkerThreadPool.h" + +#include +#include +#include + +using namespace ocpp::types; +using namespace ocpp::types::ocpp20; + +namespace ocpp +{ +namespace localcontroller +{ +namespace ocpp20 +{ + +/** @brief Instanciate a local controller */ +std::unique_ptr ILocalController20::create(const ocpp::config::ILocalControllerConfig20& stack_config, + ILocalControllerEventsHandler20& events_handler) +{ + std::shared_ptr timer_pool(new ocpp::helpers::TimerPool()); + std::shared_ptr worker_pool = + std::make_shared(2u); // 1 asynchronous timer operations + 1 for asynchronous jobs/responses + return std::unique_ptr(new LocalController20(stack_config, events_handler, timer_pool, worker_pool)); +} + +/** @brief Instanciate a local controller with the provided timer and worker pools */ +std::unique_ptr ILocalController20::create(const ocpp::config::ILocalControllerConfig20& stack_config, + ILocalControllerEventsHandler20& events_handler, + std::shared_ptr timer_pool, + std::shared_ptr worker_pool) +{ + return std::unique_ptr(new LocalController20(stack_config, events_handler, timer_pool, worker_pool)); +} + +/** @brief Constructor */ +LocalController20::LocalController20(const ocpp::config::ILocalControllerConfig20& stack_config, + ILocalControllerEventsHandler20& events_handler, + std::shared_ptr timer_pool, + std::shared_ptr worker_pool) + : m_stack_config(stack_config), + m_events_handler(events_handler), + m_timer_pool(timer_pool), + m_worker_pool(worker_pool), + m_database(), + m_internal_config(), + m_messages_converter(), + m_messages_validator(), + m_ws_server(), + m_rpc_server(), + m_rpc_pool(), + m_uptime_timer(), + m_uptime(0), + m_total_uptime(0) +{ + // Open database + if (!m_stack_config.databasePath().empty()) + { + m_database = std::make_unique(); + m_internal_config = std::make_unique(*m_database); + if (m_database->open(m_stack_config.databasePath())) + { + // Register logger + if (m_stack_config.logMaxEntriesCount() != 0) + { + ocpp::log::Logger::registerDefaultLogger(*m_database, m_stack_config.logMaxEntriesCount()); + } + + // Initialize the database + initDatabase(); + } + else + { + LOG_ERROR << "Unable to open database"; + } + } + + // Uptime timer + if (m_timer_pool && m_worker_pool && m_internal_config) + { + m_uptime_timer = std::make_unique(*m_timer_pool, "Uptime timer"); + m_uptime_timer->setCallback(std::bind(&LocalController20::processUptime, this)); + } + + // Random numbers + std::srand(static_cast(time(nullptr))); +} + +/** @brief Destructor */ +LocalController20::~LocalController20() +{ + stop(); +} + +/** @copydoc bool ILocalController20::resetData() */ +bool LocalController20::resetData() +{ + bool ret = false; + + // Check if it is already started + if (!m_rpc_server) + { + LOG_INFO << "Reset all data"; + + // Unregister logger + if (m_stack_config.logMaxEntriesCount() != 0) + { + ocpp::log::Logger::unregisterDefaultLogger(); + } + + // Close database to invalid existing connexions + if (m_database) + { + m_database->close(); + + // Delete database + if (std::filesystem::remove(m_stack_config.databasePath())) + { + // Open database + if (m_database->open(m_stack_config.databasePath())) + { + // Register logger + if (m_stack_config.logMaxEntriesCount() != 0) + { + ocpp::log::Logger::registerDefaultLogger(*m_database, m_stack_config.logMaxEntriesCount()); + } + + // Re-initialize with default values + m_total_uptime = 0; + initDatabase(); + } + else + { + LOG_ERROR << "Unable to open database"; + } + } + else + { + LOG_ERROR << "Unable to delete database"; + } + } + } + + return ret; +} + +/** @copydoc bool ILocalController20::start() */ +bool LocalController20::start() +{ + bool ret = false; + + // Check if it is already started + if (!m_rpc_server) + { + LOG_INFO << "Starting OCPP stack v" << OPEN_OCPP_VERSION << " - Listen URL : " << m_stack_config.listenUrl(); + + // Load validator + ret = m_messages_validator.load(m_stack_config.jsonSchemasPath()); + if (ret) + { + // Start uptime counter + if (m_uptime_timer) + { + m_uptime = 0; + m_internal_config->setKey(START_DATE_KEY, DateTime::now().str()); + m_uptime_timer->start(std::chrono::seconds(1u)); + } + + // Allocate resources + m_ws_server = std::unique_ptr(ocpp::websockets::WebsocketFactory::newServer()); + m_rpc_server = std::make_unique(*m_ws_server, "ocpp2.0.1"); + m_rpc_server->registerServerListener(*this); + m_rpc_pool = std::make_unique(); + + // Configure websocket link + ocpp::websockets::IWebsocketServer::Credentials credentials; + credentials.http_basic_authent = m_stack_config.httpBasicAuthent(); + credentials.tls12_cipher_list = m_stack_config.tlsv12CipherList(); + credentials.tls13_cipher_list = m_stack_config.tlsv13CipherList(); + credentials.ecdh_curve = m_stack_config.tlsEcdhCurve(); + credentials.server_certificate = m_stack_config.tlsServerCertificate(); + credentials.server_certificate_private_key = m_stack_config.tlsServerCertificatePrivateKey(); + credentials.server_certificate_private_key_passphrase = m_stack_config.tlsServerCertificatePrivateKeyPassphrase(); + credentials.server_certificate_ca = m_stack_config.tlsServerCertificateCa(); + credentials.client_certificate_authent = m_stack_config.tlsClientCertificateAuthent(); + credentials.encoded_pem_certificates = false; + + // Start listening + ret = m_rpc_pool->start(m_stack_config.incomingRequestsFromCsThreadPoolSize()); + ret = ret && m_rpc_server->start(m_stack_config.listenUrl(), + credentials, + m_stack_config.webSocketPingInterval(), + m_stack_config.incomingRequestsFromCpThreadPoolSize()); + } + else + { + LOG_ERROR << "Unable to load all the messages validators"; + } + } + else + { + LOG_ERROR << "Stack already started"; + } + + return ret; +} + +/** @copydoc bool ILocalController20::stop() */ +bool LocalController20::stop() +{ + bool ret = false; + + // Check if it is already started + if (m_rpc_server) + { + LOG_INFO << "Stopping OCPP stack"; + + // Stop uptime counter + if (m_uptime_timer) + { + m_uptime_timer->stop(); + saveUptime(); + } + + // Stop connection + ret = m_rpc_server->stop(); + ret = ret && m_rpc_pool->stop(); + + // Free resources + m_ws_server.reset(); + m_rpc_server.reset(); + m_rpc_pool.reset(); + + // Close database + if (m_database) + { + m_database->close(); + } + } + else + { + LOG_ERROR << "Stack already stopped"; + } + + return ret; +} + +/** @copydoc bool RpcServer::IListener::rpcAcceptConnection(const char*) */ +bool LocalController20::rpcAcceptConnection(const char* ip_address) +{ + // Notify connection => no additional processing is done here + // to keep this callback has fast as possible + return m_events_handler.acceptConnection(ip_address); +} + +/** @copydoc bool RpcServer::IListener::rpcCheckCredentials(const std::string&, const std::string&, const std::string&) */ +bool LocalController20::rpcCheckCredentials(const std::string& chargepoint_id, const std::string& user, const std::string& password) +{ + bool ret = false; + LOG_INFO << "Check credentials for Charge Point [" << chargepoint_id << "]"; + + // OCPP protocol force to have user = chargepoint_id + if (user == chargepoint_id) + { + // Check password + ret = m_events_handler.checkCredentials(chargepoint_id, password); + } + return ret; +} + +/** @copydoc void RpcServer::IListener::rpcClientConnected(const std::string&, std::shared_ptr) */ +void LocalController20::rpcClientConnected(const std::string& chargepoint_id, std::shared_ptr client) +{ + LOG_INFO << "Connection from Charge Point [" << chargepoint_id << "]"; + + // Instanciate proxys + CentralSystemProxy20* centralsystem = + new CentralSystemProxy20(chargepoint_id, m_messages_validator, m_messages_converter, m_stack_config, *m_rpc_pool); + std::shared_ptr chargepoint(new ChargePointProxy20(chargepoint_id, + client, + m_messages_validator, + m_messages_converter, + m_stack_config, + std::shared_ptr(centralsystem))); + centralsystem->setChargePointProxy(chargepoint); + + // Notify connection + m_events_handler.chargePointConnected(chargepoint); +} + +/** @copydoc void RpcServer::IListener::rpcClientFailedToConnect(const char*) */ +void LocalController20::rpcClientFailedToConnect(const char* ip_address) +{ + // Notify failure => no additional processing is done here + // to keep this callback has fast as possible + return m_events_handler.clientFailedToConnect(ip_address); +} + +/** @copydoc void RpcServer::IListener::rpcServerError() */ +void LocalController20::rpcServerError() +{ + LOG_ERROR << "Critical server error"; +} + +/** @brief Initialize the database */ +void LocalController20::initDatabase() +{ + // Initialize internal configuration + m_internal_config->initDatabaseTable(); + + // Internal keys + if (!m_internal_config->keyExist(STACK_VERSION_KEY)) + { + m_internal_config->createKey(STACK_VERSION_KEY, OPEN_OCPP_VERSION); + } + else + { + m_internal_config->setKey(STACK_VERSION_KEY, OPEN_OCPP_VERSION); + } + if (!m_internal_config->keyExist(START_DATE_KEY)) + { + m_internal_config->createKey(START_DATE_KEY, ""); + } + if (!m_internal_config->keyExist(UPTIME_KEY)) + { + m_internal_config->createKey(UPTIME_KEY, "0"); + } + if (!m_internal_config->keyExist(TOTAL_UPTIME_KEY)) + { + m_internal_config->createKey(TOTAL_UPTIME_KEY, "0"); + } + else + { + std::string value; + m_internal_config->getKey(TOTAL_UPTIME_KEY, value); + m_total_uptime = static_cast(std::atoi(value.c_str())); + } +} + +/** @brief Process uptime */ +void LocalController20::processUptime() +{ + // Increase counters + m_uptime++; + m_total_uptime++; + + // Save counters + if ((m_uptime % 15u) == 0) + { + m_worker_pool->run(std::bind(&LocalController20::saveUptime, this)); + } +} + +/** @brief Save the uptime counter in database */ +void LocalController20::saveUptime() +{ + m_internal_config->setKey(UPTIME_KEY, std::to_string(m_uptime)); + m_internal_config->setKey(TOTAL_UPTIME_KEY, std::to_string(m_total_uptime)); +} + +} // namespace ocpp20 +} // namespace localcontroller +} // namespace ocpp diff --git a/src/ocpp20/localcontroller/LocalController20.h b/src/ocpp20/localcontroller/LocalController20.h new file mode 100644 index 00000000..6224a36a --- /dev/null +++ b/src/ocpp20/localcontroller/LocalController20.h @@ -0,0 +1,136 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +#ifndef OPENOCPP_OCPP20_LOCALCONTROLLER20_H +#define OPENOCPP_OCPP20_LOCALCONTROLLER20_H + +#include "Database.h" +#include "ILocalController20.h" +#include "InternalConfigManager.h" +#include "MessagesConverter20.h" +#include "MessagesValidator20.h" +#include "RpcServer.h" +#include "Timer.h" + +#include + +namespace ocpp +{ +namespace localcontroller +{ +namespace ocpp20 +{ + +/** @brief Local controller implementation */ +class LocalController20 : public ILocalController20, public ocpp::rpc::RpcServer::IListener +{ + public: + /** @brief Constructor */ + LocalController20(const ocpp::config::ILocalControllerConfig20& stack_config, + ILocalControllerEventsHandler20& events_handler, + std::shared_ptr timer_pool, + std::shared_ptr worker_pool); + + /** @brief Destructor */ + virtual ~LocalController20(); + + // ILocalController20 interface + + /** @copydoc const ocpp::config::ILocalControllerConfig20& ILocalController20::getConfig() */ + const ocpp::config::ILocalControllerConfig20& getConfig() override { return m_stack_config; } + + /** @copydoc ocpp::helpers::ITimerPool& ILocalController20::getTimerPool() */ + ocpp::helpers::ITimerPool& getTimerPool() override { return *m_timer_pool.get(); } + + /** @copydoc ocpp::helpers::WorkerThreadPool& ILocalController20::getWorkerPool() */ + ocpp::helpers::WorkerThreadPool& getWorkerPool() override { return *m_worker_pool.get(); } + + /** @copydoc bool ILocalController20::resetData() */ + bool resetData() override; + + /** @copydoc bool ILocalController20::start() */ + bool start() override; + + /** @copydoc bool ILocalController20::stop() */ + bool stop() override; + + // RpcServer::IListener interface + + /** @copydoc bool RpcServer::IListener::rpcAcceptConnection(const char*) */ + bool rpcAcceptConnection(const char* ip_address) override; + + /** @copydoc bool RpcServer::IListener::rpcCheckCredentials(const std::string&, const std::string&, const std::string&) */ + bool rpcCheckCredentials(const std::string& chargepoint_id, const std::string& user, const std::string& password) override; + + /** @copydoc void RpcServer::IListener::rpcClientConnected(const std::string&, std::shared_ptr) */ + void rpcClientConnected(const std::string& chargepoint_id, std::shared_ptr client) override; + + /** @copydoc void RpcServer::IListener::rpcClientFailedToConnect(const char*) */ + void rpcClientFailedToConnect(const char* ip_address) override; + + /** @copydoc void RpcServer::IListener::rpcServerError() */ + void rpcServerError() override; + + private: + /** @brief Stack configuration */ + const ocpp::config::ILocalControllerConfig20& m_stack_config; + /** @brief User defined events handler */ + ILocalControllerEventsHandler20& m_events_handler; + + /** @brief Timer pool */ + std::shared_ptr m_timer_pool; + /** @brief Worker thread pool */ + std::shared_ptr m_worker_pool; + + /** @brief Database */ + std::unique_ptr m_database; + /** @brief Internal configuration manager */ + std::unique_ptr m_internal_config; + + /** @brief Messages converter */ + ocpp::messages::ocpp20::MessagesConverter20 m_messages_converter; + /** @brief Messages validator */ + ocpp::messages::ocpp20::MessagesValidator20 m_messages_validator; + + /** @brief Websocket server */ + std::unique_ptr m_ws_server; + /** @brief RPC server */ + std::unique_ptr m_rpc_server; + /** @brief RPC pool */ + std::unique_ptr m_rpc_pool; + + /** @brief Uptime timer */ + std::unique_ptr m_uptime_timer; + /** @brief Uptime in seconds */ + unsigned int m_uptime; + /** @brief Total uptime in seconds */ + unsigned int m_total_uptime; + + /** @brief Initialize the database */ + void initDatabase(); + /** @brief Process uptime */ + void processUptime(); + /** @brief Save the uptime counter in database */ + void saveUptime(); +}; + +} // namespace ocpp20 +} // namespace localcontroller +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_LOCALCONTROLLER20_H diff --git a/src/ocpp20/localcontroller/centralsystem/CentralSystemHandler20.cpp b/src/ocpp20/localcontroller/centralsystem/CentralSystemHandler20.cpp new file mode 100644 index 00000000..57f09ecb --- /dev/null +++ b/src/ocpp20/localcontroller/centralsystem/CentralSystemHandler20.cpp @@ -0,0 +1,662 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* Generated by json2cpp */ + +#include "CentralSystemHandler20.h" +#include "ILocalControllerConfig20.h" +#include "MessageDispatcher.h" +#include "MessagesConverter20.h" + +using namespace ocpp::messages; +using namespace ocpp::messages::ocpp20; +using namespace ocpp::types; +using namespace ocpp::types::ocpp20; + +namespace ocpp +{ +namespace localcontroller +{ +namespace ocpp20 +{ + +/** @brief Constructor */ +CentralSystemHandler20::CentralSystemHandler20(const std::string& identifier, + const ocpp::messages::ocpp20::MessagesConverter20& messages_converter, + ocpp::messages::MessageDispatcher& msg_dispatcher) + : GenericMessageHandler(CANCELRESERVATION_ACTION, messages_converter), + GenericMessageHandler(CERTIFICATESIGNED_ACTION, messages_converter), + GenericMessageHandler(CHANGEAVAILABILITY_ACTION, messages_converter), + GenericMessageHandler(CLEARCACHE_ACTION, messages_converter), + GenericMessageHandler(CLEARCHARGINGPROFILE_ACTION, messages_converter), + GenericMessageHandler(CLEARDISPLAYMESSAGE_ACTION, messages_converter), + GenericMessageHandler(CLEARVARIABLEMONITORING_ACTION, messages_converter), + GenericMessageHandler(CUSTOMERINFORMATION_ACTION, messages_converter), + GenericMessageHandler(DATATRANSFER_ACTION, messages_converter), + GenericMessageHandler(DELETECERTIFICATE_ACTION, messages_converter), + GenericMessageHandler(GET15118EVCERTIFICATE_ACTION, messages_converter), + GenericMessageHandler(GETBASEREPORT_ACTION, messages_converter), + GenericMessageHandler(GETCERTIFICATESTATUS_ACTION, messages_converter), + GenericMessageHandler(GETCHARGINGPROFILES_ACTION, messages_converter), + GenericMessageHandler(GETCOMPOSITESCHEDULE_ACTION, messages_converter), + GenericMessageHandler(GETDISPLAYMESSAGES_ACTION, messages_converter), + GenericMessageHandler(GETINSTALLEDCERTIFICATEIDS_ACTION, + messages_converter), + GenericMessageHandler(GETLOCALLISTVERSION_ACTION, messages_converter), + GenericMessageHandler(GETLOG_ACTION, messages_converter), + GenericMessageHandler(GETMONITORINGREPORT_ACTION, messages_converter), + GenericMessageHandler(GETREPORT_ACTION, messages_converter), + GenericMessageHandler(GETTRANSACTIONSTATUS_ACTION, messages_converter), + GenericMessageHandler(GETVARIABLES_ACTION, messages_converter), + GenericMessageHandler(INSTALLCERTIFICATE_ACTION, messages_converter), + GenericMessageHandler(PUBLISHFIRMWARE_ACTION, messages_converter), + GenericMessageHandler(REQUESTSTARTTRANSACTION_ACTION, messages_converter), + GenericMessageHandler(REQUESTSTOPTRANSACTION_ACTION, messages_converter), + GenericMessageHandler(RESERVENOW_ACTION, messages_converter), + GenericMessageHandler(RESET_ACTION, messages_converter), + GenericMessageHandler(SENDLOCALLIST_ACTION, messages_converter), + GenericMessageHandler(SETCHARGINGPROFILE_ACTION, messages_converter), + GenericMessageHandler(SETDISPLAYMESSAGE_ACTION, messages_converter), + GenericMessageHandler(SETMONITORINGBASE_ACTION, messages_converter), + GenericMessageHandler(SETMONITORINGLEVEL_ACTION, messages_converter), + GenericMessageHandler(SETNETWORKPROFILE_ACTION, messages_converter), + GenericMessageHandler(SETVARIABLEMONITORING_ACTION, messages_converter), + GenericMessageHandler(SETVARIABLES_ACTION, messages_converter), + GenericMessageHandler(TRIGGERMESSAGE_ACTION, messages_converter), + GenericMessageHandler(UNLOCKCONNECTOR_ACTION, messages_converter), + GenericMessageHandler(UNPUBLISHFIRMWARE_ACTION, messages_converter), + GenericMessageHandler(UPDATEFIRMWARE_ACTION, messages_converter), + + m_identifier(identifier), + m_charge_point() +{ + msg_dispatcher.registerHandler(CANCELRESERVATION_ACTION, + *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(CERTIFICATESIGNED_ACTION, + *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(CHANGEAVAILABILITY_ACTION, + *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(CLEARCACHE_ACTION, *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(CLEARCHARGINGPROFILE_ACTION, + *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(CLEARDISPLAYMESSAGE_ACTION, + *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(CLEARVARIABLEMONITORING_ACTION, + *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(CUSTOMERINFORMATION_ACTION, + *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(DATATRANSFER_ACTION, *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(DELETECERTIFICATE_ACTION, + *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(GET15118EVCERTIFICATE_ACTION, + *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(GETBASEREPORT_ACTION, *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(GETCERTIFICATESTATUS_ACTION, + *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(GETCHARGINGPROFILES_ACTION, + *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(GETCOMPOSITESCHEDULE_ACTION, + *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(GETDISPLAYMESSAGES_ACTION, + *dynamic_cast*>(this)); + msg_dispatcher.registerHandler( + GETINSTALLEDCERTIFICATEIDS_ACTION, + *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(GETLOCALLISTVERSION_ACTION, + *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(GETLOG_ACTION, *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(GETMONITORINGREPORT_ACTION, + *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(GETREPORT_ACTION, *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(GETTRANSACTIONSTATUS_ACTION, + *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(GETVARIABLES_ACTION, *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(INSTALLCERTIFICATE_ACTION, + *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(PUBLISHFIRMWARE_ACTION, + *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(REQUESTSTARTTRANSACTION_ACTION, + *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(REQUESTSTOPTRANSACTION_ACTION, + *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(RESERVENOW_ACTION, *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(RESET_ACTION, *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(SENDLOCALLIST_ACTION, *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(SETCHARGINGPROFILE_ACTION, + *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(SETDISPLAYMESSAGE_ACTION, + *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(SETMONITORINGBASE_ACTION, + *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(SETMONITORINGLEVEL_ACTION, + *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(SETNETWORKPROFILE_ACTION, + *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(SETVARIABLEMONITORING_ACTION, + *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(SETVARIABLES_ACTION, *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(TRIGGERMESSAGE_ACTION, + *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(UNLOCKCONNECTOR_ACTION, + *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(UNPUBLISHFIRMWARE_ACTION, + *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(UPDATEFIRMWARE_ACTION, + *dynamic_cast*>(this)); +} + +/** @brief Destructor */ +CentralSystemHandler20::~CentralSystemHandler20() { } + +// OCPP handlers +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool CentralSystemHandler20::handleMessage(const ocpp::messages::ocpp20::CancelReservationReq& request, + ocpp::messages::ocpp20::CancelReservationConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(CANCELRESERVATION_ACTION, request, response, error_code, error_message); +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool CentralSystemHandler20::handleMessage(const ocpp::messages::ocpp20::CertificateSignedReq& request, + ocpp::messages::ocpp20::CertificateSignedConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(CERTIFICATESIGNED_ACTION, request, response, error_code, error_message); +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool CentralSystemHandler20::handleMessage(const ocpp::messages::ocpp20::ChangeAvailabilityReq& request, + ocpp::messages::ocpp20::ChangeAvailabilityConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(CHANGEAVAILABILITY_ACTION, request, response, error_code, error_message); +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool CentralSystemHandler20::handleMessage(const ocpp::messages::ocpp20::ClearCacheReq& request, + ocpp::messages::ocpp20::ClearCacheConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(CLEARCACHE_ACTION, request, response, error_code, error_message); +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool CentralSystemHandler20::handleMessage(const ocpp::messages::ocpp20::ClearChargingProfileReq& request, + ocpp::messages::ocpp20::ClearChargingProfileConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(CLEARCHARGINGPROFILE_ACTION, request, response, error_code, error_message); +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool CentralSystemHandler20::handleMessage(const ocpp::messages::ocpp20::ClearDisplayMessageReq& request, + ocpp::messages::ocpp20::ClearDisplayMessageConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(CLEARDISPLAYMESSAGE_ACTION, request, response, error_code, error_message); +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool CentralSystemHandler20::handleMessage(const ocpp::messages::ocpp20::ClearVariableMonitoringReq& request, + ocpp::messages::ocpp20::ClearVariableMonitoringConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(CLEARVARIABLEMONITORING_ACTION, request, response, error_code, error_message); +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool CentralSystemHandler20::handleMessage(const ocpp::messages::ocpp20::CustomerInformationReq& request, + ocpp::messages::ocpp20::CustomerInformationConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(CUSTOMERINFORMATION_ACTION, request, response, error_code, error_message); +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool CentralSystemHandler20::handleMessage(const ocpp::messages::ocpp20::DataTransferReq& request, + ocpp::messages::ocpp20::DataTransferConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(DATATRANSFER_ACTION, request, response, error_code, error_message); +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool CentralSystemHandler20::handleMessage(const ocpp::messages::ocpp20::DeleteCertificateReq& request, + ocpp::messages::ocpp20::DeleteCertificateConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(DELETECERTIFICATE_ACTION, request, response, error_code, error_message); +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool CentralSystemHandler20::handleMessage(const ocpp::messages::ocpp20::Get15118EVCertificateReq& request, + ocpp::messages::ocpp20::Get15118EVCertificateConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(GET15118EVCERTIFICATE_ACTION, request, response, error_code, error_message); +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool CentralSystemHandler20::handleMessage(const ocpp::messages::ocpp20::GetBaseReportReq& request, + ocpp::messages::ocpp20::GetBaseReportConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(GETBASEREPORT_ACTION, request, response, error_code, error_message); +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool CentralSystemHandler20::handleMessage(const ocpp::messages::ocpp20::GetCertificateStatusReq& request, + ocpp::messages::ocpp20::GetCertificateStatusConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(GETCERTIFICATESTATUS_ACTION, request, response, error_code, error_message); +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool CentralSystemHandler20::handleMessage(const ocpp::messages::ocpp20::GetChargingProfilesReq& request, + ocpp::messages::ocpp20::GetChargingProfilesConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(GETCHARGINGPROFILES_ACTION, request, response, error_code, error_message); +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool CentralSystemHandler20::handleMessage(const ocpp::messages::ocpp20::GetCompositeScheduleReq& request, + ocpp::messages::ocpp20::GetCompositeScheduleConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(GETCOMPOSITESCHEDULE_ACTION, request, response, error_code, error_message); +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool CentralSystemHandler20::handleMessage(const ocpp::messages::ocpp20::GetDisplayMessagesReq& request, + ocpp::messages::ocpp20::GetDisplayMessagesConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(GETDISPLAYMESSAGES_ACTION, request, response, error_code, error_message); +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool CentralSystemHandler20::handleMessage(const ocpp::messages::ocpp20::GetInstalledCertificateIdsReq& request, + ocpp::messages::ocpp20::GetInstalledCertificateIdsConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(GETINSTALLEDCERTIFICATEIDS_ACTION, request, response, error_code, error_message); +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool CentralSystemHandler20::handleMessage(const ocpp::messages::ocpp20::GetLocalListVersionReq& request, + ocpp::messages::ocpp20::GetLocalListVersionConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(GETLOCALLISTVERSION_ACTION, request, response, error_code, error_message); +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool CentralSystemHandler20::handleMessage(const ocpp::messages::ocpp20::GetLogReq& request, + ocpp::messages::ocpp20::GetLogConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(GETLOG_ACTION, request, response, error_code, error_message); +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool CentralSystemHandler20::handleMessage(const ocpp::messages::ocpp20::GetMonitoringReportReq& request, + ocpp::messages::ocpp20::GetMonitoringReportConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(GETMONITORINGREPORT_ACTION, request, response, error_code, error_message); +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool CentralSystemHandler20::handleMessage(const ocpp::messages::ocpp20::GetReportReq& request, + ocpp::messages::ocpp20::GetReportConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(GETREPORT_ACTION, request, response, error_code, error_message); +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool CentralSystemHandler20::handleMessage(const ocpp::messages::ocpp20::GetTransactionStatusReq& request, + ocpp::messages::ocpp20::GetTransactionStatusConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(GETTRANSACTIONSTATUS_ACTION, request, response, error_code, error_message); +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool CentralSystemHandler20::handleMessage(const ocpp::messages::ocpp20::GetVariablesReq& request, + ocpp::messages::ocpp20::GetVariablesConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(GETVARIABLES_ACTION, request, response, error_code, error_message); +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool CentralSystemHandler20::handleMessage(const ocpp::messages::ocpp20::InstallCertificateReq& request, + ocpp::messages::ocpp20::InstallCertificateConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(INSTALLCERTIFICATE_ACTION, request, response, error_code, error_message); +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool CentralSystemHandler20::handleMessage(const ocpp::messages::ocpp20::PublishFirmwareReq& request, + ocpp::messages::ocpp20::PublishFirmwareConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(PUBLISHFIRMWARE_ACTION, request, response, error_code, error_message); +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool CentralSystemHandler20::handleMessage(const ocpp::messages::ocpp20::RequestStartTransactionReq& request, + ocpp::messages::ocpp20::RequestStartTransactionConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(REQUESTSTARTTRANSACTION_ACTION, request, response, error_code, error_message); +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool CentralSystemHandler20::handleMessage(const ocpp::messages::ocpp20::RequestStopTransactionReq& request, + ocpp::messages::ocpp20::RequestStopTransactionConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(REQUESTSTOPTRANSACTION_ACTION, request, response, error_code, error_message); +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool CentralSystemHandler20::handleMessage(const ocpp::messages::ocpp20::ReserveNowReq& request, + ocpp::messages::ocpp20::ReserveNowConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(RESERVENOW_ACTION, request, response, error_code, error_message); +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool CentralSystemHandler20::handleMessage(const ocpp::messages::ocpp20::ResetReq& request, + ocpp::messages::ocpp20::ResetConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(RESET_ACTION, request, response, error_code, error_message); +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool CentralSystemHandler20::handleMessage(const ocpp::messages::ocpp20::SendLocalListReq& request, + ocpp::messages::ocpp20::SendLocalListConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(SENDLOCALLIST_ACTION, request, response, error_code, error_message); +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool CentralSystemHandler20::handleMessage(const ocpp::messages::ocpp20::SetChargingProfileReq& request, + ocpp::messages::ocpp20::SetChargingProfileConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(SETCHARGINGPROFILE_ACTION, request, response, error_code, error_message); +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool CentralSystemHandler20::handleMessage(const ocpp::messages::ocpp20::SetDisplayMessageReq& request, + ocpp::messages::ocpp20::SetDisplayMessageConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(SETDISPLAYMESSAGE_ACTION, request, response, error_code, error_message); +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool CentralSystemHandler20::handleMessage(const ocpp::messages::ocpp20::SetMonitoringBaseReq& request, + ocpp::messages::ocpp20::SetMonitoringBaseConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(SETMONITORINGBASE_ACTION, request, response, error_code, error_message); +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool CentralSystemHandler20::handleMessage(const ocpp::messages::ocpp20::SetMonitoringLevelReq& request, + ocpp::messages::ocpp20::SetMonitoringLevelConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(SETMONITORINGLEVEL_ACTION, request, response, error_code, error_message); +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool CentralSystemHandler20::handleMessage(const ocpp::messages::ocpp20::SetNetworkProfileReq& request, + ocpp::messages::ocpp20::SetNetworkProfileConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(SETNETWORKPROFILE_ACTION, request, response, error_code, error_message); +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool CentralSystemHandler20::handleMessage(const ocpp::messages::ocpp20::SetVariableMonitoringReq& request, + ocpp::messages::ocpp20::SetVariableMonitoringConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(SETVARIABLEMONITORING_ACTION, request, response, error_code, error_message); +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool CentralSystemHandler20::handleMessage(const ocpp::messages::ocpp20::SetVariablesReq& request, + ocpp::messages::ocpp20::SetVariablesConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(SETVARIABLES_ACTION, request, response, error_code, error_message); +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool CentralSystemHandler20::handleMessage(const ocpp::messages::ocpp20::TriggerMessageReq& request, + ocpp::messages::ocpp20::TriggerMessageConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(TRIGGERMESSAGE_ACTION, request, response, error_code, error_message); +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool CentralSystemHandler20::handleMessage(const ocpp::messages::ocpp20::UnlockConnectorReq& request, + ocpp::messages::ocpp20::UnlockConnectorConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(UNLOCKCONNECTOR_ACTION, request, response, error_code, error_message); +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool CentralSystemHandler20::handleMessage(const ocpp::messages::ocpp20::UnpublishFirmwareReq& request, + ocpp::messages::ocpp20::UnpublishFirmwareConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(UNPUBLISHFIRMWARE_ACTION, request, response, error_code, error_message); +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool CentralSystemHandler20::handleMessage(const ocpp::messages::ocpp20::UpdateFirmwareReq& request, + ocpp::messages::ocpp20::UpdateFirmwareConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(UPDATEFIRMWARE_ACTION, request, response, error_code, error_message); +} + +} // namespace ocpp20 +} // namespace localcontroller +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/localcontroller/centralsystem/CentralSystemHandler20.h b/src/ocpp20/localcontroller/centralsystem/CentralSystemHandler20.h new file mode 100644 index 00000000..80a6737a --- /dev/null +++ b/src/ocpp20/localcontroller/centralsystem/CentralSystemHandler20.h @@ -0,0 +1,609 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* Generated by json2cpp */ + +#ifndef OPENOCPP_OCPP20_CENTRALSYSTEMHANDLER20_H +#define OPENOCPP_OCPP20_CENTRALSYSTEMHANDLER20_H + +#include "CancelReservation20.h" +#include "CertificateSigned20.h" +#include "ChangeAvailability20.h" +#include "ClearCache20.h" +#include "ClearChargingProfile20.h" +#include "ClearDisplayMessage20.h" +#include "ClearVariableMonitoring20.h" +#include "CustomerInformation20.h" +#include "DataTransfer20.h" +#include "DeleteCertificate20.h" +#include "GenericMessageHandler.h" +#include "Get15118EVCertificate20.h" +#include "GetBaseReport20.h" +#include "GetCertificateStatus20.h" +#include "GetChargingProfiles20.h" +#include "GetCompositeSchedule20.h" +#include "GetDisplayMessages20.h" +#include "GetInstalledCertificateIds20.h" +#include "GetLocalListVersion20.h" +#include "GetLog20.h" +#include "GetMonitoringReport20.h" +#include "GetReport20.h" +#include "GetTransactionStatus20.h" +#include "GetVariables20.h" +#include "IChargePointProxy20.h" +#include "IRpc.h" +#include "InstallCertificate20.h" +#include "Logger.h" +#include "PublishFirmware20.h" +#include "RequestStartTransaction20.h" +#include "RequestStopTransaction20.h" +#include "ReserveNow20.h" +#include "Reset20.h" +#include "SendLocalList20.h" +#include "SetChargingProfile20.h" +#include "SetDisplayMessage20.h" +#include "SetMonitoringBase20.h" +#include "SetMonitoringLevel20.h" +#include "SetNetworkProfile20.h" +#include "SetVariableMonitoring20.h" +#include "SetVariables20.h" +#include "TriggerMessage20.h" +#include "UnlockConnector20.h" +#include "UnpublishFirmware20.h" +#include "UpdateFirmware20.h" + +namespace ocpp +{ +namespace config +{ +class ILocalControllerConfig20; +} // namespace config +namespace messages +{ +class MessageDispatcher; +namespace ocpp20 +{ +class MessagesConverter20; +} // namespace ocpp20 +} // namespace messages + +namespace localcontroller +{ +namespace ocpp20 +{ + +/** @brief Handler for central system requests */ +class CentralSystemHandler20 + : public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler +{ + public: + /** + * @brief Constructor + * @param identifier Charge point's identifier + * @param messages_converter Converter from/to OCPP to/from JSON messages + * @param msg_dispatcher Message dispatcher + * @param stack_config Stack configuration + */ + CentralSystemHandler20(const std::string& identifier, + const ocpp::messages::ocpp20::MessagesConverter20& messages_converter, + ocpp::messages::MessageDispatcher& msg_dispatcher); + + /** @brief Destructor */ + virtual ~CentralSystemHandler20(); + + /** + * @brief Set the proxy to forward requests to the charge point + * @param central_system Proxy to forward requests to the charge point + */ + void setChargePointProxy(std::weak_ptr charge_point) { m_charge_point = charge_point; } + + // OCPP handlers + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::CancelReservationReq& request, + ocpp::messages::ocpp20::CancelReservationConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::CertificateSignedReq& request, + ocpp::messages::ocpp20::CertificateSignedConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::ChangeAvailabilityReq& request, + ocpp::messages::ocpp20::ChangeAvailabilityConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::ClearCacheReq& request, + ocpp::messages::ocpp20::ClearCacheConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::ClearChargingProfileReq& request, + ocpp::messages::ocpp20::ClearChargingProfileConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::ClearDisplayMessageReq& request, + ocpp::messages::ocpp20::ClearDisplayMessageConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::ClearVariableMonitoringReq& request, + ocpp::messages::ocpp20::ClearVariableMonitoringConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::CustomerInformationReq& request, + ocpp::messages::ocpp20::CustomerInformationConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::DataTransferReq& request, + ocpp::messages::ocpp20::DataTransferConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::DeleteCertificateReq& request, + ocpp::messages::ocpp20::DeleteCertificateConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::Get15118EVCertificateReq& request, + ocpp::messages::ocpp20::Get15118EVCertificateConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::GetBaseReportReq& request, + ocpp::messages::ocpp20::GetBaseReportConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::GetCertificateStatusReq& request, + ocpp::messages::ocpp20::GetCertificateStatusConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::GetChargingProfilesReq& request, + ocpp::messages::ocpp20::GetChargingProfilesConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::GetCompositeScheduleReq& request, + ocpp::messages::ocpp20::GetCompositeScheduleConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::GetDisplayMessagesReq& request, + ocpp::messages::ocpp20::GetDisplayMessagesConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::GetInstalledCertificateIdsReq& request, + ocpp::messages::ocpp20::GetInstalledCertificateIdsConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::GetLocalListVersionReq& request, + ocpp::messages::ocpp20::GetLocalListVersionConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::GetLogReq& request, + ocpp::messages::ocpp20::GetLogConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::GetMonitoringReportReq& request, + ocpp::messages::ocpp20::GetMonitoringReportConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::GetReportReq& request, + ocpp::messages::ocpp20::GetReportConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::GetTransactionStatusReq& request, + ocpp::messages::ocpp20::GetTransactionStatusConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::GetVariablesReq& request, + ocpp::messages::ocpp20::GetVariablesConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::InstallCertificateReq& request, + ocpp::messages::ocpp20::InstallCertificateConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::PublishFirmwareReq& request, + ocpp::messages::ocpp20::PublishFirmwareConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::RequestStartTransactionReq& request, + ocpp::messages::ocpp20::RequestStartTransactionConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::RequestStopTransactionReq& request, + ocpp::messages::ocpp20::RequestStopTransactionConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::ReserveNowReq& request, + ocpp::messages::ocpp20::ReserveNowConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::ResetReq& request, + ocpp::messages::ocpp20::ResetConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::SendLocalListReq& request, + ocpp::messages::ocpp20::SendLocalListConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::SetChargingProfileReq& request, + ocpp::messages::ocpp20::SetChargingProfileConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::SetDisplayMessageReq& request, + ocpp::messages::ocpp20::SetDisplayMessageConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::SetMonitoringBaseReq& request, + ocpp::messages::ocpp20::SetMonitoringBaseConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::SetMonitoringLevelReq& request, + ocpp::messages::ocpp20::SetMonitoringLevelConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::SetNetworkProfileReq& request, + ocpp::messages::ocpp20::SetNetworkProfileConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::SetVariableMonitoringReq& request, + ocpp::messages::ocpp20::SetVariableMonitoringConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::SetVariablesReq& request, + ocpp::messages::ocpp20::SetVariablesConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::TriggerMessageReq& request, + ocpp::messages::ocpp20::TriggerMessageConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::UnlockConnectorReq& request, + ocpp::messages::ocpp20::UnlockConnectorConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::UnpublishFirmwareReq& request, + ocpp::messages::ocpp20::UnpublishFirmwareConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::UpdateFirmwareReq& request, + ocpp::messages::ocpp20::UpdateFirmwareConf& response, + std::string& error_code, + std::string& error_message) override; + + private: + /** @brief Charge point's identifier */ + const std::string m_identifier; + /** @brief Proxy to forward requests to the charge point */ + std::weak_ptr m_charge_point; + + /** + * @brief Forward a call request to the Charge Point + * @param action RPC action for the request + * @param request Request payload + * @param response Response payload + * @param error Error code to return to the Charge Point, empty if no error + * @param message Error message to return to the Charge Point, empty if no error + * @return true if the request has been sent and a response has been received, false otherwise + */ + template + bool forward(const std::string& action, const RequestType& request, ResponseType& response, std::string& error, std::string& message) + { + bool ret = false; + + // Get charge point proxy + auto charge_point = m_charge_point.lock(); + if (charge_point) + { + // Try to forward message + std::string cs_error; + std::string cs_message; + ret = charge_point->call(request, response, cs_error, cs_message); + if (!ret) + { + // Check timeout or error response + if (cs_error.empty()) + { + LOG_WARNING << "[" << m_identifier << "] - Unable to forward [" << action << "] request"; + } + else + { + LOG_WARNING << "[" << m_identifier << "] - CallError [" << cs_error << "] received on [" << action << "] request"; + error = cs_error.c_str(); + message = cs_message; + } + } + } + else + { + LOG_WARNING << "[" << m_identifier << "] - Unable to forward [" << action << "] request"; + } + + return ret; + } +}; + +} // namespace ocpp20 +} // namespace localcontroller +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_CENTRALSYSTEMHANDLER20_H \ No newline at end of file diff --git a/src/ocpp20/localcontroller/centralsystem/CentralSystemProxy20.cpp b/src/ocpp20/localcontroller/centralsystem/CentralSystemProxy20.cpp new file mode 100644 index 00000000..0c35f89a --- /dev/null +++ b/src/ocpp20/localcontroller/centralsystem/CentralSystemProxy20.cpp @@ -0,0 +1,834 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* Generated by json2cpp */ + +#include "CentralSystemProxy20.h" +#include "ILocalControllerConfig20.h" +#include "ILocalControllerProxyEventsHandler20.h" +#include "Url.h" +#include "WebsocketFactory.h" + +#include + +using namespace ocpp::messages; +using namespace ocpp::messages::ocpp20; +using namespace ocpp::types; +using namespace ocpp::types::ocpp20; + +namespace ocpp +{ +namespace localcontroller +{ +namespace ocpp20 +{ + +/** @brief Constructor */ +CentralSystemProxy20::CentralSystemProxy20(const std::string& identifier, + const ocpp::messages::ocpp20::MessagesValidator20& messages_validator, + ocpp::messages::ocpp20::MessagesConverter20& messages_converter, + const ocpp::config::ILocalControllerConfig20& stack_config, + ocpp::rpc::RpcPool& rpc_pool) + : m_identifier(identifier), + m_stack_config(stack_config), + m_websocket(ocpp::websockets::WebsocketFactory::newClientFromPool()), + m_rpc(*m_websocket, "ocpp2.0.1", &rpc_pool), + m_messages_converter(messages_converter), + m_msg_dispatcher(messages_validator), + m_msg_sender(m_rpc, messages_converter, messages_validator, stack_config.callRequestTimeout()), + m_handler(m_identifier, messages_converter, m_msg_dispatcher), + m_listener(nullptr), + m_user_handlers() +{ + m_rpc.registerSpy(*this); + m_rpc.registerListener(*this); + m_rpc.registerClientListener(*this); +} + +/** @brief Destructor */ +CentralSystemProxy20::~CentralSystemProxy20() +{ + disconnect(); +} + +/** @copydoc void ICentralSystemProxy::setTimeout(std::chrono::milliseconds) */ +void CentralSystemProxy20::setTimeout(std::chrono::milliseconds timeout) +{ + m_msg_sender.setTimeout(timeout); +} + +/** @copydoc bool ICentralSystemProxy::connect(const std::string&, + const ocpp::websockets::IWebsocketClient::Credentials&, + std::chrono::milliseconds, + std::chrono::milliseconds, + std::chrono::milliseconds) */ +bool CentralSystemProxy20::connect(const std::string& url, + const ocpp::websockets::IWebsocketClient::Credentials& credentials, + std::chrono::milliseconds connect_timeout, + std::chrono::milliseconds retry_interval, + std::chrono::milliseconds ping_interval) +{ + bool ret = false; + + if (!url.empty()) + { + // Build URL + std::stringstream full_url; + full_url << url; + if (url[url.size() - 1] != '/') + { + full_url << "/"; + } + full_url << ocpp::websockets::Url::encode(m_identifier); + + // Connect + ret = m_rpc.start(full_url.str(), credentials, connect_timeout, retry_interval, ping_interval); + } + return ret; +} + +/** @copydoc void ICentralSystemProxy::disconnect() */ +void CentralSystemProxy20::disconnect() +{ + m_rpc.stop(); +} + +/** @brief Indicate if the connection with the central system is active */ +bool CentralSystemProxy20::isConnected() const +{ + return m_rpc.isConnected(); +} + +// OCPP actions +/** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::BootNotificationReq&, + * ocpp::messages::ocpp20::BootNotificationConf&, + * std::string&, + * std::string&) */ +bool CentralSystemProxy20::call(const ocpp::messages::ocpp20::BootNotificationReq& request, + ocpp::messages::ocpp20::BootNotificationConf& response, + std::string& error, + std::string& message) +{ + return call(BOOTNOTIFICATION_ACTION, request, response, error, message); +} +/** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::AuthorizeReq&, + * ocpp::messages::ocpp20::AuthorizeConf&, + * std::string&, + * std::string&) */ +bool CentralSystemProxy20::call(const ocpp::messages::ocpp20::AuthorizeReq& request, + ocpp::messages::ocpp20::AuthorizeConf& response, + std::string& error, + std::string& message) +{ + return call(AUTHORIZE_ACTION, request, response, error, message); +} +/** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::ClearedChargingLimitReq&, + * ocpp::messages::ocpp20::ClearedChargingLimitConf&, + * std::string&, + * std::string&) */ +bool CentralSystemProxy20::call(const ocpp::messages::ocpp20::ClearedChargingLimitReq& request, + ocpp::messages::ocpp20::ClearedChargingLimitConf& response, + std::string& error, + std::string& message) +{ + return call(CLEAREDCHARGINGLIMIT_ACTION, request, response, error, message); +} +/** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::CostUpdatedReq&, + * ocpp::messages::ocpp20::CostUpdatedConf&, + * std::string&, + * std::string&) */ +bool CentralSystemProxy20::call(const ocpp::messages::ocpp20::CostUpdatedReq& request, + ocpp::messages::ocpp20::CostUpdatedConf& response, + std::string& error, + std::string& message) +{ + return call(COSTUPDATED_ACTION, request, response, error, message); +} +/** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::DataTransferReq&, + * ocpp::messages::ocpp20::DataTransferConf&, + * std::string&, + * std::string&) */ +bool CentralSystemProxy20::call(const ocpp::messages::ocpp20::DataTransferReq& request, + ocpp::messages::ocpp20::DataTransferConf& response, + std::string& error, + std::string& message) +{ + return call(DATATRANSFER_ACTION, request, response, error, message); +} +/** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::FirmwareStatusNotificationReq&, + * ocpp::messages::ocpp20::FirmwareStatusNotificationConf&, + * std::string&, + * std::string&) */ +bool CentralSystemProxy20::call(const ocpp::messages::ocpp20::FirmwareStatusNotificationReq& request, + ocpp::messages::ocpp20::FirmwareStatusNotificationConf& response, + std::string& error, + std::string& message) +{ + return call(FIRMWARESTATUSNOTIFICATION_ACTION, request, response, error, message); +} +/** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::HeartbeatReq&, + * ocpp::messages::ocpp20::HeartbeatConf&, + * std::string&, + * std::string&) */ +bool CentralSystemProxy20::call(const ocpp::messages::ocpp20::HeartbeatReq& request, + ocpp::messages::ocpp20::HeartbeatConf& response, + std::string& error, + std::string& message) +{ + return call(HEARTBEAT_ACTION, request, response, error, message); +} +/** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::LogStatusNotificationReq&, + * ocpp::messages::ocpp20::LogStatusNotificationConf&, + * std::string&, + * std::string&) */ +bool CentralSystemProxy20::call(const ocpp::messages::ocpp20::LogStatusNotificationReq& request, + ocpp::messages::ocpp20::LogStatusNotificationConf& response, + std::string& error, + std::string& message) +{ + return call(LOGSTATUSNOTIFICATION_ACTION, request, response, error, message); +} +/** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::MeterValuesReq&, + * ocpp::messages::ocpp20::MeterValuesConf&, + * std::string&, + * std::string&) */ +bool CentralSystemProxy20::call(const ocpp::messages::ocpp20::MeterValuesReq& request, + ocpp::messages::ocpp20::MeterValuesConf& response, + std::string& error, + std::string& message) +{ + return call(METERVALUES_ACTION, request, response, error, message); +} +/** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::NotifyChargingLimitReq&, + * ocpp::messages::ocpp20::NotifyChargingLimitConf&, + * std::string&, + * std::string&) */ +bool CentralSystemProxy20::call(const ocpp::messages::ocpp20::NotifyChargingLimitReq& request, + ocpp::messages::ocpp20::NotifyChargingLimitConf& response, + std::string& error, + std::string& message) +{ + return call(NOTIFYCHARGINGLIMIT_ACTION, request, response, error, message); +} +/** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::NotifyCustomerInformationReq&, + * ocpp::messages::ocpp20::NotifyCustomerInformationConf&, + * std::string&, + * std::string&) */ +bool CentralSystemProxy20::call(const ocpp::messages::ocpp20::NotifyCustomerInformationReq& request, + ocpp::messages::ocpp20::NotifyCustomerInformationConf& response, + std::string& error, + std::string& message) +{ + return call(NOTIFYCUSTOMERINFORMATION_ACTION, request, response, error, message); +} +/** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::NotifyDisplayMessagesReq&, + * ocpp::messages::ocpp20::NotifyDisplayMessagesConf&, + * std::string&, + * std::string&) */ +bool CentralSystemProxy20::call(const ocpp::messages::ocpp20::NotifyDisplayMessagesReq& request, + ocpp::messages::ocpp20::NotifyDisplayMessagesConf& response, + std::string& error, + std::string& message) +{ + return call(NOTIFYDISPLAYMESSAGES_ACTION, request, response, error, message); +} +/** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::NotifyEVChargingNeedsReq&, + * ocpp::messages::ocpp20::NotifyEVChargingNeedsConf&, + * std::string&, + * std::string&) */ +bool CentralSystemProxy20::call(const ocpp::messages::ocpp20::NotifyEVChargingNeedsReq& request, + ocpp::messages::ocpp20::NotifyEVChargingNeedsConf& response, + std::string& error, + std::string& message) +{ + return call(NOTIFYEVCHARGINGNEEDS_ACTION, request, response, error, message); +} +/** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::NotifyEVChargingScheduleReq&, + * ocpp::messages::ocpp20::NotifyEVChargingScheduleConf&, + * std::string&, + * std::string&) */ +bool CentralSystemProxy20::call(const ocpp::messages::ocpp20::NotifyEVChargingScheduleReq& request, + ocpp::messages::ocpp20::NotifyEVChargingScheduleConf& response, + std::string& error, + std::string& message) +{ + return call(NOTIFYEVCHARGINGSCHEDULE_ACTION, request, response, error, message); +} +/** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::NotifyEventReq&, + * ocpp::messages::ocpp20::NotifyEventConf&, + * std::string&, + * std::string&) */ +bool CentralSystemProxy20::call(const ocpp::messages::ocpp20::NotifyEventReq& request, + ocpp::messages::ocpp20::NotifyEventConf& response, + std::string& error, + std::string& message) +{ + return call(NOTIFYEVENT_ACTION, request, response, error, message); +} +/** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::NotifyMonitoringReportReq&, + * ocpp::messages::ocpp20::NotifyMonitoringReportConf&, + * std::string&, + * std::string&) */ +bool CentralSystemProxy20::call(const ocpp::messages::ocpp20::NotifyMonitoringReportReq& request, + ocpp::messages::ocpp20::NotifyMonitoringReportConf& response, + std::string& error, + std::string& message) +{ + return call(NOTIFYMONITORINGREPORT_ACTION, request, response, error, message); +} +/** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::NotifyReportReq&, + * ocpp::messages::ocpp20::NotifyReportConf&, + * std::string&, + * std::string&) */ +bool CentralSystemProxy20::call(const ocpp::messages::ocpp20::NotifyReportReq& request, + ocpp::messages::ocpp20::NotifyReportConf& response, + std::string& error, + std::string& message) +{ + return call(NOTIFYREPORT_ACTION, request, response, error, message); +} +/** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::PublishFirmwareStatusNotificationReq&, + * ocpp::messages::ocpp20::PublishFirmwareStatusNotificationConf&, + * std::string&, + * std::string&) */ +bool CentralSystemProxy20::call(const ocpp::messages::ocpp20::PublishFirmwareStatusNotificationReq& request, + ocpp::messages::ocpp20::PublishFirmwareStatusNotificationConf& response, + std::string& error, + std::string& message) +{ + return call(PUBLISHFIRMWARESTATUSNOTIFICATION_ACTION, request, response, error, message); +} +/** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::ReportChargingProfilesReq&, + * ocpp::messages::ocpp20::ReportChargingProfilesConf&, + * std::string&, + * std::string&) */ +bool CentralSystemProxy20::call(const ocpp::messages::ocpp20::ReportChargingProfilesReq& request, + ocpp::messages::ocpp20::ReportChargingProfilesConf& response, + std::string& error, + std::string& message) +{ + return call(REPORTCHARGINGPROFILES_ACTION, request, response, error, message); +} +/** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::ReservationStatusUpdateReq&, + * ocpp::messages::ocpp20::ReservationStatusUpdateConf&, + * std::string&, + * std::string&) */ +bool CentralSystemProxy20::call(const ocpp::messages::ocpp20::ReservationStatusUpdateReq& request, + ocpp::messages::ocpp20::ReservationStatusUpdateConf& response, + std::string& error, + std::string& message) +{ + return call(RESERVATIONSTATUSUPDATE_ACTION, request, response, error, message); +} +/** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::SecurityEventNotificationReq&, + * ocpp::messages::ocpp20::SecurityEventNotificationConf&, + * std::string&, + * std::string&) */ +bool CentralSystemProxy20::call(const ocpp::messages::ocpp20::SecurityEventNotificationReq& request, + ocpp::messages::ocpp20::SecurityEventNotificationConf& response, + std::string& error, + std::string& message) +{ + return call(SECURITYEVENTNOTIFICATION_ACTION, request, response, error, message); +} +/** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::SignCertificateReq&, + * ocpp::messages::ocpp20::SignCertificateConf&, + * std::string&, + * std::string&) */ +bool CentralSystemProxy20::call(const ocpp::messages::ocpp20::SignCertificateReq& request, + ocpp::messages::ocpp20::SignCertificateConf& response, + std::string& error, + std::string& message) +{ + return call(SIGNCERTIFICATE_ACTION, request, response, error, message); +} +/** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::StatusNotificationReq&, + * ocpp::messages::ocpp20::StatusNotificationConf&, + * std::string&, + * std::string&) */ +bool CentralSystemProxy20::call(const ocpp::messages::ocpp20::StatusNotificationReq& request, + ocpp::messages::ocpp20::StatusNotificationConf& response, + std::string& error, + std::string& message) +{ + return call(STATUSNOTIFICATION_ACTION, request, response, error, message); +} +/** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::TransactionEventReq&, + * ocpp::messages::ocpp20::TransactionEventConf&, + * std::string&, + * std::string&) */ +bool CentralSystemProxy20::call(const ocpp::messages::ocpp20::TransactionEventReq& request, + ocpp::messages::ocpp20::TransactionEventConf& response, + std::string& error, + std::string& message) +{ + return call(TRANSACTIONEVENT_ACTION, request, response, error, message); +} +/** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ +bool CentralSystemProxy20::registerHandler( + std::function + handler) +{ + return registerHandler(CANCELRESERVATION_ACTION, handler); +} +/** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ +bool CentralSystemProxy20::registerHandler( + std::function + handler) +{ + return registerHandler(CERTIFICATESIGNED_ACTION, handler); +} +/** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ +bool CentralSystemProxy20::registerHandler( + std::function + handler) +{ + return registerHandler(CHANGEAVAILABILITY_ACTION, handler); +} +/** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ +bool CentralSystemProxy20::registerHandler( + std::function + handler) +{ + return registerHandler(CLEARCACHE_ACTION, handler); +} +/** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ +bool CentralSystemProxy20::registerHandler(std::function handler) +{ + return registerHandler(CLEARCHARGINGPROFILE_ACTION, handler); +} +/** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ +bool CentralSystemProxy20::registerHandler(std::function handler) +{ + return registerHandler(CLEARDISPLAYMESSAGE_ACTION, handler); +} +/** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ +bool CentralSystemProxy20::registerHandler(std::function handler) +{ + return registerHandler(CLEARVARIABLEMONITORING_ACTION, handler); +} +/** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ +bool CentralSystemProxy20::registerHandler(std::function handler) +{ + return registerHandler(CUSTOMERINFORMATION_ACTION, handler); +} +/** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ +bool CentralSystemProxy20::registerHandler( + std::function handler) +{ + return registerHandler(DATATRANSFER_ACTION, handler); +} +/** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ +bool CentralSystemProxy20::registerHandler( + std::function + handler) +{ + return registerHandler(DELETECERTIFICATE_ACTION, handler); +} +/** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ +bool CentralSystemProxy20::registerHandler(std::function handler) +{ + return registerHandler(GET15118EVCERTIFICATE_ACTION, handler); +} +/** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ +bool CentralSystemProxy20::registerHandler( + std::function handler) +{ + return registerHandler(GETBASEREPORT_ACTION, handler); +} +/** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ +bool CentralSystemProxy20::registerHandler(std::function handler) +{ + return registerHandler(GETCERTIFICATESTATUS_ACTION, handler); +} +/** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ +bool CentralSystemProxy20::registerHandler(std::function handler) +{ + return registerHandler(GETCHARGINGPROFILES_ACTION, handler); +} +/** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ +bool CentralSystemProxy20::registerHandler(std::function handler) +{ + return registerHandler(GETCOMPOSITESCHEDULE_ACTION, handler); +} +/** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ +bool CentralSystemProxy20::registerHandler( + std::function + handler) +{ + return registerHandler(GETDISPLAYMESSAGES_ACTION, handler); +} +/** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ +bool CentralSystemProxy20::registerHandler(std::function handler) +{ + return registerHandler(GETINSTALLEDCERTIFICATEIDS_ACTION, handler); +} +/** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ +bool CentralSystemProxy20::registerHandler(std::function handler) +{ + return registerHandler(GETLOCALLISTVERSION_ACTION, handler); +} +/** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ +bool CentralSystemProxy20::registerHandler( + std::function handler) +{ + return registerHandler(GETLOG_ACTION, handler); +} +/** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ +bool CentralSystemProxy20::registerHandler(std::function handler) +{ + return registerHandler(GETMONITORINGREPORT_ACTION, handler); +} +/** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ +bool CentralSystemProxy20::registerHandler( + std::function + handler) +{ + return registerHandler(GETREPORT_ACTION, handler); +} +/** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ +bool CentralSystemProxy20::registerHandler(std::function handler) +{ + return registerHandler(GETTRANSACTIONSTATUS_ACTION, handler); +} +/** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ +bool CentralSystemProxy20::registerHandler( + std::function handler) +{ + return registerHandler(GETVARIABLES_ACTION, handler); +} +/** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ +bool CentralSystemProxy20::registerHandler( + std::function + handler) +{ + return registerHandler(INSTALLCERTIFICATE_ACTION, handler); +} +/** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ +bool CentralSystemProxy20::registerHandler( + std::function< + bool(const ocpp::messages::ocpp20::PublishFirmwareReq&, ocpp::messages::ocpp20::PublishFirmwareConf&, std::string&, std::string&)> + handler) +{ + return registerHandler(PUBLISHFIRMWARE_ACTION, handler); +} +/** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ +bool CentralSystemProxy20::registerHandler(std::function handler) +{ + return registerHandler(REQUESTSTARTTRANSACTION_ACTION, handler); +} +/** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ +bool CentralSystemProxy20::registerHandler(std::function handler) +{ + return registerHandler(REQUESTSTOPTRANSACTION_ACTION, handler); +} +/** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ +bool CentralSystemProxy20::registerHandler( + std::function + handler) +{ + return registerHandler(RESERVENOW_ACTION, handler); +} +/** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ +bool CentralSystemProxy20::registerHandler( + std::function handler) +{ + return registerHandler(RESET_ACTION, handler); +} +/** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ +bool CentralSystemProxy20::registerHandler( + std::function handler) +{ + return registerHandler(SENDLOCALLIST_ACTION, handler); +} +/** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ +bool CentralSystemProxy20::registerHandler( + std::function + handler) +{ + return registerHandler(SETCHARGINGPROFILE_ACTION, handler); +} +/** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ +bool CentralSystemProxy20::registerHandler( + std::function + handler) +{ + return registerHandler(SETDISPLAYMESSAGE_ACTION, handler); +} +/** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ +bool CentralSystemProxy20::registerHandler( + std::function + handler) +{ + return registerHandler(SETMONITORINGBASE_ACTION, handler); +} +/** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ +bool CentralSystemProxy20::registerHandler( + std::function + handler) +{ + return registerHandler(SETMONITORINGLEVEL_ACTION, handler); +} +/** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ +bool CentralSystemProxy20::registerHandler( + std::function + handler) +{ + return registerHandler(SETNETWORKPROFILE_ACTION, handler); +} +/** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ +bool CentralSystemProxy20::registerHandler(std::function handler) +{ + return registerHandler(SETVARIABLEMONITORING_ACTION, handler); +} +/** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ +bool CentralSystemProxy20::registerHandler( + std::function handler) +{ + return registerHandler(SETVARIABLES_ACTION, handler); +} +/** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ +bool CentralSystemProxy20::registerHandler( + std::function handler) +{ + return registerHandler(TRIGGERMESSAGE_ACTION, handler); +} +/** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ +bool CentralSystemProxy20::registerHandler( + std::function< + bool(const ocpp::messages::ocpp20::UnlockConnectorReq&, ocpp::messages::ocpp20::UnlockConnectorConf&, std::string&, std::string&)> + handler) +{ + return registerHandler(UNLOCKCONNECTOR_ACTION, handler); +} +/** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ +bool CentralSystemProxy20::registerHandler( + std::function + handler) +{ + return registerHandler(UNPUBLISHFIRMWARE_ACTION, handler); +} +/** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ +bool CentralSystemProxy20::registerHandler( + std::function handler) +{ + return registerHandler(UPDATEFIRMWARE_ACTION, handler); +} + +// IRpc::IListener interface + +/** @copydoc void IRpc::IListener::rpcDisconnected() */ +void CentralSystemProxy20::rpcDisconnected() +{ + LOG_WARNING << "[" << m_identifier << "] - Disconnected from Central System"; + + // Notify listener + if (m_listener) + { + m_listener->disconnectedFromCentralSystem(); + } + + // Disconnect from Charge Point + if (m_stack_config.disconnectFromCpWhenCsDisconnected()) + { + auto charge_point = m_charge_point.lock(); + if (charge_point) + { + charge_point->disconnect(); + } + } +} + +/** @copydoc void IRpc::IListener::rpcError() */ +void CentralSystemProxy20::rpcError() +{ + LOG_ERROR << "[" << m_identifier << "] - Connection error"; +} + +/** @copydoc bool IRpc::IListener::rpcCallReceived(const std::string&, + const rapidjson::Value&, + rapidjson::Document&, + std::string&, + std::string&) */ +bool CentralSystemProxy20::rpcCallReceived(const std::string& action, + const rapidjson::Value& payload, + rapidjson::Document& response, + std::string& error_code, + std::string& error_message) +{ + return m_msg_dispatcher.dispatchMessage(action, payload, response, error_code, error_message); +} + +// IRpc::ISpy interface + +/** @copydoc void IRpc::ISpy::rcpMessageReceived(const std::string& msg) */ +void CentralSystemProxy20::rcpMessageReceived(const std::string& msg) +{ + LOG_COM << "[" << m_identifier << "] - RX : " << msg; +} + +/** @copydoc void IRpc::ISpy::rcpMessageSent(const std::string& msg) */ +void CentralSystemProxy20::rcpMessageSent(const std::string& msg) +{ + LOG_COM << "[" << m_identifier << "] - TX : " << msg; +} + +// RpcClient::IListener interface + +/** @brief Called when connection is successfull */ +void CentralSystemProxy20::rpcClientConnected() +{ + LOG_INFO << "[" << m_identifier << "] - Connected to Central System"; + + // Notify listener + if (m_listener) + { + m_listener->connectedToCentralSystem(); + } +} + +/** @brief Called when connection failed */ +void CentralSystemProxy20::rpcClientFailed() +{ + LOG_ERROR << "[" << m_identifier << "] - Failed to connect to Central System"; + + // Notify listener + if (m_listener) + { + m_listener->failedToConnectToCentralSystem(); + } + + // Disconnect from Charge Point + if (m_stack_config.disconnectFromCpWhenCsDisconnected()) + { + auto charge_point = m_charge_point.lock(); + if (charge_point) + { + charge_point->disconnect(); + } + } +} + +} // namespace ocpp20 +} // namespace localcontroller +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/localcontroller/centralsystem/CentralSystemProxy20.h b/src/ocpp20/localcontroller/centralsystem/CentralSystemProxy20.h new file mode 100644 index 00000000..d2b178cf --- /dev/null +++ b/src/ocpp20/localcontroller/centralsystem/CentralSystemProxy20.h @@ -0,0 +1,653 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* Generated by json2cpp */ + +#ifndef OPENOCPP_OCPP20_CENTRALSYSTEMPROXY20_H +#define OPENOCPP_OCPP20_CENTRALSYSTEMPROXY20_H + +#include "CentralSystemHandler20.h" +#include "GenericMessageSender.h" +#include "ICentralSystemProxy20.h" +#include "MessageDispatcher.h" +#include "MessagesConverter20.h" +#include "MessagesValidator20.h" +#include "RpcClient.h" +#include "UserMessageHandler.h" + +namespace ocpp +{ +namespace config +{ +class ILocalControllerConfig20; +} // namespace config +namespace rpc +{ +class RpcPool; +} // namespace rpc + +namespace localcontroller +{ +namespace ocpp20 +{ + +/** @brief Central system proxy */ +class CentralSystemProxy20 : public ICentralSystemProxy20, + public ocpp::rpc::IRpc::IListener, + public ocpp::rpc::IRpc::ISpy, + public ocpp::rpc::RpcClient::IListener +{ + public: + /** + * @brief Constructor + * @param identifier Charge point's identifier + * @param messages_validator JSON schemas needed to validate payloads + * @param messages_converter Converter from/to OCPP to/from JSON messages + * @param stack_config Stack configuration + * @param rpc_pool RPC pool + */ + CentralSystemProxy20(const std::string& identifier, + const ocpp::messages::ocpp20::MessagesValidator20& messages_validator, + ocpp::messages::ocpp20::MessagesConverter20& messages_converter, + const ocpp::config::ILocalControllerConfig20& stack_config, + ocpp::rpc::RpcPool& rpc_pool); + + /** @brief Destructor */ + virtual ~CentralSystemProxy20(); + + /** + * @brief Set the proxy to forward requests to the charge point + * @param central_system Proxy to forward requests to the charge point + */ + void setChargePointProxy(std::weak_ptr charge_point) + { + m_charge_point = charge_point; + m_handler.setChargePointProxy(charge_point); + } + + /** @copydoc const std::string& ICentralSystemProxy20::disconnect() const */ + const std::string& identifier() const override { return m_identifier; } + + /** @copydoc void ICentralSystemProxy20::setTimeout(std::chrono::milliseconds) */ + void setTimeout(std::chrono::milliseconds timeout) override; + + /** @copydoc bool ICentralSystemProxy20::connect(const std::string&, + const ocpp::websockets::IWebsocketClient::Credentials&, + std::chrono::milliseconds, + std::chrono::milliseconds, + std::chrono::milliseconds) */ + bool connect(const std::string& url, + const ocpp::websockets::IWebsocketClient::Credentials& credentials, + std::chrono::milliseconds connect_timeout, + std::chrono::milliseconds retry_interval, + std::chrono::milliseconds ping_interval) override; + + /** @copydoc void ICentralSystemProxy20::disconnect() */ + void disconnect() override; + + /** @brief Indicate if the connection with the central system is active */ + bool isConnected() const override; + + /** @copydoc void ICentralSystemProxy20::registerListener(ILocalControllerProxyEventsHandler20&) */ + void registerListener(ILocalControllerProxyEventsHandler20& listener) override { m_listener = &listener; } + + // OCPP actions + /** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::BootNotificationReq&, + * ocpp::messages::ocpp20::BootNotificationConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::BootNotificationReq& request, + ocpp::messages::ocpp20::BootNotificationConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::AuthorizeReq&, + * ocpp::messages::ocpp20::AuthorizeConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::AuthorizeReq& request, + ocpp::messages::ocpp20::AuthorizeConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::ClearedChargingLimitReq&, + * ocpp::messages::ocpp20::ClearedChargingLimitConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::ClearedChargingLimitReq& request, + ocpp::messages::ocpp20::ClearedChargingLimitConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::CostUpdatedReq&, + * ocpp::messages::ocpp20::CostUpdatedConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::CostUpdatedReq& request, + ocpp::messages::ocpp20::CostUpdatedConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::DataTransferReq&, + * ocpp::messages::ocpp20::DataTransferConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::DataTransferReq& request, + ocpp::messages::ocpp20::DataTransferConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::FirmwareStatusNotificationReq&, + * ocpp::messages::ocpp20::FirmwareStatusNotificationConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::FirmwareStatusNotificationReq& request, + ocpp::messages::ocpp20::FirmwareStatusNotificationConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::HeartbeatReq&, + * ocpp::messages::ocpp20::HeartbeatConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::HeartbeatReq& request, + ocpp::messages::ocpp20::HeartbeatConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::LogStatusNotificationReq&, + * ocpp::messages::ocpp20::LogStatusNotificationConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::LogStatusNotificationReq& request, + ocpp::messages::ocpp20::LogStatusNotificationConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::MeterValuesReq&, + * ocpp::messages::ocpp20::MeterValuesConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::MeterValuesReq& request, + ocpp::messages::ocpp20::MeterValuesConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::NotifyChargingLimitReq&, + * ocpp::messages::ocpp20::NotifyChargingLimitConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::NotifyChargingLimitReq& request, + ocpp::messages::ocpp20::NotifyChargingLimitConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::NotifyCustomerInformationReq&, + * ocpp::messages::ocpp20::NotifyCustomerInformationConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::NotifyCustomerInformationReq& request, + ocpp::messages::ocpp20::NotifyCustomerInformationConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::NotifyDisplayMessagesReq&, + * ocpp::messages::ocpp20::NotifyDisplayMessagesConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::NotifyDisplayMessagesReq& request, + ocpp::messages::ocpp20::NotifyDisplayMessagesConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::NotifyEVChargingNeedsReq&, + * ocpp::messages::ocpp20::NotifyEVChargingNeedsConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::NotifyEVChargingNeedsReq& request, + ocpp::messages::ocpp20::NotifyEVChargingNeedsConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::NotifyEVChargingScheduleReq&, + * ocpp::messages::ocpp20::NotifyEVChargingScheduleConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::NotifyEVChargingScheduleReq& request, + ocpp::messages::ocpp20::NotifyEVChargingScheduleConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::NotifyEventReq&, + * ocpp::messages::ocpp20::NotifyEventConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::NotifyEventReq& request, + ocpp::messages::ocpp20::NotifyEventConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::NotifyMonitoringReportReq&, + * ocpp::messages::ocpp20::NotifyMonitoringReportConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::NotifyMonitoringReportReq& request, + ocpp::messages::ocpp20::NotifyMonitoringReportConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::NotifyReportReq&, + * ocpp::messages::ocpp20::NotifyReportConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::NotifyReportReq& request, + ocpp::messages::ocpp20::NotifyReportConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::PublishFirmwareStatusNotificationReq&, + * ocpp::messages::ocpp20::PublishFirmwareStatusNotificationConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::PublishFirmwareStatusNotificationReq& request, + ocpp::messages::ocpp20::PublishFirmwareStatusNotificationConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::ReportChargingProfilesReq&, + * ocpp::messages::ocpp20::ReportChargingProfilesConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::ReportChargingProfilesReq& request, + ocpp::messages::ocpp20::ReportChargingProfilesConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::ReservationStatusUpdateReq&, + * ocpp::messages::ocpp20::ReservationStatusUpdateConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::ReservationStatusUpdateReq& request, + ocpp::messages::ocpp20::ReservationStatusUpdateConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::SecurityEventNotificationReq&, + * ocpp::messages::ocpp20::SecurityEventNotificationConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::SecurityEventNotificationReq& request, + ocpp::messages::ocpp20::SecurityEventNotificationConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::SignCertificateReq&, + * ocpp::messages::ocpp20::SignCertificateConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::SignCertificateReq& request, + ocpp::messages::ocpp20::SignCertificateConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::StatusNotificationReq&, + * ocpp::messages::ocpp20::StatusNotificationConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::StatusNotificationReq& request, + ocpp::messages::ocpp20::StatusNotificationConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystemProxy20::call(const ocpp::messages::ocpp20::TransactionEventReq&, + * ocpp::messages::ocpp20::TransactionEventConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::TransactionEventReq& request, + ocpp::messages::ocpp20::TransactionEventConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ + bool registerHandler(std::function handler) override; + /** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ + bool registerHandler(std::function handler) override; + /** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ + bool registerHandler(std::function handler) override; + /** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ + bool registerHandler( + std::function handler) + override; + /** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ + bool registerHandler(std::function handler) override; + /** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ + bool registerHandler(std::function handler) override; + /** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ + bool registerHandler(std::function handler) override; + /** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ + bool registerHandler(std::function handler) override; + /** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ + bool registerHandler( + std::function handler) + override; + /** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ + bool registerHandler(std::function handler) override; + /** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ + bool registerHandler(std::function handler) override; + /** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ + bool registerHandler( + std::function< + bool(const ocpp::messages::ocpp20::GetBaseReportReq&, ocpp::messages::ocpp20::GetBaseReportConf&, std::string&, std::string&)> + handler) override; + /** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ + bool registerHandler(std::function handler) override; + /** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ + bool registerHandler(std::function handler) override; + /** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ + bool registerHandler(std::function handler) override; + /** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ + bool registerHandler(std::function handler) override; + /** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ + bool registerHandler(std::function handler) override; + /** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ + bool registerHandler(std::function handler) override; + /** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ + bool registerHandler( + std::function + handler) override; + /** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ + bool registerHandler(std::function handler) override; + /** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ + bool registerHandler( + std::function + handler) override; + /** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ + bool registerHandler(std::function handler) override; + /** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ + bool registerHandler( + std::function handler) + override; + /** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ + bool registerHandler(std::function handler) override; + /** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ + bool registerHandler( + std::function + handler) override; + /** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ + bool registerHandler(std::function handler) override; + /** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ + bool registerHandler(std::function handler) override; + /** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ + bool registerHandler( + std::function handler) + override; + /** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ + bool registerHandler( + std::function + handler) override; + /** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ + bool registerHandler( + std::function< + bool(const ocpp::messages::ocpp20::SendLocalListReq&, ocpp::messages::ocpp20::SendLocalListConf&, std::string&, std::string&)> + handler) override; + /** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ + bool registerHandler(std::function handler) override; + /** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ + bool registerHandler(std::function handler) override; + /** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ + bool registerHandler(std::function handler) override; + /** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ + bool registerHandler(std::function handler) override; + /** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ + bool registerHandler(std::function handler) override; + /** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ + bool registerHandler(std::function handler) override; + /** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ + bool registerHandler( + std::function handler) + override; + /** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ + bool registerHandler( + std::function< + bool(const ocpp::messages::ocpp20::TriggerMessageReq&, ocpp::messages::ocpp20::TriggerMessageConf&, std::string&, std::string&)> + handler) override; + /** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ + bool registerHandler( + std::function + handler) override; + /** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ + bool registerHandler(std::function handler) override; + /** @copydoc bool ICentralSystemProxy20::registerHandler( + std::function) */ + bool registerHandler( + std::function< + bool(const ocpp::messages::ocpp20::UpdateFirmwareReq&, ocpp::messages::ocpp20::UpdateFirmwareConf&, std::string&, std::string&)> + handler) override; + + // IRpc::IListener interface + + /** @copydoc void IRpc::IListener::rpcDisconnected() */ + void rpcDisconnected() override; + + /** @copydoc void IRpc::IListener::rpcError() */ + void rpcError() override; + + /** @copydoc bool IRpc::IListener::rpcCallReceived(const std::string&, + const rapidjson::Value&, + rapidjson::Document&, + std::string&, + std::string&) */ + bool rpcCallReceived(const std::string& action, + const rapidjson::Value& payload, + rapidjson::Document& response, + std::string& error_code, + std::string& error_message) override; + + // IRpc::ISpy interface + + /** @copydoc void IRpc::ISpy::rcpMessageReceived(const std::string& msg) */ + void rcpMessageReceived(const std::string& msg) override; + + /** @copydoc void IRpc::ISpy::rcpMessageSent(const std::string& msg) */ + void rcpMessageSent(const std::string& msg) override; + + // RpcClient::IListener interface + + /** @brief Called when connection is successfull */ + void rpcClientConnected() override; + + /** @brief Called when connection failed */ + void rpcClientFailed() override; + + private: + /** @brief Charge point's identifier */ + std::string m_identifier; + /** @brief Stack configuration */ + const ocpp::config::ILocalControllerConfig20& m_stack_config; + /** @brief Client websocket */ + std::unique_ptr m_websocket; + /** @brief RPC connection */ + ocpp::rpc::RpcClient m_rpc; + /** @brief Messages converter */ + ocpp::messages::ocpp20::MessagesConverter20& m_messages_converter; + /** @brief Message dispatcher */ + ocpp::messages::MessageDispatcher m_msg_dispatcher; + /** @brief Message sender */ + ocpp::messages::GenericMessageSender m_msg_sender; + /** @brief Request handler */ + CentralSystemHandler20 m_handler; + /** @brief Proxy to forward requests to the charge point */ + std::weak_ptr m_charge_point; + /** @brief Listener to the proxy events */ + ILocalControllerProxyEventsHandler20* m_listener; + /** @brief User message handlers */ + std::vector> m_user_handlers; + + /** + * @brief Execute a call request + * @param action RPC action for the request + * @param request Request payload + * @param response Response payload + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + template + bool call(const std::string& action, const RequestType& request, ResponseType& response, std::string& error, std::string& message) + { + bool ret = true; + + LOG_DEBUG << "[" << m_identifier << "] - " << action; + + ocpp::messages::CallResult res = m_msg_sender.call(action, request, response, error, message); + if (res != ocpp::messages::CallResult::Ok) + { + LOG_ERROR << "[" << m_identifier << "] - " << action << " => " + << (res == ocpp::messages::CallResult::Failed ? "Timeout" : "Error"); + ret = false; + } + + return ret; + } + + /** + * @brief Register a user handler for an incoming request + * @param action RPC action for the request + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + template + bool registerHandler(const std::string& action, + std::function handler) + { + ocpp::messages::UserMessageHandler* msg_handler = + new ocpp::messages::UserMessageHandler(action, m_messages_converter, handler); + m_user_handlers.push_back(std::shared_ptr(msg_handler)); + return m_msg_dispatcher.registerHandler(action, *msg_handler, true); + } +}; + +} // namespace ocpp20 +} // namespace localcontroller +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_CENTRALSYSTEMPROXY20_H \ No newline at end of file diff --git a/src/ocpp20/localcontroller/chargepoint/ChargePointHandler20.cpp b/src/ocpp20/localcontroller/chargepoint/ChargePointHandler20.cpp new file mode 100644 index 00000000..ef3c9f49 --- /dev/null +++ b/src/ocpp20/localcontroller/chargepoint/ChargePointHandler20.cpp @@ -0,0 +1,416 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* Generated by json2cpp */ + +#include "ChargePointHandler20.h" +#include "ILocalControllerConfig20.h" +#include "MessageDispatcher.h" +#include "MessagesConverter20.h" + +using namespace ocpp::messages; +using namespace ocpp::messages::ocpp20; +using namespace ocpp::types; +using namespace ocpp::types::ocpp20; + +namespace ocpp +{ +namespace localcontroller +{ +namespace ocpp20 +{ + +/** @brief Constructor */ +ChargePointHandler20::ChargePointHandler20(const std::string& identifier, + const ocpp::messages::ocpp20::MessagesConverter20& messages_converter, + ocpp::messages::MessageDispatcher& msg_dispatcher, + ICentralSystemProxy20& central_system) + : GenericMessageHandler(BOOTNOTIFICATION_ACTION, messages_converter), + GenericMessageHandler(AUTHORIZE_ACTION, messages_converter), + GenericMessageHandler(CLEAREDCHARGINGLIMIT_ACTION, messages_converter), + GenericMessageHandler(COSTUPDATED_ACTION, messages_converter), + GenericMessageHandler(DATATRANSFER_ACTION, messages_converter), + GenericMessageHandler(FIRMWARESTATUSNOTIFICATION_ACTION, + messages_converter), + GenericMessageHandler(HEARTBEAT_ACTION, messages_converter), + GenericMessageHandler(LOGSTATUSNOTIFICATION_ACTION, messages_converter), + GenericMessageHandler(METERVALUES_ACTION, messages_converter), + GenericMessageHandler(NOTIFYCHARGINGLIMIT_ACTION, messages_converter), + GenericMessageHandler(NOTIFYCUSTOMERINFORMATION_ACTION, + messages_converter), + GenericMessageHandler(NOTIFYDISPLAYMESSAGES_ACTION, messages_converter), + GenericMessageHandler(NOTIFYEVCHARGINGNEEDS_ACTION, messages_converter), + GenericMessageHandler(NOTIFYEVCHARGINGSCHEDULE_ACTION, messages_converter), + GenericMessageHandler(NOTIFYEVENT_ACTION, messages_converter), + GenericMessageHandler(NOTIFYMONITORINGREPORT_ACTION, messages_converter), + GenericMessageHandler(NOTIFYREPORT_ACTION, messages_converter), + GenericMessageHandler( + PUBLISHFIRMWARESTATUSNOTIFICATION_ACTION, messages_converter), + GenericMessageHandler(REPORTCHARGINGPROFILES_ACTION, messages_converter), + GenericMessageHandler(RESERVATIONSTATUSUPDATE_ACTION, messages_converter), + GenericMessageHandler(SECURITYEVENTNOTIFICATION_ACTION, + messages_converter), + GenericMessageHandler(SIGNCERTIFICATE_ACTION, messages_converter), + GenericMessageHandler(STATUSNOTIFICATION_ACTION, messages_converter), + GenericMessageHandler(TRANSACTIONEVENT_ACTION, messages_converter), + + m_identifier(identifier), + m_central_system(central_system) +{ + msg_dispatcher.registerHandler(BOOTNOTIFICATION_ACTION, + *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(AUTHORIZE_ACTION, *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(CLEAREDCHARGINGLIMIT_ACTION, + *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(COSTUPDATED_ACTION, *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(DATATRANSFER_ACTION, *dynamic_cast*>(this)); + msg_dispatcher.registerHandler( + FIRMWARESTATUSNOTIFICATION_ACTION, + *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(HEARTBEAT_ACTION, *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(LOGSTATUSNOTIFICATION_ACTION, + *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(METERVALUES_ACTION, *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(NOTIFYCHARGINGLIMIT_ACTION, + *dynamic_cast*>(this)); + msg_dispatcher.registerHandler( + NOTIFYCUSTOMERINFORMATION_ACTION, + *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(NOTIFYDISPLAYMESSAGES_ACTION, + *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(NOTIFYEVCHARGINGNEEDS_ACTION, + *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(NOTIFYEVCHARGINGSCHEDULE_ACTION, + *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(NOTIFYEVENT_ACTION, *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(NOTIFYMONITORINGREPORT_ACTION, + *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(NOTIFYREPORT_ACTION, *dynamic_cast*>(this)); + msg_dispatcher.registerHandler( + PUBLISHFIRMWARESTATUSNOTIFICATION_ACTION, + *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(REPORTCHARGINGPROFILES_ACTION, + *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(RESERVATIONSTATUSUPDATE_ACTION, + *dynamic_cast*>(this)); + msg_dispatcher.registerHandler( + SECURITYEVENTNOTIFICATION_ACTION, + *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(SIGNCERTIFICATE_ACTION, + *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(STATUSNOTIFICATION_ACTION, + *dynamic_cast*>(this)); + msg_dispatcher.registerHandler(TRANSACTIONEVENT_ACTION, + *dynamic_cast*>(this)); +} +/** @brief Destructor */ +ChargePointHandler20::~ChargePointHandler20() { } + +// OCPP handlers +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePointHandler20::handleMessage(const ocpp::messages::ocpp20::BootNotificationReq& request, + ocpp::messages::ocpp20::BootNotificationConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(BOOTNOTIFICATION_ACTION, request, response, error_code, error_message); +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePointHandler20::handleMessage(const ocpp::messages::ocpp20::AuthorizeReq& request, + ocpp::messages::ocpp20::AuthorizeConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(AUTHORIZE_ACTION, request, response, error_code, error_message); +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePointHandler20::handleMessage(const ocpp::messages::ocpp20::ClearedChargingLimitReq& request, + ocpp::messages::ocpp20::ClearedChargingLimitConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(CLEAREDCHARGINGLIMIT_ACTION, request, response, error_code, error_message); +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePointHandler20::handleMessage(const ocpp::messages::ocpp20::CostUpdatedReq& request, + ocpp::messages::ocpp20::CostUpdatedConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(COSTUPDATED_ACTION, request, response, error_code, error_message); +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePointHandler20::handleMessage(const ocpp::messages::ocpp20::DataTransferReq& request, + ocpp::messages::ocpp20::DataTransferConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(DATATRANSFER_ACTION, request, response, error_code, error_message); +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePointHandler20::handleMessage(const ocpp::messages::ocpp20::FirmwareStatusNotificationReq& request, + ocpp::messages::ocpp20::FirmwareStatusNotificationConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(FIRMWARESTATUSNOTIFICATION_ACTION, request, response, error_code, error_message); +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePointHandler20::handleMessage(const ocpp::messages::ocpp20::HeartbeatReq& request, + ocpp::messages::ocpp20::HeartbeatConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(HEARTBEAT_ACTION, request, response, error_code, error_message); +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePointHandler20::handleMessage(const ocpp::messages::ocpp20::LogStatusNotificationReq& request, + ocpp::messages::ocpp20::LogStatusNotificationConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(LOGSTATUSNOTIFICATION_ACTION, request, response, error_code, error_message); +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePointHandler20::handleMessage(const ocpp::messages::ocpp20::MeterValuesReq& request, + ocpp::messages::ocpp20::MeterValuesConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(METERVALUES_ACTION, request, response, error_code, error_message); +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePointHandler20::handleMessage(const ocpp::messages::ocpp20::NotifyChargingLimitReq& request, + ocpp::messages::ocpp20::NotifyChargingLimitConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(NOTIFYCHARGINGLIMIT_ACTION, request, response, error_code, error_message); +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePointHandler20::handleMessage(const ocpp::messages::ocpp20::NotifyCustomerInformationReq& request, + ocpp::messages::ocpp20::NotifyCustomerInformationConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(NOTIFYCUSTOMERINFORMATION_ACTION, request, response, error_code, error_message); +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePointHandler20::handleMessage(const ocpp::messages::ocpp20::NotifyDisplayMessagesReq& request, + ocpp::messages::ocpp20::NotifyDisplayMessagesConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(NOTIFYDISPLAYMESSAGES_ACTION, request, response, error_code, error_message); +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePointHandler20::handleMessage(const ocpp::messages::ocpp20::NotifyEVChargingNeedsReq& request, + ocpp::messages::ocpp20::NotifyEVChargingNeedsConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(NOTIFYEVCHARGINGNEEDS_ACTION, request, response, error_code, error_message); +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePointHandler20::handleMessage(const ocpp::messages::ocpp20::NotifyEVChargingScheduleReq& request, + ocpp::messages::ocpp20::NotifyEVChargingScheduleConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(NOTIFYEVCHARGINGSCHEDULE_ACTION, request, response, error_code, error_message); +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePointHandler20::handleMessage(const ocpp::messages::ocpp20::NotifyEventReq& request, + ocpp::messages::ocpp20::NotifyEventConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(NOTIFYEVENT_ACTION, request, response, error_code, error_message); +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePointHandler20::handleMessage(const ocpp::messages::ocpp20::NotifyMonitoringReportReq& request, + ocpp::messages::ocpp20::NotifyMonitoringReportConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(NOTIFYMONITORINGREPORT_ACTION, request, response, error_code, error_message); +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePointHandler20::handleMessage(const ocpp::messages::ocpp20::NotifyReportReq& request, + ocpp::messages::ocpp20::NotifyReportConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(NOTIFYREPORT_ACTION, request, response, error_code, error_message); +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePointHandler20::handleMessage(const ocpp::messages::ocpp20::PublishFirmwareStatusNotificationReq& request, + ocpp::messages::ocpp20::PublishFirmwareStatusNotificationConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(PUBLISHFIRMWARESTATUSNOTIFICATION_ACTION, request, response, error_code, error_message); +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePointHandler20::handleMessage(const ocpp::messages::ocpp20::ReportChargingProfilesReq& request, + ocpp::messages::ocpp20::ReportChargingProfilesConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(REPORTCHARGINGPROFILES_ACTION, request, response, error_code, error_message); +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePointHandler20::handleMessage(const ocpp::messages::ocpp20::ReservationStatusUpdateReq& request, + ocpp::messages::ocpp20::ReservationStatusUpdateConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(RESERVATIONSTATUSUPDATE_ACTION, request, response, error_code, error_message); +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePointHandler20::handleMessage(const ocpp::messages::ocpp20::SecurityEventNotificationReq& request, + ocpp::messages::ocpp20::SecurityEventNotificationConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(SECURITYEVENTNOTIFICATION_ACTION, request, response, error_code, error_message); +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePointHandler20::handleMessage(const ocpp::messages::ocpp20::SignCertificateReq& request, + ocpp::messages::ocpp20::SignCertificateConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(SIGNCERTIFICATE_ACTION, request, response, error_code, error_message); +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePointHandler20::handleMessage(const ocpp::messages::ocpp20::StatusNotificationReq& request, + ocpp::messages::ocpp20::StatusNotificationConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(STATUSNOTIFICATION_ACTION, request, response, error_code, error_message); +} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePointHandler20::handleMessage(const ocpp::messages::ocpp20::TransactionEventReq& request, + ocpp::messages::ocpp20::TransactionEventConf& response, + std::string& error_code, + std::string& error_message) +{ + return forward(TRANSACTIONEVENT_ACTION, request, response, error_code, error_message); +} + +} // namespace ocpp20 +} // namespace localcontroller +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/localcontroller/chargepoint/ChargePointHandler20.h b/src/ocpp20/localcontroller/chargepoint/ChargePointHandler20.h new file mode 100644 index 00000000..b1822376 --- /dev/null +++ b/src/ocpp20/localcontroller/chargepoint/ChargePointHandler20.h @@ -0,0 +1,398 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* Generated by json2cpp */ + +#ifndef OPENOCPP_OCPP20_LC_CHARGEPOINTHANDLER20_H +#define OPENOCPP_OCPP20_LC_CHARGEPOINTHANDLER20_H + +#include "Authorize20.h" +#include "BootNotification20.h" +#include "ClearedChargingLimit20.h" +#include "CostUpdated20.h" +#include "DataTransfer20.h" +#include "FirmwareStatusNotification20.h" +#include "GenericMessageHandler.h" +#include "Heartbeat20.h" +#include "ICentralSystemProxy20.h" +#include "IRpc.h" +#include "LogStatusNotification20.h" +#include "Logger.h" +#include "MeterValues20.h" +#include "NotifyChargingLimit20.h" +#include "NotifyCustomerInformation20.h" +#include "NotifyDisplayMessages20.h" +#include "NotifyEVChargingNeeds20.h" +#include "NotifyEVChargingSchedule20.h" +#include "NotifyEvent20.h" +#include "NotifyMonitoringReport20.h" +#include "NotifyReport20.h" +#include "PublishFirmwareStatusNotification20.h" +#include "ReportChargingProfiles20.h" +#include "ReservationStatusUpdate20.h" +#include "SecurityEventNotification20.h" +#include "SignCertificate20.h" +#include "StatusNotification20.h" +#include "TransactionEvent20.h" + +namespace ocpp +{ +namespace config +{ +class ILocalControllerConfig20; +} // namespace config +namespace messages +{ +class MessageDispatcher; +namespace ocpp20 +{ +class MessagesConverter20; +} // namespace ocpp20 +} // namespace messages + +namespace localcontroller +{ +namespace ocpp20 +{ + +/** @brief Handler for charge point requests */ +class ChargePointHandler20 + : public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler, + public ocpp::messages::GenericMessageHandler +{ + public: + /** + * @brief Constructor + * @param identifier Charge point's identifier + * @param messages_converter Converter from/to OCPP to/from JSON messages + * @param msg_dispatcher Message dispatcher + * @param stack_config Stack configuration + */ + ChargePointHandler20(const std::string& identifier, + const ocpp::messages::ocpp20::MessagesConverter20& messages_converter, + ocpp::messages::MessageDispatcher& msg_dispatcher, + ICentralSystemProxy20& central_system); + + /** @brief Destructor */ + virtual ~ChargePointHandler20(); + + // OCPP handlers + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::BootNotificationReq& request, + ocpp::messages::ocpp20::BootNotificationConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::AuthorizeReq& request, + ocpp::messages::ocpp20::AuthorizeConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::ClearedChargingLimitReq& request, + ocpp::messages::ocpp20::ClearedChargingLimitConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::CostUpdatedReq& request, + ocpp::messages::ocpp20::CostUpdatedConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::DataTransferReq& request, + ocpp::messages::ocpp20::DataTransferConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::FirmwareStatusNotificationReq& request, + ocpp::messages::ocpp20::FirmwareStatusNotificationConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::HeartbeatReq& request, + ocpp::messages::ocpp20::HeartbeatConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::LogStatusNotificationReq& request, + ocpp::messages::ocpp20::LogStatusNotificationConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::MeterValuesReq& request, + ocpp::messages::ocpp20::MeterValuesConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::NotifyChargingLimitReq& request, + ocpp::messages::ocpp20::NotifyChargingLimitConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::NotifyCustomerInformationReq& request, + ocpp::messages::ocpp20::NotifyCustomerInformationConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::NotifyDisplayMessagesReq& request, + ocpp::messages::ocpp20::NotifyDisplayMessagesConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::NotifyEVChargingNeedsReq& request, + ocpp::messages::ocpp20::NotifyEVChargingNeedsConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::NotifyEVChargingScheduleReq& request, + ocpp::messages::ocpp20::NotifyEVChargingScheduleConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::NotifyEventReq& request, + ocpp::messages::ocpp20::NotifyEventConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::NotifyMonitoringReportReq& request, + ocpp::messages::ocpp20::NotifyMonitoringReportConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::NotifyReportReq& request, + ocpp::messages::ocpp20::NotifyReportConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::PublishFirmwareStatusNotificationReq& request, + ocpp::messages::ocpp20::PublishFirmwareStatusNotificationConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::ReportChargingProfilesReq& request, + ocpp::messages::ocpp20::ReportChargingProfilesConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::ReservationStatusUpdateReq& request, + ocpp::messages::ocpp20::ReservationStatusUpdateConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::SecurityEventNotificationReq& request, + ocpp::messages::ocpp20::SecurityEventNotificationConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::SignCertificateReq& request, + ocpp::messages::ocpp20::SignCertificateConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::StatusNotificationReq& request, + ocpp::messages::ocpp20::StatusNotificationConf& response, + std::string& error_code, + std::string& error_message) override; + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::ocpp20::TransactionEventReq& request, + ocpp::messages::ocpp20::TransactionEventConf& response, + std::string& error_code, + std::string& error_message) override; + + private: + /** @brief Charge point's identifier */ + const std::string m_identifier; + /** @brief Stack configuration */ + /** @brief Proxy to forward requests to the central system */ + ICentralSystemProxy20& m_central_system; + + /** + * @brief Forward a call request to the Central System + * @param action RPC action for the request + * @param request Request payload + * @param response Response payload + * @param error Error code to return to the Charge Point, empty if no error + * @param message Error message to return to the Charge Point, empty if no error + * @return true if the request has been sent and a response has been received, false otherwise + */ + template + bool forward(const std::string& action, const RequestType& request, ResponseType& response, std::string& error, std::string& message) + { + bool ret = false; + + // Try to forward message + std::string cs_error; + std::string cs_message; + ret = m_central_system.call(request, response, cs_error, cs_message); + if (!ret) + { + // Check timeout or error response + if (cs_error.empty()) + { + LOG_WARNING << "[" << m_identifier << "] - Unable to forward [" << action << "] request"; + } + else + { + LOG_WARNING << "[" << m_identifier << "] - CallError [" << cs_error << "] received on [" << action << "] request"; + error = cs_error.c_str(); + message = cs_message; + } + } + + return ret; + } +}; + +} // namespace ocpp20 +} // namespace localcontroller +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_LC_CHARGEPOINTHANDLER20_H \ No newline at end of file diff --git a/src/ocpp20/localcontroller/chargepoint/ChargePointProxy20.cpp b/src/ocpp20/localcontroller/chargepoint/ChargePointProxy20.cpp new file mode 100644 index 00000000..48233d7e --- /dev/null +++ b/src/ocpp20/localcontroller/chargepoint/ChargePointProxy20.cpp @@ -0,0 +1,844 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* Generated by json2cpp */ + +#include "ChargePointProxy20.h" +#include "../centralsystem/chargepoint/ChargePointProxy20.h" +#include "CentralSystemProxy20.h" +#include "ILocalControllerConfig20.h" +#include "ILocalControllerProxyEventsHandler20.h" +#include "MessagesConverter20.h" + +using namespace ocpp::messages; +using namespace ocpp::messages::ocpp20; +using namespace ocpp::types; +using namespace ocpp::types::ocpp20; + +namespace ocpp +{ +namespace localcontroller +{ +namespace ocpp20 +{ + +/** @brief Instanciate local controller's charge point proxy from a central system's charge point proxy */ +std::shared_ptr IChargePointProxy20::createFrom( + std::shared_ptr& central_system_proxy, + const ocpp::config::ILocalControllerConfig20& stack_config, + ocpp::rpc::RpcPool& rpc_pool) +{ + std::shared_ptr proxy; + + // Instanciation can only be done from centralsytem::ChargePointProxy instance + ocpp::centralsystem::ocpp20::ChargePointProxy20* cs_proxy = + dynamic_cast(central_system_proxy.get()); + if (cs_proxy) + { + // Create associated Central System proxy + CentralSystemProxy20* centralsystem = new CentralSystemProxy20( + cs_proxy->identifier(), cs_proxy->messagesValidator(), cs_proxy->messagesConverter(), stack_config, rpc_pool); + + // Create the proxy + proxy = std::shared_ptr(new ChargePointProxy20(cs_proxy->identifier(), + cs_proxy->rpcClient(), + cs_proxy->messagesValidator(), + cs_proxy->messagesConverter(), + stack_config, + std::shared_ptr(centralsystem))); + + // Associate both + centralsystem->setChargePointProxy(proxy); + + // Unregister old proxy from RPC spy events + cs_proxy->unregisterFromRpcSpy(); + } + + return proxy; +} + +/** @brief Constructor */ +ChargePointProxy20::ChargePointProxy20(const std::string& identifier, + std::shared_ptr rpc, + const ocpp::messages::ocpp20::MessagesValidator20& messages_validator, + ocpp::messages::ocpp20::MessagesConverter20& messages_converter, + const ocpp::config::ILocalControllerConfig20& stack_config, + std::shared_ptr central_system) + : m_identifier(identifier), + m_rpc(rpc), + m_messages_converter(messages_converter), + m_msg_dispatcher(messages_validator), + m_msg_sender(*m_rpc, messages_converter, messages_validator, stack_config.callRequestTimeout()), + m_central_system(central_system), + m_handler(m_identifier, messages_converter, m_msg_dispatcher, *central_system.get()), + m_listener(nullptr), + m_user_handlers() +{ + m_rpc->registerSpy(*this); + m_rpc->registerListener(*this); +} + +/** @brief Destructor */ +ChargePointProxy20::~ChargePointProxy20() +{ + // Disconnect from the charge point + m_rpc->disconnect(false); + + // Disconnect from the central system + m_central_system->disconnect(); +} + +// IChargePointProxy interface + +/** @copydoc const std::string& IChargePointProxy::ipAddress() const */ +const std::string& ChargePointProxy20::ipAddress() const +{ + return m_rpc->ipAddress(); +} + +/** @copydoc void IChargePointProxy::setTimeout(std::chrono::milliseconds) */ +void ChargePointProxy20::setTimeout(std::chrono::milliseconds timeout) +{ + m_msg_sender.setTimeout(timeout); +} + +/** @copydoc void IChargePointProxy::disconnect() */ +void ChargePointProxy20::disconnect() +{ + // Disconnect from the charge point + m_rpc->disconnect(true); + + // Disconnect from the central system + m_central_system->disconnect(); +} + +// OCPP operations +/** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::CancelReservationReq&, + * ocpp::messages::ocpp20::CancelReservationConf&, + * std::string&, + * std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::CancelReservationReq& request, + ocpp::messages::ocpp20::CancelReservationConf& response, + std::string& error, + std::string& message) +{ + return call(CANCELRESERVATION_ACTION, request, response, error, message); +} +/** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::CertificateSignedReq&, + * ocpp::messages::ocpp20::CertificateSignedConf&, + * std::string&, + * std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::CertificateSignedReq& request, + ocpp::messages::ocpp20::CertificateSignedConf& response, + std::string& error, + std::string& message) +{ + return call(CERTIFICATESIGNED_ACTION, request, response, error, message); +} +/** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::ChangeAvailabilityReq&, + * ocpp::messages::ocpp20::ChangeAvailabilityConf&, + * std::string&, + * std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::ChangeAvailabilityReq& request, + ocpp::messages::ocpp20::ChangeAvailabilityConf& response, + std::string& error, + std::string& message) +{ + return call(CHANGEAVAILABILITY_ACTION, request, response, error, message); +} +/** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::ClearCacheReq&, + * ocpp::messages::ocpp20::ClearCacheConf&, + * std::string&, + * std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::ClearCacheReq& request, + ocpp::messages::ocpp20::ClearCacheConf& response, + std::string& error, + std::string& message) +{ + return call(CLEARCACHE_ACTION, request, response, error, message); +} +/** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::ClearChargingProfileReq&, + * ocpp::messages::ocpp20::ClearChargingProfileConf&, + * std::string&, + * std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::ClearChargingProfileReq& request, + ocpp::messages::ocpp20::ClearChargingProfileConf& response, + std::string& error, + std::string& message) +{ + return call(CLEARCHARGINGPROFILE_ACTION, request, response, error, message); +} +/** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::ClearDisplayMessageReq&, + * ocpp::messages::ocpp20::ClearDisplayMessageConf&, + * std::string&, + * std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::ClearDisplayMessageReq& request, + ocpp::messages::ocpp20::ClearDisplayMessageConf& response, + std::string& error, + std::string& message) +{ + return call(CLEARDISPLAYMESSAGE_ACTION, request, response, error, message); +} +/** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::ClearVariableMonitoringReq&, + * ocpp::messages::ocpp20::ClearVariableMonitoringConf&, + * std::string&, + * std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::ClearVariableMonitoringReq& request, + ocpp::messages::ocpp20::ClearVariableMonitoringConf& response, + std::string& error, + std::string& message) +{ + return call(CLEARVARIABLEMONITORING_ACTION, request, response, error, message); +} +/** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::CustomerInformationReq&, + * ocpp::messages::ocpp20::CustomerInformationConf&, + * std::string&, + * std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::CustomerInformationReq& request, + ocpp::messages::ocpp20::CustomerInformationConf& response, + std::string& error, + std::string& message) +{ + return call(CUSTOMERINFORMATION_ACTION, request, response, error, message); +} +/** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::DataTransferReq&, + * ocpp::messages::ocpp20::DataTransferConf&, + * std::string&, + * std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::DataTransferReq& request, + ocpp::messages::ocpp20::DataTransferConf& response, + std::string& error, + std::string& message) +{ + return call(DATATRANSFER_ACTION, request, response, error, message); +} +/** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::DeleteCertificateReq&, + * ocpp::messages::ocpp20::DeleteCertificateConf&, + * std::string&, + * std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::DeleteCertificateReq& request, + ocpp::messages::ocpp20::DeleteCertificateConf& response, + std::string& error, + std::string& message) +{ + return call(DELETECERTIFICATE_ACTION, request, response, error, message); +} +/** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::Get15118EVCertificateReq&, + * ocpp::messages::ocpp20::Get15118EVCertificateConf&, + * std::string&, + * std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::Get15118EVCertificateReq& request, + ocpp::messages::ocpp20::Get15118EVCertificateConf& response, + std::string& error, + std::string& message) +{ + return call(GET15118EVCERTIFICATE_ACTION, request, response, error, message); +} +/** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::GetBaseReportReq&, + * ocpp::messages::ocpp20::GetBaseReportConf&, + * std::string&, + * std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::GetBaseReportReq& request, + ocpp::messages::ocpp20::GetBaseReportConf& response, + std::string& error, + std::string& message) +{ + return call(GETBASEREPORT_ACTION, request, response, error, message); +} +/** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::GetCertificateStatusReq&, + * ocpp::messages::ocpp20::GetCertificateStatusConf&, + * std::string&, + * std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::GetCertificateStatusReq& request, + ocpp::messages::ocpp20::GetCertificateStatusConf& response, + std::string& error, + std::string& message) +{ + return call(GETCERTIFICATESTATUS_ACTION, request, response, error, message); +} +/** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::GetChargingProfilesReq&, + * ocpp::messages::ocpp20::GetChargingProfilesConf&, + * std::string&, + * std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::GetChargingProfilesReq& request, + ocpp::messages::ocpp20::GetChargingProfilesConf& response, + std::string& error, + std::string& message) +{ + return call(GETCHARGINGPROFILES_ACTION, request, response, error, message); +} +/** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::GetCompositeScheduleReq&, + * ocpp::messages::ocpp20::GetCompositeScheduleConf&, + * std::string&, + * std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::GetCompositeScheduleReq& request, + ocpp::messages::ocpp20::GetCompositeScheduleConf& response, + std::string& error, + std::string& message) +{ + return call(GETCOMPOSITESCHEDULE_ACTION, request, response, error, message); +} +/** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::GetDisplayMessagesReq&, + * ocpp::messages::ocpp20::GetDisplayMessagesConf&, + * std::string&, + * std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::GetDisplayMessagesReq& request, + ocpp::messages::ocpp20::GetDisplayMessagesConf& response, + std::string& error, + std::string& message) +{ + return call(GETDISPLAYMESSAGES_ACTION, request, response, error, message); +} +/** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::GetInstalledCertificateIdsReq&, + * ocpp::messages::ocpp20::GetInstalledCertificateIdsConf&, + * std::string&, + * std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::GetInstalledCertificateIdsReq& request, + ocpp::messages::ocpp20::GetInstalledCertificateIdsConf& response, + std::string& error, + std::string& message) +{ + return call(GETINSTALLEDCERTIFICATEIDS_ACTION, request, response, error, message); +} +/** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::GetLocalListVersionReq&, + * ocpp::messages::ocpp20::GetLocalListVersionConf&, + * std::string&, + * std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::GetLocalListVersionReq& request, + ocpp::messages::ocpp20::GetLocalListVersionConf& response, + std::string& error, + std::string& message) +{ + return call(GETLOCALLISTVERSION_ACTION, request, response, error, message); +} +/** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::GetLogReq&, + * ocpp::messages::ocpp20::GetLogConf&, + * std::string&, + * std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::GetLogReq& request, + ocpp::messages::ocpp20::GetLogConf& response, + std::string& error, + std::string& message) +{ + return call(GETLOG_ACTION, request, response, error, message); +} +/** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::GetMonitoringReportReq&, + * ocpp::messages::ocpp20::GetMonitoringReportConf&, + * std::string&, + * std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::GetMonitoringReportReq& request, + ocpp::messages::ocpp20::GetMonitoringReportConf& response, + std::string& error, + std::string& message) +{ + return call(GETMONITORINGREPORT_ACTION, request, response, error, message); +} +/** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::GetReportReq&, + * ocpp::messages::ocpp20::GetReportConf&, + * std::string&, + * std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::GetReportReq& request, + ocpp::messages::ocpp20::GetReportConf& response, + std::string& error, + std::string& message) +{ + return call(GETREPORT_ACTION, request, response, error, message); +} +/** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::GetTransactionStatusReq&, + * ocpp::messages::ocpp20::GetTransactionStatusConf&, + * std::string&, + * std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::GetTransactionStatusReq& request, + ocpp::messages::ocpp20::GetTransactionStatusConf& response, + std::string& error, + std::string& message) +{ + return call(GETTRANSACTIONSTATUS_ACTION, request, response, error, message); +} +/** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::GetVariablesReq&, + * ocpp::messages::ocpp20::GetVariablesConf&, + * std::string&, + * std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::GetVariablesReq& request, + ocpp::messages::ocpp20::GetVariablesConf& response, + std::string& error, + std::string& message) +{ + return call(GETVARIABLES_ACTION, request, response, error, message); +} +/** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::InstallCertificateReq&, + * ocpp::messages::ocpp20::InstallCertificateConf&, + * std::string&, + * std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::InstallCertificateReq& request, + ocpp::messages::ocpp20::InstallCertificateConf& response, + std::string& error, + std::string& message) +{ + return call(INSTALLCERTIFICATE_ACTION, request, response, error, message); +} +/** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::PublishFirmwareReq&, + * ocpp::messages::ocpp20::PublishFirmwareConf&, + * std::string&, + * std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::PublishFirmwareReq& request, + ocpp::messages::ocpp20::PublishFirmwareConf& response, + std::string& error, + std::string& message) +{ + return call(PUBLISHFIRMWARE_ACTION, request, response, error, message); +} +/** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::RequestStartTransactionReq&, + * ocpp::messages::ocpp20::RequestStartTransactionConf&, + * std::string&, + * std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::RequestStartTransactionReq& request, + ocpp::messages::ocpp20::RequestStartTransactionConf& response, + std::string& error, + std::string& message) +{ + return call(REQUESTSTARTTRANSACTION_ACTION, request, response, error, message); +} +/** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::RequestStopTransactionReq&, + * ocpp::messages::ocpp20::RequestStopTransactionConf&, + * std::string&, + * std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::RequestStopTransactionReq& request, + ocpp::messages::ocpp20::RequestStopTransactionConf& response, + std::string& error, + std::string& message) +{ + return call(REQUESTSTOPTRANSACTION_ACTION, request, response, error, message); +} +/** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::ReserveNowReq&, + * ocpp::messages::ocpp20::ReserveNowConf&, + * std::string&, + * std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::ReserveNowReq& request, + ocpp::messages::ocpp20::ReserveNowConf& response, + std::string& error, + std::string& message) +{ + return call(RESERVENOW_ACTION, request, response, error, message); +} +/** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::ResetReq&, + * ocpp::messages::ocpp20::ResetConf&, + * std::string&, + * std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::ResetReq& request, + ocpp::messages::ocpp20::ResetConf& response, + std::string& error, + std::string& message) +{ + return call(RESET_ACTION, request, response, error, message); +} +/** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::SendLocalListReq&, + * ocpp::messages::ocpp20::SendLocalListConf&, + * std::string&, + * std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::SendLocalListReq& request, + ocpp::messages::ocpp20::SendLocalListConf& response, + std::string& error, + std::string& message) +{ + return call(SENDLOCALLIST_ACTION, request, response, error, message); +} +/** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::SetChargingProfileReq&, + * ocpp::messages::ocpp20::SetChargingProfileConf&, + * std::string&, + * std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::SetChargingProfileReq& request, + ocpp::messages::ocpp20::SetChargingProfileConf& response, + std::string& error, + std::string& message) +{ + return call(SETCHARGINGPROFILE_ACTION, request, response, error, message); +} +/** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::SetDisplayMessageReq&, + * ocpp::messages::ocpp20::SetDisplayMessageConf&, + * std::string&, + * std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::SetDisplayMessageReq& request, + ocpp::messages::ocpp20::SetDisplayMessageConf& response, + std::string& error, + std::string& message) +{ + return call(SETDISPLAYMESSAGE_ACTION, request, response, error, message); +} +/** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::SetMonitoringBaseReq&, + * ocpp::messages::ocpp20::SetMonitoringBaseConf&, + * std::string&, + * std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::SetMonitoringBaseReq& request, + ocpp::messages::ocpp20::SetMonitoringBaseConf& response, + std::string& error, + std::string& message) +{ + return call(SETMONITORINGBASE_ACTION, request, response, error, message); +} +/** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::SetMonitoringLevelReq&, + * ocpp::messages::ocpp20::SetMonitoringLevelConf&, + * std::string&, + * std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::SetMonitoringLevelReq& request, + ocpp::messages::ocpp20::SetMonitoringLevelConf& response, + std::string& error, + std::string& message) +{ + return call(SETMONITORINGLEVEL_ACTION, request, response, error, message); +} +/** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::SetNetworkProfileReq&, + * ocpp::messages::ocpp20::SetNetworkProfileConf&, + * std::string&, + * std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::SetNetworkProfileReq& request, + ocpp::messages::ocpp20::SetNetworkProfileConf& response, + std::string& error, + std::string& message) +{ + return call(SETNETWORKPROFILE_ACTION, request, response, error, message); +} +/** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::SetVariableMonitoringReq&, + * ocpp::messages::ocpp20::SetVariableMonitoringConf&, + * std::string&, + * std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::SetVariableMonitoringReq& request, + ocpp::messages::ocpp20::SetVariableMonitoringConf& response, + std::string& error, + std::string& message) +{ + return call(SETVARIABLEMONITORING_ACTION, request, response, error, message); +} +/** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::SetVariablesReq&, + * ocpp::messages::ocpp20::SetVariablesConf&, + * std::string&, + * std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::SetVariablesReq& request, + ocpp::messages::ocpp20::SetVariablesConf& response, + std::string& error, + std::string& message) +{ + return call(SETVARIABLES_ACTION, request, response, error, message); +} +/** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::TriggerMessageReq&, + * ocpp::messages::ocpp20::TriggerMessageConf&, + * std::string&, + * std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::TriggerMessageReq& request, + ocpp::messages::ocpp20::TriggerMessageConf& response, + std::string& error, + std::string& message) +{ + return call(TRIGGERMESSAGE_ACTION, request, response, error, message); +} +/** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::UnlockConnectorReq&, + * ocpp::messages::ocpp20::UnlockConnectorConf&, + * std::string&, + * std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::UnlockConnectorReq& request, + ocpp::messages::ocpp20::UnlockConnectorConf& response, + std::string& error, + std::string& message) +{ + return call(UNLOCKCONNECTOR_ACTION, request, response, error, message); +} +/** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::UnpublishFirmwareReq&, + * ocpp::messages::ocpp20::UnpublishFirmwareConf&, + * std::string&, + * std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::UnpublishFirmwareReq& request, + ocpp::messages::ocpp20::UnpublishFirmwareConf& response, + std::string& error, + std::string& message) +{ + return call(UNPUBLISHFIRMWARE_ACTION, request, response, error, message); +} +/** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::UpdateFirmwareReq&, + * ocpp::messages::ocpp20::UpdateFirmwareConf&, + * std::string&, + * std::string&) */ +bool ChargePointProxy20::call(const ocpp::messages::ocpp20::UpdateFirmwareReq& request, + ocpp::messages::ocpp20::UpdateFirmwareConf& response, + std::string& error, + std::string& message) +{ + return call(UPDATEFIRMWARE_ACTION, request, response, error, message); +} +/** @copydoc bool IChargePointProxy20::registerHandler( + std::function) */ +bool ChargePointProxy20::registerHandler( + std::function< + bool(const ocpp::messages::ocpp20::BootNotificationReq&, ocpp::messages::ocpp20::BootNotificationConf&, std::string&, std::string&)> + handler) +{ + return registerHandler(BOOTNOTIFICATION_ACTION, handler); +} +/** @copydoc bool IChargePointProxy20::registerHandler( + std::function) */ +bool ChargePointProxy20::registerHandler( + std::function + handler) +{ + return registerHandler(AUTHORIZE_ACTION, handler); +} +/** @copydoc bool IChargePointProxy20::registerHandler( + std::function) */ +bool ChargePointProxy20::registerHandler(std::function handler) +{ + return registerHandler(CLEAREDCHARGINGLIMIT_ACTION, handler); +} +/** @copydoc bool IChargePointProxy20::registerHandler( + std::function) */ +bool ChargePointProxy20::registerHandler( + std::function + handler) +{ + return registerHandler(COSTUPDATED_ACTION, handler); +} +/** @copydoc bool IChargePointProxy20::registerHandler( + std::function) */ +bool ChargePointProxy20::registerHandler( + std::function handler) +{ + return registerHandler(DATATRANSFER_ACTION, handler); +} +/** @copydoc bool IChargePointProxy20::registerHandler( + std::function) */ +bool ChargePointProxy20::registerHandler(std::function handler) +{ + return registerHandler(FIRMWARESTATUSNOTIFICATION_ACTION, handler); +} +/** @copydoc bool IChargePointProxy20::registerHandler( + std::function) */ +bool ChargePointProxy20::registerHandler( + std::function + handler) +{ + return registerHandler(HEARTBEAT_ACTION, handler); +} +/** @copydoc bool IChargePointProxy20::registerHandler( + std::function) */ +bool ChargePointProxy20::registerHandler(std::function handler) +{ + return registerHandler(LOGSTATUSNOTIFICATION_ACTION, handler); +} +/** @copydoc bool IChargePointProxy20::registerHandler( + std::function) */ +bool ChargePointProxy20::registerHandler( + std::function + handler) +{ + return registerHandler(METERVALUES_ACTION, handler); +} +/** @copydoc bool IChargePointProxy20::registerHandler( + std::function) */ +bool ChargePointProxy20::registerHandler(std::function handler) +{ + return registerHandler(NOTIFYCHARGINGLIMIT_ACTION, handler); +} +/** @copydoc bool IChargePointProxy20::registerHandler( + std::function) */ +bool ChargePointProxy20::registerHandler(std::function handler) +{ + return registerHandler(NOTIFYCUSTOMERINFORMATION_ACTION, handler); +} +/** @copydoc bool IChargePointProxy20::registerHandler( + std::function) */ +bool ChargePointProxy20::registerHandler(std::function handler) +{ + return registerHandler(NOTIFYDISPLAYMESSAGES_ACTION, handler); +} +/** @copydoc bool IChargePointProxy20::registerHandler( + std::function) */ +bool ChargePointProxy20::registerHandler(std::function handler) +{ + return registerHandler(NOTIFYEVCHARGINGNEEDS_ACTION, handler); +} +/** @copydoc bool IChargePointProxy20::registerHandler( + std::function) */ +bool ChargePointProxy20::registerHandler(std::function handler) +{ + return registerHandler(NOTIFYEVCHARGINGSCHEDULE_ACTION, handler); +} +/** @copydoc bool IChargePointProxy20::registerHandler( + std::function) */ +bool ChargePointProxy20::registerHandler( + std::function + handler) +{ + return registerHandler(NOTIFYEVENT_ACTION, handler); +} +/** @copydoc bool IChargePointProxy20::registerHandler( + std::function) */ +bool ChargePointProxy20::registerHandler(std::function handler) +{ + return registerHandler(NOTIFYMONITORINGREPORT_ACTION, handler); +} +/** @copydoc bool IChargePointProxy20::registerHandler( + std::function) */ +bool ChargePointProxy20::registerHandler( + std::function handler) +{ + return registerHandler(NOTIFYREPORT_ACTION, handler); +} +/** @copydoc bool IChargePointProxy20::registerHandler( + std::function) */ +bool ChargePointProxy20::registerHandler(std::function handler) +{ + return registerHandler(PUBLISHFIRMWARESTATUSNOTIFICATION_ACTION, handler); +} +/** @copydoc bool IChargePointProxy20::registerHandler( + std::function) */ +bool ChargePointProxy20::registerHandler(std::function handler) +{ + return registerHandler(REPORTCHARGINGPROFILES_ACTION, handler); +} +/** @copydoc bool IChargePointProxy20::registerHandler( + std::function) */ +bool ChargePointProxy20::registerHandler(std::function handler) +{ + return registerHandler(RESERVATIONSTATUSUPDATE_ACTION, handler); +} +/** @copydoc bool IChargePointProxy20::registerHandler( + std::function) */ +bool ChargePointProxy20::registerHandler(std::function handler) +{ + return registerHandler(SECURITYEVENTNOTIFICATION_ACTION, handler); +} +/** @copydoc bool IChargePointProxy20::registerHandler( + std::function) */ +bool ChargePointProxy20::registerHandler( + std::function< + bool(const ocpp::messages::ocpp20::SignCertificateReq&, ocpp::messages::ocpp20::SignCertificateConf&, std::string&, std::string&)> + handler) +{ + return registerHandler(SIGNCERTIFICATE_ACTION, handler); +} +/** @copydoc bool IChargePointProxy20::registerHandler( + std::function) */ +bool ChargePointProxy20::registerHandler( + std::function + handler) +{ + return registerHandler(STATUSNOTIFICATION_ACTION, handler); +} +/** @copydoc bool IChargePointProxy20::registerHandler( + std::function) */ +bool ChargePointProxy20::registerHandler( + std::function< + bool(const ocpp::messages::ocpp20::TransactionEventReq&, ocpp::messages::ocpp20::TransactionEventConf&, std::string&, std::string&)> + handler) +{ + return registerHandler(TRANSACTIONEVENT_ACTION, handler); +} + +// IRpc::IListener interface + +/** @copydoc void IRpc::IListener::rpcDisconnected() */ +void ChargePointProxy20::rpcDisconnected() +{ + LOG_WARNING << "[" << m_identifier << "] - Disconnected from Charge Point"; + + // Disconnect from the central system + m_central_system->disconnect(); + + // Notify listener + if (m_listener) + { + m_listener->disconnectedFromChargePoint(); + } +} + +/** @copydoc void IRpc::IListener::rpcError() */ +void ChargePointProxy20::rpcError() +{ + LOG_ERROR << "[" << m_identifier << "] - Connection error"; +} + +/** @copydoc bool IRpc::IListener::rpcCallReceived(const std::string&, + const rapidjson::Value&, + rapidjson::Document&, + std::string&, + std::string&) */ +bool ChargePointProxy20::rpcCallReceived(const std::string& action, + const rapidjson::Value& payload, + rapidjson::Document& response, + std::string& error_code, + std::string& error_message) +{ + return m_msg_dispatcher.dispatchMessage(action, payload, response, error_code, error_message); +} + +// IRpc::ISpy interface + +/** @copydoc void IRpc::ISpy::rcpMessageReceived(const std::string& msg) */ +void ChargePointProxy20::rcpMessageReceived(const std::string& msg) +{ + LOG_COM << "[" << m_identifier << "] - RX : " << msg; +} + +void ChargePointProxy20::rcpMessageSent(const std::string& msg) +{ + LOG_COM << "[" << m_identifier << "] - TX : " << msg; +} + +} // namespace ocpp20 +} // namespace localcontroller +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/localcontroller/chargepoint/ChargePointProxy20.h b/src/ocpp20/localcontroller/chargepoint/ChargePointProxy20.h new file mode 100644 index 00000000..7bd134c6 --- /dev/null +++ b/src/ocpp20/localcontroller/chargepoint/ChargePointProxy20.h @@ -0,0 +1,657 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* Generated by json2cpp */ + +#ifndef OPENOCPP_OCPP20_LC_CHARGEPOINTPROXY20_H +#define OPENOCPP_OCPP20_LC_CHARGEPOINTPROXY20_H + +#include "ChargePointHandler20.h" +#include "GenericMessageSender.h" +#include "IChargePointProxy20.h" +#include "Logger.h" +#include "MessageDispatcher.h" +#include "MessagesValidator20.h" +#include "RpcServer.h" +#include "UserMessageHandler.h" + +namespace ocpp +{ +namespace config +{ +class ILocalControllerConfig20; +} // namespace config +namespace localcontroller +{ +namespace ocpp20 +{ + +/** @brief Charge point proxy */ +class ChargePointProxy20 : public IChargePointProxy20, public ocpp::rpc::IRpc::IListener, public ocpp::rpc::IRpc::ISpy +{ + public: + /** + * @brief Constructor + * @param identifier Charge point's identifier + * @param rpc RPC connection with the charge point + * @param messages_validator JSON schemas needed to validate payloads + * @param messages_converter Converter from/to OCPP to/from JSON messages + * @param stack_config Stack configuration + * @param central_system Proxy to forward requests to the central system + */ + ChargePointProxy20(const std::string& identifier, + std::shared_ptr rpc, + const ocpp::messages::ocpp20::MessagesValidator20& messages_validator, + ocpp::messages::ocpp20::MessagesConverter20& messages_converter, + const ocpp::config::ILocalControllerConfig20& stack_config, + std::shared_ptr central_system); + /** @brief Destructor */ + virtual ~ChargePointProxy20(); + + // IChargePointProxy20 interface + + /** @copydoc const std::string& IChargePointProxy20::ipAddress() const */ + const std::string& ipAddress() const override; + + /** @copydoc const std::string& IChargePointProxy20::identifier() const */ + const std::string& identifier() const override { return m_identifier; } + + /** @copydoc void IChargePointProxy20::setTimeout(std::chrono::milliseconds) */ + void setTimeout(std::chrono::milliseconds timeout) override; + + /** @copydoc void IChargePointProxy20::disconnect() */ + void disconnect() override; + + /** @copydoc std::shared_ptr IChargePointProxy20::centralSystemProxy() */ + std::shared_ptr centralSystemProxy() override { return m_central_system; } + + /** @copydoc void IChargePointProxy20::registerListener(ILocalControllerProxyEventsHandler20&) */ + void registerListener(ILocalControllerProxyEventsHandler20& listener) override + { + m_listener = &listener; + m_central_system->registerListener(listener); + } + + // OCPP operations + /** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::CancelReservationReq&, + * ocpp::messages::ocpp20::CancelReservationConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::CancelReservationReq& request, + ocpp::messages::ocpp20::CancelReservationConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::CertificateSignedReq&, + * ocpp::messages::ocpp20::CertificateSignedConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::CertificateSignedReq& request, + ocpp::messages::ocpp20::CertificateSignedConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::ChangeAvailabilityReq&, + * ocpp::messages::ocpp20::ChangeAvailabilityConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::ChangeAvailabilityReq& request, + ocpp::messages::ocpp20::ChangeAvailabilityConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::ClearCacheReq&, + * ocpp::messages::ocpp20::ClearCacheConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::ClearCacheReq& request, + ocpp::messages::ocpp20::ClearCacheConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::ClearChargingProfileReq&, + * ocpp::messages::ocpp20::ClearChargingProfileConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::ClearChargingProfileReq& request, + ocpp::messages::ocpp20::ClearChargingProfileConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::ClearDisplayMessageReq&, + * ocpp::messages::ocpp20::ClearDisplayMessageConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::ClearDisplayMessageReq& request, + ocpp::messages::ocpp20::ClearDisplayMessageConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::ClearVariableMonitoringReq&, + * ocpp::messages::ocpp20::ClearVariableMonitoringConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::ClearVariableMonitoringReq& request, + ocpp::messages::ocpp20::ClearVariableMonitoringConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::CustomerInformationReq&, + * ocpp::messages::ocpp20::CustomerInformationConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::CustomerInformationReq& request, + ocpp::messages::ocpp20::CustomerInformationConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::DataTransferReq&, + * ocpp::messages::ocpp20::DataTransferConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::DataTransferReq& request, + ocpp::messages::ocpp20::DataTransferConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::DeleteCertificateReq&, + * ocpp::messages::ocpp20::DeleteCertificateConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::DeleteCertificateReq& request, + ocpp::messages::ocpp20::DeleteCertificateConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::Get15118EVCertificateReq&, + * ocpp::messages::ocpp20::Get15118EVCertificateConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::Get15118EVCertificateReq& request, + ocpp::messages::ocpp20::Get15118EVCertificateConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::GetBaseReportReq&, + * ocpp::messages::ocpp20::GetBaseReportConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::GetBaseReportReq& request, + ocpp::messages::ocpp20::GetBaseReportConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::GetCertificateStatusReq&, + * ocpp::messages::ocpp20::GetCertificateStatusConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::GetCertificateStatusReq& request, + ocpp::messages::ocpp20::GetCertificateStatusConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::GetChargingProfilesReq&, + * ocpp::messages::ocpp20::GetChargingProfilesConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::GetChargingProfilesReq& request, + ocpp::messages::ocpp20::GetChargingProfilesConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::GetCompositeScheduleReq&, + * ocpp::messages::ocpp20::GetCompositeScheduleConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::GetCompositeScheduleReq& request, + ocpp::messages::ocpp20::GetCompositeScheduleConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::GetDisplayMessagesReq&, + * ocpp::messages::ocpp20::GetDisplayMessagesConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::GetDisplayMessagesReq& request, + ocpp::messages::ocpp20::GetDisplayMessagesConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::GetInstalledCertificateIdsReq&, + * ocpp::messages::ocpp20::GetInstalledCertificateIdsConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::GetInstalledCertificateIdsReq& request, + ocpp::messages::ocpp20::GetInstalledCertificateIdsConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::GetLocalListVersionReq&, + * ocpp::messages::ocpp20::GetLocalListVersionConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::GetLocalListVersionReq& request, + ocpp::messages::ocpp20::GetLocalListVersionConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::GetLogReq&, + * ocpp::messages::ocpp20::GetLogConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::GetLogReq& request, + ocpp::messages::ocpp20::GetLogConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::GetMonitoringReportReq&, + * ocpp::messages::ocpp20::GetMonitoringReportConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::GetMonitoringReportReq& request, + ocpp::messages::ocpp20::GetMonitoringReportConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::GetReportReq&, + * ocpp::messages::ocpp20::GetReportConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::GetReportReq& request, + ocpp::messages::ocpp20::GetReportConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::GetTransactionStatusReq&, + * ocpp::messages::ocpp20::GetTransactionStatusConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::GetTransactionStatusReq& request, + ocpp::messages::ocpp20::GetTransactionStatusConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::GetVariablesReq&, + * ocpp::messages::ocpp20::GetVariablesConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::GetVariablesReq& request, + ocpp::messages::ocpp20::GetVariablesConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::InstallCertificateReq&, + * ocpp::messages::ocpp20::InstallCertificateConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::InstallCertificateReq& request, + ocpp::messages::ocpp20::InstallCertificateConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::PublishFirmwareReq&, + * ocpp::messages::ocpp20::PublishFirmwareConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::PublishFirmwareReq& request, + ocpp::messages::ocpp20::PublishFirmwareConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::RequestStartTransactionReq&, + * ocpp::messages::ocpp20::RequestStartTransactionConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::RequestStartTransactionReq& request, + ocpp::messages::ocpp20::RequestStartTransactionConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::RequestStopTransactionReq&, + * ocpp::messages::ocpp20::RequestStopTransactionConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::RequestStopTransactionReq& request, + ocpp::messages::ocpp20::RequestStopTransactionConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::ReserveNowReq&, + * ocpp::messages::ocpp20::ReserveNowConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::ReserveNowReq& request, + ocpp::messages::ocpp20::ReserveNowConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::ResetReq&, + * ocpp::messages::ocpp20::ResetConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::ResetReq& request, + ocpp::messages::ocpp20::ResetConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::SendLocalListReq&, + * ocpp::messages::ocpp20::SendLocalListConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::SendLocalListReq& request, + ocpp::messages::ocpp20::SendLocalListConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::SetChargingProfileReq&, + * ocpp::messages::ocpp20::SetChargingProfileConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::SetChargingProfileReq& request, + ocpp::messages::ocpp20::SetChargingProfileConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::SetDisplayMessageReq&, + * ocpp::messages::ocpp20::SetDisplayMessageConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::SetDisplayMessageReq& request, + ocpp::messages::ocpp20::SetDisplayMessageConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::SetMonitoringBaseReq&, + * ocpp::messages::ocpp20::SetMonitoringBaseConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::SetMonitoringBaseReq& request, + ocpp::messages::ocpp20::SetMonitoringBaseConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::SetMonitoringLevelReq&, + * ocpp::messages::ocpp20::SetMonitoringLevelConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::SetMonitoringLevelReq& request, + ocpp::messages::ocpp20::SetMonitoringLevelConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::SetNetworkProfileReq&, + * ocpp::messages::ocpp20::SetNetworkProfileConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::SetNetworkProfileReq& request, + ocpp::messages::ocpp20::SetNetworkProfileConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::SetVariableMonitoringReq&, + * ocpp::messages::ocpp20::SetVariableMonitoringConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::SetVariableMonitoringReq& request, + ocpp::messages::ocpp20::SetVariableMonitoringConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::SetVariablesReq&, + * ocpp::messages::ocpp20::SetVariablesConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::SetVariablesReq& request, + ocpp::messages::ocpp20::SetVariablesConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::TriggerMessageReq&, + * ocpp::messages::ocpp20::TriggerMessageConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::TriggerMessageReq& request, + ocpp::messages::ocpp20::TriggerMessageConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::UnlockConnectorReq&, + * ocpp::messages::ocpp20::UnlockConnectorConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::UnlockConnectorReq& request, + ocpp::messages::ocpp20::UnlockConnectorConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::UnpublishFirmwareReq&, + * ocpp::messages::ocpp20::UnpublishFirmwareConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::UnpublishFirmwareReq& request, + ocpp::messages::ocpp20::UnpublishFirmwareConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool IChargePointProxy20::call(const ocpp::messages::ocpp20::UpdateFirmwareReq&, + * ocpp::messages::ocpp20::UpdateFirmwareConf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::ocpp20::UpdateFirmwareReq& request, + ocpp::messages::ocpp20::UpdateFirmwareConf& response, + std::string& error, + std::string& message) override; + /** @copydoc bool IChargePointProxy20::registerHandler( + std::function) */ + bool registerHandler( + std::function + handler) override; + /** @copydoc bool IChargePointProxy20::registerHandler( + std::function) */ + bool registerHandler( + std::function + handler) override; + /** @copydoc bool IChargePointProxy20::registerHandler( + std::function) */ + bool registerHandler(std::function handler) override; + /** @copydoc bool IChargePointProxy20::registerHandler( + std::function) */ + bool registerHandler( + std::function handler) + override; + /** @copydoc bool IChargePointProxy20::registerHandler( + std::function) */ + bool registerHandler( + std::function handler) + override; + /** @copydoc bool IChargePointProxy20::registerHandler( + std::function) */ + bool registerHandler(std::function handler) override; + /** @copydoc bool IChargePointProxy20::registerHandler( + std::function) */ + bool registerHandler( + std::function + handler) override; + /** @copydoc bool IChargePointProxy20::registerHandler( + std::function) */ + bool registerHandler(std::function handler) override; + /** @copydoc bool IChargePointProxy20::registerHandler( + std::function) */ + bool registerHandler( + std::function handler) + override; + /** @copydoc bool IChargePointProxy20::registerHandler( + std::function) */ + bool registerHandler(std::function handler) override; + /** @copydoc bool IChargePointProxy20::registerHandler( + std::function) */ + bool registerHandler(std::function handler) override; + /** @copydoc bool IChargePointProxy20::registerHandler( + std::function) */ + bool registerHandler(std::function handler) override; + /** @copydoc bool IChargePointProxy20::registerHandler( + std::function) */ + bool registerHandler(std::function handler) override; + /** @copydoc bool IChargePointProxy20::registerHandler( + std::function) */ + bool registerHandler(std::function handler) override; + /** @copydoc bool IChargePointProxy20::registerHandler( + std::function) */ + bool registerHandler( + std::function handler) + override; + /** @copydoc bool IChargePointProxy20::registerHandler( + std::function) */ + bool registerHandler(std::function handler) override; + /** @copydoc bool IChargePointProxy20::registerHandler( + std::function) */ + bool registerHandler( + std::function handler) + override; + /** @copydoc bool IChargePointProxy20::registerHandler( + std::function) */ + bool registerHandler(std::function handler) override; + /** @copydoc bool IChargePointProxy20::registerHandler( + std::function) */ + bool registerHandler(std::function handler) override; + /** @copydoc bool IChargePointProxy20::registerHandler( + std::function) */ + bool registerHandler(std::function handler) override; + /** @copydoc bool IChargePointProxy20::registerHandler( + std::function) */ + bool registerHandler(std::function handler) override; + /** @copydoc bool IChargePointProxy20::registerHandler( + std::function) */ + bool registerHandler( + std::function + handler) override; + /** @copydoc bool IChargePointProxy20::registerHandler( + std::function) */ + bool registerHandler(std::function handler) override; + /** @copydoc bool IChargePointProxy20::registerHandler( + std::function) */ + bool registerHandler( + std::function + handler) override; + + // IRpc::IListener interface + + /** @copydoc void IRpc::IListener::rpcDisconnected() */ + void rpcDisconnected() override; + + /** @copydoc void IRpc::IListener::rpcError() */ + void rpcError() override; + + /** @copydoc bool IRpc::IListener::rpcCallReceived(const std::string&, + const rapidjson::Value&, + rapidjson::Document&, + std::string&, + std::string&) */ + bool rpcCallReceived(const std::string& action, + const rapidjson::Value& payload, + rapidjson::Document& response, + std::string& error_code, + std::string& error_message) override; + + // IRpc::ISpy interface + + /** @copydoc void IRpc::ISpy::rcpMessageReceived(const std::string& msg) */ + void rcpMessageReceived(const std::string& msg) override; + + /** @copydoc void IRpc::ISpy::rcpMessageSent(const std::string& msg) */ + void rcpMessageSent(const std::string& msg) override; + + private: + /** @brief Charge point's identifier */ + std::string m_identifier; + /** @brief RPC connection */ + std::shared_ptr m_rpc; + /** @brief Messages converter */ + ocpp::messages::ocpp20::MessagesConverter20& m_messages_converter; + /** @brief Message dispatcher */ + ocpp::messages::MessageDispatcher m_msg_dispatcher; + /** @brief Message sender */ + ocpp::messages::GenericMessageSender m_msg_sender; + /** @brief Proxy to forward requests to the central system */ + std::shared_ptr m_central_system; + /** @brief Request handler */ + ChargePointHandler20 m_handler; + /** @brief Listener to the proxy events */ + ILocalControllerProxyEventsHandler20* m_listener; + /** @brief User message handlers */ + std::vector> m_user_handlers; + + /** + * @brief Execute a call request + * @param action RPC action for the request + * @param request Request payload + * @param response Response payload + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + template + bool call(const std::string& action, const RequestType& request, ResponseType& response, std::string& error, std::string& message) + { + bool ret = true; + + LOG_DEBUG << "[" << m_identifier << "] - " << action; + + ocpp::messages::CallResult res = m_msg_sender.call(action, request, response, error, message); + if (res != ocpp::messages::CallResult::Ok) + { + LOG_ERROR << "[" << m_identifier << "] - " << action << " => " + << (res == ocpp::messages::CallResult::Failed ? "Timeout" : "Error"); + ret = false; + } + + return ret; + } + + /** + * @brief Register a user handler for an incoming request + * @param action RPC action for the request + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + template + bool registerHandler(const std::string& action, + std::function handler) + { + ocpp::messages::UserMessageHandler* msg_handler = + new ocpp::messages::UserMessageHandler(action, m_messages_converter, handler); + m_user_handlers.push_back(std::shared_ptr(msg_handler)); + return m_msg_dispatcher.registerHandler(action, *msg_handler, true); + } +}; + +} // namespace ocpp20 +} // namespace localcontroller +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_LC_CHARGEPOINTPROXY20_H \ No newline at end of file diff --git a/src/ocpp20/localcontroller/config/InternalConfigKeys.h b/src/ocpp20/localcontroller/config/InternalConfigKeys.h new file mode 100644 index 00000000..11b8e97a --- /dev/null +++ b/src/ocpp20/localcontroller/config/InternalConfigKeys.h @@ -0,0 +1,39 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +#ifndef OPENOCPP_INTERNALCONFIGKEYS_H +#define OPENOCPP_INTERNALCONFIGKEYS_H + +namespace ocpp +{ +namespace localcontroller +{ + +/** @brief Configuration key : stack version */ +static constexpr const char* STACK_VERSION_KEY = "StackVersion"; +/** @brief Configuration key : last start date */ +static constexpr const char* START_DATE_KEY = "LastSessionStartDate"; +/** @brief Configuration key : uptime */ +static constexpr const char* UPTIME_KEY = "LastSessionUpTime"; +/** @brief Configuration key : total uptime */ +static constexpr const char* TOTAL_UPTIME_KEY = "TotalUpTime"; + +} // namespace localcontroller +} // namespace ocpp + +#endif // OPENOCPP_INTERNALCONFIGKEYS_H diff --git a/src/ocpp20/localcontroller/interface/ICentralSystemProxy20.h b/src/ocpp20/localcontroller/interface/ICentralSystemProxy20.h new file mode 100644 index 00000000..55dd5999 --- /dev/null +++ b/src/ocpp20/localcontroller/interface/ICentralSystemProxy20.h @@ -0,0 +1,811 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* Generated by json2cpp */ + +#ifndef OPENOCPP_OCPP20_ICENTRALSYSTEMPROXY20_H +#define OPENOCPP_OCPP20_ICENTRALSYSTEMPROXY20_H + +#include "Authorize20.h" +#include "BootNotification20.h" +#include "CancelReservation20.h" +#include "CertificateSigned20.h" +#include "ChangeAvailability20.h" +#include "ClearCache20.h" +#include "ClearChargingProfile20.h" +#include "ClearDisplayMessage20.h" +#include "ClearVariableMonitoring20.h" +#include "ClearedChargingLimit20.h" +#include "CostUpdated20.h" +#include "CustomerInformation20.h" +#include "DataTransfer20.h" +#include "DeleteCertificate20.h" +#include "FirmwareStatusNotification20.h" +#include "Get15118EVCertificate20.h" +#include "GetBaseReport20.h" +#include "GetCertificateStatus20.h" +#include "GetChargingProfiles20.h" +#include "GetCompositeSchedule20.h" +#include "GetDisplayMessages20.h" +#include "GetInstalledCertificateIds20.h" +#include "GetLocalListVersion20.h" +#include "GetLog20.h" +#include "GetMonitoringReport20.h" +#include "GetReport20.h" +#include "GetTransactionStatus20.h" +#include "GetVariables20.h" +#include "Heartbeat20.h" +#include "IWebsocketClient.h" +#include "InstallCertificate20.h" +#include "LogStatusNotification20.h" +#include "MeterValues20.h" +#include "NotifyChargingLimit20.h" +#include "NotifyCustomerInformation20.h" +#include "NotifyDisplayMessages20.h" +#include "NotifyEVChargingNeeds20.h" +#include "NotifyEVChargingSchedule20.h" +#include "NotifyEvent20.h" +#include "NotifyMonitoringReport20.h" +#include "NotifyReport20.h" +#include "PublishFirmware20.h" +#include "PublishFirmwareStatusNotification20.h" +#include "ReportChargingProfiles20.h" +#include "RequestStartTransaction20.h" +#include "RequestStopTransaction20.h" +#include "ReservationStatusUpdate20.h" +#include "ReserveNow20.h" +#include "Reset20.h" +#include "SecurityEventNotification20.h" +#include "SendLocalList20.h" +#include "SetChargingProfile20.h" +#include "SetDisplayMessage20.h" +#include "SetMonitoringBase20.h" +#include "SetMonitoringLevel20.h" +#include "SetNetworkProfile20.h" +#include "SetVariableMonitoring20.h" +#include "SetVariables20.h" +#include "SignCertificate20.h" +#include "StatusNotification20.h" +#include "TransactionEvent20.h" +#include "TriggerMessage20.h" +#include "UnlockConnector20.h" +#include "UnpublishFirmware20.h" +#include "UpdateFirmware20.h" + +#include + +namespace ocpp +{ +namespace localcontroller +{ +namespace ocpp20 +{ + +class ILocalControllerProxyEventsHandler20; + +/** @brief Interface for central system proxy implementations */ +class ICentralSystemProxy20 +{ + public: + /** @brief Destructor */ + virtual ~ICentralSystemProxy20() { } + + /** + * @brief Get the charge point identifier + * @return charge point identifier + */ + virtual const std::string& identifier() const = 0; + + /** + * @brief Set the call request timeout + * @param timeout New timeout value + */ + virtual void setTimeout(std::chrono::milliseconds timeout) = 0; + + /** + * @brief Connect to the central system + * @param url URL to connect to + * @param credentials Credentials to use + * @param connect_timeout Connection timeout in ms + * @param retry_interval Retry interval in ms when connection cannot be established (0 = no retry) + * @param ping_interval Interval between 2 websocket PING messages when the socket is idle + * @return true if the client has been started, false otherwise + */ + virtual bool connect(const std::string& url, + const ocpp::websockets::IWebsocketClient::Credentials& credentials, + std::chrono::milliseconds connect_timeout = std::chrono::seconds(5), + std::chrono::milliseconds retry_interval = std::chrono::seconds(5), + std::chrono::milliseconds ping_interval = std::chrono::seconds(5)) = 0; + + /** @brief Disconnect from the central system */ + virtual void disconnect() = 0; + + /** + * @brief Indicate if the connection with the central system is active + * @return true if the connection is active, false otherwise + */ + virtual bool isConnected() const = 0; + + /** + * @brief Register a listener to the proxy events + * @param listener Listener to the proxy events + */ + virtual void registerListener(ILocalControllerProxyEventsHandler20& listener) = 0; + + // OCPP operations + /** + * @brief Send a BootNotification message to the central system + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::BootNotificationReq& request, + ocpp::messages::ocpp20::BootNotificationConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a Authorize message to the central system + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::AuthorizeReq& request, + ocpp::messages::ocpp20::AuthorizeConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a ClearedChargingLimit message to the central system + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::ClearedChargingLimitReq& request, + ocpp::messages::ocpp20::ClearedChargingLimitConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a CostUpdated message to the central system + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::CostUpdatedReq& request, + ocpp::messages::ocpp20::CostUpdatedConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a DataTransfer message to the central system + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::DataTransferReq& request, + ocpp::messages::ocpp20::DataTransferConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a FirmwareStatusNotification message to the central system + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::FirmwareStatusNotificationReq& request, + ocpp::messages::ocpp20::FirmwareStatusNotificationConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a Heartbeat message to the central system + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::HeartbeatReq& request, + ocpp::messages::ocpp20::HeartbeatConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a LogStatusNotification message to the central system + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::LogStatusNotificationReq& request, + ocpp::messages::ocpp20::LogStatusNotificationConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a MeterValues message to the central system + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::MeterValuesReq& request, + ocpp::messages::ocpp20::MeterValuesConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a NotifyChargingLimit message to the central system + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::NotifyChargingLimitReq& request, + ocpp::messages::ocpp20::NotifyChargingLimitConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a NotifyCustomerInformation message to the central system + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::NotifyCustomerInformationReq& request, + ocpp::messages::ocpp20::NotifyCustomerInformationConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a NotifyDisplayMessages message to the central system + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::NotifyDisplayMessagesReq& request, + ocpp::messages::ocpp20::NotifyDisplayMessagesConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a NotifyEVChargingNeeds message to the central system + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::NotifyEVChargingNeedsReq& request, + ocpp::messages::ocpp20::NotifyEVChargingNeedsConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a NotifyEVChargingSchedule message to the central system + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::NotifyEVChargingScheduleReq& request, + ocpp::messages::ocpp20::NotifyEVChargingScheduleConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a NotifyEvent message to the central system + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::NotifyEventReq& request, + ocpp::messages::ocpp20::NotifyEventConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a NotifyMonitoringReport message to the central system + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::NotifyMonitoringReportReq& request, + ocpp::messages::ocpp20::NotifyMonitoringReportConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a NotifyReport message to the central system + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::NotifyReportReq& request, + ocpp::messages::ocpp20::NotifyReportConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a PublishFirmwareStatusNotification message to the central system + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::PublishFirmwareStatusNotificationReq& request, + ocpp::messages::ocpp20::PublishFirmwareStatusNotificationConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a ReportChargingProfiles message to the central system + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::ReportChargingProfilesReq& request, + ocpp::messages::ocpp20::ReportChargingProfilesConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a ReservationStatusUpdate message to the central system + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::ReservationStatusUpdateReq& request, + ocpp::messages::ocpp20::ReservationStatusUpdateConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a SecurityEventNotification message to the central system + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::SecurityEventNotificationReq& request, + ocpp::messages::ocpp20::SecurityEventNotificationConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a SignCertificate message to the central system + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::SignCertificateReq& request, + ocpp::messages::ocpp20::SignCertificateConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a StatusNotification message to the central system + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::StatusNotificationReq& request, + ocpp::messages::ocpp20::StatusNotificationConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a TransactionEvent message to the central system + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::TransactionEventReq& request, + ocpp::messages::ocpp20::TransactionEventConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Register a handler for the CancelReservation request from the central system + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler(std::function handler) = 0; + /** + * @brief Register a handler for the CertificateSigned request from the central system + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler(std::function handler) = 0; + /** + * @brief Register a handler for the ChangeAvailability request from the central system + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler(std::function handler) = 0; + /** + * @brief Register a handler for the ClearCache request from the central system + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler( + std::function< + bool(const ocpp::messages::ocpp20::ClearCacheReq&, ocpp::messages::ocpp20::ClearCacheConf&, std::string&, std::string&)> + handler) = 0; + /** + * @brief Register a handler for the ClearChargingProfile request from the central system + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler(std::function handler) = 0; + /** + * @brief Register a handler for the ClearDisplayMessage request from the central system + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler(std::function handler) = 0; + /** + * @brief Register a handler for the ClearVariableMonitoring request from the central system + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler(std::function handler) = 0; + /** + * @brief Register a handler for the CustomerInformation request from the central system + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler(std::function handler) = 0; + /** + * @brief Register a handler for the DataTransfer request from the central system + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler( + std::function< + bool(const ocpp::messages::ocpp20::DataTransferReq&, ocpp::messages::ocpp20::DataTransferConf&, std::string&, std::string&)> + handler) = 0; + /** + * @brief Register a handler for the DeleteCertificate request from the central system + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler(std::function handler) = 0; + /** + * @brief Register a handler for the Get15118EVCertificate request from the central system + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler(std::function handler) = 0; + /** + * @brief Register a handler for the GetBaseReport request from the central system + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler( + std::function< + bool(const ocpp::messages::ocpp20::GetBaseReportReq&, ocpp::messages::ocpp20::GetBaseReportConf&, std::string&, std::string&)> + handler) = 0; + /** + * @brief Register a handler for the GetCertificateStatus request from the central system + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler(std::function handler) = 0; + /** + * @brief Register a handler for the GetChargingProfiles request from the central system + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler(std::function handler) = 0; + /** + * @brief Register a handler for the GetCompositeSchedule request from the central system + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler(std::function handler) = 0; + /** + * @brief Register a handler for the GetDisplayMessages request from the central system + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler(std::function handler) = 0; + /** + * @brief Register a handler for the GetInstalledCertificateIds request from the central system + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler(std::function handler) = 0; + /** + * @brief Register a handler for the GetLocalListVersion request from the central system + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler(std::function handler) = 0; + /** + * @brief Register a handler for the GetLog request from the central system + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler( + std::function + handler) = 0; + /** + * @brief Register a handler for the GetMonitoringReport request from the central system + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler(std::function handler) = 0; + /** + * @brief Register a handler for the GetReport request from the central system + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler( + std::function + handler) = 0; + /** + * @brief Register a handler for the GetTransactionStatus request from the central system + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler(std::function handler) = 0; + /** + * @brief Register a handler for the GetVariables request from the central system + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler( + std::function< + bool(const ocpp::messages::ocpp20::GetVariablesReq&, ocpp::messages::ocpp20::GetVariablesConf&, std::string&, std::string&)> + handler) = 0; + /** + * @brief Register a handler for the InstallCertificate request from the central system + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler(std::function handler) = 0; + /** + * @brief Register a handler for the PublishFirmware request from the central system + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler( + std::function + handler) = 0; + /** + * @brief Register a handler for the RequestStartTransaction request from the central system + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler(std::function handler) = 0; + /** + * @brief Register a handler for the RequestStopTransaction request from the central system + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler(std::function handler) = 0; + /** + * @brief Register a handler for the ReserveNow request from the central system + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler( + std::function< + bool(const ocpp::messages::ocpp20::ReserveNowReq&, ocpp::messages::ocpp20::ReserveNowConf&, std::string&, std::string&)> + handler) = 0; + /** + * @brief Register a handler for the Reset request from the central system + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler( + std::function + handler) = 0; + /** + * @brief Register a handler for the SendLocalList request from the central system + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler( + std::function< + bool(const ocpp::messages::ocpp20::SendLocalListReq&, ocpp::messages::ocpp20::SendLocalListConf&, std::string&, std::string&)> + handler) = 0; + /** + * @brief Register a handler for the SetChargingProfile request from the central system + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler(std::function handler) = 0; + /** + * @brief Register a handler for the SetDisplayMessage request from the central system + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler(std::function handler) = 0; + /** + * @brief Register a handler for the SetMonitoringBase request from the central system + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler(std::function handler) = 0; + /** + * @brief Register a handler for the SetMonitoringLevel request from the central system + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler(std::function handler) = 0; + /** + * @brief Register a handler for the SetNetworkProfile request from the central system + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler(std::function handler) = 0; + /** + * @brief Register a handler for the SetVariableMonitoring request from the central system + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler(std::function handler) = 0; + /** + * @brief Register a handler for the SetVariables request from the central system + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler( + std::function< + bool(const ocpp::messages::ocpp20::SetVariablesReq&, ocpp::messages::ocpp20::SetVariablesConf&, std::string&, std::string&)> + handler) = 0; + /** + * @brief Register a handler for the TriggerMessage request from the central system + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler( + std::function< + bool(const ocpp::messages::ocpp20::TriggerMessageReq&, ocpp::messages::ocpp20::TriggerMessageConf&, std::string&, std::string&)> + handler) = 0; + /** + * @brief Register a handler for the UnlockConnector request from the central system + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler( + std::function + handler) = 0; + /** + * @brief Register a handler for the UnpublishFirmware request from the central system + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler(std::function handler) = 0; + /** + * @brief Register a handler for the UpdateFirmware request from the central system + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler( + std::function< + bool(const ocpp::messages::ocpp20::UpdateFirmwareReq&, ocpp::messages::ocpp20::UpdateFirmwareConf&, std::string&, std::string&)> + handler) = 0; +}; + +} // namespace ocpp20 +} // namespace localcontroller +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_ICENTRALSYSTEMPROXY20_H \ No newline at end of file diff --git a/src/ocpp20/localcontroller/interface/IChargePointProxy20.h b/src/ocpp20/localcontroller/interface/IChargePointProxy20.h new file mode 100644 index 00000000..73a28d5c --- /dev/null +++ b/src/ocpp20/localcontroller/interface/IChargePointProxy20.h @@ -0,0 +1,844 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* Generated by json2cpp */ + +#ifndef OPENOCPP_OCPP20_ICHARGEPOINTPROXY20_H +#define OPENOCPP_OCPP20_ICHARGEPOINTPROXY20_H + +#include "CancelReservation20.h" +#include "CertificateSigned20.h" +#include "ChangeAvailability20.h" +#include "ClearCache20.h" +#include "ClearChargingProfile20.h" +#include "ClearDisplayMessage20.h" +#include "ClearVariableMonitoring20.h" +#include "CustomerInformation20.h" +#include "DataTransfer20.h" +#include "DeleteCertificate20.h" +#include "Get15118EVCertificate20.h" +#include "GetBaseReport20.h" +#include "GetCertificateStatus20.h" +#include "GetChargingProfiles20.h" +#include "GetCompositeSchedule20.h" +#include "GetDisplayMessages20.h" +#include "GetInstalledCertificateIds20.h" +#include "GetLocalListVersion20.h" +#include "GetLog20.h" +#include "GetMonitoringReport20.h" +#include "GetReport20.h" +#include "GetTransactionStatus20.h" +#include "GetVariables20.h" +#include "ICentralSystem20.h" +#include "ICentralSystemProxy20.h" +#include "ILocalControllerConfig20.h" +#include "InstallCertificate20.h" +#include "PublishFirmware20.h" +#include "RequestStartTransaction20.h" +#include "RequestStopTransaction20.h" +#include "ReserveNow20.h" +#include "Reset20.h" +#include "RpcPool.h" +#include "SendLocalList20.h" +#include "SetChargingProfile20.h" +#include "SetDisplayMessage20.h" +#include "SetMonitoringBase20.h" +#include "SetMonitoringLevel20.h" +#include "SetNetworkProfile20.h" +#include "SetVariableMonitoring20.h" +#include "SetVariables20.h" +#include "TriggerMessage20.h" +#include "UnlockConnector20.h" +#include "UnpublishFirmware20.h" +#include "UpdateFirmware20.h" + +#include +#include + +namespace ocpp +{ +namespace localcontroller +{ +namespace ocpp20 +{ + +/** @brief Interface for the charge point proxy implementations */ +class IChargePointProxy20 +{ + public: + /** @brief Destructor */ + virtual ~IChargePointProxy20() { } + + /** + * @brief Instanciate local controller's charge point proxy from a central system's charge point proxy + * @param central_system_proxy Central system's charge point proxy + * @param stack_config Stack configuration for local controller + * @param rpc_pool RPC pool + */ + static std::shared_ptr createFrom( + std::shared_ptr& central_system_proxy, + const ocpp::config::ILocalControllerConfig20& stack_config, + ocpp::rpc::RpcPool& rpc_pool); + + /** + * @brief Get the IP address of the charge point + * @return IP address of the charge point + */ + virtual const std::string& ipAddress() const = 0; + + /** + * @brief Get the charge point identifier + * @return charge point identifier + */ + virtual const std::string& identifier() const = 0; + + /** + * @brief Set the call request timeout + * @param timeout New timeout value + */ + virtual void setTimeout(std::chrono::milliseconds timeout) = 0; + + /** @brief Disconnect the charge point */ + virtual void disconnect() = 0; + + /** + * @brief Get the associated central system proxy + * @return Associated central system proxy + */ + virtual std::shared_ptr centralSystemProxy() = 0; + + /** + * @brief Register a listener to the proxy events + * @param listener Listener to the proxy events + */ + virtual void registerListener(ILocalControllerProxyEventsHandler20& listener) = 0; + + // OCPP operations + /** + * @brief Send a CancelReservation message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::CancelReservationReq& request, + ocpp::messages::ocpp20::CancelReservationConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a CertificateSigned message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::CertificateSignedReq& request, + ocpp::messages::ocpp20::CertificateSignedConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a ChangeAvailability message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::ChangeAvailabilityReq& request, + ocpp::messages::ocpp20::ChangeAvailabilityConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a ClearCache message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::ClearCacheReq& request, + ocpp::messages::ocpp20::ClearCacheConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a ClearChargingProfile message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::ClearChargingProfileReq& request, + ocpp::messages::ocpp20::ClearChargingProfileConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a ClearDisplayMessage message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::ClearDisplayMessageReq& request, + ocpp::messages::ocpp20::ClearDisplayMessageConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a ClearVariableMonitoring message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::ClearVariableMonitoringReq& request, + ocpp::messages::ocpp20::ClearVariableMonitoringConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a CustomerInformation message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::CustomerInformationReq& request, + ocpp::messages::ocpp20::CustomerInformationConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a DataTransfer message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::DataTransferReq& request, + ocpp::messages::ocpp20::DataTransferConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a DeleteCertificate message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::DeleteCertificateReq& request, + ocpp::messages::ocpp20::DeleteCertificateConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a Get15118EVCertificate message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::Get15118EVCertificateReq& request, + ocpp::messages::ocpp20::Get15118EVCertificateConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a GetBaseReport message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::GetBaseReportReq& request, + ocpp::messages::ocpp20::GetBaseReportConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a GetCertificateStatus message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::GetCertificateStatusReq& request, + ocpp::messages::ocpp20::GetCertificateStatusConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a GetChargingProfiles message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::GetChargingProfilesReq& request, + ocpp::messages::ocpp20::GetChargingProfilesConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a GetCompositeSchedule message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::GetCompositeScheduleReq& request, + ocpp::messages::ocpp20::GetCompositeScheduleConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a GetDisplayMessages message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::GetDisplayMessagesReq& request, + ocpp::messages::ocpp20::GetDisplayMessagesConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a GetInstalledCertificateIds message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::GetInstalledCertificateIdsReq& request, + ocpp::messages::ocpp20::GetInstalledCertificateIdsConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a GetLocalListVersion message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::GetLocalListVersionReq& request, + ocpp::messages::ocpp20::GetLocalListVersionConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a GetLog message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::GetLogReq& request, + ocpp::messages::ocpp20::GetLogConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a GetMonitoringReport message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::GetMonitoringReportReq& request, + ocpp::messages::ocpp20::GetMonitoringReportConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a GetReport message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::GetReportReq& request, + ocpp::messages::ocpp20::GetReportConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a GetTransactionStatus message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::GetTransactionStatusReq& request, + ocpp::messages::ocpp20::GetTransactionStatusConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a GetVariables message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::GetVariablesReq& request, + ocpp::messages::ocpp20::GetVariablesConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a InstallCertificate message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::InstallCertificateReq& request, + ocpp::messages::ocpp20::InstallCertificateConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a PublishFirmware message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::PublishFirmwareReq& request, + ocpp::messages::ocpp20::PublishFirmwareConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a RequestStartTransaction message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::RequestStartTransactionReq& request, + ocpp::messages::ocpp20::RequestStartTransactionConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a RequestStopTransaction message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::RequestStopTransactionReq& request, + ocpp::messages::ocpp20::RequestStopTransactionConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a ReserveNow message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::ReserveNowReq& request, + ocpp::messages::ocpp20::ReserveNowConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a Reset message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::ResetReq& request, + ocpp::messages::ocpp20::ResetConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a SendLocalList message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::SendLocalListReq& request, + ocpp::messages::ocpp20::SendLocalListConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a SetChargingProfile message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::SetChargingProfileReq& request, + ocpp::messages::ocpp20::SetChargingProfileConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a SetDisplayMessage message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::SetDisplayMessageReq& request, + ocpp::messages::ocpp20::SetDisplayMessageConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a SetMonitoringBase message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::SetMonitoringBaseReq& request, + ocpp::messages::ocpp20::SetMonitoringBaseConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a SetMonitoringLevel message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::SetMonitoringLevelReq& request, + ocpp::messages::ocpp20::SetMonitoringLevelConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a SetNetworkProfile message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::SetNetworkProfileReq& request, + ocpp::messages::ocpp20::SetNetworkProfileConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a SetVariableMonitoring message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::SetVariableMonitoringReq& request, + ocpp::messages::ocpp20::SetVariableMonitoringConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a SetVariables message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::SetVariablesReq& request, + ocpp::messages::ocpp20::SetVariablesConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a TriggerMessage message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::TriggerMessageReq& request, + ocpp::messages::ocpp20::TriggerMessageConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a UnlockConnector message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::UnlockConnectorReq& request, + ocpp::messages::ocpp20::UnlockConnectorConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a UnpublishFirmware message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::UnpublishFirmwareReq& request, + ocpp::messages::ocpp20::UnpublishFirmwareConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Send a UpdateFirmware message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::ocpp20::UpdateFirmwareReq& request, + ocpp::messages::ocpp20::UpdateFirmwareConf& response, + std::string& error, + std::string& message) = 0; + /** + * @brief Register a handler for the BootNotification request from the charge point + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler( + std::function + handler) = 0; + /** + * @brief Register a handler for the Authorize request from the charge point + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler( + std::function + handler) = 0; + /** + * @brief Register a handler for the ClearedChargingLimit request from the charge point + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler(std::function handler) = 0; + /** + * @brief Register a handler for the CostUpdated request from the charge point + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler( + std::function< + bool(const ocpp::messages::ocpp20::CostUpdatedReq&, ocpp::messages::ocpp20::CostUpdatedConf&, std::string&, std::string&)> + handler) = 0; + /** + * @brief Register a handler for the DataTransfer request from the charge point + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler( + std::function< + bool(const ocpp::messages::ocpp20::DataTransferReq&, ocpp::messages::ocpp20::DataTransferConf&, std::string&, std::string&)> + handler) = 0; + /** + * @brief Register a handler for the FirmwareStatusNotification request from the charge point + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler(std::function handler) = 0; + /** + * @brief Register a handler for the Heartbeat request from the charge point + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler( + std::function + handler) = 0; + /** + * @brief Register a handler for the LogStatusNotification request from the charge point + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler(std::function handler) = 0; + /** + * @brief Register a handler for the MeterValues request from the charge point + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler( + std::function< + bool(const ocpp::messages::ocpp20::MeterValuesReq&, ocpp::messages::ocpp20::MeterValuesConf&, std::string&, std::string&)> + handler) = 0; + /** + * @brief Register a handler for the NotifyChargingLimit request from the charge point + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler(std::function handler) = 0; + /** + * @brief Register a handler for the NotifyCustomerInformation request from the charge point + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler(std::function handler) = 0; + /** + * @brief Register a handler for the NotifyDisplayMessages request from the charge point + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler(std::function handler) = 0; + /** + * @brief Register a handler for the NotifyEVChargingNeeds request from the charge point + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler(std::function handler) = 0; + /** + * @brief Register a handler for the NotifyEVChargingSchedule request from the charge point + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler(std::function handler) = 0; + /** + * @brief Register a handler for the NotifyEvent request from the charge point + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler( + std::function< + bool(const ocpp::messages::ocpp20::NotifyEventReq&, ocpp::messages::ocpp20::NotifyEventConf&, std::string&, std::string&)> + handler) = 0; + /** + * @brief Register a handler for the NotifyMonitoringReport request from the charge point + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler(std::function handler) = 0; + /** + * @brief Register a handler for the NotifyReport request from the charge point + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler( + std::function< + bool(const ocpp::messages::ocpp20::NotifyReportReq&, ocpp::messages::ocpp20::NotifyReportConf&, std::string&, std::string&)> + handler) = 0; + /** + * @brief Register a handler for the PublishFirmwareStatusNotification request from the charge point + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler(std::function handler) = 0; + /** + * @brief Register a handler for the ReportChargingProfiles request from the charge point + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler(std::function handler) = 0; + /** + * @brief Register a handler for the ReservationStatusUpdate request from the charge point + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler(std::function handler) = 0; + /** + * @brief Register a handler for the SecurityEventNotification request from the charge point + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler(std::function handler) = 0; + /** + * @brief Register a handler for the SignCertificate request from the charge point + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler( + std::function + handler) = 0; + /** + * @brief Register a handler for the StatusNotification request from the charge point + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler(std::function handler) = 0; + /** + * @brief Register a handler for the TransactionEvent request from the charge point + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler( + std::function + handler) = 0; +}; + +} // namespace ocpp20 +} // namespace localcontroller +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_ICHARGEPOINTPROXY20_H \ No newline at end of file diff --git a/src/ocpp20/localcontroller/interface/ILocalController20.h b/src/ocpp20/localcontroller/interface/ILocalController20.h new file mode 100644 index 00000000..72a386e4 --- /dev/null +++ b/src/ocpp20/localcontroller/interface/ILocalController20.h @@ -0,0 +1,115 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +#ifndef OPENOCPP_OCPP20_ILOCALCONTROLLER20_H +#define OPENOCPP_OCPP20_ILOCALCONTROLLER20_H + +#include "ILocalControllerConfig20.h" + +#include + +namespace ocpp +{ +namespace helpers +{ +class ITimerPool; +class WorkerThreadPool; +} // namespace helpers +namespace database +{ +class Database; +} // namespace database + +namespace localcontroller +{ +namespace ocpp20 +{ + +class ILocalControllerEventsHandler20; + +/** @brief Interface for local controller implementations */ +class ILocalController20 +{ + public: + /** + * @brief Instanciate a local controller + * @param stack_config Stack configuration + * @param event_handler Stack event handler + */ + static std::unique_ptr create(const ocpp::config::ILocalControllerConfig20& stack_config, + ILocalControllerEventsHandler20& events_handler); + + /** + * @brief Instanciate a local controller with the provided timer and worker pools + * To use when you have to instanciate multiple Central System / Charge Point + * => Allow to reduce thread and memory usage + * @param stack_config Stack configuration + * @param event_handler Stack event handler + * @param timer_pool Timer pool + * @param worker_pool Worker thread pool + */ + static std::unique_ptr create(const ocpp::config::ILocalControllerConfig20& stack_config, + ILocalControllerEventsHandler20& events_handler, + std::shared_ptr timer_pool, + std::shared_ptr worker_pool); + + /** @brief Destructor */ + virtual ~ILocalController20() { } + + /** + * @brief Get the configuration associated to the local controller + * @return Configuration associated to the local controller + */ + virtual const ocpp::config::ILocalControllerConfig20& getConfig() = 0; + + /** + * @brief Get the timer pool associated to the local controller + * @return Timer pool associated to the local controller + */ + virtual ocpp::helpers::ITimerPool& getTimerPool() = 0; + + /** + * @brief Get the worker pool associated to the local controller + * @return Worker pool associated to the local controller + */ + virtual ocpp::helpers::WorkerThreadPool& getWorkerPool() = 0; + + /** + * @brief Reset the local controller's internal data (can be done only when the local controller is stopped) + * @return true if the data has been reset, false otherwise + */ + virtual bool resetData() = 0; + + /** + * @brief Start the local controller + * @return true if the local controller has been started, false otherwise + */ + virtual bool start() = 0; + + /** + * @brief Stop the local controller + * @return true if the local controller has been stopped, false otherwise + */ + virtual bool stop() = 0; +}; + +} // namespace ocpp20 +} // namespace localcontroller +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_ILOCALCONTROLLER20_H diff --git a/src/ocpp20/localcontroller/interface/ILocalControllerConfig20.h b/src/ocpp20/localcontroller/interface/ILocalControllerConfig20.h new file mode 100644 index 00000000..e56b6243 --- /dev/null +++ b/src/ocpp20/localcontroller/interface/ILocalControllerConfig20.h @@ -0,0 +1,47 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +#ifndef OPENOCPP_OCPP20_ILOCALCONTROLLERCONFIG_H +#define OPENOCPP_OCPP20_ILOCALCONTROLLERCONFIG_H + +#include "ICentralSystemConfig20.h" + +namespace ocpp +{ +namespace config +{ + +/** @brief Interface to retrieve stack internal configuration for the Local Controller role */ +class ILocalControllerConfig20 : public ICentralSystemConfig20 +{ + public: + /** @brief Destructor */ + virtual ~ILocalControllerConfig20() { } + + // Behavior + + /** @brief Size of the thread pool to handle incoming requests from the Central System */ + virtual unsigned int incomingRequestsFromCsThreadPoolSize() const = 0; + /** @brief Disconnect from Charge Point on Central System disconnection */ + virtual bool disconnectFromCpWhenCsDisconnected() const = 0; +}; + +} // namespace config +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_ILOCALCONTROLLERCONFIG_H diff --git a/src/ocpp20/localcontroller/interface/ILocalControllerEventsHandler20.h b/src/ocpp20/localcontroller/interface/ILocalControllerEventsHandler20.h new file mode 100644 index 00000000..c1a11515 --- /dev/null +++ b/src/ocpp20/localcontroller/interface/ILocalControllerEventsHandler20.h @@ -0,0 +1,70 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +#ifndef OPENOCPP_OCPP20_ILOCALCONTROLLEREVENTSHANDLER20_H +#define OPENOCPP_OCPP20_ILOCALCONTROLLEREVENTSHANDLER20_H + +#include "IChargePointProxy20.h" + +namespace ocpp +{ +namespace localcontroller +{ +namespace ocpp20 +{ + +/** @brief Interface for local controller event handlers implementations */ +class ILocalControllerEventsHandler20 +{ + public: + /** @brief Destructor */ + virtual ~ILocalControllerEventsHandler20() { } + + /** + * @brief Called to accept an incoming connection + * @param ip_address IP address of the client + * @return true if the incoming connection must be accepted, false otherwise + */ + virtual bool acceptConnection(const char* ip_address) = 0; + + /** + * @brief Called when connection fails to established + * @param ip_address IP address of the client + */ + virtual void clientFailedToConnect(const char* ip_address) = 0; + + /** + * @brief Called to check the charge point credentials for HTTP basic authentication + * @param chargepoint_id Charge Point identifier + * @param password Password + * @return true if the credentials are valid, false otherwise + */ + virtual bool checkCredentials(const std::string& chargepoint_id, const std::string& password) = 0; + + /** + * @brief Called when a charge point is connected + * @param chargepoint Charge point connection + */ + virtual void chargePointConnected(std::shared_ptr chargepoint) = 0; +}; + +} // namespace ocpp20 +} // namespace localcontroller +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_ILOCALCONTROLLEREVENTSHANDLER20_H diff --git a/src/ocpp20/localcontroller/interface/ILocalControllerProxyEventsHandler20.h b/src/ocpp20/localcontroller/interface/ILocalControllerProxyEventsHandler20.h new file mode 100644 index 00000000..9ca19f93 --- /dev/null +++ b/src/ocpp20/localcontroller/interface/ILocalControllerProxyEventsHandler20.h @@ -0,0 +1,53 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +#ifndef OPENOCPP_OCPP20_ILOCALCONTROLLERPROXYEVENTSHANDLER20_H +#define OPENOCPP_OCPP20_ILOCALCONTROLLERPROXYEVENTSHANDLER20_H + +namespace ocpp +{ +namespace localcontroller +{ +namespace ocpp20 +{ + +/** @brief Interface for Local Controller proxys event handler implementations */ +class ILocalControllerProxyEventsHandler20 +{ + public: + /** @brief Destructor */ + virtual ~ILocalControllerProxyEventsHandler20() { } + + /** @brief Called to notify the disconnection of the charge point */ + virtual void disconnectedFromChargePoint() = 0; + + /** @brief Called to notify the connection to the central system */ + virtual void connectedToCentralSystem() = 0; + + /** @brief Called to notify the failure of the connection to the central system */ + virtual void failedToConnectToCentralSystem() = 0; + + /** @brief Called to notify the disconnection from the central system */ + virtual void disconnectedFromCentralSystem() = 0; +}; + +} // namespace ocpp20 +} // namespace localcontroller +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_ILOCALCONTROLLERPROXYEVENTSHANDLER20_H diff --git a/src/ocpp20/messages/Authorize20.cpp b/src/ocpp20/messages/Authorize20.cpp new file mode 100644 index 00000000..0037454a --- /dev/null +++ b/src/ocpp20/messages/Authorize20.cpp @@ -0,0 +1,185 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:AuthorizeRequest + OCPP 2.0.1 FINAL +*/ + +#include "Authorize20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a AuthorizeReq from a JSON representation */ +bool AuthorizeReqConverter::fromJson(const rapidjson::Value& json, AuthorizeReq& data, std::string& error_code, std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // idToken + ocpp::types::ocpp20::IdTokenTypeConverter idToken_converter; + ret = ret && idToken_converter.fromJson(json["idToken"], data.idToken, error_code, error_message); + + // certificate + extract(json, "certificate", data.certificate); + + // iso15118CertificateHashData + if (json.HasMember("iso15118CertificateHashData")) + { + const rapidjson::Value& iso15118CertificateHashData_json = json["iso15118CertificateHashData"]; + ocpp::types::ocpp20::OCSPRequestDataTypeConverter iso15118CertificateHashData_converter; + for (auto it = iso15118CertificateHashData_json.Begin(); ret && (it != iso15118CertificateHashData_json.End()); ++it) + { + ocpp::types::ocpp20::OCSPRequestDataType& item = data.iso15118CertificateHashData.emplace_back(); + ret = ret && iso15118CertificateHashData_converter.fromJson(*it, item, error_code, error_message); + } + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a AuthorizeReq to a JSON representation */ +bool AuthorizeReqConverter::toJson(const AuthorizeReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // idToken + ocpp::types::ocpp20::IdTokenTypeConverter idToken_converter; + idToken_converter.setAllocator(allocator); + rapidjson::Document idToken_doc(rapidjson::kObjectType); + ret = ret && idToken_converter.toJson(data.idToken, idToken_doc); + json.AddMember(rapidjson::StringRef("idToken"), idToken_doc.Move(), *allocator); + + // certificate + fill(json, "certificate", data.certificate); + + // iso15118CertificateHashData + if (!data.iso15118CertificateHashData.empty()) + { + + rapidjson::Value iso15118CertificateHashData_json(rapidjson::kArrayType); + ocpp::types::ocpp20::OCSPRequestDataTypeConverter iso15118CertificateHashData_converter; + iso15118CertificateHashData_converter.setAllocator(allocator); + for (const ocpp::types::ocpp20::OCSPRequestDataType& item : data.iso15118CertificateHashData) + { + rapidjson::Document item_doc(rapidjson::kObjectType); + ret = ret && iso15118CertificateHashData_converter.toJson(item, item_doc); + iso15118CertificateHashData_json.PushBack(item_doc.Move(), *allocator); + } + json.AddMember(rapidjson::StringRef("iso15118CertificateHashData"), iso15118CertificateHashData_json.Move(), *allocator); + } + + return ret; +} + +/** @brief Convert a AuthorizeConf from a JSON representation */ +bool AuthorizeConfConverter::fromJson(const rapidjson::Value& json, + AuthorizeConf& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // idTokenInfo + ocpp::types::ocpp20::IdTokenInfoTypeConverter idTokenInfo_converter; + ret = ret && idTokenInfo_converter.fromJson(json["idTokenInfo"], data.idTokenInfo, error_code, error_message); + + // certificateStatus + if (json.HasMember("certificateStatus")) + { + data.certificateStatus = + ocpp::types::ocpp20::AuthorizeCertificateStatusEnumTypeHelper.fromString(json["certificateStatus"].GetString()); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a AuthorizeConf to a JSON representation */ +bool AuthorizeConfConverter::toJson(const AuthorizeConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // idTokenInfo + ocpp::types::ocpp20::IdTokenInfoTypeConverter idTokenInfo_converter; + idTokenInfo_converter.setAllocator(allocator); + rapidjson::Document idTokenInfo_doc(rapidjson::kObjectType); + ret = ret && idTokenInfo_converter.toJson(data.idTokenInfo, idTokenInfo_doc); + json.AddMember(rapidjson::StringRef("idTokenInfo"), idTokenInfo_doc.Move(), *allocator); + + // certificateStatus + if (data.certificateStatus.isSet()) + { + fill(json, "certificateStatus", ocpp::types::ocpp20::AuthorizeCertificateStatusEnumTypeHelper.toString(data.certificateStatus)); + } + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/Authorize20.h b/src/ocpp20/messages/Authorize20.h new file mode 100644 index 00000000..eeae02fb --- /dev/null +++ b/src/ocpp20/messages/Authorize20.h @@ -0,0 +1,76 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:AuthorizeRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_AUTHORIZE_H +#define OPENOCPP_OCPP20_AUTHORIZE_H + +#include "IMessageConverter.h" + +#include "AuthorizeCertificateStatusEnumType20.h" +#include "CustomDataType20.h" +#include "IdTokenInfoType20.h" +#include "IdTokenType20.h" +#include "OCSPRequestDataType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the Authorize messages */ +static const std::string AUTHORIZE_ACTION = "Authorize"; + +/** @brief AuthorizeReq message */ +struct AuthorizeReq +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::ocpp20::IdTokenType idToken; + /** @brief The X.509 certificated presented by EV and encoded in PEM format. */ + ocpp::types::Optional> certificate; + /** @brief */ + std::vector iso15118CertificateHashData; +}; + +/** @brief AuthorizeConf message */ +struct AuthorizeConf +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::ocpp20::IdTokenInfoType idTokenInfo; + /** @brief */ + ocpp::types::Optional certificateStatus; +}; + +// Message converters +MESSAGE_CONVERTERS(Authorize) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_AUTHORIZE_H \ No newline at end of file diff --git a/src/ocpp20/messages/BootNotification20.cpp b/src/ocpp20/messages/BootNotification20.cpp new file mode 100644 index 00000000..63b720cd --- /dev/null +++ b/src/ocpp20/messages/BootNotification20.cpp @@ -0,0 +1,171 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:BootNotificationRequest + OCPP 2.0.1 FINAL +*/ + +#include "BootNotification20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a BootNotificationReq from a JSON representation */ +bool BootNotificationReqConverter::fromJson(const rapidjson::Value& json, + BootNotificationReq& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // chargingStation + ocpp::types::ocpp20::ChargingStationTypeConverter chargingStation_converter; + ret = ret && chargingStation_converter.fromJson(json["chargingStation"], data.chargingStation, error_code, error_message); + + // reason + data.reason = ocpp::types::ocpp20::BootReasonEnumTypeHelper.fromString(json["reason"].GetString()); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a BootNotificationReq to a JSON representation */ +bool BootNotificationReqConverter::toJson(const BootNotificationReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // chargingStation + ocpp::types::ocpp20::ChargingStationTypeConverter chargingStation_converter; + chargingStation_converter.setAllocator(allocator); + rapidjson::Document chargingStation_doc(rapidjson::kObjectType); + ret = ret && chargingStation_converter.toJson(data.chargingStation, chargingStation_doc); + json.AddMember(rapidjson::StringRef("chargingStation"), chargingStation_doc.Move(), *allocator); + + // reason + fill(json, "reason", ocpp::types::ocpp20::BootReasonEnumTypeHelper.toString(data.reason)); + + return ret; +} + +/** @brief Convert a BootNotificationConf from a JSON representation */ +bool BootNotificationConfConverter::fromJson(const rapidjson::Value& json, + BootNotificationConf& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // currentTime + ret = ret && extract(json, "currentTime", data.currentTime, error_message); + + // interval + extract(json, "interval", data.interval); + + // status + data.status = ocpp::types::ocpp20::RegistrationStatusEnumTypeHelper.fromString(json["status"].GetString()); + + // statusInfo + if (json.HasMember("statusInfo")) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + ret = ret && statusInfo_converter.fromJson(json["statusInfo"], data.statusInfo, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a BootNotificationConf to a JSON representation */ +bool BootNotificationConfConverter::toJson(const BootNotificationConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // currentTime + fill(json, "currentTime", data.currentTime); + + // interval + fill(json, "interval", data.interval); + + // status + fill(json, "status", ocpp::types::ocpp20::RegistrationStatusEnumTypeHelper.toString(data.status)); + + // statusInfo + if (data.statusInfo.isSet()) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + statusInfo_converter.setAllocator(allocator); + rapidjson::Document statusInfo_doc(rapidjson::kObjectType); + ret = ret && statusInfo_converter.toJson(data.statusInfo, statusInfo_doc); + json.AddMember(rapidjson::StringRef("statusInfo"), statusInfo_doc.Move(), *allocator); + } + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/BootNotification20.h b/src/ocpp20/messages/BootNotification20.h new file mode 100644 index 00000000..3b3cdbf7 --- /dev/null +++ b/src/ocpp20/messages/BootNotification20.h @@ -0,0 +1,78 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:BootNotificationRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_BOOTNOTIFICATION_H +#define OPENOCPP_OCPP20_BOOTNOTIFICATION_H + +#include "IMessageConverter.h" + +#include "BootReasonEnumType20.h" +#include "ChargingStationType20.h" +#include "CustomDataType20.h" +#include "RegistrationStatusEnumType20.h" +#include "StatusInfoType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the BootNotification messages */ +static const std::string BOOTNOTIFICATION_ACTION = "BootNotification"; + +/** @brief BootNotificationReq message */ +struct BootNotificationReq +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::ocpp20::ChargingStationType chargingStation; + /** @brief */ + ocpp::types::ocpp20::BootReasonEnumType reason; +}; + +/** @brief BootNotificationConf message */ +struct BootNotificationConf +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief This contains the CSMS’s current time. */ + ocpp::types::DateTime currentTime; + /** @brief When <<cmn_registrationstatusenumtype,Status>> is Accepted, this contains the heartbeat interval in seconds. If the CSMS returns something other than Accepted, the value of the interval field indicates the minimum wait time before sending a next BootNotification request. */ + int interval; + /** @brief */ + ocpp::types::ocpp20::RegistrationStatusEnumType status; + /** @brief */ + ocpp::types::Optional statusInfo; +}; + +// Message converters +MESSAGE_CONVERTERS(BootNotification) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_BOOTNOTIFICATION_H \ No newline at end of file diff --git a/src/ocpp20/messages/CMakeLists.txt b/src/ocpp20/messages/CMakeLists.txt new file mode 100644 index 00000000..2e6a6db8 --- /dev/null +++ b/src/ocpp20/messages/CMakeLists.txt @@ -0,0 +1,15 @@ +###################################################### +# OCPP 2.0 messages library # +###################################################### + +# Library target +file (GLOB OCPP20_MESSAGES_SOURCE_FILES "*.cpp") +add_library(messages20 OBJECT + ${OCPP20_MESSAGES_SOURCE_FILES} +) + +# Exported includes +target_include_directories(messages20 PUBLIC .) + +# Dependencies +target_link_libraries(messages20 PUBLIC types20 messages) diff --git a/src/ocpp20/messages/CancelReservation20.cpp b/src/ocpp20/messages/CancelReservation20.cpp new file mode 100644 index 00000000..edbd7462 --- /dev/null +++ b/src/ocpp20/messages/CancelReservation20.cpp @@ -0,0 +1,148 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:CancelReservationRequest + OCPP 2.0.1 FINAL +*/ + +#include "CancelReservation20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a CancelReservationReq from a JSON representation */ +bool CancelReservationReqConverter::fromJson(const rapidjson::Value& json, + CancelReservationReq& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // reservationId + extract(json, "reservationId", data.reservationId); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a CancelReservationReq to a JSON representation */ +bool CancelReservationReqConverter::toJson(const CancelReservationReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // reservationId + fill(json, "reservationId", data.reservationId); + + return ret; +} + +/** @brief Convert a CancelReservationConf from a JSON representation */ +bool CancelReservationConfConverter::fromJson(const rapidjson::Value& json, + CancelReservationConf& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // status + data.status = ocpp::types::ocpp20::CancelReservationStatusEnumTypeHelper.fromString(json["status"].GetString()); + + // statusInfo + if (json.HasMember("statusInfo")) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + ret = ret && statusInfo_converter.fromJson(json["statusInfo"], data.statusInfo, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a CancelReservationConf to a JSON representation */ +bool CancelReservationConfConverter::toJson(const CancelReservationConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // status + fill(json, "status", ocpp::types::ocpp20::CancelReservationStatusEnumTypeHelper.toString(data.status)); + + // statusInfo + if (data.statusInfo.isSet()) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + statusInfo_converter.setAllocator(allocator); + rapidjson::Document statusInfo_doc(rapidjson::kObjectType); + ret = ret && statusInfo_converter.toJson(data.statusInfo, statusInfo_doc); + json.AddMember(rapidjson::StringRef("statusInfo"), statusInfo_doc.Move(), *allocator); + } + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/CancelReservation20.h b/src/ocpp20/messages/CancelReservation20.h new file mode 100644 index 00000000..ced2b621 --- /dev/null +++ b/src/ocpp20/messages/CancelReservation20.h @@ -0,0 +1,70 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:CancelReservationRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_CANCELRESERVATION_H +#define OPENOCPP_OCPP20_CANCELRESERVATION_H + +#include "IMessageConverter.h" + +#include "CancelReservationStatusEnumType20.h" +#include "CustomDataType20.h" +#include "StatusInfoType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the CancelReservation messages */ +static const std::string CANCELRESERVATION_ACTION = "CancelReservation"; + +/** @brief CancelReservationReq message */ +struct CancelReservationReq +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief Id of the reservation to cancel. */ + int reservationId; +}; + +/** @brief CancelReservationConf message */ +struct CancelReservationConf +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::ocpp20::CancelReservationStatusEnumType status; + /** @brief */ + ocpp::types::Optional statusInfo; +}; + +// Message converters +MESSAGE_CONVERTERS(CancelReservation) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_CANCELRESERVATION_H \ No newline at end of file diff --git a/src/ocpp20/messages/CertificateSigned20.cpp b/src/ocpp20/messages/CertificateSigned20.cpp new file mode 100644 index 00000000..f5b5540f --- /dev/null +++ b/src/ocpp20/messages/CertificateSigned20.cpp @@ -0,0 +1,160 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:CertificateSignedRequest + OCPP 2.0.1 FINAL +*/ + +#include "CertificateSigned20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a CertificateSignedReq from a JSON representation */ +bool CertificateSignedReqConverter::fromJson(const rapidjson::Value& json, + CertificateSignedReq& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // certificateChain + extract(json, "certificateChain", data.certificateChain); + + // certificateType + if (json.HasMember("certificateType")) + { + data.certificateType = ocpp::types::ocpp20::CertificateSigningUseEnumTypeHelper.fromString(json["certificateType"].GetString()); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a CertificateSignedReq to a JSON representation */ +bool CertificateSignedReqConverter::toJson(const CertificateSignedReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // certificateChain + fill(json, "certificateChain", data.certificateChain); + + // certificateType + if (data.certificateType.isSet()) + { + fill(json, "certificateType", ocpp::types::ocpp20::CertificateSigningUseEnumTypeHelper.toString(data.certificateType)); + } + + return ret; +} + +/** @brief Convert a CertificateSignedConf from a JSON representation */ +bool CertificateSignedConfConverter::fromJson(const rapidjson::Value& json, + CertificateSignedConf& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // status + data.status = ocpp::types::ocpp20::CertificateSignedStatusEnumTypeHelper.fromString(json["status"].GetString()); + + // statusInfo + if (json.HasMember("statusInfo")) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + ret = ret && statusInfo_converter.fromJson(json["statusInfo"], data.statusInfo, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a CertificateSignedConf to a JSON representation */ +bool CertificateSignedConfConverter::toJson(const CertificateSignedConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // status + fill(json, "status", ocpp::types::ocpp20::CertificateSignedStatusEnumTypeHelper.toString(data.status)); + + // statusInfo + if (data.statusInfo.isSet()) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + statusInfo_converter.setAllocator(allocator); + rapidjson::Document statusInfo_doc(rapidjson::kObjectType); + ret = ret && statusInfo_converter.toJson(data.statusInfo, statusInfo_doc); + json.AddMember(rapidjson::StringRef("statusInfo"), statusInfo_doc.Move(), *allocator); + } + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/CertificateSigned20.h b/src/ocpp20/messages/CertificateSigned20.h new file mode 100644 index 00000000..0f5cb7c8 --- /dev/null +++ b/src/ocpp20/messages/CertificateSigned20.h @@ -0,0 +1,75 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:CertificateSignedRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_CERTIFICATESIGNED_H +#define OPENOCPP_OCPP20_CERTIFICATESIGNED_H + +#include "IMessageConverter.h" + +#include "CertificateSignedStatusEnumType20.h" +#include "CertificateSigningUseEnumType20.h" +#include "CustomDataType20.h" +#include "StatusInfoType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the CertificateSigned messages */ +static const std::string CERTIFICATESIGNED_ACTION = "CertificateSigned"; + +/** @brief CertificateSignedReq message */ +struct CertificateSignedReq +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief The signed PEM encoded X.509 certificate. This can also contain the necessary sub CA certificates. In that case, the order of the bundle should follow the certificate chain, starting from the leaf certificate. + +The Configuration Variable <<configkey-max-certificate-chain-size,MaxCertificateChainSize>> can be used to limit the maximum size of this field. */ + ocpp::types::CiStringType<10000u> certificateChain; + /** @brief */ + ocpp::types::Optional certificateType; +}; + +/** @brief CertificateSignedConf message */ +struct CertificateSignedConf +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::ocpp20::CertificateSignedStatusEnumType status; + /** @brief */ + ocpp::types::Optional statusInfo; +}; + +// Message converters +MESSAGE_CONVERTERS(CertificateSigned) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_CERTIFICATESIGNED_H \ No newline at end of file diff --git a/src/ocpp20/messages/ChangeAvailability20.cpp b/src/ocpp20/messages/ChangeAvailability20.cpp new file mode 100644 index 00000000..a14a1957 --- /dev/null +++ b/src/ocpp20/messages/ChangeAvailability20.cpp @@ -0,0 +1,165 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:ChangeAvailabilityRequest + OCPP 2.0.1 FINAL +*/ + +#include "ChangeAvailability20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a ChangeAvailabilityReq from a JSON representation */ +bool ChangeAvailabilityReqConverter::fromJson(const rapidjson::Value& json, + ChangeAvailabilityReq& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // evse + if (json.HasMember("evse")) + { + ocpp::types::ocpp20::EVSETypeConverter evse_converter; + ret = ret && evse_converter.fromJson(json["evse"], data.evse, error_code, error_message); + } + + // operationalStatus + data.operationalStatus = ocpp::types::ocpp20::OperationalStatusEnumTypeHelper.fromString(json["operationalStatus"].GetString()); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a ChangeAvailabilityReq to a JSON representation */ +bool ChangeAvailabilityReqConverter::toJson(const ChangeAvailabilityReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // evse + if (data.evse.isSet()) + { + ocpp::types::ocpp20::EVSETypeConverter evse_converter; + evse_converter.setAllocator(allocator); + rapidjson::Document evse_doc(rapidjson::kObjectType); + ret = ret && evse_converter.toJson(data.evse, evse_doc); + json.AddMember(rapidjson::StringRef("evse"), evse_doc.Move(), *allocator); + } + + // operationalStatus + fill(json, "operationalStatus", ocpp::types::ocpp20::OperationalStatusEnumTypeHelper.toString(data.operationalStatus)); + + return ret; +} + +/** @brief Convert a ChangeAvailabilityConf from a JSON representation */ +bool ChangeAvailabilityConfConverter::fromJson(const rapidjson::Value& json, + ChangeAvailabilityConf& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // status + data.status = ocpp::types::ocpp20::ChangeAvailabilityStatusEnumTypeHelper.fromString(json["status"].GetString()); + + // statusInfo + if (json.HasMember("statusInfo")) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + ret = ret && statusInfo_converter.fromJson(json["statusInfo"], data.statusInfo, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a ChangeAvailabilityConf to a JSON representation */ +bool ChangeAvailabilityConfConverter::toJson(const ChangeAvailabilityConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // status + fill(json, "status", ocpp::types::ocpp20::ChangeAvailabilityStatusEnumTypeHelper.toString(data.status)); + + // statusInfo + if (data.statusInfo.isSet()) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + statusInfo_converter.setAllocator(allocator); + rapidjson::Document statusInfo_doc(rapidjson::kObjectType); + ret = ret && statusInfo_converter.toJson(data.statusInfo, statusInfo_doc); + json.AddMember(rapidjson::StringRef("statusInfo"), statusInfo_doc.Move(), *allocator); + } + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/ChangeAvailability20.h b/src/ocpp20/messages/ChangeAvailability20.h new file mode 100644 index 00000000..992cdb81 --- /dev/null +++ b/src/ocpp20/messages/ChangeAvailability20.h @@ -0,0 +1,74 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:ChangeAvailabilityRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_CHANGEAVAILABILITY_H +#define OPENOCPP_OCPP20_CHANGEAVAILABILITY_H + +#include "IMessageConverter.h" + +#include "ChangeAvailabilityStatusEnumType20.h" +#include "CustomDataType20.h" +#include "EVSEType20.h" +#include "OperationalStatusEnumType20.h" +#include "StatusInfoType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the ChangeAvailability messages */ +static const std::string CHANGEAVAILABILITY_ACTION = "ChangeAvailability"; + +/** @brief ChangeAvailabilityReq message */ +struct ChangeAvailabilityReq +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::Optional evse; + /** @brief */ + ocpp::types::ocpp20::OperationalStatusEnumType operationalStatus; +}; + +/** @brief ChangeAvailabilityConf message */ +struct ChangeAvailabilityConf +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::ocpp20::ChangeAvailabilityStatusEnumType status; + /** @brief */ + ocpp::types::Optional statusInfo; +}; + +// Message converters +MESSAGE_CONVERTERS(ChangeAvailability) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_CHANGEAVAILABILITY_H \ No newline at end of file diff --git a/src/ocpp20/messages/ClearCache20.cpp b/src/ocpp20/messages/ClearCache20.cpp new file mode 100644 index 00000000..9b3485dc --- /dev/null +++ b/src/ocpp20/messages/ClearCache20.cpp @@ -0,0 +1,142 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:ClearCacheRequest + OCPP 2.0.1 FINAL +*/ + +#include "ClearCache20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a ClearCacheReq from a JSON representation */ +bool ClearCacheReqConverter::fromJson(const rapidjson::Value& json, + ClearCacheReq& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a ClearCacheReq to a JSON representation */ +bool ClearCacheReqConverter::toJson(const ClearCacheReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + return ret; +} + +/** @brief Convert a ClearCacheConf from a JSON representation */ +bool ClearCacheConfConverter::fromJson(const rapidjson::Value& json, + ClearCacheConf& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // status + data.status = ocpp::types::ocpp20::ClearCacheStatusEnumTypeHelper.fromString(json["status"].GetString()); + + // statusInfo + if (json.HasMember("statusInfo")) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + ret = ret && statusInfo_converter.fromJson(json["statusInfo"], data.statusInfo, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a ClearCacheConf to a JSON representation */ +bool ClearCacheConfConverter::toJson(const ClearCacheConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // status + fill(json, "status", ocpp::types::ocpp20::ClearCacheStatusEnumTypeHelper.toString(data.status)); + + // statusInfo + if (data.statusInfo.isSet()) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + statusInfo_converter.setAllocator(allocator); + rapidjson::Document statusInfo_doc(rapidjson::kObjectType); + ret = ret && statusInfo_converter.toJson(data.statusInfo, statusInfo_doc); + json.AddMember(rapidjson::StringRef("statusInfo"), statusInfo_doc.Move(), *allocator); + } + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/ClearCache20.h b/src/ocpp20/messages/ClearCache20.h new file mode 100644 index 00000000..35d25638 --- /dev/null +++ b/src/ocpp20/messages/ClearCache20.h @@ -0,0 +1,68 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:ClearCacheRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_CLEARCACHE_H +#define OPENOCPP_OCPP20_CLEARCACHE_H + +#include "IMessageConverter.h" + +#include "ClearCacheStatusEnumType20.h" +#include "CustomDataType20.h" +#include "StatusInfoType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the ClearCache messages */ +static const std::string CLEARCACHE_ACTION = "ClearCache"; + +/** @brief ClearCacheReq message */ +struct ClearCacheReq +{ + /** @brief */ + ocpp::types::Optional customData; +}; + +/** @brief ClearCacheConf message */ +struct ClearCacheConf +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::ocpp20::ClearCacheStatusEnumType status; + /** @brief */ + ocpp::types::Optional statusInfo; +}; + +// Message converters +MESSAGE_CONVERTERS(ClearCache) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_CLEARCACHE_H \ No newline at end of file diff --git a/src/ocpp20/messages/ClearChargingProfile20.cpp b/src/ocpp20/messages/ClearChargingProfile20.cpp new file mode 100644 index 00000000..1af44b55 --- /dev/null +++ b/src/ocpp20/messages/ClearChargingProfile20.cpp @@ -0,0 +1,166 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:ClearChargingProfileRequest + OCPP 2.0.1 FINAL +*/ + +#include "ClearChargingProfile20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a ClearChargingProfileReq from a JSON representation */ +bool ClearChargingProfileReqConverter::fromJson(const rapidjson::Value& json, + ClearChargingProfileReq& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // chargingProfileId + extract(json, "chargingProfileId", data.chargingProfileId); + + // chargingProfileCriteria + if (json.HasMember("chargingProfileCriteria")) + { + ocpp::types::ocpp20::ClearChargingProfileTypeConverter chargingProfileCriteria_converter; + ret = ret && chargingProfileCriteria_converter.fromJson( + json["chargingProfileCriteria"], data.chargingProfileCriteria, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a ClearChargingProfileReq to a JSON representation */ +bool ClearChargingProfileReqConverter::toJson(const ClearChargingProfileReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // chargingProfileId + fill(json, "chargingProfileId", data.chargingProfileId); + + // chargingProfileCriteria + if (data.chargingProfileCriteria.isSet()) + { + ocpp::types::ocpp20::ClearChargingProfileTypeConverter chargingProfileCriteria_converter; + chargingProfileCriteria_converter.setAllocator(allocator); + rapidjson::Document chargingProfileCriteria_doc(rapidjson::kObjectType); + ret = ret && chargingProfileCriteria_converter.toJson(data.chargingProfileCriteria, chargingProfileCriteria_doc); + json.AddMember(rapidjson::StringRef("chargingProfileCriteria"), chargingProfileCriteria_doc.Move(), *allocator); + } + + return ret; +} + +/** @brief Convert a ClearChargingProfileConf from a JSON representation */ +bool ClearChargingProfileConfConverter::fromJson(const rapidjson::Value& json, + ClearChargingProfileConf& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // status + data.status = ocpp::types::ocpp20::ClearChargingProfileStatusEnumTypeHelper.fromString(json["status"].GetString()); + + // statusInfo + if (json.HasMember("statusInfo")) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + ret = ret && statusInfo_converter.fromJson(json["statusInfo"], data.statusInfo, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a ClearChargingProfileConf to a JSON representation */ +bool ClearChargingProfileConfConverter::toJson(const ClearChargingProfileConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // status + fill(json, "status", ocpp::types::ocpp20::ClearChargingProfileStatusEnumTypeHelper.toString(data.status)); + + // statusInfo + if (data.statusInfo.isSet()) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + statusInfo_converter.setAllocator(allocator); + rapidjson::Document statusInfo_doc(rapidjson::kObjectType); + ret = ret && statusInfo_converter.toJson(data.statusInfo, statusInfo_doc); + json.AddMember(rapidjson::StringRef("statusInfo"), statusInfo_doc.Move(), *allocator); + } + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/ClearChargingProfile20.h b/src/ocpp20/messages/ClearChargingProfile20.h new file mode 100644 index 00000000..53b1bb49 --- /dev/null +++ b/src/ocpp20/messages/ClearChargingProfile20.h @@ -0,0 +1,73 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:ClearChargingProfileRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_CLEARCHARGINGPROFILE_H +#define OPENOCPP_OCPP20_CLEARCHARGINGPROFILE_H + +#include "IMessageConverter.h" + +#include "ClearChargingProfileStatusEnumType20.h" +#include "ClearChargingProfileType20.h" +#include "CustomDataType20.h" +#include "StatusInfoType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the ClearChargingProfile messages */ +static const std::string CLEARCHARGINGPROFILE_ACTION = "ClearChargingProfile"; + +/** @brief ClearChargingProfileReq message */ +struct ClearChargingProfileReq +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief The Id of the charging profile to clear. */ + ocpp::types::Optional chargingProfileId; + /** @brief */ + ocpp::types::Optional chargingProfileCriteria; +}; + +/** @brief ClearChargingProfileConf message */ +struct ClearChargingProfileConf +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::ocpp20::ClearChargingProfileStatusEnumType status; + /** @brief */ + ocpp::types::Optional statusInfo; +}; + +// Message converters +MESSAGE_CONVERTERS(ClearChargingProfile) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_CLEARCHARGINGPROFILE_H \ No newline at end of file diff --git a/src/ocpp20/messages/ClearDisplayMessage20.cpp b/src/ocpp20/messages/ClearDisplayMessage20.cpp new file mode 100644 index 00000000..c7358617 --- /dev/null +++ b/src/ocpp20/messages/ClearDisplayMessage20.cpp @@ -0,0 +1,148 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:ClearDisplayMessageRequest + OCPP 2.0.1 FINAL +*/ + +#include "ClearDisplayMessage20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a ClearDisplayMessageReq from a JSON representation */ +bool ClearDisplayMessageReqConverter::fromJson(const rapidjson::Value& json, + ClearDisplayMessageReq& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // id + extract(json, "id", data.id); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a ClearDisplayMessageReq to a JSON representation */ +bool ClearDisplayMessageReqConverter::toJson(const ClearDisplayMessageReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // id + fill(json, "id", data.id); + + return ret; +} + +/** @brief Convert a ClearDisplayMessageConf from a JSON representation */ +bool ClearDisplayMessageConfConverter::fromJson(const rapidjson::Value& json, + ClearDisplayMessageConf& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // status + data.status = ocpp::types::ocpp20::ClearMessageStatusEnumTypeHelper.fromString(json["status"].GetString()); + + // statusInfo + if (json.HasMember("statusInfo")) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + ret = ret && statusInfo_converter.fromJson(json["statusInfo"], data.statusInfo, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a ClearDisplayMessageConf to a JSON representation */ +bool ClearDisplayMessageConfConverter::toJson(const ClearDisplayMessageConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // status + fill(json, "status", ocpp::types::ocpp20::ClearMessageStatusEnumTypeHelper.toString(data.status)); + + // statusInfo + if (data.statusInfo.isSet()) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + statusInfo_converter.setAllocator(allocator); + rapidjson::Document statusInfo_doc(rapidjson::kObjectType); + ret = ret && statusInfo_converter.toJson(data.statusInfo, statusInfo_doc); + json.AddMember(rapidjson::StringRef("statusInfo"), statusInfo_doc.Move(), *allocator); + } + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/ClearDisplayMessage20.h b/src/ocpp20/messages/ClearDisplayMessage20.h new file mode 100644 index 00000000..b9b89903 --- /dev/null +++ b/src/ocpp20/messages/ClearDisplayMessage20.h @@ -0,0 +1,70 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:ClearDisplayMessageRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_CLEARDISPLAYMESSAGE_H +#define OPENOCPP_OCPP20_CLEARDISPLAYMESSAGE_H + +#include "IMessageConverter.h" + +#include "ClearMessageStatusEnumType20.h" +#include "CustomDataType20.h" +#include "StatusInfoType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the ClearDisplayMessage messages */ +static const std::string CLEARDISPLAYMESSAGE_ACTION = "ClearDisplayMessage"; + +/** @brief ClearDisplayMessageReq message */ +struct ClearDisplayMessageReq +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief Id of the message that SHALL be removed from the Charging Station. */ + int id; +}; + +/** @brief ClearDisplayMessageConf message */ +struct ClearDisplayMessageConf +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::ocpp20::ClearMessageStatusEnumType status; + /** @brief */ + ocpp::types::Optional statusInfo; +}; + +// Message converters +MESSAGE_CONVERTERS(ClearDisplayMessage) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_CLEARDISPLAYMESSAGE_H \ No newline at end of file diff --git a/src/ocpp20/messages/ClearVariableMonitoring20.cpp b/src/ocpp20/messages/ClearVariableMonitoring20.cpp new file mode 100644 index 00000000..f09ec6ee --- /dev/null +++ b/src/ocpp20/messages/ClearVariableMonitoring20.cpp @@ -0,0 +1,164 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:ClearVariableMonitoringRequest + OCPP 2.0.1 FINAL +*/ + +#include "ClearVariableMonitoring20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a ClearVariableMonitoringReq from a JSON representation */ +bool ClearVariableMonitoringReqConverter::fromJson(const rapidjson::Value& json, + ClearVariableMonitoringReq& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // id + if (json.HasMember("id")) + { + const rapidjson::Value& id_json = json["id"]; + for (auto it = id_json.Begin(); ret && (it != id_json.End()); ++it) + { + int& item = data.id.emplace_back(); + item = it->GetInt(); + } + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a ClearVariableMonitoringReq to a JSON representation */ +bool ClearVariableMonitoringReqConverter::toJson(const ClearVariableMonitoringReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // id + + rapidjson::Value id_json(rapidjson::kArrayType); + for (const int& item : data.id) + { + id_json.PushBack(rapidjson::Value(item), *allocator); + } + json.AddMember(rapidjson::StringRef("id"), id_json.Move(), *allocator); + + return ret; +} + +/** @brief Convert a ClearVariableMonitoringConf from a JSON representation */ +bool ClearVariableMonitoringConfConverter::fromJson(const rapidjson::Value& json, + ClearVariableMonitoringConf& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // clearMonitoringResult + if (json.HasMember("clearMonitoringResult")) + { + const rapidjson::Value& clearMonitoringResult_json = json["clearMonitoringResult"]; + ocpp::types::ocpp20::ClearMonitoringResultTypeConverter clearMonitoringResult_converter; + for (auto it = clearMonitoringResult_json.Begin(); ret && (it != clearMonitoringResult_json.End()); ++it) + { + ocpp::types::ocpp20::ClearMonitoringResultType& item = data.clearMonitoringResult.emplace_back(); + ret = ret && clearMonitoringResult_converter.fromJson(*it, item, error_code, error_message); + } + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a ClearVariableMonitoringConf to a JSON representation */ +bool ClearVariableMonitoringConfConverter::toJson(const ClearVariableMonitoringConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // clearMonitoringResult + + rapidjson::Value clearMonitoringResult_json(rapidjson::kArrayType); + ocpp::types::ocpp20::ClearMonitoringResultTypeConverter clearMonitoringResult_converter; + clearMonitoringResult_converter.setAllocator(allocator); + for (const ocpp::types::ocpp20::ClearMonitoringResultType& item : data.clearMonitoringResult) + { + rapidjson::Document item_doc(rapidjson::kObjectType); + ret = ret && clearMonitoringResult_converter.toJson(item, item_doc); + clearMonitoringResult_json.PushBack(item_doc.Move(), *allocator); + } + json.AddMember(rapidjson::StringRef("clearMonitoringResult"), clearMonitoringResult_json.Move(), *allocator); + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/ClearVariableMonitoring20.h b/src/ocpp20/messages/ClearVariableMonitoring20.h new file mode 100644 index 00000000..c34dbc67 --- /dev/null +++ b/src/ocpp20/messages/ClearVariableMonitoring20.h @@ -0,0 +1,67 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:ClearVariableMonitoringRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_CLEARVARIABLEMONITORING_H +#define OPENOCPP_OCPP20_CLEARVARIABLEMONITORING_H + +#include "IMessageConverter.h" + +#include "ClearMonitoringResultType20.h" +#include "CustomDataType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the ClearVariableMonitoring messages */ +static const std::string CLEARVARIABLEMONITORING_ACTION = "ClearVariableMonitoring"; + +/** @brief ClearVariableMonitoringReq message */ +struct ClearVariableMonitoringReq +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief List of the monitors to be cleared, identified by there Id. */ + std::vector id; +}; + +/** @brief ClearVariableMonitoringConf message */ +struct ClearVariableMonitoringConf +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + std::vector clearMonitoringResult; +}; + +// Message converters +MESSAGE_CONVERTERS(ClearVariableMonitoring) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_CLEARVARIABLEMONITORING_H \ No newline at end of file diff --git a/src/ocpp20/messages/ClearedChargingLimit20.cpp b/src/ocpp20/messages/ClearedChargingLimit20.cpp new file mode 100644 index 00000000..24199a15 --- /dev/null +++ b/src/ocpp20/messages/ClearedChargingLimit20.cpp @@ -0,0 +1,131 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:ClearedChargingLimitRequest + OCPP 2.0.1 FINAL +*/ + +#include "ClearedChargingLimit20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a ClearedChargingLimitReq from a JSON representation */ +bool ClearedChargingLimitReqConverter::fromJson(const rapidjson::Value& json, + ClearedChargingLimitReq& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // chargingLimitSource + data.chargingLimitSource = ocpp::types::ocpp20::ChargingLimitSourceEnumTypeHelper.fromString(json["chargingLimitSource"].GetString()); + + // evseId + extract(json, "evseId", data.evseId); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a ClearedChargingLimitReq to a JSON representation */ +bool ClearedChargingLimitReqConverter::toJson(const ClearedChargingLimitReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // chargingLimitSource + fill(json, "chargingLimitSource", ocpp::types::ocpp20::ChargingLimitSourceEnumTypeHelper.toString(data.chargingLimitSource)); + + // evseId + fill(json, "evseId", data.evseId); + + return ret; +} + +/** @brief Convert a ClearedChargingLimitConf from a JSON representation */ +bool ClearedChargingLimitConfConverter::fromJson(const rapidjson::Value& json, + ClearedChargingLimitConf& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a ClearedChargingLimitConf to a JSON representation */ +bool ClearedChargingLimitConfConverter::toJson(const ClearedChargingLimitConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/ClearedChargingLimit20.h b/src/ocpp20/messages/ClearedChargingLimit20.h new file mode 100644 index 00000000..6374d13c --- /dev/null +++ b/src/ocpp20/messages/ClearedChargingLimit20.h @@ -0,0 +1,67 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:ClearedChargingLimitRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_CLEAREDCHARGINGLIMIT_H +#define OPENOCPP_OCPP20_CLEAREDCHARGINGLIMIT_H + +#include "IMessageConverter.h" + +#include "ChargingLimitSourceEnumType20.h" +#include "CustomDataType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the ClearedChargingLimit messages */ +static const std::string CLEAREDCHARGINGLIMIT_ACTION = "ClearedChargingLimit"; + +/** @brief ClearedChargingLimitReq message */ +struct ClearedChargingLimitReq +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::ocpp20::ChargingLimitSourceEnumType chargingLimitSource; + /** @brief EVSE Identifier. */ + ocpp::types::Optional evseId; +}; + +/** @brief ClearedChargingLimitConf message */ +struct ClearedChargingLimitConf +{ + /** @brief */ + ocpp::types::Optional customData; +}; + +// Message converters +MESSAGE_CONVERTERS(ClearedChargingLimit) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_CLEAREDCHARGINGLIMIT_H \ No newline at end of file diff --git a/src/ocpp20/messages/CostUpdated20.cpp b/src/ocpp20/messages/CostUpdated20.cpp new file mode 100644 index 00000000..532b11a1 --- /dev/null +++ b/src/ocpp20/messages/CostUpdated20.cpp @@ -0,0 +1,131 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:CostUpdatedRequest + OCPP 2.0.1 FINAL +*/ + +#include "CostUpdated20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a CostUpdatedReq from a JSON representation */ +bool CostUpdatedReqConverter::fromJson(const rapidjson::Value& json, + CostUpdatedReq& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // totalCost + extract(json, "totalCost", data.totalCost); + + // transactionId + extract(json, "transactionId", data.transactionId); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a CostUpdatedReq to a JSON representation */ +bool CostUpdatedReqConverter::toJson(const CostUpdatedReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // totalCost + fill(json, "totalCost", data.totalCost); + + // transactionId + fill(json, "transactionId", data.transactionId); + + return ret; +} + +/** @brief Convert a CostUpdatedConf from a JSON representation */ +bool CostUpdatedConfConverter::fromJson(const rapidjson::Value& json, + CostUpdatedConf& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a CostUpdatedConf to a JSON representation */ +bool CostUpdatedConfConverter::toJson(const CostUpdatedConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/CostUpdated20.h b/src/ocpp20/messages/CostUpdated20.h new file mode 100644 index 00000000..6a9ec23f --- /dev/null +++ b/src/ocpp20/messages/CostUpdated20.h @@ -0,0 +1,66 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:CostUpdatedRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_COSTUPDATED_H +#define OPENOCPP_OCPP20_COSTUPDATED_H + +#include "IMessageConverter.h" + +#include "CustomDataType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the CostUpdated messages */ +static const std::string COSTUPDATED_ACTION = "CostUpdated"; + +/** @brief CostUpdatedReq message */ +struct CostUpdatedReq +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief Current total cost, based on the information known by the CSMS, of the transaction including taxes. In the currency configured with the configuration Variable: [<<configkey-currency, Currency>>] */ + float totalCost; + /** @brief Transaction Id of the transaction the current cost are asked for. */ + ocpp::types::CiStringType<36u> transactionId; +}; + +/** @brief CostUpdatedConf message */ +struct CostUpdatedConf +{ + /** @brief */ + ocpp::types::Optional customData; +}; + +// Message converters +MESSAGE_CONVERTERS(CostUpdated) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_COSTUPDATED_H \ No newline at end of file diff --git a/src/ocpp20/messages/CustomerInformation20.cpp b/src/ocpp20/messages/CustomerInformation20.cpp new file mode 100644 index 00000000..3764700e --- /dev/null +++ b/src/ocpp20/messages/CustomerInformation20.cpp @@ -0,0 +1,201 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:CustomerInformationRequest + OCPP 2.0.1 FINAL +*/ + +#include "CustomerInformation20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a CustomerInformationReq from a JSON representation */ +bool CustomerInformationReqConverter::fromJson(const rapidjson::Value& json, + CustomerInformationReq& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // customerCertificate + if (json.HasMember("customerCertificate")) + { + ocpp::types::ocpp20::CertificateHashDataTypeConverter customerCertificate_converter; + ret = + ret && customerCertificate_converter.fromJson(json["customerCertificate"], data.customerCertificate, error_code, error_message); + } + + // idToken + if (json.HasMember("idToken")) + { + ocpp::types::ocpp20::IdTokenTypeConverter idToken_converter; + ret = ret && idToken_converter.fromJson(json["idToken"], data.idToken, error_code, error_message); + } + + // requestId + extract(json, "requestId", data.requestId); + + // report + extract(json, "report", data.report); + + // clear + extract(json, "clear", data.clear); + + // customerIdentifier + extract(json, "customerIdentifier", data.customerIdentifier); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a CustomerInformationReq to a JSON representation */ +bool CustomerInformationReqConverter::toJson(const CustomerInformationReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // customerCertificate + if (data.customerCertificate.isSet()) + { + ocpp::types::ocpp20::CertificateHashDataTypeConverter customerCertificate_converter; + customerCertificate_converter.setAllocator(allocator); + rapidjson::Document customerCertificate_doc(rapidjson::kObjectType); + ret = ret && customerCertificate_converter.toJson(data.customerCertificate, customerCertificate_doc); + json.AddMember(rapidjson::StringRef("customerCertificate"), customerCertificate_doc.Move(), *allocator); + } + + // idToken + if (data.idToken.isSet()) + { + ocpp::types::ocpp20::IdTokenTypeConverter idToken_converter; + idToken_converter.setAllocator(allocator); + rapidjson::Document idToken_doc(rapidjson::kObjectType); + ret = ret && idToken_converter.toJson(data.idToken, idToken_doc); + json.AddMember(rapidjson::StringRef("idToken"), idToken_doc.Move(), *allocator); + } + + // requestId + fill(json, "requestId", data.requestId); + + // report + fill(json, "report", data.report); + + // clear + fill(json, "clear", data.clear); + + // customerIdentifier + fill(json, "customerIdentifier", data.customerIdentifier); + + return ret; +} + +/** @brief Convert a CustomerInformationConf from a JSON representation */ +bool CustomerInformationConfConverter::fromJson(const rapidjson::Value& json, + CustomerInformationConf& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // status + data.status = ocpp::types::ocpp20::CustomerInformationStatusEnumTypeHelper.fromString(json["status"].GetString()); + + // statusInfo + if (json.HasMember("statusInfo")) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + ret = ret && statusInfo_converter.fromJson(json["statusInfo"], data.statusInfo, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a CustomerInformationConf to a JSON representation */ +bool CustomerInformationConfConverter::toJson(const CustomerInformationConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // status + fill(json, "status", ocpp::types::ocpp20::CustomerInformationStatusEnumTypeHelper.toString(data.status)); + + // statusInfo + if (data.statusInfo.isSet()) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + statusInfo_converter.setAllocator(allocator); + rapidjson::Document statusInfo_doc(rapidjson::kObjectType); + ret = ret && statusInfo_converter.toJson(data.statusInfo, statusInfo_doc); + json.AddMember(rapidjson::StringRef("statusInfo"), statusInfo_doc.Move(), *allocator); + } + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/CustomerInformation20.h b/src/ocpp20/messages/CustomerInformation20.h new file mode 100644 index 00000000..3e139a84 --- /dev/null +++ b/src/ocpp20/messages/CustomerInformation20.h @@ -0,0 +1,83 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:CustomerInformationRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_CUSTOMERINFORMATION_H +#define OPENOCPP_OCPP20_CUSTOMERINFORMATION_H + +#include "IMessageConverter.h" + +#include "CertificateHashDataType20.h" +#include "CustomDataType20.h" +#include "CustomerInformationStatusEnumType20.h" +#include "IdTokenType20.h" +#include "StatusInfoType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the CustomerInformation messages */ +static const std::string CUSTOMERINFORMATION_ACTION = "CustomerInformation"; + +/** @brief CustomerInformationReq message */ +struct CustomerInformationReq +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::Optional customerCertificate; + /** @brief */ + ocpp::types::Optional idToken; + /** @brief The Id of the request. */ + int requestId; + /** @brief Flag indicating whether the Charging Station should return NotifyCustomerInformationRequest messages containing information about the customer referred to. */ + bool report; + /** @brief Flag indicating whether the Charging Station should clear all information about the customer referred to. */ + bool clear; + /** @brief A (e.g. vendor specific) identifier of the customer this request refers to. This field contains a custom identifier other than IdToken and Certificate. +One of the possible identifiers (customerIdentifier, customerIdToken or customerCertificate) should be in the request message. */ + ocpp::types::Optional> customerIdentifier; +}; + +/** @brief CustomerInformationConf message */ +struct CustomerInformationConf +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::ocpp20::CustomerInformationStatusEnumType status; + /** @brief */ + ocpp::types::Optional statusInfo; +}; + +// Message converters +MESSAGE_CONVERTERS(CustomerInformation) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_CUSTOMERINFORMATION_H \ No newline at end of file diff --git a/src/ocpp20/messages/DataTransfer20.cpp b/src/ocpp20/messages/DataTransfer20.cpp new file mode 100644 index 00000000..f816fa35 --- /dev/null +++ b/src/ocpp20/messages/DataTransfer20.cpp @@ -0,0 +1,166 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:DataTransferRequest + OCPP 2.0.1 FINAL +*/ + +#include "DataTransfer20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a DataTransferReq from a JSON representation */ +bool DataTransferReqConverter::fromJson(const rapidjson::Value& json, + DataTransferReq& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // messageId + extract(json, "messageId", data.messageId); + + // data + extract(json, "data", data.data); + + // vendorId + extract(json, "vendorId", data.vendorId); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a DataTransferReq to a JSON representation */ +bool DataTransferReqConverter::toJson(const DataTransferReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // messageId + fill(json, "messageId", data.messageId); + + // data + fill(json, "data", data.data); + + // vendorId + fill(json, "vendorId", data.vendorId); + + return ret; +} + +/** @brief Convert a DataTransferConf from a JSON representation */ +bool DataTransferConfConverter::fromJson(const rapidjson::Value& json, + DataTransferConf& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // status + data.status = ocpp::types::ocpp20::DataTransferStatusEnumTypeHelper.fromString(json["status"].GetString()); + + // statusInfo + if (json.HasMember("statusInfo")) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + ret = ret && statusInfo_converter.fromJson(json["statusInfo"], data.statusInfo, error_code, error_message); + } + + // data + extract(json, "data", data.data); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a DataTransferConf to a JSON representation */ +bool DataTransferConfConverter::toJson(const DataTransferConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // status + fill(json, "status", ocpp::types::ocpp20::DataTransferStatusEnumTypeHelper.toString(data.status)); + + // statusInfo + if (data.statusInfo.isSet()) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + statusInfo_converter.setAllocator(allocator); + rapidjson::Document statusInfo_doc(rapidjson::kObjectType); + ret = ret && statusInfo_converter.toJson(data.statusInfo, statusInfo_doc); + json.AddMember(rapidjson::StringRef("statusInfo"), statusInfo_doc.Move(), *allocator); + } + + // data + fill(json, "data", data.data); + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/DataTransfer20.h b/src/ocpp20/messages/DataTransfer20.h new file mode 100644 index 00000000..4c2372af --- /dev/null +++ b/src/ocpp20/messages/DataTransfer20.h @@ -0,0 +1,76 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:DataTransferRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_DATATRANSFER_H +#define OPENOCPP_OCPP20_DATATRANSFER_H + +#include "IMessageConverter.h" + +#include "CustomDataType20.h" +#include "DataTransferStatusEnumType20.h" +#include "StatusInfoType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the DataTransfer messages */ +static const std::string DATATRANSFER_ACTION = "DataTransfer"; + +/** @brief DataTransferReq message */ +struct DataTransferReq +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief May be used to indicate a specific message or implementation. */ + ocpp::types::Optional> messageId; + /** @brief Data without specified length or format. This needs to be decided by both parties (Open to implementation). */ + ocpp::types::Optional data; + /** @brief This identifies the Vendor specific implementation */ + ocpp::types::CiStringType<255u> vendorId; +}; + +/** @brief DataTransferConf message */ +struct DataTransferConf +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::ocpp20::DataTransferStatusEnumType status; + /** @brief */ + ocpp::types::Optional statusInfo; + /** @brief Data without specified length or format, in response to request. */ + ocpp::types::Optional data; +}; + +// Message converters +MESSAGE_CONVERTERS(DataTransfer) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_DATATRANSFER_H \ No newline at end of file diff --git a/src/ocpp20/messages/DeleteCertificate20.cpp b/src/ocpp20/messages/DeleteCertificate20.cpp new file mode 100644 index 00000000..3c4266a3 --- /dev/null +++ b/src/ocpp20/messages/DeleteCertificate20.cpp @@ -0,0 +1,153 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:DeleteCertificateRequest + OCPP 2.0.1 FINAL +*/ + +#include "DeleteCertificate20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a DeleteCertificateReq from a JSON representation */ +bool DeleteCertificateReqConverter::fromJson(const rapidjson::Value& json, + DeleteCertificateReq& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // certificateHashData + ocpp::types::ocpp20::CertificateHashDataTypeConverter certificateHashData_converter; + ret = ret && certificateHashData_converter.fromJson(json["certificateHashData"], data.certificateHashData, error_code, error_message); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a DeleteCertificateReq to a JSON representation */ +bool DeleteCertificateReqConverter::toJson(const DeleteCertificateReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // certificateHashData + ocpp::types::ocpp20::CertificateHashDataTypeConverter certificateHashData_converter; + certificateHashData_converter.setAllocator(allocator); + rapidjson::Document certificateHashData_doc(rapidjson::kObjectType); + ret = ret && certificateHashData_converter.toJson(data.certificateHashData, certificateHashData_doc); + json.AddMember(rapidjson::StringRef("certificateHashData"), certificateHashData_doc.Move(), *allocator); + + return ret; +} + +/** @brief Convert a DeleteCertificateConf from a JSON representation */ +bool DeleteCertificateConfConverter::fromJson(const rapidjson::Value& json, + DeleteCertificateConf& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // status + data.status = ocpp::types::ocpp20::DeleteCertificateStatusEnumTypeHelper.fromString(json["status"].GetString()); + + // statusInfo + if (json.HasMember("statusInfo")) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + ret = ret && statusInfo_converter.fromJson(json["statusInfo"], data.statusInfo, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a DeleteCertificateConf to a JSON representation */ +bool DeleteCertificateConfConverter::toJson(const DeleteCertificateConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // status + fill(json, "status", ocpp::types::ocpp20::DeleteCertificateStatusEnumTypeHelper.toString(data.status)); + + // statusInfo + if (data.statusInfo.isSet()) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + statusInfo_converter.setAllocator(allocator); + rapidjson::Document statusInfo_doc(rapidjson::kObjectType); + ret = ret && statusInfo_converter.toJson(data.statusInfo, statusInfo_doc); + json.AddMember(rapidjson::StringRef("statusInfo"), statusInfo_doc.Move(), *allocator); + } + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/DeleteCertificate20.h b/src/ocpp20/messages/DeleteCertificate20.h new file mode 100644 index 00000000..53ea96e0 --- /dev/null +++ b/src/ocpp20/messages/DeleteCertificate20.h @@ -0,0 +1,71 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:DeleteCertificateRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_DELETECERTIFICATE_H +#define OPENOCPP_OCPP20_DELETECERTIFICATE_H + +#include "IMessageConverter.h" + +#include "CertificateHashDataType20.h" +#include "CustomDataType20.h" +#include "DeleteCertificateStatusEnumType20.h" +#include "StatusInfoType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the DeleteCertificate messages */ +static const std::string DELETECERTIFICATE_ACTION = "DeleteCertificate"; + +/** @brief DeleteCertificateReq message */ +struct DeleteCertificateReq +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::ocpp20::CertificateHashDataType certificateHashData; +}; + +/** @brief DeleteCertificateConf message */ +struct DeleteCertificateConf +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::ocpp20::DeleteCertificateStatusEnumType status; + /** @brief */ + ocpp::types::Optional statusInfo; +}; + +// Message converters +MESSAGE_CONVERTERS(DeleteCertificate) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_DELETECERTIFICATE_H \ No newline at end of file diff --git a/src/ocpp20/messages/FirmwareStatusNotification20.cpp b/src/ocpp20/messages/FirmwareStatusNotification20.cpp new file mode 100644 index 00000000..f23c0f24 --- /dev/null +++ b/src/ocpp20/messages/FirmwareStatusNotification20.cpp @@ -0,0 +1,131 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:FirmwareStatusNotificationRequest + OCPP 2.0.1 FINAL +*/ + +#include "FirmwareStatusNotification20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a FirmwareStatusNotificationReq from a JSON representation */ +bool FirmwareStatusNotificationReqConverter::fromJson(const rapidjson::Value& json, + FirmwareStatusNotificationReq& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // status + data.status = ocpp::types::ocpp20::FirmwareStatusEnumTypeHelper.fromString(json["status"].GetString()); + + // requestId + extract(json, "requestId", data.requestId); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a FirmwareStatusNotificationReq to a JSON representation */ +bool FirmwareStatusNotificationReqConverter::toJson(const FirmwareStatusNotificationReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // status + fill(json, "status", ocpp::types::ocpp20::FirmwareStatusEnumTypeHelper.toString(data.status)); + + // requestId + fill(json, "requestId", data.requestId); + + return ret; +} + +/** @brief Convert a FirmwareStatusNotificationConf from a JSON representation */ +bool FirmwareStatusNotificationConfConverter::fromJson(const rapidjson::Value& json, + FirmwareStatusNotificationConf& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a FirmwareStatusNotificationConf to a JSON representation */ +bool FirmwareStatusNotificationConfConverter::toJson(const FirmwareStatusNotificationConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/FirmwareStatusNotification20.h b/src/ocpp20/messages/FirmwareStatusNotification20.h new file mode 100644 index 00000000..b7b3da4e --- /dev/null +++ b/src/ocpp20/messages/FirmwareStatusNotification20.h @@ -0,0 +1,69 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:FirmwareStatusNotificationRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_FIRMWARESTATUSNOTIFICATION_H +#define OPENOCPP_OCPP20_FIRMWARESTATUSNOTIFICATION_H + +#include "IMessageConverter.h" + +#include "CustomDataType20.h" +#include "FirmwareStatusEnumType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the FirmwareStatusNotification messages */ +static const std::string FIRMWARESTATUSNOTIFICATION_ACTION = "FirmwareStatusNotification"; + +/** @brief FirmwareStatusNotificationReq message */ +struct FirmwareStatusNotificationReq +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::ocpp20::FirmwareStatusEnumType status; + /** @brief The request id that was provided in the +UpdateFirmwareRequest that started this firmware update. +This field is mandatory, unless the message was triggered by a TriggerMessageRequest AND there is no firmware update ongoing. */ + ocpp::types::Optional requestId; +}; + +/** @brief FirmwareStatusNotificationConf message */ +struct FirmwareStatusNotificationConf +{ + /** @brief */ + ocpp::types::Optional customData; +}; + +// Message converters +MESSAGE_CONVERTERS(FirmwareStatusNotification) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_FIRMWARESTATUSNOTIFICATION_H \ No newline at end of file diff --git a/src/ocpp20/messages/Get15118EVCertificate20.cpp b/src/ocpp20/messages/Get15118EVCertificate20.cpp new file mode 100644 index 00000000..8b202ec6 --- /dev/null +++ b/src/ocpp20/messages/Get15118EVCertificate20.cpp @@ -0,0 +1,166 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:Get15118EVCertificateRequest + OCPP 2.0.1 FINAL +*/ + +#include "Get15118EVCertificate20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a Get15118EVCertificateReq from a JSON representation */ +bool Get15118EVCertificateReqConverter::fromJson(const rapidjson::Value& json, + Get15118EVCertificateReq& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // iso15118SchemaVersion + extract(json, "iso15118SchemaVersion", data.iso15118SchemaVersion); + + // action + data.action = ocpp::types::ocpp20::CertificateActionEnumTypeHelper.fromString(json["action"].GetString()); + + // exiRequest + extract(json, "exiRequest", data.exiRequest); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a Get15118EVCertificateReq to a JSON representation */ +bool Get15118EVCertificateReqConverter::toJson(const Get15118EVCertificateReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // iso15118SchemaVersion + fill(json, "iso15118SchemaVersion", data.iso15118SchemaVersion); + + // action + fill(json, "action", ocpp::types::ocpp20::CertificateActionEnumTypeHelper.toString(data.action)); + + // exiRequest + fill(json, "exiRequest", data.exiRequest); + + return ret; +} + +/** @brief Convert a Get15118EVCertificateConf from a JSON representation */ +bool Get15118EVCertificateConfConverter::fromJson(const rapidjson::Value& json, + Get15118EVCertificateConf& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // status + data.status = ocpp::types::ocpp20::Iso15118EVCertificateStatusEnumTypeHelper.fromString(json["status"].GetString()); + + // statusInfo + if (json.HasMember("statusInfo")) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + ret = ret && statusInfo_converter.fromJson(json["statusInfo"], data.statusInfo, error_code, error_message); + } + + // exiResponse + extract(json, "exiResponse", data.exiResponse); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a Get15118EVCertificateConf to a JSON representation */ +bool Get15118EVCertificateConfConverter::toJson(const Get15118EVCertificateConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // status + fill(json, "status", ocpp::types::ocpp20::Iso15118EVCertificateStatusEnumTypeHelper.toString(data.status)); + + // statusInfo + if (data.statusInfo.isSet()) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + statusInfo_converter.setAllocator(allocator); + rapidjson::Document statusInfo_doc(rapidjson::kObjectType); + ret = ret && statusInfo_converter.toJson(data.statusInfo, statusInfo_doc); + json.AddMember(rapidjson::StringRef("statusInfo"), statusInfo_doc.Move(), *allocator); + } + + // exiResponse + fill(json, "exiResponse", data.exiResponse); + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/Get15118EVCertificate20.h b/src/ocpp20/messages/Get15118EVCertificate20.h new file mode 100644 index 00000000..88d5e6c4 --- /dev/null +++ b/src/ocpp20/messages/Get15118EVCertificate20.h @@ -0,0 +1,77 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:Get15118EVCertificateRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_GET15118EVCERTIFICATE_H +#define OPENOCPP_OCPP20_GET15118EVCERTIFICATE_H + +#include "IMessageConverter.h" + +#include "CertificateActionEnumType20.h" +#include "CustomDataType20.h" +#include "Iso15118EVCertificateStatusEnumType20.h" +#include "StatusInfoType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the Get15118EVCertificate messages */ +static const std::string GET15118EVCERTIFICATE_ACTION = "Get15118EVCertificate"; + +/** @brief Get15118EVCertificateReq message */ +struct Get15118EVCertificateReq +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief Schema version currently used for the 15118 session between EV and Charging Station. Needed for parsing of the EXI stream by the CSMS. */ + ocpp::types::CiStringType<50u> iso15118SchemaVersion; + /** @brief */ + ocpp::types::ocpp20::CertificateActionEnumType action; + /** @brief Raw CertificateInstallationReq request from EV, Base64 encoded. */ + ocpp::types::CiStringType<5600u> exiRequest; +}; + +/** @brief Get15118EVCertificateConf message */ +struct Get15118EVCertificateConf +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::ocpp20::Iso15118EVCertificateStatusEnumType status; + /** @brief */ + ocpp::types::Optional statusInfo; + /** @brief Raw CertificateInstallationRes response for the EV, Base64 encoded. */ + ocpp::types::CiStringType<5600u> exiResponse; +}; + +// Message converters +MESSAGE_CONVERTERS(Get15118EVCertificate) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_GET15118EVCERTIFICATE_H \ No newline at end of file diff --git a/src/ocpp20/messages/GetBaseReport20.cpp b/src/ocpp20/messages/GetBaseReport20.cpp new file mode 100644 index 00000000..ed761bf6 --- /dev/null +++ b/src/ocpp20/messages/GetBaseReport20.cpp @@ -0,0 +1,154 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetBaseReportRequest + OCPP 2.0.1 FINAL +*/ + +#include "GetBaseReport20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a GetBaseReportReq from a JSON representation */ +bool GetBaseReportReqConverter::fromJson(const rapidjson::Value& json, + GetBaseReportReq& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // requestId + extract(json, "requestId", data.requestId); + + // reportBase + data.reportBase = ocpp::types::ocpp20::ReportBaseEnumTypeHelper.fromString(json["reportBase"].GetString()); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a GetBaseReportReq to a JSON representation */ +bool GetBaseReportReqConverter::toJson(const GetBaseReportReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // requestId + fill(json, "requestId", data.requestId); + + // reportBase + fill(json, "reportBase", ocpp::types::ocpp20::ReportBaseEnumTypeHelper.toString(data.reportBase)); + + return ret; +} + +/** @brief Convert a GetBaseReportConf from a JSON representation */ +bool GetBaseReportConfConverter::fromJson(const rapidjson::Value& json, + GetBaseReportConf& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // status + data.status = ocpp::types::ocpp20::GenericDeviceModelStatusEnumTypeHelper.fromString(json["status"].GetString()); + + // statusInfo + if (json.HasMember("statusInfo")) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + ret = ret && statusInfo_converter.fromJson(json["statusInfo"], data.statusInfo, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a GetBaseReportConf to a JSON representation */ +bool GetBaseReportConfConverter::toJson(const GetBaseReportConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // status + fill(json, "status", ocpp::types::ocpp20::GenericDeviceModelStatusEnumTypeHelper.toString(data.status)); + + // statusInfo + if (data.statusInfo.isSet()) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + statusInfo_converter.setAllocator(allocator); + rapidjson::Document statusInfo_doc(rapidjson::kObjectType); + ret = ret && statusInfo_converter.toJson(data.statusInfo, statusInfo_doc); + json.AddMember(rapidjson::StringRef("statusInfo"), statusInfo_doc.Move(), *allocator); + } + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/GetBaseReport20.h b/src/ocpp20/messages/GetBaseReport20.h new file mode 100644 index 00000000..52e2161a --- /dev/null +++ b/src/ocpp20/messages/GetBaseReport20.h @@ -0,0 +1,73 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetBaseReportRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_GETBASEREPORT_H +#define OPENOCPP_OCPP20_GETBASEREPORT_H + +#include "IMessageConverter.h" + +#include "CustomDataType20.h" +#include "GenericDeviceModelStatusEnumType20.h" +#include "ReportBaseEnumType20.h" +#include "StatusInfoType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the GetBaseReport messages */ +static const std::string GETBASEREPORT_ACTION = "GetBaseReport"; + +/** @brief GetBaseReportReq message */ +struct GetBaseReportReq +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief The Id of the request. */ + int requestId; + /** @brief */ + ocpp::types::ocpp20::ReportBaseEnumType reportBase; +}; + +/** @brief GetBaseReportConf message */ +struct GetBaseReportConf +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::ocpp20::GenericDeviceModelStatusEnumType status; + /** @brief */ + ocpp::types::Optional statusInfo; +}; + +// Message converters +MESSAGE_CONVERTERS(GetBaseReport) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_GETBASEREPORT_H \ No newline at end of file diff --git a/src/ocpp20/messages/GetCertificateStatus20.cpp b/src/ocpp20/messages/GetCertificateStatus20.cpp new file mode 100644 index 00000000..d5145cc4 --- /dev/null +++ b/src/ocpp20/messages/GetCertificateStatus20.cpp @@ -0,0 +1,159 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetCertificateStatusRequest + OCPP 2.0.1 FINAL +*/ + +#include "GetCertificateStatus20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a GetCertificateStatusReq from a JSON representation */ +bool GetCertificateStatusReqConverter::fromJson(const rapidjson::Value& json, + GetCertificateStatusReq& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // ocspRequestData + ocpp::types::ocpp20::OCSPRequestDataTypeConverter ocspRequestData_converter; + ret = ret && ocspRequestData_converter.fromJson(json["ocspRequestData"], data.ocspRequestData, error_code, error_message); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a GetCertificateStatusReq to a JSON representation */ +bool GetCertificateStatusReqConverter::toJson(const GetCertificateStatusReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // ocspRequestData + ocpp::types::ocpp20::OCSPRequestDataTypeConverter ocspRequestData_converter; + ocspRequestData_converter.setAllocator(allocator); + rapidjson::Document ocspRequestData_doc(rapidjson::kObjectType); + ret = ret && ocspRequestData_converter.toJson(data.ocspRequestData, ocspRequestData_doc); + json.AddMember(rapidjson::StringRef("ocspRequestData"), ocspRequestData_doc.Move(), *allocator); + + return ret; +} + +/** @brief Convert a GetCertificateStatusConf from a JSON representation */ +bool GetCertificateStatusConfConverter::fromJson(const rapidjson::Value& json, + GetCertificateStatusConf& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // status + data.status = ocpp::types::ocpp20::GetCertificateStatusEnumTypeHelper.fromString(json["status"].GetString()); + + // statusInfo + if (json.HasMember("statusInfo")) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + ret = ret && statusInfo_converter.fromJson(json["statusInfo"], data.statusInfo, error_code, error_message); + } + + // ocspResult + extract(json, "ocspResult", data.ocspResult); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a GetCertificateStatusConf to a JSON representation */ +bool GetCertificateStatusConfConverter::toJson(const GetCertificateStatusConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // status + fill(json, "status", ocpp::types::ocpp20::GetCertificateStatusEnumTypeHelper.toString(data.status)); + + // statusInfo + if (data.statusInfo.isSet()) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + statusInfo_converter.setAllocator(allocator); + rapidjson::Document statusInfo_doc(rapidjson::kObjectType); + ret = ret && statusInfo_converter.toJson(data.statusInfo, statusInfo_doc); + json.AddMember(rapidjson::StringRef("statusInfo"), statusInfo_doc.Move(), *allocator); + } + + // ocspResult + fill(json, "ocspResult", data.ocspResult); + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/GetCertificateStatus20.h b/src/ocpp20/messages/GetCertificateStatus20.h new file mode 100644 index 00000000..b9b6ed3c --- /dev/null +++ b/src/ocpp20/messages/GetCertificateStatus20.h @@ -0,0 +1,73 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetCertificateStatusRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_GETCERTIFICATESTATUS_H +#define OPENOCPP_OCPP20_GETCERTIFICATESTATUS_H + +#include "IMessageConverter.h" + +#include "CustomDataType20.h" +#include "GetCertificateStatusEnumType20.h" +#include "OCSPRequestDataType20.h" +#include "StatusInfoType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the GetCertificateStatus messages */ +static const std::string GETCERTIFICATESTATUS_ACTION = "GetCertificateStatus"; + +/** @brief GetCertificateStatusReq message */ +struct GetCertificateStatusReq +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::ocpp20::OCSPRequestDataType ocspRequestData; +}; + +/** @brief GetCertificateStatusConf message */ +struct GetCertificateStatusConf +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::ocpp20::GetCertificateStatusEnumType status; + /** @brief */ + ocpp::types::Optional statusInfo; + /** @brief OCSPResponse class as defined in <<ref-ocpp_security_24, IETF RFC 6960>>. DER encoded (as defined in <<ref-ocpp_security_24, IETF RFC 6960>>), and then base64 encoded. MAY only be omitted when status is not Accepted. */ + ocpp::types::Optional> ocspResult; +}; + +// Message converters +MESSAGE_CONVERTERS(GetCertificateStatus) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_GETCERTIFICATESTATUS_H \ No newline at end of file diff --git a/src/ocpp20/messages/GetChargingProfiles20.cpp b/src/ocpp20/messages/GetChargingProfiles20.cpp new file mode 100644 index 00000000..764ddb26 --- /dev/null +++ b/src/ocpp20/messages/GetChargingProfiles20.cpp @@ -0,0 +1,165 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetChargingProfilesRequest + OCPP 2.0.1 FINAL +*/ + +#include "GetChargingProfiles20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a GetChargingProfilesReq from a JSON representation */ +bool GetChargingProfilesReqConverter::fromJson(const rapidjson::Value& json, + GetChargingProfilesReq& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // requestId + extract(json, "requestId", data.requestId); + + // evseId + extract(json, "evseId", data.evseId); + + // chargingProfile + ocpp::types::ocpp20::ChargingProfileCriterionTypeConverter chargingProfile_converter; + ret = ret && chargingProfile_converter.fromJson(json["chargingProfile"], data.chargingProfile, error_code, error_message); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a GetChargingProfilesReq to a JSON representation */ +bool GetChargingProfilesReqConverter::toJson(const GetChargingProfilesReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // requestId + fill(json, "requestId", data.requestId); + + // evseId + fill(json, "evseId", data.evseId); + + // chargingProfile + ocpp::types::ocpp20::ChargingProfileCriterionTypeConverter chargingProfile_converter; + chargingProfile_converter.setAllocator(allocator); + rapidjson::Document chargingProfile_doc(rapidjson::kObjectType); + ret = ret && chargingProfile_converter.toJson(data.chargingProfile, chargingProfile_doc); + json.AddMember(rapidjson::StringRef("chargingProfile"), chargingProfile_doc.Move(), *allocator); + + return ret; +} + +/** @brief Convert a GetChargingProfilesConf from a JSON representation */ +bool GetChargingProfilesConfConverter::fromJson(const rapidjson::Value& json, + GetChargingProfilesConf& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // status + data.status = ocpp::types::ocpp20::GetChargingProfileStatusEnumTypeHelper.fromString(json["status"].GetString()); + + // statusInfo + if (json.HasMember("statusInfo")) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + ret = ret && statusInfo_converter.fromJson(json["statusInfo"], data.statusInfo, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a GetChargingProfilesConf to a JSON representation */ +bool GetChargingProfilesConfConverter::toJson(const GetChargingProfilesConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // status + fill(json, "status", ocpp::types::ocpp20::GetChargingProfileStatusEnumTypeHelper.toString(data.status)); + + // statusInfo + if (data.statusInfo.isSet()) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + statusInfo_converter.setAllocator(allocator); + rapidjson::Document statusInfo_doc(rapidjson::kObjectType); + ret = ret && statusInfo_converter.toJson(data.statusInfo, statusInfo_doc); + json.AddMember(rapidjson::StringRef("statusInfo"), statusInfo_doc.Move(), *allocator); + } + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/GetChargingProfiles20.h b/src/ocpp20/messages/GetChargingProfiles20.h new file mode 100644 index 00000000..a5a93282 --- /dev/null +++ b/src/ocpp20/messages/GetChargingProfiles20.h @@ -0,0 +1,75 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetChargingProfilesRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_GETCHARGINGPROFILES_H +#define OPENOCPP_OCPP20_GETCHARGINGPROFILES_H + +#include "IMessageConverter.h" + +#include "ChargingProfileCriterionType20.h" +#include "CustomDataType20.h" +#include "GetChargingProfileStatusEnumType20.h" +#include "StatusInfoType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the GetChargingProfiles messages */ +static const std::string GETCHARGINGPROFILES_ACTION = "GetChargingProfiles"; + +/** @brief GetChargingProfilesReq message */ +struct GetChargingProfilesReq +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief Reference identification that is to be used by the Charging Station in the <<reportchargingprofilesrequest, ReportChargingProfilesRequest>> when provided. */ + int requestId; + /** @brief For which EVSE installed charging profiles SHALL be reported. If 0, only charging profiles installed on the Charging Station itself (the grid connection) SHALL be reported. If omitted, all installed charging profiles SHALL be reported. */ + ocpp::types::Optional evseId; + /** @brief */ + ocpp::types::ocpp20::ChargingProfileCriterionType chargingProfile; +}; + +/** @brief GetChargingProfilesConf message */ +struct GetChargingProfilesConf +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::ocpp20::GetChargingProfileStatusEnumType status; + /** @brief */ + ocpp::types::Optional statusInfo; +}; + +// Message converters +MESSAGE_CONVERTERS(GetChargingProfiles) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_GETCHARGINGPROFILES_H \ No newline at end of file diff --git a/src/ocpp20/messages/GetCompositeSchedule20.cpp b/src/ocpp20/messages/GetCompositeSchedule20.cpp new file mode 100644 index 00000000..60e01333 --- /dev/null +++ b/src/ocpp20/messages/GetCompositeSchedule20.cpp @@ -0,0 +1,183 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetCompositeScheduleRequest + OCPP 2.0.1 FINAL +*/ + +#include "GetCompositeSchedule20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a GetCompositeScheduleReq from a JSON representation */ +bool GetCompositeScheduleReqConverter::fromJson(const rapidjson::Value& json, + GetCompositeScheduleReq& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // duration + extract(json, "duration", data.duration); + + // chargingRateUnit + if (json.HasMember("chargingRateUnit")) + { + data.chargingRateUnit = ocpp::types::ocpp20::ChargingRateUnitEnumTypeHelper.fromString(json["chargingRateUnit"].GetString()); + } + + // evseId + extract(json, "evseId", data.evseId); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a GetCompositeScheduleReq to a JSON representation */ +bool GetCompositeScheduleReqConverter::toJson(const GetCompositeScheduleReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // duration + fill(json, "duration", data.duration); + + // chargingRateUnit + if (data.chargingRateUnit.isSet()) + { + fill(json, "chargingRateUnit", ocpp::types::ocpp20::ChargingRateUnitEnumTypeHelper.toString(data.chargingRateUnit)); + } + + // evseId + fill(json, "evseId", data.evseId); + + return ret; +} + +/** @brief Convert a GetCompositeScheduleConf from a JSON representation */ +bool GetCompositeScheduleConfConverter::fromJson(const rapidjson::Value& json, + GetCompositeScheduleConf& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // status + data.status = ocpp::types::ocpp20::GenericStatusEnumTypeHelper.fromString(json["status"].GetString()); + + // statusInfo + if (json.HasMember("statusInfo")) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + ret = ret && statusInfo_converter.fromJson(json["statusInfo"], data.statusInfo, error_code, error_message); + } + + // schedule + if (json.HasMember("schedule")) + { + ocpp::types::ocpp20::CompositeScheduleTypeConverter schedule_converter; + ret = ret && schedule_converter.fromJson(json["schedule"], data.schedule, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a GetCompositeScheduleConf to a JSON representation */ +bool GetCompositeScheduleConfConverter::toJson(const GetCompositeScheduleConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // status + fill(json, "status", ocpp::types::ocpp20::GenericStatusEnumTypeHelper.toString(data.status)); + + // statusInfo + if (data.statusInfo.isSet()) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + statusInfo_converter.setAllocator(allocator); + rapidjson::Document statusInfo_doc(rapidjson::kObjectType); + ret = ret && statusInfo_converter.toJson(data.statusInfo, statusInfo_doc); + json.AddMember(rapidjson::StringRef("statusInfo"), statusInfo_doc.Move(), *allocator); + } + + // schedule + if (data.schedule.isSet()) + { + ocpp::types::ocpp20::CompositeScheduleTypeConverter schedule_converter; + schedule_converter.setAllocator(allocator); + rapidjson::Document schedule_doc(rapidjson::kObjectType); + ret = ret && schedule_converter.toJson(data.schedule, schedule_doc); + json.AddMember(rapidjson::StringRef("schedule"), schedule_doc.Move(), *allocator); + } + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/GetCompositeSchedule20.h b/src/ocpp20/messages/GetCompositeSchedule20.h new file mode 100644 index 00000000..b898477e --- /dev/null +++ b/src/ocpp20/messages/GetCompositeSchedule20.h @@ -0,0 +1,78 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetCompositeScheduleRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_GETCOMPOSITESCHEDULE_H +#define OPENOCPP_OCPP20_GETCOMPOSITESCHEDULE_H + +#include "IMessageConverter.h" + +#include "ChargingRateUnitEnumType20.h" +#include "CompositeScheduleType20.h" +#include "CustomDataType20.h" +#include "GenericStatusEnumType20.h" +#include "StatusInfoType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the GetCompositeSchedule messages */ +static const std::string GETCOMPOSITESCHEDULE_ACTION = "GetCompositeSchedule"; + +/** @brief GetCompositeScheduleReq message */ +struct GetCompositeScheduleReq +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief Length of the requested schedule in seconds. */ + int duration; + /** @brief */ + ocpp::types::Optional chargingRateUnit; + /** @brief The ID of the EVSE for which the schedule is requested. When evseid=0, the Charging Station will calculate the expected consumption for the grid connection. */ + int evseId; +}; + +/** @brief GetCompositeScheduleConf message */ +struct GetCompositeScheduleConf +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::ocpp20::GenericStatusEnumType status; + /** @brief */ + ocpp::types::Optional statusInfo; + /** @brief */ + ocpp::types::Optional schedule; +}; + +// Message converters +MESSAGE_CONVERTERS(GetCompositeSchedule) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_GETCOMPOSITESCHEDULE_H \ No newline at end of file diff --git a/src/ocpp20/messages/GetDisplayMessages20.cpp b/src/ocpp20/messages/GetDisplayMessages20.cpp new file mode 100644 index 00000000..5ffd6f34 --- /dev/null +++ b/src/ocpp20/messages/GetDisplayMessages20.cpp @@ -0,0 +1,195 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetDisplayMessagesRequest + OCPP 2.0.1 FINAL +*/ + +#include "GetDisplayMessages20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a GetDisplayMessagesReq from a JSON representation */ +bool GetDisplayMessagesReqConverter::fromJson(const rapidjson::Value& json, + GetDisplayMessagesReq& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // id + if (json.HasMember("id")) + { + const rapidjson::Value& id_json = json["id"]; + for (auto it = id_json.Begin(); ret && (it != id_json.End()); ++it) + { + int& item = data.id.emplace_back(); + item = it->GetInt(); + } + } + + // requestId + extract(json, "requestId", data.requestId); + + // priority + if (json.HasMember("priority")) + { + data.priority = ocpp::types::ocpp20::MessagePriorityEnumTypeHelper.fromString(json["priority"].GetString()); + } + + // state + if (json.HasMember("state")) + { + data.state = ocpp::types::ocpp20::MessageStateEnumTypeHelper.fromString(json["state"].GetString()); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a GetDisplayMessagesReq to a JSON representation */ +bool GetDisplayMessagesReqConverter::toJson(const GetDisplayMessagesReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // id + if (!data.id.empty()) + { + + rapidjson::Value id_json(rapidjson::kArrayType); + for (const int& item : data.id) + { + id_json.PushBack(rapidjson::Value(item), *allocator); + } + json.AddMember(rapidjson::StringRef("id"), id_json.Move(), *allocator); + } + + // requestId + fill(json, "requestId", data.requestId); + + // priority + if (data.priority.isSet()) + { + fill(json, "priority", ocpp::types::ocpp20::MessagePriorityEnumTypeHelper.toString(data.priority)); + } + + // state + if (data.state.isSet()) + { + fill(json, "state", ocpp::types::ocpp20::MessageStateEnumTypeHelper.toString(data.state)); + } + + return ret; +} + +/** @brief Convert a GetDisplayMessagesConf from a JSON representation */ +bool GetDisplayMessagesConfConverter::fromJson(const rapidjson::Value& json, + GetDisplayMessagesConf& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // status + data.status = ocpp::types::ocpp20::GetDisplayMessagesStatusEnumTypeHelper.fromString(json["status"].GetString()); + + // statusInfo + if (json.HasMember("statusInfo")) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + ret = ret && statusInfo_converter.fromJson(json["statusInfo"], data.statusInfo, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a GetDisplayMessagesConf to a JSON representation */ +bool GetDisplayMessagesConfConverter::toJson(const GetDisplayMessagesConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // status + fill(json, "status", ocpp::types::ocpp20::GetDisplayMessagesStatusEnumTypeHelper.toString(data.status)); + + // statusInfo + if (data.statusInfo.isSet()) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + statusInfo_converter.setAllocator(allocator); + rapidjson::Document statusInfo_doc(rapidjson::kObjectType); + ret = ret && statusInfo_converter.toJson(data.statusInfo, statusInfo_doc); + json.AddMember(rapidjson::StringRef("statusInfo"), statusInfo_doc.Move(), *allocator); + } + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/GetDisplayMessages20.h b/src/ocpp20/messages/GetDisplayMessages20.h new file mode 100644 index 00000000..b6eb1df6 --- /dev/null +++ b/src/ocpp20/messages/GetDisplayMessages20.h @@ -0,0 +1,78 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetDisplayMessagesRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_GETDISPLAYMESSAGES_H +#define OPENOCPP_OCPP20_GETDISPLAYMESSAGES_H + +#include "IMessageConverter.h" + +#include "CustomDataType20.h" +#include "GetDisplayMessagesStatusEnumType20.h" +#include "MessagePriorityEnumType20.h" +#include "MessageStateEnumType20.h" +#include "StatusInfoType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the GetDisplayMessages messages */ +static const std::string GETDISPLAYMESSAGES_ACTION = "GetDisplayMessages"; + +/** @brief GetDisplayMessagesReq message */ +struct GetDisplayMessagesReq +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief If provided the Charging Station shall return Display Messages of the given ids. This field SHALL NOT contain more ids than set in <<configkey-number-of-display-messages,NumberOfDisplayMessages.maxLimit>> */ + std::vector id; + /** @brief The Id of this request. */ + int requestId; + /** @brief */ + ocpp::types::Optional priority; + /** @brief */ + ocpp::types::Optional state; +}; + +/** @brief GetDisplayMessagesConf message */ +struct GetDisplayMessagesConf +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::ocpp20::GetDisplayMessagesStatusEnumType status; + /** @brief */ + ocpp::types::Optional statusInfo; +}; + +// Message converters +MESSAGE_CONVERTERS(GetDisplayMessages) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_GETDISPLAYMESSAGES_H \ No newline at end of file diff --git a/src/ocpp20/messages/GetInstalledCertificateIds20.cpp b/src/ocpp20/messages/GetInstalledCertificateIds20.cpp new file mode 100644 index 00000000..306c139b --- /dev/null +++ b/src/ocpp20/messages/GetInstalledCertificateIds20.cpp @@ -0,0 +1,195 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetInstalledCertificateIdsRequest + OCPP 2.0.1 FINAL +*/ + +#include "GetInstalledCertificateIds20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a GetInstalledCertificateIdsReq from a JSON representation */ +bool GetInstalledCertificateIdsReqConverter::fromJson(const rapidjson::Value& json, + GetInstalledCertificateIdsReq& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // certificateType + if (json.HasMember("certificateType")) + { + const rapidjson::Value& certificateType_json = json["certificateType"]; + for (auto it = certificateType_json.Begin(); ret && (it != certificateType_json.End()); ++it) + { + ocpp::types::ocpp20::GetCertificateIdUseEnumType& item = data.certificateType.emplace_back(); + item = ocpp::types::ocpp20::GetCertificateIdUseEnumTypeHelper.fromString(it->GetString()); + } + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a GetInstalledCertificateIdsReq to a JSON representation */ +bool GetInstalledCertificateIdsReqConverter::toJson(const GetInstalledCertificateIdsReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // certificateType + if (!data.certificateType.empty()) + { + + rapidjson::Value certificateType_json(rapidjson::kArrayType); + for (const ocpp::types::ocpp20::GetCertificateIdUseEnumType& item : data.certificateType) + { + certificateType_json.PushBack( + rapidjson::Value(ocpp::types::ocpp20::GetCertificateIdUseEnumTypeHelper.toString(item).c_str(), *allocator).Move(), + *allocator); + } + json.AddMember(rapidjson::StringRef("certificateType"), certificateType_json.Move(), *allocator); + } + + return ret; +} + +/** @brief Convert a GetInstalledCertificateIdsConf from a JSON representation */ +bool GetInstalledCertificateIdsConfConverter::fromJson(const rapidjson::Value& json, + GetInstalledCertificateIdsConf& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // status + data.status = ocpp::types::ocpp20::GetInstalledCertificateStatusEnumTypeHelper.fromString(json["status"].GetString()); + + // statusInfo + if (json.HasMember("statusInfo")) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + ret = ret && statusInfo_converter.fromJson(json["statusInfo"], data.statusInfo, error_code, error_message); + } + + // certificateHashDataChain + if (json.HasMember("certificateHashDataChain")) + { + const rapidjson::Value& certificateHashDataChain_json = json["certificateHashDataChain"]; + ocpp::types::ocpp20::CertificateHashDataChainTypeConverter certificateHashDataChain_converter; + for (auto it = certificateHashDataChain_json.Begin(); ret && (it != certificateHashDataChain_json.End()); ++it) + { + ocpp::types::ocpp20::CertificateHashDataChainType& item = data.certificateHashDataChain.emplace_back(); + ret = ret && certificateHashDataChain_converter.fromJson(*it, item, error_code, error_message); + } + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a GetInstalledCertificateIdsConf to a JSON representation */ +bool GetInstalledCertificateIdsConfConverter::toJson(const GetInstalledCertificateIdsConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // status + fill(json, "status", ocpp::types::ocpp20::GetInstalledCertificateStatusEnumTypeHelper.toString(data.status)); + + // statusInfo + if (data.statusInfo.isSet()) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + statusInfo_converter.setAllocator(allocator); + rapidjson::Document statusInfo_doc(rapidjson::kObjectType); + ret = ret && statusInfo_converter.toJson(data.statusInfo, statusInfo_doc); + json.AddMember(rapidjson::StringRef("statusInfo"), statusInfo_doc.Move(), *allocator); + } + + // certificateHashDataChain + if (!data.certificateHashDataChain.empty()) + { + + rapidjson::Value certificateHashDataChain_json(rapidjson::kArrayType); + ocpp::types::ocpp20::CertificateHashDataChainTypeConverter certificateHashDataChain_converter; + certificateHashDataChain_converter.setAllocator(allocator); + for (const ocpp::types::ocpp20::CertificateHashDataChainType& item : data.certificateHashDataChain) + { + rapidjson::Document item_doc(rapidjson::kObjectType); + ret = ret && certificateHashDataChain_converter.toJson(item, item_doc); + certificateHashDataChain_json.PushBack(item_doc.Move(), *allocator); + } + json.AddMember(rapidjson::StringRef("certificateHashDataChain"), certificateHashDataChain_json.Move(), *allocator); + } + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/GetInstalledCertificateIds20.h b/src/ocpp20/messages/GetInstalledCertificateIds20.h new file mode 100644 index 00000000..e32f473a --- /dev/null +++ b/src/ocpp20/messages/GetInstalledCertificateIds20.h @@ -0,0 +1,74 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetInstalledCertificateIdsRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_GETINSTALLEDCERTIFICATEIDS_H +#define OPENOCPP_OCPP20_GETINSTALLEDCERTIFICATEIDS_H + +#include "IMessageConverter.h" + +#include "CertificateHashDataChainType20.h" +#include "CustomDataType20.h" +#include "GetCertificateIdUseEnumType20.h" +#include "GetInstalledCertificateStatusEnumType20.h" +#include "StatusInfoType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the GetInstalledCertificateIds messages */ +static const std::string GETINSTALLEDCERTIFICATEIDS_ACTION = "GetInstalledCertificateIds"; + +/** @brief GetInstalledCertificateIdsReq message */ +struct GetInstalledCertificateIdsReq +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief Indicates the type of certificates requested. When omitted, all certificate types are requested. */ + std::vector certificateType; +}; + +/** @brief GetInstalledCertificateIdsConf message */ +struct GetInstalledCertificateIdsConf +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::ocpp20::GetInstalledCertificateStatusEnumType status; + /** @brief */ + ocpp::types::Optional statusInfo; + /** @brief */ + std::vector certificateHashDataChain; +}; + +// Message converters +MESSAGE_CONVERTERS(GetInstalledCertificateIds) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_GETINSTALLEDCERTIFICATEIDS_H \ No newline at end of file diff --git a/src/ocpp20/messages/GetLocalListVersion20.cpp b/src/ocpp20/messages/GetLocalListVersion20.cpp new file mode 100644 index 00000000..f54455ed --- /dev/null +++ b/src/ocpp20/messages/GetLocalListVersion20.cpp @@ -0,0 +1,125 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetLocalListVersionRequest + OCPP 2.0.1 FINAL +*/ + +#include "GetLocalListVersion20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a GetLocalListVersionReq from a JSON representation */ +bool GetLocalListVersionReqConverter::fromJson(const rapidjson::Value& json, + GetLocalListVersionReq& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a GetLocalListVersionReq to a JSON representation */ +bool GetLocalListVersionReqConverter::toJson(const GetLocalListVersionReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + return ret; +} + +/** @brief Convert a GetLocalListVersionConf from a JSON representation */ +bool GetLocalListVersionConfConverter::fromJson(const rapidjson::Value& json, + GetLocalListVersionConf& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // versionNumber + extract(json, "versionNumber", data.versionNumber); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a GetLocalListVersionConf to a JSON representation */ +bool GetLocalListVersionConfConverter::toJson(const GetLocalListVersionConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // versionNumber + fill(json, "versionNumber", data.versionNumber); + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/GetLocalListVersion20.h b/src/ocpp20/messages/GetLocalListVersion20.h new file mode 100644 index 00000000..3b733821 --- /dev/null +++ b/src/ocpp20/messages/GetLocalListVersion20.h @@ -0,0 +1,64 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetLocalListVersionRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_GETLOCALLISTVERSION_H +#define OPENOCPP_OCPP20_GETLOCALLISTVERSION_H + +#include "IMessageConverter.h" + +#include "CustomDataType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the GetLocalListVersion messages */ +static const std::string GETLOCALLISTVERSION_ACTION = "GetLocalListVersion"; + +/** @brief GetLocalListVersionReq message */ +struct GetLocalListVersionReq +{ + /** @brief */ + ocpp::types::Optional customData; +}; + +/** @brief GetLocalListVersionConf message */ +struct GetLocalListVersionConf +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief This contains the current version number of the local authorization list in the Charging Station. */ + int versionNumber; +}; + +// Message converters +MESSAGE_CONVERTERS(GetLocalListVersion) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_GETLOCALLISTVERSION_H \ No newline at end of file diff --git a/src/ocpp20/messages/GetLog20.cpp b/src/ocpp20/messages/GetLog20.cpp new file mode 100644 index 00000000..f17abcac --- /dev/null +++ b/src/ocpp20/messages/GetLog20.cpp @@ -0,0 +1,177 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetLogRequest + OCPP 2.0.1 FINAL +*/ + +#include "GetLog20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a GetLogReq from a JSON representation */ +bool GetLogReqConverter::fromJson(const rapidjson::Value& json, GetLogReq& data, std::string& error_code, std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // log + ocpp::types::ocpp20::LogParametersTypeConverter log_converter; + ret = ret && log_converter.fromJson(json["log"], data.log, error_code, error_message); + + // logType + data.logType = ocpp::types::ocpp20::LogEnumTypeHelper.fromString(json["logType"].GetString()); + + // requestId + extract(json, "requestId", data.requestId); + + // retries + extract(json, "retries", data.retries); + + // retryInterval + extract(json, "retryInterval", data.retryInterval); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a GetLogReq to a JSON representation */ +bool GetLogReqConverter::toJson(const GetLogReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // log + ocpp::types::ocpp20::LogParametersTypeConverter log_converter; + log_converter.setAllocator(allocator); + rapidjson::Document log_doc(rapidjson::kObjectType); + ret = ret && log_converter.toJson(data.log, log_doc); + json.AddMember(rapidjson::StringRef("log"), log_doc.Move(), *allocator); + + // logType + fill(json, "logType", ocpp::types::ocpp20::LogEnumTypeHelper.toString(data.logType)); + + // requestId + fill(json, "requestId", data.requestId); + + // retries + fill(json, "retries", data.retries); + + // retryInterval + fill(json, "retryInterval", data.retryInterval); + + return ret; +} + +/** @brief Convert a GetLogConf from a JSON representation */ +bool GetLogConfConverter::fromJson(const rapidjson::Value& json, GetLogConf& data, std::string& error_code, std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // status + data.status = ocpp::types::ocpp20::LogStatusEnumTypeHelper.fromString(json["status"].GetString()); + + // statusInfo + if (json.HasMember("statusInfo")) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + ret = ret && statusInfo_converter.fromJson(json["statusInfo"], data.statusInfo, error_code, error_message); + } + + // filename + extract(json, "filename", data.filename); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a GetLogConf to a JSON representation */ +bool GetLogConfConverter::toJson(const GetLogConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // status + fill(json, "status", ocpp::types::ocpp20::LogStatusEnumTypeHelper.toString(data.status)); + + // statusInfo + if (data.statusInfo.isSet()) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + statusInfo_converter.setAllocator(allocator); + rapidjson::Document statusInfo_doc(rapidjson::kObjectType); + ret = ret && statusInfo_converter.toJson(data.statusInfo, statusInfo_doc); + json.AddMember(rapidjson::StringRef("statusInfo"), statusInfo_doc.Move(), *allocator); + } + + // filename + fill(json, "filename", data.filename); + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/GetLog20.h b/src/ocpp20/messages/GetLog20.h new file mode 100644 index 00000000..8011577b --- /dev/null +++ b/src/ocpp20/messages/GetLog20.h @@ -0,0 +1,82 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetLogRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_GETLOG_H +#define OPENOCPP_OCPP20_GETLOG_H + +#include "IMessageConverter.h" + +#include "CustomDataType20.h" +#include "LogEnumType20.h" +#include "LogParametersType20.h" +#include "LogStatusEnumType20.h" +#include "StatusInfoType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the GetLog messages */ +static const std::string GETLOG_ACTION = "GetLog"; + +/** @brief GetLogReq message */ +struct GetLogReq +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::ocpp20::LogParametersType log; + /** @brief */ + ocpp::types::ocpp20::LogEnumType logType; + /** @brief The Id of this request */ + int requestId; + /** @brief This specifies how many times the Charging Station must try to upload the log before giving up. If this field is not present, it is left to Charging Station to decide how many times it wants to retry. */ + ocpp::types::Optional retries; + /** @brief The interval in seconds after which a retry may be attempted. If this field is not present, it is left to Charging Station to decide how long to wait between attempts. */ + ocpp::types::Optional retryInterval; +}; + +/** @brief GetLogConf message */ +struct GetLogConf +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::ocpp20::LogStatusEnumType status; + /** @brief */ + ocpp::types::Optional statusInfo; + /** @brief This contains the name of the log file that will be uploaded. This field is not present when no logging information is available. */ + ocpp::types::Optional> filename; +}; + +// Message converters +MESSAGE_CONVERTERS(GetLog) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_GETLOG_H \ No newline at end of file diff --git a/src/ocpp20/messages/GetMonitoringReport20.cpp b/src/ocpp20/messages/GetMonitoringReport20.cpp new file mode 100644 index 00000000..0883f0af --- /dev/null +++ b/src/ocpp20/messages/GetMonitoringReport20.cpp @@ -0,0 +1,201 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetMonitoringReportRequest + OCPP 2.0.1 FINAL +*/ + +#include "GetMonitoringReport20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a GetMonitoringReportReq from a JSON representation */ +bool GetMonitoringReportReqConverter::fromJson(const rapidjson::Value& json, + GetMonitoringReportReq& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // componentVariable + if (json.HasMember("componentVariable")) + { + const rapidjson::Value& componentVariable_json = json["componentVariable"]; + ocpp::types::ocpp20::ComponentVariableTypeConverter componentVariable_converter; + for (auto it = componentVariable_json.Begin(); ret && (it != componentVariable_json.End()); ++it) + { + ocpp::types::ocpp20::ComponentVariableType& item = data.componentVariable.emplace_back(); + ret = ret && componentVariable_converter.fromJson(*it, item, error_code, error_message); + } + } + + // requestId + extract(json, "requestId", data.requestId); + + // monitoringCriteria + if (json.HasMember("monitoringCriteria")) + { + const rapidjson::Value& monitoringCriteria_json = json["monitoringCriteria"]; + for (auto it = monitoringCriteria_json.Begin(); ret && (it != monitoringCriteria_json.End()); ++it) + { + ocpp::types::ocpp20::MonitoringCriterionEnumType& item = data.monitoringCriteria.emplace_back(); + item = ocpp::types::ocpp20::MonitoringCriterionEnumTypeHelper.fromString(it->GetString()); + } + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a GetMonitoringReportReq to a JSON representation */ +bool GetMonitoringReportReqConverter::toJson(const GetMonitoringReportReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // componentVariable + if (!data.componentVariable.empty()) + { + + rapidjson::Value componentVariable_json(rapidjson::kArrayType); + ocpp::types::ocpp20::ComponentVariableTypeConverter componentVariable_converter; + componentVariable_converter.setAllocator(allocator); + for (const ocpp::types::ocpp20::ComponentVariableType& item : data.componentVariable) + { + rapidjson::Document item_doc(rapidjson::kObjectType); + ret = ret && componentVariable_converter.toJson(item, item_doc); + componentVariable_json.PushBack(item_doc.Move(), *allocator); + } + json.AddMember(rapidjson::StringRef("componentVariable"), componentVariable_json.Move(), *allocator); + } + + // requestId + fill(json, "requestId", data.requestId); + + // monitoringCriteria + if (!data.monitoringCriteria.empty()) + { + + rapidjson::Value monitoringCriteria_json(rapidjson::kArrayType); + for (const ocpp::types::ocpp20::MonitoringCriterionEnumType& item : data.monitoringCriteria) + { + monitoringCriteria_json.PushBack( + rapidjson::Value(ocpp::types::ocpp20::MonitoringCriterionEnumTypeHelper.toString(item).c_str(), *allocator).Move(), + *allocator); + } + json.AddMember(rapidjson::StringRef("monitoringCriteria"), monitoringCriteria_json.Move(), *allocator); + } + + return ret; +} + +/** @brief Convert a GetMonitoringReportConf from a JSON representation */ +bool GetMonitoringReportConfConverter::fromJson(const rapidjson::Value& json, + GetMonitoringReportConf& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // status + data.status = ocpp::types::ocpp20::GenericDeviceModelStatusEnumTypeHelper.fromString(json["status"].GetString()); + + // statusInfo + if (json.HasMember("statusInfo")) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + ret = ret && statusInfo_converter.fromJson(json["statusInfo"], data.statusInfo, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a GetMonitoringReportConf to a JSON representation */ +bool GetMonitoringReportConfConverter::toJson(const GetMonitoringReportConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // status + fill(json, "status", ocpp::types::ocpp20::GenericDeviceModelStatusEnumTypeHelper.toString(data.status)); + + // statusInfo + if (data.statusInfo.isSet()) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + statusInfo_converter.setAllocator(allocator); + rapidjson::Document statusInfo_doc(rapidjson::kObjectType); + ret = ret && statusInfo_converter.toJson(data.statusInfo, statusInfo_doc); + json.AddMember(rapidjson::StringRef("statusInfo"), statusInfo_doc.Move(), *allocator); + } + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/GetMonitoringReport20.h b/src/ocpp20/messages/GetMonitoringReport20.h new file mode 100644 index 00000000..e4b1f777 --- /dev/null +++ b/src/ocpp20/messages/GetMonitoringReport20.h @@ -0,0 +1,76 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetMonitoringReportRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_GETMONITORINGREPORT_H +#define OPENOCPP_OCPP20_GETMONITORINGREPORT_H + +#include "IMessageConverter.h" + +#include "ComponentVariableType20.h" +#include "CustomDataType20.h" +#include "GenericDeviceModelStatusEnumType20.h" +#include "MonitoringCriterionEnumType20.h" +#include "StatusInfoType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the GetMonitoringReport messages */ +static const std::string GETMONITORINGREPORT_ACTION = "GetMonitoringReport"; + +/** @brief GetMonitoringReportReq message */ +struct GetMonitoringReportReq +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + std::vector componentVariable; + /** @brief The Id of the request. */ + int requestId; + /** @brief This field contains criteria for components for which a monitoring report is requested */ + std::vector monitoringCriteria; +}; + +/** @brief GetMonitoringReportConf message */ +struct GetMonitoringReportConf +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::ocpp20::GenericDeviceModelStatusEnumType status; + /** @brief */ + ocpp::types::Optional statusInfo; +}; + +// Message converters +MESSAGE_CONVERTERS(GetMonitoringReport) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_GETMONITORINGREPORT_H \ No newline at end of file diff --git a/src/ocpp20/messages/GetReport20.cpp b/src/ocpp20/messages/GetReport20.cpp new file mode 100644 index 00000000..5f756f51 --- /dev/null +++ b/src/ocpp20/messages/GetReport20.cpp @@ -0,0 +1,198 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetReportRequest + OCPP 2.0.1 FINAL +*/ + +#include "GetReport20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a GetReportReq from a JSON representation */ +bool GetReportReqConverter::fromJson(const rapidjson::Value& json, GetReportReq& data, std::string& error_code, std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // componentVariable + if (json.HasMember("componentVariable")) + { + const rapidjson::Value& componentVariable_json = json["componentVariable"]; + ocpp::types::ocpp20::ComponentVariableTypeConverter componentVariable_converter; + for (auto it = componentVariable_json.Begin(); ret && (it != componentVariable_json.End()); ++it) + { + ocpp::types::ocpp20::ComponentVariableType& item = data.componentVariable.emplace_back(); + ret = ret && componentVariable_converter.fromJson(*it, item, error_code, error_message); + } + } + + // requestId + extract(json, "requestId", data.requestId); + + // componentCriteria + if (json.HasMember("componentCriteria")) + { + const rapidjson::Value& componentCriteria_json = json["componentCriteria"]; + for (auto it = componentCriteria_json.Begin(); ret && (it != componentCriteria_json.End()); ++it) + { + ocpp::types::ocpp20::ComponentCriterionEnumType& item = data.componentCriteria.emplace_back(); + item = ocpp::types::ocpp20::ComponentCriterionEnumTypeHelper.fromString(it->GetString()); + } + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a GetReportReq to a JSON representation */ +bool GetReportReqConverter::toJson(const GetReportReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // componentVariable + if (!data.componentVariable.empty()) + { + + rapidjson::Value componentVariable_json(rapidjson::kArrayType); + ocpp::types::ocpp20::ComponentVariableTypeConverter componentVariable_converter; + componentVariable_converter.setAllocator(allocator); + for (const ocpp::types::ocpp20::ComponentVariableType& item : data.componentVariable) + { + rapidjson::Document item_doc(rapidjson::kObjectType); + ret = ret && componentVariable_converter.toJson(item, item_doc); + componentVariable_json.PushBack(item_doc.Move(), *allocator); + } + json.AddMember(rapidjson::StringRef("componentVariable"), componentVariable_json.Move(), *allocator); + } + + // requestId + fill(json, "requestId", data.requestId); + + // componentCriteria + if (!data.componentCriteria.empty()) + { + + rapidjson::Value componentCriteria_json(rapidjson::kArrayType); + for (const ocpp::types::ocpp20::ComponentCriterionEnumType& item : data.componentCriteria) + { + componentCriteria_json.PushBack( + rapidjson::Value(ocpp::types::ocpp20::ComponentCriterionEnumTypeHelper.toString(item).c_str(), *allocator).Move(), + *allocator); + } + json.AddMember(rapidjson::StringRef("componentCriteria"), componentCriteria_json.Move(), *allocator); + } + + return ret; +} + +/** @brief Convert a GetReportConf from a JSON representation */ +bool GetReportConfConverter::fromJson(const rapidjson::Value& json, + GetReportConf& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // status + data.status = ocpp::types::ocpp20::GenericDeviceModelStatusEnumTypeHelper.fromString(json["status"].GetString()); + + // statusInfo + if (json.HasMember("statusInfo")) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + ret = ret && statusInfo_converter.fromJson(json["statusInfo"], data.statusInfo, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a GetReportConf to a JSON representation */ +bool GetReportConfConverter::toJson(const GetReportConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // status + fill(json, "status", ocpp::types::ocpp20::GenericDeviceModelStatusEnumTypeHelper.toString(data.status)); + + // statusInfo + if (data.statusInfo.isSet()) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + statusInfo_converter.setAllocator(allocator); + rapidjson::Document statusInfo_doc(rapidjson::kObjectType); + ret = ret && statusInfo_converter.toJson(data.statusInfo, statusInfo_doc); + json.AddMember(rapidjson::StringRef("statusInfo"), statusInfo_doc.Move(), *allocator); + } + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/GetReport20.h b/src/ocpp20/messages/GetReport20.h new file mode 100644 index 00000000..c4ba158e --- /dev/null +++ b/src/ocpp20/messages/GetReport20.h @@ -0,0 +1,76 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetReportRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_GETREPORT_H +#define OPENOCPP_OCPP20_GETREPORT_H + +#include "IMessageConverter.h" + +#include "ComponentCriterionEnumType20.h" +#include "ComponentVariableType20.h" +#include "CustomDataType20.h" +#include "GenericDeviceModelStatusEnumType20.h" +#include "StatusInfoType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the GetReport messages */ +static const std::string GETREPORT_ACTION = "GetReport"; + +/** @brief GetReportReq message */ +struct GetReportReq +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + std::vector componentVariable; + /** @brief The Id of the request. */ + int requestId; + /** @brief This field contains criteria for components for which a report is requested */ + std::vector componentCriteria; +}; + +/** @brief GetReportConf message */ +struct GetReportConf +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::ocpp20::GenericDeviceModelStatusEnumType status; + /** @brief */ + ocpp::types::Optional statusInfo; +}; + +// Message converters +MESSAGE_CONVERTERS(GetReport) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_GETREPORT_H \ No newline at end of file diff --git a/src/ocpp20/messages/GetTransactionStatus20.cpp b/src/ocpp20/messages/GetTransactionStatus20.cpp new file mode 100644 index 00000000..77c803fd --- /dev/null +++ b/src/ocpp20/messages/GetTransactionStatus20.cpp @@ -0,0 +1,137 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetTransactionStatusRequest + OCPP 2.0.1 FINAL +*/ + +#include "GetTransactionStatus20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a GetTransactionStatusReq from a JSON representation */ +bool GetTransactionStatusReqConverter::fromJson(const rapidjson::Value& json, + GetTransactionStatusReq& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // transactionId + extract(json, "transactionId", data.transactionId); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a GetTransactionStatusReq to a JSON representation */ +bool GetTransactionStatusReqConverter::toJson(const GetTransactionStatusReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // transactionId + fill(json, "transactionId", data.transactionId); + + return ret; +} + +/** @brief Convert a GetTransactionStatusConf from a JSON representation */ +bool GetTransactionStatusConfConverter::fromJson(const rapidjson::Value& json, + GetTransactionStatusConf& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // ongoingIndicator + extract(json, "ongoingIndicator", data.ongoingIndicator); + + // messagesInQueue + extract(json, "messagesInQueue", data.messagesInQueue); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a GetTransactionStatusConf to a JSON representation */ +bool GetTransactionStatusConfConverter::toJson(const GetTransactionStatusConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // ongoingIndicator + fill(json, "ongoingIndicator", data.ongoingIndicator); + + // messagesInQueue + fill(json, "messagesInQueue", data.messagesInQueue); + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/GetTransactionStatus20.h b/src/ocpp20/messages/GetTransactionStatus20.h new file mode 100644 index 00000000..4f06f871 --- /dev/null +++ b/src/ocpp20/messages/GetTransactionStatus20.h @@ -0,0 +1,68 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetTransactionStatusRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_GETTRANSACTIONSTATUS_H +#define OPENOCPP_OCPP20_GETTRANSACTIONSTATUS_H + +#include "IMessageConverter.h" + +#include "CustomDataType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the GetTransactionStatus messages */ +static const std::string GETTRANSACTIONSTATUS_ACTION = "GetTransactionStatus"; + +/** @brief GetTransactionStatusReq message */ +struct GetTransactionStatusReq +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief The Id of the transaction for which the status is requested. */ + ocpp::types::Optional> transactionId; +}; + +/** @brief GetTransactionStatusConf message */ +struct GetTransactionStatusConf +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief Whether the transaction is still ongoing. */ + ocpp::types::Optional ongoingIndicator; + /** @brief Whether there are still message to be delivered. */ + bool messagesInQueue; +}; + +// Message converters +MESSAGE_CONVERTERS(GetTransactionStatus) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_GETTRANSACTIONSTATUS_H \ No newline at end of file diff --git a/src/ocpp20/messages/GetVariables20.cpp b/src/ocpp20/messages/GetVariables20.cpp new file mode 100644 index 00000000..30d53f23 --- /dev/null +++ b/src/ocpp20/messages/GetVariables20.cpp @@ -0,0 +1,169 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetVariablesRequest + OCPP 2.0.1 FINAL +*/ + +#include "GetVariables20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a GetVariablesReq from a JSON representation */ +bool GetVariablesReqConverter::fromJson(const rapidjson::Value& json, + GetVariablesReq& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // getVariableData + if (json.HasMember("getVariableData")) + { + const rapidjson::Value& getVariableData_json = json["getVariableData"]; + ocpp::types::ocpp20::GetVariableDataTypeConverter getVariableData_converter; + for (auto it = getVariableData_json.Begin(); ret && (it != getVariableData_json.End()); ++it) + { + ocpp::types::ocpp20::GetVariableDataType& item = data.getVariableData.emplace_back(); + ret = ret && getVariableData_converter.fromJson(*it, item, error_code, error_message); + } + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a GetVariablesReq to a JSON representation */ +bool GetVariablesReqConverter::toJson(const GetVariablesReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // getVariableData + + rapidjson::Value getVariableData_json(rapidjson::kArrayType); + ocpp::types::ocpp20::GetVariableDataTypeConverter getVariableData_converter; + getVariableData_converter.setAllocator(allocator); + for (const ocpp::types::ocpp20::GetVariableDataType& item : data.getVariableData) + { + rapidjson::Document item_doc(rapidjson::kObjectType); + ret = ret && getVariableData_converter.toJson(item, item_doc); + getVariableData_json.PushBack(item_doc.Move(), *allocator); + } + json.AddMember(rapidjson::StringRef("getVariableData"), getVariableData_json.Move(), *allocator); + + return ret; +} + +/** @brief Convert a GetVariablesConf from a JSON representation */ +bool GetVariablesConfConverter::fromJson(const rapidjson::Value& json, + GetVariablesConf& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // getVariableResult + if (json.HasMember("getVariableResult")) + { + const rapidjson::Value& getVariableResult_json = json["getVariableResult"]; + ocpp::types::ocpp20::GetVariableResultTypeConverter getVariableResult_converter; + for (auto it = getVariableResult_json.Begin(); ret && (it != getVariableResult_json.End()); ++it) + { + ocpp::types::ocpp20::GetVariableResultType& item = data.getVariableResult.emplace_back(); + ret = ret && getVariableResult_converter.fromJson(*it, item, error_code, error_message); + } + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a GetVariablesConf to a JSON representation */ +bool GetVariablesConfConverter::toJson(const GetVariablesConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // getVariableResult + + rapidjson::Value getVariableResult_json(rapidjson::kArrayType); + ocpp::types::ocpp20::GetVariableResultTypeConverter getVariableResult_converter; + getVariableResult_converter.setAllocator(allocator); + for (const ocpp::types::ocpp20::GetVariableResultType& item : data.getVariableResult) + { + rapidjson::Document item_doc(rapidjson::kObjectType); + ret = ret && getVariableResult_converter.toJson(item, item_doc); + getVariableResult_json.PushBack(item_doc.Move(), *allocator); + } + json.AddMember(rapidjson::StringRef("getVariableResult"), getVariableResult_json.Move(), *allocator); + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/GetVariables20.h b/src/ocpp20/messages/GetVariables20.h new file mode 100644 index 00000000..e165e1e5 --- /dev/null +++ b/src/ocpp20/messages/GetVariables20.h @@ -0,0 +1,68 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetVariablesRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_GETVARIABLES_H +#define OPENOCPP_OCPP20_GETVARIABLES_H + +#include "IMessageConverter.h" + +#include "CustomDataType20.h" +#include "GetVariableDataType20.h" +#include "GetVariableResultType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the GetVariables messages */ +static const std::string GETVARIABLES_ACTION = "GetVariables"; + +/** @brief GetVariablesReq message */ +struct GetVariablesReq +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + std::vector getVariableData; +}; + +/** @brief GetVariablesConf message */ +struct GetVariablesConf +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + std::vector getVariableResult; +}; + +// Message converters +MESSAGE_CONVERTERS(GetVariables) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_GETVARIABLES_H \ No newline at end of file diff --git a/src/ocpp20/messages/Heartbeat20.cpp b/src/ocpp20/messages/Heartbeat20.cpp new file mode 100644 index 00000000..25cafea9 --- /dev/null +++ b/src/ocpp20/messages/Heartbeat20.cpp @@ -0,0 +1,122 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:HeartbeatRequest + OCPP 2.0.1 FINAL +*/ + +#include "Heartbeat20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a HeartbeatReq from a JSON representation */ +bool HeartbeatReqConverter::fromJson(const rapidjson::Value& json, HeartbeatReq& data, std::string& error_code, std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a HeartbeatReq to a JSON representation */ +bool HeartbeatReqConverter::toJson(const HeartbeatReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + return ret; +} + +/** @brief Convert a HeartbeatConf from a JSON representation */ +bool HeartbeatConfConverter::fromJson(const rapidjson::Value& json, + HeartbeatConf& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // currentTime + ret = ret && extract(json, "currentTime", data.currentTime, error_message); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a HeartbeatConf to a JSON representation */ +bool HeartbeatConfConverter::toJson(const HeartbeatConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // currentTime + fill(json, "currentTime", data.currentTime); + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/Heartbeat20.h b/src/ocpp20/messages/Heartbeat20.h new file mode 100644 index 00000000..6b39d28e --- /dev/null +++ b/src/ocpp20/messages/Heartbeat20.h @@ -0,0 +1,64 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:HeartbeatRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_HEARTBEAT_H +#define OPENOCPP_OCPP20_HEARTBEAT_H + +#include "IMessageConverter.h" + +#include "CustomDataType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the Heartbeat messages */ +static const std::string HEARTBEAT_ACTION = "Heartbeat"; + +/** @brief HeartbeatReq message */ +struct HeartbeatReq +{ + /** @brief */ + ocpp::types::Optional customData; +}; + +/** @brief HeartbeatConf message */ +struct HeartbeatConf +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief Contains the current time of the CSMS. */ + ocpp::types::DateTime currentTime; +}; + +// Message converters +MESSAGE_CONVERTERS(Heartbeat) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_HEARTBEAT_H \ No newline at end of file diff --git a/src/ocpp20/messages/InstallCertificate20.cpp b/src/ocpp20/messages/InstallCertificate20.cpp new file mode 100644 index 00000000..6f72cdf8 --- /dev/null +++ b/src/ocpp20/messages/InstallCertificate20.cpp @@ -0,0 +1,154 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:InstallCertificateRequest + OCPP 2.0.1 FINAL +*/ + +#include "InstallCertificate20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a InstallCertificateReq from a JSON representation */ +bool InstallCertificateReqConverter::fromJson(const rapidjson::Value& json, + InstallCertificateReq& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // certificateType + data.certificateType = ocpp::types::ocpp20::InstallCertificateUseEnumTypeHelper.fromString(json["certificateType"].GetString()); + + // certificate + extract(json, "certificate", data.certificate); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a InstallCertificateReq to a JSON representation */ +bool InstallCertificateReqConverter::toJson(const InstallCertificateReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // certificateType + fill(json, "certificateType", ocpp::types::ocpp20::InstallCertificateUseEnumTypeHelper.toString(data.certificateType)); + + // certificate + fill(json, "certificate", data.certificate); + + return ret; +} + +/** @brief Convert a InstallCertificateConf from a JSON representation */ +bool InstallCertificateConfConverter::fromJson(const rapidjson::Value& json, + InstallCertificateConf& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // status + data.status = ocpp::types::ocpp20::InstallCertificateStatusEnumTypeHelper.fromString(json["status"].GetString()); + + // statusInfo + if (json.HasMember("statusInfo")) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + ret = ret && statusInfo_converter.fromJson(json["statusInfo"], data.statusInfo, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a InstallCertificateConf to a JSON representation */ +bool InstallCertificateConfConverter::toJson(const InstallCertificateConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // status + fill(json, "status", ocpp::types::ocpp20::InstallCertificateStatusEnumTypeHelper.toString(data.status)); + + // statusInfo + if (data.statusInfo.isSet()) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + statusInfo_converter.setAllocator(allocator); + rapidjson::Document statusInfo_doc(rapidjson::kObjectType); + ret = ret && statusInfo_converter.toJson(data.statusInfo, statusInfo_doc); + json.AddMember(rapidjson::StringRef("statusInfo"), statusInfo_doc.Move(), *allocator); + } + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/InstallCertificate20.h b/src/ocpp20/messages/InstallCertificate20.h new file mode 100644 index 00000000..254041ac --- /dev/null +++ b/src/ocpp20/messages/InstallCertificate20.h @@ -0,0 +1,73 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:InstallCertificateRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_INSTALLCERTIFICATE_H +#define OPENOCPP_OCPP20_INSTALLCERTIFICATE_H + +#include "IMessageConverter.h" + +#include "CustomDataType20.h" +#include "InstallCertificateStatusEnumType20.h" +#include "InstallCertificateUseEnumType20.h" +#include "StatusInfoType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the InstallCertificate messages */ +static const std::string INSTALLCERTIFICATE_ACTION = "InstallCertificate"; + +/** @brief InstallCertificateReq message */ +struct InstallCertificateReq +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::ocpp20::InstallCertificateUseEnumType certificateType; + /** @brief A PEM encoded X.509 certificate. */ + ocpp::types::CiStringType<5500u> certificate; +}; + +/** @brief InstallCertificateConf message */ +struct InstallCertificateConf +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::ocpp20::InstallCertificateStatusEnumType status; + /** @brief */ + ocpp::types::Optional statusInfo; +}; + +// Message converters +MESSAGE_CONVERTERS(InstallCertificate) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_INSTALLCERTIFICATE_H \ No newline at end of file diff --git a/src/ocpp20/messages/LogStatusNotification20.cpp b/src/ocpp20/messages/LogStatusNotification20.cpp new file mode 100644 index 00000000..2ca9ac57 --- /dev/null +++ b/src/ocpp20/messages/LogStatusNotification20.cpp @@ -0,0 +1,131 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:LogStatusNotificationRequest + OCPP 2.0.1 FINAL +*/ + +#include "LogStatusNotification20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a LogStatusNotificationReq from a JSON representation */ +bool LogStatusNotificationReqConverter::fromJson(const rapidjson::Value& json, + LogStatusNotificationReq& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // status + data.status = ocpp::types::ocpp20::UploadLogStatusEnumTypeHelper.fromString(json["status"].GetString()); + + // requestId + extract(json, "requestId", data.requestId); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a LogStatusNotificationReq to a JSON representation */ +bool LogStatusNotificationReqConverter::toJson(const LogStatusNotificationReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // status + fill(json, "status", ocpp::types::ocpp20::UploadLogStatusEnumTypeHelper.toString(data.status)); + + // requestId + fill(json, "requestId", data.requestId); + + return ret; +} + +/** @brief Convert a LogStatusNotificationConf from a JSON representation */ +bool LogStatusNotificationConfConverter::fromJson(const rapidjson::Value& json, + LogStatusNotificationConf& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a LogStatusNotificationConf to a JSON representation */ +bool LogStatusNotificationConfConverter::toJson(const LogStatusNotificationConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/LogStatusNotification20.h b/src/ocpp20/messages/LogStatusNotification20.h new file mode 100644 index 00000000..ee20a7ec --- /dev/null +++ b/src/ocpp20/messages/LogStatusNotification20.h @@ -0,0 +1,68 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:LogStatusNotificationRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_LOGSTATUSNOTIFICATION_H +#define OPENOCPP_OCPP20_LOGSTATUSNOTIFICATION_H + +#include "IMessageConverter.h" + +#include "CustomDataType20.h" +#include "UploadLogStatusEnumType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the LogStatusNotification messages */ +static const std::string LOGSTATUSNOTIFICATION_ACTION = "LogStatusNotification"; + +/** @brief LogStatusNotificationReq message */ +struct LogStatusNotificationReq +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::ocpp20::UploadLogStatusEnumType status; + /** @brief The request id that was provided in GetLogRequest that started this log upload. This field is mandatory, +unless the message was triggered by a TriggerMessageRequest AND there is no log upload ongoing. */ + ocpp::types::Optional requestId; +}; + +/** @brief LogStatusNotificationConf message */ +struct LogStatusNotificationConf +{ + /** @brief */ + ocpp::types::Optional customData; +}; + +// Message converters +MESSAGE_CONVERTERS(LogStatusNotification) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_LOGSTATUSNOTIFICATION_H \ No newline at end of file diff --git a/src/ocpp20/messages/MessagesConverter20.cpp b/src/ocpp20/messages/MessagesConverter20.cpp new file mode 100644 index 00000000..34667142 --- /dev/null +++ b/src/ocpp20/messages/MessagesConverter20.cpp @@ -0,0 +1,245 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +#include "MessagesConverter20.h" +#include "Authorize20.h" +#include "BootNotification20.h" +#include "CancelReservation20.h" +#include "CertificateSigned20.h" +#include "ChangeAvailability20.h" +#include "ClearCache20.h" +#include "ClearChargingProfile20.h" +#include "ClearDisplayMessage20.h" +#include "ClearVariableMonitoring20.h" +#include "ClearedChargingLimit20.h" +#include "CostUpdated20.h" +#include "CustomerInformation20.h" +#include "DataTransfer20.h" +#include "DeleteCertificate20.h" +#include "FirmwareStatusNotification20.h" +#include "Get15118EVCertificate20.h" +#include "GetBaseReport20.h" +#include "GetCertificateStatus20.h" +#include "GetChargingProfiles20.h" +#include "GetCompositeSchedule20.h" +#include "GetDisplayMessages20.h" +#include "GetInstalledCertificateIds20.h" +#include "GetLocalListVersion20.h" +#include "GetLog20.h" +#include "GetMonitoringReport20.h" +#include "GetReport20.h" +#include "GetTransactionStatus20.h" +#include "GetVariables20.h" +#include "Heartbeat20.h" +#include "InstallCertificate20.h" +#include "LogStatusNotification20.h" +#include "MeterValues20.h" +#include "NotifyChargingLimit20.h" +#include "NotifyCustomerInformation20.h" +#include "NotifyDisplayMessages20.h" +#include "NotifyEVChargingNeeds20.h" +#include "NotifyEVChargingSchedule20.h" +#include "NotifyEvent20.h" +#include "NotifyMonitoringReport20.h" +#include "NotifyReport20.h" +#include "PublishFirmware20.h" +#include "PublishFirmwareStatusNotification20.h" +#include "ReportChargingProfiles20.h" +#include "RequestStartTransaction20.h" +#include "RequestStopTransaction20.h" +#include "ReservationStatusUpdate20.h" +#include "ReserveNow20.h" +#include "Reset20.h" +#include "SecurityEventNotification20.h" +#include "SendLocalList20.h" +#include "SetChargingProfile20.h" +#include "SetDisplayMessage20.h" +#include "SetMonitoringBase20.h" +#include "SetMonitoringLevel20.h" +#include "SetNetworkProfile20.h" +#include "SetVariableMonitoring20.h" +#include "SetVariables20.h" +#include "SignCertificate20.h" +#include "StatusNotification20.h" +#include "TransactionEvent20.h" +#include "TriggerMessage20.h" +#include "UnlockConnector20.h" +#include "UnpublishFirmware20.h" +#include "UpdateFirmware20.h" + +/** @brief Macro to register a message converter for an OCPP action */ +#define REGISTER_CONVERTER(action) \ + registerRequestConverter(#action, *new action##ReqConverter()); \ + registerResponseConverter(#action, *new action##ConfConverter()) + +/** @brief Macro to delete a message converter for an OCPP action */ +#define DELETE_CONVERTER(action) \ + deleteRequestConverter(#action); \ + deleteResponseConverter(#action) + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Constructor */ +MessagesConverter20::MessagesConverter20() +{ + // Register converters + REGISTER_CONVERTER(CancelReservation); + REGISTER_CONVERTER(CertificateSigned); + REGISTER_CONVERTER(ChangeAvailability); + REGISTER_CONVERTER(ClearCache); + REGISTER_CONVERTER(ClearChargingProfile); + REGISTER_CONVERTER(ClearDisplayMessage); + REGISTER_CONVERTER(ClearVariableMonitoring); + REGISTER_CONVERTER(CustomerInformation); + REGISTER_CONVERTER(DataTransfer); + REGISTER_CONVERTER(DeleteCertificate); + REGISTER_CONVERTER(Get15118EVCertificate); + REGISTER_CONVERTER(GetBaseReport); + REGISTER_CONVERTER(GetCertificateStatus); + REGISTER_CONVERTER(GetChargingProfiles); + REGISTER_CONVERTER(GetCompositeSchedule); + REGISTER_CONVERTER(GetDisplayMessages); + REGISTER_CONVERTER(GetInstalledCertificateIds); + REGISTER_CONVERTER(GetLocalListVersion); + REGISTER_CONVERTER(GetLog); + REGISTER_CONVERTER(GetMonitoringReport); + REGISTER_CONVERTER(GetReport); + REGISTER_CONVERTER(GetTransactionStatus); + REGISTER_CONVERTER(GetVariables); + REGISTER_CONVERTER(InstallCertificate); + REGISTER_CONVERTER(PublishFirmware); + REGISTER_CONVERTER(RequestStartTransaction); + REGISTER_CONVERTER(RequestStopTransaction); + REGISTER_CONVERTER(ReserveNow); + REGISTER_CONVERTER(Reset); + REGISTER_CONVERTER(SendLocalList); + REGISTER_CONVERTER(SetChargingProfile); + REGISTER_CONVERTER(SetDisplayMessage); + REGISTER_CONVERTER(SetMonitoringBase); + REGISTER_CONVERTER(SetMonitoringLevel); + REGISTER_CONVERTER(SetNetworkProfile); + REGISTER_CONVERTER(SetVariableMonitoring); + REGISTER_CONVERTER(SetVariables); + REGISTER_CONVERTER(TriggerMessage); + REGISTER_CONVERTER(UnlockConnector); + REGISTER_CONVERTER(UnpublishFirmware); + REGISTER_CONVERTER(UpdateFirmware); + REGISTER_CONVERTER(BootNotification); + REGISTER_CONVERTER(Authorize); + REGISTER_CONVERTER(ClearedChargingLimit); + REGISTER_CONVERTER(CostUpdated); + REGISTER_CONVERTER(DataTransfer); + REGISTER_CONVERTER(FirmwareStatusNotification); + REGISTER_CONVERTER(Heartbeat); + REGISTER_CONVERTER(LogStatusNotification); + REGISTER_CONVERTER(MeterValues); + REGISTER_CONVERTER(NotifyChargingLimit); + REGISTER_CONVERTER(NotifyCustomerInformation); + REGISTER_CONVERTER(NotifyDisplayMessages); + REGISTER_CONVERTER(NotifyEVChargingNeeds); + REGISTER_CONVERTER(NotifyEVChargingSchedule); + REGISTER_CONVERTER(NotifyEvent); + REGISTER_CONVERTER(NotifyMonitoringReport); + REGISTER_CONVERTER(NotifyReport); + REGISTER_CONVERTER(PublishFirmwareStatusNotification); + REGISTER_CONVERTER(ReportChargingProfiles); + REGISTER_CONVERTER(ReservationStatusUpdate); + REGISTER_CONVERTER(SecurityEventNotification); + REGISTER_CONVERTER(SignCertificate); + REGISTER_CONVERTER(StatusNotification); + REGISTER_CONVERTER(TransactionEvent); +} +/** @brief Destructor */ +MessagesConverter20::~MessagesConverter20() +{ + // Free memory + DELETE_CONVERTER(CancelReservation); + DELETE_CONVERTER(CertificateSigned); + DELETE_CONVERTER(ChangeAvailability); + DELETE_CONVERTER(ClearCache); + DELETE_CONVERTER(ClearChargingProfile); + DELETE_CONVERTER(ClearDisplayMessage); + DELETE_CONVERTER(ClearVariableMonitoring); + DELETE_CONVERTER(CustomerInformation); + DELETE_CONVERTER(DataTransfer); + DELETE_CONVERTER(DeleteCertificate); + DELETE_CONVERTER(Get15118EVCertificate); + DELETE_CONVERTER(GetBaseReport); + DELETE_CONVERTER(GetCertificateStatus); + DELETE_CONVERTER(GetChargingProfiles); + DELETE_CONVERTER(GetCompositeSchedule); + DELETE_CONVERTER(GetDisplayMessages); + DELETE_CONVERTER(GetInstalledCertificateIds); + DELETE_CONVERTER(GetLocalListVersion); + DELETE_CONVERTER(GetLog); + DELETE_CONVERTER(GetMonitoringReport); + DELETE_CONVERTER(GetReport); + DELETE_CONVERTER(GetTransactionStatus); + DELETE_CONVERTER(GetVariables); + DELETE_CONVERTER(InstallCertificate); + DELETE_CONVERTER(PublishFirmware); + DELETE_CONVERTER(RequestStartTransaction); + DELETE_CONVERTER(RequestStopTransaction); + DELETE_CONVERTER(ReserveNow); + DELETE_CONVERTER(Reset); + DELETE_CONVERTER(SendLocalList); + DELETE_CONVERTER(SetChargingProfile); + DELETE_CONVERTER(SetDisplayMessage); + DELETE_CONVERTER(SetMonitoringBase); + DELETE_CONVERTER(SetMonitoringLevel); + DELETE_CONVERTER(SetNetworkProfile); + DELETE_CONVERTER(SetVariableMonitoring); + DELETE_CONVERTER(SetVariables); + DELETE_CONVERTER(TriggerMessage); + DELETE_CONVERTER(UnlockConnector); + DELETE_CONVERTER(UnpublishFirmware); + DELETE_CONVERTER(UpdateFirmware); + DELETE_CONVERTER(BootNotification); + DELETE_CONVERTER(Authorize); + DELETE_CONVERTER(ClearedChargingLimit); + DELETE_CONVERTER(CostUpdated); + DELETE_CONVERTER(DataTransfer); + DELETE_CONVERTER(FirmwareStatusNotification); + DELETE_CONVERTER(Heartbeat); + DELETE_CONVERTER(LogStatusNotification); + DELETE_CONVERTER(MeterValues); + DELETE_CONVERTER(NotifyChargingLimit); + DELETE_CONVERTER(NotifyCustomerInformation); + DELETE_CONVERTER(NotifyDisplayMessages); + DELETE_CONVERTER(NotifyEVChargingNeeds); + DELETE_CONVERTER(NotifyEVChargingSchedule); + DELETE_CONVERTER(NotifyEvent); + DELETE_CONVERTER(NotifyMonitoringReport); + DELETE_CONVERTER(NotifyReport); + DELETE_CONVERTER(PublishFirmwareStatusNotification); + DELETE_CONVERTER(ReportChargingProfiles); + DELETE_CONVERTER(ReservationStatusUpdate); + DELETE_CONVERTER(SecurityEventNotification); + DELETE_CONVERTER(SignCertificate); + DELETE_CONVERTER(StatusNotification); + DELETE_CONVERTER(TransactionEvent); +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/MessagesConverter20.h b/src/ocpp20/messages/MessagesConverter20.h new file mode 100644 index 00000000..04a06595 --- /dev/null +++ b/src/ocpp20/messages/MessagesConverter20.h @@ -0,0 +1,45 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +#ifndef OPENOCPP_OCPP20_MESSAGESCONVERTER_H +#define OPENOCPP_OCPP20_MESSAGESCONVERTER_H + +#include "GenericMessagesConverter.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Stores all the needed message converters */ +class MessagesConverter20 : public GenericMessagesConverter +{ + public: + /** @brief Constructor */ + MessagesConverter20(); + /** @brief Destructor */ + virtual ~MessagesConverter20(); +}; + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_MESSAGESCONVERTER_H diff --git a/src/ocpp20/messages/MessagesValidator20.cpp b/src/ocpp20/messages/MessagesValidator20.cpp new file mode 100644 index 00000000..048f8e67 --- /dev/null +++ b/src/ocpp20/messages/MessagesValidator20.cpp @@ -0,0 +1,249 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* Generated by json2cpp */ + +#include "MessagesValidator20.h" +#include "Authorize20.h" +#include "BootNotification20.h" +#include "CancelReservation20.h" +#include "CertificateSigned20.h" +#include "ChangeAvailability20.h" +#include "ClearCache20.h" +#include "ClearChargingProfile20.h" +#include "ClearDisplayMessage20.h" +#include "ClearVariableMonitoring20.h" +#include "ClearedChargingLimit20.h" +#include "CostUpdated20.h" +#include "CustomerInformation20.h" +#include "DataTransfer20.h" +#include "DeleteCertificate20.h" +#include "FirmwareStatusNotification20.h" +#include "Get15118EVCertificate20.h" +#include "GetBaseReport20.h" +#include "GetCertificateStatus20.h" +#include "GetChargingProfiles20.h" +#include "GetCompositeSchedule20.h" +#include "GetDisplayMessages20.h" +#include "GetInstalledCertificateIds20.h" +#include "GetLocalListVersion20.h" +#include "GetLog20.h" +#include "GetMonitoringReport20.h" +#include "GetReport20.h" +#include "GetTransactionStatus20.h" +#include "GetVariables20.h" +#include "Heartbeat20.h" +#include "InstallCertificate20.h" +#include "LogStatusNotification20.h" +#include "Logger.h" +#include "MeterValues20.h" +#include "NotifyChargingLimit20.h" +#include "NotifyCustomerInformation20.h" +#include "NotifyDisplayMessages20.h" +#include "NotifyEVChargingNeeds20.h" +#include "NotifyEVChargingSchedule20.h" +#include "NotifyEvent20.h" +#include "NotifyMonitoringReport20.h" +#include "NotifyReport20.h" +#include "PublishFirmware20.h" +#include "PublishFirmwareStatusNotification20.h" +#include "ReportChargingProfiles20.h" +#include "RequestStartTransaction20.h" +#include "RequestStopTransaction20.h" +#include "ReservationStatusUpdate20.h" +#include "ReserveNow20.h" +#include "Reset20.h" +#include "SecurityEventNotification20.h" +#include "SendLocalList20.h" +#include "SetChargingProfile20.h" +#include "SetDisplayMessage20.h" +#include "SetMonitoringBase20.h" +#include "SetMonitoringLevel20.h" +#include "SetNetworkProfile20.h" +#include "SetVariableMonitoring20.h" +#include "SetVariables20.h" +#include "SignCertificate20.h" +#include "StatusNotification20.h" +#include "TransactionEvent20.h" +#include "TriggerMessage20.h" +#include "UnlockConnector20.h" +#include "UnpublishFirmware20.h" +#include "UpdateFirmware20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Constructor */ +MessagesValidator20::MessagesValidator20() : m_req_validators(), m_resp_validators() { } + +/** @brief Destructor */ +MessagesValidator20::~MessagesValidator20() { } + +/** @brief Load the messages validators */ +bool MessagesValidator20::load(const std::string& schemas_path) +{ + bool ret = true; + + // Load validators for all the messages + m_req_validators.clear(); + m_resp_validators.clear(); + ret = addValidator(schemas_path, CANCELRESERVATION_ACTION) && ret; + ret = addValidator(schemas_path, CERTIFICATESIGNED_ACTION) && ret; + ret = addValidator(schemas_path, CHANGEAVAILABILITY_ACTION) && ret; + ret = addValidator(schemas_path, CLEARCACHE_ACTION) && ret; + ret = addValidator(schemas_path, CLEARCHARGINGPROFILE_ACTION) && ret; + ret = addValidator(schemas_path, CLEARDISPLAYMESSAGE_ACTION) && ret; + ret = addValidator(schemas_path, CLEARVARIABLEMONITORING_ACTION) && ret; + ret = addValidator(schemas_path, CUSTOMERINFORMATION_ACTION) && ret; + ret = addValidator(schemas_path, DATATRANSFER_ACTION) && ret; + ret = addValidator(schemas_path, DELETECERTIFICATE_ACTION) && ret; + ret = addValidator(schemas_path, GET15118EVCERTIFICATE_ACTION) && ret; + ret = addValidator(schemas_path, GETBASEREPORT_ACTION) && ret; + ret = addValidator(schemas_path, GETCERTIFICATESTATUS_ACTION) && ret; + ret = addValidator(schemas_path, GETCHARGINGPROFILES_ACTION) && ret; + ret = addValidator(schemas_path, GETCOMPOSITESCHEDULE_ACTION) && ret; + ret = addValidator(schemas_path, GETDISPLAYMESSAGES_ACTION) && ret; + ret = addValidator(schemas_path, GETINSTALLEDCERTIFICATEIDS_ACTION) && ret; + ret = addValidator(schemas_path, GETLOCALLISTVERSION_ACTION) && ret; + ret = addValidator(schemas_path, GETLOG_ACTION) && ret; + ret = addValidator(schemas_path, GETMONITORINGREPORT_ACTION) && ret; + ret = addValidator(schemas_path, GETREPORT_ACTION) && ret; + ret = addValidator(schemas_path, GETTRANSACTIONSTATUS_ACTION) && ret; + ret = addValidator(schemas_path, GETVARIABLES_ACTION) && ret; + ret = addValidator(schemas_path, INSTALLCERTIFICATE_ACTION) && ret; + ret = addValidator(schemas_path, PUBLISHFIRMWARE_ACTION) && ret; + ret = addValidator(schemas_path, REQUESTSTARTTRANSACTION_ACTION) && ret; + ret = addValidator(schemas_path, REQUESTSTOPTRANSACTION_ACTION) && ret; + ret = addValidator(schemas_path, RESERVENOW_ACTION) && ret; + ret = addValidator(schemas_path, RESET_ACTION) && ret; + ret = addValidator(schemas_path, SENDLOCALLIST_ACTION) && ret; + ret = addValidator(schemas_path, SETCHARGINGPROFILE_ACTION) && ret; + ret = addValidator(schemas_path, SETDISPLAYMESSAGE_ACTION) && ret; + ret = addValidator(schemas_path, SETMONITORINGBASE_ACTION) && ret; + ret = addValidator(schemas_path, SETMONITORINGLEVEL_ACTION) && ret; + ret = addValidator(schemas_path, SETNETWORKPROFILE_ACTION) && ret; + ret = addValidator(schemas_path, SETVARIABLEMONITORING_ACTION) && ret; + ret = addValidator(schemas_path, SETVARIABLES_ACTION) && ret; + ret = addValidator(schemas_path, TRIGGERMESSAGE_ACTION) && ret; + ret = addValidator(schemas_path, UNLOCKCONNECTOR_ACTION) && ret; + ret = addValidator(schemas_path, UNPUBLISHFIRMWARE_ACTION) && ret; + ret = addValidator(schemas_path, UPDATEFIRMWARE_ACTION) && ret; + ret = addValidator(schemas_path, BOOTNOTIFICATION_ACTION) && ret; + ret = addValidator(schemas_path, AUTHORIZE_ACTION) && ret; + ret = addValidator(schemas_path, CLEAREDCHARGINGLIMIT_ACTION) && ret; + ret = addValidator(schemas_path, COSTUPDATED_ACTION) && ret; + ret = addValidator(schemas_path, DATATRANSFER_ACTION) && ret; + ret = addValidator(schemas_path, FIRMWARESTATUSNOTIFICATION_ACTION) && ret; + ret = addValidator(schemas_path, HEARTBEAT_ACTION) && ret; + ret = addValidator(schemas_path, LOGSTATUSNOTIFICATION_ACTION) && ret; + ret = addValidator(schemas_path, METERVALUES_ACTION) && ret; + ret = addValidator(schemas_path, NOTIFYCHARGINGLIMIT_ACTION) && ret; + ret = addValidator(schemas_path, NOTIFYCUSTOMERINFORMATION_ACTION) && ret; + ret = addValidator(schemas_path, NOTIFYDISPLAYMESSAGES_ACTION) && ret; + ret = addValidator(schemas_path, NOTIFYEVCHARGINGNEEDS_ACTION) && ret; + ret = addValidator(schemas_path, NOTIFYEVCHARGINGSCHEDULE_ACTION) && ret; + ret = addValidator(schemas_path, NOTIFYEVENT_ACTION) && ret; + ret = addValidator(schemas_path, NOTIFYMONITORINGREPORT_ACTION) && ret; + ret = addValidator(schemas_path, NOTIFYREPORT_ACTION) && ret; + ret = addValidator(schemas_path, PUBLISHFIRMWARESTATUSNOTIFICATION_ACTION) && ret; + ret = addValidator(schemas_path, REPORTCHARGINGPROFILES_ACTION) && ret; + ret = addValidator(schemas_path, RESERVATIONSTATUSUPDATE_ACTION) && ret; + ret = addValidator(schemas_path, SECURITYEVENTNOTIFICATION_ACTION) && ret; + ret = addValidator(schemas_path, SIGNCERTIFICATE_ACTION) && ret; + ret = addValidator(schemas_path, STATUSNOTIFICATION_ACTION) && ret; + ret = addValidator(schemas_path, TRANSACTIONEVENT_ACTION) && ret; + + return ret; +} + +/** @brief Get the message validator corresponding to a given action */ +ocpp::json::JsonValidator* MessagesValidator20::getValidator(const std::string& action, bool is_req) const +{ + ocpp::json::JsonValidator* validator = nullptr; + + // Get validators list + const std::unordered_map>* validators = &m_resp_validators; + if (is_req) + { + validators = &m_req_validators; + } + + auto iter = validators->find(action); + if (iter != validators->cend()) + { + validator = iter->second.get(); + } + + return validator; +} + +/** @brief Add a message validator for both request and response */ +bool MessagesValidator20::addValidator(const std::string& schemas_path, const std::string& action) +{ + bool ret; + + // Add validator for request + std::filesystem::path req_filepath(schemas_path); + req_filepath.append(action + "Request.json"); + ret = addValidator(req_filepath, action, true); + + // Add validator for response + std::filesystem::path resp_filepath(schemas_path); + resp_filepath.append(action + "Response.json"); + ret = addValidator(resp_filepath, action, false) && ret; + + return ret; +} +/** @brief Add a message validator */ +bool MessagesValidator20::addValidator(const std::filesystem::path& validator_path, const std::string& action, bool is_req) +{ + bool ret = false; + + // Load validator + std::shared_ptr validator = std::make_shared(); + if (validator->init(validator_path.string())) + { + LOG_DEBUG << "[" << action << "] Validator loaded : " << validator_path; + + // Add validator + if (is_req) + { + m_req_validators[action] = validator; + } + else + { + m_resp_validators[action] = validator; + } + + ret = true; + } + else + { + LOG_ERROR << "[" << action << "] Unable to load validator : " << validator_path; + } + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/MessagesValidator20.h b/src/ocpp20/messages/MessagesValidator20.h new file mode 100644 index 00000000..3e86d738 --- /dev/null +++ b/src/ocpp20/messages/MessagesValidator20.h @@ -0,0 +1,69 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +#ifndef OPENOCPP_OCPP20_MESSAGESVALIDATOR20_H +#define OPENOCPP_OCPP20_MESSAGESVALIDATOR20_H + +#include "IMessagesValidator.h" + +#include +#include +#include + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Stores all the needed message validators */ +class MessagesValidator20 : public IMessagesValidator +{ + public: + /** @brief Constructor */ + MessagesValidator20(); + /** @brief Destructor */ + virtual ~MessagesValidator20(); + + /** + * @brief Load the messages validators + * @return true if all the messages validators have been loaded, false otherwise + */ + bool load(const std::string& schemas_path); + + /** @copydoc ocpp::json::JsonValidator* IMessagesValidator::getValidator(const std::string&, bool) const */ + ocpp::json::JsonValidator* getValidator(const std::string& action, bool is_req) const override; + + private: + /** @brief Messages validators for requests */ + std::unordered_map> m_req_validators; + /** @brief Messages validators for responses */ + std::unordered_map> m_resp_validators; + + /** @brief Add a message validator for both request and response */ + bool addValidator(const std::string& schemas_path, const std::string& action); + /** @brief Add a message validator */ + bool addValidator(const std::filesystem::path& validator_path, const std::string& action, bool is_req); +}; + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_MESSAGESVALIDATOR20_H diff --git a/src/ocpp20/messages/MeterValues20.cpp b/src/ocpp20/messages/MeterValues20.cpp new file mode 100644 index 00000000..0180e10b --- /dev/null +++ b/src/ocpp20/messages/MeterValues20.cpp @@ -0,0 +1,150 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:MeterValuesRequest + OCPP 2.0.1 FINAL +*/ + +#include "MeterValues20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a MeterValuesReq from a JSON representation */ +bool MeterValuesReqConverter::fromJson(const rapidjson::Value& json, + MeterValuesReq& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // evseId + extract(json, "evseId", data.evseId); + + // meterValue + if (json.HasMember("meterValue")) + { + const rapidjson::Value& meterValue_json = json["meterValue"]; + ocpp::types::ocpp20::MeterValueTypeConverter meterValue_converter; + for (auto it = meterValue_json.Begin(); ret && (it != meterValue_json.End()); ++it) + { + ocpp::types::ocpp20::MeterValueType& item = data.meterValue.emplace_back(); + ret = ret && meterValue_converter.fromJson(*it, item, error_code, error_message); + } + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a MeterValuesReq to a JSON representation */ +bool MeterValuesReqConverter::toJson(const MeterValuesReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // evseId + fill(json, "evseId", data.evseId); + + // meterValue + + rapidjson::Value meterValue_json(rapidjson::kArrayType); + ocpp::types::ocpp20::MeterValueTypeConverter meterValue_converter; + meterValue_converter.setAllocator(allocator); + for (const ocpp::types::ocpp20::MeterValueType& item : data.meterValue) + { + rapidjson::Document item_doc(rapidjson::kObjectType); + ret = ret && meterValue_converter.toJson(item, item_doc); + meterValue_json.PushBack(item_doc.Move(), *allocator); + } + json.AddMember(rapidjson::StringRef("meterValue"), meterValue_json.Move(), *allocator); + + return ret; +} + +/** @brief Convert a MeterValuesConf from a JSON representation */ +bool MeterValuesConfConverter::fromJson(const rapidjson::Value& json, + MeterValuesConf& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a MeterValuesConf to a JSON representation */ +bool MeterValuesConfConverter::toJson(const MeterValuesConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/MeterValues20.h b/src/ocpp20/messages/MeterValues20.h new file mode 100644 index 00000000..05542541 --- /dev/null +++ b/src/ocpp20/messages/MeterValues20.h @@ -0,0 +1,69 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:MeterValuesRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_METERVALUES_H +#define OPENOCPP_OCPP20_METERVALUES_H + +#include "IMessageConverter.h" + +#include "CustomDataType20.h" +#include "MeterValueType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the MeterValues messages */ +static const std::string METERVALUES_ACTION = "MeterValues"; + +/** @brief MeterValuesReq message */ +struct MeterValuesReq +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief Request_ Body. EVSEID. Numeric_ Identifier +urn:x-enexis:ecdm:uid:1:571101 +This contains a number (>0) designating an EVSE of the Charging Station. ‘0’ (zero) is used to designate the main power meter. */ + int evseId; + /** @brief */ + std::vector meterValue; +}; + +/** @brief MeterValuesConf message */ +struct MeterValuesConf +{ + /** @brief */ + ocpp::types::Optional customData; +}; + +// Message converters +MESSAGE_CONVERTERS(MeterValues) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_METERVALUES_H \ No newline at end of file diff --git a/src/ocpp20/messages/NotifyChargingLimit20.cpp b/src/ocpp20/messages/NotifyChargingLimit20.cpp new file mode 100644 index 00000000..26984e61 --- /dev/null +++ b/src/ocpp20/messages/NotifyChargingLimit20.cpp @@ -0,0 +1,164 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:NotifyChargingLimitRequest + OCPP 2.0.1 FINAL +*/ + +#include "NotifyChargingLimit20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a NotifyChargingLimitReq from a JSON representation */ +bool NotifyChargingLimitReqConverter::fromJson(const rapidjson::Value& json, + NotifyChargingLimitReq& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // chargingSchedule + if (json.HasMember("chargingSchedule")) + { + const rapidjson::Value& chargingSchedule_json = json["chargingSchedule"]; + ocpp::types::ocpp20::ChargingScheduleTypeConverter chargingSchedule_converter; + for (auto it = chargingSchedule_json.Begin(); ret && (it != chargingSchedule_json.End()); ++it) + { + ocpp::types::ocpp20::ChargingScheduleType& item = data.chargingSchedule.emplace_back(); + ret = ret && chargingSchedule_converter.fromJson(*it, item, error_code, error_message); + } + } + + // evseId + extract(json, "evseId", data.evseId); + + // chargingLimit + ocpp::types::ocpp20::ChargingLimitTypeConverter chargingLimit_converter; + ret = ret && chargingLimit_converter.fromJson(json["chargingLimit"], data.chargingLimit, error_code, error_message); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a NotifyChargingLimitReq to a JSON representation */ +bool NotifyChargingLimitReqConverter::toJson(const NotifyChargingLimitReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // chargingSchedule + if (!data.chargingSchedule.empty()) + { + + rapidjson::Value chargingSchedule_json(rapidjson::kArrayType); + ocpp::types::ocpp20::ChargingScheduleTypeConverter chargingSchedule_converter; + chargingSchedule_converter.setAllocator(allocator); + for (const ocpp::types::ocpp20::ChargingScheduleType& item : data.chargingSchedule) + { + rapidjson::Document item_doc(rapidjson::kObjectType); + ret = ret && chargingSchedule_converter.toJson(item, item_doc); + chargingSchedule_json.PushBack(item_doc.Move(), *allocator); + } + json.AddMember(rapidjson::StringRef("chargingSchedule"), chargingSchedule_json.Move(), *allocator); + } + + // evseId + fill(json, "evseId", data.evseId); + + // chargingLimit + ocpp::types::ocpp20::ChargingLimitTypeConverter chargingLimit_converter; + chargingLimit_converter.setAllocator(allocator); + rapidjson::Document chargingLimit_doc(rapidjson::kObjectType); + ret = ret && chargingLimit_converter.toJson(data.chargingLimit, chargingLimit_doc); + json.AddMember(rapidjson::StringRef("chargingLimit"), chargingLimit_doc.Move(), *allocator); + + return ret; +} + +/** @brief Convert a NotifyChargingLimitConf from a JSON representation */ +bool NotifyChargingLimitConfConverter::fromJson(const rapidjson::Value& json, + NotifyChargingLimitConf& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a NotifyChargingLimitConf to a JSON representation */ +bool NotifyChargingLimitConfConverter::toJson(const NotifyChargingLimitConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/NotifyChargingLimit20.h b/src/ocpp20/messages/NotifyChargingLimit20.h new file mode 100644 index 00000000..db97c874 --- /dev/null +++ b/src/ocpp20/messages/NotifyChargingLimit20.h @@ -0,0 +1,70 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:NotifyChargingLimitRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_NOTIFYCHARGINGLIMIT_H +#define OPENOCPP_OCPP20_NOTIFYCHARGINGLIMIT_H + +#include "IMessageConverter.h" + +#include "ChargingLimitType20.h" +#include "ChargingScheduleType20.h" +#include "CustomDataType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the NotifyChargingLimit messages */ +static const std::string NOTIFYCHARGINGLIMIT_ACTION = "NotifyChargingLimit"; + +/** @brief NotifyChargingLimitReq message */ +struct NotifyChargingLimitReq +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + std::vector chargingSchedule; + /** @brief The charging schedule contained in this notification applies to an EVSE. evseId must be > 0. */ + ocpp::types::Optional evseId; + /** @brief */ + ocpp::types::ocpp20::ChargingLimitType chargingLimit; +}; + +/** @brief NotifyChargingLimitConf message */ +struct NotifyChargingLimitConf +{ + /** @brief */ + ocpp::types::Optional customData; +}; + +// Message converters +MESSAGE_CONVERTERS(NotifyChargingLimit) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_NOTIFYCHARGINGLIMIT_H \ No newline at end of file diff --git a/src/ocpp20/messages/NotifyCustomerInformation20.cpp b/src/ocpp20/messages/NotifyCustomerInformation20.cpp new file mode 100644 index 00000000..ebaffcc5 --- /dev/null +++ b/src/ocpp20/messages/NotifyCustomerInformation20.cpp @@ -0,0 +1,149 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:NotifyCustomerInformationRequest + OCPP 2.0.1 FINAL +*/ + +#include "NotifyCustomerInformation20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a NotifyCustomerInformationReq from a JSON representation */ +bool NotifyCustomerInformationReqConverter::fromJson(const rapidjson::Value& json, + NotifyCustomerInformationReq& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // data + extract(json, "data", data.data); + + // tbc + extract(json, "tbc", data.tbc); + + // seqNo + extract(json, "seqNo", data.seqNo); + + // generatedAt + ret = ret && extract(json, "generatedAt", data.generatedAt, error_message); + + // requestId + extract(json, "requestId", data.requestId); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a NotifyCustomerInformationReq to a JSON representation */ +bool NotifyCustomerInformationReqConverter::toJson(const NotifyCustomerInformationReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // data + fill(json, "data", data.data); + + // tbc + fill(json, "tbc", data.tbc); + + // seqNo + fill(json, "seqNo", data.seqNo); + + // generatedAt + fill(json, "generatedAt", data.generatedAt); + + // requestId + fill(json, "requestId", data.requestId); + + return ret; +} + +/** @brief Convert a NotifyCustomerInformationConf from a JSON representation */ +bool NotifyCustomerInformationConfConverter::fromJson(const rapidjson::Value& json, + NotifyCustomerInformationConf& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a NotifyCustomerInformationConf to a JSON representation */ +bool NotifyCustomerInformationConfConverter::toJson(const NotifyCustomerInformationConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/NotifyCustomerInformation20.h b/src/ocpp20/messages/NotifyCustomerInformation20.h new file mode 100644 index 00000000..63ec0c6c --- /dev/null +++ b/src/ocpp20/messages/NotifyCustomerInformation20.h @@ -0,0 +1,72 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:NotifyCustomerInformationRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_NOTIFYCUSTOMERINFORMATION_H +#define OPENOCPP_OCPP20_NOTIFYCUSTOMERINFORMATION_H + +#include "IMessageConverter.h" + +#include "CustomDataType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the NotifyCustomerInformation messages */ +static const std::string NOTIFYCUSTOMERINFORMATION_ACTION = "NotifyCustomerInformation"; + +/** @brief NotifyCustomerInformationReq message */ +struct NotifyCustomerInformationReq +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief (Part of) the requested data. No format specified in which the data is returned. Should be human readable. */ + ocpp::types::CiStringType<512u> data; + /** @brief “to be continued” indicator. Indicates whether another part of the monitoringData follows in an upcoming notifyMonitoringReportRequest message. Default value when omitted is false. */ + ocpp::types::Optional tbc; + /** @brief Sequence number of this message. First message starts at 0. */ + int seqNo; + /** @brief Timestamp of the moment this message was generated at the Charging Station. */ + ocpp::types::DateTime generatedAt; + /** @brief The Id of the request. */ + int requestId; +}; + +/** @brief NotifyCustomerInformationConf message */ +struct NotifyCustomerInformationConf +{ + /** @brief */ + ocpp::types::Optional customData; +}; + +// Message converters +MESSAGE_CONVERTERS(NotifyCustomerInformation) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_NOTIFYCUSTOMERINFORMATION_H \ No newline at end of file diff --git a/src/ocpp20/messages/NotifyDisplayMessages20.cpp b/src/ocpp20/messages/NotifyDisplayMessages20.cpp new file mode 100644 index 00000000..a4766ec7 --- /dev/null +++ b/src/ocpp20/messages/NotifyDisplayMessages20.cpp @@ -0,0 +1,159 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:NotifyDisplayMessagesRequest + OCPP 2.0.1 FINAL +*/ + +#include "NotifyDisplayMessages20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a NotifyDisplayMessagesReq from a JSON representation */ +bool NotifyDisplayMessagesReqConverter::fromJson(const rapidjson::Value& json, + NotifyDisplayMessagesReq& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // messageInfo + if (json.HasMember("messageInfo")) + { + const rapidjson::Value& messageInfo_json = json["messageInfo"]; + ocpp::types::ocpp20::MessageInfoTypeConverter messageInfo_converter; + for (auto it = messageInfo_json.Begin(); ret && (it != messageInfo_json.End()); ++it) + { + ocpp::types::ocpp20::MessageInfoType& item = data.messageInfo.emplace_back(); + ret = ret && messageInfo_converter.fromJson(*it, item, error_code, error_message); + } + } + + // requestId + extract(json, "requestId", data.requestId); + + // tbc + extract(json, "tbc", data.tbc); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a NotifyDisplayMessagesReq to a JSON representation */ +bool NotifyDisplayMessagesReqConverter::toJson(const NotifyDisplayMessagesReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // messageInfo + if (!data.messageInfo.empty()) + { + + rapidjson::Value messageInfo_json(rapidjson::kArrayType); + ocpp::types::ocpp20::MessageInfoTypeConverter messageInfo_converter; + messageInfo_converter.setAllocator(allocator); + for (const ocpp::types::ocpp20::MessageInfoType& item : data.messageInfo) + { + rapidjson::Document item_doc(rapidjson::kObjectType); + ret = ret && messageInfo_converter.toJson(item, item_doc); + messageInfo_json.PushBack(item_doc.Move(), *allocator); + } + json.AddMember(rapidjson::StringRef("messageInfo"), messageInfo_json.Move(), *allocator); + } + + // requestId + fill(json, "requestId", data.requestId); + + // tbc + fill(json, "tbc", data.tbc); + + return ret; +} + +/** @brief Convert a NotifyDisplayMessagesConf from a JSON representation */ +bool NotifyDisplayMessagesConfConverter::fromJson(const rapidjson::Value& json, + NotifyDisplayMessagesConf& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a NotifyDisplayMessagesConf to a JSON representation */ +bool NotifyDisplayMessagesConfConverter::toJson(const NotifyDisplayMessagesConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/NotifyDisplayMessages20.h b/src/ocpp20/messages/NotifyDisplayMessages20.h new file mode 100644 index 00000000..db87582b --- /dev/null +++ b/src/ocpp20/messages/NotifyDisplayMessages20.h @@ -0,0 +1,69 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:NotifyDisplayMessagesRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_NOTIFYDISPLAYMESSAGES_H +#define OPENOCPP_OCPP20_NOTIFYDISPLAYMESSAGES_H + +#include "IMessageConverter.h" + +#include "CustomDataType20.h" +#include "MessageInfoType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the NotifyDisplayMessages messages */ +static const std::string NOTIFYDISPLAYMESSAGES_ACTION = "NotifyDisplayMessages"; + +/** @brief NotifyDisplayMessagesReq message */ +struct NotifyDisplayMessagesReq +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + std::vector messageInfo; + /** @brief The id of the <<getdisplaymessagesrequest,GetDisplayMessagesRequest>> that requested this message. */ + int requestId; + /** @brief "to be continued" indicator. Indicates whether another part of the report follows in an upcoming NotifyDisplayMessagesRequest message. Default value when omitted is false. */ + ocpp::types::Optional tbc; +}; + +/** @brief NotifyDisplayMessagesConf message */ +struct NotifyDisplayMessagesConf +{ + /** @brief */ + ocpp::types::Optional customData; +}; + +// Message converters +MESSAGE_CONVERTERS(NotifyDisplayMessages) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_NOTIFYDISPLAYMESSAGES_H \ No newline at end of file diff --git a/src/ocpp20/messages/NotifyEVChargingNeeds20.cpp b/src/ocpp20/messages/NotifyEVChargingNeeds20.cpp new file mode 100644 index 00000000..f4b2f061 --- /dev/null +++ b/src/ocpp20/messages/NotifyEVChargingNeeds20.cpp @@ -0,0 +1,165 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:NotifyEVChargingNeedsRequest + OCPP 2.0.1 FINAL +*/ + +#include "NotifyEVChargingNeeds20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a NotifyEVChargingNeedsReq from a JSON representation */ +bool NotifyEVChargingNeedsReqConverter::fromJson(const rapidjson::Value& json, + NotifyEVChargingNeedsReq& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // maxScheduleTuples + extract(json, "maxScheduleTuples", data.maxScheduleTuples); + + // chargingNeeds + ocpp::types::ocpp20::ChargingNeedsTypeConverter chargingNeeds_converter; + ret = ret && chargingNeeds_converter.fromJson(json["chargingNeeds"], data.chargingNeeds, error_code, error_message); + + // evseId + extract(json, "evseId", data.evseId); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a NotifyEVChargingNeedsReq to a JSON representation */ +bool NotifyEVChargingNeedsReqConverter::toJson(const NotifyEVChargingNeedsReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // maxScheduleTuples + fill(json, "maxScheduleTuples", data.maxScheduleTuples); + + // chargingNeeds + ocpp::types::ocpp20::ChargingNeedsTypeConverter chargingNeeds_converter; + chargingNeeds_converter.setAllocator(allocator); + rapidjson::Document chargingNeeds_doc(rapidjson::kObjectType); + ret = ret && chargingNeeds_converter.toJson(data.chargingNeeds, chargingNeeds_doc); + json.AddMember(rapidjson::StringRef("chargingNeeds"), chargingNeeds_doc.Move(), *allocator); + + // evseId + fill(json, "evseId", data.evseId); + + return ret; +} + +/** @brief Convert a NotifyEVChargingNeedsConf from a JSON representation */ +bool NotifyEVChargingNeedsConfConverter::fromJson(const rapidjson::Value& json, + NotifyEVChargingNeedsConf& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // status + data.status = ocpp::types::ocpp20::NotifyEVChargingNeedsStatusEnumTypeHelper.fromString(json["status"].GetString()); + + // statusInfo + if (json.HasMember("statusInfo")) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + ret = ret && statusInfo_converter.fromJson(json["statusInfo"], data.statusInfo, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a NotifyEVChargingNeedsConf to a JSON representation */ +bool NotifyEVChargingNeedsConfConverter::toJson(const NotifyEVChargingNeedsConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // status + fill(json, "status", ocpp::types::ocpp20::NotifyEVChargingNeedsStatusEnumTypeHelper.toString(data.status)); + + // statusInfo + if (data.statusInfo.isSet()) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + statusInfo_converter.setAllocator(allocator); + rapidjson::Document statusInfo_doc(rapidjson::kObjectType); + ret = ret && statusInfo_converter.toJson(data.statusInfo, statusInfo_doc); + json.AddMember(rapidjson::StringRef("statusInfo"), statusInfo_doc.Move(), *allocator); + } + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/NotifyEVChargingNeeds20.h b/src/ocpp20/messages/NotifyEVChargingNeeds20.h new file mode 100644 index 00000000..8ca55c87 --- /dev/null +++ b/src/ocpp20/messages/NotifyEVChargingNeeds20.h @@ -0,0 +1,75 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:NotifyEVChargingNeedsRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_NOTIFYEVCHARGINGNEEDS_H +#define OPENOCPP_OCPP20_NOTIFYEVCHARGINGNEEDS_H + +#include "IMessageConverter.h" + +#include "ChargingNeedsType20.h" +#include "CustomDataType20.h" +#include "NotifyEVChargingNeedsStatusEnumType20.h" +#include "StatusInfoType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the NotifyEVChargingNeeds messages */ +static const std::string NOTIFYEVCHARGINGNEEDS_ACTION = "NotifyEVChargingNeeds"; + +/** @brief NotifyEVChargingNeedsReq message */ +struct NotifyEVChargingNeedsReq +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief Contains the maximum schedule tuples the car supports per schedule. */ + ocpp::types::Optional maxScheduleTuples; + /** @brief */ + ocpp::types::ocpp20::ChargingNeedsType chargingNeeds; + /** @brief Defines the EVSE and connector to which the EV is connected. EvseId may not be 0. */ + int evseId; +}; + +/** @brief NotifyEVChargingNeedsConf message */ +struct NotifyEVChargingNeedsConf +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::ocpp20::NotifyEVChargingNeedsStatusEnumType status; + /** @brief */ + ocpp::types::Optional statusInfo; +}; + +// Message converters +MESSAGE_CONVERTERS(NotifyEVChargingNeeds) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_NOTIFYEVCHARGINGNEEDS_H \ No newline at end of file diff --git a/src/ocpp20/messages/NotifyEVChargingSchedule20.cpp b/src/ocpp20/messages/NotifyEVChargingSchedule20.cpp new file mode 100644 index 00000000..563da2fb --- /dev/null +++ b/src/ocpp20/messages/NotifyEVChargingSchedule20.cpp @@ -0,0 +1,165 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:NotifyEVChargingScheduleRequest + OCPP 2.0.1 FINAL +*/ + +#include "NotifyEVChargingSchedule20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a NotifyEVChargingScheduleReq from a JSON representation */ +bool NotifyEVChargingScheduleReqConverter::fromJson(const rapidjson::Value& json, + NotifyEVChargingScheduleReq& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // timeBase + ret = ret && extract(json, "timeBase", data.timeBase, error_message); + + // chargingSchedule + ocpp::types::ocpp20::ChargingScheduleTypeConverter chargingSchedule_converter; + ret = ret && chargingSchedule_converter.fromJson(json["chargingSchedule"], data.chargingSchedule, error_code, error_message); + + // evseId + extract(json, "evseId", data.evseId); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a NotifyEVChargingScheduleReq to a JSON representation */ +bool NotifyEVChargingScheduleReqConverter::toJson(const NotifyEVChargingScheduleReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // timeBase + fill(json, "timeBase", data.timeBase); + + // chargingSchedule + ocpp::types::ocpp20::ChargingScheduleTypeConverter chargingSchedule_converter; + chargingSchedule_converter.setAllocator(allocator); + rapidjson::Document chargingSchedule_doc(rapidjson::kObjectType); + ret = ret && chargingSchedule_converter.toJson(data.chargingSchedule, chargingSchedule_doc); + json.AddMember(rapidjson::StringRef("chargingSchedule"), chargingSchedule_doc.Move(), *allocator); + + // evseId + fill(json, "evseId", data.evseId); + + return ret; +} + +/** @brief Convert a NotifyEVChargingScheduleConf from a JSON representation */ +bool NotifyEVChargingScheduleConfConverter::fromJson(const rapidjson::Value& json, + NotifyEVChargingScheduleConf& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // status + data.status = ocpp::types::ocpp20::GenericStatusEnumTypeHelper.fromString(json["status"].GetString()); + + // statusInfo + if (json.HasMember("statusInfo")) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + ret = ret && statusInfo_converter.fromJson(json["statusInfo"], data.statusInfo, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a NotifyEVChargingScheduleConf to a JSON representation */ +bool NotifyEVChargingScheduleConfConverter::toJson(const NotifyEVChargingScheduleConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // status + fill(json, "status", ocpp::types::ocpp20::GenericStatusEnumTypeHelper.toString(data.status)); + + // statusInfo + if (data.statusInfo.isSet()) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + statusInfo_converter.setAllocator(allocator); + rapidjson::Document statusInfo_doc(rapidjson::kObjectType); + ret = ret && statusInfo_converter.toJson(data.statusInfo, statusInfo_doc); + json.AddMember(rapidjson::StringRef("statusInfo"), statusInfo_doc.Move(), *allocator); + } + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/NotifyEVChargingSchedule20.h b/src/ocpp20/messages/NotifyEVChargingSchedule20.h new file mode 100644 index 00000000..80d5298c --- /dev/null +++ b/src/ocpp20/messages/NotifyEVChargingSchedule20.h @@ -0,0 +1,75 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:NotifyEVChargingScheduleRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_NOTIFYEVCHARGINGSCHEDULE_H +#define OPENOCPP_OCPP20_NOTIFYEVCHARGINGSCHEDULE_H + +#include "IMessageConverter.h" + +#include "ChargingScheduleType20.h" +#include "CustomDataType20.h" +#include "GenericStatusEnumType20.h" +#include "StatusInfoType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the NotifyEVChargingSchedule messages */ +static const std::string NOTIFYEVCHARGINGSCHEDULE_ACTION = "NotifyEVChargingSchedule"; + +/** @brief NotifyEVChargingScheduleReq message */ +struct NotifyEVChargingScheduleReq +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief Periods contained in the charging profile are relative to this point in time. */ + ocpp::types::DateTime timeBase; + /** @brief */ + ocpp::types::ocpp20::ChargingScheduleType chargingSchedule; + /** @brief The charging schedule contained in this notification applies to an EVSE. EvseId must be > 0. */ + int evseId; +}; + +/** @brief NotifyEVChargingScheduleConf message */ +struct NotifyEVChargingScheduleConf +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::ocpp20::GenericStatusEnumType status; + /** @brief */ + ocpp::types::Optional statusInfo; +}; + +// Message converters +MESSAGE_CONVERTERS(NotifyEVChargingSchedule) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_NOTIFYEVCHARGINGSCHEDULE_H \ No newline at end of file diff --git a/src/ocpp20/messages/NotifyEvent20.cpp b/src/ocpp20/messages/NotifyEvent20.cpp new file mode 100644 index 00000000..a2140e33 --- /dev/null +++ b/src/ocpp20/messages/NotifyEvent20.cpp @@ -0,0 +1,162 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:NotifyEventRequest + OCPP 2.0.1 FINAL +*/ + +#include "NotifyEvent20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a NotifyEventReq from a JSON representation */ +bool NotifyEventReqConverter::fromJson(const rapidjson::Value& json, + NotifyEventReq& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // generatedAt + ret = ret && extract(json, "generatedAt", data.generatedAt, error_message); + + // tbc + extract(json, "tbc", data.tbc); + + // seqNo + extract(json, "seqNo", data.seqNo); + + // eventData + if (json.HasMember("eventData")) + { + const rapidjson::Value& eventData_json = json["eventData"]; + ocpp::types::ocpp20::EventDataTypeConverter eventData_converter; + for (auto it = eventData_json.Begin(); ret && (it != eventData_json.End()); ++it) + { + ocpp::types::ocpp20::EventDataType& item = data.eventData.emplace_back(); + ret = ret && eventData_converter.fromJson(*it, item, error_code, error_message); + } + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a NotifyEventReq to a JSON representation */ +bool NotifyEventReqConverter::toJson(const NotifyEventReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // generatedAt + fill(json, "generatedAt", data.generatedAt); + + // tbc + fill(json, "tbc", data.tbc); + + // seqNo + fill(json, "seqNo", data.seqNo); + + // eventData + + rapidjson::Value eventData_json(rapidjson::kArrayType); + ocpp::types::ocpp20::EventDataTypeConverter eventData_converter; + eventData_converter.setAllocator(allocator); + for (const ocpp::types::ocpp20::EventDataType& item : data.eventData) + { + rapidjson::Document item_doc(rapidjson::kObjectType); + ret = ret && eventData_converter.toJson(item, item_doc); + eventData_json.PushBack(item_doc.Move(), *allocator); + } + json.AddMember(rapidjson::StringRef("eventData"), eventData_json.Move(), *allocator); + + return ret; +} + +/** @brief Convert a NotifyEventConf from a JSON representation */ +bool NotifyEventConfConverter::fromJson(const rapidjson::Value& json, + NotifyEventConf& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a NotifyEventConf to a JSON representation */ +bool NotifyEventConfConverter::toJson(const NotifyEventConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/NotifyEvent20.h b/src/ocpp20/messages/NotifyEvent20.h new file mode 100644 index 00000000..89576e8c --- /dev/null +++ b/src/ocpp20/messages/NotifyEvent20.h @@ -0,0 +1,71 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:NotifyEventRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_NOTIFYEVENT_H +#define OPENOCPP_OCPP20_NOTIFYEVENT_H + +#include "IMessageConverter.h" + +#include "CustomDataType20.h" +#include "EventDataType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the NotifyEvent messages */ +static const std::string NOTIFYEVENT_ACTION = "NotifyEvent"; + +/** @brief NotifyEventReq message */ +struct NotifyEventReq +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief Timestamp of the moment this message was generated at the Charging Station. */ + ocpp::types::DateTime generatedAt; + /** @brief “to be continued” indicator. Indicates whether another part of the report follows in an upcoming notifyEventRequest message. Default value when omitted is false. */ + ocpp::types::Optional tbc; + /** @brief Sequence number of this message. First message starts at 0. */ + int seqNo; + /** @brief */ + std::vector eventData; +}; + +/** @brief NotifyEventConf message */ +struct NotifyEventConf +{ + /** @brief */ + ocpp::types::Optional customData; +}; + +// Message converters +MESSAGE_CONVERTERS(NotifyEvent) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_NOTIFYEVENT_H \ No newline at end of file diff --git a/src/ocpp20/messages/NotifyMonitoringReport20.cpp b/src/ocpp20/messages/NotifyMonitoringReport20.cpp new file mode 100644 index 00000000..a2d3bbed --- /dev/null +++ b/src/ocpp20/messages/NotifyMonitoringReport20.cpp @@ -0,0 +1,171 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:NotifyMonitoringReportRequest + OCPP 2.0.1 FINAL +*/ + +#include "NotifyMonitoringReport20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a NotifyMonitoringReportReq from a JSON representation */ +bool NotifyMonitoringReportReqConverter::fromJson(const rapidjson::Value& json, + NotifyMonitoringReportReq& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // monitor + if (json.HasMember("monitor")) + { + const rapidjson::Value& monitor_json = json["monitor"]; + ocpp::types::ocpp20::MonitoringDataTypeConverter monitor_converter; + for (auto it = monitor_json.Begin(); ret && (it != monitor_json.End()); ++it) + { + ocpp::types::ocpp20::MonitoringDataType& item = data.monitor.emplace_back(); + ret = ret && monitor_converter.fromJson(*it, item, error_code, error_message); + } + } + + // requestId + extract(json, "requestId", data.requestId); + + // tbc + extract(json, "tbc", data.tbc); + + // seqNo + extract(json, "seqNo", data.seqNo); + + // generatedAt + ret = ret && extract(json, "generatedAt", data.generatedAt, error_message); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a NotifyMonitoringReportReq to a JSON representation */ +bool NotifyMonitoringReportReqConverter::toJson(const NotifyMonitoringReportReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // monitor + if (!data.monitor.empty()) + { + + rapidjson::Value monitor_json(rapidjson::kArrayType); + ocpp::types::ocpp20::MonitoringDataTypeConverter monitor_converter; + monitor_converter.setAllocator(allocator); + for (const ocpp::types::ocpp20::MonitoringDataType& item : data.monitor) + { + rapidjson::Document item_doc(rapidjson::kObjectType); + ret = ret && monitor_converter.toJson(item, item_doc); + monitor_json.PushBack(item_doc.Move(), *allocator); + } + json.AddMember(rapidjson::StringRef("monitor"), monitor_json.Move(), *allocator); + } + + // requestId + fill(json, "requestId", data.requestId); + + // tbc + fill(json, "tbc", data.tbc); + + // seqNo + fill(json, "seqNo", data.seqNo); + + // generatedAt + fill(json, "generatedAt", data.generatedAt); + + return ret; +} + +/** @brief Convert a NotifyMonitoringReportConf from a JSON representation */ +bool NotifyMonitoringReportConfConverter::fromJson(const rapidjson::Value& json, + NotifyMonitoringReportConf& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a NotifyMonitoringReportConf to a JSON representation */ +bool NotifyMonitoringReportConfConverter::toJson(const NotifyMonitoringReportConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/NotifyMonitoringReport20.h b/src/ocpp20/messages/NotifyMonitoringReport20.h new file mode 100644 index 00000000..bdc1452f --- /dev/null +++ b/src/ocpp20/messages/NotifyMonitoringReport20.h @@ -0,0 +1,73 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:NotifyMonitoringReportRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_NOTIFYMONITORINGREPORT_H +#define OPENOCPP_OCPP20_NOTIFYMONITORINGREPORT_H + +#include "IMessageConverter.h" + +#include "CustomDataType20.h" +#include "MonitoringDataType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the NotifyMonitoringReport messages */ +static const std::string NOTIFYMONITORINGREPORT_ACTION = "NotifyMonitoringReport"; + +/** @brief NotifyMonitoringReportReq message */ +struct NotifyMonitoringReportReq +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + std::vector monitor; + /** @brief The id of the GetMonitoringRequest that requested this report. */ + int requestId; + /** @brief “to be continued” indicator. Indicates whether another part of the monitoringData follows in an upcoming notifyMonitoringReportRequest message. Default value when omitted is false. */ + ocpp::types::Optional tbc; + /** @brief Sequence number of this message. First message starts at 0. */ + int seqNo; + /** @brief Timestamp of the moment this message was generated at the Charging Station. */ + ocpp::types::DateTime generatedAt; +}; + +/** @brief NotifyMonitoringReportConf message */ +struct NotifyMonitoringReportConf +{ + /** @brief */ + ocpp::types::Optional customData; +}; + +// Message converters +MESSAGE_CONVERTERS(NotifyMonitoringReport) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_NOTIFYMONITORINGREPORT_H \ No newline at end of file diff --git a/src/ocpp20/messages/NotifyReport20.cpp b/src/ocpp20/messages/NotifyReport20.cpp new file mode 100644 index 00000000..5194ccf6 --- /dev/null +++ b/src/ocpp20/messages/NotifyReport20.cpp @@ -0,0 +1,171 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:NotifyReportRequest + OCPP 2.0.1 FINAL +*/ + +#include "NotifyReport20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a NotifyReportReq from a JSON representation */ +bool NotifyReportReqConverter::fromJson(const rapidjson::Value& json, + NotifyReportReq& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // requestId + extract(json, "requestId", data.requestId); + + // generatedAt + ret = ret && extract(json, "generatedAt", data.generatedAt, error_message); + + // reportData + if (json.HasMember("reportData")) + { + const rapidjson::Value& reportData_json = json["reportData"]; + ocpp::types::ocpp20::ReportDataTypeConverter reportData_converter; + for (auto it = reportData_json.Begin(); ret && (it != reportData_json.End()); ++it) + { + ocpp::types::ocpp20::ReportDataType& item = data.reportData.emplace_back(); + ret = ret && reportData_converter.fromJson(*it, item, error_code, error_message); + } + } + + // tbc + extract(json, "tbc", data.tbc); + + // seqNo + extract(json, "seqNo", data.seqNo); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a NotifyReportReq to a JSON representation */ +bool NotifyReportReqConverter::toJson(const NotifyReportReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // requestId + fill(json, "requestId", data.requestId); + + // generatedAt + fill(json, "generatedAt", data.generatedAt); + + // reportData + if (!data.reportData.empty()) + { + + rapidjson::Value reportData_json(rapidjson::kArrayType); + ocpp::types::ocpp20::ReportDataTypeConverter reportData_converter; + reportData_converter.setAllocator(allocator); + for (const ocpp::types::ocpp20::ReportDataType& item : data.reportData) + { + rapidjson::Document item_doc(rapidjson::kObjectType); + ret = ret && reportData_converter.toJson(item, item_doc); + reportData_json.PushBack(item_doc.Move(), *allocator); + } + json.AddMember(rapidjson::StringRef("reportData"), reportData_json.Move(), *allocator); + } + + // tbc + fill(json, "tbc", data.tbc); + + // seqNo + fill(json, "seqNo", data.seqNo); + + return ret; +} + +/** @brief Convert a NotifyReportConf from a JSON representation */ +bool NotifyReportConfConverter::fromJson(const rapidjson::Value& json, + NotifyReportConf& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a NotifyReportConf to a JSON representation */ +bool NotifyReportConfConverter::toJson(const NotifyReportConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/NotifyReport20.h b/src/ocpp20/messages/NotifyReport20.h new file mode 100644 index 00000000..e18b3d19 --- /dev/null +++ b/src/ocpp20/messages/NotifyReport20.h @@ -0,0 +1,73 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:NotifyReportRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_NOTIFYREPORT_H +#define OPENOCPP_OCPP20_NOTIFYREPORT_H + +#include "IMessageConverter.h" + +#include "CustomDataType20.h" +#include "ReportDataType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the NotifyReport messages */ +static const std::string NOTIFYREPORT_ACTION = "NotifyReport"; + +/** @brief NotifyReportReq message */ +struct NotifyReportReq +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief The id of the GetReportRequest or GetBaseReportRequest that requested this report */ + int requestId; + /** @brief Timestamp of the moment this message was generated at the Charging Station. */ + ocpp::types::DateTime generatedAt; + /** @brief */ + std::vector reportData; + /** @brief “to be continued” indicator. Indicates whether another part of the report follows in an upcoming notifyReportRequest message. Default value when omitted is false. */ + ocpp::types::Optional tbc; + /** @brief Sequence number of this message. First message starts at 0. */ + int seqNo; +}; + +/** @brief NotifyReportConf message */ +struct NotifyReportConf +{ + /** @brief */ + ocpp::types::Optional customData; +}; + +// Message converters +MESSAGE_CONVERTERS(NotifyReport) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_NOTIFYREPORT_H \ No newline at end of file diff --git a/src/ocpp20/messages/PublishFirmware20.cpp b/src/ocpp20/messages/PublishFirmware20.cpp new file mode 100644 index 00000000..9282c8c0 --- /dev/null +++ b/src/ocpp20/messages/PublishFirmware20.cpp @@ -0,0 +1,172 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:PublishFirmwareRequest + OCPP 2.0.1 FINAL +*/ + +#include "PublishFirmware20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a PublishFirmwareReq from a JSON representation */ +bool PublishFirmwareReqConverter::fromJson(const rapidjson::Value& json, + PublishFirmwareReq& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // location + extract(json, "location", data.location); + + // retries + extract(json, "retries", data.retries); + + // checksum + extract(json, "checksum", data.checksum); + + // requestId + extract(json, "requestId", data.requestId); + + // retryInterval + extract(json, "retryInterval", data.retryInterval); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a PublishFirmwareReq to a JSON representation */ +bool PublishFirmwareReqConverter::toJson(const PublishFirmwareReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // location + fill(json, "location", data.location); + + // retries + fill(json, "retries", data.retries); + + // checksum + fill(json, "checksum", data.checksum); + + // requestId + fill(json, "requestId", data.requestId); + + // retryInterval + fill(json, "retryInterval", data.retryInterval); + + return ret; +} + +/** @brief Convert a PublishFirmwareConf from a JSON representation */ +bool PublishFirmwareConfConverter::fromJson(const rapidjson::Value& json, + PublishFirmwareConf& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // status + data.status = ocpp::types::ocpp20::GenericStatusEnumTypeHelper.fromString(json["status"].GetString()); + + // statusInfo + if (json.HasMember("statusInfo")) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + ret = ret && statusInfo_converter.fromJson(json["statusInfo"], data.statusInfo, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a PublishFirmwareConf to a JSON representation */ +bool PublishFirmwareConfConverter::toJson(const PublishFirmwareConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // status + fill(json, "status", ocpp::types::ocpp20::GenericStatusEnumTypeHelper.toString(data.status)); + + // statusInfo + if (data.statusInfo.isSet()) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + statusInfo_converter.setAllocator(allocator); + rapidjson::Document statusInfo_doc(rapidjson::kObjectType); + ret = ret && statusInfo_converter.toJson(data.statusInfo, statusInfo_doc); + json.AddMember(rapidjson::StringRef("statusInfo"), statusInfo_doc.Move(), *allocator); + } + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/PublishFirmware20.h b/src/ocpp20/messages/PublishFirmware20.h new file mode 100644 index 00000000..32d5f04f --- /dev/null +++ b/src/ocpp20/messages/PublishFirmware20.h @@ -0,0 +1,86 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:PublishFirmwareRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_PUBLISHFIRMWARE_H +#define OPENOCPP_OCPP20_PUBLISHFIRMWARE_H + +#include "IMessageConverter.h" + +#include "CustomDataType20.h" +#include "GenericStatusEnumType20.h" +#include "StatusInfoType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the PublishFirmware messages */ +static const std::string PUBLISHFIRMWARE_ACTION = "PublishFirmware"; + +/** @brief PublishFirmwareReq message */ +struct PublishFirmwareReq +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief This contains a string containing a URI pointing to a +location from which to retrieve the firmware. */ + ocpp::types::CiStringType<512u> location; + /** @brief This specifies how many times Charging Station must try +to download the firmware before giving up. If this field is not +present, it is left to Charging Station to decide how many times it wants to retry. */ + ocpp::types::Optional retries; + /** @brief The MD5 checksum over the entire firmware file as a hexadecimal string of length 32. */ + ocpp::types::CiStringType<32u> checksum; + /** @brief The Id of the request. */ + int requestId; + /** @brief The interval in seconds +after which a retry may be +attempted. If this field is not +present, it is left to Charging +Station to decide how long to wait +between attempts. */ + ocpp::types::Optional retryInterval; +}; + +/** @brief PublishFirmwareConf message */ +struct PublishFirmwareConf +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::ocpp20::GenericStatusEnumType status; + /** @brief */ + ocpp::types::Optional statusInfo; +}; + +// Message converters +MESSAGE_CONVERTERS(PublishFirmware) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_PUBLISHFIRMWARE_H \ No newline at end of file diff --git a/src/ocpp20/messages/PublishFirmwareStatusNotification20.cpp b/src/ocpp20/messages/PublishFirmwareStatusNotification20.cpp new file mode 100644 index 00000000..81a602a2 --- /dev/null +++ b/src/ocpp20/messages/PublishFirmwareStatusNotification20.cpp @@ -0,0 +1,154 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:PublishFirmwareStatusNotificationRequest + OCPP 2.0.1 FINAL +*/ + +#include "PublishFirmwareStatusNotification20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a PublishFirmwareStatusNotificationReq from a JSON representation */ +bool PublishFirmwareStatusNotificationReqConverter::fromJson(const rapidjson::Value& json, + PublishFirmwareStatusNotificationReq& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // status + data.status = ocpp::types::ocpp20::PublishFirmwareStatusEnumTypeHelper.fromString(json["status"].GetString()); + + // location + if (json.HasMember("location")) + { + const rapidjson::Value& location_json = json["location"]; + for (auto it = location_json.Begin(); ret && (it != location_json.End()); ++it) + { + std::string& item = data.location.emplace_back(); + item = it->GetString(); + } + } + + // requestId + extract(json, "requestId", data.requestId); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a PublishFirmwareStatusNotificationReq to a JSON representation */ +bool PublishFirmwareStatusNotificationReqConverter::toJson(const PublishFirmwareStatusNotificationReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // status + fill(json, "status", ocpp::types::ocpp20::PublishFirmwareStatusEnumTypeHelper.toString(data.status)); + + // location + if (!data.location.empty()) + { + + rapidjson::Value location_json(rapidjson::kArrayType); + for (const std::string& item : data.location) + { + location_json.PushBack(rapidjson::Value(item.c_str(), *allocator).Move(), *allocator); + } + json.AddMember(rapidjson::StringRef("location"), location_json.Move(), *allocator); + } + + // requestId + fill(json, "requestId", data.requestId); + + return ret; +} + +/** @brief Convert a PublishFirmwareStatusNotificationConf from a JSON representation */ +bool PublishFirmwareStatusNotificationConfConverter::fromJson(const rapidjson::Value& json, + PublishFirmwareStatusNotificationConf& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a PublishFirmwareStatusNotificationConf to a JSON representation */ +bool PublishFirmwareStatusNotificationConfConverter::toJson(const PublishFirmwareStatusNotificationConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/PublishFirmwareStatusNotification20.h b/src/ocpp20/messages/PublishFirmwareStatusNotification20.h new file mode 100644 index 00000000..4a3085a0 --- /dev/null +++ b/src/ocpp20/messages/PublishFirmwareStatusNotification20.h @@ -0,0 +1,72 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:PublishFirmwareStatusNotificationRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_PUBLISHFIRMWARESTATUSNOTIFICATION_H +#define OPENOCPP_OCPP20_PUBLISHFIRMWARESTATUSNOTIFICATION_H + +#include "IMessageConverter.h" + +#include "CustomDataType20.h" +#include "PublishFirmwareStatusEnumType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the PublishFirmwareStatusNotification messages */ +static const std::string PUBLISHFIRMWARESTATUSNOTIFICATION_ACTION = "PublishFirmwareStatusNotification"; + +/** @brief PublishFirmwareStatusNotificationReq message */ +struct PublishFirmwareStatusNotificationReq +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::ocpp20::PublishFirmwareStatusEnumType status; + /** @brief Required if status is Published. Can be multiple URI’s, if the Local Controller supports e.g. HTTP, HTTPS, and FTP. */ + std::vector location; + /** @brief The request id that was +provided in the +PublishFirmwareRequest which +triggered this action. */ + ocpp::types::Optional requestId; +}; + +/** @brief PublishFirmwareStatusNotificationConf message */ +struct PublishFirmwareStatusNotificationConf +{ + /** @brief */ + ocpp::types::Optional customData; +}; + +// Message converters +MESSAGE_CONVERTERS(PublishFirmwareStatusNotification) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_PUBLISHFIRMWARESTATUSNOTIFICATION_H \ No newline at end of file diff --git a/src/ocpp20/messages/ReportChargingProfiles20.cpp b/src/ocpp20/messages/ReportChargingProfiles20.cpp new file mode 100644 index 00000000..10812deb --- /dev/null +++ b/src/ocpp20/messages/ReportChargingProfiles20.cpp @@ -0,0 +1,168 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:ReportChargingProfilesRequest + OCPP 2.0.1 FINAL +*/ + +#include "ReportChargingProfiles20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a ReportChargingProfilesReq from a JSON representation */ +bool ReportChargingProfilesReqConverter::fromJson(const rapidjson::Value& json, + ReportChargingProfilesReq& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // requestId + extract(json, "requestId", data.requestId); + + // chargingLimitSource + data.chargingLimitSource = ocpp::types::ocpp20::ChargingLimitSourceEnumTypeHelper.fromString(json["chargingLimitSource"].GetString()); + + // chargingProfile + if (json.HasMember("chargingProfile")) + { + const rapidjson::Value& chargingProfile_json = json["chargingProfile"]; + ocpp::types::ocpp20::ChargingProfileTypeConverter chargingProfile_converter; + for (auto it = chargingProfile_json.Begin(); ret && (it != chargingProfile_json.End()); ++it) + { + ocpp::types::ocpp20::ChargingProfileType& item = data.chargingProfile.emplace_back(); + ret = ret && chargingProfile_converter.fromJson(*it, item, error_code, error_message); + } + } + + // tbc + extract(json, "tbc", data.tbc); + + // evseId + extract(json, "evseId", data.evseId); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a ReportChargingProfilesReq to a JSON representation */ +bool ReportChargingProfilesReqConverter::toJson(const ReportChargingProfilesReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // requestId + fill(json, "requestId", data.requestId); + + // chargingLimitSource + fill(json, "chargingLimitSource", ocpp::types::ocpp20::ChargingLimitSourceEnumTypeHelper.toString(data.chargingLimitSource)); + + // chargingProfile + + rapidjson::Value chargingProfile_json(rapidjson::kArrayType); + ocpp::types::ocpp20::ChargingProfileTypeConverter chargingProfile_converter; + chargingProfile_converter.setAllocator(allocator); + for (const ocpp::types::ocpp20::ChargingProfileType& item : data.chargingProfile) + { + rapidjson::Document item_doc(rapidjson::kObjectType); + ret = ret && chargingProfile_converter.toJson(item, item_doc); + chargingProfile_json.PushBack(item_doc.Move(), *allocator); + } + json.AddMember(rapidjson::StringRef("chargingProfile"), chargingProfile_json.Move(), *allocator); + + // tbc + fill(json, "tbc", data.tbc); + + // evseId + fill(json, "evseId", data.evseId); + + return ret; +} + +/** @brief Convert a ReportChargingProfilesConf from a JSON representation */ +bool ReportChargingProfilesConfConverter::fromJson(const rapidjson::Value& json, + ReportChargingProfilesConf& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a ReportChargingProfilesConf to a JSON representation */ +bool ReportChargingProfilesConfConverter::toJson(const ReportChargingProfilesConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/ReportChargingProfiles20.h b/src/ocpp20/messages/ReportChargingProfiles20.h new file mode 100644 index 00000000..eec02ff1 --- /dev/null +++ b/src/ocpp20/messages/ReportChargingProfiles20.h @@ -0,0 +1,74 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:ReportChargingProfilesRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_REPORTCHARGINGPROFILES_H +#define OPENOCPP_OCPP20_REPORTCHARGINGPROFILES_H + +#include "IMessageConverter.h" + +#include "ChargingLimitSourceEnumType20.h" +#include "ChargingProfileType20.h" +#include "CustomDataType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the ReportChargingProfiles messages */ +static const std::string REPORTCHARGINGPROFILES_ACTION = "ReportChargingProfiles"; + +/** @brief ReportChargingProfilesReq message */ +struct ReportChargingProfilesReq +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief Id used to match the <<getchargingprofilesrequest, GetChargingProfilesRequest>> message with the resulting ReportChargingProfilesRequest messages. When the CSMS provided a requestId in the <<getchargingprofilesrequest, GetChargingProfilesRequest>>, this field SHALL contain the same value. */ + int requestId; + /** @brief */ + ocpp::types::ocpp20::ChargingLimitSourceEnumType chargingLimitSource; + /** @brief */ + std::vector chargingProfile; + /** @brief To Be Continued. Default value when omitted: false. false indicates that there are no further messages as part of this report. */ + ocpp::types::Optional tbc; + /** @brief The evse to which the charging profile applies. If evseId = 0, the message contains an overall limit for the Charging Station. */ + int evseId; +}; + +/** @brief ReportChargingProfilesConf message */ +struct ReportChargingProfilesConf +{ + /** @brief */ + ocpp::types::Optional customData; +}; + +// Message converters +MESSAGE_CONVERTERS(ReportChargingProfiles) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_REPORTCHARGINGPROFILES_H \ No newline at end of file diff --git a/src/ocpp20/messages/RequestStartTransaction20.cpp b/src/ocpp20/messages/RequestStartTransaction20.cpp new file mode 100644 index 00000000..cb7a4224 --- /dev/null +++ b/src/ocpp20/messages/RequestStartTransaction20.cpp @@ -0,0 +1,205 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:RequestStartTransactionRequest + OCPP 2.0.1 FINAL +*/ + +#include "RequestStartTransaction20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a RequestStartTransactionReq from a JSON representation */ +bool RequestStartTransactionReqConverter::fromJson(const rapidjson::Value& json, + RequestStartTransactionReq& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // evseId + extract(json, "evseId", data.evseId); + + // groupIdToken + if (json.HasMember("groupIdToken")) + { + ocpp::types::ocpp20::IdTokenTypeConverter groupIdToken_converter; + ret = ret && groupIdToken_converter.fromJson(json["groupIdToken"], data.groupIdToken, error_code, error_message); + } + + // idToken + ocpp::types::ocpp20::IdTokenTypeConverter idToken_converter; + ret = ret && idToken_converter.fromJson(json["idToken"], data.idToken, error_code, error_message); + + // remoteStartId + extract(json, "remoteStartId", data.remoteStartId); + + // chargingProfile + if (json.HasMember("chargingProfile")) + { + ocpp::types::ocpp20::ChargingProfileTypeConverter chargingProfile_converter; + ret = ret && chargingProfile_converter.fromJson(json["chargingProfile"], data.chargingProfile, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a RequestStartTransactionReq to a JSON representation */ +bool RequestStartTransactionReqConverter::toJson(const RequestStartTransactionReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // evseId + fill(json, "evseId", data.evseId); + + // groupIdToken + if (data.groupIdToken.isSet()) + { + ocpp::types::ocpp20::IdTokenTypeConverter groupIdToken_converter; + groupIdToken_converter.setAllocator(allocator); + rapidjson::Document groupIdToken_doc(rapidjson::kObjectType); + ret = ret && groupIdToken_converter.toJson(data.groupIdToken, groupIdToken_doc); + json.AddMember(rapidjson::StringRef("groupIdToken"), groupIdToken_doc.Move(), *allocator); + } + + // idToken + ocpp::types::ocpp20::IdTokenTypeConverter idToken_converter; + idToken_converter.setAllocator(allocator); + rapidjson::Document idToken_doc(rapidjson::kObjectType); + ret = ret && idToken_converter.toJson(data.idToken, idToken_doc); + json.AddMember(rapidjson::StringRef("idToken"), idToken_doc.Move(), *allocator); + + // remoteStartId + fill(json, "remoteStartId", data.remoteStartId); + + // chargingProfile + if (data.chargingProfile.isSet()) + { + ocpp::types::ocpp20::ChargingProfileTypeConverter chargingProfile_converter; + chargingProfile_converter.setAllocator(allocator); + rapidjson::Document chargingProfile_doc(rapidjson::kObjectType); + ret = ret && chargingProfile_converter.toJson(data.chargingProfile, chargingProfile_doc); + json.AddMember(rapidjson::StringRef("chargingProfile"), chargingProfile_doc.Move(), *allocator); + } + + return ret; +} + +/** @brief Convert a RequestStartTransactionConf from a JSON representation */ +bool RequestStartTransactionConfConverter::fromJson(const rapidjson::Value& json, + RequestStartTransactionConf& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // status + data.status = ocpp::types::ocpp20::RequestStartStopStatusEnumTypeHelper.fromString(json["status"].GetString()); + + // statusInfo + if (json.HasMember("statusInfo")) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + ret = ret && statusInfo_converter.fromJson(json["statusInfo"], data.statusInfo, error_code, error_message); + } + + // transactionId + extract(json, "transactionId", data.transactionId); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a RequestStartTransactionConf to a JSON representation */ +bool RequestStartTransactionConfConverter::toJson(const RequestStartTransactionConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // status + fill(json, "status", ocpp::types::ocpp20::RequestStartStopStatusEnumTypeHelper.toString(data.status)); + + // statusInfo + if (data.statusInfo.isSet()) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + statusInfo_converter.setAllocator(allocator); + rapidjson::Document statusInfo_doc(rapidjson::kObjectType); + ret = ret && statusInfo_converter.toJson(data.statusInfo, statusInfo_doc); + json.AddMember(rapidjson::StringRef("statusInfo"), statusInfo_doc.Move(), *allocator); + } + + // transactionId + fill(json, "transactionId", data.transactionId); + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/RequestStartTransaction20.h b/src/ocpp20/messages/RequestStartTransaction20.h new file mode 100644 index 00000000..8ebc6dc4 --- /dev/null +++ b/src/ocpp20/messages/RequestStartTransaction20.h @@ -0,0 +1,82 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:RequestStartTransactionRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_REQUESTSTARTTRANSACTION_H +#define OPENOCPP_OCPP20_REQUESTSTARTTRANSACTION_H + +#include "IMessageConverter.h" + +#include "ChargingProfileType20.h" +#include "CustomDataType20.h" +#include "IdTokenType20.h" +#include "RequestStartStopStatusEnumType20.h" +#include "StatusInfoType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the RequestStartTransaction messages */ +static const std::string REQUESTSTARTTRANSACTION_ACTION = "RequestStartTransaction"; + +/** @brief RequestStartTransactionReq message */ +struct RequestStartTransactionReq +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief Number of the EVSE on which to start the transaction. EvseId SHALL be > 0 */ + ocpp::types::Optional evseId; + /** @brief */ + ocpp::types::Optional groupIdToken; + /** @brief */ + ocpp::types::ocpp20::IdTokenType idToken; + /** @brief Id given by the server to this start request. The Charging Station might return this in the <<transactioneventrequest, TransactionEventRequest>>, letting the server know which transaction was started for this request. Use to start a transaction. */ + int remoteStartId; + /** @brief */ + ocpp::types::Optional chargingProfile; +}; + +/** @brief RequestStartTransactionConf message */ +struct RequestStartTransactionConf +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::ocpp20::RequestStartStopStatusEnumType status; + /** @brief */ + ocpp::types::Optional statusInfo; + /** @brief When the transaction was already started by the Charging Station before the RequestStartTransactionRequest was received, for example: cable plugged in first. This contains the transactionId of the already started transaction. */ + ocpp::types::Optional> transactionId; +}; + +// Message converters +MESSAGE_CONVERTERS(RequestStartTransaction) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_REQUESTSTARTTRANSACTION_H \ No newline at end of file diff --git a/src/ocpp20/messages/RequestStopTransaction20.cpp b/src/ocpp20/messages/RequestStopTransaction20.cpp new file mode 100644 index 00000000..2a55f14d --- /dev/null +++ b/src/ocpp20/messages/RequestStopTransaction20.cpp @@ -0,0 +1,148 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:RequestStopTransactionRequest + OCPP 2.0.1 FINAL +*/ + +#include "RequestStopTransaction20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a RequestStopTransactionReq from a JSON representation */ +bool RequestStopTransactionReqConverter::fromJson(const rapidjson::Value& json, + RequestStopTransactionReq& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // transactionId + extract(json, "transactionId", data.transactionId); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a RequestStopTransactionReq to a JSON representation */ +bool RequestStopTransactionReqConverter::toJson(const RequestStopTransactionReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // transactionId + fill(json, "transactionId", data.transactionId); + + return ret; +} + +/** @brief Convert a RequestStopTransactionConf from a JSON representation */ +bool RequestStopTransactionConfConverter::fromJson(const rapidjson::Value& json, + RequestStopTransactionConf& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // status + data.status = ocpp::types::ocpp20::RequestStartStopStatusEnumTypeHelper.fromString(json["status"].GetString()); + + // statusInfo + if (json.HasMember("statusInfo")) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + ret = ret && statusInfo_converter.fromJson(json["statusInfo"], data.statusInfo, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a RequestStopTransactionConf to a JSON representation */ +bool RequestStopTransactionConfConverter::toJson(const RequestStopTransactionConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // status + fill(json, "status", ocpp::types::ocpp20::RequestStartStopStatusEnumTypeHelper.toString(data.status)); + + // statusInfo + if (data.statusInfo.isSet()) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + statusInfo_converter.setAllocator(allocator); + rapidjson::Document statusInfo_doc(rapidjson::kObjectType); + ret = ret && statusInfo_converter.toJson(data.statusInfo, statusInfo_doc); + json.AddMember(rapidjson::StringRef("statusInfo"), statusInfo_doc.Move(), *allocator); + } + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/RequestStopTransaction20.h b/src/ocpp20/messages/RequestStopTransaction20.h new file mode 100644 index 00000000..c3f85e8f --- /dev/null +++ b/src/ocpp20/messages/RequestStopTransaction20.h @@ -0,0 +1,70 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:RequestStopTransactionRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_REQUESTSTOPTRANSACTION_H +#define OPENOCPP_OCPP20_REQUESTSTOPTRANSACTION_H + +#include "IMessageConverter.h" + +#include "CustomDataType20.h" +#include "RequestStartStopStatusEnumType20.h" +#include "StatusInfoType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the RequestStopTransaction messages */ +static const std::string REQUESTSTOPTRANSACTION_ACTION = "RequestStopTransaction"; + +/** @brief RequestStopTransactionReq message */ +struct RequestStopTransactionReq +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief The identifier of the transaction which the Charging Station is requested to stop. */ + ocpp::types::CiStringType<36u> transactionId; +}; + +/** @brief RequestStopTransactionConf message */ +struct RequestStopTransactionConf +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::ocpp20::RequestStartStopStatusEnumType status; + /** @brief */ + ocpp::types::Optional statusInfo; +}; + +// Message converters +MESSAGE_CONVERTERS(RequestStopTransaction) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_REQUESTSTOPTRANSACTION_H \ No newline at end of file diff --git a/src/ocpp20/messages/ReservationStatusUpdate20.cpp b/src/ocpp20/messages/ReservationStatusUpdate20.cpp new file mode 100644 index 00000000..abc79bf7 --- /dev/null +++ b/src/ocpp20/messages/ReservationStatusUpdate20.cpp @@ -0,0 +1,133 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:ReservationStatusUpdateRequest + OCPP 2.0.1 FINAL +*/ + +#include "ReservationStatusUpdate20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a ReservationStatusUpdateReq from a JSON representation */ +bool ReservationStatusUpdateReqConverter::fromJson(const rapidjson::Value& json, + ReservationStatusUpdateReq& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // reservationId + extract(json, "reservationId", data.reservationId); + + // reservationUpdateStatus + data.reservationUpdateStatus = + ocpp::types::ocpp20::ReservationUpdateStatusEnumTypeHelper.fromString(json["reservationUpdateStatus"].GetString()); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a ReservationStatusUpdateReq to a JSON representation */ +bool ReservationStatusUpdateReqConverter::toJson(const ReservationStatusUpdateReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // reservationId + fill(json, "reservationId", data.reservationId); + + // reservationUpdateStatus + fill( + json, "reservationUpdateStatus", ocpp::types::ocpp20::ReservationUpdateStatusEnumTypeHelper.toString(data.reservationUpdateStatus)); + + return ret; +} + +/** @brief Convert a ReservationStatusUpdateConf from a JSON representation */ +bool ReservationStatusUpdateConfConverter::fromJson(const rapidjson::Value& json, + ReservationStatusUpdateConf& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a ReservationStatusUpdateConf to a JSON representation */ +bool ReservationStatusUpdateConfConverter::toJson(const ReservationStatusUpdateConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/ReservationStatusUpdate20.h b/src/ocpp20/messages/ReservationStatusUpdate20.h new file mode 100644 index 00000000..850a0b47 --- /dev/null +++ b/src/ocpp20/messages/ReservationStatusUpdate20.h @@ -0,0 +1,67 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:ReservationStatusUpdateRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_RESERVATIONSTATUSUPDATE_H +#define OPENOCPP_OCPP20_RESERVATIONSTATUSUPDATE_H + +#include "IMessageConverter.h" + +#include "CustomDataType20.h" +#include "ReservationUpdateStatusEnumType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the ReservationStatusUpdate messages */ +static const std::string RESERVATIONSTATUSUPDATE_ACTION = "ReservationStatusUpdate"; + +/** @brief ReservationStatusUpdateReq message */ +struct ReservationStatusUpdateReq +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief The ID of the reservation. */ + int reservationId; + /** @brief */ + ocpp::types::ocpp20::ReservationUpdateStatusEnumType reservationUpdateStatus; +}; + +/** @brief ReservationStatusUpdateConf message */ +struct ReservationStatusUpdateConf +{ + /** @brief */ + ocpp::types::Optional customData; +}; + +// Message converters +MESSAGE_CONVERTERS(ReservationStatusUpdate) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_RESERVATIONSTATUSUPDATE_H \ No newline at end of file diff --git a/src/ocpp20/messages/ReserveNow20.cpp b/src/ocpp20/messages/ReserveNow20.cpp new file mode 100644 index 00000000..44bbe350 --- /dev/null +++ b/src/ocpp20/messages/ReserveNow20.cpp @@ -0,0 +1,200 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:ReserveNowRequest + OCPP 2.0.1 FINAL +*/ + +#include "ReserveNow20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a ReserveNowReq from a JSON representation */ +bool ReserveNowReqConverter::fromJson(const rapidjson::Value& json, + ReserveNowReq& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // id + extract(json, "id", data.id); + + // expiryDateTime + ret = ret && extract(json, "expiryDateTime", data.expiryDateTime, error_message); + + // connectorType + if (json.HasMember("connectorType")) + { + data.connectorType = ocpp::types::ocpp20::ConnectorEnumTypeHelper.fromString(json["connectorType"].GetString()); + } + + // idToken + ocpp::types::ocpp20::IdTokenTypeConverter idToken_converter; + ret = ret && idToken_converter.fromJson(json["idToken"], data.idToken, error_code, error_message); + + // evseId + extract(json, "evseId", data.evseId); + + // groupIdToken + if (json.HasMember("groupIdToken")) + { + ocpp::types::ocpp20::IdTokenTypeConverter groupIdToken_converter; + ret = ret && groupIdToken_converter.fromJson(json["groupIdToken"], data.groupIdToken, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a ReserveNowReq to a JSON representation */ +bool ReserveNowReqConverter::toJson(const ReserveNowReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // id + fill(json, "id", data.id); + + // expiryDateTime + fill(json, "expiryDateTime", data.expiryDateTime); + + // connectorType + if (data.connectorType.isSet()) + { + fill(json, "connectorType", ocpp::types::ocpp20::ConnectorEnumTypeHelper.toString(data.connectorType)); + } + + // idToken + ocpp::types::ocpp20::IdTokenTypeConverter idToken_converter; + idToken_converter.setAllocator(allocator); + rapidjson::Document idToken_doc(rapidjson::kObjectType); + ret = ret && idToken_converter.toJson(data.idToken, idToken_doc); + json.AddMember(rapidjson::StringRef("idToken"), idToken_doc.Move(), *allocator); + + // evseId + fill(json, "evseId", data.evseId); + + // groupIdToken + if (data.groupIdToken.isSet()) + { + ocpp::types::ocpp20::IdTokenTypeConverter groupIdToken_converter; + groupIdToken_converter.setAllocator(allocator); + rapidjson::Document groupIdToken_doc(rapidjson::kObjectType); + ret = ret && groupIdToken_converter.toJson(data.groupIdToken, groupIdToken_doc); + json.AddMember(rapidjson::StringRef("groupIdToken"), groupIdToken_doc.Move(), *allocator); + } + + return ret; +} + +/** @brief Convert a ReserveNowConf from a JSON representation */ +bool ReserveNowConfConverter::fromJson(const rapidjson::Value& json, + ReserveNowConf& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // status + data.status = ocpp::types::ocpp20::ReserveNowStatusEnumTypeHelper.fromString(json["status"].GetString()); + + // statusInfo + if (json.HasMember("statusInfo")) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + ret = ret && statusInfo_converter.fromJson(json["statusInfo"], data.statusInfo, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a ReserveNowConf to a JSON representation */ +bool ReserveNowConfConverter::toJson(const ReserveNowConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // status + fill(json, "status", ocpp::types::ocpp20::ReserveNowStatusEnumTypeHelper.toString(data.status)); + + // statusInfo + if (data.statusInfo.isSet()) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + statusInfo_converter.setAllocator(allocator); + rapidjson::Document statusInfo_doc(rapidjson::kObjectType); + ret = ret && statusInfo_converter.toJson(data.statusInfo, statusInfo_doc); + json.AddMember(rapidjson::StringRef("statusInfo"), statusInfo_doc.Move(), *allocator); + } + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/ReserveNow20.h b/src/ocpp20/messages/ReserveNow20.h new file mode 100644 index 00000000..ae905c8b --- /dev/null +++ b/src/ocpp20/messages/ReserveNow20.h @@ -0,0 +1,82 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:ReserveNowRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_RESERVENOW_H +#define OPENOCPP_OCPP20_RESERVENOW_H + +#include "IMessageConverter.h" + +#include "ConnectorEnumType20.h" +#include "CustomDataType20.h" +#include "IdTokenType20.h" +#include "ReserveNowStatusEnumType20.h" +#include "StatusInfoType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the ReserveNow messages */ +static const std::string RESERVENOW_ACTION = "ReserveNow"; + +/** @brief ReserveNowReq message */ +struct ReserveNowReq +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief Id of reservation. */ + int id; + /** @brief Date and time at which the reservation expires. */ + ocpp::types::DateTime expiryDateTime; + /** @brief */ + ocpp::types::Optional connectorType; + /** @brief */ + ocpp::types::ocpp20::IdTokenType idToken; + /** @brief This contains ID of the evse to be reserved. */ + ocpp::types::Optional evseId; + /** @brief */ + ocpp::types::Optional groupIdToken; +}; + +/** @brief ReserveNowConf message */ +struct ReserveNowConf +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::ocpp20::ReserveNowStatusEnumType status; + /** @brief */ + ocpp::types::Optional statusInfo; +}; + +// Message converters +MESSAGE_CONVERTERS(ReserveNow) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_RESERVENOW_H \ No newline at end of file diff --git a/src/ocpp20/messages/Reset20.cpp b/src/ocpp20/messages/Reset20.cpp new file mode 100644 index 00000000..cf831290 --- /dev/null +++ b/src/ocpp20/messages/Reset20.cpp @@ -0,0 +1,148 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:ResetRequest + OCPP 2.0.1 FINAL +*/ + +#include "Reset20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a ResetReq from a JSON representation */ +bool ResetReqConverter::fromJson(const rapidjson::Value& json, ResetReq& data, std::string& error_code, std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // type + data.type = ocpp::types::ocpp20::ResetEnumTypeHelper.fromString(json["type"].GetString()); + + // evseId + extract(json, "evseId", data.evseId); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a ResetReq to a JSON representation */ +bool ResetReqConverter::toJson(const ResetReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // type + fill(json, "type", ocpp::types::ocpp20::ResetEnumTypeHelper.toString(data.type)); + + // evseId + fill(json, "evseId", data.evseId); + + return ret; +} + +/** @brief Convert a ResetConf from a JSON representation */ +bool ResetConfConverter::fromJson(const rapidjson::Value& json, ResetConf& data, std::string& error_code, std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // status + data.status = ocpp::types::ocpp20::ResetStatusEnumTypeHelper.fromString(json["status"].GetString()); + + // statusInfo + if (json.HasMember("statusInfo")) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + ret = ret && statusInfo_converter.fromJson(json["statusInfo"], data.statusInfo, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a ResetConf to a JSON representation */ +bool ResetConfConverter::toJson(const ResetConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // status + fill(json, "status", ocpp::types::ocpp20::ResetStatusEnumTypeHelper.toString(data.status)); + + // statusInfo + if (data.statusInfo.isSet()) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + statusInfo_converter.setAllocator(allocator); + rapidjson::Document statusInfo_doc(rapidjson::kObjectType); + ret = ret && statusInfo_converter.toJson(data.statusInfo, statusInfo_doc); + json.AddMember(rapidjson::StringRef("statusInfo"), statusInfo_doc.Move(), *allocator); + } + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/Reset20.h b/src/ocpp20/messages/Reset20.h new file mode 100644 index 00000000..ddfa78c9 --- /dev/null +++ b/src/ocpp20/messages/Reset20.h @@ -0,0 +1,73 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:ResetRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_RESET_H +#define OPENOCPP_OCPP20_RESET_H + +#include "IMessageConverter.h" + +#include "CustomDataType20.h" +#include "ResetEnumType20.h" +#include "ResetStatusEnumType20.h" +#include "StatusInfoType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the Reset messages */ +static const std::string RESET_ACTION = "Reset"; + +/** @brief ResetReq message */ +struct ResetReq +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::ocpp20::ResetEnumType type; + /** @brief This contains the ID of a specific EVSE that needs to be reset, instead of the entire Charging Station. */ + ocpp::types::Optional evseId; +}; + +/** @brief ResetConf message */ +struct ResetConf +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::ocpp20::ResetStatusEnumType status; + /** @brief */ + ocpp::types::Optional statusInfo; +}; + +// Message converters +MESSAGE_CONVERTERS(Reset) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_RESET_H \ No newline at end of file diff --git a/src/ocpp20/messages/SecurityEventNotification20.cpp b/src/ocpp20/messages/SecurityEventNotification20.cpp new file mode 100644 index 00000000..3685e154 --- /dev/null +++ b/src/ocpp20/messages/SecurityEventNotification20.cpp @@ -0,0 +1,137 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SecurityEventNotificationRequest + OCPP 2.0.1 FINAL +*/ + +#include "SecurityEventNotification20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a SecurityEventNotificationReq from a JSON representation */ +bool SecurityEventNotificationReqConverter::fromJson(const rapidjson::Value& json, + SecurityEventNotificationReq& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // type + extract(json, "type", data.type); + + // timestamp + ret = ret && extract(json, "timestamp", data.timestamp, error_message); + + // techInfo + extract(json, "techInfo", data.techInfo); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a SecurityEventNotificationReq to a JSON representation */ +bool SecurityEventNotificationReqConverter::toJson(const SecurityEventNotificationReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // type + fill(json, "type", data.type); + + // timestamp + fill(json, "timestamp", data.timestamp); + + // techInfo + fill(json, "techInfo", data.techInfo); + + return ret; +} + +/** @brief Convert a SecurityEventNotificationConf from a JSON representation */ +bool SecurityEventNotificationConfConverter::fromJson(const rapidjson::Value& json, + SecurityEventNotificationConf& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a SecurityEventNotificationConf to a JSON representation */ +bool SecurityEventNotificationConfConverter::toJson(const SecurityEventNotificationConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/SecurityEventNotification20.h b/src/ocpp20/messages/SecurityEventNotification20.h new file mode 100644 index 00000000..02f84d6a --- /dev/null +++ b/src/ocpp20/messages/SecurityEventNotification20.h @@ -0,0 +1,68 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SecurityEventNotificationRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_SECURITYEVENTNOTIFICATION_H +#define OPENOCPP_OCPP20_SECURITYEVENTNOTIFICATION_H + +#include "IMessageConverter.h" + +#include "CustomDataType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the SecurityEventNotification messages */ +static const std::string SECURITYEVENTNOTIFICATION_ACTION = "SecurityEventNotification"; + +/** @brief SecurityEventNotificationReq message */ +struct SecurityEventNotificationReq +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief Type of the security event. This value should be taken from the Security events list. */ + ocpp::types::CiStringType<50u> type; + /** @brief Date and time at which the event occurred. */ + ocpp::types::DateTime timestamp; + /** @brief Additional information about the occurred security event. */ + ocpp::types::Optional> techInfo; +}; + +/** @brief SecurityEventNotificationConf message */ +struct SecurityEventNotificationConf +{ + /** @brief */ + ocpp::types::Optional customData; +}; + +// Message converters +MESSAGE_CONVERTERS(SecurityEventNotification) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_SECURITYEVENTNOTIFICATION_H \ No newline at end of file diff --git a/src/ocpp20/messages/SendLocalList20.cpp b/src/ocpp20/messages/SendLocalList20.cpp new file mode 100644 index 00000000..80cd4d22 --- /dev/null +++ b/src/ocpp20/messages/SendLocalList20.cpp @@ -0,0 +1,182 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SendLocalListRequest + OCPP 2.0.1 FINAL +*/ + +#include "SendLocalList20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a SendLocalListReq from a JSON representation */ +bool SendLocalListReqConverter::fromJson(const rapidjson::Value& json, + SendLocalListReq& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // localAuthorizationList + if (json.HasMember("localAuthorizationList")) + { + const rapidjson::Value& localAuthorizationList_json = json["localAuthorizationList"]; + ocpp::types::ocpp20::AuthorizationDataConverter localAuthorizationList_converter; + for (auto it = localAuthorizationList_json.Begin(); ret && (it != localAuthorizationList_json.End()); ++it) + { + ocpp::types::ocpp20::AuthorizationData& item = data.localAuthorizationList.emplace_back(); + ret = ret && localAuthorizationList_converter.fromJson(*it, item, error_code, error_message); + } + } + + // versionNumber + extract(json, "versionNumber", data.versionNumber); + + // updateType + data.updateType = ocpp::types::ocpp20::UpdateEnumTypeHelper.fromString(json["updateType"].GetString()); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a SendLocalListReq to a JSON representation */ +bool SendLocalListReqConverter::toJson(const SendLocalListReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // localAuthorizationList + if (!data.localAuthorizationList.empty()) + { + + rapidjson::Value localAuthorizationList_json(rapidjson::kArrayType); + ocpp::types::ocpp20::AuthorizationDataConverter localAuthorizationList_converter; + localAuthorizationList_converter.setAllocator(allocator); + for (const ocpp::types::ocpp20::AuthorizationData& item : data.localAuthorizationList) + { + rapidjson::Document item_doc(rapidjson::kObjectType); + ret = ret && localAuthorizationList_converter.toJson(item, item_doc); + localAuthorizationList_json.PushBack(item_doc.Move(), *allocator); + } + json.AddMember(rapidjson::StringRef("localAuthorizationList"), localAuthorizationList_json.Move(), *allocator); + } + + // versionNumber + fill(json, "versionNumber", data.versionNumber); + + // updateType + fill(json, "updateType", ocpp::types::ocpp20::UpdateEnumTypeHelper.toString(data.updateType)); + + return ret; +} + +/** @brief Convert a SendLocalListConf from a JSON representation */ +bool SendLocalListConfConverter::fromJson(const rapidjson::Value& json, + SendLocalListConf& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // status + data.status = ocpp::types::ocpp20::SendLocalListStatusEnumTypeHelper.fromString(json["status"].GetString()); + + // statusInfo + if (json.HasMember("statusInfo")) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + ret = ret && statusInfo_converter.fromJson(json["statusInfo"], data.statusInfo, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a SendLocalListConf to a JSON representation */ +bool SendLocalListConfConverter::toJson(const SendLocalListConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // status + fill(json, "status", ocpp::types::ocpp20::SendLocalListStatusEnumTypeHelper.toString(data.status)); + + // statusInfo + if (data.statusInfo.isSet()) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + statusInfo_converter.setAllocator(allocator); + rapidjson::Document statusInfo_doc(rapidjson::kObjectType); + ret = ret && statusInfo_converter.toJson(data.statusInfo, statusInfo_doc); + json.AddMember(rapidjson::StringRef("statusInfo"), statusInfo_doc.Move(), *allocator); + } + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/SendLocalList20.h b/src/ocpp20/messages/SendLocalList20.h new file mode 100644 index 00000000..ff4491fd --- /dev/null +++ b/src/ocpp20/messages/SendLocalList20.h @@ -0,0 +1,76 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SendLocalListRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_SENDLOCALLIST_H +#define OPENOCPP_OCPP20_SENDLOCALLIST_H + +#include "IMessageConverter.h" + +#include "AuthorizationData20.h" +#include "CustomDataType20.h" +#include "SendLocalListStatusEnumType20.h" +#include "StatusInfoType20.h" +#include "UpdateEnumType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the SendLocalList messages */ +static const std::string SENDLOCALLIST_ACTION = "SendLocalList"; + +/** @brief SendLocalListReq message */ +struct SendLocalListReq +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + std::vector localAuthorizationList; + /** @brief In case of a full update this is the version number of the full list. In case of a differential update it is the version number of the list after the update has been applied. */ + int versionNumber; + /** @brief */ + ocpp::types::ocpp20::UpdateEnumType updateType; +}; + +/** @brief SendLocalListConf message */ +struct SendLocalListConf +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::ocpp20::SendLocalListStatusEnumType status; + /** @brief */ + ocpp::types::Optional statusInfo; +}; + +// Message converters +MESSAGE_CONVERTERS(SendLocalList) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_SENDLOCALLIST_H \ No newline at end of file diff --git a/src/ocpp20/messages/SetChargingProfile20.cpp b/src/ocpp20/messages/SetChargingProfile20.cpp new file mode 100644 index 00000000..1a2484d2 --- /dev/null +++ b/src/ocpp20/messages/SetChargingProfile20.cpp @@ -0,0 +1,159 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SetChargingProfileRequest + OCPP 2.0.1 FINAL +*/ + +#include "SetChargingProfile20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a SetChargingProfileReq from a JSON representation */ +bool SetChargingProfileReqConverter::fromJson(const rapidjson::Value& json, + SetChargingProfileReq& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // evseId + extract(json, "evseId", data.evseId); + + // chargingProfile + ocpp::types::ocpp20::ChargingProfileTypeConverter chargingProfile_converter; + ret = ret && chargingProfile_converter.fromJson(json["chargingProfile"], data.chargingProfile, error_code, error_message); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a SetChargingProfileReq to a JSON representation */ +bool SetChargingProfileReqConverter::toJson(const SetChargingProfileReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // evseId + fill(json, "evseId", data.evseId); + + // chargingProfile + ocpp::types::ocpp20::ChargingProfileTypeConverter chargingProfile_converter; + chargingProfile_converter.setAllocator(allocator); + rapidjson::Document chargingProfile_doc(rapidjson::kObjectType); + ret = ret && chargingProfile_converter.toJson(data.chargingProfile, chargingProfile_doc); + json.AddMember(rapidjson::StringRef("chargingProfile"), chargingProfile_doc.Move(), *allocator); + + return ret; +} + +/** @brief Convert a SetChargingProfileConf from a JSON representation */ +bool SetChargingProfileConfConverter::fromJson(const rapidjson::Value& json, + SetChargingProfileConf& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // status + data.status = ocpp::types::ocpp20::ChargingProfileStatusEnumTypeHelper.fromString(json["status"].GetString()); + + // statusInfo + if (json.HasMember("statusInfo")) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + ret = ret && statusInfo_converter.fromJson(json["statusInfo"], data.statusInfo, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a SetChargingProfileConf to a JSON representation */ +bool SetChargingProfileConfConverter::toJson(const SetChargingProfileConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // status + fill(json, "status", ocpp::types::ocpp20::ChargingProfileStatusEnumTypeHelper.toString(data.status)); + + // statusInfo + if (data.statusInfo.isSet()) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + statusInfo_converter.setAllocator(allocator); + rapidjson::Document statusInfo_doc(rapidjson::kObjectType); + ret = ret && statusInfo_converter.toJson(data.statusInfo, statusInfo_doc); + json.AddMember(rapidjson::StringRef("statusInfo"), statusInfo_doc.Move(), *allocator); + } + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/SetChargingProfile20.h b/src/ocpp20/messages/SetChargingProfile20.h new file mode 100644 index 00000000..89e2df9f --- /dev/null +++ b/src/ocpp20/messages/SetChargingProfile20.h @@ -0,0 +1,73 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SetChargingProfileRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_SETCHARGINGPROFILE_H +#define OPENOCPP_OCPP20_SETCHARGINGPROFILE_H + +#include "IMessageConverter.h" + +#include "ChargingProfileStatusEnumType20.h" +#include "ChargingProfileType20.h" +#include "CustomDataType20.h" +#include "StatusInfoType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the SetChargingProfile messages */ +static const std::string SETCHARGINGPROFILE_ACTION = "SetChargingProfile"; + +/** @brief SetChargingProfileReq message */ +struct SetChargingProfileReq +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief For TxDefaultProfile an evseId=0 applies the profile to each individual evse. For ChargingStationMaxProfile and ChargingStationExternalConstraints an evseId=0 contains an overal limit for the whole Charging Station. */ + int evseId; + /** @brief */ + ocpp::types::ocpp20::ChargingProfileType chargingProfile; +}; + +/** @brief SetChargingProfileConf message */ +struct SetChargingProfileConf +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::ocpp20::ChargingProfileStatusEnumType status; + /** @brief */ + ocpp::types::Optional statusInfo; +}; + +// Message converters +MESSAGE_CONVERTERS(SetChargingProfile) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_SETCHARGINGPROFILE_H \ No newline at end of file diff --git a/src/ocpp20/messages/SetDisplayMessage20.cpp b/src/ocpp20/messages/SetDisplayMessage20.cpp new file mode 100644 index 00000000..e62f3634 --- /dev/null +++ b/src/ocpp20/messages/SetDisplayMessage20.cpp @@ -0,0 +1,153 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SetDisplayMessageRequest + OCPP 2.0.1 FINAL +*/ + +#include "SetDisplayMessage20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a SetDisplayMessageReq from a JSON representation */ +bool SetDisplayMessageReqConverter::fromJson(const rapidjson::Value& json, + SetDisplayMessageReq& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // message + ocpp::types::ocpp20::MessageInfoTypeConverter message_converter; + ret = ret && message_converter.fromJson(json["message"], data.message, error_code, error_message); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a SetDisplayMessageReq to a JSON representation */ +bool SetDisplayMessageReqConverter::toJson(const SetDisplayMessageReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // message + ocpp::types::ocpp20::MessageInfoTypeConverter message_converter; + message_converter.setAllocator(allocator); + rapidjson::Document message_doc(rapidjson::kObjectType); + ret = ret && message_converter.toJson(data.message, message_doc); + json.AddMember(rapidjson::StringRef("message"), message_doc.Move(), *allocator); + + return ret; +} + +/** @brief Convert a SetDisplayMessageConf from a JSON representation */ +bool SetDisplayMessageConfConverter::fromJson(const rapidjson::Value& json, + SetDisplayMessageConf& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // status + data.status = ocpp::types::ocpp20::DisplayMessageStatusEnumTypeHelper.fromString(json["status"].GetString()); + + // statusInfo + if (json.HasMember("statusInfo")) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + ret = ret && statusInfo_converter.fromJson(json["statusInfo"], data.statusInfo, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a SetDisplayMessageConf to a JSON representation */ +bool SetDisplayMessageConfConverter::toJson(const SetDisplayMessageConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // status + fill(json, "status", ocpp::types::ocpp20::DisplayMessageStatusEnumTypeHelper.toString(data.status)); + + // statusInfo + if (data.statusInfo.isSet()) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + statusInfo_converter.setAllocator(allocator); + rapidjson::Document statusInfo_doc(rapidjson::kObjectType); + ret = ret && statusInfo_converter.toJson(data.statusInfo, statusInfo_doc); + json.AddMember(rapidjson::StringRef("statusInfo"), statusInfo_doc.Move(), *allocator); + } + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/SetDisplayMessage20.h b/src/ocpp20/messages/SetDisplayMessage20.h new file mode 100644 index 00000000..3ed92982 --- /dev/null +++ b/src/ocpp20/messages/SetDisplayMessage20.h @@ -0,0 +1,71 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SetDisplayMessageRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_SETDISPLAYMESSAGE_H +#define OPENOCPP_OCPP20_SETDISPLAYMESSAGE_H + +#include "IMessageConverter.h" + +#include "CustomDataType20.h" +#include "DisplayMessageStatusEnumType20.h" +#include "MessageInfoType20.h" +#include "StatusInfoType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the SetDisplayMessage messages */ +static const std::string SETDISPLAYMESSAGE_ACTION = "SetDisplayMessage"; + +/** @brief SetDisplayMessageReq message */ +struct SetDisplayMessageReq +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::ocpp20::MessageInfoType message; +}; + +/** @brief SetDisplayMessageConf message */ +struct SetDisplayMessageConf +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::ocpp20::DisplayMessageStatusEnumType status; + /** @brief */ + ocpp::types::Optional statusInfo; +}; + +// Message converters +MESSAGE_CONVERTERS(SetDisplayMessage) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_SETDISPLAYMESSAGE_H \ No newline at end of file diff --git a/src/ocpp20/messages/SetMonitoringBase20.cpp b/src/ocpp20/messages/SetMonitoringBase20.cpp new file mode 100644 index 00000000..511d849b --- /dev/null +++ b/src/ocpp20/messages/SetMonitoringBase20.cpp @@ -0,0 +1,148 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SetMonitoringBaseRequest + OCPP 2.0.1 FINAL +*/ + +#include "SetMonitoringBase20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a SetMonitoringBaseReq from a JSON representation */ +bool SetMonitoringBaseReqConverter::fromJson(const rapidjson::Value& json, + SetMonitoringBaseReq& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // monitoringBase + data.monitoringBase = ocpp::types::ocpp20::MonitoringBaseEnumTypeHelper.fromString(json["monitoringBase"].GetString()); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a SetMonitoringBaseReq to a JSON representation */ +bool SetMonitoringBaseReqConverter::toJson(const SetMonitoringBaseReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // monitoringBase + fill(json, "monitoringBase", ocpp::types::ocpp20::MonitoringBaseEnumTypeHelper.toString(data.monitoringBase)); + + return ret; +} + +/** @brief Convert a SetMonitoringBaseConf from a JSON representation */ +bool SetMonitoringBaseConfConverter::fromJson(const rapidjson::Value& json, + SetMonitoringBaseConf& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // status + data.status = ocpp::types::ocpp20::GenericDeviceModelStatusEnumTypeHelper.fromString(json["status"].GetString()); + + // statusInfo + if (json.HasMember("statusInfo")) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + ret = ret && statusInfo_converter.fromJson(json["statusInfo"], data.statusInfo, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a SetMonitoringBaseConf to a JSON representation */ +bool SetMonitoringBaseConfConverter::toJson(const SetMonitoringBaseConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // status + fill(json, "status", ocpp::types::ocpp20::GenericDeviceModelStatusEnumTypeHelper.toString(data.status)); + + // statusInfo + if (data.statusInfo.isSet()) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + statusInfo_converter.setAllocator(allocator); + rapidjson::Document statusInfo_doc(rapidjson::kObjectType); + ret = ret && statusInfo_converter.toJson(data.statusInfo, statusInfo_doc); + json.AddMember(rapidjson::StringRef("statusInfo"), statusInfo_doc.Move(), *allocator); + } + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/SetMonitoringBase20.h b/src/ocpp20/messages/SetMonitoringBase20.h new file mode 100644 index 00000000..ac79942b --- /dev/null +++ b/src/ocpp20/messages/SetMonitoringBase20.h @@ -0,0 +1,71 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SetMonitoringBaseRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_SETMONITORINGBASE_H +#define OPENOCPP_OCPP20_SETMONITORINGBASE_H + +#include "IMessageConverter.h" + +#include "CustomDataType20.h" +#include "GenericDeviceModelStatusEnumType20.h" +#include "MonitoringBaseEnumType20.h" +#include "StatusInfoType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the SetMonitoringBase messages */ +static const std::string SETMONITORINGBASE_ACTION = "SetMonitoringBase"; + +/** @brief SetMonitoringBaseReq message */ +struct SetMonitoringBaseReq +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::ocpp20::MonitoringBaseEnumType monitoringBase; +}; + +/** @brief SetMonitoringBaseConf message */ +struct SetMonitoringBaseConf +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::ocpp20::GenericDeviceModelStatusEnumType status; + /** @brief */ + ocpp::types::Optional statusInfo; +}; + +// Message converters +MESSAGE_CONVERTERS(SetMonitoringBase) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_SETMONITORINGBASE_H \ No newline at end of file diff --git a/src/ocpp20/messages/SetMonitoringLevel20.cpp b/src/ocpp20/messages/SetMonitoringLevel20.cpp new file mode 100644 index 00000000..f824bf78 --- /dev/null +++ b/src/ocpp20/messages/SetMonitoringLevel20.cpp @@ -0,0 +1,148 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SetMonitoringLevelRequest + OCPP 2.0.1 FINAL +*/ + +#include "SetMonitoringLevel20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a SetMonitoringLevelReq from a JSON representation */ +bool SetMonitoringLevelReqConverter::fromJson(const rapidjson::Value& json, + SetMonitoringLevelReq& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // severity + extract(json, "severity", data.severity); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a SetMonitoringLevelReq to a JSON representation */ +bool SetMonitoringLevelReqConverter::toJson(const SetMonitoringLevelReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // severity + fill(json, "severity", data.severity); + + return ret; +} + +/** @brief Convert a SetMonitoringLevelConf from a JSON representation */ +bool SetMonitoringLevelConfConverter::fromJson(const rapidjson::Value& json, + SetMonitoringLevelConf& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // status + data.status = ocpp::types::ocpp20::GenericStatusEnumTypeHelper.fromString(json["status"].GetString()); + + // statusInfo + if (json.HasMember("statusInfo")) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + ret = ret && statusInfo_converter.fromJson(json["statusInfo"], data.statusInfo, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a SetMonitoringLevelConf to a JSON representation */ +bool SetMonitoringLevelConfConverter::toJson(const SetMonitoringLevelConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // status + fill(json, "status", ocpp::types::ocpp20::GenericStatusEnumTypeHelper.toString(data.status)); + + // statusInfo + if (data.statusInfo.isSet()) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + statusInfo_converter.setAllocator(allocator); + rapidjson::Document statusInfo_doc(rapidjson::kObjectType); + ret = ret && statusInfo_converter.toJson(data.statusInfo, statusInfo_doc); + json.AddMember(rapidjson::StringRef("statusInfo"), statusInfo_doc.Move(), *allocator); + } + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/SetMonitoringLevel20.h b/src/ocpp20/messages/SetMonitoringLevel20.h new file mode 100644 index 00000000..c290618d --- /dev/null +++ b/src/ocpp20/messages/SetMonitoringLevel20.h @@ -0,0 +1,93 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SetMonitoringLevelRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_SETMONITORINGLEVEL_H +#define OPENOCPP_OCPP20_SETMONITORINGLEVEL_H + +#include "IMessageConverter.h" + +#include "CustomDataType20.h" +#include "GenericStatusEnumType20.h" +#include "StatusInfoType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the SetMonitoringLevel messages */ +static const std::string SETMONITORINGLEVEL_ACTION = "SetMonitoringLevel"; + +/** @brief SetMonitoringLevelReq message */ +struct SetMonitoringLevelReq +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief The Charging Station SHALL only report events with a severity number lower than or equal to this severity. +The severity range is 0-9, with 0 as the highest and 9 as the lowest severity level. + +The severity levels have the following meaning: + +*0-Danger* + +Indicates lives are potentially in danger. Urgent attention is needed and action should be taken immediately. + +*1-Hardware Failure* + +Indicates that the Charging Station is unable to continue regular operations due to Hardware issues. Action is required. + +*2-System Failure* + +Indicates that the Charging Station is unable to continue regular operations due to software or minor hardware issues. Action is required. + +*3-Critical* + +Indicates a critical error. Action is required. + +*4-Error* + +Indicates a non-urgent error. Action is required. + +*5-Alert* + +Indicates an alert event. Default severity for any type of monitoring event. + +*6-Warning* + +Indicates a warning event. Action may be required. + +*7-Notice* + +Indicates an unusual event. No immediate action is required. + +*8-Informational* + +Indicates a regular operational event. May be used for reporting, measuring throughput, etc. No action is required. + +*9-Debug* + +Indicates information useful to developers for debugging, not useful during operations. */ + int severity; +}; + +/** @brief SetMonitoringLevelConf message */ +struct SetMonitoringLevelConf +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::ocpp20::GenericStatusEnumType status; + /** @brief */ + ocpp::types::Optional statusInfo; +}; + +// Message converters +MESSAGE_CONVERTERS(SetMonitoringLevel) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_SETMONITORINGLEVEL_H \ No newline at end of file diff --git a/src/ocpp20/messages/SetNetworkProfile20.cpp b/src/ocpp20/messages/SetNetworkProfile20.cpp new file mode 100644 index 00000000..a6d0705c --- /dev/null +++ b/src/ocpp20/messages/SetNetworkProfile20.cpp @@ -0,0 +1,159 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SetNetworkProfileRequest + OCPP 2.0.1 FINAL +*/ + +#include "SetNetworkProfile20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a SetNetworkProfileReq from a JSON representation */ +bool SetNetworkProfileReqConverter::fromJson(const rapidjson::Value& json, + SetNetworkProfileReq& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // configurationSlot + extract(json, "configurationSlot", data.configurationSlot); + + // connectionData + ocpp::types::ocpp20::NetworkConnectionProfileTypeConverter connectionData_converter; + ret = ret && connectionData_converter.fromJson(json["connectionData"], data.connectionData, error_code, error_message); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a SetNetworkProfileReq to a JSON representation */ +bool SetNetworkProfileReqConverter::toJson(const SetNetworkProfileReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // configurationSlot + fill(json, "configurationSlot", data.configurationSlot); + + // connectionData + ocpp::types::ocpp20::NetworkConnectionProfileTypeConverter connectionData_converter; + connectionData_converter.setAllocator(allocator); + rapidjson::Document connectionData_doc(rapidjson::kObjectType); + ret = ret && connectionData_converter.toJson(data.connectionData, connectionData_doc); + json.AddMember(rapidjson::StringRef("connectionData"), connectionData_doc.Move(), *allocator); + + return ret; +} + +/** @brief Convert a SetNetworkProfileConf from a JSON representation */ +bool SetNetworkProfileConfConverter::fromJson(const rapidjson::Value& json, + SetNetworkProfileConf& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // status + data.status = ocpp::types::ocpp20::SetNetworkProfileStatusEnumTypeHelper.fromString(json["status"].GetString()); + + // statusInfo + if (json.HasMember("statusInfo")) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + ret = ret && statusInfo_converter.fromJson(json["statusInfo"], data.statusInfo, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a SetNetworkProfileConf to a JSON representation */ +bool SetNetworkProfileConfConverter::toJson(const SetNetworkProfileConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // status + fill(json, "status", ocpp::types::ocpp20::SetNetworkProfileStatusEnumTypeHelper.toString(data.status)); + + // statusInfo + if (data.statusInfo.isSet()) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + statusInfo_converter.setAllocator(allocator); + rapidjson::Document statusInfo_doc(rapidjson::kObjectType); + ret = ret && statusInfo_converter.toJson(data.statusInfo, statusInfo_doc); + json.AddMember(rapidjson::StringRef("statusInfo"), statusInfo_doc.Move(), *allocator); + } + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/SetNetworkProfile20.h b/src/ocpp20/messages/SetNetworkProfile20.h new file mode 100644 index 00000000..34a4e174 --- /dev/null +++ b/src/ocpp20/messages/SetNetworkProfile20.h @@ -0,0 +1,73 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SetNetworkProfileRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_SETNETWORKPROFILE_H +#define OPENOCPP_OCPP20_SETNETWORKPROFILE_H + +#include "IMessageConverter.h" + +#include "CustomDataType20.h" +#include "NetworkConnectionProfileType20.h" +#include "SetNetworkProfileStatusEnumType20.h" +#include "StatusInfoType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the SetNetworkProfile messages */ +static const std::string SETNETWORKPROFILE_ACTION = "SetNetworkProfile"; + +/** @brief SetNetworkProfileReq message */ +struct SetNetworkProfileReq +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief Slot in which the configuration should be stored. */ + int configurationSlot; + /** @brief */ + ocpp::types::ocpp20::NetworkConnectionProfileType connectionData; +}; + +/** @brief SetNetworkProfileConf message */ +struct SetNetworkProfileConf +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::ocpp20::SetNetworkProfileStatusEnumType status; + /** @brief */ + ocpp::types::Optional statusInfo; +}; + +// Message converters +MESSAGE_CONVERTERS(SetNetworkProfile) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_SETNETWORKPROFILE_H \ No newline at end of file diff --git a/src/ocpp20/messages/SetVariableMonitoring20.cpp b/src/ocpp20/messages/SetVariableMonitoring20.cpp new file mode 100644 index 00000000..ecfa34e3 --- /dev/null +++ b/src/ocpp20/messages/SetVariableMonitoring20.cpp @@ -0,0 +1,169 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SetVariableMonitoringRequest + OCPP 2.0.1 FINAL +*/ + +#include "SetVariableMonitoring20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a SetVariableMonitoringReq from a JSON representation */ +bool SetVariableMonitoringReqConverter::fromJson(const rapidjson::Value& json, + SetVariableMonitoringReq& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // setMonitoringData + if (json.HasMember("setMonitoringData")) + { + const rapidjson::Value& setMonitoringData_json = json["setMonitoringData"]; + ocpp::types::ocpp20::SetMonitoringDataTypeConverter setMonitoringData_converter; + for (auto it = setMonitoringData_json.Begin(); ret && (it != setMonitoringData_json.End()); ++it) + { + ocpp::types::ocpp20::SetMonitoringDataType& item = data.setMonitoringData.emplace_back(); + ret = ret && setMonitoringData_converter.fromJson(*it, item, error_code, error_message); + } + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a SetVariableMonitoringReq to a JSON representation */ +bool SetVariableMonitoringReqConverter::toJson(const SetVariableMonitoringReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // setMonitoringData + + rapidjson::Value setMonitoringData_json(rapidjson::kArrayType); + ocpp::types::ocpp20::SetMonitoringDataTypeConverter setMonitoringData_converter; + setMonitoringData_converter.setAllocator(allocator); + for (const ocpp::types::ocpp20::SetMonitoringDataType& item : data.setMonitoringData) + { + rapidjson::Document item_doc(rapidjson::kObjectType); + ret = ret && setMonitoringData_converter.toJson(item, item_doc); + setMonitoringData_json.PushBack(item_doc.Move(), *allocator); + } + json.AddMember(rapidjson::StringRef("setMonitoringData"), setMonitoringData_json.Move(), *allocator); + + return ret; +} + +/** @brief Convert a SetVariableMonitoringConf from a JSON representation */ +bool SetVariableMonitoringConfConverter::fromJson(const rapidjson::Value& json, + SetVariableMonitoringConf& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // setMonitoringResult + if (json.HasMember("setMonitoringResult")) + { + const rapidjson::Value& setMonitoringResult_json = json["setMonitoringResult"]; + ocpp::types::ocpp20::SetMonitoringResultTypeConverter setMonitoringResult_converter; + for (auto it = setMonitoringResult_json.Begin(); ret && (it != setMonitoringResult_json.End()); ++it) + { + ocpp::types::ocpp20::SetMonitoringResultType& item = data.setMonitoringResult.emplace_back(); + ret = ret && setMonitoringResult_converter.fromJson(*it, item, error_code, error_message); + } + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a SetVariableMonitoringConf to a JSON representation */ +bool SetVariableMonitoringConfConverter::toJson(const SetVariableMonitoringConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // setMonitoringResult + + rapidjson::Value setMonitoringResult_json(rapidjson::kArrayType); + ocpp::types::ocpp20::SetMonitoringResultTypeConverter setMonitoringResult_converter; + setMonitoringResult_converter.setAllocator(allocator); + for (const ocpp::types::ocpp20::SetMonitoringResultType& item : data.setMonitoringResult) + { + rapidjson::Document item_doc(rapidjson::kObjectType); + ret = ret && setMonitoringResult_converter.toJson(item, item_doc); + setMonitoringResult_json.PushBack(item_doc.Move(), *allocator); + } + json.AddMember(rapidjson::StringRef("setMonitoringResult"), setMonitoringResult_json.Move(), *allocator); + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/SetVariableMonitoring20.h b/src/ocpp20/messages/SetVariableMonitoring20.h new file mode 100644 index 00000000..2105d5af --- /dev/null +++ b/src/ocpp20/messages/SetVariableMonitoring20.h @@ -0,0 +1,68 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SetVariableMonitoringRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_SETVARIABLEMONITORING_H +#define OPENOCPP_OCPP20_SETVARIABLEMONITORING_H + +#include "IMessageConverter.h" + +#include "CustomDataType20.h" +#include "SetMonitoringDataType20.h" +#include "SetMonitoringResultType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the SetVariableMonitoring messages */ +static const std::string SETVARIABLEMONITORING_ACTION = "SetVariableMonitoring"; + +/** @brief SetVariableMonitoringReq message */ +struct SetVariableMonitoringReq +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + std::vector setMonitoringData; +}; + +/** @brief SetVariableMonitoringConf message */ +struct SetVariableMonitoringConf +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + std::vector setMonitoringResult; +}; + +// Message converters +MESSAGE_CONVERTERS(SetVariableMonitoring) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_SETVARIABLEMONITORING_H \ No newline at end of file diff --git a/src/ocpp20/messages/SetVariables20.cpp b/src/ocpp20/messages/SetVariables20.cpp new file mode 100644 index 00000000..d8f8af2e --- /dev/null +++ b/src/ocpp20/messages/SetVariables20.cpp @@ -0,0 +1,169 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SetVariablesRequest + OCPP 2.0.1 FINAL +*/ + +#include "SetVariables20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a SetVariablesReq from a JSON representation */ +bool SetVariablesReqConverter::fromJson(const rapidjson::Value& json, + SetVariablesReq& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // setVariableData + if (json.HasMember("setVariableData")) + { + const rapidjson::Value& setVariableData_json = json["setVariableData"]; + ocpp::types::ocpp20::SetVariableDataTypeConverter setVariableData_converter; + for (auto it = setVariableData_json.Begin(); ret && (it != setVariableData_json.End()); ++it) + { + ocpp::types::ocpp20::SetVariableDataType& item = data.setVariableData.emplace_back(); + ret = ret && setVariableData_converter.fromJson(*it, item, error_code, error_message); + } + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a SetVariablesReq to a JSON representation */ +bool SetVariablesReqConverter::toJson(const SetVariablesReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // setVariableData + + rapidjson::Value setVariableData_json(rapidjson::kArrayType); + ocpp::types::ocpp20::SetVariableDataTypeConverter setVariableData_converter; + setVariableData_converter.setAllocator(allocator); + for (const ocpp::types::ocpp20::SetVariableDataType& item : data.setVariableData) + { + rapidjson::Document item_doc(rapidjson::kObjectType); + ret = ret && setVariableData_converter.toJson(item, item_doc); + setVariableData_json.PushBack(item_doc.Move(), *allocator); + } + json.AddMember(rapidjson::StringRef("setVariableData"), setVariableData_json.Move(), *allocator); + + return ret; +} + +/** @brief Convert a SetVariablesConf from a JSON representation */ +bool SetVariablesConfConverter::fromJson(const rapidjson::Value& json, + SetVariablesConf& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // setVariableResult + if (json.HasMember("setVariableResult")) + { + const rapidjson::Value& setVariableResult_json = json["setVariableResult"]; + ocpp::types::ocpp20::SetVariableResultTypeConverter setVariableResult_converter; + for (auto it = setVariableResult_json.Begin(); ret && (it != setVariableResult_json.End()); ++it) + { + ocpp::types::ocpp20::SetVariableResultType& item = data.setVariableResult.emplace_back(); + ret = ret && setVariableResult_converter.fromJson(*it, item, error_code, error_message); + } + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a SetVariablesConf to a JSON representation */ +bool SetVariablesConfConverter::toJson(const SetVariablesConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // setVariableResult + + rapidjson::Value setVariableResult_json(rapidjson::kArrayType); + ocpp::types::ocpp20::SetVariableResultTypeConverter setVariableResult_converter; + setVariableResult_converter.setAllocator(allocator); + for (const ocpp::types::ocpp20::SetVariableResultType& item : data.setVariableResult) + { + rapidjson::Document item_doc(rapidjson::kObjectType); + ret = ret && setVariableResult_converter.toJson(item, item_doc); + setVariableResult_json.PushBack(item_doc.Move(), *allocator); + } + json.AddMember(rapidjson::StringRef("setVariableResult"), setVariableResult_json.Move(), *allocator); + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/SetVariables20.h b/src/ocpp20/messages/SetVariables20.h new file mode 100644 index 00000000..3db99c3f --- /dev/null +++ b/src/ocpp20/messages/SetVariables20.h @@ -0,0 +1,68 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SetVariablesRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_SETVARIABLES_H +#define OPENOCPP_OCPP20_SETVARIABLES_H + +#include "IMessageConverter.h" + +#include "CustomDataType20.h" +#include "SetVariableDataType20.h" +#include "SetVariableResultType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the SetVariables messages */ +static const std::string SETVARIABLES_ACTION = "SetVariables"; + +/** @brief SetVariablesReq message */ +struct SetVariablesReq +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + std::vector setVariableData; +}; + +/** @brief SetVariablesConf message */ +struct SetVariablesConf +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + std::vector setVariableResult; +}; + +// Message converters +MESSAGE_CONVERTERS(SetVariables) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_SETVARIABLES_H \ No newline at end of file diff --git a/src/ocpp20/messages/SignCertificate20.cpp b/src/ocpp20/messages/SignCertificate20.cpp new file mode 100644 index 00000000..00315e03 --- /dev/null +++ b/src/ocpp20/messages/SignCertificate20.cpp @@ -0,0 +1,160 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SignCertificateRequest + OCPP 2.0.1 FINAL +*/ + +#include "SignCertificate20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a SignCertificateReq from a JSON representation */ +bool SignCertificateReqConverter::fromJson(const rapidjson::Value& json, + SignCertificateReq& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // csr + extract(json, "csr", data.csr); + + // certificateType + if (json.HasMember("certificateType")) + { + data.certificateType = ocpp::types::ocpp20::CertificateSigningUseEnumTypeHelper.fromString(json["certificateType"].GetString()); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a SignCertificateReq to a JSON representation */ +bool SignCertificateReqConverter::toJson(const SignCertificateReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // csr + fill(json, "csr", data.csr); + + // certificateType + if (data.certificateType.isSet()) + { + fill(json, "certificateType", ocpp::types::ocpp20::CertificateSigningUseEnumTypeHelper.toString(data.certificateType)); + } + + return ret; +} + +/** @brief Convert a SignCertificateConf from a JSON representation */ +bool SignCertificateConfConverter::fromJson(const rapidjson::Value& json, + SignCertificateConf& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // status + data.status = ocpp::types::ocpp20::GenericStatusEnumTypeHelper.fromString(json["status"].GetString()); + + // statusInfo + if (json.HasMember("statusInfo")) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + ret = ret && statusInfo_converter.fromJson(json["statusInfo"], data.statusInfo, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a SignCertificateConf to a JSON representation */ +bool SignCertificateConfConverter::toJson(const SignCertificateConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // status + fill(json, "status", ocpp::types::ocpp20::GenericStatusEnumTypeHelper.toString(data.status)); + + // statusInfo + if (data.statusInfo.isSet()) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + statusInfo_converter.setAllocator(allocator); + rapidjson::Document statusInfo_doc(rapidjson::kObjectType); + ret = ret && statusInfo_converter.toJson(data.statusInfo, statusInfo_doc); + json.AddMember(rapidjson::StringRef("statusInfo"), statusInfo_doc.Move(), *allocator); + } + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/SignCertificate20.h b/src/ocpp20/messages/SignCertificate20.h new file mode 100644 index 00000000..93ed081b --- /dev/null +++ b/src/ocpp20/messages/SignCertificate20.h @@ -0,0 +1,73 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SignCertificateRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_SIGNCERTIFICATE_H +#define OPENOCPP_OCPP20_SIGNCERTIFICATE_H + +#include "IMessageConverter.h" + +#include "CertificateSigningUseEnumType20.h" +#include "CustomDataType20.h" +#include "GenericStatusEnumType20.h" +#include "StatusInfoType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the SignCertificate messages */ +static const std::string SIGNCERTIFICATE_ACTION = "SignCertificate"; + +/** @brief SignCertificateReq message */ +struct SignCertificateReq +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief The Charging Station SHALL send the public key in form of a Certificate Signing Request (CSR) as described in RFC 2986 [22] and then PEM encoded, using the <<signcertificaterequest,SignCertificateRequest>> message. */ + ocpp::types::CiStringType<5500u> csr; + /** @brief */ + ocpp::types::Optional certificateType; +}; + +/** @brief SignCertificateConf message */ +struct SignCertificateConf +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::ocpp20::GenericStatusEnumType status; + /** @brief */ + ocpp::types::Optional statusInfo; +}; + +// Message converters +MESSAGE_CONVERTERS(SignCertificate) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_SIGNCERTIFICATE_H \ No newline at end of file diff --git a/src/ocpp20/messages/StatusNotification20.cpp b/src/ocpp20/messages/StatusNotification20.cpp new file mode 100644 index 00000000..541a0c26 --- /dev/null +++ b/src/ocpp20/messages/StatusNotification20.cpp @@ -0,0 +1,143 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:StatusNotificationRequest + OCPP 2.0.1 FINAL +*/ + +#include "StatusNotification20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a StatusNotificationReq from a JSON representation */ +bool StatusNotificationReqConverter::fromJson(const rapidjson::Value& json, + StatusNotificationReq& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // timestamp + ret = ret && extract(json, "timestamp", data.timestamp, error_message); + + // connectorStatus + data.connectorStatus = ocpp::types::ocpp20::ConnectorStatusEnumTypeHelper.fromString(json["connectorStatus"].GetString()); + + // evseId + extract(json, "evseId", data.evseId); + + // connectorId + extract(json, "connectorId", data.connectorId); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a StatusNotificationReq to a JSON representation */ +bool StatusNotificationReqConverter::toJson(const StatusNotificationReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // timestamp + fill(json, "timestamp", data.timestamp); + + // connectorStatus + fill(json, "connectorStatus", ocpp::types::ocpp20::ConnectorStatusEnumTypeHelper.toString(data.connectorStatus)); + + // evseId + fill(json, "evseId", data.evseId); + + // connectorId + fill(json, "connectorId", data.connectorId); + + return ret; +} + +/** @brief Convert a StatusNotificationConf from a JSON representation */ +bool StatusNotificationConfConverter::fromJson(const rapidjson::Value& json, + StatusNotificationConf& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a StatusNotificationConf to a JSON representation */ +bool StatusNotificationConfConverter::toJson(const StatusNotificationConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/StatusNotification20.h b/src/ocpp20/messages/StatusNotification20.h new file mode 100644 index 00000000..0ec796ac --- /dev/null +++ b/src/ocpp20/messages/StatusNotification20.h @@ -0,0 +1,71 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:StatusNotificationRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_STATUSNOTIFICATION_H +#define OPENOCPP_OCPP20_STATUSNOTIFICATION_H + +#include "IMessageConverter.h" + +#include "ConnectorStatusEnumType20.h" +#include "CustomDataType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the StatusNotification messages */ +static const std::string STATUSNOTIFICATION_ACTION = "StatusNotification"; + +/** @brief StatusNotificationReq message */ +struct StatusNotificationReq +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief The time for which the status is reported. If absent time of receipt of the message will be assumed. */ + ocpp::types::DateTime timestamp; + /** @brief */ + ocpp::types::ocpp20::ConnectorStatusEnumType connectorStatus; + /** @brief The id of the EVSE to which the connector belongs for which the the status is reported. */ + int evseId; + /** @brief The id of the connector within the EVSE for which the status is reported. */ + int connectorId; +}; + +/** @brief StatusNotificationConf message */ +struct StatusNotificationConf +{ + /** @brief */ + ocpp::types::Optional customData; +}; + +// Message converters +MESSAGE_CONVERTERS(StatusNotification) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_STATUSNOTIFICATION_H \ No newline at end of file diff --git a/src/ocpp20/messages/TransactionEvent20.cpp b/src/ocpp20/messages/TransactionEvent20.cpp new file mode 100644 index 00000000..978d2cd2 --- /dev/null +++ b/src/ocpp20/messages/TransactionEvent20.cpp @@ -0,0 +1,287 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:TransactionEventRequest + OCPP 2.0.1 FINAL +*/ + +#include "TransactionEvent20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a TransactionEventReq from a JSON representation */ +bool TransactionEventReqConverter::fromJson(const rapidjson::Value& json, + TransactionEventReq& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // eventType + data.eventType = ocpp::types::ocpp20::TransactionEventEnumTypeHelper.fromString(json["eventType"].GetString()); + + // meterValue + if (json.HasMember("meterValue")) + { + const rapidjson::Value& meterValue_json = json["meterValue"]; + ocpp::types::ocpp20::MeterValueTypeConverter meterValue_converter; + for (auto it = meterValue_json.Begin(); ret && (it != meterValue_json.End()); ++it) + { + ocpp::types::ocpp20::MeterValueType& item = data.meterValue.emplace_back(); + ret = ret && meterValue_converter.fromJson(*it, item, error_code, error_message); + } + } + + // timestamp + ret = ret && extract(json, "timestamp", data.timestamp, error_message); + + // triggerReason + data.triggerReason = ocpp::types::ocpp20::TriggerReasonEnumTypeHelper.fromString(json["triggerReason"].GetString()); + + // seqNo + extract(json, "seqNo", data.seqNo); + + // offline + extract(json, "offline", data.offline); + + // numberOfPhasesUsed + extract(json, "numberOfPhasesUsed", data.numberOfPhasesUsed); + + // cableMaxCurrent + extract(json, "cableMaxCurrent", data.cableMaxCurrent); + + // reservationId + extract(json, "reservationId", data.reservationId); + + // transactionInfo + ocpp::types::ocpp20::TransactionTypeConverter transactionInfo_converter; + ret = ret && transactionInfo_converter.fromJson(json["transactionInfo"], data.transactionInfo, error_code, error_message); + + // evse + if (json.HasMember("evse")) + { + ocpp::types::ocpp20::EVSETypeConverter evse_converter; + ret = ret && evse_converter.fromJson(json["evse"], data.evse, error_code, error_message); + } + + // idToken + if (json.HasMember("idToken")) + { + ocpp::types::ocpp20::IdTokenTypeConverter idToken_converter; + ret = ret && idToken_converter.fromJson(json["idToken"], data.idToken, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a TransactionEventReq to a JSON representation */ +bool TransactionEventReqConverter::toJson(const TransactionEventReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // eventType + fill(json, "eventType", ocpp::types::ocpp20::TransactionEventEnumTypeHelper.toString(data.eventType)); + + // meterValue + if (!data.meterValue.empty()) + { + + rapidjson::Value meterValue_json(rapidjson::kArrayType); + ocpp::types::ocpp20::MeterValueTypeConverter meterValue_converter; + meterValue_converter.setAllocator(allocator); + for (const ocpp::types::ocpp20::MeterValueType& item : data.meterValue) + { + rapidjson::Document item_doc(rapidjson::kObjectType); + ret = ret && meterValue_converter.toJson(item, item_doc); + meterValue_json.PushBack(item_doc.Move(), *allocator); + } + json.AddMember(rapidjson::StringRef("meterValue"), meterValue_json.Move(), *allocator); + } + + // timestamp + fill(json, "timestamp", data.timestamp); + + // triggerReason + fill(json, "triggerReason", ocpp::types::ocpp20::TriggerReasonEnumTypeHelper.toString(data.triggerReason)); + + // seqNo + fill(json, "seqNo", data.seqNo); + + // offline + fill(json, "offline", data.offline); + + // numberOfPhasesUsed + fill(json, "numberOfPhasesUsed", data.numberOfPhasesUsed); + + // cableMaxCurrent + fill(json, "cableMaxCurrent", data.cableMaxCurrent); + + // reservationId + fill(json, "reservationId", data.reservationId); + + // transactionInfo + ocpp::types::ocpp20::TransactionTypeConverter transactionInfo_converter; + transactionInfo_converter.setAllocator(allocator); + rapidjson::Document transactionInfo_doc(rapidjson::kObjectType); + ret = ret && transactionInfo_converter.toJson(data.transactionInfo, transactionInfo_doc); + json.AddMember(rapidjson::StringRef("transactionInfo"), transactionInfo_doc.Move(), *allocator); + + // evse + if (data.evse.isSet()) + { + ocpp::types::ocpp20::EVSETypeConverter evse_converter; + evse_converter.setAllocator(allocator); + rapidjson::Document evse_doc(rapidjson::kObjectType); + ret = ret && evse_converter.toJson(data.evse, evse_doc); + json.AddMember(rapidjson::StringRef("evse"), evse_doc.Move(), *allocator); + } + + // idToken + if (data.idToken.isSet()) + { + ocpp::types::ocpp20::IdTokenTypeConverter idToken_converter; + idToken_converter.setAllocator(allocator); + rapidjson::Document idToken_doc(rapidjson::kObjectType); + ret = ret && idToken_converter.toJson(data.idToken, idToken_doc); + json.AddMember(rapidjson::StringRef("idToken"), idToken_doc.Move(), *allocator); + } + + return ret; +} + +/** @brief Convert a TransactionEventConf from a JSON representation */ +bool TransactionEventConfConverter::fromJson(const rapidjson::Value& json, + TransactionEventConf& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // totalCost + extract(json, "totalCost", data.totalCost); + + // chargingPriority + extract(json, "chargingPriority", data.chargingPriority); + + // idTokenInfo + if (json.HasMember("idTokenInfo")) + { + ocpp::types::ocpp20::IdTokenInfoTypeConverter idTokenInfo_converter; + ret = ret && idTokenInfo_converter.fromJson(json["idTokenInfo"], data.idTokenInfo, error_code, error_message); + } + + // updatedPersonalMessage + if (json.HasMember("updatedPersonalMessage")) + { + ocpp::types::ocpp20::MessageContentTypeConverter updatedPersonalMessage_converter; + ret = ret && updatedPersonalMessage_converter.fromJson( + json["updatedPersonalMessage"], data.updatedPersonalMessage, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a TransactionEventConf to a JSON representation */ +bool TransactionEventConfConverter::toJson(const TransactionEventConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // totalCost + fill(json, "totalCost", data.totalCost); + + // chargingPriority + fill(json, "chargingPriority", data.chargingPriority); + + // idTokenInfo + if (data.idTokenInfo.isSet()) + { + ocpp::types::ocpp20::IdTokenInfoTypeConverter idTokenInfo_converter; + idTokenInfo_converter.setAllocator(allocator); + rapidjson::Document idTokenInfo_doc(rapidjson::kObjectType); + ret = ret && idTokenInfo_converter.toJson(data.idTokenInfo, idTokenInfo_doc); + json.AddMember(rapidjson::StringRef("idTokenInfo"), idTokenInfo_doc.Move(), *allocator); + } + + // updatedPersonalMessage + if (data.updatedPersonalMessage.isSet()) + { + ocpp::types::ocpp20::MessageContentTypeConverter updatedPersonalMessage_converter; + updatedPersonalMessage_converter.setAllocator(allocator); + rapidjson::Document updatedPersonalMessage_doc(rapidjson::kObjectType); + ret = ret && updatedPersonalMessage_converter.toJson(data.updatedPersonalMessage, updatedPersonalMessage_doc); + json.AddMember(rapidjson::StringRef("updatedPersonalMessage"), updatedPersonalMessage_doc.Move(), *allocator); + } + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/TransactionEvent20.h b/src/ocpp20/messages/TransactionEvent20.h new file mode 100644 index 00000000..caaf1a84 --- /dev/null +++ b/src/ocpp20/messages/TransactionEvent20.h @@ -0,0 +1,102 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:TransactionEventRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_TRANSACTIONEVENT_H +#define OPENOCPP_OCPP20_TRANSACTIONEVENT_H + +#include "IMessageConverter.h" + +#include "CustomDataType20.h" +#include "EVSEType20.h" +#include "IdTokenInfoType20.h" +#include "IdTokenType20.h" +#include "MessageContentType20.h" +#include "MeterValueType20.h" +#include "TransactionEventEnumType20.h" +#include "TransactionType20.h" +#include "TriggerReasonEnumType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the TransactionEvent messages */ +static const std::string TRANSACTIONEVENT_ACTION = "TransactionEvent"; + +/** @brief TransactionEventReq message */ +struct TransactionEventReq +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::ocpp20::TransactionEventEnumType eventType; + /** @brief */ + std::vector meterValue; + /** @brief The date and time at which this transaction event occurred. */ + ocpp::types::DateTime timestamp; + /** @brief */ + ocpp::types::ocpp20::TriggerReasonEnumType triggerReason; + /** @brief Incremental sequence number, helps with determining if all messages of a transaction have been received. */ + int seqNo; + /** @brief Indication that this transaction event happened when the Charging Station was offline. Default = false, meaning: the event occurred when the Charging Station was online. */ + ocpp::types::Optional offline; + /** @brief If the Charging Station is able to report the number of phases used, then it SHALL provide it. When omitted the CSMS may be able to determine the number of phases used via device management. */ + ocpp::types::Optional numberOfPhasesUsed; + /** @brief The maximum current of the connected cable in Ampere (A). */ + ocpp::types::Optional cableMaxCurrent; + /** @brief This contains the Id of the reservation that terminates as a result of this transaction. */ + ocpp::types::Optional reservationId; + /** @brief */ + ocpp::types::ocpp20::TransactionType transactionInfo; + /** @brief */ + ocpp::types::Optional evse; + /** @brief */ + ocpp::types::Optional idToken; +}; + +/** @brief TransactionEventConf message */ +struct TransactionEventConf +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief SHALL only be sent when charging has ended. Final total cost of this transaction, including taxes. In the currency configured with the Configuration Variable: <<configkey-currency,`Currency`>>. When omitted, the transaction was NOT free. To indicate a free transaction, the CSMS SHALL send 0.00. */ + ocpp::types::Optional totalCost; + /** @brief Priority from a business point of view. Default priority is 0, The range is from -9 to 9. Higher values indicate a higher priority. The chargingPriority in <<transactioneventresponse,TransactionEventResponse>> is temporarily, so it may not be set in the <<cmn_idtokeninfotype,IdTokenInfoType>> afterwards. Also the chargingPriority in <<transactioneventresponse,TransactionEventResponse>> overrules the one in <<cmn_idtokeninfotype,IdTokenInfoType>>. */ + ocpp::types::Optional chargingPriority; + /** @brief */ + ocpp::types::Optional idTokenInfo; + /** @brief */ + ocpp::types::Optional updatedPersonalMessage; +}; + +// Message converters +MESSAGE_CONVERTERS(TransactionEvent) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_TRANSACTIONEVENT_H \ No newline at end of file diff --git a/src/ocpp20/messages/TriggerMessage20.cpp b/src/ocpp20/messages/TriggerMessage20.cpp new file mode 100644 index 00000000..d2e13d12 --- /dev/null +++ b/src/ocpp20/messages/TriggerMessage20.cpp @@ -0,0 +1,165 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:TriggerMessageRequest + OCPP 2.0.1 FINAL +*/ + +#include "TriggerMessage20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a TriggerMessageReq from a JSON representation */ +bool TriggerMessageReqConverter::fromJson(const rapidjson::Value& json, + TriggerMessageReq& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // evse + if (json.HasMember("evse")) + { + ocpp::types::ocpp20::EVSETypeConverter evse_converter; + ret = ret && evse_converter.fromJson(json["evse"], data.evse, error_code, error_message); + } + + // requestedMessage + data.requestedMessage = ocpp::types::ocpp20::MessageTriggerEnumTypeHelper.fromString(json["requestedMessage"].GetString()); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a TriggerMessageReq to a JSON representation */ +bool TriggerMessageReqConverter::toJson(const TriggerMessageReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // evse + if (data.evse.isSet()) + { + ocpp::types::ocpp20::EVSETypeConverter evse_converter; + evse_converter.setAllocator(allocator); + rapidjson::Document evse_doc(rapidjson::kObjectType); + ret = ret && evse_converter.toJson(data.evse, evse_doc); + json.AddMember(rapidjson::StringRef("evse"), evse_doc.Move(), *allocator); + } + + // requestedMessage + fill(json, "requestedMessage", ocpp::types::ocpp20::MessageTriggerEnumTypeHelper.toString(data.requestedMessage)); + + return ret; +} + +/** @brief Convert a TriggerMessageConf from a JSON representation */ +bool TriggerMessageConfConverter::fromJson(const rapidjson::Value& json, + TriggerMessageConf& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // status + data.status = ocpp::types::ocpp20::TriggerMessageStatusEnumTypeHelper.fromString(json["status"].GetString()); + + // statusInfo + if (json.HasMember("statusInfo")) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + ret = ret && statusInfo_converter.fromJson(json["statusInfo"], data.statusInfo, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a TriggerMessageConf to a JSON representation */ +bool TriggerMessageConfConverter::toJson(const TriggerMessageConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // status + fill(json, "status", ocpp::types::ocpp20::TriggerMessageStatusEnumTypeHelper.toString(data.status)); + + // statusInfo + if (data.statusInfo.isSet()) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + statusInfo_converter.setAllocator(allocator); + rapidjson::Document statusInfo_doc(rapidjson::kObjectType); + ret = ret && statusInfo_converter.toJson(data.statusInfo, statusInfo_doc); + json.AddMember(rapidjson::StringRef("statusInfo"), statusInfo_doc.Move(), *allocator); + } + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/TriggerMessage20.h b/src/ocpp20/messages/TriggerMessage20.h new file mode 100644 index 00000000..1ac87dba --- /dev/null +++ b/src/ocpp20/messages/TriggerMessage20.h @@ -0,0 +1,74 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:TriggerMessageRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_TRIGGERMESSAGE_H +#define OPENOCPP_OCPP20_TRIGGERMESSAGE_H + +#include "IMessageConverter.h" + +#include "CustomDataType20.h" +#include "EVSEType20.h" +#include "MessageTriggerEnumType20.h" +#include "StatusInfoType20.h" +#include "TriggerMessageStatusEnumType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the TriggerMessage messages */ +static const std::string TRIGGERMESSAGE_ACTION = "TriggerMessage"; + +/** @brief TriggerMessageReq message */ +struct TriggerMessageReq +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::Optional evse; + /** @brief */ + ocpp::types::ocpp20::MessageTriggerEnumType requestedMessage; +}; + +/** @brief TriggerMessageConf message */ +struct TriggerMessageConf +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::ocpp20::TriggerMessageStatusEnumType status; + /** @brief */ + ocpp::types::Optional statusInfo; +}; + +// Message converters +MESSAGE_CONVERTERS(TriggerMessage) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_TRIGGERMESSAGE_H \ No newline at end of file diff --git a/src/ocpp20/messages/UnlockConnector20.cpp b/src/ocpp20/messages/UnlockConnector20.cpp new file mode 100644 index 00000000..31beb99f --- /dev/null +++ b/src/ocpp20/messages/UnlockConnector20.cpp @@ -0,0 +1,154 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:UnlockConnectorRequest + OCPP 2.0.1 FINAL +*/ + +#include "UnlockConnector20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a UnlockConnectorReq from a JSON representation */ +bool UnlockConnectorReqConverter::fromJson(const rapidjson::Value& json, + UnlockConnectorReq& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // evseId + extract(json, "evseId", data.evseId); + + // connectorId + extract(json, "connectorId", data.connectorId); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a UnlockConnectorReq to a JSON representation */ +bool UnlockConnectorReqConverter::toJson(const UnlockConnectorReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // evseId + fill(json, "evseId", data.evseId); + + // connectorId + fill(json, "connectorId", data.connectorId); + + return ret; +} + +/** @brief Convert a UnlockConnectorConf from a JSON representation */ +bool UnlockConnectorConfConverter::fromJson(const rapidjson::Value& json, + UnlockConnectorConf& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // status + data.status = ocpp::types::ocpp20::UnlockStatusEnumTypeHelper.fromString(json["status"].GetString()); + + // statusInfo + if (json.HasMember("statusInfo")) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + ret = ret && statusInfo_converter.fromJson(json["statusInfo"], data.statusInfo, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a UnlockConnectorConf to a JSON representation */ +bool UnlockConnectorConfConverter::toJson(const UnlockConnectorConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // status + fill(json, "status", ocpp::types::ocpp20::UnlockStatusEnumTypeHelper.toString(data.status)); + + // statusInfo + if (data.statusInfo.isSet()) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + statusInfo_converter.setAllocator(allocator); + rapidjson::Document statusInfo_doc(rapidjson::kObjectType); + ret = ret && statusInfo_converter.toJson(data.statusInfo, statusInfo_doc); + json.AddMember(rapidjson::StringRef("statusInfo"), statusInfo_doc.Move(), *allocator); + } + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/UnlockConnector20.h b/src/ocpp20/messages/UnlockConnector20.h new file mode 100644 index 00000000..1effbc07 --- /dev/null +++ b/src/ocpp20/messages/UnlockConnector20.h @@ -0,0 +1,72 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:UnlockConnectorRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_UNLOCKCONNECTOR_H +#define OPENOCPP_OCPP20_UNLOCKCONNECTOR_H + +#include "IMessageConverter.h" + +#include "CustomDataType20.h" +#include "StatusInfoType20.h" +#include "UnlockStatusEnumType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the UnlockConnector messages */ +static const std::string UNLOCKCONNECTOR_ACTION = "UnlockConnector"; + +/** @brief UnlockConnectorReq message */ +struct UnlockConnectorReq +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief This contains the identifier of the EVSE for which a connector needs to be unlocked. */ + int evseId; + /** @brief This contains the identifier of the connector that needs to be unlocked. */ + int connectorId; +}; + +/** @brief UnlockConnectorConf message */ +struct UnlockConnectorConf +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::ocpp20::UnlockStatusEnumType status; + /** @brief */ + ocpp::types::Optional statusInfo; +}; + +// Message converters +MESSAGE_CONVERTERS(UnlockConnector) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_UNLOCKCONNECTOR_H \ No newline at end of file diff --git a/src/ocpp20/messages/UnpublishFirmware20.cpp b/src/ocpp20/messages/UnpublishFirmware20.cpp new file mode 100644 index 00000000..4ebb40c6 --- /dev/null +++ b/src/ocpp20/messages/UnpublishFirmware20.cpp @@ -0,0 +1,131 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:UnpublishFirmwareRequest + OCPP 2.0.1 FINAL +*/ + +#include "UnpublishFirmware20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a UnpublishFirmwareReq from a JSON representation */ +bool UnpublishFirmwareReqConverter::fromJson(const rapidjson::Value& json, + UnpublishFirmwareReq& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // checksum + extract(json, "checksum", data.checksum); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a UnpublishFirmwareReq to a JSON representation */ +bool UnpublishFirmwareReqConverter::toJson(const UnpublishFirmwareReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // checksum + fill(json, "checksum", data.checksum); + + return ret; +} + +/** @brief Convert a UnpublishFirmwareConf from a JSON representation */ +bool UnpublishFirmwareConfConverter::fromJson(const rapidjson::Value& json, + UnpublishFirmwareConf& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // status + data.status = ocpp::types::ocpp20::UnpublishFirmwareStatusEnumTypeHelper.fromString(json["status"].GetString()); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a UnpublishFirmwareConf to a JSON representation */ +bool UnpublishFirmwareConfConverter::toJson(const UnpublishFirmwareConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // status + fill(json, "status", ocpp::types::ocpp20::UnpublishFirmwareStatusEnumTypeHelper.toString(data.status)); + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/UnpublishFirmware20.h b/src/ocpp20/messages/UnpublishFirmware20.h new file mode 100644 index 00000000..3949f6de --- /dev/null +++ b/src/ocpp20/messages/UnpublishFirmware20.h @@ -0,0 +1,67 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:UnpublishFirmwareRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_UNPUBLISHFIRMWARE_H +#define OPENOCPP_OCPP20_UNPUBLISHFIRMWARE_H + +#include "IMessageConverter.h" + +#include "CustomDataType20.h" +#include "UnpublishFirmwareStatusEnumType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the UnpublishFirmware messages */ +static const std::string UNPUBLISHFIRMWARE_ACTION = "UnpublishFirmware"; + +/** @brief UnpublishFirmwareReq message */ +struct UnpublishFirmwareReq +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief The MD5 checksum over the entire firmware file as a hexadecimal string of length 32. */ + ocpp::types::CiStringType<32u> checksum; +}; + +/** @brief UnpublishFirmwareConf message */ +struct UnpublishFirmwareConf +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::ocpp20::UnpublishFirmwareStatusEnumType status; +}; + +// Message converters +MESSAGE_CONVERTERS(UnpublishFirmware) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_UNPUBLISHFIRMWARE_H \ No newline at end of file diff --git a/src/ocpp20/messages/UpdateFirmware20.cpp b/src/ocpp20/messages/UpdateFirmware20.cpp new file mode 100644 index 00000000..5a268643 --- /dev/null +++ b/src/ocpp20/messages/UpdateFirmware20.cpp @@ -0,0 +1,171 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:UpdateFirmwareRequest + OCPP 2.0.1 FINAL +*/ + +#include "UpdateFirmware20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Convert a UpdateFirmwareReq from a JSON representation */ +bool UpdateFirmwareReqConverter::fromJson(const rapidjson::Value& json, + UpdateFirmwareReq& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // retries + extract(json, "retries", data.retries); + + // retryInterval + extract(json, "retryInterval", data.retryInterval); + + // requestId + extract(json, "requestId", data.requestId); + + // firmware + ocpp::types::ocpp20::FirmwareTypeConverter firmware_converter; + ret = ret && firmware_converter.fromJson(json["firmware"], data.firmware, error_code, error_message); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a UpdateFirmwareReq to a JSON representation */ +bool UpdateFirmwareReqConverter::toJson(const UpdateFirmwareReq& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // retries + fill(json, "retries", data.retries); + + // retryInterval + fill(json, "retryInterval", data.retryInterval); + + // requestId + fill(json, "requestId", data.requestId); + + // firmware + ocpp::types::ocpp20::FirmwareTypeConverter firmware_converter; + firmware_converter.setAllocator(allocator); + rapidjson::Document firmware_doc(rapidjson::kObjectType); + ret = ret && firmware_converter.toJson(data.firmware, firmware_doc); + json.AddMember(rapidjson::StringRef("firmware"), firmware_doc.Move(), *allocator); + + return ret; +} + +/** @brief Convert a UpdateFirmwareConf from a JSON representation */ +bool UpdateFirmwareConfConverter::fromJson(const rapidjson::Value& json, + UpdateFirmwareConf& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // status + data.status = ocpp::types::ocpp20::UpdateFirmwareStatusEnumTypeHelper.fromString(json["status"].GetString()); + + // statusInfo + if (json.HasMember("statusInfo")) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + ret = ret && statusInfo_converter.fromJson(json["statusInfo"], data.statusInfo, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a UpdateFirmwareConf to a JSON representation */ +bool UpdateFirmwareConfConverter::toJson(const UpdateFirmwareConf& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + ocpp::types::ocpp20::CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // status + fill(json, "status", ocpp::types::ocpp20::UpdateFirmwareStatusEnumTypeHelper.toString(data.status)); + + // statusInfo + if (data.statusInfo.isSet()) + { + ocpp::types::ocpp20::StatusInfoTypeConverter statusInfo_converter; + statusInfo_converter.setAllocator(allocator); + rapidjson::Document statusInfo_doc(rapidjson::kObjectType); + ret = ret && statusInfo_converter.toJson(data.statusInfo, statusInfo_doc); + json.AddMember(rapidjson::StringRef("statusInfo"), statusInfo_doc.Move(), *allocator); + } + + return ret; +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/messages/UpdateFirmware20.h b/src/ocpp20/messages/UpdateFirmware20.h new file mode 100644 index 00000000..3a1c5f3c --- /dev/null +++ b/src/ocpp20/messages/UpdateFirmware20.h @@ -0,0 +1,77 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:UpdateFirmwareRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_UPDATEFIRMWARE_H +#define OPENOCPP_OCPP20_UPDATEFIRMWARE_H + +#include "IMessageConverter.h" + +#include "CustomDataType20.h" +#include "FirmwareType20.h" +#include "StatusInfoType20.h" +#include "UpdateFirmwareStatusEnumType20.h" + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Action corresponding to the UpdateFirmware messages */ +static const std::string UPDATEFIRMWARE_ACTION = "UpdateFirmware"; + +/** @brief UpdateFirmwareReq message */ +struct UpdateFirmwareReq +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief This specifies how many times Charging Station must try to download the firmware before giving up. If this field is not present, it is left to Charging Station to decide how many times it wants to retry. */ + ocpp::types::Optional retries; + /** @brief The interval in seconds after which a retry may be attempted. If this field is not present, it is left to Charging Station to decide how long to wait between attempts. */ + ocpp::types::Optional retryInterval; + /** @brief The Id of this request */ + int requestId; + /** @brief */ + ocpp::types::ocpp20::FirmwareType firmware; +}; + +/** @brief UpdateFirmwareConf message */ +struct UpdateFirmwareConf +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::ocpp20::UpdateFirmwareStatusEnumType status; + /** @brief */ + ocpp::types::Optional statusInfo; +}; + +// Message converters +MESSAGE_CONVERTERS(UpdateFirmware) + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_UPDATEFIRMWARE_H \ No newline at end of file diff --git a/src/ocpp20/types/ACChargingParametersType20.cpp b/src/ocpp20/types/ACChargingParametersType20.cpp new file mode 100644 index 00000000..a15b930a --- /dev/null +++ b/src/ocpp20/types/ACChargingParametersType20.cpp @@ -0,0 +1,102 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:NotifyEVChargingNeedsRequest + OCPP 2.0.1 FINAL +*/ + +#include "ACChargingParametersType20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Convert a ACChargingParametersType from a JSON representation */ +bool ACChargingParametersTypeConverter::fromJson(const rapidjson::Value& json, + ACChargingParametersType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // energyAmount + extract(json, "energyAmount", data.energyAmount); + + // evMinCurrent + extract(json, "evMinCurrent", data.evMinCurrent); + + // evMaxCurrent + extract(json, "evMaxCurrent", data.evMaxCurrent); + + // evMaxVoltage + extract(json, "evMaxVoltage", data.evMaxVoltage); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a ACChargingParametersType to a JSON representation */ +bool ACChargingParametersTypeConverter::toJson(const ACChargingParametersType& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // energyAmount + fill(json, "energyAmount", data.energyAmount); + + // evMinCurrent + fill(json, "evMinCurrent", data.evMinCurrent); + + // evMaxCurrent + fill(json, "evMaxCurrent", data.evMaxCurrent); + + // evMaxVoltage + fill(json, "evMaxVoltage", data.evMaxVoltage); + + return ret; +} + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/ACChargingParametersType20.h b/src/ocpp20/types/ACChargingParametersType20.h new file mode 100644 index 00000000..143fec00 --- /dev/null +++ b/src/ocpp20/types/ACChargingParametersType20.h @@ -0,0 +1,87 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:NotifyEVChargingNeedsRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_ACCHARGINGPARAMETERSTYPE_H +#define OPENOCPP_OCPP20_ACCHARGINGPARAMETERSTYPE_H + +#include "CustomDataType20.h" + +#include "IMessageConverter.h" +#include "Optional.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief AC_ Charging_ Parameters +urn:x-oca:ocpp:uid:2:233250 +EV AC charging parameters. + + */ +struct ACChargingParametersType +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief AC_ Charging_ Parameters. Energy_ Amount. Energy_ Amount +urn:x-oca:ocpp:uid:1:569211 +Amount of energy requested (in Wh). This includes energy required for preconditioning. */ + int energyAmount; + /** @brief AC_ Charging_ Parameters. EV_ Min. Current +urn:x-oca:ocpp:uid:1:569212 +Minimum current (amps) supported by the electric vehicle (per phase). */ + int evMinCurrent; + /** @brief AC_ Charging_ Parameters. EV_ Max. Current +urn:x-oca:ocpp:uid:1:569213 +Maximum current (amps) supported by the electric vehicle (per phase). Includes cable capacity. */ + int evMaxCurrent; + /** @brief AC_ Charging_ Parameters. EV_ Max. Voltage +urn:x-oca:ocpp:uid:1:569214 +Maximum voltage supported by the electric vehicle */ + int evMaxVoltage; +}; + +/** @brief Converter class for ACChargingParametersType type */ +class ACChargingParametersTypeConverter : public ocpp::messages::IMessageConverter +{ + public: + /** @brief Clone the converter */ + ocpp::messages::IMessageConverter* clone() const override { return new ACChargingParametersTypeConverter(); } + + /** @brief Convert a ACChargingParametersType from a JSON representation */ + bool fromJson(const rapidjson::Value& json, + ACChargingParametersType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) override; + + /** @brief Convert a ACChargingParametersType to a JSON representation */ + bool toJson(const ACChargingParametersType& data, rapidjson::Document& json) override; +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_ACCHARGINGPARAMETERSTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/APNAuthenticationEnumType20.cpp b/src/ocpp20/types/APNAuthenticationEnumType20.cpp new file mode 100644 index 00000000..b511e393 --- /dev/null +++ b/src/ocpp20/types/APNAuthenticationEnumType20.cpp @@ -0,0 +1,43 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SetNetworkProfileRequest + OCPP 2.0.1 FINAL +*/ + +#include "APNAuthenticationEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a APNAuthenticationEnumType enum to string */ +const EnumToStringFromString APNAuthenticationEnumTypeHelper = { + {APNAuthenticationEnumType::CHAP, "CHAP"}, + {APNAuthenticationEnumType::NONE, "NONE"}, + {APNAuthenticationEnumType::PAP, "PAP"}, + {APNAuthenticationEnumType::AUTO, "AUTO"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/APNAuthenticationEnumType20.h b/src/ocpp20/types/APNAuthenticationEnumType20.h new file mode 100644 index 00000000..6a3259e5 --- /dev/null +++ b/src/ocpp20/types/APNAuthenticationEnumType20.h @@ -0,0 +1,54 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SetNetworkProfileRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_APNAUTHENTICATIONENUMTYPE_H +#define OPENOCPP_OCPP20_APNAUTHENTICATIONENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief APN. APN_ Authentication. APN_ Authentication_ Code +urn:x-oca:ocpp:uid:1:568828 +Authentication method. */ +enum class APNAuthenticationEnumType +{ + CHAP, + NONE, + PAP, + AUTO, +}; + +/** @brief Helper to convert a APNAuthenticationEnumType enum to string */ +extern const EnumToStringFromString APNAuthenticationEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_APNAUTHENTICATIONENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/APNType20.cpp b/src/ocpp20/types/APNType20.cpp new file mode 100644 index 00000000..505e7ee1 --- /dev/null +++ b/src/ocpp20/types/APNType20.cpp @@ -0,0 +1,120 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SetNetworkProfileRequest + OCPP 2.0.1 FINAL +*/ + +#include "APNType20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Convert a APNType from a JSON representation */ +bool APNTypeConverter::fromJson(const rapidjson::Value& json, + APNType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // apn + extract(json, "apn", data.apn); + + // apnUserName + extract(json, "apnUserName", data.apnUserName); + + // apnPassword + extract(json, "apnPassword", data.apnPassword); + + // simPin + extract(json, "simPin", data.simPin); + + // preferredNetwork + extract(json, "preferredNetwork", data.preferredNetwork); + + // useOnlyPreferredNetwork + extract(json, "useOnlyPreferredNetwork", data.useOnlyPreferredNetwork); + + // apnAuthentication + data.apnAuthentication = APNAuthenticationEnumTypeHelper.fromString(json["apnAuthentication"].GetString()); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a APNType to a JSON representation */ +bool APNTypeConverter::toJson(const APNType& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // apn + fill(json, "apn", data.apn); + + // apnUserName + fill(json, "apnUserName", data.apnUserName); + + // apnPassword + fill(json, "apnPassword", data.apnPassword); + + // simPin + fill(json, "simPin", data.simPin); + + // preferredNetwork + fill(json, "preferredNetwork", data.preferredNetwork); + + // useOnlyPreferredNetwork + fill(json, "useOnlyPreferredNetwork", data.useOnlyPreferredNetwork); + + // apnAuthentication + fill(json, "apnAuthentication", APNAuthenticationEnumTypeHelper.toString(data.apnAuthentication)); + + return ret; +} + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/APNType20.h b/src/ocpp20/types/APNType20.h new file mode 100644 index 00000000..22d60e1d --- /dev/null +++ b/src/ocpp20/types/APNType20.h @@ -0,0 +1,101 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SetNetworkProfileRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_APNTYPE_H +#define OPENOCPP_OCPP20_APNTYPE_H + +#include "APNAuthenticationEnumType20.h" +#include "CustomDataType20.h" + +#include "CiStringType.h" +#include "IMessageConverter.h" +#include "Optional.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief APN +urn:x-oca:ocpp:uid:2:233134 +Collection of configuration data needed to make a data-connection over a cellular network. + +NOTE: When asking a GSM modem to dial in, it is possible to specify which mobile operator should be used. This can be done with the mobile country code (MCC) in combination with a mobile network code (MNC). Example: If your preferred network is Vodafone Netherlands, the MCC=204 and the MNC=04 which means the key PreferredNetwork = 20404 Some modems allows to specify a preferred network, which means, if this network is not available, a different network is used. If you specify UseOnlyPreferredNetwork and this network is not available, the modem will not dial in. + */ +struct APNType +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief APN. APN. URI +urn:x-oca:ocpp:uid:1:568814 +The Access Point Name as an URL. */ + ocpp::types::CiStringType<512u> apn; + /** @brief APN. APN. User_ Name +urn:x-oca:ocpp:uid:1:568818 +APN username. */ + ocpp::types::Optional> apnUserName; + /** @brief APN. APN. Password +urn:x-oca:ocpp:uid:1:568819 +APN Password. */ + ocpp::types::Optional> apnPassword; + /** @brief APN. SIMPIN. PIN_ Code +urn:x-oca:ocpp:uid:1:568821 +SIM card pin code. */ + ocpp::types::Optional simPin; + /** @brief APN. Preferred_ Network. Mobile_ Network_ ID +urn:x-oca:ocpp:uid:1:568822 +Preferred network, written as MCC and MNC concatenated. See note. */ + ocpp::types::Optional> preferredNetwork; + /** @brief APN. Use_ Only_ Preferred_ Network. Indicator +urn:x-oca:ocpp:uid:1:568824 +Default: false. Use only the preferred Network, do +not dial in when not available. See Note. */ + ocpp::types::Optional useOnlyPreferredNetwork; + /** @brief */ + APNAuthenticationEnumType apnAuthentication; +}; + +/** @brief Converter class for APNType type */ +class APNTypeConverter : public ocpp::messages::IMessageConverter +{ + public: + /** @brief Clone the converter */ + ocpp::messages::IMessageConverter* clone() const override { return new APNTypeConverter(); } + + /** @brief Convert a APNType from a JSON representation */ + bool fromJson(const rapidjson::Value& json, + APNType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) override; + + /** @brief Convert a APNType to a JSON representation */ + bool toJson(const APNType& data, rapidjson::Document& json) override; +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_APNTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/AdditionalInfoType20.cpp b/src/ocpp20/types/AdditionalInfoType20.cpp new file mode 100644 index 00000000..911204a9 --- /dev/null +++ b/src/ocpp20/types/AdditionalInfoType20.cpp @@ -0,0 +1,90 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:RequestStartTransactionRequest + OCPP 2.0.1 FINAL +*/ + +#include "AdditionalInfoType20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Convert a AdditionalInfoType from a JSON representation */ +bool AdditionalInfoTypeConverter::fromJson(const rapidjson::Value& json, + AdditionalInfoType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // additionalIdToken + extract(json, "additionalIdToken", data.additionalIdToken); + + // type + extract(json, "type", data.type); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a AdditionalInfoType to a JSON representation */ +bool AdditionalInfoTypeConverter::toJson(const AdditionalInfoType& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // additionalIdToken + fill(json, "additionalIdToken", data.additionalIdToken); + + // type + fill(json, "type", data.type); + + return ret; +} + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/AdditionalInfoType20.h b/src/ocpp20/types/AdditionalInfoType20.h new file mode 100644 index 00000000..4ed20dc5 --- /dev/null +++ b/src/ocpp20/types/AdditionalInfoType20.h @@ -0,0 +1,73 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:RequestStartTransactionRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_ADDITIONALINFOTYPE_H +#define OPENOCPP_OCPP20_ADDITIONALINFOTYPE_H + +#include "CustomDataType20.h" + +#include "CiStringType.h" +#include "IMessageConverter.h" +#include "Optional.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Contains a case insensitive identifier to use for the authorization and the type of authorization to support multiple forms of identifiers. + */ +struct AdditionalInfoType +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief This field specifies the additional IdToken. */ + ocpp::types::CiStringType<36u> additionalIdToken; + /** @brief This defines the type of the additionalIdToken. This is a custom type, so the implementation needs to be agreed upon by all involved parties. */ + ocpp::types::CiStringType<50u> type; +}; + +/** @brief Converter class for AdditionalInfoType type */ +class AdditionalInfoTypeConverter : public ocpp::messages::IMessageConverter +{ + public: + /** @brief Clone the converter */ + ocpp::messages::IMessageConverter* clone() const override { return new AdditionalInfoTypeConverter(); } + + /** @brief Convert a AdditionalInfoType from a JSON representation */ + bool fromJson(const rapidjson::Value& json, + AdditionalInfoType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) override; + + /** @brief Convert a AdditionalInfoType to a JSON representation */ + bool toJson(const AdditionalInfoType& data, rapidjson::Document& json) override; +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_ADDITIONALINFOTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/AttributeEnumType20.cpp b/src/ocpp20/types/AttributeEnumType20.cpp new file mode 100644 index 00000000..4af53a48 --- /dev/null +++ b/src/ocpp20/types/AttributeEnumType20.cpp @@ -0,0 +1,43 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:NotifyReportRequest + OCPP 2.0.1 FINAL +*/ + +#include "AttributeEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a AttributeEnumType enum to string */ +const EnumToStringFromString AttributeEnumTypeHelper = { + {AttributeEnumType::Actual, "Actual"}, + {AttributeEnumType::Target, "Target"}, + {AttributeEnumType::MinSet, "MinSet"}, + {AttributeEnumType::MaxSet, "MaxSet"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/AttributeEnumType20.h b/src/ocpp20/types/AttributeEnumType20.h new file mode 100644 index 00000000..6f3dd447 --- /dev/null +++ b/src/ocpp20/types/AttributeEnumType20.h @@ -0,0 +1,53 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:NotifyReportRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_ATTRIBUTEENUMTYPE_H +#define OPENOCPP_OCPP20_ATTRIBUTEENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Attribute: Actual, MinSet, MaxSet, etc. +Defaults to Actual if absent. */ +enum class AttributeEnumType +{ + Actual, + Target, + MinSet, + MaxSet, +}; + +/** @brief Helper to convert a AttributeEnumType enum to string */ +extern const EnumToStringFromString AttributeEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_ATTRIBUTEENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/AuthorizationData20.cpp b/src/ocpp20/types/AuthorizationData20.cpp new file mode 100644 index 00000000..725bf56d --- /dev/null +++ b/src/ocpp20/types/AuthorizationData20.cpp @@ -0,0 +1,106 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SendLocalListRequest + OCPP 2.0.1 FINAL +*/ + +#include "AuthorizationData20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Convert a AuthorizationData from a JSON representation */ +bool AuthorizationDataConverter::fromJson(const rapidjson::Value& json, + AuthorizationData& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // idToken + IdTokenTypeConverter idToken_converter; + ret = ret && idToken_converter.fromJson(json["idToken"], data.idToken, error_code, error_message); + + // idTokenInfo + if (json.HasMember("idTokenInfo")) + { + IdTokenInfoTypeConverter idTokenInfo_converter; + ret = ret && idTokenInfo_converter.fromJson(json["idTokenInfo"], data.idTokenInfo, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a AuthorizationData to a JSON representation */ +bool AuthorizationDataConverter::toJson(const AuthorizationData& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // idToken + IdTokenTypeConverter idToken_converter; + idToken_converter.setAllocator(allocator); + rapidjson::Document idToken_doc(rapidjson::kObjectType); + ret = ret && idToken_converter.toJson(data.idToken, idToken_doc); + json.AddMember(rapidjson::StringRef("idToken"), idToken_doc.Move(), *allocator); + + // idTokenInfo + if (data.idTokenInfo.isSet()) + { + IdTokenInfoTypeConverter idTokenInfo_converter; + idTokenInfo_converter.setAllocator(allocator); + rapidjson::Document idTokenInfo_doc(rapidjson::kObjectType); + ret = ret && idTokenInfo_converter.toJson(data.idTokenInfo, idTokenInfo_doc); + json.AddMember(rapidjson::StringRef("idTokenInfo"), idTokenInfo_doc.Move(), *allocator); + } + + return ret; +} + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/AuthorizationData20.h b/src/ocpp20/types/AuthorizationData20.h new file mode 100644 index 00000000..f742f3a3 --- /dev/null +++ b/src/ocpp20/types/AuthorizationData20.h @@ -0,0 +1,74 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SendLocalListRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_AUTHORIZATIONDATA_H +#define OPENOCPP_OCPP20_AUTHORIZATIONDATA_H + +#include "CustomDataType20.h" +#include "IdTokenInfoType20.h" +#include "IdTokenType20.h" + +#include "IMessageConverter.h" +#include "Optional.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Contains the identifier to use for authorization. + */ +struct AuthorizationData +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + IdTokenType idToken; + /** @brief */ + ocpp::types::Optional idTokenInfo; +}; + +/** @brief Converter class for AuthorizationData type */ +class AuthorizationDataConverter : public ocpp::messages::IMessageConverter +{ + public: + /** @brief Clone the converter */ + ocpp::messages::IMessageConverter* clone() const override { return new AuthorizationDataConverter(); } + + /** @brief Convert a AuthorizationData from a JSON representation */ + bool fromJson(const rapidjson::Value& json, + AuthorizationData& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) override; + + /** @brief Convert a AuthorizationData to a JSON representation */ + bool toJson(const AuthorizationData& data, rapidjson::Document& json) override; +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_AUTHORIZATIONDATA_H \ No newline at end of file diff --git a/src/ocpp20/types/AuthorizationStatusEnumType20.cpp b/src/ocpp20/types/AuthorizationStatusEnumType20.cpp new file mode 100644 index 00000000..be8c1198 --- /dev/null +++ b/src/ocpp20/types/AuthorizationStatusEnumType20.cpp @@ -0,0 +1,49 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:AuthorizeRequest + OCPP 2.0.1 FINAL +*/ + +#include "AuthorizationStatusEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a AuthorizationStatusEnumType enum to string */ +const EnumToStringFromString AuthorizationStatusEnumTypeHelper = { + {AuthorizationStatusEnumType::Accepted, "Accepted"}, + {AuthorizationStatusEnumType::Blocked, "Blocked"}, + {AuthorizationStatusEnumType::ConcurrentTx, "ConcurrentTx"}, + {AuthorizationStatusEnumType::Expired, "Expired"}, + {AuthorizationStatusEnumType::Invalid, "Invalid"}, + {AuthorizationStatusEnumType::NoCredit, "NoCredit"}, + {AuthorizationStatusEnumType::NotAllowedTypeEVSE, "NotAllowedTypeEVSE"}, + {AuthorizationStatusEnumType::NotAtThisLocation, "NotAtThisLocation"}, + {AuthorizationStatusEnumType::NotAtThisTime, "NotAtThisTime"}, + {AuthorizationStatusEnumType::Unknown, "Unknown"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/AuthorizationStatusEnumType20.h b/src/ocpp20/types/AuthorizationStatusEnumType20.h new file mode 100644 index 00000000..3ffbd49c --- /dev/null +++ b/src/ocpp20/types/AuthorizationStatusEnumType20.h @@ -0,0 +1,60 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:AuthorizeRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_AUTHORIZATIONSTATUSENUMTYPE_H +#define OPENOCPP_OCPP20_AUTHORIZATIONSTATUSENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief ID_ Token. Status. Authorization_ Status +urn:x-oca:ocpp:uid:1:569372 +Current status of the ID Token. */ +enum class AuthorizationStatusEnumType +{ + Accepted, + Blocked, + ConcurrentTx, + Expired, + Invalid, + NoCredit, + NotAllowedTypeEVSE, + NotAtThisLocation, + NotAtThisTime, + Unknown, +}; + +/** @brief Helper to convert a AuthorizationStatusEnumType enum to string */ +extern const EnumToStringFromString AuthorizationStatusEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_AUTHORIZATIONSTATUSENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/AuthorizeCertificateStatusEnumType20.cpp b/src/ocpp20/types/AuthorizeCertificateStatusEnumType20.cpp new file mode 100644 index 00000000..d229b712 --- /dev/null +++ b/src/ocpp20/types/AuthorizeCertificateStatusEnumType20.cpp @@ -0,0 +1,46 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:AuthorizeRequest + OCPP 2.0.1 FINAL +*/ + +#include "AuthorizeCertificateStatusEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a AuthorizeCertificateStatusEnumType enum to string */ +const EnumToStringFromString AuthorizeCertificateStatusEnumTypeHelper = { + {AuthorizeCertificateStatusEnumType::Accepted, "Accepted"}, + {AuthorizeCertificateStatusEnumType::SignatureError, "SignatureError"}, + {AuthorizeCertificateStatusEnumType::CertificateExpired, "CertificateExpired"}, + {AuthorizeCertificateStatusEnumType::CertificateRevoked, "CertificateRevoked"}, + {AuthorizeCertificateStatusEnumType::NoCertificateAvailable, "NoCertificateAvailable"}, + {AuthorizeCertificateStatusEnumType::CertChainError, "CertChainError"}, + {AuthorizeCertificateStatusEnumType::ContractCancelled, "ContractCancelled"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/AuthorizeCertificateStatusEnumType20.h b/src/ocpp20/types/AuthorizeCertificateStatusEnumType20.h new file mode 100644 index 00000000..0360f845 --- /dev/null +++ b/src/ocpp20/types/AuthorizeCertificateStatusEnumType20.h @@ -0,0 +1,57 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:AuthorizeRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_AUTHORIZECERTIFICATESTATUSENUMTYPE_H +#define OPENOCPP_OCPP20_AUTHORIZECERTIFICATESTATUSENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Certificate status information. +- if all certificates are valid: return 'Accepted'. +- if one of the certificates was revoked, return 'CertificateRevoked'. */ +enum class AuthorizeCertificateStatusEnumType +{ + Accepted, + SignatureError, + CertificateExpired, + CertificateRevoked, + NoCertificateAvailable, + CertChainError, + ContractCancelled, +}; + +/** @brief Helper to convert a AuthorizeCertificateStatusEnumType enum to string */ +extern const EnumToStringFromString AuthorizeCertificateStatusEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_AUTHORIZECERTIFICATESTATUSENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/BootReasonEnumType20.cpp b/src/ocpp20/types/BootReasonEnumType20.cpp new file mode 100644 index 00000000..2a499eaf --- /dev/null +++ b/src/ocpp20/types/BootReasonEnumType20.cpp @@ -0,0 +1,48 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:BootNotificationRequest + OCPP 2.0.1 FINAL +*/ + +#include "BootReasonEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a BootReasonEnumType enum to string */ +const EnumToStringFromString BootReasonEnumTypeHelper = { + {BootReasonEnumType::ApplicationReset, "ApplicationReset"}, + {BootReasonEnumType::FirmwareUpdate, "FirmwareUpdate"}, + {BootReasonEnumType::LocalReset, "LocalReset"}, + {BootReasonEnumType::PowerUp, "PowerUp"}, + {BootReasonEnumType::RemoteReset, "RemoteReset"}, + {BootReasonEnumType::ScheduledReset, "ScheduledReset"}, + {BootReasonEnumType::Triggered, "Triggered"}, + {BootReasonEnumType::Unknown, "Unknown"}, + {BootReasonEnumType::Watchdog, "Watchdog"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/BootReasonEnumType20.h b/src/ocpp20/types/BootReasonEnumType20.h new file mode 100644 index 00000000..f06ea861 --- /dev/null +++ b/src/ocpp20/types/BootReasonEnumType20.h @@ -0,0 +1,57 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:BootNotificationRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_BOOTREASONENUMTYPE_H +#define OPENOCPP_OCPP20_BOOTREASONENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief This contains the reason for sending this message to the CSMS. */ +enum class BootReasonEnumType +{ + ApplicationReset, + FirmwareUpdate, + LocalReset, + PowerUp, + RemoteReset, + ScheduledReset, + Triggered, + Unknown, + Watchdog, +}; + +/** @brief Helper to convert a BootReasonEnumType enum to string */ +extern const EnumToStringFromString BootReasonEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_BOOTREASONENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/CMakeLists.txt b/src/ocpp20/types/CMakeLists.txt new file mode 100644 index 00000000..876accbf --- /dev/null +++ b/src/ocpp20/types/CMakeLists.txt @@ -0,0 +1,16 @@ +###################################################### +# OCPP 2.0 types library # +###################################################### + + +# Library target +file (GLOB OCPP20_TYPES_SOURCE_FILES "*.cpp") +add_library(types20 OBJECT + ${OCPP20_TYPES_SOURCE_FILES} +) + +# Exported includes +target_include_directories(types20 PUBLIC .) + +# Dependencies +target_link_libraries(types20 PUBLIC types messages) diff --git a/src/ocpp20/types/CancelReservationStatusEnumType20.cpp b/src/ocpp20/types/CancelReservationStatusEnumType20.cpp new file mode 100644 index 00000000..98091c8a --- /dev/null +++ b/src/ocpp20/types/CancelReservationStatusEnumType20.cpp @@ -0,0 +1,41 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:CancelReservationRequest + OCPP 2.0.1 FINAL +*/ + +#include "CancelReservationStatusEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a CancelReservationStatusEnumType enum to string */ +const EnumToStringFromString CancelReservationStatusEnumTypeHelper = { + {CancelReservationStatusEnumType::Accepted, "Accepted"}, + {CancelReservationStatusEnumType::Rejected, "Rejected"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/CancelReservationStatusEnumType20.h b/src/ocpp20/types/CancelReservationStatusEnumType20.h new file mode 100644 index 00000000..17873344 --- /dev/null +++ b/src/ocpp20/types/CancelReservationStatusEnumType20.h @@ -0,0 +1,50 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:CancelReservationRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_CANCELRESERVATIONSTATUSENUMTYPE_H +#define OPENOCPP_OCPP20_CANCELRESERVATIONSTATUSENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief This indicates the success or failure of the canceling of a reservation by CSMS. */ +enum class CancelReservationStatusEnumType +{ + Accepted, + Rejected, +}; + +/** @brief Helper to convert a CancelReservationStatusEnumType enum to string */ +extern const EnumToStringFromString CancelReservationStatusEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_CANCELRESERVATIONSTATUSENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/CertificateActionEnumType20.cpp b/src/ocpp20/types/CertificateActionEnumType20.cpp new file mode 100644 index 00000000..da15c632 --- /dev/null +++ b/src/ocpp20/types/CertificateActionEnumType20.cpp @@ -0,0 +1,41 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:Get15118EVCertificateRequest + OCPP 2.0.1 FINAL +*/ + +#include "CertificateActionEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a CertificateActionEnumType enum to string */ +const EnumToStringFromString CertificateActionEnumTypeHelper = { + {CertificateActionEnumType::Install, "Install"}, + {CertificateActionEnumType::Update, "Update"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/CertificateActionEnumType20.h b/src/ocpp20/types/CertificateActionEnumType20.h new file mode 100644 index 00000000..47d6ae44 --- /dev/null +++ b/src/ocpp20/types/CertificateActionEnumType20.h @@ -0,0 +1,50 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:Get15118EVCertificateRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_CERTIFICATEACTIONENUMTYPE_H +#define OPENOCPP_OCPP20_CERTIFICATEACTIONENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Defines whether certificate needs to be installed or updated. */ +enum class CertificateActionEnumType +{ + Install, + Update, +}; + +/** @brief Helper to convert a CertificateActionEnumType enum to string */ +extern const EnumToStringFromString CertificateActionEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_CERTIFICATEACTIONENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/CertificateHashDataChainType20.cpp b/src/ocpp20/types/CertificateHashDataChainType20.cpp new file mode 100644 index 00000000..bee2b774 --- /dev/null +++ b/src/ocpp20/types/CertificateHashDataChainType20.cpp @@ -0,0 +1,123 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetInstalledCertificateIdsRequest + OCPP 2.0.1 FINAL +*/ + +#include "CertificateHashDataChainType20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Convert a CertificateHashDataChainType from a JSON representation */ +bool CertificateHashDataChainTypeConverter::fromJson(const rapidjson::Value& json, + CertificateHashDataChainType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // certificateHashData + CertificateHashDataTypeConverter certificateHashData_converter; + ret = ret && certificateHashData_converter.fromJson(json["certificateHashData"], data.certificateHashData, error_code, error_message); + + // certificateType + data.certificateType = GetCertificateIdUseEnumTypeHelper.fromString(json["certificateType"].GetString()); + + // childCertificateHashData + if (json.HasMember("childCertificateHashData")) + { + const rapidjson::Value& childCertificateHashData_json = json["childCertificateHashData"]; + CertificateHashDataTypeConverter childCertificateHashData_converter; + for (auto it = childCertificateHashData_json.Begin(); ret && (it != childCertificateHashData_json.End()); ++it) + { + CertificateHashDataType& item = data.childCertificateHashData.emplace_back(); + ret = ret && childCertificateHashData_converter.fromJson(*it, item, error_code, error_message); + } + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a CertificateHashDataChainType to a JSON representation */ +bool CertificateHashDataChainTypeConverter::toJson(const CertificateHashDataChainType& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // certificateHashData + CertificateHashDataTypeConverter certificateHashData_converter; + certificateHashData_converter.setAllocator(allocator); + rapidjson::Document certificateHashData_doc(rapidjson::kObjectType); + ret = ret && certificateHashData_converter.toJson(data.certificateHashData, certificateHashData_doc); + json.AddMember(rapidjson::StringRef("certificateHashData"), certificateHashData_doc.Move(), *allocator); + + // certificateType + fill(json, "certificateType", GetCertificateIdUseEnumTypeHelper.toString(data.certificateType)); + + // childCertificateHashData + if (!data.childCertificateHashData.empty()) + { + + rapidjson::Value childCertificateHashData_json(rapidjson::kArrayType); + CertificateHashDataTypeConverter childCertificateHashData_converter; + childCertificateHashData_converter.setAllocator(allocator); + for (const CertificateHashDataType& item : data.childCertificateHashData) + { + rapidjson::Document item_doc(rapidjson::kObjectType); + ret = ret && childCertificateHashData_converter.toJson(item, item_doc); + childCertificateHashData_json.PushBack(item_doc.Move(), *allocator); + } + json.AddMember(rapidjson::StringRef("childCertificateHashData"), childCertificateHashData_json.Move(), *allocator); + } + + return ret; +} + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/CertificateHashDataChainType20.h b/src/ocpp20/types/CertificateHashDataChainType20.h new file mode 100644 index 00000000..bda3261c --- /dev/null +++ b/src/ocpp20/types/CertificateHashDataChainType20.h @@ -0,0 +1,79 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetInstalledCertificateIdsRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_CERTIFICATEHASHDATACHAINTYPE_H +#define OPENOCPP_OCPP20_CERTIFICATEHASHDATACHAINTYPE_H + +#include "CertificateHashDataType20.h" +#include "CustomDataType20.h" +#include "GetCertificateIdUseEnumType20.h" + +#include "IMessageConverter.h" +#include "Optional.h" +#include + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief */ +struct CertificateHashDataChainType +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + CertificateHashDataType certificateHashData; + /** @brief */ + GetCertificateIdUseEnumType certificateType; + /** @brief */ + std::vector childCertificateHashData; +}; + +/** @brief Converter class for CertificateHashDataChainType type */ +class CertificateHashDataChainTypeConverter : public ocpp::messages::IMessageConverter +{ + public: + /** @brief Clone the converter */ + ocpp::messages::IMessageConverter* clone() const override + { + return new CertificateHashDataChainTypeConverter(); + } + + /** @brief Convert a CertificateHashDataChainType from a JSON representation */ + bool fromJson(const rapidjson::Value& json, + CertificateHashDataChainType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) override; + + /** @brief Convert a CertificateHashDataChainType to a JSON representation */ + bool toJson(const CertificateHashDataChainType& data, rapidjson::Document& json) override; +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_CERTIFICATEHASHDATACHAINTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/CertificateHashDataType20.cpp b/src/ocpp20/types/CertificateHashDataType20.cpp new file mode 100644 index 00000000..fd0e756f --- /dev/null +++ b/src/ocpp20/types/CertificateHashDataType20.cpp @@ -0,0 +1,102 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetInstalledCertificateIdsRequest + OCPP 2.0.1 FINAL +*/ + +#include "CertificateHashDataType20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Convert a CertificateHashDataType from a JSON representation */ +bool CertificateHashDataTypeConverter::fromJson(const rapidjson::Value& json, + CertificateHashDataType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // hashAlgorithm + data.hashAlgorithm = HashAlgorithmEnumTypeHelper.fromString(json["hashAlgorithm"].GetString()); + + // issuerNameHash + extract(json, "issuerNameHash", data.issuerNameHash); + + // issuerKeyHash + extract(json, "issuerKeyHash", data.issuerKeyHash); + + // serialNumber + extract(json, "serialNumber", data.serialNumber); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a CertificateHashDataType to a JSON representation */ +bool CertificateHashDataTypeConverter::toJson(const CertificateHashDataType& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // hashAlgorithm + fill(json, "hashAlgorithm", HashAlgorithmEnumTypeHelper.toString(data.hashAlgorithm)); + + // issuerNameHash + fill(json, "issuerNameHash", data.issuerNameHash); + + // issuerKeyHash + fill(json, "issuerKeyHash", data.issuerKeyHash); + + // serialNumber + fill(json, "serialNumber", data.serialNumber); + + return ret; +} + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/CertificateHashDataType20.h b/src/ocpp20/types/CertificateHashDataType20.h new file mode 100644 index 00000000..3e0945c3 --- /dev/null +++ b/src/ocpp20/types/CertificateHashDataType20.h @@ -0,0 +1,77 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetInstalledCertificateIdsRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_CERTIFICATEHASHDATATYPE_H +#define OPENOCPP_OCPP20_CERTIFICATEHASHDATATYPE_H + +#include "CustomDataType20.h" +#include "HashAlgorithmEnumType20.h" + +#include "CiStringType.h" +#include "IMessageConverter.h" +#include "Optional.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief */ +struct CertificateHashDataType +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + HashAlgorithmEnumType hashAlgorithm; + /** @brief Hashed value of the Issuer DN (Distinguished Name). */ + ocpp::types::CiStringType<128u> issuerNameHash; + /** @brief Hashed value of the issuers public key */ + ocpp::types::CiStringType<128u> issuerKeyHash; + /** @brief The serial number of the certificate. */ + ocpp::types::CiStringType<40u> serialNumber; +}; + +/** @brief Converter class for CertificateHashDataType type */ +class CertificateHashDataTypeConverter : public ocpp::messages::IMessageConverter +{ + public: + /** @brief Clone the converter */ + ocpp::messages::IMessageConverter* clone() const override { return new CertificateHashDataTypeConverter(); } + + /** @brief Convert a CertificateHashDataType from a JSON representation */ + bool fromJson(const rapidjson::Value& json, + CertificateHashDataType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) override; + + /** @brief Convert a CertificateHashDataType to a JSON representation */ + bool toJson(const CertificateHashDataType& data, rapidjson::Document& json) override; +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_CERTIFICATEHASHDATATYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/CertificateSignedStatusEnumType20.cpp b/src/ocpp20/types/CertificateSignedStatusEnumType20.cpp new file mode 100644 index 00000000..330f633d --- /dev/null +++ b/src/ocpp20/types/CertificateSignedStatusEnumType20.cpp @@ -0,0 +1,41 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:CertificateSignedRequest + OCPP 2.0.1 FINAL +*/ + +#include "CertificateSignedStatusEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a CertificateSignedStatusEnumType enum to string */ +const EnumToStringFromString CertificateSignedStatusEnumTypeHelper = { + {CertificateSignedStatusEnumType::Accepted, "Accepted"}, + {CertificateSignedStatusEnumType::Rejected, "Rejected"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/CertificateSignedStatusEnumType20.h b/src/ocpp20/types/CertificateSignedStatusEnumType20.h new file mode 100644 index 00000000..0bd7ff5a --- /dev/null +++ b/src/ocpp20/types/CertificateSignedStatusEnumType20.h @@ -0,0 +1,50 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:CertificateSignedRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_CERTIFICATESIGNEDSTATUSENUMTYPE_H +#define OPENOCPP_OCPP20_CERTIFICATESIGNEDSTATUSENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Returns whether certificate signing has been accepted, otherwise rejected. */ +enum class CertificateSignedStatusEnumType +{ + Accepted, + Rejected, +}; + +/** @brief Helper to convert a CertificateSignedStatusEnumType enum to string */ +extern const EnumToStringFromString CertificateSignedStatusEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_CERTIFICATESIGNEDSTATUSENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/CertificateSigningUseEnumType20.cpp b/src/ocpp20/types/CertificateSigningUseEnumType20.cpp new file mode 100644 index 00000000..8074a17b --- /dev/null +++ b/src/ocpp20/types/CertificateSigningUseEnumType20.cpp @@ -0,0 +1,41 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SignCertificateRequest + OCPP 2.0.1 FINAL +*/ + +#include "CertificateSigningUseEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a CertificateSigningUseEnumType enum to string */ +const EnumToStringFromString CertificateSigningUseEnumTypeHelper = { + {CertificateSigningUseEnumType::ChargingStationCertificate, "ChargingStationCertificate"}, + {CertificateSigningUseEnumType::V2GCertificate, "V2GCertificate"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/CertificateSigningUseEnumType20.h b/src/ocpp20/types/CertificateSigningUseEnumType20.h new file mode 100644 index 00000000..99d3aa6d --- /dev/null +++ b/src/ocpp20/types/CertificateSigningUseEnumType20.h @@ -0,0 +1,50 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SignCertificateRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_CERTIFICATESIGNINGUSEENUMTYPE_H +#define OPENOCPP_OCPP20_CERTIFICATESIGNINGUSEENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Indicates the type of certificate that is to be signed. When omitted the certificate is to be used for both the 15118 connection (if implemented) and the Charging Station to CSMS connection. */ +enum class CertificateSigningUseEnumType +{ + ChargingStationCertificate, + V2GCertificate, +}; + +/** @brief Helper to convert a CertificateSigningUseEnumType enum to string */ +extern const EnumToStringFromString CertificateSigningUseEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_CERTIFICATESIGNINGUSEENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/ChangeAvailabilityStatusEnumType20.cpp b/src/ocpp20/types/ChangeAvailabilityStatusEnumType20.cpp new file mode 100644 index 00000000..ef987c39 --- /dev/null +++ b/src/ocpp20/types/ChangeAvailabilityStatusEnumType20.cpp @@ -0,0 +1,42 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:ChangeAvailabilityRequest + OCPP 2.0.1 FINAL +*/ + +#include "ChangeAvailabilityStatusEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a ChangeAvailabilityStatusEnumType enum to string */ +const EnumToStringFromString ChangeAvailabilityStatusEnumTypeHelper = { + {ChangeAvailabilityStatusEnumType::Accepted, "Accepted"}, + {ChangeAvailabilityStatusEnumType::Rejected, "Rejected"}, + {ChangeAvailabilityStatusEnumType::Scheduled, "Scheduled"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/ChangeAvailabilityStatusEnumType20.h b/src/ocpp20/types/ChangeAvailabilityStatusEnumType20.h new file mode 100644 index 00000000..23cc2438 --- /dev/null +++ b/src/ocpp20/types/ChangeAvailabilityStatusEnumType20.h @@ -0,0 +1,51 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:ChangeAvailabilityRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_CHANGEAVAILABILITYSTATUSENUMTYPE_H +#define OPENOCPP_OCPP20_CHANGEAVAILABILITYSTATUSENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief This indicates whether the Charging Station is able to perform the availability change. */ +enum class ChangeAvailabilityStatusEnumType +{ + Accepted, + Rejected, + Scheduled, +}; + +/** @brief Helper to convert a ChangeAvailabilityStatusEnumType enum to string */ +extern const EnumToStringFromString ChangeAvailabilityStatusEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_CHANGEAVAILABILITYSTATUSENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/ChargingLimitSourceEnumType20.cpp b/src/ocpp20/types/ChargingLimitSourceEnumType20.cpp new file mode 100644 index 00000000..363a3268 --- /dev/null +++ b/src/ocpp20/types/ChargingLimitSourceEnumType20.cpp @@ -0,0 +1,43 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetChargingProfilesRequest + OCPP 2.0.1 FINAL +*/ + +#include "ChargingLimitSourceEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a ChargingLimitSourceEnumType enum to string */ +const EnumToStringFromString ChargingLimitSourceEnumTypeHelper = { + {ChargingLimitSourceEnumType::EMS, "EMS"}, + {ChargingLimitSourceEnumType::Other, "Other"}, + {ChargingLimitSourceEnumType::SO, "SO"}, + {ChargingLimitSourceEnumType::CSO, "CSO"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/ChargingLimitSourceEnumType20.h b/src/ocpp20/types/ChargingLimitSourceEnumType20.h new file mode 100644 index 00000000..b1479e9a --- /dev/null +++ b/src/ocpp20/types/ChargingLimitSourceEnumType20.h @@ -0,0 +1,52 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetChargingProfilesRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_CHARGINGLIMITSOURCEENUMTYPE_H +#define OPENOCPP_OCPP20_CHARGINGLIMITSOURCEENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief */ +enum class ChargingLimitSourceEnumType +{ + EMS, + Other, + SO, + CSO, +}; + +/** @brief Helper to convert a ChargingLimitSourceEnumType enum to string */ +extern const EnumToStringFromString ChargingLimitSourceEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_CHARGINGLIMITSOURCEENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/ChargingLimitType20.cpp b/src/ocpp20/types/ChargingLimitType20.cpp new file mode 100644 index 00000000..343c47b7 --- /dev/null +++ b/src/ocpp20/types/ChargingLimitType20.cpp @@ -0,0 +1,90 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:NotifyChargingLimitRequest + OCPP 2.0.1 FINAL +*/ + +#include "ChargingLimitType20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Convert a ChargingLimitType from a JSON representation */ +bool ChargingLimitTypeConverter::fromJson(const rapidjson::Value& json, + ChargingLimitType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // chargingLimitSource + data.chargingLimitSource = ChargingLimitSourceEnumTypeHelper.fromString(json["chargingLimitSource"].GetString()); + + // isGridCritical + extract(json, "isGridCritical", data.isGridCritical); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a ChargingLimitType to a JSON representation */ +bool ChargingLimitTypeConverter::toJson(const ChargingLimitType& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // chargingLimitSource + fill(json, "chargingLimitSource", ChargingLimitSourceEnumTypeHelper.toString(data.chargingLimitSource)); + + // isGridCritical + fill(json, "isGridCritical", data.isGridCritical); + + return ret; +} + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/ChargingLimitType20.h b/src/ocpp20/types/ChargingLimitType20.h new file mode 100644 index 00000000..6098acdd --- /dev/null +++ b/src/ocpp20/types/ChargingLimitType20.h @@ -0,0 +1,76 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:NotifyChargingLimitRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_CHARGINGLIMITTYPE_H +#define OPENOCPP_OCPP20_CHARGINGLIMITTYPE_H + +#include "ChargingLimitSourceEnumType20.h" +#include "CustomDataType20.h" + +#include "IMessageConverter.h" +#include "Optional.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Charging_ Limit +urn:x-enexis:ecdm:uid:2:234489 + */ +struct ChargingLimitType +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ChargingLimitSourceEnumType chargingLimitSource; + /** @brief Charging_ Limit. Is_ Grid_ Critical. Indicator +urn:x-enexis:ecdm:uid:1:570847 +Indicates whether the charging limit is critical for the grid. */ + ocpp::types::Optional isGridCritical; +}; + +/** @brief Converter class for ChargingLimitType type */ +class ChargingLimitTypeConverter : public ocpp::messages::IMessageConverter +{ + public: + /** @brief Clone the converter */ + ocpp::messages::IMessageConverter* clone() const override { return new ChargingLimitTypeConverter(); } + + /** @brief Convert a ChargingLimitType from a JSON representation */ + bool fromJson(const rapidjson::Value& json, + ChargingLimitType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) override; + + /** @brief Convert a ChargingLimitType to a JSON representation */ + bool toJson(const ChargingLimitType& data, rapidjson::Document& json) override; +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_CHARGINGLIMITTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/ChargingNeedsType20.cpp b/src/ocpp20/types/ChargingNeedsType20.cpp new file mode 100644 index 00000000..a829f1e8 --- /dev/null +++ b/src/ocpp20/types/ChargingNeedsType20.cpp @@ -0,0 +1,126 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:NotifyEVChargingNeedsRequest + OCPP 2.0.1 FINAL +*/ + +#include "ChargingNeedsType20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Convert a ChargingNeedsType from a JSON representation */ +bool ChargingNeedsTypeConverter::fromJson(const rapidjson::Value& json, + ChargingNeedsType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // acChargingParameters + if (json.HasMember("acChargingParameters")) + { + ACChargingParametersTypeConverter acChargingParameters_converter; + ret = ret && + acChargingParameters_converter.fromJson(json["acChargingParameters"], data.acChargingParameters, error_code, error_message); + } + + // dcChargingParameters + if (json.HasMember("dcChargingParameters")) + { + DCChargingParametersTypeConverter dcChargingParameters_converter; + ret = ret && + dcChargingParameters_converter.fromJson(json["dcChargingParameters"], data.dcChargingParameters, error_code, error_message); + } + + // requestedEnergyTransfer + data.requestedEnergyTransfer = EnergyTransferModeEnumTypeHelper.fromString(json["requestedEnergyTransfer"].GetString()); + + // departureTime + ret = ret && extract(json, "departureTime", data.departureTime, error_message); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a ChargingNeedsType to a JSON representation */ +bool ChargingNeedsTypeConverter::toJson(const ChargingNeedsType& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // acChargingParameters + if (data.acChargingParameters.isSet()) + { + ACChargingParametersTypeConverter acChargingParameters_converter; + acChargingParameters_converter.setAllocator(allocator); + rapidjson::Document acChargingParameters_doc(rapidjson::kObjectType); + ret = ret && acChargingParameters_converter.toJson(data.acChargingParameters, acChargingParameters_doc); + json.AddMember(rapidjson::StringRef("acChargingParameters"), acChargingParameters_doc.Move(), *allocator); + } + + // dcChargingParameters + if (data.dcChargingParameters.isSet()) + { + DCChargingParametersTypeConverter dcChargingParameters_converter; + dcChargingParameters_converter.setAllocator(allocator); + rapidjson::Document dcChargingParameters_doc(rapidjson::kObjectType); + ret = ret && dcChargingParameters_converter.toJson(data.dcChargingParameters, dcChargingParameters_doc); + json.AddMember(rapidjson::StringRef("dcChargingParameters"), dcChargingParameters_doc.Move(), *allocator); + } + + // requestedEnergyTransfer + fill(json, "requestedEnergyTransfer", EnergyTransferModeEnumTypeHelper.toString(data.requestedEnergyTransfer)); + + // departureTime + fill(json, "departureTime", data.departureTime); + + return ret; +} + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/ChargingNeedsType20.h b/src/ocpp20/types/ChargingNeedsType20.h new file mode 100644 index 00000000..5ac2aa92 --- /dev/null +++ b/src/ocpp20/types/ChargingNeedsType20.h @@ -0,0 +1,83 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:NotifyEVChargingNeedsRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_CHARGINGNEEDSTYPE_H +#define OPENOCPP_OCPP20_CHARGINGNEEDSTYPE_H + +#include "ACChargingParametersType20.h" +#include "CustomDataType20.h" +#include "DCChargingParametersType20.h" +#include "EnergyTransferModeEnumType20.h" + +#include "DateTime.h" +#include "IMessageConverter.h" +#include "Optional.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Charging_ Needs +urn:x-oca:ocpp:uid:2:233249 + */ +struct ChargingNeedsType +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::Optional acChargingParameters; + /** @brief */ + ocpp::types::Optional dcChargingParameters; + /** @brief */ + EnergyTransferModeEnumType requestedEnergyTransfer; + /** @brief Charging_ Needs. Departure_ Time. Date_ Time +urn:x-oca:ocpp:uid:1:569223 +Estimated departure time of the EV. */ + ocpp::types::Optional departureTime; +}; + +/** @brief Converter class for ChargingNeedsType type */ +class ChargingNeedsTypeConverter : public ocpp::messages::IMessageConverter +{ + public: + /** @brief Clone the converter */ + ocpp::messages::IMessageConverter* clone() const override { return new ChargingNeedsTypeConverter(); } + + /** @brief Convert a ChargingNeedsType from a JSON representation */ + bool fromJson(const rapidjson::Value& json, + ChargingNeedsType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) override; + + /** @brief Convert a ChargingNeedsType to a JSON representation */ + bool toJson(const ChargingNeedsType& data, rapidjson::Document& json) override; +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_CHARGINGNEEDSTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/ChargingProfileCriterionType20.cpp b/src/ocpp20/types/ChargingProfileCriterionType20.cpp new file mode 100644 index 00000000..1204f7b8 --- /dev/null +++ b/src/ocpp20/types/ChargingProfileCriterionType20.cpp @@ -0,0 +1,143 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetChargingProfilesRequest + OCPP 2.0.1 FINAL +*/ + +#include "ChargingProfileCriterionType20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Convert a ChargingProfileCriterionType from a JSON representation */ +bool ChargingProfileCriterionTypeConverter::fromJson(const rapidjson::Value& json, + ChargingProfileCriterionType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // chargingProfilePurpose + if (json.HasMember("chargingProfilePurpose")) + { + data.chargingProfilePurpose = ChargingProfilePurposeEnumTypeHelper.fromString(json["chargingProfilePurpose"].GetString()); + } + + // stackLevel + extract(json, "stackLevel", data.stackLevel); + + // chargingProfileId + if (json.HasMember("chargingProfileId")) + { + const rapidjson::Value& chargingProfileId_json = json["chargingProfileId"]; + for (auto it = chargingProfileId_json.Begin(); ret && (it != chargingProfileId_json.End()); ++it) + { + int& item = data.chargingProfileId.emplace_back(); + item = it->GetInt(); + } + } + + // chargingLimitSource + if (json.HasMember("chargingLimitSource")) + { + const rapidjson::Value& chargingLimitSource_json = json["chargingLimitSource"]; + for (auto it = chargingLimitSource_json.Begin(); ret && (it != chargingLimitSource_json.End()); ++it) + { + ChargingLimitSourceEnumType& item = data.chargingLimitSource.emplace_back(); + item = ChargingLimitSourceEnumTypeHelper.fromString(it->GetString()); + } + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a ChargingProfileCriterionType to a JSON representation */ +bool ChargingProfileCriterionTypeConverter::toJson(const ChargingProfileCriterionType& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // chargingProfilePurpose + if (data.chargingProfilePurpose.isSet()) + { + fill(json, "chargingProfilePurpose", ChargingProfilePurposeEnumTypeHelper.toString(data.chargingProfilePurpose)); + } + + // stackLevel + fill(json, "stackLevel", data.stackLevel); + + // chargingProfileId + if (!data.chargingProfileId.empty()) + { + + rapidjson::Value chargingProfileId_json(rapidjson::kArrayType); + for (const int& item : data.chargingProfileId) + { + chargingProfileId_json.PushBack(rapidjson::Value(item), *allocator); + } + json.AddMember(rapidjson::StringRef("chargingProfileId"), chargingProfileId_json.Move(), *allocator); + } + + // chargingLimitSource + if (!data.chargingLimitSource.empty()) + { + + rapidjson::Value chargingLimitSource_json(rapidjson::kArrayType); + for (const ChargingLimitSourceEnumType& item : data.chargingLimitSource) + { + chargingLimitSource_json.PushBack(rapidjson::Value(ChargingLimitSourceEnumTypeHelper.toString(item).c_str(), *allocator).Move(), + *allocator); + } + json.AddMember(rapidjson::StringRef("chargingLimitSource"), chargingLimitSource_json.Move(), *allocator); + } + + return ret; +} + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/ChargingProfileCriterionType20.h b/src/ocpp20/types/ChargingProfileCriterionType20.h new file mode 100644 index 00000000..71c27300 --- /dev/null +++ b/src/ocpp20/types/ChargingProfileCriterionType20.h @@ -0,0 +1,86 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetChargingProfilesRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_CHARGINGPROFILECRITERIONTYPE_H +#define OPENOCPP_OCPP20_CHARGINGPROFILECRITERIONTYPE_H + +#include "ChargingLimitSourceEnumType20.h" +#include "ChargingProfilePurposeEnumType20.h" +#include "CustomDataType20.h" + +#include "IMessageConverter.h" +#include "Optional.h" +#include + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Charging_ Profile +urn:x-oca:ocpp:uid:2:233255 +A ChargingProfile consists of ChargingSchedule, describing the amount of power or current that can be delivered per time interval. + */ +struct ChargingProfileCriterionType +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::Optional chargingProfilePurpose; + /** @brief Charging_ Profile. Stack_ Level. Counter +urn:x-oca:ocpp:uid:1:569230 +Value determining level in hierarchy stack of profiles. Higher values have precedence over lower values. Lowest level is 0. */ + ocpp::types::Optional stackLevel; + /** @brief List of all the chargingProfileIds requested. Any ChargingProfile that matches one of these profiles will be reported. If omitted, the Charging Station SHALL not filter on chargingProfileId. This field SHALL NOT contain more ids than set in <<configkey-charging-profile-entries,ChargingProfileEntries.maxLimit>> */ + std::vector chargingProfileId; + /** @brief For which charging limit sources, charging profiles SHALL be reported. If omitted, the Charging Station SHALL not filter on chargingLimitSource. */ + std::vector chargingLimitSource; +}; + +/** @brief Converter class for ChargingProfileCriterionType type */ +class ChargingProfileCriterionTypeConverter : public ocpp::messages::IMessageConverter +{ + public: + /** @brief Clone the converter */ + ocpp::messages::IMessageConverter* clone() const override + { + return new ChargingProfileCriterionTypeConverter(); + } + + /** @brief Convert a ChargingProfileCriterionType from a JSON representation */ + bool fromJson(const rapidjson::Value& json, + ChargingProfileCriterionType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) override; + + /** @brief Convert a ChargingProfileCriterionType to a JSON representation */ + bool toJson(const ChargingProfileCriterionType& data, rapidjson::Document& json) override; +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_CHARGINGPROFILECRITERIONTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/ChargingProfileKindEnumType20.cpp b/src/ocpp20/types/ChargingProfileKindEnumType20.cpp new file mode 100644 index 00000000..4ba7ae33 --- /dev/null +++ b/src/ocpp20/types/ChargingProfileKindEnumType20.cpp @@ -0,0 +1,42 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:RequestStartTransactionRequest + OCPP 2.0.1 FINAL +*/ + +#include "ChargingProfileKindEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a ChargingProfileKindEnumType enum to string */ +const EnumToStringFromString ChargingProfileKindEnumTypeHelper = { + {ChargingProfileKindEnumType::Absolute, "Absolute"}, + {ChargingProfileKindEnumType::Recurring, "Recurring"}, + {ChargingProfileKindEnumType::Relative, "Relative"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/ChargingProfileKindEnumType20.h b/src/ocpp20/types/ChargingProfileKindEnumType20.h new file mode 100644 index 00000000..fbae1ffb --- /dev/null +++ b/src/ocpp20/types/ChargingProfileKindEnumType20.h @@ -0,0 +1,53 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:RequestStartTransactionRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_CHARGINGPROFILEKINDENUMTYPE_H +#define OPENOCPP_OCPP20_CHARGINGPROFILEKINDENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Charging_ Profile. Charging_ Profile_ Kind. Charging_ Profile_ Kind_ Code +urn:x-oca:ocpp:uid:1:569232 +Indicates the kind of schedule. */ +enum class ChargingProfileKindEnumType +{ + Absolute, + Recurring, + Relative, +}; + +/** @brief Helper to convert a ChargingProfileKindEnumType enum to string */ +extern const EnumToStringFromString ChargingProfileKindEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_CHARGINGPROFILEKINDENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/ChargingProfilePurposeEnumType20.cpp b/src/ocpp20/types/ChargingProfilePurposeEnumType20.cpp new file mode 100644 index 00000000..71b153c3 --- /dev/null +++ b/src/ocpp20/types/ChargingProfilePurposeEnumType20.cpp @@ -0,0 +1,43 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:RequestStartTransactionRequest + OCPP 2.0.1 FINAL +*/ + +#include "ChargingProfilePurposeEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a ChargingProfilePurposeEnumType enum to string */ +const EnumToStringFromString ChargingProfilePurposeEnumTypeHelper = { + {ChargingProfilePurposeEnumType::ChargingStationExternalConstraints, "ChargingStationExternalConstraints"}, + {ChargingProfilePurposeEnumType::ChargingStationMaxProfile, "ChargingStationMaxProfile"}, + {ChargingProfilePurposeEnumType::TxDefaultProfile, "TxDefaultProfile"}, + {ChargingProfilePurposeEnumType::TxProfile, "TxProfile"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/ChargingProfilePurposeEnumType20.h b/src/ocpp20/types/ChargingProfilePurposeEnumType20.h new file mode 100644 index 00000000..ba19b91b --- /dev/null +++ b/src/ocpp20/types/ChargingProfilePurposeEnumType20.h @@ -0,0 +1,54 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:RequestStartTransactionRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_CHARGINGPROFILEPURPOSEENUMTYPE_H +#define OPENOCPP_OCPP20_CHARGINGPROFILEPURPOSEENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Charging_ Profile. Charging_ Profile_ Purpose. Charging_ Profile_ Purpose_ Code +urn:x-oca:ocpp:uid:1:569231 +Defines the purpose of the schedule transferred by this profile */ +enum class ChargingProfilePurposeEnumType +{ + ChargingStationExternalConstraints, + ChargingStationMaxProfile, + TxDefaultProfile, + TxProfile, +}; + +/** @brief Helper to convert a ChargingProfilePurposeEnumType enum to string */ +extern const EnumToStringFromString ChargingProfilePurposeEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_CHARGINGPROFILEPURPOSEENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/ChargingProfileStatusEnumType20.cpp b/src/ocpp20/types/ChargingProfileStatusEnumType20.cpp new file mode 100644 index 00000000..bb8ab3c0 --- /dev/null +++ b/src/ocpp20/types/ChargingProfileStatusEnumType20.cpp @@ -0,0 +1,41 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SetChargingProfileRequest + OCPP 2.0.1 FINAL +*/ + +#include "ChargingProfileStatusEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a ChargingProfileStatusEnumType enum to string */ +const EnumToStringFromString ChargingProfileStatusEnumTypeHelper = { + {ChargingProfileStatusEnumType::Accepted, "Accepted"}, + {ChargingProfileStatusEnumType::Rejected, "Rejected"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/ChargingProfileStatusEnumType20.h b/src/ocpp20/types/ChargingProfileStatusEnumType20.h new file mode 100644 index 00000000..dd388d07 --- /dev/null +++ b/src/ocpp20/types/ChargingProfileStatusEnumType20.h @@ -0,0 +1,50 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SetChargingProfileRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_CHARGINGPROFILESTATUSENUMTYPE_H +#define OPENOCPP_OCPP20_CHARGINGPROFILESTATUSENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Returns whether the Charging Station has been able to process the message successfully. This does not guarantee the schedule will be followed to the letter. There might be other constraints the Charging Station may need to take into account. */ +enum class ChargingProfileStatusEnumType +{ + Accepted, + Rejected, +}; + +/** @brief Helper to convert a ChargingProfileStatusEnumType enum to string */ +extern const EnumToStringFromString ChargingProfileStatusEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_CHARGINGPROFILESTATUSENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/ChargingProfileType20.cpp b/src/ocpp20/types/ChargingProfileType20.cpp new file mode 100644 index 00000000..7b18ec1a --- /dev/null +++ b/src/ocpp20/types/ChargingProfileType20.cpp @@ -0,0 +1,157 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:RequestStartTransactionRequest + OCPP 2.0.1 FINAL +*/ + +#include "ChargingProfileType20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Convert a ChargingProfileType from a JSON representation */ +bool ChargingProfileTypeConverter::fromJson(const rapidjson::Value& json, + ChargingProfileType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // id + extract(json, "id", data.id); + + // stackLevel + extract(json, "stackLevel", data.stackLevel); + + // chargingProfilePurpose + data.chargingProfilePurpose = ChargingProfilePurposeEnumTypeHelper.fromString(json["chargingProfilePurpose"].GetString()); + + // chargingProfileKind + data.chargingProfileKind = ChargingProfileKindEnumTypeHelper.fromString(json["chargingProfileKind"].GetString()); + + // recurrencyKind + if (json.HasMember("recurrencyKind")) + { + data.recurrencyKind = RecurrencyKindEnumTypeHelper.fromString(json["recurrencyKind"].GetString()); + } + + // validFrom + ret = ret && extract(json, "validFrom", data.validFrom, error_message); + + // validTo + ret = ret && extract(json, "validTo", data.validTo, error_message); + + // chargingSchedule + if (json.HasMember("chargingSchedule")) + { + const rapidjson::Value& chargingSchedule_json = json["chargingSchedule"]; + ChargingScheduleTypeConverter chargingSchedule_converter; + for (auto it = chargingSchedule_json.Begin(); ret && (it != chargingSchedule_json.End()); ++it) + { + ChargingScheduleType& item = data.chargingSchedule.emplace_back(); + ret = ret && chargingSchedule_converter.fromJson(*it, item, error_code, error_message); + } + } + + // transactionId + extract(json, "transactionId", data.transactionId); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a ChargingProfileType to a JSON representation */ +bool ChargingProfileTypeConverter::toJson(const ChargingProfileType& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // id + fill(json, "id", data.id); + + // stackLevel + fill(json, "stackLevel", data.stackLevel); + + // chargingProfilePurpose + fill(json, "chargingProfilePurpose", ChargingProfilePurposeEnumTypeHelper.toString(data.chargingProfilePurpose)); + + // chargingProfileKind + fill(json, "chargingProfileKind", ChargingProfileKindEnumTypeHelper.toString(data.chargingProfileKind)); + + // recurrencyKind + if (data.recurrencyKind.isSet()) + { + fill(json, "recurrencyKind", RecurrencyKindEnumTypeHelper.toString(data.recurrencyKind)); + } + + // validFrom + fill(json, "validFrom", data.validFrom); + + // validTo + fill(json, "validTo", data.validTo); + + // chargingSchedule + + rapidjson::Value chargingSchedule_json(rapidjson::kArrayType); + ChargingScheduleTypeConverter chargingSchedule_converter; + chargingSchedule_converter.setAllocator(allocator); + for (const ChargingScheduleType& item : data.chargingSchedule) + { + rapidjson::Document item_doc(rapidjson::kObjectType); + ret = ret && chargingSchedule_converter.toJson(item, item_doc); + chargingSchedule_json.PushBack(item_doc.Move(), *allocator); + } + json.AddMember(rapidjson::StringRef("chargingSchedule"), chargingSchedule_json.Move(), *allocator); + + // transactionId + fill(json, "transactionId", data.transactionId); + + return ret; +} + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/ChargingProfileType20.h b/src/ocpp20/types/ChargingProfileType20.h new file mode 100644 index 00000000..708ab8ef --- /dev/null +++ b/src/ocpp20/types/ChargingProfileType20.h @@ -0,0 +1,103 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:RequestStartTransactionRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_CHARGINGPROFILETYPE_H +#define OPENOCPP_OCPP20_CHARGINGPROFILETYPE_H + +#include "ChargingProfileKindEnumType20.h" +#include "ChargingProfilePurposeEnumType20.h" +#include "ChargingScheduleType20.h" +#include "CustomDataType20.h" +#include "RecurrencyKindEnumType20.h" + +#include "CiStringType.h" +#include "DateTime.h" +#include "IMessageConverter.h" +#include "Optional.h" +#include + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Charging_ Profile +urn:x-oca:ocpp:uid:2:233255 +A ChargingProfile consists of ChargingSchedule, describing the amount of power or current that can be delivered per time interval. + */ +struct ChargingProfileType +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief Identified_ Object. MRID. Numeric_ Identifier +urn:x-enexis:ecdm:uid:1:569198 +Id of ChargingProfile. */ + int id; + /** @brief Charging_ Profile. Stack_ Level. Counter +urn:x-oca:ocpp:uid:1:569230 +Value determining level in hierarchy stack of profiles. Higher values have precedence over lower values. Lowest level is 0. */ + int stackLevel; + /** @brief */ + ChargingProfilePurposeEnumType chargingProfilePurpose; + /** @brief */ + ChargingProfileKindEnumType chargingProfileKind; + /** @brief */ + ocpp::types::Optional recurrencyKind; + /** @brief Charging_ Profile. Valid_ From. Date_ Time +urn:x-oca:ocpp:uid:1:569234 +Point in time at which the profile starts to be valid. If absent, the profile is valid as soon as it is received by the Charging Station. */ + ocpp::types::Optional validFrom; + /** @brief Charging_ Profile. Valid_ To. Date_ Time +urn:x-oca:ocpp:uid:1:569235 +Point in time at which the profile stops to be valid. If absent, the profile is valid until it is replaced by another profile. */ + ocpp::types::Optional validTo; + /** @brief */ + std::vector chargingSchedule; + /** @brief SHALL only be included if ChargingProfilePurpose is set to TxProfile. The transactionId is used to match the profile to a specific transaction. */ + ocpp::types::Optional> transactionId; +}; + +/** @brief Converter class for ChargingProfileType type */ +class ChargingProfileTypeConverter : public ocpp::messages::IMessageConverter +{ + public: + /** @brief Clone the converter */ + ocpp::messages::IMessageConverter* clone() const override { return new ChargingProfileTypeConverter(); } + + /** @brief Convert a ChargingProfileType from a JSON representation */ + bool fromJson(const rapidjson::Value& json, + ChargingProfileType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) override; + + /** @brief Convert a ChargingProfileType to a JSON representation */ + bool toJson(const ChargingProfileType& data, rapidjson::Document& json) override; +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_CHARGINGPROFILETYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/ChargingRateUnitEnumType20.cpp b/src/ocpp20/types/ChargingRateUnitEnumType20.cpp new file mode 100644 index 00000000..16b83351 --- /dev/null +++ b/src/ocpp20/types/ChargingRateUnitEnumType20.cpp @@ -0,0 +1,41 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:RequestStartTransactionRequest + OCPP 2.0.1 FINAL +*/ + +#include "ChargingRateUnitEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a ChargingRateUnitEnumType enum to string */ +const EnumToStringFromString ChargingRateUnitEnumTypeHelper = { + {ChargingRateUnitEnumType::W, "W"}, + {ChargingRateUnitEnumType::A, "A"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/ChargingRateUnitEnumType20.h b/src/ocpp20/types/ChargingRateUnitEnumType20.h new file mode 100644 index 00000000..01d4ea26 --- /dev/null +++ b/src/ocpp20/types/ChargingRateUnitEnumType20.h @@ -0,0 +1,52 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:RequestStartTransactionRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_CHARGINGRATEUNITENUMTYPE_H +#define OPENOCPP_OCPP20_CHARGINGRATEUNITENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Charging_ Schedule. Charging_ Rate_ Unit. Charging_ Rate_ Unit_ Code +urn:x-oca:ocpp:uid:1:569238 +The unit of measure Limit is expressed in. */ +enum class ChargingRateUnitEnumType +{ + W, + A, +}; + +/** @brief Helper to convert a ChargingRateUnitEnumType enum to string */ +extern const EnumToStringFromString ChargingRateUnitEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_CHARGINGRATEUNITENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/ChargingSchedulePeriodType20.cpp b/src/ocpp20/types/ChargingSchedulePeriodType20.cpp new file mode 100644 index 00000000..70b41e36 --- /dev/null +++ b/src/ocpp20/types/ChargingSchedulePeriodType20.cpp @@ -0,0 +1,102 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:RequestStartTransactionRequest + OCPP 2.0.1 FINAL +*/ + +#include "ChargingSchedulePeriodType20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Convert a ChargingSchedulePeriodType from a JSON representation */ +bool ChargingSchedulePeriodTypeConverter::fromJson(const rapidjson::Value& json, + ChargingSchedulePeriodType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // startPeriod + extract(json, "startPeriod", data.startPeriod); + + // limit + extract(json, "limit", data.limit); + + // numberPhases + extract(json, "numberPhases", data.numberPhases); + + // phaseToUse + extract(json, "phaseToUse", data.phaseToUse); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a ChargingSchedulePeriodType to a JSON representation */ +bool ChargingSchedulePeriodTypeConverter::toJson(const ChargingSchedulePeriodType& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // startPeriod + fill(json, "startPeriod", data.startPeriod); + + // limit + fill(json, "limit", data.limit); + + // numberPhases + fill(json, "numberPhases", data.numberPhases); + + // phaseToUse + fill(json, "phaseToUse", data.phaseToUse); + + return ret; +} + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/ChargingSchedulePeriodType20.h b/src/ocpp20/types/ChargingSchedulePeriodType20.h new file mode 100644 index 00000000..7ed16f1d --- /dev/null +++ b/src/ocpp20/types/ChargingSchedulePeriodType20.h @@ -0,0 +1,87 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:RequestStartTransactionRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_CHARGINGSCHEDULEPERIODTYPE_H +#define OPENOCPP_OCPP20_CHARGINGSCHEDULEPERIODTYPE_H + +#include "CustomDataType20.h" + +#include "IMessageConverter.h" +#include "Optional.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Charging_ Schedule_ Period +urn:x-oca:ocpp:uid:2:233257 +Charging schedule period structure defines a time period in a charging schedule. + */ +struct ChargingSchedulePeriodType +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief Charging_ Schedule_ Period. Start_ Period. Elapsed_ Time +urn:x-oca:ocpp:uid:1:569240 +Start of the period, in seconds from the start of schedule. The value of StartPeriod also defines the stop time of the previous period. */ + int startPeriod; + /** @brief Charging_ Schedule_ Period. Limit. Measure +urn:x-oca:ocpp:uid:1:569241 +Charging rate limit during the schedule period, in the applicable chargingRateUnit, for example in Amperes (A) or Watts (W). Accepts at most one digit fraction (e.g. 8.1). */ + float limit; + /** @brief Charging_ Schedule_ Period. Number_ Phases. Counter +urn:x-oca:ocpp:uid:1:569242 +The number of phases that can be used for charging. If a number of phases is needed, numberPhases=3 will be assumed unless another number is given. */ + ocpp::types::Optional numberPhases; + /** @brief Values: 1..3, Used if numberPhases=1 and if the EVSE is capable of switching the phase connected to the EV, i.e. ACPhaseSwitchingSupported is defined and true. It’s not allowed unless both conditions above are true. If both conditions are true, and phaseToUse is omitted, the Charging Station / EVSE will make the selection on its own. */ + ocpp::types::Optional phaseToUse; +}; + +/** @brief Converter class for ChargingSchedulePeriodType type */ +class ChargingSchedulePeriodTypeConverter : public ocpp::messages::IMessageConverter +{ + public: + /** @brief Clone the converter */ + ocpp::messages::IMessageConverter* clone() const override + { + return new ChargingSchedulePeriodTypeConverter(); + } + + /** @brief Convert a ChargingSchedulePeriodType from a JSON representation */ + bool fromJson(const rapidjson::Value& json, + ChargingSchedulePeriodType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) override; + + /** @brief Convert a ChargingSchedulePeriodType to a JSON representation */ + bool toJson(const ChargingSchedulePeriodType& data, rapidjson::Document& json) override; +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_CHARGINGSCHEDULEPERIODTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/ChargingScheduleType20.cpp b/src/ocpp20/types/ChargingScheduleType20.cpp new file mode 100644 index 00000000..90995f57 --- /dev/null +++ b/src/ocpp20/types/ChargingScheduleType20.cpp @@ -0,0 +1,150 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:RequestStartTransactionRequest + OCPP 2.0.1 FINAL +*/ + +#include "ChargingScheduleType20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Convert a ChargingScheduleType from a JSON representation */ +bool ChargingScheduleTypeConverter::fromJson(const rapidjson::Value& json, + ChargingScheduleType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // id + extract(json, "id", data.id); + + // startSchedule + ret = ret && extract(json, "startSchedule", data.startSchedule, error_message); + + // duration + extract(json, "duration", data.duration); + + // chargingRateUnit + data.chargingRateUnit = ChargingRateUnitEnumTypeHelper.fromString(json["chargingRateUnit"].GetString()); + + // chargingSchedulePeriod + if (json.HasMember("chargingSchedulePeriod")) + { + const rapidjson::Value& chargingSchedulePeriod_json = json["chargingSchedulePeriod"]; + ChargingSchedulePeriodTypeConverter chargingSchedulePeriod_converter; + for (auto it = chargingSchedulePeriod_json.Begin(); ret && (it != chargingSchedulePeriod_json.End()); ++it) + { + ChargingSchedulePeriodType& item = data.chargingSchedulePeriod.emplace_back(); + ret = ret && chargingSchedulePeriod_converter.fromJson(*it, item, error_code, error_message); + } + } + + // minChargingRate + extract(json, "minChargingRate", data.minChargingRate); + + // salesTariff + if (json.HasMember("salesTariff")) + { + SalesTariffTypeConverter salesTariff_converter; + ret = ret && salesTariff_converter.fromJson(json["salesTariff"], data.salesTariff, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a ChargingScheduleType to a JSON representation */ +bool ChargingScheduleTypeConverter::toJson(const ChargingScheduleType& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // id + fill(json, "id", data.id); + + // startSchedule + fill(json, "startSchedule", data.startSchedule); + + // duration + fill(json, "duration", data.duration); + + // chargingRateUnit + fill(json, "chargingRateUnit", ChargingRateUnitEnumTypeHelper.toString(data.chargingRateUnit)); + + // chargingSchedulePeriod + + rapidjson::Value chargingSchedulePeriod_json(rapidjson::kArrayType); + ChargingSchedulePeriodTypeConverter chargingSchedulePeriod_converter; + chargingSchedulePeriod_converter.setAllocator(allocator); + for (const ChargingSchedulePeriodType& item : data.chargingSchedulePeriod) + { + rapidjson::Document item_doc(rapidjson::kObjectType); + ret = ret && chargingSchedulePeriod_converter.toJson(item, item_doc); + chargingSchedulePeriod_json.PushBack(item_doc.Move(), *allocator); + } + json.AddMember(rapidjson::StringRef("chargingSchedulePeriod"), chargingSchedulePeriod_json.Move(), *allocator); + + // minChargingRate + fill(json, "minChargingRate", data.minChargingRate); + + // salesTariff + if (data.salesTariff.isSet()) + { + SalesTariffTypeConverter salesTariff_converter; + salesTariff_converter.setAllocator(allocator); + rapidjson::Document salesTariff_doc(rapidjson::kObjectType); + ret = ret && salesTariff_converter.toJson(data.salesTariff, salesTariff_doc); + json.AddMember(rapidjson::StringRef("salesTariff"), salesTariff_doc.Move(), *allocator); + } + + return ret; +} + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/ChargingScheduleType20.h b/src/ocpp20/types/ChargingScheduleType20.h new file mode 100644 index 00000000..f4309c4f --- /dev/null +++ b/src/ocpp20/types/ChargingScheduleType20.h @@ -0,0 +1,95 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:RequestStartTransactionRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_CHARGINGSCHEDULETYPE_H +#define OPENOCPP_OCPP20_CHARGINGSCHEDULETYPE_H + +#include "ChargingRateUnitEnumType20.h" +#include "ChargingSchedulePeriodType20.h" +#include "CustomDataType20.h" +#include "SalesTariffType20.h" + +#include "DateTime.h" +#include "IMessageConverter.h" +#include "Optional.h" +#include + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Charging_ Schedule +urn:x-oca:ocpp:uid:2:233256 +Charging schedule structure defines a list of charging periods, as used in: GetCompositeSchedule.conf and ChargingProfile. + */ +struct ChargingScheduleType +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief Identifies the ChargingSchedule. */ + int id; + /** @brief Charging_ Schedule. Start_ Schedule. Date_ Time +urn:x-oca:ocpp:uid:1:569237 +Starting point of an absolute schedule. If absent the schedule will be relative to start of charging. */ + ocpp::types::Optional startSchedule; + /** @brief Charging_ Schedule. Duration. Elapsed_ Time +urn:x-oca:ocpp:uid:1:569236 +Duration of the charging schedule in seconds. If the duration is left empty, the last period will continue indefinitely or until end of the transaction if chargingProfilePurpose = TxProfile. */ + ocpp::types::Optional duration; + /** @brief */ + ChargingRateUnitEnumType chargingRateUnit; + /** @brief */ + std::vector chargingSchedulePeriod; + /** @brief Charging_ Schedule. Min_ Charging_ Rate. Numeric +urn:x-oca:ocpp:uid:1:569239 +Minimum charging rate supported by the EV. The unit of measure is defined by the chargingRateUnit. This parameter is intended to be used by a local smart charging algorithm to optimize the power allocation for in the case a charging process is inefficient at lower charging rates. Accepts at most one digit fraction (e.g. 8.1) */ + ocpp::types::Optional minChargingRate; + /** @brief */ + ocpp::types::Optional salesTariff; +}; + +/** @brief Converter class for ChargingScheduleType type */ +class ChargingScheduleTypeConverter : public ocpp::messages::IMessageConverter +{ + public: + /** @brief Clone the converter */ + ocpp::messages::IMessageConverter* clone() const override { return new ChargingScheduleTypeConverter(); } + + /** @brief Convert a ChargingScheduleType from a JSON representation */ + bool fromJson(const rapidjson::Value& json, + ChargingScheduleType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) override; + + /** @brief Convert a ChargingScheduleType to a JSON representation */ + bool toJson(const ChargingScheduleType& data, rapidjson::Document& json) override; +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_CHARGINGSCHEDULETYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/ChargingStateEnumType20.cpp b/src/ocpp20/types/ChargingStateEnumType20.cpp new file mode 100644 index 00000000..fe96af73 --- /dev/null +++ b/src/ocpp20/types/ChargingStateEnumType20.cpp @@ -0,0 +1,44 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:TransactionEventRequest + OCPP 2.0.1 FINAL +*/ + +#include "ChargingStateEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a ChargingStateEnumType enum to string */ +const EnumToStringFromString ChargingStateEnumTypeHelper = { + {ChargingStateEnumType::Charging, "Charging"}, + {ChargingStateEnumType::EVConnected, "EVConnected"}, + {ChargingStateEnumType::SuspendedEV, "SuspendedEV"}, + {ChargingStateEnumType::SuspendedEVSE, "SuspendedEVSE"}, + {ChargingStateEnumType::Idle, "Idle"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/ChargingStateEnumType20.h b/src/ocpp20/types/ChargingStateEnumType20.h new file mode 100644 index 00000000..6e1656d5 --- /dev/null +++ b/src/ocpp20/types/ChargingStateEnumType20.h @@ -0,0 +1,56 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:TransactionEventRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_CHARGINGSTATEENUMTYPE_H +#define OPENOCPP_OCPP20_CHARGINGSTATEENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Transaction. State. Transaction_ State_ Code +urn:x-oca:ocpp:uid:1:569419 +Current charging state, is required when state +has changed. */ +enum class ChargingStateEnumType +{ + Charging, + EVConnected, + SuspendedEV, + SuspendedEVSE, + Idle, +}; + +/** @brief Helper to convert a ChargingStateEnumType enum to string */ +extern const EnumToStringFromString ChargingStateEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_CHARGINGSTATEENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/ChargingStationType20.cpp b/src/ocpp20/types/ChargingStationType20.cpp new file mode 100644 index 00000000..60024019 --- /dev/null +++ b/src/ocpp20/types/ChargingStationType20.cpp @@ -0,0 +1,119 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:BootNotificationRequest + OCPP 2.0.1 FINAL +*/ + +#include "ChargingStationType20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Convert a ChargingStationType from a JSON representation */ +bool ChargingStationTypeConverter::fromJson(const rapidjson::Value& json, + ChargingStationType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // serialNumber + extract(json, "serialNumber", data.serialNumber); + + // model + extract(json, "model", data.model); + + // modem + if (json.HasMember("modem")) + { + ModemTypeConverter modem_converter; + ret = ret && modem_converter.fromJson(json["modem"], data.modem, error_code, error_message); + } + + // vendorName + extract(json, "vendorName", data.vendorName); + + // firmwareVersion + extract(json, "firmwareVersion", data.firmwareVersion); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a ChargingStationType to a JSON representation */ +bool ChargingStationTypeConverter::toJson(const ChargingStationType& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // serialNumber + fill(json, "serialNumber", data.serialNumber); + + // model + fill(json, "model", data.model); + + // modem + if (data.modem.isSet()) + { + ModemTypeConverter modem_converter; + modem_converter.setAllocator(allocator); + rapidjson::Document modem_doc(rapidjson::kObjectType); + ret = ret && modem_converter.toJson(data.modem, modem_doc); + json.AddMember(rapidjson::StringRef("modem"), modem_doc.Move(), *allocator); + } + + // vendorName + fill(json, "vendorName", data.vendorName); + + // firmwareVersion + fill(json, "firmwareVersion", data.firmwareVersion); + + return ret; +} + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/ChargingStationType20.h b/src/ocpp20/types/ChargingStationType20.h new file mode 100644 index 00000000..fb955464 --- /dev/null +++ b/src/ocpp20/types/ChargingStationType20.h @@ -0,0 +1,86 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:BootNotificationRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_CHARGINGSTATIONTYPE_H +#define OPENOCPP_OCPP20_CHARGINGSTATIONTYPE_H + +#include "CustomDataType20.h" +#include "ModemType20.h" + +#include "CiStringType.h" +#include "IMessageConverter.h" +#include "Optional.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Charge_ Point +urn:x-oca:ocpp:uid:2:233122 +The physical system where an Electrical Vehicle (EV) can be charged. + */ +struct ChargingStationType +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief Device. Serial_ Number. Serial_ Number +urn:x-oca:ocpp:uid:1:569324 +Vendor-specific device identifier. */ + ocpp::types::Optional> serialNumber; + /** @brief Device. Model. CI20_ Text +urn:x-oca:ocpp:uid:1:569325 +Defines the model of the device. */ + ocpp::types::CiStringType<20u> model; + /** @brief */ + ocpp::types::Optional modem; + /** @brief Identifies the vendor (not necessarily in a unique manner). */ + ocpp::types::CiStringType<50u> vendorName; + /** @brief This contains the firmware version of the Charging Station. */ + ocpp::types::Optional> firmwareVersion; +}; + +/** @brief Converter class for ChargingStationType type */ +class ChargingStationTypeConverter : public ocpp::messages::IMessageConverter +{ + public: + /** @brief Clone the converter */ + ocpp::messages::IMessageConverter* clone() const override { return new ChargingStationTypeConverter(); } + + /** @brief Convert a ChargingStationType from a JSON representation */ + bool fromJson(const rapidjson::Value& json, + ChargingStationType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) override; + + /** @brief Convert a ChargingStationType to a JSON representation */ + bool toJson(const ChargingStationType& data, rapidjson::Document& json) override; +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_CHARGINGSTATIONTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/ClearCacheStatusEnumType20.cpp b/src/ocpp20/types/ClearCacheStatusEnumType20.cpp new file mode 100644 index 00000000..4485a4db --- /dev/null +++ b/src/ocpp20/types/ClearCacheStatusEnumType20.cpp @@ -0,0 +1,41 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:ClearCacheRequest + OCPP 2.0.1 FINAL +*/ + +#include "ClearCacheStatusEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a ClearCacheStatusEnumType enum to string */ +const EnumToStringFromString ClearCacheStatusEnumTypeHelper = { + {ClearCacheStatusEnumType::Accepted, "Accepted"}, + {ClearCacheStatusEnumType::Rejected, "Rejected"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/ClearCacheStatusEnumType20.h b/src/ocpp20/types/ClearCacheStatusEnumType20.h new file mode 100644 index 00000000..eadf8c6a --- /dev/null +++ b/src/ocpp20/types/ClearCacheStatusEnumType20.h @@ -0,0 +1,50 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:ClearCacheRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_CLEARCACHESTATUSENUMTYPE_H +#define OPENOCPP_OCPP20_CLEARCACHESTATUSENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Accepted if the Charging Station has executed the request, otherwise rejected. */ +enum class ClearCacheStatusEnumType +{ + Accepted, + Rejected, +}; + +/** @brief Helper to convert a ClearCacheStatusEnumType enum to string */ +extern const EnumToStringFromString ClearCacheStatusEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_CLEARCACHESTATUSENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/ClearChargingProfileStatusEnumType20.cpp b/src/ocpp20/types/ClearChargingProfileStatusEnumType20.cpp new file mode 100644 index 00000000..c49c9ec4 --- /dev/null +++ b/src/ocpp20/types/ClearChargingProfileStatusEnumType20.cpp @@ -0,0 +1,41 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:ClearChargingProfileRequest + OCPP 2.0.1 FINAL +*/ + +#include "ClearChargingProfileStatusEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a ClearChargingProfileStatusEnumType enum to string */ +const EnumToStringFromString ClearChargingProfileStatusEnumTypeHelper = { + {ClearChargingProfileStatusEnumType::Accepted, "Accepted"}, + {ClearChargingProfileStatusEnumType::Unknown, "Unknown"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/ClearChargingProfileStatusEnumType20.h b/src/ocpp20/types/ClearChargingProfileStatusEnumType20.h new file mode 100644 index 00000000..1283accf --- /dev/null +++ b/src/ocpp20/types/ClearChargingProfileStatusEnumType20.h @@ -0,0 +1,50 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:ClearChargingProfileRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_CLEARCHARGINGPROFILESTATUSENUMTYPE_H +#define OPENOCPP_OCPP20_CLEARCHARGINGPROFILESTATUSENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Indicates if the Charging Station was able to execute the request. */ +enum class ClearChargingProfileStatusEnumType +{ + Accepted, + Unknown, +}; + +/** @brief Helper to convert a ClearChargingProfileStatusEnumType enum to string */ +extern const EnumToStringFromString ClearChargingProfileStatusEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_CLEARCHARGINGPROFILESTATUSENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/ClearChargingProfileType20.cpp b/src/ocpp20/types/ClearChargingProfileType20.cpp new file mode 100644 index 00000000..62a93798 --- /dev/null +++ b/src/ocpp20/types/ClearChargingProfileType20.cpp @@ -0,0 +1,102 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:ClearChargingProfileRequest + OCPP 2.0.1 FINAL +*/ + +#include "ClearChargingProfileType20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Convert a ClearChargingProfileType from a JSON representation */ +bool ClearChargingProfileTypeConverter::fromJson(const rapidjson::Value& json, + ClearChargingProfileType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // evseId + extract(json, "evseId", data.evseId); + + // chargingProfilePurpose + if (json.HasMember("chargingProfilePurpose")) + { + data.chargingProfilePurpose = ChargingProfilePurposeEnumTypeHelper.fromString(json["chargingProfilePurpose"].GetString()); + } + + // stackLevel + extract(json, "stackLevel", data.stackLevel); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a ClearChargingProfileType to a JSON representation */ +bool ClearChargingProfileTypeConverter::toJson(const ClearChargingProfileType& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // evseId + fill(json, "evseId", data.evseId); + + // chargingProfilePurpose + if (data.chargingProfilePurpose.isSet()) + { + fill(json, "chargingProfilePurpose", ChargingProfilePurposeEnumTypeHelper.toString(data.chargingProfilePurpose)); + } + + // stackLevel + fill(json, "stackLevel", data.stackLevel); + + return ret; +} + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/ClearChargingProfileType20.h b/src/ocpp20/types/ClearChargingProfileType20.h new file mode 100644 index 00000000..a9e331fc --- /dev/null +++ b/src/ocpp20/types/ClearChargingProfileType20.h @@ -0,0 +1,81 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:ClearChargingProfileRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_CLEARCHARGINGPROFILETYPE_H +#define OPENOCPP_OCPP20_CLEARCHARGINGPROFILETYPE_H + +#include "ChargingProfilePurposeEnumType20.h" +#include "CustomDataType20.h" + +#include "IMessageConverter.h" +#include "Optional.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Charging_ Profile +urn:x-oca:ocpp:uid:2:233255 +A ChargingProfile consists of a ChargingSchedule, describing the amount of power or current that can be delivered per time interval. + */ +struct ClearChargingProfileType +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief Identified_ Object. MRID. Numeric_ Identifier +urn:x-enexis:ecdm:uid:1:569198 +Specifies the id of the EVSE for which to clear charging profiles. An evseId of zero (0) specifies the charging profile for the overall Charging Station. Absence of this parameter means the clearing applies to all charging profiles that match the other criteria in the request. */ + ocpp::types::Optional evseId; + /** @brief */ + ocpp::types::Optional chargingProfilePurpose; + /** @brief Charging_ Profile. Stack_ Level. Counter +urn:x-oca:ocpp:uid:1:569230 +Specifies the stackLevel for which charging profiles will be cleared, if they meet the other criteria in the request. */ + ocpp::types::Optional stackLevel; +}; + +/** @brief Converter class for ClearChargingProfileType type */ +class ClearChargingProfileTypeConverter : public ocpp::messages::IMessageConverter +{ + public: + /** @brief Clone the converter */ + ocpp::messages::IMessageConverter* clone() const override { return new ClearChargingProfileTypeConverter(); } + + /** @brief Convert a ClearChargingProfileType from a JSON representation */ + bool fromJson(const rapidjson::Value& json, + ClearChargingProfileType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) override; + + /** @brief Convert a ClearChargingProfileType to a JSON representation */ + bool toJson(const ClearChargingProfileType& data, rapidjson::Document& json) override; +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_CLEARCHARGINGPROFILETYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/ClearMessageStatusEnumType20.cpp b/src/ocpp20/types/ClearMessageStatusEnumType20.cpp new file mode 100644 index 00000000..2df64cdc --- /dev/null +++ b/src/ocpp20/types/ClearMessageStatusEnumType20.cpp @@ -0,0 +1,41 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:ClearDisplayMessageRequest + OCPP 2.0.1 FINAL +*/ + +#include "ClearMessageStatusEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a ClearMessageStatusEnumType enum to string */ +const EnumToStringFromString ClearMessageStatusEnumTypeHelper = { + {ClearMessageStatusEnumType::Accepted, "Accepted"}, + {ClearMessageStatusEnumType::Unknown, "Unknown"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/ClearMessageStatusEnumType20.h b/src/ocpp20/types/ClearMessageStatusEnumType20.h new file mode 100644 index 00000000..d59599db --- /dev/null +++ b/src/ocpp20/types/ClearMessageStatusEnumType20.h @@ -0,0 +1,50 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:ClearDisplayMessageRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_CLEARMESSAGESTATUSENUMTYPE_H +#define OPENOCPP_OCPP20_CLEARMESSAGESTATUSENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Returns whether the Charging Station has been able to remove the message. */ +enum class ClearMessageStatusEnumType +{ + Accepted, + Unknown, +}; + +/** @brief Helper to convert a ClearMessageStatusEnumType enum to string */ +extern const EnumToStringFromString ClearMessageStatusEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_CLEARMESSAGESTATUSENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/ClearMonitoringResultType20.cpp b/src/ocpp20/types/ClearMonitoringResultType20.cpp new file mode 100644 index 00000000..40d93541 --- /dev/null +++ b/src/ocpp20/types/ClearMonitoringResultType20.cpp @@ -0,0 +1,107 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:ClearVariableMonitoringRequest + OCPP 2.0.1 FINAL +*/ + +#include "ClearMonitoringResultType20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Convert a ClearMonitoringResultType from a JSON representation */ +bool ClearMonitoringResultTypeConverter::fromJson(const rapidjson::Value& json, + ClearMonitoringResultType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // status + data.status = ClearMonitoringStatusEnumTypeHelper.fromString(json["status"].GetString()); + + // id + extract(json, "id", data.id); + + // statusInfo + if (json.HasMember("statusInfo")) + { + StatusInfoTypeConverter statusInfo_converter; + ret = ret && statusInfo_converter.fromJson(json["statusInfo"], data.statusInfo, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a ClearMonitoringResultType to a JSON representation */ +bool ClearMonitoringResultTypeConverter::toJson(const ClearMonitoringResultType& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // status + fill(json, "status", ClearMonitoringStatusEnumTypeHelper.toString(data.status)); + + // id + fill(json, "id", data.id); + + // statusInfo + if (data.statusInfo.isSet()) + { + StatusInfoTypeConverter statusInfo_converter; + statusInfo_converter.setAllocator(allocator); + rapidjson::Document statusInfo_doc(rapidjson::kObjectType); + ret = ret && statusInfo_converter.toJson(data.statusInfo, statusInfo_doc); + json.AddMember(rapidjson::StringRef("statusInfo"), statusInfo_doc.Move(), *allocator); + } + + return ret; +} + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/ClearMonitoringResultType20.h b/src/ocpp20/types/ClearMonitoringResultType20.h new file mode 100644 index 00000000..889e3f27 --- /dev/null +++ b/src/ocpp20/types/ClearMonitoringResultType20.h @@ -0,0 +1,78 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:ClearVariableMonitoringRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_CLEARMONITORINGRESULTTYPE_H +#define OPENOCPP_OCPP20_CLEARMONITORINGRESULTTYPE_H + +#include "ClearMonitoringStatusEnumType20.h" +#include "CustomDataType20.h" +#include "StatusInfoType20.h" + +#include "IMessageConverter.h" +#include "Optional.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief */ +struct ClearMonitoringResultType +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ClearMonitoringStatusEnumType status; + /** @brief Id of the monitor of which a clear was requested. */ + int id; + /** @brief */ + ocpp::types::Optional statusInfo; +}; + +/** @brief Converter class for ClearMonitoringResultType type */ +class ClearMonitoringResultTypeConverter : public ocpp::messages::IMessageConverter +{ + public: + /** @brief Clone the converter */ + ocpp::messages::IMessageConverter* clone() const override + { + return new ClearMonitoringResultTypeConverter(); + } + + /** @brief Convert a ClearMonitoringResultType from a JSON representation */ + bool fromJson(const rapidjson::Value& json, + ClearMonitoringResultType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) override; + + /** @brief Convert a ClearMonitoringResultType to a JSON representation */ + bool toJson(const ClearMonitoringResultType& data, rapidjson::Document& json) override; +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_CLEARMONITORINGRESULTTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/ClearMonitoringStatusEnumType20.cpp b/src/ocpp20/types/ClearMonitoringStatusEnumType20.cpp new file mode 100644 index 00000000..de2d4466 --- /dev/null +++ b/src/ocpp20/types/ClearMonitoringStatusEnumType20.cpp @@ -0,0 +1,42 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:ClearVariableMonitoringRequest + OCPP 2.0.1 FINAL +*/ + +#include "ClearMonitoringStatusEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a ClearMonitoringStatusEnumType enum to string */ +const EnumToStringFromString ClearMonitoringStatusEnumTypeHelper = { + {ClearMonitoringStatusEnumType::Accepted, "Accepted"}, + {ClearMonitoringStatusEnumType::Rejected, "Rejected"}, + {ClearMonitoringStatusEnumType::NotFound, "NotFound"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/ClearMonitoringStatusEnumType20.h b/src/ocpp20/types/ClearMonitoringStatusEnumType20.h new file mode 100644 index 00000000..0e7fb099 --- /dev/null +++ b/src/ocpp20/types/ClearMonitoringStatusEnumType20.h @@ -0,0 +1,51 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:ClearVariableMonitoringRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_CLEARMONITORINGSTATUSENUMTYPE_H +#define OPENOCPP_OCPP20_CLEARMONITORINGSTATUSENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Result of the clear request for this monitor, identified by its Id. */ +enum class ClearMonitoringStatusEnumType +{ + Accepted, + Rejected, + NotFound, +}; + +/** @brief Helper to convert a ClearMonitoringStatusEnumType enum to string */ +extern const EnumToStringFromString ClearMonitoringStatusEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_CLEARMONITORINGSTATUSENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/ComponentCriterionEnumType20.cpp b/src/ocpp20/types/ComponentCriterionEnumType20.cpp new file mode 100644 index 00000000..e9f8af44 --- /dev/null +++ b/src/ocpp20/types/ComponentCriterionEnumType20.cpp @@ -0,0 +1,43 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetReportRequest + OCPP 2.0.1 FINAL +*/ + +#include "ComponentCriterionEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a ComponentCriterionEnumType enum to string */ +const EnumToStringFromString ComponentCriterionEnumTypeHelper = { + {ComponentCriterionEnumType::Active, "Active"}, + {ComponentCriterionEnumType::Available, "Available"}, + {ComponentCriterionEnumType::Enabled, "Enabled"}, + {ComponentCriterionEnumType::Problem, "Problem"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/ComponentCriterionEnumType20.h b/src/ocpp20/types/ComponentCriterionEnumType20.h new file mode 100644 index 00000000..e72f0871 --- /dev/null +++ b/src/ocpp20/types/ComponentCriterionEnumType20.h @@ -0,0 +1,52 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetReportRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_COMPONENTCRITERIONENUMTYPE_H +#define OPENOCPP_OCPP20_COMPONENTCRITERIONENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief */ +enum class ComponentCriterionEnumType +{ + Active, + Available, + Enabled, + Problem, +}; + +/** @brief Helper to convert a ComponentCriterionEnumType enum to string */ +extern const EnumToStringFromString ComponentCriterionEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_COMPONENTCRITERIONENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/ComponentType20.cpp b/src/ocpp20/types/ComponentType20.cpp new file mode 100644 index 00000000..92c6cc83 --- /dev/null +++ b/src/ocpp20/types/ComponentType20.cpp @@ -0,0 +1,107 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:NotifyDisplayMessagesRequest + OCPP 2.0.1 FINAL +*/ + +#include "ComponentType20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Convert a ComponentType from a JSON representation */ +bool ComponentTypeConverter::fromJson(const rapidjson::Value& json, + ComponentType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // evse + if (json.HasMember("evse")) + { + EVSETypeConverter evse_converter; + ret = ret && evse_converter.fromJson(json["evse"], data.evse, error_code, error_message); + } + + // name + extract(json, "name", data.name); + + // instance + extract(json, "instance", data.instance); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a ComponentType to a JSON representation */ +bool ComponentTypeConverter::toJson(const ComponentType& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // evse + if (data.evse.isSet()) + { + EVSETypeConverter evse_converter; + evse_converter.setAllocator(allocator); + rapidjson::Document evse_doc(rapidjson::kObjectType); + ret = ret && evse_converter.toJson(data.evse, evse_doc); + json.AddMember(rapidjson::StringRef("evse"), evse_doc.Move(), *allocator); + } + + // name + fill(json, "name", data.name); + + // instance + fill(json, "instance", data.instance); + + return ret; +} + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/ComponentType20.h b/src/ocpp20/types/ComponentType20.h new file mode 100644 index 00000000..ab9d88dc --- /dev/null +++ b/src/ocpp20/types/ComponentType20.h @@ -0,0 +1,76 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:NotifyDisplayMessagesRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_COMPONENTTYPE_H +#define OPENOCPP_OCPP20_COMPONENTTYPE_H + +#include "CustomDataType20.h" +#include "EVSEType20.h" + +#include "CiStringType.h" +#include "IMessageConverter.h" +#include "Optional.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief A physical or logical component + */ +struct ComponentType +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::Optional evse; + /** @brief Name of the component. Name should be taken from the list of standardized component names whenever possible. Case Insensitive. strongly advised to use Camel Case. */ + ocpp::types::CiStringType<50u> name; + /** @brief Name of instance in case the component exists as multiple instances. Case Insensitive. strongly advised to use Camel Case. */ + ocpp::types::Optional> instance; +}; + +/** @brief Converter class for ComponentType type */ +class ComponentTypeConverter : public ocpp::messages::IMessageConverter +{ + public: + /** @brief Clone the converter */ + ocpp::messages::IMessageConverter* clone() const override { return new ComponentTypeConverter(); } + + /** @brief Convert a ComponentType from a JSON representation */ + bool fromJson(const rapidjson::Value& json, + ComponentType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) override; + + /** @brief Convert a ComponentType to a JSON representation */ + bool toJson(const ComponentType& data, rapidjson::Document& json) override; +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_COMPONENTTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/ComponentVariableType20.cpp b/src/ocpp20/types/ComponentVariableType20.cpp new file mode 100644 index 00000000..c2d55d50 --- /dev/null +++ b/src/ocpp20/types/ComponentVariableType20.cpp @@ -0,0 +1,106 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetReportRequest + OCPP 2.0.1 FINAL +*/ + +#include "ComponentVariableType20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Convert a ComponentVariableType from a JSON representation */ +bool ComponentVariableTypeConverter::fromJson(const rapidjson::Value& json, + ComponentVariableType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // component + ComponentTypeConverter component_converter; + ret = ret && component_converter.fromJson(json["component"], data.component, error_code, error_message); + + // variable + if (json.HasMember("variable")) + { + VariableTypeConverter variable_converter; + ret = ret && variable_converter.fromJson(json["variable"], data.variable, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a ComponentVariableType to a JSON representation */ +bool ComponentVariableTypeConverter::toJson(const ComponentVariableType& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // component + ComponentTypeConverter component_converter; + component_converter.setAllocator(allocator); + rapidjson::Document component_doc(rapidjson::kObjectType); + ret = ret && component_converter.toJson(data.component, component_doc); + json.AddMember(rapidjson::StringRef("component"), component_doc.Move(), *allocator); + + // variable + if (data.variable.isSet()) + { + VariableTypeConverter variable_converter; + variable_converter.setAllocator(allocator); + rapidjson::Document variable_doc(rapidjson::kObjectType); + ret = ret && variable_converter.toJson(data.variable, variable_doc); + json.AddMember(rapidjson::StringRef("variable"), variable_doc.Move(), *allocator); + } + + return ret; +} + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/ComponentVariableType20.h b/src/ocpp20/types/ComponentVariableType20.h new file mode 100644 index 00000000..36cbb995 --- /dev/null +++ b/src/ocpp20/types/ComponentVariableType20.h @@ -0,0 +1,74 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetReportRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_COMPONENTVARIABLETYPE_H +#define OPENOCPP_OCPP20_COMPONENTVARIABLETYPE_H + +#include "ComponentType20.h" +#include "CustomDataType20.h" +#include "VariableType20.h" + +#include "IMessageConverter.h" +#include "Optional.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Class to report components, variables and variable attributes and characteristics. + */ +struct ComponentVariableType +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ComponentType component; + /** @brief */ + ocpp::types::Optional variable; +}; + +/** @brief Converter class for ComponentVariableType type */ +class ComponentVariableTypeConverter : public ocpp::messages::IMessageConverter +{ + public: + /** @brief Clone the converter */ + ocpp::messages::IMessageConverter* clone() const override { return new ComponentVariableTypeConverter(); } + + /** @brief Convert a ComponentVariableType from a JSON representation */ + bool fromJson(const rapidjson::Value& json, + ComponentVariableType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) override; + + /** @brief Convert a ComponentVariableType to a JSON representation */ + bool toJson(const ComponentVariableType& data, rapidjson::Document& json) override; +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_COMPONENTVARIABLETYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/CompositeScheduleType20.cpp b/src/ocpp20/types/CompositeScheduleType20.cpp new file mode 100644 index 00000000..3c5103db --- /dev/null +++ b/src/ocpp20/types/CompositeScheduleType20.cpp @@ -0,0 +1,127 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetCompositeScheduleRequest + OCPP 2.0.1 FINAL +*/ + +#include "CompositeScheduleType20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Convert a CompositeScheduleType from a JSON representation */ +bool CompositeScheduleTypeConverter::fromJson(const rapidjson::Value& json, + CompositeScheduleType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // chargingSchedulePeriod + if (json.HasMember("chargingSchedulePeriod")) + { + const rapidjson::Value& chargingSchedulePeriod_json = json["chargingSchedulePeriod"]; + ChargingSchedulePeriodTypeConverter chargingSchedulePeriod_converter; + for (auto it = chargingSchedulePeriod_json.Begin(); ret && (it != chargingSchedulePeriod_json.End()); ++it) + { + ChargingSchedulePeriodType& item = data.chargingSchedulePeriod.emplace_back(); + ret = ret && chargingSchedulePeriod_converter.fromJson(*it, item, error_code, error_message); + } + } + + // evseId + extract(json, "evseId", data.evseId); + + // duration + extract(json, "duration", data.duration); + + // scheduleStart + ret = ret && extract(json, "scheduleStart", data.scheduleStart, error_message); + + // chargingRateUnit + data.chargingRateUnit = ChargingRateUnitEnumTypeHelper.fromString(json["chargingRateUnit"].GetString()); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a CompositeScheduleType to a JSON representation */ +bool CompositeScheduleTypeConverter::toJson(const CompositeScheduleType& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // chargingSchedulePeriod + + rapidjson::Value chargingSchedulePeriod_json(rapidjson::kArrayType); + ChargingSchedulePeriodTypeConverter chargingSchedulePeriod_converter; + chargingSchedulePeriod_converter.setAllocator(allocator); + for (const ChargingSchedulePeriodType& item : data.chargingSchedulePeriod) + { + rapidjson::Document item_doc(rapidjson::kObjectType); + ret = ret && chargingSchedulePeriod_converter.toJson(item, item_doc); + chargingSchedulePeriod_json.PushBack(item_doc.Move(), *allocator); + } + json.AddMember(rapidjson::StringRef("chargingSchedulePeriod"), chargingSchedulePeriod_json.Move(), *allocator); + + // evseId + fill(json, "evseId", data.evseId); + + // duration + fill(json, "duration", data.duration); + + // scheduleStart + fill(json, "scheduleStart", data.scheduleStart); + + // chargingRateUnit + fill(json, "chargingRateUnit", ChargingRateUnitEnumTypeHelper.toString(data.chargingRateUnit)); + + return ret; +} + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/CompositeScheduleType20.h b/src/ocpp20/types/CompositeScheduleType20.h new file mode 100644 index 00000000..421496f2 --- /dev/null +++ b/src/ocpp20/types/CompositeScheduleType20.h @@ -0,0 +1,88 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetCompositeScheduleRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_COMPOSITESCHEDULETYPE_H +#define OPENOCPP_OCPP20_COMPOSITESCHEDULETYPE_H + +#include "ChargingRateUnitEnumType20.h" +#include "ChargingSchedulePeriodType20.h" +#include "CustomDataType20.h" + +#include "DateTime.h" +#include "IMessageConverter.h" +#include "Optional.h" +#include + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Composite_ Schedule +urn:x-oca:ocpp:uid:2:233362 + */ +struct CompositeScheduleType +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + std::vector chargingSchedulePeriod; + /** @brief The ID of the EVSE for which the +schedule is requested. When evseid=0, the +Charging Station calculated the expected +consumption for the grid connection. */ + int evseId; + /** @brief Duration of the schedule in seconds. */ + int duration; + /** @brief Composite_ Schedule. Start. Date_ Time +urn:x-oca:ocpp:uid:1:569456 +Date and time at which the schedule becomes active. All time measurements within the schedule are relative to this timestamp. */ + ocpp::types::DateTime scheduleStart; + /** @brief */ + ChargingRateUnitEnumType chargingRateUnit; +}; + +/** @brief Converter class for CompositeScheduleType type */ +class CompositeScheduleTypeConverter : public ocpp::messages::IMessageConverter +{ + public: + /** @brief Clone the converter */ + ocpp::messages::IMessageConverter* clone() const override { return new CompositeScheduleTypeConverter(); } + + /** @brief Convert a CompositeScheduleType from a JSON representation */ + bool fromJson(const rapidjson::Value& json, + CompositeScheduleType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) override; + + /** @brief Convert a CompositeScheduleType to a JSON representation */ + bool toJson(const CompositeScheduleType& data, rapidjson::Document& json) override; +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_COMPOSITESCHEDULETYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/ConnectorEnumType20.cpp b/src/ocpp20/types/ConnectorEnumType20.cpp new file mode 100644 index 00000000..e09b87ae --- /dev/null +++ b/src/ocpp20/types/ConnectorEnumType20.cpp @@ -0,0 +1,61 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:ReserveNowRequest + OCPP 2.0.1 FINAL +*/ + +#include "ConnectorEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a ConnectorEnumType enum to string */ +const EnumToStringFromString ConnectorEnumTypeHelper = { + {ConnectorEnumType::cCCS1, "cCCS1"}, + {ConnectorEnumType::cCCS2, "cCCS2"}, + {ConnectorEnumType::cG105, "cG105"}, + {ConnectorEnumType::cTesla, "cTesla"}, + {ConnectorEnumType::cType1, "cType1"}, + {ConnectorEnumType::cType2, "cType2"}, + {ConnectorEnumType::s309_1P_16A, "s309-1P-16A"}, + {ConnectorEnumType::s309_1P_32A, "s309-1P-32A"}, + {ConnectorEnumType::s309_3P_16A, "s309-3P-16A"}, + {ConnectorEnumType::s309_3P_32A, "s309-3P-32A"}, + {ConnectorEnumType::sBS1361, "sBS1361"}, + {ConnectorEnumType::sCEE_7_7, "sCEE-7-7"}, + {ConnectorEnumType::sType2, "sType2"}, + {ConnectorEnumType::sType3, "sType3"}, + {ConnectorEnumType::Other1PhMax16A, "Other1PhMax16A"}, + {ConnectorEnumType::Other1PhOver16A, "Other1PhOver16A"}, + {ConnectorEnumType::Other3Ph, "Other3Ph"}, + {ConnectorEnumType::Pan, "Pan"}, + {ConnectorEnumType::wInductive, "wInductive"}, + {ConnectorEnumType::wResonant, "wResonant"}, + {ConnectorEnumType::Undetermined, "Undetermined"}, + {ConnectorEnumType::Unknown, "Unknown"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/ConnectorEnumType20.h b/src/ocpp20/types/ConnectorEnumType20.h new file mode 100644 index 00000000..5c9dacdf --- /dev/null +++ b/src/ocpp20/types/ConnectorEnumType20.h @@ -0,0 +1,70 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:ReserveNowRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_CONNECTORENUMTYPE_H +#define OPENOCPP_OCPP20_CONNECTORENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief This field specifies the connector type. */ +enum class ConnectorEnumType +{ + cCCS1, + cCCS2, + cG105, + cTesla, + cType1, + cType2, + s309_1P_16A, + s309_1P_32A, + s309_3P_16A, + s309_3P_32A, + sBS1361, + sCEE_7_7, + sType2, + sType3, + Other1PhMax16A, + Other1PhOver16A, + Other3Ph, + Pan, + wInductive, + wResonant, + Undetermined, + Unknown, +}; + +/** @brief Helper to convert a ConnectorEnumType enum to string */ +extern const EnumToStringFromString ConnectorEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_CONNECTORENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/ConnectorStatusEnumType20.cpp b/src/ocpp20/types/ConnectorStatusEnumType20.cpp new file mode 100644 index 00000000..b19e4cfc --- /dev/null +++ b/src/ocpp20/types/ConnectorStatusEnumType20.cpp @@ -0,0 +1,44 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:StatusNotificationRequest + OCPP 2.0.1 FINAL +*/ + +#include "ConnectorStatusEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a ConnectorStatusEnumType enum to string */ +const EnumToStringFromString ConnectorStatusEnumTypeHelper = { + {ConnectorStatusEnumType::Available, "Available"}, + {ConnectorStatusEnumType::Occupied, "Occupied"}, + {ConnectorStatusEnumType::Reserved, "Reserved"}, + {ConnectorStatusEnumType::Unavailable, "Unavailable"}, + {ConnectorStatusEnumType::Faulted, "Faulted"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/ConnectorStatusEnumType20.h b/src/ocpp20/types/ConnectorStatusEnumType20.h new file mode 100644 index 00000000..87a6b744 --- /dev/null +++ b/src/ocpp20/types/ConnectorStatusEnumType20.h @@ -0,0 +1,53 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:StatusNotificationRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_CONNECTORSTATUSENUMTYPE_H +#define OPENOCPP_OCPP20_CONNECTORSTATUSENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief This contains the current status of the Connector. */ +enum class ConnectorStatusEnumType +{ + Available, + Occupied, + Reserved, + Unavailable, + Faulted, +}; + +/** @brief Helper to convert a ConnectorStatusEnumType enum to string */ +extern const EnumToStringFromString ConnectorStatusEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_CONNECTORSTATUSENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/ConsumptionCostType20.cpp b/src/ocpp20/types/ConsumptionCostType20.cpp new file mode 100644 index 00000000..278d6420 --- /dev/null +++ b/src/ocpp20/types/ConsumptionCostType20.cpp @@ -0,0 +1,109 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:RequestStartTransactionRequest + OCPP 2.0.1 FINAL +*/ + +#include "ConsumptionCostType20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Convert a ConsumptionCostType from a JSON representation */ +bool ConsumptionCostTypeConverter::fromJson(const rapidjson::Value& json, + ConsumptionCostType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // startValue + extract(json, "startValue", data.startValue); + + // cost + if (json.HasMember("cost")) + { + const rapidjson::Value& cost_json = json["cost"]; + CostTypeConverter cost_converter; + for (auto it = cost_json.Begin(); ret && (it != cost_json.End()); ++it) + { + CostType& item = data.cost.emplace_back(); + ret = ret && cost_converter.fromJson(*it, item, error_code, error_message); + } + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a ConsumptionCostType to a JSON representation */ +bool ConsumptionCostTypeConverter::toJson(const ConsumptionCostType& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // startValue + fill(json, "startValue", data.startValue); + + // cost + + rapidjson::Value cost_json(rapidjson::kArrayType); + CostTypeConverter cost_converter; + cost_converter.setAllocator(allocator); + for (const CostType& item : data.cost) + { + rapidjson::Document item_doc(rapidjson::kObjectType); + ret = ret && cost_converter.toJson(item, item_doc); + cost_json.PushBack(item_doc.Move(), *allocator); + } + json.AddMember(rapidjson::StringRef("cost"), cost_json.Move(), *allocator); + + return ret; +} + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/ConsumptionCostType20.h b/src/ocpp20/types/ConsumptionCostType20.h new file mode 100644 index 00000000..ee394ddd --- /dev/null +++ b/src/ocpp20/types/ConsumptionCostType20.h @@ -0,0 +1,77 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:RequestStartTransactionRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_CONSUMPTIONCOSTTYPE_H +#define OPENOCPP_OCPP20_CONSUMPTIONCOSTTYPE_H + +#include "CostType20.h" +#include "CustomDataType20.h" + +#include "IMessageConverter.h" +#include "Optional.h" +#include + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Consumption_ Cost +urn:x-oca:ocpp:uid:2:233259 + */ +struct ConsumptionCostType +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief Consumption_ Cost. Start_ Value. Numeric +urn:x-oca:ocpp:uid:1:569246 +The lowest level of consumption that defines the starting point of this consumption block. The block interval extends to the start of the next interval. */ + float startValue; + /** @brief */ + std::vector cost; +}; + +/** @brief Converter class for ConsumptionCostType type */ +class ConsumptionCostTypeConverter : public ocpp::messages::IMessageConverter +{ + public: + /** @brief Clone the converter */ + ocpp::messages::IMessageConverter* clone() const override { return new ConsumptionCostTypeConverter(); } + + /** @brief Convert a ConsumptionCostType from a JSON representation */ + bool fromJson(const rapidjson::Value& json, + ConsumptionCostType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) override; + + /** @brief Convert a ConsumptionCostType to a JSON representation */ + bool toJson(const ConsumptionCostType& data, rapidjson::Document& json) override; +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_CONSUMPTIONCOSTTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/CostKindEnumType20.cpp b/src/ocpp20/types/CostKindEnumType20.cpp new file mode 100644 index 00000000..45660e6b --- /dev/null +++ b/src/ocpp20/types/CostKindEnumType20.cpp @@ -0,0 +1,42 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:RequestStartTransactionRequest + OCPP 2.0.1 FINAL +*/ + +#include "CostKindEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a CostKindEnumType enum to string */ +const EnumToStringFromString CostKindEnumTypeHelper = { + {CostKindEnumType::CarbonDioxideEmission, "CarbonDioxideEmission"}, + {CostKindEnumType::RelativePricePercentage, "RelativePricePercentage"}, + {CostKindEnumType::RenewableGenerationPercentage, "RenewableGenerationPercentage"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/CostKindEnumType20.h b/src/ocpp20/types/CostKindEnumType20.h new file mode 100644 index 00000000..737b9336 --- /dev/null +++ b/src/ocpp20/types/CostKindEnumType20.h @@ -0,0 +1,53 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:RequestStartTransactionRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_COSTKINDENUMTYPE_H +#define OPENOCPP_OCPP20_COSTKINDENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Cost. Cost_ Kind. Cost_ Kind_ Code +urn:x-oca:ocpp:uid:1:569243 +The kind of cost referred to in the message element amount */ +enum class CostKindEnumType +{ + CarbonDioxideEmission, + RelativePricePercentage, + RenewableGenerationPercentage, +}; + +/** @brief Helper to convert a CostKindEnumType enum to string */ +extern const EnumToStringFromString CostKindEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_COSTKINDENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/CostType20.cpp b/src/ocpp20/types/CostType20.cpp new file mode 100644 index 00000000..431596ae --- /dev/null +++ b/src/ocpp20/types/CostType20.cpp @@ -0,0 +1,96 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:RequestStartTransactionRequest + OCPP 2.0.1 FINAL +*/ + +#include "CostType20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Convert a CostType from a JSON representation */ +bool CostTypeConverter::fromJson(const rapidjson::Value& json, + CostType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // costKind + data.costKind = CostKindEnumTypeHelper.fromString(json["costKind"].GetString()); + + // amount + extract(json, "amount", data.amount); + + // amountMultiplier + extract(json, "amountMultiplier", data.amountMultiplier); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a CostType to a JSON representation */ +bool CostTypeConverter::toJson(const CostType& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // costKind + fill(json, "costKind", CostKindEnumTypeHelper.toString(data.costKind)); + + // amount + fill(json, "amount", data.amount); + + // amountMultiplier + fill(json, "amountMultiplier", data.amountMultiplier); + + return ret; +} + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/CostType20.h b/src/ocpp20/types/CostType20.h new file mode 100644 index 00000000..3b9eddc6 --- /dev/null +++ b/src/ocpp20/types/CostType20.h @@ -0,0 +1,80 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:RequestStartTransactionRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_COSTTYPE_H +#define OPENOCPP_OCPP20_COSTTYPE_H + +#include "CostKindEnumType20.h" +#include "CustomDataType20.h" + +#include "IMessageConverter.h" +#include "Optional.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Cost +urn:x-oca:ocpp:uid:2:233258 + */ +struct CostType +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + CostKindEnumType costKind; + /** @brief Cost. Amount. Amount +urn:x-oca:ocpp:uid:1:569244 +The estimated or actual cost per kWh */ + int amount; + /** @brief Cost. Amount_ Multiplier. Integer +urn:x-oca:ocpp:uid:1:569245 +Values: -3..3, The amountMultiplier defines the exponent to base 10 (dec). The final value is determined by: amount * 10 ^ amountMultiplier */ + ocpp::types::Optional amountMultiplier; +}; + +/** @brief Converter class for CostType type */ +class CostTypeConverter : public ocpp::messages::IMessageConverter +{ + public: + /** @brief Clone the converter */ + ocpp::messages::IMessageConverter* clone() const override { return new CostTypeConverter(); } + + /** @brief Convert a CostType from a JSON representation */ + bool fromJson(const rapidjson::Value& json, + CostType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) override; + + /** @brief Convert a CostType to a JSON representation */ + bool toJson(const CostType& data, rapidjson::Document& json) override; +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_COSTTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/CustomDataType20.cpp b/src/ocpp20/types/CustomDataType20.cpp new file mode 100644 index 00000000..c3395baf --- /dev/null +++ b/src/ocpp20/types/CustomDataType20.cpp @@ -0,0 +1,67 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:RequestStartTransactionRequest + OCPP 2.0.1 FINAL +*/ + +#include "CustomDataType20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Convert a CustomDataType from a JSON representation */ +bool CustomDataTypeConverter::fromJson(const rapidjson::Value& json, + CustomDataType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) +{ + bool ret = true; + + // vendorId + extract(json, "vendorId", data.vendorId); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a CustomDataType to a JSON representation */ +bool CustomDataTypeConverter::toJson(const CustomDataType& data, rapidjson::Document& json) +{ + bool ret = true; + + // vendorId + fill(json, "vendorId", data.vendorId); + + return ret; +} + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/CustomDataType20.h b/src/ocpp20/types/CustomDataType20.h new file mode 100644 index 00000000..dd7ac0b1 --- /dev/null +++ b/src/ocpp20/types/CustomDataType20.h @@ -0,0 +1,65 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:RequestStartTransactionRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_CUSTOMDATATYPE_H +#define OPENOCPP_OCPP20_CUSTOMDATATYPE_H + +#include "CiStringType.h" +#include "IMessageConverter.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data. */ +struct CustomDataType +{ + /** @brief */ + ocpp::types::CiStringType<255u> vendorId; +}; + +/** @brief Converter class for CustomDataType type */ +class CustomDataTypeConverter : public ocpp::messages::IMessageConverter +{ + public: + /** @brief Clone the converter */ + ocpp::messages::IMessageConverter* clone() const override { return new CustomDataTypeConverter(); } + + /** @brief Convert a CustomDataType from a JSON representation */ + bool fromJson(const rapidjson::Value& json, + CustomDataType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) override; + + /** @brief Convert a CustomDataType to a JSON representation */ + bool toJson(const CustomDataType& data, rapidjson::Document& json) override; +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_CUSTOMDATATYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/CustomerInformationStatusEnumType20.cpp b/src/ocpp20/types/CustomerInformationStatusEnumType20.cpp new file mode 100644 index 00000000..361f622a --- /dev/null +++ b/src/ocpp20/types/CustomerInformationStatusEnumType20.cpp @@ -0,0 +1,42 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:CustomerInformationRequest + OCPP 2.0.1 FINAL +*/ + +#include "CustomerInformationStatusEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a CustomerInformationStatusEnumType enum to string */ +const EnumToStringFromString CustomerInformationStatusEnumTypeHelper = { + {CustomerInformationStatusEnumType::Accepted, "Accepted"}, + {CustomerInformationStatusEnumType::Rejected, "Rejected"}, + {CustomerInformationStatusEnumType::Invalid, "Invalid"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/CustomerInformationStatusEnumType20.h b/src/ocpp20/types/CustomerInformationStatusEnumType20.h new file mode 100644 index 00000000..8bf28432 --- /dev/null +++ b/src/ocpp20/types/CustomerInformationStatusEnumType20.h @@ -0,0 +1,51 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:CustomerInformationRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_CUSTOMERINFORMATIONSTATUSENUMTYPE_H +#define OPENOCPP_OCPP20_CUSTOMERINFORMATIONSTATUSENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Indicates whether the request was accepted. */ +enum class CustomerInformationStatusEnumType +{ + Accepted, + Rejected, + Invalid, +}; + +/** @brief Helper to convert a CustomerInformationStatusEnumType enum to string */ +extern const EnumToStringFromString CustomerInformationStatusEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_CUSTOMERINFORMATIONSTATUSENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/DCChargingParametersType20.cpp b/src/ocpp20/types/DCChargingParametersType20.cpp new file mode 100644 index 00000000..0fce553b --- /dev/null +++ b/src/ocpp20/types/DCChargingParametersType20.cpp @@ -0,0 +1,126 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:NotifyEVChargingNeedsRequest + OCPP 2.0.1 FINAL +*/ + +#include "DCChargingParametersType20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Convert a DCChargingParametersType from a JSON representation */ +bool DCChargingParametersTypeConverter::fromJson(const rapidjson::Value& json, + DCChargingParametersType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // evMaxCurrent + extract(json, "evMaxCurrent", data.evMaxCurrent); + + // evMaxVoltage + extract(json, "evMaxVoltage", data.evMaxVoltage); + + // energyAmount + extract(json, "energyAmount", data.energyAmount); + + // evMaxPower + extract(json, "evMaxPower", data.evMaxPower); + + // stateOfCharge + extract(json, "stateOfCharge", data.stateOfCharge); + + // evEnergyCapacity + extract(json, "evEnergyCapacity", data.evEnergyCapacity); + + // fullSoC + extract(json, "fullSoC", data.fullSoC); + + // bulkSoC + extract(json, "bulkSoC", data.bulkSoC); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a DCChargingParametersType to a JSON representation */ +bool DCChargingParametersTypeConverter::toJson(const DCChargingParametersType& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // evMaxCurrent + fill(json, "evMaxCurrent", data.evMaxCurrent); + + // evMaxVoltage + fill(json, "evMaxVoltage", data.evMaxVoltage); + + // energyAmount + fill(json, "energyAmount", data.energyAmount); + + // evMaxPower + fill(json, "evMaxPower", data.evMaxPower); + + // stateOfCharge + fill(json, "stateOfCharge", data.stateOfCharge); + + // evEnergyCapacity + fill(json, "evEnergyCapacity", data.evEnergyCapacity); + + // fullSoC + fill(json, "fullSoC", data.fullSoC); + + // bulkSoC + fill(json, "bulkSoC", data.bulkSoC); + + return ret; +} + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/DCChargingParametersType20.h b/src/ocpp20/types/DCChargingParametersType20.h new file mode 100644 index 00000000..5edbc74a --- /dev/null +++ b/src/ocpp20/types/DCChargingParametersType20.h @@ -0,0 +1,104 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:NotifyEVChargingNeedsRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_DCCHARGINGPARAMETERSTYPE_H +#define OPENOCPP_OCPP20_DCCHARGINGPARAMETERSTYPE_H + +#include "CustomDataType20.h" + +#include "IMessageConverter.h" +#include "Optional.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief DC_ Charging_ Parameters +urn:x-oca:ocpp:uid:2:233251 +EV DC charging parameters + + + */ +struct DCChargingParametersType +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief DC_ Charging_ Parameters. EV_ Max. Current +urn:x-oca:ocpp:uid:1:569215 +Maximum current (amps) supported by the electric vehicle. Includes cable capacity. */ + int evMaxCurrent; + /** @brief DC_ Charging_ Parameters. EV_ Max. Voltage +urn:x-oca:ocpp:uid:1:569216 +Maximum voltage supported by the electric vehicle */ + int evMaxVoltage; + /** @brief DC_ Charging_ Parameters. Energy_ Amount. Energy_ Amount +urn:x-oca:ocpp:uid:1:569217 +Amount of energy requested (in Wh). This inludes energy required for preconditioning. */ + ocpp::types::Optional energyAmount; + /** @brief DC_ Charging_ Parameters. EV_ Max. Power +urn:x-oca:ocpp:uid:1:569218 +Maximum power (in W) supported by the electric vehicle. Required for DC charging. */ + ocpp::types::Optional evMaxPower; + /** @brief DC_ Charging_ Parameters. State_ Of_ Charge. Numeric +urn:x-oca:ocpp:uid:1:569219 +Energy available in the battery (in percent of the battery capacity) */ + ocpp::types::Optional stateOfCharge; + /** @brief DC_ Charging_ Parameters. EV_ Energy_ Capacity. Numeric +urn:x-oca:ocpp:uid:1:569220 +Capacity of the electric vehicle battery (in Wh) */ + ocpp::types::Optional evEnergyCapacity; + /** @brief DC_ Charging_ Parameters. Full_ SOC. Percentage +urn:x-oca:ocpp:uid:1:569221 +Percentage of SoC at which the EV considers the battery fully charged. (possible values: 0 - 100) */ + ocpp::types::Optional fullSoC; + /** @brief DC_ Charging_ Parameters. Bulk_ SOC. Percentage +urn:x-oca:ocpp:uid:1:569222 +Percentage of SoC at which the EV considers a fast charging process to end. (possible values: 0 - 100) */ + ocpp::types::Optional bulkSoC; +}; + +/** @brief Converter class for DCChargingParametersType type */ +class DCChargingParametersTypeConverter : public ocpp::messages::IMessageConverter +{ + public: + /** @brief Clone the converter */ + ocpp::messages::IMessageConverter* clone() const override { return new DCChargingParametersTypeConverter(); } + + /** @brief Convert a DCChargingParametersType from a JSON representation */ + bool fromJson(const rapidjson::Value& json, + DCChargingParametersType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) override; + + /** @brief Convert a DCChargingParametersType to a JSON representation */ + bool toJson(const DCChargingParametersType& data, rapidjson::Document& json) override; +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_DCCHARGINGPARAMETERSTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/DataEnumType20.cpp b/src/ocpp20/types/DataEnumType20.cpp new file mode 100644 index 00000000..c83a92a1 --- /dev/null +++ b/src/ocpp20/types/DataEnumType20.cpp @@ -0,0 +1,47 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:NotifyReportRequest + OCPP 2.0.1 FINAL +*/ + +#include "DataEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a DataEnumType enum to string */ +const EnumToStringFromString DataEnumTypeHelper = { + {DataEnumType::string, "string"}, + {DataEnumType::decimal, "decimal"}, + {DataEnumType::integer, "integer"}, + {DataEnumType::dateTime, "dateTime"}, + {DataEnumType::boolean, "boolean"}, + {DataEnumType::OptionList, "OptionList"}, + {DataEnumType::SequenceList, "SequenceList"}, + {DataEnumType::MemberList, "MemberList"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/DataEnumType20.h b/src/ocpp20/types/DataEnumType20.h new file mode 100644 index 00000000..2fb3772c --- /dev/null +++ b/src/ocpp20/types/DataEnumType20.h @@ -0,0 +1,56 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:NotifyReportRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_DATAENUMTYPE_H +#define OPENOCPP_OCPP20_DATAENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Data type of this variable. */ +enum class DataEnumType +{ + string, + decimal, + integer, + dateTime, + boolean, + OptionList, + SequenceList, + MemberList, +}; + +/** @brief Helper to convert a DataEnumType enum to string */ +extern const EnumToStringFromString DataEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_DATAENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/DataTransferStatusEnumType20.cpp b/src/ocpp20/types/DataTransferStatusEnumType20.cpp new file mode 100644 index 00000000..fc0836b9 --- /dev/null +++ b/src/ocpp20/types/DataTransferStatusEnumType20.cpp @@ -0,0 +1,43 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:DataTransferRequest + OCPP 2.0.1 FINAL +*/ + +#include "DataTransferStatusEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a DataTransferStatusEnumType enum to string */ +const EnumToStringFromString DataTransferStatusEnumTypeHelper = { + {DataTransferStatusEnumType::Accepted, "Accepted"}, + {DataTransferStatusEnumType::Rejected, "Rejected"}, + {DataTransferStatusEnumType::UnknownMessageId, "UnknownMessageId"}, + {DataTransferStatusEnumType::UnknownVendorId, "UnknownVendorId"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/DataTransferStatusEnumType20.h b/src/ocpp20/types/DataTransferStatusEnumType20.h new file mode 100644 index 00000000..221fb8db --- /dev/null +++ b/src/ocpp20/types/DataTransferStatusEnumType20.h @@ -0,0 +1,52 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:DataTransferRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_DATATRANSFERSTATUSENUMTYPE_H +#define OPENOCPP_OCPP20_DATATRANSFERSTATUSENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief This indicates the success or failure of the data transfer. */ +enum class DataTransferStatusEnumType +{ + Accepted, + Rejected, + UnknownMessageId, + UnknownVendorId, +}; + +/** @brief Helper to convert a DataTransferStatusEnumType enum to string */ +extern const EnumToStringFromString DataTransferStatusEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_DATATRANSFERSTATUSENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/DeleteCertificateStatusEnumType20.cpp b/src/ocpp20/types/DeleteCertificateStatusEnumType20.cpp new file mode 100644 index 00000000..42e7de3d --- /dev/null +++ b/src/ocpp20/types/DeleteCertificateStatusEnumType20.cpp @@ -0,0 +1,42 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:DeleteCertificateRequest + OCPP 2.0.1 FINAL +*/ + +#include "DeleteCertificateStatusEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a DeleteCertificateStatusEnumType enum to string */ +const EnumToStringFromString DeleteCertificateStatusEnumTypeHelper = { + {DeleteCertificateStatusEnumType::Accepted, "Accepted"}, + {DeleteCertificateStatusEnumType::Failed, "Failed"}, + {DeleteCertificateStatusEnumType::NotFound, "NotFound"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/DeleteCertificateStatusEnumType20.h b/src/ocpp20/types/DeleteCertificateStatusEnumType20.h new file mode 100644 index 00000000..540521e7 --- /dev/null +++ b/src/ocpp20/types/DeleteCertificateStatusEnumType20.h @@ -0,0 +1,51 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:DeleteCertificateRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_DELETECERTIFICATESTATUSENUMTYPE_H +#define OPENOCPP_OCPP20_DELETECERTIFICATESTATUSENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Charging Station indicates if it can process the request. */ +enum class DeleteCertificateStatusEnumType +{ + Accepted, + Failed, + NotFound, +}; + +/** @brief Helper to convert a DeleteCertificateStatusEnumType enum to string */ +extern const EnumToStringFromString DeleteCertificateStatusEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_DELETECERTIFICATESTATUSENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/DisplayMessageStatusEnumType20.cpp b/src/ocpp20/types/DisplayMessageStatusEnumType20.cpp new file mode 100644 index 00000000..67e2eb49 --- /dev/null +++ b/src/ocpp20/types/DisplayMessageStatusEnumType20.cpp @@ -0,0 +1,45 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SetDisplayMessageRequest + OCPP 2.0.1 FINAL +*/ + +#include "DisplayMessageStatusEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a DisplayMessageStatusEnumType enum to string */ +const EnumToStringFromString DisplayMessageStatusEnumTypeHelper = { + {DisplayMessageStatusEnumType::Accepted, "Accepted"}, + {DisplayMessageStatusEnumType::NotSupportedMessageFormat, "NotSupportedMessageFormat"}, + {DisplayMessageStatusEnumType::Rejected, "Rejected"}, + {DisplayMessageStatusEnumType::NotSupportedPriority, "NotSupportedPriority"}, + {DisplayMessageStatusEnumType::NotSupportedState, "NotSupportedState"}, + {DisplayMessageStatusEnumType::UnknownTransaction, "UnknownTransaction"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/DisplayMessageStatusEnumType20.h b/src/ocpp20/types/DisplayMessageStatusEnumType20.h new file mode 100644 index 00000000..7837cb08 --- /dev/null +++ b/src/ocpp20/types/DisplayMessageStatusEnumType20.h @@ -0,0 +1,54 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SetDisplayMessageRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_DISPLAYMESSAGESTATUSENUMTYPE_H +#define OPENOCPP_OCPP20_DISPLAYMESSAGESTATUSENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief This indicates whether the Charging Station is able to display the message. */ +enum class DisplayMessageStatusEnumType +{ + Accepted, + NotSupportedMessageFormat, + Rejected, + NotSupportedPriority, + NotSupportedState, + UnknownTransaction, +}; + +/** @brief Helper to convert a DisplayMessageStatusEnumType enum to string */ +extern const EnumToStringFromString DisplayMessageStatusEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_DISPLAYMESSAGESTATUSENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/EVSEType20.cpp b/src/ocpp20/types/EVSEType20.cpp new file mode 100644 index 00000000..283c2930 --- /dev/null +++ b/src/ocpp20/types/EVSEType20.cpp @@ -0,0 +1,90 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:TriggerMessageRequest + OCPP 2.0.1 FINAL +*/ + +#include "EVSEType20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Convert a EVSEType from a JSON representation */ +bool EVSETypeConverter::fromJson(const rapidjson::Value& json, + EVSEType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // id + extract(json, "id", data.id); + + // connectorId + extract(json, "connectorId", data.connectorId); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a EVSEType to a JSON representation */ +bool EVSETypeConverter::toJson(const EVSEType& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // id + fill(json, "id", data.id); + + // connectorId + fill(json, "connectorId", data.connectorId); + + return ret; +} + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/EVSEType20.h b/src/ocpp20/types/EVSEType20.h new file mode 100644 index 00000000..4c7f428e --- /dev/null +++ b/src/ocpp20/types/EVSEType20.h @@ -0,0 +1,76 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:TriggerMessageRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_EVSETYPE_H +#define OPENOCPP_OCPP20_EVSETYPE_H + +#include "CustomDataType20.h" + +#include "IMessageConverter.h" +#include "Optional.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief EVSE +urn:x-oca:ocpp:uid:2:233123 +Electric Vehicle Supply Equipment + */ +struct EVSEType +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief Identified_ Object. MRID. Numeric_ Identifier +urn:x-enexis:ecdm:uid:1:569198 +EVSE Identifier. This contains a number (> 0) designating an EVSE of the Charging Station. */ + int id; + /** @brief An id to designate a specific connector (on an EVSE) by connector index number. */ + ocpp::types::Optional connectorId; +}; + +/** @brief Converter class for EVSEType type */ +class EVSETypeConverter : public ocpp::messages::IMessageConverter +{ + public: + /** @brief Clone the converter */ + ocpp::messages::IMessageConverter* clone() const override { return new EVSETypeConverter(); } + + /** @brief Convert a EVSEType from a JSON representation */ + bool fromJson(const rapidjson::Value& json, + EVSEType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) override; + + /** @brief Convert a EVSEType to a JSON representation */ + bool toJson(const EVSEType& data, rapidjson::Document& json) override; +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_EVSETYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/EnergyTransferModeEnumType20.cpp b/src/ocpp20/types/EnergyTransferModeEnumType20.cpp new file mode 100644 index 00000000..80c9cf2d --- /dev/null +++ b/src/ocpp20/types/EnergyTransferModeEnumType20.cpp @@ -0,0 +1,43 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:NotifyEVChargingNeedsRequest + OCPP 2.0.1 FINAL +*/ + +#include "EnergyTransferModeEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a EnergyTransferModeEnumType enum to string */ +const EnumToStringFromString EnergyTransferModeEnumTypeHelper = { + {EnergyTransferModeEnumType::DC, "DC"}, + {EnergyTransferModeEnumType::AC_single_phase, "AC_single_phase"}, + {EnergyTransferModeEnumType::AC_two_phase, "AC_two_phase"}, + {EnergyTransferModeEnumType::AC_three_phase, "AC_three_phase"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/EnergyTransferModeEnumType20.h b/src/ocpp20/types/EnergyTransferModeEnumType20.h new file mode 100644 index 00000000..7947ab7d --- /dev/null +++ b/src/ocpp20/types/EnergyTransferModeEnumType20.h @@ -0,0 +1,54 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:NotifyEVChargingNeedsRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_ENERGYTRANSFERMODEENUMTYPE_H +#define OPENOCPP_OCPP20_ENERGYTRANSFERMODEENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Charging_ Needs. Requested. Energy_ Transfer_ Mode_ Code +urn:x-oca:ocpp:uid:1:569209 +Mode of energy transfer requested by the EV. */ +enum class EnergyTransferModeEnumType +{ + DC, + AC_single_phase, + AC_two_phase, + AC_three_phase, +}; + +/** @brief Helper to convert a EnergyTransferModeEnumType enum to string */ +extern const EnumToStringFromString EnergyTransferModeEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_ENERGYTRANSFERMODEENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/EventDataType20.cpp b/src/ocpp20/types/EventDataType20.cpp new file mode 100644 index 00000000..943d1219 --- /dev/null +++ b/src/ocpp20/types/EventDataType20.cpp @@ -0,0 +1,166 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:NotifyEventRequest + OCPP 2.0.1 FINAL +*/ + +#include "EventDataType20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Convert a EventDataType from a JSON representation */ +bool EventDataTypeConverter::fromJson(const rapidjson::Value& json, + EventDataType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // eventId + extract(json, "eventId", data.eventId); + + // timestamp + ret = ret && extract(json, "timestamp", data.timestamp, error_message); + + // trigger + data.trigger = EventTriggerEnumTypeHelper.fromString(json["trigger"].GetString()); + + // cause + extract(json, "cause", data.cause); + + // actualValue + extract(json, "actualValue", data.actualValue); + + // techCode + extract(json, "techCode", data.techCode); + + // techInfo + extract(json, "techInfo", data.techInfo); + + // cleared + extract(json, "cleared", data.cleared); + + // transactionId + extract(json, "transactionId", data.transactionId); + + // component + ComponentTypeConverter component_converter; + ret = ret && component_converter.fromJson(json["component"], data.component, error_code, error_message); + + // variableMonitoringId + extract(json, "variableMonitoringId", data.variableMonitoringId); + + // eventNotificationType + data.eventNotificationType = EventNotificationEnumTypeHelper.fromString(json["eventNotificationType"].GetString()); + + // variable + VariableTypeConverter variable_converter; + ret = ret && variable_converter.fromJson(json["variable"], data.variable, error_code, error_message); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a EventDataType to a JSON representation */ +bool EventDataTypeConverter::toJson(const EventDataType& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // eventId + fill(json, "eventId", data.eventId); + + // timestamp + fill(json, "timestamp", data.timestamp); + + // trigger + fill(json, "trigger", EventTriggerEnumTypeHelper.toString(data.trigger)); + + // cause + fill(json, "cause", data.cause); + + // actualValue + fill(json, "actualValue", data.actualValue); + + // techCode + fill(json, "techCode", data.techCode); + + // techInfo + fill(json, "techInfo", data.techInfo); + + // cleared + fill(json, "cleared", data.cleared); + + // transactionId + fill(json, "transactionId", data.transactionId); + + // component + ComponentTypeConverter component_converter; + component_converter.setAllocator(allocator); + rapidjson::Document component_doc(rapidjson::kObjectType); + ret = ret && component_converter.toJson(data.component, component_doc); + json.AddMember(rapidjson::StringRef("component"), component_doc.Move(), *allocator); + + // variableMonitoringId + fill(json, "variableMonitoringId", data.variableMonitoringId); + + // eventNotificationType + fill(json, "eventNotificationType", EventNotificationEnumTypeHelper.toString(data.eventNotificationType)); + + // variable + VariableTypeConverter variable_converter; + variable_converter.setAllocator(allocator); + rapidjson::Document variable_doc(rapidjson::kObjectType); + ret = ret && variable_converter.toJson(data.variable, variable_doc); + json.AddMember(rapidjson::StringRef("variable"), variable_doc.Move(), *allocator); + + return ret; +} + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/EventDataType20.h b/src/ocpp20/types/EventDataType20.h new file mode 100644 index 00000000..8d11b574 --- /dev/null +++ b/src/ocpp20/types/EventDataType20.h @@ -0,0 +1,102 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:NotifyEventRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_EVENTDATATYPE_H +#define OPENOCPP_OCPP20_EVENTDATATYPE_H + +#include "ComponentType20.h" +#include "CustomDataType20.h" +#include "EventNotificationEnumType20.h" +#include "EventTriggerEnumType20.h" +#include "VariableType20.h" + +#include "CiStringType.h" +#include "DateTime.h" +#include "IMessageConverter.h" +#include "Optional.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Class to report an event notification for a component-variable. + */ +struct EventDataType +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief Identifies the event. This field can be referred to as a cause by other events. */ + int eventId; + /** @brief Timestamp of the moment the report was generated. */ + ocpp::types::DateTime timestamp; + /** @brief */ + EventTriggerEnumType trigger; + /** @brief Refers to the Id of an event that is considered to be the cause for this event. */ + ocpp::types::Optional cause; + /** @brief Actual value (_attributeType_ Actual) of the variable. + +The Configuration Variable <<configkey-reporting-value-size,ReportingValueSize>> can be used to limit GetVariableResult.attributeValue, VariableAttribute.value and EventData.actualValue. The max size of these values will always remain equal. */ + ocpp::types::CiStringType<2500u> actualValue; + /** @brief Technical (error) code as reported by component. */ + ocpp::types::Optional> techCode; + /** @brief Technical detail information as reported by component. */ + ocpp::types::Optional> techInfo; + /** @brief _Cleared_ is set to true to report the clearing of a monitored situation, i.e. a 'return to normal'. */ + ocpp::types::Optional cleared; + /** @brief If an event notification is linked to a specific transaction, this field can be used to specify its transactionId. */ + ocpp::types::Optional> transactionId; + /** @brief */ + ComponentType component; + /** @brief Identifies the VariableMonitoring which triggered the event. */ + ocpp::types::Optional variableMonitoringId; + /** @brief */ + EventNotificationEnumType eventNotificationType; + /** @brief */ + VariableType variable; +}; + +/** @brief Converter class for EventDataType type */ +class EventDataTypeConverter : public ocpp::messages::IMessageConverter +{ + public: + /** @brief Clone the converter */ + ocpp::messages::IMessageConverter* clone() const override { return new EventDataTypeConverter(); } + + /** @brief Convert a EventDataType from a JSON representation */ + bool fromJson(const rapidjson::Value& json, + EventDataType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) override; + + /** @brief Convert a EventDataType to a JSON representation */ + bool toJson(const EventDataType& data, rapidjson::Document& json) override; +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_EVENTDATATYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/EventNotificationEnumType20.cpp b/src/ocpp20/types/EventNotificationEnumType20.cpp new file mode 100644 index 00000000..c83f594e --- /dev/null +++ b/src/ocpp20/types/EventNotificationEnumType20.cpp @@ -0,0 +1,43 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:NotifyEventRequest + OCPP 2.0.1 FINAL +*/ + +#include "EventNotificationEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a EventNotificationEnumType enum to string */ +const EnumToStringFromString EventNotificationEnumTypeHelper = { + {EventNotificationEnumType::HardWiredNotification, "HardWiredNotification"}, + {EventNotificationEnumType::HardWiredMonitor, "HardWiredMonitor"}, + {EventNotificationEnumType::PreconfiguredMonitor, "PreconfiguredMonitor"}, + {EventNotificationEnumType::CustomMonitor, "CustomMonitor"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/EventNotificationEnumType20.h b/src/ocpp20/types/EventNotificationEnumType20.h new file mode 100644 index 00000000..d5f16df1 --- /dev/null +++ b/src/ocpp20/types/EventNotificationEnumType20.h @@ -0,0 +1,52 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:NotifyEventRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_EVENTNOTIFICATIONENUMTYPE_H +#define OPENOCPP_OCPP20_EVENTNOTIFICATIONENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Specifies the event notification type of the message. */ +enum class EventNotificationEnumType +{ + HardWiredNotification, + HardWiredMonitor, + PreconfiguredMonitor, + CustomMonitor, +}; + +/** @brief Helper to convert a EventNotificationEnumType enum to string */ +extern const EnumToStringFromString EventNotificationEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_EVENTNOTIFICATIONENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/EventTriggerEnumType20.cpp b/src/ocpp20/types/EventTriggerEnumType20.cpp new file mode 100644 index 00000000..2630e1de --- /dev/null +++ b/src/ocpp20/types/EventTriggerEnumType20.cpp @@ -0,0 +1,42 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:NotifyEventRequest + OCPP 2.0.1 FINAL +*/ + +#include "EventTriggerEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a EventTriggerEnumType enum to string */ +const EnumToStringFromString EventTriggerEnumTypeHelper = { + {EventTriggerEnumType::Alerting, "Alerting"}, + {EventTriggerEnumType::Delta, "Delta"}, + {EventTriggerEnumType::Periodic, "Periodic"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/EventTriggerEnumType20.h b/src/ocpp20/types/EventTriggerEnumType20.h new file mode 100644 index 00000000..1e5d2819 --- /dev/null +++ b/src/ocpp20/types/EventTriggerEnumType20.h @@ -0,0 +1,51 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:NotifyEventRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_EVENTTRIGGERENUMTYPE_H +#define OPENOCPP_OCPP20_EVENTTRIGGERENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Type of monitor that triggered this event, e.g. exceeding a threshold value. */ +enum class EventTriggerEnumType +{ + Alerting, + Delta, + Periodic, +}; + +/** @brief Helper to convert a EventTriggerEnumType enum to string */ +extern const EnumToStringFromString EventTriggerEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_EVENTTRIGGERENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/FirmwareStatusEnumType20.cpp b/src/ocpp20/types/FirmwareStatusEnumType20.cpp new file mode 100644 index 00000000..abbff333 --- /dev/null +++ b/src/ocpp20/types/FirmwareStatusEnumType20.cpp @@ -0,0 +1,53 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:FirmwareStatusNotificationRequest + OCPP 2.0.1 FINAL +*/ + +#include "FirmwareStatusEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a FirmwareStatusEnumType enum to string */ +const EnumToStringFromString FirmwareStatusEnumTypeHelper = { + {FirmwareStatusEnumType::Downloaded, "Downloaded"}, + {FirmwareStatusEnumType::DownloadFailed, "DownloadFailed"}, + {FirmwareStatusEnumType::Downloading, "Downloading"}, + {FirmwareStatusEnumType::DownloadScheduled, "DownloadScheduled"}, + {FirmwareStatusEnumType::DownloadPaused, "DownloadPaused"}, + {FirmwareStatusEnumType::Idle, "Idle"}, + {FirmwareStatusEnumType::InstallationFailed, "InstallationFailed"}, + {FirmwareStatusEnumType::Installing, "Installing"}, + {FirmwareStatusEnumType::Installed, "Installed"}, + {FirmwareStatusEnumType::InstallRebooting, "InstallRebooting"}, + {FirmwareStatusEnumType::InstallScheduled, "InstallScheduled"}, + {FirmwareStatusEnumType::InstallVerificationFailed, "InstallVerificationFailed"}, + {FirmwareStatusEnumType::InvalidSignature, "InvalidSignature"}, + {FirmwareStatusEnumType::SignatureVerified, "SignatureVerified"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/FirmwareStatusEnumType20.h b/src/ocpp20/types/FirmwareStatusEnumType20.h new file mode 100644 index 00000000..558ed57f --- /dev/null +++ b/src/ocpp20/types/FirmwareStatusEnumType20.h @@ -0,0 +1,62 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:FirmwareStatusNotificationRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_FIRMWARESTATUSENUMTYPE_H +#define OPENOCPP_OCPP20_FIRMWARESTATUSENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief This contains the progress status of the firmware installation. */ +enum class FirmwareStatusEnumType +{ + Downloaded, + DownloadFailed, + Downloading, + DownloadScheduled, + DownloadPaused, + Idle, + InstallationFailed, + Installing, + Installed, + InstallRebooting, + InstallScheduled, + InstallVerificationFailed, + InvalidSignature, + SignatureVerified, +}; + +/** @brief Helper to convert a FirmwareStatusEnumType enum to string */ +extern const EnumToStringFromString FirmwareStatusEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_FIRMWARESTATUSENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/FirmwareType20.cpp b/src/ocpp20/types/FirmwareType20.cpp new file mode 100644 index 00000000..33d9c3e6 --- /dev/null +++ b/src/ocpp20/types/FirmwareType20.cpp @@ -0,0 +1,108 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:UpdateFirmwareRequest + OCPP 2.0.1 FINAL +*/ + +#include "FirmwareType20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Convert a FirmwareType from a JSON representation */ +bool FirmwareTypeConverter::fromJson(const rapidjson::Value& json, + FirmwareType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // location + extract(json, "location", data.location); + + // retrieveDateTime + ret = ret && extract(json, "retrieveDateTime", data.retrieveDateTime, error_message); + + // installDateTime + ret = ret && extract(json, "installDateTime", data.installDateTime, error_message); + + // signingCertificate + extract(json, "signingCertificate", data.signingCertificate); + + // signature + extract(json, "signature", data.signature); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a FirmwareType to a JSON representation */ +bool FirmwareTypeConverter::toJson(const FirmwareType& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // location + fill(json, "location", data.location); + + // retrieveDateTime + fill(json, "retrieveDateTime", data.retrieveDateTime); + + // installDateTime + fill(json, "installDateTime", data.installDateTime); + + // signingCertificate + fill(json, "signingCertificate", data.signingCertificate); + + // signature + fill(json, "signature", data.signature); + + return ret; +} + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/FirmwareType20.h b/src/ocpp20/types/FirmwareType20.h new file mode 100644 index 00000000..99252cff --- /dev/null +++ b/src/ocpp20/types/FirmwareType20.h @@ -0,0 +1,91 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:UpdateFirmwareRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_FIRMWARETYPE_H +#define OPENOCPP_OCPP20_FIRMWARETYPE_H + +#include "CustomDataType20.h" + +#include "CiStringType.h" +#include "DateTime.h" +#include "IMessageConverter.h" +#include "Optional.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Firmware +urn:x-enexis:ecdm:uid:2:233291 +Represents a copy of the firmware that can be loaded/updated on the Charging Station. + */ +struct FirmwareType +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief Firmware. Location. URI +urn:x-enexis:ecdm:uid:1:569460 +URI defining the origin of the firmware. */ + ocpp::types::CiStringType<512u> location; + /** @brief Firmware. Retrieve. Date_ Time +urn:x-enexis:ecdm:uid:1:569461 +Date and time at which the firmware shall be retrieved. */ + ocpp::types::DateTime retrieveDateTime; + /** @brief Firmware. Install. Date_ Time +urn:x-enexis:ecdm:uid:1:569462 +Date and time at which the firmware shall be installed. */ + ocpp::types::Optional installDateTime; + /** @brief Certificate with which the firmware was signed. +PEM encoded X.509 certificate. */ + ocpp::types::Optional> signingCertificate; + /** @brief Firmware. Signature. Signature +urn:x-enexis:ecdm:uid:1:569464 +Base64 encoded firmware signature. */ + ocpp::types::Optional> signature; +}; + +/** @brief Converter class for FirmwareType type */ +class FirmwareTypeConverter : public ocpp::messages::IMessageConverter +{ + public: + /** @brief Clone the converter */ + ocpp::messages::IMessageConverter* clone() const override { return new FirmwareTypeConverter(); } + + /** @brief Convert a FirmwareType from a JSON representation */ + bool fromJson(const rapidjson::Value& json, + FirmwareType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) override; + + /** @brief Convert a FirmwareType to a JSON representation */ + bool toJson(const FirmwareType& data, rapidjson::Document& json) override; +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_FIRMWARETYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/GenericDeviceModelStatusEnumType20.cpp b/src/ocpp20/types/GenericDeviceModelStatusEnumType20.cpp new file mode 100644 index 00000000..4ab8f7a1 --- /dev/null +++ b/src/ocpp20/types/GenericDeviceModelStatusEnumType20.cpp @@ -0,0 +1,43 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetReportRequest + OCPP 2.0.1 FINAL +*/ + +#include "GenericDeviceModelStatusEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a GenericDeviceModelStatusEnumType enum to string */ +const EnumToStringFromString GenericDeviceModelStatusEnumTypeHelper = { + {GenericDeviceModelStatusEnumType::Accepted, "Accepted"}, + {GenericDeviceModelStatusEnumType::Rejected, "Rejected"}, + {GenericDeviceModelStatusEnumType::NotSupported, "NotSupported"}, + {GenericDeviceModelStatusEnumType::EmptyResultSet, "EmptyResultSet"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/GenericDeviceModelStatusEnumType20.h b/src/ocpp20/types/GenericDeviceModelStatusEnumType20.h new file mode 100644 index 00000000..92b6819d --- /dev/null +++ b/src/ocpp20/types/GenericDeviceModelStatusEnumType20.h @@ -0,0 +1,52 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetReportRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_GENERICDEVICEMODELSTATUSENUMTYPE_H +#define OPENOCPP_OCPP20_GENERICDEVICEMODELSTATUSENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief This field indicates whether the Charging Station was able to accept the request. */ +enum class GenericDeviceModelStatusEnumType +{ + Accepted, + Rejected, + NotSupported, + EmptyResultSet, +}; + +/** @brief Helper to convert a GenericDeviceModelStatusEnumType enum to string */ +extern const EnumToStringFromString GenericDeviceModelStatusEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_GENERICDEVICEMODELSTATUSENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/GenericStatusEnumType20.cpp b/src/ocpp20/types/GenericStatusEnumType20.cpp new file mode 100644 index 00000000..54452e71 --- /dev/null +++ b/src/ocpp20/types/GenericStatusEnumType20.cpp @@ -0,0 +1,41 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SignCertificateRequest + OCPP 2.0.1 FINAL +*/ + +#include "GenericStatusEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a GenericStatusEnumType enum to string */ +const EnumToStringFromString GenericStatusEnumTypeHelper = { + {GenericStatusEnumType::Accepted, "Accepted"}, + {GenericStatusEnumType::Rejected, "Rejected"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/GenericStatusEnumType20.h b/src/ocpp20/types/GenericStatusEnumType20.h new file mode 100644 index 00000000..f16486de --- /dev/null +++ b/src/ocpp20/types/GenericStatusEnumType20.h @@ -0,0 +1,50 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SignCertificateRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_GENERICSTATUSENUMTYPE_H +#define OPENOCPP_OCPP20_GENERICSTATUSENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Specifies whether the CSMS can process the request. */ +enum class GenericStatusEnumType +{ + Accepted, + Rejected, +}; + +/** @brief Helper to convert a GenericStatusEnumType enum to string */ +extern const EnumToStringFromString GenericStatusEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_GENERICSTATUSENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/GetCertificateIdUseEnumType20.cpp b/src/ocpp20/types/GetCertificateIdUseEnumType20.cpp new file mode 100644 index 00000000..215e8567 --- /dev/null +++ b/src/ocpp20/types/GetCertificateIdUseEnumType20.cpp @@ -0,0 +1,44 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetInstalledCertificateIdsRequest + OCPP 2.0.1 FINAL +*/ + +#include "GetCertificateIdUseEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a GetCertificateIdUseEnumType enum to string */ +const EnumToStringFromString GetCertificateIdUseEnumTypeHelper = { + {GetCertificateIdUseEnumType::V2GRootCertificate, "V2GRootCertificate"}, + {GetCertificateIdUseEnumType::MORootCertificate, "MORootCertificate"}, + {GetCertificateIdUseEnumType::CSMSRootCertificate, "CSMSRootCertificate"}, + {GetCertificateIdUseEnumType::V2GCertificateChain, "V2GCertificateChain"}, + {GetCertificateIdUseEnumType::ManufacturerRootCertificate, "ManufacturerRootCertificate"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/GetCertificateIdUseEnumType20.h b/src/ocpp20/types/GetCertificateIdUseEnumType20.h new file mode 100644 index 00000000..cfbe1e0f --- /dev/null +++ b/src/ocpp20/types/GetCertificateIdUseEnumType20.h @@ -0,0 +1,53 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetInstalledCertificateIdsRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_GETCERTIFICATEIDUSEENUMTYPE_H +#define OPENOCPP_OCPP20_GETCERTIFICATEIDUSEENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Indicates the type of the requested certificate(s). */ +enum class GetCertificateIdUseEnumType +{ + V2GRootCertificate, + MORootCertificate, + CSMSRootCertificate, + V2GCertificateChain, + ManufacturerRootCertificate, +}; + +/** @brief Helper to convert a GetCertificateIdUseEnumType enum to string */ +extern const EnumToStringFromString GetCertificateIdUseEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_GETCERTIFICATEIDUSEENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/GetCertificateStatusEnumType20.cpp b/src/ocpp20/types/GetCertificateStatusEnumType20.cpp new file mode 100644 index 00000000..2abc2b98 --- /dev/null +++ b/src/ocpp20/types/GetCertificateStatusEnumType20.cpp @@ -0,0 +1,41 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetCertificateStatusRequest + OCPP 2.0.1 FINAL +*/ + +#include "GetCertificateStatusEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a GetCertificateStatusEnumType enum to string */ +const EnumToStringFromString GetCertificateStatusEnumTypeHelper = { + {GetCertificateStatusEnumType::Accepted, "Accepted"}, + {GetCertificateStatusEnumType::Failed, "Failed"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/GetCertificateStatusEnumType20.h b/src/ocpp20/types/GetCertificateStatusEnumType20.h new file mode 100644 index 00000000..9bc47612 --- /dev/null +++ b/src/ocpp20/types/GetCertificateStatusEnumType20.h @@ -0,0 +1,50 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetCertificateStatusRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_GETCERTIFICATESTATUSENUMTYPE_H +#define OPENOCPP_OCPP20_GETCERTIFICATESTATUSENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief This indicates whether the charging station was able to retrieve the OCSP certificate status. */ +enum class GetCertificateStatusEnumType +{ + Accepted, + Failed, +}; + +/** @brief Helper to convert a GetCertificateStatusEnumType enum to string */ +extern const EnumToStringFromString GetCertificateStatusEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_GETCERTIFICATESTATUSENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/GetChargingProfileStatusEnumType20.cpp b/src/ocpp20/types/GetChargingProfileStatusEnumType20.cpp new file mode 100644 index 00000000..ab7f92a8 --- /dev/null +++ b/src/ocpp20/types/GetChargingProfileStatusEnumType20.cpp @@ -0,0 +1,41 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetChargingProfilesRequest + OCPP 2.0.1 FINAL +*/ + +#include "GetChargingProfileStatusEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a GetChargingProfileStatusEnumType enum to string */ +const EnumToStringFromString GetChargingProfileStatusEnumTypeHelper = { + {GetChargingProfileStatusEnumType::Accepted, "Accepted"}, + {GetChargingProfileStatusEnumType::NoProfiles, "NoProfiles"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/GetChargingProfileStatusEnumType20.h b/src/ocpp20/types/GetChargingProfileStatusEnumType20.h new file mode 100644 index 00000000..aa545a1e --- /dev/null +++ b/src/ocpp20/types/GetChargingProfileStatusEnumType20.h @@ -0,0 +1,50 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetChargingProfilesRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_GETCHARGINGPROFILESTATUSENUMTYPE_H +#define OPENOCPP_OCPP20_GETCHARGINGPROFILESTATUSENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief This indicates whether the Charging Station is able to process this request and will send <<reportchargingprofilesrequest, ReportChargingProfilesRequest>> messages. */ +enum class GetChargingProfileStatusEnumType +{ + Accepted, + NoProfiles, +}; + +/** @brief Helper to convert a GetChargingProfileStatusEnumType enum to string */ +extern const EnumToStringFromString GetChargingProfileStatusEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_GETCHARGINGPROFILESTATUSENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/GetDisplayMessagesStatusEnumType20.cpp b/src/ocpp20/types/GetDisplayMessagesStatusEnumType20.cpp new file mode 100644 index 00000000..c9ab8d5e --- /dev/null +++ b/src/ocpp20/types/GetDisplayMessagesStatusEnumType20.cpp @@ -0,0 +1,41 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetDisplayMessagesRequest + OCPP 2.0.1 FINAL +*/ + +#include "GetDisplayMessagesStatusEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a GetDisplayMessagesStatusEnumType enum to string */ +const EnumToStringFromString GetDisplayMessagesStatusEnumTypeHelper = { + {GetDisplayMessagesStatusEnumType::Accepted, "Accepted"}, + {GetDisplayMessagesStatusEnumType::Unknown, "Unknown"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/GetDisplayMessagesStatusEnumType20.h b/src/ocpp20/types/GetDisplayMessagesStatusEnumType20.h new file mode 100644 index 00000000..84bf3ead --- /dev/null +++ b/src/ocpp20/types/GetDisplayMessagesStatusEnumType20.h @@ -0,0 +1,50 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetDisplayMessagesRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_GETDISPLAYMESSAGESSTATUSENUMTYPE_H +#define OPENOCPP_OCPP20_GETDISPLAYMESSAGESSTATUSENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Indicates if the Charging Station has Display Messages that match the request criteria in the <<getdisplaymessagesrequest,GetDisplayMessagesRequest>> */ +enum class GetDisplayMessagesStatusEnumType +{ + Accepted, + Unknown, +}; + +/** @brief Helper to convert a GetDisplayMessagesStatusEnumType enum to string */ +extern const EnumToStringFromString GetDisplayMessagesStatusEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_GETDISPLAYMESSAGESSTATUSENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/GetInstalledCertificateStatusEnumType20.cpp b/src/ocpp20/types/GetInstalledCertificateStatusEnumType20.cpp new file mode 100644 index 00000000..bc60f3bf --- /dev/null +++ b/src/ocpp20/types/GetInstalledCertificateStatusEnumType20.cpp @@ -0,0 +1,41 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetInstalledCertificateIdsRequest + OCPP 2.0.1 FINAL +*/ + +#include "GetInstalledCertificateStatusEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a GetInstalledCertificateStatusEnumType enum to string */ +const EnumToStringFromString GetInstalledCertificateStatusEnumTypeHelper = { + {GetInstalledCertificateStatusEnumType::Accepted, "Accepted"}, + {GetInstalledCertificateStatusEnumType::NotFound, "NotFound"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/GetInstalledCertificateStatusEnumType20.h b/src/ocpp20/types/GetInstalledCertificateStatusEnumType20.h new file mode 100644 index 00000000..84d72c8e --- /dev/null +++ b/src/ocpp20/types/GetInstalledCertificateStatusEnumType20.h @@ -0,0 +1,50 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetInstalledCertificateIdsRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_GETINSTALLEDCERTIFICATESTATUSENUMTYPE_H +#define OPENOCPP_OCPP20_GETINSTALLEDCERTIFICATESTATUSENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Charging Station indicates if it can process the request. */ +enum class GetInstalledCertificateStatusEnumType +{ + Accepted, + NotFound, +}; + +/** @brief Helper to convert a GetInstalledCertificateStatusEnumType enum to string */ +extern const EnumToStringFromString GetInstalledCertificateStatusEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_GETINSTALLEDCERTIFICATESTATUSENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/GetVariableDataType20.cpp b/src/ocpp20/types/GetVariableDataType20.cpp new file mode 100644 index 00000000..8a342f92 --- /dev/null +++ b/src/ocpp20/types/GetVariableDataType20.cpp @@ -0,0 +1,112 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetVariablesRequest + OCPP 2.0.1 FINAL +*/ + +#include "GetVariableDataType20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Convert a GetVariableDataType from a JSON representation */ +bool GetVariableDataTypeConverter::fromJson(const rapidjson::Value& json, + GetVariableDataType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // attributeType + if (json.HasMember("attributeType")) + { + data.attributeType = AttributeEnumTypeHelper.fromString(json["attributeType"].GetString()); + } + + // component + ComponentTypeConverter component_converter; + ret = ret && component_converter.fromJson(json["component"], data.component, error_code, error_message); + + // variable + VariableTypeConverter variable_converter; + ret = ret && variable_converter.fromJson(json["variable"], data.variable, error_code, error_message); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a GetVariableDataType to a JSON representation */ +bool GetVariableDataTypeConverter::toJson(const GetVariableDataType& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // attributeType + if (data.attributeType.isSet()) + { + fill(json, "attributeType", AttributeEnumTypeHelper.toString(data.attributeType)); + } + + // component + ComponentTypeConverter component_converter; + component_converter.setAllocator(allocator); + rapidjson::Document component_doc(rapidjson::kObjectType); + ret = ret && component_converter.toJson(data.component, component_doc); + json.AddMember(rapidjson::StringRef("component"), component_doc.Move(), *allocator); + + // variable + VariableTypeConverter variable_converter; + variable_converter.setAllocator(allocator); + rapidjson::Document variable_doc(rapidjson::kObjectType); + ret = ret && variable_converter.toJson(data.variable, variable_doc); + json.AddMember(rapidjson::StringRef("variable"), variable_doc.Move(), *allocator); + + return ret; +} + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/GetVariableDataType20.h b/src/ocpp20/types/GetVariableDataType20.h new file mode 100644 index 00000000..a3cd8991 --- /dev/null +++ b/src/ocpp20/types/GetVariableDataType20.h @@ -0,0 +1,77 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetVariablesRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_GETVARIABLEDATATYPE_H +#define OPENOCPP_OCPP20_GETVARIABLEDATATYPE_H + +#include "AttributeEnumType20.h" +#include "ComponentType20.h" +#include "CustomDataType20.h" +#include "VariableType20.h" + +#include "IMessageConverter.h" +#include "Optional.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Class to hold parameters for GetVariables request. + */ +struct GetVariableDataType +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::Optional attributeType; + /** @brief */ + ComponentType component; + /** @brief */ + VariableType variable; +}; + +/** @brief Converter class for GetVariableDataType type */ +class GetVariableDataTypeConverter : public ocpp::messages::IMessageConverter +{ + public: + /** @brief Clone the converter */ + ocpp::messages::IMessageConverter* clone() const override { return new GetVariableDataTypeConverter(); } + + /** @brief Convert a GetVariableDataType from a JSON representation */ + bool fromJson(const rapidjson::Value& json, + GetVariableDataType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) override; + + /** @brief Convert a GetVariableDataType to a JSON representation */ + bool toJson(const GetVariableDataType& data, rapidjson::Document& json) override; +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_GETVARIABLEDATATYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/GetVariableResultType20.cpp b/src/ocpp20/types/GetVariableResultType20.cpp new file mode 100644 index 00000000..0cb32559 --- /dev/null +++ b/src/ocpp20/types/GetVariableResultType20.cpp @@ -0,0 +1,142 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetVariablesRequest + OCPP 2.0.1 FINAL +*/ + +#include "GetVariableResultType20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Convert a GetVariableResultType from a JSON representation */ +bool GetVariableResultTypeConverter::fromJson(const rapidjson::Value& json, + GetVariableResultType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // attributeStatusInfo + if (json.HasMember("attributeStatusInfo")) + { + StatusInfoTypeConverter attributeStatusInfo_converter; + ret = + ret && attributeStatusInfo_converter.fromJson(json["attributeStatusInfo"], data.attributeStatusInfo, error_code, error_message); + } + + // attributeStatus + data.attributeStatus = GetVariableStatusEnumTypeHelper.fromString(json["attributeStatus"].GetString()); + + // attributeType + if (json.HasMember("attributeType")) + { + data.attributeType = AttributeEnumTypeHelper.fromString(json["attributeType"].GetString()); + } + + // attributeValue + extract(json, "attributeValue", data.attributeValue); + + // component + ComponentTypeConverter component_converter; + ret = ret && component_converter.fromJson(json["component"], data.component, error_code, error_message); + + // variable + VariableTypeConverter variable_converter; + ret = ret && variable_converter.fromJson(json["variable"], data.variable, error_code, error_message); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a GetVariableResultType to a JSON representation */ +bool GetVariableResultTypeConverter::toJson(const GetVariableResultType& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // attributeStatusInfo + if (data.attributeStatusInfo.isSet()) + { + StatusInfoTypeConverter attributeStatusInfo_converter; + attributeStatusInfo_converter.setAllocator(allocator); + rapidjson::Document attributeStatusInfo_doc(rapidjson::kObjectType); + ret = ret && attributeStatusInfo_converter.toJson(data.attributeStatusInfo, attributeStatusInfo_doc); + json.AddMember(rapidjson::StringRef("attributeStatusInfo"), attributeStatusInfo_doc.Move(), *allocator); + } + + // attributeStatus + fill(json, "attributeStatus", GetVariableStatusEnumTypeHelper.toString(data.attributeStatus)); + + // attributeType + if (data.attributeType.isSet()) + { + fill(json, "attributeType", AttributeEnumTypeHelper.toString(data.attributeType)); + } + + // attributeValue + fill(json, "attributeValue", data.attributeValue); + + // component + ComponentTypeConverter component_converter; + component_converter.setAllocator(allocator); + rapidjson::Document component_doc(rapidjson::kObjectType); + ret = ret && component_converter.toJson(data.component, component_doc); + json.AddMember(rapidjson::StringRef("component"), component_doc.Move(), *allocator); + + // variable + VariableTypeConverter variable_converter; + variable_converter.setAllocator(allocator); + rapidjson::Document variable_doc(rapidjson::kObjectType); + ret = ret && variable_converter.toJson(data.variable, variable_doc); + json.AddMember(rapidjson::StringRef("variable"), variable_doc.Move(), *allocator); + + return ret; +} + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/GetVariableResultType20.h b/src/ocpp20/types/GetVariableResultType20.h new file mode 100644 index 00000000..2bc638fa --- /dev/null +++ b/src/ocpp20/types/GetVariableResultType20.h @@ -0,0 +1,88 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetVariablesRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_GETVARIABLERESULTTYPE_H +#define OPENOCPP_OCPP20_GETVARIABLERESULTTYPE_H + +#include "AttributeEnumType20.h" +#include "ComponentType20.h" +#include "CustomDataType20.h" +#include "GetVariableStatusEnumType20.h" +#include "StatusInfoType20.h" +#include "VariableType20.h" + +#include "CiStringType.h" +#include "IMessageConverter.h" +#include "Optional.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Class to hold results of GetVariables request. + */ +struct GetVariableResultType +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::Optional attributeStatusInfo; + /** @brief */ + GetVariableStatusEnumType attributeStatus; + /** @brief */ + ocpp::types::Optional attributeType; + /** @brief Value of requested attribute type of component-variable. This field can only be empty when the given status is NOT accepted. + +The Configuration Variable <<configkey-reporting-value-size,ReportingValueSize>> can be used to limit GetVariableResult.attributeValue, VariableAttribute.value and EventData.actualValue. The max size of these values will always remain equal. */ + ocpp::types::Optional> attributeValue; + /** @brief */ + ComponentType component; + /** @brief */ + VariableType variable; +}; + +/** @brief Converter class for GetVariableResultType type */ +class GetVariableResultTypeConverter : public ocpp::messages::IMessageConverter +{ + public: + /** @brief Clone the converter */ + ocpp::messages::IMessageConverter* clone() const override { return new GetVariableResultTypeConverter(); } + + /** @brief Convert a GetVariableResultType from a JSON representation */ + bool fromJson(const rapidjson::Value& json, + GetVariableResultType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) override; + + /** @brief Convert a GetVariableResultType to a JSON representation */ + bool toJson(const GetVariableResultType& data, rapidjson::Document& json) override; +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_GETVARIABLERESULTTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/GetVariableStatusEnumType20.cpp b/src/ocpp20/types/GetVariableStatusEnumType20.cpp new file mode 100644 index 00000000..fd6dd511 --- /dev/null +++ b/src/ocpp20/types/GetVariableStatusEnumType20.cpp @@ -0,0 +1,44 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetVariablesRequest + OCPP 2.0.1 FINAL +*/ + +#include "GetVariableStatusEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a GetVariableStatusEnumType enum to string */ +const EnumToStringFromString GetVariableStatusEnumTypeHelper = { + {GetVariableStatusEnumType::Accepted, "Accepted"}, + {GetVariableStatusEnumType::Rejected, "Rejected"}, + {GetVariableStatusEnumType::UnknownComponent, "UnknownComponent"}, + {GetVariableStatusEnumType::UnknownVariable, "UnknownVariable"}, + {GetVariableStatusEnumType::NotSupportedAttributeType, "NotSupportedAttributeType"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/GetVariableStatusEnumType20.h b/src/ocpp20/types/GetVariableStatusEnumType20.h new file mode 100644 index 00000000..4a0ec258 --- /dev/null +++ b/src/ocpp20/types/GetVariableStatusEnumType20.h @@ -0,0 +1,53 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetVariablesRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_GETVARIABLESTATUSENUMTYPE_H +#define OPENOCPP_OCPP20_GETVARIABLESTATUSENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Result status of getting the variable. */ +enum class GetVariableStatusEnumType +{ + Accepted, + Rejected, + UnknownComponent, + UnknownVariable, + NotSupportedAttributeType, +}; + +/** @brief Helper to convert a GetVariableStatusEnumType enum to string */ +extern const EnumToStringFromString GetVariableStatusEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_GETVARIABLESTATUSENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/HashAlgorithmEnumType20.cpp b/src/ocpp20/types/HashAlgorithmEnumType20.cpp new file mode 100644 index 00000000..388fc608 --- /dev/null +++ b/src/ocpp20/types/HashAlgorithmEnumType20.cpp @@ -0,0 +1,42 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:AuthorizeRequest + OCPP 2.0.1 FINAL +*/ + +#include "HashAlgorithmEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a HashAlgorithmEnumType enum to string */ +const EnumToStringFromString HashAlgorithmEnumTypeHelper = { + {HashAlgorithmEnumType::SHA256, "SHA256"}, + {HashAlgorithmEnumType::SHA384, "SHA384"}, + {HashAlgorithmEnumType::SHA512, "SHA512"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/HashAlgorithmEnumType20.h b/src/ocpp20/types/HashAlgorithmEnumType20.h new file mode 100644 index 00000000..e2967830 --- /dev/null +++ b/src/ocpp20/types/HashAlgorithmEnumType20.h @@ -0,0 +1,51 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:AuthorizeRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_HASHALGORITHMENUMTYPE_H +#define OPENOCPP_OCPP20_HASHALGORITHMENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Used algorithms for the hashes provided. */ +enum class HashAlgorithmEnumType +{ + SHA256, + SHA384, + SHA512, +}; + +/** @brief Helper to convert a HashAlgorithmEnumType enum to string */ +extern const EnumToStringFromString HashAlgorithmEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_HASHALGORITHMENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/IdTokenEnumType20.cpp b/src/ocpp20/types/IdTokenEnumType20.cpp new file mode 100644 index 00000000..928b6291 --- /dev/null +++ b/src/ocpp20/types/IdTokenEnumType20.cpp @@ -0,0 +1,47 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:RequestStartTransactionRequest + OCPP 2.0.1 FINAL +*/ + +#include "IdTokenEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a IdTokenEnumType enum to string */ +const EnumToStringFromString IdTokenEnumTypeHelper = { + {IdTokenEnumType::Central, "Central"}, + {IdTokenEnumType::eMAID, "eMAID"}, + {IdTokenEnumType::ISO14443, "ISO14443"}, + {IdTokenEnumType::ISO15693, "ISO15693"}, + {IdTokenEnumType::KeyCode, "KeyCode"}, + {IdTokenEnumType::Local, "Local"}, + {IdTokenEnumType::MacAddress, "MacAddress"}, + {IdTokenEnumType::NoAuthorization, "NoAuthorization"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/IdTokenEnumType20.h b/src/ocpp20/types/IdTokenEnumType20.h new file mode 100644 index 00000000..ab7b434c --- /dev/null +++ b/src/ocpp20/types/IdTokenEnumType20.h @@ -0,0 +1,56 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:RequestStartTransactionRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_IDTOKENENUMTYPE_H +#define OPENOCPP_OCPP20_IDTOKENENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Enumeration of possible idToken types. */ +enum class IdTokenEnumType +{ + Central, + eMAID, + ISO14443, + ISO15693, + KeyCode, + Local, + MacAddress, + NoAuthorization, +}; + +/** @brief Helper to convert a IdTokenEnumType enum to string */ +extern const EnumToStringFromString IdTokenEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_IDTOKENENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/IdTokenInfoType20.cpp b/src/ocpp20/types/IdTokenInfoType20.cpp new file mode 100644 index 00000000..187286ea --- /dev/null +++ b/src/ocpp20/types/IdTokenInfoType20.cpp @@ -0,0 +1,165 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:AuthorizeRequest + OCPP 2.0.1 FINAL +*/ + +#include "IdTokenInfoType20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Convert a IdTokenInfoType from a JSON representation */ +bool IdTokenInfoTypeConverter::fromJson(const rapidjson::Value& json, + IdTokenInfoType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // status + data.status = AuthorizationStatusEnumTypeHelper.fromString(json["status"].GetString()); + + // cacheExpiryDateTime + ret = ret && extract(json, "cacheExpiryDateTime", data.cacheExpiryDateTime, error_message); + + // chargingPriority + extract(json, "chargingPriority", data.chargingPriority); + + // language1 + extract(json, "language1", data.language1); + + // evseId + if (json.HasMember("evseId")) + { + const rapidjson::Value& evseId_json = json["evseId"]; + for (auto it = evseId_json.Begin(); ret && (it != evseId_json.End()); ++it) + { + int& item = data.evseId.emplace_back(); + item = it->GetInt(); + } + } + + // groupIdToken + if (json.HasMember("groupIdToken")) + { + IdTokenTypeConverter groupIdToken_converter; + ret = ret && groupIdToken_converter.fromJson(json["groupIdToken"], data.groupIdToken, error_code, error_message); + } + + // language2 + extract(json, "language2", data.language2); + + // personalMessage + if (json.HasMember("personalMessage")) + { + MessageContentTypeConverter personalMessage_converter; + ret = ret && personalMessage_converter.fromJson(json["personalMessage"], data.personalMessage, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a IdTokenInfoType to a JSON representation */ +bool IdTokenInfoTypeConverter::toJson(const IdTokenInfoType& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // status + fill(json, "status", AuthorizationStatusEnumTypeHelper.toString(data.status)); + + // cacheExpiryDateTime + fill(json, "cacheExpiryDateTime", data.cacheExpiryDateTime); + + // chargingPriority + fill(json, "chargingPriority", data.chargingPriority); + + // language1 + fill(json, "language1", data.language1); + + // evseId + if (!data.evseId.empty()) + { + + rapidjson::Value evseId_json(rapidjson::kArrayType); + for (const int& item : data.evseId) + { + evseId_json.PushBack(rapidjson::Value(item), *allocator); + } + json.AddMember(rapidjson::StringRef("evseId"), evseId_json.Move(), *allocator); + } + + // groupIdToken + if (data.groupIdToken.isSet()) + { + IdTokenTypeConverter groupIdToken_converter; + groupIdToken_converter.setAllocator(allocator); + rapidjson::Document groupIdToken_doc(rapidjson::kObjectType); + ret = ret && groupIdToken_converter.toJson(data.groupIdToken, groupIdToken_doc); + json.AddMember(rapidjson::StringRef("groupIdToken"), groupIdToken_doc.Move(), *allocator); + } + + // language2 + fill(json, "language2", data.language2); + + // personalMessage + if (data.personalMessage.isSet()) + { + MessageContentTypeConverter personalMessage_converter; + personalMessage_converter.setAllocator(allocator); + rapidjson::Document personalMessage_doc(rapidjson::kObjectType); + ret = ret && personalMessage_converter.toJson(data.personalMessage, personalMessage_doc); + json.AddMember(rapidjson::StringRef("personalMessage"), personalMessage_doc.Move(), *allocator); + } + + return ret; +} + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/IdTokenInfoType20.h b/src/ocpp20/types/IdTokenInfoType20.h new file mode 100644 index 00000000..87df6698 --- /dev/null +++ b/src/ocpp20/types/IdTokenInfoType20.h @@ -0,0 +1,99 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:AuthorizeRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_IDTOKENINFOTYPE_H +#define OPENOCPP_OCPP20_IDTOKENINFOTYPE_H + +#include "AuthorizationStatusEnumType20.h" +#include "CustomDataType20.h" +#include "IdTokenType20.h" +#include "MessageContentType20.h" + +#include "CiStringType.h" +#include "DateTime.h" +#include "IMessageConverter.h" +#include "Optional.h" +#include + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief ID_ Token +urn:x-oca:ocpp:uid:2:233247 +Contains status information about an identifier. +It is advised to not stop charging for a token that expires during charging, as ExpiryDate is only used for caching purposes. If ExpiryDate is not given, the status has no end date. + */ +struct IdTokenInfoType +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + AuthorizationStatusEnumType status; + /** @brief ID_ Token. Expiry. Date_ Time +urn:x-oca:ocpp:uid:1:569373 +Date and Time after which the token must be considered invalid. */ + ocpp::types::Optional cacheExpiryDateTime; + /** @brief Priority from a business point of view. Default priority is 0, The range is from -9 to 9. Higher values indicate a higher priority. The chargingPriority in <<transactioneventresponse,TransactionEventResponse>> overrules this one. */ + ocpp::types::Optional chargingPriority; + /** @brief ID_ Token. Language1. Language_ Code +urn:x-oca:ocpp:uid:1:569374 +Preferred user interface language of identifier user. Contains a language code as defined in <<ref-RFC5646,[RFC5646]>>. */ + ocpp::types::Optional> language1; + /** @brief Only used when the IdToken is only valid for one or more specific EVSEs, not for the entire Charging Station. */ + std::vector evseId; + /** @brief */ + ocpp::types::Optional groupIdToken; + /** @brief ID_ Token. Language2. Language_ Code +urn:x-oca:ocpp:uid:1:569375 +Second preferred user interface language of identifier user. Don’t use when language1 is omitted, has to be different from language1. Contains a language code as defined in <<ref-RFC5646,[RFC5646]>>. */ + ocpp::types::Optional> language2; + /** @brief */ + ocpp::types::Optional personalMessage; +}; + +/** @brief Converter class for IdTokenInfoType type */ +class IdTokenInfoTypeConverter : public ocpp::messages::IMessageConverter +{ + public: + /** @brief Clone the converter */ + ocpp::messages::IMessageConverter* clone() const override { return new IdTokenInfoTypeConverter(); } + + /** @brief Convert a IdTokenInfoType from a JSON representation */ + bool fromJson(const rapidjson::Value& json, + IdTokenInfoType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) override; + + /** @brief Convert a IdTokenInfoType to a JSON representation */ + bool toJson(const IdTokenInfoType& data, rapidjson::Document& json) override; +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_IDTOKENINFOTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/IdTokenType20.cpp b/src/ocpp20/types/IdTokenType20.cpp new file mode 100644 index 00000000..75e5eb47 --- /dev/null +++ b/src/ocpp20/types/IdTokenType20.cpp @@ -0,0 +1,118 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:RequestStartTransactionRequest + OCPP 2.0.1 FINAL +*/ + +#include "IdTokenType20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Convert a IdTokenType from a JSON representation */ +bool IdTokenTypeConverter::fromJson(const rapidjson::Value& json, + IdTokenType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // additionalInfo + if (json.HasMember("additionalInfo")) + { + const rapidjson::Value& additionalInfo_json = json["additionalInfo"]; + AdditionalInfoTypeConverter additionalInfo_converter; + for (auto it = additionalInfo_json.Begin(); ret && (it != additionalInfo_json.End()); ++it) + { + AdditionalInfoType& item = data.additionalInfo.emplace_back(); + ret = ret && additionalInfo_converter.fromJson(*it, item, error_code, error_message); + } + } + + // idToken + extract(json, "idToken", data.idToken); + + // type + data.type = IdTokenEnumTypeHelper.fromString(json["type"].GetString()); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a IdTokenType to a JSON representation */ +bool IdTokenTypeConverter::toJson(const IdTokenType& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // additionalInfo + if (!data.additionalInfo.empty()) + { + + rapidjson::Value additionalInfo_json(rapidjson::kArrayType); + AdditionalInfoTypeConverter additionalInfo_converter; + additionalInfo_converter.setAllocator(allocator); + for (const AdditionalInfoType& item : data.additionalInfo) + { + rapidjson::Document item_doc(rapidjson::kObjectType); + ret = ret && additionalInfo_converter.toJson(item, item_doc); + additionalInfo_json.PushBack(item_doc.Move(), *allocator); + } + json.AddMember(rapidjson::StringRef("additionalInfo"), additionalInfo_json.Move(), *allocator); + } + + // idToken + fill(json, "idToken", data.idToken); + + // type + fill(json, "type", IdTokenEnumTypeHelper.toString(data.type)); + + return ret; +} + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/IdTokenType20.h b/src/ocpp20/types/IdTokenType20.h new file mode 100644 index 00000000..df413df5 --- /dev/null +++ b/src/ocpp20/types/IdTokenType20.h @@ -0,0 +1,78 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:RequestStartTransactionRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_IDTOKENTYPE_H +#define OPENOCPP_OCPP20_IDTOKENTYPE_H + +#include "AdditionalInfoType20.h" +#include "CustomDataType20.h" +#include "IdTokenEnumType20.h" + +#include "CiStringType.h" +#include "IMessageConverter.h" +#include "Optional.h" +#include + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Contains a case insensitive identifier to use for the authorization and the type of authorization to support multiple forms of identifiers. + */ +struct IdTokenType +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + std::vector additionalInfo; + /** @brief IdToken is case insensitive. Might hold the hidden id of an RFID tag, but can for example also contain a UUID. */ + ocpp::types::CiStringType<36u> idToken; + /** @brief */ + IdTokenEnumType type; +}; + +/** @brief Converter class for IdTokenType type */ +class IdTokenTypeConverter : public ocpp::messages::IMessageConverter +{ + public: + /** @brief Clone the converter */ + ocpp::messages::IMessageConverter* clone() const override { return new IdTokenTypeConverter(); } + + /** @brief Convert a IdTokenType from a JSON representation */ + bool fromJson(const rapidjson::Value& json, + IdTokenType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) override; + + /** @brief Convert a IdTokenType to a JSON representation */ + bool toJson(const IdTokenType& data, rapidjson::Document& json) override; +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_IDTOKENTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/InstallCertificateStatusEnumType20.cpp b/src/ocpp20/types/InstallCertificateStatusEnumType20.cpp new file mode 100644 index 00000000..443eee8c --- /dev/null +++ b/src/ocpp20/types/InstallCertificateStatusEnumType20.cpp @@ -0,0 +1,42 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:InstallCertificateRequest + OCPP 2.0.1 FINAL +*/ + +#include "InstallCertificateStatusEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a InstallCertificateStatusEnumType enum to string */ +const EnumToStringFromString InstallCertificateStatusEnumTypeHelper = { + {InstallCertificateStatusEnumType::Accepted, "Accepted"}, + {InstallCertificateStatusEnumType::Rejected, "Rejected"}, + {InstallCertificateStatusEnumType::Failed, "Failed"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/InstallCertificateStatusEnumType20.h b/src/ocpp20/types/InstallCertificateStatusEnumType20.h new file mode 100644 index 00000000..40f371f9 --- /dev/null +++ b/src/ocpp20/types/InstallCertificateStatusEnumType20.h @@ -0,0 +1,51 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:InstallCertificateRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_INSTALLCERTIFICATESTATUSENUMTYPE_H +#define OPENOCPP_OCPP20_INSTALLCERTIFICATESTATUSENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Charging Station indicates if installation was successful. */ +enum class InstallCertificateStatusEnumType +{ + Accepted, + Rejected, + Failed, +}; + +/** @brief Helper to convert a InstallCertificateStatusEnumType enum to string */ +extern const EnumToStringFromString InstallCertificateStatusEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_INSTALLCERTIFICATESTATUSENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/InstallCertificateUseEnumType20.cpp b/src/ocpp20/types/InstallCertificateUseEnumType20.cpp new file mode 100644 index 00000000..d9d728f1 --- /dev/null +++ b/src/ocpp20/types/InstallCertificateUseEnumType20.cpp @@ -0,0 +1,43 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:InstallCertificateRequest + OCPP 2.0.1 FINAL +*/ + +#include "InstallCertificateUseEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a InstallCertificateUseEnumType enum to string */ +const EnumToStringFromString InstallCertificateUseEnumTypeHelper = { + {InstallCertificateUseEnumType::V2GRootCertificate, "V2GRootCertificate"}, + {InstallCertificateUseEnumType::MORootCertificate, "MORootCertificate"}, + {InstallCertificateUseEnumType::CSMSRootCertificate, "CSMSRootCertificate"}, + {InstallCertificateUseEnumType::ManufacturerRootCertificate, "ManufacturerRootCertificate"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/InstallCertificateUseEnumType20.h b/src/ocpp20/types/InstallCertificateUseEnumType20.h new file mode 100644 index 00000000..c2462ddf --- /dev/null +++ b/src/ocpp20/types/InstallCertificateUseEnumType20.h @@ -0,0 +1,52 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:InstallCertificateRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_INSTALLCERTIFICATEUSEENUMTYPE_H +#define OPENOCPP_OCPP20_INSTALLCERTIFICATEUSEENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Indicates the certificate type that is sent. */ +enum class InstallCertificateUseEnumType +{ + V2GRootCertificate, + MORootCertificate, + CSMSRootCertificate, + ManufacturerRootCertificate, +}; + +/** @brief Helper to convert a InstallCertificateUseEnumType enum to string */ +extern const EnumToStringFromString InstallCertificateUseEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_INSTALLCERTIFICATEUSEENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/Iso15118EVCertificateStatusEnumType20.cpp b/src/ocpp20/types/Iso15118EVCertificateStatusEnumType20.cpp new file mode 100644 index 00000000..f36ee06c --- /dev/null +++ b/src/ocpp20/types/Iso15118EVCertificateStatusEnumType20.cpp @@ -0,0 +1,41 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:Get15118EVCertificateRequest + OCPP 2.0.1 FINAL +*/ + +#include "Iso15118EVCertificateStatusEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a Iso15118EVCertificateStatusEnumType enum to string */ +const EnumToStringFromString Iso15118EVCertificateStatusEnumTypeHelper = { + {Iso15118EVCertificateStatusEnumType::Accepted, "Accepted"}, + {Iso15118EVCertificateStatusEnumType::Failed, "Failed"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/Iso15118EVCertificateStatusEnumType20.h b/src/ocpp20/types/Iso15118EVCertificateStatusEnumType20.h new file mode 100644 index 00000000..12b7e594 --- /dev/null +++ b/src/ocpp20/types/Iso15118EVCertificateStatusEnumType20.h @@ -0,0 +1,50 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:Get15118EVCertificateRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_ISO15118EVCERTIFICATESTATUSENUMTYPE_H +#define OPENOCPP_OCPP20_ISO15118EVCERTIFICATESTATUSENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Indicates whether the message was processed properly. */ +enum class Iso15118EVCertificateStatusEnumType +{ + Accepted, + Failed, +}; + +/** @brief Helper to convert a Iso15118EVCertificateStatusEnumType enum to string */ +extern const EnumToStringFromString Iso15118EVCertificateStatusEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_ISO15118EVCERTIFICATESTATUSENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/LocationEnumType20.cpp b/src/ocpp20/types/LocationEnumType20.cpp new file mode 100644 index 00000000..7d13d1bf --- /dev/null +++ b/src/ocpp20/types/LocationEnumType20.cpp @@ -0,0 +1,44 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:MeterValuesRequest + OCPP 2.0.1 FINAL +*/ + +#include "LocationEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a LocationEnumType enum to string */ +const EnumToStringFromString LocationEnumTypeHelper = { + {LocationEnumType::Body, "Body"}, + {LocationEnumType::Cable, "Cable"}, + {LocationEnumType::EV, "EV"}, + {LocationEnumType::Inlet, "Inlet"}, + {LocationEnumType::Outlet, "Outlet"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/LocationEnumType20.h b/src/ocpp20/types/LocationEnumType20.h new file mode 100644 index 00000000..8d877cbe --- /dev/null +++ b/src/ocpp20/types/LocationEnumType20.h @@ -0,0 +1,55 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:MeterValuesRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_LOCATIONENUMTYPE_H +#define OPENOCPP_OCPP20_LOCATIONENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Sampled_ Value. Location. Location_ Code +urn:x-oca:ocpp:uid:1:569265 +Indicates where the measured value has been sampled. Default = "Outlet" */ +enum class LocationEnumType +{ + Body, + Cable, + EV, + Inlet, + Outlet, +}; + +/** @brief Helper to convert a LocationEnumType enum to string */ +extern const EnumToStringFromString LocationEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_LOCATIONENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/LogEnumType20.cpp b/src/ocpp20/types/LogEnumType20.cpp new file mode 100644 index 00000000..116d5149 --- /dev/null +++ b/src/ocpp20/types/LogEnumType20.cpp @@ -0,0 +1,41 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetLogRequest + OCPP 2.0.1 FINAL +*/ + +#include "LogEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a LogEnumType enum to string */ +const EnumToStringFromString LogEnumTypeHelper = { + {LogEnumType::DiagnosticsLog, "DiagnosticsLog"}, + {LogEnumType::SecurityLog, "SecurityLog"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/LogEnumType20.h b/src/ocpp20/types/LogEnumType20.h new file mode 100644 index 00000000..553a0fb1 --- /dev/null +++ b/src/ocpp20/types/LogEnumType20.h @@ -0,0 +1,51 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetLogRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_LOGENUMTYPE_H +#define OPENOCPP_OCPP20_LOGENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief This contains the type of log file that the Charging Station +should send. */ +enum class LogEnumType +{ + DiagnosticsLog, + SecurityLog, +}; + +/** @brief Helper to convert a LogEnumType enum to string */ +extern const EnumToStringFromString LogEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_LOGENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/LogParametersType20.cpp b/src/ocpp20/types/LogParametersType20.cpp new file mode 100644 index 00000000..d4695903 --- /dev/null +++ b/src/ocpp20/types/LogParametersType20.cpp @@ -0,0 +1,96 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetLogRequest + OCPP 2.0.1 FINAL +*/ + +#include "LogParametersType20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Convert a LogParametersType from a JSON representation */ +bool LogParametersTypeConverter::fromJson(const rapidjson::Value& json, + LogParametersType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // remoteLocation + extract(json, "remoteLocation", data.remoteLocation); + + // oldestTimestamp + ret = ret && extract(json, "oldestTimestamp", data.oldestTimestamp, error_message); + + // latestTimestamp + ret = ret && extract(json, "latestTimestamp", data.latestTimestamp, error_message); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a LogParametersType to a JSON representation */ +bool LogParametersTypeConverter::toJson(const LogParametersType& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // remoteLocation + fill(json, "remoteLocation", data.remoteLocation); + + // oldestTimestamp + fill(json, "oldestTimestamp", data.oldestTimestamp); + + // latestTimestamp + fill(json, "latestTimestamp", data.latestTimestamp); + + return ret; +} + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/LogParametersType20.h b/src/ocpp20/types/LogParametersType20.h new file mode 100644 index 00000000..1da09bfd --- /dev/null +++ b/src/ocpp20/types/LogParametersType20.h @@ -0,0 +1,84 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetLogRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_LOGPARAMETERSTYPE_H +#define OPENOCPP_OCPP20_LOGPARAMETERSTYPE_H + +#include "CustomDataType20.h" + +#include "CiStringType.h" +#include "DateTime.h" +#include "IMessageConverter.h" +#include "Optional.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Log +urn:x-enexis:ecdm:uid:2:233373 +Generic class for the configuration of logging entries. + */ +struct LogParametersType +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief Log. Remote_ Location. URI +urn:x-enexis:ecdm:uid:1:569484 +The URL of the location at the remote system where the log should be stored. */ + ocpp::types::CiStringType<512u> remoteLocation; + /** @brief Log. Oldest_ Timestamp. Date_ Time +urn:x-enexis:ecdm:uid:1:569477 +This contains the date and time of the oldest logging information to include in the diagnostics. */ + ocpp::types::Optional oldestTimestamp; + /** @brief Log. Latest_ Timestamp. Date_ Time +urn:x-enexis:ecdm:uid:1:569482 +This contains the date and time of the latest logging information to include in the diagnostics. */ + ocpp::types::Optional latestTimestamp; +}; + +/** @brief Converter class for LogParametersType type */ +class LogParametersTypeConverter : public ocpp::messages::IMessageConverter +{ + public: + /** @brief Clone the converter */ + ocpp::messages::IMessageConverter* clone() const override { return new LogParametersTypeConverter(); } + + /** @brief Convert a LogParametersType from a JSON representation */ + bool fromJson(const rapidjson::Value& json, + LogParametersType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) override; + + /** @brief Convert a LogParametersType to a JSON representation */ + bool toJson(const LogParametersType& data, rapidjson::Document& json) override; +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_LOGPARAMETERSTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/LogStatusEnumType20.cpp b/src/ocpp20/types/LogStatusEnumType20.cpp new file mode 100644 index 00000000..a0e49a22 --- /dev/null +++ b/src/ocpp20/types/LogStatusEnumType20.cpp @@ -0,0 +1,42 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetLogRequest + OCPP 2.0.1 FINAL +*/ + +#include "LogStatusEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a LogStatusEnumType enum to string */ +const EnumToStringFromString LogStatusEnumTypeHelper = { + {LogStatusEnumType::Accepted, "Accepted"}, + {LogStatusEnumType::Rejected, "Rejected"}, + {LogStatusEnumType::AcceptedCanceled, "AcceptedCanceled"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/LogStatusEnumType20.h b/src/ocpp20/types/LogStatusEnumType20.h new file mode 100644 index 00000000..46190c08 --- /dev/null +++ b/src/ocpp20/types/LogStatusEnumType20.h @@ -0,0 +1,51 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetLogRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_LOGSTATUSENUMTYPE_H +#define OPENOCPP_OCPP20_LOGSTATUSENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief This field indicates whether the Charging Station was able to accept the request. */ +enum class LogStatusEnumType +{ + Accepted, + Rejected, + AcceptedCanceled, +}; + +/** @brief Helper to convert a LogStatusEnumType enum to string */ +extern const EnumToStringFromString LogStatusEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_LOGSTATUSENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/MeasurandEnumType20.cpp b/src/ocpp20/types/MeasurandEnumType20.cpp new file mode 100644 index 00000000..b3447947 --- /dev/null +++ b/src/ocpp20/types/MeasurandEnumType20.cpp @@ -0,0 +1,64 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:MeterValuesRequest + OCPP 2.0.1 FINAL +*/ + +#include "MeasurandEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a MeasurandEnumType enum to string */ +const EnumToStringFromString MeasurandEnumTypeHelper = { + {MeasurandEnumType::Current_Export, "Current.Export"}, + {MeasurandEnumType::Current_Import, "Current.Import"}, + {MeasurandEnumType::Current_Offered, "Current.Offered"}, + {MeasurandEnumType::Energy_Active_Export_Register, "Energy.Active.Export.Register"}, + {MeasurandEnumType::Energy_Active_Import_Register, "Energy.Active.Import.Register"}, + {MeasurandEnumType::Energy_Reactive_Export_Register, "Energy.Reactive.Export.Register"}, + {MeasurandEnumType::Energy_Reactive_Import_Register, "Energy.Reactive.Import.Register"}, + {MeasurandEnumType::Energy_Active_Export_Interval, "Energy.Active.Export.Interval"}, + {MeasurandEnumType::Energy_Active_Import_Interval, "Energy.Active.Import.Interval"}, + {MeasurandEnumType::Energy_Active_Net, "Energy.Active.Net"}, + {MeasurandEnumType::Energy_Reactive_Export_Interval, "Energy.Reactive.Export.Interval"}, + {MeasurandEnumType::Energy_Reactive_Import_Interval, "Energy.Reactive.Import.Interval"}, + {MeasurandEnumType::Energy_Reactive_Net, "Energy.Reactive.Net"}, + {MeasurandEnumType::Energy_Apparent_Net, "Energy.Apparent.Net"}, + {MeasurandEnumType::Energy_Apparent_Import, "Energy.Apparent.Import"}, + {MeasurandEnumType::Energy_Apparent_Export, "Energy.Apparent.Export"}, + {MeasurandEnumType::Frequency, "Frequency"}, + {MeasurandEnumType::Power_Active_Export, "Power.Active.Export"}, + {MeasurandEnumType::Power_Active_Import, "Power.Active.Import"}, + {MeasurandEnumType::Power_Factor, "Power.Factor"}, + {MeasurandEnumType::Power_Offered, "Power.Offered"}, + {MeasurandEnumType::Power_Reactive_Export, "Power.Reactive.Export"}, + {MeasurandEnumType::Power_Reactive_Import, "Power.Reactive.Import"}, + {MeasurandEnumType::SoC, "SoC"}, + {MeasurandEnumType::Voltage, "Voltage"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/MeasurandEnumType20.h b/src/ocpp20/types/MeasurandEnumType20.h new file mode 100644 index 00000000..58bc2e0b --- /dev/null +++ b/src/ocpp20/types/MeasurandEnumType20.h @@ -0,0 +1,75 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:MeterValuesRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_MEASURANDENUMTYPE_H +#define OPENOCPP_OCPP20_MEASURANDENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Sampled_ Value. Measurand. Measurand_ Code +urn:x-oca:ocpp:uid:1:569263 +Type of measurement. Default = "Energy.Active.Import.Register" */ +enum class MeasurandEnumType +{ + Current_Export, + Current_Import, + Current_Offered, + Energy_Active_Export_Register, + Energy_Active_Import_Register, + Energy_Reactive_Export_Register, + Energy_Reactive_Import_Register, + Energy_Active_Export_Interval, + Energy_Active_Import_Interval, + Energy_Active_Net, + Energy_Reactive_Export_Interval, + Energy_Reactive_Import_Interval, + Energy_Reactive_Net, + Energy_Apparent_Net, + Energy_Apparent_Import, + Energy_Apparent_Export, + Frequency, + Power_Active_Export, + Power_Active_Import, + Power_Factor, + Power_Offered, + Power_Reactive_Export, + Power_Reactive_Import, + SoC, + Voltage, +}; + +/** @brief Helper to convert a MeasurandEnumType enum to string */ +extern const EnumToStringFromString MeasurandEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_MEASURANDENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/MessageContentType20.cpp b/src/ocpp20/types/MessageContentType20.cpp new file mode 100644 index 00000000..2ca22e5b --- /dev/null +++ b/src/ocpp20/types/MessageContentType20.cpp @@ -0,0 +1,96 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:NotifyDisplayMessagesRequest + OCPP 2.0.1 FINAL +*/ + +#include "MessageContentType20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Convert a MessageContentType from a JSON representation */ +bool MessageContentTypeConverter::fromJson(const rapidjson::Value& json, + MessageContentType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // format + data.format = MessageFormatEnumTypeHelper.fromString(json["format"].GetString()); + + // language + extract(json, "language", data.language); + + // content + extract(json, "content", data.content); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a MessageContentType to a JSON representation */ +bool MessageContentTypeConverter::toJson(const MessageContentType& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // format + fill(json, "format", MessageFormatEnumTypeHelper.toString(data.format)); + + // language + fill(json, "language", data.language); + + // content + fill(json, "content", data.content); + + return ret; +} + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/MessageContentType20.h b/src/ocpp20/types/MessageContentType20.h new file mode 100644 index 00000000..4ffd6b53 --- /dev/null +++ b/src/ocpp20/types/MessageContentType20.h @@ -0,0 +1,83 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:NotifyDisplayMessagesRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_MESSAGECONTENTTYPE_H +#define OPENOCPP_OCPP20_MESSAGECONTENTTYPE_H + +#include "CustomDataType20.h" +#include "MessageFormatEnumType20.h" + +#include "CiStringType.h" +#include "IMessageConverter.h" +#include "Optional.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Message_ Content +urn:x-enexis:ecdm:uid:2:234490 +Contains message details, for a message to be displayed on a Charging Station. + + */ +struct MessageContentType +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + MessageFormatEnumType format; + /** @brief Message_ Content. Language. Language_ Code +urn:x-enexis:ecdm:uid:1:570849 +Message language identifier. Contains a language code as defined in <<ref-RFC5646,[RFC5646]>>. */ + ocpp::types::Optional> language; + /** @brief Message_ Content. Content. Message +urn:x-enexis:ecdm:uid:1:570852 +Message contents. */ + ocpp::types::CiStringType<512u> content; +}; + +/** @brief Converter class for MessageContentType type */ +class MessageContentTypeConverter : public ocpp::messages::IMessageConverter +{ + public: + /** @brief Clone the converter */ + ocpp::messages::IMessageConverter* clone() const override { return new MessageContentTypeConverter(); } + + /** @brief Convert a MessageContentType from a JSON representation */ + bool fromJson(const rapidjson::Value& json, + MessageContentType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) override; + + /** @brief Convert a MessageContentType to a JSON representation */ + bool toJson(const MessageContentType& data, rapidjson::Document& json) override; +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_MESSAGECONTENTTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/MessageFormatEnumType20.cpp b/src/ocpp20/types/MessageFormatEnumType20.cpp new file mode 100644 index 00000000..68d038ad --- /dev/null +++ b/src/ocpp20/types/MessageFormatEnumType20.cpp @@ -0,0 +1,43 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:NotifyDisplayMessagesRequest + OCPP 2.0.1 FINAL +*/ + +#include "MessageFormatEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a MessageFormatEnumType enum to string */ +const EnumToStringFromString MessageFormatEnumTypeHelper = { + {MessageFormatEnumType::ASCII, "ASCII"}, + {MessageFormatEnumType::HTML, "HTML"}, + {MessageFormatEnumType::URI, "URI"}, + {MessageFormatEnumType::UTF8, "UTF8"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/MessageFormatEnumType20.h b/src/ocpp20/types/MessageFormatEnumType20.h new file mode 100644 index 00000000..b63045b2 --- /dev/null +++ b/src/ocpp20/types/MessageFormatEnumType20.h @@ -0,0 +1,54 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:NotifyDisplayMessagesRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_MESSAGEFORMATENUMTYPE_H +#define OPENOCPP_OCPP20_MESSAGEFORMATENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Message_ Content. Format. Message_ Format_ Code +urn:x-enexis:ecdm:uid:1:570848 +Format of the message. */ +enum class MessageFormatEnumType +{ + ASCII, + HTML, + URI, + UTF8, +}; + +/** @brief Helper to convert a MessageFormatEnumType enum to string */ +extern const EnumToStringFromString MessageFormatEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_MESSAGEFORMATENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/MessageInfoType20.cpp b/src/ocpp20/types/MessageInfoType20.cpp new file mode 100644 index 00000000..5957e9d4 --- /dev/null +++ b/src/ocpp20/types/MessageInfoType20.cpp @@ -0,0 +1,148 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:NotifyDisplayMessagesRequest + OCPP 2.0.1 FINAL +*/ + +#include "MessageInfoType20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Convert a MessageInfoType from a JSON representation */ +bool MessageInfoTypeConverter::fromJson(const rapidjson::Value& json, + MessageInfoType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // display + if (json.HasMember("display")) + { + ComponentTypeConverter display_converter; + ret = ret && display_converter.fromJson(json["display"], data.display, error_code, error_message); + } + + // id + extract(json, "id", data.id); + + // priority + data.priority = MessagePriorityEnumTypeHelper.fromString(json["priority"].GetString()); + + // state + if (json.HasMember("state")) + { + data.state = MessageStateEnumTypeHelper.fromString(json["state"].GetString()); + } + + // startDateTime + ret = ret && extract(json, "startDateTime", data.startDateTime, error_message); + + // endDateTime + ret = ret && extract(json, "endDateTime", data.endDateTime, error_message); + + // transactionId + extract(json, "transactionId", data.transactionId); + + // message + MessageContentTypeConverter message_converter; + ret = ret && message_converter.fromJson(json["message"], data.message, error_code, error_message); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a MessageInfoType to a JSON representation */ +bool MessageInfoTypeConverter::toJson(const MessageInfoType& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // display + if (data.display.isSet()) + { + ComponentTypeConverter display_converter; + display_converter.setAllocator(allocator); + rapidjson::Document display_doc(rapidjson::kObjectType); + ret = ret && display_converter.toJson(data.display, display_doc); + json.AddMember(rapidjson::StringRef("display"), display_doc.Move(), *allocator); + } + + // id + fill(json, "id", data.id); + + // priority + fill(json, "priority", MessagePriorityEnumTypeHelper.toString(data.priority)); + + // state + if (data.state.isSet()) + { + fill(json, "state", MessageStateEnumTypeHelper.toString(data.state)); + } + + // startDateTime + fill(json, "startDateTime", data.startDateTime); + + // endDateTime + fill(json, "endDateTime", data.endDateTime); + + // transactionId + fill(json, "transactionId", data.transactionId); + + // message + MessageContentTypeConverter message_converter; + message_converter.setAllocator(allocator); + rapidjson::Document message_doc(rapidjson::kObjectType); + ret = ret && message_converter.toJson(data.message, message_doc); + json.AddMember(rapidjson::StringRef("message"), message_doc.Move(), *allocator); + + return ret; +} + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/MessageInfoType20.h b/src/ocpp20/types/MessageInfoType20.h new file mode 100644 index 00000000..34eac907 --- /dev/null +++ b/src/ocpp20/types/MessageInfoType20.h @@ -0,0 +1,100 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:NotifyDisplayMessagesRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_MESSAGEINFOTYPE_H +#define OPENOCPP_OCPP20_MESSAGEINFOTYPE_H + +#include "ComponentType20.h" +#include "CustomDataType20.h" +#include "MessageContentType20.h" +#include "MessagePriorityEnumType20.h" +#include "MessageStateEnumType20.h" + +#include "CiStringType.h" +#include "DateTime.h" +#include "IMessageConverter.h" +#include "Optional.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Message_ Info +urn:x-enexis:ecdm:uid:2:233264 +Contains message details, for a message to be displayed on a Charging Station. + */ +struct MessageInfoType +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::Optional display; + /** @brief Identified_ Object. MRID. Numeric_ Identifier +urn:x-enexis:ecdm:uid:1:569198 +Master resource identifier, unique within an exchange context. It is defined within the OCPP context as a positive Integer value (greater or equal to zero). */ + int id; + /** @brief */ + MessagePriorityEnumType priority; + /** @brief */ + ocpp::types::Optional state; + /** @brief Message_ Info. Start. Date_ Time +urn:x-enexis:ecdm:uid:1:569256 +From what date-time should this message be shown. If omitted: directly. */ + ocpp::types::Optional startDateTime; + /** @brief Message_ Info. End. Date_ Time +urn:x-enexis:ecdm:uid:1:569257 +Until what date-time should this message be shown, after this date/time this message SHALL be removed. */ + ocpp::types::Optional endDateTime; + /** @brief During which transaction shall this message be shown. +Message SHALL be removed by the Charging Station after transaction has +ended. */ + ocpp::types::Optional> transactionId; + /** @brief */ + MessageContentType message; +}; + +/** @brief Converter class for MessageInfoType type */ +class MessageInfoTypeConverter : public ocpp::messages::IMessageConverter +{ + public: + /** @brief Clone the converter */ + ocpp::messages::IMessageConverter* clone() const override { return new MessageInfoTypeConverter(); } + + /** @brief Convert a MessageInfoType from a JSON representation */ + bool fromJson(const rapidjson::Value& json, + MessageInfoType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) override; + + /** @brief Convert a MessageInfoType to a JSON representation */ + bool toJson(const MessageInfoType& data, rapidjson::Document& json) override; +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_MESSAGEINFOTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/MessagePriorityEnumType20.cpp b/src/ocpp20/types/MessagePriorityEnumType20.cpp new file mode 100644 index 00000000..3b10e49d --- /dev/null +++ b/src/ocpp20/types/MessagePriorityEnumType20.cpp @@ -0,0 +1,42 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:NotifyDisplayMessagesRequest + OCPP 2.0.1 FINAL +*/ + +#include "MessagePriorityEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a MessagePriorityEnumType enum to string */ +const EnumToStringFromString MessagePriorityEnumTypeHelper = { + {MessagePriorityEnumType::AlwaysFront, "AlwaysFront"}, + {MessagePriorityEnumType::InFront, "InFront"}, + {MessagePriorityEnumType::NormalCycle, "NormalCycle"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/MessagePriorityEnumType20.h b/src/ocpp20/types/MessagePriorityEnumType20.h new file mode 100644 index 00000000..c1aea26b --- /dev/null +++ b/src/ocpp20/types/MessagePriorityEnumType20.h @@ -0,0 +1,53 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:NotifyDisplayMessagesRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_MESSAGEPRIORITYENUMTYPE_H +#define OPENOCPP_OCPP20_MESSAGEPRIORITYENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Message_ Info. Priority. Message_ Priority_ Code +urn:x-enexis:ecdm:uid:1:569253 +With what priority should this message be shown */ +enum class MessagePriorityEnumType +{ + AlwaysFront, + InFront, + NormalCycle, +}; + +/** @brief Helper to convert a MessagePriorityEnumType enum to string */ +extern const EnumToStringFromString MessagePriorityEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_MESSAGEPRIORITYENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/MessageStateEnumType20.cpp b/src/ocpp20/types/MessageStateEnumType20.cpp new file mode 100644 index 00000000..5b1cd64b --- /dev/null +++ b/src/ocpp20/types/MessageStateEnumType20.cpp @@ -0,0 +1,43 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:NotifyDisplayMessagesRequest + OCPP 2.0.1 FINAL +*/ + +#include "MessageStateEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a MessageStateEnumType enum to string */ +const EnumToStringFromString MessageStateEnumTypeHelper = { + {MessageStateEnumType::Charging, "Charging"}, + {MessageStateEnumType::Faulted, "Faulted"}, + {MessageStateEnumType::Idle, "Idle"}, + {MessageStateEnumType::Unavailable, "Unavailable"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/MessageStateEnumType20.h b/src/ocpp20/types/MessageStateEnumType20.h new file mode 100644 index 00000000..b7a4f217 --- /dev/null +++ b/src/ocpp20/types/MessageStateEnumType20.h @@ -0,0 +1,54 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:NotifyDisplayMessagesRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_MESSAGESTATEENUMTYPE_H +#define OPENOCPP_OCPP20_MESSAGESTATEENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Message_ Info. State. Message_ State_ Code +urn:x-enexis:ecdm:uid:1:569254 +During what state should this message be shown. When omitted this message should be shown in any state of the Charging Station. */ +enum class MessageStateEnumType +{ + Charging, + Faulted, + Idle, + Unavailable, +}; + +/** @brief Helper to convert a MessageStateEnumType enum to string */ +extern const EnumToStringFromString MessageStateEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_MESSAGESTATEENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/MessageTriggerEnumType20.cpp b/src/ocpp20/types/MessageTriggerEnumType20.cpp new file mode 100644 index 00000000..f36948f6 --- /dev/null +++ b/src/ocpp20/types/MessageTriggerEnumType20.cpp @@ -0,0 +1,50 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:TriggerMessageRequest + OCPP 2.0.1 FINAL +*/ + +#include "MessageTriggerEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a MessageTriggerEnumType enum to string */ +const EnumToStringFromString MessageTriggerEnumTypeHelper = { + {MessageTriggerEnumType::BootNotification, "BootNotification"}, + {MessageTriggerEnumType::LogStatusNotification, "LogStatusNotification"}, + {MessageTriggerEnumType::FirmwareStatusNotification, "FirmwareStatusNotification"}, + {MessageTriggerEnumType::Heartbeat, "Heartbeat"}, + {MessageTriggerEnumType::MeterValues, "MeterValues"}, + {MessageTriggerEnumType::SignChargingStationCertificate, "SignChargingStationCertificate"}, + {MessageTriggerEnumType::SignV2GCertificate, "SignV2GCertificate"}, + {MessageTriggerEnumType::StatusNotification, "StatusNotification"}, + {MessageTriggerEnumType::TransactionEvent, "TransactionEvent"}, + {MessageTriggerEnumType::SignCombinedCertificate, "SignCombinedCertificate"}, + {MessageTriggerEnumType::PublishFirmwareStatusNotification, "PublishFirmwareStatusNotification"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/MessageTriggerEnumType20.h b/src/ocpp20/types/MessageTriggerEnumType20.h new file mode 100644 index 00000000..13682c00 --- /dev/null +++ b/src/ocpp20/types/MessageTriggerEnumType20.h @@ -0,0 +1,59 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:TriggerMessageRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_MESSAGETRIGGERENUMTYPE_H +#define OPENOCPP_OCPP20_MESSAGETRIGGERENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Type of message to be triggered. */ +enum class MessageTriggerEnumType +{ + BootNotification, + LogStatusNotification, + FirmwareStatusNotification, + Heartbeat, + MeterValues, + SignChargingStationCertificate, + SignV2GCertificate, + StatusNotification, + TransactionEvent, + SignCombinedCertificate, + PublishFirmwareStatusNotification, +}; + +/** @brief Helper to convert a MessageTriggerEnumType enum to string */ +extern const EnumToStringFromString MessageTriggerEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_MESSAGETRIGGERENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/MeterValueType20.cpp b/src/ocpp20/types/MeterValueType20.cpp new file mode 100644 index 00000000..94d89287 --- /dev/null +++ b/src/ocpp20/types/MeterValueType20.cpp @@ -0,0 +1,109 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:MeterValuesRequest + OCPP 2.0.1 FINAL +*/ + +#include "MeterValueType20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Convert a MeterValueType from a JSON representation */ +bool MeterValueTypeConverter::fromJson(const rapidjson::Value& json, + MeterValueType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // sampledValue + if (json.HasMember("sampledValue")) + { + const rapidjson::Value& sampledValue_json = json["sampledValue"]; + SampledValueTypeConverter sampledValue_converter; + for (auto it = sampledValue_json.Begin(); ret && (it != sampledValue_json.End()); ++it) + { + SampledValueType& item = data.sampledValue.emplace_back(); + ret = ret && sampledValue_converter.fromJson(*it, item, error_code, error_message); + } + } + + // timestamp + ret = ret && extract(json, "timestamp", data.timestamp, error_message); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a MeterValueType to a JSON representation */ +bool MeterValueTypeConverter::toJson(const MeterValueType& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // sampledValue + + rapidjson::Value sampledValue_json(rapidjson::kArrayType); + SampledValueTypeConverter sampledValue_converter; + sampledValue_converter.setAllocator(allocator); + for (const SampledValueType& item : data.sampledValue) + { + rapidjson::Document item_doc(rapidjson::kObjectType); + ret = ret && sampledValue_converter.toJson(item, item_doc); + sampledValue_json.PushBack(item_doc.Move(), *allocator); + } + json.AddMember(rapidjson::StringRef("sampledValue"), sampledValue_json.Move(), *allocator); + + // timestamp + fill(json, "timestamp", data.timestamp); + + return ret; +} + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/MeterValueType20.h b/src/ocpp20/types/MeterValueType20.h new file mode 100644 index 00000000..1ebdd467 --- /dev/null +++ b/src/ocpp20/types/MeterValueType20.h @@ -0,0 +1,79 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:MeterValuesRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_METERVALUETYPE_H +#define OPENOCPP_OCPP20_METERVALUETYPE_H + +#include "CustomDataType20.h" +#include "SampledValueType20.h" + +#include "DateTime.h" +#include "IMessageConverter.h" +#include "Optional.h" +#include + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Meter_ Value +urn:x-oca:ocpp:uid:2:233265 +Collection of one or more sampled values in MeterValuesRequest and TransactionEvent. All sampled values in a MeterValue are sampled at the same point in time. + */ +struct MeterValueType +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + std::vector sampledValue; + /** @brief Meter_ Value. Timestamp. Date_ Time +urn:x-oca:ocpp:uid:1:569259 +Timestamp for measured value(s). */ + ocpp::types::DateTime timestamp; +}; + +/** @brief Converter class for MeterValueType type */ +class MeterValueTypeConverter : public ocpp::messages::IMessageConverter +{ + public: + /** @brief Clone the converter */ + ocpp::messages::IMessageConverter* clone() const override { return new MeterValueTypeConverter(); } + + /** @brief Convert a MeterValueType from a JSON representation */ + bool fromJson(const rapidjson::Value& json, + MeterValueType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) override; + + /** @brief Convert a MeterValueType to a JSON representation */ + bool toJson(const MeterValueType& data, rapidjson::Document& json) override; +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_METERVALUETYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/ModemType20.cpp b/src/ocpp20/types/ModemType20.cpp new file mode 100644 index 00000000..b891e4a9 --- /dev/null +++ b/src/ocpp20/types/ModemType20.cpp @@ -0,0 +1,90 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:BootNotificationRequest + OCPP 2.0.1 FINAL +*/ + +#include "ModemType20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Convert a ModemType from a JSON representation */ +bool ModemTypeConverter::fromJson(const rapidjson::Value& json, + ModemType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // iccid + extract(json, "iccid", data.iccid); + + // imsi + extract(json, "imsi", data.imsi); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a ModemType to a JSON representation */ +bool ModemTypeConverter::toJson(const ModemType& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // iccid + fill(json, "iccid", data.iccid); + + // imsi + fill(json, "imsi", data.imsi); + + return ret; +} + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/ModemType20.h b/src/ocpp20/types/ModemType20.h new file mode 100644 index 00000000..98b44f7a --- /dev/null +++ b/src/ocpp20/types/ModemType20.h @@ -0,0 +1,79 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:BootNotificationRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_MODEMTYPE_H +#define OPENOCPP_OCPP20_MODEMTYPE_H + +#include "CustomDataType20.h" + +#include "CiStringType.h" +#include "IMessageConverter.h" +#include "Optional.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Wireless_ Communication_ Module +urn:x-oca:ocpp:uid:2:233306 +Defines parameters required for initiating and maintaining wireless communication with other devices. + */ +struct ModemType +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief Wireless_ Communication_ Module. ICCID. CI20_ Text +urn:x-oca:ocpp:uid:1:569327 +This contains the ICCID of the modem’s SIM card. */ + ocpp::types::Optional> iccid; + /** @brief Wireless_ Communication_ Module. IMSI. CI20_ Text +urn:x-oca:ocpp:uid:1:569328 +This contains the IMSI of the modem’s SIM card. */ + ocpp::types::Optional> imsi; +}; + +/** @brief Converter class for ModemType type */ +class ModemTypeConverter : public ocpp::messages::IMessageConverter +{ + public: + /** @brief Clone the converter */ + ocpp::messages::IMessageConverter* clone() const override { return new ModemTypeConverter(); } + + /** @brief Convert a ModemType from a JSON representation */ + bool fromJson(const rapidjson::Value& json, + ModemType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) override; + + /** @brief Convert a ModemType to a JSON representation */ + bool toJson(const ModemType& data, rapidjson::Document& json) override; +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_MODEMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/MonitorEnumType20.cpp b/src/ocpp20/types/MonitorEnumType20.cpp new file mode 100644 index 00000000..49c55a64 --- /dev/null +++ b/src/ocpp20/types/MonitorEnumType20.cpp @@ -0,0 +1,44 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SetVariableMonitoringRequest + OCPP 2.0.1 FINAL +*/ + +#include "MonitorEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a MonitorEnumType enum to string */ +const EnumToStringFromString MonitorEnumTypeHelper = { + {MonitorEnumType::UpperThreshold, "UpperThreshold"}, + {MonitorEnumType::LowerThreshold, "LowerThreshold"}, + {MonitorEnumType::Delta, "Delta"}, + {MonitorEnumType::Periodic, "Periodic"}, + {MonitorEnumType::PeriodicClockAligned, "PeriodicClockAligned"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/MonitorEnumType20.h b/src/ocpp20/types/MonitorEnumType20.h new file mode 100644 index 00000000..d6434eb2 --- /dev/null +++ b/src/ocpp20/types/MonitorEnumType20.h @@ -0,0 +1,53 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SetVariableMonitoringRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_MONITORENUMTYPE_H +#define OPENOCPP_OCPP20_MONITORENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief The type of this monitor, e.g. a threshold, delta or periodic monitor. */ +enum class MonitorEnumType +{ + UpperThreshold, + LowerThreshold, + Delta, + Periodic, + PeriodicClockAligned, +}; + +/** @brief Helper to convert a MonitorEnumType enum to string */ +extern const EnumToStringFromString MonitorEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_MONITORENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/MonitoringBaseEnumType20.cpp b/src/ocpp20/types/MonitoringBaseEnumType20.cpp new file mode 100644 index 00000000..e88413f3 --- /dev/null +++ b/src/ocpp20/types/MonitoringBaseEnumType20.cpp @@ -0,0 +1,42 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SetMonitoringBaseRequest + OCPP 2.0.1 FINAL +*/ + +#include "MonitoringBaseEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a MonitoringBaseEnumType enum to string */ +const EnumToStringFromString MonitoringBaseEnumTypeHelper = { + {MonitoringBaseEnumType::All, "All"}, + {MonitoringBaseEnumType::FactoryDefault, "FactoryDefault"}, + {MonitoringBaseEnumType::HardWiredOnly, "HardWiredOnly"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/MonitoringBaseEnumType20.h b/src/ocpp20/types/MonitoringBaseEnumType20.h new file mode 100644 index 00000000..f49c7f1c --- /dev/null +++ b/src/ocpp20/types/MonitoringBaseEnumType20.h @@ -0,0 +1,51 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SetMonitoringBaseRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_MONITORINGBASEENUMTYPE_H +#define OPENOCPP_OCPP20_MONITORINGBASEENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Specify which monitoring base will be set */ +enum class MonitoringBaseEnumType +{ + All, + FactoryDefault, + HardWiredOnly, +}; + +/** @brief Helper to convert a MonitoringBaseEnumType enum to string */ +extern const EnumToStringFromString MonitoringBaseEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_MONITORINGBASEENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/MonitoringCriterionEnumType20.cpp b/src/ocpp20/types/MonitoringCriterionEnumType20.cpp new file mode 100644 index 00000000..38100759 --- /dev/null +++ b/src/ocpp20/types/MonitoringCriterionEnumType20.cpp @@ -0,0 +1,42 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetMonitoringReportRequest + OCPP 2.0.1 FINAL +*/ + +#include "MonitoringCriterionEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a MonitoringCriterionEnumType enum to string */ +const EnumToStringFromString MonitoringCriterionEnumTypeHelper = { + {MonitoringCriterionEnumType::ThresholdMonitoring, "ThresholdMonitoring"}, + {MonitoringCriterionEnumType::DeltaMonitoring, "DeltaMonitoring"}, + {MonitoringCriterionEnumType::PeriodicMonitoring, "PeriodicMonitoring"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/MonitoringCriterionEnumType20.h b/src/ocpp20/types/MonitoringCriterionEnumType20.h new file mode 100644 index 00000000..24710bc0 --- /dev/null +++ b/src/ocpp20/types/MonitoringCriterionEnumType20.h @@ -0,0 +1,51 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetMonitoringReportRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_MONITORINGCRITERIONENUMTYPE_H +#define OPENOCPP_OCPP20_MONITORINGCRITERIONENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief */ +enum class MonitoringCriterionEnumType +{ + ThresholdMonitoring, + DeltaMonitoring, + PeriodicMonitoring, +}; + +/** @brief Helper to convert a MonitoringCriterionEnumType enum to string */ +extern const EnumToStringFromString MonitoringCriterionEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_MONITORINGCRITERIONENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/MonitoringDataType20.cpp b/src/ocpp20/types/MonitoringDataType20.cpp new file mode 100644 index 00000000..35067dda --- /dev/null +++ b/src/ocpp20/types/MonitoringDataType20.cpp @@ -0,0 +1,125 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:NotifyMonitoringReportRequest + OCPP 2.0.1 FINAL +*/ + +#include "MonitoringDataType20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Convert a MonitoringDataType from a JSON representation */ +bool MonitoringDataTypeConverter::fromJson(const rapidjson::Value& json, + MonitoringDataType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // component + ComponentTypeConverter component_converter; + ret = ret && component_converter.fromJson(json["component"], data.component, error_code, error_message); + + // variable + VariableTypeConverter variable_converter; + ret = ret && variable_converter.fromJson(json["variable"], data.variable, error_code, error_message); + + // variableMonitoring + if (json.HasMember("variableMonitoring")) + { + const rapidjson::Value& variableMonitoring_json = json["variableMonitoring"]; + VariableMonitoringTypeConverter variableMonitoring_converter; + for (auto it = variableMonitoring_json.Begin(); ret && (it != variableMonitoring_json.End()); ++it) + { + VariableMonitoringType& item = data.variableMonitoring.emplace_back(); + ret = ret && variableMonitoring_converter.fromJson(*it, item, error_code, error_message); + } + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a MonitoringDataType to a JSON representation */ +bool MonitoringDataTypeConverter::toJson(const MonitoringDataType& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // component + ComponentTypeConverter component_converter; + component_converter.setAllocator(allocator); + rapidjson::Document component_doc(rapidjson::kObjectType); + ret = ret && component_converter.toJson(data.component, component_doc); + json.AddMember(rapidjson::StringRef("component"), component_doc.Move(), *allocator); + + // variable + VariableTypeConverter variable_converter; + variable_converter.setAllocator(allocator); + rapidjson::Document variable_doc(rapidjson::kObjectType); + ret = ret && variable_converter.toJson(data.variable, variable_doc); + json.AddMember(rapidjson::StringRef("variable"), variable_doc.Move(), *allocator); + + // variableMonitoring + + rapidjson::Value variableMonitoring_json(rapidjson::kArrayType); + VariableMonitoringTypeConverter variableMonitoring_converter; + variableMonitoring_converter.setAllocator(allocator); + for (const VariableMonitoringType& item : data.variableMonitoring) + { + rapidjson::Document item_doc(rapidjson::kObjectType); + ret = ret && variableMonitoring_converter.toJson(item, item_doc); + variableMonitoring_json.PushBack(item_doc.Move(), *allocator); + } + json.AddMember(rapidjson::StringRef("variableMonitoring"), variableMonitoring_json.Move(), *allocator); + + return ret; +} + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/MonitoringDataType20.h b/src/ocpp20/types/MonitoringDataType20.h new file mode 100644 index 00000000..2e685990 --- /dev/null +++ b/src/ocpp20/types/MonitoringDataType20.h @@ -0,0 +1,78 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:NotifyMonitoringReportRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_MONITORINGDATATYPE_H +#define OPENOCPP_OCPP20_MONITORINGDATATYPE_H + +#include "ComponentType20.h" +#include "CustomDataType20.h" +#include "VariableMonitoringType20.h" +#include "VariableType20.h" + +#include "IMessageConverter.h" +#include "Optional.h" +#include + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Class to hold parameters of SetVariableMonitoring request. + */ +struct MonitoringDataType +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ComponentType component; + /** @brief */ + VariableType variable; + /** @brief */ + std::vector variableMonitoring; +}; + +/** @brief Converter class for MonitoringDataType type */ +class MonitoringDataTypeConverter : public ocpp::messages::IMessageConverter +{ + public: + /** @brief Clone the converter */ + ocpp::messages::IMessageConverter* clone() const override { return new MonitoringDataTypeConverter(); } + + /** @brief Convert a MonitoringDataType from a JSON representation */ + bool fromJson(const rapidjson::Value& json, + MonitoringDataType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) override; + + /** @brief Convert a MonitoringDataType to a JSON representation */ + bool toJson(const MonitoringDataType& data, rapidjson::Document& json) override; +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_MONITORINGDATATYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/MutabilityEnumType20.cpp b/src/ocpp20/types/MutabilityEnumType20.cpp new file mode 100644 index 00000000..2c96b4bd --- /dev/null +++ b/src/ocpp20/types/MutabilityEnumType20.cpp @@ -0,0 +1,42 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:NotifyReportRequest + OCPP 2.0.1 FINAL +*/ + +#include "MutabilityEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a MutabilityEnumType enum to string */ +const EnumToStringFromString MutabilityEnumTypeHelper = { + {MutabilityEnumType::ReadOnly, "ReadOnly"}, + {MutabilityEnumType::WriteOnly, "WriteOnly"}, + {MutabilityEnumType::ReadWrite, "ReadWrite"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/MutabilityEnumType20.h b/src/ocpp20/types/MutabilityEnumType20.h new file mode 100644 index 00000000..6a11e822 --- /dev/null +++ b/src/ocpp20/types/MutabilityEnumType20.h @@ -0,0 +1,51 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:NotifyReportRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_MUTABILITYENUMTYPE_H +#define OPENOCPP_OCPP20_MUTABILITYENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Defines the mutability of this attribute. Default is ReadWrite when omitted. */ +enum class MutabilityEnumType +{ + ReadOnly, + WriteOnly, + ReadWrite, +}; + +/** @brief Helper to convert a MutabilityEnumType enum to string */ +extern const EnumToStringFromString MutabilityEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_MUTABILITYENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/NetworkConnectionProfileType20.cpp b/src/ocpp20/types/NetworkConnectionProfileType20.cpp new file mode 100644 index 00000000..c3d66047 --- /dev/null +++ b/src/ocpp20/types/NetworkConnectionProfileType20.cpp @@ -0,0 +1,148 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SetNetworkProfileRequest + OCPP 2.0.1 FINAL +*/ + +#include "NetworkConnectionProfileType20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Convert a NetworkConnectionProfileType from a JSON representation */ +bool NetworkConnectionProfileTypeConverter::fromJson(const rapidjson::Value& json, + NetworkConnectionProfileType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // apn + if (json.HasMember("apn")) + { + APNTypeConverter apn_converter; + ret = ret && apn_converter.fromJson(json["apn"], data.apn, error_code, error_message); + } + + // ocppVersion + data.ocppVersion = OCPPVersionEnumTypeHelper.fromString(json["ocppVersion"].GetString()); + + // ocppTransport + data.ocppTransport = OCPPTransportEnumTypeHelper.fromString(json["ocppTransport"].GetString()); + + // ocppCsmsUrl + extract(json, "ocppCsmsUrl", data.ocppCsmsUrl); + + // messageTimeout + extract(json, "messageTimeout", data.messageTimeout); + + // securityProfile + extract(json, "securityProfile", data.securityProfile); + + // ocppInterface + data.ocppInterface = OCPPInterfaceEnumTypeHelper.fromString(json["ocppInterface"].GetString()); + + // vpn + if (json.HasMember("vpn")) + { + VPNTypeConverter vpn_converter; + ret = ret && vpn_converter.fromJson(json["vpn"], data.vpn, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a NetworkConnectionProfileType to a JSON representation */ +bool NetworkConnectionProfileTypeConverter::toJson(const NetworkConnectionProfileType& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // apn + if (data.apn.isSet()) + { + APNTypeConverter apn_converter; + apn_converter.setAllocator(allocator); + rapidjson::Document apn_doc(rapidjson::kObjectType); + ret = ret && apn_converter.toJson(data.apn, apn_doc); + json.AddMember(rapidjson::StringRef("apn"), apn_doc.Move(), *allocator); + } + + // ocppVersion + fill(json, "ocppVersion", OCPPVersionEnumTypeHelper.toString(data.ocppVersion)); + + // ocppTransport + fill(json, "ocppTransport", OCPPTransportEnumTypeHelper.toString(data.ocppTransport)); + + // ocppCsmsUrl + fill(json, "ocppCsmsUrl", data.ocppCsmsUrl); + + // messageTimeout + fill(json, "messageTimeout", data.messageTimeout); + + // securityProfile + fill(json, "securityProfile", data.securityProfile); + + // ocppInterface + fill(json, "ocppInterface", OCPPInterfaceEnumTypeHelper.toString(data.ocppInterface)); + + // vpn + if (data.vpn.isSet()) + { + VPNTypeConverter vpn_converter; + vpn_converter.setAllocator(allocator); + rapidjson::Document vpn_doc(rapidjson::kObjectType); + ret = ret && vpn_converter.toJson(data.vpn, vpn_doc); + json.AddMember(rapidjson::StringRef("vpn"), vpn_doc.Move(), *allocator); + } + + return ret; +} + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/NetworkConnectionProfileType20.h b/src/ocpp20/types/NetworkConnectionProfileType20.h new file mode 100644 index 00000000..03fbed00 --- /dev/null +++ b/src/ocpp20/types/NetworkConnectionProfileType20.h @@ -0,0 +1,99 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SetNetworkProfileRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_NETWORKCONNECTIONPROFILETYPE_H +#define OPENOCPP_OCPP20_NETWORKCONNECTIONPROFILETYPE_H + +#include "APNType20.h" +#include "CustomDataType20.h" +#include "OCPPInterfaceEnumType20.h" +#include "OCPPTransportEnumType20.h" +#include "OCPPVersionEnumType20.h" +#include "VPNType20.h" + +#include "CiStringType.h" +#include "IMessageConverter.h" +#include "Optional.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Communication_ Function +urn:x-oca:ocpp:uid:2:233304 +The NetworkConnectionProfile defines the functional and technical parameters of a communication link. + */ +struct NetworkConnectionProfileType +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::Optional apn; + /** @brief */ + OCPPVersionEnumType ocppVersion; + /** @brief */ + OCPPTransportEnumType ocppTransport; + /** @brief Communication_ Function. OCPP_ Central_ System_ URL. URI +urn:x-oca:ocpp:uid:1:569357 +URL of the CSMS(s) that this Charging Station communicates with. */ + ocpp::types::CiStringType<512u> ocppCsmsUrl; + /** @brief Duration in seconds before a message send by the Charging Station via this network connection times-out. +The best setting depends on the underlying network and response times of the CSMS. +If you are looking for a some guideline: use 30 seconds as a starting point. */ + int messageTimeout; + /** @brief This field specifies the security profile used when connecting to the CSMS with this NetworkConnectionProfile. */ + int securityProfile; + /** @brief */ + OCPPInterfaceEnumType ocppInterface; + /** @brief */ + ocpp::types::Optional vpn; +}; + +/** @brief Converter class for NetworkConnectionProfileType type */ +class NetworkConnectionProfileTypeConverter : public ocpp::messages::IMessageConverter +{ + public: + /** @brief Clone the converter */ + ocpp::messages::IMessageConverter* clone() const override + { + return new NetworkConnectionProfileTypeConverter(); + } + + /** @brief Convert a NetworkConnectionProfileType from a JSON representation */ + bool fromJson(const rapidjson::Value& json, + NetworkConnectionProfileType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) override; + + /** @brief Convert a NetworkConnectionProfileType to a JSON representation */ + bool toJson(const NetworkConnectionProfileType& data, rapidjson::Document& json) override; +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_NETWORKCONNECTIONPROFILETYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/NotifyEVChargingNeedsStatusEnumType20.cpp b/src/ocpp20/types/NotifyEVChargingNeedsStatusEnumType20.cpp new file mode 100644 index 00000000..a8e35cfa --- /dev/null +++ b/src/ocpp20/types/NotifyEVChargingNeedsStatusEnumType20.cpp @@ -0,0 +1,42 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:NotifyEVChargingNeedsRequest + OCPP 2.0.1 FINAL +*/ + +#include "NotifyEVChargingNeedsStatusEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a NotifyEVChargingNeedsStatusEnumType enum to string */ +const EnumToStringFromString NotifyEVChargingNeedsStatusEnumTypeHelper = { + {NotifyEVChargingNeedsStatusEnumType::Accepted, "Accepted"}, + {NotifyEVChargingNeedsStatusEnumType::Rejected, "Rejected"}, + {NotifyEVChargingNeedsStatusEnumType::Processing, "Processing"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/NotifyEVChargingNeedsStatusEnumType20.h b/src/ocpp20/types/NotifyEVChargingNeedsStatusEnumType20.h new file mode 100644 index 00000000..b5e36b58 --- /dev/null +++ b/src/ocpp20/types/NotifyEVChargingNeedsStatusEnumType20.h @@ -0,0 +1,51 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:NotifyEVChargingNeedsRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_NOTIFYEVCHARGINGNEEDSSTATUSENUMTYPE_H +#define OPENOCPP_OCPP20_NOTIFYEVCHARGINGNEEDSSTATUSENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Returns whether the CSMS has been able to process the message successfully. It does not imply that the evChargingNeeds can be met with the current charging profile. */ +enum class NotifyEVChargingNeedsStatusEnumType +{ + Accepted, + Rejected, + Processing, +}; + +/** @brief Helper to convert a NotifyEVChargingNeedsStatusEnumType enum to string */ +extern const EnumToStringFromString NotifyEVChargingNeedsStatusEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_NOTIFYEVCHARGINGNEEDSSTATUSENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/OCPPInterfaceEnumType20.cpp b/src/ocpp20/types/OCPPInterfaceEnumType20.cpp new file mode 100644 index 00000000..e601b3a3 --- /dev/null +++ b/src/ocpp20/types/OCPPInterfaceEnumType20.cpp @@ -0,0 +1,47 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SetNetworkProfileRequest + OCPP 2.0.1 FINAL +*/ + +#include "OCPPInterfaceEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a OCPPInterfaceEnumType enum to string */ +const EnumToStringFromString OCPPInterfaceEnumTypeHelper = { + {OCPPInterfaceEnumType::Wired0, "Wired0"}, + {OCPPInterfaceEnumType::Wired1, "Wired1"}, + {OCPPInterfaceEnumType::Wired2, "Wired2"}, + {OCPPInterfaceEnumType::Wired3, "Wired3"}, + {OCPPInterfaceEnumType::Wireless0, "Wireless0"}, + {OCPPInterfaceEnumType::Wireless1, "Wireless1"}, + {OCPPInterfaceEnumType::Wireless2, "Wireless2"}, + {OCPPInterfaceEnumType::Wireless3, "Wireless3"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/OCPPInterfaceEnumType20.h b/src/ocpp20/types/OCPPInterfaceEnumType20.h new file mode 100644 index 00000000..44ec57ad --- /dev/null +++ b/src/ocpp20/types/OCPPInterfaceEnumType20.h @@ -0,0 +1,56 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SetNetworkProfileRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_OCPPINTERFACEENUMTYPE_H +#define OPENOCPP_OCPP20_OCPPINTERFACEENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Applicable Network Interface. */ +enum class OCPPInterfaceEnumType +{ + Wired0, + Wired1, + Wired2, + Wired3, + Wireless0, + Wireless1, + Wireless2, + Wireless3, +}; + +/** @brief Helper to convert a OCPPInterfaceEnumType enum to string */ +extern const EnumToStringFromString OCPPInterfaceEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_OCPPINTERFACEENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/OCPPTransportEnumType20.cpp b/src/ocpp20/types/OCPPTransportEnumType20.cpp new file mode 100644 index 00000000..05485415 --- /dev/null +++ b/src/ocpp20/types/OCPPTransportEnumType20.cpp @@ -0,0 +1,41 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SetNetworkProfileRequest + OCPP 2.0.1 FINAL +*/ + +#include "OCPPTransportEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a OCPPTransportEnumType enum to string */ +const EnumToStringFromString OCPPTransportEnumTypeHelper = { + {OCPPTransportEnumType::JSON, "JSON"}, + {OCPPTransportEnumType::SOAP, "SOAP"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/OCPPTransportEnumType20.h b/src/ocpp20/types/OCPPTransportEnumType20.h new file mode 100644 index 00000000..6ab1776b --- /dev/null +++ b/src/ocpp20/types/OCPPTransportEnumType20.h @@ -0,0 +1,52 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SetNetworkProfileRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_OCPPTRANSPORTENUMTYPE_H +#define OPENOCPP_OCPP20_OCPPTRANSPORTENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Communication_ Function. OCPP_ Transport. OCPP_ Transport_ Code +urn:x-oca:ocpp:uid:1:569356 +Defines the transport protocol (e.g. SOAP or JSON). Note: SOAP is not supported in OCPP 2.0, but is supported by other versions of OCPP. */ +enum class OCPPTransportEnumType +{ + JSON, + SOAP, +}; + +/** @brief Helper to convert a OCPPTransportEnumType enum to string */ +extern const EnumToStringFromString OCPPTransportEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_OCPPTRANSPORTENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/OCPPVersionEnumType20.cpp b/src/ocpp20/types/OCPPVersionEnumType20.cpp new file mode 100644 index 00000000..1717a53d --- /dev/null +++ b/src/ocpp20/types/OCPPVersionEnumType20.cpp @@ -0,0 +1,43 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SetNetworkProfileRequest + OCPP 2.0.1 FINAL +*/ + +#include "OCPPVersionEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a OCPPVersionEnumType enum to string */ +const EnumToStringFromString OCPPVersionEnumTypeHelper = { + {OCPPVersionEnumType::OCPP12, "OCPP12"}, + {OCPPVersionEnumType::OCPP15, "OCPP15"}, + {OCPPVersionEnumType::OCPP16, "OCPP16"}, + {OCPPVersionEnumType::OCPP20, "OCPP20"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/OCPPVersionEnumType20.h b/src/ocpp20/types/OCPPVersionEnumType20.h new file mode 100644 index 00000000..dbcfe11c --- /dev/null +++ b/src/ocpp20/types/OCPPVersionEnumType20.h @@ -0,0 +1,54 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SetNetworkProfileRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_OCPPVERSIONENUMTYPE_H +#define OPENOCPP_OCPP20_OCPPVERSIONENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Communication_ Function. OCPP_ Version. OCPP_ Version_ Code +urn:x-oca:ocpp:uid:1:569355 +Defines the OCPP version used for this communication function. */ +enum class OCPPVersionEnumType +{ + OCPP12, + OCPP15, + OCPP16, + OCPP20, +}; + +/** @brief Helper to convert a OCPPVersionEnumType enum to string */ +extern const EnumToStringFromString OCPPVersionEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_OCPPVERSIONENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/OCSPRequestDataType20.cpp b/src/ocpp20/types/OCSPRequestDataType20.cpp new file mode 100644 index 00000000..e724e0f1 --- /dev/null +++ b/src/ocpp20/types/OCSPRequestDataType20.cpp @@ -0,0 +1,108 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:AuthorizeRequest + OCPP 2.0.1 FINAL +*/ + +#include "OCSPRequestDataType20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Convert a OCSPRequestDataType from a JSON representation */ +bool OCSPRequestDataTypeConverter::fromJson(const rapidjson::Value& json, + OCSPRequestDataType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // hashAlgorithm + data.hashAlgorithm = HashAlgorithmEnumTypeHelper.fromString(json["hashAlgorithm"].GetString()); + + // issuerNameHash + extract(json, "issuerNameHash", data.issuerNameHash); + + // issuerKeyHash + extract(json, "issuerKeyHash", data.issuerKeyHash); + + // serialNumber + extract(json, "serialNumber", data.serialNumber); + + // responderURL + extract(json, "responderURL", data.responderURL); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a OCSPRequestDataType to a JSON representation */ +bool OCSPRequestDataTypeConverter::toJson(const OCSPRequestDataType& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // hashAlgorithm + fill(json, "hashAlgorithm", HashAlgorithmEnumTypeHelper.toString(data.hashAlgorithm)); + + // issuerNameHash + fill(json, "issuerNameHash", data.issuerNameHash); + + // issuerKeyHash + fill(json, "issuerKeyHash", data.issuerKeyHash); + + // serialNumber + fill(json, "serialNumber", data.serialNumber); + + // responderURL + fill(json, "responderURL", data.responderURL); + + return ret; +} + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/OCSPRequestDataType20.h b/src/ocpp20/types/OCSPRequestDataType20.h new file mode 100644 index 00000000..9eb4dc14 --- /dev/null +++ b/src/ocpp20/types/OCSPRequestDataType20.h @@ -0,0 +1,79 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:AuthorizeRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_OCSPREQUESTDATATYPE_H +#define OPENOCPP_OCPP20_OCSPREQUESTDATATYPE_H + +#include "CustomDataType20.h" +#include "HashAlgorithmEnumType20.h" + +#include "CiStringType.h" +#include "IMessageConverter.h" +#include "Optional.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief */ +struct OCSPRequestDataType +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + HashAlgorithmEnumType hashAlgorithm; + /** @brief Hashed value of the Issuer DN (Distinguished Name). */ + ocpp::types::CiStringType<128u> issuerNameHash; + /** @brief Hashed value of the issuers public key */ + ocpp::types::CiStringType<128u> issuerKeyHash; + /** @brief The serial number of the certificate. */ + ocpp::types::CiStringType<40u> serialNumber; + /** @brief This contains the responder URL (Case insensitive). */ + ocpp::types::CiStringType<512u> responderURL; +}; + +/** @brief Converter class for OCSPRequestDataType type */ +class OCSPRequestDataTypeConverter : public ocpp::messages::IMessageConverter +{ + public: + /** @brief Clone the converter */ + ocpp::messages::IMessageConverter* clone() const override { return new OCSPRequestDataTypeConverter(); } + + /** @brief Convert a OCSPRequestDataType from a JSON representation */ + bool fromJson(const rapidjson::Value& json, + OCSPRequestDataType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) override; + + /** @brief Convert a OCSPRequestDataType to a JSON representation */ + bool toJson(const OCSPRequestDataType& data, rapidjson::Document& json) override; +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_OCSPREQUESTDATATYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/OperationalStatusEnumType20.cpp b/src/ocpp20/types/OperationalStatusEnumType20.cpp new file mode 100644 index 00000000..bbb1bbf6 --- /dev/null +++ b/src/ocpp20/types/OperationalStatusEnumType20.cpp @@ -0,0 +1,41 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:ChangeAvailabilityRequest + OCPP 2.0.1 FINAL +*/ + +#include "OperationalStatusEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a OperationalStatusEnumType enum to string */ +const EnumToStringFromString OperationalStatusEnumTypeHelper = { + {OperationalStatusEnumType::Inoperative, "Inoperative"}, + {OperationalStatusEnumType::Operative, "Operative"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/OperationalStatusEnumType20.h b/src/ocpp20/types/OperationalStatusEnumType20.h new file mode 100644 index 00000000..fbb17bfe --- /dev/null +++ b/src/ocpp20/types/OperationalStatusEnumType20.h @@ -0,0 +1,50 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:ChangeAvailabilityRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_OPERATIONALSTATUSENUMTYPE_H +#define OPENOCPP_OCPP20_OPERATIONALSTATUSENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief This contains the type of availability change that the Charging Station should perform. */ +enum class OperationalStatusEnumType +{ + Inoperative, + Operative, +}; + +/** @brief Helper to convert a OperationalStatusEnumType enum to string */ +extern const EnumToStringFromString OperationalStatusEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_OPERATIONALSTATUSENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/PhaseEnumType20.cpp b/src/ocpp20/types/PhaseEnumType20.cpp new file mode 100644 index 00000000..3a5d0863 --- /dev/null +++ b/src/ocpp20/types/PhaseEnumType20.cpp @@ -0,0 +1,49 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:MeterValuesRequest + OCPP 2.0.1 FINAL +*/ + +#include "PhaseEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a PhaseEnumType enum to string */ +const EnumToStringFromString PhaseEnumTypeHelper = { + {PhaseEnumType::L1, "L1"}, + {PhaseEnumType::L2, "L2"}, + {PhaseEnumType::L3, "L3"}, + {PhaseEnumType::N, "N"}, + {PhaseEnumType::L1_N, "L1-N"}, + {PhaseEnumType::L2_N, "L2-N"}, + {PhaseEnumType::L3_N, "L3-N"}, + {PhaseEnumType::L1_L2, "L1-L2"}, + {PhaseEnumType::L2_L3, "L2-L3"}, + {PhaseEnumType::L3_L1, "L3-L1"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/PhaseEnumType20.h b/src/ocpp20/types/PhaseEnumType20.h new file mode 100644 index 00000000..522ddb16 --- /dev/null +++ b/src/ocpp20/types/PhaseEnumType20.h @@ -0,0 +1,60 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:MeterValuesRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_PHASEENUMTYPE_H +#define OPENOCPP_OCPP20_PHASEENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Sampled_ Value. Phase. Phase_ Code +urn:x-oca:ocpp:uid:1:569264 +Indicates how the measured value is to be interpreted. For instance between L1 and neutral (L1-N) Please note that not all values of phase are applicable to all Measurands. When phase is absent, the measured value is interpreted as an overall value. */ +enum class PhaseEnumType +{ + L1, + L2, + L3, + N, + L1_N, + L2_N, + L3_N, + L1_L2, + L2_L3, + L3_L1, +}; + +/** @brief Helper to convert a PhaseEnumType enum to string */ +extern const EnumToStringFromString PhaseEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_PHASEENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/PublishFirmwareStatusEnumType20.cpp b/src/ocpp20/types/PublishFirmwareStatusEnumType20.cpp new file mode 100644 index 00000000..04bdec7e --- /dev/null +++ b/src/ocpp20/types/PublishFirmwareStatusEnumType20.cpp @@ -0,0 +1,49 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:PublishFirmwareStatusNotificationRequest + OCPP 2.0.1 FINAL +*/ + +#include "PublishFirmwareStatusEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a PublishFirmwareStatusEnumType enum to string */ +const EnumToStringFromString PublishFirmwareStatusEnumTypeHelper = { + {PublishFirmwareStatusEnumType::Idle, "Idle"}, + {PublishFirmwareStatusEnumType::DownloadScheduled, "DownloadScheduled"}, + {PublishFirmwareStatusEnumType::Downloading, "Downloading"}, + {PublishFirmwareStatusEnumType::Downloaded, "Downloaded"}, + {PublishFirmwareStatusEnumType::Published, "Published"}, + {PublishFirmwareStatusEnumType::DownloadFailed, "DownloadFailed"}, + {PublishFirmwareStatusEnumType::DownloadPaused, "DownloadPaused"}, + {PublishFirmwareStatusEnumType::InvalidChecksum, "InvalidChecksum"}, + {PublishFirmwareStatusEnumType::ChecksumVerified, "ChecksumVerified"}, + {PublishFirmwareStatusEnumType::PublishFailed, "PublishFailed"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/PublishFirmwareStatusEnumType20.h b/src/ocpp20/types/PublishFirmwareStatusEnumType20.h new file mode 100644 index 00000000..49c666ec --- /dev/null +++ b/src/ocpp20/types/PublishFirmwareStatusEnumType20.h @@ -0,0 +1,59 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:PublishFirmwareStatusNotificationRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_PUBLISHFIRMWARESTATUSENUMTYPE_H +#define OPENOCPP_OCPP20_PUBLISHFIRMWARESTATUSENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief This contains the progress status of the publishfirmware +installation. */ +enum class PublishFirmwareStatusEnumType +{ + Idle, + DownloadScheduled, + Downloading, + Downloaded, + Published, + DownloadFailed, + DownloadPaused, + InvalidChecksum, + ChecksumVerified, + PublishFailed, +}; + +/** @brief Helper to convert a PublishFirmwareStatusEnumType enum to string */ +extern const EnumToStringFromString PublishFirmwareStatusEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_PUBLISHFIRMWARESTATUSENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/ReadingContextEnumType20.cpp b/src/ocpp20/types/ReadingContextEnumType20.cpp new file mode 100644 index 00000000..88f18eb6 --- /dev/null +++ b/src/ocpp20/types/ReadingContextEnumType20.cpp @@ -0,0 +1,47 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:MeterValuesRequest + OCPP 2.0.1 FINAL +*/ + +#include "ReadingContextEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a ReadingContextEnumType enum to string */ +const EnumToStringFromString ReadingContextEnumTypeHelper = { + {ReadingContextEnumType::Interruption_Begin, "Interruption.Begin"}, + {ReadingContextEnumType::Interruption_End, "Interruption.End"}, + {ReadingContextEnumType::Other, "Other"}, + {ReadingContextEnumType::Sample_Clock, "Sample.Clock"}, + {ReadingContextEnumType::Sample_Periodic, "Sample.Periodic"}, + {ReadingContextEnumType::Transaction_Begin, "Transaction.Begin"}, + {ReadingContextEnumType::Transaction_End, "Transaction.End"}, + {ReadingContextEnumType::Trigger, "Trigger"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/ReadingContextEnumType20.h b/src/ocpp20/types/ReadingContextEnumType20.h new file mode 100644 index 00000000..bc6cf039 --- /dev/null +++ b/src/ocpp20/types/ReadingContextEnumType20.h @@ -0,0 +1,58 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:MeterValuesRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_READINGCONTEXTENUMTYPE_H +#define OPENOCPP_OCPP20_READINGCONTEXTENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Sampled_ Value. Context. Reading_ Context_ Code +urn:x-oca:ocpp:uid:1:569261 +Type of detail value: start, end or sample. Default = "Sample.Periodic" */ +enum class ReadingContextEnumType +{ + Interruption_Begin, + Interruption_End, + Other, + Sample_Clock, + Sample_Periodic, + Transaction_Begin, + Transaction_End, + Trigger, +}; + +/** @brief Helper to convert a ReadingContextEnumType enum to string */ +extern const EnumToStringFromString ReadingContextEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_READINGCONTEXTENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/ReasonEnumType20.cpp b/src/ocpp20/types/ReasonEnumType20.cpp new file mode 100644 index 00000000..925033a7 --- /dev/null +++ b/src/ocpp20/types/ReasonEnumType20.cpp @@ -0,0 +1,58 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:TransactionEventRequest + OCPP 2.0.1 FINAL +*/ + +#include "ReasonEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a ReasonEnumType enum to string */ +const EnumToStringFromString ReasonEnumTypeHelper = { + {ReasonEnumType::DeAuthorized, "DeAuthorized"}, + {ReasonEnumType::EmergencyStop, "EmergencyStop"}, + {ReasonEnumType::EnergyLimitReached, "EnergyLimitReached"}, + {ReasonEnumType::EVDisconnected, "EVDisconnected"}, + {ReasonEnumType::GroundFault, "GroundFault"}, + {ReasonEnumType::ImmediateReset, "ImmediateReset"}, + {ReasonEnumType::Local, "Local"}, + {ReasonEnumType::LocalOutOfCredit, "LocalOutOfCredit"}, + {ReasonEnumType::MasterPass, "MasterPass"}, + {ReasonEnumType::Other, "Other"}, + {ReasonEnumType::OvercurrentFault, "OvercurrentFault"}, + {ReasonEnumType::PowerLoss, "PowerLoss"}, + {ReasonEnumType::PowerQuality, "PowerQuality"}, + {ReasonEnumType::Reboot, "Reboot"}, + {ReasonEnumType::Remote, "Remote"}, + {ReasonEnumType::SOCLimitReached, "SOCLimitReached"}, + {ReasonEnumType::StoppedByEV, "StoppedByEV"}, + {ReasonEnumType::TimeLimitReached, "TimeLimitReached"}, + {ReasonEnumType::Timeout, "Timeout"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/ReasonEnumType20.h b/src/ocpp20/types/ReasonEnumType20.h new file mode 100644 index 00000000..23db83aa --- /dev/null +++ b/src/ocpp20/types/ReasonEnumType20.h @@ -0,0 +1,69 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:TransactionEventRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_REASONENUMTYPE_H +#define OPENOCPP_OCPP20_REASONENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Transaction. Stopped_ Reason. EOT_ Reason_ Code +urn:x-oca:ocpp:uid:1:569413 +This contains the reason why the transaction was stopped. MAY only be omitted when Reason is "Local". */ +enum class ReasonEnumType +{ + DeAuthorized, + EmergencyStop, + EnergyLimitReached, + EVDisconnected, + GroundFault, + ImmediateReset, + Local, + LocalOutOfCredit, + MasterPass, + Other, + OvercurrentFault, + PowerLoss, + PowerQuality, + Reboot, + Remote, + SOCLimitReached, + StoppedByEV, + TimeLimitReached, + Timeout, +}; + +/** @brief Helper to convert a ReasonEnumType enum to string */ +extern const EnumToStringFromString ReasonEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_REASONENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/RecurrencyKindEnumType20.cpp b/src/ocpp20/types/RecurrencyKindEnumType20.cpp new file mode 100644 index 00000000..0ed699df --- /dev/null +++ b/src/ocpp20/types/RecurrencyKindEnumType20.cpp @@ -0,0 +1,41 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:RequestStartTransactionRequest + OCPP 2.0.1 FINAL +*/ + +#include "RecurrencyKindEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a RecurrencyKindEnumType enum to string */ +const EnumToStringFromString RecurrencyKindEnumTypeHelper = { + {RecurrencyKindEnumType::Daily, "Daily"}, + {RecurrencyKindEnumType::Weekly, "Weekly"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/RecurrencyKindEnumType20.h b/src/ocpp20/types/RecurrencyKindEnumType20.h new file mode 100644 index 00000000..912c257d --- /dev/null +++ b/src/ocpp20/types/RecurrencyKindEnumType20.h @@ -0,0 +1,52 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:RequestStartTransactionRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_RECURRENCYKINDENUMTYPE_H +#define OPENOCPP_OCPP20_RECURRENCYKINDENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Charging_ Profile. Recurrency_ Kind. Recurrency_ Kind_ Code +urn:x-oca:ocpp:uid:1:569233 +Indicates the start point of a recurrence. */ +enum class RecurrencyKindEnumType +{ + Daily, + Weekly, +}; + +/** @brief Helper to convert a RecurrencyKindEnumType enum to string */ +extern const EnumToStringFromString RecurrencyKindEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_RECURRENCYKINDENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/RegistrationStatusEnumType20.cpp b/src/ocpp20/types/RegistrationStatusEnumType20.cpp new file mode 100644 index 00000000..7426a48f --- /dev/null +++ b/src/ocpp20/types/RegistrationStatusEnumType20.cpp @@ -0,0 +1,42 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:BootNotificationRequest + OCPP 2.0.1 FINAL +*/ + +#include "RegistrationStatusEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a RegistrationStatusEnumType enum to string */ +const EnumToStringFromString RegistrationStatusEnumTypeHelper = { + {RegistrationStatusEnumType::Accepted, "Accepted"}, + {RegistrationStatusEnumType::Pending, "Pending"}, + {RegistrationStatusEnumType::Rejected, "Rejected"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/RegistrationStatusEnumType20.h b/src/ocpp20/types/RegistrationStatusEnumType20.h new file mode 100644 index 00000000..24a4d508 --- /dev/null +++ b/src/ocpp20/types/RegistrationStatusEnumType20.h @@ -0,0 +1,52 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:BootNotificationRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_REGISTRATIONSTATUSENUMTYPE_H +#define OPENOCPP_OCPP20_REGISTRATIONSTATUSENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief This contains whether the Charging Station has been registered +within the CSMS. */ +enum class RegistrationStatusEnumType +{ + Accepted, + Pending, + Rejected, +}; + +/** @brief Helper to convert a RegistrationStatusEnumType enum to string */ +extern const EnumToStringFromString RegistrationStatusEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_REGISTRATIONSTATUSENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/RelativeTimeIntervalType20.cpp b/src/ocpp20/types/RelativeTimeIntervalType20.cpp new file mode 100644 index 00000000..37f63157 --- /dev/null +++ b/src/ocpp20/types/RelativeTimeIntervalType20.cpp @@ -0,0 +1,90 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:RequestStartTransactionRequest + OCPP 2.0.1 FINAL +*/ + +#include "RelativeTimeIntervalType20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Convert a RelativeTimeIntervalType from a JSON representation */ +bool RelativeTimeIntervalTypeConverter::fromJson(const rapidjson::Value& json, + RelativeTimeIntervalType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // start + extract(json, "start", data.start); + + // duration + extract(json, "duration", data.duration); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a RelativeTimeIntervalType to a JSON representation */ +bool RelativeTimeIntervalTypeConverter::toJson(const RelativeTimeIntervalType& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // start + fill(json, "start", data.start); + + // duration + fill(json, "duration", data.duration); + + return ret; +} + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/RelativeTimeIntervalType20.h b/src/ocpp20/types/RelativeTimeIntervalType20.h new file mode 100644 index 00000000..0010e54b --- /dev/null +++ b/src/ocpp20/types/RelativeTimeIntervalType20.h @@ -0,0 +1,77 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:RequestStartTransactionRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_RELATIVETIMEINTERVALTYPE_H +#define OPENOCPP_OCPP20_RELATIVETIMEINTERVALTYPE_H + +#include "CustomDataType20.h" + +#include "IMessageConverter.h" +#include "Optional.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Relative_ Timer_ Interval +urn:x-oca:ocpp:uid:2:233270 + */ +struct RelativeTimeIntervalType +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief Relative_ Timer_ Interval. Start. Elapsed_ Time +urn:x-oca:ocpp:uid:1:569279 +Start of the interval, in seconds from NOW. */ + int start; + /** @brief Relative_ Timer_ Interval. Duration. Elapsed_ Time +urn:x-oca:ocpp:uid:1:569280 +Duration of the interval, in seconds. */ + ocpp::types::Optional duration; +}; + +/** @brief Converter class for RelativeTimeIntervalType type */ +class RelativeTimeIntervalTypeConverter : public ocpp::messages::IMessageConverter +{ + public: + /** @brief Clone the converter */ + ocpp::messages::IMessageConverter* clone() const override { return new RelativeTimeIntervalTypeConverter(); } + + /** @brief Convert a RelativeTimeIntervalType from a JSON representation */ + bool fromJson(const rapidjson::Value& json, + RelativeTimeIntervalType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) override; + + /** @brief Convert a RelativeTimeIntervalType to a JSON representation */ + bool toJson(const RelativeTimeIntervalType& data, rapidjson::Document& json) override; +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_RELATIVETIMEINTERVALTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/ReportBaseEnumType20.cpp b/src/ocpp20/types/ReportBaseEnumType20.cpp new file mode 100644 index 00000000..e596d18e --- /dev/null +++ b/src/ocpp20/types/ReportBaseEnumType20.cpp @@ -0,0 +1,42 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetBaseReportRequest + OCPP 2.0.1 FINAL +*/ + +#include "ReportBaseEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a ReportBaseEnumType enum to string */ +const EnumToStringFromString ReportBaseEnumTypeHelper = { + {ReportBaseEnumType::ConfigurationInventory, "ConfigurationInventory"}, + {ReportBaseEnumType::FullInventory, "FullInventory"}, + {ReportBaseEnumType::SummaryInventory, "SummaryInventory"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/ReportBaseEnumType20.h b/src/ocpp20/types/ReportBaseEnumType20.h new file mode 100644 index 00000000..e9bf9329 --- /dev/null +++ b/src/ocpp20/types/ReportBaseEnumType20.h @@ -0,0 +1,51 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetBaseReportRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_REPORTBASEENUMTYPE_H +#define OPENOCPP_OCPP20_REPORTBASEENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief This field specifies the report base. */ +enum class ReportBaseEnumType +{ + ConfigurationInventory, + FullInventory, + SummaryInventory, +}; + +/** @brief Helper to convert a ReportBaseEnumType enum to string */ +extern const EnumToStringFromString ReportBaseEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_REPORTBASEENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/ReportDataType20.cpp b/src/ocpp20/types/ReportDataType20.cpp new file mode 100644 index 00000000..7767b6da --- /dev/null +++ b/src/ocpp20/types/ReportDataType20.cpp @@ -0,0 +1,143 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:NotifyReportRequest + OCPP 2.0.1 FINAL +*/ + +#include "ReportDataType20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Convert a ReportDataType from a JSON representation */ +bool ReportDataTypeConverter::fromJson(const rapidjson::Value& json, + ReportDataType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // component + ComponentTypeConverter component_converter; + ret = ret && component_converter.fromJson(json["component"], data.component, error_code, error_message); + + // variable + VariableTypeConverter variable_converter; + ret = ret && variable_converter.fromJson(json["variable"], data.variable, error_code, error_message); + + // variableAttribute + if (json.HasMember("variableAttribute")) + { + const rapidjson::Value& variableAttribute_json = json["variableAttribute"]; + VariableAttributeTypeConverter variableAttribute_converter; + for (auto it = variableAttribute_json.Begin(); ret && (it != variableAttribute_json.End()); ++it) + { + VariableAttributeType& item = data.variableAttribute.emplace_back(); + ret = ret && variableAttribute_converter.fromJson(*it, item, error_code, error_message); + } + } + + // variableCharacteristics + if (json.HasMember("variableCharacteristics")) + { + VariableCharacteristicsTypeConverter variableCharacteristics_converter; + ret = ret && variableCharacteristics_converter.fromJson( + json["variableCharacteristics"], data.variableCharacteristics, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a ReportDataType to a JSON representation */ +bool ReportDataTypeConverter::toJson(const ReportDataType& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // component + ComponentTypeConverter component_converter; + component_converter.setAllocator(allocator); + rapidjson::Document component_doc(rapidjson::kObjectType); + ret = ret && component_converter.toJson(data.component, component_doc); + json.AddMember(rapidjson::StringRef("component"), component_doc.Move(), *allocator); + + // variable + VariableTypeConverter variable_converter; + variable_converter.setAllocator(allocator); + rapidjson::Document variable_doc(rapidjson::kObjectType); + ret = ret && variable_converter.toJson(data.variable, variable_doc); + json.AddMember(rapidjson::StringRef("variable"), variable_doc.Move(), *allocator); + + // variableAttribute + + rapidjson::Value variableAttribute_json(rapidjson::kArrayType); + VariableAttributeTypeConverter variableAttribute_converter; + variableAttribute_converter.setAllocator(allocator); + for (const VariableAttributeType& item : data.variableAttribute) + { + rapidjson::Document item_doc(rapidjson::kObjectType); + ret = ret && variableAttribute_converter.toJson(item, item_doc); + variableAttribute_json.PushBack(item_doc.Move(), *allocator); + } + json.AddMember(rapidjson::StringRef("variableAttribute"), variableAttribute_json.Move(), *allocator); + + // variableCharacteristics + if (data.variableCharacteristics.isSet()) + { + VariableCharacteristicsTypeConverter variableCharacteristics_converter; + variableCharacteristics_converter.setAllocator(allocator); + rapidjson::Document variableCharacteristics_doc(rapidjson::kObjectType); + ret = ret && variableCharacteristics_converter.toJson(data.variableCharacteristics, variableCharacteristics_doc); + json.AddMember(rapidjson::StringRef("variableCharacteristics"), variableCharacteristics_doc.Move(), *allocator); + } + + return ret; +} + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/ReportDataType20.h b/src/ocpp20/types/ReportDataType20.h new file mode 100644 index 00000000..1588ba39 --- /dev/null +++ b/src/ocpp20/types/ReportDataType20.h @@ -0,0 +1,81 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:NotifyReportRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_REPORTDATATYPE_H +#define OPENOCPP_OCPP20_REPORTDATATYPE_H + +#include "ComponentType20.h" +#include "CustomDataType20.h" +#include "VariableAttributeType20.h" +#include "VariableCharacteristicsType20.h" +#include "VariableType20.h" + +#include "IMessageConverter.h" +#include "Optional.h" +#include + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Class to report components, variables and variable attributes and characteristics. + */ +struct ReportDataType +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ComponentType component; + /** @brief */ + VariableType variable; + /** @brief */ + std::vector variableAttribute; + /** @brief */ + ocpp::types::Optional variableCharacteristics; +}; + +/** @brief Converter class for ReportDataType type */ +class ReportDataTypeConverter : public ocpp::messages::IMessageConverter +{ + public: + /** @brief Clone the converter */ + ocpp::messages::IMessageConverter* clone() const override { return new ReportDataTypeConverter(); } + + /** @brief Convert a ReportDataType from a JSON representation */ + bool fromJson(const rapidjson::Value& json, + ReportDataType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) override; + + /** @brief Convert a ReportDataType to a JSON representation */ + bool toJson(const ReportDataType& data, rapidjson::Document& json) override; +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_REPORTDATATYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/RequestStartStopStatusEnumType20.cpp b/src/ocpp20/types/RequestStartStopStatusEnumType20.cpp new file mode 100644 index 00000000..43048a17 --- /dev/null +++ b/src/ocpp20/types/RequestStartStopStatusEnumType20.cpp @@ -0,0 +1,41 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:RequestStartTransactionRequest + OCPP 2.0.1 FINAL +*/ + +#include "RequestStartStopStatusEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a RequestStartStopStatusEnumType enum to string */ +const EnumToStringFromString RequestStartStopStatusEnumTypeHelper = { + {RequestStartStopStatusEnumType::Accepted, "Accepted"}, + {RequestStartStopStatusEnumType::Rejected, "Rejected"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/RequestStartStopStatusEnumType20.h b/src/ocpp20/types/RequestStartStopStatusEnumType20.h new file mode 100644 index 00000000..7784ba69 --- /dev/null +++ b/src/ocpp20/types/RequestStartStopStatusEnumType20.h @@ -0,0 +1,50 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:RequestStartTransactionRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_REQUESTSTARTSTOPSTATUSENUMTYPE_H +#define OPENOCPP_OCPP20_REQUESTSTARTSTOPSTATUSENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Status indicating whether the Charging Station accepts the request to start a transaction. */ +enum class RequestStartStopStatusEnumType +{ + Accepted, + Rejected, +}; + +/** @brief Helper to convert a RequestStartStopStatusEnumType enum to string */ +extern const EnumToStringFromString RequestStartStopStatusEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_REQUESTSTARTSTOPSTATUSENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/ReservationUpdateStatusEnumType20.cpp b/src/ocpp20/types/ReservationUpdateStatusEnumType20.cpp new file mode 100644 index 00000000..3c25753c --- /dev/null +++ b/src/ocpp20/types/ReservationUpdateStatusEnumType20.cpp @@ -0,0 +1,41 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:ReservationStatusUpdateRequest + OCPP 2.0.1 FINAL +*/ + +#include "ReservationUpdateStatusEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a ReservationUpdateStatusEnumType enum to string */ +const EnumToStringFromString ReservationUpdateStatusEnumTypeHelper = { + {ReservationUpdateStatusEnumType::Expired, "Expired"}, + {ReservationUpdateStatusEnumType::Removed, "Removed"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/ReservationUpdateStatusEnumType20.h b/src/ocpp20/types/ReservationUpdateStatusEnumType20.h new file mode 100644 index 00000000..ee2e67b9 --- /dev/null +++ b/src/ocpp20/types/ReservationUpdateStatusEnumType20.h @@ -0,0 +1,50 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:ReservationStatusUpdateRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_RESERVATIONUPDATESTATUSENUMTYPE_H +#define OPENOCPP_OCPP20_RESERVATIONUPDATESTATUSENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief The updated reservation status. */ +enum class ReservationUpdateStatusEnumType +{ + Expired, + Removed, +}; + +/** @brief Helper to convert a ReservationUpdateStatusEnumType enum to string */ +extern const EnumToStringFromString ReservationUpdateStatusEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_RESERVATIONUPDATESTATUSENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/ReserveNowStatusEnumType20.cpp b/src/ocpp20/types/ReserveNowStatusEnumType20.cpp new file mode 100644 index 00000000..2877c30c --- /dev/null +++ b/src/ocpp20/types/ReserveNowStatusEnumType20.cpp @@ -0,0 +1,44 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:ReserveNowRequest + OCPP 2.0.1 FINAL +*/ + +#include "ReserveNowStatusEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a ReserveNowStatusEnumType enum to string */ +const EnumToStringFromString ReserveNowStatusEnumTypeHelper = { + {ReserveNowStatusEnumType::Accepted, "Accepted"}, + {ReserveNowStatusEnumType::Faulted, "Faulted"}, + {ReserveNowStatusEnumType::Occupied, "Occupied"}, + {ReserveNowStatusEnumType::Rejected, "Rejected"}, + {ReserveNowStatusEnumType::Unavailable, "Unavailable"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/ReserveNowStatusEnumType20.h b/src/ocpp20/types/ReserveNowStatusEnumType20.h new file mode 100644 index 00000000..537865b5 --- /dev/null +++ b/src/ocpp20/types/ReserveNowStatusEnumType20.h @@ -0,0 +1,53 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:ReserveNowRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_RESERVENOWSTATUSENUMTYPE_H +#define OPENOCPP_OCPP20_RESERVENOWSTATUSENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief This indicates the success or failure of the reservation. */ +enum class ReserveNowStatusEnumType +{ + Accepted, + Faulted, + Occupied, + Rejected, + Unavailable, +}; + +/** @brief Helper to convert a ReserveNowStatusEnumType enum to string */ +extern const EnumToStringFromString ReserveNowStatusEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_RESERVENOWSTATUSENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/ResetEnumType20.cpp b/src/ocpp20/types/ResetEnumType20.cpp new file mode 100644 index 00000000..b167e2ce --- /dev/null +++ b/src/ocpp20/types/ResetEnumType20.cpp @@ -0,0 +1,41 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:ResetRequest + OCPP 2.0.1 FINAL +*/ + +#include "ResetEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a ResetEnumType enum to string */ +const EnumToStringFromString ResetEnumTypeHelper = { + {ResetEnumType::Immediate, "Immediate"}, + {ResetEnumType::OnIdle, "OnIdle"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/ResetEnumType20.h b/src/ocpp20/types/ResetEnumType20.h new file mode 100644 index 00000000..044eea2b --- /dev/null +++ b/src/ocpp20/types/ResetEnumType20.h @@ -0,0 +1,50 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:ResetRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_RESETENUMTYPE_H +#define OPENOCPP_OCPP20_RESETENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief This contains the type of reset that the Charging Station or EVSE should perform. */ +enum class ResetEnumType +{ + Immediate, + OnIdle, +}; + +/** @brief Helper to convert a ResetEnumType enum to string */ +extern const EnumToStringFromString ResetEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_RESETENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/ResetStatusEnumType20.cpp b/src/ocpp20/types/ResetStatusEnumType20.cpp new file mode 100644 index 00000000..341d31c6 --- /dev/null +++ b/src/ocpp20/types/ResetStatusEnumType20.cpp @@ -0,0 +1,42 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:ResetRequest + OCPP 2.0.1 FINAL +*/ + +#include "ResetStatusEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a ResetStatusEnumType enum to string */ +const EnumToStringFromString ResetStatusEnumTypeHelper = { + {ResetStatusEnumType::Accepted, "Accepted"}, + {ResetStatusEnumType::Rejected, "Rejected"}, + {ResetStatusEnumType::Scheduled, "Scheduled"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/ResetStatusEnumType20.h b/src/ocpp20/types/ResetStatusEnumType20.h new file mode 100644 index 00000000..001b32ab --- /dev/null +++ b/src/ocpp20/types/ResetStatusEnumType20.h @@ -0,0 +1,51 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:ResetRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_RESETSTATUSENUMTYPE_H +#define OPENOCPP_OCPP20_RESETSTATUSENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief This indicates whether the Charging Station is able to perform the reset. */ +enum class ResetStatusEnumType +{ + Accepted, + Rejected, + Scheduled, +}; + +/** @brief Helper to convert a ResetStatusEnumType enum to string */ +extern const EnumToStringFromString ResetStatusEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_RESETSTATUSENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/SalesTariffEntryType20.cpp b/src/ocpp20/types/SalesTariffEntryType20.cpp new file mode 100644 index 00000000..f5b2af4b --- /dev/null +++ b/src/ocpp20/types/SalesTariffEntryType20.cpp @@ -0,0 +1,124 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:RequestStartTransactionRequest + OCPP 2.0.1 FINAL +*/ + +#include "SalesTariffEntryType20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Convert a SalesTariffEntryType from a JSON representation */ +bool SalesTariffEntryTypeConverter::fromJson(const rapidjson::Value& json, + SalesTariffEntryType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // relativeTimeInterval + RelativeTimeIntervalTypeConverter relativeTimeInterval_converter; + ret = + ret && relativeTimeInterval_converter.fromJson(json["relativeTimeInterval"], data.relativeTimeInterval, error_code, error_message); + + // ePriceLevel + extract(json, "ePriceLevel", data.ePriceLevel); + + // consumptionCost + if (json.HasMember("consumptionCost")) + { + const rapidjson::Value& consumptionCost_json = json["consumptionCost"]; + ConsumptionCostTypeConverter consumptionCost_converter; + for (auto it = consumptionCost_json.Begin(); ret && (it != consumptionCost_json.End()); ++it) + { + ConsumptionCostType& item = data.consumptionCost.emplace_back(); + ret = ret && consumptionCost_converter.fromJson(*it, item, error_code, error_message); + } + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a SalesTariffEntryType to a JSON representation */ +bool SalesTariffEntryTypeConverter::toJson(const SalesTariffEntryType& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // relativeTimeInterval + RelativeTimeIntervalTypeConverter relativeTimeInterval_converter; + relativeTimeInterval_converter.setAllocator(allocator); + rapidjson::Document relativeTimeInterval_doc(rapidjson::kObjectType); + ret = ret && relativeTimeInterval_converter.toJson(data.relativeTimeInterval, relativeTimeInterval_doc); + json.AddMember(rapidjson::StringRef("relativeTimeInterval"), relativeTimeInterval_doc.Move(), *allocator); + + // ePriceLevel + fill(json, "ePriceLevel", data.ePriceLevel); + + // consumptionCost + if (!data.consumptionCost.empty()) + { + + rapidjson::Value consumptionCost_json(rapidjson::kArrayType); + ConsumptionCostTypeConverter consumptionCost_converter; + consumptionCost_converter.setAllocator(allocator); + for (const ConsumptionCostType& item : data.consumptionCost) + { + rapidjson::Document item_doc(rapidjson::kObjectType); + ret = ret && consumptionCost_converter.toJson(item, item_doc); + consumptionCost_json.PushBack(item_doc.Move(), *allocator); + } + json.AddMember(rapidjson::StringRef("consumptionCost"), consumptionCost_json.Move(), *allocator); + } + + return ret; +} + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/SalesTariffEntryType20.h b/src/ocpp20/types/SalesTariffEntryType20.h new file mode 100644 index 00000000..43f554f3 --- /dev/null +++ b/src/ocpp20/types/SalesTariffEntryType20.h @@ -0,0 +1,80 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:RequestStartTransactionRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_SALESTARIFFENTRYTYPE_H +#define OPENOCPP_OCPP20_SALESTARIFFENTRYTYPE_H + +#include "ConsumptionCostType20.h" +#include "CustomDataType20.h" +#include "RelativeTimeIntervalType20.h" + +#include "IMessageConverter.h" +#include "Optional.h" +#include + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Sales_ Tariff_ Entry +urn:x-oca:ocpp:uid:2:233271 + */ +struct SalesTariffEntryType +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + RelativeTimeIntervalType relativeTimeInterval; + /** @brief Sales_ Tariff_ Entry. E_ Price_ Level. Unsigned_ Integer +urn:x-oca:ocpp:uid:1:569281 +Defines the price level of this SalesTariffEntry (referring to NumEPriceLevels). Small values for the EPriceLevel represent a cheaper TariffEntry. Large values for the EPriceLevel represent a more expensive TariffEntry. */ + ocpp::types::Optional ePriceLevel; + /** @brief */ + std::vector consumptionCost; +}; + +/** @brief Converter class for SalesTariffEntryType type */ +class SalesTariffEntryTypeConverter : public ocpp::messages::IMessageConverter +{ + public: + /** @brief Clone the converter */ + ocpp::messages::IMessageConverter* clone() const override { return new SalesTariffEntryTypeConverter(); } + + /** @brief Convert a SalesTariffEntryType from a JSON representation */ + bool fromJson(const rapidjson::Value& json, + SalesTariffEntryType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) override; + + /** @brief Convert a SalesTariffEntryType to a JSON representation */ + bool toJson(const SalesTariffEntryType& data, rapidjson::Document& json) override; +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_SALESTARIFFENTRYTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/SalesTariffType20.cpp b/src/ocpp20/types/SalesTariffType20.cpp new file mode 100644 index 00000000..13a01c79 --- /dev/null +++ b/src/ocpp20/types/SalesTariffType20.cpp @@ -0,0 +1,121 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:RequestStartTransactionRequest + OCPP 2.0.1 FINAL +*/ + +#include "SalesTariffType20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Convert a SalesTariffType from a JSON representation */ +bool SalesTariffTypeConverter::fromJson(const rapidjson::Value& json, + SalesTariffType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // id + extract(json, "id", data.id); + + // salesTariffDescription + extract(json, "salesTariffDescription", data.salesTariffDescription); + + // numEPriceLevels + extract(json, "numEPriceLevels", data.numEPriceLevels); + + // salesTariffEntry + if (json.HasMember("salesTariffEntry")) + { + const rapidjson::Value& salesTariffEntry_json = json["salesTariffEntry"]; + SalesTariffEntryTypeConverter salesTariffEntry_converter; + for (auto it = salesTariffEntry_json.Begin(); ret && (it != salesTariffEntry_json.End()); ++it) + { + SalesTariffEntryType& item = data.salesTariffEntry.emplace_back(); + ret = ret && salesTariffEntry_converter.fromJson(*it, item, error_code, error_message); + } + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a SalesTariffType to a JSON representation */ +bool SalesTariffTypeConverter::toJson(const SalesTariffType& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // id + fill(json, "id", data.id); + + // salesTariffDescription + fill(json, "salesTariffDescription", data.salesTariffDescription); + + // numEPriceLevels + fill(json, "numEPriceLevels", data.numEPriceLevels); + + // salesTariffEntry + + rapidjson::Value salesTariffEntry_json(rapidjson::kArrayType); + SalesTariffEntryTypeConverter salesTariffEntry_converter; + salesTariffEntry_converter.setAllocator(allocator); + for (const SalesTariffEntryType& item : data.salesTariffEntry) + { + rapidjson::Document item_doc(rapidjson::kObjectType); + ret = ret && salesTariffEntry_converter.toJson(item, item_doc); + salesTariffEntry_json.PushBack(item_doc.Move(), *allocator); + } + json.AddMember(rapidjson::StringRef("salesTariffEntry"), salesTariffEntry_json.Move(), *allocator); + + return ret; +} + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/SalesTariffType20.h b/src/ocpp20/types/SalesTariffType20.h new file mode 100644 index 00000000..e6859c8a --- /dev/null +++ b/src/ocpp20/types/SalesTariffType20.h @@ -0,0 +1,87 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:RequestStartTransactionRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_SALESTARIFFTYPE_H +#define OPENOCPP_OCPP20_SALESTARIFFTYPE_H + +#include "CustomDataType20.h" +#include "SalesTariffEntryType20.h" + +#include "CiStringType.h" +#include "IMessageConverter.h" +#include "Optional.h" +#include + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Sales_ Tariff +urn:x-oca:ocpp:uid:2:233272 +NOTE: This dataType is based on dataTypes from <<ref-ISOIEC15118-2,ISO 15118-2>>. + */ +struct SalesTariffType +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief Identified_ Object. MRID. Numeric_ Identifier +urn:x-enexis:ecdm:uid:1:569198 +SalesTariff identifier used to identify one sales tariff. An SAID remains a unique identifier for one schedule throughout a charging session. */ + int id; + /** @brief Sales_ Tariff. Sales. Tariff_ Description +urn:x-oca:ocpp:uid:1:569283 +A human readable title/short description of the sales tariff e.g. for HMI display purposes. */ + ocpp::types::Optional> salesTariffDescription; + /** @brief Sales_ Tariff. Num_ E_ Price_ Levels. Counter +urn:x-oca:ocpp:uid:1:569284 +Defines the overall number of distinct price levels used across all provided SalesTariff elements. */ + ocpp::types::Optional numEPriceLevels; + /** @brief */ + std::vector salesTariffEntry; +}; + +/** @brief Converter class for SalesTariffType type */ +class SalesTariffTypeConverter : public ocpp::messages::IMessageConverter +{ + public: + /** @brief Clone the converter */ + ocpp::messages::IMessageConverter* clone() const override { return new SalesTariffTypeConverter(); } + + /** @brief Convert a SalesTariffType from a JSON representation */ + bool fromJson(const rapidjson::Value& json, + SalesTariffType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) override; + + /** @brief Convert a SalesTariffType to a JSON representation */ + bool toJson(const SalesTariffType& data, rapidjson::Document& json) override; +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_SALESTARIFFTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/SampledValueType20.cpp b/src/ocpp20/types/SampledValueType20.cpp new file mode 100644 index 00000000..9c6a2b66 --- /dev/null +++ b/src/ocpp20/types/SampledValueType20.cpp @@ -0,0 +1,166 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:MeterValuesRequest + OCPP 2.0.1 FINAL +*/ + +#include "SampledValueType20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Convert a SampledValueType from a JSON representation */ +bool SampledValueTypeConverter::fromJson(const rapidjson::Value& json, + SampledValueType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // value + extract(json, "value", data.value); + + // context + if (json.HasMember("context")) + { + data.context = ReadingContextEnumTypeHelper.fromString(json["context"].GetString()); + } + + // measurand + if (json.HasMember("measurand")) + { + data.measurand = MeasurandEnumTypeHelper.fromString(json["measurand"].GetString()); + } + + // phase + if (json.HasMember("phase")) + { + data.phase = PhaseEnumTypeHelper.fromString(json["phase"].GetString()); + } + + // location + if (json.HasMember("location")) + { + data.location = LocationEnumTypeHelper.fromString(json["location"].GetString()); + } + + // signedMeterValue + if (json.HasMember("signedMeterValue")) + { + SignedMeterValueTypeConverter signedMeterValue_converter; + ret = ret && signedMeterValue_converter.fromJson(json["signedMeterValue"], data.signedMeterValue, error_code, error_message); + } + + // unitOfMeasure + if (json.HasMember("unitOfMeasure")) + { + UnitOfMeasureTypeConverter unitOfMeasure_converter; + ret = ret && unitOfMeasure_converter.fromJson(json["unitOfMeasure"], data.unitOfMeasure, error_code, error_message); + } + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a SampledValueType to a JSON representation */ +bool SampledValueTypeConverter::toJson(const SampledValueType& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // value + fill(json, "value", data.value); + + // context + if (data.context.isSet()) + { + fill(json, "context", ReadingContextEnumTypeHelper.toString(data.context)); + } + + // measurand + if (data.measurand.isSet()) + { + fill(json, "measurand", MeasurandEnumTypeHelper.toString(data.measurand)); + } + + // phase + if (data.phase.isSet()) + { + fill(json, "phase", PhaseEnumTypeHelper.toString(data.phase)); + } + + // location + if (data.location.isSet()) + { + fill(json, "location", LocationEnumTypeHelper.toString(data.location)); + } + + // signedMeterValue + if (data.signedMeterValue.isSet()) + { + SignedMeterValueTypeConverter signedMeterValue_converter; + signedMeterValue_converter.setAllocator(allocator); + rapidjson::Document signedMeterValue_doc(rapidjson::kObjectType); + ret = ret && signedMeterValue_converter.toJson(data.signedMeterValue, signedMeterValue_doc); + json.AddMember(rapidjson::StringRef("signedMeterValue"), signedMeterValue_doc.Move(), *allocator); + } + + // unitOfMeasure + if (data.unitOfMeasure.isSet()) + { + UnitOfMeasureTypeConverter unitOfMeasure_converter; + unitOfMeasure_converter.setAllocator(allocator); + rapidjson::Document unitOfMeasure_doc(rapidjson::kObjectType); + ret = ret && unitOfMeasure_converter.toJson(data.unitOfMeasure, unitOfMeasure_doc); + json.AddMember(rapidjson::StringRef("unitOfMeasure"), unitOfMeasure_doc.Move(), *allocator); + } + + return ret; +} + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/SampledValueType20.h b/src/ocpp20/types/SampledValueType20.h new file mode 100644 index 00000000..82d199d1 --- /dev/null +++ b/src/ocpp20/types/SampledValueType20.h @@ -0,0 +1,94 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:MeterValuesRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_SAMPLEDVALUETYPE_H +#define OPENOCPP_OCPP20_SAMPLEDVALUETYPE_H + +#include "CustomDataType20.h" +#include "LocationEnumType20.h" +#include "MeasurandEnumType20.h" +#include "PhaseEnumType20.h" +#include "ReadingContextEnumType20.h" +#include "SignedMeterValueType20.h" +#include "UnitOfMeasureType20.h" + +#include "IMessageConverter.h" +#include "Optional.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Sampled_ Value +urn:x-oca:ocpp:uid:2:233266 +Single sampled value in MeterValues. Each value can be accompanied by optional fields. + +To save on mobile data usage, default values of all of the optional fields are such that. The value without any additional fields will be interpreted, as a register reading of active import energy in Wh (Watt-hour) units. + */ +struct SampledValueType +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief Sampled_ Value. Value. Measure +urn:x-oca:ocpp:uid:1:569260 +Indicates the measured value. */ + float value; + /** @brief */ + ocpp::types::Optional context; + /** @brief */ + ocpp::types::Optional measurand; + /** @brief */ + ocpp::types::Optional phase; + /** @brief */ + ocpp::types::Optional location; + /** @brief */ + ocpp::types::Optional signedMeterValue; + /** @brief */ + ocpp::types::Optional unitOfMeasure; +}; + +/** @brief Converter class for SampledValueType type */ +class SampledValueTypeConverter : public ocpp::messages::IMessageConverter +{ + public: + /** @brief Clone the converter */ + ocpp::messages::IMessageConverter* clone() const override { return new SampledValueTypeConverter(); } + + /** @brief Convert a SampledValueType from a JSON representation */ + bool fromJson(const rapidjson::Value& json, + SampledValueType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) override; + + /** @brief Convert a SampledValueType to a JSON representation */ + bool toJson(const SampledValueType& data, rapidjson::Document& json) override; +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_SAMPLEDVALUETYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/SendLocalListStatusEnumType20.cpp b/src/ocpp20/types/SendLocalListStatusEnumType20.cpp new file mode 100644 index 00000000..2ca31138 --- /dev/null +++ b/src/ocpp20/types/SendLocalListStatusEnumType20.cpp @@ -0,0 +1,42 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SendLocalListRequest + OCPP 2.0.1 FINAL +*/ + +#include "SendLocalListStatusEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a SendLocalListStatusEnumType enum to string */ +const EnumToStringFromString SendLocalListStatusEnumTypeHelper = { + {SendLocalListStatusEnumType::Accepted, "Accepted"}, + {SendLocalListStatusEnumType::Failed, "Failed"}, + {SendLocalListStatusEnumType::VersionMismatch, "VersionMismatch"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/SendLocalListStatusEnumType20.h b/src/ocpp20/types/SendLocalListStatusEnumType20.h new file mode 100644 index 00000000..699db1af --- /dev/null +++ b/src/ocpp20/types/SendLocalListStatusEnumType20.h @@ -0,0 +1,51 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SendLocalListRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_SENDLOCALLISTSTATUSENUMTYPE_H +#define OPENOCPP_OCPP20_SENDLOCALLISTSTATUSENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief This indicates whether the Charging Station has successfully received and applied the update of the Local Authorization List. */ +enum class SendLocalListStatusEnumType +{ + Accepted, + Failed, + VersionMismatch, +}; + +/** @brief Helper to convert a SendLocalListStatusEnumType enum to string */ +extern const EnumToStringFromString SendLocalListStatusEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_SENDLOCALLISTSTATUSENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/SetMonitoringDataType20.cpp b/src/ocpp20/types/SetMonitoringDataType20.cpp new file mode 100644 index 00000000..5494d4f7 --- /dev/null +++ b/src/ocpp20/types/SetMonitoringDataType20.cpp @@ -0,0 +1,130 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SetVariableMonitoringRequest + OCPP 2.0.1 FINAL +*/ + +#include "SetMonitoringDataType20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Convert a SetMonitoringDataType from a JSON representation */ +bool SetMonitoringDataTypeConverter::fromJson(const rapidjson::Value& json, + SetMonitoringDataType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // id + extract(json, "id", data.id); + + // transaction + extract(json, "transaction", data.transaction); + + // value + extract(json, "value", data.value); + + // type + data.type = MonitorEnumTypeHelper.fromString(json["type"].GetString()); + + // severity + extract(json, "severity", data.severity); + + // component + ComponentTypeConverter component_converter; + ret = ret && component_converter.fromJson(json["component"], data.component, error_code, error_message); + + // variable + VariableTypeConverter variable_converter; + ret = ret && variable_converter.fromJson(json["variable"], data.variable, error_code, error_message); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a SetMonitoringDataType to a JSON representation */ +bool SetMonitoringDataTypeConverter::toJson(const SetMonitoringDataType& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // id + fill(json, "id", data.id); + + // transaction + fill(json, "transaction", data.transaction); + + // value + fill(json, "value", data.value); + + // type + fill(json, "type", MonitorEnumTypeHelper.toString(data.type)); + + // severity + fill(json, "severity", data.severity); + + // component + ComponentTypeConverter component_converter; + component_converter.setAllocator(allocator); + rapidjson::Document component_doc(rapidjson::kObjectType); + ret = ret && component_converter.toJson(data.component, component_doc); + json.AddMember(rapidjson::StringRef("component"), component_doc.Move(), *allocator); + + // variable + VariableTypeConverter variable_converter; + variable_converter.setAllocator(allocator); + rapidjson::Document variable_doc(rapidjson::kObjectType); + ret = ret && variable_converter.toJson(data.variable, variable_doc); + json.AddMember(rapidjson::StringRef("variable"), variable_doc.Move(), *allocator); + + return ret; +} + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/SetMonitoringDataType20.h b/src/ocpp20/types/SetMonitoringDataType20.h new file mode 100644 index 00000000..fd3117ab --- /dev/null +++ b/src/ocpp20/types/SetMonitoringDataType20.h @@ -0,0 +1,108 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SetVariableMonitoringRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_SETMONITORINGDATATYPE_H +#define OPENOCPP_OCPP20_SETMONITORINGDATATYPE_H + +#include "ComponentType20.h" +#include "CustomDataType20.h" +#include "MonitorEnumType20.h" +#include "VariableType20.h" + +#include "IMessageConverter.h" +#include "Optional.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Class to hold parameters of SetVariableMonitoring request. + */ +struct SetMonitoringDataType +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief An id SHALL only be given to replace an existing monitor. The Charging Station handles the generation of id's for new monitors. */ + ocpp::types::Optional id; + /** @brief Monitor only active when a transaction is ongoing on a component relevant to this transaction. Default = false. */ + ocpp::types::Optional transaction; + /** @brief Value for threshold or delta monitoring. +For Periodic or PeriodicClockAligned this is the interval in seconds. */ + float value; + /** @brief */ + MonitorEnumType type; + /** @brief The severity that will be assigned to an event that is triggered by this monitor. The severity range is 0-9, with 0 as the highest and 9 as the lowest severity level. + +The severity levels have the following meaning: + +*0-Danger* + +Indicates lives are potentially in danger. Urgent attention is needed and action should be taken immediately. + +*1-Hardware Failure* + +Indicates that the Charging Station is unable to continue regular operations due to Hardware issues. Action is required. + +*2-System Failure* + +Indicates that the Charging Station is unable to continue regular operations due to software or minor hardware issues. Action is required. + +*3-Critical* + +Indicates a critical error. Action is required. + +*4-Error* + +Indicates a non-urgent error. Action is required. + +*5-Alert* + +Indicates an alert event. Default severity for any type of monitoring event. + +*6-Warning* + +Indicates a warning event. Action may be required. + +*7-Notice* + +Indicates an unusual event. No immediate action is required. + +*8-Informational* + +Indicates a regular operational event. May be used for reporting, measuring throughput, etc. No action is required. + +*9-Debug* + +Indicates information useful to developers for debugging, not useful during operations. */ + int severity; + /** @brief */ + ComponentType component; + /** @brief */ + VariableType variable; +}; + +/** @brief Converter class for SetMonitoringDataType type */ +class SetMonitoringDataTypeConverter : public ocpp::messages::IMessageConverter +{ + public: + /** @brief Clone the converter */ + ocpp::messages::IMessageConverter* clone() const override { return new SetMonitoringDataTypeConverter(); } + + /** @brief Convert a SetMonitoringDataType from a JSON representation */ + bool fromJson(const rapidjson::Value& json, + SetMonitoringDataType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) override; + + /** @brief Convert a SetMonitoringDataType to a JSON representation */ + bool toJson(const SetMonitoringDataType& data, rapidjson::Document& json) override; +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_SETMONITORINGDATATYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/SetMonitoringResultType20.cpp b/src/ocpp20/types/SetMonitoringResultType20.cpp new file mode 100644 index 00000000..97eb2cb4 --- /dev/null +++ b/src/ocpp20/types/SetMonitoringResultType20.cpp @@ -0,0 +1,141 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SetVariableMonitoringRequest + OCPP 2.0.1 FINAL +*/ + +#include "SetMonitoringResultType20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Convert a SetMonitoringResultType from a JSON representation */ +bool SetMonitoringResultTypeConverter::fromJson(const rapidjson::Value& json, + SetMonitoringResultType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // id + extract(json, "id", data.id); + + // statusInfo + if (json.HasMember("statusInfo")) + { + StatusInfoTypeConverter statusInfo_converter; + ret = ret && statusInfo_converter.fromJson(json["statusInfo"], data.statusInfo, error_code, error_message); + } + + // status + data.status = SetMonitoringStatusEnumTypeHelper.fromString(json["status"].GetString()); + + // type + data.type = MonitorEnumTypeHelper.fromString(json["type"].GetString()); + + // component + ComponentTypeConverter component_converter; + ret = ret && component_converter.fromJson(json["component"], data.component, error_code, error_message); + + // variable + VariableTypeConverter variable_converter; + ret = ret && variable_converter.fromJson(json["variable"], data.variable, error_code, error_message); + + // severity + extract(json, "severity", data.severity); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a SetMonitoringResultType to a JSON representation */ +bool SetMonitoringResultTypeConverter::toJson(const SetMonitoringResultType& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // id + fill(json, "id", data.id); + + // statusInfo + if (data.statusInfo.isSet()) + { + StatusInfoTypeConverter statusInfo_converter; + statusInfo_converter.setAllocator(allocator); + rapidjson::Document statusInfo_doc(rapidjson::kObjectType); + ret = ret && statusInfo_converter.toJson(data.statusInfo, statusInfo_doc); + json.AddMember(rapidjson::StringRef("statusInfo"), statusInfo_doc.Move(), *allocator); + } + + // status + fill(json, "status", SetMonitoringStatusEnumTypeHelper.toString(data.status)); + + // type + fill(json, "type", MonitorEnumTypeHelper.toString(data.type)); + + // component + ComponentTypeConverter component_converter; + component_converter.setAllocator(allocator); + rapidjson::Document component_doc(rapidjson::kObjectType); + ret = ret && component_converter.toJson(data.component, component_doc); + json.AddMember(rapidjson::StringRef("component"), component_doc.Move(), *allocator); + + // variable + VariableTypeConverter variable_converter; + variable_converter.setAllocator(allocator); + rapidjson::Document variable_doc(rapidjson::kObjectType); + ret = ret && variable_converter.toJson(data.variable, variable_doc); + json.AddMember(rapidjson::StringRef("variable"), variable_doc.Move(), *allocator); + + // severity + fill(json, "severity", data.severity); + + return ret; +} + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/SetMonitoringResultType20.h b/src/ocpp20/types/SetMonitoringResultType20.h new file mode 100644 index 00000000..3cf44f5a --- /dev/null +++ b/src/ocpp20/types/SetMonitoringResultType20.h @@ -0,0 +1,109 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SetVariableMonitoringRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_SETMONITORINGRESULTTYPE_H +#define OPENOCPP_OCPP20_SETMONITORINGRESULTTYPE_H + +#include "ComponentType20.h" +#include "CustomDataType20.h" +#include "MonitorEnumType20.h" +#include "SetMonitoringStatusEnumType20.h" +#include "StatusInfoType20.h" +#include "VariableType20.h" + +#include "IMessageConverter.h" +#include "Optional.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Class to hold result of SetVariableMonitoring request. + */ +struct SetMonitoringResultType +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief Id given to the VariableMonitor by the Charging Station. The Id is only returned when status is accepted. Installed VariableMonitors should have unique id's but the id's of removed Installed monitors should have unique id's but the id's of removed monitors MAY be reused. */ + ocpp::types::Optional id; + /** @brief */ + ocpp::types::Optional statusInfo; + /** @brief */ + SetMonitoringStatusEnumType status; + /** @brief */ + MonitorEnumType type; + /** @brief */ + ComponentType component; + /** @brief */ + VariableType variable; + /** @brief The severity that will be assigned to an event that is triggered by this monitor. The severity range is 0-9, with 0 as the highest and 9 as the lowest severity level. + +The severity levels have the following meaning: + +*0-Danger* + +Indicates lives are potentially in danger. Urgent attention is needed and action should be taken immediately. + +*1-Hardware Failure* + +Indicates that the Charging Station is unable to continue regular operations due to Hardware issues. Action is required. + +*2-System Failure* + +Indicates that the Charging Station is unable to continue regular operations due to software or minor hardware issues. Action is required. + +*3-Critical* + +Indicates a critical error. Action is required. + +*4-Error* + +Indicates a non-urgent error. Action is required. + +*5-Alert* + +Indicates an alert event. Default severity for any type of monitoring event. + +*6-Warning* + +Indicates a warning event. Action may be required. + +*7-Notice* + +Indicates an unusual event. No immediate action is required. + +*8-Informational* + +Indicates a regular operational event. May be used for reporting, measuring throughput, etc. No action is required. + +*9-Debug* + +Indicates information useful to developers for debugging, not useful during operations. */ + int severity; +}; + +/** @brief Converter class for SetMonitoringResultType type */ +class SetMonitoringResultTypeConverter : public ocpp::messages::IMessageConverter +{ + public: + /** @brief Clone the converter */ + ocpp::messages::IMessageConverter* clone() const override { return new SetMonitoringResultTypeConverter(); } + + /** @brief Convert a SetMonitoringResultType from a JSON representation */ + bool fromJson(const rapidjson::Value& json, + SetMonitoringResultType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) override; + + /** @brief Convert a SetMonitoringResultType to a JSON representation */ + bool toJson(const SetMonitoringResultType& data, rapidjson::Document& json) override; +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_SETMONITORINGRESULTTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/SetMonitoringStatusEnumType20.cpp b/src/ocpp20/types/SetMonitoringStatusEnumType20.cpp new file mode 100644 index 00000000..b5bf489c --- /dev/null +++ b/src/ocpp20/types/SetMonitoringStatusEnumType20.cpp @@ -0,0 +1,45 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SetVariableMonitoringRequest + OCPP 2.0.1 FINAL +*/ + +#include "SetMonitoringStatusEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a SetMonitoringStatusEnumType enum to string */ +const EnumToStringFromString SetMonitoringStatusEnumTypeHelper = { + {SetMonitoringStatusEnumType::Accepted, "Accepted"}, + {SetMonitoringStatusEnumType::UnknownComponent, "UnknownComponent"}, + {SetMonitoringStatusEnumType::UnknownVariable, "UnknownVariable"}, + {SetMonitoringStatusEnumType::UnsupportedMonitorType, "UnsupportedMonitorType"}, + {SetMonitoringStatusEnumType::Rejected, "Rejected"}, + {SetMonitoringStatusEnumType::Duplicate, "Duplicate"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/SetMonitoringStatusEnumType20.h b/src/ocpp20/types/SetMonitoringStatusEnumType20.h new file mode 100644 index 00000000..0c560da9 --- /dev/null +++ b/src/ocpp20/types/SetMonitoringStatusEnumType20.h @@ -0,0 +1,54 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SetVariableMonitoringRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_SETMONITORINGSTATUSENUMTYPE_H +#define OPENOCPP_OCPP20_SETMONITORINGSTATUSENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Status is OK if a value could be returned. Otherwise this will indicate the reason why a value could not be returned. */ +enum class SetMonitoringStatusEnumType +{ + Accepted, + UnknownComponent, + UnknownVariable, + UnsupportedMonitorType, + Rejected, + Duplicate, +}; + +/** @brief Helper to convert a SetMonitoringStatusEnumType enum to string */ +extern const EnumToStringFromString SetMonitoringStatusEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_SETMONITORINGSTATUSENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/SetNetworkProfileStatusEnumType20.cpp b/src/ocpp20/types/SetNetworkProfileStatusEnumType20.cpp new file mode 100644 index 00000000..4894593b --- /dev/null +++ b/src/ocpp20/types/SetNetworkProfileStatusEnumType20.cpp @@ -0,0 +1,42 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SetNetworkProfileRequest + OCPP 2.0.1 FINAL +*/ + +#include "SetNetworkProfileStatusEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a SetNetworkProfileStatusEnumType enum to string */ +const EnumToStringFromString SetNetworkProfileStatusEnumTypeHelper = { + {SetNetworkProfileStatusEnumType::Accepted, "Accepted"}, + {SetNetworkProfileStatusEnumType::Rejected, "Rejected"}, + {SetNetworkProfileStatusEnumType::Failed, "Failed"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/SetNetworkProfileStatusEnumType20.h b/src/ocpp20/types/SetNetworkProfileStatusEnumType20.h new file mode 100644 index 00000000..70a6122d --- /dev/null +++ b/src/ocpp20/types/SetNetworkProfileStatusEnumType20.h @@ -0,0 +1,51 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SetNetworkProfileRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_SETNETWORKPROFILESTATUSENUMTYPE_H +#define OPENOCPP_OCPP20_SETNETWORKPROFILESTATUSENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Result of operation. */ +enum class SetNetworkProfileStatusEnumType +{ + Accepted, + Rejected, + Failed, +}; + +/** @brief Helper to convert a SetNetworkProfileStatusEnumType enum to string */ +extern const EnumToStringFromString SetNetworkProfileStatusEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_SETNETWORKPROFILESTATUSENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/SetVariableDataType20.cpp b/src/ocpp20/types/SetVariableDataType20.cpp new file mode 100644 index 00000000..c423dc51 --- /dev/null +++ b/src/ocpp20/types/SetVariableDataType20.cpp @@ -0,0 +1,118 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SetVariablesRequest + OCPP 2.0.1 FINAL +*/ + +#include "SetVariableDataType20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Convert a SetVariableDataType from a JSON representation */ +bool SetVariableDataTypeConverter::fromJson(const rapidjson::Value& json, + SetVariableDataType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // attributeType + if (json.HasMember("attributeType")) + { + data.attributeType = AttributeEnumTypeHelper.fromString(json["attributeType"].GetString()); + } + + // attributeValue + extract(json, "attributeValue", data.attributeValue); + + // component + ComponentTypeConverter component_converter; + ret = ret && component_converter.fromJson(json["component"], data.component, error_code, error_message); + + // variable + VariableTypeConverter variable_converter; + ret = ret && variable_converter.fromJson(json["variable"], data.variable, error_code, error_message); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a SetVariableDataType to a JSON representation */ +bool SetVariableDataTypeConverter::toJson(const SetVariableDataType& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // attributeType + if (data.attributeType.isSet()) + { + fill(json, "attributeType", AttributeEnumTypeHelper.toString(data.attributeType)); + } + + // attributeValue + fill(json, "attributeValue", data.attributeValue); + + // component + ComponentTypeConverter component_converter; + component_converter.setAllocator(allocator); + rapidjson::Document component_doc(rapidjson::kObjectType); + ret = ret && component_converter.toJson(data.component, component_doc); + json.AddMember(rapidjson::StringRef("component"), component_doc.Move(), *allocator); + + // variable + VariableTypeConverter variable_converter; + variable_converter.setAllocator(allocator); + rapidjson::Document variable_doc(rapidjson::kObjectType); + ret = ret && variable_converter.toJson(data.variable, variable_doc); + json.AddMember(rapidjson::StringRef("variable"), variable_doc.Move(), *allocator); + + return ret; +} + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/SetVariableDataType20.h b/src/ocpp20/types/SetVariableDataType20.h new file mode 100644 index 00000000..a4aa2b43 --- /dev/null +++ b/src/ocpp20/types/SetVariableDataType20.h @@ -0,0 +1,81 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SetVariablesRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_SETVARIABLEDATATYPE_H +#define OPENOCPP_OCPP20_SETVARIABLEDATATYPE_H + +#include "AttributeEnumType20.h" +#include "ComponentType20.h" +#include "CustomDataType20.h" +#include "VariableType20.h" + +#include "CiStringType.h" +#include "IMessageConverter.h" +#include "Optional.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief */ +struct SetVariableDataType +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::Optional attributeType; + /** @brief Value to be assigned to attribute of variable. + +The Configuration Variable <<configkey-configuration-value-size,ConfigurationValueSize>> can be used to limit SetVariableData.attributeValue and VariableCharacteristics.valueList. The max size of these values will always remain equal. */ + ocpp::types::CiStringType<1000u> attributeValue; + /** @brief */ + ComponentType component; + /** @brief */ + VariableType variable; +}; + +/** @brief Converter class for SetVariableDataType type */ +class SetVariableDataTypeConverter : public ocpp::messages::IMessageConverter +{ + public: + /** @brief Clone the converter */ + ocpp::messages::IMessageConverter* clone() const override { return new SetVariableDataTypeConverter(); } + + /** @brief Convert a SetVariableDataType from a JSON representation */ + bool fromJson(const rapidjson::Value& json, + SetVariableDataType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) override; + + /** @brief Convert a SetVariableDataType to a JSON representation */ + bool toJson(const SetVariableDataType& data, rapidjson::Document& json) override; +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_SETVARIABLEDATATYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/SetVariableResultType20.cpp b/src/ocpp20/types/SetVariableResultType20.cpp new file mode 100644 index 00000000..a08a1509 --- /dev/null +++ b/src/ocpp20/types/SetVariableResultType20.cpp @@ -0,0 +1,136 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SetVariablesRequest + OCPP 2.0.1 FINAL +*/ + +#include "SetVariableResultType20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Convert a SetVariableResultType from a JSON representation */ +bool SetVariableResultTypeConverter::fromJson(const rapidjson::Value& json, + SetVariableResultType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // attributeType + if (json.HasMember("attributeType")) + { + data.attributeType = AttributeEnumTypeHelper.fromString(json["attributeType"].GetString()); + } + + // attributeStatus + data.attributeStatus = SetVariableStatusEnumTypeHelper.fromString(json["attributeStatus"].GetString()); + + // attributeStatusInfo + if (json.HasMember("attributeStatusInfo")) + { + StatusInfoTypeConverter attributeStatusInfo_converter; + ret = + ret && attributeStatusInfo_converter.fromJson(json["attributeStatusInfo"], data.attributeStatusInfo, error_code, error_message); + } + + // component + ComponentTypeConverter component_converter; + ret = ret && component_converter.fromJson(json["component"], data.component, error_code, error_message); + + // variable + VariableTypeConverter variable_converter; + ret = ret && variable_converter.fromJson(json["variable"], data.variable, error_code, error_message); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a SetVariableResultType to a JSON representation */ +bool SetVariableResultTypeConverter::toJson(const SetVariableResultType& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // attributeType + if (data.attributeType.isSet()) + { + fill(json, "attributeType", AttributeEnumTypeHelper.toString(data.attributeType)); + } + + // attributeStatus + fill(json, "attributeStatus", SetVariableStatusEnumTypeHelper.toString(data.attributeStatus)); + + // attributeStatusInfo + if (data.attributeStatusInfo.isSet()) + { + StatusInfoTypeConverter attributeStatusInfo_converter; + attributeStatusInfo_converter.setAllocator(allocator); + rapidjson::Document attributeStatusInfo_doc(rapidjson::kObjectType); + ret = ret && attributeStatusInfo_converter.toJson(data.attributeStatusInfo, attributeStatusInfo_doc); + json.AddMember(rapidjson::StringRef("attributeStatusInfo"), attributeStatusInfo_doc.Move(), *allocator); + } + + // component + ComponentTypeConverter component_converter; + component_converter.setAllocator(allocator); + rapidjson::Document component_doc(rapidjson::kObjectType); + ret = ret && component_converter.toJson(data.component, component_doc); + json.AddMember(rapidjson::StringRef("component"), component_doc.Move(), *allocator); + + // variable + VariableTypeConverter variable_converter; + variable_converter.setAllocator(allocator); + rapidjson::Document variable_doc(rapidjson::kObjectType); + ret = ret && variable_converter.toJson(data.variable, variable_doc); + json.AddMember(rapidjson::StringRef("variable"), variable_doc.Move(), *allocator); + + return ret; +} + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/SetVariableResultType20.h b/src/ocpp20/types/SetVariableResultType20.h new file mode 100644 index 00000000..da776fb9 --- /dev/null +++ b/src/ocpp20/types/SetVariableResultType20.h @@ -0,0 +1,82 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SetVariablesRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_SETVARIABLERESULTTYPE_H +#define OPENOCPP_OCPP20_SETVARIABLERESULTTYPE_H + +#include "AttributeEnumType20.h" +#include "ComponentType20.h" +#include "CustomDataType20.h" +#include "SetVariableStatusEnumType20.h" +#include "StatusInfoType20.h" +#include "VariableType20.h" + +#include "IMessageConverter.h" +#include "Optional.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief */ +struct SetVariableResultType +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::Optional attributeType; + /** @brief */ + SetVariableStatusEnumType attributeStatus; + /** @brief */ + ocpp::types::Optional attributeStatusInfo; + /** @brief */ + ComponentType component; + /** @brief */ + VariableType variable; +}; + +/** @brief Converter class for SetVariableResultType type */ +class SetVariableResultTypeConverter : public ocpp::messages::IMessageConverter +{ + public: + /** @brief Clone the converter */ + ocpp::messages::IMessageConverter* clone() const override { return new SetVariableResultTypeConverter(); } + + /** @brief Convert a SetVariableResultType from a JSON representation */ + bool fromJson(const rapidjson::Value& json, + SetVariableResultType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) override; + + /** @brief Convert a SetVariableResultType to a JSON representation */ + bool toJson(const SetVariableResultType& data, rapidjson::Document& json) override; +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_SETVARIABLERESULTTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/SetVariableStatusEnumType20.cpp b/src/ocpp20/types/SetVariableStatusEnumType20.cpp new file mode 100644 index 00000000..ac853ca0 --- /dev/null +++ b/src/ocpp20/types/SetVariableStatusEnumType20.cpp @@ -0,0 +1,45 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SetVariablesRequest + OCPP 2.0.1 FINAL +*/ + +#include "SetVariableStatusEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a SetVariableStatusEnumType enum to string */ +const EnumToStringFromString SetVariableStatusEnumTypeHelper = { + {SetVariableStatusEnumType::Accepted, "Accepted"}, + {SetVariableStatusEnumType::Rejected, "Rejected"}, + {SetVariableStatusEnumType::UnknownComponent, "UnknownComponent"}, + {SetVariableStatusEnumType::UnknownVariable, "UnknownVariable"}, + {SetVariableStatusEnumType::NotSupportedAttributeType, "NotSupportedAttributeType"}, + {SetVariableStatusEnumType::RebootRequired, "RebootRequired"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/SetVariableStatusEnumType20.h b/src/ocpp20/types/SetVariableStatusEnumType20.h new file mode 100644 index 00000000..e85cf1ad --- /dev/null +++ b/src/ocpp20/types/SetVariableStatusEnumType20.h @@ -0,0 +1,54 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SetVariablesRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_SETVARIABLESTATUSENUMTYPE_H +#define OPENOCPP_OCPP20_SETVARIABLESTATUSENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Result status of setting the variable. */ +enum class SetVariableStatusEnumType +{ + Accepted, + Rejected, + UnknownComponent, + UnknownVariable, + NotSupportedAttributeType, + RebootRequired, +}; + +/** @brief Helper to convert a SetVariableStatusEnumType enum to string */ +extern const EnumToStringFromString SetVariableStatusEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_SETVARIABLESTATUSENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/SignedMeterValueType20.cpp b/src/ocpp20/types/SignedMeterValueType20.cpp new file mode 100644 index 00000000..b4d1fdb8 --- /dev/null +++ b/src/ocpp20/types/SignedMeterValueType20.cpp @@ -0,0 +1,102 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:MeterValuesRequest + OCPP 2.0.1 FINAL +*/ + +#include "SignedMeterValueType20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Convert a SignedMeterValueType from a JSON representation */ +bool SignedMeterValueTypeConverter::fromJson(const rapidjson::Value& json, + SignedMeterValueType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // signedMeterData + extract(json, "signedMeterData", data.signedMeterData); + + // signingMethod + extract(json, "signingMethod", data.signingMethod); + + // encodingMethod + extract(json, "encodingMethod", data.encodingMethod); + + // publicKey + extract(json, "publicKey", data.publicKey); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a SignedMeterValueType to a JSON representation */ +bool SignedMeterValueTypeConverter::toJson(const SignedMeterValueType& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // signedMeterData + fill(json, "signedMeterData", data.signedMeterData); + + // signingMethod + fill(json, "signingMethod", data.signingMethod); + + // encodingMethod + fill(json, "encodingMethod", data.encodingMethod); + + // publicKey + fill(json, "publicKey", data.publicKey); + + return ret; +} + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/SignedMeterValueType20.h b/src/ocpp20/types/SignedMeterValueType20.h new file mode 100644 index 00000000..8246923e --- /dev/null +++ b/src/ocpp20/types/SignedMeterValueType20.h @@ -0,0 +1,77 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:MeterValuesRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_SIGNEDMETERVALUETYPE_H +#define OPENOCPP_OCPP20_SIGNEDMETERVALUETYPE_H + +#include "CustomDataType20.h" + +#include "CiStringType.h" +#include "IMessageConverter.h" +#include "Optional.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Represent a signed version of the meter value. + */ +struct SignedMeterValueType +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief Base64 encoded, contains the signed data which might contain more then just the meter value. It can contain information like timestamps, reference to a customer etc. */ + ocpp::types::CiStringType<2500u> signedMeterData; + /** @brief Method used to create the digital signature. */ + ocpp::types::CiStringType<50u> signingMethod; + /** @brief Method used to encode the meter values before applying the digital signature algorithm. */ + ocpp::types::CiStringType<50u> encodingMethod; + /** @brief Base64 encoded, sending depends on configuration variable _PublicKeyWithSignedMeterValue_. */ + ocpp::types::CiStringType<2500u> publicKey; +}; + +/** @brief Converter class for SignedMeterValueType type */ +class SignedMeterValueTypeConverter : public ocpp::messages::IMessageConverter +{ + public: + /** @brief Clone the converter */ + ocpp::messages::IMessageConverter* clone() const override { return new SignedMeterValueTypeConverter(); } + + /** @brief Convert a SignedMeterValueType from a JSON representation */ + bool fromJson(const rapidjson::Value& json, + SignedMeterValueType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) override; + + /** @brief Convert a SignedMeterValueType to a JSON representation */ + bool toJson(const SignedMeterValueType& data, rapidjson::Document& json) override; +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_SIGNEDMETERVALUETYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/StatusInfoType20.cpp b/src/ocpp20/types/StatusInfoType20.cpp new file mode 100644 index 00000000..a2f8566d --- /dev/null +++ b/src/ocpp20/types/StatusInfoType20.cpp @@ -0,0 +1,90 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:RequestStartTransactionRequest + OCPP 2.0.1 FINAL +*/ + +#include "StatusInfoType20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Convert a StatusInfoType from a JSON representation */ +bool StatusInfoTypeConverter::fromJson(const rapidjson::Value& json, + StatusInfoType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // reasonCode + extract(json, "reasonCode", data.reasonCode); + + // additionalInfo + extract(json, "additionalInfo", data.additionalInfo); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a StatusInfoType to a JSON representation */ +bool StatusInfoTypeConverter::toJson(const StatusInfoType& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // reasonCode + fill(json, "reasonCode", data.reasonCode); + + // additionalInfo + fill(json, "additionalInfo", data.additionalInfo); + + return ret; +} + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/StatusInfoType20.h b/src/ocpp20/types/StatusInfoType20.h new file mode 100644 index 00000000..5f66f979 --- /dev/null +++ b/src/ocpp20/types/StatusInfoType20.h @@ -0,0 +1,73 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:RequestStartTransactionRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_STATUSINFOTYPE_H +#define OPENOCPP_OCPP20_STATUSINFOTYPE_H + +#include "CustomDataType20.h" + +#include "CiStringType.h" +#include "IMessageConverter.h" +#include "Optional.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Element providing more information about the status. + */ +struct StatusInfoType +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief A predefined code for the reason why the status is returned in this response. The string is case-insensitive. */ + ocpp::types::CiStringType<20u> reasonCode; + /** @brief Additional text to provide detailed information. */ + ocpp::types::Optional> additionalInfo; +}; + +/** @brief Converter class for StatusInfoType type */ +class StatusInfoTypeConverter : public ocpp::messages::IMessageConverter +{ + public: + /** @brief Clone the converter */ + ocpp::messages::IMessageConverter* clone() const override { return new StatusInfoTypeConverter(); } + + /** @brief Convert a StatusInfoType from a JSON representation */ + bool fromJson(const rapidjson::Value& json, + StatusInfoType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) override; + + /** @brief Convert a StatusInfoType to a JSON representation */ + bool toJson(const StatusInfoType& data, rapidjson::Document& json) override; +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_STATUSINFOTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/TransactionEventEnumType20.cpp b/src/ocpp20/types/TransactionEventEnumType20.cpp new file mode 100644 index 00000000..e22a16f5 --- /dev/null +++ b/src/ocpp20/types/TransactionEventEnumType20.cpp @@ -0,0 +1,42 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:TransactionEventRequest + OCPP 2.0.1 FINAL +*/ + +#include "TransactionEventEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a TransactionEventEnumType enum to string */ +const EnumToStringFromString TransactionEventEnumTypeHelper = { + {TransactionEventEnumType::Ended, "Ended"}, + {TransactionEventEnumType::Started, "Started"}, + {TransactionEventEnumType::Updated, "Updated"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/TransactionEventEnumType20.h b/src/ocpp20/types/TransactionEventEnumType20.h new file mode 100644 index 00000000..c0fafb08 --- /dev/null +++ b/src/ocpp20/types/TransactionEventEnumType20.h @@ -0,0 +1,52 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:TransactionEventRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_TRANSACTIONEVENTENUMTYPE_H +#define OPENOCPP_OCPP20_TRANSACTIONEVENTENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief This contains the type of this event. +The first TransactionEvent of a transaction SHALL contain: "Started" The last TransactionEvent of a transaction SHALL contain: "Ended" All others SHALL contain: "Updated" */ +enum class TransactionEventEnumType +{ + Ended, + Started, + Updated, +}; + +/** @brief Helper to convert a TransactionEventEnumType enum to string */ +extern const EnumToStringFromString TransactionEventEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_TRANSACTIONEVENTENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/TransactionType20.cpp b/src/ocpp20/types/TransactionType20.cpp new file mode 100644 index 00000000..fcfd150a --- /dev/null +++ b/src/ocpp20/types/TransactionType20.cpp @@ -0,0 +1,120 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:TransactionEventRequest + OCPP 2.0.1 FINAL +*/ + +#include "TransactionType20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Convert a TransactionType from a JSON representation */ +bool TransactionTypeConverter::fromJson(const rapidjson::Value& json, + TransactionType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // transactionId + extract(json, "transactionId", data.transactionId); + + // chargingState + if (json.HasMember("chargingState")) + { + data.chargingState = ChargingStateEnumTypeHelper.fromString(json["chargingState"].GetString()); + } + + // timeSpentCharging + extract(json, "timeSpentCharging", data.timeSpentCharging); + + // stoppedReason + if (json.HasMember("stoppedReason")) + { + data.stoppedReason = ReasonEnumTypeHelper.fromString(json["stoppedReason"].GetString()); + } + + // remoteStartId + extract(json, "remoteStartId", data.remoteStartId); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a TransactionType to a JSON representation */ +bool TransactionTypeConverter::toJson(const TransactionType& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // transactionId + fill(json, "transactionId", data.transactionId); + + // chargingState + if (data.chargingState.isSet()) + { + fill(json, "chargingState", ChargingStateEnumTypeHelper.toString(data.chargingState)); + } + + // timeSpentCharging + fill(json, "timeSpentCharging", data.timeSpentCharging); + + // stoppedReason + if (data.stoppedReason.isSet()) + { + fill(json, "stoppedReason", ReasonEnumTypeHelper.toString(data.stoppedReason)); + } + + // remoteStartId + fill(json, "remoteStartId", data.remoteStartId); + + return ret; +} + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/TransactionType20.h b/src/ocpp20/types/TransactionType20.h new file mode 100644 index 00000000..aaacfdf2 --- /dev/null +++ b/src/ocpp20/types/TransactionType20.h @@ -0,0 +1,84 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:TransactionEventRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_TRANSACTIONTYPE_H +#define OPENOCPP_OCPP20_TRANSACTIONTYPE_H + +#include "ChargingStateEnumType20.h" +#include "CustomDataType20.h" +#include "ReasonEnumType20.h" + +#include "CiStringType.h" +#include "IMessageConverter.h" +#include "Optional.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Transaction +urn:x-oca:ocpp:uid:2:233318 + */ +struct TransactionType +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief This contains the Id of the transaction. */ + ocpp::types::CiStringType<36u> transactionId; + /** @brief */ + ocpp::types::Optional chargingState; + /** @brief Transaction. Time_ Spent_ Charging. Elapsed_ Time +urn:x-oca:ocpp:uid:1:569415 +Contains the total time that energy flowed from EVSE to EV during the transaction (in seconds). Note that timeSpentCharging is smaller or equal to the duration of the transaction. */ + ocpp::types::Optional timeSpentCharging; + /** @brief */ + ocpp::types::Optional stoppedReason; + /** @brief The ID given to remote start request (<<requeststarttransactionrequest, RequestStartTransactionRequest>>. This enables to CSMS to match the started transaction to the given start request. */ + ocpp::types::Optional remoteStartId; +}; + +/** @brief Converter class for TransactionType type */ +class TransactionTypeConverter : public ocpp::messages::IMessageConverter +{ + public: + /** @brief Clone the converter */ + ocpp::messages::IMessageConverter* clone() const override { return new TransactionTypeConverter(); } + + /** @brief Convert a TransactionType from a JSON representation */ + bool fromJson(const rapidjson::Value& json, + TransactionType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) override; + + /** @brief Convert a TransactionType to a JSON representation */ + bool toJson(const TransactionType& data, rapidjson::Document& json) override; +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_TRANSACTIONTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/TriggerMessageStatusEnumType20.cpp b/src/ocpp20/types/TriggerMessageStatusEnumType20.cpp new file mode 100644 index 00000000..0b038da3 --- /dev/null +++ b/src/ocpp20/types/TriggerMessageStatusEnumType20.cpp @@ -0,0 +1,42 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:TriggerMessageRequest + OCPP 2.0.1 FINAL +*/ + +#include "TriggerMessageStatusEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a TriggerMessageStatusEnumType enum to string */ +const EnumToStringFromString TriggerMessageStatusEnumTypeHelper = { + {TriggerMessageStatusEnumType::Accepted, "Accepted"}, + {TriggerMessageStatusEnumType::Rejected, "Rejected"}, + {TriggerMessageStatusEnumType::NotImplemented, "NotImplemented"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/TriggerMessageStatusEnumType20.h b/src/ocpp20/types/TriggerMessageStatusEnumType20.h new file mode 100644 index 00000000..b9924445 --- /dev/null +++ b/src/ocpp20/types/TriggerMessageStatusEnumType20.h @@ -0,0 +1,51 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:TriggerMessageRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_TRIGGERMESSAGESTATUSENUMTYPE_H +#define OPENOCPP_OCPP20_TRIGGERMESSAGESTATUSENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Indicates whether the Charging Station will send the requested notification or not. */ +enum class TriggerMessageStatusEnumType +{ + Accepted, + Rejected, + NotImplemented, +}; + +/** @brief Helper to convert a TriggerMessageStatusEnumType enum to string */ +extern const EnumToStringFromString TriggerMessageStatusEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_TRIGGERMESSAGESTATUSENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/TriggerReasonEnumType20.cpp b/src/ocpp20/types/TriggerReasonEnumType20.cpp new file mode 100644 index 00000000..a76382cf --- /dev/null +++ b/src/ocpp20/types/TriggerReasonEnumType20.cpp @@ -0,0 +1,60 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:TransactionEventRequest + OCPP 2.0.1 FINAL +*/ + +#include "TriggerReasonEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a TriggerReasonEnumType enum to string */ +const EnumToStringFromString TriggerReasonEnumTypeHelper = { + {TriggerReasonEnumType::Authorized, "Authorized"}, + {TriggerReasonEnumType::CablePluggedIn, "CablePluggedIn"}, + {TriggerReasonEnumType::ChargingRateChanged, "ChargingRateChanged"}, + {TriggerReasonEnumType::ChargingStateChanged, "ChargingStateChanged"}, + {TriggerReasonEnumType::Deauthorized, "Deauthorized"}, + {TriggerReasonEnumType::EnergyLimitReached, "EnergyLimitReached"}, + {TriggerReasonEnumType::EVCommunicationLost, "EVCommunicationLost"}, + {TriggerReasonEnumType::EVConnectTimeout, "EVConnectTimeout"}, + {TriggerReasonEnumType::MeterValueClock, "MeterValueClock"}, + {TriggerReasonEnumType::MeterValuePeriodic, "MeterValuePeriodic"}, + {TriggerReasonEnumType::TimeLimitReached, "TimeLimitReached"}, + {TriggerReasonEnumType::Trigger, "Trigger"}, + {TriggerReasonEnumType::UnlockCommand, "UnlockCommand"}, + {TriggerReasonEnumType::StopAuthorized, "StopAuthorized"}, + {TriggerReasonEnumType::EVDeparted, "EVDeparted"}, + {TriggerReasonEnumType::EVDetected, "EVDetected"}, + {TriggerReasonEnumType::RemoteStop, "RemoteStop"}, + {TriggerReasonEnumType::RemoteStart, "RemoteStart"}, + {TriggerReasonEnumType::AbnormalCondition, "AbnormalCondition"}, + {TriggerReasonEnumType::SignedDataReceived, "SignedDataReceived"}, + {TriggerReasonEnumType::ResetCommand, "ResetCommand"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/TriggerReasonEnumType20.h b/src/ocpp20/types/TriggerReasonEnumType20.h new file mode 100644 index 00000000..61867191 --- /dev/null +++ b/src/ocpp20/types/TriggerReasonEnumType20.h @@ -0,0 +1,69 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:TransactionEventRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_TRIGGERREASONENUMTYPE_H +#define OPENOCPP_OCPP20_TRIGGERREASONENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Reason the Charging Station sends this message to the CSMS */ +enum class TriggerReasonEnumType +{ + Authorized, + CablePluggedIn, + ChargingRateChanged, + ChargingStateChanged, + Deauthorized, + EnergyLimitReached, + EVCommunicationLost, + EVConnectTimeout, + MeterValueClock, + MeterValuePeriodic, + TimeLimitReached, + Trigger, + UnlockCommand, + StopAuthorized, + EVDeparted, + EVDetected, + RemoteStop, + RemoteStart, + AbnormalCondition, + SignedDataReceived, + ResetCommand, +}; + +/** @brief Helper to convert a TriggerReasonEnumType enum to string */ +extern const EnumToStringFromString TriggerReasonEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_TRIGGERREASONENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/UnitOfMeasureType20.cpp b/src/ocpp20/types/UnitOfMeasureType20.cpp new file mode 100644 index 00000000..d81bab4a --- /dev/null +++ b/src/ocpp20/types/UnitOfMeasureType20.cpp @@ -0,0 +1,90 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:MeterValuesRequest + OCPP 2.0.1 FINAL +*/ + +#include "UnitOfMeasureType20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Convert a UnitOfMeasureType from a JSON representation */ +bool UnitOfMeasureTypeConverter::fromJson(const rapidjson::Value& json, + UnitOfMeasureType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // unit + extract(json, "unit", data.unit); + + // multiplier + extract(json, "multiplier", data.multiplier); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a UnitOfMeasureType to a JSON representation */ +bool UnitOfMeasureTypeConverter::toJson(const UnitOfMeasureType& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // unit + fill(json, "unit", data.unit); + + // multiplier + fill(json, "multiplier", data.multiplier); + + return ret; +} + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/UnitOfMeasureType20.h b/src/ocpp20/types/UnitOfMeasureType20.h new file mode 100644 index 00000000..4af4ec5c --- /dev/null +++ b/src/ocpp20/types/UnitOfMeasureType20.h @@ -0,0 +1,75 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:MeterValuesRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_UNITOFMEASURETYPE_H +#define OPENOCPP_OCPP20_UNITOFMEASURETYPE_H + +#include "CustomDataType20.h" + +#include "CiStringType.h" +#include "IMessageConverter.h" +#include "Optional.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Represents a UnitOfMeasure with a multiplier + */ +struct UnitOfMeasureType +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief Unit of the value. Default = "Wh" if the (default) measurand is an "Energy" type. +This field SHALL use a value from the list Standardized Units of Measurements in Part 2 Appendices. +If an applicable unit is available in that list, otherwise a "custom" unit might be used. */ + ocpp::types::Optional> unit; + /** @brief Multiplier, this value represents the exponent to base 10. I.e. multiplier 3 means 10 raised to the 3rd power. Default is 0. */ + ocpp::types::Optional multiplier; +}; + +/** @brief Converter class for UnitOfMeasureType type */ +class UnitOfMeasureTypeConverter : public ocpp::messages::IMessageConverter +{ + public: + /** @brief Clone the converter */ + ocpp::messages::IMessageConverter* clone() const override { return new UnitOfMeasureTypeConverter(); } + + /** @brief Convert a UnitOfMeasureType from a JSON representation */ + bool fromJson(const rapidjson::Value& json, + UnitOfMeasureType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) override; + + /** @brief Convert a UnitOfMeasureType to a JSON representation */ + bool toJson(const UnitOfMeasureType& data, rapidjson::Document& json) override; +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_UNITOFMEASURETYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/UnlockStatusEnumType20.cpp b/src/ocpp20/types/UnlockStatusEnumType20.cpp new file mode 100644 index 00000000..1fb78661 --- /dev/null +++ b/src/ocpp20/types/UnlockStatusEnumType20.cpp @@ -0,0 +1,43 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:UnlockConnectorRequest + OCPP 2.0.1 FINAL +*/ + +#include "UnlockStatusEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a UnlockStatusEnumType enum to string */ +const EnumToStringFromString UnlockStatusEnumTypeHelper = { + {UnlockStatusEnumType::Unlocked, "Unlocked"}, + {UnlockStatusEnumType::UnlockFailed, "UnlockFailed"}, + {UnlockStatusEnumType::OngoingAuthorizedTransaction, "OngoingAuthorizedTransaction"}, + {UnlockStatusEnumType::UnknownConnector, "UnknownConnector"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/UnlockStatusEnumType20.h b/src/ocpp20/types/UnlockStatusEnumType20.h new file mode 100644 index 00000000..6e9454b3 --- /dev/null +++ b/src/ocpp20/types/UnlockStatusEnumType20.h @@ -0,0 +1,52 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:UnlockConnectorRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_UNLOCKSTATUSENUMTYPE_H +#define OPENOCPP_OCPP20_UNLOCKSTATUSENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief This indicates whether the Charging Station has unlocked the connector. */ +enum class UnlockStatusEnumType +{ + Unlocked, + UnlockFailed, + OngoingAuthorizedTransaction, + UnknownConnector, +}; + +/** @brief Helper to convert a UnlockStatusEnumType enum to string */ +extern const EnumToStringFromString UnlockStatusEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_UNLOCKSTATUSENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/UnpublishFirmwareStatusEnumType20.cpp b/src/ocpp20/types/UnpublishFirmwareStatusEnumType20.cpp new file mode 100644 index 00000000..b37eb862 --- /dev/null +++ b/src/ocpp20/types/UnpublishFirmwareStatusEnumType20.cpp @@ -0,0 +1,42 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:UnpublishFirmwareRequest + OCPP 2.0.1 FINAL +*/ + +#include "UnpublishFirmwareStatusEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a UnpublishFirmwareStatusEnumType enum to string */ +const EnumToStringFromString UnpublishFirmwareStatusEnumTypeHelper = { + {UnpublishFirmwareStatusEnumType::DownloadOngoing, "DownloadOngoing"}, + {UnpublishFirmwareStatusEnumType::NoFirmware, "NoFirmware"}, + {UnpublishFirmwareStatusEnumType::Unpublished, "Unpublished"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/UnpublishFirmwareStatusEnumType20.h b/src/ocpp20/types/UnpublishFirmwareStatusEnumType20.h new file mode 100644 index 00000000..225ab12d --- /dev/null +++ b/src/ocpp20/types/UnpublishFirmwareStatusEnumType20.h @@ -0,0 +1,51 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:UnpublishFirmwareRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_UNPUBLISHFIRMWARESTATUSENUMTYPE_H +#define OPENOCPP_OCPP20_UNPUBLISHFIRMWARESTATUSENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Indicates whether the Local Controller succeeded in unpublishing the firmware. */ +enum class UnpublishFirmwareStatusEnumType +{ + DownloadOngoing, + NoFirmware, + Unpublished, +}; + +/** @brief Helper to convert a UnpublishFirmwareStatusEnumType enum to string */ +extern const EnumToStringFromString UnpublishFirmwareStatusEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_UNPUBLISHFIRMWARESTATUSENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/UpdateEnumType20.cpp b/src/ocpp20/types/UpdateEnumType20.cpp new file mode 100644 index 00000000..7e463d5d --- /dev/null +++ b/src/ocpp20/types/UpdateEnumType20.cpp @@ -0,0 +1,41 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SendLocalListRequest + OCPP 2.0.1 FINAL +*/ + +#include "UpdateEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a UpdateEnumType enum to string */ +const EnumToStringFromString UpdateEnumTypeHelper = { + {UpdateEnumType::Differential, "Differential"}, + {UpdateEnumType::Full, "Full"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/UpdateEnumType20.h b/src/ocpp20/types/UpdateEnumType20.h new file mode 100644 index 00000000..a87279d5 --- /dev/null +++ b/src/ocpp20/types/UpdateEnumType20.h @@ -0,0 +1,50 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SendLocalListRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_UPDATEENUMTYPE_H +#define OPENOCPP_OCPP20_UPDATEENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief This contains the type of update (full or differential) of this request. */ +enum class UpdateEnumType +{ + Differential, + Full, +}; + +/** @brief Helper to convert a UpdateEnumType enum to string */ +extern const EnumToStringFromString UpdateEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_UPDATEENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/UpdateFirmwareStatusEnumType20.cpp b/src/ocpp20/types/UpdateFirmwareStatusEnumType20.cpp new file mode 100644 index 00000000..ce3c8466 --- /dev/null +++ b/src/ocpp20/types/UpdateFirmwareStatusEnumType20.cpp @@ -0,0 +1,44 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:UpdateFirmwareRequest + OCPP 2.0.1 FINAL +*/ + +#include "UpdateFirmwareStatusEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a UpdateFirmwareStatusEnumType enum to string */ +const EnumToStringFromString UpdateFirmwareStatusEnumTypeHelper = { + {UpdateFirmwareStatusEnumType::Accepted, "Accepted"}, + {UpdateFirmwareStatusEnumType::Rejected, "Rejected"}, + {UpdateFirmwareStatusEnumType::AcceptedCanceled, "AcceptedCanceled"}, + {UpdateFirmwareStatusEnumType::InvalidCertificate, "InvalidCertificate"}, + {UpdateFirmwareStatusEnumType::RevokedCertificate, "RevokedCertificate"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/UpdateFirmwareStatusEnumType20.h b/src/ocpp20/types/UpdateFirmwareStatusEnumType20.h new file mode 100644 index 00000000..ed3a1a95 --- /dev/null +++ b/src/ocpp20/types/UpdateFirmwareStatusEnumType20.h @@ -0,0 +1,53 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:UpdateFirmwareRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_UPDATEFIRMWARESTATUSENUMTYPE_H +#define OPENOCPP_OCPP20_UPDATEFIRMWARESTATUSENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief This field indicates whether the Charging Station was able to accept the request. */ +enum class UpdateFirmwareStatusEnumType +{ + Accepted, + Rejected, + AcceptedCanceled, + InvalidCertificate, + RevokedCertificate, +}; + +/** @brief Helper to convert a UpdateFirmwareStatusEnumType enum to string */ +extern const EnumToStringFromString UpdateFirmwareStatusEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_UPDATEFIRMWARESTATUSENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/UploadLogStatusEnumType20.cpp b/src/ocpp20/types/UploadLogStatusEnumType20.cpp new file mode 100644 index 00000000..6c2d9b94 --- /dev/null +++ b/src/ocpp20/types/UploadLogStatusEnumType20.cpp @@ -0,0 +1,47 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:LogStatusNotificationRequest + OCPP 2.0.1 FINAL +*/ + +#include "UploadLogStatusEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a UploadLogStatusEnumType enum to string */ +const EnumToStringFromString UploadLogStatusEnumTypeHelper = { + {UploadLogStatusEnumType::BadMessage, "BadMessage"}, + {UploadLogStatusEnumType::Idle, "Idle"}, + {UploadLogStatusEnumType::NotSupportedOperation, "NotSupportedOperation"}, + {UploadLogStatusEnumType::PermissionDenied, "PermissionDenied"}, + {UploadLogStatusEnumType::Uploaded, "Uploaded"}, + {UploadLogStatusEnumType::UploadFailure, "UploadFailure"}, + {UploadLogStatusEnumType::Uploading, "Uploading"}, + {UploadLogStatusEnumType::AcceptedCanceled, "AcceptedCanceled"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/UploadLogStatusEnumType20.h b/src/ocpp20/types/UploadLogStatusEnumType20.h new file mode 100644 index 00000000..ff8f607f --- /dev/null +++ b/src/ocpp20/types/UploadLogStatusEnumType20.h @@ -0,0 +1,56 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:LogStatusNotificationRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_UPLOADLOGSTATUSENUMTYPE_H +#define OPENOCPP_OCPP20_UPLOADLOGSTATUSENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief This contains the status of the log upload. */ +enum class UploadLogStatusEnumType +{ + BadMessage, + Idle, + NotSupportedOperation, + PermissionDenied, + Uploaded, + UploadFailure, + Uploading, + AcceptedCanceled, +}; + +/** @brief Helper to convert a UploadLogStatusEnumType enum to string */ +extern const EnumToStringFromString UploadLogStatusEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_UPLOADLOGSTATUSENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/VPNEnumType20.cpp b/src/ocpp20/types/VPNEnumType20.cpp new file mode 100644 index 00000000..a3b1bfdc --- /dev/null +++ b/src/ocpp20/types/VPNEnumType20.cpp @@ -0,0 +1,43 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SetNetworkProfileRequest + OCPP 2.0.1 FINAL +*/ + +#include "VPNEnumType20.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Helper to convert a VPNEnumType enum to string */ +const EnumToStringFromString VPNEnumTypeHelper = { + {VPNEnumType::IKEv2, "IKEv2"}, + {VPNEnumType::IPSec, "IPSec"}, + {VPNEnumType::L2TP, "L2TP"}, + {VPNEnumType::PPTP, "PPTP"}, +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/VPNEnumType20.h b/src/ocpp20/types/VPNEnumType20.h new file mode 100644 index 00000000..171105fe --- /dev/null +++ b/src/ocpp20/types/VPNEnumType20.h @@ -0,0 +1,54 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SetNetworkProfileRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_VPNENUMTYPE_H +#define OPENOCPP_OCPP20_VPNENUMTYPE_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief VPN. Type. VPN_ Code +urn:x-oca:ocpp:uid:1:569277 +Type of VPN */ +enum class VPNEnumType +{ + IKEv2, + IPSec, + L2TP, + PPTP, +}; + +/** @brief Helper to convert a VPNEnumType enum to string */ +extern const EnumToStringFromString VPNEnumTypeHelper; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_VPNENUMTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/VPNType20.cpp b/src/ocpp20/types/VPNType20.cpp new file mode 100644 index 00000000..1a365c81 --- /dev/null +++ b/src/ocpp20/types/VPNType20.cpp @@ -0,0 +1,114 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SetNetworkProfileRequest + OCPP 2.0.1 FINAL +*/ + +#include "VPNType20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Convert a VPNType from a JSON representation */ +bool VPNTypeConverter::fromJson(const rapidjson::Value& json, + VPNType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // server + extract(json, "server", data.server); + + // user + extract(json, "user", data.user); + + // group + extract(json, "group", data.group); + + // password + extract(json, "password", data.password); + + // key + extract(json, "key", data.key); + + // type + data.type = VPNEnumTypeHelper.fromString(json["type"].GetString()); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a VPNType to a JSON representation */ +bool VPNTypeConverter::toJson(const VPNType& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // server + fill(json, "server", data.server); + + // user + fill(json, "user", data.user); + + // group + fill(json, "group", data.group); + + // password + fill(json, "password", data.password); + + // key + fill(json, "key", data.key); + + // type + fill(json, "type", VPNEnumTypeHelper.toString(data.type)); + + return ret; +} + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/VPNType20.h b/src/ocpp20/types/VPNType20.h new file mode 100644 index 00000000..f4983c80 --- /dev/null +++ b/src/ocpp20/types/VPNType20.h @@ -0,0 +1,94 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:SetNetworkProfileRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_VPNTYPE_H +#define OPENOCPP_OCPP20_VPNTYPE_H + +#include "CustomDataType20.h" +#include "VPNEnumType20.h" + +#include "CiStringType.h" +#include "IMessageConverter.h" +#include "Optional.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief VPN +urn:x-oca:ocpp:uid:2:233268 +VPN Configuration settings + */ +struct VPNType +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief VPN. Server. URI +urn:x-oca:ocpp:uid:1:569272 +VPN Server Address */ + ocpp::types::CiStringType<512u> server; + /** @brief VPN. User. User_ Name +urn:x-oca:ocpp:uid:1:569273 +VPN User */ + ocpp::types::CiStringType<20u> user; + /** @brief VPN. Group. Group_ Name +urn:x-oca:ocpp:uid:1:569274 +VPN group. */ + ocpp::types::Optional> group; + /** @brief VPN. Password. Password +urn:x-oca:ocpp:uid:1:569275 +VPN Password. */ + ocpp::types::CiStringType<20u> password; + /** @brief VPN. Key. VPN_ Key +urn:x-oca:ocpp:uid:1:569276 +VPN shared secret. */ + ocpp::types::CiStringType<255u> key; + /** @brief */ + VPNEnumType type; +}; + +/** @brief Converter class for VPNType type */ +class VPNTypeConverter : public ocpp::messages::IMessageConverter +{ + public: + /** @brief Clone the converter */ + ocpp::messages::IMessageConverter* clone() const override { return new VPNTypeConverter(); } + + /** @brief Convert a VPNType from a JSON representation */ + bool fromJson(const rapidjson::Value& json, + VPNType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) override; + + /** @brief Convert a VPNType to a JSON representation */ + bool toJson(const VPNType& data, rapidjson::Document& json) override; +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_VPNTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/VariableAttributeType20.cpp b/src/ocpp20/types/VariableAttributeType20.cpp new file mode 100644 index 00000000..7d3a57ac --- /dev/null +++ b/src/ocpp20/types/VariableAttributeType20.cpp @@ -0,0 +1,120 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:NotifyReportRequest + OCPP 2.0.1 FINAL +*/ + +#include "VariableAttributeType20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Convert a VariableAttributeType from a JSON representation */ +bool VariableAttributeTypeConverter::fromJson(const rapidjson::Value& json, + VariableAttributeType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // type + if (json.HasMember("type")) + { + data.type = AttributeEnumTypeHelper.fromString(json["type"].GetString()); + } + + // value + extract(json, "value", data.value); + + // mutability + if (json.HasMember("mutability")) + { + data.mutability = MutabilityEnumTypeHelper.fromString(json["mutability"].GetString()); + } + + // persistent + extract(json, "persistent", data.persistent); + + // constant + extract(json, "constant", data.constant); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a VariableAttributeType to a JSON representation */ +bool VariableAttributeTypeConverter::toJson(const VariableAttributeType& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // type + if (data.type.isSet()) + { + fill(json, "type", AttributeEnumTypeHelper.toString(data.type)); + } + + // value + fill(json, "value", data.value); + + // mutability + if (data.mutability.isSet()) + { + fill(json, "mutability", MutabilityEnumTypeHelper.toString(data.mutability)); + } + + // persistent + fill(json, "persistent", data.persistent); + + // constant + fill(json, "constant", data.constant); + + return ret; +} + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/VariableAttributeType20.h b/src/ocpp20/types/VariableAttributeType20.h new file mode 100644 index 00000000..6a2a25c1 --- /dev/null +++ b/src/ocpp20/types/VariableAttributeType20.h @@ -0,0 +1,83 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:NotifyReportRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_VARIABLEATTRIBUTETYPE_H +#define OPENOCPP_OCPP20_VARIABLEATTRIBUTETYPE_H + +#include "AttributeEnumType20.h" +#include "CustomDataType20.h" +#include "MutabilityEnumType20.h" + +#include "CiStringType.h" +#include "IMessageConverter.h" +#include "Optional.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Attribute data of a variable. + */ +struct VariableAttributeType +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief */ + ocpp::types::Optional type; + /** @brief Value of the attribute. May only be omitted when mutability is set to 'WriteOnly'. + +The Configuration Variable <<configkey-reporting-value-size,ReportingValueSize>> can be used to limit GetVariableResult.attributeValue, VariableAttribute.value and EventData.actualValue. The max size of these values will always remain equal. */ + ocpp::types::Optional> value; + /** @brief */ + ocpp::types::Optional mutability; + /** @brief If true, value will be persistent across system reboots or power down. Default when omitted is false. */ + ocpp::types::Optional persistent; + /** @brief If true, value that will never be changed by the Charging Station at runtime. Default when omitted is false. */ + ocpp::types::Optional constant; +}; + +/** @brief Converter class for VariableAttributeType type */ +class VariableAttributeTypeConverter : public ocpp::messages::IMessageConverter +{ + public: + /** @brief Clone the converter */ + ocpp::messages::IMessageConverter* clone() const override { return new VariableAttributeTypeConverter(); } + + /** @brief Convert a VariableAttributeType from a JSON representation */ + bool fromJson(const rapidjson::Value& json, + VariableAttributeType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) override; + + /** @brief Convert a VariableAttributeType to a JSON representation */ + bool toJson(const VariableAttributeType& data, rapidjson::Document& json) override; +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_VARIABLEATTRIBUTETYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/VariableCharacteristicsType20.cpp b/src/ocpp20/types/VariableCharacteristicsType20.cpp new file mode 100644 index 00000000..827110ed --- /dev/null +++ b/src/ocpp20/types/VariableCharacteristicsType20.cpp @@ -0,0 +1,114 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:NotifyReportRequest + OCPP 2.0.1 FINAL +*/ + +#include "VariableCharacteristicsType20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Convert a VariableCharacteristicsType from a JSON representation */ +bool VariableCharacteristicsTypeConverter::fromJson(const rapidjson::Value& json, + VariableCharacteristicsType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // unit + extract(json, "unit", data.unit); + + // dataType + data.dataType = DataEnumTypeHelper.fromString(json["dataType"].GetString()); + + // minLimit + extract(json, "minLimit", data.minLimit); + + // maxLimit + extract(json, "maxLimit", data.maxLimit); + + // valuesList + extract(json, "valuesList", data.valuesList); + + // supportsMonitoring + extract(json, "supportsMonitoring", data.supportsMonitoring); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a VariableCharacteristicsType to a JSON representation */ +bool VariableCharacteristicsTypeConverter::toJson(const VariableCharacteristicsType& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // unit + fill(json, "unit", data.unit); + + // dataType + fill(json, "dataType", DataEnumTypeHelper.toString(data.dataType)); + + // minLimit + fill(json, "minLimit", data.minLimit); + + // maxLimit + fill(json, "maxLimit", data.maxLimit); + + // valuesList + fill(json, "valuesList", data.valuesList); + + // supportsMonitoring + fill(json, "supportsMonitoring", data.supportsMonitoring); + + return ret; +} + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/VariableCharacteristicsType20.h b/src/ocpp20/types/VariableCharacteristicsType20.h new file mode 100644 index 00000000..6bb5dd52 --- /dev/null +++ b/src/ocpp20/types/VariableCharacteristicsType20.h @@ -0,0 +1,95 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:NotifyReportRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_VARIABLECHARACTERISTICSTYPE_H +#define OPENOCPP_OCPP20_VARIABLECHARACTERISTICSTYPE_H + +#include "CustomDataType20.h" +#include "DataEnumType20.h" + +#include "CiStringType.h" +#include "IMessageConverter.h" +#include "Optional.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Fixed read-only parameters of a variable. + */ +struct VariableCharacteristicsType +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief Unit of the variable. When the transmitted value has a unit, this field SHALL be included. */ + ocpp::types::Optional> unit; + /** @brief */ + DataEnumType dataType; + /** @brief Minimum possible value of this variable. */ + ocpp::types::Optional minLimit; + /** @brief Maximum possible value of this variable. When the datatype of this Variable is String, OptionList, SequenceList or MemberList, this field defines the maximum length of the (CSV) string. */ + ocpp::types::Optional maxLimit; + /** @brief Allowed values when variable is Option/Member/SequenceList. + +* OptionList: The (Actual) Variable value must be a single value from the reported (CSV) enumeration list. + +* MemberList: The (Actual) Variable value may be an (unordered) (sub-)set of the reported (CSV) valid values list. + +* SequenceList: The (Actual) Variable value may be an ordered (priority, etc) (sub-)set of the reported (CSV) valid values. + +This is a comma separated list. + +The Configuration Variable <<configkey-configuration-value-size,ConfigurationValueSize>> can be used to limit SetVariableData.attributeValue and VariableCharacteristics.valueList. The max size of these values will always remain equal. */ + ocpp::types::Optional> valuesList; + /** @brief Flag indicating if this variable supports monitoring. */ + bool supportsMonitoring; +}; + +/** @brief Converter class for VariableCharacteristicsType type */ +class VariableCharacteristicsTypeConverter : public ocpp::messages::IMessageConverter +{ + public: + /** @brief Clone the converter */ + ocpp::messages::IMessageConverter* clone() const override + { + return new VariableCharacteristicsTypeConverter(); + } + + /** @brief Convert a VariableCharacteristicsType from a JSON representation */ + bool fromJson(const rapidjson::Value& json, + VariableCharacteristicsType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) override; + + /** @brief Convert a VariableCharacteristicsType to a JSON representation */ + bool toJson(const VariableCharacteristicsType& data, rapidjson::Document& json) override; +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_VARIABLECHARACTERISTICSTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/VariableMonitoringType20.cpp b/src/ocpp20/types/VariableMonitoringType20.cpp new file mode 100644 index 00000000..847239d7 --- /dev/null +++ b/src/ocpp20/types/VariableMonitoringType20.cpp @@ -0,0 +1,108 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:NotifyMonitoringReportRequest + OCPP 2.0.1 FINAL +*/ + +#include "VariableMonitoringType20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Convert a VariableMonitoringType from a JSON representation */ +bool VariableMonitoringTypeConverter::fromJson(const rapidjson::Value& json, + VariableMonitoringType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // id + extract(json, "id", data.id); + + // transaction + extract(json, "transaction", data.transaction); + + // value + extract(json, "value", data.value); + + // type + data.type = MonitorEnumTypeHelper.fromString(json["type"].GetString()); + + // severity + extract(json, "severity", data.severity); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a VariableMonitoringType to a JSON representation */ +bool VariableMonitoringTypeConverter::toJson(const VariableMonitoringType& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // id + fill(json, "id", data.id); + + // transaction + fill(json, "transaction", data.transaction); + + // value + fill(json, "value", data.value); + + // type + fill(json, "type", MonitorEnumTypeHelper.toString(data.type)); + + // severity + fill(json, "severity", data.severity); + + return ret; +} + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/VariableMonitoringType20.h b/src/ocpp20/types/VariableMonitoringType20.h new file mode 100644 index 00000000..fbc4a6e6 --- /dev/null +++ b/src/ocpp20/types/VariableMonitoringType20.h @@ -0,0 +1,102 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:NotifyMonitoringReportRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_VARIABLEMONITORINGTYPE_H +#define OPENOCPP_OCPP20_VARIABLEMONITORINGTYPE_H + +#include "CustomDataType20.h" +#include "MonitorEnumType20.h" + +#include "IMessageConverter.h" +#include "Optional.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief A monitoring setting for a variable. + */ +struct VariableMonitoringType +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief Identifies the monitor. */ + int id; + /** @brief Monitor only active when a transaction is ongoing on a component relevant to this transaction. */ + bool transaction; + /** @brief Value for threshold or delta monitoring. +For Periodic or PeriodicClockAligned this is the interval in seconds. */ + float value; + /** @brief */ + MonitorEnumType type; + /** @brief The severity that will be assigned to an event that is triggered by this monitor. The severity range is 0-9, with 0 as the highest and 9 as the lowest severity level. + +The severity levels have the following meaning: + +*0-Danger* + +Indicates lives are potentially in danger. Urgent attention is needed and action should be taken immediately. + +*1-Hardware Failure* + +Indicates that the Charging Station is unable to continue regular operations due to Hardware issues. Action is required. + +*2-System Failure* + +Indicates that the Charging Station is unable to continue regular operations due to software or minor hardware issues. Action is required. + +*3-Critical* + +Indicates a critical error. Action is required. + +*4-Error* + +Indicates a non-urgent error. Action is required. + +*5-Alert* + +Indicates an alert event. Default severity for any type of monitoring event. + +*6-Warning* + +Indicates a warning event. Action may be required. + +*7-Notice* + +Indicates an unusual event. No immediate action is required. + +*8-Informational* + +Indicates a regular operational event. May be used for reporting, measuring throughput, etc. No action is required. + +*9-Debug* + +Indicates information useful to developers for debugging, not useful during operations. */ + int severity; +}; + +/** @brief Converter class for VariableMonitoringType type */ +class VariableMonitoringTypeConverter : public ocpp::messages::IMessageConverter +{ + public: + /** @brief Clone the converter */ + ocpp::messages::IMessageConverter* clone() const override { return new VariableMonitoringTypeConverter(); } + + /** @brief Convert a VariableMonitoringType from a JSON representation */ + bool fromJson(const rapidjson::Value& json, + VariableMonitoringType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) override; + + /** @brief Convert a VariableMonitoringType to a JSON representation */ + bool toJson(const VariableMonitoringType& data, rapidjson::Document& json) override; +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_VARIABLEMONITORINGTYPE_H \ No newline at end of file diff --git a/src/ocpp20/types/VariableType20.cpp b/src/ocpp20/types/VariableType20.cpp new file mode 100644 index 00000000..d8f08c8e --- /dev/null +++ b/src/ocpp20/types/VariableType20.cpp @@ -0,0 +1,90 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetReportRequest + OCPP 2.0.1 FINAL +*/ + +#include "VariableType20.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Convert a VariableType from a JSON representation */ +bool VariableTypeConverter::fromJson(const rapidjson::Value& json, + VariableType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) +{ + bool ret = true; + + // customData + if (json.HasMember("customData")) + { + CustomDataTypeConverter customData_converter; + ret = ret && customData_converter.fromJson(json["customData"], data.customData, error_code, error_message); + } + + // name + extract(json, "name", data.name); + + // instance + extract(json, "instance", data.instance); + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a VariableType to a JSON representation */ +bool VariableTypeConverter::toJson(const VariableType& data, rapidjson::Document& json) +{ + bool ret = true; + + // customData + if (data.customData.isSet()) + { + CustomDataTypeConverter customData_converter; + customData_converter.setAllocator(allocator); + rapidjson::Document customData_doc(rapidjson::kObjectType); + ret = ret && customData_converter.toJson(data.customData, customData_doc); + json.AddMember(rapidjson::StringRef("customData"), customData_doc.Move(), *allocator); + } + + // name + fill(json, "name", data.name); + + // instance + fill(json, "instance", data.instance); + + return ret; +} + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp \ No newline at end of file diff --git a/src/ocpp20/types/VariableType20.h b/src/ocpp20/types/VariableType20.h new file mode 100644 index 00000000..bae3baf5 --- /dev/null +++ b/src/ocpp20/types/VariableType20.h @@ -0,0 +1,73 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : urn:OCPP:Cp:2:2020:3:GetReportRequest + OCPP 2.0.1 FINAL +*/ + +#ifndef OPENOCPP_OCPP20_VARIABLETYPE_H +#define OPENOCPP_OCPP20_VARIABLETYPE_H + +#include "CustomDataType20.h" + +#include "CiStringType.h" +#include "IMessageConverter.h" +#include "Optional.h" + +namespace ocpp +{ +namespace types +{ +namespace ocpp20 +{ + +/** @brief Reference key to a component-variable. + */ +struct VariableType +{ + /** @brief */ + ocpp::types::Optional customData; + /** @brief Name of the variable. Name should be taken from the list of standardized variable names whenever possible. Case Insensitive. strongly advised to use Camel Case. */ + ocpp::types::CiStringType<50u> name; + /** @brief Name of instance in case the variable exists as multiple instances. Case Insensitive. strongly advised to use Camel Case. */ + ocpp::types::Optional> instance; +}; + +/** @brief Converter class for VariableType type */ +class VariableTypeConverter : public ocpp::messages::IMessageConverter +{ + public: + /** @brief Clone the converter */ + ocpp::messages::IMessageConverter* clone() const override { return new VariableTypeConverter(); } + + /** @brief Convert a VariableType from a JSON representation */ + bool fromJson(const rapidjson::Value& json, + VariableType& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) override; + + /** @brief Convert a VariableType to a JSON representation */ + bool toJson(const VariableType& data, rapidjson::Document& json) override; +}; + +} // namespace ocpp20 +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_OCPP20_VARIABLETYPE_H \ No newline at end of file diff --git a/src/rpc/RpcBase.cpp b/src/rpc/RpcBase.cpp index 03205ebe..b49d5ec8 100644 --- a/src/rpc/RpcBase.cpp +++ b/src/rpc/RpcBase.cpp @@ -178,10 +178,9 @@ void RpcBase::unregisterSpy(IRpc::ISpy& spy) void RpcBase::processIncomingRequest(std::shared_ptr& rpc_message) { // Notify call - rapidjson::Document response; + rapidjson::Document response(rapidjson::kObjectType); std::string error; std::string error_code; - response.Parse("{}"); if (m_rpc_listener->rpcCallReceived(rpc_message->action, rpc_message->payload, response, error_code, error)) { // Serialize message diff --git a/src/tools/json/JsonValidator.cpp b/src/tools/json/JsonValidator.cpp index 8b448680..e121b3d8 100644 --- a/src/tools/json/JsonValidator.cpp +++ b/src/tools/json/JsonValidator.cpp @@ -41,21 +41,10 @@ bool JsonValidator::init(const std::string& schema_file) file.open(schema_file); if (file.is_open()) { - // Read the whole file - std::string json; - char buffer[1024u]; - std::streamsize size; - do - { - file.read(buffer, sizeof(buffer) - 1u); - size = file.gcount(); - buffer[size] = 0; - json.append(buffer); - } while (size != 0); - // Parse JSON schema - rapidjson::Document schema_doc; - schema_doc.Parse(json.c_str()); + rapidjson::IStreamWrapper file_wrapper(file); + rapidjson::Document schema_doc; + schema_doc.ParseStream(file_wrapper); rapidjson::ParseErrorCode error = schema_doc.GetParseError(); if (error == rapidjson::ParseErrorCode ::kParseErrorNone) { @@ -64,6 +53,14 @@ bool JsonValidator::init(const std::string& schema_file) m_last_error = ""; ret = true; } + else + { + m_last_error = GetParseError_En(error); + } + } + else + { + m_last_error = "Unable to open schema file : " + schema_file; } return ret; @@ -81,15 +78,7 @@ bool JsonValidator::isValid(const rapidjson::Value& json_document) ret = json_document.Accept(validator); if (!ret) { - const char* invalid_keyword = validator.GetInvalidSchemaKeyword(); - if (invalid_keyword) - { - m_last_error = "Error on keyword : " + std::string(invalid_keyword); - } - else - { - m_last_error = "Unknown error"; - } + m_last_error = GetValidateError_En(validator.GetInvalidSchemaCode()); } return ret; diff --git a/src/tools/json/json.h b/src/tools/json/json.h index c3fa2bdb..010bd6d9 100644 --- a/src/tools/json/json.h +++ b/src/tools/json/json.h @@ -66,6 +66,8 @@ class parse_exception : public std::logic_error // Include rapidjson's headers #include "rapidjson/document.h" #include "rapidjson/error/en.h" +#include "rapidjson/istreamwrapper.h" +#include "rapidjson/ostreamwrapper.h" #include "rapidjson/schema.h" #include "rapidjson/stringbuffer.h" #include "rapidjson/writer.h" diff --git a/src/types/CiStringType.h b/src/types/CiStringType.h index 8e1baf63..615b760a 100644 --- a/src/types/CiStringType.h +++ b/src/types/CiStringType.h @@ -157,12 +157,12 @@ class CiStringType : public ICiStringType bool ret = false; if (value.size() <= MAX_STRING_SIZE) { - m_string.assign(value); + m_string.assign(std::move(value)); ret = true; } else { - m_string.assign(value); + m_string.assign(std::move(value)); m_string.resize(MAX_STRING_SIZE); } return ret; diff --git a/src/types/Optional.h b/src/types/Optional.h index 04971216..064ee752 100644 --- a/src/types/Optional.h +++ b/src/types/Optional.h @@ -39,7 +39,7 @@ class Optional Optional(const T& value) : m_value(value), m_is_set(true) { } /** @brief Move constructor */ - Optional(T&& value) : m_value(value), m_is_set(true) { } + Optional(T&& value) : m_value(std::move(value)), m_is_set(true) { } /** * @brief Copy operator @@ -139,6 +139,23 @@ class Optional return m_value; } + /** + * @brief Get the underlying value if it set, if not, return the given default value + * @param default_value Default value to return if not set + * @return Underlying value if set, default value otherwise + */ + const T& valueOr(const T& default_value) const + { + if (m_is_set) + { + return m_value; + } + else + { + return default_value; + } + } + /** * @brief Indicate if the value has been set * @return true if the value has been set, false otherwise diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index c2592b13..cefe5cf3 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,6 +1,6 @@ # Path to the JSON schemas -add_definitions(-DSCHEMAS_DIR="${CMAKE_SOURCE_DIR}/schemas") +add_definitions(-DSCHEMAS_DIR="${CMAKE_SOURCE_DIR}/schemas/ocpp16") # Common libraries if (NOT MSVC) @@ -13,7 +13,7 @@ endif() include_directories(.) # Subdirectories -add_subdirectory(chargepoint) +add_subdirectory(ocpp16) add_subdirectory(rpc) add_subdirectory(stubs) add_subdirectory(tools) diff --git a/tests/deploy/main.cpp b/tests/deploy/main.cpp index 40df9f6b..a85cbde8 100644 --- a/tests/deploy/main.cpp +++ b/tests/deploy/main.cpp @@ -25,6 +25,7 @@ along with OpenOCPP. If not, see . using namespace ocpp; using namespace ocpp::config; using namespace ocpp::types; +using namespace ocpp::types::ocpp16; using namespace ocpp::centralsystem; using namespace ocpp::chargepoint; @@ -260,7 +261,7 @@ class OcppConfig : public IOcppConfig * @param unknown_values List of unknown parameters in the [keys] list */ void getConfiguration(const std::vector>& keys, - std::vector& values, + std::vector& values, std::vector>& unknown_values) override { (void)keys; @@ -274,7 +275,7 @@ class OcppConfig : public IOcppConfig * @param value New value * @return Status of the operation (see ConfigurationStatus) */ - ocpp::types::ConfigurationStatus setConfiguration(const std::string& key, const std::string& value) override + ocpp::types::ocpp16::ConfigurationStatus setConfiguration(const std::string& key, const std::string& value) override { (void)key; (void)value; @@ -524,7 +525,7 @@ class ChargePointEventsHandler : public IChargePointEventsHandler * @brief Called when the first attempt to connect to the central system has failed * @param status Previous registration status (if Accepted, some offline operations are allowed) */ - void connectionFailed(ocpp::types::RegistrationStatus status) override { (void)status; } + void connectionFailed(ocpp::types::ocpp16::RegistrationStatus status) override { (void)status; } /** * @brief Called when the charge point connection status has changed @@ -537,7 +538,7 @@ class ChargePointEventsHandler : public IChargePointEventsHandler * @param status Registration status * @param datetime Date and time of the central system */ - void bootNotification(ocpp::types::RegistrationStatus status, const ocpp::types::DateTime& datetime) override + void bootNotification(ocpp::types::ocpp16::RegistrationStatus status, const ocpp::types::DateTime& datetime) override { (void)status; (void)datetime; @@ -554,8 +555,8 @@ class ChargePointEventsHandler : public IChargePointEventsHandler * @param availability Requested availability * @return Status of the requested availability change (see AvailabilityStatus) */ - ocpp::types::AvailabilityStatus changeAvailabilityRequested(unsigned int connector_id, - ocpp::types::AvailabilityType availability) override + ocpp::types::ocpp16::AvailabilityStatus changeAvailabilityRequested(unsigned int connector_id, + ocpp::types::ocpp16::AvailabilityType availability) override { (void)connector_id; (void)availability; @@ -598,10 +599,10 @@ class ChargePointEventsHandler : public IChargePointEventsHandler * @param response_data Data associated with the response * @return Response status (see DataTransferStatus enum) */ - ocpp::types::DataTransferStatus dataTransferRequested(const std::string& vendor_id, - const std::string& message_id, - const std::string& request_data, - std::string& response_data) override + ocpp::types::ocpp16::DataTransferStatus dataTransferRequested(const std::string& vendor_id, + const std::string& message_id, + const std::string& request_data, + std::string& response_data) override { (void)vendor_id; (void)message_id; @@ -617,9 +618,9 @@ class ChargePointEventsHandler : public IChargePointEventsHandler * @param meter_value Meter value to fill (the context and measurand fields of SampleValues doesn't need to be filled) * @return true if the meter value can be retrived, false otherwise */ - bool getMeterValue(unsigned int connector_id, - const std::pair>& measurand, - ocpp::types::MeterValue& meter_value) override + bool getMeterValue(unsigned int connector_id, + const std::pair>& measurand, + ocpp::types::ocpp16::MeterValue& meter_value) override { (void)connector_id; (void)measurand; @@ -665,7 +666,9 @@ class ChargePointEventsHandler : public IChargePointEventsHandler * @param schedule Schedule containing the local limitations for the requested duration * @return true if a schedule has been defined, false if there are no local limitations for the requested duration */ - bool getLocalLimitationsSchedule(unsigned int connector_id, unsigned int duration, ocpp::types::ChargingSchedule& schedule) override + bool getLocalLimitationsSchedule(unsigned int connector_id, + unsigned int duration, + ocpp::types::ocpp16::ChargingSchedule& schedule) override { (void)connector_id; (void)duration; @@ -678,7 +681,7 @@ class ChargePointEventsHandler : public IChargePointEventsHandler * @param reset_type Type of reset * @return true if the request is accepted, false otherwise */ - bool resetRequested(ocpp::types::ResetType reset_type) override + bool resetRequested(ocpp::types::ocpp16::ResetType reset_type) override { (void)reset_type; return false; @@ -689,7 +692,7 @@ class ChargePointEventsHandler : public IChargePointEventsHandler * @param connector_id Id of the concerned connector * @return Unlock status (see UnlockStatus documentation) */ - ocpp::types::UnlockStatus unlockConnectorRequested(unsigned int connector_id) override + ocpp::types::ocpp16::UnlockStatus unlockConnectorRequested(unsigned int connector_id) override { (void)connector_id; return UnlockStatus::NotSupported; @@ -761,8 +764,8 @@ class ChargePointEventsHandler : public IChargePointEventsHandler * @param certificate CA certificate to install * @return Installation status (see CertificateStatusEnumType enum) */ - ocpp::types::CertificateStatusEnumType caCertificateReceived(ocpp::types::CertificateUseEnumType type, - const ocpp::x509::Certificate& certificate) override + ocpp::types::ocpp16::CertificateStatusEnumType caCertificateReceived(ocpp::types::ocpp16::CertificateUseEnumType type, + const ocpp::x509::Certificate& certificate) override { (void)type; (void)certificate; @@ -790,10 +793,10 @@ class ChargePointEventsHandler : public IChargePointEventsHandler * @param serial_number Serial number of the certificate * @return Deletion status (see DeleteCertificateStatusEnumType enum) */ - ocpp::types::DeleteCertificateStatusEnumType deleteCertificate(ocpp::types::HashAlgorithmEnumType hash_algorithm, - const std::string& issuer_name_hash, - const std::string& issuer_key_hash, - const std::string& serial_number) override + ocpp::types::ocpp16::DeleteCertificateStatusEnumType deleteCertificate(ocpp::types::ocpp16::HashAlgorithmEnumType hash_algorithm, + const std::string& issuer_name_hash, + const std::string& issuer_key_hash, + const std::string& serial_number) override { (void)hash_algorithm; (void)issuer_name_hash; @@ -816,7 +819,8 @@ class ChargePointEventsHandler : public IChargePointEventsHandler * @param type Type of CA certificate * @param certificates Installed certificates */ - void getInstalledCertificates(ocpp::types::CertificateUseEnumType type, std::vector& certificates) override + void getInstalledCertificates(ocpp::types::ocpp16::CertificateUseEnumType type, + std::vector& certificates) override { (void)type; (void)certificates; @@ -832,7 +836,7 @@ class ChargePointEventsHandler : public IChargePointEventsHandler * @return Path to the generated log file to upload to the Central System, or empty * string if no log are available */ - std::string getLog(ocpp::types::LogEnumType type, + std::string getLog(ocpp::types::ocpp16::LogEnumType type, const ocpp::types::Optional& start_time, const ocpp::types::Optional& stop_time) override { @@ -862,7 +866,8 @@ class ChargePointEventsHandler : public IChargePointEventsHandler * @param signing_certificate Certificate to check * @return Check status (see UpdateFirmwareStatusEnumType enum) */ - ocpp::types::UpdateFirmwareStatusEnumType checkFirmwareSigningCertificate(const ocpp::x509::Certificate& signing_certificate) override + ocpp::types::ocpp16::UpdateFirmwareStatusEnumType checkFirmwareSigningCertificate( + const ocpp::x509::Certificate& signing_certificate) override { (void)signing_certificate; return UpdateFirmwareStatusEnumType::Rejected; @@ -900,10 +905,11 @@ class ChargePointEventsHandler : public IChargePointEventsHandler * @param serial_number Serial number of the certificate * @return Deletion status (see DeleteCertificateStatusEnumType enum) */ - ocpp::types::DeleteCertificateStatusEnumType iso15118DeleteCertificate(ocpp::types::HashAlgorithmEnumType hash_algorithm, - const std::string& issuer_name_hash, - const std::string& issuer_key_hash, - const std::string& serial_number) override + ocpp::types::ocpp16::DeleteCertificateStatusEnumType iso15118DeleteCertificate( + ocpp::types::ocpp16::HashAlgorithmEnumType hash_algorithm, + const std::string& issuer_name_hash, + const std::string& issuer_key_hash, + const std::string& serial_number) override { (void)hash_algorithm; (void)issuer_name_hash; @@ -924,8 +930,8 @@ class ChargePointEventsHandler : public IChargePointEventsHandler bool mo_root_certificate, bool v2g_certificate_chain, bool oem_root_certificate, - std::vector>>& - certificates) override + std::tuple> > + &certificates) override { (void)v2g_root_certificate; (void)mo_root_certificate; @@ -940,8 +946,8 @@ class ChargePointEventsHandler : public IChargePointEventsHandler * @param certificate certificate to install * @return Installation status (see InstallCertificateStatusEnumType enum) */ - ocpp::types::InstallCertificateStatusEnumType iso15118CertificateReceived(ocpp::types::InstallCertificateUseEnumType type, - const ocpp::x509::Certificate& certificate) override + ocpp::types::ocpp16::InstallCertificateStatusEnumType iso15118CertificateReceived( + ocpp::types::ocpp16::InstallCertificateUseEnumType type, const ocpp::x509::Certificate& certificate) override { (void)type; (void)certificate; diff --git a/tests/chargepoint/CMakeLists.txt b/tests/ocpp16/CMakeLists.txt similarity index 100% rename from tests/chargepoint/CMakeLists.txt rename to tests/ocpp16/CMakeLists.txt diff --git a/tests/chargepoint/authent/CMakeLists.txt b/tests/ocpp16/authent/CMakeLists.txt similarity index 100% rename from tests/chargepoint/authent/CMakeLists.txt rename to tests/ocpp16/authent/CMakeLists.txt diff --git a/tests/chargepoint/authent/test_authent.cpp b/tests/ocpp16/authent/test_authent.cpp similarity index 99% rename from tests/chargepoint/authent/test_authent.cpp rename to tests/ocpp16/authent/test_authent.cpp index 197cc824..1d2b4cb4 100644 --- a/tests/chargepoint/authent/test_authent.cpp +++ b/tests/ocpp16/authent/test_authent.cpp @@ -38,8 +38,10 @@ using namespace ocpp::chargepoint; using namespace ocpp::config; using namespace ocpp::database; using namespace ocpp::messages; +using namespace ocpp::messages::ocpp16; using namespace ocpp::rpc; using namespace ocpp::types; +using namespace ocpp::types::ocpp16; static constexpr const char* DATABASE_PATH = "/tmp/test.db"; @@ -55,8 +57,7 @@ static void setAuthorizeResponse(RpcStub& rpc, const IdTagInfo& tag_info) AuthorizeConf resp; resp.idTagInfo = tag_info; - rapidjson::Document json_resp; - json_resp.Parse("{}"); + rapidjson::Document json_resp(rapidjson::kObjectType); AuthorizeConfConverter converter; converter.setAllocator(&json_resp.GetAllocator()); converter.toJson(resp, json_resp); diff --git a/tests/chargepoint/authent/test_authent_cache.cpp b/tests/ocpp16/authent/test_authent_cache.cpp similarity index 98% rename from tests/chargepoint/authent/test_authent_cache.cpp rename to tests/ocpp16/authent/test_authent_cache.cpp index 5dcbcc26..c4153541 100644 --- a/tests/chargepoint/authent/test_authent_cache.cpp +++ b/tests/ocpp16/authent/test_authent_cache.cpp @@ -32,7 +32,9 @@ using namespace ocpp::chargepoint; using namespace ocpp::config; using namespace ocpp::database; using namespace ocpp::messages; +using namespace ocpp::messages::ocpp16; using namespace ocpp::types; +using namespace ocpp::types::ocpp16; static constexpr const char* DATABASE_PATH = "/tmp/test.db"; diff --git a/tests/chargepoint/authent/test_authent_locallist.cpp b/tests/ocpp16/authent/test_authent_locallist.cpp similarity index 99% rename from tests/chargepoint/authent/test_authent_locallist.cpp rename to tests/ocpp16/authent/test_authent_locallist.cpp index 9dead4d7..edf96365 100644 --- a/tests/chargepoint/authent/test_authent_locallist.cpp +++ b/tests/ocpp16/authent/test_authent_locallist.cpp @@ -33,7 +33,9 @@ using namespace ocpp::chargepoint; using namespace ocpp::config; using namespace ocpp::database; using namespace ocpp::messages; +using namespace ocpp::messages::ocpp16; using namespace ocpp::types; +using namespace ocpp::types::ocpp16; static constexpr const char* DATABASE_PATH = "/tmp/test.db"; diff --git a/tests/chargepoint/connector/CMakeLists.txt b/tests/ocpp16/connector/CMakeLists.txt similarity index 100% rename from tests/chargepoint/connector/CMakeLists.txt rename to tests/ocpp16/connector/CMakeLists.txt diff --git a/tests/chargepoint/connector/test_connectors.cpp b/tests/ocpp16/connector/test_connectors.cpp similarity index 99% rename from tests/chargepoint/connector/test_connectors.cpp rename to tests/ocpp16/connector/test_connectors.cpp index 02e2fdaf..d8358227 100644 --- a/tests/chargepoint/connector/test_connectors.cpp +++ b/tests/ocpp16/connector/test_connectors.cpp @@ -27,6 +27,7 @@ along with OpenOCPP. If not, see . using namespace ocpp::config; using namespace ocpp::types; +using namespace ocpp::types::ocpp16; using namespace ocpp::helpers; using namespace ocpp::database; using namespace ocpp::chargepoint; diff --git a/tests/chargepoint/metervalues/CMakeLists.txt b/tests/ocpp16/metervalues/CMakeLists.txt similarity index 100% rename from tests/chargepoint/metervalues/CMakeLists.txt rename to tests/ocpp16/metervalues/CMakeLists.txt diff --git a/tests/chargepoint/metervalues/test_metervalues.cpp b/tests/ocpp16/metervalues/test_metervalues.cpp similarity index 99% rename from tests/chargepoint/metervalues/test_metervalues.cpp rename to tests/ocpp16/metervalues/test_metervalues.cpp index b0adcba2..6e2ead0a 100644 --- a/tests/chargepoint/metervalues/test_metervalues.cpp +++ b/tests/ocpp16/metervalues/test_metervalues.cpp @@ -42,8 +42,10 @@ using namespace ocpp::config; using namespace ocpp::database; using namespace ocpp::helpers; using namespace ocpp::messages; +using namespace ocpp::messages::ocpp16; using namespace ocpp::rpc; using namespace ocpp::types; +using namespace ocpp::types::ocpp16; static constexpr const char* DATABASE_PATH = "/tmp/test.db"; @@ -985,8 +987,7 @@ TEST_SUITE("Metervalues component") status_mgr.forceRegistrationStatus(RegistrationStatus::Accepted); // Response - rapidjson::Document json_resp; - json_resp.Parse("{}"); + rapidjson::Document json_resp(rapidjson::kObjectType); rpc.setResponse(json_resp); // Send meter values on connector 2 diff --git a/tests/chargepoint/smartcharging/CMakeLists.txt b/tests/ocpp16/smartcharging/CMakeLists.txt similarity index 100% rename from tests/chargepoint/smartcharging/CMakeLists.txt rename to tests/ocpp16/smartcharging/CMakeLists.txt diff --git a/tests/chargepoint/smartcharging/test_composite_schedule1.cpp b/tests/ocpp16/smartcharging/test_composite_schedule1.cpp similarity index 99% rename from tests/chargepoint/smartcharging/test_composite_schedule1.cpp rename to tests/ocpp16/smartcharging/test_composite_schedule1.cpp index 2576e06d..fe126103 100644 --- a/tests/chargepoint/smartcharging/test_composite_schedule1.cpp +++ b/tests/ocpp16/smartcharging/test_composite_schedule1.cpp @@ -38,7 +38,9 @@ using namespace ocpp::chargepoint; using namespace ocpp::config; using namespace ocpp::database; using namespace ocpp::messages; +using namespace ocpp::messages::ocpp16; using namespace ocpp::types; +using namespace ocpp::types::ocpp16; using namespace ocpp::rpc; using namespace ocpp::helpers; diff --git a/tests/chargepoint/smartcharging/test_composite_schedule2.cpp b/tests/ocpp16/smartcharging/test_composite_schedule2.cpp similarity index 99% rename from tests/chargepoint/smartcharging/test_composite_schedule2.cpp rename to tests/ocpp16/smartcharging/test_composite_schedule2.cpp index 90af513d..8fb86b49 100644 --- a/tests/chargepoint/smartcharging/test_composite_schedule2.cpp +++ b/tests/ocpp16/smartcharging/test_composite_schedule2.cpp @@ -38,7 +38,9 @@ using namespace ocpp::chargepoint; using namespace ocpp::config; using namespace ocpp::database; using namespace ocpp::messages; +using namespace ocpp::messages::ocpp16; using namespace ocpp::types; +using namespace ocpp::types::ocpp16; using namespace ocpp::rpc; using namespace ocpp::helpers; diff --git a/tests/chargepoint/smartcharging/test_composite_schedule3.cpp b/tests/ocpp16/smartcharging/test_composite_schedule3.cpp similarity index 97% rename from tests/chargepoint/smartcharging/test_composite_schedule3.cpp rename to tests/ocpp16/smartcharging/test_composite_schedule3.cpp index 561fc6bd..96a6264c 100644 --- a/tests/chargepoint/smartcharging/test_composite_schedule3.cpp +++ b/tests/ocpp16/smartcharging/test_composite_schedule3.cpp @@ -38,7 +38,9 @@ using namespace ocpp::chargepoint; using namespace ocpp::config; using namespace ocpp::database; using namespace ocpp::messages; +using namespace ocpp::messages::ocpp16; using namespace ocpp::types; +using namespace ocpp::types::ocpp16; using namespace ocpp::rpc; using namespace ocpp::helpers; @@ -49,8 +51,10 @@ class CustomChargePointEventsHandlerStub : public ChargePointEventsHandlerStub public: ChargingSchedule schedule; - /** @copydoc bool IChargePointEventsHandler::getLocalLimitationsSchedule(unsigned int, unsigned int, ocpp::types::ChargingSchedule&) */ - bool getLocalLimitationsSchedule(unsigned int connector_id, unsigned int duration, ocpp::types::ChargingSchedule& _schedule) override + /** @copydoc bool IChargePointEventsHandler::getLocalLimitationsSchedule(unsigned int, unsigned int, ocpp::types::ocpp16::ChargingSchedule&) */ + bool getLocalLimitationsSchedule(unsigned int connector_id, + unsigned int duration, + ocpp::types::ocpp16::ChargingSchedule& _schedule) override { (void)connector_id; (void)duration; diff --git a/tests/chargepoint/smartcharging/test_profile_database.cpp b/tests/ocpp16/smartcharging/test_profile_database.cpp similarity index 99% rename from tests/chargepoint/smartcharging/test_profile_database.cpp rename to tests/ocpp16/smartcharging/test_profile_database.cpp index 08d6be15..900d6da9 100644 --- a/tests/chargepoint/smartcharging/test_profile_database.cpp +++ b/tests/ocpp16/smartcharging/test_profile_database.cpp @@ -29,7 +29,9 @@ using namespace ocpp::chargepoint; using namespace ocpp::config; using namespace ocpp::database; using namespace ocpp::messages; +using namespace ocpp::messages::ocpp16; using namespace ocpp::types; +using namespace ocpp::types::ocpp16; static constexpr const char* DATABASE_PATH = "/tmp/test.db"; diff --git a/tests/chargepoint/smartcharging/test_smartcharging_setpoint.cpp b/tests/ocpp16/smartcharging/test_smartcharging_setpoint.cpp similarity index 95% rename from tests/chargepoint/smartcharging/test_smartcharging_setpoint.cpp rename to tests/ocpp16/smartcharging/test_smartcharging_setpoint.cpp index 3687e736..85ce6f16 100644 --- a/tests/chargepoint/smartcharging/test_smartcharging_setpoint.cpp +++ b/tests/ocpp16/smartcharging/test_smartcharging_setpoint.cpp @@ -38,7 +38,9 @@ using namespace ocpp::chargepoint; using namespace ocpp::config; using namespace ocpp::database; using namespace ocpp::messages; +using namespace ocpp::messages::ocpp16; using namespace ocpp::types; +using namespace ocpp::types::ocpp16; using namespace ocpp::rpc; using namespace ocpp::helpers; @@ -130,8 +132,8 @@ TEST_SUITE("Get composite schedule - multiple OCPP profiles") profile1.chargingSchedule.duration = 300; CHECK(installProfile(0, profile1, smartcharging_mgr)); - ocpp::types::Optional charge_point_setpoint; - ocpp::types::Optional connector_setpoint; + ocpp::types::Optional charge_point_setpoint; + ocpp::types::Optional connector_setpoint; CHECK(smartcharging_mgr.getSetpoint(1u, charge_point_setpoint, connector_setpoint, ChargingRateUnitType::A)); CHECK_FALSE(charge_point_setpoint.isSet()); @@ -177,8 +179,8 @@ TEST_SUITE("Get composite schedule - multiple OCPP profiles") profile1.chargingSchedule.duration = 300; CHECK(installProfile(0, profile1, smartcharging_mgr)); - ocpp::types::Optional charge_point_setpoint; - ocpp::types::Optional connector_setpoint; + ocpp::types::Optional charge_point_setpoint; + ocpp::types::Optional connector_setpoint; CHECK(smartcharging_mgr.getSetpoint(1u, charge_point_setpoint, connector_setpoint, ChargingRateUnitType::A)); CHECK_FALSE(charge_point_setpoint.isSet()); @@ -219,8 +221,8 @@ TEST_SUITE("Get composite schedule - multiple OCPP profiles") profile1.chargingSchedule.duration = 300; CHECK(installProfile(0, profile1, smartcharging_mgr)); - ocpp::types::Optional charge_point_setpoint; - ocpp::types::Optional connector_setpoint; + ocpp::types::Optional charge_point_setpoint; + ocpp::types::Optional connector_setpoint; CHECK(smartcharging_mgr.getSetpoint(1u, charge_point_setpoint, connector_setpoint, ChargingRateUnitType::A)); CHECK_FALSE(charge_point_setpoint.isSet()); @@ -266,8 +268,8 @@ TEST_SUITE("Get composite schedule - multiple OCPP profiles") profile1.chargingSchedule.duration = 300; CHECK(installProfile(0, profile1, smartcharging_mgr)); - ocpp::types::Optional charge_point_setpoint; - ocpp::types::Optional connector_setpoint; + ocpp::types::Optional charge_point_setpoint; + ocpp::types::Optional connector_setpoint; CHECK(smartcharging_mgr.getSetpoint(1u, charge_point_setpoint, connector_setpoint, ChargingRateUnitType::A)); CHECK_FALSE(charge_point_setpoint.isSet()); @@ -329,8 +331,8 @@ TEST_SUITE("Get composite schedule - multiple OCPP profiles") profile2.chargingSchedule.minChargingRate = 8.f; CHECK(installProfile(1, profile2, smartcharging_mgr)); - ocpp::types::Optional charge_point_setpoint; - ocpp::types::Optional connector_setpoint; + ocpp::types::Optional charge_point_setpoint; + ocpp::types::Optional connector_setpoint; CHECK(smartcharging_mgr.getSetpoint(1u, charge_point_setpoint, connector_setpoint, ChargingRateUnitType::A)); CHECK_FALSE(charge_point_setpoint.isSet()); @@ -397,8 +399,8 @@ TEST_SUITE("Get composite schedule - multiple OCPP profiles") profile2.chargingSchedule.minChargingRate = 6.f; CHECK(installProfile(0, profile2, smartcharging_mgr)); - ocpp::types::Optional charge_point_setpoint; - ocpp::types::Optional connector_setpoint; + ocpp::types::Optional charge_point_setpoint; + ocpp::types::Optional connector_setpoint; CHECK(smartcharging_mgr.getSetpoint(1u, charge_point_setpoint, connector_setpoint, ChargingRateUnitType::A)); CHECK(charge_point_setpoint.isSet()); @@ -469,8 +471,8 @@ TEST_SUITE("Get composite schedule - multiple OCPP profiles") profile2.chargingSchedule.minChargingRate = 8.f; CHECK(installProfile(1, profile2, smartcharging_mgr)); - ocpp::types::Optional charge_point_setpoint; - ocpp::types::Optional connector_setpoint; + ocpp::types::Optional charge_point_setpoint; + ocpp::types::Optional connector_setpoint; CHECK(smartcharging_mgr.getSetpoint(1u, charge_point_setpoint, connector_setpoint, ChargingRateUnitType::A)); CHECK_FALSE(charge_point_setpoint.isSet()); @@ -537,8 +539,8 @@ TEST_SUITE("Get composite schedule - multiple OCPP profiles") profile2.chargingSchedule.minChargingRate = 8.f; CHECK(installProfile(1, profile2, smartcharging_mgr)); - ocpp::types::Optional charge_point_setpoint; - ocpp::types::Optional connector_setpoint; + ocpp::types::Optional charge_point_setpoint; + ocpp::types::Optional connector_setpoint; CHECK(smartcharging_mgr.getSetpoint(1u, charge_point_setpoint, connector_setpoint, ChargingRateUnitType::A)); CHECK_FALSE(charge_point_setpoint.isSet()); @@ -628,8 +630,8 @@ TEST_SUITE("Get composite schedule - multiple OCPP profiles") profile3.chargingSchedule.minChargingRate = 6.f; CHECK(installProfile(0, profile3, smartcharging_mgr)); - ocpp::types::Optional charge_point_setpoint; - ocpp::types::Optional connector_setpoint; + ocpp::types::Optional charge_point_setpoint; + ocpp::types::Optional connector_setpoint; CHECK(smartcharging_mgr.getSetpoint(1u, charge_point_setpoint, connector_setpoint, ChargingRateUnitType::A)); CHECK(charge_point_setpoint.isSet()); @@ -723,8 +725,8 @@ TEST_SUITE("Get composite schedule - multiple OCPP profiles") profile3.chargingSchedule.minChargingRate = 6.f; CHECK(installProfile(0, profile3, smartcharging_mgr)); - ocpp::types::Optional charge_point_setpoint; - ocpp::types::Optional connector_setpoint; + ocpp::types::Optional charge_point_setpoint; + ocpp::types::Optional connector_setpoint; CHECK(smartcharging_mgr.getSetpoint(1u, charge_point_setpoint, connector_setpoint, ChargingRateUnitType::A)); CHECK(charge_point_setpoint.isSet()); @@ -818,8 +820,8 @@ TEST_SUITE("Get composite schedule - multiple OCPP profiles") profile3.chargingSchedule.minChargingRate = 6.f; CHECK(installProfile(0, profile3, smartcharging_mgr)); - ocpp::types::Optional charge_point_setpoint; - ocpp::types::Optional connector_setpoint; + ocpp::types::Optional charge_point_setpoint; + ocpp::types::Optional connector_setpoint; CHECK(smartcharging_mgr.getSetpoint(1u, charge_point_setpoint, connector_setpoint, ChargingRateUnitType::A)); CHECK(charge_point_setpoint.isSet()); @@ -912,8 +914,8 @@ TEST_SUITE("Get composite schedule - multiple OCPP profiles") profile3.chargingSchedule.minChargingRate = 6.f; CHECK(installProfile(0, profile3, smartcharging_mgr)); - ocpp::types::Optional charge_point_setpoint; - ocpp::types::Optional connector_setpoint; + ocpp::types::Optional charge_point_setpoint; + ocpp::types::Optional connector_setpoint; CHECK(smartcharging_mgr.getSetpoint(1u, charge_point_setpoint, connector_setpoint, ChargingRateUnitType::A)); CHECK(charge_point_setpoint.isSet()); diff --git a/tests/stubs/CMakeLists.txt b/tests/stubs/CMakeLists.txt index a4bf586e..47ac1cb0 100755 --- a/tests/stubs/CMakeLists.txt +++ b/tests/stubs/CMakeLists.txt @@ -10,19 +10,19 @@ add_library(unit_tests_stubs STATIC WebsocketClientStub.cpp ) target_include_directories(unit_tests_stubs PUBLIC . - ${CMAKE_SOURCE_DIR}/src/chargepoint/authent - ${CMAKE_SOURCE_DIR}/src/chargepoint/config - ${CMAKE_SOURCE_DIR}/src/chargepoint/connector - ${CMAKE_SOURCE_DIR}/src/chargepoint/datatransfer - ${CMAKE_SOURCE_DIR}/src/chargepoint/maintenance - ${CMAKE_SOURCE_DIR}/src/chargepoint/metervalues - ${CMAKE_SOURCE_DIR}/src/chargepoint/requestfifo - ${CMAKE_SOURCE_DIR}/src/chargepoint/reservation - ${CMAKE_SOURCE_DIR}/src/chargepoint/security - ${CMAKE_SOURCE_DIR}/src/chargepoint/smartcharging - ${CMAKE_SOURCE_DIR}/src/chargepoint/status - ${CMAKE_SOURCE_DIR}/src/chargepoint/transaction - ${CMAKE_SOURCE_DIR}/src/chargepoint/trigger + ${CMAKE_SOURCE_DIR}/src/ocpp16/chargepoint/authent + ${CMAKE_SOURCE_DIR}/src/ocpp16/chargepoint/config + ${CMAKE_SOURCE_DIR}/src/ocpp16/chargepoint/connector + ${CMAKE_SOURCE_DIR}/src/ocpp16/chargepoint/datatransfer + ${CMAKE_SOURCE_DIR}/src/ocpp16/chargepoint/maintenance + ${CMAKE_SOURCE_DIR}/src/ocpp16/chargepoint/metervalues + ${CMAKE_SOURCE_DIR}/src/ocpp16/chargepoint/requestfifo + ${CMAKE_SOURCE_DIR}/src/ocpp16/chargepoint/reservation + ${CMAKE_SOURCE_DIR}/src/ocpp16/chargepoint/security + ${CMAKE_SOURCE_DIR}/src/ocpp16/chargepoint/smartcharging + ${CMAKE_SOURCE_DIR}/src/ocpp16/chargepoint/status + ${CMAKE_SOURCE_DIR}/src/ocpp16/chargepoint/transaction + ${CMAKE_SOURCE_DIR}/src/ocpp16/chargepoint/trigger ) # Dependencies @@ -30,8 +30,8 @@ target_link_libraries(unit_tests_stubs centralsystem chargepoint config - types - messages + types16 + messages16 log database json diff --git a/tests/stubs/ChargePointEventsHandlerStub.cpp b/tests/stubs/ChargePointEventsHandlerStub.cpp old mode 100755 new mode 100644 index 52a9f925..9ad38539 --- a/tests/stubs/ChargePointEventsHandlerStub.cpp +++ b/tests/stubs/ChargePointEventsHandlerStub.cpp @@ -22,6 +22,7 @@ along with OpenOCPP. If not, see . using namespace std; using namespace ocpp::types; +using namespace ocpp::types::ocpp16; /** @brief Constructor */ ChargePointEventsHandlerStub::ChargePointEventsHandlerStub() @@ -44,8 +45,8 @@ void ChargePointEventsHandlerStub::connectionUrlChanged(std::string const& url) m_calls["connectionUrlChanged"] = {{"url", url}}; } -/** @copydoc void IChargePointEventsHandler::connectionStateChanged(ocpp::types::RegistrationStatus) */ -void ChargePointEventsHandlerStub::connectionFailed(ocpp::types::RegistrationStatus status) +/** @copydoc void IChargePointEventsHandler::connectionFailed(ocpp::types::RegistrationStatus) */ +void ChargePointEventsHandlerStub::connectionFailed(ocpp::types::ocpp16::RegistrationStatus status) { m_calls["connectionFailed"] = {{"status", RegistrationStatusHelper.toString(status)}}; } @@ -56,8 +57,8 @@ void ChargePointEventsHandlerStub::connectionStateChanged(bool isConnected) m_calls["connectionStateChanged"] = {{"isConnected", std::to_string(isConnected)}}; } -/** @copydoc void IChargePointEventsHandler::bootNotification(ocpp::types::RegistrationStatus, const ocpp::types::DateTime&) */ -void ChargePointEventsHandlerStub::bootNotification(ocpp::types::RegistrationStatus status, const ocpp::types::DateTime& datetime) +/** @copydoc void IChargePointEventsHandler::bootNotification(ocpp::types::ocpp16::RegistrationStatus, const ocpp::types::DateTime&) */ +void ChargePointEventsHandlerStub::bootNotification(ocpp::types::ocpp16::RegistrationStatus status, const ocpp::types::DateTime& datetime) { m_calls["bootNotification"] = {{"status", RegistrationStatusHelper.toString(status)}, {"dateTime", datetime.str()}}; } @@ -68,9 +69,9 @@ void ChargePointEventsHandlerStub::datetimeReceived(const ocpp::types::DateTime& m_calls["datetimeReceived"] = {{"dateTime", datetime.str()}}; } -/** @copydoc AvailabilityStatus IChargePointEventsHandler::changeAvailabilityRequested(unsigned int, ocpp::types::AvailabilityType) */ -ocpp::types::AvailabilityStatus ChargePointEventsHandlerStub::changeAvailabilityRequested(unsigned int connector_id, - ocpp::types::AvailabilityType availability) +/** @copydoc AvailabilityStatus IChargePointEventsHandler::changeAvailabilityRequested(unsigned int, ocpp::types::ocpp16::AvailabilityType) */ +ocpp::types::ocpp16::AvailabilityStatus ChargePointEventsHandlerStub::changeAvailabilityRequested( + unsigned int connector_id, ocpp::types::ocpp16::AvailabilityType availability) { m_calls["changeAvailabilityRequested"] = {{"connector_id", std::to_string(connector_id)}, {"availability", AvailabilityTypeHelper.toString(availability)}}; @@ -97,25 +98,25 @@ void ChargePointEventsHandlerStub::reservationEnded(unsigned int connector_id, b m_calls["reservationStarted"] = {{"connector_id", std::to_string(connector_id)}, {"canceled", std::to_string(canceled)}}; } -/** @copydoc ocpp::types::DataTransferStatus IChargePointEventsHandler::dataTransferRequested(const std::string&, +/** @copydoc ocpp::types::ocpp16::DataTransferStatus IChargePointEventsHandler::dataTransferRequested(const std::string&, const std::string&, const std::string&, std::string&) */ -ocpp::types::DataTransferStatus ChargePointEventsHandlerStub::dataTransferRequested(const std::string& vendor_id, - const std::string& message_id, - const std::string& request_data, - std::string& response_data) +ocpp::types::ocpp16::DataTransferStatus ChargePointEventsHandlerStub::dataTransferRequested(const std::string& vendor_id, + const std::string& message_id, + const std::string& request_data, + std::string& response_data) { (void)response_data; m_calls["dataTransferRequested"] = {{"vendor_id", vendor_id}, {"message_id", message_id}, {"request_data", request_data}}; return m_data_transfer_status; } -/** @copydoc bool getMeterValue(unsigned int, const std::pair>&, ocpp::types::MeterValue&) */ +/** @copydoc bool getMeterValue(unsigned int, const std::pair>&, ocpp::types::ocpp16::MeterValue&) */ bool ChargePointEventsHandlerStub::getMeterValue( - unsigned int connector_id, - const std::pair>& measurand, - ocpp::types::MeterValue& meter_value) + unsigned int connector_id, + const std::pair>& measurand, + ocpp::types::ocpp16::MeterValue& meter_value) { m_calls["getMeterValue"] = {{"connector_id", std::to_string(connector_id)}, {"measurand", MeasurandHelper.toString(measurand.first)}, @@ -163,25 +164,25 @@ void ChargePointEventsHandlerStub::transactionDeAuthorized(unsigned int connecto m_calls["transactionDeAuthorized"] = {{"connector_id", std::to_string(connector_id)}}; } -/** @copydoc bool IChargePointEventsHandler::getLocalLimitationsSchedule(unsigned int, unsigned int, ocpp::types::ChargingSchedule&) */ -bool ChargePointEventsHandlerStub::getLocalLimitationsSchedule(unsigned int connector_id, - unsigned int duration, - ocpp::types::ChargingSchedule& schedule) +/** @copydoc bool IChargePointEventsHandler::getLocalLimitationsSchedule(unsigned int, unsigned int, ocpp::types::ocpp16::ChargingSchedule&) */ +bool ChargePointEventsHandlerStub::getLocalLimitationsSchedule(unsigned int connector_id, + unsigned int duration, + ocpp::types::ocpp16::ChargingSchedule& schedule) { (void)schedule; m_calls["getLocalLimitationsSchedule"] = {{"connector_id", std::to_string(connector_id)}, {"duration", std::to_string(duration)}}; return false; } -/** @copydoc bool IChargePointEventsHandler::resetRequested(ocpp::types::ResetType) */ -bool ChargePointEventsHandlerStub::resetRequested(ocpp::types::ResetType reset_type) +/** @copydoc bool IChargePointEventsHandler::resetRequested(ocpp::types::ocpp16::ResetType) */ +bool ChargePointEventsHandlerStub::resetRequested(ocpp::types::ocpp16::ResetType reset_type) { m_calls["resetRequested"] = {{"reset_type", ResetTypeHelper.toString(reset_type)}}; return callResult("resetRequested"); } -/** @copydoc ocpp::types::UnlockStatus IChargePointEventsHandler::unlockConnectorRequested(unsigned int) */ -ocpp::types::UnlockStatus ChargePointEventsHandlerStub::unlockConnectorRequested(unsigned int connector_id) +/** @copydoc ocpp::types::ocpp16::UnlockStatus IChargePointEventsHandler::unlockConnectorRequested(unsigned int) */ +ocpp::types::ocpp16::UnlockStatus ChargePointEventsHandlerStub::unlockConnectorRequested(unsigned int connector_id) { m_calls["unlockConnectorRequested"] = {{"connector_id", std::to_string(connector_id)}}; return m_unlock_status; @@ -226,10 +227,10 @@ bool ChargePointEventsHandlerStub::downloadFile(const std::string& url, const st // Security extensions -/** @copydoc ocpp::types::CertificateStatusEnumType IChargePointEventsHandler::caCertificateReceived(ocpp::types::CertificateUseEnumType, +/** @copydoc ocpp::types::ocpp16::CertificateStatusEnumType IChargePointEventsHandler::caCertificateReceived(ocpp::types::ocpp16::CertificateUseEnumType, const ocpp::x509::Certificate&) */ -ocpp::types::CertificateStatusEnumType ChargePointEventsHandlerStub::caCertificateReceived(ocpp::types::CertificateUseEnumType type, - const ocpp::x509::Certificate& certificate) +ocpp::types::ocpp16::CertificateStatusEnumType ChargePointEventsHandlerStub::caCertificateReceived( + ocpp::types::ocpp16::CertificateUseEnumType type, const ocpp::x509::Certificate& certificate) { m_calls["caCertificateReceived"] = {{"type", CertificateUseEnumTypeHelper.toString(type)}, {"certificate", certificate.pem()}}; return CertificateStatusEnumType::Accepted; @@ -242,15 +243,15 @@ bool ChargePointEventsHandlerStub::chargePointCertificateReceived(const ocpp::x5 return m_call_results["chargePointCertificateReceived"]; } -/** @copydoc ocpp::types::DeleteCertificateStatusEnumType IChargePointEventsHandler::deleteCertificate(ocpp::types::HashAlgorithmEnumType, +/** @copydoc ocpp::types::ocpp16::DeleteCertificateStatusEnumType IChargePointEventsHandler::deleteCertificate(ocpp::types::ocpp16::HashAlgorithmEnumType, const std::string&, const std::string&, const std::string&) */ -ocpp::types::DeleteCertificateStatusEnumType ChargePointEventsHandlerStub::deleteCertificate( - ocpp::types::HashAlgorithmEnumType hash_algorithm, - const std::string& issuer_name_hash, - const std::string& issuer_key_hash, - const std::string& serial_number) +ocpp::types::ocpp16::DeleteCertificateStatusEnumType ChargePointEventsHandlerStub::deleteCertificate( + ocpp::types::ocpp16::HashAlgorithmEnumType hash_algorithm, + const std::string& issuer_name_hash, + const std::string& issuer_key_hash, + const std::string& serial_number) { m_calls["deleteCertificate"] = {{"hash_algorithm", HashAlgorithmEnumTypeHelper.toString(hash_algorithm)}, {"issuer_name_hash", issuer_name_hash}, @@ -266,19 +267,19 @@ void ChargePointEventsHandlerStub::generateCsr(std::string& csr) m_calls["generateCsr"] = {{}}; } -/** @copydoc void IChargePointEventsHandler::getInstalledCertificates(ocpp::types::CertificateUseEnumType, +/** @copydoc void IChargePointEventsHandler::getInstalledCertificates(ocpp::types::ocpp16::CertificateUseEnumType, * std::vector&) */ -void ChargePointEventsHandlerStub::getInstalledCertificates(ocpp::types::CertificateUseEnumType type, - std::vector& certificates) +void ChargePointEventsHandlerStub::getInstalledCertificates(ocpp::types::ocpp16::CertificateUseEnumType type, + std::vector& certificates) { (void)certificates; m_calls["getInstalledCertificates"] = {{"type", CertificateUseEnumTypeHelper.toString(type)}}; } -/** @copydoc std::string IChargePointEventsHandler::getLog(ocpp::types::LogEnumType, +/** @copydoc std::string IChargePointEventsHandler::getLog(ocpp::types::ocpp16::LogEnumType, const ocpp::types::Optional&, const ocpp::types::Optional&) */ -std::string ChargePointEventsHandlerStub::getLog(ocpp::types::LogEnumType type, +std::string ChargePointEventsHandlerStub::getLog(ocpp::types::ocpp16::LogEnumType type, const ocpp::types::Optional& start_time, const ocpp::types::Optional& stop_time) { @@ -299,9 +300,9 @@ bool ChargePointEventsHandlerStub::hasChargePointCertificateInstalled() return m_call_results["hasChargePointCertificateInstalled"]; } -/** @copydoc ocpp::types::UpdateFirmwareStatusEnumType IChargePointEventsHandler::checkFirmwareSigningCertificate( +/** @copydoc ocpp::types::ocpp16::UpdateFirmwareStatusEnumType IChargePointEventsHandler::checkFirmwareSigningCertificate( * const ocpp::x509::Certificate&) */ -ocpp::types::UpdateFirmwareStatusEnumType ChargePointEventsHandlerStub::checkFirmwareSigningCertificate( +ocpp::types::ocpp16::UpdateFirmwareStatusEnumType ChargePointEventsHandlerStub::checkFirmwareSigningCertificate( const ocpp::x509::Certificate& signing_certificate) { m_calls["checkFirmwareSigningCertificate"] = {{"signing_certificate", signing_certificate.pem()}}; @@ -324,15 +325,15 @@ bool ChargePointEventsHandlerStub::iso15118ChargePointCertificateReceived(const return true; } -/** @copydoc ocpp::types::DeleteCertificateStatusEnumType IChargePointEventsHandler::iso15118DeleteCertificate(ocpp::types::HashAlgorithmEnumType, +/** @copydoc ocpp::types::ocpp16::DeleteCertificateStatusEnumType IChargePointEventsHandler::iso15118DeleteCertificate(ocpp::types::ocpp16::HashAlgorithmEnumType, const std::string&, const std::string&, const std::string&) */ -ocpp::types::DeleteCertificateStatusEnumType ChargePointEventsHandlerStub::iso15118DeleteCertificate( - ocpp::types::HashAlgorithmEnumType hash_algorithm, - const std::string& issuer_name_hash, - const std::string& issuer_key_hash, - const std::string& serial_number) +ocpp::types::ocpp16::DeleteCertificateStatusEnumType ChargePointEventsHandlerStub::iso15118DeleteCertificate( + ocpp::types::ocpp16::HashAlgorithmEnumType hash_algorithm, + const std::string& issuer_name_hash, + const std::string& issuer_key_hash, + const std::string& serial_number) { m_calls["iso15118ChargePointCertificateReceived"] = {{"hash_algorithm", HashAlgorithmEnumTypeHelper.toString(hash_algorithm)}, {"issuer_name_hash", issuer_name_hash}, @@ -352,7 +353,8 @@ void ChargePointEventsHandlerStub::iso15118GetInstalledCertificates( bool mo_root_certificate, bool v2g_certificate_chain, bool oem_root_certificate, - std::vector>>& + std::vector< + std::tuple>>& certificates) { (void)certificates; @@ -362,11 +364,11 @@ void ChargePointEventsHandlerStub::iso15118GetInstalledCertificates( {"oem_root_certificate", std::to_string(oem_root_certificate)}}; } -/** @copydoc ocpp::types::InstallCertificateStatusEnumType IChargePointEventsHandler::iso15118CertificateReceived( - ocpp::types::InstallCertificateUseEnumType type, +/** @copydoc ocpp::types::ocpp16::InstallCertificateStatusEnumType IChargePointEventsHandler::iso15118CertificateReceived( + ocpp::types::ocpp16::InstallCertificateUseEnumType type, const ocpp::x509::Certificate&) */ -ocpp::types::InstallCertificateStatusEnumType ChargePointEventsHandlerStub::iso15118CertificateReceived( - ocpp::types::InstallCertificateUseEnumType type, const ocpp::x509::Certificate& certificate) +ocpp::types::ocpp16::InstallCertificateStatusEnumType ChargePointEventsHandlerStub::iso15118CertificateReceived( + ocpp::types::ocpp16::InstallCertificateUseEnumType type, const ocpp::x509::Certificate& certificate) { m_calls["iso15118CertificateReceived"] = {{"type", InstallCertificateUseEnumTypeHelper.toString(type)}, {"certificate", certificate.pem()}}; @@ -411,9 +413,10 @@ bool ChargePointEventsHandlerStub::callResult(const std::string method_name) } /** @brief Set a meter value */ -void ChargePointEventsHandlerStub::setMeterValue(unsigned int connector_id, - std::pair> measurand, - const ocpp::types::MeterValue& meter_value) +void ChargePointEventsHandlerStub::setMeterValue( + unsigned int connector_id, + std::pair> measurand, + const ocpp::types::ocpp16::MeterValue& meter_value) { std::stringstream ss; ss << MeasurandHelper.toString(measurand.first) << "-"; diff --git a/tests/stubs/ChargePointEventsHandlerStub.h b/tests/stubs/ChargePointEventsHandlerStub.h old mode 100755 new mode 100644 index 0fb61a98..5ffafc92 --- a/tests/stubs/ChargePointEventsHandlerStub.h +++ b/tests/stubs/ChargePointEventsHandlerStub.h @@ -38,21 +38,21 @@ class ChargePointEventsHandlerStub : public ocpp::chargepoint::IChargePointEvent /** @copydoc void IChargePointEventsHandler::connectionUrlChanged(std::string const&) */ void connectionUrlChanged(std::string const& url) override; - /** @copydoc void IChargePointEventsHandler::connectionStateChanged(ocpp::types::RegistrationStatus) */ - void connectionFailed(ocpp::types::RegistrationStatus status) override; + /** @copydoc void IChargePointEventsHandler::connectionFailed(ocpp::types::RegistrationStatus) */ + void connectionFailed(ocpp::types::ocpp16::RegistrationStatus status) override; /** @copydoc void IChargePointEventsHandler::connectionStateChanged(bool) */ void connectionStateChanged(bool isConnected) override; - /** @copydoc void IChargePointEventsHandler::bootNotification(ocpp::types::RegistrationStatus, const ocpp::types::DateTime&) */ - void bootNotification(ocpp::types::RegistrationStatus status, const ocpp::types::DateTime& datetime) override; + /** @copydoc void IChargePointEventsHandler::bootNotification(ocpp::types::ocpp16::RegistrationStatus, const ocpp::types::DateTime&) */ + void bootNotification(ocpp::types::ocpp16::RegistrationStatus status, const ocpp::types::DateTime& datetime) override; /** @copydoc void IChargePointEventsHandler::datetimeReceived(const ocpp::types::DateTime&) */ void datetimeReceived(const ocpp::types::DateTime& datetime) override; - /** @copydoc AvailabilityStatus IChargePointEventsHandler::changeAvailabilityRequested(unsigned int, ocpp::types::AvailabilityType) */ - ocpp::types::AvailabilityStatus changeAvailabilityRequested(unsigned int connector_id, - ocpp::types::AvailabilityType availability) override; + /** @copydoc AvailabilityStatus IChargePointEventsHandler::changeAvailabilityRequested(unsigned int, ocpp::types::ocpp16::AvailabilityType) */ + ocpp::types::ocpp16::AvailabilityStatus changeAvailabilityRequested(unsigned int connector_id, + ocpp::types::ocpp16::AvailabilityType availability) override; /** @copydoc int IChargePointEventsHandler::getTxStartStopMeterValue(unsigned int) */ int getTxStartStopMeterValue(unsigned int connector_id) override; @@ -63,19 +63,19 @@ class ChargePointEventsHandlerStub : public ocpp::chargepoint::IChargePointEvent /** @copydoc void IChargePointEventsHandler::reservationEnded(unsigned int, bool) */ void reservationEnded(unsigned int connector_id, bool canceled) override; - /** @copydoc ocpp::types::DataTransferStatus IChargePointEventsHandler::dataTransferRequested(const std::string&, + /** @copydoc ocpp::types::ocpp16::DataTransferStatus IChargePointEventsHandler::dataTransferRequested(const std::string&, const std::string&, const std::string&, std::string&) */ - ocpp::types::DataTransferStatus dataTransferRequested(const std::string& vendor_id, - const std::string& message_id, - const std::string& request_data, - std::string& response_data) override; + ocpp::types::ocpp16::DataTransferStatus dataTransferRequested(const std::string& vendor_id, + const std::string& message_id, + const std::string& request_data, + std::string& response_data) override; - /** @copydoc bool IChargePointEventsHandler::getMeterValue(unsigned int, const std::pair>&, ocpp::types::MeterValue&) */ - bool getMeterValue(unsigned int connector_id, - const std::pair>& measurand, - ocpp::types::MeterValue& meter_value) override; + /** @copydoc bool IChargePointEventsHandler::getMeterValue(unsigned int, const std::pair>&, ocpp::types::ocpp16::MeterValue&) */ + bool getMeterValue(unsigned int connector_id, + const std::pair>& measurand, + ocpp::types::ocpp16::MeterValue& meter_value) override; /** @copydoc bool IChargePointEventsHandler::remoteStartTransactionRequested(unsigned int, const std::string&) */ bool remoteStartTransactionRequested(unsigned int connector_id, const std::string& id_tag) override; @@ -86,14 +86,16 @@ class ChargePointEventsHandlerStub : public ocpp::chargepoint::IChargePointEvent /** @copydoc void IChargePointEventsHandler::transactionDeAuthorized(unsigned int) */ void transactionDeAuthorized(unsigned int connector_id) override; - /** @copydoc bool IChargePointEventsHandler::getLocalLimitationsSchedule(unsigned int, unsigned int, ocpp::types::ChargingSchedule&) */ - bool getLocalLimitationsSchedule(unsigned int connector_id, unsigned int duration, ocpp::types::ChargingSchedule& schedule) override; + /** @copydoc bool IChargePointEventsHandler::getLocalLimitationsSchedule(unsigned int, unsigned int, ocpp::types::ocpp16::ChargingSchedule&) */ + bool getLocalLimitationsSchedule(unsigned int connector_id, + unsigned int duration, + ocpp::types::ocpp16::ChargingSchedule& schedule) override; - /** @copydoc bool IChargePointEventsHandler::resetRequested(ocpp::types::ResetType) */ - bool resetRequested(ocpp::types::ResetType reset_type) override; + /** @copydoc bool IChargePointEventsHandler::resetRequested(ocpp::types::ocpp16::ResetType) */ + bool resetRequested(ocpp::types::ocpp16::ResetType reset_type) override; - /** @copydoc ocpp::types::UnlockStatus IChargePointEventsHandler::unlockConnectorRequested(unsigned int) */ - ocpp::types::UnlockStatus unlockConnectorRequested(unsigned int connector_id) override; + /** @copydoc ocpp::types::ocpp16::UnlockStatus IChargePointEventsHandler::unlockConnectorRequested(unsigned int) */ + ocpp::types::ocpp16::UnlockStatus unlockConnectorRequested(unsigned int connector_id) override; /** @copydoc std::string IChargePointEventsHandler::getDiagnostics(const ocpp::types::Optional&, const ocpp::types::Optional&) */ @@ -114,34 +116,35 @@ class ChargePointEventsHandlerStub : public ocpp::chargepoint::IChargePointEvent // Security extensions - /** @copydoc ocpp::types::CertificateStatusEnumType IChargePointEventsHandler::caCertificateReceived(ocpp::types::CertificateUseEnumType, + /** @copydoc ocpp::types::ocpp16::CertificateStatusEnumType IChargePointEventsHandler::caCertificateReceived(ocpp::types::ocpp16::CertificateUseEnumType, const ocpp::x509::Certificate&) */ - ocpp::types::CertificateStatusEnumType caCertificateReceived(ocpp::types::CertificateUseEnumType type, - const ocpp::x509::Certificate& certificate) override; + ocpp::types::ocpp16::CertificateStatusEnumType caCertificateReceived(ocpp::types::ocpp16::CertificateUseEnumType type, + const ocpp::x509::Certificate& certificate) override; /** @copydoc bool IChargePointEventsHandler::chargePointCertificateReceived(const ocpp::x509::Certificate&) */ bool chargePointCertificateReceived(const ocpp::x509::Certificate& certificate) override; - /** @copydoc ocpp::types::DeleteCertificateStatusEnumType IChargePointEventsHandler::deleteCertificate(ocpp::types::HashAlgorithmEnumType, + /** @copydoc ocpp::types::ocpp16::DeleteCertificateStatusEnumType IChargePointEventsHandler::deleteCertificate(ocpp::types::ocpp16::HashAlgorithmEnumType, const std::string&, const std::string&, const std::string&) */ - ocpp::types::DeleteCertificateStatusEnumType deleteCertificate(ocpp::types::HashAlgorithmEnumType hash_algorithm, - const std::string& issuer_name_hash, - const std::string& issuer_key_hash, - const std::string& serial_number) override; + ocpp::types::ocpp16::DeleteCertificateStatusEnumType deleteCertificate(ocpp::types::ocpp16::HashAlgorithmEnumType hash_algorithm, + const std::string& issuer_name_hash, + const std::string& issuer_key_hash, + const std::string& serial_number) override; /** @copydoc void IChargePointEventsHandler::generateCsr(std::string&) */ void generateCsr(std::string& csr) override; - /** @copydoc void IChargePointEventsHandler::getInstalledCertificates(ocpp::types::CertificateUseEnumType, + /** @copydoc void IChargePointEventsHandler::getInstalledCertificates(ocpp::types::ocpp16::CertificateUseEnumType, * std::vector&) */ - void getInstalledCertificates(ocpp::types::CertificateUseEnumType type, std::vector& certificates) override; + void getInstalledCertificates(ocpp::types::ocpp16::CertificateUseEnumType type, + std::vector& certificates) override; - /** @copydoc std::string IChargePointEventsHandler::getLog(ocpp::types::LogEnumType, + /** @copydoc std::string IChargePointEventsHandler::getLog(ocpp::types::ocpp16::LogEnumType, const ocpp::types::Optional&, const ocpp::types::Optional&) */ - std::string getLog(ocpp::types::LogEnumType type, + std::string getLog(ocpp::types::ocpp16::LogEnumType type, const ocpp::types::Optional& start_time, const ocpp::types::Optional& stop_time) override; @@ -151,9 +154,10 @@ class ChargePointEventsHandlerStub : public ocpp::chargepoint::IChargePointEvent /** @copydoc bool IChargePointEventsHandler::hasChargePointCertificateInstalled() */ bool hasChargePointCertificateInstalled() override; - /** @copydoc ocpp::types::UpdateFirmwareStatusEnumType IChargePointEventsHandler::checkFirmwareSigningCertificate( + /** @copydoc ocpp::types::ocpp16::UpdateFirmwareStatusEnumType IChargePointEventsHandler::checkFirmwareSigningCertificate( * const ocpp::x509::Certificate&) */ - ocpp::types::UpdateFirmwareStatusEnumType checkFirmwareSigningCertificate(const ocpp::x509::Certificate& signing_certificate) override; + ocpp::types::ocpp16::UpdateFirmwareStatusEnumType checkFirmwareSigningCertificate( + const ocpp::x509::Certificate& signing_certificate) override; // ISO 15118 PnC extensions @@ -163,14 +167,15 @@ class ChargePointEventsHandlerStub : public ocpp::chargepoint::IChargePointEvent /** @copydoc bool IChargePointEventsHandler::iso15118ChargePointCertificateReceived(const ocpp::x509::Certificate&) */ bool iso15118ChargePointCertificateReceived(const ocpp::x509::Certificate& certificate) override; - /** @copydoc ocpp::types::DeleteCertificateStatusEnumType IChargePointEventsHandler::iso15118DeleteCertificate(ocpp::types::HashAlgorithmEnumType, + /** @copydoc ocpp::types::ocpp16::DeleteCertificateStatusEnumType IChargePointEventsHandler::iso15118DeleteCertificate(ocpp::types::ocpp16::HashAlgorithmEnumType, const std::string&, const std::string&, const std::string&) */ - ocpp::types::DeleteCertificateStatusEnumType iso15118DeleteCertificate(ocpp::types::HashAlgorithmEnumType hash_algorithm, - const std::string& issuer_name_hash, - const std::string& issuer_key_hash, - const std::string& serial_number) override; + ocpp::types::ocpp16::DeleteCertificateStatusEnumType iso15118DeleteCertificate( + ocpp::types::ocpp16::HashAlgorithmEnumType hash_algorithm, + const std::string& issuer_name_hash, + const std::string& issuer_key_hash, + const std::string& serial_number) override; /** @copydoc void IChargePointEventsHandler::iso15118GetInstalledCertificates( bool, @@ -183,14 +188,15 @@ class ChargePointEventsHandlerStub : public ocpp::chargepoint::IChargePointEvent bool mo_root_certificate, bool v2g_certificate_chain, bool oem_root_certificate, - std::vector>>& + std::vector< + std::tuple>>& certificates) override; - /** @copydoc ocpp::types::InstallCertificateStatusEnumType IChargePointEventsHandler::iso15118CertificateReceived( - ocpp::types::InstallCertificateUseEnumType type, + /** @copydoc ocpp::types::ocpp16::InstallCertificateStatusEnumType IChargePointEventsHandler::iso15118CertificateReceived( + ocpp::types::ocpp16::InstallCertificateUseEnumType type, const ocpp::x509::Certificate&) */ - ocpp::types::InstallCertificateStatusEnumType iso15118CertificateReceived(ocpp::types::InstallCertificateUseEnumType type, - const ocpp::x509::Certificate& certificate) override; + ocpp::types::ocpp16::InstallCertificateStatusEnumType iso15118CertificateReceived( + ocpp::types::ocpp16::InstallCertificateUseEnumType type, const ocpp::x509::Certificate& certificate) override; /** @copydoc void IChargePointEventsHandler::iso15118GenerateCsr(std::string&) */ void iso15118GenerateCsr(std::string& csr) override; @@ -205,19 +211,22 @@ class ChargePointEventsHandlerStub : public ocpp::chargepoint::IChargePointEvent /** @brief Call results for boolean methods */ void setCallResult(const std::string method_name, bool result) { m_call_results[method_name] = result; } /** @brief Availability status to return */ - void setAvailabilityStatus(ocpp::types::AvailabilityStatus availability_status) { m_availability_status = availability_status; } + void setAvailabilityStatus(ocpp::types::ocpp16::AvailabilityStatus availability_status) { m_availability_status = availability_status; } /** @brief Tx start stop meter value */ void setTxStartStopMeterValue(int tx_start_stop_value) { m_tx_start_stop_value = tx_start_stop_value; } /** @brief Data transfer status */ - void setDataTransferStatus(ocpp::types::DataTransferStatus data_transfer_status) { m_data_transfer_status = data_transfer_status; } + void setDataTransferStatus(ocpp::types::ocpp16::DataTransferStatus data_transfer_status) + { + m_data_transfer_status = data_transfer_status; + } /** @brief Unlock status */ - void setUnlockStatus(ocpp::types::UnlockStatus unlock_status) { m_unlock_status = unlock_status; } + void setUnlockStatus(ocpp::types::ocpp16::UnlockStatus unlock_status) { m_unlock_status = unlock_status; } /** @brief Diagnostic / log file */ void setDiagFile(std::string diag_file) { m_diag_file = diag_file; } /** @brief Set a meter value */ - void setMeterValue(unsigned int connector_id, - std::pair> measurand, - const ocpp::types::MeterValue& meter_value); + void setMeterValue(unsigned int connector_id, + std::pair> measurand, + const ocpp::types::ocpp16::MeterValue& meter_value); private: /** @brief Calls to the event handler */ @@ -226,17 +235,17 @@ class ChargePointEventsHandlerStub : public ocpp::chargepoint::IChargePointEvent /** @brief Call results for boolean methods */ std::map m_call_results; /** @brief Availability status to return */ - ocpp::types::AvailabilityStatus m_availability_status; + ocpp::types::ocpp16::AvailabilityStatus m_availability_status; /** @brief Tx start stop meter value */ int m_tx_start_stop_value; /** @brief Data transfer status */ - ocpp::types::DataTransferStatus m_data_transfer_status; + ocpp::types::ocpp16::DataTransferStatus m_data_transfer_status; /** @brief Unlock status */ - ocpp::types::UnlockStatus m_unlock_status; + ocpp::types::ocpp16::UnlockStatus m_unlock_status; /** @brief Diagnostic / log file */ std::string m_diag_file; /** @brief Meter values */ - std::map> m_meter_values; + std::map> m_meter_values; /** @brief Get the call result of a method */ bool callResult(const std::string method_name); diff --git a/tests/stubs/OcppConfigStub.h b/tests/stubs/OcppConfigStub.h index 132247f0..dc91baf8 100755 --- a/tests/stubs/OcppConfigStub.h +++ b/tests/stubs/OcppConfigStub.h @@ -51,11 +51,11 @@ class OcppConfigStub : public IOcppConfig /// /** @copydoc void IOcppConfig::getConfiguration(const std::vector>&, - * std::vector&, + * std::vector&, * std::vector>&); */ void getConfiguration(const std::vector>& keys, - std::vector& values, + std::vector& values, std::vector>& unknown_values) override { (void)keys; @@ -68,11 +68,11 @@ class OcppConfigStub : public IOcppConfig /// /** @copydoc ConfigurationStatus IOcppConfig::setConfiguration(const std::string&, const std::string&) */ - ocpp::types::ConfigurationStatus setConfiguration(const std::string& key, const std::string& value) override + ocpp::types::ocpp16::ConfigurationStatus setConfiguration(const std::string& key, const std::string& value) override { (void)key; (void)value; - return ocpp::types::ConfigurationStatus::Rejected; + return ocpp::types::ocpp16::ConfigurationStatus::Rejected; } // diff --git a/tests/stubs/StatusManagerStub.cpp b/tests/stubs/StatusManagerStub.cpp index 4a98bd72..b1c5ce9e 100644 --- a/tests/stubs/StatusManagerStub.cpp +++ b/tests/stubs/StatusManagerStub.cpp @@ -19,6 +19,7 @@ along with OpenOCPP. If not, see . #include "StatusManagerStub.h" using namespace ocpp::types; +using namespace ocpp::types::ocpp16; namespace ocpp { @@ -36,18 +37,18 @@ StatusManagerStub::StatusManagerStub() StatusManagerStub::~StatusManagerStub() { } /** @copydoc bool IStatusManager::updateConnectorStatus(unsigned int, - * ocpp::types::ChargePointStatus, - * ocpp::types::ChargePointErrorCode, + * ocpp::types::ocpp16::ChargePointStatus, + * ocpp::types::ocpp16::ChargePointErrorCode, * const std::string&, * const std::string&, * const std::string&) */ -bool StatusManagerStub::updateConnectorStatus(unsigned int connector_id, - ocpp::types::ChargePointStatus status, - ocpp::types::ChargePointErrorCode error_code, - const std::string& info, - const std::string& vendor_id, - const std::string& vendor_error) +bool StatusManagerStub::updateConnectorStatus(unsigned int connector_id, + ocpp::types::ocpp16::ChargePointStatus status, + ocpp::types::ocpp16::ChargePointErrorCode error_code, + const std::string& info, + const std::string& vendor_id, + const std::string& vendor_error) { auto connector_status = std::make_tuple(status, error_code, info, vendor_id, vendor_error); m_connectors[connector_id] = connector_status; @@ -55,7 +56,7 @@ bool StatusManagerStub::updateConnectorStatus(unsigned int } /** @brief Get the status of a connector */ -ocpp::types::ChargePointStatus StatusManagerStub::StatusManagerStub::getConnectorStatus(unsigned int connector_id) +ocpp::types::ocpp16::ChargePointStatus StatusManagerStub::StatusManagerStub::getConnectorStatus(unsigned int connector_id) { ChargePointStatus status = ChargePointStatus::Unavailable; @@ -69,7 +70,7 @@ ocpp::types::ChargePointStatus StatusManagerStub::StatusManagerStub::getConnecto } /** @brief Get the error code of a connector */ -ocpp::types::ChargePointErrorCode StatusManagerStub::getConnectorErrorCode(unsigned int connector_id) +ocpp::types::ocpp16::ChargePointErrorCode StatusManagerStub::getConnectorErrorCode(unsigned int connector_id) { ChargePointErrorCode error = ChargePointErrorCode::OtherError; diff --git a/tests/stubs/StatusManagerStub.h b/tests/stubs/StatusManagerStub.h index 1be0803f..d1dd291f 100644 --- a/tests/stubs/StatusManagerStub.h +++ b/tests/stubs/StatusManagerStub.h @@ -41,28 +41,28 @@ class StatusManagerStub : public IStatusManager // IStatusManager interface - /** @copydoc ocpp::types::RegistrationStatus IStatusManager::getRegistrationStatus() */ - ocpp::types::RegistrationStatus getRegistrationStatus() override { return m_registration_status; } + /** @copydoc ocpp::types::ocpp16::RegistrationStatus IStatusManager::getRegistrationStatus() */ + ocpp::types::ocpp16::RegistrationStatus getRegistrationStatus() override { return m_registration_status; } - /** @copydoc void IStatusManager::forceRegistrationStatus(ocpp::types::RegistrationStatus) */ - void forceRegistrationStatus(ocpp::types::RegistrationStatus status) override { m_registration_status = status; } + /** @copydoc void IStatusManager::forceRegistrationStatus(ocpp::types::ocpp16::RegistrationStatus) */ + void forceRegistrationStatus(ocpp::types::ocpp16::RegistrationStatus status) override { m_registration_status = status; } /** @copydoc void IStatusManager::updateConnectionStatus(bool) */ void updateConnectionStatus(bool is_connected) override { m_connected = is_connected; } /** @copydoc bool IStatusManager::updateConnectorStatus(unsigned int, - * ocpp::types::ChargePointStatus, - * ocpp::types::ChargePointErrorCode, + * ocpp::types::ocpp16::ChargePointStatus, + * ocpp::types::ocpp16::ChargePointErrorCode, * const std::string&, * const std::string&, * const std::string&) */ - bool updateConnectorStatus(unsigned int connector_id, - ocpp::types::ChargePointStatus status, - ocpp::types::ChargePointErrorCode error_code = ocpp::types::ChargePointErrorCode::NoError, - const std::string& info = "", - const std::string& vendor_id = "", - const std::string& vendor_error = "") override; + bool updateConnectorStatus(unsigned int connector_id, + ocpp::types::ocpp16::ChargePointStatus status, + ocpp::types::ocpp16::ChargePointErrorCode error_code = ocpp::types::ocpp16::ChargePointErrorCode::NoError, + const std::string& info = "", + const std::string& vendor_id = "", + const std::string& vendor_error = "") override; /** @copydoc void IStatusManager::resetHeartBeatTimer() */ void resetHeartBeatTimer() override { m_hb_timer_reset = true; } @@ -75,9 +75,9 @@ class StatusManagerStub : public IStatusManager bool isHeartbeatTimerReset() const { return m_hb_timer_reset; } /** @brief Get the status of a connector */ - ocpp::types::ChargePointStatus getConnectorStatus(unsigned int connector_id); + ocpp::types::ocpp16::ChargePointStatus getConnectorStatus(unsigned int connector_id); /** @brief Get the error code of a connector */ - ocpp::types::ChargePointErrorCode getConnectorErrorCode(unsigned int connector_id); + ocpp::types::ocpp16::ChargePointErrorCode getConnectorErrorCode(unsigned int connector_id); /** @brief Get the info of a connector */ std::string getConnectorInfo(unsigned int connector_id); /** @brief Get the vendor id of a connector */ @@ -90,14 +90,16 @@ class StatusManagerStub : public IStatusManager private: /** @brief Registration status */ - ocpp::types::RegistrationStatus m_registration_status; + ocpp::types::ocpp16::RegistrationStatus m_registration_status; /** @brief Connection status */ bool m_connected; /** @brief Indicate if the heartbeat timer has been reset */ bool m_hb_timer_reset; /** @brief Connectors status */ - std::map> + std::map< + unsigned int, + std:: + tuple> m_connectors; }; diff --git a/tests/stubs/TriggerMessageManagerStub.h b/tests/stubs/TriggerMessageManagerStub.h index ee21e83a..37ba58a6 100755 --- a/tests/stubs/TriggerMessageManagerStub.h +++ b/tests/stubs/TriggerMessageManagerStub.h @@ -37,14 +37,14 @@ class TriggerMessageManagerStub : public ITriggerMessageManager /** @brief Destructor */ virtual ~TriggerMessageManagerStub() { } - /** @copydoc void ITriggerMessageManager::registerHandler(ocpp::types::MessageTrigger, ITriggerMessageHandler&) */ - void registerHandler(ocpp::types::MessageTrigger message, ITriggerMessageHandler& handler) override + /** @copydoc void ITriggerMessageManager::registerHandler(ocpp::types::ocpp16::MessageTrigger, ITriggerMessageHandler&) */ + void registerHandler(ocpp::types::ocpp16::MessageTrigger message, ITriggerMessageHandler& handler) override { m_standard_handlers[message] = &handler; } - /** @copydoc void ITriggerMessageManager::registerHandler(ocpp::types::MessageTriggerEnumType, IExtendedTriggerMessageHandler&) */ - void registerHandler(ocpp::types::MessageTriggerEnumType message, IExtendedTriggerMessageHandler& handler) override + /** @copydoc void ITriggerMessageManager::registerHandler(ocpp::types::ocpp16::MessageTriggerEnumType, IExtendedTriggerMessageHandler&) */ + void registerHandler(ocpp::types::ocpp16::MessageTriggerEnumType message, IExtendedTriggerMessageHandler& handler) override { m_extended_handlers[message] = &handler; } @@ -52,23 +52,23 @@ class TriggerMessageManagerStub : public ITriggerMessageManager // API /** @brief Check if a handler has been registered for a message */ - bool isMessageHandlerRegistered(ocpp::types::MessageTrigger message) const + bool isMessageHandlerRegistered(ocpp::types::ocpp16::MessageTrigger message) const { return (m_standard_handlers.find(message) != m_standard_handlers.end()); } /** @brief Check if a handler has been registered for a message */ - bool isMessageHandlerRegistered(ocpp::types::MessageTriggerEnumType message) const + bool isMessageHandlerRegistered(ocpp::types::ocpp16::MessageTriggerEnumType message) const { return (m_extended_handlers.find(message) != m_extended_handlers.end()); } private: /** @brief Handlers for standard trigger messages */ - std::map m_standard_handlers; + std::map m_standard_handlers; /** @brief Handlers for extended trigger messages */ - std::map m_extended_handlers; + std::map m_extended_handlers; }; } // namespace chargepoint diff --git a/tools/json2cpp/json2cpp.py b/tools/json2cpp/json2cpp.py new file mode 100644 index 00000000..14f4704f --- /dev/null +++ b/tools/json2cpp/json2cpp.py @@ -0,0 +1,1030 @@ +# -*- coding: utf-8 -*- + +''' +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +''' + +import os +import sys +import argparse +import jinja2 +import json + +class Parameters(object): + ''' + Tools parameters + ''' + + def __init__(self): + ''' + Constructor + ''' + + self.input_dir = "" + ''' Input directory ''' + + self.output_dir = "" + ''' Output directory ''' + + self.templates_dir = "" + ''' Code templates directory ''' + + self.ocpp_version = "" + ''' OCPP version ''' + + self.types_dir = "" + ''' Directory where the data types will be generated ''' + + self.messages_dir = "" + ''' Directory where the messages will be generated ''' + +class Type(object): + ''' + OCPP type + ''' + + def __init__(self): + ''' + Constructor + ''' + + self.name = "" + ''' Name of the type ''' + + self.basic_type = "" + ''' Corresponding basic type ''' + + self.comment = "" + ''' Comment of the type definition ''' + + self.requires = [] + ''' Dependencies of the type ''' + + self.fields = {} + ''' Fields composing the type ''' + + def cpp_dependencies(self) -> list: + ''' + Get the C++ dependencies corresponding to the type + ''' + deps = [] + for field in self.fields.values(): + field_deps = field.cpp_dependencies() + for field_dep in field_deps: + if not field_dep in deps: + deps.append(field_dep) + return deps + +class TypeField(object): + ''' + Field of an OCPP type + ''' + + def __init__(self): + ''' + Constructor + ''' + + self.name = "" + ''' Name of the field ''' + + self.type = "" + ''' Type of the field ''' + + self.array_type = None + ''' Underlying type of the array composing the field ''' + + self.is_required = False + ''' Indicate if the presence of the field is required ''' + + self.min = None + ''' Minimum value of the field ''' + + self.max = None + ''' Maximum value of the field ''' + + self.comment = "" + ''' Comment of the field ''' + + def cpp_type(self, add_namespace : str) -> str: + ''' + Get the C++ type corresponding to the type of the field + ''' + type = self.get_cpp_type(self.type, add_namespace) + if not self.is_required and not self.type == "array": + type = f"ocpp::types::Optional<{type}>" + return type + + def cpp_dependencies(self) -> list: + ''' + Get the C++ dependencies corresponding to the type of the field + ''' + deps = self.__cpp_dependencies(self.type) + if not self.is_required and not self.type == "array": + deps.append('"Optional.h"') + return deps + + def get_cpp_type(self, type : str, add_namespace : str) -> str: + ''' + Get the C++ type corresponding to the type of the field + ''' + if type == "string": + if self.max: + return f"ocpp::types::CiStringType<{self.max}u>" + else: + return "std::string" + elif type == "array": + return f"std::vector<{self.get_cpp_type(self.array_type, add_namespace)}>" + elif type == "integer": + return "int" + elif type == "boolean": + return "bool" + elif type == "number": + return "float" + elif type == "date-time": + return "ocpp::types::DateTime" + else: + if not (len(add_namespace) == 0): + return f"ocpp::types::{add_namespace}::{type}" + else: + return type + + def __cpp_dependencies(self, type : str) -> list: + ''' + Get the C++ dependencies corresponding to the type of the field + ''' + if type == "string": + if self.max: + return ['"CiStringType.h"'] + else: + return [""] + elif type == "array": + deps = [""] + array_deps = self.__cpp_dependencies(self.array_type) + for array_dep in array_deps: + if not array_dep in deps: + deps.append(array_dep) + return deps + elif type == "date-time": + return ['"DateTime.h"'] + else: + return [] + +class Request(Type): + ''' + OCPP request + ''' + + def __init__(self): + ''' + Constructor + ''' + + self.associated_types = [] + ''' OCPP types associated with the request ''' + +class Message(Type): + ''' + OCPP message + ''' + + def __init__(self): + ''' + Constructor + ''' + + self.name = "" + ''' Name of the message ''' + + self.id = "" + ''' Id of the message definition ''' + + self.comment = "" + ''' Comment of the message definition ''' + + self.request = Request() + ''' Request ''' + + self.response = Request() + ''' Response ''' + + self.types = {} + ''' Dictionnary of the request and response types ''' + +def check_dir_exists(dir, path) -> bool: + ''' + Check if a directory exists + + @param dir: Name of the directory to check + @type dir: string + + @param path: Path to the directory to check + @type path: string + + @return: if the directory exists : True, if not : False + @rtype: boolean + ''' + + ret = False + if os.path.exists(path): + if os.path.exists(path): + ret = True + else: + print(f"{dir} must be a directory") + else: + print(f"{dir} does not exists") + return ret + +def check_args(args, params): + ''' + Check the command line parameters + + @param args: command line parameters + @type args: string[] + + @param params: parameter storage class + @type params: Parameters + + @return: if the parameters are valid : True, if not : False + @rtype: boolean + ''' + + # Retrieve the parameters + parser_description = "json2cpp" + parser = argparse.ArgumentParser(description=parser_description) + parser.add_argument('-i', nargs=1, metavar='input_dir', required=True, + help='[string] Input directory') + parser.add_argument('-o', nargs=1, metavar='output_dir', required=True, + help='[string] Output directory (must exists)') + parser.add_argument('-t', nargs=1, metavar='templates_dir', required=False, + help='[string] Code templates directory') + parser.add_argument('-v', nargs=1, metavar='ocpp_version', required=True, + help='[string] OCPP version (ocpp20 or ocpp21)') + + # Display the software inline help + if (("-h" in args) or ("--help" in args)): + parser.print_help() + return False + + # Parse the parameters + args = parser.parse_args() + params.input_dir = args.i[0] + params.output_dir = args.o[0] + params.ocpp_version = args.v[0] + if args.t: + params.templates_dir = args.t[0] + else: + params.templates_dir = os.path.join(os.curdir, "templates") + + # Checks params + return check_dir_exists("Input directory", params.input_dir) and check_dir_exists("Output directory", params.output_dir) + +def read_code_templates(params) -> dict: + ''' + Read the code templates + + @param params: Command line parameters + @type params: Parameters + + @return: Content of the code template files if they exists, None otherwise + @rtype: {string, string} + ''' + + templates = {} + + try: + template_file_path = os.path.join(params.templates_dir, "types", "enum_header.template.j2") + template_file = open(template_file_path, "rt") + templates["enum_header"] = template_file.read() + + template_file_path = os.path.join(params.templates_dir, "types", "enum_impl.template.j2") + template_file = open(template_file_path, "rt") + templates["enum_impl"] = template_file.read() + + template_file_path = os.path.join(params.templates_dir, "types", "type_header.template.j2") + template_file = open(template_file_path, "rt") + templates["type_header"] = template_file.read() + + template_file_path = os.path.join(params.templates_dir, "types", "type_impl.template.j2") + template_file = open(template_file_path, "rt") + templates["type_impl"] = template_file.read() + + template_file_path = os.path.join(params.templates_dir, "messages", "msg_header.template.j2") + template_file = open(template_file_path, "rt") + templates["msg_header"] = template_file.read() + + template_file_path = os.path.join(params.templates_dir, "messages", "msg_impl.template.j2") + template_file = open(template_file_path, "rt") + templates["msg_impl"] = template_file.read() + + template_file_path = os.path.join(params.templates_dir, "messages", "MessagesConverter.cpp.j2") + template_file = open(template_file_path, "rt") + templates["msg_converter_impl"] = template_file.read() + + template_file_path = os.path.join(params.templates_dir, "messages", "MessagesValidator.cpp.j2") + template_file = open(template_file_path, "rt") + templates["msg_validator_impl"] = template_file.read() + + + template_file_path = os.path.join(params.templates_dir, "chargepoint", "IChargePoint.h.j2") + template_file = open(template_file_path, "rt") + templates["cs_ichargepoint"] = template_file.read() + + template_file_path = os.path.join(params.templates_dir, "chargepoint", "IChargePointEventsHandler.h.j2") + template_file = open(template_file_path, "rt") + templates["cs_ichargepointeventshandler"] = template_file.read() + + + template_file_path = os.path.join(params.templates_dir, "centralsystem", "ICentralSystem.h.j2") + template_file = open(template_file_path, "rt") + templates["csms_icentralsystem"] = template_file.read() + + template_file_path = os.path.join(params.templates_dir, "centralsystem", "IChargePointRequestHandler.h.j2") + template_file = open(template_file_path, "rt") + templates["csms_ichargepointrequesthandler"] = template_file.read() + + template_file_path = os.path.join(params.templates_dir, "centralsystem", "ChargePointProxy.h.j2") + template_file = open(template_file_path, "rt") + templates["csms_chargepointproxy_header"] = template_file.read() + + template_file_path = os.path.join(params.templates_dir, "centralsystem", "ChargePointProxy.cpp.j2") + template_file = open(template_file_path, "rt") + templates["csms_chargepointproxy_impl"] = template_file.read() + + template_file_path = os.path.join(params.templates_dir, "centralsystem", "ChargePointHandler.h.j2") + template_file = open(template_file_path, "rt") + templates["csms_chargepointhandler_header"] = template_file.read() + + template_file_path = os.path.join(params.templates_dir, "centralsystem", "ChargePointHandler.cpp.j2") + template_file = open(template_file_path, "rt") + templates["csms_chargepointhandler_impl"] = template_file.read() + + + template_file_path = os.path.join(params.templates_dir, "localcontroller", "ICentralSystemProxy.h.j2") + template_file = open(template_file_path, "rt") + templates["lc_icentralsystemproxy"] = template_file.read() + + template_file_path = os.path.join(params.templates_dir, "localcontroller", "IChargePointProxy.h.j2") + template_file = open(template_file_path, "rt") + templates["lc_ichargepointproxy"] = template_file.read() + + template_file_path = os.path.join(params.templates_dir, "localcontroller", "CentralSystemProxy.h.j2") + template_file = open(template_file_path, "rt") + templates["lc_centralsystemproxy_header"] = template_file.read() + + template_file_path = os.path.join(params.templates_dir, "localcontroller", "CentralSystemProxy.cpp.j2") + template_file = open(template_file_path, "rt") + templates["lc_centralsystemproxy_impl"] = template_file.read() + + template_file_path = os.path.join(params.templates_dir, "localcontroller", "CentralSystemHandler.h.j2") + template_file = open(template_file_path, "rt") + templates["lc_centralsystemhandler_header"] = template_file.read() + + template_file_path = os.path.join(params.templates_dir, "localcontroller", "CentralSystemHandler.cpp.j2") + template_file = open(template_file_path, "rt") + templates["lc_centralsystemhandler_impl"] = template_file.read() + + template_file_path = os.path.join(params.templates_dir, "localcontroller", "ChargePointProxy.h.j2") + template_file = open(template_file_path, "rt") + templates["lc_chargepointproxy_header"] = template_file.read() + + template_file_path = os.path.join(params.templates_dir, "localcontroller", "ChargePointProxy.cpp.j2") + template_file = open(template_file_path, "rt") + templates["lc_chargepointproxy_impl"] = template_file.read() + + template_file_path = os.path.join(params.templates_dir, "localcontroller", "ChargePointHandler.h.j2") + template_file = open(template_file_path, "rt") + templates["lc_chargepointhandler_header"] = template_file.read() + + template_file_path = os.path.join(params.templates_dir, "localcontroller", "ChargePointHandler.cpp.j2") + template_file = open(template_file_path, "rt") + templates["lc_chargepointhandler_impl"] = template_file.read() + + except IOError: + print(f"Unable to open template file : {template_file_path}") + templates = None + + return templates + +def parse_type_contents(name, contents, ocpp_version_suffix) -> Type: + ''' + Parse the contents of an OCPP type message + + @params name: Name of the OCPP type + @type name: string + + @param contents: JSON definition of the OCPP type + @type contents: json + + @param ocpp_version_suffix: Suffix of the OCPP version + @type ocpp_version_suffix: string + + @return message: OCPP message type + @rtype message: Message + ''' + + # Generic type data + type = Type() + type.name = f"{name}" + type.basic_type = contents["type"] + if "description" in contents: + type.comment = contents["description"] + + # Specific data + if type.basic_type == "object": + for property in contents["properties"]: + property_definition = contents["properties"][property] + + field = TypeField() + field.name = property + if "description" in property_definition: + field.comment = property_definition["description"] + if "$ref" in property_definition: + external_type = property_definition["$ref"] + field.type = external_type[external_type.rfind("/") + 1:] + type.requires.append(field.type) + else: + if "type" in property_definition: + field.type = property_definition["type"] + else: + field.type = "string" + if field.type == "string": + if "maxLength" in property_definition: + field.max = property_definition["maxLength"] + if "format" in property_definition: + if property_definition["format"] == "date-time": + field.type = "date-time" + elif field.type == "array": + if "$ref" in property_definition["items"]: + external_type = property_definition["items"]["$ref"] + field.array_type = external_type[external_type.rfind("/") + 1:] + type.requires.append(field.array_type) + else: + field.array_type = property_definition["items"]["type"] + else: + pass + + type.fields[property] = field + + if "required" in contents: + for required_field in contents["required"]: + type.fields[required_field].is_required = True + + elif type.basic_type == "string" and "enum" in contents: + type.basic_type = "enum" + for enum_value in contents["enum"]: + type.fields[enum_value] = enum_value + + else: + print(f"Unknown type : {type.basic_type}") + pass + + return type + + + +def parse_message_contents(message, contents, ocpp_version_suffix) -> None: + ''' + Parse the contents of an OCPP message + + @param message: OCPP message data + @type message: Message + + @param contents: JSON definition of the OCPP message + @type contents: json + + @param ocpp_version_suffix: Suffix of the OCPP version + @type ocpp_version_suffix: string + ''' + + # Types definition + for type_name in contents["definitions"]: + type_definition = contents["definitions"][type_name] + type = parse_type_contents(type_name, type_definition, ocpp_version_suffix) + message.associated_types.append(type) + + # Message + message_type = parse_type_contents("", contents, ocpp_version_suffix) + message.fields = message_type.fields + message.requires = message_type.requires + + return + +def gen_ocpp_enum(message, enum, templates, params, ocpp_version_suffix) -> None: + ''' + Generate the code corresponding to an OCPP enum + + @param message: Associated OCPP message + @type message: Message + + @param enum: OCPP enum + @type enum: Type + + @param templates: Code templates + @type templates: {string,string} + + @param params: Command line parameters + @type params: Parameters + + @param ocpp_version_suffix: Suffix of the OCPP version + @type ocpp_version_suffix: string + ''' + + # Generate header file + enum_header_path = os.path.join(params.types_dir, enum.name + ocpp_version_suffix + ".h") + enum_header = open(enum_header_path, "wt") + + env = jinja2.Environment() + template = env.from_string(templates["enum_header"]) + rendered_template = template.render(message = message, enum = enum, ocpp_version_namespace = params.ocpp_version, ocpp_version_suffix = ocpp_version_suffix) + + enum_header.write(rendered_template) + enum_header.close() + + # Generate implementation file + enum_impl_path = os.path.join(params.types_dir, enum.name + ocpp_version_suffix + ".cpp") + enum_impl = open(enum_impl_path, "wt") + + env = jinja2.Environment() + template = env.from_string(templates["enum_impl"]) + rendered_template = template.render(message = message, enum = enum, ocpp_version_namespace = params.ocpp_version, ocpp_version_suffix = ocpp_version_suffix) + + enum_impl.write(rendered_template) + enum_impl.close() + +def gen_ocpp_type(message, type, other_types, templates, params, ocpp_version_suffix) -> None: + ''' + Generate the code corresponding to an OCPP type + + @param message: Associated OCPP message + @type message: Message + + @param type: OCPP type + @type type: Type + + @param other_types: OCPP types + @type other_types: {string,Type} + + @param templates: Code templates + @type templates: {string,string} + + @param params: Command line parameters + @type params: Parameters + + @param ocpp_version_suffix: Suffix of the OCPP version + @type ocpp_version_suffix: string + ''' + + # Generate header file + type_header_path = os.path.join(params.types_dir, type.name + ocpp_version_suffix + ".h") + type_header = open(type_header_path, "wt") + + env = jinja2.Environment() + template = env.from_string(templates["type_header"]) + rendered_template = template.render(message = message, type = type, ocpp_version_namespace = params.ocpp_version, ocpp_version_suffix = ocpp_version_suffix) + + type_header.write(rendered_template) + type_header.close() + + # Generate implementation file + type_impl_path = os.path.join(params.types_dir, type.name + ocpp_version_suffix + ".cpp") + type_impl = open(type_impl_path, "wt") + + env = jinja2.Environment() + template = env.from_string(templates["type_impl"]) + rendered_template = template.render(message = message, type = type, other_types=other_types, ocpp_version_namespace = params.ocpp_version, ocpp_version_suffix = ocpp_version_suffix) + + type_impl.write(rendered_template) + type_impl.close() + +def gen_ocpp_message(message, templates, params) -> None: + ''' + Generate the code corresponding to an OCPP message + + @param message: Name of the OCPP message + @type message: string + + @param templates: Code templates + @type templates: {string,string} + + @param params: Command line parameters + @type params: Parameters + ''' + + # Message object + ocpp_version_suffix = params.ocpp_version[4:] + + msg = Message() + msg.name = f"{message}" + + # Parse input files + request = json.load(open(os.path.join(params.input_dir, f"{ocpp_message}Request.json"))) + parse_message_contents(msg.request, request, ocpp_version_suffix) + response = json.load(open(os.path.join(params.input_dir, f"{ocpp_message}Response.json"))) + parse_message_contents(msg.response, response, ocpp_version_suffix) + + msg.id = request["$id"] + msg.comment = request["comment"] + msg.types = {f"{ocpp_message}Req": msg.request, f"{ocpp_message}Conf": msg.response} + + # Required types + msg.requires = msg.request.requires + for required_type in msg.response.requires: + if not required_type in msg.requires: + msg.requires.append(required_type) + + # Generate associated type + associated_types = {} + for type in msg.request.associated_types: + associated_types[type.name] = type + for type in msg.response.associated_types: + associated_types[type.name] = type + for associated_type in associated_types.values(): + if associated_type.basic_type == "enum": + gen_ocpp_enum(msg, associated_type, templates, params, ocpp_version_suffix) + else: + gen_ocpp_type(msg, associated_type, associated_types, templates, params, ocpp_version_suffix) + + # Generate message header file + msg_header_path = os.path.join(params.messages_dir, ocpp_message + ocpp_version_suffix + ".h") + msg_header = open(msg_header_path, "wt") + + env = jinja2.Environment() + template = env.from_string(templates["msg_header"]) + rendered_template = template.render(msg = msg, ocpp_version_namespace = params.ocpp_version, ocpp_version_suffix = ocpp_version_suffix) + + msg_header.write(rendered_template) + msg_header.close() + + # Generate implementation file + msg_impl_path = os.path.join(params.messages_dir, ocpp_message + ocpp_version_suffix + ".cpp") + msg_impl = open(msg_impl_path, "wt") + + env = jinja2.Environment() + template = env.from_string(templates["msg_impl"]) + rendered_template = template.render(msg = msg, other_types = associated_types, ocpp_version_namespace = params.ocpp_version, ocpp_version_suffix = ocpp_version_suffix) + + msg_impl.write(rendered_template) + msg_impl.close() + + return + +def gen_converters(templates, params, msg_list): + ''' + Generate the code for the message converters + + @param templates: Code templates + @type templates: {string,string} + + @param params: Command line parameters + @type params: Parameters + + @param msg_list: List of OCPP messages per roles + @type msg_list: {string, [string]} + ''' + + # Generate implementations + ocpp_version_suffix = params.ocpp_version[4:] + + gen_file_path = os.path.join(params.messages_dir, f"MessagesConverter{ocpp_version_suffix}.cpp") + gen_file = open(gen_file_path, "wt") + env = jinja2.Environment() + template = env.from_string(templates["msg_converter_impl"]) + rendered_template = template.render(csms_msgs = msg_list["from_csms"], cs_msgs = msg_list["from_cs"], ocpp_version_namespace = params.ocpp_version, ocpp_version_suffix = ocpp_version_suffix) + gen_file.write(rendered_template) + gen_file.close() + + gen_file_path = os.path.join(params.messages_dir, f"MessagesValidator{ocpp_version_suffix}.cpp") + gen_file = open(gen_file_path, "wt") + env = jinja2.Environment() + template = env.from_string(templates["msg_validator_impl"]) + rendered_template = template.render(csms_msgs = msg_list["from_csms"], cs_msgs = msg_list["from_cs"], ocpp_version_namespace = params.ocpp_version, ocpp_version_suffix = ocpp_version_suffix) + gen_file.write(rendered_template) + gen_file.close() + +def gen_chargepoint(templates, params, msg_list): + ''' + Generate the code for the charge point features + + @param templates: Code templates + @type templates: {string,string} + + @param params: Command line parameters + @type params: Parameters + + @param msg_list: List of OCPP messages per roles + @type msg_list: {string, [string]} + ''' + + # Create output directories + cs_dir = os.path.join(params.output_dir, "chargepoint") + cs_dirs = [cs_dir] + cs_dirs.append(os.path.join(cs_dir, "interface")) + for dir in cs_dirs: + if not os.path.exists(dir): + os.mkdir(dir) + + # Generate interfaces + cs_interface_dir = cs_dirs[1] + ocpp_version_suffix = params.ocpp_version[4:] + + gen_file_path = os.path.join(cs_interface_dir, f"IChargePoint{ocpp_version_suffix}.h") + gen_file = open(gen_file_path, "wt") + env = jinja2.Environment() + template = env.from_string(templates["cs_ichargepoint"]) + rendered_template = template.render(csms_msgs = msg_list["from_csms"], cs_msgs = msg_list["from_cs"], ocpp_version_namespace = params.ocpp_version, ocpp_version_suffix = ocpp_version_suffix) + gen_file.write(rendered_template) + gen_file.close() + + gen_file_path = os.path.join(cs_interface_dir, f"IChargePointEventsHandler{ocpp_version_suffix}.h") + gen_file = open(gen_file_path, "wt") + env = jinja2.Environment() + template = env.from_string(templates["cs_ichargepointeventshandler"]) + rendered_template = template.render(csms_msgs = msg_list["from_csms"], cs_msgs = msg_list["from_cs"], ocpp_version_namespace = params.ocpp_version, ocpp_version_suffix = ocpp_version_suffix) + gen_file.write(rendered_template) + gen_file.close() + + return + + +def gen_centralsystem(templates, params, msg_list): + ''' + Generate the code for the central system features + + @param templates: Code templates + @type templates: {string,string} + + @param params: Command line parameters + @type params: Parameters + + @param msg_list: List of OCPP messages per roles + @type msg_list: {string, [string]} + ''' + + # Create output directories + csms_dir = os.path.join(params.output_dir, "centralsystem") + csms_dirs = [csms_dir] + csms_dirs.append(os.path.join(csms_dir, "chargepoint")) + csms_dirs.append(os.path.join(csms_dir, "interface")) + for dir in csms_dirs: + if not os.path.exists(dir): + os.mkdir(dir) + + # Generate interfaces + csms_interface_dir = csms_dirs[2] + ocpp_version_suffix = params.ocpp_version[4:] + + gen_file_path = os.path.join(csms_interface_dir, f"ICentralSystem{ocpp_version_suffix}.h") + gen_file = open(gen_file_path, "wt") + env = jinja2.Environment() + template = env.from_string(templates["csms_icentralsystem"]) + rendered_template = template.render(csms_msgs = msg_list["from_csms"], cs_msgs = msg_list["from_cs"], ocpp_version_namespace = params.ocpp_version, ocpp_version_suffix = ocpp_version_suffix) + gen_file.write(rendered_template) + gen_file.close() + + gen_file_path = os.path.join(csms_interface_dir, f"IChargePointRequestHandler{ocpp_version_suffix}.h") + gen_file = open(gen_file_path, "wt") + env = jinja2.Environment() + template = env.from_string(templates["csms_ichargepointrequesthandler"]) + rendered_template = template.render(csms_msgs = msg_list["from_csms"], cs_msgs = msg_list["from_cs"], ocpp_version_namespace = params.ocpp_version, ocpp_version_suffix = ocpp_version_suffix) + gen_file.write(rendered_template) + gen_file.close() + + # Generate central system classes + chargepoint_dir = csms_dirs[1] + gen_file_path = os.path.join(chargepoint_dir, f"ChargePointProxy{ocpp_version_suffix}.h") + gen_file = open(gen_file_path, "wt") + env = jinja2.Environment() + template = env.from_string(templates["csms_chargepointproxy_header"]) + rendered_template = template.render(csms_msgs = msg_list["from_csms"], cs_msgs = msg_list["from_cs"], ocpp_version_namespace = params.ocpp_version, ocpp_version_suffix = ocpp_version_suffix) + gen_file.write(rendered_template) + gen_file.close() + + gen_file_path = os.path.join(chargepoint_dir, f"ChargePointProxy{ocpp_version_suffix}.cpp") + gen_file = open(gen_file_path, "wt") + env = jinja2.Environment() + template = env.from_string(templates["csms_chargepointproxy_impl"]) + rendered_template = template.render(csms_msgs = msg_list["from_csms"], cs_msgs = msg_list["from_cs"], ocpp_version_namespace = params.ocpp_version, ocpp_version_suffix = ocpp_version_suffix) + gen_file.write(rendered_template) + gen_file.close() + + gen_file_path = os.path.join(chargepoint_dir, f"ChargePointHandler{ocpp_version_suffix}.h") + gen_file = open(gen_file_path, "wt") + env = jinja2.Environment() + template = env.from_string(templates["csms_chargepointhandler_header"]) + rendered_template = template.render(csms_msgs = msg_list["from_csms"], cs_msgs = msg_list["from_cs"], ocpp_version_namespace = params.ocpp_version, ocpp_version_suffix = ocpp_version_suffix) + gen_file.write(rendered_template) + gen_file.close() + + gen_file_path = os.path.join(chargepoint_dir, f"ChargePointHandler{ocpp_version_suffix}.cpp") + gen_file = open(gen_file_path, "wt") + env = jinja2.Environment() + template = env.from_string(templates["csms_chargepointhandler_impl"]) + rendered_template = template.render(csms_msgs = msg_list["from_csms"], cs_msgs = msg_list["from_cs"], ocpp_version_namespace = params.ocpp_version, ocpp_version_suffix = ocpp_version_suffix) + gen_file.write(rendered_template) + gen_file.close() + + return + + +def gen_localcontroller(templates, params, msg_list): + ''' + Generate the code for the local controller features + + @param templates: Code templates + @type templates: {string,string} + + @param params: Command line parameters + @type params: Parameters + + @param msg_list: List of OCPP messages per roles + @type msg_list: {string, [string]} + ''' + + # Create output directories + lc_dir = os.path.join(params.output_dir, "localcontroller") + lc_dirs = [lc_dir] + lc_dirs.append(os.path.join(lc_dir, "centralsystem")) + lc_dirs.append(os.path.join(lc_dir, "chargepoint")) + lc_dirs.append(os.path.join(lc_dir, "interface")) + for dir in lc_dirs: + if not os.path.exists(dir): + os.mkdir(dir) + + # Generate interfaces + lc_interface_dir = lc_dirs[3] + ocpp_version_suffix = params.ocpp_version[4:] + if params.ocpp_version == "ocpp20": + ocpp_ws_protocol = "ocpp2.0.1" + elif params.ocpp_version == "ocpp21": + ocpp_ws_protocol = "ocpp2.0.1" + else: + ocpp_ws_protocol = "ocpp1.6" + + gen_file_path = os.path.join(lc_interface_dir, f"IChargePointProxy{ocpp_version_suffix}.h") + gen_file = open(gen_file_path, "wt") + env = jinja2.Environment() + template = env.from_string(templates["lc_ichargepointproxy"]) + rendered_template = template.render(csms_msgs = msg_list["from_csms"], cs_msgs = msg_list["from_cs"], ocpp_version_namespace = params.ocpp_version, ocpp_version_suffix = ocpp_version_suffix) + gen_file.write(rendered_template) + gen_file.close() + + gen_file_path = os.path.join(lc_interface_dir, f"ICentralSystemProxy{ocpp_version_suffix}.h") + gen_file = open(gen_file_path, "wt") + env = jinja2.Environment() + template = env.from_string(templates["lc_icentralsystemproxy"]) + rendered_template = template.render(csms_msgs = msg_list["from_csms"], cs_msgs = msg_list["from_cs"], ocpp_version_namespace = params.ocpp_version, ocpp_version_suffix = ocpp_version_suffix) + gen_file.write(rendered_template) + gen_file.close() + + # Generate central system classes + centralsystem_dir = lc_dirs[1] + gen_file_path = os.path.join(centralsystem_dir, f"CentralSystemProxy{ocpp_version_suffix}.h") + gen_file = open(gen_file_path, "wt") + env = jinja2.Environment() + template = env.from_string(templates["lc_centralsystemproxy_header"]) + rendered_template = template.render(csms_msgs = msg_list["from_csms"], cs_msgs = msg_list["from_cs"], ocpp_version_namespace = params.ocpp_version, ocpp_version_suffix = ocpp_version_suffix) + gen_file.write(rendered_template) + gen_file.close() + + gen_file_path = os.path.join(centralsystem_dir, f"CentralSystemProxy{ocpp_version_suffix}.cpp") + gen_file = open(gen_file_path, "wt") + env = jinja2.Environment() + template = env.from_string(templates["lc_centralsystemproxy_impl"]) + rendered_template = template.render(csms_msgs = msg_list["from_csms"], cs_msgs = msg_list["from_cs"], ocpp_version_namespace = params.ocpp_version, ocpp_version_suffix = ocpp_version_suffix, ocpp_ws_protocol = ocpp_ws_protocol) + gen_file.write(rendered_template) + gen_file.close() + + gen_file_path = os.path.join(centralsystem_dir, f"CentralSystemHandler{ocpp_version_suffix}.h") + gen_file = open(gen_file_path, "wt") + env = jinja2.Environment() + template = env.from_string(templates["lc_centralsystemhandler_header"]) + rendered_template = template.render(csms_msgs = msg_list["from_csms"], cs_msgs = msg_list["from_cs"], ocpp_version_namespace = params.ocpp_version, ocpp_version_suffix = ocpp_version_suffix) + gen_file.write(rendered_template) + gen_file.close() + + gen_file_path = os.path.join(centralsystem_dir, f"CentralSystemHandler{ocpp_version_suffix}.cpp") + gen_file = open(gen_file_path, "wt") + env = jinja2.Environment() + template = env.from_string(templates["lc_centralsystemhandler_impl"]) + rendered_template = template.render(csms_msgs = msg_list["from_csms"], cs_msgs = msg_list["from_cs"], ocpp_version_namespace = params.ocpp_version, ocpp_version_suffix = ocpp_version_suffix) + gen_file.write(rendered_template) + gen_file.close() + + # Generate charge point classes + chargepoint_dir = lc_dirs[2] + gen_file_path = os.path.join(chargepoint_dir, f"ChargePointProxy{ocpp_version_suffix}.h") + gen_file = open(gen_file_path, "wt") + env = jinja2.Environment() + template = env.from_string(templates["lc_chargepointproxy_header"]) + rendered_template = template.render(csms_msgs = msg_list["from_csms"], cs_msgs = msg_list["from_cs"], ocpp_version_namespace = params.ocpp_version, ocpp_version_suffix = ocpp_version_suffix) + gen_file.write(rendered_template) + gen_file.close() + + gen_file_path = os.path.join(chargepoint_dir, f"ChargePointProxy{ocpp_version_suffix}.cpp") + gen_file = open(gen_file_path, "wt") + env = jinja2.Environment() + template = env.from_string(templates["lc_chargepointproxy_impl"]) + rendered_template = template.render(csms_msgs = msg_list["from_csms"], cs_msgs = msg_list["from_cs"], ocpp_version_namespace = params.ocpp_version, ocpp_version_suffix = ocpp_version_suffix) + gen_file.write(rendered_template) + gen_file.close() + + gen_file_path = os.path.join(chargepoint_dir, f"ChargePointHandler{ocpp_version_suffix}.h") + gen_file = open(gen_file_path, "wt") + env = jinja2.Environment() + template = env.from_string(templates["lc_chargepointhandler_header"]) + rendered_template = template.render(csms_msgs = msg_list["from_csms"], cs_msgs = msg_list["from_cs"], ocpp_version_namespace = params.ocpp_version, ocpp_version_suffix = ocpp_version_suffix) + gen_file.write(rendered_template) + gen_file.close() + + gen_file_path = os.path.join(chargepoint_dir, f"ChargePointHandler{ocpp_version_suffix}.cpp") + gen_file = open(gen_file_path, "wt") + env = jinja2.Environment() + template = env.from_string(templates["lc_chargepointhandler_impl"]) + rendered_template = template.render(csms_msgs = msg_list["from_csms"], cs_msgs = msg_list["from_cs"], ocpp_version_namespace = params.ocpp_version, ocpp_version_suffix = ocpp_version_suffix) + gen_file.write(rendered_template) + gen_file.close() + + return + + + +# Entry point +if __name__ == '__main__': + + ret = False + + try: + + # Check the command line parameters + params = Parameters() + if not check_args(sys.argv, params): + sys.exit(-1) + + print(f"Creating output directories...") + + # Create output directories + params.types_dir = os.path.join(params.output_dir, "types") + params.messages_dir = os.path.join(params.output_dir, "messages") + if not os.path.exists(params.types_dir): + os.mkdir(params.types_dir) + if not os.path.exists(params.messages_dir): + os.mkdir(params.messages_dir) + + print(f"Generating files from {params.input_dir}") + + # Read messages list + ocpp_version_suffix = params.ocpp_version[4:] + msg_list_file_path = os.path.join(params.input_dir, "list.json") + try: + msg_list = json.load(open(msg_list_file_path, "rt")) + except: + print(f"Unable to load messages list file : {msg_list_file_path}") + + # Code templates + templates = read_code_templates(params) + if templates: + + # List OCPP messages + ocpp_messages = [f[:f.find("Request.json")] for f in os.listdir(params.input_dir) if os.path.isfile(os.path.join(params.input_dir, f)) and f.endswith("Request.json")] + print(f"{len(ocpp_messages)} messages found") + + # Generate messages + gen_converters(templates, params, msg_list) + for ocpp_message in ocpp_messages: + print(f"Generating {ocpp_message} message...") + gen_ocpp_message(ocpp_message,templates, params) + + # Generate charge point interfaces and classes + gen_chargepoint(templates, params, msg_list) + + # Generate central system interfaces and classes + gen_centralsystem(templates, params, msg_list) + + # Generate localcontroller interfaces and classes + gen_localcontroller(templates, params, msg_list) + + ret = True + + except Exception as e: + print(f"Unexpected error : {e}") + ret = False + + if ret: + sys.exit(0) + else: + sys.exit(-1) diff --git a/tools/json2cpp/templates/centralsystem/ChargePointHandler.cpp.j2 b/tools/json2cpp/templates/centralsystem/ChargePointHandler.cpp.j2 new file mode 100644 index 00000000..7b901db7 --- /dev/null +++ b/tools/json2cpp/templates/centralsystem/ChargePointHandler.cpp.j2 @@ -0,0 +1,94 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* Generated by json2cpp */ + +#include "ChargePointHandler{{ocpp_version_suffix}}.h" +#include "ICentralSystemConfig{{ocpp_version_suffix}}.h" +#include "IChargePointRequestHandler{{ocpp_version_suffix}}.h" +#include "IRpc.h" +#include "MessageDispatcher.h" + +using namespace ocpp::messages; +using namespace ocpp::messages::{{ocpp_version_namespace}}; +using namespace ocpp::types; +using namespace ocpp::types::{{ocpp_version_namespace}}; + +namespace ocpp +{ +namespace centralsystem +{ +namespace {{ocpp_version_namespace}} +{ + +/** @brief Constructor */ +ChargePointHandler{{ocpp_version_suffix}}::ChargePointHandler{{ocpp_version_suffix}}(const std::string& identifier, + const ocpp::messages::{{ocpp_version_namespace}}::MessagesConverter{{ocpp_version_suffix}}& messages_converter, + ocpp::messages::MessageDispatcher& msg_dispatcher) + : + {%- for msg_name in cs_msgs %} + GenericMessageHandler<{{msg_name}}Req, {{msg_name}}Conf>({{msg_name.upper()}}_ACTION, messages_converter), + {%- endfor %} + + m_identifier(identifier), + m_handler(nullptr) +{ + {%- for msg_name in cs_msgs %} + msg_dispatcher.registerHandler({{msg_name.upper()}}_ACTION, + *dynamic_cast*>(this)); + {%- endfor %} +} +/** @brief Destructor */ +ChargePointHandler{{ocpp_version_suffix}}::~ChargePointHandler{{ocpp_version_suffix}}() { } + +// OCPP handlers + +{%- for msg_name in cs_msgs %} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePointHandler{{ocpp_version_suffix}}::handleMessage(const ocpp::messages::{{ocpp_version_namespace}}::{{msg_name}}Req& request, + ocpp::messages::{{ocpp_version_namespace}}::{{msg_name}}Conf& response, + std::string& error_code, + std::string& error_message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - {{msg_name}} requested"; + + // Notify request + if (m_handler) + { + ret = m_handler->on{{msg_name}}(request, response, error_code, error_message); + + LOG_INFO << "[" << m_identifier << "] - {{msg_name}} handled"; + } + else + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_INTERNAL; + } + + return ret; +} +{%- endfor %} + +} // namespace {{ocpp_version_namespace}} +} // namespace centralsystem +} // namespace ocpp diff --git a/tools/json2cpp/templates/centralsystem/ChargePointHandler.h.j2 b/tools/json2cpp/templates/centralsystem/ChargePointHandler.h.j2 new file mode 100644 index 00000000..e458bfe9 --- /dev/null +++ b/tools/json2cpp/templates/centralsystem/ChargePointHandler.h.j2 @@ -0,0 +1,101 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +#ifndef OPENOCPP_{{ocpp_version_namespace.upper()}}_CS_CHARGEPOINTHANDLER{{ocpp_version_suffix}}_H +#define OPENOCPP_{{ocpp_version_namespace.upper()}}_CS_CHARGEPOINTHANDLER{{ocpp_version_suffix}}_H + +#include "Logger.h" +#include "GenericMessageHandler.h" +#include "MessagesConverter{{ocpp_version_suffix}}.h" +{%- for msg_name in cs_msgs %} +#include "{{msg_name}}{{ocpp_version_suffix}}.h" +{%- endfor %} + +namespace ocpp +{ +namespace config +{ +class ICentralSystemConfig{{ocpp_version_suffix}}; +} // namespace config +namespace messages +{ +class MessageDispatcher; + +namespace {{ocpp_version_namespace}} +{ +class MessagesConverter{{ocpp_version_suffix}}; +} // namespace {{ocpp_version_namespace}} +} // namespace messages + +namespace centralsystem +{ +namespace {{ocpp_version_namespace}} +{ + +class IChargePointRequestHandler{{ocpp_version_suffix}}; + +/** @brief Handler for charge point requests */ +class ChargePointHandler{{ocpp_version_suffix}} + : + {%- for msg_name in cs_msgs %} + public ocpp::messages::GenericMessageHandler{% if not loop.last %},{% endif %} + {%- endfor %} +{ + public: + /** + * @brief Constructor + * @param identifier Charge point's identifier + * @param messages_converter Converter from/to OCPP to/from JSON messages + * @param msg_dispatcher Message dispatcher + */ + ChargePointHandler{{ocpp_version_suffix}}(const std::string& identifier, + const ocpp::messages::{{ocpp_version_namespace}}::MessagesConverter{{ocpp_version_suffix}}& messages_converter, + ocpp::messages::MessageDispatcher& msg_dispatcher); + /** @brief Destructor */ + virtual ~ChargePointHandler{{ocpp_version_suffix}}(); + + /** @brief Register the event handler */ + void registerHandler(IChargePointRequestHandler{{ocpp_version_suffix}}& handler) { m_handler = &handler; } + + // OCPP handlers + + {%- for msg_name in cs_msgs %} + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::{{ocpp_version_namespace}}::{{msg_name}}Req& request, + ocpp::messages::{{ocpp_version_namespace}}::{{msg_name}}Conf& response, + std::string& error_code, + std::string& error_message) override; + {%- endfor %} + + private: + /** @brief Charge point's identifier */ + const std::string m_identifier; + /** @brief Request handler */ + IChargePointRequestHandler{{ocpp_version_suffix}}* m_handler; +}; + +} // namespace {{ocpp_version_namespace}} +} // namespace centralsystem +} // namespace ocpp + +#endif // OPENOCPP_{{ocpp_version_namespace.upper()}}_CS_CHARGEPOINTHANDLER{{ocpp_version_suffix}}_H diff --git a/tools/json2cpp/templates/centralsystem/ChargePointProxy.cpp.j2 b/tools/json2cpp/templates/centralsystem/ChargePointProxy.cpp.j2 new file mode 100644 index 00000000..134beb29 --- /dev/null +++ b/tools/json2cpp/templates/centralsystem/ChargePointProxy.cpp.j2 @@ -0,0 +1,174 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* Generated by json2cpp */ + +#include "ChargePointProxy{{ocpp_version_suffix}}.h" + +using namespace ocpp::messages; +using namespace ocpp::messages::{{ocpp_version_namespace}}; +using namespace ocpp::types; +using namespace ocpp::types::{{ocpp_version_namespace}}; + +namespace ocpp +{ +namespace centralsystem +{ +namespace {{ocpp_version_namespace}} +{ + +/** @brief Constructor */ +ChargePointProxy{{ocpp_version_suffix}}::ChargePointProxy{{ocpp_version_suffix}}(ICentralSystem{{ocpp_version_suffix}}& central_system, + const std::string& identifier, + std::shared_ptr rpc, + const ocpp::messages::{{ocpp_version_namespace}}::MessagesValidator{{ocpp_version_suffix}}& messages_validator, + ocpp::messages::{{ocpp_version_namespace}}::MessagesConverter{{ocpp_version_suffix}}& messages_converter, + const ocpp::config::ICentralSystemConfig{{ocpp_version_suffix}}& stack_config) + : m_central_system(central_system), + m_identifier(identifier), + m_rpc(rpc), + m_msg_dispatcher(messages_validator), + m_msg_sender(*m_rpc, messages_converter, messages_validator, stack_config.callRequestTimeout()), + m_handler(m_identifier, messages_converter, m_msg_dispatcher), + m_messages_validator(messages_validator), + m_messages_converter(messages_converter) +{ + m_rpc->registerSpy(*this); + m_rpc->registerListener(*this); +} + +/** @brief Destructor */ +ChargePointProxy{{ocpp_version_suffix}}::~ChargePointProxy{{ocpp_version_suffix}}() +{ + unregisterFromRpcSpy(); +} + +/** @brief Unregister to the IRpc::ISpy interface messages */ +void ChargePointProxy{{ocpp_version_suffix}}::unregisterFromRpcSpy() +{ + m_rpc->unregisterSpy(*this); +} + +// ICentralSystem{{ocpp_version_suffix}}::IChargePoint{{ocpp_version_suffix}} interface + +/** @copydoc const std::string& ICentralSystem{{ocpp_version_suffix}}::IChargePoint{{ocpp_version_suffix}}::ipAddress() const */ +const std::string& ChargePointProxy{{ocpp_version_suffix}}::ipAddress() const +{ + return m_rpc->ipAddress(); +} + +/** @copydoc void ICentralSystem{{ocpp_version_suffix}}::IChargePoint{{ocpp_version_suffix}}::setTimeout(std::chrono::milliseconds) */ +void ChargePointProxy{{ocpp_version_suffix}}::setTimeout(std::chrono::milliseconds timeout) +{ + m_msg_sender.setTimeout(timeout); +} + +/** @copydoc void ICentralSystem{{ocpp_version_suffix}}::IChargePoint{{ocpp_version_suffix}}::disconnect() */ +void ChargePointProxy{{ocpp_version_suffix}}::disconnect() +{ + m_rpc->disconnect(true); +} + +/** @copydoc void ICentralSystem{{ocpp_version_suffix}}::IChargePoint{{ocpp_version_suffix}}::registerHandler(IChargePointRequestHandler{{ocpp_version_suffix}}&) */ +void ChargePointProxy{{ocpp_version_suffix}}::registerHandler(IChargePointRequestHandler{{ocpp_version_suffix}}& handler) +{ + m_user_handler = &handler; + m_handler.registerHandler(handler); +} + +// OCPP operations + +{%- for msg_name in csms_msgs %} +/** @copydoc bool ICentralSystem{{ocpp_version_suffix}}::IChargePoint{{ocpp_version_suffix}}::call( + const ocpp::messages::{{ocpp_version_namespace}}::{{msg_name}}Req&, + ocpp::messages::{{ocpp_version_namespace}}::{{msg_name}}Conf&, + std::string&, + std::string&) */ +bool ChargePointProxy{{ocpp_version_suffix}}::call(const ocpp::messages::{{ocpp_version_namespace}}::{{msg_name}}Req& request, + ocpp::messages::{{ocpp_version_namespace}}::{{msg_name}}Conf& response, + std::string& error, + std::string& message) +{ + bool ret = false; + + LOG_INFO << "[" << m_identifier << "] - {{msg_name}}"; + + // Send request + CallResult res = m_msg_sender.call({{msg_name.upper()}}_ACTION, request, response, error, message); + if (res == CallResult::Ok) + { + LOG_INFO << "[" << m_identifier << "] - Call done : {{msg_name}}"; + ret = true; + } + else + { + LOG_ERROR << "[" << m_identifier << "] - Call failed : " << CallResultHelper.toString(res); + } + + return ret; +} +{%- endfor %} + +// IRpc::IListener interface + +/** @copydoc void IRpc::IListener::rpcDisconnected() */ +void ChargePointProxy{{ocpp_version_suffix}}::rpcDisconnected() +{ + LOG_WARNING << "[" << m_identifier << "] - Disconnected"; + if (m_user_handler) + { + m_user_handler->disconnected(); + } +} + +/** @copydoc void IRpc::IListener::rpcError() */ +void ChargePointProxy{{ocpp_version_suffix}}::rpcError() +{ + LOG_ERROR << "[" << m_identifier << "] - Connection error"; +} + +/** @copydoc bool IRpc::IListener::rpcCallReceived(const std::string&, + const rapidjson::Value&, + rapidjson::Document&, + std::string&, + std::string&) */ +bool ChargePointProxy{{ocpp_version_suffix}}::rpcCallReceived(const std::string& action, + const rapidjson::Value& payload, + rapidjson::Document& response, + std::string& error_code, + std::string& error_message) +{ + return m_msg_dispatcher.dispatchMessage(action, payload, response, error_code, error_message); +} + +// IRpc::ISpy interface + +/** @copydoc void IRpc::ISpy::rcpMessageReceived(const std::string& msg) */ +void ChargePointProxy{{ocpp_version_suffix}}::rcpMessageReceived(const std::string& msg) +{ + LOG_COM << "[" << m_identifier << "] - RX : " << msg; +} + +void ChargePointProxy{{ocpp_version_suffix}}::rcpMessageSent(const std::string& msg) +{ + LOG_COM << "[" << m_identifier << "] - TX : " << msg; +} + +} // namespace {{ocpp_version_namespace}} +} // namespace centralsystem +} // namespace ocpp diff --git a/tools/json2cpp/templates/centralsystem/ChargePointProxy.h.j2 b/tools/json2cpp/templates/centralsystem/ChargePointProxy.h.j2 new file mode 100644 index 00000000..4ec5f3b5 --- /dev/null +++ b/tools/json2cpp/templates/centralsystem/ChargePointProxy.h.j2 @@ -0,0 +1,164 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* Generated by json2cpp */ + +#ifndef OPENOCPP_{{ocpp_version_namespace.upper()}}_CS_CHARGEPOINTPROXY{{ocpp_version_suffix}}_H +#define OPENOCPP_{{ocpp_version_namespace.upper()}}_CS_CHARGEPOINTPROXY{{ocpp_version_suffix}}_H + +#include "Logger.h" +#include "RpcServer.h" +#include "MessageDispatcher.h" +#include "GenericMessageSender.h" +#include "ChargePointHandler{{ocpp_version_suffix}}.h" +#include "ICentralSystem{{ocpp_version_suffix}}.h" +#include "MessagesConverter{{ocpp_version_suffix}}.h" +#include "MessagesValidator{{ocpp_version_suffix}}.h" + +#include + +namespace ocpp +{ +namespace centralsystem +{ +namespace {{ocpp_version_namespace}} +{ + +/** @brief Charge point proxy */ +class ChargePointProxy{{ocpp_version_suffix}} : public ICentralSystem{{ocpp_version_suffix}}::IChargePoint{{ocpp_version_suffix}}, public ocpp::rpc::IRpc::IListener, public ocpp::rpc::IRpc::ISpy +{ + public: + /** + * @brief Constructor + * @param central_system Central System instance associated to the charge point + * @param identifier Charge point's identifier + * @param rpc RPC connection with the charge point + * @param messages_validator JSON schemas needed to validate payloads + * @param messages_converter Converter from/to OCPP to/from JSON messages + * @param stack_config Stack configuration + */ + ChargePointProxy{{ocpp_version_suffix}}(ICentralSystem{{ocpp_version_suffix}}& central_system, + const std::string& identifier, + std::shared_ptr rpc, + const ocpp::messages::{{ocpp_version_namespace}}::MessagesValidator{{ocpp_version_suffix}}& messages_validator, + ocpp::messages::{{ocpp_version_namespace}}::MessagesConverter{{ocpp_version_suffix}}& messages_converter, + const ocpp::config::ICentralSystemConfig{{ocpp_version_suffix}}& stack_config); + /** @brief Destructor */ + virtual ~ChargePointProxy{{ocpp_version_suffix}}(); + + /** @brief Unregister to the IRpc::ISpy interface messages */ + void unregisterFromRpcSpy(); + + // ICentralSystem{{ocpp_version_suffix}}::IChargePoint{{ocpp_version_suffix}} interface + + /** @copydoc ICentralSystem{{ocpp_version_suffix}}& ICentralSystem{{ocpp_version_suffix}}::IChargePoint{{ocpp_version_suffix}}::centralSystem() */ + ICentralSystem{{ocpp_version_suffix}}& centralSystem() override { return m_central_system; } + + /** @copydoc const std::string& ICentralSystem{{ocpp_version_suffix}}::IChargePoint::ipAddress() const */ + const std::string& ipAddress() const override; + + /** @copydoc const std::string& ICentralSystem{{ocpp_version_suffix}}::IChargePoint::identifier() const */ + const std::string& identifier() const override { return m_identifier; } + + /** @copydoc void ICentralSystem{{ocpp_version_suffix}}::IChargePoint::setTimeout(std::chrono::milliseconds) */ + void setTimeout(std::chrono::milliseconds timeout) override; + + /** @copydoc void ICentralSystem{{ocpp_version_suffix}}::IChargePoint::disconnect() */ + void disconnect() override; + + /** @copydoc void ICentralSystem{{ocpp_version_suffix}}::IChargePoint{{ocpp_version_suffix}}::registerHandler(IChargePointRequestHandler{{ocpp_version_suffix}}&) */ + void registerHandler(IChargePointRequestHandler{{ocpp_version_suffix}}& handler) override; + + // OCPP operations + + {%- for msg_name in csms_msgs %} + /** @copydoc bool ICentralSystem{{ocpp_version_suffix}}::IChargePoint{{ocpp_version_suffix}}::call( + const ocpp::messages::{{ocpp_version_namespace}}::{{msg_name}}Req&, + ocpp::messages::{{ocpp_version_namespace}}::{{msg_name}}Conf&, + std::string&, + std::string&) */ + bool call(const ocpp::messages::{{ocpp_version_namespace}}::{{msg_name}}Req& request, + ocpp::messages::{{ocpp_version_namespace}}::{{msg_name}}Conf& response, + std::string& error, + std::string& message) override; + {%- endfor %} + + // IRpc::IListener interface + + /** @copydoc void IRpc::IListener::rpcDisconnected() */ + void rpcDisconnected() override; + + /** @copydoc void IRpc::IListener::rpcError() */ + void rpcError() override; + + /** @copydoc bool IRpc::IListener::rpcCallReceived(const std::string&, + const rapidjson::Value&, + rapidjson::Document&, + std::string&, + std::string&) */ + bool rpcCallReceived(const std::string& action, + const rapidjson::Value& payload, + rapidjson::Document& response, + std::string& error_code, + std::string& error_message) override; + + // IRpc::ISpy interface + + /** @copydoc void IRpc::ISpy::rcpMessageReceived(const std::string& msg) */ + void rcpMessageReceived(const std::string& msg) override; + + /** @copydoc void IRpc::ISpy::rcpMessageSent(const std::string& msg) */ + void rcpMessageSent(const std::string& msg) override; + + // Accessors + + /** @brief RPC connection */ + std::shared_ptr& rpcClient() { return m_rpc; } + + /** @brief Messages validator */ + const ocpp::messages::{{ocpp_version_namespace}}::MessagesValidator{{ocpp_version_suffix}}& messagesValidator() { return m_messages_validator; } + + /** @brief Messages converters */ + ocpp::messages::{{ocpp_version_namespace}}::MessagesConverter{{ocpp_version_suffix}}& messagesConverter() { return m_messages_converter; } + + private: + /** @brief Central System instance associated to the charge point */ + ICentralSystem{{ocpp_version_suffix}}& m_central_system; + /** @brief Charge point's identifier */ + std::string m_identifier; + /** @brief RPC connection */ + std::shared_ptr m_rpc; + /** @brief Message dispatcher */ + ocpp::messages::MessageDispatcher m_msg_dispatcher; + /** @brief Message sender */ + ocpp::messages::GenericMessageSender m_msg_sender; + /** @brief Request handler */ + ChargePointHandler{{ocpp_version_suffix}} m_handler; + /** @brief Messages validator */ + const ocpp::messages::{{ocpp_version_namespace}}::MessagesValidator{{ocpp_version_suffix}}& m_messages_validator; + /** @brief Messages converters */ + ocpp::messages::{{ocpp_version_namespace}}::MessagesConverter{{ocpp_version_suffix}}& m_messages_converter; + /** @brief User request handler */ + IChargePointRequestHandler{{ocpp_version_suffix}}* m_user_handler; +}; + +} // namespace {{ocpp_version_namespace}} +} // namespace centralsystem +} // namespace ocpp + +#endif // OPENOCPP_{{ocpp_version_namespace.upper()}}_CS_CHARGEPOINTPROXY{{ocpp_version_suffix}}_H diff --git a/tools/json2cpp/templates/centralsystem/ICentralSystem.h.j2 b/tools/json2cpp/templates/centralsystem/ICentralSystem.h.j2 new file mode 100644 index 00000000..ef981579 --- /dev/null +++ b/tools/json2cpp/templates/centralsystem/ICentralSystem.h.j2 @@ -0,0 +1,178 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* Generated by json2cpp */ + +#ifndef OPENOCPP_{{ocpp_version_namespace.upper()}}_ICENTRALSYSTEM{{ocpp_version_suffix}}_H +#define OPENOCPP_{{ocpp_version_namespace.upper()}}_ICENTRALSYSTEM{{ocpp_version_suffix}}_H + + +#include "ICentralSystemConfig{{ocpp_version_suffix}}.h" +#include "IChargePointRequestHandler{{ocpp_version_suffix}}.h" + +{%- for msg_name in csms_msgs %} +#include "{{msg_name}}{{ocpp_version_suffix}}.h" +{%- endfor %} + +#include + +namespace ocpp +{ +namespace helpers +{ +class ITimerPool; +class WorkerThreadPool; +} // namespace helpers +namespace database +{ +class Database; +} // namespace database + +namespace centralsystem +{ +namespace {{ocpp_version_namespace}} +{ + +class ICentralSystemEventsHandler{{ocpp_version_suffix}}; + +/** @brief Interface for central system implementations */ +class ICentralSystem{{ocpp_version_suffix}} +{ + public: + /** + * @brief Instanciate a central system + * @param stack_config Stack configuration + * @param event_handler Stack event handler + */ + static std::unique_ptr create(const ocpp::config::ICentralSystemConfig{{ocpp_version_suffix}}& stack_config, + ICentralSystemEventsHandler{{ocpp_version_suffix}}& events_handler); + + /** + * @brief Instanciate a central system with the provided timer and worker pools + * To use when you have to instanciate multiple Central System / Charge Point + * => Allow to reduce thread and memory usage + * @param stack_config Stack configuration + * @param event_handler Stack event handler + * @param timer_pool Timer pool + * @param worker_pool Worker thread pool + */ + static std::unique_ptr create(const ocpp::config::ICentralSystemConfig{{ocpp_version_suffix}}& stack_config, + ICentralSystemEventsHandler{{ocpp_version_suffix}}& events_handler, + std::shared_ptr timer_pool, + std::shared_ptr worker_pool); + + /** @brief Destructor */ + virtual ~ICentralSystem{{ocpp_version_suffix}}() { } + + /** + * @brief Get the configuration associated to the central system + * @return Configuration associated to the central system + */ + virtual const ocpp::config::ICentralSystemConfig{{ocpp_version_suffix}}& getConfig() = 0; + + /** + * @brief Get the timer pool associated to the central system + * @return Timer pool associated to the central system + */ + virtual ocpp::helpers::ITimerPool& getTimerPool() = 0; + + /** + * @brief Get the worker pool associated to the central system + * @return Worker pool associated to the central system + */ + virtual ocpp::helpers::WorkerThreadPool& getWorkerPool() = 0; + + /** + * @brief Reset the central system's internal data (can be done only when the central system is stopped) + * @return true if the data has been reset, false otherwise + */ + virtual bool resetData() = 0; + + /** + * @brief Start the central system + * @return true if the central system has been started, false otherwise + */ + virtual bool start() = 0; + + /** + * @brief Stop the central system + * @return true if the central system has been stopped, false otherwise + */ + virtual bool stop() = 0; + + /** @brief Interface for charge point proxy implementations */ + class IChargePoint{{ocpp_version_suffix}} + { + public: + /** @brief Destructor */ + virtual ~IChargePoint{{ocpp_version_suffix}}() { } + + /** + * @brief Get the central system instance associated to the charge point + * @return Central system instance associated to the charge point + */ + virtual ICentralSystem{{ocpp_version_suffix}}& centralSystem() = 0; + + /** + * @brief Get the IP address of the charge point + * @return IP address of the charge point + */ + virtual const std::string& ipAddress() const = 0; + + /** + * @brief Get the charge point identifier + * @return charge point identifier + */ + virtual const std::string& identifier() const = 0; + + /** + * @brief Set the call request timeout + * @param timeout New timeout value + */ + virtual void setTimeout(std::chrono::milliseconds timeout) = 0; + + /** @brief Disconnect the charge point */ + virtual void disconnect() = 0; + + /** @brief Register the event handler */ + virtual void registerHandler(IChargePointRequestHandler{{ocpp_version_suffix}}& handler) = 0; + + // OCPP operations + + {%- for msg_name in csms_msgs %} + /** + * @brief Send a {{msg_name}} message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::{{ocpp_version_namespace}}::{{msg_name}}Req& request, + ocpp::messages::{{ocpp_version_namespace}}::{{msg_name}}Conf& response, + std::string& error, + std::string& message) = 0; + {%- endfor %} + }; +}; + +} // namespace {{ocpp_version_namespace}} +} // namespace centralsystem +} // namespace ocpp + +#endif // OPENOCPP_{{ocpp_version_namespace.upper()}}_ICENTRALSYSTEM{{ocpp_version_suffix}}_H diff --git a/tools/json2cpp/templates/centralsystem/IChargePointRequestHandler.h.j2 b/tools/json2cpp/templates/centralsystem/IChargePointRequestHandler.h.j2 new file mode 100644 index 00000000..4f3cf165 --- /dev/null +++ b/tools/json2cpp/templates/centralsystem/IChargePointRequestHandler.h.j2 @@ -0,0 +1,67 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* Generated by json2cpp */ + +#ifndef OPENOCPP_{{ocpp_version_namespace.upper()}}_ICHARGEPOINTREQUESTHANDLER{{ocpp_version_suffix}}_H +#define OPENOCPP_{{ocpp_version_namespace.upper()}}_ICHARGEPOINTREQUESTHANDLER{{ocpp_version_suffix}}_H + +{%- for msg_name in cs_msgs %} +#include "{{msg_name}}{{ocpp_version_suffix}}.h" +{%- endfor %} + +#include + +namespace ocpp +{ +namespace centralsystem +{ +namespace {{ocpp_version_namespace}} +{ + +/** @brief Interface for charge point requests implementations */ +class IChargePointRequestHandler{{ocpp_version_suffix}} +{ + public: + /** @brief Destructor */ + virtual ~IChargePointRequestHandler{{ocpp_version_suffix}}() { } + + /** @brief Called to notify the disconnection of the charge point */ + virtual void disconnected() = 0; + + {%- for msg_name in cs_msgs %} + /** + * @brief Called on reception of a {{msg_name}} request from the charge point + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been handled and a response must be sent, false otherwise + */ + virtual bool on{{msg_name}}(const ocpp::messages::{{ocpp_version_namespace}}::{{msg_name}}Req& request, + ocpp::messages::{{ocpp_version_namespace}}::{{msg_name}}Conf& response, + std::string& error, + std::string& message) = 0; + {%- endfor %} +}; + +} // namespace {{ocpp_version_namespace}} +} // namespace centralsystem +} // namespace ocpp + +#endif // OPENOCPP_{{ocpp_version_namespace.upper()}}_ICHARGEPOINTREQUESTHANDLER{{ocpp_version_suffix}}_H diff --git a/tools/json2cpp/templates/chargepoint/IChargePoint.h.j2 b/tools/json2cpp/templates/chargepoint/IChargePoint.h.j2 new file mode 100644 index 00000000..45d4c3ab --- /dev/null +++ b/tools/json2cpp/templates/chargepoint/IChargePoint.h.j2 @@ -0,0 +1,139 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* Generated by json2cpp */ + +#ifndef OPENOCPP_{{ocpp_version_namespace.upper()}}_ICHARGEPOINT{{ocpp_version_suffix}}_H +#define OPENOCPP_{{ocpp_version_namespace.upper()}}_ICHARGEPOINT{{ocpp_version_suffix}}_H + + +#include "IChargePointConfig{{ocpp_version_suffix}}.h" +#include "IChargePointEventsHandler{{ocpp_version_suffix}}.h" + +{%- for msg_name in cs_msgs %} +#include "{{msg_name}}{{ocpp_version_suffix}}.h" +{%- endfor %} + +#include + +namespace ocpp +{ +namespace helpers +{ +class ITimerPool; +class WorkerThreadPool; +} // namespace helpers +namespace database +{ +class Database; +} // namespace database + +namespace chargepoint +{ +namespace {{ocpp_version_namespace}} +{ + +/** @brief Interface for charge point implementations */ +class IChargePoint{{ocpp_version_suffix}} +{ + public: + /** + * @brief Instanciate a charge point + * @param stack_config Stack configuration + * @param event_handler Stack event handler + */ + static std::unique_ptr create(const ocpp::config::IChargePointConfig{{ocpp_version_suffix}}& stack_config, + IChargePointEventsHandler{{ocpp_version_suffix}}& events_handler); + + /** + * @brief Instanciate a charge point with the provided timer and worker pools + * To use when you have to instanciate multiple Central System / Charge Point + * => Allow to reduce thread and memory usage + * @param stack_config Stack configuration + * @param event_handler Stack event handler + * @param timer_pool Timer pool + * @param worker_pool Worker thread pool + */ + static std::unique_ptr create(const ocpp::config::IChargePointConfig{{ocpp_version_suffix}}& stack_config, + IChargePointEventsHandler{{ocpp_version_suffix}}& events_handler, + std::shared_ptr timer_pool, + std::shared_ptr worker_pool); + + /** @brief Destructor */ + virtual ~IChargePoint{{ocpp_version_suffix}}() { } + + /** + * @brief Get the timer pool associated to the charge point + * @return Timer pool associated to the charge point + */ + virtual ocpp::helpers::ITimerPool& getTimerPool() = 0; + + /** + * @brief Get the worker pool associated to the charge point + * @return Worker pool associated to the charge point + */ + virtual ocpp::helpers::WorkerThreadPool& getWorkerPool() = 0; + + /** + * @brief Reset the charge point's internal data (can be done only when the charge point is stopped) + * @return true if the data has been reset, false otherwise + */ + virtual bool resetData() = 0; + + /** + * @brief Start the charge point + * @return true if the charge point has been started, false otherwise + */ + virtual bool start() = 0; + + /** + * @brief Stop the charge point + * @return true if the charge point has been stopped, false otherwise + */ + virtual bool stop() = 0; + + /** + * @brief Triggers a reconnexion of the charge point to the Central System + * @return true if the reconnexion has been scheduled, false otherwise + */ + virtual bool reconnect() = 0; + + + // OCPP operations + + {%- for msg_name in cs_msgs %} + /** + * @brief Send a {{msg_name}} message to the central system + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::{{ocpp_version_namespace}}::{{msg_name}}Req& request, + ocpp::messages::{{ocpp_version_namespace}}::{{msg_name}}Conf& response, + std::string& error, + std::string& message) = 0; + {%- endfor %} +}; + +} // namespace {{ocpp_version_namespace}} +} // namespace chargepoint +} // namespace ocpp + +#endif // OPENOCPP_{{ocpp_version_namespace.upper()}}_ICHARGEPOINT{{ocpp_version_suffix}}_H diff --git a/tools/json2cpp/templates/chargepoint/IChargePointEventsHandler.h.j2 b/tools/json2cpp/templates/chargepoint/IChargePointEventsHandler.h.j2 new file mode 100644 index 00000000..9f6dd3b4 --- /dev/null +++ b/tools/json2cpp/templates/chargepoint/IChargePointEventsHandler.h.j2 @@ -0,0 +1,75 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* Generated by json2cpp */ + +#ifndef OPENOCPP_{{ocpp_version_namespace.upper()}}_ICHARGEPOINTEVENTSHANDLERCHARGEPOINT{{ocpp_version_suffix}}_H +#define OPENOCPP_{{ocpp_version_namespace.upper()}}_ICHARGEPOINTEVENTSHANDLERCHARGEPOINT{{ocpp_version_suffix}}_H + + +{%- for msg_name in csms_msgs %} +#include "{{msg_name}}{{ocpp_version_suffix}}.h" +{%- endfor %} + +namespace ocpp +{ +namespace chargepoint +{ +namespace {{ocpp_version_namespace}} +{ + +/** @brief Interface for charge point event handlers implementations */ +class IChargePointEventsHandler{{ocpp_version_suffix}} +{ + public: + /** @brief Destructor */ + virtual ~IChargePointEventsHandler{{ocpp_version_suffix}}() { } + + /** @brief Called when the first attempt to connect to the central system has failed */ + virtual void connectionFailed() = 0; + + /** + * @brief Called when the charge point connection status has changed + * @param isConnected true if the charge point is connected to the central system, false otherwise + */ + virtual void connectionStateChanged(bool isConnected) = 0; + + + // OCPP operations + + {%- for msg_name in csms_msgs %} + /** + * @brief Called on reception of a {{msg_name}} message from the central system + * @param request Request received + * @param response Response to send + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool on{{msg_name}}(const ocpp::messages::{{ocpp_version_namespace}}::{{msg_name}}Req& request, + ocpp::messages::{{ocpp_version_namespace}}::{{msg_name}}Conf& response, + std::string& error, + std::string& message) = 0; + {%- endfor %} +}; + +} // namespace {{ocpp_version_namespace}} +} // namespace chargepoint +} // namespace ocpp + +#endif // OPENOCPP_{{ocpp_version_namespace.upper()}}_ICHARGEPOINTEVENTSHANDLERCHARGEPOINT{{ocpp_version_suffix}}_H diff --git a/tools/json2cpp/templates/localcontroller/CentralSystemHandler.cpp.j2 b/tools/json2cpp/templates/localcontroller/CentralSystemHandler.cpp.j2 new file mode 100644 index 00000000..c3645ea0 --- /dev/null +++ b/tools/json2cpp/templates/localcontroller/CentralSystemHandler.cpp.j2 @@ -0,0 +1,78 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* Generated by json2cpp */ + +#include "CentralSystemHandler{{ocpp_version_suffix}}.h" +#include "ILocalControllerConfig{{ocpp_version_suffix}}.h" +#include "MessagesConverter{{ocpp_version_suffix}}.h" +#include "MessageDispatcher.h" + +using namespace ocpp::messages; +using namespace ocpp::messages::{{ocpp_version_namespace}}; +using namespace ocpp::types; +using namespace ocpp::types::{{ocpp_version_namespace}}; + +namespace ocpp +{ +namespace localcontroller +{ +namespace {{ocpp_version_namespace}} +{ + +/** @brief Constructor */ +CentralSystemHandler{{ocpp_version_suffix}}::CentralSystemHandler{{ocpp_version_suffix}}(const std::string& identifier, + const ocpp::messages::{{ocpp_version_namespace}}::MessagesConverter{{ocpp_version_suffix}}& messages_converter, + ocpp::messages::MessageDispatcher& msg_dispatcher) + : + {%- for msg_name in csms_msgs %} + GenericMessageHandler<{{msg_name}}Req, {{msg_name}}Conf>({{msg_name.upper()}}_ACTION, messages_converter), + {%- endfor %} + + m_identifier(identifier), + m_charge_point() +{ + {%- for msg_name in csms_msgs %} + msg_dispatcher.registerHandler({{msg_name.upper()}}_ACTION, + *dynamic_cast*>(this)); + {%- endfor %} +} + +/** @brief Destructor */ +CentralSystemHandler{{ocpp_version_suffix}}::~CentralSystemHandler{{ocpp_version_suffix}}() { } + +// OCPP handlers + +{%- for msg_name in csms_msgs %} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool CentralSystemHandler{{ocpp_version_suffix}}::handleMessage(const ocpp::messages::{{ocpp_version_namespace}}::{{msg_name}}Req& request, + ocpp::messages::{{ocpp_version_namespace}}::{{msg_name}}Conf& response, + std::string& error_code, + std::string& error_message) +{ + return forward({{msg_name.upper()}}_ACTION, request, response, error_code, error_message); +} +{%- endfor %} + +} // namespace {{ocpp_version_namespace}} +} // namespace localcontroller +} // namespace ocpp diff --git a/tools/json2cpp/templates/localcontroller/CentralSystemHandler.h.j2 b/tools/json2cpp/templates/localcontroller/CentralSystemHandler.h.j2 new file mode 100644 index 00000000..cf739f7d --- /dev/null +++ b/tools/json2cpp/templates/localcontroller/CentralSystemHandler.h.j2 @@ -0,0 +1,152 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* Generated by json2cpp */ + +#ifndef OPENOCPP_{{ocpp_version_namespace.upper()}}_CENTRALSYSTEMHANDLER{{ocpp_version_suffix}}_H +#define OPENOCPP_{{ocpp_version_namespace.upper()}}_CENTRALSYSTEMHANDLER{{ocpp_version_suffix}}_H + +#include "IChargePointProxy{{ocpp_version_suffix}}.h" +#include "GenericMessageHandler.h" +#include "Logger.h" +#include "IRpc.h" + +{%- for msg_name in csms_msgs %} +#include "{{msg_name}}{{ocpp_version_suffix}}.h" +{%- endfor %} + +namespace ocpp +{ +namespace config +{ +class ILocalControllerConfig{{ocpp_version_suffix}}; +} // namespace config +namespace messages +{ +class MessageDispatcher; +namespace {{ocpp_version_namespace}} +{ +class MessagesConverter{{ocpp_version_suffix}}; +} // namespace {{ocpp_version_namespace}} +} // namespace messages + +namespace localcontroller +{ +namespace {{ocpp_version_namespace}} +{ + +/** @brief Handler for central system requests */ +class CentralSystemHandler{{ocpp_version_suffix}} + : + {%- for msg_name in csms_msgs %} + public ocpp::messages::GenericMessageHandler{% if not loop.last %},{% endif %} + {%- endfor %} +{ + public: + /** + * @brief Constructor + * @param identifier Charge point's identifier + * @param messages_converter Converter from/to OCPP to/from JSON messages + * @param msg_dispatcher Message dispatcher + * @param stack_config Stack configuration + */ + CentralSystemHandler{{ocpp_version_suffix}}(const std::string& identifier, + const ocpp::messages::{{ocpp_version_namespace}}::MessagesConverter{{ocpp_version_suffix}}& messages_converter, + ocpp::messages::MessageDispatcher& msg_dispatcher); + + /** @brief Destructor */ + virtual ~CentralSystemHandler{{ocpp_version_suffix}}(); + + /** + * @brief Set the proxy to forward requests to the charge point + * @param central_system Proxy to forward requests to the charge point + */ + void setChargePointProxy(std::weak_ptr charge_point) { m_charge_point = charge_point; } + + // OCPP handlers + + {%- for msg_name in csms_msgs %} + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::{{ocpp_version_namespace}}::{{msg_name}}Req& request, + ocpp::messages::{{ocpp_version_namespace}}::{{msg_name}}Conf& response, + std::string& error_code, + std::string& error_message) override; + {%- endfor %} + + private: + /** @brief Charge point's identifier */ + const std::string m_identifier; + /** @brief Proxy to forward requests to the charge point */ + std::weak_ptr m_charge_point; + + /** + * @brief Forward a call request to the Charge Point + * @param action RPC action for the request + * @param request Request payload + * @param response Response payload + * @param error Error code to return to the Charge Point, empty if no error + * @param message Error message to return to the Charge Point, empty if no error + * @return true if the request has been sent and a response has been received, false otherwise + */ + template + bool forward(const std::string& action, const RequestType& request, ResponseType& response, std::string& error, std::string& message) + { + bool ret = false; + + // Get charge point proxy + auto charge_point = m_charge_point.lock(); + if (charge_point) + { + // Try to forward message + std::string cs_error; + std::string cs_message; + ret = charge_point->call(request, response, cs_error, cs_message); + if (!ret) + { + // Check timeout or error response + if (cs_error.empty()) + { + LOG_WARNING << "[" << m_identifier << "] - Unable to forward [" << action << "] request"; + } + else + { + LOG_WARNING << "[" << m_identifier << "] - CallError [" << cs_error << "] received on [" << action << "] request"; + error = cs_error.c_str(); + message = cs_message; + } + } + } + else + { + LOG_WARNING << "[" << m_identifier << "] - Unable to forward [" << action << "] request"; + } + + return ret; + } +}; + +} // namespace {{ocpp_version_namespace}} +} // namespace localcontroller +} // namespace ocpp + +#endif // OPENOCPP_{{ocpp_version_namespace.upper()}}_CENTRALSYSTEMHANDLER{{ocpp_version_suffix}}_H diff --git a/tools/json2cpp/templates/localcontroller/CentralSystemProxy.cpp.j2 b/tools/json2cpp/templates/localcontroller/CentralSystemProxy.cpp.j2 new file mode 100644 index 00000000..b87f98f9 --- /dev/null +++ b/tools/json2cpp/templates/localcontroller/CentralSystemProxy.cpp.j2 @@ -0,0 +1,241 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* Generated by json2cpp */ + +#include "CentralSystemProxy{{ocpp_version_suffix}}.h" +#include "ILocalControllerConfig{{ocpp_version_suffix}}.h" +#include "ILocalControllerProxyEventsHandler{{ocpp_version_suffix}}.h" +#include "Url.h" +#include "WebsocketFactory.h" + +#include + +using namespace ocpp::messages; +using namespace ocpp::messages::{{ocpp_version_namespace}}; +using namespace ocpp::types; +using namespace ocpp::types::{{ocpp_version_namespace}}; + +namespace ocpp +{ +namespace localcontroller +{ +namespace {{ocpp_version_namespace}} +{ + +/** @brief Constructor */ +CentralSystemProxy{{ocpp_version_suffix}}::CentralSystemProxy{{ocpp_version_suffix}}(const std::string& identifier, + const ocpp::messages::{{ocpp_version_namespace}}::MessagesValidator{{ocpp_version_suffix}}& messages_validator, + ocpp::messages::{{ocpp_version_namespace}}::MessagesConverter{{ocpp_version_suffix}}& messages_converter, + const ocpp::config::ILocalControllerConfig{{ocpp_version_suffix}}& stack_config, + ocpp::rpc::RpcPool& rpc_pool) + : m_identifier(identifier), + m_stack_config(stack_config), + m_websocket(ocpp::websockets::WebsocketFactory::newClientFromPool()), + m_rpc(*m_websocket, "{{ocpp_ws_protocol}}", &rpc_pool), + m_messages_converter(messages_converter), + m_msg_dispatcher(messages_validator), + m_msg_sender(m_rpc, messages_converter, messages_validator, stack_config.callRequestTimeout()), + m_handler(m_identifier, messages_converter, m_msg_dispatcher), + m_listener(nullptr), + m_user_handlers() +{ + m_rpc.registerSpy(*this); + m_rpc.registerListener(*this); + m_rpc.registerClientListener(*this); +} + +/** @brief Destructor */ +CentralSystemProxy{{ocpp_version_suffix}}::~CentralSystemProxy{{ocpp_version_suffix}}() +{ + disconnect(); +} + +/** @copydoc void ICentralSystemProxy::setTimeout(std::chrono::milliseconds) */ +void CentralSystemProxy{{ocpp_version_suffix}}::setTimeout(std::chrono::milliseconds timeout) +{ + m_msg_sender.setTimeout(timeout); +} + +/** @copydoc bool ICentralSystemProxy::connect(const std::string&, + const ocpp::websockets::IWebsocketClient::Credentials&, + std::chrono::milliseconds, + std::chrono::milliseconds, + std::chrono::milliseconds) */ +bool CentralSystemProxy{{ocpp_version_suffix}}::connect(const std::string& url, + const ocpp::websockets::IWebsocketClient::Credentials& credentials, + std::chrono::milliseconds connect_timeout, + std::chrono::milliseconds retry_interval, + std::chrono::milliseconds ping_interval) +{ + bool ret = false; + + if (!url.empty()) + { + // Build URL + std::stringstream full_url; + full_url << url; + if (url[url.size() - 1] != '/') + { + full_url << "/"; + } + full_url << ocpp::websockets::Url::encode(m_identifier); + + // Connect + ret = m_rpc.start(full_url.str(), credentials, connect_timeout, retry_interval, ping_interval); + } + return ret; +} + +/** @copydoc void ICentralSystemProxy::disconnect() */ +void CentralSystemProxy{{ocpp_version_suffix}}::disconnect() +{ + m_rpc.stop(); +} + +/** @brief Indicate if the connection with the central system is active */ +bool CentralSystemProxy{{ocpp_version_suffix}}::isConnected() const +{ + return m_rpc.isConnected(); +} + +// OCPP actions + +{%- for msg_name in cs_msgs %} +/** @copydoc bool ICentralSystemProxy{{ocpp_version_suffix}}::call(const ocpp::messages::{{ocpp_version_namespace}}::{{msg_name}}Req&, + * ocpp::messages::{{ocpp_version_namespace}}::{{msg_name}}Conf&, + * std::string&, + * std::string&) */ +bool CentralSystemProxy{{ocpp_version_suffix}}::call(const ocpp::messages::{{ocpp_version_namespace}}::{{msg_name}}Req& request, + ocpp::messages::{{ocpp_version_namespace}}::{{msg_name}}Conf& response, + std::string& error, + std::string& message) +{ + return call({{msg_name.upper()}}_ACTION, request, response, error, message); +} +{%- endfor %} + +{%- for msg_name in csms_msgs %} +/** @copydoc bool ICentralSystemProxy{{ocpp_version_suffix}}::registerHandler( + std::function) */ +bool CentralSystemProxy{{ocpp_version_suffix}}::registerHandler( + std::function + handler) +{ + return registerHandler({{msg_name.upper()}}_ACTION, handler); +} +{%- endfor %} + +// IRpc::IListener interface + +/** @copydoc void IRpc::IListener::rpcDisconnected() */ +void CentralSystemProxy{{ocpp_version_suffix}}::rpcDisconnected() +{ + LOG_WARNING << "[" << m_identifier << "] - Disconnected from Central System"; + + // Notify listener + if (m_listener) + { + m_listener->disconnectedFromCentralSystem(); + } + + // Disconnect from Charge Point + if (m_stack_config.disconnectFromCpWhenCsDisconnected()) + { + auto charge_point = m_charge_point.lock(); + if (charge_point) + { + charge_point->disconnect(); + } + } +} + +/** @copydoc void IRpc::IListener::rpcError() */ +void CentralSystemProxy{{ocpp_version_suffix}}::rpcError() +{ + LOG_ERROR << "[" << m_identifier << "] - Connection error"; +} + +/** @copydoc bool IRpc::IListener::rpcCallReceived(const std::string&, + const rapidjson::Value&, + rapidjson::Document&, + std::string&, + std::string&) */ +bool CentralSystemProxy{{ocpp_version_suffix}}::rpcCallReceived(const std::string& action, + const rapidjson::Value& payload, + rapidjson::Document& response, + std::string& error_code, + std::string& error_message) +{ + return m_msg_dispatcher.dispatchMessage(action, payload, response, error_code, error_message); +} + +// IRpc::ISpy interface + +/** @copydoc void IRpc::ISpy::rcpMessageReceived(const std::string& msg) */ +void CentralSystemProxy{{ocpp_version_suffix}}::rcpMessageReceived(const std::string& msg) +{ + LOG_COM << "[" << m_identifier << "] - RX : " << msg; +} + +/** @copydoc void IRpc::ISpy::rcpMessageSent(const std::string& msg) */ +void CentralSystemProxy{{ocpp_version_suffix}}::rcpMessageSent(const std::string& msg) +{ + LOG_COM << "[" << m_identifier << "] - TX : " << msg; +} + +// RpcClient::IListener interface + +/** @brief Called when connection is successfull */ +void CentralSystemProxy{{ocpp_version_suffix}}::rpcClientConnected() +{ + LOG_INFO << "[" << m_identifier << "] - Connected to Central System"; + + // Notify listener + if (m_listener) + { + m_listener->connectedToCentralSystem(); + } +} + +/** @brief Called when connection failed */ +void CentralSystemProxy{{ocpp_version_suffix}}::rpcClientFailed() +{ + LOG_ERROR << "[" << m_identifier << "] - Failed to connect to Central System"; + + // Notify listener + if (m_listener) + { + m_listener->failedToConnectToCentralSystem(); + } + + // Disconnect from Charge Point + if (m_stack_config.disconnectFromCpWhenCsDisconnected()) + { + auto charge_point = m_charge_point.lock(); + if (charge_point) + { + charge_point->disconnect(); + } + } +} + +} // namespace {{ocpp_version_namespace}} +} // namespace localcontroller +} // namespace ocpp diff --git a/tools/json2cpp/templates/localcontroller/CentralSystemProxy.h.j2 b/tools/json2cpp/templates/localcontroller/CentralSystemProxy.h.j2 new file mode 100644 index 00000000..1dd061a6 --- /dev/null +++ b/tools/json2cpp/templates/localcontroller/CentralSystemProxy.h.j2 @@ -0,0 +1,239 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* Generated by json2cpp */ + +#ifndef OPENOCPP_{{ocpp_version_namespace.upper()}}_CENTRALSYSTEMPROXY{{ocpp_version_suffix}}_H +#define OPENOCPP_{{ocpp_version_namespace.upper()}}_CENTRALSYSTEMPROXY{{ocpp_version_suffix}}_H + +#include "GenericMessageSender.h" +#include "CentralSystemHandler{{ocpp_version_suffix}}.h" +#include "ICentralSystemProxy{{ocpp_version_suffix}}.h" +#include "MessagesConverter{{ocpp_version_suffix}}.h" +#include "MessagesValidator{{ocpp_version_suffix}}.h" +#include "MessageDispatcher.h" +#include "RpcClient.h" +#include "UserMessageHandler.h" + +namespace ocpp +{ +namespace config +{ +class ILocalControllerConfig{{ocpp_version_suffix}}; +} // namespace config +namespace rpc +{ +class RpcPool; +} // namespace rpc + +namespace localcontroller +{ +namespace {{ocpp_version_namespace}} +{ + +/** @brief Central system proxy */ +class CentralSystemProxy{{ocpp_version_suffix}} : public ICentralSystemProxy{{ocpp_version_suffix}}, + public ocpp::rpc::IRpc::IListener, + public ocpp::rpc::IRpc::ISpy, + public ocpp::rpc::RpcClient::IListener +{ + public: + /** + * @brief Constructor + * @param identifier Charge point's identifier + * @param messages_validator JSON schemas needed to validate payloads + * @param messages_converter Converter from/to OCPP to/from JSON messages + * @param stack_config Stack configuration + * @param rpc_pool RPC pool + */ + CentralSystemProxy{{ocpp_version_suffix}}(const std::string& identifier, + const ocpp::messages::{{ocpp_version_namespace}}::MessagesValidator{{ocpp_version_suffix}}& messages_validator, + ocpp::messages::{{ocpp_version_namespace}}::MessagesConverter{{ocpp_version_suffix}}& messages_converter, + const ocpp::config::ILocalControllerConfig{{ocpp_version_suffix}}& stack_config, + ocpp::rpc::RpcPool& rpc_pool); + + /** @brief Destructor */ + virtual ~CentralSystemProxy{{ocpp_version_suffix}}(); + + /** + * @brief Set the proxy to forward requests to the charge point + * @param central_system Proxy to forward requests to the charge point + */ + void setChargePointProxy(std::weak_ptr charge_point) + { + m_charge_point = charge_point; + m_handler.setChargePointProxy(charge_point); + } + + /** @copydoc const std::string& ICentralSystemProxy{{ocpp_version_suffix}}::disconnect() const */ + const std::string& identifier() const override { return m_identifier; } + + /** @copydoc void ICentralSystemProxy{{ocpp_version_suffix}}::setTimeout(std::chrono::milliseconds) */ + void setTimeout(std::chrono::milliseconds timeout) override; + + /** @copydoc bool ICentralSystemProxy{{ocpp_version_suffix}}::connect(const std::string&, + const ocpp::websockets::IWebsocketClient::Credentials&, + std::chrono::milliseconds, + std::chrono::milliseconds, + std::chrono::milliseconds) */ + bool connect(const std::string& url, + const ocpp::websockets::IWebsocketClient::Credentials& credentials, + std::chrono::milliseconds connect_timeout, + std::chrono::milliseconds retry_interval, + std::chrono::milliseconds ping_interval) override; + + /** @copydoc void ICentralSystemProxy{{ocpp_version_suffix}}::disconnect() */ + void disconnect() override; + + /** @brief Indicate if the connection with the central system is active */ + bool isConnected() const override; + + /** @copydoc void ICentralSystemProxy{{ocpp_version_suffix}}::registerListener(ILocalControllerProxyEventsHandler{{ocpp_version_suffix}}&) */ + void registerListener(ILocalControllerProxyEventsHandler{{ocpp_version_suffix}}& listener) override { m_listener = &listener; } + + // OCPP actions + + {%- for msg_name in cs_msgs %} + /** @copydoc bool ICentralSystemProxy{{ocpp_version_suffix}}::call(const ocpp::messages::{{ocpp_version_namespace}}::{{msg_name}}Req&, + * ocpp::messages::{{ocpp_version_namespace}}::{{msg_name}}Conf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::{{ocpp_version_namespace}}::{{msg_name}}Req& request, + ocpp::messages::{{ocpp_version_namespace}}::{{msg_name}}Conf& response, + std::string& error, + std::string& message) override; + {%- endfor %} + + + {%- for msg_name in csms_msgs %} + /** @copydoc bool ICentralSystemProxy{{ocpp_version_suffix}}::registerHandler( + std::function) */ + bool registerHandler(std::function handler) override; + {%- endfor %} + + // IRpc::IListener interface + + /** @copydoc void IRpc::IListener::rpcDisconnected() */ + void rpcDisconnected() override; + + /** @copydoc void IRpc::IListener::rpcError() */ + void rpcError() override; + + /** @copydoc bool IRpc::IListener::rpcCallReceived(const std::string&, + const rapidjson::Value&, + rapidjson::Document&, + std::string&, + std::string&) */ + bool rpcCallReceived(const std::string& action, + const rapidjson::Value& payload, + rapidjson::Document& response, + std::string& error_code, + std::string& error_message) override; + + // IRpc::ISpy interface + + /** @copydoc void IRpc::ISpy::rcpMessageReceived(const std::string& msg) */ + void rcpMessageReceived(const std::string& msg) override; + + /** @copydoc void IRpc::ISpy::rcpMessageSent(const std::string& msg) */ + void rcpMessageSent(const std::string& msg) override; + + // RpcClient::IListener interface + + /** @brief Called when connection is successfull */ + void rpcClientConnected() override; + + /** @brief Called when connection failed */ + void rpcClientFailed() override; + + private: + /** @brief Charge point's identifier */ + std::string m_identifier; + /** @brief Stack configuration */ + const ocpp::config::ILocalControllerConfig{{ocpp_version_suffix}}& m_stack_config; + /** @brief Client websocket */ + std::unique_ptr m_websocket; + /** @brief RPC connection */ + ocpp::rpc::RpcClient m_rpc; + /** @brief Messages converter */ + ocpp::messages::{{ocpp_version_namespace}}::MessagesConverter{{ocpp_version_suffix}}& m_messages_converter; + /** @brief Message dispatcher */ + ocpp::messages::MessageDispatcher m_msg_dispatcher; + /** @brief Message sender */ + ocpp::messages::GenericMessageSender m_msg_sender; + /** @brief Request handler */ + CentralSystemHandler{{ocpp_version_suffix}} m_handler; + /** @brief Proxy to forward requests to the charge point */ + std::weak_ptr m_charge_point; + /** @brief Listener to the proxy events */ + ILocalControllerProxyEventsHandler{{ocpp_version_suffix}}* m_listener; + /** @brief User message handlers */ + std::vector> m_user_handlers; + + /** + * @brief Execute a call request + * @param action RPC action for the request + * @param request Request payload + * @param response Response payload + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + template + bool call(const std::string& action, const RequestType& request, ResponseType& response, std::string& error, std::string& message) + { + bool ret = true; + + LOG_DEBUG << "[" << m_identifier << "] - " << action; + + ocpp::messages::CallResult res = m_msg_sender.call(action, request, response, error, message); + if (res != ocpp::messages::CallResult::Ok) + { + LOG_ERROR << "[" << m_identifier << "] - " << action << " => " + << (res == ocpp::messages::CallResult::Failed ? "Timeout" : "Error"); + ret = false; + } + + return ret; + } + + /** + * @brief Register a user handler for an incoming request + * @param action RPC action for the request + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + template + bool registerHandler(const std::string& action, + std::function handler) + { + ocpp::messages::UserMessageHandler* msg_handler = + new ocpp::messages::UserMessageHandler(action, m_messages_converter, handler); + m_user_handlers.push_back(std::shared_ptr(msg_handler)); + return m_msg_dispatcher.registerHandler(action, *msg_handler, true); + } +}; + +} // namespace {{ocpp_version_namespace}} +} // namespace localcontroller +} // namespace ocpp + +#endif // OPENOCPP_{{ocpp_version_namespace.upper()}}_CENTRALSYSTEMPROXY{{ocpp_version_suffix}}_H diff --git a/tools/json2cpp/templates/localcontroller/ChargePointHandler.cpp.j2 b/tools/json2cpp/templates/localcontroller/ChargePointHandler.cpp.j2 new file mode 100644 index 00000000..a491e810 --- /dev/null +++ b/tools/json2cpp/templates/localcontroller/ChargePointHandler.cpp.j2 @@ -0,0 +1,78 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* Generated by json2cpp */ + +#include "MessageDispatcher.h" +#include "ChargePointHandler{{ocpp_version_suffix}}.h" +#include "ILocalControllerConfig{{ocpp_version_suffix}}.h" +#include "MessagesConverter{{ocpp_version_suffix}}.h" + +using namespace ocpp::messages; +using namespace ocpp::messages::{{ocpp_version_namespace}}; +using namespace ocpp::types; +using namespace ocpp::types::{{ocpp_version_namespace}}; + +namespace ocpp +{ +namespace localcontroller +{ +namespace {{ocpp_version_namespace}} +{ + +/** @brief Constructor */ +ChargePointHandler{{ocpp_version_suffix}}::ChargePointHandler{{ocpp_version_suffix}}(const std::string& identifier, + const ocpp::messages::{{ocpp_version_namespace}}::MessagesConverter{{ocpp_version_suffix}}& messages_converter, + ocpp::messages::MessageDispatcher& msg_dispatcher, + ICentralSystemProxy{{ocpp_version_suffix}}& central_system) + : + {%- for msg_name in cs_msgs %} + GenericMessageHandler<{{msg_name}}Req, {{msg_name}}Conf>({{msg_name.upper()}}_ACTION, messages_converter), + {%- endfor %} + + m_identifier(identifier), + m_central_system(central_system) +{ + {%- for msg_name in cs_msgs %} + msg_dispatcher.registerHandler({{msg_name.upper()}}_ACTION, + *dynamic_cast*>(this)); + {%- endfor %} +} +/** @brief Destructor */ +ChargePointHandler{{ocpp_version_suffix}}::~ChargePointHandler{{ocpp_version_suffix}}() { } + +// OCPP handlers + +{%- for msg_name in cs_msgs %} +/** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ +bool ChargePointHandler{{ocpp_version_suffix}}::handleMessage(const ocpp::messages::{{ocpp_version_namespace}}::{{msg_name}}Req& request, + ocpp::messages::{{ocpp_version_namespace}}::{{msg_name}}Conf& response, + std::string& error_code, + std::string& error_message) +{ + return forward({{msg_name.upper()}}_ACTION, request, response, error_code, error_message); +} +{%- endfor %} + +} // namespace {{ocpp_version_namespace}} +} // namespace localcontroller +} // namespace ocpp diff --git a/tools/json2cpp/templates/localcontroller/ChargePointHandler.h.j2 b/tools/json2cpp/templates/localcontroller/ChargePointHandler.h.j2 new file mode 100644 index 00000000..99597a5f --- /dev/null +++ b/tools/json2cpp/templates/localcontroller/ChargePointHandler.h.j2 @@ -0,0 +1,139 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* Generated by json2cpp */ + +#ifndef OPENOCPP_{{ocpp_version_namespace.upper()}}_LC_CHARGEPOINTHANDLER{{ocpp_version_suffix}}_H +#define OPENOCPP_{{ocpp_version_namespace.upper()}}_LC_CHARGEPOINTHANDLER{{ocpp_version_suffix}}_H + +#include "ICentralSystemProxy{{ocpp_version_suffix}}.h" +#include "GenericMessageHandler.h" +#include "Logger.h" +#include "IRpc.h" + +{%- for msg_name in cs_msgs %} +#include "{{msg_name}}{{ocpp_version_suffix}}.h" +{%- endfor %} + +namespace ocpp +{ +namespace config +{ +class ILocalControllerConfig{{ocpp_version_suffix}}; +} // namespace config +namespace messages +{ +class MessageDispatcher; +namespace {{ocpp_version_namespace}} +{ +class MessagesConverter{{ocpp_version_suffix}}; +} // namespace {{ocpp_version_namespace}} +} // namespace messages + +namespace localcontroller +{ +namespace {{ocpp_version_namespace}} +{ + +/** @brief Handler for charge point requests */ +class ChargePointHandler{{ocpp_version_suffix}} + : + {%- for msg_name in cs_msgs %} + public ocpp::messages::GenericMessageHandler{% if not loop.last %},{% endif %} + {%- endfor %} +{ + public: + /** + * @brief Constructor + * @param identifier Charge point's identifier + * @param messages_converter Converter from/to OCPP to/from JSON messages + * @param msg_dispatcher Message dispatcher + * @param stack_config Stack configuration + */ + ChargePointHandler{{ocpp_version_suffix}}(const std::string& identifier, + const ocpp::messages::{{ocpp_version_namespace}}::MessagesConverter{{ocpp_version_suffix}}& messages_converter, + ocpp::messages::MessageDispatcher& msg_dispatcher, + ICentralSystemProxy{{ocpp_version_suffix}}& central_system); + + /** @brief Destructor */ + virtual ~ChargePointHandler{{ocpp_version_suffix}}(); + + // OCPP handlers + + {%- for msg_name in cs_msgs %} + /** @copydoc bool GenericMessageHandler::handleMessage(const RequestType& request, + * ResponseType& response, + * std::string& error_code, + * std::string& error_message) + */ + bool handleMessage(const ocpp::messages::{{ocpp_version_namespace}}::{{msg_name}}Req& request, + ocpp::messages::{{ocpp_version_namespace}}::{{msg_name}}Conf& response, + std::string& error_code, + std::string& error_message) override; + {%- endfor %} + + private: + /** @brief Charge point's identifier */ + const std::string m_identifier; + /** @brief Stack configuration */ + /** @brief Proxy to forward requests to the central system */ + ICentralSystemProxy{{ocpp_version_suffix}}& m_central_system; + + /** + * @brief Forward a call request to the Central System + * @param action RPC action for the request + * @param request Request payload + * @param response Response payload + * @param error Error code to return to the Charge Point, empty if no error + * @param message Error message to return to the Charge Point, empty if no error + * @return true if the request has been sent and a response has been received, false otherwise + */ + template + bool forward(const std::string& action, const RequestType& request, ResponseType& response, std::string& error, std::string& message) + { + bool ret = false; + + // Try to forward message + std::string cs_error; + std::string cs_message; + ret = m_central_system.call(request, response, cs_error, cs_message); + if (!ret) + { + // Check timeout or error response + if (cs_error.empty()) + { + LOG_WARNING << "[" << m_identifier << "] - Unable to forward [" << action << "] request"; + } + else + { + LOG_WARNING << "[" << m_identifier << "] - CallError [" << cs_error << "] received on [" << action << "] request"; + error = cs_error.c_str(); + message = cs_message; + } + } + + return ret; + } +}; + +} // namespace {{ocpp_version_namespace}} +} // namespace localcontroller +} // namespace ocpp + +#endif // OPENOCPP_{{ocpp_version_namespace.upper()}}_LC_CHARGEPOINTHANDLER{{ocpp_version_suffix}}_H diff --git a/tools/json2cpp/templates/localcontroller/ChargePointProxy.cpp.j2 b/tools/json2cpp/templates/localcontroller/ChargePointProxy.cpp.j2 new file mode 100644 index 00000000..048ebe95 --- /dev/null +++ b/tools/json2cpp/templates/localcontroller/ChargePointProxy.cpp.j2 @@ -0,0 +1,209 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* Generated by json2cpp */ + +#include "ChargePointProxy{{ocpp_version_suffix}}.h" +#include "../centralsystem/chargepoint/ChargePointProxy{{ocpp_version_suffix}}.h" +#include "CentralSystemProxy{{ocpp_version_suffix}}.h" +#include "ILocalControllerConfig{{ocpp_version_suffix}}.h" +#include "ILocalControllerProxyEventsHandler{{ocpp_version_suffix}}.h" +#include "MessagesConverter{{ocpp_version_suffix}}.h" + +using namespace ocpp::messages; +using namespace ocpp::messages::{{ocpp_version_namespace}}; +using namespace ocpp::types; +using namespace ocpp::types::{{ocpp_version_namespace}}; + +namespace ocpp +{ +namespace localcontroller +{ +namespace {{ocpp_version_namespace}} +{ + +/** @brief Instanciate local controller's charge point proxy from a central system's charge point proxy */ +std::shared_ptr IChargePointProxy{{ocpp_version_suffix}}::createFrom( + std::shared_ptr& central_system_proxy, + const ocpp::config::ILocalControllerConfig{{ocpp_version_suffix}}& stack_config, + ocpp::rpc::RpcPool& rpc_pool) +{ + std::shared_ptr proxy; + + // Instanciation can only be done from centralsytem::ChargePointProxy instance + ocpp::centralsystem::{{ocpp_version_namespace}}::ChargePointProxy{{ocpp_version_suffix}}* cs_proxy = dynamic_cast(central_system_proxy.get()); + if (cs_proxy) + { + // Create associated Central System proxy + CentralSystemProxy{{ocpp_version_suffix}}* centralsystem = new CentralSystemProxy{{ocpp_version_suffix}}( + cs_proxy->identifier(), cs_proxy->messagesValidator(), cs_proxy->messagesConverter(), stack_config, rpc_pool); + + // Create the proxy + proxy = std::shared_ptr(new ChargePointProxy{{ocpp_version_suffix}}(cs_proxy->identifier(), + cs_proxy->rpcClient(), + cs_proxy->messagesValidator(), + cs_proxy->messagesConverter(), + stack_config, + std::shared_ptr(centralsystem))); + + // Associate both + centralsystem->setChargePointProxy(proxy); + + // Unregister old proxy from RPC spy events + cs_proxy->unregisterFromRpcSpy(); + } + + return proxy; +} + +/** @brief Constructor */ +ChargePointProxy{{ocpp_version_suffix}}::ChargePointProxy{{ocpp_version_suffix}}(const std::string& identifier, + std::shared_ptr rpc, + const ocpp::messages::{{ocpp_version_namespace}}::MessagesValidator{{ocpp_version_suffix}}& messages_validator, + ocpp::messages::{{ocpp_version_namespace}}::MessagesConverter{{ocpp_version_suffix}}& messages_converter, + const ocpp::config::ILocalControllerConfig{{ocpp_version_suffix}}& stack_config, + std::shared_ptr central_system) + : m_identifier(identifier), + m_rpc(rpc), + m_messages_converter(messages_converter), + m_msg_dispatcher(messages_validator), + m_msg_sender(*m_rpc, messages_converter, messages_validator, stack_config.callRequestTimeout()), + m_central_system(central_system), + m_handler(m_identifier, messages_converter, m_msg_dispatcher, *central_system.get()), + m_listener(nullptr), + m_user_handlers() +{ + m_rpc->registerSpy(*this); + m_rpc->registerListener(*this); +} + +/** @brief Destructor */ +ChargePointProxy{{ocpp_version_suffix}}::~ChargePointProxy{{ocpp_version_suffix}}() +{ + // Disconnect from the charge point + m_rpc->disconnect(false); + + // Disconnect from the central system + m_central_system->disconnect(); +} + +// IChargePointProxy interface + +/** @copydoc const std::string& IChargePointProxy::ipAddress() const */ +const std::string& ChargePointProxy{{ocpp_version_suffix}}::ipAddress() const +{ + return m_rpc->ipAddress(); +} + +/** @copydoc void IChargePointProxy::setTimeout(std::chrono::milliseconds) */ +void ChargePointProxy{{ocpp_version_suffix}}::setTimeout(std::chrono::milliseconds timeout) +{ + m_msg_sender.setTimeout(timeout); +} + +/** @copydoc void IChargePointProxy::disconnect() */ +void ChargePointProxy{{ocpp_version_suffix}}::disconnect() +{ + // Disconnect from the charge point + m_rpc->disconnect(true); + + // Disconnect from the central system + m_central_system->disconnect(); +} + +// OCPP operations + +{%- for msg_name in csms_msgs %} +/** @copydoc bool IChargePointProxy{{ocpp_version_suffix}}::call(const ocpp::messages::{{ocpp_version_namespace}}::{{msg_name}}Req&, + * ocpp::messages::{{ocpp_version_namespace}}::{{msg_name}}Conf&, + * std::string&, + * std::string&) */ +bool ChargePointProxy{{ocpp_version_suffix}}::call(const ocpp::messages::{{ocpp_version_namespace}}::{{msg_name}}Req& request, + ocpp::messages::{{ocpp_version_namespace}}::{{msg_name}}Conf& response, + std::string& error, + std::string& message) +{ + return call({{msg_name.upper()}}_ACTION, request, response, error, message); +} +{%- endfor %} + +{%- for msg_name in cs_msgs %} +/** @copydoc bool IChargePointProxy{{ocpp_version_suffix}}::registerHandler( + std::function) */ +bool ChargePointProxy{{ocpp_version_suffix}}::registerHandler( + std::function + handler) +{ + return registerHandler({{msg_name.upper()}}_ACTION, handler); +} +{%- endfor %} + +// IRpc::IListener interface + +/** @copydoc void IRpc::IListener::rpcDisconnected() */ +void ChargePointProxy{{ocpp_version_suffix}}::rpcDisconnected() +{ + LOG_WARNING << "[" << m_identifier << "] - Disconnected from Charge Point"; + + // Disconnect from the central system + m_central_system->disconnect(); + + // Notify listener + if (m_listener) + { + m_listener->disconnectedFromChargePoint(); + } +} + +/** @copydoc void IRpc::IListener::rpcError() */ +void ChargePointProxy{{ocpp_version_suffix}}::rpcError() +{ + LOG_ERROR << "[" << m_identifier << "] - Connection error"; +} + +/** @copydoc bool IRpc::IListener::rpcCallReceived(const std::string&, + const rapidjson::Value&, + rapidjson::Document&, + std::string&, + std::string&) */ +bool ChargePointProxy{{ocpp_version_suffix}}::rpcCallReceived(const std::string& action, + const rapidjson::Value& payload, + rapidjson::Document& response, + std::string& error_code, + std::string& error_message) +{ + return m_msg_dispatcher.dispatchMessage(action, payload, response, error_code, error_message); +} + +// IRpc::ISpy interface + +/** @copydoc void IRpc::ISpy::rcpMessageReceived(const std::string& msg) */ +void ChargePointProxy{{ocpp_version_suffix}}::rcpMessageReceived(const std::string& msg) +{ + LOG_COM << "[" << m_identifier << "] - RX : " << msg; +} + +void ChargePointProxy{{ocpp_version_suffix}}::rcpMessageSent(const std::string& msg) +{ + LOG_COM << "[" << m_identifier << "] - TX : " << msg; +} + +} // namespace {{ocpp_version_namespace}} +} // namespace localcontroller +} // namespace ocpp diff --git a/tools/json2cpp/templates/localcontroller/ChargePointProxy.h.j2 b/tools/json2cpp/templates/localcontroller/ChargePointProxy.h.j2 new file mode 100644 index 00000000..5b6a54e5 --- /dev/null +++ b/tools/json2cpp/templates/localcontroller/ChargePointProxy.h.j2 @@ -0,0 +1,208 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* Generated by json2cpp */ + +#ifndef OPENOCPP_{{ocpp_version_namespace.upper()}}_LC_CHARGEPOINTPROXY{{ocpp_version_suffix}}_H +#define OPENOCPP_{{ocpp_version_namespace.upper()}}_LC_CHARGEPOINTPROXY{{ocpp_version_suffix}}_H + +#include "ChargePointHandler{{ocpp_version_suffix}}.h" +#include "GenericMessageSender.h" +#include "IChargePointProxy{{ocpp_version_suffix}}.h" +#include "Logger.h" +#include "MessageDispatcher.h" +#include "MessagesValidator{{ocpp_version_suffix}}.h" +#include "RpcServer.h" +#include "UserMessageHandler.h" + +namespace ocpp +{ +namespace config +{ +class ILocalControllerConfig{{ocpp_version_suffix}}; +} // namespace config +namespace localcontroller +{ +namespace {{ocpp_version_namespace}} +{ + +/** @brief Charge point proxy */ +class ChargePointProxy{{ocpp_version_suffix}} : public IChargePointProxy{{ocpp_version_suffix}}, public ocpp::rpc::IRpc::IListener, public ocpp::rpc::IRpc::ISpy +{ + public: + /** + * @brief Constructor + * @param identifier Charge point's identifier + * @param rpc RPC connection with the charge point + * @param messages_validator JSON schemas needed to validate payloads + * @param messages_converter Converter from/to OCPP to/from JSON messages + * @param stack_config Stack configuration + * @param central_system Proxy to forward requests to the central system + */ + ChargePointProxy{{ocpp_version_suffix}}(const std::string& identifier, + std::shared_ptr rpc, + const ocpp::messages::{{ocpp_version_namespace}}::MessagesValidator{{ocpp_version_suffix}}& messages_validator, + ocpp::messages::{{ocpp_version_namespace}}::MessagesConverter{{ocpp_version_suffix}}& messages_converter, + const ocpp::config::ILocalControllerConfig{{ocpp_version_suffix}}& stack_config, + std::shared_ptr central_system); + /** @brief Destructor */ + virtual ~ChargePointProxy{{ocpp_version_suffix}}(); + + // IChargePointProxy{{ocpp_version_suffix}} interface + + /** @copydoc const std::string& IChargePointProxy{{ocpp_version_suffix}}::ipAddress() const */ + const std::string& ipAddress() const override; + + /** @copydoc const std::string& IChargePointProxy{{ocpp_version_suffix}}::identifier() const */ + const std::string& identifier() const override { return m_identifier; } + + /** @copydoc void IChargePointProxy{{ocpp_version_suffix}}::setTimeout(std::chrono::milliseconds) */ + void setTimeout(std::chrono::milliseconds timeout) override; + + /** @copydoc void IChargePointProxy{{ocpp_version_suffix}}::disconnect() */ + void disconnect() override; + + /** @copydoc std::shared_ptr IChargePointProxy{{ocpp_version_suffix}}::centralSystemProxy() */ + std::shared_ptr centralSystemProxy() override { return m_central_system; } + + /** @copydoc void IChargePointProxy{{ocpp_version_suffix}}::registerListener(ILocalControllerProxyEventsHandler{{ocpp_version_suffix}}&) */ + void registerListener(ILocalControllerProxyEventsHandler{{ocpp_version_suffix}}& listener) override + { + m_listener = &listener; + m_central_system->registerListener(listener); + } + + // OCPP operations + + {%- for msg_name in csms_msgs %} + /** @copydoc bool IChargePointProxy{{ocpp_version_suffix}}::call(const ocpp::messages::{{ocpp_version_namespace}}::{{msg_name}}Req&, + * ocpp::messages::{{ocpp_version_namespace}}::{{msg_name}}Conf&, + * std::string&, + * std::string&) */ + bool call(const ocpp::messages::{{ocpp_version_namespace}}::{{msg_name}}Req& request, + ocpp::messages::{{ocpp_version_namespace}}::{{msg_name}}Conf& response, + std::string& error, + std::string& message) override; + {%- endfor %} + + + {%- for msg_name in cs_msgs %} + /** @copydoc bool IChargePointProxy{{ocpp_version_suffix}}::registerHandler( + std::function) */ + bool registerHandler(std::function handler) override; + {%- endfor %} + + // IRpc::IListener interface + + /** @copydoc void IRpc::IListener::rpcDisconnected() */ + void rpcDisconnected() override; + + /** @copydoc void IRpc::IListener::rpcError() */ + void rpcError() override; + + /** @copydoc bool IRpc::IListener::rpcCallReceived(const std::string&, + const rapidjson::Value&, + rapidjson::Document&, + std::string&, + std::string&) */ + bool rpcCallReceived(const std::string& action, + const rapidjson::Value& payload, + rapidjson::Document& response, + std::string& error_code, + std::string& error_message) override; + + // IRpc::ISpy interface + + /** @copydoc void IRpc::ISpy::rcpMessageReceived(const std::string& msg) */ + void rcpMessageReceived(const std::string& msg) override; + + /** @copydoc void IRpc::ISpy::rcpMessageSent(const std::string& msg) */ + void rcpMessageSent(const std::string& msg) override; + + private: + /** @brief Charge point's identifier */ + std::string m_identifier; + /** @brief RPC connection */ + std::shared_ptr m_rpc; + /** @brief Messages converter */ + ocpp::messages::{{ocpp_version_namespace}}::MessagesConverter{{ocpp_version_suffix}}& m_messages_converter; + /** @brief Message dispatcher */ + ocpp::messages::MessageDispatcher m_msg_dispatcher; + /** @brief Message sender */ + ocpp::messages::GenericMessageSender m_msg_sender; + /** @brief Proxy to forward requests to the central system */ + std::shared_ptr m_central_system; + /** @brief Request handler */ + ChargePointHandler{{ocpp_version_suffix}} m_handler; + /** @brief Listener to the proxy events */ + ILocalControllerProxyEventsHandler{{ocpp_version_suffix}}* m_listener; + /** @brief User message handlers */ + std::vector> m_user_handlers; + + /** + * @brief Execute a call request + * @param action RPC action for the request + * @param request Request payload + * @param response Response payload + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + template + bool call(const std::string& action, const RequestType& request, ResponseType& response, std::string& error, std::string& message) + { + bool ret = true; + + LOG_DEBUG << "[" << m_identifier << "] - " << action; + + ocpp::messages::CallResult res = m_msg_sender.call(action, request, response, error, message); + if (res != ocpp::messages::CallResult::Ok) + { + LOG_ERROR << "[" << m_identifier << "] - " << action << " => " + << (res == ocpp::messages::CallResult::Failed ? "Timeout" : "Error"); + ret = false; + } + + return ret; + } + + /** + * @brief Register a user handler for an incoming request + * @param action RPC action for the request + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + template + bool registerHandler(const std::string& action, + std::function handler) + { + ocpp::messages::UserMessageHandler* msg_handler = + new ocpp::messages::UserMessageHandler(action, m_messages_converter, handler); + m_user_handlers.push_back(std::shared_ptr(msg_handler)); + return m_msg_dispatcher.registerHandler(action, *msg_handler, true); + } +}; + +} // namespace {{ocpp_version_namespace}} +} // namespace localcontroller +} // namespace ocpp + +#endif // OPENOCPP_{{ocpp_version_namespace.upper()}}_LC_CHARGEPOINTPROXY{{ocpp_version_suffix}}_H diff --git a/tools/json2cpp/templates/localcontroller/ICentralSystemProxy.h.j2 b/tools/json2cpp/templates/localcontroller/ICentralSystemProxy.h.j2 new file mode 100644 index 00000000..b1198ad7 --- /dev/null +++ b/tools/json2cpp/templates/localcontroller/ICentralSystemProxy.h.j2 @@ -0,0 +1,125 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* Generated by json2cpp */ + +#ifndef OPENOCPP_{{ocpp_version_namespace.upper()}}_ICENTRALSYSTEMPROXY{{ocpp_version_suffix}}_H +#define OPENOCPP_{{ocpp_version_namespace.upper()}}_ICENTRALSYSTEMPROXY{{ocpp_version_suffix}}_H + +#include "IWebsocketClient.h" +{%- for msg_name in csms_msgs %} +#include "{{msg_name}}{{ocpp_version_suffix}}.h" +{%- endfor %} +{%- for msg_name in cs_msgs %} +#include "{{msg_name}}{{ocpp_version_suffix}}.h" +{%- endfor %} + +#include + +namespace ocpp +{ +namespace localcontroller +{ +namespace {{ocpp_version_namespace}} +{ + +class ILocalControllerProxyEventsHandler{{ocpp_version_suffix}}; + +/** @brief Interface for central system proxy implementations */ +class ICentralSystemProxy{{ocpp_version_suffix}} +{ + public: + /** @brief Destructor */ + virtual ~ICentralSystemProxy{{ocpp_version_suffix}}() { } + + /** + * @brief Get the charge point identifier + * @return charge point identifier + */ + virtual const std::string& identifier() const = 0; + + /** + * @brief Set the call request timeout + * @param timeout New timeout value + */ + virtual void setTimeout(std::chrono::milliseconds timeout) = 0; + + /** + * @brief Connect to the central system + * @param url URL to connect to + * @param credentials Credentials to use + * @param connect_timeout Connection timeout in ms + * @param retry_interval Retry interval in ms when connection cannot be established (0 = no retry) + * @param ping_interval Interval between 2 websocket PING messages when the socket is idle + * @return true if the client has been started, false otherwise + */ + virtual bool connect(const std::string& url, + const ocpp::websockets::IWebsocketClient::Credentials& credentials, + std::chrono::milliseconds connect_timeout = std::chrono::seconds(5), + std::chrono::milliseconds retry_interval = std::chrono::seconds(5), + std::chrono::milliseconds ping_interval = std::chrono::seconds(5)) = 0; + + /** @brief Disconnect from the central system */ + virtual void disconnect() = 0; + + /** + * @brief Indicate if the connection with the central system is active + * @return true if the connection is active, false otherwise + */ + virtual bool isConnected() const = 0; + + /** + * @brief Register a listener to the proxy events + * @param listener Listener to the proxy events + */ + virtual void registerListener(ILocalControllerProxyEventsHandler{{ocpp_version_suffix}}& listener) = 0; + + // OCPP operations + + {%- for msg_name in cs_msgs %} + /** + * @brief Send a {{msg_name}} message to the central system + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::{{ocpp_version_namespace}}::{{msg_name}}Req& request, + ocpp::messages::{{ocpp_version_namespace}}::{{msg_name}}Conf& response, + std::string& error, + std::string& message) = 0; + {%- endfor %} + + {%- for msg_name in csms_msgs %} + /** + * @brief Register a handler for the {{msg_name}} request from the central system + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler( + std::function + handler) = 0; + {%- endfor %} +}; + +} // namespace {{ocpp_version_namespace}} +} // namespace localcontroller +} // namespace ocpp + +#endif // OPENOCPP_{{ocpp_version_namespace.upper()}}_ICENTRALSYSTEMPROXY{{ocpp_version_suffix}}_H diff --git a/tools/json2cpp/templates/localcontroller/IChargePointProxy.h.j2 b/tools/json2cpp/templates/localcontroller/IChargePointProxy.h.j2 new file mode 100644 index 00000000..26703279 --- /dev/null +++ b/tools/json2cpp/templates/localcontroller/IChargePointProxy.h.j2 @@ -0,0 +1,127 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* Generated by json2cpp */ + +#ifndef OPENOCPP_{{ocpp_version_namespace.upper()}}_ICHARGEPOINTPROXY{{ocpp_version_suffix}}_H +#define OPENOCPP_{{ocpp_version_namespace.upper()}}_ICHARGEPOINTPROXY{{ocpp_version_suffix}}_H + +#include "ICentralSystem{{ocpp_version_suffix}}.h" +#include "ICentralSystemProxy{{ocpp_version_suffix}}.h" +#include "ILocalControllerConfig{{ocpp_version_suffix}}.h" +#include "RpcPool.h" + +{%- for msg_name in csms_msgs %} +#include "{{msg_name}}{{ocpp_version_suffix}}.h" +{%- endfor %} + +#include +#include + +namespace ocpp +{ +namespace localcontroller +{ +namespace {{ocpp_version_namespace}} +{ + +/** @brief Interface for the charge point proxy implementations */ +class IChargePointProxy{{ocpp_version_suffix}} +{ + public: + /** @brief Destructor */ + virtual ~IChargePointProxy{{ocpp_version_suffix}}() { } + + /** + * @brief Instanciate local controller's charge point proxy from a central system's charge point proxy + * @param central_system_proxy Central system's charge point proxy + * @param stack_config Stack configuration for local controller + * @param rpc_pool RPC pool + */ + static std::shared_ptr createFrom( + std::shared_ptr& central_system_proxy, + const ocpp::config::ILocalControllerConfig{{ocpp_version_suffix}}& stack_config, + ocpp::rpc::RpcPool& rpc_pool); + + /** + * @brief Get the IP address of the charge point + * @return IP address of the charge point + */ + virtual const std::string& ipAddress() const = 0; + + /** + * @brief Get the charge point identifier + * @return charge point identifier + */ + virtual const std::string& identifier() const = 0; + + /** + * @brief Set the call request timeout + * @param timeout New timeout value + */ + virtual void setTimeout(std::chrono::milliseconds timeout) = 0; + + /** @brief Disconnect the charge point */ + virtual void disconnect() = 0; + + /** + * @brief Get the associated central system proxy + * @return Associated central system proxy + */ + virtual std::shared_ptr centralSystemProxy() = 0; + + /** + * @brief Register a listener to the proxy events + * @param listener Listener to the proxy events + */ + virtual void registerListener(ILocalControllerProxyEventsHandler{{ocpp_version_suffix}}& listener) = 0; + + // OCPP operations + + {%- for msg_name in csms_msgs %} + /** + * @brief Send a {{msg_name}} message to the charge point + * @param request Request to send + * @param response Received response + * @param error Error (Empty if not a CallError) + * @param message Error message (Empty if not a CallError) + * @return true if the request has been sent and a response has been received, false otherwise + */ + virtual bool call(const ocpp::messages::{{ocpp_version_namespace}}::{{msg_name}}Req& request, + ocpp::messages::{{ocpp_version_namespace}}::{{msg_name}}Conf& response, + std::string& error, + std::string& message) = 0; + {%- endfor %} + + {%- for msg_name in cs_msgs %} + /** + * @brief Register a handler for the {{msg_name}} request from the charge point + * @param handler Handler function + * @return true if the handler has been registered, false otherwise + */ + virtual bool registerHandler( + std::function + handler) = 0; + {%- endfor %} +}; + +} // namespace {{ocpp_version_namespace}} +} // namespace localcontroller +} // namespace ocpp + +#endif // OPENOCPP_{{ocpp_version_namespace.upper()}}_ICHARGEPOINTPROXY{{ocpp_version_suffix}}_H diff --git a/tools/json2cpp/templates/messages/MessagesConverter.cpp.j2 b/tools/json2cpp/templates/messages/MessagesConverter.cpp.j2 new file mode 100644 index 00000000..577fa3e7 --- /dev/null +++ b/tools/json2cpp/templates/messages/MessagesConverter.cpp.j2 @@ -0,0 +1,70 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +#include "MessagesConverter20.h" + +{%- for msg_name in csms_msgs %} +#include "{{msg_name}}{{ocpp_version_suffix}}.h" +{%- endfor %} +{%- for msg_name in cs_msgs %} +#include "{{msg_name}}{{ocpp_version_suffix}}.h" +{%- endfor %} + +/** @brief Macro to register a message converter for an OCPP action */ +#define REGISTER_CONVERTER(action) \ + registerRequestConverter(#action, *new action##ReqConverter()); \ + registerResponseConverter(#action, *new action##ConfConverter()) + +/** @brief Macro to delete a message converter for an OCPP action */ +#define DELETE_CONVERTER(action) \ + deleteRequestConverter(#action); \ + deleteResponseConverter(#action) + +namespace ocpp +{ +namespace messages +{ +namespace ocpp20 +{ + +/** @brief Constructor */ +MessagesConverter20::MessagesConverter20() +{ + // Register converters + {%- for msg_name in csms_msgs %} + REGISTER_CONVERTER({{msg_name.replace(ocpp_version_suffix, "")}}); + {%- endfor %} + {%- for msg_name in cs_msgs %} + REGISTER_CONVERTER({{msg_name.replace(ocpp_version_suffix, "")}}); + {%- endfor %} +} +/** @brief Destructor */ +MessagesConverter20::~MessagesConverter20() +{ + // Free memory + {%- for msg_name in csms_msgs %} + DELETE_CONVERTER({{msg_name.replace(ocpp_version_suffix, "")}}); + {%- endfor %} + {%- for msg_name in cs_msgs %} + DELETE_CONVERTER({{msg_name.replace(ocpp_version_suffix, "")}}); + {%- endfor %} +} + +} // namespace ocpp20 +} // namespace messages +} // namespace ocpp diff --git a/tools/json2cpp/templates/messages/MessagesValidator.cpp.j2 b/tools/json2cpp/templates/messages/MessagesValidator.cpp.j2 new file mode 100644 index 00000000..32415262 --- /dev/null +++ b/tools/json2cpp/templates/messages/MessagesValidator.cpp.j2 @@ -0,0 +1,133 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* Generated by json2cpp */ + +#include "MessagesValidator20.h" +#include "Logger.h" + +{%- for msg_name in csms_msgs %} +#include "{{msg_name}}{{ocpp_version_suffix}}.h" +{%- endfor %} +{%- for msg_name in cs_msgs %} +#include "{{msg_name}}{{ocpp_version_suffix}}.h" +{%- endfor %} + +namespace ocpp +{ +namespace messages +{ +namespace {{ocpp_version_namespace}} +{ + +/** @brief Constructor */ +MessagesValidator20::MessagesValidator20() : m_req_validators(), m_resp_validators() { } + +/** @brief Destructor */ +MessagesValidator20::~MessagesValidator20() { } + +/** @brief Load the messages validators */ +bool MessagesValidator20::load(const std::string& schemas_path) +{ + bool ret = true; + + // Load validators for all the messages + m_req_validators.clear(); + m_resp_validators.clear(); + {%- for msg_name in csms_msgs %} + ret = addValidator(schemas_path, {{msg_name.upper()}}_ACTION) && ret; + {%- endfor %} + {%- for msg_name in cs_msgs %} + ret = addValidator(schemas_path, {{msg_name.upper()}}_ACTION) && ret; + {%- endfor %} + + return ret; +} + +/** @brief Get the message validator corresponding to a given action */ +ocpp::json::JsonValidator* MessagesValidator20::getValidator(const std::string& action, bool is_req) const +{ + ocpp::json::JsonValidator* validator = nullptr; + + // Get validators list + const std::unordered_map>* validators = &m_resp_validators; + if (is_req) + { + validators = &m_req_validators; + } + + auto iter = validators->find(action); + if (iter != validators->cend()) + { + validator = iter->second.get(); + } + + return validator; +} + +/** @brief Add a message validator for both request and response */ +bool MessagesValidator20::addValidator(const std::string& schemas_path, const std::string& action) +{ + bool ret; + + // Add validator for request + std::filesystem::path req_filepath(schemas_path); + req_filepath.append(action + "Request.json"); + ret = addValidator(req_filepath, action, true); + + // Add validator for response + std::filesystem::path resp_filepath(schemas_path); + resp_filepath.append(action + "Response.json"); + ret = addValidator(resp_filepath, action, false) && ret; + + return ret; +} +/** @brief Add a message validator */ +bool MessagesValidator20::addValidator(const std::filesystem::path& validator_path, const std::string& action, bool is_req) +{ + bool ret = false; + + // Load validator + std::shared_ptr validator = std::make_shared(); + if (validator->init(validator_path.string())) + { + LOG_DEBUG << "[" << action << "] Validator loaded : " << validator_path; + + // Add validator + if (is_req) + { + m_req_validators[action] = validator; + } + else + { + m_resp_validators[action] = validator; + } + + ret = true; + } + else + { + LOG_ERROR << "[" << action << "] Unable to load validator : " << validator_path; + } + + return ret; +} + +} // namespace {{ocpp_version_namespace}} +} // namespace messages +} // namespace ocpp diff --git a/tools/json2cpp/templates/messages/msg_header.template.j2 b/tools/json2cpp/templates/messages/msg_header.template.j2 new file mode 100644 index 00000000..8f9d7c4f --- /dev/null +++ b/tools/json2cpp/templates/messages/msg_header.template.j2 @@ -0,0 +1,63 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : {{msg.id}} + {{msg.comment}} +*/ + +#ifndef OPENOCPP_{{ocpp_version_namespace.upper()}}_{{msg.name.upper()}}_H +#define OPENOCPP_{{ocpp_version_namespace.upper()}}_{{msg.name.upper()}}_H + +#include "IMessageConverter.h" +{% for dependency in msg.requires %} +#include "{{dependency}}{{ocpp_version_suffix}}.h" +{%- endfor %} + +namespace ocpp +{ +namespace messages +{ +namespace {{ocpp_version_namespace}} +{ + +/** @brief Action corresponding to the {{msg.name}} messages */ +static const std::string {{msg.name.upper()}}_ACTION = "{{msg.name}}"; + +{%- for msg_name in msg.types %} +{%- set type = msg.types[msg_name] %} + +/** @brief {{msg_name}} message */ +struct {{msg_name}} +{ + {%- for field in type.fields.values() %} + /** @brief {{field.comment.strip().strip('\n').strip('\r')}} */ + {{field.cpp_type(ocpp_version_namespace)}} {{field.name}}; + {%- endfor %} +}; + +{%- endfor %} + +// Message converters +MESSAGE_CONVERTERS({{msg.name}}) + +} // namespace {{ocpp_version_namespace}} +} // namespace messages +} // namespace ocpp + +#endif // OPENOCPP_{{ocpp_version_namespace.upper()}}_{{msg.name.upper()}}_H diff --git a/tools/json2cpp/templates/messages/msg_impl.template.j2 b/tools/json2cpp/templates/messages/msg_impl.template.j2 new file mode 100644 index 00000000..603ca88b --- /dev/null +++ b/tools/json2cpp/templates/messages/msg_impl.template.j2 @@ -0,0 +1,202 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : {{msg.id}} + {{msg.comment}} +*/ + +#include "{{msg.name}}{{ocpp_version_suffix}}.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace messages +{ +namespace {{ocpp_version_namespace}} +{ + +{%- for msg_name in msg.types %} +{%- set type = msg.types[msg_name] %} + +/** @brief Convert a {{msg_name}} from a JSON representation */ +bool {{msg_name}}Converter::fromJson(const rapidjson::Value& json, + {{msg_name}}& data, + std::string& error_code, + std::string& error_message) +{ + bool ret = true; + + {%- for field in type.fields.values() %} + + // {{field.name}} + + {%- if field.type in other_types %} + + {%- if not field.is_required %} + if (json.HasMember("{{field.name}}")) + { + {%- endif %} + + {%- if other_types[field.type].basic_type == "enum" %} + data.{{field.name}} = ocpp::types::{{ocpp_version_namespace}}::{{field.type}}Helper.fromString(json["{{field.name}}"].GetString()); + {%- else %} + ocpp::types::{{ocpp_version_namespace}}::{{field.type}}Converter {{field.name}}_converter; + ret = ret && {{field.name}}_converter.fromJson(json["{{field.name}}"], data.{{field.name}}, error_code, error_message); + {%- endif %} + + {%- if not field.is_required %} + } + {%- endif %} + + {%- elif field.type == "array" %} + if (json.HasMember("{{field.name}}")) + { + const rapidjson::Value& {{field.name}}_json = json["{{field.name}}"]; + + {%- if field.array_type in other_types %} + {%- if other_types[field.array_type].basic_type == "enum" %} + for (auto it = {{field.name}}_json.Begin(); ret && (it != {{field.name}}_json.End()); ++it) + { + ocpp::types::{{ocpp_version_namespace}}::{{field.array_type}}& item = data.{{field.name}}.emplace_back(); + item = ocpp::types::{{ocpp_version_namespace}}::{{field.array_type}}Helper.fromString(it->GetString()); + } + {%- else %} + ocpp::types::{{ocpp_version_namespace}}::{{field.array_type}}Converter {{field.name}}_converter; + for (auto it = {{field.name}}_json.Begin(); ret && (it != {{field.name}}_json.End()); ++it) + { + ocpp::types::{{ocpp_version_namespace}}::{{field.array_type}}& item = data.{{field.name}}.emplace_back(); + ret = ret && {{field.name}}_converter.fromJson(*it, item, error_code, error_message); + } + {%- endif %} + {%- else %} + for (auto it = {{field.name}}_json.Begin(); ret && (it != {{field.name}}_json.End()); ++it) + { + {{field.get_cpp_type(field.array_type, ocpp_version_namespace)}}& item = data.{{field.name}}.emplace_back(); + {%- if field.get_cpp_type(field.array_type, ocpp_version_namespace) == "std::string" %} + item = it->GetString(); + {%- else %} + item = it->GetInt(); + {%- endif %} + } + {%- endif %} + } + + + {%- elif field.type == "date-time" %} + ret = ret && extract(json, "{{field.name}}", data.{{field.name}}, error_message); + + {%- else %} + extract(json, "{{field.name}}", data.{{field.name}}); + {%- endif %} + + {%- endfor %} + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a {{msg_name}} to a JSON representation */ +bool {{msg_name}}Converter::toJson(const {{msg_name}}& data, rapidjson::Document& json) +{ + bool ret = true; + + {%- for field in type.fields.values() %} + + // {{field.name}} + + {%- if field.type in other_types %} + + {%- if not field.is_required %} + if (data.{{field.name}}.isSet()) + { + {%- endif %} + + {%- if other_types[field.type].basic_type == "enum" %} + fill(json, "{{field.name}}", ocpp::types::{{ocpp_version_namespace}}::{{field.type}}Helper.toString(data.{{field.name}})); + {%- else %} + ocpp::types::{{ocpp_version_namespace}}::{{field.type}}Converter {{field.name}}_converter; + {{field.name}}_converter.setAllocator(allocator); + rapidjson::Document {{field.name}}_doc(rapidjson::kObjectType); + ret = ret && {{field.name}}_converter.toJson(data.{{field.name}}, {{field.name}}_doc); + json.AddMember(rapidjson::StringRef("{{field.name}}"), {{field.name}}_doc.Move(), *allocator); + {%- endif %} + + {%- if not field.is_required %} + } + {%- endif %} + + {%- elif field.type == "array" %} + + {%- if not field.is_required %} + if (!data.{{field.name}}.empty()) + { + {%- endif %} + + rapidjson::Value {{field.name}}_json(rapidjson::kArrayType); + {%- if field.array_type in other_types %} + {%- if other_types[field.array_type].basic_type == "enum" %} + for (const ocpp::types::{{ocpp_version_namespace}}::{{field.array_type}}& item : data.{{field.name}}) + { + {{field.name}}_json.PushBack(rapidjson::Value(ocpp::types::{{ocpp_version_namespace}}::{{field.array_type}}Helper.toString(item).c_str(), *allocator).Move(), *allocator); + } + {%- else %} + ocpp::types::{{ocpp_version_namespace}}::{{field.array_type}}Converter {{field.name}}_converter; + {{field.name}}_converter.setAllocator(allocator); + for (const ocpp::types::{{ocpp_version_namespace}}::{{field.array_type}}& item : data.{{field.name}}) + { + rapidjson::Document item_doc(rapidjson::kObjectType); + ret = ret && {{field.name}}_converter.toJson(item, item_doc); + {{field.name}}_json.PushBack(item_doc.Move(), *allocator); + } + {%- endif %} + {%- else %} + for (const {{field.get_cpp_type(field.array_type, ocpp_version_namespace)}}& item : data.{{field.name}}) + { + {%- if field.get_cpp_type(field.array_type, ocpp_version_namespace) == "std::string" %} + {{field.name}}_json.PushBack(rapidjson::Value(item.c_str(), *allocator).Move(), *allocator); + {%- else %} + {{field.name}}_json.PushBack(rapidjson::Value(item), *allocator); + {%- endif %} + } + {%- endif %} + json.AddMember(rapidjson::StringRef("{{field.name}}"), {{field.name}}_json.Move(), *allocator); + + {%- if not field.is_required %} + } + {%- endif %} + + {%- else %} + fill(json, "{{field.name}}", data.{{field.name}}); + {%- endif %} + + {%- endfor %} + + return ret; +} + +{%- endfor %} + +} // namespace {{ocpp_version_namespace}} +} // namespace messages +} // namespace ocpp diff --git a/tools/json2cpp/templates/types/enum_header.template.j2 b/tools/json2cpp/templates/types/enum_header.template.j2 new file mode 100644 index 00000000..a26dc5f8 --- /dev/null +++ b/tools/json2cpp/templates/types/enum_header.template.j2 @@ -0,0 +1,51 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : {{message.id}} + {{message.comment}} +*/ + +#ifndef OPENOCPP_{{ocpp_version_namespace.upper()}}_{{enum.name.upper()}}_H +#define OPENOCPP_{{ocpp_version_namespace.upper()}}_{{enum.name.upper()}}_H + +#include "EnumToStringFromString.h" + +namespace ocpp +{ +namespace types +{ +namespace {{ocpp_version_namespace}} +{ + +/** @brief {{enum.comment.strip().strip('\n').strip('\r')}} */ +enum class {{enum.name}} +{ + {%- for field in enum.fields %} + {{field.replace('-', '_').replace('.', '_')}}, + {%- endfor %} +}; + +/** @brief Helper to convert a {{enum.name}} enum to string */ +extern const EnumToStringFromString<{{enum.name}}> {{enum.name}}Helper; + +} // namespace {{ocpp_version_namespace}} +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_{{ocpp_version_namespace.upper()}}_{{enum.name.upper()}}_H diff --git a/tools/json2cpp/templates/types/enum_impl.template.j2 b/tools/json2cpp/templates/types/enum_impl.template.j2 new file mode 100644 index 00000000..43e61fc7 --- /dev/null +++ b/tools/json2cpp/templates/types/enum_impl.template.j2 @@ -0,0 +1,42 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : {{message.id}} + {{message.comment}} +*/ + +#include "{{enum.name}}{{ocpp_version_suffix}}.h" + +namespace ocpp +{ +namespace types +{ +namespace {{ocpp_version_namespace}} +{ + +/** @brief Helper to convert a {{enum.name}} enum to string */ +const EnumToStringFromString<{{enum.name}}> {{enum.name}}Helper = { + {%- for field in enum.fields %} + { {{enum.name}}::{{field.replace('-', '_').replace('.', '_')}}, "{{field}}" }, + {%- endfor %} +}; + +} // namespace {{ocpp_version_namespace}} +} // namespace types +} // namespace ocpp diff --git a/tools/json2cpp/templates/types/type_header.template.j2 b/tools/json2cpp/templates/types/type_header.template.j2 new file mode 100644 index 00000000..89211e48 --- /dev/null +++ b/tools/json2cpp/templates/types/type_header.template.j2 @@ -0,0 +1,72 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : {{message.id}} + {{message.comment}} +*/ + +#ifndef OPENOCPP_{{ocpp_version_namespace.upper()}}_{{type.name.upper()}}_H +#define OPENOCPP_{{ocpp_version_namespace.upper()}}_{{type.name.upper()}}_H + +{%for dependency in type.requires %} +#include "{{dependency}}{{ocpp_version_suffix}}.h" +{%- endfor %} +{%for dependency in type.cpp_dependencies() %} +#include {{dependency}} +{%- endfor %} +#include "IMessageConverter.h" + +namespace ocpp +{ +namespace types +{ +namespace {{ocpp_version_namespace}} +{ + +/** @brief {{type.comment}} */ +struct {{type.name}} +{ + {%- for field in type.fields.values() %} + /** @brief {{field.comment.strip().strip('\n').strip('\r')}} */ + {{field.cpp_type("")}} {{field.name}}; + {%- endfor %} +}; + +/** @brief Converter class for {{type.name}} type */ +class {{type.name}}Converter : public ocpp::messages::IMessageConverter<{{type.name}}> +{ + public: + /** @brief Clone the converter */ + ocpp::messages::IMessageConverter<{{type.name}}>* clone() const override { return new {{type.name}}Converter(); } + + /** @brief Convert a {{type.name}} from a JSON representation */ + bool fromJson(const rapidjson::Value& json, + {{type.name}}& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) override; + + /** @brief Convert a {{type.name}} to a JSON representation */ + bool toJson(const {{type.name}}& data, rapidjson::Document& json) override; +}; + +} // namespace {{ocpp_version_namespace}} +} // namespace types +} // namespace ocpp + +#endif // OPENOCPP_{{ocpp_version_namespace.upper()}}_{{type.name.upper()}}_H diff --git a/tools/json2cpp/templates/types/type_impl.template.j2 b/tools/json2cpp/templates/types/type_impl.template.j2 new file mode 100644 index 00000000..ed48bc84 --- /dev/null +++ b/tools/json2cpp/templates/types/type_impl.template.j2 @@ -0,0 +1,189 @@ +/* +Copyright (c) 2020 Cedric Jimenez +This file is part of OpenOCPP. + +OpenOCPP is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +OpenOCPP is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with OpenOCPP. If not, see . +*/ + +/* + Generated by json2cpp from : {{message.id}} + {{message.comment}} +*/ + +#include "{{type.name}}{{ocpp_version_suffix}}.h" + +#include "IRpc.h" + +namespace ocpp +{ +namespace types +{ +namespace {{ocpp_version_namespace}} +{ + +/** @brief Convert a {{type.name}} from a JSON representation */ +bool {{type.name}}Converter::fromJson(const rapidjson::Value& json, + {{type.name}}& data, + std::string& error_code, + [[maybe_unused]] std::string& error_message) +{ + bool ret = true; + + {%- for field in type.fields.values() %} + + // {{field.name}} + + {%- if field.type in other_types %} + + {%- if not field.is_required %} + if (json.HasMember("{{field.name}}")) + { + {%- endif %} + + {%- if other_types[field.type].basic_type == "enum" %} + data.{{field.name}} = {{field.type}}Helper.fromString(json["{{field.name}}"].GetString()); + {%- else %} + {{field.type}}Converter {{field.name}}_converter; + ret = ret && {{field.name}}_converter.fromJson(json["{{field.name}}"], data.{{field.name}}, error_code, error_message); + {%- endif %} + + {%- if not field.is_required %} + } + {%- endif %} + + {%- elif field.type == "array" %} + if (json.HasMember("{{field.name}}")) + { + const rapidjson::Value& {{field.name}}_json = json["{{field.name}}"]; + + {%- if field.array_type in other_types %} + {%- if other_types[field.array_type].basic_type == "enum" %} + for (auto it = {{field.name}}_json.Begin(); ret && (it != {{field.name}}_json.End()); ++it) + { + {{field.array_type}}& item = data.{{field.name}}.emplace_back(); + item = {{field.array_type}}Helper.fromString(it->GetString()); + } + {%- else %} + {{field.array_type}}Converter {{field.name}}_converter; + for (auto it = {{field.name}}_json.Begin(); ret && (it != {{field.name}}_json.End()); ++it) + { + {{field.array_type}}& item = data.{{field.name}}.emplace_back(); + ret = ret && {{field.name}}_converter.fromJson(*it, item, error_code, error_message); + } + {%- endif %} + {%- else %} + for (auto it = {{field.name}}_json.Begin(); ret && (it != {{field.name}}_json.End()); ++it) + { + {{field.get_cpp_type(field.array_type, "")}}& item = data.{{field.name}}.emplace_back(); + item = it->GetInt(); + } + {%- endif %} + } + + + {%- elif field.type == "date-time" %} + ret = ret && extract(json, "{{field.name}}", data.{{field.name}}, error_message); + + {%- else %} + extract(json, "{{field.name}}", data.{{field.name}}); + {%- endif %} + + {%- endfor %} + + if (!ret) + { + error_code = ocpp::rpc::IRpc::RPC_ERROR_TYPE_CONSTRAINT_VIOLATION; + } + + return ret; +} + +/** @brief Convert a {{type.name}} to a JSON representation */ +bool {{type.name}}Converter::toJson(const {{type.name}}& data, rapidjson::Document& json) +{ + bool ret = true; + + {%- for field in type.fields.values() %} + + // {{field.name}} + + {%- if field.type in other_types %} + + {%- if not field.is_required %} + if (data.{{field.name}}.isSet()) + { + {%- endif %} + + {%- if other_types[field.type].basic_type == "enum" %} + fill(json, "{{field.name}}", {{field.type}}Helper.toString(data.{{field.name}})); + {%- else %} + {{field.type}}Converter {{field.name}}_converter; + {{field.name}}_converter.setAllocator(allocator); + rapidjson::Document {{field.name}}_doc(rapidjson::kObjectType); + ret = ret && {{field.name}}_converter.toJson(data.{{field.name}}, {{field.name}}_doc); + json.AddMember(rapidjson::StringRef("{{field.name}}"), {{field.name}}_doc.Move(), *allocator); + {%- endif %} + + {%- if not field.is_required %} + } + {%- endif %} + + {%- elif field.type == "array" %} + + {%- if not field.is_required %} + if (!data.{{field.name}}.empty()) + { + {%- endif %} + + rapidjson::Value {{field.name}}_json(rapidjson::kArrayType); + {%- if field.array_type in other_types %} + {%- if other_types[field.array_type].basic_type == "enum" %} + for (const {{field.array_type}}& item : data.{{field.name}}) + { + {{field.name}}_json.PushBack(rapidjson::Value({{field.array_type}}Helper.toString(item).c_str(), *allocator).Move(), *allocator); + } + {%- else %} + {{field.array_type}}Converter {{field.name}}_converter; + {{field.name}}_converter.setAllocator(allocator); + for (const {{field.array_type}}& item : data.{{field.name}}) + { + rapidjson::Document item_doc(rapidjson::kObjectType); + ret = ret && {{field.name}}_converter.toJson(item, item_doc); + {{field.name}}_json.PushBack(item_doc.Move(), *allocator); + } + {%- endif %} + {%- else %} + for (const {{field.get_cpp_type(field.array_type, "")}}& item : data.{{field.name}}) + { + {{field.name}}_json.PushBack(rapidjson::Value(item), *allocator); + } + {%- endif %} + json.AddMember(rapidjson::StringRef("{{field.name}}"), {{field.name}}_json.Move(), *allocator); + + {%- if not field.is_required %} + } + {%- endif %} + + {%- else %} + fill(json, "{{field.name}}", data.{{field.name}}); + {%- endif %} + + {%- endfor %} + + return ret; +} + +} // namespace {{ocpp_version_namespace}} +} // namespace types +} // namespace ocpp