source: trunk/MagicSoft/Mars/datacenter/scripts/sourcefile@ 7486

Last change on this file since 7486 was 7486, checked in by Daniela Dorner, 19 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 5.1 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
49check="ok"
50
51
52#failed codes
53#sequence build status
54Fbuildsequ=1
55Fdoexcl=2
56#run process status
57Ftimecorr=3
58Ffillraw=4
59Fsinope=5
60Ffillsinope=6
61Fresetexcl=7
62#sequence process status
63Fwritesequfile=8
64Ffilesavail=9
65Fnoccfile=10
66Fnocacofile=11
67Fmerppcc=12
68Fmerppcaco=13
69Fcallisto=14
70Ffillcalib=15
71Ffillsignal=16
72Fstar=17
73Ffillstar=18
74#dataset process status
75Fstardone=19
76Fganymed=20
77Ffillganymed=21
78
79
80
81function finish()
82{
83 rm -v $todofile
84 rm -v $lockfile
85 date
86 exit
87}
88
89function makedir()
90{
91 if [ ! -d $@ ]
92 then
93 mkdir -pv $@
94 if [ ! -d $@ ]
95 then
96 echo "could not make dir "$@
97 finish
98 fi
99 fi
100}
101
102function checklock()
103{
104 date > $lockfile
105 checklock0=$?
106 case $checklock0 in
107 0) echo "checklock0=$checklock0 -> continue " ;;
108 1) echo "checklock0=$checklock0 -> file $lockfile exists "
109 echo "-> $@ $program is running -> exit"
110 date
111 exit;;
112 *) echo "checklock0=$checklock0 -> something went completely wrong" ;;
113 esac
114}
115
116function getdolist()
117{
118 datetime=`date +%F-%H-%M-%S`
119 year=`date +%Y`
120 date=NULL
121
122 getstatuslogpath=$logpath/getstatus/$program/$year
123 getstatuslog=$getstatuslogpath/getstatus-$table-$column-$datetime.log
124 makedir $getstatuslogpath
125
126 # get todo list
127 echo "getting todo list..."
128 check0=`root -q -b $macrospath/getdolist.C+\("\"$table\""\,"\"$column\""\,"\"$date\""\,"\"$listpath\""\) | tee $getstatus | grep int | sed -e 's/(int)//'`
129
130 case $check0 in
131 1) echo "check0=$check0 -> everything ok, got todo list -> run $program";;
132 *) echo "check0=$check0 -> ERROR -> could not get todo list -> exit"
133 finish ;;
134 esac
135
136}
137
138function resetstatusvalues()
139{
140 statustime=NULL
141 starttime=NULL
142 returncode=NULL
143 failedcode=NULL
144 failedcodeadd=NULL
145 failedtime=NULL
146}
147
148function printstatusvalues()
149{
150 echo "the current values are:"
151 echo " statustime=$statustime"
152 echo " starttime=$starttime"
153 echo " returncode=$returncode"
154 echo " failedcode=$failedcode"
155 echo " failedcodeadd=$failedcodeadd"
156 echo " failedtime=$failedtime"
157 echo "-- check: -$check-"
158 echo ""
159}
160
161function setstatus()
162{
163 # set status values
164 resetstatusvalues
165 case $@ in
166 start) echo "start"
167 starttime="Now()"
168 ;;
169 stop) echo "stop"
170 case $check in
171 ok) echo " ok"
172 statustime="Now()"
173 ;;
174 *) echo " failed"
175 starttime=noreset
176 returncode=$check
177 failedcode=$com
178 if ! [ "$comadd" = "" ]
179 then
180 failedcodeadd=$comadd
181 fi
182 failedtime="Now()"
183 ;;
184 esac
185 ;;
186 *) echo "error -> exit"
187 exit
188 ;;
189 esac
190
191# printstatusvalues
192 # set status
193 setstatuslogpath=$logpath/setstatus/$program/$var1
194 makedir $setstatuslogpath
195 setstatuslog=$setstatuslogpath/setstatus-$@-$program-$var2.log
196 checkstatus=`root -q -b $macrospath/setstatus.C+\("\"$sequence\""\,"\"$table\""\,"\"$column\""\,"\"$statustime\""\,"\"$returncode\""\,"\"$failedcode\""\,"\"$failedcodeadd\""\,"\"$starttime\""\,"\"$failedtime\""\) | tee $setstatuslog | grep int | sed -e 's/(int)//'`
197 case $checkstatus in
198 1) echo "checkstatus=$checkstatus -> everything ok, status has been set";;
199 *) echo "checkstatus=$checkstatus -> ERROR -> step could not be set -> exit"
200 finish ;;
201 esac
202}
203
204
205
Note: See TracBrowser for help on using the repository browser.