-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added new class MessageDispatcherInterface that can dispatch OCPP Call, CallResult, CallError * MessageDispatcherInterface became member of ChargePoint classes. The templated methods for sending/dispatching Call, CallResult, CallError have been moved from ChargePoint classes to MessageDispatcher Signed-off-by: Piet Gömpel <[email protected]>
- Loading branch information
Showing
17 changed files
with
497 additions
and
303 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
|
||
@startuml | ||
|
||
interface MessageDispatcherInterface { | ||
+dispatch_call(const json& call, bool triggered = false) | ||
+dispatch_call_async(const json& call, bool triggered = false): std::future<EnhancedMessage<T>> | ||
+dispatch_call_result(const json& call_result) | ||
+dispatch_call_error(const json& call_error) | ||
} | ||
|
||
class v16::MessageDispatcher { | ||
- MessageQueue& message_queue | ||
- ChargePointConfiguration& configuration | ||
- RegistrationStatus& registration_status | ||
} | ||
|
||
class v201::MessageDispatcher { | ||
- MessageQueue& message_queue | ||
- DeviceModel& device_model | ||
- ConnectivityManager& connectivity_manager | ||
- RegistrationStatusEnum& registration_status | ||
} | ||
|
||
interface v201::DataTransferInterface { | ||
+data_transfer_req(request: DataTransferRequest): std::optional<DataTransferResponse> | ||
+handle_data_transfer_req(call: Call<DataTransferRequest>) | ||
} | ||
|
||
class v201::DataTransfer { | ||
-MessageDispatcherInterface &message_dispatcher | ||
-std::optional<std::function<DataTransferResponse(DataTransferRequest)>> data_transfer_callback | ||
} | ||
|
||
class v201::ChargePoint { | ||
std::unique_ptr<MessageDispatcherInterface> message_dispatcher; | ||
std::unique_ptr<v201::DataTransferInterface> data_transfer; | ||
} | ||
|
||
class v16::ChargePoint { | ||
std::unique_ptr<MessageDispatcherInterface> message_dispatcher; | ||
} | ||
|
||
MessageDispatcherInterface <|-- v16::MessageDispatcher | ||
MessageDispatcherInterface <|-- v201::MessageDispatcher | ||
v201::DataTransferInterface <|-- v201::DataTransfer | ||
MessageDispatcherInterface *-- v201::DataTransfer | ||
MessageDispatcherInterface *-- v201::ChargePoint | ||
v201::DataTransferInterface *-- v201::ChargePoint | ||
MessageDispatcherInterface *-- v16::ChargePoint | ||
|
||
@enduml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Copyright Pionix GmbH and Contributors to EVerest | ||
|
||
#pragma once | ||
|
||
#include <ocpp/common/message_queue.hpp> | ||
|
||
namespace ocpp { | ||
|
||
/// \brief Interface for dispatching OCPP messages that shall be send over the websocket. This interface defines | ||
/// dispatching of Call, CallResult and CallError messages. | ||
/// \tparam T Type specifies the OCPP protocol version | ||
template <typename T> class MessageDispatcherInterface { | ||
|
||
public: | ||
virtual ~MessageDispatcherInterface(){}; | ||
|
||
/// \brief Dispatches a Call message. | ||
/// \param call the OCPP Call message. | ||
/// \param triggered indicates if the call was triggered by a TriggerMessage. Default is false. | ||
virtual void dispatch_call(const json& call, bool triggered = false) = 0; | ||
|
||
/// \brief Dispatches a Call message asynchronously. | ||
/// \param call the OCPP Call message. | ||
/// \param triggered indicates if the call was triggered by a TriggerMessage. Default is false. | ||
/// \return std::future<ocpp::EnhancedMessage<T>> Future object containing the enhanced message | ||
/// result of type T. | ||
virtual std::future<ocpp::EnhancedMessage<T>> dispatch_call_async(const json& call, bool triggered = false) = 0; | ||
|
||
/// \brief Dispatches a CallResult message. | ||
/// \param call_result the OCPP CallResult message. | ||
virtual void dispatch_call_result(const json& call_result) = 0; | ||
|
||
/// \brief Dispatches a CallError message. | ||
/// \param call_result the OCPP CallError message. | ||
virtual void dispatch_call_error(const json& call_error) = 0; | ||
}; | ||
|
||
} // namespace ocpp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Copyright Pionix GmbH and Contributors to EVerest | ||
|
||
#pragma once | ||
|
||
#include <ocpp/common/message_dispatcher.hpp> | ||
#include <ocpp/v16/charge_point_configuration.hpp> | ||
|
||
namespace ocpp { | ||
namespace v16 { | ||
|
||
class MessageDispatcher : public MessageDispatcherInterface<MessageType> { | ||
|
||
public: | ||
MessageDispatcher(ocpp::MessageQueue<MessageType>& message_queue, ChargePointConfiguration& configuration, | ||
std::atomic<RegistrationStatus>& registration_status) : | ||
message_queue(message_queue), configuration(configuration), registration_status(registration_status){}; | ||
void dispatch_call(const json& call, bool triggered = false) override; | ||
std::future<ocpp::EnhancedMessage<MessageType>> dispatch_call_async(const json& call, bool triggered) override; | ||
void dispatch_call_result(const json& call_result) override; | ||
void dispatch_call_error(const json& call_error) override; | ||
|
||
private: | ||
ocpp::MessageQueue<MessageType>& message_queue; | ||
ChargePointConfiguration& configuration; | ||
std::atomic<RegistrationStatus>& registration_status; | ||
}; | ||
|
||
} // namespace v16 | ||
} // namespace ocpp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Copyright Pionix GmbH and Contributors to EVerest | ||
|
||
#pragma once | ||
|
||
#include <ocpp/common/message_dispatcher.hpp> | ||
#include <ocpp/v201/connectivity_manager.hpp> | ||
#include <ocpp/v201/device_model.hpp> | ||
|
||
namespace ocpp { | ||
namespace v201 { | ||
|
||
class MessageDispatcher : public MessageDispatcherInterface<MessageType> { | ||
|
||
public: | ||
MessageDispatcher(ocpp::MessageQueue<MessageType>& message_queue, DeviceModel& device_model, | ||
std::atomic<RegistrationStatusEnum>& registration_status) : | ||
message_queue(message_queue), device_model(device_model), registration_status(registration_status){}; | ||
void dispatch_call(const json& call, bool triggered = false) override; | ||
std::future<ocpp::EnhancedMessage<MessageType>> dispatch_call_async(const json& call, bool triggered) override; | ||
void dispatch_call_result(const json& call_result) override; | ||
void dispatch_call_error(const json& call_error) override; | ||
|
||
private: | ||
ocpp::MessageQueue<MessageType>& message_queue; | ||
DeviceModel& device_model; | ||
std::atomic<RegistrationStatusEnum>& registration_status; | ||
}; | ||
|
||
} // namespace v201 | ||
} // namespace ocpp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.