Skip to content

DCP support (wip) - #1558

Open
robbr48 wants to merge 13 commits into
OpenModelica:masterfrom
robbr48:dcp_support
Open

DCP support (wip)#1558
robbr48 wants to merge 13 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
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