Browse Source

Jay Version 3.1

master
root 4 years ago
parent
commit
ee3e85dda5
  1. 4
      lib/controller/dash/node_3.js
  2. BIN
      lib/controller/data/mysqlitedb.db
  3. BIN
      lib/controller/data/reports.db
  4. 6
      lib/controller/doMaskOperation.php
  5. 63
      lib/controller/getDeviceMask.php
  6. 4
      lib/controller/getHistoryEvents.php
  7. 2
      lib/controller/getReportLayout.php
  8. 8
      lib/controller/getStatus.php
  9. 2
      lib/controller/report/node_3.js
  10. 51
      lib/controller/uploadDeviceMask.php
  11. 135
      lib/javascript/jsapi_dynamic/mojo_dashboard.js
  12. 225
      lib/javascript/jsapi_dynamic/rgoose_devices.js
  13. 2458
      lib/javascript/jsapi_dynamic/rgoose_devices.js.bak
  14. 2370
      lib/javascript/jsapi_dynamic/rgoose_devices_.js

4
lib/controller/dash/node_3.js

@ -43,7 +43,7 @@
layout: 'hbox',
items:[{
id: 'cp_radar_%%%NODEID%%%',
html: '<div id="div_radar_%%%NODEID%%%" style="display: block; padding: 5px; width: \'100%\'; height: \'100%\';"><center><svg id="draw_svg_%%%NODEID%%%" opacity="0.3" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" width="86%" version="1.1" onclick="select2DROI( %%%NODEID%%%, event );" style="shape-rendering:geometricPrecision; text-rendering:geometricPrecision; image-rendering:optimizeQuality; fill-rule:evenodd; clip-rule:evenodd; cursor: crosshair;" viewBox="0 0 574 574" xmlns:xlink="http://www.w3.org/1999/xlink"><text id="g_txt_%%%NODEID%%%" text-anchor="left" transform="rotate(0,35,35)" x="35" y="35" fill="#FFF212" style="font: 30px sans-serif">100 m.</text><circle fill="#00A859" stroke="#373435" stroke-width="5.92139" cx="287" cy="287" r="284"/><circle id="r50_%%%NODEID%%%" fill="none" stroke="#FFF212" stroke-width="3.94741" cx="287" cy="287" r="142"/><text id="50_txt_%%%NODEID%%%" text-anchor="left" transform="rotate(45,140,140)" x="140" y="140" fill="#FFF212" style="font: 25px sans-serif">50</text><circle id="r25_%%%NODEID%%%" fill="none" stroke="#FFF212" stroke-width="2.96042" cx="287" cy="287" r="71"/><text id="25_txt_%%%NODEID%%%" text-anchor="left" transform="rotate(45,210,210)" x="210" y="210" fill="#FFF212" style="font: 15px sans-serif">25</text><circle id="r12_%%%NODEID%%%" fill="none" stroke="#FFF212" stroke-width="1.47993" cx="287" cy="287" r="34"/><text id="12_txt_%%%NODEID%%%" text-anchor="left" transform="rotate(45,245,245)" x="245" y="245" fill="#FFF212" style="font: 10px sans-serif">12.5</text><line fill="none" stroke="#FFF212" stroke-width="3.94741" x1="287" y1="3" x2="287" y2="571"/><line fill="none" stroke="#FFF212" stroke-width="3.94741" x1="3" y1="287" x2="571" y2="287"/><circle fill="none" stroke="#373435" stroke-width="5.92139" cx="287" cy="287" r="284"/></svg></center></div>',
html: '<div id="div_radar_%%%NODEID%%%" style="display: block; padding: 5px; width: \'100%\'; height: \'100%\';"><center><svg id="draw_svg_%%%NODEID%%%" opacity="0.3" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" width="86%" version="1.1" onclick="select2DROI( %%%NODEID%%%, event );" style="shape-rendering:geometricPrecision; text-rendering:geometricPrecision; image-rendering:optimizeQuality; fill-rule:evenodd; clip-rule:evenodd; cursor: crosshair;" viewBox="0 0 574 574" xmlns:xlink="http://www.w3.org/1999/xlink"><defs><clipPath id="svg_mask_%%%NODEID%%%"><circle cx="287" cy="287" r="284"/></clipPath></defs><text id="g_txt_%%%NODEID%%%" text-anchor="left" transform="rotate(0,35,35)" x="35" y="35" fill="#FFF212" style="font: 30px sans-serif">100 m.</text><circle fill="#00A859" stroke="none" cx="287" cy="287" r="284"/><circle id="border_%%%NODEID%%%" fill="none" stroke="#373435" stroke-width="5.92139" cx="287" cy="287" r="284"/><circle id="r50_%%%NODEID%%%" fill="none" stroke="#FFF212" stroke-width="3.94741" cx="287" cy="287" r="142"/><text id="50_txt_%%%NODEID%%%" text-anchor="left" transform="rotate(45,140,140)" x="140" y="140" fill="#FFF212" style="font: 25px sans-serif">50</text><circle id="r25_%%%NODEID%%%" fill="none" stroke="#FFF212" stroke-width="2.96042" cx="287" cy="287" r="71"/><text id="25_txt_%%%NODEID%%%" text-anchor="left" transform="rotate(45,210,210)" x="210" y="210" fill="#FFF212" style="font: 15px sans-serif">25</text><circle id="r12_%%%NODEID%%%" fill="none" stroke="#FFF212" stroke-width="1.47993" cx="287" cy="287" r="34"/><text id="12_txt_%%%NODEID%%%" text-anchor="left" transform="rotate(45,245,245)" x="245" y="245" fill="#FFF212" style="font: 10px sans-serif">12.5</text><line fill="none" stroke="#FFF212" stroke-width="3.94741" x1="287" y1="3" x2="287" y2="571"/><line fill="none" stroke="#FFF212" stroke-width="3.94741" x1="3" y1="287" x2="571" y2="287"/><circle fill="none" stroke="#373435" stroke-width="5.92139" cx="287" cy="287" r="284"/></svg></center></div>',
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',

BIN
lib/controller/data/mysqlitedb.db

Binary file not shown.

BIN
lib/controller/data/reports.db

Binary file not shown.

6
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() );

63
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;
};
};
};
};

