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
9a41dfc6
Commit
9a41dfc6
authored
3 years ago
by
Federico Felici
Browse files
Options
Downloads
Patches
Plain Diff
some cleanups
parent
a264ec22
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
code/classes/SCDclass_component.m
+3
-39
3 additions, 39 deletions
code/classes/SCDclass_component.m
code/classes/SCDclass_expcode.m
+21
-32
21 additions, 32 deletions
code/classes/SCDclass_expcode.m
code/classes/SCDclass_node.m
+35
-0
35 additions, 0 deletions
code/classes/SCDclass_node.m
with
59 additions
and
71 deletions
code/classes/SCDclass_component.m
+
3
−
39
View file @
9a41dfc6
classdef
SCDclass_component
classdef
SCDclass_component
% Superclass for SCD component
% Superclass for SCD component
% Can be a wrapper or a node or all SCD
% Can be a wrapper or a node
% Anything that has a model, a data dictionary
% Includes functions to link associated data dictionaries
% and optionally an associated algorithm
properties
properties
loadverbose
=
1
;
loadverbose
=
1
;
...
@@ -61,42 +60,7 @@ classdef SCDclass_component
...
@@ -61,42 +60,7 @@ classdef SCDclass_component
end
end
end
end
end
end
function
obj
=
linknodedd
(
obj
,
node
)
% link node data dictionary to main expcode object data dicationary
assert
(
isa
(
node
,
'SCDclass_node'
),
'node must be an SCDclass_node object'
)
ddObj
=
Simulink
.
data
.
dictionary
.
open
(
obj
.
ddname
);
prefix
=
'SCD_rtc'
;
% already linked sources
prevsources
=
ddObj
.
DataSources
;
prevsources_nodes
=
prevsources
(
startsWith
(
prevsources
,
prefix
));
% make algo data dictionary list list
reqsources
=
node
.
ddname
;
% removing unnecessary ones
for
ii
=
1
:
numel
(
prevsources_nodes
)
mysource
=
prevsources_nodes
{
ii
};
if
~
contains
(
reqsources
,
mysource
)
obj
.
printlog
(
'Removing algorithm data source %s from %s'
,
mysource
,
obj
.
ddname
);
ddObj
.
removeDataSource
(
prevsources_nodes
{
ii
})
end
end
% add new ones not yet present
mysource
=
reqsources
;
assert
(
startsWith
(
mysource
,
prefix
),
...
'attempting to add algo dd: %s that does not start with
''
%s
''
-aborting'
,
prefix
,
mysource
);
if
contains
(
prevsources
,
mysource
)
obj
.
printlog
(
'Not adding node data source %s - already exists'
,
mysource
);
else
obj
.
printlog
(
'Adding node data source %s to %s'
,
mysource
,
obj
.
ddname
);
ddObj
.
addDataSource
(
mysource
);
end
end
function
obj
=
printlog
(
obj
,
str
,
varargin
)
function
obj
=
printlog
(
obj
,
str
,
varargin
)
% printlog, allows sprintf()-like expressions
% printlog, allows sprintf()-like expressions
if
obj
.
loadverbose
==
1
if
obj
.
loadverbose
==
1
...
...
This diff is collapsed.
Click to expand it.
code/classes/SCDclass_expcode.m
+
21
−
32
View file @
9a41dfc6
...
@@ -37,10 +37,10 @@ classdef SCDclass_expcode
...
@@ -37,10 +37,10 @@ classdef SCDclass_expcode
modeltoactualize
% name of the algorithm to actualize ('all' means all coonfigured)
modeltoactualize
% name of the algorithm to actualize ('all' means all coonfigured)
algos
% list of algorithms objects
algos
% list of algorithms objects
nodes
% array of node properties structs
nodes
% array of node properties structs
configur
ednodes
% nodes that are
configured (that exist)
defin
ednodes
% nodes that are
defined in Simulink
configur
edcpus
% cpus per node nodes that are
configured (that exist)
defin
edcpus
% cpus per node nodes that are
defined in Simulink
ddname
% top level
data dictionary name
for the expcode
ddname
=
'tcv.sldd'
% main expcode
data dictionary name
ddpath
%
top level
data dicationary save path
ddpath
%
main expcode
data dicationary save path
end
end
%%
%%
...
@@ -77,17 +77,6 @@ classdef SCDclass_expcode
...
@@ -77,17 +77,6 @@ classdef SCDclass_expcode
end
end
end
end
function
mydd
=
getddname
(
inode
)
if
nargin
==
0
mydd
=
'tcv.sldd'
;
elseif
nargin
==
1
assert
(
isnumeric
(
inode
))
mydd
=
sprintf
(
'SCD_rtc_%02d.sldd'
,
inode
);
else
error
(
'invalid number of arguments'
);
end
end
function
close_all
(
saveflag
)
function
close_all
(
saveflag
)
if
nargin
==
0
if
nargin
==
0
saveflag
=
1
;
saveflag
=
1
;
...
@@ -119,14 +108,14 @@ classdef SCDclass_expcode
...
@@ -119,14 +108,14 @@ classdef SCDclass_expcode
obj
.
maincode
=
1
;
obj
.
maincode
=
1
;
obj
.
status
=
'debug'
;
obj
.
status
=
'debug'
;
obj
.
loadverbose
=
1
;
obj
.
loadverbose
=
1
;
obj
.
ddname
=
obj
.
getddname
;
hardwarepath
=
fileparts
(
which
(
'tcv.slx'
));
mainslx
=
obj
.
getslxname
;
assert
(
~
isempty
(
hardwarepath
),
'tcv.slx not found?'
)
hardwarepath
=
fileparts
(
which
(
mainslx
));
assert
(
~
isempty
(
hardwarepath
),
'%s not found?'
,
mainslx
)
obj
.
ddpath
=
hardwarepath
;
obj
.
ddpath
=
hardwarepath
;
obj
.
configur
ednodes
=
[
1
2
6
7
8
];
obj
.
defin
ednodes
=
[
1
2
6
7
8
];
obj
.
configur
edcpus
=
[{
1
};
...
obj
.
defin
edcpus
=
[{
1
};
...
{
1
:
6
};
...
{
1
:
6
};
...
{};
...
{};
...
{
1
};
...
{
1
};
...
...
@@ -142,10 +131,10 @@ classdef SCDclass_expcode
...
@@ -142,10 +131,10 @@ classdef SCDclass_expcode
obj
.
mdscontainer
=
SCDclass_mdsobjcontainer
;
obj
.
mdscontainer
=
SCDclass_mdsobjcontainer
;
obj
.
taskcontainer
=
SCDclass_taskcontainer
;
obj
.
taskcontainer
=
SCDclass_taskcontainer
;
nnodes
=
numel
(
obj
.
configur
ednodes
);
nnodes
=
numel
(
obj
.
defin
ednodes
);
obj
.
nodes
=
cell
(
1
,
nnodes
);
obj
.
nodes
=
cell
(
1
,
nnodes
);
for
inode
=
1
:
nnodes
for
inode
=
1
:
nnodes
nodenr
=
obj
.
configur
ednodes
(
inode
);
nodenr
=
obj
.
defin
ednodes
(
inode
);
obj
.
nodes
{
nodenr
}
=
SCDclass_node
(
nodenr
);
obj
.
nodes
{
nodenr
}
=
SCDclass_node
(
nodenr
);
end
end
end
end
...
@@ -202,7 +191,7 @@ classdef SCDclass_expcode
...
@@ -202,7 +191,7 @@ classdef SCDclass_expcode
dd
=
Simulink
.
data
.
dictionary
.
open
(
obj
.
ddname
);
dd
=
Simulink
.
data
.
dictionary
.
open
(
obj
.
ddname
);
% link data dictionaries for active nodes
% link data dictionaries for active nodes
for
ii
=
obj
.
configur
ednodes
for
ii
=
obj
.
defin
ednodes
mydatasource
=
obj
.
nodes
{
ii
}
.
ddname
;
mydatasource
=
obj
.
nodes
{
ii
}
.
ddname
;
fprintf
(
'adding data source %s to %s\n'
,
mydatasource
,
obj
.
ddname
)
fprintf
(
'adding data source %s to %s\n'
,
mydatasource
,
obj
.
ddname
)
dd
.
addDataSource
(
mydatasource
);
dd
.
addDataSource
(
mydatasource
);
...
@@ -711,8 +700,8 @@ classdef SCDclass_expcode
...
@@ -711,8 +700,8 @@ classdef SCDclass_expcode
fprintf
(
'opening %s\n'
,
datadictname
)
fprintf
(
'opening %s\n'
,
datadictname
)
% Looping through every active node
% Looping through every active node
for
idx_nodedds
=
1
:
numel
(
obj
.
configur
ednodes
)
for
idx_nodedds
=
1
:
numel
(
obj
.
defin
ednodes
)
inode
=
obj
.
configur
ednodes
(
idx_nodedds
);
inode
=
obj
.
defin
ednodes
(
idx_nodedds
);
mynode
=
obj
.
nodes
{
inode
};
mynode
=
obj
.
nodes
{
inode
};
% Add all wrapper dictionaries as datasources for main dd
% Add all wrapper dictionaries as datasources for main dd
...
@@ -757,8 +746,8 @@ classdef SCDclass_expcode
...
@@ -757,8 +746,8 @@ classdef SCDclass_expcode
% obj.mdscontainer.buildworkspacesimstruct; % old
% obj.mdscontainer.buildworkspacesimstruct; % old
dd
=
SCDconf_getdatadict
(
obj
.
ddname
);
dd
=
SCDconf_getdatadict
(
obj
.
ddname
);
for
ii
=
1
:
numel
(
obj
.
configur
ednodes
)
for
ii
=
1
:
numel
(
obj
.
defin
ednodes
)
inode
=
obj
.
configur
ednodes
(
ii
);
inode
=
obj
.
defin
ednodes
(
ii
);
buildworkspacesimstructnode
(
obj
,
inode
,
dd
);
buildworkspacesimstructnode
(
obj
,
inode
,
dd
);
end
end
...
@@ -782,10 +771,10 @@ classdef SCDclass_expcode
...
@@ -782,10 +771,10 @@ classdef SCDclass_expcode
zeroElem
=
Simulink
.
BusElement
;
zeroElem
=
Simulink
.
BusElement
;
zeroElem
.
Name
=
'zero'
;
zeroElem
.
Name
=
'zero'
;
Elems
=
repmat
(
Simulink
.
BusElement
,
numel
(
obj
.
configur
ednodes
),
1
);
Elems
=
repmat
(
Simulink
.
BusElement
,
numel
(
obj
.
defin
ednodes
),
1
);
for
ii
=
1
:
numel
(
obj
.
configur
ednodes
)
for
ii
=
1
:
numel
(
obj
.
defin
ednodes
)
inode
=
obj
.
configur
ednodes
(
ii
);
inode
=
obj
.
defin
ednodes
(
ii
);
leafName
=
sprintf
(
'Node%02d_RFM'
,
inode
);
leafName
=
sprintf
(
'Node%02d_RFM'
,
inode
);
subBusName
=
sprintf
(
'Bus: RFMOUT%02dbus'
,
inode
);
subBusName
=
sprintf
(
'Bus: RFMOUT%02dbus'
,
inode
);
...
@@ -830,8 +819,8 @@ classdef SCDclass_expcode
...
@@ -830,8 +819,8 @@ classdef SCDclass_expcode
s
=
struct
();
s
=
struct
();
% Looping through every active node
% Looping through every active node
for
ii
=
1
:
numel
(
obj
.
configur
ednodes
)
for
ii
=
1
:
numel
(
obj
.
defin
ednodes
)
inode
=
obj
.
configur
ednodes
(
ii
);
inode
=
obj
.
defin
ednodes
(
ii
);
mynode
=
obj
.
nodes
{
inode
};
mynode
=
obj
.
nodes
{
inode
};
for
jj
=
1
:
numel
(
mynode
.
wrappers
)
for
jj
=
1
:
numel
(
mynode
.
wrappers
)
...
...
This diff is collapsed.
Click to expand it.
code/classes/SCDclass_node.m
+
35
−
0
View file @
9a41dfc6
...
@@ -193,6 +193,41 @@ classdef SCDclass_node < SCDclass_component
...
@@ -193,6 +193,41 @@ classdef SCDclass_node < SCDclass_component
obj
.
active
=
value
;
obj
.
active
=
value
;
end
end
function
linknodedd
(
obj
,
node
)
% link node data dictionary to main expcode object data dicationary
assert
(
isa
(
node
,
'SCDclass_node'
),
'node must be an SCDclass_node object'
)
ddObj
=
Simulink
.
data
.
dictionary
.
open
(
obj
.
ddname
);
prefix
=
'SCD_rtc'
;
% already linked sources
prevsources
=
ddObj
.
DataSources
;
prevsources_nodes
=
prevsources
(
startsWith
(
prevsources
,
prefix
));
% make algo data dictionary list list
reqsources
=
node
.
ddname
;
% removing unnecessary ones
for
ii
=
1
:
numel
(
prevsources_nodes
)
mysource
=
prevsources_nodes
{
ii
};
if
~
contains
(
reqsources
,
mysource
)
obj
.
printlog
(
'Removing algorithm data source %s from %s'
,
mysource
,
obj
.
ddname
);
ddObj
.
removeDataSource
(
prevsources_nodes
{
ii
})
end
end
% add new ones not yet present
mysource
=
reqsources
;
assert
(
startsWith
(
mysource
,
prefix
),
...
'attempting to add algo dd: %s that does not start with
''
%s
''
-aborting'
,
prefix
,
mysource
);
if
contains
(
prevsources
,
mysource
)
obj
.
printlog
(
'Not adding node data source %s - already exists'
,
mysource
);
else
obj
.
printlog
(
'Adding node data source %s to %s'
,
mysource
,
obj
.
ddname
);
ddObj
.
addDataSource
(
mysource
);
end
end
function
updatetemplatetp
(
obj
)
function
updatetemplatetp
(
obj
)
% update wrapper algos
% update wrapper algos
for
ii
=
1
:
numel
(
obj
.
wrappers
)
for
ii
=
1
:
numel
(
obj
.
wrappers
)
...
...
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