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.

327 lines
11 KiB

6 years ago
​
​
​
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
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 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
​
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. $SAVE_AS_PICTURE = false;
  4. if( $CUser->Data['id'] > 1 ){
  5. header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
  6. header("Cache-Control: post-check=0, pre-check=0", false);
  7. header("Pragma: no-cache");
  8. header("Content-Type: image/png");
  9. if(isset( $_POST['NID'] )){
  10. $NID = intval($_POST['NID']);
  11. } else {
  12. $NID = intval($_GET['NID']);
  13. };
  14. if(isset( $_POST['AUX'] )){
  15. $AUX = intval($_POST['AUX']);
  16. } elseif( isset($_GET['AUX']) ) {
  17. $AUX = intval($_GET['AUX']);
  18. } else $AUX = 0;
  19. $QS = "SELECT * FROM lrf_draw WHERE node_id={$NID} ORDER BY ts DESC LIMIT 1";
  20. $Result = $DATABASE->Query( $QS, false );
  21. if( count( $Result ) ){
  22. if( $SAVE_AS_PICTURE ){
  23. if( $Result[0]['rendered'] == 'Y' ){
  24. if( $AUX ){
  25. $FN = "data/device_draws/{$Result[0]['md5']}_{$AUX}.png";
  26. } else {
  27. $FN = "data/device_draws/{$Result[0]['md5']}_100.png";
  28. };
  29. } else {
  30. $FF = "data/device_draws/{$Result[0]['md5']}.raw";
  31. $FN = "ddd";
  32. if( file_exists( $FF ) ) {
  33. $FD = fopen( $FF, "rb" );
  34. if( $FD ){
  35. $CL = fread( $FD, 4 );
  36. $size = unpack( "V", $CL );
  37. $pts = array();
  38. $as = $size[1];
  39. for($i=0; $i< $as; $i++ ){
  40. $CL = fread( $FD, 4 );
  41. $T = unpack( "V", $CL );
  42. //print_r( $T );
  43. $pts[] = $T[1] >> 16;
  44. };
  45. fclose( $FD );
  46. $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}";
  47. $PP = $DATABASE->Query( $QS );
  48. $stp = 2.0 * ( M_PI / $as );
  49. $MR = intval( $PP[0]['max_range'] );
  50. $S = ( M_PI / 3000.0 ) * intval( $PP[0]['base_shift'] );
  51. $IM = imagecreatefrompng("../../style/assets/lfs_draw_empty_100.png");
  52. imagesavealpha( $IM, true );
  53. $bg = imagecolorallocate($IM, 0, 0, 0);
  54. $black = imagecolorallocate($IM, 255, 255, 0);
  55. //$green = imagecolorallocate($IM, 0, 255, 0);
  56. $green = imagecolorallocatealpha( $IM, 0, 64, 0, 64 );
  57. imagefilledrectangle( $IM, 5, 5, 36, 18, $bg );
  58. imagestring( $IM, 2, 6, 5, $MR . "m.", $black );
  59. $maxR = 98.0;
  60. $rst = $maxR / 1025.0;
  61. $x0 = 100;
  62. $y0 = 100;
  63. $ppA = array();
  64. $ppB = array();
  65. for( $i=0; $i< $as; $i++ ){
  66. if( $pts[$i] > 0 ){
  67. $cr = ($rst * $pts[$i]);
  68. $ca = 0.0 - ( $S + $i * $stp );
  69. $ppA[] = $x0 + $cr * cos( $ca );
  70. $ppA[] = $y0 + $cr * sin( $ca );
  71. $ppB[] = $x0 + $maxR * cos( $ca );
  72. $ppB[] = $y0 + $maxR * sin( $ca );
  73. } else {
  74. $ca = 0.0 - ( $S + $i * $stp );
  75. $ppA[] = $x0 + $maxR * cos( $ca );
  76. $ppA[] = $y0 + $maxR * sin( $ca );
  77. $ppB[] = $x0 + $maxR * cos( $ca );
  78. $ppB[] = $y0 + $maxR * sin( $ca );
  79. };
  80. };
  81. $ppB[] = $ppA[count($ppA)-2];
  82. $ppB[] = $ppA[count($ppA)-1];
  83. $popo = array_merge( $ppA, $ppB );
  84. imagefilledpolygon( $IM, $popo, count( $popo ) / 2, $green );
  85. imagepng( $IM, "data/device_draws/{$Result[0]['md5']}_100.png" );
  86. imagedestroy( $IM );
  87. $IM = imagecreatefrompng("../../style/assets/lfs_draw_empty_50.png");
  88. imagesavealpha( $IM, true );
  89. $bg = imagecolorallocate($IM, 0, 0, 0);
  90. $black = imagecolorallocate($IM, 255, 255, 0);
  91. //$green = imagecolorallocate($IM, 0, 255, 0);
  92. $green = imagecolorallocatealpha( $IM, 0, 64, 0, 64 );
  93. imagefilledrectangle( $IM, 5, 5, 36, 18, $bg );
  94. imagestring( $IM, 2, 6, 5, ( $MR / 2 ) . "m.", $black );
  95. $rst = $maxR / 513.0;
  96. $ppA = array();
  97. $ppB = array();
  98. for( $i=0; $i< $as; $i++ ){
  99. if( $pts[$i] > 0 && $pts[$i] < 513 ){
  100. $cr = ($rst * $pts[$i]);
  101. $ca = 0.0 - ( $S + $i * $stp );
  102. $ppA[] = $x0 + $cr * cos( $ca );
  103. $ppA[] = $y0 + $cr * sin( $ca );
  104. $ppB[] = $x0 + $maxR * cos( $ca );
  105. $ppB[] = $y0 + $maxR * sin( $ca );
  106. } else {
  107. $ca = 0.0 - ( $S + $i * $stp );
  108. $ppA[] = $x0 + $maxR * cos( $ca );
  109. $ppA[] = $y0 + $maxR * sin( $ca );
  110. $ppB[] = $x0 + $maxR * cos( $ca );
  111. $ppB[] = $y0 + $maxR * sin( $ca );
  112. };
  113. };
  114. $ppB[] = $ppA[count($ppA)-2];
  115. $ppB[] = $ppA[count($ppA)-1];
  116. $popo = array_merge( $ppA, $ppB );
  117. imagefilledpolygon( $IM, $popo, count( $popo ) / 2, $green );
  118. imagepng( $IM, "data/device_draws/{$Result[0]['md5']}_50.png" );
  119. imagedestroy( $IM );
  120. $IM = imagecreatefrompng("../../style/assets/lfs_draw_empty_25.png");
  121. imagesavealpha( $IM, true );
  122. $bg = imagecolorallocate($IM, 0, 0, 0);
  123. $black = imagecolorallocate($IM, 255, 255, 0);
  124. //$green = imagecolorallocate($IM, 0, 255, 0);
  125. $green = imagecolorallocatealpha( $IM, 0, 64, 0, 64 );
  126. imagefilledrectangle( $IM, 5, 5, 36, 18, $bg );
  127. imagestring( $IM, 2, 6, 5, ( $MR / 4 ) . "m.", $black );
  128. $rst = $maxR / 257.0;
  129. $ppA = array();
  130. $ppB = array();
  131. for( $i=0; $i< $as; $i++ ){
  132. if( $pts[$i] > 0 && $pts[$i] < 256 ){
  133. $cr = ($rst * $pts[$i]);
  134. $ca = 0.0 - ( $S + $i * $stp );
  135. $ppA[] = $x0 + $cr * cos( $ca );
  136. $ppA[] = $y0 + $cr * sin( $ca );
  137. $ppB[] = $x0 + $maxR * cos( $ca );
  138. $ppB[] = $y0 + $maxR * sin( $ca );
  139. } else {
  140. $ca = 0.0 - ( $S + $i * $stp );
  141. $ppA[] = $x0 + $maxR * cos( $ca );
  142. $ppA[] = $y0 + $maxR * sin( $ca );
  143. $ppB[] = $x0 + $maxR * cos( $ca );
  144. $ppB[] = $y0 + $maxR * sin( $ca );
  145. };
  146. };
  147. $ppB[] = $ppA[count($ppA)-2];
  148. $ppB[] = $ppA[count($ppA)-1];
  149. $popo = array_merge( $ppA, $ppB );
  150. imagefilledpolygon( $IM, $popo, count( $popo ) / 2, $green );
  151. imagepng( $IM, "data/device_draws/{$Result[0]['md5']}_25.png" );
  152. imagedestroy( $IM );
  153. $IM = imagecreatefrompng("../../style/assets/lfs_draw_empty_12.png");
  154. imagesavealpha( $IM, true );
  155. $bg = imagecolorallocate($IM, 0, 0, 0);
  156. $black = imagecolorallocate($IM, 255, 255, 0);
  157. //$green = imagecolorallocate($IM, 0, 255, 0);
  158. $green = imagecolorallocatealpha( $IM, 0, 64, 0, 64 );
  159. imagefilledrectangle( $IM, 5, 5, 36, 18, $bg );
  160. imagestring( $IM, 2, 6, 5, ( $MR / 8 ) . "m.", $black );
  161. $rst = $maxR / 129.0;
  162. $ppA = array();
  163. $ppB = array();
  164. for( $i=0; $i< $as; $i++ ){
  165. if( $pts[$i] > 0 && $pts[$i] < 128 ){
  166. $cr = ($rst * $pts[$i]);
  167. $ca = 0.0 - ( $S + $i * $stp );
  168. $ppA[] = $x0 + $cr * cos( $ca );
  169. $ppA[] = $y0 + $cr * sin( $ca );
  170. $ppB[] = $x0 + $maxR * cos( $ca );
  171. $ppB[] = $y0 + $maxR * sin( $ca );
  172. } else {
  173. $ca = 0.0 - ( $S + $i * $stp );
  174. $ppA[] = $x0 + $maxR * cos( $ca );
  175. $ppA[] = $y0 + $maxR * sin( $ca );
  176. $ppB[] = $x0 + $maxR * cos( $ca );
  177. $ppB[] = $y0 + $maxR * sin( $ca );
  178. };
  179. };
  180. $ppB[] = $ppA[count($ppA)-2];
  181. $ppB[] = $ppA[count($ppA)-1];
  182. $popo = array_merge( $ppA, $ppB );
  183. imagefilledpolygon( $IM, $popo, count( $popo ) / 2, $green );
  184. imagepng( $IM, "data/device_draws/{$Result[0]['md5']}_12.png" );
  185. imagedestroy( $IM );
  186. $QS = "UPDATE lrf_draw SET rendered='Y' WHERE id={$Result[0]['id']}";
  187. $DATABASE->Query( $QS );
  188. if( $AUX ){
  189. $FN = "data/device_draws/{$Result[0]['md5']}_{$AUX}.png";
  190. } else {
  191. $FN = "data/device_draws/{$Result[0]['md5']}_100.png";
  192. };
  193. };
  194. } else {
  195. echo "No Res"; exit();
  196. if( $AUX ){
  197. $FN = "../../style/assets/lfs_draw_empty_{$AUX}.png";
  198. } else {
  199. $FN = "../../style/assets/lfs_draw_empty_100.png";
  200. };
  201. };
  202. };
  203. if( !file_exists( $FN ) ) $FN = "../../style/assets/lfs_draw_empty_100.png";
  204. readfile( $FN );
  205. } else {
  206. //! $SAVE_AS_PICTURE
  207. $FF = "data/device_draws/{$Result[0]['md5']}.raw";
  208. if( file_exists( $FF ) ) {
  209. $FD = fopen( $FF, "rb" );
  210. if( $FD ){
  211. $CL = fread( $FD, 4 );
  212. $size = unpack( "V", $CL );
  213. $pts = array();
  214. $as = $size[1];
  215. for($i=0; $i< $as; $i++ ){
  216. $CL = fread( $FD, 4 );
  217. $T = unpack( "V", $CL );
  218. $pts[] = $T[1] >> 16;
  219. };
  220. fclose( $FD );
  221. $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}";
  222. $PP = $DATABASE->Query( $QS );
  223. $stp = 2.0 * ( M_PI / $as );
  224. $MR = intval( $PP[0]['max_range'] );
  225. $S = ( M_PI / 3000.0 ) * intval( $PP[0]['base_shift'] );
  226. switch( $AUX ){
  227. case 12: {
  228. $IM = imagecreatefrompng("../../style/assets/lfs_draw_empty_12.png");
  229. $RR = 129.0;
  230. $MR = $MR / 8;
  231. $MD = 128;
  232. break;
  233. };
  234. case 25: {
  235. $IM = imagecreatefrompng("../../style/assets/lfs_draw_empty_25.png");
  236. $RR = 257.0;
  237. $MR = $MR / 4;
  238. $MD = 256;
  239. break;
  240. };
  241. case 50: {
  242. $IM = imagecreatefrompng("../../style/assets/lfs_draw_empty_50.png");
  243. $RR = 513.0;
  244. $MR = $MR / 2;
  245. $MD = 512;
  246. break;
  247. };
  248. default:{
  249. $IM = imagecreatefrompng("../../style/assets/lfs_draw_empty_100.png");
  250. $RR = 1025.0;
  251. $MD = 1025;
  252. break;
  253. };
  254. };
  255. imagesavealpha( $IM, true );
  256. $bg = imagecolorallocate($IM, 0, 0, 0);
  257. $black = imagecolorallocate($IM, 255, 255, 0);
  258. //$green = imagecolorallocate($IM, 0, 255, 0);
  259. $green = imagecolorallocatealpha( $IM, 0, 64, 0, 64 );
  260. imagefilledrectangle( $IM, 5, 5, 36, 18, $bg );
  261. imagestring( $IM, 2, 6, 5, $MR . "m.", $black );
  262. $maxR = 98.0;
  263. $x0 = 100;
  264. $y0 = 100;
  265. $rst = $maxR / $RR;
  266. $ppA = array();
  267. $ppB = array();
  268. for( $i=0; $i< $as; $i++ ){
  269. if( $pts[$i] > 0 && $pts[$i] < $MD ){
  270. $cr = ($rst * $pts[$i]);
  271. $ca = 0.0 - ( $S + $i * $stp );
  272. $ppA[] = $x0 + $cr * cos( $ca );
  273. $ppA[] = $y0 + $cr * sin( $ca );
  274. $ppB[] = $x0 + $maxR * cos( $ca );
  275. $ppB[] = $y0 + $maxR * sin( $ca );
  276. } else {
  277. $ca = 0.0 - ( $S + $i * $stp );
  278. $ppA[] = $x0 + $maxR * cos( $ca );
  279. $ppA[] = $y0 + $maxR * sin( $ca );
  280. $ppB[] = $x0 + $maxR * cos( $ca );
  281. $ppB[] = $y0 + $maxR * sin( $ca );
  282. };
  283. };
  284. $ppB[] = $ppA[count($ppA)-2];
  285. $ppB[] = $ppA[count($ppA)-1];
  286. $popo = array_merge( $ppA, $ppB );
  287. imagefilledpolygon( $IM, $popo, count( $popo ) / 2, $green );
  288. imagepng( $IM );
  289. imagedestroy( $IM );
  290. } else {
  291. if( $AUX ){
  292. $FN = "../../style/assets/lfs_draw_empty_{$AUX}.png";
  293. } else {
  294. $FN = "../../style/assets/lfs_draw_empty_100.png";
  295. };
  296. if( !file_exists( $FN ) ) $FN = "../../style/assets/lfs_draw_empty_100.png";
  297. readfile( $FN );
  298. };
  299. } else {
  300. if( $AUX ){
  301. $FN = "../../style/assets/lfs_draw_empty_{$AUX}.png";
  302. } else {
  303. $FN = "../../style/assets/lfs_draw_empty_100.png";
  304. };
  305. if( !file_exists( $FN ) ) $FN = "../../style/assets/lfs_draw_empty_100.png";
  306. readfile( $FN );
  307. };
  308. };
  309. } else {
  310. if( $AUX ){
  311. $FN = "../../style/assets/lfs_draw_empty_{$AUX}.png";
  312. } else {
  313. $FN = "../../style/assets/lfs_draw_empty_100.png";
  314. };
  315. if( !file_exists( $FN ) ) $FN = "../../style/assets/lfs_draw_empty_100.png";
  316. readfile( $FN );
  317. };
  318. } else {
  319. header('location: /');
  320. };
  321. ?>