Skip to content

Commit ae7a9db

Browse files
author
Cédric Jimenez
committed
[chargepoint] Add reserved behavior + new end of transaction authorize method
1 parent 5231803 commit ae7a9db

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

src/chargepoint/SimulatedChargePoint.cpp

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,19 @@ void SimulatedChargePoint::loop(MqttManager& mqtt,
402402
case ChargePointStatus::Reserved:
403403
{
404404
// If valid id tag (local or remote) => Preparing
405-
// Start preparing timeout
405+
if (isValidIdTagPresent(mqtt, charge_point, event_handler, connector, false))
406+
{
407+
charge_point.statusNotification(connector.id, ChargePointStatus::Preparing);
408+
}
409+
// If fault pending => Faulted
410+
else if (connector.fault_pending)
411+
{
412+
charge_point.statusNotification(connector.id, ChargePointStatus::Faulted);
413+
}
414+
else
415+
{
416+
// Stay in current state
417+
}
406418
}
407419
break;
408420

@@ -497,21 +509,11 @@ bool SimulatedChargePoint::isTransactionStopCondition(MqttManager&
497509
// Check local id tag
498510
if (mqtt.isIdTagPending(connector.id))
499511
{
500-
std::string id_tag = mqtt.pendingIdTag(connector.id);
501-
if (id_tag != connector.id_tag)
502-
{
503-
AuthorizationStatus auth_status;
504-
std::string parent_id_tag;
505-
auth_status = charge_point.authorize(connector.id, id_tag, parent_id_tag);
506-
if ((auth_status == AuthorizationStatus::Accepted) || (auth_status == AuthorizationStatus::ConcurrentTx))
507-
{
508-
ret = !parent_id_tag.empty() && (parent_id_tag == connector.parent_id_tag);
509-
}
510-
else
511-
{
512-
ret = false;
513-
}
514-
}
512+
AuthorizationStatus auth_status;
513+
std::string parent_id_tag;
514+
std::string id_tag = mqtt.pendingIdTag(connector.id);
515+
auth_status = charge_point.authorize(connector.id, id_tag, parent_id_tag);
516+
ret = (auth_status == AuthorizationStatus::Accepted);
515517
mqtt.resetIdTagPending(connector.id);
516518
if (ret)
517519
{

0 commit comments

Comments
 (0)