Skip to content

Commit 2bd05e4

Browse files
authored
Merge pull request #201 from c-jimenez/dev/get_composite_schedule
Dev/get composite schedule
2 parents 94ceef7 + 452f152 commit 2bd05e4

File tree

3 files changed

+24
-13
lines changed

3 files changed

+24
-13
lines changed

src/chargepoint/reservation/ReservationManager.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,8 @@ bool ReservationManager::handleMessage(const ocpp::messages::ReserveNowReq& requ
185185
if (connector)
186186
{
187187
// Check if reservation is allowed on connector
188-
if (((request.connectorId != 0) || ((request.connectorId == 0) && m_ocpp_config.reserveConnectorZeroSupported()))
189-
&&( m_ocpp_config.supportedFeatureProfiles().find("Reservation")!= std::string::npos) )
188+
if (((request.connectorId != 0) || ((request.connectorId == 0) && m_ocpp_config.reserveConnectorZeroSupported())) &&
189+
(m_ocpp_config.supportedFeatureProfiles().find("Reservation") != std::string::npos))
190190
{
191191
std::lock_guard<std::mutex> lock(connector->mutex);
192192

src/chargepoint/smartcharging/SmartChargingManager.cpp

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -356,9 +356,26 @@ bool SmartChargingManager::handleMessage(const ocpp::messages::GetCompositeSched
356356
(void)error_code;
357357
(void)error_message;
358358

359+
ocpp::types::ChargingRateUnitType charging_rate_unit;
360+
if (!request.chargingRateUnit.isSet())
361+
{
362+
if (m_ocpp_config.chargingScheduleAllowedChargingRateUnit().find("Power") != std::string::npos)
363+
{
364+
charging_rate_unit = types::ChargingRateUnitType::W;
365+
}
366+
else
367+
{
368+
charging_rate_unit = types::ChargingRateUnitType::A;
369+
}
370+
}
371+
else
372+
{
373+
charging_rate_unit = request.chargingRateUnit.value();
374+
}
375+
359376
LOG_INFO << "GetCompositeSchedule requested : connectorId = " << request.connectorId << " - duration = " << request.duration
360-
<< " - chargingRateUnit = "
361-
<< (request.chargingRateUnit.isSet() ? ChargingRateUnitTypeHelper.toString(request.chargingRateUnit) : "not set");
377+
<< " - chargingRateUnit = " << ChargingRateUnitTypeHelper.toString(charging_rate_unit)
378+
<< (!request.chargingRateUnit.isSet() ? " (from allowed charging unit)" : "");
362379

363380
// Lock profiles
364381
std::lock_guard<std::mutex> lock(m_mutex);
@@ -442,14 +459,8 @@ bool SmartChargingManager::handleMessage(const ocpp::messages::GetCompositeSched
442459

443460
ChargingSchedule& schedule = response.chargingSchedule.value();
444461
schedule.duration = 0;
445-
if (request.chargingRateUnit.isSet())
446-
{
447-
schedule.chargingRateUnit = request.chargingRateUnit;
448-
}
449-
else
450-
{
451-
schedule.chargingRateUnit = ChargingRateUnitType::A;
452-
}
462+
schedule.chargingRateUnit = charging_rate_unit;
463+
453464
// Adjust start if needed since first period must start at 0
454465
time_t offset = periods[0].start;
455466
schedule.startSchedule = DateTime(now.timestamp() + offset);

src/websockets/libwebsockets/LibWebsocketClientPool.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ void LibWebsocketClientPool::process()
147147

148148
// Dummy vhost to handle context related events
149149
struct lws_protocols protocols[] = {{"LibWebsocketClientPool", &LibWebsocketClientPool::eventCallback, 0, 0, 0, this, 0},
150-
LWS_PROTOCOL_LIST_TERM};
150+
LWS_PROTOCOL_LIST_TERM};
151151
struct lws_context_creation_info vhost_info;
152152
memset(&vhost_info, 0, sizeof(vhost_info));
153153
vhost_info.protocols = protocols;

0 commit comments

Comments
 (0)