source: tags/Mars-V0.9.6/datacenter/scripts/sourcefile

Last change on this file was 7612, checked in by Daniela Dorner, 19 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 5.2 KB
Line 
1#!/bin/sh
2#
3# ========================================================================
4#
5# *
6# * This file is part of MARS, the MAGIC Analysis and Reconstruction
7# * Software. It is distributed to you in the hope that it can be a useful
8# * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
9# * It is distributed WITHOUT ANY WARRANTY.
10# *
11# * Permission to use, copy, modify and distribute this software and its
12# * documentation for any purpose is hereby granted without fee,
13# * provided that the above copyright notice appear in all copies and
14# * that both that copyright notice and this permission notice appear
15# * in supporting documentation. It is provided "as is" without express
16# * or implied warranty.
17# *
18#
19#
20# Author(s): Daniela Dorner 05/2005 <mailto:dorner@astro.uni-wuerzburg.de>
21#
22# Copyright: MAGIC Software Development, 2000-2006
23#
24#
25# ========================================================================
26#
27# This a resource file for the scripts, in which the standard paths and
28# functions, which are needed more often are stored.
29#
30
31export ROOTSYS=/opt/root_v4.04.02g
32export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ROOTSYS/lib
33export PATH=$PATH:$ROOTSYS/bin
34
35mars=/home/operator/Mars
36macrospath=$mars/datacenter/macros
37scriptspath=$mars/datacenter/scripts
38
39logpath=/magic/datacenter/autologs
40lockpath=/magic/datacenter/locks
41listpath=/magic/datacenter/lists
42setuppath=/magic/datacenter/setup
43
44datapath=/magic/data
45subsystempath=/magic/subsystemdata
46sequpath=/magic/sequences
47datasetpath=/magic/datasets
48
49datetime=`date +%F-%H-%M-%S`
50
51check="ok"
52
53
54#failed codes
55#sequence build status
56Fbuildsequ=1
57Fdoexcl=2
58#run process status
59Ftimecorr=3
60Ffillraw=4
61Fsinope=5
62Ffillsinope=6
63Fresetexcl=7
64#sequence process status
65Fwritesequfile=8
66Ffilesavail=9
67Fnoccfile=10
68Fnocacofile=11
69Fmerppcc=12
70Fmerppcaco=13
71Fcallisto=14
72Ffillcalib=15
73Ffillsignal=16
74Fstar=17
75Ffillstar=18
76#dataset process status
77Fstardone=19
78Fganymed=20
79Ffillganymed=21
80
81
82
83function finish()
84{
85 rm -v $todofile
86 rm -v $lockfile
87 date
88 exit
89}
90
91function makedir()
92{
93 if [ ! -d $@ ]
94 then
95 mkdir -pv $@
96 if [ ! -d $@ ]
97 then
98 echo "could not make dir "$@
99 finish
100 fi
101 fi
102}
103
104function checklock()
105{
106 date > $lockfile
107 checklock0=$?
108 case $checklock0 in
109 0) echo "checklock0=$checklock0 -> continue " ;;
110 1) echo "checklock0=$checklock0 -> file $lockfile exists "
111 echo "-> $@ $program is running -> exit"
112 date
113 exit;;
114 *) echo "checklock0=$checklock0 -> something went completely wrong" ;;
115 esac
116}
117
118function getdolist()
119{
120 datetime=`date +%F-%H-%M-%S`
121 year=`date +%Y`
122 date=NULL
123
124 getstatuslogpath=$logpath/getstatus/$program/$year
125 getstatuslog=$getstatuslogpath/getstatus-$table-$column-$datetime.log
126 makedir $getstatuslogpath
127
128 # get todo list
129 echo "getting todo list..."
130 check0=`root -q -b $macrospath/getdolist.C+\("\"$table\""\,"\"$column\""\,"\"$date\""\,"\"$listpath\""\) | tee $getstatuslog | grep int | sed -e 's/(int)//'`
131
132 case $check0 in
133 1) echo "check0=$check0 -> everything ok, got todo list -> run $program";;
134 *) echo "check0=$check0 -> ERROR -> could not get todo list -> exit"
135 finish ;;
136 esac
137
138}
139
140function resetstatusvalues()
141{
142 statustime=NULL
143 starttime=NULL
144 returncode=NULL
145 failedcode=NULL
146 failedcodeadd=NULL
147 failedtime=NULL
148}
149
150function printstatusvalues()
151{
152 echo "the current values are:"
153 echo " statustime=$statustime"
154 echo " starttime=$starttime"
155 echo " returncode=$returncode"
156 echo " failedcode=$failedcode"
157 echo " failedcodeadd=$failedcodeadd"
158 echo " failedtime=$failedtime"
159 echo "-- check: -$check-"
160 echo ""
161}
162
163function setstatus()
164{
165 # set status values
166 resetstatusvalues
167 case $@ in
168 start) echo "start"
169 starttime="Now()"
170 ;;
171 stop) echo "stop"
172 case $check in
173 ok) echo " ok"
174 statustime="Now()"
175 ;;
176 no) echo "nothing new"
177 check="ok"
178 ;;
179 *) echo " failed"
180 starttime=noreset
181 returncode=$check
182 failedcode=$com
183 if ! [ "$comadd" = "" ]
184 then
185 failedcodeadd=$comadd
186 fi
187 failedtime="Now()"
188 check="ok"
189 ;;
190 esac
191 ;;
192 *) echo "error -> exit"
193 exit
194 ;;
195 esac
196
197# printstatusvalues
198 # set status
199 setstatuslogpath=$logpath/setstatus/$program/$var1
200 makedir $setstatuslogpath
201 setstatuslog=$setstatuslogpath/setstatus-$@-$program-$var2.log
202 checkstatus=`root -q -b $macrospath/setstatus.C+\("\"$var2\""\,"\"$table\""\,"\"$column\""\,"\"$statustime\""\,"\"$returncode\""\,"\"$failedcode\""\,"\"$failedcodeadd\""\,"\"$starttime\""\,"\"$failedtime\""\) | tee $setstatuslog | grep int | sed -e 's/(int)//'`
203 case $checkstatus in
204 1) echo "checkstatus=$checkstatus -> everything ok, status has been set";;
205 *) echo "checkstatus=$checkstatus -> ERROR -> step could not be set -> exit"
206 finish ;;
207 esac
208}
209
210
211
Note: See TracBrowser for help on using the repository browser.