forked from OpenGridMap/CIM2Simulink
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generatePowerSystem.m
65 lines (51 loc) · 1.75 KB
/
generatePowerSystem.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
% This script handles the automatic generation of large power systems ins
% Simulink.
%
% Author: First Name: Bernhard
% Last Name: Krop
% E-Mail: b.krop@gmx.de
%
% Last time updated: 25. December 2015
% @param path The path of the input file. This is an optional
% argument. If it does not exist or is not a string,
% 'Input.txt' will be set as standard path.
% @param title The title for the Simulink model. This is an optional
% argument. If it does not exist or is not a string,
% 'untitled' will be set as standard title.
% @return system The Simulink model, created by this script.
function system = generatePowerSystem(path, title)
% Use global variables.
global g_dSystem;
% Make variables global.
global g_sFilePath g_sTitle;
% The path for the input file.
if(exist('path', 'var') && ischar(path))
g_sFilePath = path;
else
g_sFilePath = 'Input.txt';
end
% The CIM objects, defined in the input file.
if(~exist('parseCIM.m', 'file'))
clearvars -global;
error('Cannot find ''parseCIM.m''!');
end
parseCIM();
% The title for the Simulink model.
if(exist('title', 'var') && ischar(title))
g_sTitle = title;
else
g_sTitle = 'untitled';
end
% The Simulink model.
if(~exist('createSystem.m', 'file'))
clearvars -global;
error('Cannot find ''createSystem.m''!');
end
createSystem();
% Open the created system.
open_system(g_dSystem);
% Clean up everything, that is not needed anymore.
system = g_dSystem;
clearvars -global -except system;
end % End of main function.
% End of script