Skip to content

Commit 1f0d9ee

Browse files
张钦c-jimenez
authored andcommitted
fix:Improve the reservation logic.
1 parent 94a8523 commit 1f0d9ee

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

src/chargepoint/reservation/ReservationManager.cpp

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -132,18 +132,26 @@ ocpp::types::AuthorizationStatus ReservationManager::isTransactionAllowed(unsign
132132
Connector& charge_point = m_connectors.getChargePointConnector();
133133
if (charge_point.status == ChargePointStatus::Reserved)
134134
{
135-
// At least 1 connector must stay available
136-
unsigned int available_count = 0;
137-
for (const Connector* c : m_connectors.getConnectors())
135+
// Ensure that the module functions properly even when the gun is inserted first by the user.
136+
if (m_connectors.getConnector(connector_id)->status == ChargePointStatus::Preparing)
138137
{
139-
if (c->status == ChargePointStatus::Available)
140-
{
141-
available_count++;
142-
}
138+
ret = AuthorizationStatus::Accepted;
143139
}
144-
if (available_count > 1)
140+
else
145141
{
146-
ret = AuthorizationStatus::Accepted;
142+
// At least 1 connector must stay available
143+
unsigned int available_count = 0;
144+
for (const Connector* c : m_connectors.getConnectors())
145+
{
146+
if (c->status == ChargePointStatus::Available)
147+
{
148+
available_count++;
149+
}
150+
}
151+
if (available_count >= 1)
152+
{
153+
ret = AuthorizationStatus::Accepted;
154+
}
147155
}
148156
}
149157
else

0 commit comments

Comments
 (0)