Skip to content

Commit 3f5c196

Browse files
authored
Merge pull request #202 from mahdidadashi65/develop_dadashi
Solving some minor problems in the test procedure of charging point test cases
2 parents 2bd05e4 + 751710d commit 3f5c196

File tree

3 files changed

+75
-43
lines changed

3 files changed

+75
-43
lines changed

src/chargepoint/smartcharging/SmartChargingManager.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,19 @@ bool SmartChargingManager::handleMessage(const ocpp::messages::SetChargingProfil
281281
// Check if a transaction is in progress for the specific connector
282282
if (connector->transaction_id != 0)
283283
{
284-
// Add profile
285-
ret = true;
284+
if(request.csChargingProfiles.transactionId.isSet())
285+
{
286+
if(request.csChargingProfiles.transactionId.value() == connector->transaction_id)
287+
{
288+
// Add profile
289+
ret = true;
290+
}
291+
}
292+
else
293+
{
294+
// Add profile
295+
ret = true;
296+
}
286297
}
287298
}
288299
break;
@@ -340,7 +351,7 @@ bool SmartChargingManager::handleMessage(const ocpp::messages::SetChargingProfil
340351
LOG_INFO << "Set charging profile status rejected : " << error_message;
341352
}
342353

343-
return ret;
354+
return true;
344355
}
345356

