-
Notifications
You must be signed in to change notification settings - Fork 74
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
Reservation changes for 2.0.1 #943
base: main
Are you sure you want to change the base?
Changes from 34 commits
1abe69e
606af4f
dc3b0cf
c8f44cc
c40fe98
228cdd0
63ca3de
b56eca9
bc9b476
3b1170f
81f407d
2abd635
35a306f
84f7208
b46b503
8172cd0
fd13f08
bfe4ee5
f4eaf0d
3437975
4e6d076
7d03a7a
ef6abde
f4d10a8
315b62a
4a0ac28
c1994aa
c2d2b65
843fae4
501d73a
08a38ee
5543e0a
f1e923f
f2fcace
c4f8756
7c9d33a
5c7dbac
132ca86
0847d20
295a7ec
46695d9
ce3781b
2d61ce9
cf54aaa
78eacfb
cc6c6a9
8ab8859
3cc70d4
6df07ce
df45d6c
42d5461
c671e80
925e08f
f205906
5f4f0e6
9ae31b5
53aa3a5
b1e1040
e6d2374
ad9d05a
3b19bd0
08282f2
cf690d0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -1,21 +1,15 @@ | ||||||||
description: Interface for reservations | ||||||||
cmds: | ||||||||
reserve_now: | ||||||||
description: Reserves this evse. | ||||||||
description: Reserves an evse. | ||||||||
arguments: | ||||||||
connector_id: | ||||||||
description: >- | ||||||||
The id of the connector to be reserved. A value of 0 means that | ||||||||
the reservation is not for a specific connector | ||||||||
type: integer | ||||||||
reservation: | ||||||||
description: The information about the Reservation to be placed | ||||||||
request: | ||||||||
type: object | ||||||||
$ref: /reservation#/Reservation | ||||||||
$ref: /reservation#/ReserveNowRequest | ||||||||
description: Requests to make a reservation | ||||||||
result: | ||||||||
description: >- | ||||||||
Returns Accepted if reservation was succesfull or specifies error | ||||||||
code. | ||||||||
Returns Accepted if reservation was succesful or specifies error code. | ||||||||
type: string | ||||||||
$ref: /reservation#/ReservationResult | ||||||||
cancel_reservation: | ||||||||
|
@@ -29,4 +23,23 @@ cmds: | |||||||
Returns true if reservation was cancelled. Returns false if there | ||||||||
was no reservation to cancel. | ||||||||
type: boolean | ||||||||
vars: {} | ||||||||
is_reservation_for_token: | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would prefer something like |
||||||||
description: >- | ||||||||
Checks if there is a reservation made for the given connector and token. Will also return true if there | ||||||||
is a reservation with this token for evse id 0. | ||||||||
arguments: | ||||||||
request: | ||||||||
type: object | ||||||||
$ref: /reservation#/ReservationCheck | ||||||||
description: Check if there is a reservation on the given connector for the given token. | ||||||||
result: | ||||||||
description: >- | ||||||||
Returns true if there is a reservation for the given connector id and token or group id token. If there is a | ||||||||
connector id given, it will also return true if a reservation with this token was made for connector id 0. | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
type: boolean | ||||||||
vars: | ||||||||
reservation_update: | ||||||||
description: >- | ||||||||
Update of the reservation. | ||||||||
type: object | ||||||||
$ref: /reservation#/ReservationUpdateStatus |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,8 @@ void Auth::init() { | |
|
||
this->auth_handler = std::make_unique<AuthHandler>( | ||
string_to_selection_algorithm(this->config.selection_algorithm), this->config.connection_timeout, | ||
this->config.prioritize_authorization_over_stopping_transaction, this->config.ignore_connector_faults); | ||
this->config.prioritize_authorization_over_stopping_transaction, this->config.ignore_connector_faults, | ||
this->info.id, (!this->r_kvs.empty() ? this->r_kvs.at(0).get() : nullptr)); | ||
|
||
for (const auto& token_provider : this->r_token_provider) { | ||
token_provider->subscribe_provided_token([this](ProvidedIdToken provided_token) { | ||
|
@@ -30,20 +31,24 @@ void Auth::ready() { | |
|
||
int32_t evse_index = 0; | ||
for (const auto& evse_manager : this->r_evse_manager) { | ||
int32_t connector_id = evse_manager->call_get_evse().id; | ||
this->auth_handler->init_connector(connector_id, evse_index); | ||
const int32_t evse_id = evse_manager->call_get_evse().id; | ||
|
||
evse_manager->subscribe_session_event([this, connector_id](SessionEvent session_event) { | ||
this->auth_handler->handle_session_event(connector_id, session_event); | ||
for (const auto& connector : evse_manager->call_get_evse().connectors) { | ||
this->auth_handler->init_connector( | ||
connector.id, evse_index, connector.type.value_or(types::evse_manager::ConnectorTypeEnum::Unknown)); | ||
} | ||
|
||
evse_manager->subscribe_session_event([this, evse_id](SessionEvent session_event) { | ||
this->auth_handler->handle_session_event(evse_id, session_event); | ||
}); | ||
|
||
evse_manager->subscribe_error( | ||
"evse_manager/Inoperative", | ||
[this, connector_id](const Everest::error::Error& error) { | ||
this->auth_handler->handle_permanent_fault_raised(connector_id); | ||
[this, evse_id](const Everest::error::Error& error) { | ||
this->auth_handler->handle_permanent_fault_raised(evse_id); | ||
}, | ||
[this, connector_id](const Everest::error::Error& error) { | ||
this->auth_handler->handle_permanent_fault_cleared(connector_id); | ||
[this, evse_id](const Everest::error::Error& error) { | ||
this->auth_handler->handle_permanent_fault_cleared(evse_id); | ||
}); | ||
|
||
evse_index++; | ||
|
@@ -53,6 +58,7 @@ void Auth::ready() { | |
[this](const ProvidedIdToken& token, TokenValidationStatus status) { | ||
this->p_main->publish_token_validation_status({token, status}); | ||
}); | ||
|
||
this->auth_handler->register_notify_evse_callback( | ||
[this](const int evse_index, const ProvidedIdToken& provided_token, const ValidationResult& validation_result) { | ||
this->r_evse_manager.at(evse_index)->call_authorize_response(provided_token, validation_result); | ||
|
@@ -70,11 +76,35 @@ void Auth::ready() { | |
[this](const int32_t evse_index, const StopTransactionRequest& request) { | ||
this->r_evse_manager.at(evse_index)->call_stop_transaction(request); | ||
}); | ||
this->auth_handler->register_reserved_callback([this](const int32_t evse_index, const int32_t& reservation_id) { | ||
this->r_evse_manager.at(evse_index)->call_reserve(reservation_id); | ||
}); | ||
this->auth_handler->register_reserved_callback( | ||
[this](const std::optional<int32_t> evse_id, const int32_t& reservation_id) { | ||
// Only call the evse manager to store the reservation if it is done for a specific evse. | ||
if (evse_id.has_value()) { | ||
EVLOG_info << "Call reserved callback for evse id " << evse_id.value(); | ||
|
||
this->r_evse_manager.at(evse_id.value() - 1)->call_reserve(reservation_id); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm yes that's a good one. Since the ReservationHandler has a copy of this states, it should just always be possible. But ok, if the evse manager returns false here, should we cancel the reservation in that case then? Because I think at this point the reservation has already been made. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just left a todo there for now. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The EvseManager shall stay autonoumus with the decision if a reservation can be made, so we should be able to handle the response at some point There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So should the flow be:
? Is that all going well when a new car just arrives in the meantime? Or maybe we just have to create the reservation and if the evse manager returns false, cancel it again? Because we have kind of a strange situation if the reservation is not yet made, the evse manager returns true on the 'reserve' call, we make the reservation but it is not possible anymore (because a car just arrived). BTW, the evse manager also has nothing to say about reservations that are not tight to a specific evse. So who is responsible for the reservations here then? |
||
} | ||
}); | ||
this->auth_handler->register_reservation_cancelled_callback( | ||
[this](const int32_t evse_index) { this->r_evse_manager.at(evse_index)->call_cancel_reservation(); }); | ||
[this](const std::optional<int32_t> evse_id, const int32_t reservation_id, const ReservationEndReason reason) { | ||
// Only call the evse manager to cancel the reservation if it was for a specific evse | ||
if (evse_id.has_value()) { | ||
EVLOG_debug << "Call evse manager to cancel the reservation with evse id " << evse_id.value(); | ||
this->r_evse_manager.at(evse_id.value() - 1)->call_cancel_reservation(); | ||
} | ||
|
||
ReservationUpdateStatus status; | ||
status.reservation_id = reservation_id; | ||
if (reason == ReservationEndReason::Expired) { | ||
status.reservation_status = Reservation_status::Expired; | ||
} else if (reason == ReservationEndReason::Cancelled) { | ||
status.reservation_status = Reservation_status::Removed; | ||
} else { | ||
// On reservation used: do not publish a reservation update!! | ||
return; | ||
} | ||
this->p_reservation->publish_reservation_update(status); | ||
}); | ||
} | ||
|
||
void Auth::set_connection_timeout(int& connection_timeout) { | ||
|
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.
The default
charge_mode
value isAC
, so type2 would be more appropriate