plotTempProfileStandalone.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. require_once('/var/www/stsstatus/phplot.php');
  3. // ADEI channels of sensors
  4. $adeiChannel = array(
  5. // temperature sensors on top of beamtube
  6. array(//0
  7. "cswgts__ControlSystem_WGTS_Strahlrohr__200_STR_WGTS__75", // RTP-3-5102, starting at front side
  8. "cswgts__ControlSystem_WGTS_Strahlrohr__200_STR_WGTS__87", // RTP-3-5106
  9. "cswgts__ControlSystem_WGTS_Strahlrohr__200_STR_WGTS__93", // RTP-3-5108
  10. "cswgts__ControlSystem_WGTS_Strahlrohr__200_STR_WGTS__99", // RTP-3-5110
  11. "cswgts__ControlSystem_WGTS_Strahlrohr__200_STR_WGTS__105", // RTP-3-5112
  12. "cswgts__ControlSystem_WGTS_Strahlrohr__200_STR_WGTS__111", // RTP-3-5114
  13. "cswgts__ControlSystem_WGTS_Strahlrohr__200_STR_WGTS__117", // RTP-3-5116
  14. "cswgts__ControlSystem_WGTS_Strahlrohr__200_STR_WGTS__123", // RTP-3-5118
  15. "cswgts__ControlSystem_WGTS_Strahlrohr__200_STR_WGTS__129", // RTP-3-5120
  16. "cswgts__ControlSystem_WGTS_Strahlrohr__200_STR_WGTS__141" // RTP-3-5124
  17. ),
  18. // temperature sensors on bottom of beamtube
  19. array(//1
  20. "cswgts__ControlSystem_WGTS_Strahlrohr__200_STR_WGTS__72", // RTP-3-5101, starting at front side
  21. "cswgts__ControlSystem_WGTS_Strahlrohr__200_STR_WGTS__84", // RTP-3-5105
  22. "cswgts__ControlSystem_WGTS_Strahlrohr__200_STR_WGTS__90", // RTP-3-5107
  23. "cswgts__ControlSystem_WGTS_Strahlrohr__200_STR_WGTS__96", // RTP-3-5109
  24. "cswgts__ControlSystem_WGTS_Strahlrohr__200_STR_WGTS__102", // RTP-3-5111
  25. "cswgts__ControlSystem_WGTS_Strahlrohr__200_STR_WGTS__108", // RTP-3-5113
  26. "cswgts__ControlSystem_WGTS_Strahlrohr__200_STR_WGTS__114", // RTP-3-5115
  27. "cswgts__ControlSystem_WGTS_Strahlrohr__200_STR_WGTS__120", // RTP-3-5117
  28. "cswgts__ControlSystem_WGTS_Strahlrohr__200_STR_WGTS__126", // RTP-3-5119
  29. "cswgts__ControlSystem_WGTS_Strahlrohr__200_STR_WGTS__138" // RTP-3-5123
  30. )
  31. );
  32. $username = 'katrin';
  33. $password = 'neutrino';
  34. $context = stream_context_create(array(
  35. 'http' => array(
  36. 'header' => "Authorization: Basic " . base64_encode("$username:$password"), "Connection: close\r\n"
  37. )
  38. ));
  39. for ($id = 0; $id < sizeof($adeiChannel); $id++)
  40. {
  41. $adeiChannels = "";
  42. for ($id2 = 0; $id2 < sizeof($adeiChannel[$id]); $id2++)
  43. {
  44. $adeiChannels = $adeiChannels . $adeiChannel[$id][$id2] . ",";
  45. }
  46. $adeiChannels = substr($adeiChannels, 0, strlen($adeiChannels) - 1);
  47. $fileip = file_get_contents("https://adei-katrin.kaas.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);
  48. //$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);
  49. //echo $fileip . "<br>";
  50. for ($id2 = sizeof($adeiChannel[$id]) - 1 ; $id2 > -1; $id2--)
  51. {
  52. $pos = strrpos($fileip, ",");
  53. $adeiValue[$id][$id2] = floatval(substr($fileip, $pos + 2)); // values of sensors
  54. $fileip = substr($fileip, 0, $pos);
  55. //echo $id . "," . $id2 . "," . $adeiValue[$id][$id2] . "<br>";
  56. }
  57. }
  58. // positions of sensors
  59. // z-positions of top/bottom sensors
  60. $position = file('data/SensorPositionsTopBottom.txt');
  61. $data = array();
  62. for ($ii=0; $ii<sizeof($position); $ii++) {
  63. $tempTop = $adeiValue[0][$ii]; $tempBottom = $adeiValue[1][$ii];
  64. $tempError = 1.5;
  65. if ($ii==1 || $ii==5) $tempTop="";
  66. if ($ii==3 || $ii==5) $tempBottom="";
  67. $data[] = array( '', $position[$ii]/1000, $tempTop, $tempError, $tempError, $tempBottom, $tempError, $tempError );
  68. //echo $data[$ii][1];
  69. }
  70. $plot = new PHPlot(1500, 250);
  71. $plot->SetImageBorderType('plain');
  72. $plot->SetFont('title', 5); $plot->SetFont('x_title', 4); $plot->SetFont('y_title', 4);
  73. $plot->SetFont('x_label', 2); $plot->SetFont('y_label', 2);
  74. $plot->SetDataType('data-data-error');
  75. $plot->SetDataValues($data);
  76. # Main plot title:
  77. $plot->SetTitle('source temperature profile');
  78. $plot->SetPlotType('linepoints');
  79. $plot->SetLineStyles(array('solid', 'dashed') );
  80. $plot->SetLineWidths( 2.5 );
  81. $colors = array('red', 'blue');
  82. $plot->SetDataColors( $colors );
  83. $plot->SetErrorBarColors( $colors );
  84. $plot->SetPointShapes( array('delta', 'dot') );
  85. $plot->SetXLabel( 'longitudinal position (m)' );
  86. $plot->SetYLabel( 'temperature (K)' );
  87. $plot->SetLegend( array('top', 'bottom') );
  88. $plot->SetLegendUseShapes(true);
  89. $plot->SetLegendPosition(1, 0, 'plot', 1, 0, 12, -23);
  90. # Make sure Y axis starts at 0:
  91. //$plot->SetPlotAreaWorld(NULL, 0, NULL, NULL);
  92. $plot->DrawGraph();
  93. ?>