Web UI for ARGUS server
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

219 lines
7.9 KiB

6 years ago
​
​
5 years ago
​
​
​
​
​
5 years ago
5 years ago
​
​
​
​
5 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 years ago
​
​
5 years ago
5 years ago
5 years ago
​
6 years ago
5 years ago
6 years ago
​
  1. <?php
  2. require_once('../ajax_asm.php');
  3. if( $CUser->Data['id'] > 1 ){
  4. header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
  5. header("Cache-Control: post-check=0, pre-check=0", false);
  6. header("Pragma: no-cache");
  7. header("Content-Type: image/png");
  8. if(isset( $_POST['NID'] )){
  9. $NID = intval($_POST['NID']);
  10. } else {
  11. $NID = intval($_GET['NID']);
  12. };
  13. if(isset( $_POST['AUX'] )){
  14. $AUX = intval($_POST['AUX']);
  15. } elseif( isset($_GET['AUX']) ) {
  16. $AUX = intval($_GET['AUX']);
  17. } else $AUX = 0;
  18. $QS = "SELECT * FROM lrf_draw WHERE node_id={$NID} ORDER BY ts DESC LIMIT 1";
  19. $Result = $DATABASE->Query( $QS, false );
  20. if( count( $Result ) ){
  21. if( $Result[0]['rendered'] == 'Y' ){
  22. if( $AUX ){
  23. $FN = "data/device_draws/{$Result[0]['md5']}_{$AUX}.png";
  24. } else {
  25. $FN = "data/device_draws/{$Result[0]['md5']}_100.png";
  26. };
  27. } else {
  28. $FF = "data/device_draws/{$Result[0]['md5']}.raw";
  29. $FN = "ddd";
  30. if( file_exists( $FF ) ) {
  31. $FD = fopen( $FF, "rb" );
  32. if( $FD ){
  33. $CL = fread( $FD, 4 );
  34. $size = unpack( "V", $CL );
  35. $pts = array();
  36. $as = $size[1];
  37. for($i=0; $i< $as; $i++ ){
  38. $CL = fread( $FD, 4 );
  39. $T = unpack( "V", $CL );
  40. //print_r( $T );
  41. $pts[] = $T[1] >> 16;
  42. };
  43. fclose( $FD );
  44. $QS = "SELECT ls.base_shift, ls.max_range FROM nodes ns LEFT JOIN lrf_sensors ls ON ( ls.id=ns.aux_id ) WHERE ns.id={$NID}";
  45. $PP = $DATABASE->Query( $QS );
  46. $stp = 2.0 * ( M_PI / $as );
  47. $MR = intval( $PP[0]['max_range'] );
  48. $S = ( M_PI / 3000.0 ) * intval( $PP[0]['base_shift'] );
  49. $IM = imagecreatefrompng("../../style/assets/lfs_draw_empty_100.png");
  50. imagesavealpha( $IM, true );
  51. $bg = imagecolorallocate($IM, 0, 0, 0);
  52. $black = imagecolorallocate($IM, 255, 255, 0);
  53. //$green = imagecolorallocate($IM, 0, 255, 0);
  54. $green = imagecolorallocatealpha( $IM, 0, 64, 0, 64 );
  55. imagefilledrectangle( $IM, 5, 5, 36, 18, $bg );
  56. imagestring( $IM, 2, 6, 5, $MR . "m.", $black );
  57. $maxR = 98.0;
  58. $rst = $maxR / 1025.0;
  59. $x0 = 100;
  60. $y0 = 100;
  61. $ppA = array();
  62. $ppB = array();
  63. for( $i=0; $i< $as; $i++ ){
  64. if( $pts[$i] > 0 ){
  65. $cr = ($rst * $pts[$i]);
  66. $ca = 0.0 - ( $S + $i * $stp );
  67. $ppA[] = $x0 + $cr * cos( $ca );
  68. $ppA[] = $y0 + $cr * sin( $ca );
  69. $ppB[] = $x0 + $maxR * cos( $ca );
  70. $ppB[] = $y0 + $maxR * sin( $ca );
  71. } else {
  72. $ca = 0.0 - ( $S + $i * $stp );
  73. $ppA[] = $x0 + $maxR * cos( $ca );
  74. $ppA[] = $y0 + $maxR * sin( $ca );
  75. $ppB[] = $x0 + $maxR * cos( $ca );
  76. $ppB[] = $y0 + $maxR * sin( $ca );
  77. };
  78. };
  79. $ppB[] = $ppA[count($ppA)-2];
  80. $ppB[] = $ppA[count($ppA)-1];
  81. $popo = array_merge( $ppA, $ppB );
  82. imagefilledpolygon( $IM, $popo, count( $popo ) / 2, $green );
  83. imagepng( $IM, "data/device_draws/{$Result[0]['md5']}_100.png" );
  84. imagedestroy( $IM );
  85. $IM = imagecreatefrompng("../../style/assets/lfs_draw_empty_50.png");
  86. imagesavealpha( $IM, true );
  87. $bg = imagecolorallocate($IM, 0, 0, 0);
  88. $black = imagecolorallocate($IM, 255, 255, 0);
  89. //$green = imagecolorallocate($IM, 0, 255, 0);
  90. $green = imagecolorallocatealpha( $IM, 0, 64, 0, 64 );
  91. imagefilledrectangle( $IM, 5, 5, 36, 18, $bg );
  92. imagestring( $IM, 2, 6, 5, ( $MR / 2 ) . "m.", $black );
  93. $rst = $maxR / 513.0;
  94. $ppA = array();
  95. $ppB = array();
  96. for( $i=0; $i< $as; $i++ ){
  97. if( $pts[$i] > 0 && $pts[$i] < 513 ){
  98. $cr = ($rst * $pts[$i]);
  99. $ca = 0.0 - ( $S + $i * $stp );
  100. $ppA[] = $x0 + $cr * cos( $ca );
  101. $ppA[] = $y0 + $cr * sin( $ca );
  102. $ppB[] = $x0 + $maxR * cos( $ca );
  103. $ppB[] = $y0 + $maxR * sin( $ca );
  104. } else {
  105. $ca = 0.0 - ( $S + $i * $stp );
  106. $ppA[] = $x0 + $maxR * cos( $ca );
  107. $ppA[] = $y0 + $maxR * sin( $ca );
  108. $ppB[] = $x0 + $maxR * cos( $ca );
  109. $ppB[] = $y0 + $maxR * sin( $ca );
  110. };
  111. };
  112. $ppB[] = $ppA[count($ppA)-2];
  113. $ppB[] = $ppA[count($ppA)-1];
  114. $popo = array_merge( $ppA, $ppB );
  115. imagefilledpolygon( $IM, $popo, count( $popo ) / 2, $green );
  116. imagepng( $IM, "data/device_draws/{$Result[0]['md5']}_50.png" );
  117. imagedestroy( $IM );
  118. $IM = imagecreatefrompng("../../style/assets/lfs_draw_empty_25.png");
  119. imagesavealpha( $IM, true );
  120. $bg = imagecolorallocate($IM, 0, 0, 0);
  121. $black = imagecolorallocate($IM, 255, 255, 0);
  122. //$green = imagecolorallocate($IM, 0, 255, 0);
  123. $green = imagecolorallocatealpha( $IM, 0, 64, 0, 64 );
  124. imagefilledrectangle( $IM, 5, 5, 36, 18, $bg );
  125. imagestring( $IM, 2, 6, 5, ( $MR / 4 ) . "m.", $black );
  126. $rst = $maxR / 257.0;
  127. $ppA = array();
  128. $ppB = array();
  129. for( $i=0; $i< $as; $i++ ){
  130. if( $pts[$i] > 0 && $pts[$i] < 256 ){
  131. $cr = ($rst * $pts[$i]);
  132. $ca = 0.0 - ( $S + $i * $stp );
  133. $ppA[] = $x0 + $cr * cos( $ca );
  134. $ppA[] = $y0 + $cr * sin( $ca );
  135. $ppB[] = $x0 + $maxR * cos( $ca );
  136. $ppB[] = $y0 + $maxR * sin( $ca );
  137. } else {
  138. $ca = 0.0 - ( $S + $i * $stp );
  139. $ppA[] = $x0 + $maxR * cos( $ca );
  140. $ppA[] = $y0 + $maxR * sin( $ca );
  141. $ppB[] = $x0 + $maxR * cos( $ca );
  142. $ppB[] = $y0 + $maxR * sin( $ca );
  143. };
  144. };
  145. $ppB[] = $ppA[count($ppA)-2];
  146. $ppB[] = $ppA[count($ppA)-1];
  147. $popo = array_merge( $ppA, $ppB );
  148. imagefilledpolygon( $IM, $popo, count( $popo ) / 2, $green );
  149. imagepng( $IM, "data/device_draws/{$Result[0]['md5']}_25.png" );
  150. imagedestroy( $IM );
  151. $IM = imagecreatefrompng("../../style/assets/lfs_draw_empty_12.png");
  152. imagesavealpha( $IM, true );
  153. $bg = imagecolorallocate($IM, 0, 0, 0);
  154. $black = imagecolorallocate($IM, 255, 255, 0);
  155. //$green = imagecolorallocate($IM, 0, 255, 0);
  156. $green = imagecolorallocatealpha( $IM, 0, 64, 0, 64 );
  157. imagefilledrectangle( $IM, 5, 5, 36, 18, $bg );
  158. imagestring( $IM, 2, 6, 5, ( $MR / 8 ) . "m.", $black );
  159. $rst = $maxR / 129.0;
  160. $ppA = array();
  161. $ppB = array();
  162. for( $i=0; $i< $as; $i++ ){
  163. if( $pts[$i] > 0 && $pts[$i] < 128 ){
  164. $cr = ($rst * $pts[$i]);
  165. $ca = 0.0 - ( $S + $i * $stp );
  166. $ppA[] = $x0 + $cr * cos( $ca );
  167. $ppA[] = $y0 + $cr * sin( $ca );
  168. $ppB[] = $x0 + $maxR * cos( $ca );
  169. $ppB[] = $y0 + $maxR * sin( $ca );
  170. } else {
  171. $ca = 0.0 - ( $S + $i * $stp );
  172. $ppA[] = $x0 + $maxR * cos( $ca );
  173. $ppA[] = $y0 + $maxR * sin( $ca );
  174. $ppB[] = $x0 + $maxR * cos( $ca );
  175. $ppB[] = $y0 + $maxR * sin( $ca );
  176. };
  177. };
  178. $ppB[] = $ppA[count($ppA)-2];
  179. $ppB[] = $ppA[count($ppA)-1];
  180. $popo = array_merge( $ppA, $ppB );
  181. imagefilledpolygon( $IM, $popo, count( $popo ) / 2, $green );
  182. imagepng( $IM, "data/device_draws/{$Result[0]['md5']}_12.png" );
  183. imagedestroy( $IM );
  184. $QS = "UPDATE lrf_draw SET rendered='Y' WHERE id={$Result[0]['id']}";
  185. $DATABASE->Query( $QS );
  186. if( $AUX ){
  187. $FN = "data/device_draws/{$Result[0]['md5']}_{$AUX}.png";
  188. } else {
  189. $FN = "data/device_draws/{$Result[0]['md5']}_100.png";
  190. };
  191. };
  192. } else {
  193. echo "No Res"; exit();
  194. if( $AUX ){
  195. $FN = "../../style/assets/lfs_draw_empty_{$AUX}.png";
  196. } else {
  197. $FN = "../../style/assets/lfs_draw_empty_100.png";
  198. };
  199. };
  200. };
  201. if( !file_exists( $FN ) ) $FN = "../../style/assets/lfs_draw_empty_100.png";
  202. readfile( $FN );
  203. } else {
  204. if( $AUX ){
  205. $FN = "../../style/assets/lfs_draw_empty_{$AUX}.png";
  206. } else {
  207. $FN = "../../style/assets/lfs_draw_empty_100.png";
  208. };
  209. if( !file_exists( $FN ) ) $FN = "../../style/assets/lfs_draw_empty_100.png";
  210. readfile( $FN );
  211. };
  212. } else {
  213. header('location: /');
  214. };
  215. ?>