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

DCSupplySimulator: Add C++ simulation module #499

Merged
merged 1 commit into from
Jan 24, 2024

Conversation

barsnick
Copy link
Contributor

This C++ module supplements JsDCSupplySimulator, and emulates its behavior.

Unlike JsDCSupplySimulator, it does not provide the powermeter simulation interface though. This should be implemented in a separate C++ module, if required.

Co-authored-by: Cornelius Claussen [email protected]
Co-authored-by: Fabian Hartung [email protected]
Co-authored-by: Mohannad Oraby [email protected]
Co-authored-by: Moritz Barsnick [email protected]

double settings_connector_max_export_current;
double settings_connector_max_import_current;
types::power_supply_DC::Mode mode;
double connector_voltage;
Copy link
Contributor

Choose a reason for hiding this comment

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

As far as I can see connector_voltage and connector_current are used in the worker thread without locking the mutex. Also the set mode command handler does not use the mutex. Please review all access and add locks or use std::atomic here if it is ok that voltage/current do not both need to be locked at the same time.

@@ -1,3 +1,4 @@
ev_add_module(DCSupplySimulator)
Copy link
Contributor

Choose a reason for hiding this comment

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

We could remove JsDCSupplySimulator probably with this PR and update the configs in core to use the C++ version

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not yet, as the car sides of the SIL configs use JsDCSupplySimulator's powermeter interface implementation. That is not covered in this PR. (Should it be?)

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah right, not neccesarily now, but I'd like to drop the JS module at some point

@barsnick barsnick changed the title DCSupplySimulator: Add C++ module DCSupplySimulator: Add C++ simulation module Jan 22, 2024
@barsnick
Copy link
Contributor Author

Latest commits tested with config/config-sil-dc.yaml with this config:

diff --git a/config/config-sil-dc.yaml b/config/config-sil-dc.yaml
index 0756652..6f77277 100644
--- a/config/config-sil-dc.yaml
+++ b/config/config-sil-dc.yaml
@@ -31,7 +31,7 @@ active_modules:
         - module_id: yeti_driver
           implementation_id: board_support
       powermeter_car_side:
-        - module_id: powersupply_dc
+        - module_id: powersupply_dc_js
           implementation_id: powermeter
       slac:
         - module_id: slac
@@ -46,6 +46,8 @@ active_modules:
         - module_id: imd
           implementation_id: main
   powersupply_dc:
+    module: DCSupplySimulator
+  powersupply_dc_js:
     module: JsDCSupplySimulator
   yeti_driver:
     module: JsYetiSimulator

@barsnick barsnick force-pushed the cb-add-dc-supply-simulator branch from e65b1f5 to 9b6c67e Compare January 22, 2024 16:58
@corneliusclaussen
Copy link
Contributor

Please squash before merging into one commit and adapt commit description

This C++ module emulates the behavior of the existing JsDCSupplySimulator.

Unlike JsDCSupplySimulator, it does not provide the powermeter simulation
interface though. This should be implemented in a separate C++ module.

Co-authored-by: Cornelius Claussen <[email protected]>
Co-authored-by: Fabian Hartung <[email protected]>
Co-authored-by: Mohannad Oraby <[email protected]>
Co-authored-by: Moritz Barsnick <[email protected]>

Signed-off-by: Fabian Hartung <[email protected]>
Signed-off-by: Moritz Barsnick <[email protected]>
@barsnick barsnick force-pushed the cb-add-dc-supply-simulator branch from 9b6c67e to 3d619bb Compare January 24, 2024 13:42
@barsnick barsnick merged commit 3b6a044 into EVerest:main Jan 24, 2024
3 of 4 checks passed
@barsnick barsnick deleted the cb-add-dc-supply-simulator branch January 24, 2024 13:56
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.

3 participants