Skip to content

Commit a6097a3

Browse files
authored
Merge pull request #99 from mahdidadashi65/develop_dadashi
Develop dadashi
2 parents f862215 + 0ab1291 commit a6097a3

File tree

2 files changed

+73
-26
lines changed

2 files changed

+73
-26
lines changed

src/chargepoint/authent/AuthentLocalList.cpp

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,7 @@ bool AuthentLocalList::handleMessage(const ocpp::messages::SendLocalListReq& req
124124
// Check local list activation
125125
if (m_ocpp_config.localAuthListEnabled())
126126
{
127-
// Check local list version
128-
if (request.listVersion > m_local_list_version)
127+
if (request.listVersion > 0)
129128
{
130129
// Check update list size
131130
if (request.localAuthorizationList.size() <= m_ocpp_config.sendLocalListMaxLength())
@@ -135,26 +134,50 @@ bool AuthentLocalList::handleMessage(const ocpp::messages::SendLocalListReq& req
135134
if (request.updateType == UpdateType::Full)
136135
{
137136
success = performFullUpdate(request.localAuthorizationList);
138-
}
139-
else
140-
{
141-
success = performPartialUpdate(request.localAuthorizationList);
142-
}
143-
if (success)
144-
{
145-
response.status = UpdateStatus::Accepted;
137+
if (success)
138+
{
139+
response.status = UpdateStatus::Accepted;
146140

147-
// Update local list version
148-
m_local_list_version = request.listVersion;
149-
if (!m_internal_config.setKey(LOCAL_LIST_VERSION_KEY, std::to_string(m_local_list_version)))
141+
// Update local list version
142+
m_local_list_version = request.listVersion;
143+
if (!m_internal_config.setKey(LOCAL_LIST_VERSION_KEY, std::to_string(m_local_list_version)))
144+
{
145+
LOG_ERROR << "Unable to save authent local list version";
146+
}
147+
}
148+
else
150149
{
151-
LOG_ERROR << "Unable to save authent local list version";
150+
response.status = UpdateStatus::Failed;
152151
}
153152
}
154153
else
155154
{
156-
response.status = UpdateStatus::Failed;
155+
// Check local list version
156+
if (request.listVersion > m_local_list_version)
157+
{
158+
success = performPartialUpdate(request.localAuthorizationList);
159+
if (success)
160+
{
161+
response.status = UpdateStatus::Accepted;
162+
163+
// Update local list version
164+
m_local_list_version = request.listVersion;
165+
if (!m_internal_config.setKey(LOCAL_LIST_VERSION_KEY, std::to_string(m_local_list_version)))
166+
{
167+
LOG_ERROR << "Unable to save authent local list version";
168+
}
169+
}
170+
else
171+
{
172+
response.status = UpdateStatus::Failed;
173+
}
174+
}
175+
else
176+
{
177+
response.status = UpdateStatus::VersionMismatch;
178+
}
157179
}
180+
158181
}
159182
else
160183
{
@@ -163,7 +186,8 @@ bool AuthentLocalList::handleMessage(const ocpp::messages::SendLocalListReq& req
163186
}
164187
else
165188
{
166-
response.status = UpdateStatus::VersionMismatch;
189+
response.status = UpdateStatus::Failed;
190+
167191
}
168192
}
169193
else

src/chargepoint/status/StatusManager.cpp

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -363,20 +363,43 @@ bool StatusManager::handleMessage(const ocpp::messages::ChangeAvailabilityReq& r
363363
unsigned int connector_id = request.connectorId;
364364
if (m_connectors.isValid(connector_id))
365365
{
366-
// Notify request
367-
response.status = m_events_handler.changeAvailabilityRequested(connector_id, request.type);
368-
if (response.status == AvailabilityStatus::Accepted)
369-
{
370-
// Update status
371-
ChargePointStatus status = ChargePointStatus::Unavailable;
372-
if (request.type == AvailabilityType::Operative)
366+
//In the case the ChangeAvailability.req contains ConnectorId = 0, the status change applies to the Charge Point and all Connectors.
367+
if(connector_id == 0)
368+
{
369+
for(unsigned int i=0;i <= m_connectors.getCount();i++)
373370
{
374-
status = ChargePointStatus::Available;
371+
response.status = m_events_handler.changeAvailabilityRequested(i, request.type);
372+
if (response.status == AvailabilityStatus::Accepted)
373+
{
374+
// Update status
375+
ChargePointStatus status = ChargePointStatus::Unavailable;
376+
if (request.type == AvailabilityType::Operative)
377+
{
378+
status = ChargePointStatus::Available;
379+
}
380+
m_worker_pool.run<void>([this, i, status] { updateConnectorStatus(i, status); });
381+
}
382+
383+
LOG_INFO << "Change availability " << AvailabilityStatusHelper.toString(response.status);
375384
}
376-
m_worker_pool.run<void>([this, connector_id, status] { updateConnectorStatus(connector_id, status); });
377385
}
386+
else
387+
{
388+
// Notify request
389+
response.status = m_events_handler.changeAvailabilityRequested(connector_id, request.type);
390+
if (response.status == AvailabilityStatus::Accepted)
391+
{
392+
// Update status
393+
ChargePointStatus status = ChargePointStatus::Unavailable;
394+
if (request.type == AvailabilityType::Operative)
395+
{
396+
status = ChargePointStatus::Available;
397+
}
398+
m_worker_pool.run<void>([this, connector_id, status] { updateConnectorStatus(connector_id, status); });
399+
}
378400

379-
LOG_INFO << "Change availability " << AvailabilityStatusHelper.toString(response.status);
401+
LOG_INFO << "Change availability " << AvailabilityStatusHelper.toString(response.status);
402+
}
380403
ret = true;
381404
}
382405
else

0 commit comments

Comments
 (0)