index.php.backup 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. <html>
  2. <head>
  3. <title>STS Status Overview</title>
  4. <style type="text/css">
  5. body { font-family:Calibri,Arial; }
  6. a:link { text-decoration:none; }
  7. a:visited { text-decoration:none; }
  8. a:hover { text-decoration:none; }
  9. a:active { text-decoration:none; }
  10. a:focus { text-decoration:none; }
  11. </style>
  12. <meta http-equiv="refresh" content="60">
  13. </head>
  14. <body>
  15. <?php
  16. function placePic($posY, $posX, $pic, $size, $title)
  17. {
  18. echo '<div title="' . $title . '" style="position:absolute; top:' . $posY . 'px; left:' . $posX . 'px">';
  19. echo '<img src="pictures/' . $pic . '" width="' . $size . '" height="' . $size . '">';
  20. echo '</div>';
  21. }
  22. function placePicWithLink($posY, $posX, $pic, $size, $title, $link)
  23. {
  24. echo '<a href="https://katrin.kit.edu/adei-katrin/#module=graph&db_server=virtual&db_name=srctree&db_group=-3&control_group=-3&db_mask=all&experiment=-&window=86400&module=graph&virtual=srctree&srctree=' . $link . '" target="_blank">';
  25. placePic($posY, $posX, $pic, $size, $title);
  26. echo '</a>';
  27. }
  28. function placeText($posY, $posX, $text, $width, $size, $color)
  29. {
  30. echo '<div align="center" style="width:' . $width . 'px; position:absolute; top:' . $posY . 'px; left:' . $posX . 'px">';
  31. echo '<font size="' . $size . '" color="' . $color . '"><b>';
  32. echo $text;
  33. echo '</b></font></div>';
  34. }
  35. function placeTextWithLink($posY, $posX, $text, $width, $size, $color, $title, $link)
  36. {
  37. echo '<div title="' . $title . '" align="center" style="width:' . $width . 'px; position:absolute; top:' . $posY . 'px; left:' . $posX . 'px">';
  38. echo '<a href="https://katrin.kit.edu/adei-katrin/#module=graph&db_server=virtual&db_name=srctree&db_group=-3&control_group=-3&db_mask=all&experiment=-&window=86400&module=graph&virtual=srctree&srctree=' . $link . '" target="_blank">';
  39. echo '<font size="' . $size . '" color="' . $color . '"><b>';
  40. echo $text;
  41. echo '</b></font></a></div>';
  42. }
  43. function placeBox($posY, $posX, $text, $width, $size, $color)
  44. {
  45. echo '<div align="center" style="background-color:' . $color . '; border-style:solid; border-width:2px; border-color:#000000; width:' . $width . 'px; position:absolute; top:' . $posY . 'px; left:' . $posX . 'px">';
  46. echo '<font size="' . $size . '" color=#000000><b>';
  47. echo $text;
  48. echo '</b></font></div>';
  49. }
  50. function getValveStatus($value)
  51. {
  52. $value = decbin($value);
  53. $value = substr("00000000000", 0, 11 - strlen($value)) . $value;
  54. if (substr($value, 3, 1) == 1) return 1;
  55. else if (substr($value, 2, 1) == 1) return 0;
  56. else return -1;
  57. }
  58. ?>
  59. <?php
  60. // ########## SLOW CONTROL CHANNELS ##########
  61. $adeiChannel = array(
  62. array(
  63. "cscryo__ControlSystem_Cryo__310DPS_Magnetsteuerung__15",
  64. "cscryo__ControlSystem_Cryo__310DPS_Magnetsteuerung__18",
  65. "cscryo__ControlSystem_Cryo__310DPS_Magnetsteuerung__21",
  66. "cscryo__ControlSystem_Cryo__310DPS_Magnetsteuerung__24",
  67. "cscryo__ControlSystem_Cryo__310DPS_Magnetsteuerung__27",
  68. "cscryo__ControlSystem_Cryo__310DPS_Magnetsteuerung__30",
  69. "cscryo__ControlSystem_Cryo__310DPS_Magnetsteuerung__33",
  70. "cscryo__ControlSystem_Cryo__310DPS_Magnetsteuerung__36",
  71. "cscryo__ControlSystem_Cryo__310DPS_Magnetsteuerung__39",
  72. "cscryo__ControlSystem_Cryo__310DPS_Magnetsteuerung__42"
  73. )
  74. );
  75. $username = 'katrin';
  76. $password = 'neutrino';
  77. $context = stream_context_create(array(
  78. 'http' => array(
  79. 'header' => "Authorization: Basic " . base64_encode("$username:$password"), "Connection: close\r\n"
  80. )
  81. ));
  82. for ($id = 0; $id < sizeof($adeiChannel); $id++)
  83. {
  84. $adeiChannels = "";
  85. for ($id2 = 0; $id2 < sizeof($adeiChannel[$id]); $id2++)
  86. {
  87. $adeiChannels = $adeiChannels . $adeiChannel[$id][$id2] . ",";
  88. }
  89. $adeiChannels = substr($adeiChannels, 0, strlen($adeiChannels) - 1);
  90. //$fileip = file_get_contents("http://katrin.kit.edu/adei/services/getdata.php?db_server=virtual&db_name=srctree&db_group=-3&control_group=-3&virtual=srctree&srctree=" . $adeiChannels . "&window=60&format=csv", false, $context);
  91. $fileip = file_get_contents("http://ipekatrinbackupserv1.ipe.kit.edu/adei/services/getdata.php?db_server=virtual&db_name=srctree&db_group=-3&control_group=-3&virtual=srctree&srctree=" . $adeiChannels . "&window=60&format=csv", false, $context);
  92. //echo $fileip . "<br>";
  93. for ($id2 = sizeof($adeiChannel[$id]) - 1 ; $id2 > -1; $id2--)
  94. {
  95. $pos = strrpos($fileip, ",");
  96. $adeiValue[$id][$id2] = floatval(substr($fileip, $pos + 2));
  97. $fileip = substr($fileip, 0, $pos);
  98. //echo $id . "," . $id2 . "," . $adeiValue[$id][$id2] . "<br>";
  99. }
  100. }
  101. ?>
  102. <?php
  103. // ########## TITLE and DATE ##########
  104. echo '<font size="6" color="#000000"><b>STS Status Overview</b></font><br>';
  105. echo '<font size="4" color="#000000">' . date(DATE_RFC822) . '</font><br>';
  106. ?>
  107. <!-- beamline picture (center) -->
  108. <div style="position:absolute; top:300px; left:0px">
  109. <img src="pictures/Beamline_STS_side_1410.png">
  110. <!-- KATRIN logo (upper left) -->
  111. <a href="http://katrin.kit.edu" target="_blank">
  112. <div style="position:absolute; top:-285px; left:300px">
  113. <img src="pictures/katrin_logo.jpg" width="100" height="100">
  114. </div>
  115. <!-- email link (upper left)-->
  116. <a href="mailto:Florian.Heizmann@kit.edu">
  117. <div title="send email to Florian Heizmann" style="position:absolute; top:-220px; left:8px">
  118. <img src="pictures/newEmail.png" width="23" height="23">
  119. </div>
  120. </a>
  121. <?php
  122. $color = "#000000";
  123. // ########## Rearsection ##########
  124. placeText(-100, 100, "Rear Section", 70, 30, $color);
  125. placeText(100, 240, "RSCM", 30, 5, $color);
  126. // ########## WGTS ##########
  127. placeText(-100, 670, "WGTS", 70, 30, $color);
  128. placeText(100, 340, "M5", 30, 5, $color);
  129. placeText(100, 410, "M4", 30, 5, $color);
  130. placeText(100, 550, "M1", 30, 5, $color);
  131. placeText(50, 730, "M2", 30, 5, $color);
  132. placeText(100, 900, "M3", 30, 5, $color);
  133. placeText(100, 1040, "M7", 30, 5, $color);
  134. placeText(100, 1115, "M6", 30, 5, $color);
  135. // ########## DPS ##########
  136. placeText(-100, 1330, "DPS", 70, 30, $color);
  137. $thres = 0.4; // magnet B in T
  138. $tol = 180; // hall sensor B in mT 55
  139. $cali = array( 800, -800, 800, -800, 800, -800, 808, -769, 736, -778 );
  140. for ($pp = 1; $pp < 6; $pp++)
  141. {
  142. $pic = "coilA";
  143. if ($pp == 2) $pic = "coilB";
  144. else if ($pp == 4) $pic = "coilC";
  145. if ($pp == 1 || $pp == 5) $posY = 230+3;
  146. else if ($pp == 2 || $pp == 4) $posY = 224+3;
  147. else if ($pp == 3) $posY = 220+3;
  148. $posX = 1220 + 70*($pp-1);
  149. $link = $adeiChannel[0][0 + 2*($pp-1)] . "," . $adeiChannel[0][1 + 2*($pp-1)];
  150. $value = ( (5.5 * $adeiValue[0][2*($pp-1)] / $cali[2*($pp-1)]) + (5.5 * $adeiValue[0][1 + 2*($pp-1)] / $cali[1 + 2*($pp-1)]) ) / 2.0 ;
  151. if ($value > $thres && $adeiValue[0][2*($pp-1)] + $adeiValue[0][1 + 2*($pp-1)] < $tol && $adeiValue[0][2*($pp-1)] + $adeiValue[0][1 + 2*($pp-1)] > -$tol)
  152. {
  153. $posOffset = 0;
  154. if ($pp == 2) $posOffset = 1;
  155. else if ($pp == 4) $posOffset = -1;
  156. $text = "magnetic field [T] DPS magnet " . $pp;
  157. placeTextWithLink($posY + 13, $posX - 5 + $posOffset, sprintf('%.1F', $value), 30, 2, "#FF0000", $text, $link);
  158. $pic = $pic . "On";
  159. $color = "#FF0000";
  160. }
  161. $text = "status DPS magnet " . $pp . "&#10;red: ramped, white: off";
  162. placePicWithLink($posY, $posX, $pic . ".png", 20, $text, $link);
  163. placeText(100, $posX, "M" . $pp, 20, 5, $color);
  164. }
  165. // ########## CPS ##########
  166. placeText(-100, 1650, "CPS", 70, 30, $color);
  167. for ($index = 1; $index < 8; $index++)
  168. {
  169. placeText(0, 1570+50*($index-1), "M" . $index, 30, 5, $color);
  170. }
  171. ?>
  172. </div>
  173. </body>
  174. </html>