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.

1574 lines
42 KiB

6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
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
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. //<?php require_once('../../js_asm.php'); ?>
  2. var UartListStore = new Ext.data.JsonStore({
  3. root: 'ports',
  4. totalProperty: 'totalCount',
  5. idProperty: 'uart_id',
  6. remoteSort: false,
  7. baseParams: {
  8. UID: '<?=$CUser->Data['id'];?>',
  9. SID: '<?=$Session;?>',
  10. SITE: <?=$SiteID;?>
  11. },
  12. fields: [{
  13. name: 'uart_id',
  14. type: 'int'
  15. },{
  16. name: 'uart_name',
  17. type: 'string'
  18. }],
  19. proxy : new Ext.data.HttpProxy({
  20. method: 'POST',
  21. prettyUrls: false,
  22. url: '/lib/controller/listUarts.php'
  23. })
  24. });
  25. var ServerListStore = new Ext.data.JsonStore({
  26. root: 'servers',
  27. totalProperty: 'totalCount',
  28. idProperty: 'server_id',
  29. remoteSort: false,
  30. baseParams: {
  31. UID: '<?=$CUser->Data['id'];?>',
  32. SID: '<?=$Session;?>',
  33. SITE: <?=$SiteID;?>
  34. },
  35. fields: [{
  36. name: 'server_id',
  37. type: 'int'
  38. },{
  39. name: 'server_name',
  40. type: 'string'
  41. }],
  42. proxy : new Ext.data.HttpProxy({
  43. method: 'POST',
  44. prettyUrls: false,
  45. url: '/lib/controller/listServers.php'
  46. })
  47. });
  48. function loadSettingsLidar3D( NodeID, Master ){
  49. SelectedNodeID = NodeID;
  50. Ext.Ajax.request({
  51. url: '/lib/controller/getSettingsLidsr3D.php',
  52. params: {
  53. NID: NodeID,
  54. MST: ((Master)?1:0),
  55. UID: <?=$UserID;?>,
  56. SID: '<?=$Session;?>',
  57. },
  58. success: function( response, opts ){
  59. // If the response is JSON, you have to decode it
  60. var data = Ext.decode(response.responseText);
  61. Ext.getCmp('setting_master_ip').setValue( data.ip_address );
  62. Ext.getCmp('setting_master_port').setValue( data.port );
  63. Ext.getCmp('setting_slave_ip').setValue( data.aux_ip_address );
  64. Ext.getCmp('setting_slave_port').setValue( data.aux_port );
  65. Ext.getCmp('setting_lat').setValue( data.lat );
  66. Ext.getCmp('setting_lon').setValue( data.lon );
  67. Ext.getCmp('setting_alt').setValue( data.alt );
  68. Ext.getCmp('setting_roll').setValue( data.roll );
  69. Ext.getCmp('setting_pitch').setValue( data.pitch );
  70. Ext.getCmp('setting_yaw').setValue( data.yaw );
  71. },
  72. failure: failureAJAXFunction
  73. });
  74. };
  75. function saveSettingsLidar3D( ){
  76. if( SelectedNodeID == 0 ) return;
  77. t1 = Ext.getCmp('setting_master_ip').getValue();
  78. t2 = Ext.getCmp('setting_master_port').getValue();
  79. t3 = Ext.getCmp('setting_slave_ip').getValue();
  80. t4 = Ext.getCmp('setting_slave_port').getValue();
  81. t5 = Ext.getCmp('setting_lat').getValue();
  82. t6 = Ext.getCmp('setting_lon').getValue();
  83. t7 = Ext.getCmp('setting_alt').getValue();
  84. t8 = Ext.getCmp('setting_roll').getValue();
  85. t9 = Ext.getCmp('setting_pitch').getValue();
  86. t10 = Ext.getCmp('setting_yaw').getValue();
  87. Ext.Ajax.request({
  88. url: '/lib/controller/setSettingsLidsr3D.php',
  89. params: {
  90. NID: SelectedNodeID,
  91. UID: <?=$UserID;?>,
  92. SID: '<?=$Session;?>',
  93. MIP: t1,
  94. MPP: t2,
  95. SIP: t3,
  96. SPP: t4,
  97. LAT: t5,
  98. LON: t6,
  99. ALT: t7,
  100. ROL: t8,
  101. PCH: t9,
  102. YAW: t10
  103. },
  104. success: function( response, opts ){
  105. // If the response is JSON, you have to decode it
  106. var data = Ext.decode(response.responseText);
  107. if( data.success == true ) {
  108. Ext.Msg.show({
  109. title:'<?=$Labels->GetLabel("_INFO_MSG_");?>',
  110. msg: '<?=$Labels->GetLabel("_SETTING_SAVE_OK_");?>',
  111. buttons: Ext.Msg.OK,//YESNOCANCEL,
  112. fn: function(){
  113. SettingsLidar3D.hide();
  114. },
  115. //animEl: 'elId',
  116. icon: Ext.MessageBox.INFO //QUESTION
  117. });
  118. } else {
  119. Ext.Msg.show({
  120. title:'<?=$Labels->GetLabel("_ERROR_MSG_");?>',
  121. msg: data['error'],
  122. buttons: Ext.Msg.OK,//YESNOCANCEL,
  123. fn: function(){
  124. SettingsLidar3D.hide();
  125. },
  126. //animEl: 'elId',
  127. icon: Ext.MessageBox.ERROR //QUESTION
  128. });
  129. };
  130. },
  131. failure: failureAJAXFunction
  132. });
  133. };
  134. function editSettingsLidar3D( NodeID, Master ){
  135. if( SettingsLidar3D == null ){
  136. SettingsLidar3D = new Ext.Window({
  137. modal: true,
  138. title: '<?=$Labels->GetLabel("_EDIT_LRF3D_SETTINGS_");?>',
  139. width: 773,
  140. height: 600,
  141. layout: 'fit',
  142. closeAction: 'hide',
  143. listeners:{
  144. beforehide : function(){
  145. Ext.getCmp('connectstarterbutton').toggle( false, false );
  146. }
  147. },
  148. items:[{
  149. layout: 'table',
  150. border: false,
  151. defaults: {
  152. // applied to each contained panel
  153. bodyStyle:'padding-top:10px;padding-left:20px;padding-right:20px;padding-bottom:10px;'
  154. },
  155. layoutConfig: {
  156. // The total column count must be specified here
  157. columns: 4
  158. },
  159. items: [{
  160. border: false,
  161. html: 'Master IP Address:'
  162. },{
  163. xtype: 'textfield',
  164. id: 'setting_master_ip',
  165. width: '70%'
  166. },{
  167. border: false,
  168. html: 'Port:'
  169. },{
  170. xtype: 'textfield',
  171. id: 'setting_master_port',
  172. width: '30%'
  173. },{
  174. border: false,
  175. html: 'Slave IP Address:'
  176. },{
  177. xtype: 'textfield',
  178. id: 'setting_slave_ip',
  179. width: '70%'
  180. },{
  181. border: false,
  182. html: 'Port:'
  183. },{
  184. xtype: 'textfield',
  185. id: 'setting_slave_port',
  186. width: '30%'
  187. },{
  188. border: false,
  189. html: 'Position Lat/Lon/Alt:'
  190. },{
  191. xtype: 'textfield',
  192. id: 'setting_lat',
  193. width: '30%'
  194. },{
  195. xtype: 'textfield',
  196. id: 'setting_lon',
  197. width: '30%'
  198. },{
  199. xtype: 'textfield',
  200. id: 'setting_alt',
  201. width: '30%'
  202. },{
  203. border: false,
  204. html: 'Orientation Roll/Pitch/Yaw:'
  205. },{
  206. xtype: 'textfield',
  207. id: 'setting_roll',
  208. width: '30%'
  209. },{
  210. xtype: 'textfield',
  211. id: 'setting_pitch',
  212. width: '30%'
  213. },{
  214. xtype: 'textfield',
  215. id: 'setting_yaw',
  216. width: '30%'
  217. }]
  218. }],
  219. bbar: [{
  220. text: '<?=$Labels->GetLabel("_CANCEL_");?>',
  221. handler: function(){
  222. SettingsLidar3D.hide();
  223. }
  224. },{
  225. text: '<?=$Labels->GetLabel("_SAVE_");?>',
  226. handler: SaveSettingsLidar3D
  227. }]
  228. });
  229. };
  230. SettingsLidar3D.show();
  231. loadSettingsLidar3D( NodeID, Master );
  232. };
  233. var devicesStore = new Ext.data.JsonStore({
  234. root: 'nodes',
  235. totalProperty: 'totalCount',
  236. idProperty: 'id',
  237. remoteSort: true,
  238. fields: [{
  239. name: 'id',
  240. type: 'int'
  241. },{
  242. name: 'name',
  243. type: 'string'
  244. },{
  245. name: 'hardware',
  246. type: 'string'
  247. },{
  248. name: 'caps',
  249. type: 'int'
  250. },{
  251. name: 'ip',
  252. type: 'string'
  253. },{
  254. name: 'mac',
  255. type: 'string'
  256. }],
  257. proxy : new Ext.data.HttpProxy({
  258. method: 'POST',
  259. prettyUrls: false,
  260. url: '/lib/controller/listDiscoveredCameraSources.php',
  261. headers: {
  262. 'UID': '<?=$CUser->Data['id'];?>',
  263. 'SID': '<?=$Session;?>'
  264. }
  265. })
  266. });
  267. var LRF1D2_st_win = null;
  268. var LRF2D2_st_win = null;
  269. var LRF16D3_st_win = null;
  270. var currentDeviceOperatioId = 0;
  271. var currentOperationTO = 0;
  272. var currentOperationTimer = null;
  273. var lastOperationCode = 0;
  274. function checkDeviceOperationStatus(){
  275. if( currentOperationTO ){
  276. currentOperationTO--;
  277. Ext.Ajax.request({
  278. url: '/lib/controller/checkDeviceOperation.php',
  279. params: {
  280. OID: currentDeviceOperatioId,
  281. UID: '<?=$CUser->Data['id'];?>',
  282. SID: '<?=$Session;?>'
  283. },
  284. success: function( response, opts ){
  285. var data = Ext.decode(response.responseText);
  286. if( !data.success ){
  287. Ext.MessageBox.hide();
  288. Ext.Msg.show({
  289. title:'Node Command Status',
  290. msg: data.msg,
  291. buttons: Ext.Msg.OK,
  292. icon: Ext.MessageBox.ERROR
  293. });
  294. } else {
  295. if( lastOperationCode != data.code || data.code == 0 ){
  296. lastOperationCode = data.code;
  297. currentOperationTO = 20;
  298. };
  299. if( data.code < 100 ){
  300. currentOperationTimer = window.setTimeout( checkDeviceOperationStatus, 100 );
  301. } else {
  302. Ext.MessageBox.hide();
  303. switch( data.code ){
  304. case 120:
  305. case 100:
  306. default:
  307. Ext.Msg.show({
  308. title:'Node Command Status',
  309. msg: 'Operation Complete',
  310. buttons: Ext.Msg.OK,
  311. icon: Ext.MessageBox.INFO
  312. });
  313. };
  314. };
  315. };
  316. },
  317. failure: failureAJAXFunction
  318. });
  319. } else {
  320. Ext.MessageBox.hide();
  321. Ext.Msg.show({
  322. title:'Node Command Status',
  323. msg: 'Operation Status - Time Out!',
  324. buttons: Ext.Msg.OK,
  325. icon: Ext.MessageBox.ERROR
  326. });
  327. };
  328. };
  329. function doDeviceOperation( NodeID, OpCode, Param='', nowait=false ){
  330. if( !nowait ){
  331. Ext.MessageBox.wait("<?=$Labels->GetLabel('_Loading_Calo_');?>","<?=$Labels->GetLabel('_Please_Wait_');?>",{
  332. width: '100%',
  333. hidden: true,
  334. progress: true,
  335. closable: false
  336. });
  337. };
  338. Ext.Ajax.request({
  339. url: '/lib/controller/doDeviceOperation.php',
  340. params: {
  341. NID: NodeID,
  342. UID: '<?=$CUser->Data['id'];?>',
  343. CMD: OpCode,
  344. SID: '<?=$Session;?>',
  345. PARAM: Param
  346. },
  347. success: function( response, opts ){
  348. var data = Ext.decode(response.responseText);
  349. if( !data.success ){
  350. if( !nowait ) Ext.MessageBox.hide();
  351. Ext.Msg.show({
  352. title:'Node Command Status',
  353. msg: data.msg,
  354. buttons: Ext.Msg.OK,
  355. icon: Ext.MessageBox.ERROR
  356. });
  357. } else {
  358. if( !nowait ){
  359. currentDeviceOperatioId = data.operation_id;
  360. currentOperationTO = 20;
  361. lastOperationCode = 0;
  362. currentOperationTimer = window.setTimeout( checkDeviceOperationStatus, 100 );
  363. };
  364. };
  365. },
  366. failure: failureAJAXFunction
  367. });
  368. };
  369. function loadFullLRF1D2Data( NodeID ){
  370. if( LRF1D2_st_win == null ) return;
  371. Ext.Ajax.request({
  372. url: '/lib/controller/getSettingsLRF.php',
  373. params: {
  374. NID: NodeID,
  375. UID: '<?=$CUser->Data['id'];?>',
  376. SID: '<?=$Session;?>',
  377. },
  378. success: function( response, opts ){
  379. if( LRF1D2_st_win!= null ){
  380. var data = Ext.decode(response.responseText);
  381. if( data.online ){
  382. switch( data.data_status ){
  383. case 0: Ext.getCmp('dev_online').update('<p class="green_status">ONLINE/Data Incomplete</p>'); break;
  384. case 1: Ext.getCmp('dev_online').update('<p class="green_status">ONLINE/Synced</p>'); break;
  385. case 2: Ext.getCmp('dev_online').update('<p class="green_status">ONLINE/Data Not Applyed</p>'); break;
  386. };
  387. } else {
  388. switch( data.data_status ){
  389. case 0: Ext.getCmp('dev_online').update('<p class="blue_status">OFFLINE/Data Incomplete</p>'); break;
  390. case 1: Ext.getCmp('dev_online').update('<p class="blue_status">OFFLINE/Synced</p>'); break;
  391. case 2: Ext.getCmp('dev_online').update('<p class="blue_status">OFFLINE/Data Not Applyed</p>'); break;
  392. };
  393. };
  394. Ext.getCmp('dev_name').setValue( data.name );
  395. Ext.getCmp('serial_num').setValue( data.serial );
  396. Ext.getCmp('version_id').setValue( data.version );
  397. Ext.getCmp('device_id').setValue( data.device_id );
  398. Ext.getCmp('com_spd').setValue( data.com_spd );
  399. Ext.getCmp('max_range').setValue( data.max_range );
  400. Ext.getCmp('base_shift').setValue( data.base_shift );
  401. Ext.getCmp('com_spd').setValue( data.uart_speed );
  402. Ext.getCmp('mlrf_offset').setValue( data.m_offset );
  403. Ext.getCmp('slrf_offset').setValue( data.s_offset );
  404. Ext.getCmp('mlrf_delta').setValue( data.m_delta );
  405. Ext.getCmp('slrf_delta').setValue( data.s_delta );
  406. Ext.getCmp('mlrf_width').setValue( data.m_width );
  407. Ext.getCmp('slrf_width').setValue( data.s_width );
  408. Ext.getCmp('mlrf_order').setValue( data.m_order );
  409. Ext.getCmp('slrf_order').setValue( data.s_order );
  410. Ext.getCmp('mlrf_sst').setValue( data.m_sst );
  411. Ext.getCmp('slrf_sst').setValue( data.s_sst );
  412. Ext.getCmp('mlrf_flip').setValue( data.m_flip );
  413. Ext.getCmp('slrf_flip').setValue( data.s_flip );
  414. Ext.getCmp('mlrf_sun').setValue( data.m_sun );
  415. Ext.getCmp('slrf_sun').setValue( data.s_sun );
  416. };
  417. },
  418. failure: failureAJAXFunction
  419. });
  420. };
  421. function LRF1D2_settings(){
  422. if( LRF1D2_st_win == null ){
  423. LRF1D2_st_win = new Ext.Window({
  424. title: 'Sensor Settings',
  425. modal: true,
  426. width: 800,
  427. height: 600,
  428. closeAction: 'hide',
  429. items:{
  430. xtype: 'tabpanel',
  431. activeTab: 0,
  432. items:[{
  433. title: 'General Settings',
  434. xtype: 'form',
  435. layout: 'table',
  436. defaults: {
  437. bodyStyle:'padding:20px'
  438. },
  439. layoutConfig: {
  440. columns: 3
  441. },
  442. items:[{
  443. html: 'Status',
  444. frame: false,
  445. border: false
  446. },{
  447. html: '<p class="green_status">ONLINE</p>',
  448. id: 'dev_online',
  449. frame: false,
  450. border: false
  451. },{},{
  452. html: 'Device Title',
  453. frame: false,
  454. border: false
  455. },{
  456. xtype: 'field',
  457. id: 'dev_name',
  458. readOnly: false,
  459. value: 'KOKO'
  460. },{},{
  461. html: 'Serial Number',
  462. frame: false,
  463. border: false
  464. },{
  465. xtype: 'field',
  466. id: 'serial_num',
  467. readOnly: true,
  468. value: '1212'
  469. },{},{
  470. html: 'Version ID',
  471. frame: false,
  472. border: false
  473. },{
  474. xtype: 'field',
  475. id: 'version_id',
  476. readOnly: true,
  477. value: 'LiberManDA122'
  478. },{},{
  479. html: 'Device Adress',
  480. frame: false,
  481. border: false
  482. },{
  483. xtype: 'numberfield',
  484. id: 'device_id'
  485. },{
  486. xtype: 'button',
  487. id: 'upddiBTN',
  488. text: 'Update Device Address',
  489. handler: function(){
  490. Ext.Msg.show({
  491. title:'Update Device Address?',
  492. msg: 'Are you sure to do so?',
  493. buttons: Ext.Msg.YESNOCANCEL,
  494. //fn: processResult,
  495. animEl: 'upddiBTN',
  496. icon: Ext.MessageBox.QUESTION
  497. });
  498. }
  499. },{
  500. html: 'Device COM Speed',
  501. frame: false,
  502. border: false
  503. },{
  504. xtype: 'combo',
  505. id: 'com_spd',
  506. editable: false,
  507. typeAhead: true,
  508. triggerAction: 'all',
  509. width: '100%',
  510. lazyRender:true,
  511. mode: 'local',
  512. store: new Ext.data.ArrayStore({
  513. id: 0,
  514. fields: ['mySPD', 'displayText' ],
  515. data: [[4800,'4800'],[9600,'9600'],[14400,'14400'],[19200,'19200'],[38400, '38400'],[56000,'56000'],[57600,'57600'],[115200,'115200']]
  516. }),
  517. valueField: 'mySPD',
  518. displayField: 'displayText'
  519. },{
  520. xtype: 'button',
  521. id: 'updspBTN',
  522. text: 'Set Device Speed',
  523. handler: function(){
  524. Ext.Msg.show({
  525. title:'Update Device Speed?',
  526. msg: 'Are you sure to do so?',
  527. buttons: Ext.Msg.YESNOCANCEL,
  528. //fn: processResult,
  529. animEl: 'upddiBTN',
  530. icon: Ext.MessageBox.QUESTION
  531. });
  532. }
  533. },{
  534. html: 'Detection Maximal Range',
  535. frame: false,
  536. border: false
  537. },{
  538. xtype: 'numberfield',
  539. id: 'max_range',
  540. readOnly: true,
  541. value: '1212'
  542. },{},{
  543. html: 'Base Shift',
  544. frame: false,
  545. border: false
  546. },{
  547. xtype: 'numberfield',
  548. id: 'base_shift',
  549. readOnly: true,
  550. value: '1212'
  551. },{}]
  552. },{
  553. title: 'Mantenence',
  554. xtype: 'form',
  555. layout: 'table',
  556. defaults: {
  557. bodyStyle:'padding:20px'
  558. },
  559. layoutConfig: {
  560. columns: 2
  561. },
  562. items:[{
  563. html: 'Restart Device',
  564. frame: false,
  565. border: false
  566. },{
  567. xtype: 'button',
  568. id: 'rstBTN',
  569. text: 'Full Reset',
  570. handler: function(){
  571. Ext.Msg.show({
  572. title:'Reset Device?',
  573. msg: 'You are closing a tab that has unsaved changes. Would you like to save your changes?',
  574. buttons: Ext.Msg.YESNOCANCEL,
  575. //fn: processResult,
  576. animEl: 'rstBTN',
  577. icon: Ext.MessageBox.QUESTION
  578. });
  579. }
  580. }]
  581. },{
  582. title: 'Detection Settings',
  583. xtype: 'form',
  584. layout: 'table',
  585. defaults: {
  586. bodyStyle:'padding:20px'
  587. },
  588. layoutConfig: {
  589. columns: 4
  590. },
  591. items:[{
  592. html: 'Master Offset',
  593. frame: false,
  594. border: false
  595. },{
  596. xtype: 'numberfield',
  597. id: 'mlrf_offset',
  598. name: 'mlrf_offset',
  599. allowBlank: false,
  600. allowDecimals: false,
  601. maxText: 'The Range is: 0 - 60',
  602. maxValue: 60,
  603. minText: 'No Negative Values Allowed',
  604. minValue: 0,
  605. },{
  606. html: 'Slave Offset',
  607. frame: false,
  608. border: false
  609. },{
  610. xtype: 'numberfield',
  611. id: 'slrf_offset',
  612. name: 'slrf_offset',
  613. allowBlank: false,
  614. allowDecimals: false,
  615. maxText: 'The Range is: 0 - 60',
  616. maxValue: 60,
  617. minText: 'No Negative Values Allowed',
  618. minValue: 0,
  619. },{
  620. html: 'Master Delta',
  621. frame: false,
  622. border: false
  623. },{
  624. xtype: 'numberfield',
  625. id: 'mlrf_delta',
  626. name: 'mlrf_delta',
  627. allowBlank: false,
  628. allowDecimals: false,
  629. maxText: 'The Range is: 0 - 320',
  630. maxValue: 320,
  631. minText: 'No Negative Values Allowed',
  632. minValue: 0
  633. },{
  634. html: 'Slave Delta',
  635. frame: false,
  636. border: false
  637. },{
  638. xtype: 'numberfield',
  639. id: 'slrf_delta',
  640. name: 'slrf_delta',
  641. allowBlank: false,
  642. allowDecimals: false,
  643. maxText: 'The Range is: 0 - 320',
  644. maxValue: 320,
  645. minText: 'No Negative Values Allowed',
  646. minValue: 0
  647. },{
  648. html: 'Master Width',
  649. frame: false,
  650. border: false
  651. },{
  652. xtype: 'numberfield',
  653. id: 'mlrf_width',
  654. name: 'mlrf_width',
  655. allowBlank: false,
  656. allowDecimals: false,
  657. maxText: 'The Range is: 1800 - 16000',
  658. maxValue: 16000,
  659. minText: 'The Range is: 1800 - 16000',
  660. minValue: 1800
  661. },{
  662. html: 'Slave Width',
  663. frame: false,
  664. border: false
  665. },{
  666. xtype: 'numberfield',
  667. id: 'slrf_width',
  668. name: 'slrf_width',
  669. allowBlank: false,
  670. allowDecimals: false,
  671. maxText: 'The Range is: 1800 - 16000',
  672. maxValue: 16000,
  673. minText: 'The Range is: 1800 - 16000',
  674. minValue: 1800
  675. },{
  676. html: 'Master Order',
  677. frame: false,
  678. border: false
  679. },{
  680. xtype: 'numberfield',
  681. id: 'mlrf_order',
  682. name: 'mlrf_order',
  683. allowBlank: false,
  684. allowDecimals: false,
  685. maxText: 'The Range is: 0 - 10',
  686. maxValue: 10,
  687. minText: 'No Negative Values Allowed',
  688. minValue: 0
  689. },{
  690. html: 'Slave Order',
  691. frame: false,
  692. border: false
  693. },{
  694. xtype: 'numberfield',
  695. id: 'slrf_order',
  696. name: 'slrf_order',
  697. allowBlank: false,
  698. allowDecimals: false,
  699. maxText: 'The Range is: 0 - 10',
  700. maxValue: 10,
  701. minText: 'No Negative Values Allowed',
  702. minValue: 0
  703. },{
  704. html: 'Master SST',
  705. frame: false,
  706. border: false
  707. },{
  708. xtype: 'numberfield',
  709. id: 'mlrf_sst',
  710. name: 'mlrf_sst',
  711. allowBlank: false,
  712. allowDecimals: false,
  713. maxText: 'The Range is: 0 - 100',
  714. maxValue: 100,
  715. minText: 'No Negative Values Allowed',
  716. minValue: 0
  717. },{
  718. html: 'Slave SST',
  719. frame: false,
  720. border: false
  721. },{
  722. xtype: 'numberfield',
  723. id: 'slrf_sst',
  724. name: 'slrf_sst',
  725. allowBlank: false,
  726. allowDecimals: false,
  727. maxText: 'The Range is: 0 - 100',
  728. maxValue: 100,
  729. minText: 'No Negative Values Allowed',
  730. minValue: 0
  731. },{
  732. html: 'Mastr Flip',
  733. frame: false,
  734. border: false
  735. },{
  736. xtype: 'numberfield',
  737. id: 'mlrf_flip',
  738. name: 'mlrf_flip',
  739. allowBlank: false,
  740. allowDecimals: false,
  741. maxText: 'The Range is: 8 - 128',
  742. maxValue: 128,
  743. minText: 'The Range is: 8 - 128',
  744. minValue: 8
  745. },{
  746. html: 'Slave Flip',
  747. frame: false,
  748. border: false
  749. },{
  750. xtype: 'numberfield',
  751. id: 'slrf_flip',
  752. name: 'slrf_flip',
  753. allowBlank: false,
  754. allowDecimals: false,
  755. maxText: 'The Range is: 8 - 128',
  756. maxValue: 128,
  757. minText: 'The Range is: 8 - 128',
  758. minValue: 8
  759. },{
  760. html: 'Master Sun',
  761. frame: false,
  762. border: false
  763. },{
  764. xtype: 'numberfield',
  765. id: 'mlrf_sun',
  766. name: 'mlrf_sun',
  767. allowBlank: false,
  768. allowDecimals: false,
  769. maxText: 'The Range is: 0 - 100',
  770. maxValue: 100,
  771. minText: 'No Negative Values Allowed',
  772. minValue: 0
  773. },{
  774. html: 'Slave Sun',
  775. frame: false,
  776. border: false
  777. },{
  778. xtype: 'numberfield',
  779. id: 'slrf_sun',
  780. name: 'slrf_sun',
  781. allowBlank: false,
  782. allowDecimals: false,
  783. maxText: 'The Range is: 0 - 100',
  784. maxValue: 100,
  785. minText: 'No Negative Values Allowed',
  786. minValue: 0
  787. }]
  788. },{
  789. title: 'Embed Options'
  790. },{
  791. title: 'Target Width Table'
  792. }]
  793. }
  794. });
  795. };
  796. LRF1D2_st_win.show();
  797. loadFullLRF1D2Data( SelectedNodeID );
  798. };
  799. function LRF2D2_settings(){
  800. };
  801. function LRF16D3_settings(){
  802. };
  803. var currentResolveDeviceNode = 0;
  804. var ResolveDeviceNodeWin = null;
  805. function resolveDeviceMistmatch( NodeID ){
  806. currentResolveDeviceNode = NodeID;
  807. if( ResolveDeviceNodeWin == null ){
  808. ResolveDeviceNodeWin = new Ext.Window({
  809. title: '<?=$Labels->GetLabel('_WDEV_MISTMATCH_');?>',
  810. modal: true,
  811. width: 500,
  812. height: 200,
  813. closeAction: 'hide',
  814. items:[{
  815. xtype: 'spacer',
  816. style: {
  817. marginTop: '13px'
  818. },
  819. html: '<center><?=$Labels->GetLabel('_DEV_MISTMATT1_');?></center>',
  820. height: 30
  821. },{
  822. xtype: 'button',
  823. width: '100%',
  824. text: 'It is Newly Connected Device',
  825. handler: function(){
  826. Ext.Ajax.request({
  827. url: '/lib/controller/validateNode.php',
  828. params: {
  829. NID: currentResolveDeviceNode,
  830. UID: '<?=$CUser->Data['id'];?>',
  831. SID: '<?=$Session;?>',
  832. MET: 1
  833. },
  834. success: function( response, opts ){
  835. ResolveDeviceNodeWin.hide();
  836. },
  837. failure: failureAJAXFunction
  838. });
  839. }
  840. },{
  841. xtype: 'button',
  842. width: '100%',
  843. text: 'Apply Existing Detection Profiles to Newly Connected Device',
  844. handler: function(){
  845. Ext.Ajax.request({
  846. url: '/lib/controller/validateNode.php',
  847. params: {
  848. NID: currentResolveDeviceNode,
  849. UID: '<?=$CUser->Data['id'];?>',
  850. SID: '<?=$Session;?>',
  851. MET: 1
  852. },
  853. success: function( response, opts ){
  854. ResolveDeviceNodeWin.hide();
  855. },
  856. failure: failureAJAXFunction
  857. });
  858. }
  859. },{
  860. xtype: 'button',
  861. width: '100%',
  862. text: 'Discard old Detection Profiles and Start Device Setup Wizard',
  863. handler: function(){
  864. ResolveDeviceNodeWin.hide();
  865. startDeviceDetectionWizard( currentResolveDeviceNode );
  866. }
  867. },{
  868. xtype: 'button',
  869. width: '100%',
  870. text: 'Discard old Detection Profiles and Load Factory Settings from Device'
  871. },{
  872. xtype: 'button',
  873. width: '100%',
  874. text: 'Discard this Connection for NOW'
  875. }]
  876. });
  877. };
  878. ResolveDeviceNodeWin.show();
  879. };
  880. var DeviceDetectionWizardWnd = null;
  881. var DDWizardActiveDevice = '';
  882. var RangeSetBlocker = false;
  883. function startDeviceDetectionWizard( NodeID ){
  884. DDWizardActiveDevice = NodeID
  885. if( DeviceDetectionWizardWnd == null ){
  886. DeviceDetectionWizardWnd = new Ext.Window({
  887. title: '<?=$Labels->GetLabel('_WDEV_DET_WIZT_');?>',
  888. modal: true,
  889. width: 500,
  890. height: 208,
  891. closeAction: 'hide',
  892. items:[{
  893. xtype: 'tabpanel',
  894. activeTab: 1,
  895. items: [{
  896. title: '<?=$Labels->GetLabel('_WDEV_DET_WIZ0_');?>',
  897. frame: false,
  898. xtype: 'form',
  899. items:[{
  900. xtype: 'spacer',
  901. height: 20
  902. },{
  903. xtype: 'combo',
  904. id: 'DDWizST',
  905. fieldLabel: '<?=$Labels->GetLabel('_DEV_TYPE_FLD_');?>',
  906. typeAhead: true,
  907. triggerAction: 'all',
  908. lazyRender:true,
  909. mode: 'local',
  910. store: new Ext.data.ArrayStore({
  911. id: 0,
  912. fields: [
  913. 'dtId',
  914. 'dtText'
  915. ],
  916. data: [
  917. [1, '<?=$Labels->GetLabel('_DEV_TYPE_ALS_');?>'],
  918. [2, '<?=$Labels->GetLabel('_DEV_TYPE_LFS_');?>'],
  919. [3, '<?=$Labels->GetLabel('_DEV_TYPE_PLS200_');?>'],
  920. [4, '<?=$Labels->GetLabel('_DEV_TYPE_PLS360_');?>'],
  921. [5, '<?=$Labels->GetLabel('_DEV_TYPE_3D_');?>'],
  922. [6, '<?=$Labels->GetLabel('_DEV_TYPE_NPLS200_');?>']
  923. ]
  924. }),
  925. valueField: 'dtId',
  926. displayField: 'dtText'
  927. },{
  928. xtype: 'numberfield',
  929. id: 'DDWizSR',
  930. fieldLabel: '<?=$Labels->GetLabel('_DEV_RANGE_FLD_');?>',
  931. minValue: 15.0,
  932. maxValue: 300.0,
  933. listeners:{
  934. change: function( m, nv, ov ){
  935. if( RangeSetBlocker ) return;
  936. RangeSetBlocker = true;
  937. Ext.getCmp('DDWizSRS').setValue( nv );
  938. RangeSetBlocker = false;
  939. }
  940. }
  941. },{
  942. xtype: 'slider',
  943. id: 'DDWizSRS',
  944. fieldLabel: '<?=$Labels->GetLabel('_DEV_RANGE_FLD_');?>',
  945. minValue: 15.0,
  946. maxValue: 300.0,
  947. listeners:{
  948. change: function( m, nv, ov ){
  949. if( RangeSetBlocker ) return;
  950. RangeSetBlocker = true;
  951. Ext.getCmp('DDWizSR').setValue( nv );
  952. RangeSetBlocker = false;
  953. }
  954. }
  955. },{
  956. xtype: 'spacer',
  957. height: 10
  958. }]
  959. },{
  960. title: '<?=$Labels->GetLabel('_WDEV_DET_WIZ1_');?>',
  961. frame: false,
  962. xtype: 'form',
  963. labelWidth: 120,
  964. items:[{
  965. xtype: 'spacer',
  966. height: 20
  967. },{
  968. xtype: 'combo',
  969. id: 'DDWizIT',
  970. fieldLabel: '<?=$Labels->GetLabel('_DEV_ITYPE_FLD_');?>',
  971. typeAhead: true,
  972. triggerAction: 'all',
  973. lazyRender:true,
  974. mode: 'local',
  975. value: 1,
  976. store: new Ext.data.ArrayStore({
  977. id: 0,
  978. fields: [
  979. 'dpId',
  980. 'dpText'
  981. ],
  982. data: [
  983. [1, '<?=$Labels->GetLabel('_DEV_PL_HORI_');?>'],
  984. [2, '<?=$Labels->GetLabel('_DEV_PL_VERT_');?>'],
  985. [3, '<?=$Labels->GetLabel('_DEV_PL_ANG_');?>']
  986. ]
  987. }),
  988. valueField: 'dpId',
  989. displayField: 'dpText'
  990. }]
  991. },{
  992. title: '<?=$Labels->GetLabel('_WDEV_DET_WIZ2_');?>',
  993. html: 'Another one'
  994. },{
  995. title: '<?=$Labels->GetLabel('_WDEV_DET_WIZ3_');?>',
  996. html: 'Another one'
  997. }]
  998. }],
  999. bbar:[{
  1000. text: 'Create Profiles And Finish',
  1001. handler: function(){
  1002. DeviceDetectionWizardWnd.hide();
  1003. }
  1004. },{
  1005. text: 'Advanced Config',
  1006. handler: function(){
  1007. DeviceDetectionWizardWnd.hide();
  1008. startAdvancedDeviceDetection( DDWizardActiveDevice );
  1009. }
  1010. }]
  1011. });
  1012. };
  1013. Ext.Ajax.request({
  1014. url: '/lib/controller/getNodeBasicNfo.php',
  1015. params: {
  1016. NID: DDWizardActiveDevice,
  1017. UID: '<?=$CUser->Data['id'];?>',
  1018. SID: '<?=$Session;?>'
  1019. },
  1020. success: function( response, opts ){
  1021. var data = Ext.decode(response.responseText);
  1022. DeviceDetectionWizardWnd.setTitle( '<?=$Labels->GetLabel('_WDEV_DET_WIZT_');?> [' + data.name+']' );
  1023. Ext.getCmp('DDWizST').setValue( data.type );
  1024. RangeSetBlocker = true;
  1025. Ext.getCmp('DDWizSR').setValue( data.range );
  1026. Ext.getCmp('DDWizSRS').setValue( data.range );
  1027. RangeSetBlocker = false;
  1028. DeviceDetectionWizardWnd.show();
  1029. },
  1030. failure: failureAJAXFunction
  1031. });
  1032. };
  1033. var DeviceDetectionAdvancedWnd = null;
  1034. var DeviceDetectionProfileNames = ['factory default', 'low sens', 'medium sens', 'high sens'];
  1035. function loadAdvancedDeviceDetectionSettings(){
  1036. Ext.getCmp('ADD_TP').removeAll( false );
  1037. Ext.Ajax.request({
  1038. url: '/lib/controller/getNodeAdvancedNfo.php',
  1039. params: {
  1040. NID: DDWizardActiveDevice,
  1041. UID: '<?=$CUser->Data['id'];?>',
  1042. SID: '<?=$Session;?>'
  1043. },
  1044. success: function( response, opts ){
  1045. var data = Ext.decode(response.responseText);
  1046. DeviceDetectionAdvancedWnd.setTitle( '<?=$Labels->GetLabel('_WDEV_DET_WIZT_');?> [' + data.name+']' );
  1047. if( data.profiles.length > 0 ){
  1048. if( data.profiles.length > 3 ) Ext.getCmp('ADD_PADD_BTN').disable();
  1049. switch( data.type ){
  1050. case 1:
  1051. case 5:{
  1052. for( i = 0; i < data.profiles.length / 2; i++){
  1053. };
  1054. break;
  1055. };
  1056. case 2:
  1057. case 3:
  1058. case 4:
  1059. case 6:{
  1060. for( i = 0; i < data.profiles.length; i++){
  1061. Ext.getCmp('ADD_TP').add({
  1062. title: DeviceDetectionProfileNames[ data.profiles[i].id ],
  1063. xtype: 'form',
  1064. frame: false,
  1065. items:[{xtype: 'spacer', height: 10 },{
  1066. xtype: 'numberfield',
  1067. id: 'OFFSET_P'+data.profiles[i].id,
  1068. fieldLabel: 'OFFSET',
  1069. minValue: 15.0,
  1070. maxValue: 300.0,
  1071. value: data.profiles[i].offset
  1072. },{
  1073. xtype: 'numberfield',
  1074. id: 'DELTA_P'+data.profiles[i].id,
  1075. fieldLabel: 'DELTA',
  1076. minValue: 15.0,
  1077. maxValue: 300.0,
  1078. value: data.profiles[i].delta
  1079. },{
  1080. xtype: 'numberfield',
  1081. id: 'WIDTH_P'+data.profiles[i].id,
  1082. fieldLabel: 'WIDTH',
  1083. minValue: 15.0,
  1084. maxValue: 300.0,
  1085. value: data.profiles[i].width
  1086. },{
  1087. xtype: 'numberfield',
  1088. id: 'SST_P'+data.profiles[i].id,
  1089. fieldLabel: 'SST',
  1090. minValue: 15.0,
  1091. maxValue: 300.0,
  1092. value: data.profiles[i].sst
  1093. },{
  1094. xtype: 'numberfield',
  1095. id: 'FLIP_P'+data.profiles[i].id,
  1096. fieldLabel: 'FLIP',
  1097. minValue: 15.0,
  1098. maxValue: 300.0,
  1099. value: data.profiles[i].flip
  1100. },{
  1101. xtype: 'numberfield',
  1102. id: 'SUN_P'+data.profiles[i].id,
  1103. fieldLabel: 'SUN',
  1104. minValue: 15.0,
  1105. maxValue: 300.0,
  1106. value: data.profiles[i].sun
  1107. }]
  1108. });
  1109. };
  1110. break;
  1111. };
  1112. };
  1113. //
  1114. } else {
  1115. Ext.getCmp('ADD_TP').add({
  1116. title: 'Error!',
  1117. html: 'No Profiles Defined'
  1118. });
  1119. };
  1120. DeviceDetectionAdvancedWnd.show();
  1121. },
  1122. failure: failureAJAXFunction
  1123. });
  1124. };
  1125. function startAdvancedDeviceDetection( NodeID ){
  1126. DDWizardActiveDevice = NodeID;
  1127. if( DeviceDetectionAdvancedWnd == null ){
  1128. DeviceDetectionAdvancedWnd = new Ext.Window({
  1129. title: '<?=$Labels->GetLabel('_WDEV_DET_WIZT_');?>',
  1130. modal: true,
  1131. width: 500,
  1132. height: 300,
  1133. closeAction: 'hide',
  1134. items:[{
  1135. xtype: 'tabpanel',
  1136. id: 'ADD_TP',
  1137. frame: false,
  1138. border: false,
  1139. activeTab: 0,
  1140. items: []
  1141. }],
  1142. bbar:[{
  1143. id: 'ADD_PADD_BTN',
  1144. text: 'Add Detection Profile',
  1145. handler: function(){
  1146. Ext.Ajax.request({
  1147. url: '/lib/controller/addDetectionProfile.php',
  1148. params: {
  1149. NID: DDWizardActiveDevice,
  1150. UID: '<?=$CUser->Data['id'];?>',
  1151. SID: '<?=$Session;?>'
  1152. },
  1153. success: function( response, opts ){
  1154. loadAdvancedDeviceDetectionSettings();
  1155. },
  1156. failure: failureAJAXFunction
  1157. });
  1158. }
  1159. },{
  1160. text: 'Apply And Finish'
  1161. },{
  1162. text: 'Use Wizard'
  1163. }]
  1164. });
  1165. };
  1166. loadAdvancedDeviceDetectionSettings();
  1167. };
  1168. var maskEditorDiv = null;
  1169. var MEPanel = null;
  1170. function handleFSMaskEditorClose( event ){
  1171. if ( document.fullscreenElement ||
  1172. document.webkitFullscreenElement ||
  1173. document.mozFullScreenElement ||
  1174. document.msFullscreenElement ){
  1175. } else {
  1176. MEPanel.destroy();
  1177. maskEditorDiv.remove();
  1178. maskEditorDiv = null;
  1179. MEPanel = null;
  1180. document.removeEventListener( 'fullscreenchange', handleFSMaskEditorClose );
  1181. };
  1182. };
  1183. function hideMaskEditor(){
  1184. if(
  1185. document.fullscreenElement ||
  1186. document.webkitFullscreenElement ||
  1187. document.mozFullScreenElement ||
  1188. document.msFullscreenElement
  1189. ){
  1190. if( document.exitFullscreen ){
  1191. document.exitFullscreen();
  1192. }else if( document.mozCancelFullScreen ){
  1193. document.mozCancelFullScreen();
  1194. }else if( document.webkitExitFullscreen ){
  1195. document.webkitExitFullscreen();
  1196. }else if( document.msExitFullscreen ){
  1197. document.msExitFullscreen();
  1198. };
  1199. // Removal Done by event!
  1200. //maskEditorDiv.remove();
  1201. //maskEditorDiv = null;
  1202. //document.removeEventListener( 'fullscreenchange', handleFSMaskEditorClose );
  1203. };
  1204. };
  1205. var values = {
  1206. paths: 50,
  1207. minPoints: 5,
  1208. maxPoints: 15,
  1209. minRadius: 30,
  1210. maxRadius: 90
  1211. };
  1212. var hitOptions = {
  1213. segments: true,
  1214. stroke: true,
  1215. fill: true,
  1216. tolerance: 10
  1217. };
  1218. var polycolors = new Array();
  1219. var polyindex = 0;
  1220. var poligones = new Array();
  1221. var segment = null;
  1222. var path = null;
  1223. var MaskProject = null;
  1224. var MaskEditorMode = 0;
  1225. function onMouseDown(event) {
  1226. segment = path = null;
  1227. var hitResult = MaskProject.hitTest( event.point, hitOptions );
  1228. if (!hitResult) return;
  1229. if( event.modifiers.shift ){
  1230. if (hitResult.type == 'segment') {
  1231. hitResult.segment.remove();
  1232. };
  1233. return;
  1234. };
  1235. if( hitResult ){
  1236. path = hitResult.item;
  1237. if( hitResult.type == 'segment' ){
  1238. segment = hitResult.segment;
  1239. path.fullySelected = false;
  1240. segment.selected = true;
  1241. } else if( hitResult.type == 'stroke' ){
  1242. var location = hitResult.location;
  1243. segment = path.insert(location.index + 1, event.point);
  1244. //path.smooth();
  1245. path.fullySelected = false;
  1246. segment.selected = true;
  1247. } else if ( hitResult.type == 'fill' ){
  1248. path.fullySelected = true;
  1249. };
  1250. }
  1251. //movePath = ;
  1252. //if( movePath ) MaskProject.activeLayer.addChild(hitResult.item);
  1253. }
  1254. function onMouseMove(event) {
  1255. MaskProject.activeLayer.selected = false;
  1256. if( event.item ) {
  1257. //event.item.selected = true;
  1258. event.item.fullySelected = true;
  1259. };
  1260. }
  1261. function onMouseDrag(event) {
  1262. if( segment ){
  1263. //segment.point += event.delta;
  1264. segment.point = event.point;
  1265. //path.smooth();
  1266. };
  1267. //else if (path) {
  1268. // path.position += event.delta;
  1269. //}
  1270. }
  1271. var absDrawMapSizes = [[2000,2000],[2304,288]];
  1272. var deviceMapScaling = 1.0;
  1273. var deviceMapTopShift = 100;
  1274. var deviceMapLeftShift = 100;
  1275. var cMapImageWidth = 0;
  1276. var cMapImageHeight = 0;
  1277. var cMapCanvasWidth = 0;
  1278. var cMapCanvasHeight = 0;
  1279. function showMaskEditor( fromDevTool, DevType, NodeID ){
  1280. //alert( "DevType: "+DevType + " Dev Map size: "+ absDrawMapSizes[DevType][0]+"x"+absDrawMapSizes[DevType][1] );
  1281. if( DevType == 1 ){
  1282. deviceMapScaling = ( window.screen.height * window.devicePixelRatio - 130 - ( deviceMapTopShift * 2 )) / absDrawMapSizes[DevType][1];
  1283. } else {
  1284. deviceMapScaling = ( window.screen.width * window.devicePixelRatio - 30 - ( deviceMapLeftShift * 2 )) / absDrawMapSizes[DevType][0];
  1285. };
  1286. cMapImageHeight = deviceMapScaling * absDrawMapSizes[DevType][1];
  1287. cMapImageWidth = deviceMapScaling * absDrawMapSizes[DevType][0];
  1288. cMapCanvasWidth = cMapImageWidth + (deviceMapLeftShift * 2);
  1289. cMapCanvasHeight = cMapImageHeight + (deviceMapTopShift * 2);
  1290. if( fromDevTool ){
  1291. detectionProfileWindow.hide();
  1292. };
  1293. if(
  1294. document.fullscreenElement ||
  1295. document.webkitFullscreenElement ||
  1296. document.mozFullScreenElement ||
  1297. document.msFullscreenElement
  1298. ){
  1299. //fs mode allready
  1300. hideMaskEditor();
  1301. }else{
  1302. if( maskEditorDiv == null ){
  1303. maskEditorDiv = document.createElement("div");
  1304. maskEditorDiv.style.height="200px";
  1305. maskEditorDiv.style.width="200px";
  1306. //maskEditorDiv.style.backgroundImage = "url('your_image.png')";
  1307. //append div as a child to body
  1308. document.body.appendChild( maskEditorDiv );
  1309. //var elem = document.createElement("img"); 'getDeviceMap.php?NID='+NodeID
  1310. //elem.setAttribute("src", "/lib/controller/data/device_draws/75c85fec4be204fc0bc0452f53b5a3df_map.png");
  1311. //elem.setAttribute("height", "80%");
  1312. //elem.setAttribute("width", "130");
  1313. //maskEditorDiv.appendChild( elem );
  1314. //alert( window.screen.width * window.devicePixelRatio + "x" + window.screen.height * window.devicePixelRatio);
  1315. if( MEPanel == null ){
  1316. var ww = window.screen.width * window.devicePixelRatio;
  1317. var hh = window.screen.height * window.devicePixelRatio;
  1318. MEPanel = new Ext.Panel( {
  1319. title: 'Mask Editor',
  1320. renderTo: maskEditorDiv,
  1321. width: ww,
  1322. height: hh,
  1323. frame: true,
  1324. autoScroll: true,
  1325. items:[{
  1326. xtype: 'panel',
  1327. width: cMapCanvasWidth,
  1328. html: '<div id=\'popomas\' style="display: block; width: '+cMapCanvasWidth+'px; height: '+cMapCanvasHeight+ 'px; background: orange; background-position-x: '+deviceMapLeftShift+'px; background-position-y: '+deviceMapTopShift+'px; background-size: '+cMapImageWidth+'px '+cMapImageHeight+'px; background-image: url(\'/lib/controller/getDeviceDraw.php?MAP=1&NID='+NodeID+'\'); background-repeat: no-repeat;"><canvas id="mask_canvas" width="'+cMapCanvasWidth+'px" height="'+cMapCanvasHeight+'px"></canvas></dvi>'
  1329. }],
  1330. tbar:[{
  1331. text:'New Polygone',
  1332. id: 'me_b_newp',
  1333. enableToggle: true,
  1334. toggleGroup: 'me_topbar_grp',
  1335. handler: function( btn ){
  1336. if( btn.pressed ) setMaskEditorMode( 0 );
  1337. }
  1338. },{
  1339. text:'Delete Polygone',
  1340. id: 'me_b_delp',
  1341. enableToggle: true,
  1342. toggleGroup: 'me_topbar_grp'
  1343. },{
  1344. text:'Delete Point',
  1345. id: 'me_b_delpo',
  1346. enableToggle: true,
  1347. toggleGroup: 'me_topbar_grp'
  1348. },{
  1349. text:'Clear Mask',
  1350. id: 'me_b_delm',
  1351. handler: function(){
  1352. if( MaskProject!= null ){
  1353. //alert( 'ClearMask' );
  1354. };
  1355. }
  1356. }],
  1357. buttons:[{
  1358. text: 'Cancel',
  1359. handler: function(){
  1360. hideMaskEditor();
  1361. }
  1362. },{
  1363. text:'Save Mask and Close',
  1364. handler: function(){
  1365. var serial = MaskProject.exportJSON();
  1366. Ext.Ajax.request({
  1367. url: '/lib/controller/uploadDeviceMask.php',
  1368. params: {
  1369. NID: NodeID,
  1370. UID: '<?=$CUser->Data['id'];?>',
  1371. SID: '<?=$Session;?>',
  1372. MID: 0,
  1373. LID: 0,
  1374. MDTA: serial,
  1375. MIH: cMapImageHeight,
  1376. MIW: cMapImageWidth,
  1377. //MSF: deviceMapScaling,
  1378. MSHX: deviceMapLeftShift,
  1379. MSHY: deviceMapTopShift
  1380. },
  1381. success: function( response, opts ){
  1382. var data = Ext.decode(response.responseText);
  1383. hideMaskEditor();
  1384. },
  1385. failure: failureAJAXFunction
  1386. });
  1387. }
  1388. }]
  1389. });
  1390. };
  1391. MEPanel.doLayout();
  1392. loadDeviceMask( NodeID );
  1393. };
  1394. //maskEditorDiv = $('#container').get(0);
  1395. //var maskEditorDiv = document.getElementById( id ); //Ext.getCmp( id );
  1396. if( maskEditorDiv.requestFullscreen ){
  1397. maskEditorDiv.requestFullscreen();
  1398. }else if( maskEditorDiv.mozRequestFullScreen ){
  1399. maskEditorDiv.mozRequestFullScreen();
  1400. }else if( maskEditorDiv.webkitRequestFullscreen ){
  1401. maskEditorDiv.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
  1402. }else if( maskEditorDiv.msRequestFullscreen ){
  1403. maskEditorDiv.msRequestFullscreen();
  1404. };
  1405. document.addEventListener( 'fullscreenchange', handleFSMaskEditorClose );
  1406. };
  1407. };
  1408. function setMaskEditorMode( nM ){
  1409. switch( nM ){
  1410. case 0:{
  1411. var MEP = Ext.getCmp('me_b_newp');
  1412. if( !MEP.pressed ) MEP.toggle( true );
  1413. var caca = document.getElementById('mask_canvas');
  1414. caca.style.cursor = 'crosshair';
  1415. break;
  1416. };
  1417. case 1:{
  1418. var MEP = Ext.getCmp('me_b_newp');
  1419. if( !MEP.pressed ) MEP.toggle( false );
  1420. MEP = Ext.getCmp('me_b_delp');
  1421. if( !MEP.pressed ) MEP.toggle( false );
  1422. MEP = Ext.getCmp('me_b_delpo');
  1423. if( !MEP.pressed ) MEP.toggle( false );
  1424. if( MaskProject!= null ){
  1425. if( MaskProject.isEmpty() ){
  1426. MEP = Ext.getCmp('me_b_delp');
  1427. MEP.disable();
  1428. MEP = Ext.getCmp('me_b_delpo');
  1429. MEP.disable();
  1430. MEP = Ext.getCmp('me_b_delm');
  1431. MEP.disable();
  1432. setMaskEditorMode( 0 );
  1433. } else {
  1434. MEP = Ext.getCmp('me_b_delp');
  1435. MEP.enable();
  1436. MEP = Ext.getCmp('me_b_delpo');
  1437. MEP.enable();
  1438. MEP = Ext.getCmp('me_b_delm');
  1439. MEP.enable();
  1440. };
  1441. };
  1442. var caca = document.getElementById('mask_canvas');
  1443. caca.style.cursor = 'default';
  1444. break;
  1445. };
  1446. case 2:{
  1447. var MEP = Ext.getCmp('me_b_delp');
  1448. if( !MEP.pressed ) MEP.toggle( true );
  1449. break;
  1450. };
  1451. case 3:{
  1452. var MEP = Ext.getCmp('me_b_delpo');
  1453. if( !MEP.pressed ) MEP.toggle( true );
  1454. break;
  1455. };
  1456. };
  1457. MaskEditorMode = nM;
  1458. };
  1459. function loadDeviceMask( NodeID, LrfID = 0, LayerID = 0 ){
  1460. Ext.Ajax.request({
  1461. url: '/lib/controller/getDeviceMask.php',
  1462. params: {
  1463. NID: NodeID,
  1464. UID: '<?=$CUser->Data['id'];?>',
  1465. SID: '<?=$Session;?>',
  1466. MID: LayerID,
  1467. LID: LrfID
  1468. },
  1469. success: function( response, opts ){
  1470. var data = Ext.decode(response.responseText);
  1471. var canvas = document.getElementById('mask_canvas');// Create an empty project and a view for the canvas:
  1472. //paper.setup( canvas );
  1473. paper.settings.handleSize = 10;
  1474. MaskProject = new paper.Project( canvas );
  1475. if( data.length > 0 ){
  1476. for( i = 0; i < data.length; i++ ){
  1477. var path = new paper.Path();
  1478. path.strokeColor = 'black';
  1479. //var lightness = (Math.random() - 0.5) * 0.4 + 0.4;
  1480. //var hue = Math.random() * 360;
  1481. //path.fillColor = { hue: hue, saturation: 1, lightness: lightness };
  1482. path.fillColor = data[i].colour;
  1483. path.closed = true;
  1484. path.opacity = 0.5;
  1485. //path.onMouseMove = onMouseMove;
  1486. path.onMouseDown = onMouseDown;
  1487. path.onMouseDrag = onMouseDrag;
  1488. //path.onMouseUp = function( event ){
  1489. // path.add(event.point);
  1490. //}
  1491. if( data[i].points.length > 2 ){
  1492. var tX = data[i].points[0][0] * deviceMapScaling + deviceMapLeftShift;
  1493. var tY = data[i].points[0][1] * deviceMapScaling + deviceMapTopShift;
  1494. path.moveTo( [tX,tY] );
  1495. for(k = 1; k < data[i].points.length; k++ ){
  1496. tX = data[i].points[k][0] * deviceMapScaling + deviceMapLeftShift;
  1497. tY = data[i].points[k][1] * deviceMapScaling + deviceMapTopShift;
  1498. path.lineTo( [tX,tY] );
  1499. };
  1500. path.fullySelected = true;
  1501. paper.view.draw();
  1502. };
  1503. poligones.push(path);
  1504. };
  1505. };
  1506. setMaskEditorMode( 1 ); // Observer
  1507. canvas.addEventListener( 'mousemove', onMaskMouseMove );
  1508. canvas.addEventListener( 'mousedown', onMaskMouseDown );
  1509. canvas.addEventListener( 'mouseup', onMaskMouseUp );
  1510. canvas.addEventListener( 'mousedrag', onMaskMouseMove );
  1511. },
  1512. failure: failureAJAXFunction
  1513. });
  1514. };
  1515. function onMaskMouseDown( evt ){
  1516. if( MaskEditorMode == 0 ){
  1517. path = new paper.Path();
  1518. path.strokeColor = 'black';
  1519. path.closed = true;
  1520. path.opacity = 0.5;
  1521. path.moveTo( [ evt.clientX, evt.clientY ] );
  1522. setMaskEditorMode( 4 );
  1523. };
  1524. };
  1525. function onMaskMouseUp( evt ){
  1526. if( MaskEditorMode == 4 ){
  1527. path.lineTo( [ evt.clientX, evt.clientY ] );
  1528. setMaskEditorMode( 1 );
  1529. };
  1530. };
  1531. function onMaskMouseMove( event ){
  1532. if( MaskEditorMode == 4 ){
  1533. paper.view.draw();
  1534. };
  1535. };