Newer
Older
classdef SCDclass_taskmdsloadprevADC < SCDclass_task
% This is a special class which loads previous
% values of the ADCs for the acquiring nodes
properties
modelbus
node
workspacedatabasestructure
end
properties(Access=private)
logdecimate
end
methods
function obj=SCDclass_taskmdsloadprevADC(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 1
obj.workspacedatabasestructure='SCDsimdata.SCDnode01simdata.adc';
case 2
obj.workspacedatabasestructure='SCDsimdata.SCDnode02simdata.adc';
otherwise
obj.workspacedatabasestructure='';
end
obj.classname=mfilename;
end
function init(obj, shot)
mdsconnect(obj.mdsserver);
mdsopen(obj.mdstree, shot);
try
switch(obj.node)
case 1
obj.actualizeNode(shot, 96);
case 2
obj.actualizeNode(shot, 192);
end
catch
fprintf('\n');
warning('SCDclass_taskmdsloadprevADC:init','Error initializing ADC bus for node %d.',obj.node);
end
end
function [obj, value] = getdata(obj,shot)
%obj=obj.actualizegetcmd('mdsvalue(''%s'')', shot);
%value=eval(obj.getcommand);
switch(obj.node)
case 1
[~,value]=obj.getdataNode01ACQ196(shot);
% Here we need to switch betweeen old and new acquisition unit
% TODO: add tcv standard in case data is not available
[~,value]=obj.getdataNode02ACQ196(shot);
[~,value]=obj.getdataNode02ACQ2106(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, nadcs)
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);
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/nadcs*100);
end
end
evalin('base','clear temp');
if obj.verbose==1
%%
% Node 01 loading functions
function [obj, value] = getdataNode01ACQ196(obj, shot)
T=timeseries;
timebase=mdsvalue('dim_of(\top.crpprt01.board1.adc_01)'); %% TODO: check with marte
d_time = double(mdsvalueraw( '\top.crpprt01.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),96);
datamatrix=zeros(numel(timebase),96);
fprintf('Getting data for bus: ''%s'' (%s, shot %d) 0%% ', obj.modelbus, obj.classname, shot);
for ii=1:96
% Node 01 data are loaded in the stored order since
% up to now there is only old node 01
channelstr=sprintf('\\top.crpprt01.board1.adc_%02d.raw',physical2logical(ii));
datamatrix(:,ii)=int16(mdsvalue(channelstr));
if obj.verbose==1 && mod(ii,obj.logdecimate)==0
fprintf('%.0f%% ', ii/96*100);
T.Data=datamatrix; % this speeds up a lot the loading
value=T;
%%
% Node 02 loading functions
function [obj, value] = getdataNode02ACQ196(obj, shot)
T=timeseries;
timebase=mdsvalue('dim_of(\top.crpprt02.board1.adc_01)');
d_time = double(mdsvalueraw( '\top.crpprt02.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),192);
datamatrix=zeros(numel(timebase),192);
fprintf('Getting data for bus: ''%s'' (%s, shot %d) 0%% ', obj.modelbus, obj.classname, shot);
end
for ii=1:96
% NOTE: physical2logical remapping is only for
% data acquired with the ACQ196 system, not for the new
% 2106 based one
channelstr=sprintf('\\top.crpprt02.board1.adc_%02d.raw',physical2logical(ii));
datamatrix(:,ii)=int16(mdsvalue(channelstr));
if obj.verbose==1 && mod(ii,obj.logdecimate)==0
fprintf('%.0f%% ', ii/192*100);
end
end
for ii=1:96
channelstr=sprintf('\\top.crpprt02.board2.adc_%02d.raw',physical2logical(ii));
datamatrix(:,ii+96)=int16(mdsvalue(channelstr));
if obj.verbose==1 && mod(ii,obj.logdecimate)==0
fprintf('%.0f%% ', (ii+96)/192*100);
T.Data=datamatrix; % this speeds up a lot the loading
value=T;
if obj.verbose==1
function [obj, value] = getdataNode02ACQ2106(obj, shot)
if shot>65826
mdsnodename='node02';
else
mdsnodename='tcvrt02';
end
mdsopen('rtc',shot);
timebase=mdsvalue(['dim_of(\top.' mdsnodename '.adc.adc_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;
timebase = timebase + d_time; % this fits perfectly sim/rt data on 68072
T.Time=timebase;
T.Data=zeros(numel(timebase),192);
datamatrix=zeros(numel(timebase),192);
fprintf('Getting data for bus: ''%s'' (%s, shot %d) 0%% ', obj.modelbus, obj.classname, shot);
channelstr=sprintf(['\\top.' mdsnodename '.adc.adc_%03d.raw'],ii);
%T.Data(:,ii)=int16(mdsvalue(channelstr));
%T.Data(:,ii)=int16(mdsvalueraw(channelstr));
datamatrix(:,ii)=int16(mdsvalueraw(channelstr));
if obj.verbose==1 && mod(ii,obj.logdecimate)==0
fprintf('%.0f%% ', ii/192*100);
T.Data=datamatrix; % this speeds up a lot the loading
value=T;
if obj.verbose==1