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

Reservation all connectors reserved (#958) #972

Merged
merged 20 commits into from
Dec 16, 2024

Conversation

maaikez
Copy link
Contributor

@maaikez maaikez commented Nov 27, 2024

Describe your changes

When there are as many reservations as evse's available, all available evse's must go to 'reserved'. And back to 'available' when there are more evse's than reservations.

Also, added unittests.

See other related pull requests:
EVerest/libocpp#878
EVerest/everest-utils#171

Issue ticket number and link

#958

Checklist before requesting a review

  • I have performed a self-review of my code
  • I have made corresponding changes to the documentation
  • I read the contribution documentation and made sure that my changes meet its requirements

@maaikez maaikez force-pushed the feature/958-reservation-all-connectors-reserved branch from 44f3b63 to ec79914 Compare November 27, 2024 14:37
@maaikez maaikez marked this pull request as draft November 27, 2024 14:50
@maaikez maaikez force-pushed the feature/958-reservation-all-connectors-reserved branch from e7b1ad9 to b359a9f Compare November 27, 2024 15:17
@maaikez maaikez force-pushed the feature/958-reservation-all-connectors-reserved branch 2 times, most recently from aace320 to b1476a4 Compare November 28, 2024 14:38
@maaikez maaikez marked this pull request as ready for review November 28, 2024 16:18
@Pietfried Pietfried self-assigned this Dec 3, 2024
@maaikez maaikez force-pushed the feature/958-reservation-all-connectors-reserved branch 4 times, most recently from 19ae787 to 37f9f0d Compare December 10, 2024 13:39
Copy link
Contributor

@Pietfried Pietfried left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, added a few suggestions

Comment on lines 52 to 53
The reservation id (should be added to the TransactionStarted event). Negative value if there was
no specific reservation id for this evse (if there are 'global' reservations for 'any' evse).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The reservation id (should be added to the TransactionStarted event). Negative value if there was
no specific reservation id for this evse (if there are 'global' reservations for 'any' evse).
The reservation id (should be added to the TransactionStarted event). Set tis to a negative value if there is
no specific reservation id for this evse but the evse should still move to a Reserved state because of total
global reservations.

@@ -54,11 +54,15 @@ types:
Expired: When the reservation expired before the reserved token was used for a session
Cancelled: When the reservation was cancelled manually
UsedToStartCharging: When the reservation ended because the reserved token was used for a session
GlobalReservationConnectorFree: When the reservation ended because there is a connector free and there are less
reservations than available evse's (reservation is still there but it is not
occupying the EVSE anymore).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
occupying the EVSE anymore).
occupying this EVSE anymore).

type: string
enum:
- Expired
- Cancelled
- UsedToStartCharging
- GlobalReservationConnectorFree
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since I was a little confused by the name.. maybe GlobalReservationRequirementDropped ?

Comment on lines 4801 to 4802
test_controller.clear_error(1)

await asyncio.sleep(1)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesnt look like its required at the end of the test case

test_controller.diode_fail()
test_controller.raise_error("MREC6UnderVoltage", 1)

await asyncio.sleep(1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think that we have to sleep here since wait_for_and_validate will wait for the error event already

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well I gave it a try and removed it again, but we have a race condition here. The statusnotification is sent earlier than the status is received by the auth handler so the reservation handler does not know of the state of the connector yet. :(

Comment on lines 339 to 551
test_controller.raise_error("MREC6UnderVoltage", 1)

await asyncio.sleep(1)

t = datetime.utcnow() + timedelta(minutes=10)

# Send a reserve new request
await charge_point_v201.reserve_now_req(
id=0,
id_token=IdTokenType(id_token=test_config.authorization_info.valid_id_tag_1,
type=IdTokenTypeEnum.iso14443),
expiry_date_time=t.isoformat(),
evse_id=1
)

# which should return 'faulted'
assert await wait_for_and_validate(
test_utility,
charge_point_v201,
"ReserveNow",
call_result201.ReserveNowPayload(ReserveNowStatusType.faulted),
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also here you can do drop the sleep if you do

  1. raise_error
  2. wait and validate for StatusNotification.req(Faulted)
  3. ReserveNow
  4. wait and validate ReserveNow

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here:
We have a race condition here. The statusnotification is sent earlier than the status is received by the auth handler so the reservation handler does not know of the state of the connector yet. :(

),
)

await asyncio.sleep(1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can also be dropped.

@@ -400,6 +413,52 @@ bool ReservationHandler::has_reservation_parent_id(const std::optional<uint32_t>
return false;
}

ReservationEvseStatus ReservationHandler::check_number_global_reservations_match_number_available_evses() {
ReservationEvseStatus evse_status;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ReservationEvseStatus evse_status;

This looks like it is not used

@maaikez maaikez force-pushed the feature/958-reservation-all-connectors-reserved branch 2 times, most recently from 9c9f185 to 0beb627 Compare December 16, 2024 09:40
Signed-off-by: Maaike Zijderveld, iolar <[email protected]>
…s and notify evse manager.

Signed-off-by: Maaike Zijderveld, iolar <[email protected]>
…eserved if no more reservations can be made.

Signed-off-by: Maaike Zijderveld, iolar <[email protected]>
Signed-off-by: Maaike Zijderveld, iolar <[email protected]>
…rvation was made for connector 0.

Signed-off-by: Maaike Zijderveld, iolar <[email protected]>
Signed-off-by: Maaike Zijderveld, iolar <[email protected]>
… after a car stopped charging.

Signed-off-by: Maaike Zijderveld, iolar <[email protected]>
Signed-off-by: Maaike Zijderveld, iolar <[email protected]>
Signed-off-by: Maaike Zijderveld, iolar <[email protected]>
Signed-off-by: Maaike Zijderveld, iolar <[email protected]>
Signed-off-by: Maaike Zijderveld, iolar <[email protected]>
Signed-off-by: Maaike Zijderveld, iolar <[email protected]>
Signed-off-by: Maaike Zijderveld, iolar <[email protected]>
Signed-off-by: Maaike Zijderveld, iolar <[email protected]>
…ndler, only cancel it internally. The EVSE Manager will cancel the reservation itself. If the ReservationHandler is calling the callback, there will be race conditions with the evse manager not knowing there is a transaction yet, but the reservation is already cancelled. And some other bug fixes.

Signed-off-by: Maaike Zijderveld, iolar <[email protected]>
Signed-off-by: Maaike Zijderveld, iolar <[email protected]>
@maaikez maaikez force-pushed the feature/958-reservation-all-connectors-reserved branch from 47b7f5d to 4314efc Compare December 16, 2024 11:28
@maaikez maaikez merged commit 4180de7 into main Dec 16, 2024
11 checks passed
@maaikez maaikez deleted the feature/958-reservation-all-connectors-reserved branch December 16, 2024 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants