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.

1435 lines
46 KiB

​
​
​
12 months ago
​
​
​
​
12 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
12 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
12 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
12 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
12 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
12 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
12 months ago
12 months ago
​
​
​
​
​
​
​
​
12 months ago
​
12 months ago
​
​
​
​
​
​
​
12 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
12 months ago
​
12 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
12 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
12 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
12 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
12 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
12 months ago
​
​
​
​
​
​
12 months ago
12 months ago
12 months ago
​
​
​
​
​
​
​
​
​
12 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
12 months ago
​
​
​
​
​
​
​
​
​
​
​
12 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
12 months ago
​
​
​
​
​
​
​
​
​
​
​
12 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
12 months ago
​
​
​
​
​
​
​
​
12 months ago
​
​
​
​
​
  1. //<?php require_once('../../js_asm.php'); ?>
  2. var monitoringViewLevel = 0;
  3. var monitoringActiveSession = false;
  4. var mon_selectedEventId = 0;
  5. var mon_selectedPlatform = 0;
  6. var mon_selectedStation = 0;
  7. var mon_selectedTrack = 0;
  8. var mon_selectedModule = 0;
  9. var mon_platform_train = 0;
  10. var autoRiseEvent = true;
  11. var activeEvents = [];
  12. var expiredEvents = [];
  13. function imgLoadEvent(){
  14. alert('l c');
  15. };
  16. function createEventTagContent( a ){
  17. var gif='green_2.gif';
  18. var add=','+a.status;
  19. if( a.status == 0 ){
  20. gif='red_2.gif';
  21. };
  22. if( mon_selectedEventId == a.id ){
  23. return '<div id="event_tag_'+a.id+'"class="evt_side_tag_selected" onclick="selectEvent('+a.id+add+');"><table width="100%" border=0><tr><td colspan=2><div class="evt_side_stname">'+a.station_name+'</div></td><td width="18px"><img src="/style/assets/'+gif+'"></td></tr><tr><td><div class="evt_side_plname">'+a.platform_name+'</div></td><td colspan=2><div class="level_label_title">'+a.track_tag+'</div></td></tr></div>';
  24. };
  25. return '<div id="event_tag_'+a.id+'"class="evt_side_tag" onclick="selectEvent('+a.id+add+');"><table width="100%" border=0><tr><td colspan=2><div class="evt_side_stname">'+a.station_name+'</div></td><td width="18px"><img src="/style/assets/'+gif+'"></td></tr><tr><td><div class="evt_side_plname">'+a.platform_name+'</div></td><td colspan=2><div class="level_label_title">'+a.track_tag+'</div></td></tr></div>';
  26. };
  27. var GREEN_Icon = L.icon({
  28. iconUrl: '/style/assets/igr.png',
  29. iconSize: [44, 44],
  30. iconAnchor: [22, 22],
  31. popupAnchor: [0, -22]
  32. //shadowUrl: 'leaf-shadow.png',
  33. //shadowSize: [50, 64], // size of the shadow
  34. //shadowAnchor: [4, 62], // the same for the shadow
  35. });
  36. var BLUE_Icon = L.icon({
  37. iconUrl: '/style/assets/irs.png',
  38. iconSize: [44, 44],
  39. iconAnchor: [22, 22],
  40. popupAnchor: [0, -22]
  41. //shadowUrl: 'leaf-shadow.png',
  42. //shadowSize: [50, 64], // size of the shadow
  43. //shadowAnchor: [4, 62], // the same for the shadow
  44. });
  45. var RED_Icon = L.icon({
  46. iconUrl: '/style/assets/ira.png',
  47. iconSize: [44, 44],
  48. iconAnchor: [22, 22],
  49. popupAnchor: [0, -22]
  50. });
  51. var REDB_Icon = L.icon({
  52. iconUrl: '/style/assets/irabl.gif',
  53. iconSize: [44, 44],
  54. iconAnchor: [22, 22],
  55. popupAnchor: [0, -22]
  56. });
  57. var GREY_Icon = L.icon({
  58. iconUrl: '/style/assets/ign.png',
  59. iconSize: [44, 44],
  60. iconAnchor: [22, 22],
  61. popupAnchor: [0, -22]
  62. });
  63. var GREYN_Icon = L.icon({
  64. iconUrl: '/style/assets/ign.png',
  65. iconSize: [44, 44],
  66. iconAnchor: [22, 22],
  67. popupAnchor: [0, -22]
  68. });
  69. function makePtzMove( me ){
  70. var name = me.target.id;
  71. const myArray = name.split("_");
  72. Ext.Ajax.request({
  73. url: '/lib/controller/doModuleOperations.php',
  74. params: {
  75. UID: <?=$UserID;?>,
  76. SID: '<?=$Session;?>',
  77. OPID: 8,
  78. MID: myArray[3],
  79. MOV: myArray[2]
  80. },
  81. failure: failureAJAXFunction
  82. });
  83. };
  84. function makePtzStop( me ){
  85. var name = me.target.id;
  86. const myArray = name.split("_");
  87. Ext.Ajax.request({
  88. url: '/lib/controller/doModuleOperations.php',
  89. params: {
  90. SITE: <?=$SiteID;?>,
  91. UID: <?=$UserID;?>,
  92. SID: '<?=$Session;?>',
  93. OPID: 8,
  94. MID: myArray[3],
  95. MOV: 0
  96. },
  97. failure: failureAJAXFunction
  98. });
  99. };
  100. function makePtzHome( me ){
  101. var name = me.target.id;
  102. const myArray = name.split("_");
  103. Ext.Ajax.request({
  104. url: '/lib/controller/doModuleOperation.php',
  105. params: {
  106. SITE: <?=$SiteID;?>,
  107. UID: <?=$UserID;?>,
  108. SID: '<?=$Session;?>',
  109. OPID: 9,
  110. MID: myArray[3],
  111. MOV: 0
  112. },
  113. failure: failureAJAXFunction
  114. });
  115. };
  116. var fsDrawID = 0;
  117. function exitFullScreen( evt ){
  118. if( document.fullscreenElement ){
  119. } else {
  120. if( fsDrawID ){
  121. console.log("Leaving fullscreen mode.");
  122. };
  123. };
  124. };
  125. function fullScreen( id = '' ){
  126. if(
  127. id == '' ||
  128. document.fullscreenElement ||
  129. document.webkitFullscreenElement ||
  130. document.mozFullScreenElement ||
  131. document.msFullscreenElement
  132. ){
  133. if( document.exitFullscreen ){
  134. document.exitFullscreen();
  135. }else if( document.mozCancelFullScreen ){
  136. document.mozCancelFullScreen();
  137. }else if( document.webkitExitFullscreen ){
  138. document.webkitExitFullscreen();
  139. }else if( document.msExitFullscreen ){
  140. document.msExitFullscreen();
  141. };
  142. if( fsDrawID ){
  143. console.log('resized');
  144. };
  145. }else{
  146. var element = document.getElementById( id );
  147. if( element.requestFullscreen ){
  148. element.requestFullscreen();
  149. }else if( element.mozRequestFullScreen ){
  150. element.mozRequestFullScreen();
  151. }else if( element.webkitRequestFullscreen ){
  152. element.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
  153. }else if( element.msRequestFullscreen ){
  154. element.msRequestFullscreen();
  155. };
  156. };
  157. };
  158. function loadStationViewEvt( e ){
  159. loadStationView( e.target.options.mycustomid );
  160. };
  161. function loadStationView( STT, buba ){
  162. if( buba == undefined ){
  163. autoRiseEvent = false;
  164. } else {
  165. autoRiseEvent = buba;
  166. };
  167. if( mon_selectedEventId ) unselectEvent();
  168. mon_selectedStation = STT;
  169. changeContent( 1, 1, mon_selectedStation );
  170. updateUserContent();
  171. Ext.Ajax.request({
  172. url: '/lib/controller/getMonitoringStationView.php',
  173. params: {
  174. STT: mon_selectedStation,
  175. UID: <?=$UserID;?>,
  176. SID: '<?=$Session;?>'
  177. },
  178. success: function( response, opts ){
  179. var data = Ext.decode(response.responseText);
  180. if( data.status == 'ok' ){
  181. monitoringViewLevel = 1;
  182. Ext.getCmp('main_content').removeAll(true);
  183. Ext.getCmp('main_content').add( Ext.decode( data.content ) );
  184. Ext.getCmp('main_content').doLayout();
  185. if( data.pids != undefined ){
  186. if( data.pids.length > 0 ){
  187. //for( i=0; i<data.pids.length; i++ )correctPlatformView( data.pids[i] );
  188. };
  189. };
  190. fetchStatus();
  191. } else {
  192. if( data.status == 'steight' ){
  193. loadPlatformView( data.next_id );
  194. };
  195. };
  196. },
  197. failure: failureAJAXFunction
  198. });
  199. return;
  200. };
  201. function correctPlatformView( id ){
  202. var pp = Ext.getCmp('plat_panel_'+id);
  203. var pawi = pp.getWidth() / 70;
  204. var tt = document.getElementById('plat_table_'+id );
  205. if( tt != null ){
  206. tt.width = 36.5 * pawi +'px';
  207. };
  208. tt = Ext.getCmp('plat_schematics_'+id );
  209. if( tt != null ){
  210. tt.setHeight( 18 * pawi + 2 * 56 );
  211. };
  212. tt = document.getElementById('plat_video_'+id+'_'+pp.getComponent(0).custom);
  213. if( tt != null ){
  214. tt.style.width = 16 * pawi +'px';
  215. tt.style.height = 9 * pawi +'px';
  216. };
  217. tt = document.getElementById('plat_video_'+id+'_'+pp.getComponent(2).custom);
  218. if( tt != null ){
  219. tt.style.width = 16 * pawi +'px';
  220. tt.style.height = 9 * pawi +'px';
  221. };
  222. tt = document.getElementById('plat_video_'+id+'_'+pp.getComponent(3).custom);
  223. if( tt != null ){
  224. tt.style.width = 16 * pawi +'px';
  225. tt.style.height = 9 * pawi +'px';
  226. };
  227. tt = document.getElementById('plat_video_'+id+'_'+pp.getComponent(4).custom);
  228. if( tt != null ){
  229. tt.style.width = 16 * pawi +'px';
  230. tt.style.height = 9 * pawi +'px';
  231. };
  232. };
  233. function correctModuleView( id ){
  234. var juja = Ext.getCmp('module_panel_'+id );
  235. var pawi = juja.getWidth() / 70;
  236. var tt = Ext.getCmp('module_schematics_'+id);
  237. tt.setWidth( 20+35 * pawi );
  238. tt.setHeight( 38+19 * pawi );
  239. tt = document.getElementById('plat_video_div_'+id );
  240. tt.style.width = 32 * pawi +'px';
  241. tt.style.height = 18 * pawi +'px';
  242. pawi = Ext.getCmp('plat_video_panel_'+id);
  243. pawi.setWidth( 32+32 * pawi);
  244. pawi.setHeight( 32+ 18 * pawi);
  245. };
  246. function addSetSessionUI( session_id ){
  247. Ext.Ajax.request({
  248. url: '/lib/controller/doSessionOperations.php',
  249. params: {
  250. SESSION: session_id,
  251. OPID: 2,
  252. OPAR: 0,
  253. UID: <?=$UserID;?>,
  254. SID: '<?=$Session;?>'
  255. },
  256. success: function( response, opts ){
  257. var data = Ext.decode(response.responseText);
  258. if( data.status == 'ok' ){
  259. var tv = Ext.getCmp('trx_view');
  260. if( tv != undefined ){
  261. var tt = Ext.getCmp('sets_ui');
  262. if( tt != undefined ){
  263. tv.remove( tt );
  264. };
  265. tv.add( Ext.decode( data.content ) );
  266. tv.doLayout();
  267. };
  268. };
  269. }//,
  270. //failure: failureAJAXFunction
  271. });
  272. };
  273. function doSessionOperation( session_id, op, param, reload ){
  274. Ext.Ajax.request({
  275. url: '/lib/controller/doSessionOperations.php',
  276. params: {
  277. SESSION: session_id,
  278. OPID: op,
  279. OPAR: param,
  280. UID: <?=$UserID;?>,
  281. SID: '<?=$Session;?>'
  282. },
  283. success: function( response, opts ){
  284. var data = Ext.decode(response.responseText);
  285. if( data.status == 'ok' ){
  286. if( reload ){
  287. };
  288. };
  289. },
  290. failure: failureAJAXFunction
  291. });
  292. };
  293. function loadPlatformView( pid, buba ){
  294. if( buba == undefined ){
  295. autoRiseEvent = false;
  296. } else {
  297. autoRiseEvent = buba;
  298. };
  299. if( mon_selectedEventId ) unselectEvent( mon_selectedEventId );
  300. mon_platform_train = 0;
  301. mTrainSvgElements = [];
  302. mon_selectedPlatform = pid;
  303. changeContent( 1, 2, pid );
  304. updateUserContent();
  305. Ext.Ajax.request({
  306. url: '/lib/controller/getMonitoringPlatformView.php',
  307. params: {
  308. PID: mon_selectedPlatform,
  309. UID: <?=$UserID;?>,
  310. SID: '<?=$Session;?>'
  311. },
  312. success: function( response, opts ){
  313. var data = Ext.decode(response.responseText);
  314. if( data.status == 'ok' ){
  315. monitoringViewLevel = 2;
  316. Ext.getCmp('main_content').removeAll(true);
  317. Ext.getCmp('main_content').add( Ext.decode( data.content ) );
  318. Ext.getCmp('main_content').doLayout();
  319. correctPlatformView( data.pid );
  320. fetchStatus();
  321. };
  322. },
  323. failure: failureAJAXFunction
  324. });
  325. return;
  326. };
  327. function loadTrackViewBySession( session_id ){
  328. autoRiseEvent = false;
  329. mSvgElements = [];
  330. Ext.Ajax.request({
  331. url: '/lib/controller/getMonitoringTrackView.php',
  332. params: {
  333. SESSION: session_id,
  334. UID: <?=$UserID;?>,
  335. SID: '<?=$Session;?>'
  336. },
  337. success: function( response, opts ){
  338. var data = Ext.decode(response.responseText);
  339. if( data.status == 'ok' ){
  340. monitoringViewLevel = 3;
  341. mon_selectedTrack = data.track_id;
  342. changeContent( 1, 3, mon_selectedTrack );
  343. updateUserContent();
  344. Ext.getCmp('main_content').removeAll(true);
  345. Ext.getCmp('main_content').add( Ext.decode( data.content ) );
  346. Ext.getCmp('main_content').doLayout();
  347. tt=document.getElementById('trx_status_txt');
  348. tt.classList.remove('static_status_text');
  349. tt.classList.add('blinking_status_text');
  350. tt.innerText = 'ACTIVE';
  351. tt=document.getElementById('trx_status_cell');
  352. tt.classList.remove('top_status_hidden');
  353. tt.classList.add('top_status_red_lbl');
  354. monitoringActiveSession = true;
  355. fetchStatus();
  356. };
  357. },
  358. failure: failureAJAXFunction
  359. });
  360. return;
  361. };
  362. function loadTrackView( tid ){
  363. autoRiseEvent = false;
  364. mon_selectedTrack = tid;
  365. changeContent( 1, 3, mon_selectedTrack );
  366. updateUserContent();
  367. mSvgElements = [];
  368. Ext.Ajax.request({
  369. url: '/lib/controller/getMonitoringTrackView.php',
  370. params: {
  371. TID: mon_selectedTrack,
  372. UID: <?=$UserID;?>,
  373. SID: '<?=$Session;?>'
  374. },
  375. success: function( response, opts ){
  376. var data = Ext.decode(response.responseText);
  377. if( data.status == 'ok' ){
  378. monitoringViewLevel = 3;
  379. mon_selectedPlatform = data.platform_id;
  380. mon_selectedStation = data.station_id;
  381. Ext.getCmp('main_content').removeAll(true);
  382. Ext.getCmp('main_content').add( Ext.decode( data.content ) );
  383. Ext.getCmp('main_content').doLayout();
  384. tt=document.getElementById('trx_status_txt');
  385. tt.innerText = 'LIVE VIEW';
  386. monitoringActiveSession = false;
  387. tt=document.getElementById('trx_status_cell');
  388. tt.classList.remove('top_status_hidden');
  389. tt.classList.add('top_status_green_lbl');
  390. fetchStatus();
  391. };
  392. },
  393. failure: failureAJAXFunction
  394. });
  395. return;
  396. };
  397. function loadModuleView( pid, mid ){
  398. autoRiseEvent = false;
  399. if( mon_selectedEventId ) unselectEvent( mon_selectedEventId );
  400. changeContent( 1, 4, pid+'-'+mid );
  401. updateUserContent();
  402. Ext.Ajax.request({
  403. url: '/lib/controller/getMonitoringModuleView.php',
  404. params: {
  405. PID: pid,
  406. MID: mid,
  407. UID: <?=$UserID;?>,
  408. SID: '<?=$Session;?>'
  409. },
  410. success: function( response, opts ){
  411. var data = Ext.decode(response.responseText);
  412. if( data.status == 'ok' ){
  413. monitoringViewLevel = 4;
  414. Ext.getCmp('main_content').removeAll(true);
  415. Ext.getCmp('main_content').add( Ext.decode( data.content ) );
  416. Ext.getCmp('main_content').doLayout();
  417. correctModuleView( mid );
  418. fetchStatus();
  419. };
  420. },
  421. failure: failureAJAXFunction
  422. });
  423. return;
  424. };
  425. function loadMapView(){
  426. changeContent( 0, 0, 0 );
  427. updateUserContent();
  428. autoRiseEvent = false;
  429. if( mon_selectedEventId ) unselectEvent( mon_selectedEventId );
  430. Ext.Ajax.request({
  431. url: '/lib/controller/getMonitoringMapView.php',
  432. params: {
  433. UID: <?=$UserID;?>,
  434. SID: '<?=$Session;?>'
  435. },
  436. success: function( response, opts ){
  437. var data = Ext.decode(response.responseText);
  438. if( data.status == 'ok' ){
  439. monitoringViewLevel = 0;
  440. Ext.getCmp('main_content').removeAll(true);
  441. Ext.getCmp('main_content').add( Ext.decode( data.content ) );
  442. Ext.getCmp('main_content').doLayout();
  443. };
  444. },
  445. failure: failureAJAXFunction
  446. });
  447. return;
  448. };
  449. var monitoring_map = null;
  450. var c_icon = null;
  451. var stationMarkers = [];
  452. function initMonitoringMap( map_id, x, y ){
  453. var mapLayers = [];
  454. if( monitoring_map != null ){
  455. monitoring_map.off();
  456. monitoring_map.remove();
  457. monitoring_map = null;
  458. };
  459. monitoring_map = L.map( map_id,{
  460. crs: L.CRS.Simple,
  461. attributionControl: false,
  462. preferCanvas: true,
  463. zoomControl: true,
  464. center: [x,y],
  465. zoom: 0,
  466. minZoom: -3,
  467. maxZoom: 0,
  468. keyboard: false
  469. });
  470. var bounds = [[SCHEMATIC_SET.bounds_lx,SCHEMATIC_SET.bounds_ly], [SCHEMATIC_SET.bounds_rx,SCHEMATIC_SET.bounds_ry]];
  471. var image = L.imageOverlay( SCHEMATIC_SET.layer_url, bounds ).addTo( monitoring_map );
  472. Ext.Ajax.request({
  473. url: '/lib/controller/listStations.php',
  474. params: {
  475. UID: <?=$UserID;?>,
  476. SID: '<?=$Session;?>'
  477. },
  478. success: function( response, opts ){
  479. var data = Ext.decode(response.responseText);
  480. if( data.status == 'ok' ){
  481. for( i=0; i < data.stations.length; i++ ){
  482. stationMarkers[ data.stations[i].id ] = L.marker([data.stations[i].y, data.stations[i].x], { draggable: false, icon: GREY_Icon, zIndexOffset: 1000, mycustomid: data.stations[i].id } ).addTo( monitoring_map ).on('click', loadStationViewEvt );;
  483. };
  484. };
  485. // Ready -> Start Getting data
  486. fetchStatus();
  487. },
  488. failure: failureAJAXFunction
  489. });
  490. };
  491. function getBackToMap(){
  492. autoRiseEvent = true;
  493. changeContent( 1, 0 );
  494. updateUserContent();
  495. loadMapView();
  496. };
  497. function initMonitoring( x, y ){
  498. if( tlInterval!= null ){
  499. window.clearInterval( tlInterval );
  500. tlInterval = null;
  501. timelineObj = null;
  502. };
  503. var tP = Ext.getCmp('left_side_menu');
  504. tP.removeAll( true );
  505. tP.add({
  506. layout:'vbox',
  507. frame: false,
  508. border: false,
  509. items:[{
  510. width: "100%",
  511. html: '<div class="mon_side_tag">Active Alerts</div>'
  512. },{
  513. id: 'sme_inner',
  514. layout:'vbox',
  515. width: '100%',
  516. height: PanelH/2,
  517. autoScroll: true ,
  518. frame: false,
  519. border: false,
  520. items:[]
  521. },{
  522. width: "100%",
  523. html: '<div class="mon_side_tag">Expired Alerts</div>'
  524. },{
  525. id: 'sme_outer',
  526. layout:'vbox',
  527. width: '100%',
  528. height: 1000,//PanelH/2,
  529. frame: false,
  530. border: false,
  531. items:[]
  532. }]
  533. });
  534. tP.doLayout();
  535. monitoringViewLevel = contentView.l[1].v;
  536. switch( monitoringViewLevel ){
  537. case 0:{
  538. loadMapView();
  539. autoRiseEvent = true;
  540. var tt = Ext.getCmp('aer_button');
  541. if( tt != undefined ){
  542. tt.toggle( true, true );
  543. }
  544. break;
  545. };
  546. case 1:{
  547. loadStationView( parseInt( contentView.l[1].p ), autoRiseEvent );
  548. break;
  549. };
  550. case 2:{
  551. loadPlatformView( parseInt( contentView.l[1].p ), autoRiseEvent );
  552. break;
  553. };
  554. case 3:{
  555. loadTrackView( parseInt( contentView.l[1].p ), autoRiseEvent );
  556. break;
  557. };
  558. case 4:{
  559. var tA = contentView.l[1].p.split('-');
  560. a = parseInt( tA[0] );
  561. b = parseInt( tA[1] );
  562. loadModuleView( a, b );
  563. break;
  564. };
  565. case 5:{
  566. selectEvent( parseInt( contentView.l[1].p ), true );
  567. break;
  568. };
  569. };
  570. Ext.getCmp('main_content').doLayout();
  571. };
  572. var statusLTS = 0;
  573. var statusLID = 0;
  574. function manageSideTags( tag_area, buba ){
  575. var tP = Ext.getCmp( tag_area );
  576. if( tP != undefined ){
  577. if( buba != undefined ){
  578. if( buba.length ){
  579. var idx_a = 0;
  580. //alert( tag_area + ' has '+tP.items.getCount() );
  581. while( a = tP.getComponent( idx_a ) ){
  582. var f=false;
  583. for( var zz=0; zz < buba.length; zz++ ){
  584. if( a.getId() == 'tag_panel_'+buba[zz].id ){
  585. f = true;
  586. break;
  587. };
  588. };
  589. if( !f ) {
  590. tt--;
  591. tP.remove( a, true );
  592. } else idx_a++;
  593. };
  594. tP.doLayout();
  595. var aa = tP.items.getRange();
  596. var tt = aa.length;
  597. for( var zz=0; zz < buba.length; zz++ ){
  598. var f=false;
  599. for( var i=0; i < aa.length; i++ ){
  600. if( aa[i].getId() == 'tag_panel_'+buba[zz].id ){
  601. f = true;
  602. break;
  603. };
  604. };
  605. if( !f ){
  606. var ichu = createEventTagContent( buba[zz] );
  607. tP.insert( 0,{
  608. id: 'tag_panel_'+buba[zz].id,
  609. width: '100%',
  610. html: ichu
  611. });
  612. tt++;
  613. };
  614. if( tt > 32 ){
  615. tP.remove( aa[31], true );
  616. tt--;
  617. };
  618. };
  619. if( tag_area == 'sme_inner' ){
  620. // Active
  621. activeEvents = [];
  622. for( var zz=0; zz < buba.length; zz++ ) activeEvents[zz]={id: buba[zz].id};
  623. } else {
  624. // Expired
  625. expiredEvents = [];
  626. for( var zz=0; zz < buba.length; zz++ ) expiredEvents[zz]={id: buba[zz].id};
  627. };
  628. } else {
  629. tP.removeAll( true );
  630. if( tag_area == 'sme_inner' ){
  631. // Active
  632. activeEvents = [];
  633. } else {
  634. // Expired
  635. expiredEvents = [];
  636. };
  637. };
  638. } else {
  639. tP.removeAll( true );
  640. if( tag_area == 'sme_inner' ){
  641. // Active
  642. activeEvents = [];
  643. } else {
  644. // Expired
  645. expiredEvents = [];
  646. };
  647. };
  648. tP.doLayout();
  649. };
  650. };
  651. var mSvgElements = [];
  652. var mTrainSvgElements=[];
  653. function animateTrainOnPlatform( _in, _out ){
  654. if( ( _out & 3 ) > 0 ){
  655. if( typeof mTrainSvgElements[0] === 'undefined') {
  656. switch( _out & 3 ) {
  657. case 1:{
  658. var svgns = "http://www.w3.org/2000/svg";
  659. mTrainSvgElements[0] = document.createElementNS(svgns, 'rect');
  660. mTrainSvgElements[0].setAttribute('x', '1550');
  661. mTrainSvgElements[0].setAttribute('y', '50' );
  662. mTrainSvgElements[0].setAttribute('rx','5' );
  663. mTrainSvgElements[0].setAttribute('height', ''+100);
  664. mTrainSvgElements[0].setAttribute('width', ''+540);
  665. mTrainSvgElements[0].setAttribute('fill', '#FF0000FF');
  666. var anim1 = document.createElementNS(svgns, 'animate');
  667. anim1.setAttribute('dur', '3s' );
  668. anim1.setAttribute('attributeName', 'x' );
  669. anim1.setAttribute('from', '2000' );
  670. anim1.setAttribute('to', '1100' );
  671. anim1.setAttribute('calcMode', 'linear' );
  672. anim1.setAttribute('fill', 'freeze' );
  673. var anim2 = document.createElementNS(svgns, 'animate');
  674. anim2.setAttribute('dur', '3s' );
  675. anim2.setAttribute('attributeName', 'opacity' );
  676. anim2.setAttribute('from', '0' );
  677. anim2.setAttribute('to', '1' );
  678. anim2.setAttribute('calcMode','linear' );
  679. anim2.setAttribute('fill', 'freeze' );
  680. mTrainSvgElements[0].appendChild( anim1 );
  681. mTrainSvgElements[0].appendChild( anim2 );
  682. break;
  683. };
  684. case 2:{
  685. var svgns = "http://www.w3.org/2000/svg";
  686. mTrainSvgElements[0] = document.createElementNS(svgns, 'rect');
  687. mTrainSvgElements[0].setAttribute('x', '-550');
  688. mTrainSvgElements[0].setAttribute('y', '50' );
  689. mTrainSvgElements[0].setAttribute('rx','5' );
  690. mTrainSvgElements[0].setAttribute('height', ''+100);
  691. mTrainSvgElements[0].setAttribute('width', ''+540);
  692. mTrainSvgElements[0].setAttribute('fill', '#FF0000FF');
  693. var anim1 = document.createElementNS(svgns, 'animate');
  694. anim1.setAttribute('dur', '3s' );
  695. anim1.setAttribute('attributeName', 'x' );
  696. anim1.setAttribute('from', '-550' );
  697. anim1.setAttribute('to', '300' );
  698. anim1.setAttribute('calcMode', 'linear' );
  699. anim1.setAttribute('fill', 'freeze' );
  700. var anim2 = document.createElementNS(svgns, 'animate');
  701. anim2.setAttribute('dur', '3s' );
  702. anim2.setAttribute('attributeName', 'opacity' );
  703. anim2.setAttribute('from', '0' );
  704. anim2.setAttribute('to', '1' );
  705. anim2.setAttribute('calcMode','linear' );
  706. anim2.setAttribute('fill', 'freeze' );
  707. mTrainSvgElements[0].appendChild( anim1 );
  708. mTrainSvgElements[0].appendChild( anim2 );
  709. break;
  710. };
  711. case 3:{
  712. var svgns = "http://www.w3.org/2000/svg";
  713. mTrainSvgElements[0] = document.createElementNS(svgns, 'rect');
  714. mTrainSvgElements[0].setAttribute('x', '700');
  715. mTrainSvgElements[0].setAttribute('y', '50' );
  716. mTrainSvgElements[0].setAttribute('rx','5' );
  717. mTrainSvgElements[0].setAttribute('height', ''+100);
  718. mTrainSvgElements[0].setAttribute('width', ''+540);
  719. mTrainSvgElements[0].setAttribute('fill', '#FF0000FF');
  720. var anim = document.createElementNS(svgns, 'animate');
  721. anim.setAttribute('dur', '3s' );
  722. anim.setAttribute('attributeName', 'opacity' );
  723. anim.setAttribute('from', '0' );
  724. anim.setAttribute('to', '1' );
  725. anim.setAttribute('calcMode','linear' );
  726. anim.setAttribute('fill', 'freeze' );
  727. mTrainSvgElements[0].appendChild( anim );
  728. };
  729. };
  730. var tt = document.getElementById('svgTrackMap');
  731. tt.appendChild( mTrainSvgElements[0] );
  732. } else {
  733. };
  734. } else {
  735. if( typeof mTrainSvgElements[0] != 'undefined') {
  736. var tt = document.getElementById('svgTrackMap');
  737. tt.removeChild( mTrainSvgElements[0] );
  738. mTrainSvgElements[0] = null;
  739. };
  740. };
  741. if( ( _out & 12 ) > 0 ){
  742. if( typeof mTrainSvgElements[1] === 'undefined') {
  743. switch( ( _out >> 2 ) ) {
  744. case 2:{
  745. var svgns = "http://www.w3.org/2000/svg";
  746. mTrainSvgElements[1] = document.createElementNS(svgns, 'rect');
  747. mTrainSvgElements[1].setAttribute('x', '1550');
  748. mTrainSvgElements[1].setAttribute('y', '550' );
  749. mTrainSvgElements[1].setAttribute('rx','5' );
  750. mTrainSvgElements[1].setAttribute('height', ''+100);
  751. mTrainSvgElements[1].setAttribute('width', ''+540);
  752. mTrainSvgElements[1].setAttribute('fill', '#FF0000FF');
  753. var anim1 = document.createElementNS(svgns, 'animate');
  754. anim1.setAttribute('dur', '3s' );
  755. anim1.setAttribute('attributeName', 'x' );
  756. anim1.setAttribute('from', '2000' );
  757. anim1.setAttribute('to', '1100' );
  758. anim1.setAttribute('calcMode', 'linear' );
  759. anim1.setAttribute('fill', 'freeze' );
  760. var anim2 = document.createElementNS(svgns, 'animate');
  761. anim2.setAttribute('dur', '3s' );
  762. anim2.setAttribute('attributeName', 'opacity' );
  763. anim2.setAttribute('from', '0' );
  764. anim2.setAttribute('to', '1' );
  765. anim2.setAttribute('calcMode','linear' );
  766. anim2.setAttribute('fill', 'freeze' );
  767. mTrainSvgElements[1].appendChild( anim1 );
  768. mTrainSvgElements[1].appendChild( anim2 );
  769. break;
  770. };
  771. case 1:{
  772. var svgns = "http://www.w3.org/2000/svg";
  773. mTrainSvgElements[1] = document.createElementNS(svgns, 'rect');
  774. mTrainSvgElements[1].setAttribute('x', '-550');
  775. mTrainSvgElements[1].setAttribute('y', '550' );
  776. mTrainSvgElements[1].setAttribute('rx','5' );
  777. mTrainSvgElements[1].setAttribute('height', ''+100);
  778. mTrainSvgElements[1].setAttribute('width', ''+540);
  779. mTrainSvgElements[1].setAttribute('fill', '#FF0000FF');
  780. var anim1 = document.createElementNS(svgns, 'animate');
  781. anim1.setAttribute('dur', '3s' );
  782. anim1.setAttribute('attributeName', 'x' );
  783. anim1.setAttribute('from', '-550' );
  784. anim1.setAttribute('to', '300' );
  785. anim1.setAttribute('calcMode', 'linear' );
  786. anim1.setAttribute('fill', 'freeze' );
  787. var anim2 = document.createElementNS(svgns, 'animate');
  788. anim2.setAttribute('dur', '3s' );
  789. anim2.setAttribute('attributeName', 'opacity' );
  790. anim2.setAttribute('from', '0' );
  791. anim2.setAttribute('to', '1' );
  792. anim2.setAttribute('calcMode','linear' );
  793. anim2.setAttribute('fill', 'freeze' );
  794. mTrainSvgElements[1].appendChild( anim1 );
  795. mTrainSvgElements[1].appendChild( anim2 );
  796. break;
  797. };
  798. case 3:{
  799. var svgns = "http://www.w3.org/2000/svg";
  800. mTrainSvgElements[1] = document.createElementNS(svgns, 'rect');
  801. mTrainSvgElements[1].setAttribute('x', '700');
  802. mTrainSvgElements[1].setAttribute('y', '550' );
  803. mTrainSvgElements[1].setAttribute('rx','5' );
  804. mTrainSvgElements[1].setAttribute('height', ''+100);
  805. mTrainSvgElements[1].setAttribute('width', ''+540);
  806. mTrainSvgElements[1].setAttribute('fill', '#FF0000FF');
  807. var anim = document.createElementNS(svgns, 'animate');
  808. anim.setAttribute('dur', '3s' );
  809. anim.setAttribute('attributeName', 'opacity' );
  810. anim.setAttribute('from', '0' );
  811. anim.setAttribute('to', '1' );
  812. anim.setAttribute('calcMode','linear' );
  813. anim.setAttribute('fill', 'freeze' );
  814. mTrainSvgElements[1].appendChild( anim );
  815. };
  816. };
  817. var tt = document.getElementById('svgTrackMap');
  818. tt.appendChild( mTrainSvgElements[1] );
  819. } else {
  820. };
  821. } else {
  822. if( typeof mTrainSvgElements[1] != 'undefined') {
  823. var tt = document.getElementById('svgTrackMap');
  824. tt.removeChild( mTrainSvgElements[1] );
  825. mTrainSvgElements[1] = null;
  826. };
  827. };
  828. };
  829. function fetchStatus(){
  830. if( tlInterval!= null ){
  831. window.clearTimeout( tlInterval );
  832. tlInterval = null;
  833. };
  834. switch(monitoringViewLevel){
  835. case 0:{
  836. var ll = monitoring_map.getCenter();
  837. CX = ll.lat;
  838. CY = ll.lng;
  839. ajax_params = {
  840. VLVL: monitoringViewLevel,
  841. UID: <?=$UserID;?>,
  842. SID: '<?=$Session;?>',
  843. LTS: statusLTS,
  844. LID: statusLID,
  845. MX: CX,
  846. MY: CY
  847. };
  848. break;
  849. };
  850. case 1:{
  851. ajax_params = {
  852. VLVL: monitoringViewLevel,
  853. UID: <?=$UserID;?>,
  854. SID: '<?=$Session;?>',
  855. LTS: statusLTS,
  856. LID: statusLID,
  857. SSID: mon_selectedStation
  858. };
  859. break;
  860. };
  861. case 2:{
  862. ajax_params = {
  863. VLVL: monitoringViewLevel,
  864. UID: <?=$UserID;?>,
  865. SID: '<?=$Session;?>',
  866. PID: mon_selectedPlatform,
  867. LTS: statusLTS,
  868. LID: statusLID
  869. };
  870. break;
  871. };
  872. case 3:{
  873. ajax_params = {
  874. VLVL: monitoringViewLevel,
  875. UID: <?=$UserID;?>,
  876. SID: '<?=$Session;?>',
  877. TID: mon_selectedTrack,
  878. LTS: statusLTS,
  879. LID: statusLID
  880. };
  881. break;
  882. };
  883. case 4:{
  884. ajax_params = {
  885. VLVL: monitoringViewLevel,
  886. UID: <?=$UserID;?>,
  887. SID: '<?=$Session;?>',
  888. MID: mon_selectedModule,
  889. LTS: statusLTS,
  890. LID: statusLID
  891. };
  892. break;
  893. };
  894. case 5:{
  895. ajax_params = {
  896. VLVL: monitoringViewLevel,
  897. UID: <?=$UserID;?>,
  898. SID: '<?=$Session;?>',
  899. SESSION: mon_selectedEventId,
  900. LTS: statusLTS,
  901. LID: statusLID
  902. };
  903. break;
  904. };
  905. };
  906. Ext.Ajax.request({
  907. url: '/lib/controller/getStatus.php',
  908. params: ajax_params,
  909. success: function( response, opts ){
  910. var data = Ext.decode(response.responseText);
  911. if( data.status == 'ok' ){
  912. if( monitoringViewLevel == data.VLVL ){
  913. statusLTS = data.LTS;
  914. if( autoRiseEvent ){
  915. if( data.active_session_id != undefined ){
  916. if( data.active_session_id > 0 ){
  917. if( ssIsActive ) ssHideSS();
  918. if( data.active_session_id != mon_selectedEventId ){
  919. playSound( 1 );
  920. selectEvent( data.active_session_id, false );
  921. return;
  922. };
  923. };
  924. };
  925. };
  926. //debugger;
  927. switch( monitoringViewLevel ){
  928. case 0:{ //Map
  929. for( i=0; i < data.station_ids.length; i++ ){
  930. switch( data.station_status[i] ){
  931. case 0: {
  932. if( stationMarkers[data.station_ids[i]].options.icon != GREY_Icon ) stationMarkers[data.station_ids[i]].setIcon( GREY_Icon );
  933. break;
  934. };
  935. case 1: {
  936. if( stationMarkers[data.station_ids[i]].options.icon != BLUE_Icon ) stationMarkers[data.station_ids[i]].setIcon( BLUE_Icon );
  937. break;
  938. };
  939. case 2: {
  940. if( stationMarkers[data.station_ids[i]].options.icon != GREEN_Icon ) stationMarkers[data.station_ids[i]].setIcon( GREEN_Icon );
  941. break;
  942. };
  943. case 3: {
  944. if( ( Math.floor(Date.now() / 1000) % 2 ) == 0 ) {
  945. if( stationMarkers[data.station_ids[i]].options.icon != GREEN_Icon ) stationMarkers[data.station_ids[i]].setIcon( GREEN_Icon );
  946. } else {
  947. if( stationMarkers[data.station_ids[i]].options.icon != RED_Icon ) stationMarkers[data.station_ids[i]].setIcon( RED_Icon );
  948. };
  949. break;
  950. };
  951. case 4: {
  952. if( stationMarkers[data.station_ids[i]].options.icon != REDB_Icon ) stationMarkers[data.station_ids[i]].setIcon( REDB_Icon );
  953. break;
  954. };
  955. };
  956. };
  957. break;
  958. };
  959. case 1:{ //Platforms
  960. if( data.platforms != undefined ){
  961. for( i=0; i< data.platforms.length; i++ ){
  962. var tt = document.getElementById( 'plat_table_'+data.platforms[i].id );
  963. if( data.platforms[i].status == 1 ){
  964. if( tt.classList.contains('active_green') ){
  965. tt.classList.remove('active_green');
  966. tt.classList.add('active_red');
  967. };
  968. } else {
  969. if( tt.classList.contains('active_red') ){
  970. tt.classList.remove('active_red');
  971. tt.classList.add('active_green');
  972. };
  973. };
  974. if( data.platforms[i].modules != undefined ){
  975. for( j=0; j<data.platforms[i].modules.length; j++ ){
  976. if( data.platforms[i].modules[j].status ){
  977. var zz = document.getElementById('mod_vp_'+data.platforms[i].modules[j].id );
  978. if( zz.style.backgroundImage != 'url("'+data.platforms[i].modules[j].img+'")' ){
  979. zz.style.backgroundImage = 'url("'+data.platforms[i].modules[j].img+'")';
  980. };
  981. };
  982. };
  983. };
  984. };
  985. };
  986. break;
  987. };
  988. case 2:{ // Platform
  989. if( data.modules != undefined ){
  990. for( var i=0; i< data.modules.length; i++){
  991. if( data.modules[i].status > 0 ){
  992. var tt = document.getElementById('plat_video_'+mon_selectedPlatform+'_'+data.modules[i].id );
  993. if( tt != undefined ){
  994. if( tt.src != data.modules[i].img ) tt.src = data.modules[i].img;
  995. };
  996. tt = document.getElementById('plat_status_'+mon_selectedPlatform+'_'+data.modules[i].id );
  997. if( tt != undefined ){
  998. switch( data.modules[i].status ){
  999. case 1: tt.innerHTML='<img src="/style/assets/bul_gray.png">'; break;
  1000. case 2: tt.innerHTML='<img src="/style/assets/bul_green.png">'; break;
  1001. case 3: tt.innerHTML='<img src="/style/assets/bul_green_rst.png">'; break;
  1002. };
  1003. };
  1004. };
  1005. };
  1006. };
  1007. if( data.scada != undefined ){
  1008. var tt = document.getElementById('scada_status');
  1009. switch( data.scada.status ){
  1010. case 0:{
  1011. tt.innerHTML='<?=$Labels->GetLabel('_NOT_ASSIGNED_');?>';
  1012. tt.setAttribute('class', 'mon_scada_status_tag_na');
  1013. tt = document.getElementById('scada_a');
  1014. tt.setAttribute('class', 'mon_scada_head');
  1015. tt = document.getElementById('scada_b');
  1016. tt.setAttribute('class', 'mon_scada_head');
  1017. tt = document.getElementById('scada_c');
  1018. tt.setAttribute('class', 'mon_scada_head');
  1019. tt = document.getElementById('scada_d');
  1020. tt.setAttribute('class', 'mon_scada_head');
  1021. break;
  1022. };
  1023. case 1:{
  1024. tt.innerHTML='<?=$Labels->GetLabel('__DISABLED__');?>';
  1025. tt.setAttribute('class', 'mon_scada_status_tag_na');
  1026. tt = document.getElementById('scada_a');
  1027. tt.setAttribute('class', 'mon_scada_head');
  1028. tt = document.getElementById('scada_b');
  1029. tt.setAttribute('class', 'mon_scada_head');
  1030. tt = document.getElementById('scada_c');
  1031. tt.setAttribute('class', 'mon_scada_head');
  1032. tt = document.getElementById('scada_d');
  1033. tt.setAttribute('class', 'mon_scada_head');
  1034. break;
  1035. };
  1036. case 2:{//offline
  1037. tt.innerHTML='<?=$Labels->GetLabel('__OFFLINE__');?>';
  1038. tt.setAttribute('class', 'mon_scada_status_tag_na');
  1039. tt = document.getElementById('scada_a');
  1040. tt.setAttribute('class', 'mon_scada_head');
  1041. tt = document.getElementById('scada_b');
  1042. tt.setAttribute('class', 'mon_scada_head');
  1043. tt = document.getElementById('scada_c');
  1044. tt.setAttribute('class', 'mon_scada_head');
  1045. tt = document.getElementById('scada_d');
  1046. tt.setAttribute('class', 'mon_scada_head');
  1047. break;
  1048. };
  1049. case 3:{//online
  1050. tt.innerHTML='<?=$Labels->GetLabel('__ONLINE__');?>';
  1051. tt.setAttribute('class', 'mon_scada_status_tag_ok');
  1052. tt = document.getElementById('scada_a');
  1053. if( data.scada.A ){
  1054. tt.setAttribute('class', 'mon_scada_head_active');
  1055. } else {
  1056. tt.setAttribute('class', 'mon_scada_head_ok');
  1057. };
  1058. tt = document.getElementById('scada_b');
  1059. if( data.scada.B ){
  1060. tt.setAttribute('class', 'mon_scada_head_active');
  1061. } else {
  1062. tt.setAttribute('class', 'mon_scada_head_ok');
  1063. };
  1064. tt = document.getElementById('scada_c');
  1065. if( data.scada.C ){
  1066. tt.setAttribute('class', 'mon_scada_head_active');
  1067. } else {
  1068. tt.setAttribute('class', 'mon_scada_head_ok');
  1069. };
  1070. tt = document.getElementById('scada_d');
  1071. if( data.scada.D ){
  1072. tt.setAttribute('class', 'mon_scada_head_active');
  1073. } else {
  1074. tt.setAttribute('class', 'mon_scada_head_ok');
  1075. };
  1076. break;
  1077. };
  1078. };
  1079. };
  1080. if( data.events != undefined ){
  1081. var sid = data.events.length - 1;
  1082. if( sid > -1 ){
  1083. for( var i=0; i< max_grad_levels; i++ ){
  1084. var cid = sid-i;
  1085. var csize = getSize( i );
  1086. //debugger;
  1087. if( typeof mSvgElements[i] === 'undefined') {
  1088. if( cid > -1 ){
  1089. var svgns = "http://www.w3.org/2000/svg";
  1090. mSvgElements[i] = document.createElementNS(svgns, 'rect');
  1091. mSvgElements[i].setAttribute('x', data.events[cid].x+'%');
  1092. mSvgElements[i].setAttribute('y', ''+(50+(100-csize)/2) );
  1093. mSvgElements[i].setAttribute('height', ''+csize);
  1094. mSvgElements[i].setAttribute('width', ''+csize);
  1095. mSvgElements[i].setAttribute('fill', '#FF0000'+getTransperecy(i));
  1096. var tt = document.getElementById('svgTrackMap');
  1097. var zz = document.getElementById('scheme_anch');
  1098. tt.insertBefore( mSvgElements[i], zz );
  1099. //document.getElementById('svgTrackMap').appendChild(this.mSvgElements[i]);
  1100. };
  1101. } else {
  1102. if( cid > -1 ){
  1103. mSvgElements[i].setAttribute('x', data.events[cid].x+'%');
  1104. mSvgElements[i].setAttribute('y', ''+(50+(100-csize)/2) );
  1105. mSvgElements[i].setAttribute('height', ''+csize);
  1106. mSvgElements[i].setAttribute('width', ''+csize);
  1107. mSvgElements[i].setAttribute('fill', '#FF0000'+getTransperecy(i) );
  1108. } else {
  1109. mSvgElements[i].setAttribute('fill', '#FF000000');
  1110. };
  1111. };
  1112. };
  1113. } else
  1114. for( var i=0; i< max_grad_levels; i++ )
  1115. if( typeof mSvgElements[i] !== 'undefined') mSvgElements[i].setAttribute('fill', '#FF000000');
  1116. };
  1117. if( data.train != undefined ){
  1118. if( mon_platform_train != data.train.status ){
  1119. animateTrainOnPlatform( mon_platform_train, data.train.status );
  1120. mon_platform_train = data.train.status;
  1121. };
  1122. };
  1123. break;
  1124. };
  1125. case 3:{ // Track
  1126. if( data.active_session_id != undefined ){
  1127. if( data.active_session_id > 0 ){
  1128. if( mon_selectedEventId != data.active_session_id ){
  1129. mon_selectedEventId = data.active_session_id;
  1130. monitoringActiveSession = true;
  1131. for( var zz=0; zz< activeEvents.length; zz++ ){
  1132. var tP = document.getElementById('event_tag_'+activeEvents[zz].id );
  1133. if( tP != undefined ){
  1134. tP.className ='';
  1135. if( activeEvents[zz].id == mon_selectedEventId ){
  1136. tP.classList.add("evt_side_tag_selected");
  1137. } else {
  1138. tP.classList.add("evt_side_tag");
  1139. };
  1140. };
  1141. };
  1142. addSetSessionUI( mon_selectedEventId );
  1143. tt=document.getElementById('trx_status_txt');
  1144. tt.classList.remove('static_status_text');
  1145. tt.classList.add('blinking_status_text');
  1146. tt.innerText = 'ACTIVE';
  1147. tt=document.getElementById('trx_status_cell');
  1148. tt.classList.remove('top_status_hidden');
  1149. tt.classList.remove('top_status_green_lbl');
  1150. tt.classList.add('top_status_red_lbl');
  1151. };
  1152. } else {
  1153. if( mon_selectedEventId ){
  1154. var d = true;
  1155. for( var zz=activeEvents.length-1; zz> -1; zz-- ){
  1156. if( activeEvents[zz].id != mon_selectedEventId ){
  1157. selectEvent( activeEvents[zz].id, false );
  1158. d = false;
  1159. break;
  1160. };
  1161. };
  1162. if( d ){
  1163. mon_selectedEventId = 0;
  1164. monitoringActiveSession = false;
  1165. tt=document.getElementById('trx_status_txt');
  1166. tt.classList.remove('blinking_status_text');
  1167. tt.classList.add('static_status_text');
  1168. tt.innerText = 'LIVE VEW';
  1169. tt=document.getElementById('trx_status_cell');
  1170. tt.classList.remove('top_status_hidden');
  1171. tt.classList.remove('top_status_red_lbl');
  1172. tt.classList.add('top_status_green_lbl');
  1173. var tv = Ext.getCmp('trx_view');
  1174. if( tv != undefined ){
  1175. var tt = Ext.getCmp('sets_ui');
  1176. if( tt != undefined ){
  1177. tv.remove( tt );
  1178. };
  1179. tv.doLayout();
  1180. };
  1181. for( var i=0; i< max_grad_levels; i++ )
  1182. if( typeof mSvgElements[i] !== 'undefined') mSvgElements[i].setAttribute('fill', '#FF000000');
  1183. };
  1184. };
  1185. };
  1186. };
  1187. if( data.modules != undefined ){
  1188. for( var i=0; i< data.modules.length; i++){
  1189. if( data.modules[i].status > 0 ){
  1190. var tt = document.getElementById('plat_video_img_'+data.modules[i].id );
  1191. if( tt != undefined ){
  1192. if( tt.src != data.modules[i].img ) tt.src = data.modules[i].img;
  1193. };
  1194. //tt = document.getElementById('plat_status_'+mon_selectedPlatform+'_'+data.modules[i].id );
  1195. tt = document.getElementById('cam_ctrl_'+data.modules[i].id );
  1196. if( tt != undefined ){
  1197. if( data.modules[i].status > 1 ) {
  1198. if( tt.style.display != 'block' )tt.style.display = 'block';
  1199. } else {
  1200. if( tt.style.display != 'none' )tt.style.display = 'none';
  1201. };
  1202. };
  1203. };
  1204. };
  1205. };
  1206. if( data.events != undefined ){
  1207. var sid = data.events.length - 1;
  1208. if( sid > -1 ){
  1209. for( var i=0; i< max_grad_levels; i++ ){
  1210. var cid = sid-i;
  1211. var csize = getSize( i );
  1212. //debugger;
  1213. if( typeof mSvgElements[i] === 'undefined') {
  1214. if( cid > -1 ){
  1215. var svgns = "http://www.w3.org/2000/svg";
  1216. mSvgElements[i] = document.createElementNS(svgns, 'rect');
  1217. mSvgElements[i].setAttribute('x', data.events[cid].x+'%');
  1218. mSvgElements[i].setAttribute('y', ''+(50+(100-csize)/2) );
  1219. mSvgElements[i].setAttribute('height', ''+csize);
  1220. mSvgElements[i].setAttribute('width', ''+csize);
  1221. mSvgElements[i].setAttribute('fill', '#FF0000'+getTransperecy(i));
  1222. var tt = document.getElementById('svgTrackMap');
  1223. var zz = document.getElementById('scheme_anch');
  1224. tt.insertBefore( mSvgElements[i], zz );
  1225. //document.getElementById('svgTrackMap').appendChild(this.mSvgElements[i]);
  1226. };
  1227. } else {
  1228. if( cid > -1 ){
  1229. mSvgElements[i].setAttribute('x', data.events[cid].x+'%');
  1230. mSvgElements[i].setAttribute('y', ''+(50+(100-csize)/2) );
  1231. mSvgElements[i].setAttribute('height', ''+csize);
  1232. mSvgElements[i].setAttribute('width', ''+csize);
  1233. mSvgElements[i].setAttribute('fill', '#FF0000'+getTransperecy(i) );
  1234. } else {
  1235. mSvgElements[i].setAttribute('fill', '#FF000000');
  1236. };
  1237. };
  1238. };
  1239. } else
  1240. for( var i=0; i< max_grad_levels; i++ )
  1241. if( typeof mSvgElements[i] !== 'undefined') mSvgElements[i].setAttribute('fill', '#FF000000');
  1242. };
  1243. if( data.scada != undefined ){
  1244. };
  1245. break;
  1246. };
  1247. };
  1248. manageSideTags('sme_inner', data.actual );
  1249. manageSideTags('sme_outer', data.expired );
  1250. };
  1251. };
  1252. tlInterval = window.setTimeout( fetchStatus, 333, selectedSite );
  1253. },
  1254. failure: failureAJAXFunction
  1255. });
  1256. };
  1257. function selectEvent( ii, bb ){
  1258. mon_selectedEventId = ii;
  1259. if( tlInterval!= null ){
  1260. window.clearTimeout( tlInterval );
  1261. tlInterval = null;
  1262. };
  1263. if( bb ){
  1264. for( var zz=0; zz< expiredEvents.length; zz++ ){
  1265. var tP = document.getElementById('event_tag_'+expiredEvents[zz].id );
  1266. if( tP != undefined ){
  1267. tP.className ='';
  1268. if( expiredEvents[zz].id == mon_selectedEventId ){
  1269. monitoringActiveSession = false;
  1270. tP.classList.add("evt_side_tag_selected");
  1271. } else {
  1272. tP.classList.add("evt_side_tag");
  1273. };
  1274. };
  1275. };
  1276. loadMonitoringSessionView( ii );
  1277. } else {
  1278. for( var zz=0; zz< activeEvents.length; zz++ ){
  1279. var tP = document.getElementById('event_tag_'+activeEvents[zz].id );
  1280. if( tP != undefined ){
  1281. tP.className ='';
  1282. if( activeEvents[zz].id == mon_selectedEventId ){
  1283. monitoringActiveSession = true;
  1284. tP.classList.add("evt_side_tag_selected");
  1285. } else {
  1286. tP.classList.add("evt_side_tag");
  1287. };
  1288. };
  1289. };
  1290. loadTrackViewBySession( ii );
  1291. };
  1292. };
  1293. function setSessionStatus( a , b, autoremove ){
  1294. Ext.Ajax.request({
  1295. url: '/lib/controller/doSessionOperations.php',
  1296. params: {
  1297. SESSION: a,
  1298. OPID: 2,
  1299. OPAR: b,
  1300. UID: <?=$UserID;?>,
  1301. SID: '<?=$Session;?>'
  1302. },
  1303. success: function( response, opts ){
  1304. var data = Ext.decode(response.responseText);
  1305. if( data.status == 'ok' ){
  1306. if( autoremove ){
  1307. //On Expired
  1308. var d = true;
  1309. for( var zz=expiredEvents.length-1; zz> -1; zz-- ){
  1310. if( expiredEvents[zz].id != mon_selectedEventId ){
  1311. selectEvent( expiredEvents[zz].id, true );
  1312. d = false;
  1313. break;
  1314. };
  1315. };
  1316. if( d ){
  1317. loadMapView();
  1318. autoRiseEvent = true;
  1319. var tt = Ext.getCmp('aer_button');
  1320. if( tt != undefined ) tt.toggle( true, true );
  1321. };
  1322. } else {
  1323. // On LiveSession
  1324. var tv = Ext.getCmp('trx_view');
  1325. if( tv != undefined ){
  1326. var tt = Ext.getCmp('sets_ui');
  1327. if( tt != undefined ){
  1328. tv.remove( tt );
  1329. };
  1330. tv.add( Ext.decode( data.content ) );
  1331. tv.doLayout();
  1332. };
  1333. };
  1334. };
  1335. },
  1336. failure: failureAJAXFunction
  1337. });
  1338. };
  1339. function unselectEvent( ii ){
  1340. mon_selectedEventId = 0;
  1341. for( var zz=0; zz< activeEvents.length; zz++ ){
  1342. var tP = document.getElementById('event_tag_'+activeEvents[zz].id );
  1343. if( tP != undefined ){
  1344. tP.className ='';
  1345. tP.classList.add("evt_side_tag");
  1346. };
  1347. };
  1348. for( var zz=0; zz< expiredEvents.length; zz++ ){
  1349. var tP = document.getElementById('event_tag_'+expiredEvents[zz].id );
  1350. if( tP != undefined ){
  1351. tP.className ='';
  1352. tP.classList.add("evt_side_tag");
  1353. };
  1354. };
  1355. };
  1356. function loadMonitoringSessionView( session_id ){
  1357. autoRiseEvent = false;
  1358. mon_selectedEventId = session_id;
  1359. changeContent( 1, 5, mon_selectedEventId );
  1360. updateUserContent();
  1361. Ext.Ajax.request({
  1362. url: '/lib/controller/getMonitoringSessionView.php',
  1363. params: {
  1364. SESSION: mon_selectedEventId,
  1365. UID: <?=$UserID;?>,
  1366. SID: '<?=$Session;?>'
  1367. },
  1368. success: function( response, opts ){
  1369. var data = Ext.decode(response.responseText);
  1370. if( data.status == 'ok' ){
  1371. monitoringViewLevel = 5;
  1372. if( mSesPlay!= null ) {
  1373. mSesPlay.dispose();
  1374. mSesPlay = null;
  1375. };
  1376. Ext.getCmp('main_content').removeAll(true);
  1377. Ext.getCmp('main_content').add( Ext.decode( data.content ) );
  1378. Ext.getCmp('main_content').doLayout();
  1379. tt=document.getElementById('trx_status_txt');
  1380. //tt.classList.remove('static_status_text');
  1381. //tt.classList.add('blinking_status_text');
  1382. tt.innerText = 'EXPIRED';
  1383. tt=document.getElementById('trx_status_cell');
  1384. tt.classList.remove('top_status_hidden');
  1385. tt.classList.remove('top_status_red_lbl');
  1386. tt.classList.remove('top_status_green_lbl');
  1387. tt.classList.add('top_status_orange_lbl');
  1388. mSesPlay = new argusSessionPlayer( mon_selectedEventId );
  1389. mSesPlay.play();
  1390. fetchStatus();
  1391. };
  1392. },
  1393. failure: failureAJAXFunction
  1394. });
  1395. };