346357
/** @copydoc bool GenericMessageHandler<RequestType, ResponseType>::handleMessage(const RequestType& request,

src/chargepoint/status/StatusManager.cpp

Lines changed: 60 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ StatusManager::StatusManager(const ocpp::config::IChargePointConfig& sta
6464
m_msg_sender(msg_sender),
6565
m_registration_status(RegistrationStatus::Rejected),
6666
m_force_boot_notification(false),
67-
m_boot_notification_timer(timer_pool, "Boot notification"),
67+
m_boot_notification_sent(false),
68+
m_boot_notification_timer(timer_pool, "Boot notification"),
6869
m_heartbeat_timer(timer_pool, "Heartbeat")
6970
{
7071
m_boot_notification_timer.setCallback([this] { m_worker_pool.run<void>(std::bind(&StatusManager::bootNotificationProcess, this)); });
@@ -400,57 +401,77 @@ bool StatusManager::handleMessage(const ocpp::messages::ChangeAvailabilityReq& r
400401

401402
/** @brief Boot notification process thread */
402403
void StatusManager::bootNotificationProcess()
403-
{
404-
// Fill boot notification request
405-
BootNotificationReq boot_req;
406-
boot_req.chargeBoxSerialNumber.value().assign(m_stack_config.chargeBoxSerialNumber());
407-
boot_req.chargePointModel.assign(m_stack_config.chargePointModel());
408-
boot_req.chargePointSerialNumber.value().assign(m_stack_config.chargePointSerialNumber());
409-
boot_req.chargePointVendor.assign(m_stack_config.chargePointVendor());
410-
boot_req.firmwareVersion.value().assign(m_stack_config.firmwareVersion());
411-
boot_req.iccid.value().assign(m_stack_config.iccid());
412-
boot_req.imsi.value().assign(m_stack_config.imsi());
413-
boot_req.meterSerialNumber.value().assign(m_stack_config.meterSerialNumber());
414-
415-
// Send BootNotificationRequest
416-
BootNotificationConf boot_conf;
417-
CallResult result = m_msg_sender.call(BOOT_NOTIFICATION_ACTION, boot_req, boot_conf);
418-
if (result == CallResult::Ok)
404+
{
405+
if(m_boot_notification_sent == false)
419406
{
420-
m_registration_status = boot_conf.status;
421-
if (m_registration_status == RegistrationStatus::Accepted)
407+
// Fill boot notification request
408+
BootNotificationReq boot_req;
409+
boot_req.chargeBoxSerialNumber.value().assign(m_stack_config.chargeBoxSerialNumber());
410+
boot_req.chargePointModel.assign(m_stack_config.chargePointModel());
411+
boot_req.chargePointSerialNumber.value().assign(m_stack_config.chargePointSerialNumber());
412+
boot_req.chargePointVendor.assign(m_stack_config.chargePointVendor());
413+
boot_req.firmwareVersion.value().assign(m_stack_config.firmwareVersion());
414+
boot_req.iccid.value().assign(m_stack_config.iccid());
415+
boot_req.imsi.value().assign(m_stack_config.imsi());
416+
boot_req.meterSerialNumber.value().assign(m_stack_config.meterSerialNumber());
417+
418+
m_registration_status = RegistrationStatus::Rejected;
419+
// Send BootNotificationRequest
420+
BootNotificationConf boot_conf;
421+
CallResult result = m_msg_sender.call(BOOT_NOTIFICATION_ACTION, boot_req, boot_conf);
422+
if (result == CallResult::Ok)
422423
{
423-
// Send first status notifications
424-
for (unsigned int id = 0; id <= m_connectors.getCount(); id++)
424+
if (boot_conf.status == RegistrationStatus::Accepted)
425425
{
426-
statusNotificationProcess(id);
426+
m_boot_notification_sent = true;
427+
// Send first status notifications
428+
for (unsigned int id = 0; id <= m_connectors.getCount(); id++)
429+
{
430+
statusNotificationProcess(id);
431+
}
432+
433+
// Configure hearbeat
434+
std::chrono::seconds interval(boot_conf.interval);
435+
m_ocpp_config.heartbeatInterval(interval);
436+
m_heartbeat_timer.start(std::chrono::milliseconds(interval));
427437
}
438+
else
439+
{
440+
// Schedule next retry
441+
m_boot_notification_timer.start(std::chrono::seconds(boot_conf.interval), true);
442+
}
443+
444+
m_registration_status = boot_conf.status;
445+
std::string registration_status = RegistrationStatusHelper.toString(m_registration_status);
446+
LOG_INFO << "Registration status : " << registration_status;
428447

429-
// Configure hearbeat
430-
std::chrono::seconds interval(boot_conf.interval);
431-
m_ocpp_config.heartbeatInterval(interval);
432-
m_heartbeat_timer.start(std::chrono::milliseconds(interval));
448+
// Save registration status
449+
m_force_boot_notification = false;
450+
m_internal_config.setKey(LAST_REGISTRATION_STATUS_KEY, registration_status);
451+
452+
// Notify boot
453+
m_events_handler.bootNotification(m_registration_status, boot_conf.currentTime);
433454
}
434455
else
435456
{
436457
// Schedule next retry
437-
m_boot_notification_timer.start(std::chrono::seconds(boot_conf.interval), true);
458+
m_boot_notification_timer.start(m_stack_config.retryInterval(), true);
438459
}
439-
440-
std::string registration_status = RegistrationStatusHelper.toString(m_registration_status);
441-
LOG_INFO << "Registration status : " << registration_status;
442-
443-
// Save registration status
444-
m_force_boot_notification = false;
445-
m_internal_config.setKey(LAST_REGISTRATION_STATUS_KEY, registration_status);
446-
447-
// Notify boot
448-
m_events_handler.bootNotification(m_registration_status, boot_conf.currentTime);
449460
}
450461
else
451462
{
452-
// Schedule next retry
453-
m_boot_notification_timer.start(m_stack_config.retryInterval(), true);
463+
// If the status of a connector has changed since the last notification
464+
// to the central system, send the new connector status
465+
for (const Connector* connector : m_connectors.getConnectors())
466+
{
467+
if (connector->status != connector->last_notified_status)
468+
{
469+
statusNotificationProcess(connector->id);
470+
}
471+
}
472+
473+
// Configure hearbeat
474+
m_heartbeat_timer.start(m_ocpp_config.heartbeatInterval());
454475
}
455476
}
456477

src/chargepoint/status/StatusManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ class StatusManager
142142
ocpp::types::RegistrationStatus m_registration_status;
143143
/** @brief Indicate if the boot notification message must be inconditionnaly sent on connection */
144144
bool m_force_boot_notification;
145-
145+
bool m_boot_notification_sent;
146146
/** @brief Boot notification process timer */
147147
ocpp::helpers::Timer m_boot_notification_timer;
148148
/** @brief Heartbeat timer */

0 commit comments

Comments
 (0)