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
658b8c6f
Commit
658b8c6f
authored
Sep 18, 2018
by
Steffen Vogel
🎅🏼
Browse files
python: add new option "fail_on_overrun" for dpsim.Simulation
Former-commit-id:
5aa67ba5
parent
af5cd6eb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Include/dpsim/Python/Simulation.h
View file @
658b8c6f
...
...
@@ -76,6 +76,7 @@ namespace Python {
double
realTimeStep
;
/// effective timestep for real-time simulation
bool
realTime
;
bool
startSync
;
bool
failOnOverrun
;
bool
singleStepping
;
/// Debugger like stepping for simulations
Timer
::
StartTimePoint
startTime
;
...
...
Source/Python/Simulation.cpp
View file @
658b8c6f
...
...
@@ -81,8 +81,10 @@ void Python::Simulation::threadFunction(Python::Simulation *self)
catch
(
Timer
::
OverrunException
e
)
{
std
::
unique_lock
<
std
::
mutex
>
lk
(
*
self
->
mut
);
newState
(
self
,
Simulation
::
State
::
overrun
);
self
->
cond
->
notify_one
();
if
(
self
->
failOnOverrun
)
{
newState
(
self
,
Simulation
::
State
::
overrun
);
self
->
cond
->
notify_one
();
}
}
}
...
...
@@ -151,10 +153,11 @@ PyObject* Python::Simulation::newfunc(PyTypeObject* subtype, PyObject *args, PyO
int
Python
::
Simulation
::
init
(
Simulation
*
self
,
PyObject
*
args
,
PyObject
*
kwds
)
{
static
const
char
*
kwlist
[]
=
{
"name"
,
"system"
,
"timestep"
,
"duration"
,
"start_time"
,
"start_time_us"
,
"sim_type"
,
"solver_type"
,
"single_stepping"
,
"rt"
,
"rt_factor"
,
"start_sync"
,
"init_steady_state"
,
"log_level"
,
nullptr
};
static
const
char
*
kwlist
[]
=
{
"name"
,
"system"
,
"timestep"
,
"duration"
,
"start_time"
,
"start_time_us"
,
"sim_type"
,
"solver_type"
,
"single_stepping"
,
"rt"
,
"rt_factor"
,
"start_sync"
,
"init_steady_state"
,
"log_level"
,
"fail_on_overrun"
,
nullptr
};
double
timestep
=
1e-3
,
duration
=
DBL_MAX
,
rtFactor
=
1
;
const
char
*
name
=
nullptr
;
int
t
=
0
,
s
=
0
,
rt
=
0
,
ss
=
0
,
st
=
0
,
initSteadyState
=
0
;
int
failOnOverrun
=
0
;
CPS
::
Logger
::
Level
logLevel
=
CPS
::
Logger
::
Level
::
INFO
;
...
...
@@ -164,8 +167,8 @@ int Python::Simulation::init(Simulation* self, PyObject *args, PyObject *kwds)
enum
Solver
::
Type
solverType
;
enum
Domain
domain
;
if
(
!
PyArg_ParseTupleAndKeywords
(
args
,
kwds
,
"sO|ddkkiippdppi"
,
(
char
**
)
kwlist
,
&
name
,
&
self
->
pySys
,
&
timestep
,
&
duration
,
&
startTime
,
&
startTimeUs
,
&
s
,
&
t
,
&
ss
,
&
rt
,
&
rtFactor
,
&
st
,
&
initSteadyState
,
&
logLevel
))
{
if
(
!
PyArg_ParseTupleAndKeywords
(
args
,
kwds
,
"sO|ddkkiippdppi
p
"
,
(
char
**
)
kwlist
,
&
name
,
&
self
->
pySys
,
&
timestep
,
&
duration
,
&
startTime
,
&
startTimeUs
,
&
s
,
&
t
,
&
ss
,
&
rt
,
&
rtFactor
,
&
st
,
&
initSteadyState
,
&
logLevel
,
&
failOnOverrun
))
{
return
-
1
;
}
...
...
@@ -173,6 +176,7 @@ int Python::Simulation::init(Simulation* self, PyObject *args, PyObject *kwds)
self
->
realTime
=
rt
;
self
->
startSync
=
ss
;
self
->
singleStepping
=
st
;
self
->
failOnOverrun
=
failOnOverrun
;
self
->
realTimeStep
=
timestep
/
rtFactor
;
if
(
startTime
>
0
)
{
...
...
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