Skip to content

DCP support (wip) - #1558

Merged
robbr48 merged 21 commits into
OpenModelica:masterfrom
robbr48:dcp_support
Aug 28, 2026
Merged

DCP support (wip)#1558
robbr48 merged 21 commits into
OpenModelica:masterfrom
robbr48:dcp_support

Conversation

@robbr48

@robbr48 robbr48 commented Jan 30, 2026

Copy link
Copy Markdown
Contributor

As agreed, I made a draft PR of my DCP work. I think we should sit down and discuss implementation details, e.g. where to put the master/slave code and the interaction between FMI and DCP. Also, a lot of things in OMSimulator are currently hard-coded for FMU, so I guess we need to do some refactoring.

@robbr48 robbr48 self-assigned this Jan 30, 2026
@arun3688

arun3688 commented Mar 4, 2026

Copy link
Copy Markdown
Contributor

@robbr48 can you rebase the PR and fix the conflicts it will be easier to fix

@robha67 robha67 mentioned this pull request Apr 1, 2026
@robbr48
robbr48 marked this pull request as ready for review June 1, 2026 13:53
@robbr48

robbr48 commented Jun 1, 2026

Copy link
Copy Markdown
Contributor Author

@arun3688 The implementation is now good enough for merging. Only non-realtime simulations are yet supported, but we can add realtime support later in another PR. Also start time is hard-coded to zero, but it should not matter in most cases. Below is the example Python script I used to test it, you can just replace Hopsan with some other tool:

from OMSimulator import SSP, CRef, Settings
Settings.suppressPath = True

model = SSP()
model.addResource('../../testsuite/resources/Modelica.Blocks.Sources.Sine.fmu', new_name='resources/Sine.fmu')
model.addResource('C:/users/robbr48/Documents/Hopsan/dcp_sin.dcp', new_name='resources/Hopsan.dcp')
model.addResource('../../testsuite/resources/Modelica.Blocks.Math.Gain.fmu', new_name='resources/Gain.fmu')

component1 = model.addComponent(CRef('default', 'Sine1'), 'resources/Sine.fmu')
component3 = model.addComponent(CRef('default', 'Hopsan1'), 'resources/Hopsan.dcp')
component3 = model.addComponent(CRef('default', 'Gain1'), 'resources/Gain.fmu')

model.list()

model.addConnection(CRef('default', 'Sine1', 'y'), CRef('default', 'Hopsan1', 'in'))
model.addConnection(CRef('default', 'Hopsan1', 'out'), CRef('default', 'Gain1', 'u'))

instantiated_model = model.instantiate()
instantiated_model.setStopTime(10);
instantiated_model.setResultFile("SimpleSimulation5_res.mat")
instantiated_model.setDcpPorts(8000, 8001)
instantiated_model.setFixedStepSize(0.001)
instantiated_model.setValue(CRef('default', 'Gain1', 'k'), 2.0)
instantiated_model.setValue(CRef('default', 'Sine1', 'startTime'), -1)

instantiated_model.initialize()
instantiated_model.simulate()
instantiated_model.terminate()
instantiated_model.delete()

@arun3688

arun3688 commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

@robbr48 great i will look into this as early as possible and merge it

@arun3688

Copy link
Copy Markdown
Contributor

@robbr48 Can you rebase your branch with the master and resolve the conflicts so that we can merge it. I tried to rebase the branch but the conflicts are more

@arun3688 arun3688 added the CI/Update Submodules Allow a pull request to update submodules label Aug 25, 2026
@codecov

codecov Bot commented Aug 27, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 2.02128% with 921 lines in your changes missing coverage. Please review.
✅ Project coverage is 27.37%. Comparing base (54d0ffc) to head (6970977).

Files with missing lines Patch % Lines
src/OMSimulatorLib/Model.cpp 1.63% 238 Missing and 2 partials ⚠️
src/OMSimulatorLib/ComponentDCP.cpp 0.00% 163 Missing ⚠️
src/OMSimulatorLib/Values.cpp 0.00% 153 Missing ⚠️
src/OMSimulatorLib/Variable.cpp 5.80% 143 Missing and 3 partials ⚠️
src/OMSimulatorLib/System.cpp 3.54% 132 Missing and 4 partials ⚠️
src/OMSimulatorLib/DCPInfo.cpp 0.00% 39 Missing ⚠️
src/OMSimulatorLib/Util.h 0.00% 23 Missing ⚠️
src/OMSimulatorLib/ComRef.cpp 0.00% 7 Missing ⚠️
src/OMSimulatorLib/OMSimulator.cpp 12.50% 7 Missing ⚠️
src/OMSimulatorLib/Component.cpp 0.00% 0 Missing and 2 partials ⚠️
... and 4 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1558      +/-   ##
==========================================
- Coverage   29.24%   27.37%   -1.87%     
==========================================
  Files          68       72       +4     
  Lines       12960    13889     +929     
  Branches     8389     8966     +577     
==========================================
+ Hits         3790     3802      +12     
- Misses       7979     8888     +909     
- Partials     1191     1199       +8     
Flag Coverage Δ
linux 27.37% <2.02%> (-1.87%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@robbr48
robbr48 merged commit d318ba2 into OpenModelica:master Aug 28, 2026
4 of 6 checks passed
@robbr48
robbr48 deleted the dcp_support branch August 28, 2026 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI/Update Submodules Allow a pull request to update submodules

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants