diff --git a/lib/controller/dash/node_3.js b/lib/controller/dash/node_3.js index 3187334..a17ba5f 100644 --- a/lib/controller/dash/node_3.js +++ b/lib/controller/dash/node_3.js @@ -43,7 +43,7 @@ layout: 'hbox', items:[{ id: 'cp_radar_%%%NODEID%%%', - html: '
100 m.502512.5
', + html: '
100 m.502512.5
', width: '56%' },{ frame: false, @@ -58,7 +58,7 @@ iconCls: 'ctrl_panel_clean_sm', iconAlign: 'left', handler: function(){ - doDeviceOperation( %%%NODEID%%%, 125,'', true ); + doDeviceOperation( 1, 125,'', true ); } },{ xtype: 'spacer', diff --git a/lib/controller/data/mysqlitedb.db b/lib/controller/data/mysqlitedb.db index 3244f16..79e5bc0 100644 Binary files a/lib/controller/data/mysqlitedb.db and b/lib/controller/data/mysqlitedb.db differ diff --git a/lib/controller/data/reports.db b/lib/controller/data/reports.db index b881ea3..9429127 100644 Binary files a/lib/controller/data/reports.db and b/lib/controller/data/reports.db differ diff --git a/lib/controller/doMaskOperation.php b/lib/controller/doMaskOperation.php index 17275e4..10d69ea 100644 --- a/lib/controller/doMaskOperation.php +++ b/lib/controller/doMaskOperation.php @@ -34,8 +34,7 @@ $RBASE = new SQLite_DB( '/dev/shm/argus/mem_db.db'); $Data['success'] = true; $Data['status'] = 'ok'; - $CMD = 70+$MID; - $QS = "INSERT INTO `nodes_qcq`(`node_id`,`cmd`,`status`,`parameter`) VALUES({$NodeID},{$CMD},0,'')"; + $QS = "INSERT INTO `nodes_qcq`(`node_id`,`cmd`,`status`,`parameter`) VALUES({$NodeID},65,0,'')"; $Data['query'] = $QS; $RBASE->Query( $QS, false ); $Data['operation_id'] = intval( $RBASE->getLastInsertID() ); @@ -62,8 +61,7 @@ $RBASE = new SQLite_DB( '/dev/shm/argus/mem_db.db'); $Data['success'] = true; $Data['status'] = 'ok'; - $CMD = 65+$MID; - $QS = "INSERT INTO `nodes_qcq`(`node_id`,`cmd`,`status`,`parameter`) VALUES({$NodeID},{$CMD},0,'')"; + $QS = "INSERT INTO `nodes_qcq`(`node_id`,`cmd`,`status`,`parameter`) VALUES({$NodeID},65,0,'')"; $Data['query'] = $QS; $RBASE->Query( $QS, false ); $Data['operation_id'] = intval( $RBASE->getLastInsertID() ); diff --git a/lib/controller/getDeviceMask.php b/lib/controller/getDeviceMask.php index 9bbde4c..23bba69 100644 --- a/lib/controller/getDeviceMask.php +++ b/lib/controller/getDeviceMask.php @@ -2,29 +2,58 @@ require_once('../ajax_asm.php'); if( $CUser->Data['id'] > 1 ){ $NodeID = intval($_POST['NID']); - $LayerID = intval($_POST['MID']); - $LRFID = intval($_POST['LID']); + if( isset( $_POST['MID'] ) ) $LayerID = intval($_POST['MID']); else $LayerID = 0; + if( isset( $_POST['LID'] ) ) $LRFID = intval($_POST['LID']); else $LRFID = 0; $QS = "SELECT * FROM nodes WHERE id={$NodeID} "; $Data = array(); $result = $DATABASE->Query( $QS, false ); if( count( $result ) ){ $T = $result[0]; $AID = $T['aux_id']; - $QS = "SELECT * FROM `lrf_masks` WHERE `sensor_id`={$AID} AND `lrf_id`={$LRFID} AND `layer`={$LayerID}"; - $result = $DATABASE->Query( $QS, false ); - if( count($result) ){ - $CM = $result[0]; - $QS = "SELECT * FROM `lrf_mask_vertexes` WHERE `mask_id`={$CM['id']}"; - $ZA = $DATABASE->Query( $QS ); - $CV = array(); - if( count( $ZA ) ){ - foreach( $ZA as $VV ){ - $CV['colour']="rgba(".intval($VV['r']).",".intval($VV['g']).",".intval($VV['b']).",255)"; - $QS = "SELECT * FROM `lrf_mask_vertex_points` WHERE `vertex_id`={$VV['id']}"; - $PP = $DATABASE->Query( $QS ); - $CV['points'] = array(); - foreach( $PP as $P ) $CV['points'][] = array( $P['x'], $P['y']); - $Data[] = $CV; + if( isset( $_POST['ALL'] ) ){ + for( $i=0; $i<5; $i++){ + $CMA = array(); + $QS = "SELECT * FROM `lrf_masks` WHERE `sensor_id`={$AID} AND `lrf_id`={$LRFID} AND `layer`={$i}"; + $result = $DATABASE->Query( $QS, false ); + if( count($result) ){ + $CM = $result[0]; + $QS = "SELECT * FROM `lrf_mask_vertexes` WHERE `mask_id`={$CM['id']}"; + $ZA = $DATABASE->Query( $QS ); + $CMA['vtx'] = array(); + if( count( $ZA ) ){ + $CMA['status'] = ( $CM['status'] == 'E' ); + foreach( $ZA as $VV ){ + //$CMA['colour'] = sprintf( "#%02H%02H%02H", intval($VV['r']), intval($VV['g']), intval($VV['b']) ); + $QS = "SELECT * FROM `lrf_mask_vertex_points` WHERE `vertex_id`={$VV['id']}"; + $PP = $DATABASE->Query( $QS ); + $CV = array(); + foreach( $PP as $P ) $CV[] = array( $P['x'], $P['y']); + $CMA['vtx'][] = $CV; + }; + }; + } else { + $CMA['status'] = false; + $CMA['vcnt'] = 0; + }; + $Data[$i] = $CMA; + }; + } else { + $QS = "SELECT * FROM `lrf_masks` WHERE `sensor_id`={$AID} AND `lrf_id`={$LRFID} AND `layer`={$LayerID}"; + $result = $DATABASE->Query( $QS, false ); + if( count($result) ){ + $CM = $result[0]; + $QS = "SELECT * FROM `lrf_mask_vertexes` WHERE `mask_id`={$CM['id']}"; + $ZA = $DATABASE->Query( $QS ); + $CV = array(); + if( count( $ZA ) ){ + foreach( $ZA as $VV ){ + $CV['colour']="rgba(".intval($VV['r']).",".intval($VV['g']).",".intval($VV['b']).",255)"; + $QS = "SELECT * FROM `lrf_mask_vertex_points` WHERE `vertex_id`={$VV['id']}"; + $PP = $DATABASE->Query( $QS ); + $CV['points'] = array(); + foreach( $PP as $P ) $CV['points'][] = array( $P['x'], $P['y']); + $Data[] = $CV; + }; }; }; }; diff --git a/lib/controller/getHistoryEvents.php b/lib/controller/getHistoryEvents.php index d561bda..77372c6 100644 --- a/lib/controller/getHistoryEvents.php +++ b/lib/controller/getHistoryEvents.php @@ -7,9 +7,9 @@ $result = $DATABASE->Query( $QS, false ); $NodeNames = array(); foreach( $result as $R ) $NodeNames[$R['id']] = $R['name']; - $QS = "SELECT `events`.*, `events_2_videos`.* FROM `events` LEFT JOIN `events_2_videos` ON( `events`.`id` = `events_2_videos`.`evt_id` ) WHERE `ts` >= {$CTS} ORDER BY `ts` DESC, `ts_ms` DESC LIMIT 32"; + $QS = "SELECT `events`.*, `events_2_videos`.* FROM `events` LEFT JOIN `events_2_videos` ON( `events`.`id` = `events_2_videos`.`evt_id` ) WHERE `ts` >= {$CTS} ORDER BY `ts` DESC, `ts_ms` DESC LIMIT 248"; $ZIZI = new SQLite_DB( '/srv/www/web/lib/controller/data/reports.db'); - $LREC = $ZIZI->Query( $QS ); + $LREC = array_reverse( $ZIZI->Query( $QS ) ); $Data['log'] = array(); foreach( $LREC as $REC ){ $CR['id'] = intval( $REC['id'] ); diff --git a/lib/controller/getReportLayout.php b/lib/controller/getReportLayout.php index af9f192..dab2606 100644 --- a/lib/controller/getReportLayout.php +++ b/lib/controller/getReportLayout.php @@ -93,7 +93,7 @@ kahkjahskfgkgkh; $DUMMY['camera']="{xtype:'panel', id:'pan_ph_ccc_%%ID%%', title: 'Camera Placeholder', frame: true, border: true, draggable: false, layouit: 'fit', items:{$TABA}}"; $DUMMY['sensor']="{xtype:'panel', title: 'Sensor Placeholder', frame: true, border: true, draggable: false, html:'NO SENSOR', listeners:{ afterrender: function(p){ var W=p.getWidth(); p.setHeight( 32+(W/16)*9);}}}"; $DUMMY['map']="{xtype:'panel', title: 'Map Placeholder', frame: true, height: 200, border: true, draggable: false, html:'NO MAP'}"; - $DUMMY['log']="{xtype:'panel', id: 'lg_panel', title: 'Report Log', frame: true, /*height: 200,*/ border: true, draggable: false, items:[{$LOGIO}] }"; + $DUMMY['log']="{xtype:'panel', id: 'lg_panel', title: 'Report Log', frame: true, border: true, draggable: false, items:[{$LOGIO}] }"; } else { $DUMMY['camera']="{xtype:'panel', title: false, frame: true, draggable: false, html: ' ', listeners:{ afterrender: function(p){ var W=p.getWidth(); p.setHeight( 32+(W/16)*9);}}}"; $DUMMY['sensor']="{xtype:'panel', title: false, frame: true, draggable: false, html: ' ', listeners:{ afterrender: function(p){ var W=p.getWidth(); p.setHeight( 32+(W/16)*9);}}}"; diff --git a/lib/controller/getStatus.php b/lib/controller/getStatus.php index 7fb70ef..e53faab 100644 --- a/lib/controller/getStatus.php +++ b/lib/controller/getStatus.php @@ -107,10 +107,10 @@ } else { $CN['reload_draw'] = true; }; - if( $CN['status'] == 5 ){ + if( ( $CN['status'] == 5 ) || 1 ){ // check Targets $CN['targets'] = array(); - $QS="SELECT * FROM events WHERE node_id={$CN['id']} ORDER BY ts DESC, ts_ms DESC LIMIT 32"; + $QS="SELECT * FROM events WHERE ( node_id={$CN['id']} OR node_id=1 ) AND ( evt_type=10 OR evt_type=11 OR evt_type=12 OR evt_type=13 OR evt_type=14 OR evt_type=52 OR evt_type=53 OR evt_type=54 ) ORDER BY ts DESC, ts_ms DESC LIMIT 32"; //$QS="SELECT * FROM events_cloud WHERE node_id={$CN['id']} AND ( evt_type=13 OR evt_type=14) AND (UNIX_TIMESTAMP(NOW())-ts)<60 ORDER BY id DESC LIMIT 32"; //$QS="SELECT * FROM events_cloud WHERE node_id={$CN['id']} AND ( evt_type=13 OR evt_type=14) ORDER BY ts, ts_ms DESC LIMIT 32"; //echo $QS . "\n\n"; @@ -119,8 +119,8 @@ $CT = array(); foreach( $zult as $Z ){ $TT = intval( $Z['evt_type'] ); - if( $TT > 52 && $TT < 56 ) break; - if( !( $TT == 10 || $TT == 11 ||$TT == 12 ||$TT == 13 || $TT == 14 || $TT == 36 ) ) continue; + if( ( $TT == 52 ) || ( $TT == 53 ) || ( $TT == 54 ) ) break; + //if( !( $TT == 10 || $TT == 11 ||$TT == 12 ||$TT == 13 || $TT == 14 || $TT == 36 ) ) continue; //$CT['type'] = $TT; $CT['digital'] = intval( $Z['range_digital']); $CT['lat'] = floatval( $Z['lon'] ); diff --git a/lib/controller/report/node_3.js b/lib/controller/report/node_3.js index 508141c..e6b14d0 100644 --- a/lib/controller/report/node_3.js +++ b/lib/controller/report/node_3.js @@ -43,7 +43,7 @@ layout: 'hbox', items:[{ id: 'cp_radar_%%%NODEID%%%', - html: '
100 m.502512.5
', + html: '
100 m.502512.5
', width: '100%' }], bbar:[{ diff --git a/lib/controller/uploadDeviceMask.php b/lib/controller/uploadDeviceMask.php index 3f7fb91..efd0e6d 100644 --- a/lib/controller/uploadDeviceMask.php +++ b/lib/controller/uploadDeviceMask.php @@ -14,7 +14,7 @@ $QS = "SELECT * FROM nodes WHERE id={$NodeID} "; $Data = array(); $NPC = 0; - $SCHEDULE_JOB = 0; // NOJOB + $DeleteMasks = true; // NOJOB $result = $DATABASE->Query( $QS, false ); if( $SHX == $SHY ) $Process = 0; else $Process = 1; if( count( $result ) && $MHEI ){ @@ -44,9 +44,6 @@ $QS = "DELETE FROM `lrf_mask_vertexes` WHERE `mask_id`={$MID}"; $DATABASE->Query( $QS ); }; - - - $SCHEDULE_JOB = 1; // Clear Mask foreach( $SERIAL[0][1]->children as $CCC ){ $R = $CCC[1]->fillColor[0] * 255; $G = $CCC[1]->fillColor[1] * 255; @@ -83,40 +80,28 @@ $QS = "INSERT INTO `lrf_mask_vertex_points` (`vertex_id`,`x`,`y`) VALUES ({$VID},{$X},{$Y}) "; $DATABASE->Query( $QS, false ); $NPC++; - $SCHEDULE_JOB = 2; // Update - Set Mask + $DeleteMasks = false; }; }; - switch( $SCHEDULE_JOB ){ - case 1:{ - // Clear Mask No Points. - $QS = "SELECT * FROM `lrf_mask_vertexes` WHERE `mask_id`={$MID}"; - $ZA = $DATABASE->Query( $QS ); - foreach( $ZA as $A ){ - $QS = "DELETE FROM `lrf_mask_vertex_points` WHERE `vertex_id`={$A['id']}"; - $DATABASE->Query( $QS ); - }; - $QS = "DELETE FROM `lrf_mask_vertexes` WHERE `mask_id`={$MID}"; - $DATABASE->Query( $QS ); - $QS = "DELETE FROM `lrf_masks` WHERE `id`={$MID}"; + if( $DeleteMasks ){ + // Clear Mask No Points. + $QS = "SELECT * FROM `lrf_mask_vertexes` WHERE `mask_id`={$MID}"; + $ZA = $DATABASE->Query( $QS ); + foreach( $ZA as $A ){ + $QS = "DELETE FROM `lrf_mask_vertex_points` WHERE `vertex_id`={$A['id']}"; $DATABASE->Query( $QS ); - break; - }; - case 2:{ - // Don't Send To Device - if( $DSTS == 0 ){ - $CMD = 67;//60+$LayerID; - $QS = "INSERT INTO `nodes_qcq` (`node_id`,`cmd`,`parameter`) VALUES ({$NodeID},{$CMD},'{$LRFID}')"; - //echo $QS; - $DATABASE->Query( $QS, false ); - }; - break; }; + $QS = "DELETE FROM `lrf_mask_vertexes` WHERE `mask_id`={$MID}"; + $DATABASE->Query( $QS ); + $QS = "DELETE FROM `lrf_masks` WHERE `id`={$MID}"; + $DATABASE->Query( $QS ); + }; + if( $DSTS == 0 ){ + $RBASE = new SQLite_DB( '/dev/shm/argus/mem_db.db'); + $QS = "INSERT INTO `nodes_qcq`(`node_id`,`cmd`,`status`,`parameter`) VALUES({$NodeID},132,0,'')"; + $RBASE->Query( $QS, false ); + $Data[] = $CV; }; - $Data[] = $CV; - }; - if( $NPC > 2 ){ - // Need to shcedule Rasterisation and send to device - }; echo json_encode( $Data ); exit(); diff --git a/lib/javascript/jsapi_dynamic/mojo_dashboard.js b/lib/javascript/jsapi_dynamic/mojo_dashboard.js index bd3165e..7005960 100644 --- a/lib/javascript/jsapi_dynamic/mojo_dashboard.js +++ b/lib/javascript/jsapi_dynamic/mojo_dashboard.js @@ -186,6 +186,7 @@ function select2DROI( id, event ){ cc.setAttributeNS(null, "stroke", "#FFFF00" ); cc.setAttributeNS(null, "stroke-width", ""+(2*rk)+"" ); cc.setAttributeNS(null, "fill", "#0000FF" ); + cc.setAttributeNS(null, "clip-path", "url(#svg_mask_"+id+")" ); //cc.setAttributeNS(null, "fill-opacity", "0.4"); cc.setAttributeNS(null, "id", "roi"); csvg.appendChild( cc ); @@ -646,6 +647,8 @@ var targets_lts_2d=[]; var targets_2d_el=[]; var roi_2d=[]; var draws_2d=[]; +var masks_2d=[]; +var masks_2d_shown=[]; function cleanup2DTargets( a ){ targets_2d_el[a] = []; @@ -670,9 +673,15 @@ function draw2DTargets( a ){ cleanup2DDraw( a ); var csvg = document.getElementById( 'draw_svg_' + a ); if( csvg!= undefined ){ - var roi = csvg.getElementById( "roi" ); + var roi = csvg.getElementById( "roi" ); if( roi != null ) csvg.removeChild( roi ); - var bBox = csvg.getBBox(); + var cpath = csvg.getElementById( "svg_mask_"+a ); + var bBox; + if( cpath!=undefined){ + bBox = cpath.getBBox(); + } else { + bBox = csvg.getBBox(); + }; var max = 2048; switch( drawZoomLevels[a] ){ case 50: max = 1024; break; @@ -682,7 +691,7 @@ function draw2DTargets( a ){ var rk = bBox.width / ( max * 2 ); var cpx = bBox.width / 2.0; var cpy = bBox.height / 2.0; - + console.log( '2 box: '+ bBox.width+'x'+bBox.height ); if( targets_2d[a] != undefined ){ if( targets_2d[a].length ) { var ak = 2.0*Math.PI/360; @@ -722,6 +731,7 @@ function draw2DTargets( a ){ cc.setAttributeNS(null, "stroke", "#FFFF00" ); cc.setAttributeNS(null, "stroke-width", ""+(2*rz)+"" ); cc.setAttributeNS(null, "fill", "#0000FF" ); + cc.setAttributeNS(null, "clip-path", "url(#svg_mask_"+a+")" ); //cc.setAttributeNS(null, "fill-opacity", "0.4"); cc.setAttributeNS(null, "id", "roi"); csvg.appendChild( cc ); @@ -731,6 +741,107 @@ function draw2DTargets( a ){ }; }; +function cleanup2DMasks( a ){ + var csvg = document.getElementById( 'draw_svg_' + a ); + if( csvg!= undefined ){ + if( masks_2d_shown[a] != undefined ){ + for( i=0; i<5; i++){ + if( masks_2d_shown[a][i]!=undefined ){ + for( idx = 0; idx < masks_2d_shown[a][i].length; idx++ ){ + var juja = csvg.getElementById( "mask_"+a+"_"+i+"_"+idx ); + if( juja != null ) csvg.removeChild( juja ); + }; + }; + masks_2d_shown[a][i] = []; + }; + masks_2d_shown[a] = []; + }; + }; +}; + +function draw2DMasks( a, zzz='' ){ + cleanup2DMasks( a ); + if( masks_2d[a] != undefined ){ + if( zzz == '') zzz = 'draw_svg_'; + var csvg = document.getElementById( zzz + a ); + if( csvg != undefined ){ + masks_2d_shown[a] = []; + var cpath = csvg.getElementById( "svg_mask_"+a ); + var bBox; + if( cpath!=undefined){ + bBox = cpath.getBBox(); + } else { + bBox = csvg.getBBox(); + }; + var colors=['#FF0000','#FFFF00','#00FF00','#203080','#0000FF']; + for( i = 0; i<5; i++){ + masks_2d_shown[a][i] = []; + if( masks_2d[a][i].vtx != undefined ){ + console.log( '0 box: '+ bBox.width+'x'+bBox.height ); + var cpx = bBox.width / 2.0; + var cpy = bBox.height / 2.0; + var max = 2048; + switch( drawZoomLevels[a] ){ + case 50: max = 1024; break; + case 25: max = 512; break; + case 12: max = 256; break; + }; + var rk = bBox.width / ( max * 2 ); + for( k=0; k, + UID: , + SID: '', + ALL: 1, + NID: a + }, + success: function( response, opts ){ + var data = Ext.decode(response.responseText); + if( data.length > 4 ){ + //if( masks_2d[a] != undefined ){ + // masks_2d[a] = []; + //}; + masks_2d[a] = data; + } else masks_2d[a] = []; + draw2DMasks( a ); + }, + failure: failureAJAXFunction + }); +}; + function remove2DDraw( a ){ var csvg = document.getElementById( 'draw_svg_' + a ); if( csvg != undefined ){ @@ -751,9 +862,16 @@ function draw2DDraw( a, zzz = '' ){ var csvg = document.getElementById( zzz + a ); if( csvg != undefined ){ - var bBox = csvg.getBBox(); + var cpath = csvg.getElementById( "svg_mask_"+a ); + var bBox; + if( cpath!=undefined){ + bBox = cpath.getBBox(); + } else { + bBox = csvg.getBBox(); + }; var newpath = document.createElementNS('http://www.w3.org/2000/svg', "polygon"); var ak = 2.0*Math.PI/draws_2d[a].length; + console.log( '1 box: '+ bBox.width+'x'+bBox.height ); var cpx = bBox.width / 2.0; var cpy = bBox.height / 2.0; var max = 1024; @@ -808,6 +926,7 @@ function load2DDraw( a, id='' ){ if( data.count > 0 ){ draws_2d[a] = data.data; draw2DDraw( a, id ); + load2DMasks( a, id ); }; }, failure: failureAJAXFunction @@ -834,6 +953,7 @@ function set2DZoomLevel( a, zl ){ document.getElementById( 'r50_'+a ).setAttribute( 'stroke', '#FFF212'); document.getElementById( 'g_txt_'+a ).textContent = cSensor.max_range + ' m.'; draw2DDraw( a ); + draw2DMasks( a ); }; break; }; @@ -850,6 +970,7 @@ function set2DZoomLevel( a, zl ){ document.getElementById( 'r50_'+a ).setAttribute( 'stroke', '#FFF212'); document.getElementById( 'g_txt_'+a ).textContent = (cSensor.max_range / 2).toFixed(1)+' m.'; draw2DDraw( a ); + draw2DMasks( a ); }; break; }; @@ -864,7 +985,8 @@ function set2DZoomLevel( a, zl ){ document.getElementById( '50_txt_'+a ).textContent = (cSensor.max_range / 8).toFixed(1); document.getElementById( 'r50_'+a ).setAttribute( 'stroke', '#FFF212'); document.getElementById( 'g_txt_'+a ).textContent = (cSensor.max_range / 4).toFixed(1)+' m.'; - draw2DDraw( a ) + draw2DDraw( a ); + draw2DMasks( a ); }; break; }; @@ -879,11 +1001,14 @@ function set2DZoomLevel( a, zl ){ document.getElementById( 'r50_'+a ).setAttribute( 'stroke', '#00A859'); document.getElementById( 'g_txt_'+a ).textContent = (cSensor.max_range / 8).toFixed(1)+' m.'; draw2DDraw( a ); + draw2DMasks( a ); }; break; }; }; + draw2DTargets( a ); + }; function Drawss2DTargets( k, b ){ diff --git a/lib/javascript/jsapi_dynamic/rgoose_devices.js b/lib/javascript/jsapi_dynamic/rgoose_devices.js index ce91639..37d801f 100644 --- a/lib/javascript/jsapi_dynamic/rgoose_devices.js +++ b/lib/javascript/jsapi_dynamic/rgoose_devices.js @@ -1861,16 +1861,89 @@ function onMouseDown(event) { //movePath = ; //if( movePath ) MaskProject.activeLayer.addChild(hitResult.item); } - -function onMouseMove(event) { - MaskProject.activeLayer.selected = false; - if( event.item ) { - //event.item.selected = true; - event.item.fullySelected = true; +var c_m_X = 0; +var c_m_Y = 0; +function onMouseMove( e ) { + //e.preventDefault(); + //e.stopPropagation(); + var mx = parseInt( e.offsetX - deviceMapLeftShift ); + var my = parseInt( e.offsetY - deviceMapTopShift ); + if( ( mx != c_m_X ) || ( my!= c_m_Y ) ){ + c_m_X = mx; + c_m_Y = my; + var t = Ext.getCmp('me_coords_panel'); + if( t!= undefined ){ + var k = 2048 / ( cMapImageWidth ); + var j = 2048 / ( cMapImageHeight ); + var jaja = parseInt( mx * k - 1024 ); + var juju = parseInt( my * j - 1024 ); + if( juju != 0 ){ + if( juju < 0 ){ + az = ( Math.atan( jaja / juju ) * ( 180 / Math.PI )+90).toFixed(1); + } else { + az = ( Math.atan( jaja / juju ) * ( 180 / Math.PI )+270).toFixed(1); + }; + } else { + if( jaja < 0 ) { + az = 90; + } else { + az = 270; + }; + }; + range = ( ( ME_max_range / 1024 ) * Math.sqrt( Math.pow( jaja, 2 ) + Math.pow( juju, 2 ) )).toFixed(2); + t.update('Range:' + range + ' m. Azimuth:' + az + '°'); + }; + }; +} +function onPathMouseMove( event ) { + //event.preventDefault(); + //event.stopPropagation(); + var mx = event.point.x - deviceMapLeftShift; + var my = event.point.y - deviceMapTopShift; + if( ( mx != c_m_X ) || ( my != c_m_Y ) ){ + c_m_X = mx; + c_m_Y = my; + var t = Ext.getCmp('me_coords_panel'); + if( t!= undefined ){ + t.update(''+c_m_X+'x'+c_m_Y+''); + }; }; + //MaskProject.activeLayer.selected = false; + //if( event.item ) { + //event.item.selected = true; + // event.item.fullySelected = true; + //}; } function onMouseDrag(event) { + var mx = event.point.x - deviceMapLeftShift; + var my = event.point.y - deviceMapTopShift; + if( ( mx != c_m_X ) || ( my != c_m_Y ) ){ + c_m_X = mx; + c_m_Y = my; + var t = Ext.getCmp('me_coords_panel'); + if( t!= undefined ){ + var k = 2048 / ( cMapImageWidth ); + var j = 2048 / ( cMapImageHeight ); + var jaja = parseInt( c_m_X * k - 1024 ); + var juju = parseInt( c_m_Y * j - 1024 ); + if( juju != 0 ){ + if( juju < 0 ){ + az = ( Math.atan( jaja / juju ) * ( 180 / Math.PI )+90).toFixed(1); + } else { + az = ( Math.atan( jaja / juju ) * ( 180 / Math.PI )+270).toFixed(1); + }; + } else { + if( jaja < 0 ) { + az = 90; + } else { + az = 270; + }; + }; + range = ( ( ME_max_range / 1024 ) * Math.sqrt( Math.pow( jaja, 2 ) + Math.pow( juju, 2 ) )).toFixed(2); + t.update('Range:' + range + ' m. Azimuth:' + az + '°'); + }; + }; if( segment ){ //segment.point += event.delta; segment.point = event.point; @@ -1930,13 +2003,12 @@ function doMaskOperation( NodeID, Cmd, Mid = 0, LRFID = 0 ){ LID: LRFID }, success: function( response, opts ){ - //var data = Ext.decode(response.responseText); - //hideMaskEditor(); + load2DMasks( NodeID ); }, failure: failureAJAXFunction }); } - +var ME_max_range = 100; function showMaskEditor( fromDevTool, DevType, NodeID ){ //alert( "DevType: "+DevType + " Dev Map size: "+ absDrawMapSizes[DevType][0]+"x"+absDrawMapSizes[DevType][1] ); cMapType = DevType; @@ -1965,6 +2037,7 @@ function showMaskEditor( fromDevTool, DevType, NodeID ){ maskEditorDiv = document.createElement("div"); maskEditorDiv.style.height="200px"; maskEditorDiv.style.width="200px"; + maskEditorDiv.style.position="relative"; //var svg = document.getElementById('draw_svg_'+parseInt( NodeID ) ); //var svgCode = window.btoa(svg.outerHTML); //maskEditorDiv.style.background = "url(data:image/svg+xml;base64," + svgCode + ")"; @@ -1991,48 +2064,24 @@ function showMaskEditor( fromDevTool, DevType, NodeID ){ items:[{ xtype: 'panel', width: cMapCanvasWidth, - html: '
', + //html: '
', + html: '
', listeners:{ afterrender: function(){ //Doing a custom svg here for background! var chicha = document.getElementById( 'popomas' ); - var svg = document.getElementById('draw_svg_'+parseInt( NodeID ) ); - var svgCode = window.btoa(svg.outerHTML); - chicha.style.backgroundImage = "url(data:image/svg+xml;base64," + svgCode + ")"; + var cSensor = getSensorByNodeId( NodeID ); + if( cSensor!= null ){ + ME_max_range = cSensor.max_range; + } else { + ME_max_range = 100; + }; + //var svg = document.getElementById('draw_svg_'+parseInt( NodeID ) ); + //var svgCode = window.btoa(svg.outerHTML); + //chicha.style.backgroundImage = "url(data:image/svg+xml;base64," + svgCode + ")"; //chicha.style.backgroundImage = "url('style/wicons/011.png')"; - //alert( NodeID ); - /* - - var svg = document.querySelector('#svg'); - var svgCode = encodeURI(svg.outerHTML); - - element.style.backgroundImage = "url(data:image/svg+xml;utf8," + svgCode + ")"; - - function set_gridSize (num) { - num = Number(num); - - var xml = ' '; - var data = $($.parseXML(xml)); - - var defs = data.children("svg").children("defs"); - defs.children("#smallGrid").attr({ height: num, width: num }); - var path = defs.children("#smallGrid").children().attr("d"); - var arr = path.split(" "); - arr[1] = num; - arr[arr.length - 1] = num; - path = arr.join(" "); - defs.children("#smallGrid").children("path").attr("d", path) - defs.children("#grid").attr({ height: num * 10, width: num * 10 }); - defs.children("#grid").children("rect").attr({ height: num * 10, width: num * 10 }); - var path = defs.children("#grid").children("path").attr("d"); - var arr = path.split(" "); - arr[1] = num*10; - arr[arr.length - 1] = num*10; - path = arr.join(" "); - defs.children("#grid").children("path").attr("d", path); - - return "url(data:image/svg+xml;base64," + Base64.encode(new XMLSerializer().serializeToString(defs.parent()[0]))+")"; - }; */ + $("#mask_canvas").mousemove( onMouseMove ); + loadMaskDraw( NodeID ); } } }], @@ -2136,6 +2185,14 @@ function showMaskEditor( fromDevTool, DevType, NodeID ){ cMaskID = 4; loadDeviceMask( NodeID, cMaskID ); } + },'->',{ + xtype: 'panel', + frame: 'false', + id: 'me_coords_panel', + border: true, + width: 230, + height: 30, + html: '

kook

' }], buttons:[{ text: 'Cancel', @@ -2159,11 +2216,13 @@ function showMaskEditor( fromDevTool, DevType, NodeID ){ MIW: cMapImageWidth, //MSF: deviceMapScaling, MSHX: deviceMapLeftShift, - MSHY: deviceMapTopShift + MSHY: deviceMapTopShift, + DSTD: 0 }, success: function( response, opts ){ var data = Ext.decode(response.responseText); hideMaskEditor(); + load2DMasks( NodeID ); }, failure: failureAJAXFunction }); @@ -2199,6 +2258,73 @@ function showMaskEditor( fromDevTool, DevType, NodeID ){ }; }; +function loadMaskDraw( a ){ + + Ext.Ajax.request({ + url: '/lib/controller/getDeviceDraw.php', + params: { + UID: , + SID: '', + NID: a + }, + success: function( response, opts ){ + var data = Ext.decode(response.responseText); + if( data.count > 0 ){ + //draws_2d[a] = data.data; + var csvg = document.getElementById( 'draw_svg_me' ); + + if( csvg != undefined ){ + var draw = csvg.getElementById( "draw" ); + if( draw != null ) csvg.removeChild( draw ); + + var p2 = 2.0*Math.PI; + var so = -10 * p2 / 360.0; + + var bBox = csvg.getBBox(); + var newpath = document.createElementNS('http://www.w3.org/2000/svg', "polygon"); + var ak = 2.0*Math.PI/draws_2d[a].length; + var cpx = bBox.width / 2.0; + var cpy = bBox.height / 2.0; + var max = 1024; + //switch( drawZoomLevels[a] ){ + // case 50: max = 512; break; + // case 25: max = 256; break; + // case 12: max = 128; break; + //}; + var rk = bBox.width / ( max * 2 ); + var pp = ''; + var jj = ''; + for( i=0;i + + + +var devices = new Array(); +var cameras = new Array(); + +var systemDevicesAreLoadded = false; + +function loadSystemDevices(){ + Ext.Ajax.request({ + url: '/lib/controller/getSystemDevices.php', + params: { + UID: , + SID: '', + }, + success: function( response, opts ){ + // If the response is JSON, you have to decode it + var data = Ext.decode(response.responseText); + devices = data.sensors; + cameras = data.cameras; + systemDevicesAreLoadded = true; + }, + failure: failureAJAXFunction + }); +}; + +function getSensorByNodeId( NID ){ + if( systemDevicesAreLoadded ) for( i=0; i< devices.length; i++ ) if( devices[i].node_id == NID ) return devices[i]; + return null; +}; + +function getSensorById( SID ){ + if( systemDevicesAreLoadded ) for( i=0; i< devices.length; i++) if( devices[i].id == SID ) return devices[i]; + return null; +}; + +function getCameraByNodeId( NID ){ + if( systemDevicesAreLoadded ) for( i=0; i< cameras.length; i++) if( cameras[i].node_id == NID ) return cameras[i]; + return null; +}; + +function getCameraById( SID ){ + if( systemDevicesAreLoadded ) for( i=0; i< cameras.length; i++) if( cameras[i].id == SID ) return cameras[i]; + return null; +}; + + +var UartListStore = new Ext.data.JsonStore({ + root: 'ports', + totalProperty: 'totalCount', + idProperty: 'uart_id', + remoteSort: false, + baseParams: { + UID: 'Data['id'];?>', + SID: '', + SITE: + }, + fields: [{ + name: 'uart_id', + type: 'int' + },{ + name: 'uart_name', + type: 'string' + }], + proxy : new Ext.data.HttpProxy({ + method: 'POST', + prettyUrls: false, + url: '/lib/controller/listUarts.php' + }) +}); + +var ServersListStore = new Ext.data.JsonStore({ + root: 'servers', + totalProperty: 'totalCount', + idProperty: 'server_id', + remoteSort: false, + baseParams: { + UID: 'Data['id'];?>', + SID: '', + SITE: + }, + fields: [{ + name: 'server_id', + type: 'int' + },{ + name: 'server_name', + type: 'string' + }], + proxy : new Ext.data.HttpProxy({ + method: 'POST', + prettyUrls: false, + url: '/lib/controller/listServers.php' + }) +}); + +var ServerListStore = new Ext.data.JsonStore({ + root: 'servers', + totalProperty: 'totalCount', + idProperty: 'server_id', + remoteSort: false, + baseParams: { + UID: 'Data['id'];?>', + SID: '', + SITE: + }, + fields: [{ + name: 'server_id', + type: 'int' + },{ + name: 'server_name', + type: 'string' + }], + proxy : new Ext.data.HttpProxy({ + method: 'POST', + prettyUrls: false, + url: '/lib/controller/listServers.php' + }) +}); + +function loadSettingsLidar3D( NodeID, Master ){ + SelectedNodeID = NodeID; + Ext.Ajax.request({ + url: '/lib/controller/getSettingsLidsr3D.php', + params: { + NID: NodeID, + MST: ((Master)?1:0), + UID: , + SID: '', + }, + success: function( response, opts ){ + // If the response is JSON, you have to decode it + var data = Ext.decode(response.responseText); + Ext.getCmp('setting_master_ip').setValue( data.ip_address ); + Ext.getCmp('setting_master_port').setValue( data.port ); + Ext.getCmp('setting_slave_ip').setValue( data.aux_ip_address ); + Ext.getCmp('setting_slave_port').setValue( data.aux_port ); + Ext.getCmp('setting_lat').setValue( data.lat ); + Ext.getCmp('setting_lon').setValue( data.lon ); + Ext.getCmp('setting_alt').setValue( data.alt ); + Ext.getCmp('setting_roll').setValue( data.roll ); + Ext.getCmp('setting_pitch').setValue( data.pitch ); + Ext.getCmp('setting_yaw').setValue( data.yaw ); + }, + failure: failureAJAXFunction + }); +}; + +function saveSettingsLidar3D( ){ + if( SelectedNodeID == 0 ) return; + t1 = Ext.getCmp('setting_master_ip').getValue(); + t2 = Ext.getCmp('setting_master_port').getValue(); + t3 = Ext.getCmp('setting_slave_ip').getValue(); + t4 = Ext.getCmp('setting_slave_port').getValue(); + t5 = Ext.getCmp('setting_lat').getValue(); + t6 = Ext.getCmp('setting_lon').getValue(); + t7 = Ext.getCmp('setting_alt').getValue(); + t8 = Ext.getCmp('setting_roll').getValue(); + t9 = Ext.getCmp('setting_pitch').getValue(); + t10 = Ext.getCmp('setting_yaw').getValue(); + Ext.Ajax.request({ + url: '/lib/controller/setSettingsLidsr3D.php', + params: { + NID: SelectedNodeID, + UID: , + SID: '', + MIP: t1, + MPP: t2, + SIP: t3, + SPP: t4, + LAT: t5, + LON: t6, + ALT: t7, + ROL: t8, + PCH: t9, + YAW: t10 + }, + success: function( response, opts ){ + // If the response is JSON, you have to decode it + var data = Ext.decode(response.responseText); + if( data.success == true ) { + Ext.Msg.show({ + title:'GetLabel("_INFO_MSG_");?>', + msg: 'GetLabel("_SETTING_SAVE_OK_");?>', + buttons: Ext.Msg.OK,//YESNOCANCEL, + fn: function(){ + SettingsLidar3D.hide(); + }, + //animEl: 'elId', + icon: Ext.MessageBox.INFO //QUESTION + }); + } else { + Ext.Msg.show({ + title:'GetLabel("_ERROR_MSG_");?>', + msg: data['error'], + buttons: Ext.Msg.OK,//YESNOCANCEL, + fn: function(){ + SettingsLidar3D.hide(); + }, + //animEl: 'elId', + icon: Ext.MessageBox.ERROR //QUESTION + }); + }; + }, + failure: failureAJAXFunction + }); +}; + + +function editSettingsLidar3D( NodeID, Master ){ + if( SettingsLidar3D == null ){ + SettingsLidar3D = new Ext.Window({ + modal: true, + title: 'GetLabel("_EDIT_LRF3D_SETTINGS_");?>', + width: 773, + height: 600, + layout: 'fit', + closeAction: 'hide', + listeners:{ + beforehide : function(){ + Ext.getCmp('connectstarterbutton').toggle( false, false ); + } + }, + items:[{ + layout: 'table', + border: false, + defaults: { + // applied to each contained panel + bodyStyle:'padding-top:10px;padding-left:20px;padding-right:20px;padding-bottom:10px;' + }, + layoutConfig: { + // The total column count must be specified here + columns: 4 + }, + items: [{ + border: false, + html: 'Master IP Address:' + },{ + xtype: 'textfield', + id: 'setting_master_ip', + width: '70%' + },{ + border: false, + html: 'Port:' + },{ + xtype: 'textfield', + id: 'setting_master_port', + width: '30%' + },{ + border: false, + html: 'Slave IP Address:' + },{ + xtype: 'textfield', + id: 'setting_slave_ip', + width: '70%' + },{ + border: false, + html: 'Port:' + },{ + xtype: 'textfield', + id: 'setting_slave_port', + width: '30%' + },{ + border: false, + html: 'Position Lat/Lon/Alt:' + },{ + xtype: 'textfield', + id: 'setting_lat', + width: '30%' + },{ + xtype: 'textfield', + id: 'setting_lon', + width: '30%' + },{ + xtype: 'textfield', + id: 'setting_alt', + width: '30%' + },{ + border: false, + html: 'Orientation Roll/Pitch/Yaw:' + },{ + xtype: 'textfield', + id: 'setting_roll', + width: '30%' + },{ + xtype: 'textfield', + id: 'setting_pitch', + width: '30%' + },{ + xtype: 'textfield', + id: 'setting_yaw', + width: '30%' + }] + }], + bbar: [{ + text: 'GetLabel("_CANCEL_");?>', + handler: function(){ + SettingsLidar3D.hide(); + } + },{ + text: 'GetLabel("_SAVE_");?>', + handler: SaveSettingsLidar3D + }] + }); + }; + SettingsLidar3D.show(); + loadSettingsLidar3D( NodeID, Master ); +}; + +var devicesStore = new Ext.data.JsonStore({ + root: 'nodes', + totalProperty: 'totalCount', + idProperty: 'id', + remoteSort: true, + fields: [{ + name: 'id', + type: 'int' + },{ + name: 'name', + type: 'string' + },{ + name: 'hardware', + type: 'string' + },{ + name: 'caps', + type: 'int' + },{ + name: 'ip', + type: 'string' + },{ + name: 'mac', + type: 'string' + }], + proxy : new Ext.data.HttpProxy({ + method: 'POST', + prettyUrls: false, + url: '/lib/controller/listDiscoveredCameraSources.php', + headers: { + 'UID': 'Data['id'];?>', + 'SID': '' + } + }) +}); + +var LRF1D2_st_win = null; +var LRF2D2_st_win = null; +var LRF16D3_st_win = null; + +var currentDeviceOperatioId = 0; +var currentOperationTO = 0; +var currentOperationTimer = null; +var lastOperationCode = 0; +function checkDeviceOperationStatus(){ + if( currentOperationTO ){ + currentOperationTO--; + Ext.Ajax.request({ + url: '/lib/controller/checkDeviceOperation.php', + params: { + OID: currentDeviceOperatioId, + UID: 'Data['id'];?>', + SID: '' + }, + success: function( response, opts ){ + var data = Ext.decode(response.responseText); + if( !data.success ){ + Ext.MessageBox.hide(); + Ext.Msg.show({ + title:'Node Command Status', + msg: data.msg, + buttons: Ext.Msg.OK, + icon: Ext.MessageBox.ERROR + }); + } else { + if( lastOperationCode != data.code || data.code == 0 ){ + lastOperationCode = data.code; + currentOperationTO = 20; + }; + if( data.code < 100 ){ + currentOperationTimer = window.setTimeout( checkDeviceOperationStatus, 100 ); + } else { + Ext.MessageBox.hide(); + switch( data.code ){ + case 120: + case 100: + default: + Ext.Msg.show({ + title:'Node Command Status', + msg: 'Operation Complete', + buttons: Ext.Msg.OK, + icon: Ext.MessageBox.INFO + }); + }; + }; + }; + }, + failure: failureAJAXFunction + }); + } else { + Ext.MessageBox.hide(); + Ext.Msg.show({ + title:'Node Command Status', + msg: 'Operation Status - Time Out!', + buttons: Ext.Msg.OK, + icon: Ext.MessageBox.ERROR + }); + }; +}; + +function doDeviceOperation( NodeID, OpCode, Param='', nowait=false ){ + if( !nowait ){ + Ext.MessageBox.wait("GetLabel('_Loading_Calo_');?>","GetLabel('_Please_Wait_');?>",{ + width: '100%', + hidden: true, + progress: true, + closable: false + }); + }; + + Ext.Ajax.request({ + url: '/lib/controller/doNodeOperation.php', + params: { + NID: NodeID, + UID: 'Data['id'];?>', + CMD: OpCode, + SID: '', + PARAM: Param + }, + success: function( response, opts ){ + var data = Ext.decode(response.responseText); + if( !data.success ){ + if( !nowait ) Ext.MessageBox.hide(); + Ext.Msg.show({ + title:'Node Command Status', + msg: data.msg, + buttons: Ext.Msg.OK, + icon: Ext.MessageBox.ERROR + }); + } else { + if( !nowait ){ + currentDeviceOperatioId = data.operation_id; + currentOperationTO = 20; + lastOperationCode = 0; + currentOperationTimer = window.setTimeout( checkDeviceOperationStatus, 100 ); + }; + }; + }, + failure: failureAJAXFunction + }); +}; + +function clearDeviceEvents( NodeID ){ + Ext.Ajax.request({ + url: '/lib/controller/clearEventCloud.php', + params: { + NID: NodeID, + UID: 'Data['id'];?>', + SID: '' + }, + success: function( response, opts ){ + }, + failure: failureAJAXFunction + }); +}; + +function loadFullLRF1D2Data( NodeID ){ + + if( LRF1D2_st_win == null ) return; + + Ext.Ajax.request({ + url: '/lib/controller/getSettingsLRF.php', + params: { + NID: NodeID, + UID: 'Data['id'];?>', + SID: '', + }, + success: function( response, opts ){ + if( LRF1D2_st_win!= null ){ + var data = Ext.decode(response.responseText); + if( data.online ){ + switch( data.data_status ){ + case 0: Ext.getCmp('dev_online').update('

ONLINE/Data Incomplete

'); break; + case 1: Ext.getCmp('dev_online').update('

ONLINE/Synced

'); break; + case 2: Ext.getCmp('dev_online').update('

ONLINE/Data Not Applyed

'); break; + }; + } else { + switch( data.data_status ){ + case 0: Ext.getCmp('dev_online').update('

OFFLINE/Data Incomplete

'); break; + case 1: Ext.getCmp('dev_online').update('

OFFLINE/Synced

'); break; + case 2: Ext.getCmp('dev_online').update('

OFFLINE/Data Not Applyed

'); break; + }; + }; + Ext.getCmp('dev_name').setValue( data.name ); + Ext.getCmp('serial_num').setValue( data.serial ); + Ext.getCmp('version_id').setValue( data.version ); + Ext.getCmp('device_id').setValue( data.device_id ); + Ext.getCmp('com_spd').setValue( data.com_spd ); + Ext.getCmp('max_range').setValue( data.max_range ); + Ext.getCmp('base_shift').setValue( data.base_shift ); + Ext.getCmp('com_spd').setValue( data.uart_speed ); + Ext.getCmp('mlrf_offset').setValue( data.m_offset ); + Ext.getCmp('slrf_offset').setValue( data.s_offset ); + Ext.getCmp('mlrf_delta').setValue( data.m_delta ); + Ext.getCmp('slrf_delta').setValue( data.s_delta ); + Ext.getCmp('mlrf_width').setValue( data.m_width ); + Ext.getCmp('slrf_width').setValue( data.s_width ); + Ext.getCmp('mlrf_order').setValue( data.m_order ); + Ext.getCmp('slrf_order').setValue( data.s_order ); + Ext.getCmp('mlrf_sst').setValue( data.m_sst ); + Ext.getCmp('slrf_sst').setValue( data.s_sst ); + Ext.getCmp('mlrf_flip').setValue( data.m_flip ); + Ext.getCmp('slrf_flip').setValue( data.s_flip ); + Ext.getCmp('mlrf_sun').setValue( data.m_sun ); + Ext.getCmp('slrf_sun').setValue( data.s_sun ); + }; + }, + failure: failureAJAXFunction + }); +}; + +function loadFullLRF2D2Data( NodeID ){ + + if( LRF2D2_st_win == null ) return; + + Ext.Ajax.request({ + url: '/lib/controller/getSettingsLRF.php', + params: { + NID: NodeID, + UID: 'Data['id'];?>', + SID: '', + }, + success: function( response, opts ){ + if( LRF2D2_st_win!= null ){ + var data = Ext.decode(response.responseText); + if( data.online ){ + switch( data.data_status ){ + case 0: Ext.getCmp('LRF2D2_dev_status').update('

ONLINE/Data Incomplete

'); break; + case 1: Ext.getCmp('LRF2D2_dev_status').update('

ONLINE/Synced

'); break; + case 2: Ext.getCmp('LRF2D2_dev_status').update('

ONLINE/Data Not Applyed

'); break; + }; + } else { + switch( data.data_status ){ + case 0: Ext.getCmp('LRF2D2_dev_status').update('

OFFLINE/Data Incomplete

'); break; + case 1: Ext.getCmp('LRF2D2_dev_status').update('

OFFLINE/Synced

'); break; + case 2: Ext.getCmp('LRF2D2_dev_status').update('

OFFLINE/Data Not Applyed

'); break; + }; + }; + Ext.getCmp('LRF2D2_name').setValue( data.name ); + Ext.getCmp('LRF2D2_serial_num').setValue( data.serial ); + Ext.getCmp('LRF2D2_version_id').setValue( data.version ); + Ext.getCmp('LRF2D2_device_id').setValue( data.device_id ); + Ext.getCmp('LRF2D2_com_spd').setValue( data.com_spd ); + Ext.getCmp('LRF2D2_max_range').setValue( data.max_range ); + Ext.getCmp('LRF2D2_base_shift').setValue( data.base_shift ); + Ext.getCmp('LRF2D2_com_spd').setValue( data.uart_speed ); + Ext.getCmp('mlrf_offset').setValue( data.master_profile.offset ); + Ext.getCmp('slrf_offset').setValue( data.slave_profile.offset ); + Ext.getCmp('mlrf_delta').setValue( data.master_profile.delta ); + Ext.getCmp('slrf_delta').setValue( data.slave_profile.delta ); + Ext.getCmp('mlrf_width').setValue( data.master_profile.width ); + Ext.getCmp('slrf_width').setValue( data.slave_profile.width ); + Ext.getCmp('mlrf_order').setValue( data.master_profile.order ); + Ext.getCmp('slrf_order').setValue( data.slave_profile.order ); + Ext.getCmp('mlrf_sst').setValue( data.master_profile.sst ); + Ext.getCmp('slrf_sst').setValue( data.slave_profile.sst ); + Ext.getCmp('mlrf_flip').setValue( data.master_profile.flip ); + Ext.getCmp('slrf_flip').setValue( data.slave_profile.flip ); + Ext.getCmp('mlrf_sun').setValue( data.master_profile.sun ); + Ext.getCmp('slrf_sun').setValue( data.slave_profile.sun ); + }; + }, + failure: failureAJAXFunction + }); +}; + +function LRF1D2_settings(){ + if( LRF1D2_st_win == null ){ + LRF1D2_st_win = new Ext.Window({ + title: 'Sensor Settings', + modal: true, + width: 800, + height: 600, + closeAction: 'hide', + items:{ + xtype: 'tabpanel', + activeTab: 0, + items:[{ + title: 'General Settings', + xtype: 'form', + layout: 'table', + defaults: { + bodyStyle:'padding:20px' + }, + layoutConfig: { + columns: 3 + }, + items:[{ + html: 'Status', + frame: false, + border: false + },{ + html: '

ONLINE

', + id: 'dev_online', + frame: false, + border: false + },{},{ + html: 'Device Title', + frame: false, + border: false + },{ + xtype: 'field', + id: 'dev_name', + readOnly: false, + value: 'KOKO' + },{},{ + html: 'Serial Number', + frame: false, + border: false + },{ + xtype: 'field', + id: 'serial_num', + readOnly: true, + value: '1212' + },{},{ + html: 'Version ID', + frame: false, + border: false + },{ + xtype: 'field', + id: 'version_id', + readOnly: true, + value: 'LiberManDA122' + },{},{ + html: 'Device Adress', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'device_id' + },{ + xtype: 'button', + id: 'upddiBTN', + text: 'Update Device Address', + handler: function(){ + Ext.Msg.show({ + title:'Update Device Address?', + msg: 'Are you sure to do so?', + buttons: Ext.Msg.YESNOCANCEL, + //fn: processResult, + animEl: 'upddiBTN', + icon: Ext.MessageBox.QUESTION + }); + } + },{ + html: 'Device COM Speed', + frame: false, + border: false + },{ + xtype: 'combo', + id: 'com_spd', + editable: false, + typeAhead: true, + triggerAction: 'all', + width: '100%', + lazyRender:true, + mode: 'local', + store: new Ext.data.ArrayStore({ + id: 0, + fields: ['mySPD', 'displayText' ], + data: [[4800,'4800'],[9600,'9600'],[14400,'14400'],[19200,'19200'],[38400, '38400'],[56000,'56000'],[57600,'57600'],[115200,'115200']] + }), + valueField: 'mySPD', + displayField: 'displayText' + },{ + xtype: 'button', + id: 'updspBTN', + text: 'Set Device Speed', + handler: function(){ + Ext.Msg.show({ + title:'Update Device Speed?', + msg: 'Are you sure to do so?', + buttons: Ext.Msg.YESNOCANCEL, + //fn: processResult, + animEl: 'upddiBTN', + icon: Ext.MessageBox.QUESTION + }); + } + },{ + html: 'Detection Maximal Range', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'max_range', + readOnly: true, + value: '1212' + },{},{ + html: 'Base Shift', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'base_shift', + readOnly: true, + value: '1212' + },{}] + },{ + title: 'Mantenence', + xtype: 'form', + layout: 'table', + defaults: { + bodyStyle:'padding:20px' + }, + layoutConfig: { + columns: 2 + }, + items:[{ + html: 'Restart Device', + frame: false, + border: false + },{ + xtype: 'button', + id: 'rstBTN', + text: 'Full Reset', + handler: function(){ + Ext.Msg.show({ + title:'Reset Device?', + msg: 'You are closing a tab that has unsaved changes. Would you like to save your changes?', + buttons: Ext.Msg.YESNOCANCEL, + //fn: processResult, + animEl: 'rstBTN', + icon: Ext.MessageBox.QUESTION + }); + } + }] + },{ + title: 'Detection Settings', + xtype: 'form', + layout: 'table', + defaults: { + bodyStyle:'padding:20px' + }, + layoutConfig: { + columns: 4 + }, + items:[{ + html: 'Master Offset', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'mlrf_offset', + name: 'mlrf_offset', + allowBlank: false, + allowDecimals: false, + maxText: 'The Range is: 0 - 60', + maxValue: 60, + minText: 'No Negative Values Allowed', + minValue: 0, + },{ + html: 'Slave Offset', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'slrf_offset', + name: 'slrf_offset', + allowBlank: false, + allowDecimals: false, + maxText: 'The Range is: 0 - 60', + maxValue: 60, + minText: 'No Negative Values Allowed', + minValue: 0, + },{ + html: 'Master Delta', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'mlrf_delta', + name: 'mlrf_delta', + allowBlank: false, + allowDecimals: false, + maxText: 'The Range is: 0 - 320', + maxValue: 320, + minText: 'No Negative Values Allowed', + minValue: 0 + },{ + html: 'Slave Delta', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'slrf_delta', + name: 'slrf_delta', + allowBlank: false, + allowDecimals: false, + maxText: 'The Range is: 0 - 320', + maxValue: 320, + minText: 'No Negative Values Allowed', + minValue: 0 + },{ + html: 'Master Width', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'mlrf_width', + name: 'mlrf_width', + allowBlank: false, + allowDecimals: false, + maxText: 'The Range is: 1800 - 16000', + maxValue: 16000, + minText: 'The Range is: 1800 - 16000', + minValue: 1800 + },{ + html: 'Slave Width', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'slrf_width', + name: 'slrf_width', + allowBlank: false, + allowDecimals: false, + maxText: 'The Range is: 1800 - 16000', + maxValue: 16000, + minText: 'The Range is: 1800 - 16000', + minValue: 1800 + },{ + html: 'Master Order', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'mlrf_order', + name: 'mlrf_order', + allowBlank: false, + allowDecimals: false, + maxText: 'The Range is: 0 - 10', + maxValue: 10, + minText: 'No Negative Values Allowed', + minValue: 0 + },{ + html: 'Slave Order', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'slrf_order', + name: 'slrf_order', + allowBlank: false, + allowDecimals: false, + maxText: 'The Range is: 0 - 10', + maxValue: 10, + minText: 'No Negative Values Allowed', + minValue: 0 + },{ + html: 'Master SST', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'mlrf_sst', + name: 'mlrf_sst', + allowBlank: false, + allowDecimals: false, + maxText: 'The Range is: 0 - 100', + maxValue: 100, + minText: 'No Negative Values Allowed', + minValue: 0 + },{ + html: 'Slave SST', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'slrf_sst', + name: 'slrf_sst', + allowBlank: false, + allowDecimals: false, + maxText: 'The Range is: 0 - 100', + maxValue: 100, + minText: 'No Negative Values Allowed', + minValue: 0 + },{ + html: 'Mastr Flip', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'mlrf_flip', + name: 'mlrf_flip', + allowBlank: false, + allowDecimals: false, + maxText: 'The Range is: 8 - 128', + maxValue: 128, + minText: 'The Range is: 8 - 128', + minValue: 8 + },{ + html: 'Slave Flip', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'slrf_flip', + name: 'slrf_flip', + allowBlank: false, + allowDecimals: false, + maxText: 'The Range is: 8 - 128', + maxValue: 128, + minText: 'The Range is: 8 - 128', + minValue: 8 + },{ + html: 'Master Sun', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'mlrf_sun', + name: 'mlrf_sun', + allowBlank: false, + allowDecimals: false, + maxText: 'The Range is: 0 - 100', + maxValue: 100, + minText: 'No Negative Values Allowed', + minValue: 0 + },{ + html: 'Slave Sun', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'slrf_sun', + name: 'slrf_sun', + allowBlank: false, + allowDecimals: false, + maxText: 'The Range is: 0 - 100', + maxValue: 100, + minText: 'No Negative Values Allowed', + minValue: 0 + }] + },{ + title: 'Embed Options' + },{ + title: 'Target Width Table' + }] + } + }); + }; + LRF1D2_st_win.show(); + loadFullLRF1D2Data( SelectedNodeID ); +}; + +function LRF2D2_settings(){ + if( LRF2D2_st_win == null ){ + LRF2D2_st_win = new Ext.Window({ + title: 'Sensor Settings', + modal: true, + width: 800, + height: 600, + closeAction: 'hide', + items:{ + xtype: 'tabpanel', + activeTab: 0, + items:[{ + title: 'General Settings', + xtype: 'form', + layout: 'table', + defaults: { + bodyStyle:'padding:20px' + }, + layoutConfig: { + columns: 3 + }, + items:[{ + html: 'Status', + frame: false, + border: false + },{ + html: '

ONLINE

', + id: 'LRF2D2_dev_status', + frame: false, + border: false + },{},{ + html: 'Device Title', + frame: false, + border: false + },{ + xtype: 'field', + id: 'LRF2D2_name', + readOnly: false, + value: '' + },{},{ + html: 'Serial Number', + frame: false, + border: false + },{ + xtype: 'field', + id: 'LRF2D2_serial_num', + readOnly: true, + value: '1212' + },{},{ + html: 'Version ID', + frame: false, + border: false + },{ + xtype: 'field', + id: 'LRF2D2_version_id', + readOnly: true, + value: 'LiberManDA122' + },{},{ + html: 'Device Adress', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'LRF2D2_device_id' + },{ + xtype: 'button', + text: 'Update Device Address', + handler: function(){ + Ext.Msg.show({ + title:'Update Device Address?', + msg: 'Are you sure to do so?', + buttons: Ext.Msg.YESNOCANCEL, + //fn: processResult, + animEl: 'upddiBTN', + icon: Ext.MessageBox.QUESTION + }); + } + },{ + html: 'Device COM Speed', + frame: false, + border: false + },{ + xtype: 'combo', + id: 'LRF2D2_com_spd', + editable: false, + typeAhead: true, + triggerAction: 'all', + width: '100%', + lazyRender:true, + mode: 'local', + store: new Ext.data.ArrayStore({ + id: 0, + fields: ['mySPD', 'displayText' ], + data: [[4800,'4800'],[9600,'9600'],[14400,'14400'],[19200,'19200'],[38400, '38400'],[56000,'56000'],[57600,'57600'],[115200,'115200']] + }), + valueField: 'mySPD', + displayField: 'displayText' + },{ + xtype: 'button', + text: 'Set Device Speed', + handler: function(){ + Ext.Msg.show({ + title:'Update Device Speed?', + msg: 'Are you sure to do so?', + buttons: Ext.Msg.YESNOCANCEL, + //fn: processResult, + animEl: 'upddiBTN', + icon: Ext.MessageBox.QUESTION + }); + } + },{ + html: 'Detection Maximal Range', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'LRF2D2_max_range', + readOnly: false, + value: '1212' + },{},{ + html: 'Base Shift', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'LRF2D2_base_shift', + readOnly: false, + value: '1212' + },{ + xtype: 'button', + text: 'Update Base Shift', + handler: function(){ + var bash = Ext.getCmp('LRF2D2_base_shift').getValue(); + Ext.Ajax.request({ + url: '/lib/controller/updateLrfSettings_baseshift.php', + params: { + NID: SelectedNodeID, + UID: 'Data['id'];?>', + SID: '', + PID: 0, + BASH: bash + }, + success: function( response, opts ){ + loadFullLRF2D2Data( SelectedNodeID ); + }, + failure: failureAJAXFunction + }); + } + }] + },{ + title: 'Detection Settings', + xtype: 'form', + layout: 'table', + defaults: { + bodyStyle:'padding:20px' + }, + layoutConfig: { + columns: 4 + }, + items:[{ + html: 'Master Offset', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'mlrf_offset', + name: 'mlrf_offset', + allowBlank: false, + allowDecimals: false, + maxText: 'The Range is: 0 - 60', + maxValue: 60, + minText: 'No Negative Values Allowed', + minValue: 0, + },{ + html: 'Slave Offset', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'slrf_offset', + name: 'slrf_offset', + allowBlank: false, + allowDecimals: false, + maxText: 'The Range is: 0 - 60', + maxValue: 60, + minText: 'No Negative Values Allowed', + minValue: 0, + },{ + html: 'Master Delta', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'mlrf_delta', + name: 'mlrf_delta', + allowBlank: false, + allowDecimals: false, + maxText: 'The Range is: 0 - 320', + maxValue: 320, + minText: 'No Negative Values Allowed', + minValue: 0 + },{ + html: 'Slave Delta', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'slrf_delta', + name: 'slrf_delta', + allowBlank: false, + allowDecimals: false, + maxText: 'The Range is: 0 - 320', + maxValue: 320, + minText: 'No Negative Values Allowed', + minValue: 0 + },{ + html: 'Master Width', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'mlrf_width', + name: 'mlrf_width', + allowBlank: false, + allowDecimals: false, + maxText: 'The Range is: 1800 - 16000', + maxValue: 16000, + minText: 'The Range is: 1800 - 16000', + minValue: 1800 + },{ + html: 'Slave Width', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'slrf_width', + name: 'slrf_width', + allowBlank: false, + allowDecimals: false, + maxText: 'The Range is: 1800 - 16000', + maxValue: 16000, + minText: 'The Range is: 1800 - 16000', + minValue: 1800 + },{ + html: 'Master Order', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'mlrf_order', + name: 'mlrf_order', + allowBlank: false, + allowDecimals: false, + maxText: 'The Range is: 0 - 10', + maxValue: 10, + minText: 'No Negative Values Allowed', + minValue: 0 + },{ + html: 'Slave Order', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'slrf_order', + name: 'slrf_order', + allowBlank: false, + allowDecimals: false, + maxText: 'The Range is: 0 - 10', + maxValue: 10, + minText: 'No Negative Values Allowed', + minValue: 0 + },{ + html: 'Master SST', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'mlrf_sst', + name: 'mlrf_sst', + allowBlank: false, + allowDecimals: false, + maxText: 'The Range is: 0 - 100', + maxValue: 100, + minText: 'No Negative Values Allowed', + minValue: 0 + },{ + html: 'Slave SST', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'slrf_sst', + name: 'slrf_sst', + allowBlank: false, + allowDecimals: false, + maxText: 'The Range is: 0 - 100', + maxValue: 100, + minText: 'No Negative Values Allowed', + minValue: 0 + },{ + html: 'Mastr Flip', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'mlrf_flip', + name: 'mlrf_flip', + allowBlank: false, + allowDecimals: false, + maxText: 'The Range is: 8 - 128', + maxValue: 128, + minText: 'The Range is: 8 - 128', + minValue: 8 + },{ + html: 'Slave Flip', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'slrf_flip', + name: 'slrf_flip', + allowBlank: false, + allowDecimals: false, + maxText: 'The Range is: 8 - 128', + maxValue: 128, + minText: 'The Range is: 8 - 128', + minValue: 8 + },{ + html: 'Master Sun', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'mlrf_sun', + name: 'mlrf_sun', + allowBlank: false, + allowDecimals: false, + maxText: 'The Range is: 0 - 100', + maxValue: 100, + minText: 'No Negative Values Allowed', + minValue: 0 + },{ + html: 'Slave Sun', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'slrf_sun', + name: 'slrf_sun', + allowBlank: false, + allowDecimals: false, + maxText: 'The Range is: 0 - 100', + maxValue: 100, + minText: 'No Negative Values Allowed', + minValue: 0 + },{ + xtype: 'button', + text: 'Update Detection Settings', + width: '100%', + colspan: 4, + handler: function(){ + var MOFS=Ext.getCmp('mlrf_offset').getValue(); + var MDEL=Ext.getCmp('mlrf_delta').getValue(); + var MWIT=Ext.getCmp('mlrf_width').getValue(); + var MORD=Ext.getCmp('mlrf_order').getValue(); + var MSST=Ext.getCmp('mlrf_sst').getValue(); + var MFLP=Ext.getCmp('mlrf_flip').getValue(); + var MSUN=Ext.getCmp('mlrf_sun').getValue(); + var SOFS=Ext.getCmp('slrf_offset').getValue(); + var SDEL=Ext.getCmp('slrf_delta').getValue(); + var SWIT=Ext.getCmp('slrf_width').getValue(); + var SORD=Ext.getCmp('slrf_order').getValue(); + var SSST=Ext.getCmp('slrf_sst').getValue(); + var SFLP=Ext.getCmp('slrf_flip').getValue(); + var SSUN=Ext.getCmp('slrf_sun').getValue(); + Ext.Ajax.request({ + url: '/lib/controller/updateDetecttionProfile.php', + params: { + NID: SelectedNodeID, + UID: 'Data['id'];?>', + SID: '', + PID: 0, + MOFS: MOFS, + MDEL: MDEL, + MWIT: MWIT, + MORD: MORD, + MSST: MSST, + MFLP: MFLP, + MSUN: MSUN, + SOFS: SOFS, + SDEL: SDEL, + SWIT: SWIT, + SORD: SORD, + SSST: SSST, + SFLP: SFLP, + SSUN: SSUN + }, + success: function( response, opts ){ + loadFullLRF2D2Data( SelectedNodeID ); + }, + failure: failureAJAXFunction + }); + } + }] + },{ + title: 'Embed Options' + },{ + title: 'Target Width Table' + },{ + title: 'Mantenence', + xtype: 'form', + layout: 'table', + defaults: { + bodyStyle:'padding:20px' + }, + layoutConfig: { + columns: 2 + }, + items:[{ + html: 'Restart Device', + frame: false, + border: false + },{ + xtype: 'button', + id: 'rstBTN', + text: 'Full Reset', + handler: function(){ + Ext.Msg.show({ + title:'Reset Device?', + msg: 'You are closing a tab that has unsaved changes. Would you like to save your changes?', + buttons: Ext.Msg.YESNOCANCEL, + //fn: processResult, + animEl: 'rstBTN', + icon: Ext.MessageBox.QUESTION + }); + } + }] + }] + } + }); + }; + LRF2D2_st_win.show(); + loadFullLRF2D2Data( SelectedNodeID ); +}; + +function LRF16D3_settings(){ +}; + +var currentResolveDeviceNode = 0; +var ResolveDeviceNodeWin = null; + +function resolveDeviceMistmatch( NodeID ){ + currentResolveDeviceNode = NodeID; + if( ResolveDeviceNodeWin == null ){ + ResolveDeviceNodeWin = new Ext.Window({ + title: 'GetLabel('_WDEV_MISTMATCH_');?>', + modal: true, + width: 500, + height: 200, + closeAction: 'hide', + items:[{ + xtype: 'spacer', + style: { + marginTop: '13px' + }, + html: '
GetLabel('_DEV_MISTMATT1_');?>
', + height: 30 + },{ + xtype: 'button', + width: '100%', + text: 'It is Newly Connected Device', + handler: function(){ + Ext.Ajax.request({ + url: '/lib/controller/validateNode.php', + params: { + NID: currentResolveDeviceNode, + UID: 'Data['id'];?>', + SID: '', + MET: 1 + }, + success: function( response, opts ){ + ResolveDeviceNodeWin.hide(); + }, + failure: failureAJAXFunction + }); + } + },{ + xtype: 'button', + width: '100%', + text: 'Apply Existing Detection Profiles to Newly Connected Device', + handler: function(){ + Ext.Ajax.request({ + url: '/lib/controller/validateNode.php', + params: { + NID: currentResolveDeviceNode, + UID: 'Data['id'];?>', + SID: '', + MET: 1 + }, + success: function( response, opts ){ + ResolveDeviceNodeWin.hide(); + }, + failure: failureAJAXFunction + }); + } + },{ + xtype: 'button', + width: '100%', + text: 'Discard old Detection Profiles and Start Device Setup Wizard', + handler: function(){ + ResolveDeviceNodeWin.hide(); + startDeviceDetectionWizard( currentResolveDeviceNode ); + } + },{ + xtype: 'button', + width: '100%', + text: 'Discard old Detection Profiles and Load Factory Settings from Device' + },{ + xtype: 'button', + width: '100%', + text: 'Discard this Connection for NOW' + }] + }); + }; + ResolveDeviceNodeWin.show(); +}; + +var DeviceDetectionWizardWnd = null; +var DDWizardActiveDevice = ''; +var RangeSetBlocker = false; +function startDeviceDetectionWizard( NodeID ){ + DDWizardActiveDevice = NodeID + if( DeviceDetectionWizardWnd == null ){ + DeviceDetectionWizardWnd = new Ext.Window({ + title: 'GetLabel('_WDEV_DET_WIZT_');?>', + modal: true, + width: 500, + height: 208, + closeAction: 'hide', + items:[{ + xtype: 'tabpanel', + activeTab: 1, + items: [{ + title: 'GetLabel('_WDEV_DET_WIZ0_');?>', + frame: false, + xtype: 'form', + items:[{ + xtype: 'spacer', + height: 20 + },{ + xtype: 'combo', + id: 'DDWizST', + fieldLabel: 'GetLabel('_DEV_TYPE_FLD_');?>', + typeAhead: true, + triggerAction: 'all', + lazyRender:true, + mode: 'local', + store: new Ext.data.ArrayStore({ + id: 0, + fields: [ + 'dtId', + 'dtText' + ], + data: [ + [1, 'GetLabel('_DEV_TYPE_ALS_');?>'], + [2, 'GetLabel('_DEV_TYPE_LFS_');?>'], + [3, 'GetLabel('_DEV_TYPE_PLS200_');?>'], + [4, 'GetLabel('_DEV_TYPE_PLS360_');?>'], + [5, 'GetLabel('_DEV_TYPE_3D_');?>'], + [6, 'GetLabel('_DEV_TYPE_NPLS200_');?>'] + ] + }), + valueField: 'dtId', + displayField: 'dtText' + },{ + xtype: 'numberfield', + id: 'DDWizSR', + fieldLabel: 'GetLabel('_DEV_RANGE_FLD_');?>', + minValue: 15.0, + maxValue: 300.0, + listeners:{ + change: function( m, nv, ov ){ + if( RangeSetBlocker ) return; + RangeSetBlocker = true; + Ext.getCmp('DDWizSRS').setValue( nv ); + RangeSetBlocker = false; + } + } + },{ + xtype: 'slider', + id: 'DDWizSRS', + fieldLabel: 'GetLabel('_DEV_RANGE_FLD_');?>', + minValue: 15.0, + maxValue: 300.0, + listeners:{ + change: function( m, nv, ov ){ + if( RangeSetBlocker ) return; + RangeSetBlocker = true; + Ext.getCmp('DDWizSR').setValue( nv ); + RangeSetBlocker = false; + } + } + },{ + xtype: 'spacer', + height: 10 + }] + },{ + title: 'GetLabel('_WDEV_DET_WIZ1_');?>', + frame: false, + xtype: 'form', + labelWidth: 120, + items:[{ + xtype: 'spacer', + height: 20 + },{ + xtype: 'combo', + id: 'DDWizIT', + fieldLabel: 'GetLabel('_DEV_ITYPE_FLD_');?>', + typeAhead: true, + triggerAction: 'all', + lazyRender:true, + mode: 'local', + value: 1, + store: new Ext.data.ArrayStore({ + id: 0, + fields: [ + 'dpId', + 'dpText' + ], + data: [ + [1, 'GetLabel('_DEV_PL_HORI_');?>'], + [2, 'GetLabel('_DEV_PL_VERT_');?>'], + [3, 'GetLabel('_DEV_PL_ANG_');?>'] + ] + }), + valueField: 'dpId', + displayField: 'dpText' + }] + },{ + title: 'GetLabel('_WDEV_DET_WIZ2_');?>', + html: 'Another one' + },{ + title: 'GetLabel('_WDEV_DET_WIZ3_');?>', + html: 'Another one' + }] + }], + bbar:[{ + text: 'Create Profiles And Finish', + handler: function(){ + DeviceDetectionWizardWnd.hide(); + } + },{ + text: 'Advanced Config', + handler: function(){ + DeviceDetectionWizardWnd.hide(); + startAdvancedDeviceDetection( DDWizardActiveDevice ); + } + }] + }); + }; + Ext.Ajax.request({ + url: '/lib/controller/getNodeBasicNfo.php', + params: { + NID: DDWizardActiveDevice, + UID: 'Data['id'];?>', + SID: '' + }, + success: function( response, opts ){ + var data = Ext.decode(response.responseText); + DeviceDetectionWizardWnd.setTitle( 'GetLabel('_WDEV_DET_WIZT_');?> [' + data.name+']' ); + Ext.getCmp('DDWizST').setValue( data.type ); + RangeSetBlocker = true; + Ext.getCmp('DDWizSR').setValue( data.range ); + Ext.getCmp('DDWizSRS').setValue( data.range ); + RangeSetBlocker = false; + DeviceDetectionWizardWnd.show(); + }, + failure: failureAJAXFunction + }); +}; + +var DeviceDetectionAdvancedWnd = null; +var DeviceDetectionProfileNames = ['factory default', 'low sens', 'medium sens', 'high sens']; +function loadAdvancedDeviceDetectionSettings(){ + Ext.getCmp('ADD_TP').removeAll( false ); + Ext.Ajax.request({ + url: '/lib/controller/getNodeAdvancedNfo.php', + params: { + NID: DDWizardActiveDevice, + UID: 'Data['id'];?>', + SID: '' + }, + success: function( response, opts ){ + var data = Ext.decode(response.responseText); + DeviceDetectionAdvancedWnd.setTitle( 'GetLabel('_WDEV_DET_WIZT_');?> [' + data.name+']' ); + if( data.profiles.length > 0 ){ + if( data.profiles.length > 3 ) Ext.getCmp('ADD_PADD_BTN').disable(); + switch( data.type ){ + case 1: + case 5:{ + for( i = 0; i < data.profiles.length / 2; i++){ + }; + break; + }; + case 2: + case 3: + case 4: + case 6:{ + for( i = 0; i < data.profiles.length; i++){ + Ext.getCmp('ADD_TP').add({ + title: DeviceDetectionProfileNames[ data.profiles[i].id ], + xtype: 'form', + frame: false, + items:[{xtype: 'spacer', height: 10 },{ + xtype: 'numberfield', + id: 'OFFSET_P'+data.profiles[i].id, + fieldLabel: 'OFFSET', + minValue: 15.0, + maxValue: 300.0, + value: data.profiles[i].offset + },{ + xtype: 'numberfield', + id: 'DELTA_P'+data.profiles[i].id, + fieldLabel: 'DELTA', + minValue: 15.0, + maxValue: 300.0, + value: data.profiles[i].delta + },{ + xtype: 'numberfield', + id: 'WIDTH_P'+data.profiles[i].id, + fieldLabel: 'WIDTH', + minValue: 15.0, + maxValue: 300.0, + value: data.profiles[i].width + },{ + xtype: 'numberfield', + id: 'SST_P'+data.profiles[i].id, + fieldLabel: 'SST', + minValue: 15.0, + maxValue: 300.0, + value: data.profiles[i].sst + },{ + xtype: 'numberfield', + id: 'FLIP_P'+data.profiles[i].id, + fieldLabel: 'FLIP', + minValue: 15.0, + maxValue: 300.0, + value: data.profiles[i].flip + },{ + xtype: 'numberfield', + id: 'SUN_P'+data.profiles[i].id, + fieldLabel: 'SUN', + minValue: 15.0, + maxValue: 300.0, + value: data.profiles[i].sun + }] + }); + }; + break; + }; + }; + // + } else { + Ext.getCmp('ADD_TP').add({ + title: 'Error!', + html: 'No Profiles Defined' + }); + }; + DeviceDetectionAdvancedWnd.show(); + }, + failure: failureAJAXFunction + }); +}; + +function startAdvancedDeviceDetection( NodeID ){ + DDWizardActiveDevice = NodeID; + if( DeviceDetectionAdvancedWnd == null ){ + DeviceDetectionAdvancedWnd = new Ext.Window({ + title: 'GetLabel('_WDEV_DET_WIZT_');?>', + modal: true, + width: 500, + height: 300, + closeAction: 'hide', + items:[{ + xtype: 'tabpanel', + id: 'ADD_TP', + frame: false, + border: false, + activeTab: 0, + items: [] + }], + bbar:[{ + id: 'ADD_PADD_BTN', + text: 'Add Detection Profile', + handler: function(){ + Ext.Ajax.request({ + url: '/lib/controller/addDetectionProfile.php', + params: { + NID: DDWizardActiveDevice, + UID: 'Data['id'];?>', + SID: '' + }, + success: function( response, opts ){ + loadAdvancedDeviceDetectionSettings(); + }, + failure: failureAJAXFunction + }); + } + },{ + text: 'Apply And Finish' + },{ + text: 'Use Wizard' + }] + }); + }; + loadAdvancedDeviceDetectionSettings(); +}; + +var maskEditorDiv = null; +var MEPanel = null; +function handleFSMaskEditorClose( event ){ + if ( document.fullscreenElement || + document.webkitFullscreenElement || + document.mozFullScreenElement || + document.msFullscreenElement ){ + } else { + MEPanel.destroy(); + maskEditorDiv.remove(); + maskEditorDiv = null; + MEPanel = null; + document.removeEventListener( 'fullscreenchange', handleFSMaskEditorClose ); + }; +}; + +function hideMaskEditor(){ + if( + document.fullscreenElement || + document.webkitFullscreenElement || + document.mozFullScreenElement || + document.msFullscreenElement + ){ + if( document.exitFullscreen ){ + document.exitFullscreen(); + }else if( document.mozCancelFullScreen ){ + document.mozCancelFullScreen(); + }else if( document.webkitExitFullscreen ){ + document.webkitExitFullscreen(); + }else if( document.msExitFullscreen ){ + document.msExitFullscreen(); + }; + // Removal Done by event! + //maskEditorDiv.remove(); + //maskEditorDiv = null; + //document.removeEventListener( 'fullscreenchange', handleFSMaskEditorClose ); + }; +}; +var values = { + paths: 50, + minPoints: 5, + maxPoints: 15, + minRadius: 30, + maxRadius: 90 +}; + +var hitOptions = { + segments: true, + stroke: true, + fill: true, + tolerance: 10 +}; + +var polycolors = new Array(); +var polyindex = 0; +var poligones = new Array(); + +var segment = null; +var path = null; +var MaskProject = null; +var MaskEditorMode = 0; + +function onMouseDown(event) { + segment = path = null; + var hitResult = MaskProject.hitTest( event.point, hitOptions ); + if (!hitResult) return; + + if( event.modifiers.shift ){ + if (hitResult.type == 'segment') { + hitResult.segment.remove(); + }; + return; + }; + if( hitResult ){ + path = hitResult.item; + if( hitResult.type == 'segment' ){ + segment = hitResult.segment; + path.fullySelected = false; + segment.selected = true; + } else if( hitResult.type == 'stroke' ){ + var location = hitResult.location; + segment = path.insert(location.index + 1, event.point); + //path.smooth(); + path.fullySelected = false; + segment.selected = true; + } else if ( hitResult.type == 'fill' ){ + path.fullySelected = true; + }; + } + //movePath = ; + //if( movePath ) MaskProject.activeLayer.addChild(hitResult.item); +} +var c_m_X = 0; +var c_m_Y = 0; +function onMouseMove( e ) { + //e.preventDefault(); + //e.stopPropagation(); + var mx=parseInt(e.offsetX * deviceMapScaling);// - deviceMapLeftShift; + var my=parseInt(e.offsetY * deviceMapScaling);// - deviceMapTopShift; + if( ( mx != c_m_X ) || ( my!= c_m_Y ) ){ + c_m_X = mx; + c_m_Y = my; + var t = Ext.getCmp('me_coords_panel'); + if( t!= undefined ){ + var k = cMapImageWidth / 2048; + var jaja = parseInt(( e.offsetX * deviceMapScaling ) - deviceMapLeftShift ); + t.update(''+c_m_X+'x'+c_m_Y+' --- ' + jaja + ''); + }; + }; +} +function onPathMouseMove( event ) { + event.preventDefault(); + event.stopPropagation(); + if( ( event.point.x != c_m_X ) || ( event.point.y != c_m_Y ) ){ + c_m_X = event.point.x; + c_m_Y = event.point.y; + var t = Ext.getCmp('me_coords_panel'); + if( t!= undefined ){ + t.update(''+c_m_X+'x'+c_m_Y+''); + }; + }; + MaskProject.activeLayer.selected = false; + if( event.item ) { + //event.item.selected = true; + event.item.fullySelected = true; + }; +} + +function onMouseDrag(event) { + if( ( event.point.x != c_m_X ) || ( event.point.y != c_m_Y ) ){ + c_m_X = event.point.x; + c_m_Y = event.point.y; + var t = Ext.getCmp('me_coords_panel'); + if( t!= undefined ){ + t.update(''+c_m_X+'x'+c_m_Y+''); + }; + }; + if( segment ){ + //segment.point += event.delta; + segment.point = event.point; + //path.smooth(); + }; + //else if (path) { + // path.position += event.delta; + //} +} +var absDrawMapSizes = [[4096,4096],[2304,288]]; +var deviceMapScaling = 1.0; +var deviceMapTopShift = 100; +var deviceMapLeftShift = 100; +var cMapImageWidth = 0; +var cMapImageHeight = 0; +var cMapCanvasWidth = 0; +var cMapCanvasHeight = 0; +var cMapType = 0; +var cMaskLRF = 0; +var cMaskID = 0; + +function SaveCurrentMask( NodeID, MaskID = 0, LRFID = 0 ){ + var serial = MaskProject.exportJSON(); + Ext.Ajax.request({ + url: '/lib/controller/uploadDeviceMask.php', + params: { + NID: NodeID, + UID: 'Data['id'];?>', + SID: '', + MID: MaskID, + LID: LRFID, + MDTA: serial, + MIH: cMapImageHeight, + MIW: cMapImageWidth, + MSHX: deviceMapLeftShift, + MSHY: deviceMapTopShift, + DSTD: 1 + }, + success: function( response, opts ){ + //var data = Ext.decode(response.responseText); + //hideMaskEditor(); + }, + failure: failureAJAXFunction + }); +} + + +function doMaskOperation( NodeID, Cmd, Mid = 0, LRFID = 0 ){ + Ext.Ajax.request({ + url: '/lib/controller/doMaskOperation.php', + params: { + NID: NodeID, + UID: 'Data['id'];?>', + SID: '', + CMD: Cmd, + MID: Mid, + LID: LRFID + }, + success: function( response, opts ){ + //var data = Ext.decode(response.responseText); + //hideMaskEditor(); + }, + failure: failureAJAXFunction + }); +} +var ME_max_range = 100; +function showMaskEditor( fromDevTool, DevType, NodeID ){ + //alert( "DevType: "+DevType + " Dev Map size: "+ absDrawMapSizes[DevType][0]+"x"+absDrawMapSizes[DevType][1] ); + cMapType = DevType; + if( DevType == 1 ){ + deviceMapScaling = ( window.screen.height * window.devicePixelRatio - 130 - ( deviceMapTopShift * 2 )) / absDrawMapSizes[DevType][1]; + } else { + deviceMapScaling = ( window.screen.width * window.devicePixelRatio - 30 - ( deviceMapLeftShift * 2 )) / absDrawMapSizes[DevType][0]; + }; + cMapImageHeight = deviceMapScaling * absDrawMapSizes[DevType][1]; + cMapImageWidth = deviceMapScaling * absDrawMapSizes[DevType][0]; + cMapCanvasWidth = cMapImageWidth + (deviceMapLeftShift * 2); + cMapCanvasHeight = cMapImageHeight + (deviceMapTopShift * 2); + if( fromDevTool ){ + detectionProfileWindow.hide(); + }; + if( + document.fullscreenElement || + document.webkitFullscreenElement || + document.mozFullScreenElement || + document.msFullscreenElement + ){ + //fs mode allready + hideMaskEditor(); + }else{ + if( maskEditorDiv == null ){ + maskEditorDiv = document.createElement("div"); + maskEditorDiv.style.height="200px"; + maskEditorDiv.style.width="200px"; + maskEditorDiv.style.position="relative"; + //var svg = document.getElementById('draw_svg_'+parseInt( NodeID ) ); + //var svgCode = window.btoa(svg.outerHTML); + //maskEditorDiv.style.background = "url(data:image/svg+xml;base64," + svgCode + ")"; + //maskEditorDiv.style.background = 'solid red;'; + //maskEditorDiv.style.backgroundImage = "url('style/wicons/011.png')"; + //append div as a child to body + document.body.appendChild( maskEditorDiv ); + //var elem = document.createElement("img"); 'getDeviceMap.php?NID='+NodeID + //elem.setAttribute("src", "/lib/controller/data/device_draws/75c85fec4be204fc0bc0452f53b5a3df_map.png"); + //elem.setAttribute("height", "80%"); + //elem.setAttribute("width", "130"); + //maskEditorDiv.appendChild( elem ); + //alert( window.screen.width * window.devicePixelRatio + "x" + window.screen.height * window.devicePixelRatio); + if( MEPanel == null ){ + var ww = window.screen.width * window.devicePixelRatio; + var hh = window.screen.height * window.devicePixelRatio; + MEPanel = new Ext.Panel( { + title: 'Mask Editor', + renderTo: maskEditorDiv, + width: ww, + height: hh, + frame: true, + autoScroll: true, + items:[{ + xtype: 'panel', + width: cMapCanvasWidth, + //html: '
', + html: '
', + listeners:{ + afterrender: function(){ + //Doing a custom svg here for background! + var chicha = document.getElementById( 'popomas' ); + var cSensor = getSensorByNodeId( NodeID ); + if( cSensor!= null ){ + ME_max_range = cSensor.max_range; + } else { + ME_max_range = 100; + }; + //var svg = document.getElementById('draw_svg_'+parseInt( NodeID ) ); + //var svgCode = window.btoa(svg.outerHTML); + //chicha.style.backgroundImage = "url(data:image/svg+xml;base64," + svgCode + ")"; + //chicha.style.backgroundImage = "url('style/wicons/011.png')"; + $("#mask_canvas").mousemove( onMouseMove ); + loadMaskDraw( NodeID ); + } + } + }], + tbar:[{ + text:'New Polygone', + id: 'me_b_newp', + enableToggle: true, + toggleGroup: 'me_topbar_grp', + pressed: false, + handler: function( btn ){ + if( btn.pressed ) setMaskEditorMode( 0 ); + } + }/*,{ + text:'Delete Polygone', + id: 'me_b_delp', + enableToggle: true, + toggleGroup: 'me_topbar_grp' + },{ + text:'Delete Point', + id: 'me_b_delpo', + enableToggle: true, + toggleGroup: 'me_topbar_grp' + }*/,{ + text:'Clear Mask', + id: 'me_b_delm', + handler: function(){ + if( MaskProject!= null ){ + doMaskOperation( NodeID, 3, cMaskID ); + }; + MaskProject = new paper.Project( canvas ); + paper.view.draw(); + setMaskEditorMode( 0 ); + } + },{ + text:'1', + enableToggle: true, + toggleGroup: 'me_maskbar_grp', + pressed: (cMaskID == 0 ), + handler: function(){ + if( cMaskID != 0 ){ + SaveCurrentMask( NodeID, cMaskID ); + }; + MaskProject = new paper.Project( canvas ); + paper.view.draw(); + cMaskID = 0; + loadDeviceMask( NodeID, cMaskID ); + } + },{ + text:'2', + enableToggle: true, + toggleGroup: 'me_maskbar_grp', + pressed: ( cMaskID == 1 ), + handler: function(){ + if( cMaskID != 1 ){ + SaveCurrentMask( NodeID, cMaskID ); + }; + MaskProject = new paper.Project( canvas ); + paper.view.draw(); + cMaskID = 1; + loadDeviceMask( NodeID, cMaskID ); + } + },{ + text:'3', + enableToggle: true, + toggleGroup: 'me_maskbar_grp', + pressed: ( cMaskID == 2 ), + handler: function(){ + if( cMaskID != 2 ){ + SaveCurrentMask( NodeID, cMaskID ); + }; + MaskProject = new paper.Project( canvas ); + paper.view.draw(); + cMaskID = 2; + loadDeviceMask( NodeID, cMaskID ); + } + },{ + text:'4', + enableToggle: true, + toggleGroup: 'me_maskbar_grp', + pressed: ( cMaskID == 3 ), + handler: function(){ + if( cMaskID != 3 ){ + SaveCurrentMask( NodeID, cMaskID ); + }; + MaskProject = new paper.Project( canvas ); + paper.view.draw(); + cMaskID = 3; + loadDeviceMask( NodeID, cMaskID ); + } + },{ + text:'5', + enableToggle: true, + toggleGroup: 'me_maskbar_grp', + pressed: ( cMaskID == 4 ), + handler: function(){ + if( cMaskID != 4 ){ + SaveCurrentMask( NodeID, cMaskID ); + }; + MaskProject = new paper.Project( canvas ); + paper.view.draw(); + cMaskID = 4; + loadDeviceMask( NodeID, cMaskID ); + } + },{ + xtype: 'panel', + frame: 'false', + id: 'me_coords_panel', + border: true, + width: 200, + height: 30, + html: '

kook

' + }], + buttons:[{ + text: 'Cancel', + handler: function(){ + hideMaskEditor(); + } + },{ + text:'Save Mask and Close', + handler: function(){ + var serial = MaskProject.exportJSON(); + Ext.Ajax.request({ + url: '/lib/controller/uploadDeviceMask.php', + params: { + NID: NodeID, + UID: 'Data['id'];?>', + SID: '', + MID: cMaskID, + LID: 0, + MDTA: serial, + MIH: cMapImageHeight, + MIW: cMapImageWidth, + //MSF: deviceMapScaling, + MSHX: deviceMapLeftShift, + MSHY: deviceMapTopShift + }, + success: function( response, opts ){ + var data = Ext.decode(response.responseText); + hideMaskEditor(); + }, + failure: failureAJAXFunction + }); + } + }] + }); + }; + MEPanel.doLayout(); + //if( MaskProject == null ){ + var canvas = document.getElementById('mask_canvas'); + paper.settings.handleSize = 10; + MaskProject = new paper.Project( canvas ); + //canvas.addEventListener( 'mousemove', onMaskMouseMove ); + canvas.addEventListener( 'mousedown', onMaskMouseDown ); + //canvas.addEventListener( 'mouseup', onMaskMouseUp ); + //canvas.addEventListener( 'mousedrag', onMaskMouseMove ); + //}; + cMaskID = 0; + loadDeviceMask( NodeID, cMaskID ); + }; + //maskEditorDiv = $('#container').get(0); + //var maskEditorDiv = document.getElementById( id ); //Ext.getCmp( id ); + if( maskEditorDiv.requestFullscreen ){ + maskEditorDiv.requestFullscreen(); + }else if( maskEditorDiv.mozRequestFullScreen ){ + maskEditorDiv.mozRequestFullScreen(); + }else if( maskEditorDiv.webkitRequestFullscreen ){ + maskEditorDiv.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT); + }else if( maskEditorDiv.msRequestFullscreen ){ + maskEditorDiv.msRequestFullscreen(); + }; + document.addEventListener( 'fullscreenchange', handleFSMaskEditorClose ); + }; +}; + +function loadMaskDraw( a ){ + + Ext.Ajax.request({ + url: '/lib/controller/getDeviceDraw.php', + params: { + UID: , + SID: '', + NID: a + }, + success: function( response, opts ){ + var data = Ext.decode(response.responseText); + if( data.count > 0 ){ + //draws_2d[a] = data.data; + var csvg = document.getElementById( 'draw_svg_me' ); + + if( csvg != undefined ){ + var draw = csvg.getElementById( "draw" ); + if( draw != null ) csvg.removeChild( draw ); + + var p2 = 2.0*Math.PI; + var so = -10 * p2 / 360.0; + + var bBox = csvg.getBBox(); + var newpath = document.createElementNS('http://www.w3.org/2000/svg', "polygon"); + var ak = 2.0*Math.PI/draws_2d[a].length; + var cpx = bBox.width / 2.0; + var cpy = bBox.height / 2.0; + var max = 1024; + //switch( drawZoomLevels[a] ){ + // case 50: max = 512; break; + // case 25: max = 256; break; + // case 12: max = 128; break; + //}; + var rk = bBox.width / ( max * 2 ); + var pp = ''; + var jj = ''; + for( i=0;iData['id'];?>', + SID: '', + MID: LayerID, + LID: LrfID + }, + success: function( response, opts ){ + var data = Ext.decode(response.responseText); + + if( data.length > 0 ){ + for( i = 0; i < data.length; i++ ){ + //var + path = new paper.Path(); + path.strokeColor = 'black'; + //var lightness = (Math.random() - 0.5) * 0.4 + 0.4; + //var hue = Math.random() * 360; + //path.fillColor = { hue: hue, saturation: 1, lightness: lightness }; + path.fillColor = data[i].colour; + path.closed = true; + path.opacity = 0.5; + path.onMouseMove = onPathMouseMove; + path.onMouseDown = onMouseDown; + path.onMouseDrag = onMouseDrag; + //path.onMouseUp = function( event ){ + // path.add(event.point); + //} + if( data[i].points.length > 2 ){ + if( cMapType == 1 ){ + var tX = data[i].points[0][0] * deviceMapScaling + deviceMapLeftShift; + var tY = data[i].points[0][1] * deviceMapScaling + deviceMapTopShift; + path.moveTo( [tX,tY] ); + for(k = 1; k < data[i].points.length; k++ ){ + tX = data[i].points[k][0] * deviceMapScaling + deviceMapLeftShift; + tY = data[i].points[k][1] * deviceMapScaling + deviceMapTopShift; + path.lineTo( [tX,tY] ); + }; + } else { + var tX = ( 2047 + parseInt( data[i].points[0][0]) ) * deviceMapScaling + deviceMapLeftShift; + var tY = ( 2047 + parseInt( data[i].points[0][1]) ) * deviceMapScaling + deviceMapTopShift; + path.moveTo( [tX,tY] ); + for(k = 1; k < data[i].points.length; k++ ){ + tX = ( 2047 + parseInt(data[i].points[k][0]) ) * deviceMapScaling + deviceMapLeftShift; + tY = ( 2047 + parseInt(data[i].points[k][1]) ) * deviceMapScaling + deviceMapTopShift; + path.lineTo( [tX,tY] ); + }; + }; + path.fullySelected = true; + paper.view.draw(); + }; + poligones.push(path); + setMaskEditorMode( 4 ); + }; + } else { + setMaskEditorMode( 0 ); + }; + }, + failure: failureAJAXFunction + }); +}; + +function onMaskMouseDown( evt ){ + switch( MaskEditorMode ){ + case 0:{ + path = new paper.Path(); + path.strokeColor = 'black'; + path.fillColor = '#ff8020'; + path.onMouseDown = onMouseDown; + path.onMouseDrag = onMouseDrag; + path.onMouseMove = onPathMouseMove; + path.fullySelected = true; + path.closed = true; + path.opacity = 0.5; + path.moveTo( [ evt.pageX - $(document).scrollLeft() - $('#mask_canvas').offset().left, evt.pageY - $(document).scrollTop() - $('#mask_canvas').offset().top ] ); + setMaskEditorMode( 1 ); + break; + }; + case 1:{ + path.lineTo( [ evt.pageX - $(document).scrollLeft() - $('#mask_canvas').offset().left, evt.pageY - $(document).scrollTop() - $('#mask_canvas').offset().top ] ); + if( path.segments.length == 3 ){ + setMaskEditorMode( 4 ); + }; + }; + }; + //if( MaskEditorMode == 0 ){ + // + //} else { + // path.lineTo( [ evt.pageX - $(document).scrollLeft() - $('#mask_canvas').offset().left, evt.pageY - $(document).scrollTop() - $('#mask_canvas').offset().top ] ); + //}; +}; + +function onMaskMouseUp( evt ){ + if( MaskEditorMode == 4 ){ + //path.lineTo( [ evt.pageX - $(document).scrollLeft() - $('#mask_canvas').offset().left, evt.pageY - $(document).scrollTop() - $('#mask_canvas').offset().top ] ); + path.fullySelected = true; + path.onMouseDown = onMouseDown; + path.onMouseDrag = onMouseDrag; + path.onMouseMove = onPathMouseMove; + paper.view.draw(); + //poligones.push( path ); + setMaskEditorMode( 1 ); + }; +}; + +function onMaskMouseMove( event ){ + if( MaskEditorMode == 4 ){ + //paper.view.draw(); + }; +}; + + + diff --git a/lib/javascript/jsapi_dynamic/rgoose_devices_.js b/lib/javascript/jsapi_dynamic/rgoose_devices_.js new file mode 100644 index 0000000..ce91639 --- /dev/null +++ b/lib/javascript/jsapi_dynamic/rgoose_devices_.js @@ -0,0 +1,2370 @@ +// + + + +var devices = new Array(); +var cameras = new Array(); + +var systemDevicesAreLoadded = false; + +function loadSystemDevices(){ + Ext.Ajax.request({ + url: '/lib/controller/getSystemDevices.php', + params: { + UID: , + SID: '', + }, + success: function( response, opts ){ + // If the response is JSON, you have to decode it + var data = Ext.decode(response.responseText); + devices = data.sensors; + cameras = data.cameras; + systemDevicesAreLoadded = true; + }, + failure: failureAJAXFunction + }); +}; + +function getSensorByNodeId( NID ){ + if( systemDevicesAreLoadded ) for( i=0; i< devices.length; i++ ) if( devices[i].node_id == NID ) return devices[i]; + return null; +}; + +function getSensorById( SID ){ + if( systemDevicesAreLoadded ) for( i=0; i< devices.length; i++) if( devices[i].id == SID ) return devices[i]; + return null; +}; + +function getCameraByNodeId( NID ){ + if( systemDevicesAreLoadded ) for( i=0; i< cameras.length; i++) if( cameras[i].node_id == NID ) return cameras[i]; + return null; +}; + +function getCameraById( SID ){ + if( systemDevicesAreLoadded ) for( i=0; i< cameras.length; i++) if( cameras[i].id == SID ) return cameras[i]; + return null; +}; + + +var UartListStore = new Ext.data.JsonStore({ + root: 'ports', + totalProperty: 'totalCount', + idProperty: 'uart_id', + remoteSort: false, + baseParams: { + UID: 'Data['id'];?>', + SID: '', + SITE: + }, + fields: [{ + name: 'uart_id', + type: 'int' + },{ + name: 'uart_name', + type: 'string' + }], + proxy : new Ext.data.HttpProxy({ + method: 'POST', + prettyUrls: false, + url: '/lib/controller/listUarts.php' + }) +}); + +var ServersListStore = new Ext.data.JsonStore({ + root: 'servers', + totalProperty: 'totalCount', + idProperty: 'server_id', + remoteSort: false, + baseParams: { + UID: 'Data['id'];?>', + SID: '', + SITE: + }, + fields: [{ + name: 'server_id', + type: 'int' + },{ + name: 'server_name', + type: 'string' + }], + proxy : new Ext.data.HttpProxy({ + method: 'POST', + prettyUrls: false, + url: '/lib/controller/listServers.php' + }) +}); + +var ServerListStore = new Ext.data.JsonStore({ + root: 'servers', + totalProperty: 'totalCount', + idProperty: 'server_id', + remoteSort: false, + baseParams: { + UID: 'Data['id'];?>', + SID: '', + SITE: + }, + fields: [{ + name: 'server_id', + type: 'int' + },{ + name: 'server_name', + type: 'string' + }], + proxy : new Ext.data.HttpProxy({ + method: 'POST', + prettyUrls: false, + url: '/lib/controller/listServers.php' + }) +}); + +function loadSettingsLidar3D( NodeID, Master ){ + SelectedNodeID = NodeID; + Ext.Ajax.request({ + url: '/lib/controller/getSettingsLidsr3D.php', + params: { + NID: NodeID, + MST: ((Master)?1:0), + UID: , + SID: '', + }, + success: function( response, opts ){ + // If the response is JSON, you have to decode it + var data = Ext.decode(response.responseText); + Ext.getCmp('setting_master_ip').setValue( data.ip_address ); + Ext.getCmp('setting_master_port').setValue( data.port ); + Ext.getCmp('setting_slave_ip').setValue( data.aux_ip_address ); + Ext.getCmp('setting_slave_port').setValue( data.aux_port ); + Ext.getCmp('setting_lat').setValue( data.lat ); + Ext.getCmp('setting_lon').setValue( data.lon ); + Ext.getCmp('setting_alt').setValue( data.alt ); + Ext.getCmp('setting_roll').setValue( data.roll ); + Ext.getCmp('setting_pitch').setValue( data.pitch ); + Ext.getCmp('setting_yaw').setValue( data.yaw ); + }, + failure: failureAJAXFunction + }); +}; + +function saveSettingsLidar3D( ){ + if( SelectedNodeID == 0 ) return; + t1 = Ext.getCmp('setting_master_ip').getValue(); + t2 = Ext.getCmp('setting_master_port').getValue(); + t3 = Ext.getCmp('setting_slave_ip').getValue(); + t4 = Ext.getCmp('setting_slave_port').getValue(); + t5 = Ext.getCmp('setting_lat').getValue(); + t6 = Ext.getCmp('setting_lon').getValue(); + t7 = Ext.getCmp('setting_alt').getValue(); + t8 = Ext.getCmp('setting_roll').getValue(); + t9 = Ext.getCmp('setting_pitch').getValue(); + t10 = Ext.getCmp('setting_yaw').getValue(); + Ext.Ajax.request({ + url: '/lib/controller/setSettingsLidsr3D.php', + params: { + NID: SelectedNodeID, + UID: , + SID: '', + MIP: t1, + MPP: t2, + SIP: t3, + SPP: t4, + LAT: t5, + LON: t6, + ALT: t7, + ROL: t8, + PCH: t9, + YAW: t10 + }, + success: function( response, opts ){ + // If the response is JSON, you have to decode it + var data = Ext.decode(response.responseText); + if( data.success == true ) { + Ext.Msg.show({ + title:'GetLabel("_INFO_MSG_");?>', + msg: 'GetLabel("_SETTING_SAVE_OK_");?>', + buttons: Ext.Msg.OK,//YESNOCANCEL, + fn: function(){ + SettingsLidar3D.hide(); + }, + //animEl: 'elId', + icon: Ext.MessageBox.INFO //QUESTION + }); + } else { + Ext.Msg.show({ + title:'GetLabel("_ERROR_MSG_");?>', + msg: data['error'], + buttons: Ext.Msg.OK,//YESNOCANCEL, + fn: function(){ + SettingsLidar3D.hide(); + }, + //animEl: 'elId', + icon: Ext.MessageBox.ERROR //QUESTION + }); + }; + }, + failure: failureAJAXFunction + }); +}; + + +function editSettingsLidar3D( NodeID, Master ){ + if( SettingsLidar3D == null ){ + SettingsLidar3D = new Ext.Window({ + modal: true, + title: 'GetLabel("_EDIT_LRF3D_SETTINGS_");?>', + width: 773, + height: 600, + layout: 'fit', + closeAction: 'hide', + listeners:{ + beforehide : function(){ + Ext.getCmp('connectstarterbutton').toggle( false, false ); + } + }, + items:[{ + layout: 'table', + border: false, + defaults: { + // applied to each contained panel + bodyStyle:'padding-top:10px;padding-left:20px;padding-right:20px;padding-bottom:10px;' + }, + layoutConfig: { + // The total column count must be specified here + columns: 4 + }, + items: [{ + border: false, + html: 'Master IP Address:' + },{ + xtype: 'textfield', + id: 'setting_master_ip', + width: '70%' + },{ + border: false, + html: 'Port:' + },{ + xtype: 'textfield', + id: 'setting_master_port', + width: '30%' + },{ + border: false, + html: 'Slave IP Address:' + },{ + xtype: 'textfield', + id: 'setting_slave_ip', + width: '70%' + },{ + border: false, + html: 'Port:' + },{ + xtype: 'textfield', + id: 'setting_slave_port', + width: '30%' + },{ + border: false, + html: 'Position Lat/Lon/Alt:' + },{ + xtype: 'textfield', + id: 'setting_lat', + width: '30%' + },{ + xtype: 'textfield', + id: 'setting_lon', + width: '30%' + },{ + xtype: 'textfield', + id: 'setting_alt', + width: '30%' + },{ + border: false, + html: 'Orientation Roll/Pitch/Yaw:' + },{ + xtype: 'textfield', + id: 'setting_roll', + width: '30%' + },{ + xtype: 'textfield', + id: 'setting_pitch', + width: '30%' + },{ + xtype: 'textfield', + id: 'setting_yaw', + width: '30%' + }] + }], + bbar: [{ + text: 'GetLabel("_CANCEL_");?>', + handler: function(){ + SettingsLidar3D.hide(); + } + },{ + text: 'GetLabel("_SAVE_");?>', + handler: SaveSettingsLidar3D + }] + }); + }; + SettingsLidar3D.show(); + loadSettingsLidar3D( NodeID, Master ); +}; + +var devicesStore = new Ext.data.JsonStore({ + root: 'nodes', + totalProperty: 'totalCount', + idProperty: 'id', + remoteSort: true, + fields: [{ + name: 'id', + type: 'int' + },{ + name: 'name', + type: 'string' + },{ + name: 'hardware', + type: 'string' + },{ + name: 'caps', + type: 'int' + },{ + name: 'ip', + type: 'string' + },{ + name: 'mac', + type: 'string' + }], + proxy : new Ext.data.HttpProxy({ + method: 'POST', + prettyUrls: false, + url: '/lib/controller/listDiscoveredCameraSources.php', + headers: { + 'UID': 'Data['id'];?>', + 'SID': '' + } + }) +}); + +var LRF1D2_st_win = null; +var LRF2D2_st_win = null; +var LRF16D3_st_win = null; + +var currentDeviceOperatioId = 0; +var currentOperationTO = 0; +var currentOperationTimer = null; +var lastOperationCode = 0; +function checkDeviceOperationStatus(){ + if( currentOperationTO ){ + currentOperationTO--; + Ext.Ajax.request({ + url: '/lib/controller/checkDeviceOperation.php', + params: { + OID: currentDeviceOperatioId, + UID: 'Data['id'];?>', + SID: '' + }, + success: function( response, opts ){ + var data = Ext.decode(response.responseText); + if( !data.success ){ + Ext.MessageBox.hide(); + Ext.Msg.show({ + title:'Node Command Status', + msg: data.msg, + buttons: Ext.Msg.OK, + icon: Ext.MessageBox.ERROR + }); + } else { + if( lastOperationCode != data.code || data.code == 0 ){ + lastOperationCode = data.code; + currentOperationTO = 20; + }; + if( data.code < 100 ){ + currentOperationTimer = window.setTimeout( checkDeviceOperationStatus, 100 ); + } else { + Ext.MessageBox.hide(); + switch( data.code ){ + case 120: + case 100: + default: + Ext.Msg.show({ + title:'Node Command Status', + msg: 'Operation Complete', + buttons: Ext.Msg.OK, + icon: Ext.MessageBox.INFO + }); + }; + }; + }; + }, + failure: failureAJAXFunction + }); + } else { + Ext.MessageBox.hide(); + Ext.Msg.show({ + title:'Node Command Status', + msg: 'Operation Status - Time Out!', + buttons: Ext.Msg.OK, + icon: Ext.MessageBox.ERROR + }); + }; +}; + +function doDeviceOperation( NodeID, OpCode, Param='', nowait=false ){ + if( !nowait ){ + Ext.MessageBox.wait("GetLabel('_Loading_Calo_');?>","GetLabel('_Please_Wait_');?>",{ + width: '100%', + hidden: true, + progress: true, + closable: false + }); + }; + + Ext.Ajax.request({ + url: '/lib/controller/doNodeOperation.php', + params: { + NID: NodeID, + UID: 'Data['id'];?>', + CMD: OpCode, + SID: '', + PARAM: Param + }, + success: function( response, opts ){ + var data = Ext.decode(response.responseText); + if( !data.success ){ + if( !nowait ) Ext.MessageBox.hide(); + Ext.Msg.show({ + title:'Node Command Status', + msg: data.msg, + buttons: Ext.Msg.OK, + icon: Ext.MessageBox.ERROR + }); + } else { + if( !nowait ){ + currentDeviceOperatioId = data.operation_id; + currentOperationTO = 20; + lastOperationCode = 0; + currentOperationTimer = window.setTimeout( checkDeviceOperationStatus, 100 ); + }; + }; + }, + failure: failureAJAXFunction + }); +}; + +function clearDeviceEvents( NodeID ){ + Ext.Ajax.request({ + url: '/lib/controller/clearEventCloud.php', + params: { + NID: NodeID, + UID: 'Data['id'];?>', + SID: '' + }, + success: function( response, opts ){ + }, + failure: failureAJAXFunction + }); +}; + +function loadFullLRF1D2Data( NodeID ){ + + if( LRF1D2_st_win == null ) return; + + Ext.Ajax.request({ + url: '/lib/controller/getSettingsLRF.php', + params: { + NID: NodeID, + UID: 'Data['id'];?>', + SID: '', + }, + success: function( response, opts ){ + if( LRF1D2_st_win!= null ){ + var data = Ext.decode(response.responseText); + if( data.online ){ + switch( data.data_status ){ + case 0: Ext.getCmp('dev_online').update('

ONLINE/Data Incomplete

'); break; + case 1: Ext.getCmp('dev_online').update('

ONLINE/Synced

'); break; + case 2: Ext.getCmp('dev_online').update('

ONLINE/Data Not Applyed

'); break; + }; + } else { + switch( data.data_status ){ + case 0: Ext.getCmp('dev_online').update('

OFFLINE/Data Incomplete

'); break; + case 1: Ext.getCmp('dev_online').update('

OFFLINE/Synced

'); break; + case 2: Ext.getCmp('dev_online').update('

OFFLINE/Data Not Applyed

'); break; + }; + }; + Ext.getCmp('dev_name').setValue( data.name ); + Ext.getCmp('serial_num').setValue( data.serial ); + Ext.getCmp('version_id').setValue( data.version ); + Ext.getCmp('device_id').setValue( data.device_id ); + Ext.getCmp('com_spd').setValue( data.com_spd ); + Ext.getCmp('max_range').setValue( data.max_range ); + Ext.getCmp('base_shift').setValue( data.base_shift ); + Ext.getCmp('com_spd').setValue( data.uart_speed ); + Ext.getCmp('mlrf_offset').setValue( data.m_offset ); + Ext.getCmp('slrf_offset').setValue( data.s_offset ); + Ext.getCmp('mlrf_delta').setValue( data.m_delta ); + Ext.getCmp('slrf_delta').setValue( data.s_delta ); + Ext.getCmp('mlrf_width').setValue( data.m_width ); + Ext.getCmp('slrf_width').setValue( data.s_width ); + Ext.getCmp('mlrf_order').setValue( data.m_order ); + Ext.getCmp('slrf_order').setValue( data.s_order ); + Ext.getCmp('mlrf_sst').setValue( data.m_sst ); + Ext.getCmp('slrf_sst').setValue( data.s_sst ); + Ext.getCmp('mlrf_flip').setValue( data.m_flip ); + Ext.getCmp('slrf_flip').setValue( data.s_flip ); + Ext.getCmp('mlrf_sun').setValue( data.m_sun ); + Ext.getCmp('slrf_sun').setValue( data.s_sun ); + }; + }, + failure: failureAJAXFunction + }); +}; + +function loadFullLRF2D2Data( NodeID ){ + + if( LRF2D2_st_win == null ) return; + + Ext.Ajax.request({ + url: '/lib/controller/getSettingsLRF.php', + params: { + NID: NodeID, + UID: 'Data['id'];?>', + SID: '', + }, + success: function( response, opts ){ + if( LRF2D2_st_win!= null ){ + var data = Ext.decode(response.responseText); + if( data.online ){ + switch( data.data_status ){ + case 0: Ext.getCmp('LRF2D2_dev_status').update('

ONLINE/Data Incomplete

'); break; + case 1: Ext.getCmp('LRF2D2_dev_status').update('

ONLINE/Synced

'); break; + case 2: Ext.getCmp('LRF2D2_dev_status').update('

ONLINE/Data Not Applyed

'); break; + }; + } else { + switch( data.data_status ){ + case 0: Ext.getCmp('LRF2D2_dev_status').update('

OFFLINE/Data Incomplete

'); break; + case 1: Ext.getCmp('LRF2D2_dev_status').update('

OFFLINE/Synced

'); break; + case 2: Ext.getCmp('LRF2D2_dev_status').update('

OFFLINE/Data Not Applyed

'); break; + }; + }; + Ext.getCmp('LRF2D2_name').setValue( data.name ); + Ext.getCmp('LRF2D2_serial_num').setValue( data.serial ); + Ext.getCmp('LRF2D2_version_id').setValue( data.version ); + Ext.getCmp('LRF2D2_device_id').setValue( data.device_id ); + Ext.getCmp('LRF2D2_com_spd').setValue( data.com_spd ); + Ext.getCmp('LRF2D2_max_range').setValue( data.max_range ); + Ext.getCmp('LRF2D2_base_shift').setValue( data.base_shift ); + Ext.getCmp('LRF2D2_com_spd').setValue( data.uart_speed ); + Ext.getCmp('mlrf_offset').setValue( data.master_profile.offset ); + Ext.getCmp('slrf_offset').setValue( data.slave_profile.offset ); + Ext.getCmp('mlrf_delta').setValue( data.master_profile.delta ); + Ext.getCmp('slrf_delta').setValue( data.slave_profile.delta ); + Ext.getCmp('mlrf_width').setValue( data.master_profile.width ); + Ext.getCmp('slrf_width').setValue( data.slave_profile.width ); + Ext.getCmp('mlrf_order').setValue( data.master_profile.order ); + Ext.getCmp('slrf_order').setValue( data.slave_profile.order ); + Ext.getCmp('mlrf_sst').setValue( data.master_profile.sst ); + Ext.getCmp('slrf_sst').setValue( data.slave_profile.sst ); + Ext.getCmp('mlrf_flip').setValue( data.master_profile.flip ); + Ext.getCmp('slrf_flip').setValue( data.slave_profile.flip ); + Ext.getCmp('mlrf_sun').setValue( data.master_profile.sun ); + Ext.getCmp('slrf_sun').setValue( data.slave_profile.sun ); + }; + }, + failure: failureAJAXFunction + }); +}; + +function LRF1D2_settings(){ + if( LRF1D2_st_win == null ){ + LRF1D2_st_win = new Ext.Window({ + title: 'Sensor Settings', + modal: true, + width: 800, + height: 600, + closeAction: 'hide', + items:{ + xtype: 'tabpanel', + activeTab: 0, + items:[{ + title: 'General Settings', + xtype: 'form', + layout: 'table', + defaults: { + bodyStyle:'padding:20px' + }, + layoutConfig: { + columns: 3 + }, + items:[{ + html: 'Status', + frame: false, + border: false + },{ + html: '

ONLINE

', + id: 'dev_online', + frame: false, + border: false + },{},{ + html: 'Device Title', + frame: false, + border: false + },{ + xtype: 'field', + id: 'dev_name', + readOnly: false, + value: 'KOKO' + },{},{ + html: 'Serial Number', + frame: false, + border: false + },{ + xtype: 'field', + id: 'serial_num', + readOnly: true, + value: '1212' + },{},{ + html: 'Version ID', + frame: false, + border: false + },{ + xtype: 'field', + id: 'version_id', + readOnly: true, + value: 'LiberManDA122' + },{},{ + html: 'Device Adress', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'device_id' + },{ + xtype: 'button', + id: 'upddiBTN', + text: 'Update Device Address', + handler: function(){ + Ext.Msg.show({ + title:'Update Device Address?', + msg: 'Are you sure to do so?', + buttons: Ext.Msg.YESNOCANCEL, + //fn: processResult, + animEl: 'upddiBTN', + icon: Ext.MessageBox.QUESTION + }); + } + },{ + html: 'Device COM Speed', + frame: false, + border: false + },{ + xtype: 'combo', + id: 'com_spd', + editable: false, + typeAhead: true, + triggerAction: 'all', + width: '100%', + lazyRender:true, + mode: 'local', + store: new Ext.data.ArrayStore({ + id: 0, + fields: ['mySPD', 'displayText' ], + data: [[4800,'4800'],[9600,'9600'],[14400,'14400'],[19200,'19200'],[38400, '38400'],[56000,'56000'],[57600,'57600'],[115200,'115200']] + }), + valueField: 'mySPD', + displayField: 'displayText' + },{ + xtype: 'button', + id: 'updspBTN', + text: 'Set Device Speed', + handler: function(){ + Ext.Msg.show({ + title:'Update Device Speed?', + msg: 'Are you sure to do so?', + buttons: Ext.Msg.YESNOCANCEL, + //fn: processResult, + animEl: 'upddiBTN', + icon: Ext.MessageBox.QUESTION + }); + } + },{ + html: 'Detection Maximal Range', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'max_range', + readOnly: true, + value: '1212' + },{},{ + html: 'Base Shift', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'base_shift', + readOnly: true, + value: '1212' + },{}] + },{ + title: 'Mantenence', + xtype: 'form', + layout: 'table', + defaults: { + bodyStyle:'padding:20px' + }, + layoutConfig: { + columns: 2 + }, + items:[{ + html: 'Restart Device', + frame: false, + border: false + },{ + xtype: 'button', + id: 'rstBTN', + text: 'Full Reset', + handler: function(){ + Ext.Msg.show({ + title:'Reset Device?', + msg: 'You are closing a tab that has unsaved changes. Would you like to save your changes?', + buttons: Ext.Msg.YESNOCANCEL, + //fn: processResult, + animEl: 'rstBTN', + icon: Ext.MessageBox.QUESTION + }); + } + }] + },{ + title: 'Detection Settings', + xtype: 'form', + layout: 'table', + defaults: { + bodyStyle:'padding:20px' + }, + layoutConfig: { + columns: 4 + }, + items:[{ + html: 'Master Offset', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'mlrf_offset', + name: 'mlrf_offset', + allowBlank: false, + allowDecimals: false, + maxText: 'The Range is: 0 - 60', + maxValue: 60, + minText: 'No Negative Values Allowed', + minValue: 0, + },{ + html: 'Slave Offset', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'slrf_offset', + name: 'slrf_offset', + allowBlank: false, + allowDecimals: false, + maxText: 'The Range is: 0 - 60', + maxValue: 60, + minText: 'No Negative Values Allowed', + minValue: 0, + },{ + html: 'Master Delta', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'mlrf_delta', + name: 'mlrf_delta', + allowBlank: false, + allowDecimals: false, + maxText: 'The Range is: 0 - 320', + maxValue: 320, + minText: 'No Negative Values Allowed', + minValue: 0 + },{ + html: 'Slave Delta', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'slrf_delta', + name: 'slrf_delta', + allowBlank: false, + allowDecimals: false, + maxText: 'The Range is: 0 - 320', + maxValue: 320, + minText: 'No Negative Values Allowed', + minValue: 0 + },{ + html: 'Master Width', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'mlrf_width', + name: 'mlrf_width', + allowBlank: false, + allowDecimals: false, + maxText: 'The Range is: 1800 - 16000', + maxValue: 16000, + minText: 'The Range is: 1800 - 16000', + minValue: 1800 + },{ + html: 'Slave Width', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'slrf_width', + name: 'slrf_width', + allowBlank: false, + allowDecimals: false, + maxText: 'The Range is: 1800 - 16000', + maxValue: 16000, + minText: 'The Range is: 1800 - 16000', + minValue: 1800 + },{ + html: 'Master Order', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'mlrf_order', + name: 'mlrf_order', + allowBlank: false, + allowDecimals: false, + maxText: 'The Range is: 0 - 10', + maxValue: 10, + minText: 'No Negative Values Allowed', + minValue: 0 + },{ + html: 'Slave Order', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'slrf_order', + name: 'slrf_order', + allowBlank: false, + allowDecimals: false, + maxText: 'The Range is: 0 - 10', + maxValue: 10, + minText: 'No Negative Values Allowed', + minValue: 0 + },{ + html: 'Master SST', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'mlrf_sst', + name: 'mlrf_sst', + allowBlank: false, + allowDecimals: false, + maxText: 'The Range is: 0 - 100', + maxValue: 100, + minText: 'No Negative Values Allowed', + minValue: 0 + },{ + html: 'Slave SST', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'slrf_sst', + name: 'slrf_sst', + allowBlank: false, + allowDecimals: false, + maxText: 'The Range is: 0 - 100', + maxValue: 100, + minText: 'No Negative Values Allowed', + minValue: 0 + },{ + html: 'Mastr Flip', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'mlrf_flip', + name: 'mlrf_flip', + allowBlank: false, + allowDecimals: false, + maxText: 'The Range is: 8 - 128', + maxValue: 128, + minText: 'The Range is: 8 - 128', + minValue: 8 + },{ + html: 'Slave Flip', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'slrf_flip', + name: 'slrf_flip', + allowBlank: false, + allowDecimals: false, + maxText: 'The Range is: 8 - 128', + maxValue: 128, + minText: 'The Range is: 8 - 128', + minValue: 8 + },{ + html: 'Master Sun', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'mlrf_sun', + name: 'mlrf_sun', + allowBlank: false, + allowDecimals: false, + maxText: 'The Range is: 0 - 100', + maxValue: 100, + minText: 'No Negative Values Allowed', + minValue: 0 + },{ + html: 'Slave Sun', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'slrf_sun', + name: 'slrf_sun', + allowBlank: false, + allowDecimals: false, + maxText: 'The Range is: 0 - 100', + maxValue: 100, + minText: 'No Negative Values Allowed', + minValue: 0 + }] + },{ + title: 'Embed Options' + },{ + title: 'Target Width Table' + }] + } + }); + }; + LRF1D2_st_win.show(); + loadFullLRF1D2Data( SelectedNodeID ); +}; + +function LRF2D2_settings(){ + if( LRF2D2_st_win == null ){ + LRF2D2_st_win = new Ext.Window({ + title: 'Sensor Settings', + modal: true, + width: 800, + height: 600, + closeAction: 'hide', + items:{ + xtype: 'tabpanel', + activeTab: 0, + items:[{ + title: 'General Settings', + xtype: 'form', + layout: 'table', + defaults: { + bodyStyle:'padding:20px' + }, + layoutConfig: { + columns: 3 + }, + items:[{ + html: 'Status', + frame: false, + border: false + },{ + html: '

ONLINE

', + id: 'LRF2D2_dev_status', + frame: false, + border: false + },{},{ + html: 'Device Title', + frame: false, + border: false + },{ + xtype: 'field', + id: 'LRF2D2_name', + readOnly: false, + value: '' + },{},{ + html: 'Serial Number', + frame: false, + border: false + },{ + xtype: 'field', + id: 'LRF2D2_serial_num', + readOnly: true, + value: '1212' + },{},{ + html: 'Version ID', + frame: false, + border: false + },{ + xtype: 'field', + id: 'LRF2D2_version_id', + readOnly: true, + value: 'LiberManDA122' + },{},{ + html: 'Device Adress', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'LRF2D2_device_id' + },{ + xtype: 'button', + text: 'Update Device Address', + handler: function(){ + Ext.Msg.show({ + title:'Update Device Address?', + msg: 'Are you sure to do so?', + buttons: Ext.Msg.YESNOCANCEL, + //fn: processResult, + animEl: 'upddiBTN', + icon: Ext.MessageBox.QUESTION + }); + } + },{ + html: 'Device COM Speed', + frame: false, + border: false + },{ + xtype: 'combo', + id: 'LRF2D2_com_spd', + editable: false, + typeAhead: true, + triggerAction: 'all', + width: '100%', + lazyRender:true, + mode: 'local', + store: new Ext.data.ArrayStore({ + id: 0, + fields: ['mySPD', 'displayText' ], + data: [[4800,'4800'],[9600,'9600'],[14400,'14400'],[19200,'19200'],[38400, '38400'],[56000,'56000'],[57600,'57600'],[115200,'115200']] + }), + valueField: 'mySPD', + displayField: 'displayText' + },{ + xtype: 'button', + text: 'Set Device Speed', + handler: function(){ + Ext.Msg.show({ + title:'Update Device Speed?', + msg: 'Are you sure to do so?', + buttons: Ext.Msg.YESNOCANCEL, + //fn: processResult, + animEl: 'upddiBTN', + icon: Ext.MessageBox.QUESTION + }); + } + },{ + html: 'Detection Maximal Range', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'LRF2D2_max_range', + readOnly: false, + value: '1212' + },{},{ + html: 'Base Shift', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'LRF2D2_base_shift', + readOnly: false, + value: '1212' + },{ + xtype: 'button', + text: 'Update Base Shift', + handler: function(){ + var bash = Ext.getCmp('LRF2D2_base_shift').getValue(); + Ext.Ajax.request({ + url: '/lib/controller/updateLrfSettings_baseshift.php', + params: { + NID: SelectedNodeID, + UID: 'Data['id'];?>', + SID: '', + PID: 0, + BASH: bash + }, + success: function( response, opts ){ + loadFullLRF2D2Data( SelectedNodeID ); + }, + failure: failureAJAXFunction + }); + } + }] + },{ + title: 'Detection Settings', + xtype: 'form', + layout: 'table', + defaults: { + bodyStyle:'padding:20px' + }, + layoutConfig: { + columns: 4 + }, + items:[{ + html: 'Master Offset', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'mlrf_offset', + name: 'mlrf_offset', + allowBlank: false, + allowDecimals: false, + maxText: 'The Range is: 0 - 60', + maxValue: 60, + minText: 'No Negative Values Allowed', + minValue: 0, + },{ + html: 'Slave Offset', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'slrf_offset', + name: 'slrf_offset', + allowBlank: false, + allowDecimals: false, + maxText: 'The Range is: 0 - 60', + maxValue: 60, + minText: 'No Negative Values Allowed', + minValue: 0, + },{ + html: 'Master Delta', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'mlrf_delta', + name: 'mlrf_delta', + allowBlank: false, + allowDecimals: false, + maxText: 'The Range is: 0 - 320', + maxValue: 320, + minText: 'No Negative Values Allowed', + minValue: 0 + },{ + html: 'Slave Delta', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'slrf_delta', + name: 'slrf_delta', + allowBlank: false, + allowDecimals: false, + maxText: 'The Range is: 0 - 320', + maxValue: 320, + minText: 'No Negative Values Allowed', + minValue: 0 + },{ + html: 'Master Width', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'mlrf_width', + name: 'mlrf_width', + allowBlank: false, + allowDecimals: false, + maxText: 'The Range is: 1800 - 16000', + maxValue: 16000, + minText: 'The Range is: 1800 - 16000', + minValue: 1800 + },{ + html: 'Slave Width', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'slrf_width', + name: 'slrf_width', + allowBlank: false, + allowDecimals: false, + maxText: 'The Range is: 1800 - 16000', + maxValue: 16000, + minText: 'The Range is: 1800 - 16000', + minValue: 1800 + },{ + html: 'Master Order', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'mlrf_order', + name: 'mlrf_order', + allowBlank: false, + allowDecimals: false, + maxText: 'The Range is: 0 - 10', + maxValue: 10, + minText: 'No Negative Values Allowed', + minValue: 0 + },{ + html: 'Slave Order', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'slrf_order', + name: 'slrf_order', + allowBlank: false, + allowDecimals: false, + maxText: 'The Range is: 0 - 10', + maxValue: 10, + minText: 'No Negative Values Allowed', + minValue: 0 + },{ + html: 'Master SST', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'mlrf_sst', + name: 'mlrf_sst', + allowBlank: false, + allowDecimals: false, + maxText: 'The Range is: 0 - 100', + maxValue: 100, + minText: 'No Negative Values Allowed', + minValue: 0 + },{ + html: 'Slave SST', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'slrf_sst', + name: 'slrf_sst', + allowBlank: false, + allowDecimals: false, + maxText: 'The Range is: 0 - 100', + maxValue: 100, + minText: 'No Negative Values Allowed', + minValue: 0 + },{ + html: 'Mastr Flip', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'mlrf_flip', + name: 'mlrf_flip', + allowBlank: false, + allowDecimals: false, + maxText: 'The Range is: 8 - 128', + maxValue: 128, + minText: 'The Range is: 8 - 128', + minValue: 8 + },{ + html: 'Slave Flip', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'slrf_flip', + name: 'slrf_flip', + allowBlank: false, + allowDecimals: false, + maxText: 'The Range is: 8 - 128', + maxValue: 128, + minText: 'The Range is: 8 - 128', + minValue: 8 + },{ + html: 'Master Sun', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'mlrf_sun', + name: 'mlrf_sun', + allowBlank: false, + allowDecimals: false, + maxText: 'The Range is: 0 - 100', + maxValue: 100, + minText: 'No Negative Values Allowed', + minValue: 0 + },{ + html: 'Slave Sun', + frame: false, + border: false + },{ + xtype: 'numberfield', + id: 'slrf_sun', + name: 'slrf_sun', + allowBlank: false, + allowDecimals: false, + maxText: 'The Range is: 0 - 100', + maxValue: 100, + minText: 'No Negative Values Allowed', + minValue: 0 + },{ + xtype: 'button', + text: 'Update Detection Settings', + width: '100%', + colspan: 4, + handler: function(){ + var MOFS=Ext.getCmp('mlrf_offset').getValue(); + var MDEL=Ext.getCmp('mlrf_delta').getValue(); + var MWIT=Ext.getCmp('mlrf_width').getValue(); + var MORD=Ext.getCmp('mlrf_order').getValue(); + var MSST=Ext.getCmp('mlrf_sst').getValue(); + var MFLP=Ext.getCmp('mlrf_flip').getValue(); + var MSUN=Ext.getCmp('mlrf_sun').getValue(); + var SOFS=Ext.getCmp('slrf_offset').getValue(); + var SDEL=Ext.getCmp('slrf_delta').getValue(); + var SWIT=Ext.getCmp('slrf_width').getValue(); + var SORD=Ext.getCmp('slrf_order').getValue(); + var SSST=Ext.getCmp('slrf_sst').getValue(); + var SFLP=Ext.getCmp('slrf_flip').getValue(); + var SSUN=Ext.getCmp('slrf_sun').getValue(); + Ext.Ajax.request({ + url: '/lib/controller/updateDetecttionProfile.php', + params: { + NID: SelectedNodeID, + UID: 'Data['id'];?>', + SID: '', + PID: 0, + MOFS: MOFS, + MDEL: MDEL, + MWIT: MWIT, + MORD: MORD, + MSST: MSST, + MFLP: MFLP, + MSUN: MSUN, + SOFS: SOFS, + SDEL: SDEL, + SWIT: SWIT, + SORD: SORD, + SSST: SSST, + SFLP: SFLP, + SSUN: SSUN + }, + success: function( response, opts ){ + loadFullLRF2D2Data( SelectedNodeID ); + }, + failure: failureAJAXFunction + }); + } + }] + },{ + title: 'Embed Options' + },{ + title: 'Target Width Table' + },{ + title: 'Mantenence', + xtype: 'form', + layout: 'table', + defaults: { + bodyStyle:'padding:20px' + }, + layoutConfig: { + columns: 2 + }, + items:[{ + html: 'Restart Device', + frame: false, + border: false + },{ + xtype: 'button', + id: 'rstBTN', + text: 'Full Reset', + handler: function(){ + Ext.Msg.show({ + title:'Reset Device?', + msg: 'You are closing a tab that has unsaved changes. Would you like to save your changes?', + buttons: Ext.Msg.YESNOCANCEL, + //fn: processResult, + animEl: 'rstBTN', + icon: Ext.MessageBox.QUESTION + }); + } + }] + }] + } + }); + }; + LRF2D2_st_win.show(); + loadFullLRF2D2Data( SelectedNodeID ); +}; + +function LRF16D3_settings(){ +}; + +var currentResolveDeviceNode = 0; +var ResolveDeviceNodeWin = null; + +function resolveDeviceMistmatch( NodeID ){ + currentResolveDeviceNode = NodeID; + if( ResolveDeviceNodeWin == null ){ + ResolveDeviceNodeWin = new Ext.Window({ + title: 'GetLabel('_WDEV_MISTMATCH_');?>', + modal: true, + width: 500, + height: 200, + closeAction: 'hide', + items:[{ + xtype: 'spacer', + style: { + marginTop: '13px' + }, + html: '
GetLabel('_DEV_MISTMATT1_');?>
', + height: 30 + },{ + xtype: 'button', + width: '100%', + text: 'It is Newly Connected Device', + handler: function(){ + Ext.Ajax.request({ + url: '/lib/controller/validateNode.php', + params: { + NID: currentResolveDeviceNode, + UID: 'Data['id'];?>', + SID: '', + MET: 1 + }, + success: function( response, opts ){ + ResolveDeviceNodeWin.hide(); + }, + failure: failureAJAXFunction + }); + } + },{ + xtype: 'button', + width: '100%', + text: 'Apply Existing Detection Profiles to Newly Connected Device', + handler: function(){ + Ext.Ajax.request({ + url: '/lib/controller/validateNode.php', + params: { + NID: currentResolveDeviceNode, + UID: 'Data['id'];?>', + SID: '', + MET: 1 + }, + success: function( response, opts ){ + ResolveDeviceNodeWin.hide(); + }, + failure: failureAJAXFunction + }); + } + },{ + xtype: 'button', + width: '100%', + text: 'Discard old Detection Profiles and Start Device Setup Wizard', + handler: function(){ + ResolveDeviceNodeWin.hide(); + startDeviceDetectionWizard( currentResolveDeviceNode ); + } + },{ + xtype: 'button', + width: '100%', + text: 'Discard old Detection Profiles and Load Factory Settings from Device' + },{ + xtype: 'button', + width: '100%', + text: 'Discard this Connection for NOW' + }] + }); + }; + ResolveDeviceNodeWin.show(); +}; + +var DeviceDetectionWizardWnd = null; +var DDWizardActiveDevice = ''; +var RangeSetBlocker = false; +function startDeviceDetectionWizard( NodeID ){ + DDWizardActiveDevice = NodeID + if( DeviceDetectionWizardWnd == null ){ + DeviceDetectionWizardWnd = new Ext.Window({ + title: 'GetLabel('_WDEV_DET_WIZT_');?>', + modal: true, + width: 500, + height: 208, + closeAction: 'hide', + items:[{ + xtype: 'tabpanel', + activeTab: 1, + items: [{ + title: 'GetLabel('_WDEV_DET_WIZ0_');?>', + frame: false, + xtype: 'form', + items:[{ + xtype: 'spacer', + height: 20 + },{ + xtype: 'combo', + id: 'DDWizST', + fieldLabel: 'GetLabel('_DEV_TYPE_FLD_');?>', + typeAhead: true, + triggerAction: 'all', + lazyRender:true, + mode: 'local', + store: new Ext.data.ArrayStore({ + id: 0, + fields: [ + 'dtId', + 'dtText' + ], + data: [ + [1, 'GetLabel('_DEV_TYPE_ALS_');?>'], + [2, 'GetLabel('_DEV_TYPE_LFS_');?>'], + [3, 'GetLabel('_DEV_TYPE_PLS200_');?>'], + [4, 'GetLabel('_DEV_TYPE_PLS360_');?>'], + [5, 'GetLabel('_DEV_TYPE_3D_');?>'], + [6, 'GetLabel('_DEV_TYPE_NPLS200_');?>'] + ] + }), + valueField: 'dtId', + displayField: 'dtText' + },{ + xtype: 'numberfield', + id: 'DDWizSR', + fieldLabel: 'GetLabel('_DEV_RANGE_FLD_');?>', + minValue: 15.0, + maxValue: 300.0, + listeners:{ + change: function( m, nv, ov ){ + if( RangeSetBlocker ) return; + RangeSetBlocker = true; + Ext.getCmp('DDWizSRS').setValue( nv ); + RangeSetBlocker = false; + } + } + },{ + xtype: 'slider', + id: 'DDWizSRS', + fieldLabel: 'GetLabel('_DEV_RANGE_FLD_');?>', + minValue: 15.0, + maxValue: 300.0, + listeners:{ + change: function( m, nv, ov ){ + if( RangeSetBlocker ) return; + RangeSetBlocker = true; + Ext.getCmp('DDWizSR').setValue( nv ); + RangeSetBlocker = false; + } + } + },{ + xtype: 'spacer', + height: 10 + }] + },{ + title: 'GetLabel('_WDEV_DET_WIZ1_');?>', + frame: false, + xtype: 'form', + labelWidth: 120, + items:[{ + xtype: 'spacer', + height: 20 + },{ + xtype: 'combo', + id: 'DDWizIT', + fieldLabel: 'GetLabel('_DEV_ITYPE_FLD_');?>', + typeAhead: true, + triggerAction: 'all', + lazyRender:true, + mode: 'local', + value: 1, + store: new Ext.data.ArrayStore({ + id: 0, + fields: [ + 'dpId', + 'dpText' + ], + data: [ + [1, 'GetLabel('_DEV_PL_HORI_');?>'], + [2, 'GetLabel('_DEV_PL_VERT_');?>'], + [3, 'GetLabel('_DEV_PL_ANG_');?>'] + ] + }), + valueField: 'dpId', + displayField: 'dpText' + }] + },{ + title: 'GetLabel('_WDEV_DET_WIZ2_');?>', + html: 'Another one' + },{ + title: 'GetLabel('_WDEV_DET_WIZ3_');?>', + html: 'Another one' + }] + }], + bbar:[{ + text: 'Create Profiles And Finish', + handler: function(){ + DeviceDetectionWizardWnd.hide(); + } + },{ + text: 'Advanced Config', + handler: function(){ + DeviceDetectionWizardWnd.hide(); + startAdvancedDeviceDetection( DDWizardActiveDevice ); + } + }] + }); + }; + Ext.Ajax.request({ + url: '/lib/controller/getNodeBasicNfo.php', + params: { + NID: DDWizardActiveDevice, + UID: 'Data['id'];?>', + SID: '' + }, + success: function( response, opts ){ + var data = Ext.decode(response.responseText); + DeviceDetectionWizardWnd.setTitle( 'GetLabel('_WDEV_DET_WIZT_');?> [' + data.name+']' ); + Ext.getCmp('DDWizST').setValue( data.type ); + RangeSetBlocker = true; + Ext.getCmp('DDWizSR').setValue( data.range ); + Ext.getCmp('DDWizSRS').setValue( data.range ); + RangeSetBlocker = false; + DeviceDetectionWizardWnd.show(); + }, + failure: failureAJAXFunction + }); +}; + +var DeviceDetectionAdvancedWnd = null; +var DeviceDetectionProfileNames = ['factory default', 'low sens', 'medium sens', 'high sens']; +function loadAdvancedDeviceDetectionSettings(){ + Ext.getCmp('ADD_TP').removeAll( false ); + Ext.Ajax.request({ + url: '/lib/controller/getNodeAdvancedNfo.php', + params: { + NID: DDWizardActiveDevice, + UID: 'Data['id'];?>', + SID: '' + }, + success: function( response, opts ){ + var data = Ext.decode(response.responseText); + DeviceDetectionAdvancedWnd.setTitle( 'GetLabel('_WDEV_DET_WIZT_');?> [' + data.name+']' ); + if( data.profiles.length > 0 ){ + if( data.profiles.length > 3 ) Ext.getCmp('ADD_PADD_BTN').disable(); + switch( data.type ){ + case 1: + case 5:{ + for( i = 0; i < data.profiles.length / 2; i++){ + }; + break; + }; + case 2: + case 3: + case 4: + case 6:{ + for( i = 0; i < data.profiles.length; i++){ + Ext.getCmp('ADD_TP').add({ + title: DeviceDetectionProfileNames[ data.profiles[i].id ], + xtype: 'form', + frame: false, + items:[{xtype: 'spacer', height: 10 },{ + xtype: 'numberfield', + id: 'OFFSET_P'+data.profiles[i].id, + fieldLabel: 'OFFSET', + minValue: 15.0, + maxValue: 300.0, + value: data.profiles[i].offset + },{ + xtype: 'numberfield', + id: 'DELTA_P'+data.profiles[i].id, + fieldLabel: 'DELTA', + minValue: 15.0, + maxValue: 300.0, + value: data.profiles[i].delta + },{ + xtype: 'numberfield', + id: 'WIDTH_P'+data.profiles[i].id, + fieldLabel: 'WIDTH', + minValue: 15.0, + maxValue: 300.0, + value: data.profiles[i].width + },{ + xtype: 'numberfield', + id: 'SST_P'+data.profiles[i].id, + fieldLabel: 'SST', + minValue: 15.0, + maxValue: 300.0, + value: data.profiles[i].sst + },{ + xtype: 'numberfield', + id: 'FLIP_P'+data.profiles[i].id, + fieldLabel: 'FLIP', + minValue: 15.0, + maxValue: 300.0, + value: data.profiles[i].flip + },{ + xtype: 'numberfield', + id: 'SUN_P'+data.profiles[i].id, + fieldLabel: 'SUN', + minValue: 15.0, + maxValue: 300.0, + value: data.profiles[i].sun + }] + }); + }; + break; + }; + }; + // + } else { + Ext.getCmp('ADD_TP').add({ + title: 'Error!', + html: 'No Profiles Defined' + }); + }; + DeviceDetectionAdvancedWnd.show(); + }, + failure: failureAJAXFunction + }); +}; + +function startAdvancedDeviceDetection( NodeID ){ + DDWizardActiveDevice = NodeID; + if( DeviceDetectionAdvancedWnd == null ){ + DeviceDetectionAdvancedWnd = new Ext.Window({ + title: 'GetLabel('_WDEV_DET_WIZT_');?>', + modal: true, + width: 500, + height: 300, + closeAction: 'hide', + items:[{ + xtype: 'tabpanel', + id: 'ADD_TP', + frame: false, + border: false, + activeTab: 0, + items: [] + }], + bbar:[{ + id: 'ADD_PADD_BTN', + text: 'Add Detection Profile', + handler: function(){ + Ext.Ajax.request({ + url: '/lib/controller/addDetectionProfile.php', + params: { + NID: DDWizardActiveDevice, + UID: 'Data['id'];?>', + SID: '' + }, + success: function( response, opts ){ + loadAdvancedDeviceDetectionSettings(); + }, + failure: failureAJAXFunction + }); + } + },{ + text: 'Apply And Finish' + },{ + text: 'Use Wizard' + }] + }); + }; + loadAdvancedDeviceDetectionSettings(); +}; + +var maskEditorDiv = null; +var MEPanel = null; +function handleFSMaskEditorClose( event ){ + if ( document.fullscreenElement || + document.webkitFullscreenElement || + document.mozFullScreenElement || + document.msFullscreenElement ){ + } else { + MEPanel.destroy(); + maskEditorDiv.remove(); + maskEditorDiv = null; + MEPanel = null; + document.removeEventListener( 'fullscreenchange', handleFSMaskEditorClose ); + }; +}; + +function hideMaskEditor(){ + if( + document.fullscreenElement || + document.webkitFullscreenElement || + document.mozFullScreenElement || + document.msFullscreenElement + ){ + if( document.exitFullscreen ){ + document.exitFullscreen(); + }else if( document.mozCancelFullScreen ){ + document.mozCancelFullScreen(); + }else if( document.webkitExitFullscreen ){ + document.webkitExitFullscreen(); + }else if( document.msExitFullscreen ){ + document.msExitFullscreen(); + }; + // Removal Done by event! + //maskEditorDiv.remove(); + //maskEditorDiv = null; + //document.removeEventListener( 'fullscreenchange', handleFSMaskEditorClose ); + }; +}; +var values = { + paths: 50, + minPoints: 5, + maxPoints: 15, + minRadius: 30, + maxRadius: 90 +}; + +var hitOptions = { + segments: true, + stroke: true, + fill: true, + tolerance: 10 +}; + +var polycolors = new Array(); +var polyindex = 0; +var poligones = new Array(); + +var segment = null; +var path = null; +var MaskProject = null; +var MaskEditorMode = 0; + +function onMouseDown(event) { + segment = path = null; + var hitResult = MaskProject.hitTest( event.point, hitOptions ); + if (!hitResult) return; + + if( event.modifiers.shift ){ + if (hitResult.type == 'segment') { + hitResult.segment.remove(); + }; + return; + }; + if( hitResult ){ + path = hitResult.item; + if( hitResult.type == 'segment' ){ + segment = hitResult.segment; + path.fullySelected = false; + segment.selected = true; + } else if( hitResult.type == 'stroke' ){ + var location = hitResult.location; + segment = path.insert(location.index + 1, event.point); + //path.smooth(); + path.fullySelected = false; + segment.selected = true; + } else if ( hitResult.type == 'fill' ){ + path.fullySelected = true; + }; + } + //movePath = ; + //if( movePath ) MaskProject.activeLayer.addChild(hitResult.item); +} + +function onMouseMove(event) { + MaskProject.activeLayer.selected = false; + if( event.item ) { + //event.item.selected = true; + event.item.fullySelected = true; + }; +} + +function onMouseDrag(event) { + if( segment ){ + //segment.point += event.delta; + segment.point = event.point; + //path.smooth(); + }; + //else if (path) { + // path.position += event.delta; + //} +} +var absDrawMapSizes = [[4096,4096],[2304,288]]; +var deviceMapScaling = 1.0; +var deviceMapTopShift = 100; +var deviceMapLeftShift = 100; +var cMapImageWidth = 0; +var cMapImageHeight = 0; +var cMapCanvasWidth = 0; +var cMapCanvasHeight = 0; +var cMapType = 0; +var cMaskLRF = 0; +var cMaskID = 0; + +function SaveCurrentMask( NodeID, MaskID = 0, LRFID = 0 ){ + var serial = MaskProject.exportJSON(); + Ext.Ajax.request({ + url: '/lib/controller/uploadDeviceMask.php', + params: { + NID: NodeID, + UID: 'Data['id'];?>', + SID: '', + MID: MaskID, + LID: LRFID, + MDTA: serial, + MIH: cMapImageHeight, + MIW: cMapImageWidth, + MSHX: deviceMapLeftShift, + MSHY: deviceMapTopShift, + DSTD: 1 + }, + success: function( response, opts ){ + //var data = Ext.decode(response.responseText); + //hideMaskEditor(); + }, + failure: failureAJAXFunction + }); +} + + +function doMaskOperation( NodeID, Cmd, Mid = 0, LRFID = 0 ){ + Ext.Ajax.request({ + url: '/lib/controller/doMaskOperation.php', + params: { + NID: NodeID, + UID: 'Data['id'];?>', + SID: '', + CMD: Cmd, + MID: Mid, + LID: LRFID + }, + success: function( response, opts ){ + //var data = Ext.decode(response.responseText); + //hideMaskEditor(); + }, + failure: failureAJAXFunction + }); +} + +function showMaskEditor( fromDevTool, DevType, NodeID ){ + //alert( "DevType: "+DevType + " Dev Map size: "+ absDrawMapSizes[DevType][0]+"x"+absDrawMapSizes[DevType][1] ); + cMapType = DevType; + if( DevType == 1 ){ + deviceMapScaling = ( window.screen.height * window.devicePixelRatio - 130 - ( deviceMapTopShift * 2 )) / absDrawMapSizes[DevType][1]; + } else { + deviceMapScaling = ( window.screen.width * window.devicePixelRatio - 30 - ( deviceMapLeftShift * 2 )) / absDrawMapSizes[DevType][0]; + }; + cMapImageHeight = deviceMapScaling * absDrawMapSizes[DevType][1]; + cMapImageWidth = deviceMapScaling * absDrawMapSizes[DevType][0]; + cMapCanvasWidth = cMapImageWidth + (deviceMapLeftShift * 2); + cMapCanvasHeight = cMapImageHeight + (deviceMapTopShift * 2); + if( fromDevTool ){ + detectionProfileWindow.hide(); + }; + if( + document.fullscreenElement || + document.webkitFullscreenElement || + document.mozFullScreenElement || + document.msFullscreenElement + ){ + //fs mode allready + hideMaskEditor(); + }else{ + if( maskEditorDiv == null ){ + maskEditorDiv = document.createElement("div"); + maskEditorDiv.style.height="200px"; + maskEditorDiv.style.width="200px"; + //var svg = document.getElementById('draw_svg_'+parseInt( NodeID ) ); + //var svgCode = window.btoa(svg.outerHTML); + //maskEditorDiv.style.background = "url(data:image/svg+xml;base64," + svgCode + ")"; + //maskEditorDiv.style.background = 'solid red;'; + //maskEditorDiv.style.backgroundImage = "url('style/wicons/011.png')"; + //append div as a child to body + document.body.appendChild( maskEditorDiv ); + //var elem = document.createElement("img"); 'getDeviceMap.php?NID='+NodeID + //elem.setAttribute("src", "/lib/controller/data/device_draws/75c85fec4be204fc0bc0452f53b5a3df_map.png"); + //elem.setAttribute("height", "80%"); + //elem.setAttribute("width", "130"); + //maskEditorDiv.appendChild( elem ); + //alert( window.screen.width * window.devicePixelRatio + "x" + window.screen.height * window.devicePixelRatio); + if( MEPanel == null ){ + var ww = window.screen.width * window.devicePixelRatio; + var hh = window.screen.height * window.devicePixelRatio; + MEPanel = new Ext.Panel( { + title: 'Mask Editor', + renderTo: maskEditorDiv, + width: ww, + height: hh, + frame: true, + autoScroll: true, + items:[{ + xtype: 'panel', + width: cMapCanvasWidth, + html: '
', + listeners:{ + afterrender: function(){ + //Doing a custom svg here for background! + var chicha = document.getElementById( 'popomas' ); + var svg = document.getElementById('draw_svg_'+parseInt( NodeID ) ); + var svgCode = window.btoa(svg.outerHTML); + chicha.style.backgroundImage = "url(data:image/svg+xml;base64," + svgCode + ")"; + //chicha.style.backgroundImage = "url('style/wicons/011.png')"; + //alert( NodeID ); + /* + + var svg = document.querySelector('#svg'); + var svgCode = encodeURI(svg.outerHTML); + + element.style.backgroundImage = "url(data:image/svg+xml;utf8," + svgCode + ")"; + + function set_gridSize (num) { + num = Number(num); + + var xml = ' '; + var data = $($.parseXML(xml)); + + var defs = data.children("svg").children("defs"); + defs.children("#smallGrid").attr({ height: num, width: num }); + var path = defs.children("#smallGrid").children().attr("d"); + var arr = path.split(" "); + arr[1] = num; + arr[arr.length - 1] = num; + path = arr.join(" "); + defs.children("#smallGrid").children("path").attr("d", path) + defs.children("#grid").attr({ height: num * 10, width: num * 10 }); + defs.children("#grid").children("rect").attr({ height: num * 10, width: num * 10 }); + var path = defs.children("#grid").children("path").attr("d"); + var arr = path.split(" "); + arr[1] = num*10; + arr[arr.length - 1] = num*10; + path = arr.join(" "); + defs.children("#grid").children("path").attr("d", path); + + return "url(data:image/svg+xml;base64," + Base64.encode(new XMLSerializer().serializeToString(defs.parent()[0]))+")"; + }; */ + } + } + }], + tbar:[{ + text:'New Polygone', + id: 'me_b_newp', + enableToggle: true, + toggleGroup: 'me_topbar_grp', + pressed: false, + handler: function( btn ){ + if( btn.pressed ) setMaskEditorMode( 0 ); + } + }/*,{ + text:'Delete Polygone', + id: 'me_b_delp', + enableToggle: true, + toggleGroup: 'me_topbar_grp' + },{ + text:'Delete Point', + id: 'me_b_delpo', + enableToggle: true, + toggleGroup: 'me_topbar_grp' + }*/,{ + text:'Clear Mask', + id: 'me_b_delm', + handler: function(){ + if( MaskProject!= null ){ + doMaskOperation( NodeID, 3, cMaskID ); + }; + MaskProject = new paper.Project( canvas ); + paper.view.draw(); + setMaskEditorMode( 0 ); + } + },{ + text:'1', + enableToggle: true, + toggleGroup: 'me_maskbar_grp', + pressed: (cMaskID == 0 ), + handler: function(){ + if( cMaskID != 0 ){ + SaveCurrentMask( NodeID, cMaskID ); + }; + MaskProject = new paper.Project( canvas ); + paper.view.draw(); + cMaskID = 0; + loadDeviceMask( NodeID, cMaskID ); + } + },{ + text:'2', + enableToggle: true, + toggleGroup: 'me_maskbar_grp', + pressed: ( cMaskID == 1 ), + handler: function(){ + if( cMaskID != 1 ){ + SaveCurrentMask( NodeID, cMaskID ); + }; + MaskProject = new paper.Project( canvas ); + paper.view.draw(); + cMaskID = 1; + loadDeviceMask( NodeID, cMaskID ); + } + },{ + text:'3', + enableToggle: true, + toggleGroup: 'me_maskbar_grp', + pressed: ( cMaskID == 2 ), + handler: function(){ + if( cMaskID != 2 ){ + SaveCurrentMask( NodeID, cMaskID ); + }; + MaskProject = new paper.Project( canvas ); + paper.view.draw(); + cMaskID = 2; + loadDeviceMask( NodeID, cMaskID ); + } + },{ + text:'4', + enableToggle: true, + toggleGroup: 'me_maskbar_grp', + pressed: ( cMaskID == 3 ), + handler: function(){ + if( cMaskID != 3 ){ + SaveCurrentMask( NodeID, cMaskID ); + }; + MaskProject = new paper.Project( canvas ); + paper.view.draw(); + cMaskID = 3; + loadDeviceMask( NodeID, cMaskID ); + } + },{ + text:'5', + enableToggle: true, + toggleGroup: 'me_maskbar_grp', + pressed: ( cMaskID == 4 ), + handler: function(){ + if( cMaskID != 4 ){ + SaveCurrentMask( NodeID, cMaskID ); + }; + MaskProject = new paper.Project( canvas ); + paper.view.draw(); + cMaskID = 4; + loadDeviceMask( NodeID, cMaskID ); + } + }], + buttons:[{ + text: 'Cancel', + handler: function(){ + hideMaskEditor(); + } + },{ + text:'Save Mask and Close', + handler: function(){ + var serial = MaskProject.exportJSON(); + Ext.Ajax.request({ + url: '/lib/controller/uploadDeviceMask.php', + params: { + NID: NodeID, + UID: 'Data['id'];?>', + SID: '', + MID: cMaskID, + LID: 0, + MDTA: serial, + MIH: cMapImageHeight, + MIW: cMapImageWidth, + //MSF: deviceMapScaling, + MSHX: deviceMapLeftShift, + MSHY: deviceMapTopShift + }, + success: function( response, opts ){ + var data = Ext.decode(response.responseText); + hideMaskEditor(); + }, + failure: failureAJAXFunction + }); + } + }] + }); + }; + MEPanel.doLayout(); + //if( MaskProject == null ){ + var canvas = document.getElementById('mask_canvas'); + paper.settings.handleSize = 10; + MaskProject = new paper.Project( canvas ); + //canvas.addEventListener( 'mousemove', onMaskMouseMove ); + canvas.addEventListener( 'mousedown', onMaskMouseDown ); + //canvas.addEventListener( 'mouseup', onMaskMouseUp ); + //canvas.addEventListener( 'mousedrag', onMaskMouseMove ); + //}; + cMaskID = 0; + loadDeviceMask( NodeID, cMaskID ); + }; + //maskEditorDiv = $('#container').get(0); + //var maskEditorDiv = document.getElementById( id ); //Ext.getCmp( id ); + if( maskEditorDiv.requestFullscreen ){ + maskEditorDiv.requestFullscreen(); + }else if( maskEditorDiv.mozRequestFullScreen ){ + maskEditorDiv.mozRequestFullScreen(); + }else if( maskEditorDiv.webkitRequestFullscreen ){ + maskEditorDiv.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT); + }else if( maskEditorDiv.msRequestFullscreen ){ + maskEditorDiv.msRequestFullscreen(); + }; + document.addEventListener( 'fullscreenchange', handleFSMaskEditorClose ); + }; +}; + +function setMaskEditorMode( nM ){ + switch( nM ){ + case 0:{ + var MEP = Ext.getCmp('me_b_newp'); + if( !MEP.pressed ) MEP.toggle( true ); + var caca = document.getElementById('mask_canvas'); + caca.style.cursor = 'crosshair'; + break; + }; + case 1:{ + var MEP = Ext.getCmp('me_b_newp'); + if( !MEP.pressed ) MEP.toggle( false ); + //MEP = Ext.getCmp('me_b_delp'); + //if( !MEP.pressed ) MEP.toggle( false ); + //MEP = Ext.getCmp('me_b_delpo'); + //if( !MEP.pressed ) MEP.toggle( false ); + if( MaskProject!= null ){ + if( MaskProject.isEmpty() ){ + //MEP = Ext.getCmp('me_b_delp'); + //MEP.disable(); + //MEP = Ext.getCmp('me_b_delpo'); + //MEP.disable(); + MEP = Ext.getCmp('me_b_delm'); + MEP.disable(); + setMaskEditorMode( 0 ); + } else { + //MEP = Ext.getCmp('me_b_delp'); + //MEP.enable(); + //MEP = Ext.getCmp('me_b_delpo'); + //MEP.enable(); + MEP = Ext.getCmp('me_b_delm'); + MEP.enable(); + }; + }; + var caca = document.getElementById('mask_canvas'); + caca.style.cursor = 'default'; + break; + }; + case 2:{ + //var MEP = Ext.getCmp('me_b_delp'); + //if( !MEP.pressed ) MEP.toggle( true ); + break; + }; + case 3:{ + //var MEP = Ext.getCmp('me_b_delpo'); + //if( !MEP.pressed ) MEP.toggle( true ); + break; + }; + case 4:{ + + }; + }; + MaskEditorMode = nM; +}; + +function loadDeviceMask( NodeID, LayerID = 0, LrfID = 0 ){ + Ext.Ajax.request({ + url: '/lib/controller/getDeviceMask.php', + params: { + NID: NodeID, + UID: 'Data['id'];?>', + SID: '', + MID: LayerID, + LID: LrfID + }, + success: function( response, opts ){ + var data = Ext.decode(response.responseText); + + if( data.length > 0 ){ + for( i = 0; i < data.length; i++ ){ + //var + path = new paper.Path(); + path.strokeColor = 'black'; + //var lightness = (Math.random() - 0.5) * 0.4 + 0.4; + //var hue = Math.random() * 360; + //path.fillColor = { hue: hue, saturation: 1, lightness: lightness }; + path.fillColor = data[i].colour; + path.closed = true; + path.opacity = 0.5; + //path.onMouseMove = onMouseMove; + path.onMouseDown = onMouseDown; + path.onMouseDrag = onMouseDrag; + //path.onMouseUp = function( event ){ + // path.add(event.point); + //} + if( data[i].points.length > 2 ){ + if( cMapType == 1 ){ + var tX = data[i].points[0][0] * deviceMapScaling + deviceMapLeftShift; + var tY = data[i].points[0][1] * deviceMapScaling + deviceMapTopShift; + path.moveTo( [tX,tY] ); + for(k = 1; k < data[i].points.length; k++ ){ + tX = data[i].points[k][0] * deviceMapScaling + deviceMapLeftShift; + tY = data[i].points[k][1] * deviceMapScaling + deviceMapTopShift; + path.lineTo( [tX,tY] ); + }; + } else { + var tX = ( 2047 + parseInt( data[i].points[0][0]) ) * deviceMapScaling + deviceMapLeftShift; + var tY = ( 2047 + parseInt( data[i].points[0][1]) ) * deviceMapScaling + deviceMapTopShift; + path.moveTo( [tX,tY] ); + for(k = 1; k < data[i].points.length; k++ ){ + tX = ( 2047 + parseInt(data[i].points[k][0]) ) * deviceMapScaling + deviceMapLeftShift; + tY = ( 2047 + parseInt(data[i].points[k][1]) ) * deviceMapScaling + deviceMapTopShift; + path.lineTo( [tX,tY] ); + }; + }; + path.fullySelected = true; + paper.view.draw(); + }; + poligones.push(path); + setMaskEditorMode( 4 ); + }; + } else { + setMaskEditorMode( 0 ); + }; + }, + failure: failureAJAXFunction + }); +}; + +function onMaskMouseDown( evt ){ + switch( MaskEditorMode ){ + case 0:{ + path = new paper.Path(); + path.strokeColor = 'black'; + path.fillColor = '#ff8020'; + path.onMouseDown = onMouseDown; + path.onMouseDrag = onMouseDrag; + //path.onMouseMove = onMouseMove; + path.fullySelected = true; + path.closed = true; + path.opacity = 0.5; + path.moveTo( [ evt.pageX - $(document).scrollLeft() - $('#mask_canvas').offset().left, evt.pageY - $(document).scrollTop() - $('#mask_canvas').offset().top ] ); + setMaskEditorMode( 1 ); + break; + }; + case 1:{ + path.lineTo( [ evt.pageX - $(document).scrollLeft() - $('#mask_canvas').offset().left, evt.pageY - $(document).scrollTop() - $('#mask_canvas').offset().top ] ); + if( path.segments.length == 3 ){ + setMaskEditorMode( 4 ); + }; + }; + }; + //if( MaskEditorMode == 0 ){ + // + //} else { + // path.lineTo( [ evt.pageX - $(document).scrollLeft() - $('#mask_canvas').offset().left, evt.pageY - $(document).scrollTop() - $('#mask_canvas').offset().top ] ); + //}; +}; + +function onMaskMouseUp( evt ){ + if( MaskEditorMode == 4 ){ + //path.lineTo( [ evt.pageX - $(document).scrollLeft() - $('#mask_canvas').offset().left, evt.pageY - $(document).scrollTop() - $('#mask_canvas').offset().top ] ); + path.fullySelected = true; + path.onMouseDown = onMouseDown; + path.onMouseDrag = onMouseDrag; + paper.view.draw(); + //poligones.push( path ); + setMaskEditorMode( 1 ); + }; +}; + +function onMaskMouseMove( event ){ + if( MaskEditorMode == 4 ){ + //paper.view.draw(); + }; +}; + + +