-
Notifications
You must be signed in to change notification settings - Fork 2
Fix OCPP sample to use consistent, realistic charging simulation values #274
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
base: main
Are you sure you want to change the base?
Conversation
- Add connector_meter struct to track meter values per connector - Implement get_current_meter_value() to simulate realistic charging at ~2 Wh/second - Use consistent starting values (connector 1: 1000 Wh, connector 2: 2000 Wh) - Replace random values in start/stop transactions with tracked meter values - Ensure meter readings during charging are consistent with start/stop values Co-authored-by: kartben <[email protected]>
Co-authored-by: kartben <[email protected]>
- Track meter values with sensible starting point (1000 Wh) - Calculate energy consumed based on time at ~2 Wh/second - Ensure start and stop transaction use consistent values - Update meter reading callback to provide realistic values Co-authored-by: kartben <[email protected]>
Co-authored-by: kartben <[email protected]>
|
There is more than just OCPP_OMM_ACTIVE_ENERGY_TO_EV , implement all the other types of measures |
- Add support for all meter measurand types defined in OCPP spec - Provide realistic values for current, power, voltage, frequency, etc. - Active energy still uses time-based calculation for consistency - Reactive energy/power calculated as ~10% of active (power factor 0.9) - Added comprehensive comments explaining each measurement type - Updated both sample and test files with complete implementation Co-authored-by: kartben <[email protected]>
Implemented all 17 OCPP meter measurand types in commit 3039fe0:
All values are realistic for a 7.2kW European EV charger (32A @ 230V, 50Hz). The active energy measurand continues to use the time-based calculation for consistency with start/stop transactions. |
The OCPP sample used random values for meter readings at transaction start/stop, with polling callbacks returning unrelated incrementing values. This made it impossible to track realistic energy consumption or verify charging behavior.
Changes
Sample application (
samples/net/ocpp/src/main.c):struct connector_meter) with start value, timestamp, and charging stateget_current_meter_value()to simulate 7.2 kW charging power (~2 Wh/second based on elapsed time)sys_rand32_get()calls with tracked meter values inocpp_start_transaction()andocpp_stop_transaction()Test file (
tests/net/lib/ocpp/src/main.c):io->stop_charge.id_con→io->start_charge.id_conin start charging callbackBefore:
After:
All simulated values are realistic for a 7.2kW European EV charging station (32A @ 230V, 50Hz).
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.