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
2d7d5522
Commit
2d7d5522
authored
Sep 13, 2017
by
Georg Martin Reinke
Browse files
pass few parameters to Simulation constructor
parent
2c7053e9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Source/PySimulation.cpp
View file @
2d7d5522
#include "PySimulation.h"
#include <iostream>
using
namespace
DPsim
;
std
::
vector
<
BaseComponent
*>
DPsim
::
components
;
void
PySimulation
::
simThreadFunction
(
PySimulation
*
pySim
)
{
bool
notDone
=
true
;
Logger
rlog
(
"rvector.csv"
),
llog
(
"lvector.csv"
);
std
::
unique_lock
<
std
::
mutex
>
lk
(
*
pySim
->
mut
,
std
::
defer_lock
);
pySim
->
numStep
=
0
;
while
(
pySim
->
running
&&
notDone
)
{
notDone
=
pySim
->
sim
->
step
(
*
pySim
->
log
);
notDone
=
pySim
->
sim
->
step
(
*
pySim
->
log
,
llog
,
rlog
);
pySim
->
numStep
++
;
pySim
->
sim
->
increaseByTimeStep
();
if
(
pySim
->
sigPause
)
{
...
...
@@ -41,8 +46,14 @@ PyObject* PySimulation::newfunc(PyTypeObject* type, PyObject *args, PyObject *kw
int
PySimulation
::
init
(
PySimulation
*
self
,
PyObject
*
args
,
PyObject
*
kwds
)
{
// TODO: actually parse arguments (frequency, timestep etc.)
static
char
*
kwlist
[]
=
{
"frequency"
,
"timestep"
,
"duration"
,
NULL
};
double
frequency
,
timestep
,
duration
;
if
(
!
PyArg_ParseTupleAndKeywords
(
args
,
kwds
,
"|ddd"
,
kwlist
,
&
frequency
,
&
timestep
,
&
duration
))
return
-
1
;
self
->
log
=
new
Logger
(
"log.txt"
);
self
->
sim
=
new
Simulation
(
components
,
2
*
PI
*
50
,
1e-3
,
0.3
,
*
self
->
log
);
self
->
sim
=
new
Simulation
(
components
,
2
*
PI
*
frequency
,
timestep
,
duration
,
*
self
->
log
);
return
0
;
};
...
...
@@ -51,6 +62,7 @@ void PySimulation::dealloc(PySimulation* self) {
// We have to cancel the running thread here, because otherwise self can't
// be freed.
PySimulation
::
stop
((
PyObject
*
)
self
,
NULL
);
self
->
simThread
->
join
();
delete
self
->
simThread
;
}
if
(
self
->
sim
)
...
...
Source/PySimulation.h
View file @
2d7d5522
...
...
@@ -103,7 +103,6 @@ namespace DPsim {
PySimulation
::
newfunc
,
/* tp_new */
};
static
std
::
vector
<
BaseComponent
*>
components
;
extern
std
::
vector
<
BaseComponent
*>
components
;
};
#endif
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