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
9728638c
Commit
9728638c
authored
2 years ago
by
Federico Felici
Browse files
Options
Downloads
Patches
Plain Diff
cleanup class and add general setup checks
parent
ed3bc7f5
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
classes/SCDclass_algo.m
+44
-22
44 additions, 22 deletions
classes/SCDclass_algo.m
with
44 additions
and
22 deletions
classes/SCDclass_algo.m
+
44
−
22
View file @
9728638c
...
@@ -22,7 +22,9 @@ classdef SCDclass_algo
...
@@ -22,7 +22,9 @@ classdef SCDclass_algo
timing
% Timing info structure
timing
% Timing info structure
exportedtpsdefaults
% default tunable parameters defining functions
exportedtpsdefaults
% default tunable parameters defining functions
buslist
% list of buses and their sources
buslist
% list of buses and their sources
signals
% Defined Simulink.Signals
inBus
% Root inport bus
outBus
% Root outport bus
outSignal
% Outport signal
end
end
properties
properties
...
@@ -51,6 +53,8 @@ classdef SCDclass_algo
...
@@ -51,6 +53,8 @@ classdef SCDclass_algo
obj
.
timing
.
t_stop
=
1
;
obj
.
timing
.
t_stop
=
1
;
obj
.
timing
.
dt
=
1e-3
;
obj
.
timing
.
dt
=
1e-3
;
obj
.
buslist
=
[];
obj
.
buslist
=
[];
obj
.
inBus
.
name
=
[
name
,
'_inBus'
];
obj
.
outBus
.
name
=
[
name
,
'_outBus'
];
% Buses
% Buses
obj
.
modelslx
=
[
obj
.
modelname
,
'.slx'
];
obj
.
modelslx
=
[
obj
.
modelname
,
'.slx'
];
...
@@ -67,6 +71,8 @@ classdef SCDclass_algo
...
@@ -67,6 +71,8 @@ classdef SCDclass_algo
% Standard data dictionary equal to algorithm name,
% Standard data dictionary equal to algorithm name,
% overriddable by the setter method
% overriddable by the setter method
obj
=
obj
.
setdatadictionary
([
name
'.sldd'
]);
obj
=
obj
.
setdatadictionary
([
name
'.sldd'
]);
obj
=
obj
.
define_signals
;
end
end
%% Print infos
%% Print infos
...
@@ -140,7 +146,19 @@ classdef SCDclass_algo
...
@@ -140,7 +146,19 @@ classdef SCDclass_algo
function
refddparent
=
getrefddparentalgo
(
obj
)
function
refddparent
=
getrefddparentalgo
(
obj
)
refddparent
=
obj
.
refddparentalgo
;
refddparent
=
obj
.
refddparentalgo
;
end
end
function
obj
=
define_signals
(
obj
)
% generate signal for root output port
mySigName
=
[
obj
.
getname
,
'_outport'
];
mySig
=
Simulink
.
Signal
;
mySig
.
DataType
=
[
'Bus: '
,
obj
.
outBus
.
name
];
mySig
.
Description
=
sprintf
(
'%s outport bus signal'
,
obj
.
getname
);
% assign signals
obj
.
outSignal
.
name
=
mySigName
;
obj
.
outSignal
.
obj
=
mySig
;
end
%% Setup functions setter and getter
%% Setup functions setter and getter
function
obj
=
addstdinitfcn
(
obj
,
fcnhandle
)
function
obj
=
addstdinitfcn
(
obj
,
fcnhandle
)
if
ischar
(
fcnhandle
)
if
ischar
(
fcnhandle
)
...
@@ -345,14 +363,14 @@ classdef SCDclass_algo
...
@@ -345,14 +363,14 @@ classdef SCDclass_algo
end
end
function
addsignalstodd
(
obj
)
function
addsignalstodd
(
obj
)
obj
=
obj
.
addsignals
;
% add signals
dictionaryObj
=
Simulink
.
data
.
dictionary
.
open
(
obj
.
getdatadictionary
);
dictionaryObj
=
Simulink
.
data
.
dictionary
.
open
(
obj
.
getdatadictionary
);
designDataObj
=
getSection
(
dictionaryObj
,
'Design Data'
);
designDataObj
=
getSection
(
dictionaryObj
,
'Design Data'
);
for
ii
=
1
:
numel
(
obj
.
signals
)
signals
=
obj
.
outSignal
;
% for now just this one, maybe later add more
mysignalObj
=
obj
.
signals
(
ii
)
.
obj
;
mysignalName
=
obj
.
signals
(
ii
)
.
name
;
for
ii
=
1
:
numel
(
signals
)
mysignalObj
=
signals
(
ii
)
.
obj
;
mysignalName
=
signals
(
ii
)
.
name
;
fprintf
(
'adding signal %25s to %s\n'
,
...
fprintf
(
'adding signal %25s to %s\n'
,
...
mysignalName
,
obj
.
getdatadictionary
)
mysignalName
,
obj
.
getdatadictionary
)
obj
.
replaceorcreateddentry
(
designDataObj
,
mysignalName
,
mysignalObj
);
obj
.
replaceorcreateddentry
(
designDataObj
,
mysignalName
,
mysignalObj
);
...
@@ -516,8 +534,8 @@ classdef SCDclass_algo
...
@@ -516,8 +534,8 @@ classdef SCDclass_algo
end
end
end
end
function
obj
=
add
signals
(
obj
)
function
check
signals
(
obj
)
% root outport signal
s
%
check
root outport signal
load_system
(
obj
.
getname
);
load_system
(
obj
.
getname
);
model_handle
=
get_param
(
obj
.
getname
,
'Handle'
);
model_handle
=
get_param
(
obj
.
getname
,
'Handle'
);
outport_handle
=
find_system
(
model_handle
,
'BlockType'
,
'Outport'
);
outport_handle
=
find_system
(
model_handle
,
'BlockType'
,
'Outport'
);
...
@@ -526,23 +544,17 @@ classdef SCDclass_algo
...
@@ -526,23 +544,17 @@ classdef SCDclass_algo
% Datatype
% Datatype
datatypeStr
=
get_param
(
outport_name
,
'OutDataTypeStr'
);
datatypeStr
=
get_param
(
outport_name
,
'OutDataTypeStr'
);
expected_busname
=
[
'Bus: '
,
obj
.
outBus
.
name
];
% generate signal from this port datatype
assert
(
isequal
(
datatypeStr
,
expected_busname
),
...
mySigName
=
[
obj
.
getname
,
'_outport'
];
'root outport data bus name mismatch, found %s expected %s'
,
datatypeStr
,
expected_busname
);
mySig
=
Simulink
.
Signal
;
mySig
.
DataType
=
datatypeStr
;
mySig
.
Description
=
sprintf
(
'%s outport bus signal'
,
obj
.
getname
);
% check algo .slx configuration compatibility with signal
% check algo .slx configuration compatibility with signal
outSigName
=
get_param
(
outport_name
,
'SignalName'
);
outSigName
=
get_param
(
outport_name
,
'SignalName'
);
assert
(
isequal
(
outSigName
,
mySigName
),
'outport signal name must resolve to %s'
,
mySigName
)
assert
(
isequal
(
outSigName
,
obj
.
outSignal
.
name
),
...
'Found unexpected outport signal: %s instead of %s'
,
outSigName
,
obj
.
outSignal
.
name
)
ison
=
get_param
(
outport_name
,
'MustResolveToSignalObject'
);
ison
=
get_param
(
outport_name
,
'MustResolveToSignalObject'
);
assert
(
isequal
(
ison
,
'on'
),
'outport %s must be set to resolve to signal object name'
);
assert
(
isequal
(
ison
,
'on'
),
'outport %s must be set to resolve to signal object name'
);
% assign signals
obj
.
signals
(
1
)
.
name
=
mySigName
;
obj
.
signals
(
1
)
.
obj
=
mySig
;
end
end
%% MDS container methods forwarders
%% MDS container methods forwarders
...
@@ -620,7 +632,7 @@ classdef SCDclass_algo
...
@@ -620,7 +632,7 @@ classdef SCDclass_algo
% populate with template tunable parameters
% populate with template tunable parameters
obj
.
updatetemplatetp
;
obj
.
updatetemplatetp
;
% add referenced data dictionaries to obj data dictionary
% add referenced data dictionaries to obj data dictionary
obj
.
addrefddtodd
obj
.
addrefddtodd
...
@@ -629,6 +641,7 @@ classdef SCDclass_algo
...
@@ -629,6 +641,7 @@ classdef SCDclass_algo
% add signals to dd
% add signals to dd
obj
.
addsignalstodd
;
obj
.
addsignalstodd
;
end
end
function
callinits
(
obj
)
function
callinits
(
obj
)
...
@@ -717,7 +730,7 @@ classdef SCDclass_algo
...
@@ -717,7 +730,7 @@ classdef SCDclass_algo
obj
.
initdd
;
% setup data dictionary
obj
.
initdd
;
% setup data dictionary
obj
.
callrefmodelinits
(
obj
.
getname
);
% setup workspaces for referenced models
obj
.
callrefmodelinits
(
obj
.
getname
);
% setup workspaces for referenced models
end
end
function
setup
(
obj
)
function
setup
(
obj
)
% setup()
% setup()
%
%
...
@@ -727,6 +740,8 @@ classdef SCDclass_algo
...
@@ -727,6 +740,8 @@ classdef SCDclass_algo
% an algorithm block diagram
% an algorithm block diagram
% should pass ctrl-d (instandalone opening)
% should pass ctrl-d (instandalone opening)
% after this call
% after this call
obj
.
checks
;
obj
.
updatetemplatetp
;
obj
.
updatetemplatetp
;
obj
.
buildworkspacetpstruct
;
obj
.
buildworkspacetpstruct
;
SCDconf_setConf
(
'sim'
);
SCDconf_setConf
(
'sim'
);
...
@@ -769,9 +784,16 @@ classdef SCDclass_algo
...
@@ -769,9 +784,16 @@ classdef SCDclass_algo
function
load
(
obj
)
function
load
(
obj
)
load_system
(
obj
.
modelname
);
load_system
(
obj
.
modelname
);
end
end
function
checks
(
obj
)
% various checks
obj
.
checksignals
;
% check signal definitions
% more checks to be added
end
end
end
methods
(
Static
,
Hidden
=
true
)
methods
(
Static
,
Hidden
=
true
)
function
createdatadictionary
(
ddname
,
folder
)
function
createdatadictionary
(
ddname
,
folder
)
% Create data dictionary in path folder/ddname
% Create data dictionary in path folder/ddname
dd_fullpath
=
fullfile
(
folder
,
ddname
);
dd_fullpath
=
fullfile
(
folder
,
ddname
);
...
...
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