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
8e767e65
Commit
8e767e65
authored
Sep 14, 2017
by
Georg Martin Reinke
Browse files
add lvector method to PySimulation
parent
1a6e1dba
Changes
2
Hide whitespace changes
Inline
Side-by-side
Source/PySimulation.cpp
View file @
8e767e65
...
...
@@ -78,6 +78,19 @@ void PySimulation::dealloc(PySimulation* self) {
Py_TYPE
(
self
)
->
tp_free
((
PyObject
*
)
self
);
}
PyObject
*
PySimulation
::
lvector
(
PyObject
*
self
,
PyObject
*
args
)
{
PySimulation
*
pySim
=
(
PySimulation
*
)
self
;
if
(
pySim
->
state
==
StateRunning
)
{
PyErr_SetString
(
PyExc_SystemError
,
"Simulation currently running"
);
return
nullptr
;
}
Matrix
&
lvector
=
pySim
->
sim
->
getLeftSideVector
();
PyObject
*
list
=
PyList_New
(
lvector
.
rows
());
for
(
int
i
=
0
;
i
<
lvector
.
rows
();
i
++
)
PyList_SetItem
(
list
,
i
,
PyFloat_FromDouble
(
lvector
(
i
,
0
)));
return
list
;
}
PyObject
*
PySimulation
::
start
(
PyObject
*
self
,
PyObject
*
args
)
{
PySimulation
*
pySim
=
(
PySimulation
*
)
self
;
std
::
unique_lock
<
std
::
mutex
>
lk
(
*
pySim
->
mut
);
...
...
Source/PySimulation.h
View file @
8e767e65
...
...
@@ -45,6 +45,7 @@ namespace DPsim {
static
void
dealloc
(
PySimulation
*
);
// Methods that are actually available from Python
static
PyObject
*
lvector
(
PyObject
*
self
,
PyObject
*
args
);
static
PyObject
*
start
(
PyObject
*
self
,
PyObject
*
args
);
static
PyObject
*
step
(
PyObject
*
self
,
PyObject
*
args
);
static
PyObject
*
stop
(
PyObject
*
self
,
PyObject
*
args
);
...
...
@@ -53,6 +54,7 @@ namespace DPsim {
};
static
PyMethodDef
PySimulation_methods
[]
=
{
{
"lvector"
,
PySimulation
::
lvector
,
METH_NOARGS
,
"Returns the left-side vector from the last step."
},
{
"start"
,
PySimulation
::
start
,
METH_NOARGS
,
"Start the simulation, or resume if it is paused."
},
{
"step"
,
PySimulation
::
step
,
METH_NOARGS
,
"Perform a single simulation step."
},
{
"stop"
,
PySimulation
::
stop
,
METH_NOARGS
,
"Cancel the running simulation."
},
...
...
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