-
Notifications
You must be signed in to change notification settings - Fork 52
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
Fixing transactionData omitted in StopTransaction.req #493
Conversation
…ing response with empty certificateHashData Signed-off-by: Mahdi Movahedi <[email protected]>
Signed-off-by: pietfried <[email protected]>
…r sampled value existed) bug fixed Signed-off-by: Mahdi Movahedi <[email protected]>
Signed-off-by: Mahdi Movahedi <[email protected]>
The tests failed and it seems it is in part because |
Signed-off-by: Mahdi Movahedi <[email protected]>
Signed-off-by: Mahdi Movahedi <[email protected]>
Signed-off-by: Mahdi Movahedi <[email protected]>
The other approach is to avoid meddling in std::vector<TransactionData> transaction_data_vec = transaction->get_transaction_data();
bool has_singed_meter_values =
std::find_if(
transaction_data_vec.begin(), transaction_data_vec.end(), [](TransactionData const& TransactionData_Item) {
return (std::find_if(TransactionData_Item.sampledValue.begin(), TransactionData_Item.sampledValue.end(),
[](SampledValue const& SampledValue_item) {
return SampledValue_item.format.value_or(ValueFormat::Raw) ==
ValueFormat::SignedData;
}) != TransactionData_Item.end());
}) != transaction_data_vec.end();
if (!stop_txn_sampled_data_measurands.empty() or !stop_txn_aligned_data_measurands.empty() or
has_singed_meter_values) { ...
This way we make use of two nested std::find_if algorithm in order to define |
Sorry for making too much noise, but another approach I think is to delete void Transaction::add_meter_value(MeterValue meter_value) {
if (this->active) {
std::lock_guard<std::mutex> lock(this->meter_values_mutex);
this->meter_values.push_back(meter_value);
if (std::find_if(meter_value.sampledValue.begin(), meter_value.sampledValue.end(),
[](SampledValue const& SampledValueItem) {
return SampledValueItem.format == ValueFormat::SignedData;
}) != meter_value.sampledValue.end()) {
this->set_has_signed_meter_values();
}
}
} However, if we can define a signed_meter_value_flag defaulted to false as an argument for void Transaction::add_meter_value(MeterValue meter_value, bool signed_meter_value = false) {
if (this->active) {
std::lock_guard<std::mutex> lock(this->meter_values_mutex);
this->meter_values.push_back(meter_value);
if (signed_meter_value) {
this->set_has_signed_meter_values();
}
}
} So in charge_point_impl.cpp we will have: void ChargePointImpl::on_transaction_started(const int32_t& connector, const std::string& session_id,
const std::string& id_token, const int32_t& meter_start,
std::optional<int32_t> reservation_id, const ocpp::DateTime& timestamp,
std::optional<std::string> signed_meter_value) {
...
if (bool singed_meter_value_flag = signed_meter_value.has_value(); signed_meter_value_flag) {
const auto meter_value =
this->get_signed_meter_value(signed_meter_value.value(), ReadingContext::Transaction_Begin, timestamp);
transaction->add_meter_value(meter_value, has_signed_meter_value);
}
...
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
has_signed_meter_values is checking a state and letting start transaction happen
Great job Mahdi!
You need to get the checks reviewed and see what the reason behind this disapproval is! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see no issue in this request!
Signed-off-by: Mahdi Movahedi <[email protected]>
Dear @thenaserov , it is a good_first_issue, it is much better if solved with a |
Dear @Pietfried could you please guide me on the changes in the commits and changes proposed in the comments? May I have your supervision about the approaches? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @movhdi , since this PR was in Draft state we missed it. Thanks for the contribution! Please run clang format so we can merge it.
Signed-off-by: Mahdi Movahedi <[email protected]>
…the newly added functions Signed-off-by: Mahdi Movahedi <[email protected]>
Signed-off-by: Mahdi Movahedi <[email protected]>
Signed-off-by: Mahdi Movahedi <[email protected]>
Dear @Pietfried, I runned clang-format. Thanks for your comment. |
* transactionData omitted in StopTransaction.req (in case no aligned nor sampled value existed) bug fixed --------- Signed-off-by: Mahdi Movahedi <[email protected]> Signed-off-by: pietfried <[email protected]> Co-authored-by: pietfried <[email protected]>
Describe your changes
A boolean variable added inside transaction class as a flag for existing signed meter values.
The flag has been set in both
on_transaction_started
andon_transaction_stopped
methods.The flag has been used to fall in the main if statement in
get_filtered_transaction_data
method in which meter values are populated infiltered_transaction_data_vec
.I think this works although I am afraid I have meddled in
transaction
class.Issue ticket number and link
issue number #472
Checklist before requesting a review