3
3
4
4
#include < ocpp/v2/functional_blocks/tariff_and_cost.hpp>
5
5
6
- #include < ocpp/v2/functional_blocks/block_context.hpp>
7
6
#include < ocpp/v2/ctrlr_component_variables.hpp>
8
7
#include < ocpp/v2/device_model.hpp>
9
8
#include < ocpp/v2/evse_manager.hpp>
9
+ #include < ocpp/v2/functional_blocks/block_context.hpp>
10
10
#include < ocpp/v2/functional_blocks/meter_values.hpp>
11
11
12
12
#include < ocpp/v2/messages/CostUpdated.hpp>
13
13
14
14
const auto DEFAULT_PRICE_NUMBER_OF_DECIMALS = 3 ;
15
15
16
16
namespace ocpp ::v2 {
17
- TariffAndCost::TariffAndCost (const BlockContext & block_context, MeterValuesInterface& meter_values,
17
+ TariffAndCost::TariffAndCost (const BlockContext& block_context, MeterValuesInterface& meter_values,
18
18
std::optional<SetDisplayMessageCallback>& set_display_message_callback,
19
19
std::optional<SetRunningCostCallback>& set_running_cost_callback,
20
20
boost::asio::io_service& io_service) :
@@ -111,7 +111,8 @@ void TariffAndCost::handle_cost_and_tariff(const TransactionEventResponse& respo
111
111
if (/* custom_data.contains("vendorId") and
112
112
(custom_data.at("vendorId").get<std::string>() == "org.openchargealliance.org.qrcode") and */
113
113
custom_data.contains (" qrCodeText" ) and
114
- this ->context .device_model .get_optional_value <bool >(ControllerComponentVariables::DisplayMessageQRCodeDisplayCapable)
114
+ this ->context .device_model
115
+ .get_optional_value <bool >(ControllerComponentVariables::DisplayMessageQRCodeDisplayCapable)
115
116
.value_or (false )) {
116
117
running_cost.qr_code_text = custom_data.at (" qrCodeText" );
117
118
}
@@ -166,7 +167,8 @@ void TariffAndCost::handle_cost_and_tariff(const TransactionEventResponse& respo
166
167
}
167
168
168
169
const int number_of_decimals =
169
- this ->context .device_model .get_optional_value <int >(ControllerComponentVariables::NumberOfDecimalsForCostValues)
170
+ this ->context .device_model
171
+ .get_optional_value <int >(ControllerComponentVariables::NumberOfDecimalsForCostValues)
170
172
.value_or (DEFAULT_PRICE_NUMBER_OF_DECIMALS);
171
173
uint32_t decimals =
172
174
(number_of_decimals < 0 ? DEFAULT_PRICE_NUMBER_OF_DECIMALS : static_cast <uint32_t >(number_of_decimals));
@@ -209,7 +211,8 @@ void TariffAndCost::handle_costupdated_req(const Call<CostUpdatedRequest> call)
209
211
running_cost.cost = static_cast <double >(call.msg .totalCost );
210
212
running_cost.transaction_id = call.msg .transactionId ;
211
213
212
- std::optional<int32_t > transaction_evse_id = this ->context .evse_manager .get_transaction_evseid (running_cost.transaction_id );
214
+ std::optional<int32_t > transaction_evse_id =
215
+ this ->context .evse_manager .get_transaction_evseid (running_cost.transaction_id );
213
216
if (!transaction_evse_id.has_value ()) {
214
217
// We just put an error in the log as the spec does not define what to do here. It is not possible to return
215
218
// a 'Rejected' or something in that manner.
@@ -232,7 +235,8 @@ void TariffAndCost::handle_costupdated_req(const Call<CostUpdatedRequest> call)
232
235
return ;
233
236
}
234
237
235
- const std::optional<int32_t > evse_id_opt = this ->context .evse_manager .get_transaction_evseid (running_cost.transaction_id );
238
+ const std::optional<int32_t > evse_id_opt =
239
+ this ->context .evse_manager .get_transaction_evseid (running_cost.transaction_id );
236
240
if (!evse_id_opt.has_value ()) {
237
241
EVLOG_warning << " Can not set running cost triggers as there is no evse id found with the transaction id from "
238
242
" the incoming CostUpdatedRequest" ;
@@ -256,14 +260,17 @@ bool TariffAndCost::is_multilanguage_enabled() const {
256
260
}
257
261
258
262
bool TariffAndCost::is_tariff_enabled () const {
259
- return this ->context .device_model .get_optional_value <bool >(ControllerComponentVariables::TariffCostCtrlrAvailableTariff)
263
+ return this ->context .device_model
264
+ .get_optional_value <bool >(ControllerComponentVariables::TariffCostCtrlrAvailableTariff)
260
265
.value_or (false ) and
261
- this ->context .device_model .get_optional_value <bool >(ControllerComponentVariables::TariffCostCtrlrEnabledTariff)
266
+ this ->context .device_model
267
+ .get_optional_value <bool >(ControllerComponentVariables::TariffCostCtrlrEnabledTariff)
262
268
.value_or (false );
263
269
}
264
270
265
271
bool TariffAndCost::is_cost_enabled () const {
266
- return this ->context .device_model .get_optional_value <bool >(ControllerComponentVariables::TariffCostCtrlrAvailableCost)
272
+ return this ->context .device_model
273
+ .get_optional_value <bool >(ControllerComponentVariables::TariffCostCtrlrAvailableCost)
267
274
.value_or (false ) and
268
275
this ->context .device_model .get_optional_value <bool >(ControllerComponentVariables::TariffCostCtrlrEnabledCost)
269
276
.value_or (false );
0 commit comments