Back to home page

Project CMSSW displayed by LXR

 
 

    


Warning, /DQM/SiPixelMonitorClient/scripts/initialize is written in an unsupported language. File is not indexed.

0001 #!/usr/bin/env perl
0002 
0003 ################################################################################
0004 #
0005 # initialize
0006 # ----------
0007 #
0008 # Setup XDAQ filter farm applications for testing, and generate scripts to
0009 # control execution.
0010 #
0011 #                          03/28/2007 Philipp Schieferdecker <schiefer@fnal.gov>
0012 ################################################################################
0013 use File::Copy;
0014 
0015 my $mode = shift || die "usage: $0 mode => file/live/playback, stopped";
0016 
0017 # welcome
0018 print "\n============================================================";
0019 print "\ninitialize ...";
0020 print "\n============================================================\n";
0021 
0022 # hostname, default
0023 #my $hostname = $ENV{"HOST"};
0024 chop(my $hostname = `hostname -f`);
0025 
0026 # set variables
0027 my $port = 41866;
0028 
0029 my $appname="evf::FUEventProcessor";
0030 
0031 my $localid=50;
0032 
0033 my $libpath = getLibraryPath("EventFilter/Processor");
0034 
0035 my $libname = "libEventFilterProcessor.so";
0036 
0037 my $pwd = `pwd`; chomp $pwd;
0038 
0039 #`mkdir -p $pwd/PixelDQM`;
0040 
0041 #my $mode = $ARGV[0];
0042 my $dqm_dir = $ENV{"CMSSW_BASE"}."/src/DQM/SiPixelMonitorClient/test";
0043 my $dqm_int = $ENV{"CMSSW_BASE"}."/src/DQM/Integration/test";
0044 my $dqm_common = $ENV{"CMSSW_RELEASE_BASE"}."/src/DQM/TrackerCommon/test";
0045 `mkdir -p /tmp/PixelDQM`;
0046 my $dqm_wdir = "/tmp/PixelDQM";
0047 
0048 my $cfg_file = "pixel_dqm_sourceclient-".$mode."_cfg.py";
0049 print "cfg file name : $cfg_file\n";
0050 #
0051 # interpret command line
0052 #
0053 #foreach $param (@ARGV) {
0054 #    if    ($hostname eq "fillme")    { $hostname=$param; }
0055 #    elsif ($param    eq "-host")     { $hostname="fillme"; }
0056 #
0057 #    else { die ("Unknown parameter $param!\n"); }
0058 #}
0059 
0060 print "hostname = $hostname\n";
0061 
0062 #
0063 # make directories
0064 #
0065 print "make directories ...\n";
0066 `mkdir -p $dqm_wdir/log`;
0067 `mkdir -p $dqm_wdir/soap`;
0068 `mkdir -p $dqm_wdir/xml`;
0069 `mkdir -p $dqm_int/TkMap`;
0070 
0071 #
0072 # make cfg files
0073 #
0074 print "copy cfg files ...\n";
0075 
0076 #copy("$dqm_int/$cfg_file", "$ENV{PWD}/.") unless -e "$ENV{PWD}/$cfg_file";
0077 #copy("$dqm_dir/../scripts/Reference.root", "$ENV{PWD}/Reference.root") unless -e "$ENV{PWD}/Reference.root";
0078 
0079 #system qq[perl], qq[-pi -e], qq[s/ sourceURL/ #sourceURL/], qq[$dqm_int/../python/test/inputsource_cfi.py]; 
0080 #system qq[perl], qq[-pi -e], qq[s/%s:22100/%s:40867/], qq[$dqm_int/../python/test/inputsource_cfi.py]; 
0081 #system qq[perl], qq[-pi -e], qq[s/lid=30' /lid=50' /], qq[$dqm_int/../python/test/inputsource_cfi.py];
0082 
0083 
0084 my $dqm_python = $ENV{"CMSSW_BASE"}."/src/DQM/Integration/python/test";
0085 my $input_url = qq[ sourceURL = cms.string('http://%s:40867/urn:xdaq-application:lid=50' %socket.gethostname()),];
0086 system qq[perl], qq[-pi -e], qq[s! sourceURL.*!$input_url!], qq[$dqm_python/inputsource_cfi.py]; 
0087 
0088 #
0089 # make XDAQ 'profile.xml'
0090 #
0091 print "make xdaq profile ...\n";
0092 
0093 my @EXproperties = ("logUrl",  "string","console",
0094                     "logLevel","string","ERROR");
0095 
0096 
0097 my @Pathproperties = ("documentRoot", "string",q|${XDAQ_DOCUMENT_ROOT}|,
0098                      "aliasName",  "string","temporary",
0099                     "aliasPath","string",$dqm_wdir);
0100 
0101 my @XPproperties = ("settings", "string",q|${XDAQ_ROOT}/htdocs/xplore/xml/shortcuts.xml|,
0102                     "republishInterval",  "string",3600);
0103 
0104 my @STproperties = ("useDiscovery", "boolean","true",
0105                      "publish", "string", "exception",
0106                      "watchdog", "string", "PT5S");
0107 my @XMasproperties = ("useDiscovery", "boolean","true",
0108                        "autoConfigure", "boolean", "true",
0109                        "autoConfSearchPath", "string", q|${XDAQ_SETUP_ROOT}/${XDAQ_ZONE}/sensor|);
0110 
0111 open (XML,">$dqm_wdir/xml/profile.xml") or die ("Can't open file: $!\n");
0112 print XML makeXmlHeader();
0113 print XML makeXmlProfileHeader();
0114 print XML makeXmlAppHeader(0,"executive::Application",0,"executive","profile");
0115 print XML makeXmlAppProperties("Executive",@EXproperties);
0116 print XML "    </properties>\n";
0117 print XML "    </xp:Application>\n";
0118 print XML makeXmlAppTrailer(0,q|${XDAQ_ROOT}/lib|,"libexecutive.so");
0119 print XML makeXmlAppHeader(0,"pt::http::PeerTransportHTTP",1);
0120 print XML makeXmlAppProperties("pt::http::PeerTransportHTTP",@Pathproperties);
0121 print XML "      </properties>\n";
0122 print XML "    </xp:Application>\n";
0123 print XML makeXmlAppTrailer(0,q|${XDAQ_ROOT}/lib|,"libpthttp.so");
0124 print XML makeXmlAppHeader(0,"pt::fifo::PeerTransportFifo",8);
0125 print XML "    </xp:Application>\n";
0126 print XML makeXmlAppTrailer(0,q|${XDAQ_ROOT}/lib|,"libptfifo.so");
0127 print XML makeXmlAppHeader(0,"xrelay::Application",4,"xrelay");
0128 print XML "    </xp:Application>\n";
0129 print XML makeXmlAppTrailer(0,q|${XDAQ_ROOT}/lib|,"libxrelay.so");
0130 print XML makeXmlAppHeader(0,"hyperdaq::Application",3,"hyperdaq");
0131 print XML "    </xp:Application>\n";
0132 print XML makeXmlAppTrailer(0,q|${XDAQ_ROOT}/lib|,"libhyperdaq.so");
0133 #print XML makeXmlAppHeader(0,"xplore::Application",9);
0134 #print XML makeXmlAppProperties("xplore::Application",@XPproperties);
0135 #print XML "      </properties>\n";
0136 #print XML "    </xp:Application>\n";
0137 #print XML makeXmlAppTrailer(0,q|${XDAQ_ROOT}/lib|,"libslp.so");
0138 #print XML makeXmlAppTrailer(0,q|${XDAQ_ROOT}/lib|,"libxslp.so");
0139 #print XML makeXmlAppTrailer(0,q|${XDAQ_ROOT}/lib|,"libxploreutils.so");
0140 #print XML makeXmlAppTrailer(0,q|${XDAQ_ROOT}/lib|,"libxplore.so");
0141 #print XML makeXmlAppHeader(0,"sentinel::Application",21,"sentinel","exception");
0142 #print XML makeXmlAppProperties("Sentinel",@STproperties);
0143 #print XML "      </properties>\n";
0144 #print XML "    </xp:Application>\n";
0145 #print XML makeXmlAppTrailer(0,q|${XDAQ_ROOT}/lib|,"libwsaddressing.so");
0146 #print XML makeXmlAppTrailer(0,q|${XDAQ_ROOT}/lib|,"libwseventing.so");
0147 #print XML makeXmlAppTrailer(0,q|${XDAQ_ROOT}/lib|,"libsentinelutils.so");
0148 #print XML makeXmlAppTrailer(0,q|${XDAQ_ROOT}/lib|,"libsentinel.so");
0149 #print XML makeXmlAppHeader(0,"xmas::sensor::Application",10,"sensor","c2d05,service,init3");
0150 #print XML makeXmlAppProperties("xmas",@XMasproperties);
0151 #print XML makeXmlAppPublish();
0152 #print XML "      </properties>\n";
0153 #print XML "    </xp:Application>\n";
0154 #print XML makeXmlAppTrailer(0,q|${XDAQ_ROOT}/lib|,"libxmasutils.so");
0155 #print XML makeXmlAppTrailer(0,q|${XDAQ_ROOT}/lib|,"libxmassensor.so");
0156 print XML makeXmlProfileTrailer();
0157 
0158 
0159 
0160 #
0161 # make  xdaq configuration file 'evf.xml'
0162 #
0163 print "make xdaq  configuration ...\n";
0164 
0165 my @properties = ("parameterSet", "string","file:$dqm_int/$cfg_file",
0166                     "hasPrescaleService","boolean","false",
0167                     "isRunNumberSetter","boolean","false",
0168                     "hasSharedMemory","boolean","false");
0169 
0170 open (XML,">$dqm_wdir/xml/evf.xml") or die ("Can't open file: $!\n");
0171 print XML makeXmlHeader();
0172 print XML makeXmlPartitionHeader();
0173 print XML makeXmlComm(@apps);
0174 
0175 
0176   print XML makeXmlContextHeader("DQM",$hostname,$port);
0177   print XML makeXmlAppHeader(1,$appname,$localid);
0178   print XML makeXmlAppProperties($appname,@properties);
0179   print XML "      </properties>\n";
0180   print XML "    </xc:Application>\n";
0181   print XML makeXmlAppTrailer(1,$libpath,$libname);
0182   print XML makeXmlContextTrailer();
0183 
0184 
0185 print XML makeXmlPartitionTrailer();
0186 close (XML);
0187 
0188 
0189 #
0190 # make soap command xml files
0191 #
0192 print "make soap command files ...\n";
0193 
0194 my @commands = ('Configure','Enable','Stop','Halt' );
0195 
0196 foreach  (@commands) {
0197     open(CMD,">$dqm_wdir/soap/$_".".xml") or die ("Can't open file: $!\n");
0198     print CMD makeSoapCommand($hostname,$port,$localid,$_);
0199     close(CMD);
0200 }
0201 
0202 
0203 #
0204 # make control scripts
0205 #
0206 print "make control scripts ...\n";
0207 
0208 # configure
0209 open (CTL,qq|>$dqm_wdir/configure|) or die ("Can't open file: $!\n");
0210 print CTL "#!/usr/bin/perl\n\n";
0211 print CTL makeCtlCommand("Configure",$appname,"DQM",$hostname,$port,0,"source");
0212 
0213 close (CTL);
0214 `chmod +x $dqm_wdir/configure`;
0215 
0216 # enable
0217 open (CTL,qq|>$dqm_wdir/enable|) or die ("Can't open file: $!\n");
0218 print CTL "#!/usr/bin/perl\n\n";
0219 print CTL makeCtlCommand("Enable",$appname,"DQM",$hostname,$port,0,"source");
0220 
0221 close (CTL);
0222 `chmod +x $dqm_wdir/enable`;
0223 
0224 # stop
0225 open (CTL,qq|>$dqm_wdir/stop|) or die ("Can't open file: $!\n");
0226 print CTL "#!/usr/bin/perl\n\n";
0227 print CTL makeCtlCommand("Stop",$appname,"DQM",$hostname,$port,5,"source");
0228 
0229 close (CTL);
0230 `chmod +x $dqm_wdir/stop`;
0231 
0232 # halt
0233 open (CTL,qq|>$dqm_wdir/halt|) or die ("Can't open file: $!\n");
0234 print CTL "#!/usr/bin/perl\n\n";
0235 print CTL makeCtlCommand("Halt",$appname,"DQM",$hostname,$port,1,"source");
0236 
0237 close (CTL);
0238 `chmod +x $dqm_wdir/halt`;
0239 
0240 # destroy
0241 open (CTL,qq|>$dqm_wdir/destroy|) or die ("Can't open file: $!\n");
0242 print CTL makeCtlDestroy();
0243 close (CTL);
0244 `chmod +x $dqm_wdir/destroy`;
0245 
0246 #
0247 # copy scripts and other auxiliary files
0248 #
0249 copy("$dqm_dir/.WebLib.js",  "$dqm_wdir/WebLib.js");
0250 copy("$dqm_dir/Online.html", "$dqm_wdir/.");
0251 copy("$dqm_dir/loader.html", "$dqm_wdir/.");
0252 copy("$dqm_dir/TrackerMapFrame.html", "$dqm_wdir/.");
0253 copy("$dqm_dir/TrackerMapME.html", "$dqm_wdir/.");
0254 copy("$dqm_dir/TrackerMapHeader.txt", "$dqm_wdir/.");
0255 copy("$dqm_dir/TrackerMapTrailer.txt",  "$dqm_wdir/.");
0256 copy("$dqm_dir/TrackerMapPlot.html",  "$dqm_wdir/.");
0257 copy("$dqm_dir/rightEmbedded.html", "$dqm_wdir/.");
0258 copy("$dqm_dir/embedded_svg.html",       "$dqm_wdir/.");
0259 copy("$dqm_dir/svgmap.xml",              "$dqm_wdir/.");
0260 
0261 $SERVED_DIR="http://$hostname:$port/temporary";
0262 system qq[perl], qq[-pi -e], qq[s#SERVED_DIRECTORY_URL#$SERVED_DIR#], qq[$dqm_wdir/WebLib.js]; 
0263 system qq[perl], qq[-pi -e], qq[s#40000#$port#], qq[$dqm_wdir/WebLib.js]; 
0264 system qq[perl], qq[-pi -e], qq[s#lid=27#lid=$localid#], qq[$dqm_wdir/WebLib.js]; 
0265 
0266 system qq[cp], qq[-r], qq[$dqm_dir/js_files], qq[$dqm_wdir/js_files];
0267 system qq[cp], qq[-r], qq[$dqm_dir/css_files], qq[$dqm_wdir/css_files];
0268 system qq[cp], qq[-r], qq[$dqm_dir/images], qq[$dqm_wdir/images];
0269 system qq[perl], qq[-pi -e], qq[s#40000#$port#], qq[$dqm_wdir/js_files/IMGC.js]; 
0270 system qq[perl], qq[-pi -e], qq[s#lid=27#lid=$localid#], qq[$dqm_wdir/js_files/IMGC.js]; 
0271 system qq[perl], qq[-pi -e], qq[s#lid=27#lid=$localid#], qq[$dqm_wdir/js_files/TkMapFrame.js]; 
0272 
0273 copy("$dqm_dir/js_files/.svgmap.js", "$dqm_wdir/js_files/svgmap.js");
0274 system qq[perl], qq[-pi -e], qq[s#serverHost#$COLLECTORNAME#g], qq[$dqm_wdir/js_files/svgmap.js];
0275 
0276 #
0277 # start processes
0278 #
0279 
0280 #print "\nstart xdaq.exe on $hostname:$port\n";
0281 #`nice -n 15 xdaq.exe -h $hostname -p $port -e xml/profile.xml -c xml/evf.xml >& log/$hostname.$port.log &`;
0282 open OUTPUT, qq|>$dqm_wdir/start| or die($!);
0283 my $script=<<"EOS";
0284 #!/bin/sh
0285 
0286 xdaq.exe -h $hostname -p $port -e $dqm_wdir/xml/profile.xml -c $dqm_wdir/xml/evf.xml
0287 EOS
0288 print OUTPUT $script;
0289 close OUTPUT;
0290 `chmod +x $dqm_wdir/start`;
0291 
0292 
0293 
0294 ################################################################################
0295 ################################################################################
0296 ## sub routines
0297 ################################################################################
0298 ################################################################################
0299 
0300 
0301 ################################################################################
0302 sub getLibraryPath
0303 {
0304     my ($pkg) = (@_);
0305     
0306     my $cmssw_base         = $ENV{"CMSSW_BASE"};
0307     my $cmssw_release_base = $ENV{"CMSSW_RELEASE_BASE"};
0308 
0309     my $result = "/lib/" . $ENV{"SCRAM_ARCH"};
0310     
0311     if (-e "$cmssw_base/src/$pkg") {
0312         $result = $cmssw_base . $result;
0313     }
0314     else {
0315         $result = $cmssw_release_base . $result;
0316     }
0317     print "\n Result of Lib Path $result\n";
0318     return $result;
0319 }
0320 
0321 ################################################################################
0322 sub makeSoapCommand
0323 {
0324     my ($hostname,$port,$localid,$command) = @_;
0325     
0326     my $result="";
0327     
0328     $result = $result . "<SOAP-ENV:Envelope\n";
0329     $result = $result . "  SOAP-ENV:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"\n";
0330     $result = $result . "  xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\"\n";
0331     $result = $result . "  xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n";
0332     $result = $result . "  xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"\n";
0333     $result = $result . "  xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\">\n\n";
0334     $result = $result . "<SOAP-ENV:Header>\n";
0335     $result = $result . "  <xr:relay SOAP-ENV:actor=\"http://xdaq.web.cern.ch/xdaq/xsd/2004/XRelay-10\"\n";
0336     $result = $result . "    xmlns:xr=\"http://xdaq.web.cern.ch/xdaq/xsd/2004/XRelay-10\">\n";
0337     $result = $result . "  <xr:to url=\"http://$hostname:$port\" urn=\"urn:xdaq-application:lid=$localid\"/>\n";
0338     $result = $result . "</xr:relay>\n";
0339     $result = $result . "</SOAP-ENV:Header>\n\n";
0340     $result = $result . "<SOAP-ENV:Body>\n";
0341     $result = $result . "  <xdaq:$command xmlns:xdaq=\"urn:xdaq-soap:3.0\"></xdaq:$command>\n";
0342     $result = $result . "</SOAP-ENV:Body>\n\n";
0343     $result = $result . "</SOAP-ENV:Envelope>\n";
0344     
0345     return $result;
0346 }
0347 
0348 
0349 
0350 
0351 ################################################################################
0352 ################################################################################
0353 sub makeXmlHeader
0354 {
0355     my $result = "";
0356     
0357     return "<?xml version='1.0'?>\n\n";
0358     $result = $result . "<xc:Partition\n";
0359     $result = $result . "  xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n";
0360     $result = $result . "  xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\"\n";
0361     $result = $result . "  xmlns:xc=\"http://xdaq.web.cern.ch/xdaq/xsd/2004/XMLConfiguration-30\">\n\n";
0362     
0363     return $result;
0364 }
0365 
0366 
0367 ################################################################################
0368 sub makeXmlPartitionHeader
0369 {
0370     my $result = "";
0371     
0372     $result = $result . "<xc:Partition\n";
0373     $result = $result . "  xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n";
0374     $result = $result . "  xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\"\n";
0375     $result = $result . "  xmlns:xc=\"http://xdaq.web.cern.ch/xdaq/xsd/2004/XMLConfiguration-30\">\n\n";
0376     
0377     return $result;
0378 }
0379 
0380 
0381 ################################################################################
0382 sub makeXmlProfileHeader
0383 {
0384     return 
0385         "<xp:Profile\n" .
0386         "  xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" .
0387         "  xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\"\n" .
0388         "  xmlns:xp=\"http://xdaq.web.cern.ch/xdaq/xsd/2005/XMLProfile-10\">\n\n";
0389 }
0390 
0391 
0392 ################################################################################
0393 sub makeXmlComm
0394 {
0395     my $result = "";
0396     
0397     $result = $result . "  <!-- communication protocoll -->\n";
0398     $result = $result . "  <i2o:protocol xmlns:i2o=" .
0399         "\"http://xdaq.web.cern.ch/xdaq/xsd/2004/I2OConfiguration-30\">\n";
0400     
0401     while (@_>0) {
0402         my $appname  = shift (@_);
0403         my $localid  = shift (@_);
0404         $result = $result . "    <i2o:target class=\"" . $appname .
0405                             "\" instance=\"0\" tid=\"" . $localid . "\"/>\n";
0406     }
0407     $result = $result . "  </i2o:protocol>\n\n";
0408     
0409     return $result;
0410 }
0411 
0412 
0413 ################################################################################
0414 sub makeXmlContextHeader
0415 {
0416     my ($contextname,$hostname,$port) = @_;
0417 
0418     my $result = "";
0419     
0420     $result = $result . "<!-- " . $contextname . " CONTEXT -->\n";
0421     $result = $result . "  <xc:Context url=\"http://$hostname:$port\">\n\n";
0422     
0423     return $result;
0424 }
0425 
0426 
0427 
0428 ################################################################################
0429 sub makeXmlEndpoint
0430 {
0431     my ($hostname,$port) = @_;
0432 
0433     my $result = "";
0434     $result = $result . "    <xc:Endpoint hostname=\"" . $hostname .
0435         "\" network=\"tcp0\" " .
0436         "port=\"" .$port . "\" protocol=\"tcp\" " .
0437         "service=\"i2o\"></xc:Endpoint>\n\n";
0438     return $result;
0439 }
0440 
0441 
0442 ################################################################################
0443 sub makeXmlAppHeader
0444 {
0445     my ($inContext,$appname,$localid,$service,$group) = @_;
0446 
0447     my $ns = "xc"; if (!$inContext) { $ns = "xp"; }
0448     
0449     my $result = qq|    <$ns:Application class="$appname" id="$localid"|;
0450     $result .= qq| group="$group"| if defined $group;
0451     $result .= qq| service="$service"| if defined $service;
0452     $result .= qq| instance="0"|;
0453     $result .= qq| network="local">\n|;
0454     return $result;
0455 }
0456 
0457 
0458 ################################################################################
0459 sub makeXmlAppProperties
0460 {
0461     my $result = "";
0462 
0463     my $appname = shift (@_);
0464 
0465     $result = $result . "      <properties xmlns=\"urn:xdaq-application:" . $appname .
0466                                     "\" xsi:type=\"soapenc:Struct\">\n";
0467     while (@_>0) {
0468         my $name  = shift (@_);
0469         my $type  = shift (@_);
0470         my $value = shift (@_);
0471         $result = $result . "        <" . $name . " xsi:type=\"xsd:" . $type . "\">" . $value . "</" . $name . ">\n";
0472     }
0473 #    $result = $result . "      </properties>\n";
0474     
0475     return $result;
0476 }
0477 
0478 
0479 ################################################################################
0480 sub makeXmlUnicast
0481 {
0482     my ($appname) = (@_);
0483     return "      <xc:Unicast class=\"" . $appname . "\" network=\"tcp0\"></xc:Unicast>\n";
0484 }
0485 
0486 
0487 ################################################################################
0488 sub makeXmlAppTrailer
0489 {
0490     my ($inContext,$libpath,$libname) = @_;
0491 
0492     my $ns = "xc"; if (!$inContext) { $ns = "xp"; }
0493     
0494     my $result = "";
0495     
0496 #    $result = $result . "    </$ns:Application>\n";
0497     $result = $result . "    <$ns:Module>" . $libpath .
0498                         "/" . $libname . "</$ns:Module>\n\n";
0499     
0500     return $result;
0501 }
0502 
0503 
0504 ################################################################################
0505 sub makeXmlContextTrailer
0506 {
0507     return "  </xc:Context>\n\n\n";
0508 }
0509 
0510 
0511 ################################################################################
0512 sub makeXmlProfileTrailer
0513 {
0514     return "</xp:Profile>\n";
0515 }
0516 
0517 
0518 ################################################################################
0519 sub makeXmlPartitionTrailer
0520 {
0521     return "</xc:Partition>\n";
0522 }
0523 
0524 
0525 ################################################################################
0526 sub makeXmlAppPublish
0527 {
0528 
0529     my $result = qq|             <publish xsi:type="soapenc:Array" soapenc:arrayType="xsd:ur-type[1]">\n|;
0530     $result .= qq|                <item xsi:type="soapenc:Struct" soapenc:position="[0]">\n|;
0531     $result .= qq|                   <tag xsi:type="xsd:string"></tag>\n|;
0532     $result .= qq|                   <group xsi:type="xsd:string">c2d05</group>\n|;
0533     $result .= qq|                </item>\n|;
0534     $result .= qq|             </publish>\n|;
0535     
0536     return $result;
0537 }
0538 ################################################################################
0539 sub makeCtlDestroy
0540 {
0541     my $result = "";
0542 
0543     my $cmd = "killall xdaq.exe";
0544 
0545     $result = $result . "#!/usr/bin/perl\n\n";
0546     $result = $result . "print \"$cmd ...\\n\";\n\n";
0547     $result = $result . "`$cmd`;\n\n";
0548     $result = $result . "print \"remove files and dirs ...\n\";\n\n";
0549     $result = $result . "`rm -rf  $dqm_wdir`;\n\n";
0550     $result = $result . "`rm -rf svgmap.xml \*.png`;\n\n";
0551     $result = $result . "print \"FUShmCleanUp_t ...\\n\";\n\n";
0552     $result = $result . "`FUShmCleanUp_t`;\n\n";
0553     $result = $result . "print \"XDAQ session destroyed!\\n\";\n\n";
0554     
0555     return $result;
0556 }
0557 
0558 
0559 ################################################################################
0560 sub makeCtlCommand
0561 {
0562     my ($cmd,$appname,$appabrev,$host,$port,$sleep,$param) = (@_);
0563 
0564     my $result = "";
0565     
0566     $result = $result."print \"\\n===============================================\";\n";
0567     $result = $result."print \"\\n$cmd the $appname ($appabrev)...\";\n";
0568     $result = $result."print \"\\n\===============================================\";\n";
0569     $result = $result."my \$result = `".makeCurlCommand($cmd,$appabrev,$host,$port)."`;\n";
0570     $result = $result."print \"\\n\$result\\n\\n\";\n";
0571     if ($sleep>0){
0572         $result = $result . "\n\t`sleep $sleep`;\n";
0573     }
0574 
0575     return $result;
0576 }
0577 
0578 
0579 ################################################################################
0580 sub makeCurlCommand
0581 {
0582     my ($cmd,$appabrev,$host,$port) = @_;
0583     my $pwd = `pwd`; chomp($pwd);
0584     return 
0585         "curl --stderr /dev/null -H " .
0586         "\"SOAPAction: urn:xdaq-application:lid=4\" " .
0587         "-d @" . $dqm_wdir . "/soap/" . $cmd . ".xml " .
0588         "http://" . $host . ":" . $port;
0589 }