@@ -709,9 +709,14 @@ void ChargePoint::initialize(const std::map<int32_t, int32_t>& evse_connector_st
709
709
*this ->database_handler , this ->callbacks .set_charging_profiles_callback );
710
710
}
711
711
712
- this ->tariff_and_cost = std::make_unique<TariffAndCost>(
713
- *this ->message_dispatcher , *this ->device_model , *this ->evse_manager , *this ->meter_values ,
714
- this ->callbacks .set_display_message_callback , this ->callbacks .set_running_cost_callback , this ->io_service );
712
+ if (device_model->get_optional_value <bool >(ControllerComponentVariables::TariffCostCtrlrAvailableCost)
713
+ .value_or (false ) ||
714
+ device_model->get_optional_value <bool >(ControllerComponentVariables::TariffCostCtrlrAvailableTariff)
715
+ .value_or (false )) {
716
+ this ->tariff_and_cost = std::make_unique<TariffAndCost>(
717
+ *this ->message_dispatcher , *this ->device_model , *this ->evse_manager , *this ->meter_values ,
718
+ this ->callbacks .set_display_message_callback , this ->callbacks .set_running_cost_callback , this ->io_service );
719
+ }
715
720
716
721
Component ocpp_comm_ctrlr = {" OCPPCommCtrlr" };
717
722
Variable field_length = {" FieldLength" };
@@ -823,7 +828,12 @@ void ChargePoint::handle_message(const EnhancedMessage<v201::MessageType>& messa
823
828
}
824
829
break ;
825
830
case MessageType::CostUpdated:
826
- this ->tariff_and_cost ->handle_message (message);
831
+ if (this ->tariff_and_cost != nullptr ) {
832
+ this ->tariff_and_cost ->handle_message (message);
833
+ } else {
834
+ send_not_implemented_error (message.uniqueId , message.messageTypeId );
835
+ }
836
+
827
837
break ;
828
838
default :
829
839
send_not_implemented_error (message.uniqueId , message.messageTypeId );
@@ -1690,7 +1700,10 @@ void ChargePoint::handle_transaction_event_response(const EnhancedMessage<v201::
1690
1700
this ->callbacks .transaction_event_response_callback .value ()(original_msg, call_result.msg );
1691
1701
}
1692
1702
1693
- this ->tariff_and_cost ->handle_cost_and_tariff (call_result.msg , original_msg, message.message [CALLRESULT_PAYLOAD]);
1703
+ if (tariff_and_cost != nullptr ) {
1704
+ this ->tariff_and_cost ->handle_cost_and_tariff (call_result.msg , original_msg,
1705
+ message.message [CALLRESULT_PAYLOAD]);
1706
+ }
1694
1707
1695
1708
if (original_msg.eventType == TransactionEventEnum::Ended) {
1696
1709
// nothing to do for TransactionEventEnum::Ended
0 commit comments