@@ -100,7 +100,10 @@ void ChargePoint::start(BootReasonEnum bootreason, bool start_connecting) {
100
100
this ->message_queue ->get_persisted_messages_from_db ();
101
101
this ->boot_notification_req (bootreason);
102
102
// call clear_invalid_charging_profiles when system boots
103
- this ->clear_invalid_charging_profiles ();
103
+ if (this ->smart_charging != nullptr ) {
104
+ this ->clear_invalid_charging_profiles ();
105
+ }
106
+
104
107
if (start_connecting) {
105
108
this ->connectivity_manager ->connect ();
106
109
}
@@ -306,7 +309,9 @@ void ChargePoint::on_transaction_finished(const int32_t evse_id, const DateTime&
306
309
transaction_id_token, meter_values, std::nullopt, this ->is_offline (), std::nullopt);
307
310
308
311
// K02.FR.05 The transaction is over, so delete the TxProfiles associated with the transaction.
309
- smart_charging->delete_transaction_tx_profiles (enhanced_transaction->get_transaction ().transactionId );
312
+ if (smart_charging != nullptr ) {
313
+ smart_charging->delete_transaction_tx_profiles (enhanced_transaction->get_transaction ().transactionId );
314
+ }
310
315
evse_handle.release_transaction ();
311
316
312
317
bool send_reset = false ;
@@ -697,9 +702,12 @@ void ChargePoint::initialize(const std::map<int32_t, int32_t>& evse_connector_st
697
702
this ->callbacks .configure_network_connection_profile_callback .value ());
698
703
}
699
704
700
- this ->smart_charging = std::make_unique<SmartCharging>(
701
- *this ->device_model , *this ->evse_manager , *this ->connectivity_manager , *this ->message_dispatcher ,
702
- *this ->database_handler , this ->callbacks .set_charging_profiles_callback );
705
+ if (device_model->get_optional_value <bool >(ControllerComponentVariables::SmartChargingCtrlrAvailable)
706
+ .value_or (false )) {
707
+ this ->smart_charging = std::make_unique<SmartCharging>(
708
+ *this ->device_model , *this ->evse_manager , *this ->connectivity_manager , *this ->message_dispatcher ,
709
+ *this ->database_handler , this ->callbacks .set_charging_profiles_callback );
710
+ }
703
711
704
712
this ->tariff_and_cost = std::make_unique<TariffAndCost>(
705
713
*this ->message_dispatcher , *this ->device_model , *this ->evse_manager , *this ->meter_values ,
@@ -799,7 +807,11 @@ void ChargePoint::handle_message(const EnhancedMessage<v201::MessageType>& messa
799
807
case MessageType::ClearChargingProfile:
800
808
case MessageType::GetChargingProfiles:
801
809
case MessageType::GetCompositeSchedule:
802
- this ->smart_charging ->handle_message (message);
810
+ if (this ->smart_charging != nullptr ) {
811
+ this ->smart_charging ->handle_message (message);
812
+ } else {
813
+ send_not_implemented_error (message.uniqueId , message.messageTypeId );
814
+ }
803
815
break ;
804
816
case MessageType::GetDisplayMessages:
805
817
case MessageType::SetDisplayMessage:
@@ -2036,9 +2048,12 @@ void ChargePoint::handle_remote_start_transaction_request(Call<RequestStartTrans
2036
2048
// with RequestStartTransactionResponse with status = Rejected and optionally with reasonCode =
2037
2049
// "InvalidProfile" or "InvalidSchedule".
2038
2050
2039
- bool is_smart_charging_enabled =
2051
+ const bool is_smart_charging_enabled =
2052
+ this ->device_model ->get_optional_value <bool >(ControllerComponentVariables::SmartChargingCtrlrAvailable)
2053
+ .value_or (false ) &&
2040
2054
this ->device_model ->get_optional_value <bool >(ControllerComponentVariables::SmartChargingCtrlrEnabled)
2041
- .value_or (false );
2055
+ .value_or (false ) &&
2056
+ this ->smart_charging != nullptr ;
2042
2057
2043
2058
if (is_smart_charging_enabled) {
2044
2059
if (msg.chargingProfile .has_value ()) {
@@ -2256,8 +2271,9 @@ void ChargePoint::clear_invalid_charging_profiles() {
2256
2271
for (const auto & [evse_id, profiles] : evses) {
2257
2272
for (auto profile : profiles) {
2258
2273
try {
2259
- if (this ->smart_charging ->conform_and_validate_profile (profile, evse_id) !=
2260
- ProfileValidationResultEnum::Valid) {
2274
+ if (this ->smart_charging != nullptr &&
2275
+ this ->smart_charging ->conform_and_validate_profile (profile, evse_id) !=
2276
+ ProfileValidationResultEnum::Valid) {
2261
2277
this ->database_handler ->delete_charging_profile (profile.id );
2262
2278
}
2263
2279
} catch (const QueryExecutionException& e) {
@@ -2300,16 +2316,27 @@ ChargePoint::set_variables(const std::vector<SetVariableData>& set_variable_data
2300
2316
}
2301
2317
2302
2318
GetCompositeScheduleResponse ChargePoint::get_composite_schedule (const GetCompositeScheduleRequest& request) {
2319
+ if (this ->smart_charging == nullptr ) {
2320
+ GetCompositeScheduleResponse response;
2321
+ response.status = GenericStatusEnum::Rejected;
2322
+ return response;
2323
+ }
2303
2324
return this ->smart_charging ->get_composite_schedule (request);
2304
2325
}
2305
2326
2306
2327
std::optional<CompositeSchedule> ChargePoint::get_composite_schedule (int32_t evse_id, std::chrono::seconds duration,
2307
2328
ChargingRateUnitEnum unit) {
2329
+ if (this ->smart_charging == nullptr ) {
2330
+ return std::nullopt;
2331
+ }
2308
2332
return this ->smart_charging ->get_composite_schedule (evse_id, duration, unit);
2309
2333
}
2310
2334
2311
2335
std::vector<CompositeSchedule> ChargePoint::get_all_composite_schedules (const int32_t duration_s,
2312
2336
const ChargingRateUnitEnum& unit) {
2337
+ if (this ->smart_charging == nullptr ) {
2338
+ return {};
2339
+ }
2313
2340
return this ->smart_charging ->get_all_composite_schedules (duration_s, unit);
2314
2341
}
2315
2342
0 commit comments