Skip to content
Snippets Groups Projects
Commit 34e1b86c authored by Lorenzo Pivetta's avatar Lorenzo Pivetta
Browse files

First import

parent 51f020b0
No related branches found
Tags 1.0.25
No related merge requests found
clear all;
for num_sequences=1:32
for num_cond=1:10
clear header;
clear footer;
clear blk;
seq_name = sprintf('seq_corr_monitor_%02d_%02d.txt',num_sequences,num_cond);
header{1} = '#';
header{2} = '# Description: Calculate FEL On/Off state getting data from $devcorrcalc';
header{3} = '# Author: Giulio Gaio';
header{4} = '# Date: 2020/10/19';
header{5} = '#';
cnt = 0;
cnt = cnt + 1;
blk{cnt} = sprintf('step%d;sleep($sleep_monitor) && (read($devcorrcalc/State) != RUNNING) ? (write(this/FelOn) = 0) && goto(1) : (write(this/Cnt) = 0) && goto(2);Reading $devcorrcalc state;Error reading $devcorrcalc state;-1',cnt);
for seq=1:num_sequences
cnt = cnt + 1;
blk{cnt} = sprintf('step%d;read($devcorrcalc/$attr%02d$) > read(this/CorrelThreshold) ? (write(this/Cnt) = (read(this/Cnt) + 1)) && goto(%d) : goto(%d);Reading $attr%02d$ value;Error reading $attr%02d$ value;-1;tangoerror=goto(%d)',cnt,seq,cnt+1,cnt+1,seq,seq,3+num_sequences+num_cond*2);
end
% additional conditions
for i=1:num_cond
cnt = cnt + 1;
blk{cnt} = sprintf('step%d;(read(this/EnaCond%02d) == 1) ? goto(%d) : (write(this/ErrCond%02d) = 0) && goto(%d);Checking $cond_expr%02d;Error checking $cond_expr%02d;-1',cnt,i,cnt+1,i,cnt+2,i,i);
cnt = cnt + 1;
blk{cnt} = sprintf('step%d;($cond_expr%02d$) ? (write(this/ErrCond%02d) = 0) && goto(%d) : (write(this/ErrCond%02d) = 1) && goto(%d);Evaluating $cond_expr%02d$;Error evaluating $cond_expr%02d$;-1;tangoerror=goto(%d)',cnt,i,i,cnt+1,i,3+num_sequences+num_cond*2,i,i,3+num_sequences+num_cond*2);
end
% FEL state calculation
cnt = cnt + 1;
blk{cnt} = sprintf('step%d;(write(this/FelEnabled) = 1) && read(this/Cnt) >= read(this/CntThreshold) ? (write(this/FelOn) = 1) && goto(1) : (write(this/FelOn) = 0) && goto(1);Calculating FEL state;Error calculating FEL state;-1',cnt);
% Error step
cnt = cnt + 1;
blk{cnt} = sprintf('step%d;(write(this/FelOn) = 0) && (write(this/FelEnabled) = 0) && goto(1);Setting FEL error state;Setting FEL error state;-1',cnt);
% Dynamic attributes
cnt = 0;
cnt = cnt + 1;
footer{cnt} = 'attr;Cnt;long;0';
cnt = cnt + 1;
footer{cnt} = 'attr;CntThreshold;long;0';
cnt = cnt + 1;
footer{cnt} = 'attr;CorrelThreshold;double;0.6';
for i=1:num_cond
cnt = cnt + 1;
footer{cnt} = sprintf('attr;EnaCond%02d;bool;1',i);
end
for i=1:num_cond
cnt = cnt + 1;
footer{cnt} = sprintf('attr;ErrCond%02d;bool;0',i);
end
cnt = cnt + 1;
footer{cnt} = 'attr;FelOn;bool;0';
cnt = cnt + 1;
footer{cnt} = 'attr;FelEnabled;bool;0';
fileID = fopen(seq_name,'w');
for i=1:size(header,2)
fprintf(fileID,'%s\n',header{i});
end
for i=1:size(blk,2)
fprintf(fileID,'%s\n',blk{i});
end
for i=1:size(footer,2)
fprintf(fileID,'%s\n',footer{i});
end
fclose(fileID);
end
end
% Dynamic R/W attributes
%
% User
% attr;CntThreshold;long;2
% attr;CorrelThreshold;long;0.6
% Internal
% attr;Cnt;long;0
% attr;FelOn;bool;0
% Wildcards
% $devcorrcalc=seq/calc/fast_stats_fel
% sleep_monitor=2
% $sleep_monitor=1
% $attr01$=t001_t002_Corr
% $attr02$=t001_t002_Corr
%
% .........
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment