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
ad456b47
Commit
ad456b47
authored
4 years ago
by
Cristian Galperti
Browse files
Options
Downloads
Patches
Plain Diff
prev ethcat data (only int16) actualization added
parent
0b935e3f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
code/classes/SCDclass_taskmdsloadprevETHCAT.m
+133
-0
133 additions, 0 deletions
code/classes/SCDclass_taskmdsloadprevETHCAT.m
with
133 additions
and
0 deletions
code/classes/SCDclass_taskmdsloadprevETHCAT.m
0 → 100644
+
133
−
0
View file @
ad456b47
classdef
SCDclass_taskmdsloadprevETHCAT
<
SCDclass_task
% This is a special class which loads previous
% values of the EtherCAT1 real-time network
properties
modelbus
node
workspacedatabasestructure
end
properties
(
Access
=
private
)
logdecimate
nint16
nfloat32
% not yet implemented
end
methods
function
obj
=
SCDclass_taskmdsloadprevETHCAT
(
id
,
varargin
)
obj
@
SCDclass_task
(
id
,
varargin
);
obj
.
cparser
.
addRequired
(
'modelbus'
,
@
(
x
)
ischar
(
x
));
obj
.
cparser
.
addParameter
(
'node'
,
0
,
@
(
x
)
(
isnumeric
(
x
)
&&
((
x
==
1
)
||
x
==
2
)));
obj
=
obj
.
parseconstructorcommon
(
id
,
varargin
);
obj
.
modelbus
=
obj
.
cparser
.
Results
.
modelbus
;
obj
.
node
=
obj
.
cparser
.
Results
.
node
;
switch
(
obj
.
node
)
case
2
obj
.
workspacedatabasestructure
=
'SCDsimdata.SCDnode02simdata.ethercat'
;
otherwise
error
(
'SCDclass_taskmdsloadprevETHCAT:constructor'
,
'Class not implemented for node %d'
,
obj
.
node
);
%obj.workspacedatabasestructure='';
end
obj
.
classname
=
mfilename
;
obj
.
logdecimate
=
2
;
obj
.
nint16
=
20
;
obj
.
nfloat32
=
10
;
% not yet implemented
end
function
init
(
obj
,
shot
)
mdsconnect
(
obj
.
mdsserver
);
mdsopen
(
obj
.
mdstree
,
shot
);
%try
switch
(
obj
.
node
)
case
2
obj
.
actualizeNode
(
shot
);
end
%catch
% fprintf('\n');
% warning('SCDclass_taskmdsloadprevETHCAT:init','Error initializing ETHCAT bus for node %d.',obj.node);
%end
end
function
[
obj
,
value
]
=
getdata
(
obj
,
shot
)
switch
(
obj
.
node
)
case
2
[
~
,
value
]
=
obj
.
getdataNodeETHCAT1
(
shot
);
end
end
function
printinfo
(
obj
)
obj
.
printinfocommon
;
fprintf
(
' Init model bus: %s, node: %d, ws base struct: %s\n'
,
obj
.
modelbus
,
obj
.
node
,
obj
.
workspacedatabasestructure
);
end
function
entrystring
=
genMARTe2entry
(
obj
,
shot
)
% TODO: this is a workaround which works by chance, need a more accurate fix
entrystring
=
''
;
end
end
methods
(
Access
=
private
)
function
obj
=
actualizeNode
(
obj
,
shot
)
dd
=
SCDconf_getdatadict
(
obj
.
datadictionary
);
adcbus
=
dd
.
getEntry
(
obj
.
modelbus
)
.
getValue
;
[
~
,
data
]
=
obj
.
getdata
(
shot
);
T
=
timeseries
;
if
obj
.
verbose
==
1
fprintf
(
'Actualizing data for bus:
''
%s
''
(%s, shot %d) 0%% '
,
obj
.
modelbus
,
obj
.
classname
,
shot
);
end
for
ii
=
1
:
obj
.
nint16
T
.
Time
=
data
.
Time
;
T
.
Data
=
int16
(
data
.
Data
(:,
ii
));
assignin
(
'base'
,
'temp'
,
T
);
assigncmd
=
sprintf
(
'%s.%s=temp;'
,
obj
.
workspacedatabasestructure
,
adcbus
.
Elements
(
ii
)
.
Name
);
evalin
(
'base'
,
assigncmd
);
if
obj
.
verbose
==
1
&&
mod
(
ii
,
obj
.
logdecimate
)
==
0
fprintf
(
'%.0f%% '
,
ii
/
obj
.
nint16
*
100
);
end
end
evalin
(
'base'
,
'clear temp'
);
if
obj
.
verbose
==
1
fprintf
(
'100%% \n'
);
end
end
%%
% Node 02 loading functions
function
[
obj
,
value
]
=
getdataNodeETHCAT1
(
obj
,
shot
)
mdsnodename
=
'node02'
;
mdsopen
(
'rtc'
,
shot
);
T
=
timeseries
;
timebase
=
mdsvalue
([
'dim_of(\top.'
mdsnodename
'.ethcat1.in.int16_001)'
]);
d_time
=
double
(
mdsvalueraw
([
'\top.'
mdsnodename
'.params:d_time'
]))
*
1.0e-6
;
%timebase = round(timebase.*1/d_time)*d_time-d_time/2;
timebase
=
round
(
timebase
.*
1
/
d_time
)
*
d_time
-
d_time
/
100
;
T
.
Time
=
timebase
;
T
.
Data
=
zeros
(
numel
(
timebase
),
obj
.
nint16
);
datamatrix
=
zeros
(
numel
(
timebase
),
obj
.
nint16
);
if
obj
.
verbose
==
1
fprintf
(
'Getting data for bus:
''
%s
''
(%s, shot %d) 0%% '
,
obj
.
modelbus
,
obj
.
classname
,
shot
);
end
for
ii
=
1
:
obj
.
nint16
channelstr
=
sprintf
([
'\\top.'
mdsnodename
'.ethcat1.in.int16_%03d.raw'
],
ii
);
datamatrix
(:,
ii
)
=
int16
(
mdsvalueraw
(
channelstr
));
if
obj
.
verbose
==
1
&&
mod
(
ii
,
obj
.
logdecimate
)
==
0
fprintf
(
'%.0f%% '
,
ii
/
192
*
100
);
end
end
T
.
Data
=
datamatrix
;
% this speeds up a lot the loading
value
=
T
;
if
obj
.
verbose
==
1
fprintf
(
'100%% \n'
);
end
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