4
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'] );

2
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: '&nbsp;', 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: '&nbsp;', listeners:{ afterrender: function(p){ var W=p.getWidth(); p.setHeight( 32+(W/16)*9);}}}";

8
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'] );

2
lib/controller/report/node_3.js

@ -43,7 +43,7 @@
layout: 'hbox',
items:[{
id: 'cp_radar_%%%NODEID%%%',
html: '<div id="div_radar_%%%NODEID%%%" style="display: block; padding: 5px; width: \'100%\'; height: \'100%\';"><center><svg id="draw_svgr_%%%NODEID%%%" opacity="1.0" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" width="86%" version="1.1" onclick="select2DROI( %%%NODEID%%%, event );" style="shape-rendering:geometricPrecision; text-rendering:geometricPrecision; image-rendering:optimizeQuality; fill-rule:evenodd; clip-rule:evenodd; cursor: crosshair;" viewBox="0 0 574 574" xmlns:xlink="http://www.w3.org/1999/xlink"><text id="g_txt_%%%NODEID%%%" text-anchor="left" transform="rotate(0,35,35)" x="35" y="35" fill="#FFF212" style="font: 30px sans-serif">100 m.</text><circle fill="#00A859" stroke="#373435" stroke-width="5.92139" cx="287" cy="287" r="284"/><circle id="r50_%%%NODEID%%%" fill="none" stroke="#FFF212" stroke-width="3.94741" cx="287" cy="287" r="142"/><text id="50_txt_%%%NODEID%%%" text-anchor="left" transform="rotate(45,140,140)" x="140" y="140" fill="#FFF212" style="font: 25px sans-serif">50</text><circle id="r25_%%%NODEID%%%" fill="none" stroke="#FFF212" stroke-width="2.96042" cx="287" cy="287" r="71"/><text id="25_txt_%%%NODEID%%%" text-anchor="left" transform="rotate(45,210,210)" x="210" y="210" fill="#FFF212" style="font: 15px sans-serif">25</text><circle id="r12_%%%NODEID%%%" fill="none" stroke="#FFF212" stroke-width="1.47993" cx="287" cy="287" r="34"/><text id="12_txt_%%%NODEID%%%" text-anchor="left" transform="rotate(45,245,245)" x="245" y="245" fill="#FFF212" style="font: 10px sans-serif">12.5</text><line fill="none" stroke="#FFF212" stroke-width="3.94741" x1="287" y1="3" x2="287" y2="571"/><line fill="none" stroke="#FFF212" stroke-width="3.94741" x1="3" y1="287" x2="571" y2="287"/><circle fill="none" stroke="#373435" stroke-width="5.92139" cx="287" cy="287" r="284"/></svg></center></div>',
html: '<div id="div_radar_%%%NODEID%%%" style="display: block; padding: 5px; width: \'100%\'; height: \'100%\';"><center><svg id="draw_svgr_%%%NODEID%%%" opacity="1.0" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" width="86%" version="1.1" onclick="select2DROI( %%%NODEID%%%, event );" style="shape-rendering:geometricPrecision; text-rendering:geometricPrecision; image-rendering:optimizeQuality; fill-rule:evenodd; clip-rule:evenodd; cursor: crosshair;" viewBox="0 0 574 574" xmlns:xlink="http://www.w3.org/1999/xlink"><text id="g_txt_%%%NODEID%%%" text-anchor="left" transform="rotate(0,35,35)" x="35" y="35" fill="#FFF212" style="font: 30px sans-serif">100 m.</text><circle fill="#00A859" stroke="none" cx="287" cy="287" r="284"/><circle id="border_%%%NODEID%%%" fill="none" stroke="#373435" stroke-width="5.92139" cx="287" cy="287" r="284"/><circle id="r50_%%%NODEID%%%" fill="none" stroke="#FFF212" stroke-width="3.94741" cx="287" cy="287" r="142"/><text id="50_txt_%%%NODEID%%%" text-anchor="left" transform="rotate(45,140,140)" x="140" y="140" fill="#FFF212" style="font: 25px sans-serif">50</text><circle id="r25_%%%NODEID%%%" fill="none" stroke="#FFF212" stroke-width="2.96042" cx="287" cy="287" r="71"/><text id="25_txt_%%%NODEID%%%" text-anchor="left" transform="rotate(45,210,210)" x="210" y="210" fill="#FFF212" style="font: 15px sans-serif">25</text><circle id="r12_%%%NODEID%%%" fill="none" stroke="#FFF212" stroke-width="1.47993" cx="287" cy="287" r="34"/><text id="12_txt_%%%NODEID%%%" text-anchor="left" transform="rotate(45,245,245)" x="245" y="245" fill="#FFF212" style="font: 10px sans-serif">12.5</text><line fill="none" stroke="#FFF212" stroke-width="3.94741" x1="287" y1="3" x2="287" y2="571"/><line fill="none" stroke="#FFF212" stroke-width="3.94741" x1="3" y1="287" x2="571" y2="287"/><circle fill="none" stroke="#373435" stroke-width="5.92139" cx="287" cy="287" r="284"/></svg></center></div>',
width: '100%'
}],
bbar:[{

51
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();

135
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<masks_2d[a][i].vtx.length; k++ ){
var pp = '';
for( l=0; l<masks_2d[a][i].vtx[k].length; l++){
pp += ' '+(cpx + rk * masks_2d[a][i].vtx[k][l][0])+','+( cpy + rk*masks_2d[a][i].vtx[k][l][1]);
};
var newpath = document.createElementNS('http://www.w3.org/2000/svg', "polygon");
newpath.setAttributeNS(null, "points", pp );
newpath.setAttributeNS(null, "fill",colors[i] );
if( masks_2d[a][i].status ){
newpath.setAttributeNS(null, "fill-opacity", "0.6");
} else {
newpath.setAttributeNS(null, "fill-opacity", "0.2");
};
newpath.setAttributeNS(null, "id", "mask_"+a+"_"+i+"_"+k );
newpath.setAttributeNS(null, "clip-path", "url(#svg_mask_"+a+")" );
var tch = csvg.getElementById( "border_"+a );
if( tch != undefined ){
csvg.insertBefore( newpath, tch );
} else {
csvg.appendChild( newpath );
};
masks_2d_shown[a][i][k] = 1;
};
};
};
};
};
};
function load2DMasks( a ){
Ext.Ajax.request({
url: '/lib/controller/getDeviceMask.php',
params: {
SITE: <?=$SiteID;?>,
UID: <?=$UserID;?>,
SID: '<?=$Session;?>',
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 ){

225
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('<b>Range:' + range + ' m. Azimuth:' + az + '°</b>');
};
};
}
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('<b>'+c_m_X+'x'+c_m_Y+'</b>');
};
};
//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('<b>Range:' + range + ' m. Azimuth:' + az + '°</b>');
};
};
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: '<div id=\'popomas\' style="display: block; width: '+cMapCanvasWidth+'px; height: '+cMapCanvasHeight+ 'px; background: orange; background-position-x: '+deviceMapLeftShift+'px; background-position-y: '+deviceMapTopShift+'px; background-size: '+cMapImageWidth+'px '+cMapImageHeight+'px; background-image: url(\'/lib/controller/getDeviceDraw.php?MAP=1&NID='+NodeID+'\'); background-repeat: no-repeat;"><canvas id="mask_canvas" width="'+cMapCanvasWidth+'px" height="'+cMapCanvasHeight+'px"></canvas></dvi>',
//html: '<div id=\'popomas\' style="display: block; width: '+cMapCanvasWidth+'px; height: '+cMapCanvasHeight+ 'px; background: orange; background-position-x: '+deviceMapLeftShift+'px; background-position-y: '+deviceMapTopShift+'px; background-size: '+cMapImageWidth+'px '+cMapImageHeight+'px; background-image: url(\'/lib/controller/getDeviceDraw.php?MAP=1&NID='+NodeID+'\'); background-repeat: no-repeat; z-index:10;"><canvas id="mask_canvas" width="'+cMapCanvasWidth+'px" height="'+cMapCanvasHeight+'px"></canvas></dvi>',
html: '<div id="popomas" style="display: block; width: '+cMapCanvasWidth+'px; height: '+cMapCanvasHeight+ 'px; position: relative; top:0; left:0; z-index: 1000;"><canvas id="mask_canvas" width="'+cMapCanvasWidth+'px" height="'+cMapCanvasHeight+'px"></canvas></div><div id="baka" style="background:orange;display:block;width: '+cMapCanvasWidth+'px; height: '+cMapCanvasHeight+ 'px; position:absolute;top:0; left:0; z-index:0;"><svg id="draw_svg_me" opacity="1.0" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" width="'+cMapImageWidth+'" height="'+cMapImageHeight+'" version="1.1" style="position: relative; top:'+deviceMapTopShift+'; left:'+deviceMapLeftShift+'; z-index:0; shape-rendering:geometricPrecision; text-rendering:geometricPrecision; image-rendering:optimizeQuality; fill-rule:evenodd; clip-rule:evenodd;" viewBox="0 0 574 574" xmlns:xlink="http://www.w3.org/1999/xlink"><defs><clipPath id="me_mask"><circle cx="287" cy="287" r="284"/></clipPath></defs><circle fill="#00A859" stroke="#373435" stroke-width="5.92139" cx="287" cy="287" r="284"/><line fill="none" stroke="#FFF212" stroke-width="1" x1="287" y1="3" x2="287" y2="571"/><line fill="none" stroke="#FFF212" stroke-width="1" x1="3" y1="287" x2="571" y2="287"/><circle fill="none" stroke="#373435" stroke-width="1" cx="287" cy="287" r="284"/></svg></div>',
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 = '<svg width="100%" height="100%" xmlns="http://www.w3.org/2000/svg"><defs><pattern id="smallGrid" width="10" height="10" patternUnits="userSpaceOnUse"><path d="M 10 0 L 0 0 0 10" fill="none" stroke="gray" stroke-width="0.5"/> </pattern><pattern id="grid" width="100" height="100" patternUnits="userSpaceOnUse"><rect width="100" height="100" fill="url(#smallGrid)"/><path d="M 100 0 L 0 0 0 100" fill="none" stroke="gray" stroke-width="1"/></pattern></defs><rect width="100%" height="100%" fill="url(#grid)" /></svg>';
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: '<p style="color: white;">kook</p>'
}],
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: <?=$UserID;?>,
SID: '<?=$Session;?>',
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<data.data.length;i++){
var cc = Math.cos( p2 - ak * i - so );
var cs = Math.sin( p2 - ak * i - so );
za = cpx + cpx * cc;
zb = cpy + cpx * cs;
if( data.data[i].M == 0 ){
x = za; y = zb;
} else {
if( data.data[i].M < max ){
x = cpx + data.data[i].M * rk * cc;
y = cpy + data.data[i].M * rk * cs;
} else {
x = za; y = zb;
};
};
pp += ' '+za+','+zb;
jj += ' '+x+','+y;
};
pp += jj;
newpath.setAttributeNS(null, "points", pp );
newpath.setAttributeNS(null, "fill", "#044B94" );
newpath.setAttributeNS(null, "fill-opacity", "0.4");
newpath.setAttributeNS(null, "id", "draw" );
csvg.appendChild( newpath );
};
};
},
failure: failureAJAXFunction
});
};
function setMaskEditorMode( nM ){
switch( nM ){
case 0:{
@ -2278,7 +2404,7 @@ function loadDeviceMask( NodeID, LayerID = 0, LrfID = 0 ){
path.fillColor = data[i].colour;
path.closed = true;
path.opacity = 0.5;
//path.onMouseMove = onMouseMove;
//path.onMouseMove = onPathMouseMove;
path.onMouseDown = onMouseDown;
path.onMouseDrag = onMouseDrag;
//path.onMouseUp = function( event ){
@ -2326,7 +2452,7 @@ function onMaskMouseDown( evt ){
path.fillColor = '#ff8020';
path.onMouseDown = onMouseDown;
path.onMouseDrag = onMouseDrag;
//path.onMouseMove = onMouseMove;
//path.onMouseMove = onPathMouseMove;
path.fullySelected = true;
path.closed = true;
path.opacity = 0.5;
@ -2354,6 +2480,7 @@ function onMaskMouseUp( evt ){
path.fullySelected = true;
path.onMouseDown = onMouseDown;
path.onMouseDrag = onMouseDrag;
//path.onMouseMove = onPathMouseMove;
paper.view.draw();
//poligones.push( path );
setMaskEditorMode( 1 );

2458
lib/javascript/jsapi_dynamic/rgoose_devices.js.bak
File diff suppressed because it is too large
View File

2370
lib/javascript/jsapi_dynamic/rgoose_devices_.js
File diff suppressed because it is too large
View File

Loading…
Cancel
Save