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

Changed connector_id and evse_id properties to optional in OcppTransactionEvent #944

Merged
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
21 changes: 14 additions & 7 deletions modules/OCPP/OCPP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -745,25 +745,32 @@ void OCPP::ready() {

this->charge_point->register_transaction_started_callback(
[this](const int32_t connector, const std::string& session_id) {
types::ocpp::OcppTransactionEvent tevent = {
types::ocpp::TransactionEvent::Started, connector, 1, session_id, std::nullopt,
};
types::ocpp::OcppTransactionEvent tevent;
tevent.transaction_event = types::ocpp::TransactionEvent::Started;
tevent.evse = {connector, 1};
tevent.session_id = session_id;
p_ocpp_generic->publish_ocpp_transaction_event(tevent);
});

this->charge_point->register_transaction_updated_callback(
[this](const int32_t connector, const std::string& session_id, const int32_t transaction_id,
const ocpp::v16::IdTagInfo& id_tag_info) {
types::ocpp::OcppTransactionEvent tevent = {types::ocpp::TransactionEvent::Updated, connector, 1,
session_id, std::to_string(transaction_id)};
types::ocpp::OcppTransactionEvent tevent;
tevent.transaction_event = types::ocpp::TransactionEvent::Updated;
tevent.evse = {connector, 1};
tevent.session_id = session_id;
tevent.transaction_id = std::to_string(transaction_id);
p_ocpp_generic->publish_ocpp_transaction_event(tevent);
});

this->charge_point->register_transaction_stopped_callback(
[this](const int32_t connector, const std::string& session_id, const int32_t transaction_id) {
EVLOG_info << "Transaction stopped at connector: " << connector << "session_id: " << session_id;
types::ocpp::OcppTransactionEvent tevent = {types::ocpp::TransactionEvent::Ended, connector, 1, session_id,
std::to_string(transaction_id)};
types::ocpp::OcppTransactionEvent tevent;
tevent.transaction_event = types::ocpp::TransactionEvent::Ended;
tevent.evse = {connector, 1};
tevent.session_id = session_id;
tevent.transaction_id = std::to_string(transaction_id);
p_ocpp_generic->publish_ocpp_transaction_event(tevent);
});

Expand Down
14 changes: 1 addition & 13 deletions modules/OCPP201/conversions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1058,21 +1058,9 @@ to_everest_ocpp_transaction_event(const ocpp::v201::TransactionEventRequest& tra
break;
}

auto evse_id = 1;
auto connector_id = 1;

if (transaction_event.evse.has_value()) {
evse_id = transaction_event.evse.value().id;
if (transaction_event.evse.value().connectorId.has_value()) {
connector_id = transaction_event.evse.value().connectorId.value();
}
} else {
EVLOG_warning << "Attempting to convert TransactionEventRequest that does not contain information about the "
"EVSE. evse_id and connector default to 1.";
ocpp_transaction_event.evse = to_everest_evse(transaction_event.evse.value());
}

ocpp_transaction_event.evse_id = evse_id;
ocpp_transaction_event.connector = connector_id;
ocpp_transaction_event.session_id =
transaction_event.transactionInfo.transactionId; // session_id == transaction_id for OCPP2.0.1
ocpp_transaction_event.transaction_id = transaction_event.transactionInfo.transactionId;
Expand Down
45 changes: 20 additions & 25 deletions types/ocpp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,29 +73,40 @@ types:
description: schedule for a connector
type: object
$ref: /ocpp#/ChargingSchedule
EVSE:
description: >-
Type of an EVSE. If only the id is present, this type identifies an EVSE.
If also a connector_id is given, this type identifies a Connector of the EVSE
type: object
required:
- id
properties:
id:
description: Id of the EVSE
type: integer
minimum: 1
connector_id:
description: An id to designate a specific connector (on an EVSE) by connector index number
type: integer
minimum: 1
OcppTransactionEvent:
description: >-
Element providing information on OCPP transactions.
type: object
required:
- transaction_event
- evse_id
- connector
- session_id
properties:
transaction_event:
description: >-
The transaction related event.
type: string
$ref: /ocpp#/TransactionEvent
evse_id:
description: >-
The OCPP 2.0.1 EVSE ID associated with the transaction.
type: integer
connector:
evse:
description: >-
The connector associated with the transaction.
type: integer
The OCPP 2.0.1 EVSE associated with the transaction.
type: object
$ref: /ocpp#/EVSE
session_id:
description: >-
The EVSE manager assigned session ID.
Expand Down Expand Up @@ -271,22 +282,6 @@ types:
description: Timestamp of the moment the security event was generated, if absent the current datetime is assumed
type: string
format: date-time
EVSE:
description: >-
Type of an EVSE. If only the id is present, this type identifies an EVSE.
If also a connector_id is given, this type identifies a Connector of the EVSE
type: object
required:
- id
properties:
id:
description: Id of the EVSE
type: integer
minimum: 1
connector_id:
description: An id to designate a specific connector (on an EVSE) by connector index number
type: integer
minimum: 1
Variable:
description: >-
Type for a variable with a name and an optional instance
Expand Down
Loading