Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update nlohmann json and schema validator #144

Merged
merged 3 commits into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
name: Lint
strategy:
matrix:
os: [large-ubuntu-22.04-s]
os: [ubuntu-22.04]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout libocpp
Expand Down
12 changes: 9 additions & 3 deletions dependencies.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
---
nlohmann_json:
git: https://github.com/nlohmann/json
git_tag: v3.10.5
git_tag: v3.11.2
options: ["JSON_BuildTests OFF", "JSON_MultipleHeaders ON"]
nlohmann_json_schema_validator:
git: https://github.com/pboettch/json-schema-validator
git_tag: 2.1.0
options: ["BUILD_TESTS OFF", "BUILD_EXAMPLES OFF"]
git_tag: 2.2.0
options:
[
"JSON_VALIDATOR_INSTALL OFF",
"JSON_VALIDATOR_BUILD_TESTS OFF",
"JSON_VALIDATOR_BUILD_EXAMPLES OFF",
"JSON_VALIDATOR_BUILD_SHARED_LIBS ON",
]
liblog:
git: https://github.com/EVerest/liblog.git
git_tag: v0.1.0
Expand Down
3 changes: 2 additions & 1 deletion include/ocpp/v201/charge_point.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,8 @@ class ChargePoint : ocpp::ChargingStationBase {
/// \param signed_meter_value
void on_transaction_finished(const int32_t evse_id, const DateTime& timestamp, const MeterValue& meter_stop,
const ReasonEnum reason, const std::optional<std::string>& id_token,
const std::optional<std::string>& signed_meter_value, const ChargingStateEnum charging_state);
const std::optional<std::string>& signed_meter_value,
const ChargingStateEnum charging_state);

/// \brief Event handler that should be called when a session has finished
/// \param evse_id
Expand Down
27 changes: 10 additions & 17 deletions lib/ocpp/v201/charge_point.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,14 +230,10 @@ bool ChargePoint::on_charging_state_changed(const uint32_t evse_id, ChargingStat
this->evses.at(static_cast<int32_t>(evse_id))->get_transaction();
if (transaction != nullptr) {
transaction->chargingState = charging_state;
this->transaction_event_req(
TransactionEventEnum::Updated, DateTime(),
transaction->get_transaction(),
TriggerReasonEnum::ChargingStateChanged,
transaction->get_seq_no(), std::nullopt,
this->evses.at(static_cast<int32_t>(evse_id))->get_evse_info(),
std::nullopt, std::nullopt, std::nullopt, std::nullopt,
std::nullopt);
this->transaction_event_req(TransactionEventEnum::Updated, DateTime(), transaction->get_transaction(),
TriggerReasonEnum::ChargingStateChanged, transaction->get_seq_no(),
std::nullopt, this->evses.at(static_cast<int32_t>(evse_id))->get_evse_info(),
std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt);
return true;
} else {
EVLOG_warning << "Can not change charging state: no transaction for evse id " << evse_id;
Expand Down Expand Up @@ -852,27 +848,24 @@ void ChargePoint::transaction_event_req(const TransactionEventEnum& event_type,

ocpp::Call<TransactionEventRequest> call(req, this->message_queue->createMessageId());

// Check if id token is in the remote start map, because when a remote
// start request is done, the first transaction event request should
// always contain trigger reason 'RemoteStart'.
// Check if id token is in the remote start map, because when a remote
// start request is done, the first transaction event request should
// always contain trigger reason 'RemoteStart'.
auto it = std::find_if(
remote_start_id_per_evse.begin(), remote_start_id_per_evse.end(),
[&id_token, &evse](const std::pair<int32_t, std::pair<IdToken, int32_t>>& remote_start_per_evse) {
if (id_token.has_value() &&
remote_start_per_evse.second.first.idToken == id_token.value().idToken) {
if (id_token.has_value() && remote_start_per_evse.second.first.idToken == id_token.value().idToken) {

if (remote_start_per_evse.first == 0) {
return true;
}

if (evse.has_value() &&
evse.value().id == remote_start_per_evse.first) {
if (evse.has_value() && evse.value().id == remote_start_per_evse.first) {
return true;
}
}
return false;
}
);
});

if (it != remote_start_id_per_evse.end()) {
// Found remote start. Set remote start id and the trigger reason.
Expand Down