Repository navigation
soc_calculation_threshold, range calculation #3153
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
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
5e21f4b
soc_calculation_threshold, range calculation
rleidner 21ac21a
fix pytest: adding average_consump
rleidner ec82429
fix flake8 issues
rleidner 847138a
Update packages/modules/common/configurable_vehicle.py
rleidner 42b3ef8
resolve conflict in update_config.py
rleidner befde9c
Merge branch 'soc_calc_threshold' of github.com:rleidner/core into so…
rleidner 0f907f9
Merge branch 'master' into soc_calc_threshold
rleidner dc56e0b
simplify as requested
rleidner 9565ea2
Merge branch 'master' of github.com:rleidner/core into soc_calc_thres…
rleidner 4197084
conclude merge
rleidner 50b72ce
calc_soc -> calc_vehicle_data, fix pytest
rleidner bcfeb44
fix flake8
rleidner dc8996a
remove odometer
rleidner 7830a88
Feinschliff
rleidner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
packages/modules/vehicles/common/calc_soc/calc_soc_test.py
This file was deleted.
Oops, something went wrong.
File renamed without changes.
25 changes: 25 additions & 0 deletions
25
packages/modules/vehicles/common/calc_vehicle_data/calc_vehicle_data.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import logging | ||
|
|
||
| from modules.common.abstract_vehicle import VehicleUpdateData | ||
| from modules.common.component_state import CarState | ||
|
|
||
| log = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| def calc_vehicle_data(vehicle_update_data: VehicleUpdateData, | ||
| last_imported: float) -> CarState: | ||
| imported_since_last_soc = vehicle_update_data.imported - last_imported | ||
| energy_battery_gain = imported_since_last_soc * vehicle_update_data.efficiency / 100 | ||
| battery_soc_gain = (energy_battery_gain / vehicle_update_data.battery_capacity) * 100 | ||
| _soc = vehicle_update_data.last_soc + battery_soc_gain | ||
| _eff = vehicle_update_data.efficiency | ||
| log.debug( | ||
| f"SoC-Gain: (({imported_since_last_soc/1000}kWh charged * {_eff}% _eff) / " | ||
| f"{vehicle_update_data.battery_capacity/1000}kWh battery-size) * 100 = {battery_soc_gain}%", | ||
| ) | ||
| log.debug(f"{vehicle_update_data.last_soc}% + {energy_battery_gain / 1000}kWh = {_soc}%") | ||
| if _soc > 100: | ||
| log.warning(f"Calculated SoC of {_soc}% exceeds maximum and is limited to 100%! Check your settings!") | ||
| _soc = 100 | ||
| _range = int(vehicle_update_data.battery_capacity * _soc / vehicle_update_data.average_consump) | ||
| return CarState(soc=_soc, range=_range) | ||
19 changes: 19 additions & 0 deletions
19
packages/modules/vehicles/common/calc_vehicle_data/calc_vehicle_data_test.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
|
|
||
| from modules.common.abstract_vehicle import VehicleUpdateData | ||
| from modules.common.component_state import CarState | ||
| from modules.vehicles.common.calc_vehicle_data.calc_vehicle_data import calc_vehicle_data | ||
|
|
||
|
|
||
| def test_calc_vehicle_data(): | ||
| # setup & execution | ||
| carState = calc_vehicle_data(VehicleUpdateData(imported=10000, last_soc=12.6, | ||
| efficiency=90, | ||
| battery_capacity=100000, | ||
| average_consump=18000), | ||
| last_imported=0) | ||
|
|
||
| # evaluation | ||
| # print(f"soc={carState.soc}, range={carState.range}") | ||
| assert isinstance(carState, CarState) | ||
| assert carState.soc == 21.6 | ||
| assert carState.range == 120 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.