source: palm/trunk/SCRIPTS/process_dvr_output @ 260

Last change on this file since 260 was 260, checked in by raasch, 12 years ago

automatic generation of dvrs/html file for combined dvr streams; automatic call of streaming server

  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 4.3 KB
Line 
1#!/bin/ksh
2# process_dvr_output - a script processing dvr steering + data files
3# $Id: process_dvr_output 260 2009-03-16 11:57:58Z raasch $
4
5     # Last changes:
6     # 16/03/09 - Siggi - Generating the first version
7
8
9
10    # variable declarations + default values
11 camera=false
12 groundplate=false
13 topography=false
14
15 typeset  -i  i nstream nscenes
16
17
18    # read shellscript options
19 while  getopts  :d:f: option
20 do
21   case  $option  in
22       (d)   data_catalog=$OPTARG;;
23       (f)   file_identifier=$OPTARG;;
24       (\?)  printf "\n  +++ unknown option $OPTARG \n"
25             printf "\n      allowed option are -d and -f \n"
26             exit;;
27   esac
28 done
29
30
31    # find out the number of streams
32 (( i = 0 ))
33 while true
34 do
35    (( i = i + 1 ))
36    if (( i < 10 ))
37    then
38       cstream=0$i
39    else
40       cstream=$i
41    fi
42
43    if [[ $(ls -1 *.* | grep -c $cstream) = 0 ]]
44    then
45       (( i = i - 1 ))
46       break
47    fi
48
49       # find out the stream name
50    streamname[$i]=`ls -1 ${cstream}_*-ge.dvrs | cut -f1 -d"-"`
51
52       # get addres
53    adr[$i]=`grep ADR= ${streamname[$i]}.dvrs | grep '*' | cut -f2 -d"="`
54
55       # get maxbytes
56    maxbytes[$i]=`head -1 ${streamname[$i]}.max`
57
58       # get number of frames
59    frames[$i]=`tail -1 ${streamname[$i]}.max`
60
61 done
62
63 nstream=$i
64 nscenes=$nstream
65
66 echo "*** number of detected streams = $i"
67
68 (( i = 0 ))
69 while (( i < nstream ))
70 do
71
72    (( i = i + 1 ))
73    echo "*** streamname: \"${streamname[$i]}\" "
74    echo "    adr = \"${adr[$i]}\" "
75    echo "    maxbytes = \"${maxbytes[$i]}\" "
76    echo "    frames = \"${frames[$i]}\" "
77
78 done
79
80    # Check, if there are files containing the camera data, the ground plate
81    # and topography data.
82    # Check the first stream only, because all streams have the same files.
83 if [[ -f ${streamname[1]}_camera.max ]]
84 then
85    camera=true
86    adr_camera=`grep ADR= ${streamname[1]}.dvrs | grep 'camera' | cut -f2 -d"="`
87    maxbytes_camera=`head -1 ${streamname[1]}_camera.max`
88    (( nscenes = nscenes + 1 ))
89 fi
90 if [[ -f ${streamname[1]}_groundplate.max ]]
91 then
92    groundplate=true
93    adr_groundplate=`echo $adr_camera | sed "s/camera/groundplate/g"`
94    maxbytes_groundplate=`head -1 ${streamname[1]}_groundplate.max`
95    (( nscenes = nscenes + 1 ))
96 fi
97 if [[ -f ${streamname[1]}_topography.max ]]
98 then
99    topography=true
100    adr_topography=`echo $adr_camera | sed "s/camera/topography/g"`
101    maxbytes_topography=`head -1 ${streamname[1]}_topography.max`
102    (( nscenes = nscenes + 1 ))
103 fi
104
105
106
107    # start with writing the dvrs file for the combined streams
108 dvr_file=${file_identifier}.dvrs
109
110 echo  "SCENES=$nscenes"  >  $dvr_file
111
112    # first, add the static scenes
113 if [[ $camera = true ]]
114 then
115    echo  "MED=TCP"                    >>  $dvr_file
116    echo  "ADR=$adr_camera"            >>  $dvr_file
117    echo  "MAXBYTES=$maxbytes_camera"  >>  $dvr_file
118    echo  "FRAMES=1"                   >>  $dvr_file
119    echo  "FRAMES_P_SEC=0"             >>  $dvr_file
120    echo  "SCENEEND"                   >>  $dvr_file
121 fi
122
123 if [[ $groundplate = true ]]
124 then
125    echo  "MED=TCP"                         >>  $dvr_file
126    echo  "ADR=$adr_groundplate"            >>  $dvr_file
127    echo  "MAXBYTES=$maxbytes_groundplate"  >>  $dvr_file
128    echo  "FRAMES=1"                        >>  $dvr_file
129    echo  "FRAMES_P_SEC=0"                  >>  $dvr_file
130    echo  "SCENEEND"                        >>  $dvr_file
131 fi
132
133 if [[ $topography = true ]]
134 then
135    echo  "MED=TCP"                        >>  $dvr_file
136    echo  "ADR=$adr_topography"            >>  $dvr_file
137    echo  "MAXBYTES=$maxbytes_topography"  >>  $dvr_file
138    echo  "FRAMES=1"                       >>  $dvr_file
139    echo  "FRAMES_P_SEC=0"                 >>  $dvr_file
140    echo  "SCENEEND"                       >>  $dvr_file
141 fi
142
143
144     # now add the streams
145 (( i = 0 ))
146 while (( i < nstream ))
147 do
148
149    (( i = i + 1 ))
150
151    echo  "MED=TCP"                   >>  $dvr_file
152    echo  "ADR=${adr[$i]}"            >>  $dvr_file
153    echo  "MAXBYTES=${maxbytes[$i]}"  >>  $dvr_file
154    echo  "FRAMES=${frames[$i]}"      >>  $dvr_file
155    echo  "FRAMES_P_SEC=25"           >>  $dvr_file
156    echo  "SCENEEND"                  >>  $dvr_file
157
158 done
159
160
161    # create the html file for the combined scenes
162 cp  01_*-ge.html  tmp.html
163 replace=$(echo `grep src= tmp.html`)
164 sed "s&${replace}&src=\"${file_identifier}.dvrs\"&g" tmp.html > ${file_identifier}.html
165 rm tmp.html
Note: See TracBrowser for help on using the repository browser.