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
c9532b89
Commit
c9532b89
authored
Sep 13, 2017
by
Georg Martin Reinke
Browse files
add another "done" simulation state
Former-commit-id:
50c7da4e
parent
cac0c80e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Source/DPsimMain.cpp
View file @
c9532b89
...
...
@@ -43,7 +43,8 @@ std::vector<BaseComponent*> components;
enum
SimState
{
StateStopped
=
0
,
StateRunning
,
StatePaused
StatePaused
,
StateDone
};
static
std
::
thread
*
simThread
;
...
...
@@ -87,7 +88,7 @@ static void simThreadFunction(SimContext* ctx) {
}
}
lk
.
lock
();
ctx
->
state
=
State
Stopped
;
ctx
->
state
=
State
Done
;
ctx
->
cond
.
notify_one
();
}
...
...
@@ -96,6 +97,9 @@ static PyObject* pythonStart(PyObject *self, PyObject *args) {
if
(
globalCtx
->
state
==
StateRunning
)
{
PyErr_SetString
(
PyExc_SystemError
,
"Simulation already started"
);
return
nullptr
;
}
else
if
(
globalCtx
->
state
==
StateDone
)
{
PyErr_SetString
(
PyExc_SystemError
,
"Simulation already finished"
);
return
nullptr
;
}
else
if
(
globalCtx
->
state
==
StatePaused
)
{
globalCtx
->
stop
=
0
;
globalCtx
->
cond
.
notify_one
();
...
...
@@ -118,6 +122,9 @@ static PyObject* pythonStep(PyObject *self, PyObject *args) {
}
else
if
(
globalCtx
->
state
==
StatePaused
)
{
globalCtx
->
stop
=
1
;
globalCtx
->
cond
.
notify_one
();
}
else
if
(
globalCtx
->
state
==
StateDone
)
{
PyErr_SetString
(
PyExc_SystemError
,
"Simulation already finished"
);
return
nullptr
;
}
else
{
PyErr_SetString
(
PyExc_SystemError
,
"Simulation currently running"
);
return
nullptr
;
...
...
@@ -144,9 +151,12 @@ static PyObject* pythonPause(PyObject *self, PyObject *args) {
static
PyObject
*
pythonWait
(
PyObject
*
self
,
PyObject
*
args
)
{
std
::
unique_lock
<
std
::
mutex
>
lk
(
globalCtx
->
mut
);
if
(
globalCtx
->
state
==
State
Stopped
)
{
if
(
globalCtx
->
state
==
State
Done
)
{
Py_INCREF
(
Py_None
);
return
Py_None
;
}
else
if
(
globalCtx
->
state
==
StateStopped
)
{
PyErr_SetString
(
PyExc_SystemError
,
"Simulation not currently running"
);
return
nullptr
;
}
else
if
(
globalCtx
->
state
==
StatePaused
)
{
PyErr_SetString
(
PyExc_SystemError
,
"Simulation currently paused"
);
return
nullptr
;
...
...
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