From f81afe1efa1ed9357edd5fd7993c9899ce266000 Mon Sep 17 00:00:00 2001
From: Carmelo Pellegrino <carmelo.pellegrino@gmail.com>
Date: Thu, 14 May 2015 16:26:12 +0200
Subject: [PATCH] Asking for run duration before the run number calculation
 Asking repeteadly if "Cancel" is selected Waiting for 10 secs to cancel the
 operation, reporting the parameters Launch the logger

---
 rsselector.sh | 70 ++++++++++++++++++++++++++++++++++-----------------
 1 file changed, 47 insertions(+), 23 deletions(-)

diff --git a/rsselector.sh b/rsselector.sh
index 6d362b0..83f3886 100644
--- a/rsselector.sh
+++ b/rsselector.sh
@@ -52,36 +52,60 @@ function get_run_number() {
   echo ${run_number}
 }
 
-# Ask for the run setup
-
-rs_file=`zenity --title "Run Setup Selector" \
-                 --list \
-                 --text "Select one of the following Run Setups:" \
-                 --radiolist \
-                 --column="Selection" \
-                 --column="Run Setup file" \
-                 $(createList ${folder})`
-
-if [ -z "${rs_file}" ]; then
-  zenity --error  --text="No Run Setup file selectet, aborting"
-  exit -1
-fi
+while [ 1 ]; do
+
+  # Ask for the run setup
+
+  rs_file=`zenity --title "Run Setup Selector" \
+                   --list \
+                   --text "Select one of the following Run Setups:" \
+                   --radiolist \
+                   --column="Selection" \
+                   --column="Run Setup file" \
+                   $(createList ${folder})`
+
+  if [ -z "${rs_file}" ]; then
+    zenity --error  --text="No Run Setup file selectet, aborting"
+    exit -1
+  fi
+
+  # Ask for run duration
+
+  run_duration=`zenity --title "Run duration" \
+                       --list \
+                       --text "Select one of the following duration:" \
+                       --radiolist \
+                       --column="Selection" \
+                       --column="Minutes" \
+                       FALSE Cancel FALSE 5 TRUE 10 FALSE 20`
+
+  if [ "$run_duration" == "Cancel" ]; then
+    break
+  fi
+
+done
+
+# Wait 10 seconds
+i=0;
+while [ $i -lt 100 ]; do
+  echo $i
+  sleep 1
+  let "i = $i + 10"
+done | zenity --progress \
+              --auto-close \
+              --text="You have 10 seconds to cancel the current operation:\nrunsetup: ${rs_file}\nduration: ${run_duration}" \
+              --auto-kill
 
 # Peak the run number
 
 run_number=`get_run_number`
 
-# Copy selected run setup file, changing the run number
+daq_log_file=~/.km3_private/daq_${run_number}.log
+JGetMessage -H localhost -T MSG -d 3 >${daq_log_file} &
 
-# Ask for run duration
 
-run_duration=`zenity --title "Run duration" \
-                     --list \
-                     --text "Select one of the following duration:" \
-                     --radiolist \
-                     --column="Selection" \
-                     --column="Minutes" \
-                     FALSE 5 TRUE 10 FALSE 20`
+# Copy selected run setup file, changing the run number
+
 
 # Launch the DM
 dm_driver ${run_duration} | mono DetectorControl.exe --control --reset &
-- 
GitLab