From 5cbb6eeca131b624872ec5b8495a38a9c9ad5603 Mon Sep 17 00:00:00 2001 From: Lorenzo Pivetta <lorenzo.pivetta@elettra.eu> Date: Mon, 29 May 2023 15:10:33 +0200 Subject: [PATCH] First import --- gen_seq_condition.m | 58 +++++++++++++++++++++++++++++++ gen_seq_condition_recov.m | 72 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 130 insertions(+) create mode 100644 gen_seq_condition.m create mode 100644 gen_seq_condition_recov.m diff --git a/gen_seq_condition.m b/gen_seq_condition.m new file mode 100644 index 0000000..2df2483 --- /dev/null +++ b/gen_seq_condition.m @@ -0,0 +1,58 @@ +clear all; + +for num_sequences=1:99 + +seq_name = sprintf('seq_condition_%d.txt',num_sequences); + +header{1} = '#'; +header{2} = '# Description: $description'; +header{3} = '# Author: Giulio Gaio'; +header{4} = '# Date: 2021/02/10'; +header{5} = '#'; +header{6} = sprintf('# This script checks %d conditions and returns FAULT when the first is false',num_sequences); +header{7} = '#'; + +cnt = 0; + +% Check condition +for seq=1:num_sequences + cnt = cnt + 1; + blk{cnt} = sprintf('step%d;read(this/Enable%02d) == 1 ? goto(%d) : goto(%d);Checking enable condition %02d;Error checking enable condition %02d;-1',cnt,seq,cnt+1,cnt+2,seq,seq); + cnt = cnt + 1; + blk{cnt} = sprintf('step%d;($cond%02d) ? goto(%d) : goto(-1);Checking $errmsg%02d;$errmsg%02d;-1',cnt,seq,cnt+1,seq,seq); +end + +% dynamic attributes +cnt = 0; +% attributes +for seq=1:num_sequences + cnt = cnt + 1; + footer{cnt} = sprintf('attr;Enable%02d;bool;1',seq); +end + +% Wildcards +% $description= +% $cond01=$devplcaccess/Undulator_bst_inhibit_linac[0] == true +% $errmsg01=Ronda pendente nella hutch della Sala Sperimentale // failure description +% $cond02=$devplcaccess/Undulator_bst_inhibit_linac[1] == true +% $errmsg02=Monitore di dose della linea FEL1 in Malfunzionamento +% ........ +% $devplcaccess=f/access_control/safety + + +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 diff --git a/gen_seq_condition_recov.m b/gen_seq_condition_recov.m new file mode 100644 index 0000000..9e0560e --- /dev/null +++ b/gen_seq_condition_recov.m @@ -0,0 +1,72 @@ +clear all; + +for num_sequences=1:99 + +seq_name = sprintf('seq_condition_recov_%d.txt',num_sequences); + +header{1} = '#'; +header{2} = '# Description: $description'; +header{3} = '# Author: Giulio Gaio'; +header{4} = '# Date: 2021/02/10'; +header{5} = '#'; +header{6} = sprintf('# This script checks %d conditions and returns FAULT when the first is false',num_sequences); +header{7} = '#'; + +cnt = 0; + +% Check condition +for seq=1:num_sequences + cnt = cnt + 1; + blk{cnt} = sprintf('step%d;read(this/Enable%02d) == 1 ? goto(%d) : goto(%d);Checking enable condition %02d;Error checking enable condition %02d;-1',cnt,seq,cnt+1,cnt+2,seq,seq); + cnt = cnt + 1; + blk{cnt} = sprintf('step%d;($cond%02d) ? goto(%d) : goto(%d);Checking $errmsg%02d;$errmsg%02d;-1',cnt,seq,cnt+5,seq,seq); + cnt = cnt + 1; + blk{cnt} = sprintf('step%d;read(this/Recover%02d) == 1 ? command($devseqrecov%02d/Start) && goto(%d) : goto(-1);Checking $errmsg%02d;$errmsg%02d;-1',cnt,seq,seq,cnt+1,seq,seq); + cnt = cnt + 1; + blk{cnt} = sprintf('step%d;sleep($sleep_monitor) && (read($devseqrecov%02d/State) == RUNNING) ? goto(%d) : goto(%d);Waiting recovery sequence for condition %02d;Error waiting recovery sequence for condition %02d;$sequence_timeout000',cnt,seq,cnt,cnt+1,seq,seq); + cnt = cnt + 1; + blk{cnt} = sprintf('step%d;sleep($sleep_monitor) && (read($devseqrecov%02d/State) == OFF) ? goto(%d) : goto(-1);Checking recovery sequence for condition %02d;Checking recovery sequence for condition %02d;-1',cnt,seq,cnt+1,seq,seq); + cnt = cnt + 1; + blk{cnt} = sprintf('step%d;sleep($sleep_monitor) && ($cond%02d) ? goto(%d) : goto(%d);Checking $errmsg%02d;$errmsg%02d;-1',cnt,seq,cnt+1,seq,seq); +end + +% dynamic attributes +cnt = 0; +% attributes +for seq=1:num_sequences + cnt = cnt + 1; + footer{cnt} = sprintf('attr;Enable%02d;bool;1',seq); + cnt = cnt + 1; + footer{cnt} = sprintf('attr;Recover%02d;bool;0',seq); +end + +% Wildcards +% $description= +% $cond01=$devplcaccess/Undulator_bst_inhibit_linac[0] == true +% $errmsg01=Ronda pendente nella hutch della Sala Sperimentale // failure description +% $devseqrecov01= +% $cond02=$devplcaccess/Undulator_bst_inhibit_linac[1] == true +% $errmsg02=Monitore di dose della linea FEL1 in Malfunzionamento +% $devseqrecov02= +% ........ +% $devplcaccess=f/access_control/safety +% $sleep_monitor=1 +% $sequence_timeout=120 + + +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 -- GitLab