Skip to content

Commit 46cba52

Browse files
committed
Change 'BlockContext' to 'FunctionalBlockContext'. Add documentation.
Signed-off-by: Maaike Zijderveld, iolar <git.mail@iolar.nl>
1 parent 01dcc26 commit 46cba52

38 files changed

+229
-283
lines changed

include/ocpp/v2/charge_point.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class DeviceModel;
4949
class DeviceModelStorageInterface;
5050
class EvseManager;
5151

52-
struct BlockContext;
52+
struct FunctionalBlockContext;
5353

5454
class UnexpectedMessageTypeFromCSMS : public std::runtime_error {
5555
using std::runtime_error::runtime_error;
@@ -341,7 +341,7 @@ class ChargePoint : public ChargePointInterface, private ocpp::ChargingStationBa
341341
std::unique_ptr<MessageDispatcherInterface<MessageType>> message_dispatcher;
342342

343343
// Functional blocks
344-
std::unique_ptr<BlockContext> block_context;
344+
std::unique_ptr<FunctionalBlockContext> functional_block_context;
345345
std::unique_ptr<DataTransferInterface> data_transfer;
346346
std::unique_ptr<ReservationInterface> reservation;
347347
std::unique_ptr<AvailabilityInterface> availability;

include/ocpp/v2/functional_blocks/authorization.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include <ocpp/v2/message_handler.hpp>
77

88
namespace ocpp::v2 {
9-
struct BlockContext;
9+
struct FunctionalBlockContext;
1010
struct AuthorizationCacheEntry;
1111
struct AuthorizeResponse;
1212
struct ClearCacheRequest;
@@ -44,7 +44,7 @@ class AuthorizationInterface : public MessageHandlerInterface {
4444

4545
class Authorization : public AuthorizationInterface {
4646
private: // Members
47-
const BlockContext& context;
47+
const FunctionalBlockContext& context;
4848

4949
// threads and synchronization
5050
bool auth_cache_cleanup_required;
@@ -54,7 +54,7 @@ class Authorization : public AuthorizationInterface {
5454
std::atomic_bool auth_cache_cleanup_handler_running;
5555

5656
public:
57-
explicit Authorization(const BlockContext& context);
57+
explicit Authorization(const FunctionalBlockContext& context);
5858
~Authorization();
5959
void start_auth_cache_cleanup_thread() override;
6060
void handle_message(const ocpp::EnhancedMessage<MessageType>& message) override;

include/ocpp/v2/functional_blocks/availability.hpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include <ocpp/v2/messages/ChangeAvailability.hpp>
99

1010
namespace ocpp::v2 {
11-
struct BlockContext;
11+
struct FunctionalBlockContext;
1212

1313
struct HeartbeatResponse;
1414

@@ -75,7 +75,7 @@ typedef std::function<void()> AllConnectorsUnavailableCallback;
7575

7676
class Availability : public AvailabilityInterface {
7777
private: // Members
78-
const BlockContext& context;
78+
const FunctionalBlockContext& context;
7979

8080
std::optional<TimeSyncCallback> time_sync_callback;
8181
std::optional<AllConnectorsUnavailableCallback> all_connectors_unavailable_callback;
@@ -86,7 +86,8 @@ class Availability : public AvailabilityInterface {
8686
Everest::SteadyTimer heartbeat_timer;
8787

8888
public:
89-
Availability(const BlockContext& block_context, std::optional<TimeSyncCallback> time_sync_callback,
89+
Availability(const FunctionalBlockContext& functional_block_context,
90+
std::optional<TimeSyncCallback> time_sync_callback,
9091
std::optional<AllConnectorsUnavailableCallback> all_connectors_unavailable_callback);
9192
~Availability();
9293
void handle_message(const ocpp::EnhancedMessage<MessageType>& message) override;

include/ocpp/v2/functional_blocks/data_transfer.hpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
namespace ocpp {
99
namespace v2 {
10-
struct BlockContext;
10+
struct FunctionalBlockContext;
1111
struct DataTransferRequest;
1212
struct DataTransferResponse;
1313

@@ -35,16 +35,16 @@ class DataTransferInterface : public MessageHandlerInterface {
3535
class DataTransfer : public DataTransferInterface {
3636

3737
private:
38-
const BlockContext& context;
38+
const FunctionalBlockContext& context;
3939
std::optional<std::function<DataTransferResponse(const DataTransferRequest& request)>> data_transfer_callback;
4040
std::chrono::seconds response_timeout;
4141

4242
public:
43-
DataTransfer(const BlockContext& block_context,
43+
DataTransfer(const FunctionalBlockContext& functional_block_context,
4444
const std::optional<std::function<DataTransferResponse(const DataTransferRequest& request)>>&
4545
data_transfer_callback,
4646
const std::chrono::seconds response_timeout) :
47-
context(block_context), data_transfer_callback(data_transfer_callback), response_timeout(response_timeout){};
47+
context(functional_block_context), data_transfer_callback(data_transfer_callback), response_timeout(response_timeout){};
4848

4949
void handle_message(const EnhancedMessage<MessageType>& message) override;
5050

include/ocpp/v2/functional_blocks/diagnostics.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
namespace ocpp::v2 {
1111
class AuthorizationInterface;
12-
struct BlockContext;
12+
struct FunctionalBlockContext;
1313

1414
struct GetLogRequest;
1515
struct GetLogResponse;
@@ -44,7 +44,7 @@ class DiagnosticsInterface : public MessageHandlerInterface {
4444

4545
class Diagnostics : public DiagnosticsInterface {
4646
public:
47-
Diagnostics(const BlockContext& context, AuthorizationInterface& authorization,
47+
Diagnostics(const FunctionalBlockContext& context, AuthorizationInterface& authorization,
4848
GetLogRequestCallback get_log_request_callback,
4949
std::optional<GetCustomerInformationCallback> get_customer_information_callback,
5050
std::optional<ClearCustomerInformationCallback> clear_customer_information_callback);
@@ -55,7 +55,7 @@ class Diagnostics : public DiagnosticsInterface {
5555
void process_triggered_monitors() override;
5656

5757
private: // Members
58-
const BlockContext& context;
58+
const FunctionalBlockContext& context;
5959
AuthorizationInterface& authorization;
6060
/// \brief Updater for triggered monitors
6161
MonitoringUpdater monitoring_updater;

include/ocpp/v2/functional_blocks/display_message.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include <ocpp/v2/messages/SetDisplayMessage.hpp>
99

1010
namespace ocpp::v2 {
11-
struct BlockContext;
11+
struct FunctionalBlockContext;
1212
struct GetDisplayMessagesRequest;
1313
struct ClearDisplayMessageResponse;
1414
struct ClearDisplayMessageRequest;
@@ -47,13 +47,13 @@ class DisplayMessageInterface : public MessageHandlerInterface {
4747
class DisplayMessageBlock : public DisplayMessageInterface {
4848

4949
public:
50-
DisplayMessageBlock(const BlockContext& block_context, GetDisplayMessageCallback get_display_message_callback,
50+
DisplayMessageBlock(const FunctionalBlockContext& functional_block_context, GetDisplayMessageCallback get_display_message_callback,
5151
SetDisplayMessageCallback set_display_message_callback,
5252
ClearDisplayMessageCallback clear_display_message_callback);
5353
virtual void handle_message(const ocpp::EnhancedMessage<MessageType>& message) override;
5454

5555
private:
56-
const BlockContext& context;
56+
const FunctionalBlockContext& context;
5757

5858
GetDisplayMessageCallback get_display_message_callback;
5959
SetDisplayMessageCallback set_display_message_callback;

include/ocpp/v2/functional_blocks/firmware_update.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
namespace ocpp::v2 {
99
// Formward declarations.
10-
struct BlockContext;
10+
struct FunctionalBlockContext;
1111
class AvailabilityInterface;
1212
class SecurityInterface;
1313

@@ -29,7 +29,7 @@ class FirmwareUpdateInterface : public MessageHandlerInterface {
2929

3030
class FirmwareUpdate : public FirmwareUpdateInterface {
3131
private: // Members
32-
const BlockContext& context;
32+
const FunctionalBlockContext& context;
3333
AvailabilityInterface& availability;
3434
SecurityInterface& security;
3535

@@ -43,7 +43,7 @@ class FirmwareUpdate : public FirmwareUpdateInterface {
4343
FirmwareStatusEnum firmware_status_before_installing = FirmwareStatusEnum::SignatureVerified;
4444

4545
public:
46-
FirmwareUpdate(const BlockContext& block_context, AvailabilityInterface& availability, SecurityInterface& security,
46+
FirmwareUpdate(const FunctionalBlockContext& functional_block_context, AvailabilityInterface& availability, SecurityInterface& security,
4747
UpdateFirmwareRequestCallback update_firmware_request_callback,
4848
std::optional<AllConnectorsUnavailableCallback> all_connectors_unavailable_callback);
4949
void handle_message(const ocpp::EnhancedMessage<MessageType>& message) override;

include/ocpp/v2/functional_blocks/block_context.hpp include/ocpp/v2/functional_blocks/functional_block_context.hpp

+9-5
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ class EvseManagerInterface;
1616
class DatabaseHandlerInterface;
1717
class ComponentStateManagerInterface;
1818

19-
struct BlockContext {
19+
/// \brief Context / requirements for the functional blocks.
20+
///
21+
/// All functional blocks will get this context. The references and pointers in this struct are used by all or most
22+
/// functional blocks.
23+
struct FunctionalBlockContext {
2024
MessageDispatcherInterface<MessageType>& message_dispatcher;
2125
DeviceModel& device_model;
2226
ConnectivityManagerInterface& connectivity_manager;
@@ -25,10 +29,10 @@ struct BlockContext {
2529
EvseSecurity& evse_security;
2630
ComponentStateManagerInterface& component_state_manager;
2731

28-
BlockContext(MessageDispatcherInterface<MessageType>& message_dispatcher, DeviceModel& device_model,
29-
ConnectivityManagerInterface& connectivity_manager, EvseManagerInterface& evse_manager,
30-
DatabaseHandlerInterface& database_handler, EvseSecurity& evse_security,
31-
ComponentStateManagerInterface& component_state_manager) :
32+
FunctionalBlockContext(MessageDispatcherInterface<MessageType>& message_dispatcher, DeviceModel& device_model,
33+
ConnectivityManagerInterface& connectivity_manager, EvseManagerInterface& evse_manager,
34+
DatabaseHandlerInterface& database_handler, EvseSecurity& evse_security,
35+
ComponentStateManagerInterface& component_state_manager) :
3236
message_dispatcher(message_dispatcher),
3337
device_model(device_model),
3438
connectivity_manager(connectivity_manager),

include/ocpp/v2/functional_blocks/meter_values.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <ocpp/v2/average_meter_values.hpp>
1010

1111
namespace ocpp::v2 {
12-
struct BlockContext;
12+
struct FunctionalBlockContext;
1313

1414
class MeterValuesInterface : public MessageHandlerInterface {
1515
public:
@@ -29,7 +29,7 @@ class MeterValuesInterface : public MessageHandlerInterface {
2929
class MeterValues : public MeterValuesInterface {
3030
public:
3131
virtual ~MeterValues() override = default;
32-
explicit MeterValues(const BlockContext& block_context);
32+
explicit MeterValues(const FunctionalBlockContext& functional_block_context);
3333
void handle_message(const ocpp::EnhancedMessage<MessageType>& message) override;
3434
void update_aligned_data_interval() override;
3535
void on_meter_value(const int32_t evse_id, const MeterValue& meter_value) override;
@@ -40,7 +40,7 @@ class MeterValues : public MeterValuesInterface {
4040
const bool initiated_by_trigger_message = false) override;
4141

4242
private: // Members
43-
const BlockContext& context;
43+
const FunctionalBlockContext& context;
4444

4545
ClockAlignedTimer aligned_meter_values_timer;
4646
AverageMeterValues aligned_data_evse0; // represents evseId = 0 meter value

include/ocpp/v2/functional_blocks/provisioning.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include <ocpp/v2/message_handler.hpp>
77

88
namespace ocpp::v2 {
9-
struct BlockContext;
9+
struct FunctionalBlockContext;
1010
class OcspUpdaterInterface;
1111

1212
class AvailabilityInterface;
@@ -64,7 +64,7 @@ class ProvisioningInterface : public MessageHandlerInterface {
6464

6565
class Provisioning : public ProvisioningInterface {
6666
public:
67-
Provisioning(const BlockContext& block_context, MessageQueue<v2::MessageType>& message_queue,
67+
Provisioning(const FunctionalBlockContext& functional_block_context, MessageQueue<v2::MessageType>& message_queue,
6868
OcspUpdaterInterface& ocsp_updater, AvailabilityInterface& availability,
6969
MeterValuesInterface& meter_values, SecurityInterface& security, DiagnosticsInterface& diagnostics,
7070
TransactionInterface& transaction, std::optional<TimeSyncCallback> time_sync_callback,
@@ -84,7 +84,7 @@ class Provisioning : public ProvisioningInterface {
8484
set_variables(const std::vector<SetVariableData>& set_variable_data_vector, const std::string& source) override;
8585

8686
private: // Members
87-
const BlockContext& context;
87+
const FunctionalBlockContext& context;
8888
MessageQueue<v2::MessageType>& message_queue;
8989
OcspUpdaterInterface& ocsp_updater;
9090

include/ocpp/v2/functional_blocks/remote_transaction_control.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include <ocpp/v2/message_handler.hpp>
77

88
namespace ocpp::v2 {
9-
struct BlockContext;
9+
struct FunctionalBlockContext;
1010
class EvseInterface;
1111

1212
class TransactionInterface;
@@ -39,7 +39,7 @@ class RemoteTransactionControlInterface : public MessageHandlerInterface {
3939

4040
class RemoteTransactionControl : public RemoteTransactionControlInterface {
4141
public:
42-
RemoteTransactionControl(const BlockContext& block_context, TransactionInterface& transaction,
42+
RemoteTransactionControl(const FunctionalBlockContext& functional_block_context, TransactionInterface& transaction,
4343
SmartChargingInterface& smart_charging, MeterValuesInterface& meter_values,
4444
AvailabilityInterface& availability, FirmwareUpdateInterface& firmware_update,
4545
SecurityInterface& security, ReservationInterface* reservation,
@@ -52,7 +52,7 @@ class RemoteTransactionControl : public RemoteTransactionControlInterface {
5252
void handle_message(const ocpp::EnhancedMessage<MessageType>& message) override;
5353

5454
private: // Members
55-
const BlockContext& context;
55+
const FunctionalBlockContext& context;
5656

5757
TransactionInterface& transaction;
5858
SmartChargingInterface& smart_charging;

include/ocpp/v2/functional_blocks/reservation.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#pragma once
77

88
namespace ocpp::v2 {
9-
struct BlockContext;
9+
struct FunctionalBlockContext;
1010
class EvseInterface;
1111

1212
struct ReserveNowRequest;
@@ -31,7 +31,7 @@ class ReservationInterface : public MessageHandlerInterface {
3131

3232
class Reservation : public ReservationInterface {
3333
private: // Members
34-
const BlockContext& context;
34+
const FunctionalBlockContext& context;
3535

3636
/// \brief Callback function is called when a reservation request is received from the CSMS
3737
ReserveNowCallback reserve_now_callback;
@@ -44,7 +44,7 @@ class Reservation : public ReservationInterface {
4444
IsReservationForTokenCallback is_reservation_for_token_callback;
4545

4646
public:
47-
Reservation(const BlockContext& block_context, ReserveNowCallback reserve_now_callback,
47+
Reservation(const FunctionalBlockContext& functional_block_context, ReserveNowCallback reserve_now_callback,
4848
CancelReservationCallback cancel_reservation_callback,
4949
const IsReservationForTokenCallback is_reservation_for_token_callback);
5050
virtual void handle_message(const ocpp::EnhancedMessage<MessageType>& message) override;

include/ocpp/v2/functional_blocks/security.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace ocpp {
1212
class MessageLogging;
1313

1414
namespace v2 {
15-
struct BlockContext;
15+
struct FunctionalBlockContext;
1616

1717
struct CertificateSignedRequest;
1818
struct CertificateSignedResponse;
@@ -47,7 +47,7 @@ class SecurityInterface : public MessageHandlerInterface {
4747

4848
class Security : public SecurityInterface {
4949
public:
50-
Security(const BlockContext& block_context, MessageLogging& logging, OcspUpdaterInterface& ocsp_updater,
50+
Security(const FunctionalBlockContext& functional_block_context, MessageLogging& logging, OcspUpdaterInterface& ocsp_updater,
5151
SecurityEventCallback security_event_callback);
5252
virtual ~Security();
5353
void handle_message(const EnhancedMessage<MessageType>& message) override;
@@ -66,7 +66,7 @@ class Security : public SecurityInterface {
6666
const bool initiated_by_trigger_message = false) override;
6767

6868
private: // Members
69-
const BlockContext& context;
69+
const FunctionalBlockContext& context;
7070
MessageLogging& logging;
7171
OcspUpdaterInterface& ocsp_updater;
7272

include/ocpp/v2/functional_blocks/smart_charging.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include <ocpp/v2/evse.hpp>
99

1010
namespace ocpp::v2 {
11-
struct BlockContext;
11+
struct FunctionalBlockContext;
1212
class SmartChargingHandlerInterface;
1313

1414
struct GetChargingProfilesRequest;
@@ -121,11 +121,11 @@ class SmartChargingInterface : public MessageHandlerInterface {
121121

122122
class SmartCharging : public SmartChargingInterface {
123123
private: // Members
124-
const BlockContext& context;
124+
const FunctionalBlockContext& context;
125125
std::function<void()> set_charging_profiles_callback;
126126

127127
public:
128-
SmartCharging(const BlockContext& block_context, std::function<void()> set_charging_profiles_callback);
128+
SmartCharging(const FunctionalBlockContext& functional_block_context, std::function<void()> set_charging_profiles_callback);
129129
void handle_message(const ocpp::EnhancedMessage<MessageType>& message) override;
130130
GetCompositeScheduleResponse get_composite_schedule(const GetCompositeScheduleRequest& request) override;
131131
std::optional<CompositeSchedule> get_composite_schedule(int32_t evse_id, std::chrono::seconds duration,

include/ocpp/v2/functional_blocks/tariff_and_cost.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include <ocpp/v2/functional_blocks/display_message.hpp>
99

1010
namespace ocpp::v2 {
11-
struct BlockContext;
11+
struct FunctionalBlockContext;
1212
class MeterValuesInterface;
1313

1414
struct CostUpdatedRequest;
@@ -34,7 +34,7 @@ class TariffAndCostInterface : public MessageHandlerInterface {
3434

3535
class TariffAndCost : public TariffAndCostInterface {
3636
public:
37-
TariffAndCost(const BlockContext& block_context, MeterValuesInterface& meter_values,
37+
TariffAndCost(const FunctionalBlockContext& functional_block_context, MeterValuesInterface& meter_values,
3838
std::optional<SetDisplayMessageCallback>& set_display_message_callback,
3939
std::optional<SetRunningCostCallback>& set_running_cost_callback,
4040
boost::asio::io_service& io_service);
@@ -45,7 +45,7 @@ class TariffAndCost : public TariffAndCostInterface {
4545
const json& original_transaction_event_response) override;
4646

4747
private: // Members
48-
const BlockContext& context;
48+
const FunctionalBlockContext& context;
4949
MeterValuesInterface& meter_values;
5050
std::optional<SetDisplayMessageCallback> set_display_message_callback;
5151
std::optional<SetRunningCostCallback> set_running_cost_callback;

0 commit comments

Comments
 (0)