ShmemControllableSource.cpp 1.9 KB
Newer Older
1
2
/** Example of shared memory interface
 *
Steffen Vogel's avatar
Steffen Vogel committed
3
 * @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
4
 * @copyright 2017-2018, Institute for Automation of Complex Power Systems, EONERC
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
 *
 * DPsim
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *********************************************************************************/

22
#include <DPsim.h>
23
24

using namespace DPsim;
25
using namespace CPS::DP;
26
using namespace CPS::DP::Ph1;
27
28

int main(int argc, char *argv[]) {
Steffen Vogel's avatar
Steffen Vogel committed
29

30
	Interface::Config conf;
31
32
33
34
35
36
37
	conf.samplelen = 64;
	conf.queuelen = 1024;
	conf.polling = false;

	String in  = "/dpsim10";
	String out = "/dpsim01";

38
39
40
41
	Real timeStep = 0.001;
	Real finalTime = 10;
	String simName = "ShmemControllableSource";

42
	Interface intf(out, in, &conf);
43

44
	// Nodes
Markus Mirz's avatar
Markus Mirz committed
45
	auto n1 = Node::make("n1");
46

47
	// Components
Markus Mirz's avatar
Markus Mirz committed
48
49
50
51
	auto ecs = CurrentSource::make("v_intf");
	ecs->setParameters(Complex(10, 0));
	auto r1 = Resistor::make("r_1");
	r1->setParameters(1);
Steffen Vogel's avatar
Steffen Vogel committed
52

53
54
	ecs->connect({ Node::GND, n1 });
	r1->connect({ Node::GND, n1 });
55

Steffen Vogel's avatar
Steffen Vogel committed
56
	intf.addImport(ecs->attribute<Complex>("I_ref"), 0);
Steffen Vogel's avatar
merge    
Steffen Vogel committed
57
	intf.addExport(ecs->attribute<Complex>("v_comp"), 0);
58

Steffen Vogel's avatar
Steffen Vogel committed
59
	auto sys = SystemTopology(50, SystemNodeList{n1}, SystemComponentList{ecs, r1});
60
	auto sim = RealTimeSimulation(simName, sys, timeStep, finalTime,
61
	Domain::DP, Solver::Type::MNA, Logger::Level::INFO);
62

63
	sim.addInterface(&intf);
64
	sim.run();
Steffen Vogel's avatar
Steffen Vogel committed
65

66
67
	return 0;
}