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
eeea14cc
Commit
eeea14cc
authored
4 years ago
by
Cristian Galperti
Browse files
Options
Downloads
Patches
Plain Diff
enums for ECRH and loader class added (WIP)
parent
80cce206
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
code/classes/SCDclass_mdspar.m
+13
-9
13 additions, 9 deletions
code/classes/SCDclass_mdspar.m
code/classes/SCDclass_mdsparenum.m
+116
-0
116 additions, 0 deletions
code/classes/SCDclass_mdsparenum.m
with
129 additions
and
9 deletions
code/classes/SCDclass_mdspar.m
+
13
−
9
View file @
eeea14cc
...
...
@@ -117,6 +117,16 @@ classdef SCDclass_mdspar < matlab.mixin.Heterogeneous
assert
(
s
==
localshot
,
str
);
end
function
obj
=
setactualizecmds
(
obj
,
shot
)
pointspos
=
strfind
(
obj
.
modelparam
,
'.'
);
baseparam
=
obj
.
modelparam
(
1
:
pointspos
(
1
)
-
1
);
structparam
=
obj
.
modelparam
(
pointspos
(
1
):
end
);
obj
.
assignvar
=
sprintf
(
'%s.Value%s'
,
baseparam
,
structparam
);
obj
.
assignstring
=
sprintf
(
'%s=%s;'
,
obj
.
assignvar
,
obj
.
getcommand
);
obj
.
denanstring
=
sprintf
(
'%s(isnan(%s))=0;'
,
obj
.
assignvar
,
obj
.
assignvar
);
obj
.
caststring
=
sprintf
(
'%s=%s;'
,
obj
.
assignvar
,
obj
.
assignvar
);
end
function
obj
=
preactualizecommon
(
obj
,
shot
)
if
(
~
obj
.
unlinked
)
% Opening the tree
...
...
@@ -125,13 +135,7 @@ classdef SCDclass_mdspar < matlab.mixin.Heterogeneous
[
obj
,
obj
.
value
]
=
obj
.
getdata
(
shot
);
if
~
obj
.
actualizable
,
return
;
end
pointspos
=
strfind
(
obj
.
modelparam
,
'.'
);
baseparam
=
obj
.
modelparam
(
1
:
pointspos
(
1
)
-
1
);
structparam
=
obj
.
modelparam
(
pointspos
(
1
):
end
);
obj
.
assignvar
=
sprintf
(
'%s.Value%s'
,
baseparam
,
structparam
);
obj
.
assignstring
=
sprintf
(
'%s=%s;'
,
obj
.
assignvar
,
obj
.
getcommand
);
obj
.
denanstring
=
sprintf
(
'%s(isnan(%s))=0;'
,
obj
.
assignvar
,
obj
.
assignvar
);
obj
.
caststring
=
sprintf
(
'%s=%s;'
,
obj
.
assignvar
,
obj
.
assignvar
);
obj
=
obj
.
setactualizecmds
(
shot
);
end
end
...
...
@@ -156,9 +160,9 @@ classdef SCDclass_mdspar < matlab.mixin.Heterogeneous
function
[
obj
,
value
]
=
getdatacommon
(
obj
,
shot
)
obj
=
obj
.
actualizegetcmd
(
'mdsvalue(
''
%s
''
)'
,
shot
);
value
=
eval
(
obj
.
getcommand
);
if
(
~
isnumeric
(
value
)
)
if
(
~
isnumeric
(
value
)
&&
~
isa
(
obj
,
'SCDclass_mdsparenum'
))
% TODO: better handle this exception
warning
(
'SCDclass_mdspar:MDSerror'
,
'MDS+ error for parameter %s: %s. Actualization skipped.'
,
obj
.
modelparam
,
value
);
obj
.
actualizable
=
false
;
else
...
...
This diff is collapsed.
Click to expand it.
code/classes/SCDclass_mdsparenum.m
0 → 100644
+
116
−
0
View file @
eeea14cc
classdef
SCDclass_mdsparenum
<
SCDclass_mdspar
% A string enumerated MDS parameter, for uint16 enum codes
%
% behavior in MATLAB:
% if a string match between MDS string and matlab num string is
% asserted, the enum choice is loaded into the tun parameter
% if not a warning is issued and the param is left untouched
% behavior in MARTe2:
% the same than before but the enum map is used to load the
% equivalent uint16 code on the MARTe2 side tunable parameter
% if a string match is not detected, the parameter is invalidated
properties
(
Access
=
private
)
enumclass
stringmap
intmap
end
methods
function
obj
=
SCDclass_mdsparenum
(
srctdimodel
,
destparam
,
varargin
)
obj
@
SCDclass_mdspar
();
% Constructor parser customization definitions here
obj
=
obj
.
parseconstructorcommon
(
srctdimodel
,
destparam
,
varargin
);
% Constructor parser customization results here
obj
.
classname
=
mfilename
;
obj
.
marteclassname
=
'MDSParEnum'
;
end
function
actualizedata
(
obj
,
shot
)
obj
=
obj
.
preactualizecommon
(
shot
);
if
(
~
obj
.
unlinked
)
% Enumeration map fill
obj
=
obj
.
initenummap
();
found
=
false
;
for
ii
=
1
:
numel
(
obj
.
stringmap
)
if
strcmp
(
obj
.
value
,
char
(
obj
.
stringmap
(
ii
)))
found
=
true
;
break
;
end
end
if
~
found
warning
(
'SCDclass_mdsparenum:actualize'
,
'No match between MDS and enum values, parameter not actualized'
);
return
end
obj
.
assignstring
=
sprintf
(
'%s=%s.%s;'
,
obj
.
assignvar
,
obj
.
enumclass
,
obj
.
value
);
obj
.
denanstring
=
''
;
obj
.
caststring
=
''
;
end
obj
.
postactualizecommon
(
shot
);
end
function
[
obj
,
value
]
=
getdata
(
obj
,
shot
)
[
obj
,
value
]
=
obj
.
getdatacommon
(
shot
);
end
function
printinfo
(
obj
)
obj
.
printinfocommon
;
end
function
entrystring
=
genMARTe2entry
(
obj
,
shot
)
entrystring
=
obj
.
genMARTe2entrycommon
(
shot
);
% to populate obj.assignvar
obj
=
obj
.
setactualizecmds
(
shot
);
% Enumeration map fill
obj
=
obj
.
initenummap
();
enumval
=
'EnumVal = {'
;
enumcode
=
'EnumCode = {'
;
for
ii
=
1
:
numel
(
obj
.
stringmap
)
enumval
=
[
enumval
'"'
char
(
obj
.
stringmap
(
ii
))
'"'
];
if
ii
~=
numel
(
obj
.
stringmap
)
enumval
=
[
enumval
','
];
end
end
enumval
=
[
enumval
,
'}'
];
for
ii
=
1
:
numel
(
obj
.
intmap
)
enumcode
=
[
enumcode
num2str
(
obj
.
intmap
(
ii
))];
if
ii
~=
numel
(
obj
.
intmap
)
enumcode
=
[
enumcode
','
];
end
end
enumcode
=
[
enumcode
'}'
];
entrystring
=
[
entrystring
' '
enumcode
' '
enumval
'}'
];
end
end
methods
(
Access
=
private
)
function
obj
=
initenummap
(
obj
)
% TODO: probably Simulink.data.evalinGlobal better than
% evalin('base'
basecmd
=
[
'class('
obj
.
assignvar
');'
];
obj
.
enumclass
=
evalin
(
'base'
,
basecmd
);
basecmd
=
[
'enumeration('
obj
.
assignvar
');'
];
obj
.
stringmap
=
evalin
(
'base'
,
basecmd
);
basecmd
=
[
'uint16(enumeration('
obj
.
assignvar
'));'
];
obj
.
intmap
=
evalin
(
'base'
,
basecmd
);
end
end
end
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