Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ACS
Public
Power System Simulation and Optimization
DPsim
DPsim
Commits
cac0c80e
Commit
cac0c80e
authored
Sep 13, 2017
by
Georg Martin Reinke
Browse files
resume simulation if start() is called when paused
Former-commit-id:
269e8378
parent
c067c58f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Source/DPsimMain.cpp
View file @
cac0c80e
...
...
@@ -93,13 +93,17 @@ static void simThreadFunction(SimContext* ctx) {
static
PyObject
*
pythonStart
(
PyObject
*
self
,
PyObject
*
args
)
{
std
::
unique_lock
<
std
::
mutex
>
lk
(
globalCtx
->
mut
);
if
(
globalCtx
->
state
!
=
State
Stopped
)
{
if
(
globalCtx
->
state
=
=
State
Running
)
{
PyErr_SetString
(
PyExc_SystemError
,
"Simulation already started"
);
return
nullptr
;
}
else
if
(
globalCtx
->
state
==
StatePaused
)
{
globalCtx
->
stop
=
0
;
globalCtx
->
cond
.
notify_one
();
}
else
{
globalCtx
->
stop
=
0
;
globalCtx
->
state
=
StateRunning
;
simThread
=
new
std
::
thread
(
simThreadFunction
,
globalCtx
);
}
globalCtx
->
stop
=
0
;
globalCtx
->
state
=
StateRunning
;
simThread
=
new
std
::
thread
(
simThreadFunction
,
globalCtx
);
Py_INCREF
(
Py_None
);
return
Py_None
;
}
...
...
@@ -154,7 +158,7 @@ static PyObject* pythonWait(PyObject *self, PyObject *args) {
}
static
PyMethodDef
pythonMethods
[]
=
{
{
"start"
,
pythonStart
,
METH_VARARGS
,
"Start the simulation."
},
{
"start"
,
pythonStart
,
METH_VARARGS
,
"Start the simulation
, or resume if it is paused
."
},
{
"step"
,
pythonStep
,
METH_VARARGS
,
"Perform a single simulation step."
},
{
"pause"
,
pythonPause
,
METH_VARARGS
,
"Pause the already running simulation."
},
{
"wait"
,
pythonWait
,
METH_VARARGS
,
"Wait for the simulation to finish."
},
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment