Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JDAQDriver.sh
Go to the documentation of this file.
1 #!/bin/zsh
2 #
3 # \author mdejong
4 #
5 script=${0##*/}
6 
7 # ------------------------------------------------------------------------------------------
8 #
9 # Example script to run JDAQDriver.
10 #
11 # ------------------------------------------------------------------------------------------
12 
13 
14 
15 if [ -z $JPP_DIR ]; then
16  echo "Variable JPP_DIR undefined."
17  exit
18 fi
19 
20 
21 source $JPP_DIR/setenv.sh $JPP_DIR >& /dev/null
22 
23 if ( do_usage $* ); then
24  usage "$script"
25 fi
26 
27 set_variable SERVER localhost
28 set_variable LOGGER localhost
30 set_variable RUN 1001
31 set_variable TIMEOUT_S 3
32 set_variable RUNTIME_S 1
33 set_variable HOST `get_ip_address`
34 set_variable HOST1 $HOST
35 set_variable HOST2 $HOST
36 set_variable HOST3 $HOST
37 set_variable HOST4 $HOST
38 set_variable PORT 5552
39 set_variable EVENT_NUMBER 1234
40 
41 
42 # re-start ligier for command and logger messages
43 
44 if (( 1 )); then
45  JLigier.sh continue
46 fi
47 
48 
49 # example to read event associated data from a file
50 
51 cat>ev_init.txt<<EOF
52 hello world
53 EOF
54 
55 
56 # driver input
57 
58 cat>driver.txt<<EOF
59 
60 # To avoid unnecessary shell processes, the process I/O is redirected to /dev/null and the ssh command is quoted.
61 # Note that process with extension /- will deliberately crash during the configure transition
62 # and process with extension /+ will sleep forever during the exit transition.
63 
64 process JDAQDemoClient/A $HOST1 ssh \$HOST\$ "JDAQDemoClient -u %/A -H \$SERVER\$ -M \$LOGGER\$ -d $DEBUG </dev/null >&/dev/null &";
65 process JDAQDemoClient/B $HOST2 JDAQClientStarter -H $HOST3:$PORT -m "-H \$SERVER\$ -M \$LOGGER\$ -d $DEBUG";
66 process JDAQDemoClient/- $HOST3 ssh \$HOST\$ "JDAQDemoClient -u \$NAME\$ -H \$SERVER\$ -M \$LOGGER\$ -d $DEBUG </dev/null >&/dev/null &";
67 process JDAQDemoClient/+ $HOST4 ssh \$HOST\$ "JDAQDemoClient -u \$NAME\$ -H \$SERVER\$ -M \$LOGGER\$ -d $DEBUG </dev/null >&/dev/null &";
68 
69 enter
70 
71 event ev_init:$EVENT_NUMBER { RC_CMD %<ev_init.txt>%from me%<ev_init.txt>% }
72 event ev_configure { RC_CMD }
73 
74 # Client with extension /- should have crashed by now.
75 # So, put failed clients to sleep with names containing given character sequence.
76 
77 filter JDAQDemoClient;
78 
79 event ev_start { RC_CMD $RUN 1 }
80 
81 sleep $RUNTIME_S
82 
83 event ev_pause { RC_CMD }
84 event ev_stop { RC_CMD }
85 event ev_reset { RC_CMD }
86 event ev_off { RC_CMD }
87 
88 EOF
89 
90 
91 # The following process is assumed to run 'forever', i.e.
92 # it is started before the driver and continues thereafter.
93 # It is therefore killed by hand at the end of the show.
94 
95 JDAQDemoClient -u JDAQDemoClient/B -P $PORT &
96 
97 PID=$!
98 
99 JDAQDriver -H $SERVER -M $LOGGER -d $DEBUG -t $TIMEOUT_S -f driver.txt -c
100 
101 kill -9 $PID
102 
103 
104 if (( 0 )); then
105 
106  JStopDAQ.sh $SERVER
107 
108 fi
static const double H
Planck constant [eV s].
Definition: JConstants.hh:25
event< ev_daq > ev_reset
Definition: JDAQCHSM.chsm:180
then JLigiers sh continue fi cat driver txt<< EOFprocess dfilter $HOST1 ssh\$HOST\$"JDataFilter -H \$SERVER\$ -M \$LOGGER\$ -d $DEBUG &";enterevent ev_init{RC_CMD%< ev_init.txt > from me< ev_init.txt > event ev_configure
do $JPP JMEstimator M
Definition: JMEstimator.sh:37
event< ev_daq > ev_stop
Definition: JDAQCHSM.chsm:179
void set_variable(const std::string &name, const std::string &value)
Set environment variable.
then usage $script[host[local file]] fi case set_variable LOGGER
Definition: JStopDAQ.sh:28
exit
Definition: JPizza.sh:36
event< ev_daq > ev_pause
Definition: JDAQCHSM.chsm:177
then JPizza f
Definition: JPizza.sh:46
then cat ev_configure txt<< EOFdatawriter=$DWRITER_HOST;inputFile=$INPUT_FILE;eventRate_Hz=100.0;EOFfiif[[!-f driver.txt]];thencat > driver txt<< EOFprocess JEventGenerator $HOST ssh\$HOST\$"$JPP_BIN/JEventGenerator -u \$NAME\$ -H \$SERVER\$ -M \$LOGGER\$ -d $DEBUG </dev/null >& dev null& process JDataWriter $HOST ssh $HOST $JPP_BIN JDataWriter u $NAME H $SERVER M $LOGGER d $DEBUG</dev/null >& dev null& enter event ev_init
then echo
then print_variable DETECTOR INPUT_FILE INTERMEDIATE_FILE check_input_file $DETECTOR $INPUT_FILE check_output_file $INTERMEDIATE_FILE $OUTPUT_FILE JMCEvt f $INPUT_FILE o $INTERMEDIATE_FILE d
Definition: JPath.sh:52
then rm i $OUTPUT_FILE fi let RUN
* usage
do sleep done JPutMessage H $LOGGER t MSG m Hello world
&set_variable HOST
then JLigier sh continue fi cat ev_init txt<< EOFhello worldEOFcat > driver txt<< EOFprocess JDAQDemoClient/A $HOST1 ssh\$HOST\$"JDAQDemoClient -u %/A -H \$SERVER\$ -M \$LOGGER\$ -d $DEBUG </dev/null >& dev null& process JDAQDemoClient B $HOST2 JDAQClientStarter H $HOST3
Definition: JDAQDriver.sh:64
then PID
event< ev_daq > ev_off
Definition: JDAQCHSM.chsm:182
static const JNET::JTag RC_CMD
Definition: JDAQTags.hh:44
double u[N+1]
Definition: JPolint.hh:706
source $JPP_DIR setenv csh $JPP_DIR eval JShellParser o a A
esac $JPP_BIN JLogger sh $LOGGER until pgrep JGetMessage</dev/null > dev null
then $DIR JPlotNPE PDG P
Definition: JPlotNPE-PDG.sh:60
then usage $script fi SERVER
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62