PageRenderTime 62ms CodeModel.GetById 28ms RepoModel.GetById 0ms app.codeStats 0ms

/dev/dcsRealTime.php

https://github.com/lauramoraes/WIS
PHP | 378 lines | 307 code | 39 blank | 32 comment | 32 complexity | 61665909c421862ea338442879d2b5fb MD5 | raw file
  1. <?
  2. //Taking the modules
  3. $moduleString = "";
  4. $runNumber = "";
  5. $runType="";
  6. $createdModule="";
  7. $nonCreatedModule="";
  8. if(!$HTTP_POST_VARS)
  9. $HTTP_POST_VARS = &$HTTP_GET_VARS;
  10. reset ($HTTP_POST_VARS);
  11. while ( list($key, $val) = each($HTTP_POST_VARS))
  12. {
  13. if ( $key=="moduleString" ) $moduleString = $val; //getting the module name
  14. if ( $key=="runNumber" ) $runNumber = $val; //getting the module name
  15. if ( $key=="runType" ) $runType = $val; //getting the module name
  16. if ( $key=="createdModuleString") $createdModule = $val;
  17. if ( $key=="nonCreatedModuleString") $nonCreatedModule = $val;
  18. }
  19. include_once("TileCalBarrel.php");
  20. //Create an instance of the TileCalBarrel
  21. $barrel = new TileCalBarrel();
  22. $barrel2 = new TileCalBarrel();
  23. //Set the barrel name. Initializes internal properties
  24. //of the barrel (chirality,...)
  25. $barrel->SetName("LBA");
  26. $barrel2->SetName("LBC");
  27. //Define the number of wedges you want for your barrel
  28. $barrel->wedges = 3;
  29. $barrel2->wedges = 3;
  30. //Set if you want to see the Sector Labels
  31. //$barrel->SetSectorLabels();
  32. //Set the barrel Legend depending on chirality
  33. //$barrel->SetLegend();
  34. //Use your own WAY of setting the colors
  35. if(isset($_GET["draw"]))
  36. {
  37. //Connect Tilecomm Database
  38. $mysqlCon = mysql_connect("atlasdev1.cern.ch","lodi","cOAnAd26")
  39. or die("cannot connect to database server atlasdev1 :(");
  40. mysql_select_db("tbanalysis", $mysqlCon);
  41. //Creating commentsArray
  42. // All module commented array
  43. $selectComment="SELECT tcaRun.idAtlasId, tcaRun.idTestId, idatlas.code, testsID.testID FROM tcaRun, idatlas, testsID WHERE tcaRun.runNumber=$runNumber AND (LTRIM(comments) IS NOT NULL AND LTRIM(comments) <> \"\") AND testsID.id=tcaRun.idTestId AND idatlas.id= tcaRun.idAtlasId ;";
  44. $resComment = mysql_query($selectComment,$mysqlCon) or die("Failure: " . mysql_error());
  45. $countComment= mysql_num_rows($resComment);
  46. $commentsArray= array();
  47. for($indexComment=0; $indexComment<$countComment;$indexComment++)
  48. {
  49. $rowComment = mysql_fetch_row($resComment);
  50. $tempString= $rowComment[2];
  51. if($rowComment[3]<10)
  52. $tempString .= 0;
  53. $tempString .= $rowComment[3];
  54. array_push($commentsArray, $tempString);
  55. }
  56. mysql_free_result($resComment);
  57. $selectComment="SELECT tcaRun.idAtlasId, tcaRun.idTestId, idatlas.code, testsID.testID, tcaRun.statusCommentsId FROM tcaRun, idatlas, testsID WHERE tcaRun.runNumber=$runNumber AND testsID.id=tcaRun.idTestId AND idatlas.id= tcaRun.idAtlasId ;";
  58. //echo "<H1>$selectComment</H1>";
  59. $resComment = mysql_query($selectComment,$mysqlCon) or die("Failure: " . mysql_error());
  60. $countComment= mysql_num_rows($resComment);
  61. $statusCommentsArray = array();
  62. for($indexComment=0; $indexComment<$countComment;$indexComment++)
  63. {
  64. $rowComment = mysql_fetch_row($resComment);
  65. $tempString= $rowComment[2];
  66. if($rowComment[3]<10)
  67. $tempString .= 0;
  68. $tempString .= $rowComment[3];
  69. $tempArray= array($tempString => $rowComment[4]);
  70. //print_r($tempArray);echo"<BR>";
  71. $statusCommentsArray= array_merge($statusCommentsArray, $tempArray);
  72. }
  73. //print_r($statusCommentsArray);
  74. mysql_close($mysqlCon);
  75. for($i=1;$i<=DEF_NUM_MODULES;$i++)
  76. {
  77. $moduleNameTemp=sprintf("LBA%02u", $i);
  78. if(array_search($moduleNameTemp,$commentsArray) !==false)
  79. $barrel->SetModuleColor($i,3,$color4);
  80. else
  81. $barrel->SetModuleColor($i,3,$color3);
  82. if(isset($statusCommentsArray[$moduleNameTemp]))
  83. $barrel->SetModuleColor($i,2,$statusColor[$statusCommentsArray[$moduleNameTemp]]);
  84. else
  85. $barrel->SetModuleColor($i,2,$statusColor[0]);
  86. if(strstr($createdModule, $moduleNameTemp))
  87. $barrel->SetModuleColor($i,1,$color1);
  88. else
  89. {
  90. if(strstr($nonCreatedModule, $moduleNameTemp))
  91. $barrel->SetModuleColor($i,1,$color2);
  92. else{
  93. $barrel->SetModuleColor($i,1,$color);
  94. $barrel->SetModuleColor($i,2,$color);
  95. $barrel->SetModuleColor($i,3,$color);
  96. }
  97. }
  98. $moduleNameTemp=sprintf("LBC%02u", $i);
  99. if(array_search($moduleNameTemp,$commentsArray) !==false)
  100. $barrel2->SetModuleColor($i,3,$color4);
  101. else
  102. $barrel2->SetModuleColor($i,3,$color3);
  103. if(isset($statusCommentsArray[$moduleNameTemp]))
  104. $barrel2->SetModuleColor($i,2,$statusColor[$statusCommentsArray[$moduleNameTemp]]);
  105. else
  106. $barrel2->SetModuleColor($i,2,$statusColor[0]);
  107. if(strstr($createdModule, $moduleNameTemp))
  108. $barrel2->SetModuleColor($i,1,$color1);
  109. else
  110. {
  111. if(strstr($nonCreatedModule, $moduleNameTemp))
  112. $barrel2->SetModuleColor($i,1,$color2);
  113. else{
  114. $barrel2->SetModuleColor($i,1,$color);
  115. $barrel2->SetModuleColor($i,2,$color);
  116. $barrel2->SetModuleColor($i,3,$color);
  117. }
  118. }
  119. }
  120. }
  121. //Commit all the chages before drawing
  122. $barrel->Commit();
  123. $barrel2->Commit();
  124. //GET TO DRAW
  125. if($_GET["draw"]=="1"){
  126. $barrel->Draw();
  127. exit;
  128. }
  129. else if($_GET["draw"]=="2"){
  130. $barrel2->Draw();
  131. exit;
  132. }
  133. function writeMap($name,&$barrel, $runNumber, $moduleString){
  134. for ($i=0;$i< DEF_NUM_MODULES; $i++){
  135. $moduleNumber="";
  136. if($i<9){$moduleNumber = "0";}
  137. $moduleNumber .= $i+1;
  138. for ($w=0;$w<$barrel->wedges;$w++){
  139. echo '<';
  140. echo 'area ';
  141. echo 'shape="poly" ';
  142. echo 'coords="';
  143. echo $barrel->coordinates[$i][$w];
  144. echo '" ';
  145. $moduleName = $name.$moduleNumber;
  146. //switch($w)
  147. //{
  148. // case 1:
  149. if(strpos($moduleString,$moduleName )!==false)
  150. echo "href=\"javascript:retrieveComment($runNumber, '$moduleName');\" ";
  151. else
  152. echo "href=\"javascript: commentBoxFunction();\" ";
  153. // break;
  154. // case 0:
  155. // echo "href=\"#\" ";
  156. // break;
  157. // default:
  158. //}
  159. echo 'onMouseOver="pop0(';
  160. echo "'<center><u>";
  161. echo $name.$moduleNumber;
  162. echo "</u></center>'";
  163. echo ')" ';
  164. echo 'onMouseOut="disparaitre0()" ';
  165. echo '/>'."\n";
  166. }
  167. }
  168. }
  169. ?>
  170. <html>
  171. <head>
  172. <link href="./css/standard.css" type="text/css" rel="stylesheet" />
  173. <style type="text/css" rel="stylesheet">
  174. #top-bar span.left {
  175. float: left;
  176. text-align: left;
  177. font-weight: bold;
  178. color: #fff;
  179. width: 49%;
  180. }
  181. span.right {
  182. float: right;
  183. text-align: right;
  184. font-weight: bold;
  185. color: #fff;
  186. width: 49%;
  187. }
  188. </style>
  189. <title>
  190. Web Interface for Commissioning Monitoring
  191. </title>
  192. <script language="JavaScript" src="wisRunSelectionScript.js"></script>
  193. <script type="text/javascript">
  194. function linkTo(URL){
  195. window.parent.location = URL;
  196. }
  197. function retrieveComment(runNumber, module)
  198. {
  199. var URL ="wisRetrieveComment.php?runNumber="+ runNumber;
  200. URL+="&module="+module;
  201. callToServer(URL);
  202. //setTimeout('matchWidth("header", "contents");matchWidth("top-bar", "header");',200);
  203. }
  204. function commentBoxFunction()
  205. {
  206. document.getElementById("commentBox").innerHTML = '';
  207. }
  208. function getDate()
  209. {
  210. var URL="wicomShowNtupleDate.php?runNumber=<?php echo $runNumber;?>&runType=<?php echo $runType;?>";
  211. // alert(URL);
  212. //window.location=URL;
  213. callToServer(URL)
  214. }
  215. function getFocus()
  216. {
  217. window.focus();
  218. }
  219. </script>
  220. </head>
  221. <body onLoad="getDate();">
  222. <CENTER>
  223. <div id="bulle" style="position: absolute;"></div>
  224. <script language="javascript">
  225. decal_x = 25;
  226. decal_y = -15;
  227. document.onmousemove = suivre_souris0;
  228. var contenu
  229. function pop0(contenu)
  230. {
  231. document.getElementById("bulle").innerHTML = "<table border='1'bordercolor='#C0C0C0'style='background-color: #fff2d2;'cellpadding='6' cellspacing='0'><tr><td><font color='#000000'face='verdana'size='1'><b>"+contenu+"</b></font></td></tr></table>";
  232. }
  233. function suivre_souris0(e)
  234. {
  235. if (navigator.appName=="Microsoft Internet Explorer")
  236. {
  237. var x = event.x + document.body.scrollLeft; var y = event.y + document.body.scrollTop;
  238. }
  239. else
  240. {
  241. var x = e.pageX;var y = e.pageY;
  242. }
  243. document.getElementById("bulle").style.left = x + decal_x; document.getElementById("bulle").style.top = y + decal_y;
  244. }
  245. function disparaitre0()
  246. {
  247. document.getElementById("bulle").innerHTML = '';
  248. }
  249. </script>
  250. <?php
  251. $numberOfSmallNtuples =0;
  252. $numberOfModules=0;
  253. $moduleTemp = strtok($moduleString, " ");
  254. while($moduleTemp!=false)
  255. {
  256. //Looking for root file in Castor directory
  257. $numberOfModules++;
  258. $modulePrefix = substr($moduleTemp, 0 , 3);
  259. $moduleNumber = substr($moduleTemp, 3 , 2);
  260. $command = "./wicomExistSmallNtuple ntuple $moduleTemp $runNumber $runType > /dev/null";
  261. passthru($command, $existSmallNtuple);
  262. if( $existSmallNtuple==2)
  263. {
  264. $numberOfSmallNtuples++;
  265. $createdModules.= $moduleTemp." ";
  266. }
  267. else
  268. {
  269. $nonCreatedModules.= $moduleTemp." ";
  270. }
  271. $moduleTemp = strtok(" ");
  272. }
  273. echo "<h2>Run Number : $runNumber</h2><p> ";
  274. if($numberOfModules!=0)
  275. {
  276. $percent= round(100*($numberOfSmallNtuples/$numberOfModules));
  277. echo $percent."% of the $numberOfModules ntuples are in the CASTOR</p>";
  278. }
  279. ?>
  280. <img usemap="#map1" src="wisNtuplesPerModule.php?name=LBA&draw=1" border="0">
  281. <BR>
  282. <A href='http://atlas-php.web.cern.ch/atlas-php/NOVA/TBAnalysis/TileCommAnalysis/version1.3/searchResult.php?runNumber=<?echo $runNumber;?>' target="_blank">See Plots or Edit Comments</A>
  283. </CENTER>
  284. <div style='position:absolute;bottom:0px;right:0px;width:300px;' id='commentBox' name='commentBox'>
  285. </div>
  286. <div id='dateBox' name='dateBox' style='position:absolute;top:0px;right:0px;'>
  287. Checking Dates...
  288. </div>
  289. <div id='legenda' name='legenda' style='position:absolute;bottom:0px;left:0px;width:400px;'>
  290. <font size="1" face="arial">
  291. <table class='main' width="400" height="100"border="1" CELLSPACING=0 CELLPADDING=0>
  292. <tr>
  293. <th bgcolor="#EEEEEE" colspan="100%">&nbsp;</td> Colour Code</tr>
  294. <tr>
  295. <th bgcolor="#EEEEEE"><font size="1" face="arial">INNER EDGE</font></td>
  296. <td><font size="1" face="arial">CASTOR</font></td>
  297. <td bgcolor="#006600" width="15">&nbsp;</td>
  298. <td ><font size="1" face="arial">Not in Castor</font></td>
  299. <td width="18" bgcolor="#990000" width="15">&nbsp;</td>
  300. <td colspan="4">&nbsp;</td>
  301. <td rowspan="3"><font size="1" face="arial">Not tested</font></td>
  302. <td rowspan="3" bgcolor="#FFFFCC" width="15">&nbsp;</td>
  303. </tr>
  304. <tr>
  305. <th bgcolor="#EEEEEE"><font size="1" face="arial">MIDDLE EDGE</font></td>
  306. <td><font size="1" face="arial">OK</font></td>
  307. <td bgcolor="#00FF00" width="15">&nbsp;</td>
  308. <td ><font size="1" face="arial">Bad</font></td>
  309. <td width="18" bgcolor="red" width="15">&nbsp;</td>
  310. <td><font size="1" face="arial">Some Problems</font></td>
  311. <td bgcolor="#FF8000" width="15">&nbsp;</td>
  312. <td><font size="1" face="arial">Not to be analysed</font></td>
  313. <td bgcolor="black" width="15">&nbsp;</td>
  314. <!--<td><font size="1" face="arial">Empty</font></td>
  315. <td bgcolor="#FFFFCC" width="15">&nbsp;</td>-->
  316. </tr>
  317. <tr>
  318. <th bgcolor="#EEEEEE"><font size="1" face="arial">OUTER EDGE</font></td>
  319. <td ><font size="1" face="arial">No Detailed Comment</font></td>
  320. <td bgcolor="#CCCCCC" width="15">&nbsp;</td>
  321. <td ><font size="1" face="arial">Commented</font></td>
  322. <td bgcolor="blue" width="15">&nbsp;</td>
  323. <td colspan="4">&nbsp;</td>
  324. </tr>
  325. </table>
  326. </font>
  327. </div>
  328. <map name="map1">
  329. <?
  330. writeMap("LBA",$barrel, $runNumber, $moduleString);
  331. ?>
  332. </map>
  333. <map name="map2">
  334. <?
  335. writeMap("LBC",$barrel2, $runNumber, $moduleString);
  336. ?>
  337. </map>
  338. </body>
  339. </html>