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

New python interface #933

Merged
merged 1 commit into from
Feb 9, 2021
Merged

New python interface #933

merged 1 commit into from
Feb 9, 2021

Conversation

lochel
Copy link
Member

@lochel lochel commented Feb 6, 2021

Description

This is the attempt of making the python API more object oriented. The old API is kept for compabaility reasons.

Example

new api

import OMSimulator as oms

model = oms.newModel('model')

model.stopTime = 2.0
print(model.stopTime)

model.delete()

old api

import OMSimulator

oms = OMSimulator.OMSimulator()
oms.newModel('model')

oms.setStopTime('model', 2.0)
print(oms.getStopTime('model'))

oms.delete('model')

@lochel lochel self-assigned this Feb 6, 2021
@lochel lochel changed the title Py capi New python interface Feb 6, 2021
@lochel lochel marked this pull request as ready for review February 8, 2021 15:52
@lochel
Copy link
Member Author

lochel commented Feb 8, 2021

This is how the old and new api can be mixed:

import OMSimulator as oms

# old api to create a model
OMSimulator = oms.OMSimulator()
OMSimulator.newModel('model')

# new api using the same model
model = oms.Model('model')

model.stopTime = 2.0
print(model.stopTime)

model.delete()

@lochel lochel force-pushed the py-capi branch 2 times, most recently from a2f5573 to c5f972c Compare February 9, 2021 12:12
@lochel lochel merged commit 3ee6cf2 into OpenModelica:master Feb 9, 2021
@lochel lochel deleted the py-capi branch February 9, 2021 14:30
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.

1 participant