Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SCDDS-core
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SPC
SCDDS
SCDDS-core
Commits
5f73506d
Commit
5f73506d
authored
4 years ago
by
Federico Felici
Browse files
Options
Downloads
Patches
Plain Diff
Cleanups & split bus definition code
parent
a97f3737
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
code/classes/SCDclass_algo.m
+43
-19
43 additions, 19 deletions
code/classes/SCDclass_algo.m
with
43 additions
and
19 deletions
code/classes/SCDclass_algo.m
+
43
−
19
View file @
5f73506d
...
...
@@ -133,19 +133,20 @@ classdef SCDclass_algo
designDataObj
=
getSection
(
dict
,
'Design Data'
);
end
function
dictionaryObj
=
createdatadictionary
(
obj
,
varargin
)
function
createdatadictionary
(
obj
,
varargin
)
% create data dictionary in path obj.folder/obj.getdatadictionary
dd
=
obj
.
getdatadictionary
;
ddpath
=
fullfile
(
obj
.
folder
,
dd
);
% Close all open models.
bdclose
all
% Close all open data dictionaries
Simulink
.
data
.
dictionary
.
closeAll
(
'-discard'
);
% Create if not existing already
if
isempty
(
ddpath
)
if
isempty
(
which
(
ddpath
)
)
fprintf
(
'generating data dictionary %s\n'
,
fullfile
(
obj
.
folder
,
obj
.
getdatadictionary
));
dictionaryObj
=
Simulink
.
data
.
dictionary
.
create
(
ddpath
);
else
dictionaryObj
=
Simulink
.
data
.
dictionary
.
open
(
ddpath
);
fprintf
(
'Data dictionary %s already exists, not created\n'
,
ddpath
);
Simulink
.
data
.
dictionary
.
create
(
ddpath
);
end
end
...
...
@@ -181,6 +182,8 @@ classdef SCDclass_algo
if
nargin
==
3
assert
(
isa
(
default_function
,
'function_handle'
),
'SCDclass_algo:addtunparamstruct'
,
'third argument, if present, must be a function handle'
);
obj
.
exportedtpsdefaults
{
end
+
1
}
=
default_function
;
% add defaults to list
else
obj
.
exportedtpsdefaults
{
end
+
1
}
=
[];
% empty, no default assigned for this tp
end
end
...
...
@@ -259,6 +262,32 @@ classdef SCDclass_algo
evalin
(
'base'
,
'clear temp;'
);
end
function
addbuses
(
obj
)
% Add buses to data dictionary from .m file descriptions, if
% available. Bus names in obj.inBus, obj.outBus
if
~
isempty
(
which
(
obj
.
inBus
))
&&
~
isempty
(
which
(
obj
.
outBus
))
designDataObj
=
opendatadictionarydesigndata
(
obj
);
fprintf
(
'Add buses to data dictionary: %s, %s\n'
,
obj
.
inBus
,
obj
.
outBus
);
eval
(
obj
.
inBus
);
% eval buses in base workspace
eval
(
obj
.
outBus
);
if
~
designDataObj
.
exist
(
obj
.
inBus
)
addEntry
(
designDataObj
,
obj
.
inBus
,
evalin
(
'base'
,
obj
.
inBus
));
else
entryObj
=
getEntry
(
designDataObj
,
obj
.
inBus
);
setValue
(
entryObj
,
evalin
(
'base'
,
obj
.
inBus
));
end
if
~
designDataObj
.
exist
(
obj
.
outBus
)
addEntry
(
designDataObj
,
obj
.
outBus
,
evalin
(
'base'
,
obj
.
outBus
));
else
entryObj
=
getEntry
(
designDataObj
,
obj
.
outBus
);
setValue
(
entryObj
,
evalin
(
'base'
,
obj
.
outBus
));
end
evalin
(
'base'
,
sprintf
(
'clear %s %s'
,
obj
.
inBus
,
obj
.
outBus
));
else
fprintf
(
'no buses imported in datadictionary - assuming they are already there\n'
)
end
end
%% MDS container methods forwarders
function
obj
=
addparameter
(
obj
,
param
)
...
...
@@ -359,8 +388,7 @@ classdef SCDclass_algo
function
init
(
obj
)
% generate/initialize data dictionary
dictionaryObj
=
obj
.
createdatadictionary
;
designDataObj
=
opendatadictionarydesigndata
(
obj
);
obj
.
createdatadictionary
;
obj
.
callinits
;
% call generic algorithm init functions
...
...
@@ -375,23 +403,19 @@ classdef SCDclass_algo
obj
.
updatetemplatetp
;
% add buses
if
~
isempty
(
which
(
obj
.
inBus
))
&&
~
isempty
(
which
(
obj
.
outBus
))
fprintf
(
'Add buses to data dictionary: %s, %s\n'
,
obj
.
inBus
,
obj
.
outBus
);
eval
(
obj
.
inBus
);
% eval buses in base workspace
eval
(
obj
.
outBus
);
addEntry
(
designDataObj
,
obj
.
inBus
,
evalin
(
'base'
,
obj
.
inBus
));
addEntry
(
designDataObj
,
obj
.
outBus
,
evalin
(
'base'
,
obj
.
outBus
));
evalin
(
'base'
,
sprintf
(
'clear %s %s'
,
obj
.
inBus
,
obj
.
outBus
));
else
fprintf
(
'no buses imported in datadictionary - assuming they are already there\n'
)
end
obj
.
addbuses
;
% add configurations.sldd as referenced data dictionary, plus
% other optional data dictionaries (e.g. used by lower-level components of an algorithm)
for
refdd
=
[
'configurations.sldd'
,
obj
.
refdatadictionaries
]
dictionaryObj
=
Simulink
.
data
.
dictionary
.
open
(
obj
.
getdatadictionary
);
fprintf
(
'adding referenced data dictionary %s to %s \n'
,
refdd
{:},
obj
.
getdatadictionary
)
refddpath
=
which
(
refdd
{:});
assert
(
~
isempty
(
refddpath
),
'could not find %s'
);
dictionaryObj
.
addDataSource
(
refdd
{:});
end
dictionaryObj
.
saveChanges
;
end
function
callinits
(
obj
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment