-
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
Added charging schedules definition #582
Conversation
Note this is an API breaking change. Originally charging schedules were published: { "0": {...}, "1": {...}} using the connector number as the key. This is not supported in the YAML interface or type definitions. Instead an array is used with an additional key added: [ { "connector": 0, ...}, { "connector": 1, ...} ... ] Note is should not be assumed that the array index will match the connector number. The existing types in libocpp have not been changed. A new mapping has been created in the OCPP module. (OCPP201 doesn't publish schedules at the moment) Signed-off-by: James Chapman <[email protected]>
The autogenerated code doesn't support a module var being an array (of a specific object type) [{},{}] Instead the array is now wrapped in an object: {"schedules": [{},{}]} Signed-off-by: James Chapman <[email protected]>
Signed-off-by: James Chapman <[email protected]>
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.
Types and interfaces look good from my side.
Although the definitions in the OCPP spec are camelCase, we try to stick to snake_case in our internal interfaces. I have added some suggestions inline, but the code also needs to apply the changes.
@corneliusclaussen : Do we need changes on the EnergyManager side if we make these changes?
types/ocpp.yaml
Outdated
- startPeriod | ||
- limit | ||
- stackLevel |
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.
- startPeriod | |
- limit | |
- stackLevel | |
- start_period | |
- limit | |
- stack_level |
types/ocpp.yaml
Outdated
startPeriod: | ||
type: integer | ||
limit: | ||
type: number | ||
numberPhases: | ||
type: integer | ||
stackLevel: | ||
type: integer |
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.
startPeriod: | |
type: integer | |
limit: | |
type: number | |
numberPhases: | |
type: integer | |
stackLevel: | |
type: integer | |
start_period: | |
type: integer | |
limit: | |
type: number | |
number_phases: | |
type: integer | |
stack_level: | |
type: integer |
types/ocpp.yaml
Outdated
- chargingRateUnit | ||
- chargingSchedulePeriod |
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.
- chargingRateUnit | |
- chargingSchedulePeriod | |
- charging_rate_unit | |
- charging_schedule_period |
types/ocpp.yaml
Outdated
connector: | ||
type: integer | ||
minimum: 0 | ||
chargingRateUnit: |
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.
chargingRateUnit: | |
charging_rate_unit: |
types/ocpp.yaml
Outdated
minimum: 0 | ||
chargingRateUnit: | ||
type: string | ||
chargingSchedulePeriod: |
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.
chargingSchedulePeriod: | |
charging_schedule_period: |
types/ocpp.yaml
Outdated
$ref: /ocpp#/ChargingSchedulePeriod | ||
duration: | ||
type: integer | ||
startSchedule: |
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.
startSchedule: | |
start_schedule: |
types/ocpp.yaml
Outdated
type: integer | ||
startSchedule: | ||
type: string | ||
minChargingRate: |
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.
minChargingRate: | |
min_charging_rate: |
modules/OCPP/OCPP.cpp
Outdated
@@ -141,14 +142,46 @@ void OCPP::set_external_limits(const std::map<int32_t, ocpp::v16::EnhancedChargi | |||
} | |||
} | |||
|
|||
namespace { | |||
types::ocpp::ChargingSchedulePeriod to_ChargingSchedulePeriod(const ocpp::v16::EnhancedChargingSchedulePeriod& period) { |
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.
Please use the conversions.hpp / cpp for these conversions
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.
moved functions to conversions.[ch]pp
fix: moved conversions to separate file Signed-off-by: James Chapman <[email protected]>
The case naming came from struct EnhancedChargingSchedule rather than OCPP. DataTransferStatus:
description: Data Transfer Status enum
type: string
enum:
- Accepted
- Rejected
- UnknownMessageId
- UnknownVendorId Updated |
It doesn't look like EnergyManager depends on the ocpp interface and I can't locate any MQTT subscribe for charging_schedules. Looking at recent updates to main it seems the API module now subscribes for charging_schedules. |
c310bf6
to
fa3f464
Compare
Describe your changes
Create YAML/JSON definition for charging schedules.
Note this is an API breaking change. Originally charging schedules were published:
Using the connector number as the key. This is not supported in the YAML interface or type definitions.
Instead an array is used with an additional key added:
Unfortunately the generated code doesn't like arrays at that point, so the array has been wrapped in an object:
Note is should not be assumed that the array index will match the connector number.
The existing types in libocpp have not been changed. A new mapping has been created in the OCPP module to convert from the internal format to the MQTT JSON format.
Note OCPP201 doesn't publish schedules at the moment and has not changed.
Issue ticket number and link
None
Checklist before requesting a review