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.

1504 lines
40 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
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  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:'Info Message',
  110. msg: 'Settings are sucessfully saved.',
  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:'Error Message',
  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. function doDeviceOperation( NodeID, OpCode, Param='' ){
  271. Ext.Ajax.request({
  272. url: '/lib/controller/doDeviceOperation.php',
  273. params: {
  274. NID: NodeID,
  275. UID: '<?=$CUser->Data['id'];?>',
  276. CMD: OpCode,
  277. SID: '<?=$Session;?>',
  278. PARAM: Param
  279. },
  280. success: function( response, opts ){
  281. var data = Ext.decode(response.responseText);
  282. if( !data.success ){
  283. Ext.Msg.show({
  284. title:'Node Command Status',
  285. msg: data.msg,
  286. buttons: Ext.Msg.OK,
  287. //fn: processResult,
  288. //animEl: 'upddiBTN',
  289. icon: Ext.MessageBox.ERROR
  290. });
  291. } else {
  292. Ext.Msg.show({
  293. title:'Node Command Status',
  294. msg: data.query,
  295. buttons: Ext.Msg.OK,
  296. //fn: processResult,
  297. //animEl: 'upddiBTN',
  298. icon: Ext.MessageBox.INFO
  299. });
  300. };
  301. },
  302. failure: failureAJAXFunction
  303. });
  304. };
  305. function loadFullLRF1D2Data( NodeID ){
  306. if( LRF1D2_st_win == null ) return;
  307. Ext.Ajax.request({
  308. url: '/lib/controller/getSettingsLRF.php',
  309. params: {
  310. NID: NodeID,
  311. UID: '<?=$CUser->Data['id'];?>',
  312. SID: '<?=$Session;?>',
  313. },
  314. success: function( response, opts ){
  315. if( LRF1D2_st_win!= null ){
  316. var data = Ext.decode(response.responseText);
  317. if( data.online ){
  318. switch( data.data_status ){
  319. case 0: Ext.getCmp('dev_online').update('<p class="green_status">ONLINE/Data Incomplete</p>'); break;
  320. case 1: Ext.getCmp('dev_online').update('<p class="green_status">ONLINE/Synced</p>'); break;
  321. case 2: Ext.getCmp('dev_online').update('<p class="green_status">ONLINE/Data Not Applyed</p>'); break;
  322. };
  323. } else {
  324. switch( data.data_status ){
  325. case 0: Ext.getCmp('dev_online').update('<p class="blue_status">OFFLINE/Data Incomplete</p>'); break;
  326. case 1: Ext.getCmp('dev_online').update('<p class="blue_status">OFFLINE/Synced</p>'); break;
  327. case 2: Ext.getCmp('dev_online').update('<p class="blue_status">OFFLINE/Data Not Applyed</p>'); break;
  328. };
  329. };
  330. Ext.getCmp('dev_name').setValue( data.name );
  331. Ext.getCmp('serial_num').setValue( data.serial );
  332. Ext.getCmp('version_id').setValue( data.version );
  333. Ext.getCmp('device_id').setValue( data.device_id );
  334. Ext.getCmp('com_spd').setValue( data.com_spd );
  335. Ext.getCmp('max_range').setValue( data.max_range );
  336. Ext.getCmp('base_shift').setValue( data.base_shift );
  337. Ext.getCmp('com_spd').setValue( data.uart_speed );
  338. Ext.getCmp('mlrf_offset').setValue( data.m_offset );
  339. Ext.getCmp('slrf_offset').setValue( data.s_offset );
  340. Ext.getCmp('mlrf_delta').setValue( data.m_delta );
  341. Ext.getCmp('slrf_delta').setValue( data.s_delta );
  342. Ext.getCmp('mlrf_width').setValue( data.m_width );
  343. Ext.getCmp('slrf_width').setValue( data.s_width );
  344. Ext.getCmp('mlrf_order').setValue( data.m_order );
  345. Ext.getCmp('slrf_order').setValue( data.s_order );
  346. Ext.getCmp('mlrf_sst').setValue( data.m_sst );
  347. Ext.getCmp('slrf_sst').setValue( data.s_sst );
  348. Ext.getCmp('mlrf_flip').setValue( data.m_flip );
  349. Ext.getCmp('slrf_flip').setValue( data.s_flip );
  350. Ext.getCmp('mlrf_sun').setValue( data.m_sun );
  351. Ext.getCmp('slrf_sun').setValue( data.s_sun );
  352. };
  353. },
  354. failure: failureAJAXFunction
  355. });
  356. };
  357. function LRF1D2_settings(){
  358. if( LRF1D2_st_win == null ){
  359. LRF1D2_st_win = new Ext.Window({
  360. title: 'Sensor Settings',
  361. modal: true,
  362. width: 800,
  363. height: 600,
  364. closeAction: 'hide',
  365. items:{
  366. xtype: 'tabpanel',
  367. activeTab: 0,
  368. items:[{
  369. title: 'General Settings',
  370. xtype: 'form',
  371. layout: 'table',
  372. defaults: {
  373. bodyStyle:'padding:20px'
  374. },
  375. layoutConfig: {
  376. columns: 3
  377. },
  378. items:[{
  379. html: 'Status',
  380. frame: false,
  381. border: false
  382. },{
  383. html: '<p class="green_status">ONLINE</p>',
  384. id: 'dev_online',
  385. frame: false,
  386. border: false
  387. },{},{
  388. html: 'Device Title',
  389. frame: false,
  390. border: false
  391. },{
  392. xtype: 'field',
  393. id: 'dev_name',
  394. readOnly: false,
  395. value: 'KOKO'
  396. },{},{
  397. html: 'Serial Number',
  398. frame: false,
  399. border: false
  400. },{
  401. xtype: 'field',
  402. id: 'serial_num',
  403. readOnly: true,
  404. value: '1212'
  405. },{},{
  406. html: 'Version ID',
  407. frame: false,
  408. border: false
  409. },{
  410. xtype: 'field',
  411. id: 'version_id',
  412. readOnly: true,
  413. value: 'LiberManDA122'
  414. },{},{
  415. html: 'Device Adress',
  416. frame: false,
  417. border: false
  418. },{
  419. xtype: 'numberfield',
  420. id: 'device_id'
  421. },{
  422. xtype: 'button',
  423. id: 'upddiBTN',
  424. text: 'Update Device Address',
  425. handler: function(){
  426. Ext.Msg.show({
  427. title:'Update Device Address?',
  428. msg: 'Are you sure to do so?',
  429. buttons: Ext.Msg.YESNOCANCEL,
  430. //fn: processResult,
  431. animEl: 'upddiBTN',
  432. icon: Ext.MessageBox.QUESTION
  433. });
  434. }
  435. },{
  436. html: 'Device COM Speed',
  437. frame: false,
  438. border: false
  439. },{
  440. xtype: 'combo',
  441. id: 'com_spd',
  442. editable: false,
  443. typeAhead: true,
  444. triggerAction: 'all',
  445. width: '100%',
  446. lazyRender:true,
  447. mode: 'local',
  448. store: new Ext.data.ArrayStore({
  449. id: 0,
  450. fields: ['mySPD', 'displayText' ],
  451. data: [[4800,'4800'],[9600,'9600'],[14400,'14400'],[19200,'19200'],[38400, '38400'],[56000,'56000'],[57600,'57600'],[115200,'115200']]
  452. }),
  453. valueField: 'mySPD',
  454. displayField: 'displayText'
  455. },{
  456. xtype: 'button',
  457. id: 'updspBTN',
  458. text: 'Set Device Speed',
  459. handler: function(){
  460. Ext.Msg.show({
  461. title:'Update Device Speed?',
  462. msg: 'Are you sure to do so?',
  463. buttons: Ext.Msg.YESNOCANCEL,
  464. //fn: processResult,
  465. animEl: 'upddiBTN',
  466. icon: Ext.MessageBox.QUESTION
  467. });
  468. }
  469. },{
  470. html: 'Detection Maximal Range',
  471. frame: false,
  472. border: false
  473. },{
  474. xtype: 'numberfield',
  475. id: 'max_range',
  476. readOnly: true,
  477. value: '1212'
  478. },{},{
  479. html: 'Base Shift',
  480. frame: false,
  481. border: false
  482. },{
  483. xtype: 'numberfield',
  484. id: 'base_shift',
  485. readOnly: true,
  486. value: '1212'
  487. },{}]
  488. },{
  489. title: 'Mantenence',
  490. xtype: 'form',
  491. layout: 'table',
  492. defaults: {
  493. bodyStyle:'padding:20px'
  494. },
  495. layoutConfig: {
  496. columns: 2
  497. },
  498. items:[{
  499. html: 'Restart Device',
  500. frame: false,
  501. border: false
  502. },{
  503. xtype: 'button',
  504. id: 'rstBTN',
  505. text: 'Full Reset',
  506. handler: function(){
  507. Ext.Msg.show({
  508. title:'Reset Device?',
  509. msg: 'You are closing a tab that has unsaved changes. Would you like to save your changes?',
  510. buttons: Ext.Msg.YESNOCANCEL,
  511. //fn: processResult,
  512. animEl: 'rstBTN',
  513. icon: Ext.MessageBox.QUESTION
  514. });
  515. }
  516. }]
  517. },{
  518. title: 'Detection Settings',
  519. xtype: 'form',
  520. layout: 'table',
  521. defaults: {
  522. bodyStyle:'padding:20px'
  523. },
  524. layoutConfig: {
  525. columns: 4
  526. },
  527. items:[{
  528. html: 'Master Offset',
  529. frame: false,
  530. border: false
  531. },{
  532. xtype: 'numberfield',
  533. id: 'mlrf_offset',
  534. name: 'mlrf_offset',
  535. allowBlank: false,
  536. allowDecimals: false,
  537. maxText: 'The Range is: 0 - 60',
  538. maxValue: 60,
  539. minText: 'No Negative Values Allowed',
  540. minValue: 0,
  541. },{
  542. html: 'Slave Offset',
  543. frame: false,
  544. border: false
  545. },{
  546. xtype: 'numberfield',
  547. id: 'slrf_offset',
  548. name: 'slrf_offset',
  549. allowBlank: false,
  550. allowDecimals: false,
  551. maxText: 'The Range is: 0 - 60',
  552. maxValue: 60,
  553. minText: 'No Negative Values Allowed',
  554. minValue: 0,
  555. },{
  556. html: 'Master Delta',
  557. frame: false,
  558. border: false
  559. },{
  560. xtype: 'numberfield',
  561. id: 'mlrf_delta',
  562. name: 'mlrf_delta',
  563. allowBlank: false,
  564. allowDecimals: false,
  565. maxText: 'The Range is: 0 - 320',
  566. maxValue: 320,
  567. minText: 'No Negative Values Allowed',
  568. minValue: 0
  569. },{
  570. html: 'Slave Delta',
  571. frame: false,
  572. border: false
  573. },{
  574. xtype: 'numberfield',
  575. id: 'slrf_delta',
  576. name: 'slrf_delta',
  577. allowBlank: false,
  578. allowDecimals: false,
  579. maxText: 'The Range is: 0 - 320',
  580. maxValue: 320,
  581. minText: 'No Negative Values Allowed',
  582. minValue: 0
  583. },{
  584. html: 'Master Width',
  585. frame: false,
  586. border: false
  587. },{
  588. xtype: 'numberfield',
  589. id: 'mlrf_width',
  590. name: 'mlrf_width',
  591. allowBlank: false,
  592. allowDecimals: false,
  593. maxText: 'The Range is: 1800 - 16000',
  594. maxValue: 16000,
  595. minText: 'The Range is: 1800 - 16000',
  596. minValue: 1800
  597. },{
  598. html: 'Slave Width',
  599. frame: false,
  600. border: false
  601. },{
  602. xtype: 'numberfield',
  603. id: 'slrf_width',
  604. name: 'slrf_width',
  605. allowBlank: false,
  606. allowDecimals: false,
  607. maxText: 'The Range is: 1800 - 16000',
  608. maxValue: 16000,
  609. minText: 'The Range is: 1800 - 16000',
  610. minValue: 1800
  611. },{
  612. html: 'Master Order',
  613. frame: false,
  614. border: false
  615. },{
  616. xtype: 'numberfield',
  617. id: 'mlrf_order',
  618. name: 'mlrf_order',
  619. allowBlank: false,
  620. allowDecimals: false,
  621. maxText: 'The Range is: 0 - 10',
  622. maxValue: 10,
  623. minText: 'No Negative Values Allowed',
  624. minValue: 0
  625. },{
  626. html: 'Slave Order',
  627. frame: false,
  628. border: false
  629. },{
  630. xtype: 'numberfield',
  631. id: 'slrf_order',
  632. name: 'slrf_order',
  633. allowBlank: false,
  634. allowDecimals: false,
  635. maxText: 'The Range is: 0 - 10',
  636. maxValue: 10,
  637. minText: 'No Negative Values Allowed',
  638. minValue: 0
  639. },{
  640. html: 'Master SST',
  641. frame: false,
  642. border: false
  643. },{
  644. xtype: 'numberfield',
  645. id: 'mlrf_sst',
  646. name: 'mlrf_sst',
  647. allowBlank: false,
  648. allowDecimals: false,
  649. maxText: 'The Range is: 0 - 100',
  650. maxValue: 100,
  651. minText: 'No Negative Values Allowed',
  652. minValue: 0
  653. },{
  654. html: 'Slave SST',
  655. frame: false,
  656. border: false
  657. },{
  658. xtype: 'numberfield',
  659. id: 'slrf_sst',
  660. name: 'slrf_sst',
  661. allowBlank: false,
  662. allowDecimals: false,
  663. maxText: 'The Range is: 0 - 100',
  664. maxValue: 100,
  665. minText: 'No Negative Values Allowed',
  666. minValue: 0
  667. },{
  668. html: 'Mastr Flip',
  669. frame: false,
  670. border: false
  671. },{
  672. xtype: 'numberfield',
  673. id: 'mlrf_flip',
  674. name: 'mlrf_flip',
  675. allowBlank: false,
  676. allowDecimals: false,
  677. maxText: 'The Range is: 8 - 128',
  678. maxValue: 128,
  679. minText: 'The Range is: 8 - 128',
  680. minValue: 8
  681. },{
  682. html: 'Slave Flip',
  683. frame: false,
  684. border: false
  685. },{
  686. xtype: 'numberfield',
  687. id: 'slrf_flip',
  688. name: 'slrf_flip',
  689. allowBlank: false,
  690. allowDecimals: false,
  691. maxText: 'The Range is: 8 - 128',
  692. maxValue: 128,
  693. minText: 'The Range is: 8 - 128',
  694. minValue: 8
  695. },{
  696. html: 'Master Sun',
  697. frame: false,
  698. border: false
  699. },{
  700. xtype: 'numberfield',
  701. id: 'mlrf_sun',
  702. name: 'mlrf_sun',
  703. allowBlank: false,
  704. allowDecimals: false,
  705. maxText: 'The Range is: 0 - 100',
  706. maxValue: 100,
  707. minText: 'No Negative Values Allowed',
  708. minValue: 0
  709. },{
  710. html: 'Slave Sun',
  711. frame: false,
  712. border: false
  713. },{
  714. xtype: 'numberfield',
  715. id: 'slrf_sun',
  716. name: 'slrf_sun',
  717. allowBlank: false,
  718. allowDecimals: false,
  719. maxText: 'The Range is: 0 - 100',
  720. maxValue: 100,
  721. minText: 'No Negative Values Allowed',
  722. minValue: 0
  723. }]
  724. },{
  725. title: 'Embed Options'
  726. },{
  727. title: 'Target Width Table'
  728. }]
  729. }
  730. });
  731. };
  732. LRF1D2_st_win.show();
  733. loadFullLRF1D2Data( SelectedNodeID );
  734. };
  735. function LRF2D2_settings(){
  736. };
  737. function LRF16D3_settings(){
  738. };
  739. var currentResolveDeviceNode = 0;
  740. var ResolveDeviceNodeWin = null;
  741. function resolveDeviceMistmatch( NodeID ){
  742. currentResolveDeviceNode = NodeID;
  743. if( ResolveDeviceNodeWin == null ){
  744. ResolveDeviceNodeWin = new Ext.Window({
  745. title: '<?=$Labels->GetLabel('_WDEV_MISTMATCH_');?>',
  746. modal: true,
  747. width: 500,
  748. height: 200,
  749. closeAction: 'hide',
  750. items:[{
  751. xtype: 'spacer',
  752. style: {
  753. marginTop: '13px'
  754. },
  755. html: '<center><?=$Labels->GetLabel('_DEV_MISTMATT1_');?></center>',
  756. height: 30
  757. },{
  758. xtype: 'button',
  759. width: '100%',
  760. text: 'It is Newly Connected Device',
  761. handler: function(){
  762. Ext.Ajax.request({
  763. url: '/lib/controller/validateNode.php',
  764. params: {
  765. NID: currentResolveDeviceNode,
  766. UID: '<?=$CUser->Data['id'];?>',
  767. SID: '<?=$Session;?>',
  768. MET: 1
  769. },
  770. success: function( response, opts ){
  771. ResolveDeviceNodeWin.hide();
  772. },
  773. failure: failureAJAXFunction
  774. });
  775. }
  776. },{
  777. xtype: 'button',
  778. width: '100%',
  779. text: 'Apply Existing Detection Profiles to Newly Connected Device',
  780. handler: function(){
  781. Ext.Ajax.request({
  782. url: '/lib/controller/validateNode.php',
  783. params: {
  784. NID: currentResolveDeviceNode,
  785. UID: '<?=$CUser->Data['id'];?>',
  786. SID: '<?=$Session;?>',
  787. MET: 1
  788. },
  789. success: function( response, opts ){
  790. ResolveDeviceNodeWin.hide();
  791. },
  792. failure: failureAJAXFunction
  793. });
  794. }
  795. },{
  796. xtype: 'button',
  797. width: '100%',
  798. text: 'Discard old Detection Profiles and Start Device Setup Wizard',
  799. handler: function(){
  800. ResolveDeviceNodeWin.hide();
  801. startDeviceDetectionWizard( currentResolveDeviceNode );
  802. }
  803. },{
  804. xtype: 'button',
  805. width: '100%',
  806. text: 'Discard old Detection Profiles and Load Factory Settings from Device'
  807. },{
  808. xtype: 'button',
  809. width: '100%',
  810. text: 'Discard this Connection for NOW'
  811. }]
  812. });
  813. };
  814. ResolveDeviceNodeWin.show();
  815. };
  816. var DeviceDetectionWizardWnd = null;
  817. var DDWizardActiveDevice = '';
  818. var RangeSetBlocker = false;
  819. function startDeviceDetectionWizard( NodeID ){
  820. DDWizardActiveDevice = NodeID
  821. if( DeviceDetectionWizardWnd == null ){
  822. DeviceDetectionWizardWnd = new Ext.Window({
  823. title: '<?=$Labels->GetLabel('_WDEV_DET_WIZT_');?>',
  824. modal: true,
  825. width: 500,
  826. height: 208,
  827. closeAction: 'hide',
  828. items:[{
  829. xtype: 'tabpanel',
  830. activeTab: 1,
  831. items: [{
  832. title: '<?=$Labels->GetLabel('_WDEV_DET_WIZ0_');?>',
  833. frame: false,
  834. xtype: 'form',
  835. items:[{
  836. xtype: 'spacer',
  837. height: 20
  838. },{
  839. xtype: 'combo',
  840. id: 'DDWizST',
  841. fieldLabel: '<?=$Labels->GetLabel('_DEV_TYPE_FLD_');?>',
  842. typeAhead: true,
  843. triggerAction: 'all',
  844. lazyRender:true,
  845. mode: 'local',
  846. store: new Ext.data.ArrayStore({
  847. id: 0,
  848. fields: [
  849. 'dtId',
  850. 'dtText'
  851. ],
  852. data: [
  853. [1, '<?=$Labels->GetLabel('_DEV_TYPE_ALS_');?>'],
  854. [2, '<?=$Labels->GetLabel('_DEV_TYPE_LFS_');?>'],
  855. [3, '<?=$Labels->GetLabel('_DEV_TYPE_PLS200_');?>'],
  856. [4, '<?=$Labels->GetLabel('_DEV_TYPE_PLS360_');?>'],
  857. [5, '<?=$Labels->GetLabel('_DEV_TYPE_3D_');?>'],
  858. [6, '<?=$Labels->GetLabel('_DEV_TYPE_NPLS200_');?>']
  859. ]
  860. }),
  861. valueField: 'dtId',
  862. displayField: 'dtText'
  863. },{
  864. xtype: 'numberfield',
  865. id: 'DDWizSR',
  866. fieldLabel: '<?=$Labels->GetLabel('_DEV_RANGE_FLD_');?>',
  867. minValue: 15.0,
  868. maxValue: 300.0,
  869. listeners:{
  870. change: function( m, nv, ov ){
  871. if( RangeSetBlocker ) return;
  872. RangeSetBlocker = true;
  873. Ext.getCmp('DDWizSRS').setValue( nv );
  874. RangeSetBlocker = false;
  875. }
  876. }
  877. },{
  878. xtype: 'slider',
  879. id: 'DDWizSRS',
  880. fieldLabel: '<?=$Labels->GetLabel('_DEV_RANGE_FLD_');?>',
  881. minValue: 15.0,
  882. maxValue: 300.0,
  883. listeners:{
  884. change: function( m, nv, ov ){
  885. if( RangeSetBlocker ) return;
  886. RangeSetBlocker = true;
  887. Ext.getCmp('DDWizSR').setValue( nv );
  888. RangeSetBlocker = false;
  889. }
  890. }
  891. },{
  892. xtype: 'spacer',
  893. height: 10
  894. }]
  895. },{
  896. title: '<?=$Labels->GetLabel('_WDEV_DET_WIZ1_');?>',
  897. frame: false,
  898. xtype: 'form',
  899. labelWidth: 120,
  900. items:[{
  901. xtype: 'spacer',
  902. height: 20
  903. },{
  904. xtype: 'combo',
  905. id: 'DDWizIT',
  906. fieldLabel: '<?=$Labels->GetLabel('_DEV_ITYPE_FLD_');?>',
  907. typeAhead: true,
  908. triggerAction: 'all',
  909. lazyRender:true,
  910. mode: 'local',
  911. value: 1,
  912. store: new Ext.data.ArrayStore({
  913. id: 0,
  914. fields: [
  915. 'dpId',
  916. 'dpText'
  917. ],
  918. data: [
  919. [1, '<?=$Labels->GetLabel('_DEV_PL_HORI_');?>'],
  920. [2, '<?=$Labels->GetLabel('_DEV_PL_VERT_');?>'],
  921. [3, '<?=$Labels->GetLabel('_DEV_PL_ANG_');?>']
  922. ]
  923. }),
  924. valueField: 'dpId',
  925. displayField: 'dpText'
  926. }]
  927. },{
  928. title: '<?=$Labels->GetLabel('_WDEV_DET_WIZ2_');?>',
  929. html: 'Another one'
  930. },{
  931. title: '<?=$Labels->GetLabel('_WDEV_DET_WIZ3_');?>',
  932. html: 'Another one'
  933. }]
  934. }],
  935. bbar:[{
  936. text: 'Create Profiles And Finish',
  937. handler: function(){
  938. DeviceDetectionWizardWnd.hide();
  939. }
  940. },{
  941. text: 'Advanced Config',
  942. handler: function(){
  943. DeviceDetectionWizardWnd.hide();
  944. startAdvancedDeviceDetection( DDWizardActiveDevice );
  945. }
  946. }]
  947. });
  948. };
  949. Ext.Ajax.request({
  950. url: '/lib/controller/getNodeBasicNfo.php',
  951. params: {
  952. NID: DDWizardActiveDevice,
  953. UID: '<?=$CUser->Data['id'];?>',
  954. SID: '<?=$Session;?>'
  955. },
  956. success: function( response, opts ){
  957. var data = Ext.decode(response.responseText);
  958. DeviceDetectionWizardWnd.setTitle( '<?=$Labels->GetLabel('_WDEV_DET_WIZT_');?> [' + data.name+']' );
  959. Ext.getCmp('DDWizST').setValue( data.type );
  960. RangeSetBlocker = true;
  961. Ext.getCmp('DDWizSR').setValue( data.range );
  962. Ext.getCmp('DDWizSRS').setValue( data.range );
  963. RangeSetBlocker = false;
  964. DeviceDetectionWizardWnd.show();
  965. },
  966. failure: failureAJAXFunction
  967. });
  968. };
  969. var DeviceDetectionAdvancedWnd = null;
  970. var DeviceDetectionProfileNames = ['factory default', 'low sens', 'medium sens', 'high sens'];
  971. function loadAdvancedDeviceDetectionSettings(){
  972. Ext.getCmp('ADD_TP').removeAll( false );
  973. Ext.Ajax.request({
  974. url: '/lib/controller/getNodeAdvancedNfo.php',
  975. params: {
  976. NID: DDWizardActiveDevice,
  977. UID: '<?=$CUser->Data['id'];?>',
  978. SID: '<?=$Session;?>'
  979. },
  980. success: function( response, opts ){
  981. var data = Ext.decode(response.responseText);
  982. DeviceDetectionAdvancedWnd.setTitle( '<?=$Labels->GetLabel('_WDEV_DET_WIZT_');?> [' + data.name+']' );
  983. if( data.profiles.length > 0 ){
  984. if( data.profiles.length > 3 ) Ext.getCmp('ADD_PADD_BTN').disable();
  985. switch( data.type ){
  986. case 1:
  987. case 5:{
  988. for( i = 0; i < data.profiles.length / 2; i++){
  989. };
  990. break;
  991. };
  992. case 2:
  993. case 3:
  994. case 4:
  995. case 6:{
  996. for( i = 0; i < data.profiles.length; i++){
  997. Ext.getCmp('ADD_TP').add({
  998. title: DeviceDetectionProfileNames[ data.profiles[i].id ],
  999. xtype: 'form',
  1000. frame: false,
  1001. items:[{xtype: 'spacer', height: 10 },{
  1002. xtype: 'numberfield',
  1003. id: 'OFFSET_P'+data.profiles[i].id,
  1004. fieldLabel: 'OFFSET',
  1005. minValue: 15.0,
  1006. maxValue: 300.0,
  1007. value: data.profiles[i].offset
  1008. },{
  1009. xtype: 'numberfield',
  1010. id: 'DELTA_P'+data.profiles[i].id,
  1011. fieldLabel: 'DELTA',
  1012. minValue: 15.0,
  1013. maxValue: 300.0,
  1014. value: data.profiles[i].delta
  1015. },{
  1016. xtype: 'numberfield',
  1017. id: 'WIDTH_P'+data.profiles[i].id,
  1018. fieldLabel: 'WIDTH',
  1019. minValue: 15.0,
  1020. maxValue: 300.0,
  1021. value: data.profiles[i].width
  1022. },{
  1023. xtype: 'numberfield',
  1024. id: 'SST_P'+data.profiles[i].id,
  1025. fieldLabel: 'SST',
  1026. minValue: 15.0,
  1027. maxValue: 300.0,
  1028. value: data.profiles[i].sst
  1029. },{
  1030. xtype: 'numberfield',
  1031. id: 'FLIP_P'+data.profiles[i].id,
  1032. fieldLabel: 'FLIP',
  1033. minValue: 15.0,
  1034. maxValue: 300.0,
  1035. value: data.profiles[i].flip
  1036. },{
  1037. xtype: 'numberfield',
  1038. id: 'SUN_P'+data.profiles[i].id,
  1039. fieldLabel: 'SUN',
  1040. minValue: 15.0,
  1041. maxValue: 300.0,
  1042. value: data.profiles[i].sun
  1043. }]
  1044. });
  1045. };
  1046. break;
  1047. };
  1048. };
  1049. //
  1050. } else {
  1051. Ext.getCmp('ADD_TP').add({
  1052. title: 'Error!',
  1053. html: 'No Profiles Defined'
  1054. });
  1055. };
  1056. DeviceDetectionAdvancedWnd.show();
  1057. },
  1058. failure: failureAJAXFunction
  1059. });
  1060. };
  1061. function startAdvancedDeviceDetection( NodeID ){
  1062. DDWizardActiveDevice = NodeID;
  1063. if( DeviceDetectionAdvancedWnd == null ){
  1064. DeviceDetectionAdvancedWnd = new Ext.Window({
  1065. title: '<?=$Labels->GetLabel('_WDEV_DET_WIZT_');?>',
  1066. modal: true,
  1067. width: 500,
  1068. height: 300,
  1069. closeAction: 'hide',
  1070. items:[{
  1071. xtype: 'tabpanel',
  1072. id: 'ADD_TP',
  1073. frame: false,
  1074. border: false,
  1075. activeTab: 0,
  1076. items: []
  1077. }],
  1078. bbar:[{
  1079. id: 'ADD_PADD_BTN',
  1080. text: 'Add Detection Profile',
  1081. handler: function(){
  1082. Ext.Ajax.request({
  1083. url: '/lib/controller/addDetectionProfile.php',
  1084. params: {
  1085. NID: DDWizardActiveDevice,
  1086. UID: '<?=$CUser->Data['id'];?>',
  1087. SID: '<?=$Session;?>'
  1088. },
  1089. success: function( response, opts ){
  1090. loadAdvancedDeviceDetectionSettings();
  1091. },
  1092. failure: failureAJAXFunction
  1093. });
  1094. }
  1095. },{
  1096. text: 'Apply And Finish'
  1097. },{
  1098. text: 'Use Wizard'
  1099. }]
  1100. });
  1101. };
  1102. loadAdvancedDeviceDetectionSettings();
  1103. };
  1104. var maskEditorDiv = null;
  1105. var MEPanel = null;
  1106. function handleFSMaskEditorClose( event ){
  1107. if ( document.fullscreenElement ||
  1108. document.webkitFullscreenElement ||
  1109. document.mozFullScreenElement ||
  1110. document.msFullscreenElement ){
  1111. } else {
  1112. MEPanel.destroy();
  1113. maskEditorDiv.remove();
  1114. maskEditorDiv = null;
  1115. MEPanel = null;
  1116. document.removeEventListener( 'fullscreenchange', handleFSMaskEditorClose );
  1117. };
  1118. };
  1119. function hideMaskEditor(){
  1120. if(
  1121. document.fullscreenElement ||
  1122. document.webkitFullscreenElement ||
  1123. document.mozFullScreenElement ||
  1124. document.msFullscreenElement
  1125. ){
  1126. if( document.exitFullscreen ){
  1127. document.exitFullscreen();
  1128. }else if( document.mozCancelFullScreen ){
  1129. document.mozCancelFullScreen();
  1130. }else if( document.webkitExitFullscreen ){
  1131. document.webkitExitFullscreen();
  1132. }else if( document.msExitFullscreen ){
  1133. document.msExitFullscreen();
  1134. };
  1135. // Removal Done by event!
  1136. //maskEditorDiv.remove();
  1137. //maskEditorDiv = null;
  1138. //document.removeEventListener( 'fullscreenchange', handleFSMaskEditorClose );
  1139. };
  1140. };
  1141. var values = {
  1142. paths: 50,
  1143. minPoints: 5,
  1144. maxPoints: 15,
  1145. minRadius: 30,
  1146. maxRadius: 90
  1147. };
  1148. var hitOptions = {
  1149. segments: true,
  1150. stroke: true,
  1151. fill: true,
  1152. tolerance: 10
  1153. };
  1154. var polycolors = new Array();
  1155. var polyindex = 0;
  1156. var poligones = new Array();
  1157. var segment = null;
  1158. var path = null;
  1159. var MaskProject = null;
  1160. var MaskEditorMode = 0;
  1161. function onMouseDown(event) {
  1162. segment = path = null;
  1163. var hitResult = MaskProject.hitTest( event.point, hitOptions );
  1164. if (!hitResult) return;
  1165. if( event.modifiers.shift ){
  1166. if (hitResult.type == 'segment') {
  1167. hitResult.segment.remove();
  1168. };
  1169. return;
  1170. };
  1171. if( hitResult ){
  1172. path = hitResult.item;
  1173. if( hitResult.type == 'segment' ){
  1174. segment = hitResult.segment;
  1175. path.fullySelected = false;
  1176. segment.selected = true;
  1177. } else if( hitResult.type == 'stroke' ){
  1178. var location = hitResult.location;
  1179. segment = path.insert(location.index + 1, event.point);
  1180. //path.smooth();
  1181. path.fullySelected = false;
  1182. segment.selected = true;
  1183. } else if ( hitResult.type == 'fill' ){
  1184. path.fullySelected = true;
  1185. };
  1186. }
  1187. //movePath = ;
  1188. //if( movePath ) MaskProject.activeLayer.addChild(hitResult.item);
  1189. }
  1190. function onMouseMove(event) {
  1191. MaskProject.activeLayer.selected = false;
  1192. if( event.item ) {
  1193. //event.item.selected = true;
  1194. event.item.fullySelected = true;
  1195. };
  1196. }
  1197. function onMouseDrag(event) {
  1198. if( segment ){
  1199. //segment.point += event.delta;
  1200. segment.point = event.point;
  1201. //path.smooth();
  1202. };
  1203. //else if (path) {
  1204. // path.position += event.delta;
  1205. //}
  1206. }
  1207. var absDrawMapSizes = [[0,0],[2304,288]];
  1208. var deviceMapScaling = 1.0;
  1209. var deviceMapTopShift = 100;
  1210. var deviceMapLeftShift = 100;
  1211. var cMapImageWidth = 0;
  1212. var cMapImageHeight = 0;
  1213. var cMapCanvasWidth = 0;
  1214. var cMapCanvasHeight = 0;
  1215. function showMaskEditor( fromDevTool, DevType, NodeID ){
  1216. //alert( "DevType: "+DevType + " Dev Map size: "+ absDrawMapSizes[DevType][0]+"x"+absDrawMapSizes[DevType][1] );
  1217. deviceMapScaling = ( window.screen.height * window.devicePixelRatio - 130 - ( deviceMapTopShift * 2 )) / absDrawMapSizes[DevType][1];
  1218. cMapImageHeight = deviceMapScaling * absDrawMapSizes[DevType][1];
  1219. cMapImageWidth = deviceMapScaling * absDrawMapSizes[DevType][0];
  1220. cMapCanvasWidth = cMapImageWidth + (deviceMapLeftShift * 2);
  1221. cMapCanvasHeight = cMapImageHeight + (deviceMapTopShift * 2);
  1222. if( fromDevTool ){
  1223. detectionProfileWindow.hide();
  1224. };
  1225. if(
  1226. document.fullscreenElement ||
  1227. document.webkitFullscreenElement ||
  1228. document.mozFullScreenElement ||
  1229. document.msFullscreenElement
  1230. ){
  1231. //fs mode allready
  1232. hideMaskEditor();
  1233. }else{
  1234. if( maskEditorDiv == null ){
  1235. maskEditorDiv = document.createElement("div");
  1236. maskEditorDiv.style.height="200px";
  1237. maskEditorDiv.style.width="200px";
  1238. //maskEditorDiv.style.backgroundImage = "url('your_image.png')";
  1239. //append div as a child to body
  1240. document.body.appendChild( maskEditorDiv );
  1241. //var elem = document.createElement("img"); 'getDeviceMap.php?NID='+NodeID
  1242. //elem.setAttribute("src", "/lib/controller/data/device_draws/75c85fec4be204fc0bc0452f53b5a3df_map.png");
  1243. //elem.setAttribute("height", "80%");
  1244. //elem.setAttribute("width", "130");
  1245. //maskEditorDiv.appendChild( elem );
  1246. //alert( window.screen.width * window.devicePixelRatio + "x" + window.screen.height * window.devicePixelRatio);
  1247. if( MEPanel == null ){
  1248. var ww = window.screen.width * window.devicePixelRatio;
  1249. var hh = window.screen.height * window.devicePixelRatio;
  1250. MEPanel = new Ext.Panel( {
  1251. title: 'Mask Editor',
  1252. renderTo: maskEditorDiv,
  1253. width: ww,
  1254. height: hh,
  1255. frame: true,
  1256. autoScroll: true,
  1257. items:[{
  1258. xtype: 'panel',
  1259. width: cMapCanvasWidth,
  1260. 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/data/device_draws/75c85fec4be204fc0bc0452f53b5a3df_map.png\'); background-repeat: no-repeat;"><canvas id="mask_canvas" width="'+cMapCanvasWidth+'px" height="'+cMapCanvasHeight+'px"></canvas></dvi>'
  1261. }],
  1262. tbar:[{
  1263. text:'New Polygone',
  1264. id: 'me_b_newp',
  1265. enableToggle: true,
  1266. toggleGroup: 'me_topbar_grp',
  1267. handler: function( btn ){
  1268. if( btn.pressed ) setMaskEditorMode( 0 );
  1269. }
  1270. },{
  1271. text:'Delete Polygone',
  1272. id: 'me_b_delp',
  1273. enableToggle: true,
  1274. toggleGroup: 'me_topbar_grp'
  1275. },{
  1276. text:'Delete Point',
  1277. id: 'me_b_delpo',
  1278. enableToggle: true,
  1279. toggleGroup: 'me_topbar_grp'
  1280. },{
  1281. text:'Clear Mask',
  1282. id: 'me_b_delm',
  1283. handler: function(){
  1284. if( MaskProject!= null ){
  1285. alert( 'ClearMask' );
  1286. };
  1287. }
  1288. }],
  1289. buttons:[{
  1290. text: 'Cancel',
  1291. handler: function(){
  1292. hideMaskEditor();
  1293. }
  1294. },{
  1295. text:'Save Mask and Close',
  1296. handler: function(){
  1297. var serial = MaskProject.exportJSON();
  1298. Ext.Ajax.request({
  1299. url: '/lib/controller/uploadDeviceMask.php',
  1300. params: {
  1301. NID: NodeID,
  1302. UID: '<?=$CUser->Data['id'];?>',
  1303. SID: '<?=$Session;?>',
  1304. MID: 0,
  1305. LID: 0,
  1306. MDTA: serial,
  1307. MIH: cMapImageHeight,
  1308. //MSF: deviceMapScaling,
  1309. MSHX: deviceMapLeftShift,
  1310. MSHY: deviceMapTopShift
  1311. },
  1312. success: function( response, opts ){
  1313. var data = Ext.decode(response.responseText);
  1314. hideMaskEditor();
  1315. },
  1316. failure: failureAJAXFunction
  1317. });
  1318. }
  1319. }]
  1320. });
  1321. };
  1322. MEPanel.doLayout();
  1323. loadDeviceMask( NodeID );
  1324. };
  1325. //maskEditorDiv = $('#container').get(0);
  1326. //var maskEditorDiv = document.getElementById( id ); //Ext.getCmp( id );
  1327. if( maskEditorDiv.requestFullscreen ){
  1328. maskEditorDiv.requestFullscreen();
  1329. }else if( maskEditorDiv.mozRequestFullScreen ){
  1330. maskEditorDiv.mozRequestFullScreen();
  1331. }else if( maskEditorDiv.webkitRequestFullscreen ){
  1332. maskEditorDiv.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
  1333. }else if( maskEditorDiv.msRequestFullscreen ){
  1334. maskEditorDiv.msRequestFullscreen();
  1335. };
  1336. document.addEventListener( 'fullscreenchange', handleFSMaskEditorClose );
  1337. };
  1338. };
  1339. function setMaskEditorMode( nM ){
  1340. switch( nM ){
  1341. case 0:{
  1342. var MEP = Ext.getCmp('me_b_newp');
  1343. if( !MEP.pressed ) MEP.toggle( true );
  1344. var caca = document.getElementById('mask_canvas');
  1345. caca.style.cursor = 'crosshair';
  1346. break;
  1347. };
  1348. case 1:{
  1349. var MEP = Ext.getCmp('me_b_newp');
  1350. if( !MEP.pressed ) MEP.toggle( false );
  1351. MEP = Ext.getCmp('me_b_delp');
  1352. if( !MEP.pressed ) MEP.toggle( false );
  1353. MEP = Ext.getCmp('me_b_delpo');
  1354. if( !MEP.pressed ) MEP.toggle( false );
  1355. if( MaskProject!= null ){
  1356. if( MaskProject.isEmpty() ){
  1357. MEP = Ext.getCmp('me_b_delp');
  1358. MEP.disable();
  1359. MEP = Ext.getCmp('me_b_delpo');
  1360. MEP.disable();
  1361. MEP = Ext.getCmp('me_b_delm');
  1362. MEP.disable();
  1363. setMaskEditorMode( 0 );
  1364. } else {
  1365. MEP = Ext.getCmp('me_b_delp');
  1366. MEP.enable();
  1367. MEP = Ext.getCmp('me_b_delpo');
  1368. MEP.enable();
  1369. MEP = Ext.getCmp('me_b_delm');
  1370. MEP.enable();
  1371. };
  1372. };
  1373. var caca = document.getElementById('mask_canvas');
  1374. caca.style.cursor = 'default';
  1375. break;
  1376. };
  1377. case 2:{
  1378. var MEP = Ext.getCmp('me_b_delp');
  1379. if( !MEP.pressed ) MEP.toggle( true );
  1380. break;
  1381. };
  1382. case 3:{
  1383. var MEP = Ext.getCmp('me_b_delpo');
  1384. if( !MEP.pressed ) MEP.toggle( true );
  1385. break;
  1386. };
  1387. };
  1388. MaskEditorMode = nM;
  1389. };
  1390. function loadDeviceMask( NodeID, LrfID = 0, LayerID = 0 ){
  1391. Ext.Ajax.request({
  1392. url: '/lib/controller/getDeviceMask.php',
  1393. params: {
  1394. NID: NodeID,
  1395. UID: '<?=$CUser->Data['id'];?>',
  1396. SID: '<?=$Session;?>',
  1397. MID: LayerID,
  1398. LID: LrfID
  1399. },
  1400. success: function( response, opts ){
  1401. var data = Ext.decode(response.responseText);
  1402. var canvas = document.getElementById('mask_canvas');// Create an empty project and a view for the canvas:
  1403. //paper.setup( canvas );
  1404. paper.settings.handleSize = 10;
  1405. MaskProject = new paper.Project( canvas );
  1406. if( data.length > 0 ){
  1407. for( i = 0; i < data.length; i++ ){
  1408. var path = new paper.Path();
  1409. path.strokeColor = 'black';
  1410. //var lightness = (Math.random() - 0.5) * 0.4 + 0.4;
  1411. //var hue = Math.random() * 360;
  1412. //path.fillColor = { hue: hue, saturation: 1, lightness: lightness };
  1413. path.fillColor = data[i].colour;
  1414. path.closed = true;
  1415. path.opacity = 0.5;
  1416. //path.onMouseMove = onMouseMove;
  1417. path.onMouseDown = onMouseDown;
  1418. path.onMouseDrag = onMouseDrag;
  1419. //path.onMouseUp = function( event ){
  1420. // path.add(event.point);
  1421. //}
  1422. if( data[i].points.length > 2 ){
  1423. var tX = data[i].points[0][0] * deviceMapScaling + deviceMapLeftShift;
  1424. var tY = data[i].points[0][1] * deviceMapScaling + deviceMapTopShift;
  1425. path.moveTo( [tX,tY] );
  1426. for(k = 1; k < data[i].points.length; k++ ){
  1427. tX = data[i].points[k][0] * deviceMapScaling + deviceMapLeftShift;
  1428. tY = data[i].points[k][1] * deviceMapScaling + deviceMapTopShift;
  1429. path.lineTo( [tX,tY] );
  1430. };
  1431. path.fullySelected = true;
  1432. paper.view.draw();
  1433. };
  1434. poligones.push(path);
  1435. };
  1436. };
  1437. setMaskEditorMode( 1 ); // Observer
  1438. canvas.addEventListener( 'mousemove', onMaskMouseMove );
  1439. canvas.addEventListener( 'mousedown', onMaskMouseDown );
  1440. canvas.addEventListener( 'mouseup', onMaskMouseUp );
  1441. canvas.addEventListener( 'mousedrag', onMaskMouseMove );
  1442. },
  1443. failure: failureAJAXFunction
  1444. });
  1445. };
  1446. function onMaskMouseDown( evt ){
  1447. if( MaskEditorMode == 0 ){
  1448. path = new paper.Path();
  1449. path.strokeColor = 'black';
  1450. path.closed = true;
  1451. path.opacity = 0.5;
  1452. path.moveTo( [ evt.clientX, evt.clientY ] );
  1453. setMaskEditorMode( 4 );
  1454. };
  1455. };
  1456. function onMaskMouseUp( evt ){
  1457. if( MaskEditorMode == 4 ){
  1458. path.lineTo( [ evt.clientX, evt.clientY ] );
  1459. setMaskEditorMode( 1 );
  1460. };
  1461. };
  1462. function onMaskMouseMove( event ){
  1463. if( MaskEditorMode == 4 ){
  1464. paper.view.draw();
  1465. };
  1466. };