diff --git a/lib/controller/addNetworkNode.php b/lib/controller/addNetworkNode.php index 938f16a..e68c262 100644 --- a/lib/controller/addNetworkNode.php +++ b/lib/controller/addNetworkNode.php @@ -4,11 +4,15 @@ if( $CUser->Data['id'] > 1 ){ $Data['success'] = false; if( $CUser->Data['access'] > 5 ){ - if( isset($_POST['SITEID']) ) $SiteID = intval($_POST['SITEID']); else $SiteID = 0; - if( isset($_POST['TYPE']) ) $NodeType = intval($_POST['TYPE']); else $NodeType = 0; - if( $SiteID ){ + if( isset($_POST['SITEID']) ) $SiteID = intval($_POST['SITEID']); else $SiteID = 0; + if( isset($_POST['SRVID']) ) $ServerID = intval($_POST['SRVID']); else $ServerID = 0; + if( isset($_POST['TYPE']) ) $NodeType = intval($_POST['TYPE']); else $NodeType = 0; + if( $ServerID == 0 ){ + if( isset($_POST['UART']) ) $ServerID = getServerIdByUartId( intval($_POST['UART']) ); + }; + if( $SiteID && $ServerID && $NodeType ){ if( $NodeType ){ - $ServerNODE = getServerNode( $SiteID ); + $ServerNODE = getServerNode( $ServerID ); if( $ServerNODE ){ switch( $NodeType ){ case ARGUS_ALS_SENSOR: @@ -20,7 +24,7 @@ if(isset($_POST['UART'])) $CUART = intval($_POST['UART']); else $CUART = 0; if(isset($_POST['DEVID'])) $DEVID = intval($_POST['DEVID']); else $DEVID = 0; if( $CNAME != '' && $CRANGE > 0 && $CUART > 0 ){ - $Data['success'] = addSerialSensor( $SiteID, $NodeType, $CRANGE, $CNAME, $CUART, $DEVID ); + $Data['success'] = addSerialSensor( $SiteID, $ServerID, $NodeType, $CRANGE, $CNAME, $CUART, $DEVID ); if( !$Data['success'] ){ $Data['msg'] = $Labels->GetLabel('NODE_CREA_ERROR'); }; @@ -34,7 +38,7 @@ if(isset($_POST['ADDR'])) $CADDR = validateIP4($_POST['ADDR']); else $CADDR = false; if(isset($_POST['SERVER'])) $ServerNODE = intval($_POST['SERVER']); else $ServerNODE = 0; if( $CNAME != '' && $CPORT !== false && $CADDR!==false && $ServerNODE > 0 ){ - $Data['success'] = add3DSensor( $SiteID, $ServerNODE, $CNAME, $CADDR, $CPORT ); + $Data['success'] = add3DSensor( $SiteID, $ServerID, $CNAME, $CADDR, $CPORT ); if( !$Data['success'] ){ $Data['msg'] = $Labels->GetLabel('NODE_CREA_ERROR'); }; @@ -48,9 +52,27 @@ if(isset($_POST['IMSIZE'])) $IMSIZE = intval($_POST['IMSIZE']); else $IMSIZE = 2; if(isset($_POST['LAB'])) $CNAME = $DATABASE->escape($_POST['LAB']); else $CNAME = ''; if( $CSTR && $CNAME!='' ){ - $Data['success'] = addAnalogStaticCamera( $SiteID, $ServerNODE, $CNAME, $CSTR, $IMSIZE, $FMIN ); - if( !$Data['success'] ){ - $Data['msg'] = $Labels->GetLabel('NODE_CREA_ERROR'); + $VA = validateCamConnections( $CSTR, 0 ); + if( $VA > -1 ){ + if( $VA ){ + //$SNID = getServerNode( $ServerID ); + if( $VA!= $ServerNODE ){ + $Data['msg'] = $Labels->GetLabel('ERR_WRONG_SERVER'); break; + break; + }; + }; + $Data['success'] = addAnalogStaticCamera( $SiteID, $ServerID, $CNAME, $CSTR, $IMSIZE, $FMIN ); + if( !$Data['success'] ){ + $Data['msg'] = $Labels->GetLabel('NODE_CREA_ERROR'); + }; + } else { + switch( $VA ){ + case -1: $Data['msg'] = $Labels->GetLabel('ERR_DINO_SRC_CTL'); break; + case -2: $Data['msg'] = $Labels->GetLabel('ERR_UART_NOCONNE'); break; + case -3: $Data['msg'] = $Labels->GetLabel('ERR_ERROR_UART'); break; + case -4: $Data['msg'] = $Labels->GetLabel('ERR_NO_ANAL_RES'); break; + case -5: $Data['msg'] = $Labels->GetLabel('ERR_WRONG_STREAM'); break; + }; }; } else { $Data['msg'] = $Labels->GetLabel('PARAM_ERROR'); @@ -70,7 +92,7 @@ if(isset($_POST['PROTOID'])) $PROTOID = intval( $_POST['PROTOID'] ); else $PROTOID = 0; if(isset($_POST['LAB'])) $CNAME = $DATABASE->escape($_POST['LAB']); else $CNAME = ''; if( $CSTR && $CNAME!='' ){ - $Data['success'] = addAnalogPtzCamera( $SiteID, $ServerNODE, $CNAME, $CSTR, $IMSIZE, $FMIN, $FMAX, $PANMODE, $PANANG, $TILTMODE, $TILTANG, $PTZ, $PROTOID, $UART ); + $Data['success'] = addAnalogPtzCamera( $SiteID, $ServerID, $CNAME, $CSTR, $IMSIZE, $FMIN, $FMAX, $PANMODE, $PANANG, $TILTMODE, $TILTANG, $PTZ, $PROTOID, $UART ); if( !$Data['success'] ){ $Data['msg'] = $Labels->GetLabel('NODE_CREA_ERROR'); }; @@ -85,7 +107,7 @@ if(isset($_POST['IMSIZE'])) $IMSIZE = intval($_POST['IMSIZE']); else $IMSIZE = 2; if(isset($_POST['LAB'])) $CNAME = $DATABASE->escape($_POST['LAB']); else $CNAME = ''; if( $CSTR && $CNAME!='' ){ - $Data['success'] = addIpStaticCamera( $SiteID, $ServerNODE, $CNAME, $CamID, $CSTR, $IMSIZE, $LFL ); + $Data['success'] = addIpStaticCamera( $SiteID, $ServerID, $CNAME, $CamID, $CSTR, $IMSIZE, $LFL ); if( !$Data['success'] ){ $Data['msg'] = $Labels->GetLabel('NODE_CREA_ERROR'); }; @@ -108,7 +130,7 @@ if(isset($_POST['PROTOID'])) $PROTOID = intval( $_POST['PROTOID'] ); else $PROTOID = 0; if(isset($_POST['LAB'])) $CNAME = $DATABASE->escape($_POST['LAB']); else $CNAME = ''; if( $CamID && $CSTR && $CNAME!='' ){ - $Data['success'] = addIpPtzCamera( $SiteID, $ServerNODE, $CNAME, $CamID, $CSTR, $IMSIZE, $LFL, $ZOOM, $PANMODE, $PANANG, $TILTMODE, $TILTANG, $PTZ, $PROTOID, $UART ); + $Data['success'] = addIpPtzCamera( $SiteID, $ServerID, $CNAME, $CamID, $CSTR, $IMSIZE, $LFL, $ZOOM, $PANMODE, $PANANG, $TILTMODE, $TILTANG, $PTZ, $PROTOID, $UART ); if( !$Data['success'] ){ $Data['msg'] = $Labels->GetLabel('NODE_CREA_ERROR'); }; @@ -127,7 +149,7 @@ if(isset($_POST['UART_IP'])) $IP = $DATABASE->escape( $_POST['UART_IP'] ); if(isset($_POST['UART_MAC'])) $MAC = $DATABASE->escape( $_POST['UART_MAC'] ); if( $PORT && $IP != '' ){ - $Data['success'] = addEthernet2Serial( $SiteID, $ServerNODE, $NAME, $MAC, $IP, $PORT, $MODE, $SPD, $BITS, $STOP, $PAR ); + $Data['success'] = addEthernet2Serial( $SiteID, $ServerID, $NAME, $MAC, $IP, $PORT, $MODE, $SPD, $BITS, $STOP, $PAR ); if( !$Data['success'] ){ $Data['msg'] = $Labels->GetLabel('NODE_CREA_ERROR'); }; @@ -137,7 +159,7 @@ break; }; } else { - $Data['msg'] = $Labels->GetLabel('WRONG_SITE_ID'); + $Data['msg'] = $ServerID . $Labels->GetLabel('WRONG_SITE_ID'); }; } else { $Data['msg'] = $Labels->GetLabel('UNKNOWN_NODE_TYPE'); diff --git a/lib/controller/clearEventCloud.php b/lib/controller/clearEventCloud.php index 3578da3..22defa7 100644 --- a/lib/controller/clearEventCloud.php +++ b/lib/controller/clearEventCloud.php @@ -1,9 +1,12 @@ Data['id'] > 1 ){ - //$QS = "INSERT INTO `events_archive` (`id`, `node_id`,`uuid`,`ts`,`ts_ms`,`evt_type`,`range_digital`,`azimuth`,`elevation`,`range`,`area`,`lat`,`lon`,`alt`,`ref_id`,`ref_uuid`) SELECT `id`, `node_id`,`uuid`,`ts`,`ts_ms`,`evt_type`,`range_digital`,`azimuth`,`elevation`,`range`,`area`,`lat`,`lon`,`alt`,`ref_id`,`ref_uuid` FROM `events_cloud`"; - //$DATABASE->Query( $QS, false ); - $QS = "DELETE FROM events_cloud"; + if( isset( $_POST['NID'] )){ + $NODE = intval( $_POST['NID'] ); + $QS = "DELETE FROM `events_cloud` WHERE `node_id`={$NODE}"; + } else { + $QS = "DELETE FROM `events_cloud`"; + }; $DATABASE->Query( $QS, false ); } else { header('location: /'); diff --git a/lib/controller/getDetectionProfile.php b/lib/controller/getDetectionProfile.php index 0ca6947..b3a22c2 100644 --- a/lib/controller/getDetectionProfile.php +++ b/lib/controller/getDetectionProfile.php @@ -23,25 +23,15 @@ case 4:{ $K['profile_id'] = intval( $CS['detection_profile_id'] ); $K['profiles'] = array(); - $QS = "SELECT DISTINCT `profile_id` as `id` FROM `lrf_detection_profiles` WHERE `aux_id`={$AID} ORDER BY `profile_id`"; + $QS = "SELECT `id` FROM `lrf_detection_profiles` WHERE `aux_id`={$AID} and `master`=b'1' ORDER BY `profile_id`"; foreach( $DATABASE->Query( $QS ) as $Z ) $K['profiles'][] = intval($Z['id']); - $K['additional'] = <<Query( $QS ); + $LL = array( 'N', 'N', 'N', 'N', 'N' ); + foreach( $UU as $U ) $LL[intval($U['layer'])] = $U['status']; + $K['masks_array'] = $LL; + $K['additional'] = ''; break; }; case 5: { diff --git a/lib/controller/getDeviceMask.php b/lib/controller/getDeviceMask.php index 9e55589..e6874d7 100644 --- a/lib/controller/getDeviceMask.php +++ b/lib/controller/getDeviceMask.php @@ -20,7 +20,7 @@ $CV = array(); if( count( $ZA ) ){ foreach( $ZA as $VV ){ - $CV['colour']="rgba({$VV['r']},{$VV['g']},{$VV['b']})";//sprintf("#%02X%02X%02X", intval( $VV['r'] ), intval( $VV['g'] ), intval( $VV['b'] ) ); + $CV['colour']="rgba({$VV['r']},{$VV['g']},{$VV['b']},255)"; $QS = "SELECT * FROM `lrf_mask_vertex_points` WHERE `vertex_id`={$VV['id']}"; $PP = $DATABASE->Query( $QS ); $CV['points'] = array(); @@ -29,7 +29,7 @@ }; }; }; - }; + } else $Data['soso']='No Node!'; echo json_encode( $Data ); exit(); }; diff --git a/lib/controller/getEventRecords.php b/lib/controller/getEventRecords.php index fb9466a..702a1e3 100644 --- a/lib/controller/getEventRecords.php +++ b/lib/controller/getEventRecords.php @@ -1,5 +1,6 @@ Data['id'] > 1 ){ $Data = array(); + $RA = array(); + $RevertResults = false; //$GID = intval($_POST['']); if( isset( $_POST['SITE'] ) ) $SITE = intval( $_POST['SITE'] ); else $SITE = 1; if( isset( $_POST['MODE'] ) ) if( $_POST['MODE'] == 'live' ) $Mode = 1; else $Mode = 0; if( isset( $_POST['FIL'] ) ) $FIL = intval( $_POST['FIL'] ); else $FIL = 0; - if( $Mode ){ + if( isset( $_POST['SDA'] ) ) $SDA = intval( $_POST['SDA'] ); else $SDA = 0; + if( isset( $_POST['STR'] ) ) $StartID = intval( $_POST['STR'] ); else $StartID = 0; + if( isset( $_POST['DIR'] ) ) $Direction = intval( $_POST['DIR'] ); else $Direction = 0; + if( $Mode ){ if( $FIL ){ - $QS = "SELECT ec.* FROM events_cloud ec WHERE ec.node_id={$FIL} ORDER BY ec.id DESC LIMIT 20"; + $QS = "SELECT ec.* FROM events_cloud ec WHERE ec.node_id={$FIL} ORDER BY ec.id DESC LIMIT {$LCOUNT}"; } else { - $QS = "SELECT ec.* FROM events_cloud ec ORDER BY ec.id DESC LIMIT 20"; + $QS = "SELECT ec.* FROM events_cloud ec ORDER BY ec.id DESC LIMIT {$LCOUNT}"; }; } else { - if( isset( $_POST['SDA'] ) ) $SDA = intval( $_POST['SDA'] ); else $SDA = 0; - if( $SDA ){ - if( isset( $_POST['SMO'] ) ) $SMO = intval( $_POST['SMO'] ); - if( isset( $_POST['SYE'] ) ) $SYE = intval( $_POST['SYE'] ); - if( isset( $_POST['STM'] ) ) $STM = intval( $_POST['STM'] ); - if( isset( $_POST['ETM'] ) ) $ETM = intval( $_POST['ETM'] ); - date_default_timezone_set('UTC'); - $T = sprintf( "%04d-%02d-%02d", $SYE, $SMO, $SDA ); - $CTS = strtotime( $T ); - if( $STM && $ETM ){ - $STS = $CTS + $STM; - $ETS = $CTS + $ETM; + $RA['updateFROMTO'] = true; + if( $StartID ){ + if( $Direction < 0 ){ + $EID = $StartID + 1; + if( $FIL ){ + $QS = "SELECT ea.* FROM events_archive ea WHERE ea.node_id={$FIL} AND id < {$EID} ORDER BY ea.id DESC LIMIT {$LCOUNT}"; + } else { + $QS = "SELECT ea.* FROM events_archive ea WHERE id < {$EID} ORDER BY ea.id DESC LIMIT {$LCOUNT}"; + }; } else { - $STS = $CTS; - $ETS = $CTS + 86400; - }; - if( $FIL ){ - $QS = "SELECT ea.* FROM events_archive ea WHERE ea.node_id={$FIL} AND ea.ts >= {$STS} AND ea.ts <= {$ETS} ORDER BY ea.id DESC LIMIT 20"; - } else { - $QS = "SELECT ea.* FROM events_archive ea WHERE ea.ts >= {$STS} AND ea.ts <= {$ETS} ORDER BY ea.id DESC LIMIT 20"; + $EID = $StartID - 1; + $RevertResults = true; + if( $FIL ){ + $QS = "SELECT ea.* FROM events_archive ea WHERE ea.node_id={$FIL} AND id > {$EID} ORDER BY ea.id ASC LIMIT {$LCOUNT}"; + } else { + $QS = "SELECT ea.* FROM events_archive ea WHERE id > {$EID} ORDER BY ea.id ASC LIMIT {$LCOUNT}"; + }; }; } else { - if( $FIL ){ - $QS = "SELECT ea.* FROM events_archive ea WHERE ea.node_id={$FIL} ORDER BY ea.id DESC LIMIT 20"; + if( $SDA ){ + if( isset( $_POST['SMO'] ) ) $SMO = intval( $_POST['SMO'] ); + if( isset( $_POST['SYE'] ) ) $SYE = intval( $_POST['SYE'] ); + if( isset( $_POST['STM'] ) ) $STM = intval( $_POST['STM'] ); + if( isset( $_POST['ETM'] ) ) $ETM = intval( $_POST['ETM'] ); + date_default_timezone_set('UTC'); + $T = sprintf( "%04d-%02d-%02d", $SYE, $SMO, $SDA ); + $CTS = strtotime( $T ); + if( $STM && $ETM ){ + $STS = $CTS + $STM; + $ETS = $CTS + $ETM; + $Limit = ''; + } else { + $STS = $CTS; + $ETS = $CTS + 86400; + $Limit = " LIMIT {$LCOUNT} "; + }; + if( $FIL ){ + $QS = "SELECT ea.* FROM events_archive ea WHERE ea.node_id={$FIL} AND ea.ts >= {$STS} AND ea.ts <= {$ETS} ORDER BY ea.id DESC {$Limit}"; + } else { + $QS = "SELECT ea.* FROM events_archive ea WHERE ea.ts >= {$STS} AND ea.ts <= {$ETS} ORDER BY ea.id DESC {$Limit}"; + }; } else { - $QS = "SELECT ea.* FROM events_archive ea ORDER BY ea.id DESC LIMIT 20"; + if( $FIL ){ + $QS = "SELECT ea.* FROM events_archive ea WHERE ea.node_id={$FIL} ORDER BY ea.id DESC LIMIT {$LCOUNT}"; + } else { + $QS = "SELECT ea.* FROM events_archive ea ORDER BY ea.id DESC LIMIT {$LCOUNT}"; + }; }; }; }; $Result = $DATABASE->Query( $QS, false ); date_default_timezone_set('UTC'); //foreach( array_reverse ( $Result ) as $CD ){ + if( $RA['updateFROMTO'] ){ + $RA['STT']=86400; + $RA['ENT']=0; + $RA['SLD']=0; + $DATAR = array(); + }; + if( $RevertResults ) $Result = array_reverse( $Result ); foreach( $Result as $CD ){ + if( $RA['updateFROMTO'] ){ + $SSE = intval($CD['ts']); + $CTS = $SSE % 86400; + $DATAR[intdiv( $SSE, 86400 )]++; + if( $CTS < $RA['STT'] ) $RA['STT'] = $CTS; + if( $CTS > $RA['ENT'] ) $RA['ENT'] = $CTS; + if( $SSS == 0 ) $SSS = $SSE; + }; $cnode['has_target'] = false; $cnode['has_geo'] = false; $cnode['images'] = getEventImages( $CD['id'] ); $cnode['has_images'] = count( $cnode['images'] ) > 0; + $cnode['event'] = intval( $CD['evt_type'] ); switch( intval( $CD['evt_type'] ) ){ case 0:// NoInit case 1:// Ready @@ -99,7 +142,7 @@ case 12:// Target 3DB case 13:// Target 2DW case 14:// Target 2DB - $cnode['event']='Target'; + //$cnode['event']='Target'; $cnode['data'] = sprintf("AZ: %0.2f El: %0.2f R: %0.2f", floatval($CD['azimuth']), floatval($CD['elevation']), floatval($CD['range'])); $cnode['has_target'] = true; $cnode['has_geo'] = true; @@ -125,18 +168,37 @@ case 32:// FH Busy case 33:// Camera DM case 34:// Error + case 36:// ROI + //$cnode['event']='Region Of Interest'; + $cnode['data'] = sprintf("AZ: %0.2f El: %0.2f R: %0.2f", floatval($CD['azimuth']), floatval($CD['elevation']), floatval($CD['range'])); + $cnode['has_target'] = true; + $cnode['has_geo'] = true; + $cnode['geo'] = array( 'lat'=>floatval( $CD['lat'] ),'lon'=>floatval( $CD['lon'] ),'alt'=>floatval( $CD['alt'] ) ); default: continue; }; $cnode['id'] = intval( $CD['id'] ); $uts = intval($CD['ts']); - $cnode['date'] = date( "m.d.y", $uts ); - $cnode['time'] = date( "H:m:s", $uts ); + $cnode['date'] = date( "d M Y", $uts ); + $cnode['time'] = date( "H:i:s", $uts ); $NIFO = getNodeInfo( $CD['node_id'] ); $cnode['device'] = $NIFO['name']; $cnode['dev_type'] = intval( $NIFO['type'] ); $Data[] = $cnode; }; + if( $RA['updateFROMTO'] ){ + $RA['STT']=intdiv( $RA['STT'], 3600 )*3600; + $RA['ENT']=intdiv( $RA['ENT'], 3600 )*3600+3600; + //if( $RA['STT'] == $RA['ENT'] ){ + if( $RA['ENT'] > 86400 ) $RA['ENT'] = 86400; + $MID = 0; + foreach( $DATAR as $Key=>$Val ){ + if( $Val > $MID ){ + $MID = $Val; + $RA['SLD'] = $Key*86400; + }; + }; + }; $RA['log']=$Data; $RA['totalCount'] = count( $Data ); echo json_encode( $RA ); diff --git a/lib/controller/getGeoAlerts.php b/lib/controller/getGeoAlerts.php index 4bb413c..c68ab8e 100644 --- a/lib/controller/getGeoAlerts.php +++ b/lib/controller/getGeoAlerts.php @@ -25,32 +25,32 @@ $QS = "SELECT * FROM `target_filter_apf` WHERE `id`={$R['aux_id']}"; $Juno = $DATABASE->Query( $QS, false ); if( count( $Juno ) ){ - $CC = $Juno[0]; - $A = new gPoint(); - $A->setLongLat($CC['lon'],$CC['lat']); - $A->convertLLtoTM(); - $XC = $A->E(); - $YC = $A->N(); - $Z = $A->Z(); - $ANG = (pi()/180)*floatval( $CC['yaw'] ); - $QS = "SELECT * FROM `target_filter_apf_boxes` WHERE `filter_id`={$R['aux_id']}"; - $Obubu = $DATABASE->Query( $QS, false ); - foreach( $Obubu as $G ){ - $P['type']='circle'; - $P['color']='#00FF00'; - $TX = floatval($G['x']); - $TY = floatval($G['y']); - $CR = sqrt($TX*$TX+$TY*$TY); - if( $TX != 0 ){ - $CA = atan( $TY/$TX ); - } else { - $CA = 0; + $CC = $Juno[0]; + $A = new gPoint(); + $A->setLongLat($CC['lon'],$CC['lat']); + $A->convertLLtoTM(); + $XC = $A->E(); + $YC = $A->N(); + $Z = $A->Z(); + $ANG = (pi()/180)*floatval( $CC['yaw'] ); + $QS = "SELECT * FROM `target_filter_apf_boxes` WHERE `filter_id`={$R['aux_id']}"; + $Obubu = $DATABASE->Query( $QS, false ); + foreach( $Obubu as $G ){ + $P['type']='circle'; + $P['color']='#00FF00'; + $TX = floatval($G['x']); + $TY = floatval($G['y']); + $CR = sqrt($TX*$TX+$TY*$TY); + if( $TX != 0 ){ + $CA = atan( $TY/$TX ); + } else { + $CA = 0; + }; + $A->setUTM($XC+$CR*cos($CA+$ANG),$YC+$CR*sin($CA+$ANG),$Z); + $A->convertTMtoLL(); + $P['loc']=array('lat'=>$A->Lat(),'lon'=>$A->Long()); + $Data['other'][] = $P; }; - $A->setUTM($XC+$CR*cos($CA+$ANG),$YC+$CR*sin($CA+$ANG),$Z); - $A->convertTMtoLL(); - $P['loc']=array('lat'=>$A->Lat(),'lon'=>$A->Long()); - $Data['other'][] = $P; - }; }; break; }; diff --git a/lib/controller/getGeoZones.php b/lib/controller/getGeoZones.php index 983bd28..0fd35f8 100644 --- a/lib/controller/getGeoZones.php +++ b/lib/controller/getGeoZones.php @@ -1,6 +1,62 @@ Query( $QS, false ); + $Zone['dev_is_source'] = true; + $Zone['dev_type'] = intval( $R['type'] ); + $Zone['dev_id'] = intval( $R['id'] ); + $Zone['dev_name'] = $R['name']; + if( count( $D ) ){ + $CC = $D[0]; + $A = new gPoint(); + $A->setUTM( $BASE_X + floatval( $CC['x'] ), $BASE_Y + floatval( $CC['y'] ), $BASE_ZONE ); + $A->convertTMtoLL(); + $LAT = $A->Lat(); + $LON = $A->Long(); + $XC = $A->E(); + $YC = $A->N(); + $Z = $A->Z(); + $RAN = floatval( $CC['max_range'] ); + + $K = pi()/ 36; // 5 deg// + $Points = array(); + $Points[] = array( 'lat'=>$LAT, 'lon'=>$LON ); + $SANG = ( pi() / 180 ) * floatval( $CC['z_rot'] ) + ( pi()/3000.0 * floatval( $CC['base_shift'] ) ); + for( $i = 0; $i < 20; $i++ ){ + $CA = $i * $K; + $B = new gPoint(); + $B->setUTM( $XC + $RAN * cos( $SANG + $CA ), $YC + $RAN * sin( $SANG + $CA ), $Z ); + $B->convertTMtoLL(); + $Points[]=array('lat'=>$B->Lat(),'lon'=>$B->Long()); + }; + $ZMARK = array(); + $B = new gPoint(); + $SANG = $SANG - ( pi()/3000.0 * floatval( $CC['base_shift'] ) ); + $B->setUTM( $XC + $RAN * cos( $SANG ), $YC + $RAN * sin( $SANG ), $Z ); + $B->convertTMtoLL(); + $ZMARK=array('lat'=>$B->Lat(),'lon'=>$B->Long()); + $Zone['zang'] = $ZMARK; + $Zone['type']='poly'; + $Zone['points']=$Points; + $Zone['color'] = '#880000'; + $Zone['center'] = array( 'lat'=>$LAT,'lon'=>$LON ); + $Zone['name'] = $R['name']; + $Data[] = $Zone; + }; + break; + }; + case 3:{ // PLS 200 $QS = "SELECT x, y, x_rot, y_rot, z_rot, max_range, base_shift FROM lrf_sensors WHERE id={$R['aux_id']}"; $D = $DATABASE->Query( $QS, false ); @@ -253,7 +353,7 @@ function ToLL($north, $east, $utmZone){ $Points = array(); $Points[] = array( 'lat'=>$LAT, 'lon'=>$LON ); $SANG = ( pi() / 180 ) * floatval( $CC['z_rot'] ) + ( pi()/3000.0 * floatval( $CC['base_shift'] ) ); - for( $i = 0; $i < 42; $i++ ){ + for( $i = 0; $i < 40; $i++ ){ $CA = $i * $K; $B = new gPoint(); $B->setUTM( $XC + $RAN * cos( $SANG + $CA ), $YC + $RAN * sin( $SANG + $CA ), $Z ); @@ -341,12 +441,13 @@ function ToLL($north, $east, $utmZone){ }; break; }; - case 5:{ - // 3D + case 1://ALS + case 4://PLS360 + case 5:{//3D $QS = "SELECT x, y, x_rot, y_rot, z_rot, max_range FROM lrf_sensors WHERE id={$R['aux_id']}"; $D = $DATABASE->Query( $QS, false ); $Zone['dev_is_source'] = true; - $Zone['dev_type'] = 5; + $Zone['dev_type'] = intval( $R['type'] ); $Zone['dev_id'] = intval( $R['id'] ); $Zone['dev_name'] = $R['name']; if( count( $D ) ){ @@ -384,13 +485,56 @@ function ToLL($north, $east, $utmZone){ }; break; }; - case 13:{ - // Camera PTZ; + case 10: + case 12:{ // Camera Static + $QS = "SELECT x, y, x_rot, y_rot, z_rot, max_range, imager_type, lens_f FROM cameras WHERE id={$R['aux_id']}"; + $D = $DATABASE->Query( $QS, false ); + if( count( $D ) ){ + $CC = $D[0]; + $A = new gPoint(); + $A->setUTM( $BASE_X + floatval( $CC['x'] ), $BASE_Y + floatval( $CC['y'] ), $BASE_ZONE ); + $A->convertTMtoLL(); + $LAT = $A->Lat(); + $LON = $A->Long(); + $YC = $A->N(); + $XC = $A->E(); + $Z = $A->Z(); + $CFOV = (2.0*atan($AC_imager_width[$CC['imager_type']]/(2.0*$cam_predef_focal_length[$CC['lens_f']]))); + $Points = array(); + $A = new gPoint(); + $Points[] = array( 'lat'=>$LAT, 'lon'=>$LON ); + $K = floatval( $CFOV ) / 40; + $SANG = (M_PI/180) * floatval( $CC['z_rot'] ) - ($CFOV/2.0); + $RAN = floatval( $CC['max_range'] ); + for( $i = 0; $i < 41; $i++ ){ + $CA = $i * $K; + $B = new gPoint(); + $B->setUTM( $XC + $RAN * cos( $SANG + $CA ), $YC + $RAN * sin( $SANG + $CA ), $Z ); + $B->convertTMtoLL(); + $Points[]=array('lat'=>$B->Lat(),'lon'=>$B->Long()); + }; + $Zone['type']='poly'; + $Zone['points']=$Points; + $Zone['color'] = '#000088'; + $Zone['center'] = array( 'lat'=>$LAT, 'lon'=>$LON ); + $ZMARK = array(); + $B = new gPoint(); + //$RAN = $RAN - 0.5; + $B->setUTM( $XC + $RAN * cos( $SANG+( $CFOV / 2.0 ) ), $YC + $RAN * sin( $SANG +( $CFOV / 2.0 ) ), $Z ); + $B->convertTMtoLL(); + $ZMARK=array('lat'=>$B->Lat(),'lon'=>$B->Long()); + $Zone['zang'] = $ZMARK; + $Zone['name'] = $R['name']; + $Data[] = $Zone; + }; + break; + }; + case 11: + case 13:{ // Camera PTZ $QS = "SELECT x, y, x_rot, y_rot, z_rot, max_range, pan_angles FROM cameras WHERE id={$R['aux_id']}"; $D = $DATABASE->Query( $QS, false ); if( count( $D ) ){ $CC = $D[0]; - $A = new gPoint(); $A->setUTM( $BASE_X + floatval( $CC['x'] ), $BASE_Y + floatval( $CC['y'] ), $BASE_ZONE ); $A->convertTMtoLL(); diff --git a/lib/controller/getOnvifCredentials.php b/lib/controller/getIpCamCredentials.php similarity index 92% rename from lib/controller/getOnvifCredentials.php rename to lib/controller/getIpCamCredentials.php index e7dd2b4..ae5267b 100644 --- a/lib/controller/getOnvifCredentials.php +++ b/lib/controller/getIpCamCredentials.php @@ -17,6 +17,8 @@ $Rlt = $DATABASE->Query($QS,false); $Data['login'] = $Rlt[0]['access_login']; $Data['password'] = $Rlt[0]['access_pass']; + $Data['password'] = $Rlt[0]['access_pass']; + $Data['auth_mode'] = $Rlt[0]['auth_mode']; foreach( $Result as $CD ){ $cnode['id'] = $CD['id']; $cnode['name'] = $CD['name']; diff --git a/lib/controller/getLocationItems.php b/lib/controller/getLocationItems.php index 403e175..fddca6f 100644 --- a/lib/controller/getLocationItems.php +++ b/lib/controller/getLocationItems.php @@ -34,15 +34,19 @@ case ARGUS_NET_PLS_200: $QS="SELECT x, y FROM lrf_sensors WHERE id={$CD['aux_id']}"; $RV = $DATABASE->Query( $QS ); - if( floatval($RV[0]['x']) == 0 && floatval($RV[0]['y']) == 0 ){ - $cnode['lat'] = $SLAT; - $cnode['lon'] = $SLON; - } else { - $CC->setUTM( floatval($RV[0]['x']), floatval($RV[0]['y']), $ZC ); - $CC->convertTMtoLL(); - $cnode['lat']= $CC->Lat(); - $cnode['lon']= $CC->Long(); - }; + $CC->setUTM( $XC + floatval($RV[0]['x']), $YC+floatval($RV[0]['y']), $ZC ); + $CC->convertTMtoLL(); + $cnode['lat'] = $CC->Lat(); + $cnode['lon'] = $CC->Long(); + //if( floatval($RV[0]['x']) == 0 && floatval($RV[0]['y']) == 0 ){ + // $cnode['lat'] = $SLAT; + // $cnode['lon'] = $SLON; + //} else { + // $CC->setUTM( floatval($RV[0]['x']), floatval($RV[0]['y']), $ZC ); + // $CC->convertTMtoLL(); + // $cnode['lat']= $CC->Lat(); + // $cnode['lon']= $CC->Long(); + //}; $PUPA = true; break; case ARGUS_ANALOG_STATIC_CAMERA: @@ -51,15 +55,19 @@ case ARGUS_IP_PTZ_CAMERA: $QS="SELECT x, y FROM cameras WHERE id={$CD['aux_id']}"; $RV = $DATABASE->Query( $QS ); - if( floatval($RV[0]['x']) == 0 && floatval($RV[0]['y']) == 0 ){ - $cnode['lat'] = $SLAT; - $cnode['lon'] = $SLON; - } else { - $CC->setUTM( floatval($RV[0]['x']), floatval($RV[0]['y']), $ZC ); - $CC->convertTMtoLL(); - $cnode['lat']= $CC->Lat(); - $cnode['lon']= $CC->Long(); - }; + $CC->setUTM( $XC + floatval($RV[0]['x']), $YC+floatval($RV[0]['y']), $ZC ); + $CC->convertTMtoLL(); + $cnode['lat'] = $CC->Lat(); + $cnode['lon'] = $CC->Long(); + //if( floatval($RV[0]['x']) == 0 && floatval($RV[0]['y']) == 0 ){ + // $cnode['lat'] = $SLAT; + // $cnode['lon'] = $SLON; + //} else { + // $CC->setUTM( floatval($RV[0]['x']), floatval($RV[0]['y']), $ZC ); + // $CC->convertTMtoLL(); + // $cnode['lat']= $CC->Lat(); + // $cnode['lon']= $CC->Long(); + //}; $PUPA = true; break; }; diff --git a/lib/controller/getLocationNodeProps.php b/lib/controller/getLocationNodeProps.php index 4b02cd4..f444100 100644 --- a/lib/controller/getLocationNodeProps.php +++ b/lib/controller/getLocationNodeProps.php @@ -1,83 +1,81 @@ Data['id'] > 1 ){ - $Node = intval( $_POST['NODE'] ); - $QS = "SELECT * FROM nodes WHERE id = {$Node}"; - $Result = $DATABASE->Query( $QS, false ); - if( count( $Result ) ){ - $Props = $Result[0]; - $Type = intval( $Props['type'] ); - $TName = 'props/loc_prop.js';// '.$Type.'_node_prop.js'; - $Data = file_get_contents( $TName ); - $Data = str_replace('%%%NODEID%%%', ''.$Node, $Data ); - $Data = str_replace('%%%TYPE%%%', $Type, $Data ); - switch( $Type ){ - case 1: - case 2: - case 3: - case 4: - case ARGUS_3D_SENSOR:{ - $QS = "SELECT * FROM lrf_sensors WHERE id={$Props['aux_id']}"; - $RR = $DATABASE->Query( $QS ); - $C = $RR[0]; - - $Data = str_replace('%%%NODEID%%%', ''.$Node, $Data ); - $Data = str_replace('%%%NAME%%%', $Props['name'] , $Data ); - //Loc - $LAT = floatval( $C['lat'] ); - $LON = floatval( $C['lon'] ); - $ALT = floatval( $C['alt'] ); - $ROLL = floatval( $C['roll'] ); - $PITCH = floatval( $C['pitch'] ); - $YAW = floatval( $C['yaw'] ); - $Data = str_replace( '%%%LAT%%%', $LAT, $Data ); - $Data = str_replace( '%%%LON%%%', $LON, $Data ); - $Data = str_replace( '%%%ALT%%%', $ALT, $Data ); - $Data = str_replace( '%%%ROLL%%%', $ROLL, $Data ); - $Data = str_replace( '%%%PITCH%%%', $PITCH, $Data ); - $Data = str_replace( '%%%YAW%%%', $YAW, $Data ); - //Info - $InfoData = ''; - $InfoParts = array(); - $InfoParts[] = '{ xtype: \'panel\', html: \'
'.$Server['identity'].'
\'}'; - switch( intval($Props['online']) ){ - case 0: $InfoParts[] = '{ xtype: \'panel\', html: \'
Offline
\'}'; break; - case 1: $InfoParts[] = '{ xtype: \'panel\', html: \'
Handler Online
\'}'; break; - case 3: $InfoParts[] = '{ xtype: \'panel\', html: \'
Master Online
\'}'; break; - case 5: $InfoParts[] = '{ xtype: \'panel\', html: \'
Slave Online
\'}'; break; - case 7: $InfoParts[] = '{ xtype: \'panel\', html: \'
Device Online
\'}'; break; + $Node = intval( $_POST['NODE'] ); + $QS = "SELECT * FROM `nodes` WHERE id = {$Node}"; + $Result = $DATABASE->Query( $QS, false ); + if( count( $Result ) ){ + $Props = $Result[0]; + $Type = intval( $Props['type'] ); + $TName = 'props/loc_prop.js'; + $QS = "SELECT * FROM `sites` WHERE `id`={$Props['site_id']}"; + $R = $DATABASE->Query($QS); + $SLAT = $R[0]['anchor_lat']; + $SLON = $R[0]['anchor_lon']; + $SALT = $R[0]['anchor_alt']; + $A = new gPoint(); + $A->setLongLat( $SLON, $SLAT ); + $A->convertLLtoTM(); + $XC = $A->E(); + $YC = $A->N(); + $Zo = floatval( $SALT ); + $ZC = $A->Z(); + + $Data = file_get_contents( $TName ); + $Data = str_replace('%%%NODEID%%%', ''.$Node, $Data ); + $Data = str_replace('%%%TYPE%%%', $Type, $Data ); + $Data = str_replace('%%%NAME%%%', $Props['name'] , $Data ); + switch( $Type ){ + case 1: + case 2: + case 3: + case 4: + case ARGUS_3D_SENSOR: + case 6:{ + $QS = "SELECT * FROM lrf_sensors WHERE id={$Props['aux_id']}"; + $RR = $DATABASE->Query( $QS ); + $C = $RR[0]; + break; }; - $InfoData = implode( ',', $InfoParts ); - $Data = str_replace('%%%INFO%%%', $InfoData, $Data ); - break; - }; - case 10: - case 13:{ - $QS="SELECT * FROM cameras WHERE id={$Props['aux_id']}"; - $RR = $DATABASE->Query( $QS ); - $C = $RR[0]; - $LAT = floatval( $C['lat'] ); - $LON = floatval( $C['lon'] ); - $ALT = floatval( $C['alt'] ); - $ROLL = floatval( $C['roll'] ); - $PITCH = floatval( $C['pitch'] ); - $YAW = floatval( $C['yaw'] ); - $Data = str_replace( '%%%LAT%%%', $LAT, $Data ); - $Data = str_replace( '%%%LON%%%', $LON, $Data ); - $Data = str_replace( '%%%ALT%%%', $ALT, $Data ); - $Data = str_replace( '%%%ROLL%%%', $ROLL, $Data ); - $Data = str_replace( '%%%PITCH%%%', $PITCH, $Data ); - $Data = str_replace( '%%%YAW%%%', $YAW, $Data ); - $Data = str_replace( '%%%NAME%%%', urldecode( $C['name'] ), $Data ); - break; + case 10: + case 11: + case 12: + case 13:{ + $QS="SELECT * FROM cameras WHERE id={$Props['aux_id']}"; + $RR = $DATABASE->Query( $QS ); + $C = $RR[0]; + break; + }; + default: $Data = '{}'; }; - default: $Data = '{}'; + $DX = floatval( $C['x'] ); + $DY = floatval( $C['y'] ); + $DZ = floatval( $C['z'] ); + $CC = new gPoint(); + $CC->setUTM( $XC + $DX, $YC + $DY, $ZC ); + $CC->convertTMtoLL(); + $LAT = $CC->Lat(); + $LON = $CC->Long(); + $ALT = $Zo + $DZ; + $ROLL = floatval( $C['x_rot'] ); + $PITCH = floatval( $C['y_rot'] ); + $YAW = floatval( $C['z_rot'] ); + $Data = str_replace( '%%%LAT%%%', $LAT, $Data ); + $Data = str_replace( '%%%LON%%%', $LON, $Data ); + $Data = str_replace( '%%%ALT%%%', $ALT, $Data ); + $Data = str_replace( '%%%ROLL%%%', $ROLL, $Data ); + $Data = str_replace( '%%%PITCH%%%', $PITCH, $Data ); + $Data = str_replace( '%%%YAW%%%', $YAW, $Data ); + $Data = str_replace( '%%%DX%%%', $DX, $Data ); + $Data = str_replace( '%%%DY%%%', $DY, $Data ); + $Data = str_replace( '%%%DZ%%%', $DZ, $Data ); + echo $Data; + } else { + echo '{ html: \'Node '.$_POST['NODE'].' Loadded\'}'; }; - echo $Data; - } else { - echo '{ html: \'Node '.$_POST['NODE'].' Loadded\'}'; - }; } else { - header('location: /'); + header('location: /'); }; ?> \ No newline at end of file diff --git a/lib/controller/getLocationNodes.php b/lib/controller/getLocationNodes.php index 923d134..c02a811 100644 --- a/lib/controller/getLocationNodes.php +++ b/lib/controller/getLocationNodes.php @@ -5,14 +5,15 @@ $QS = "SELECT * FROM nodes WHERE site_id={$GID}"; $Result = $DATABASE->Query( $QS, false ); $Data = "{ xtype: 'panel', frame: false, bodyStyle:'padding:5px 5px 0', items: ["; + $DL = array(); foreach( $Result as $CD ){ $cid = intval($CD['id']); $ct = intval($CD['type']); - if( in_array( $ct, array( 2, 3, 5, 10, 13 ) ) ){ - $Data .= "{ xtype: 'button', text: '{$CD['name']}', width: '100%', handler: function(){ locationSelectedNode={$cid}; loadNodeLocationProps({$cid}); } },"; + if( in_array( $ct, array( 1, 2, 3, 5, 6, 10, 11, 12, 13 ) ) ){ + $DL[] = "{ xtype: 'button', text: '{$CD['name']}', width: '100%', handler: function(){ locationSelectedNode={$cid}; loadNodeLocationProps({$cid}); } }"; }; }; - echo $Data . "{}] }"; + echo $Data . implode(',',$DL) ."] }"; } else { echo "{}"; }; diff --git a/lib/controller/getModuleEditor.php b/lib/controller/getModuleEditor.php new file mode 100644 index 0000000..5b99fa2 --- /dev/null +++ b/lib/controller/getModuleEditor.php @@ -0,0 +1,514 @@ +Data['id'] > 1 ){ + $EID = intval( $_POST['MID'] ); + $QS = "SELECT * FROM server_modules WHERE id = {$EID}"; + $Result = $DATABASE->Query( $QS, false ); + if( count( $Result ) ){ + $CR = $Result[0]; + switch( $CR['type'] ){ + case 1: //ZLMedia + $QS = "SELECT * FROM uart_settings WHERE id={$CR['aux_id']}"; + $Result = $DATABASE->Query( $QS ); + $Z = $Result[0]; + $R_name = $Labels->GetLabel('_RES_HW_UART_DESC_'); + $R_dev = $CR['device']; + $R_nfo = 'Speed: ' . $Z['speed'] . ', Bits: ' . $Z['bit'] . ', Parity: ' . $Z['parity'] . ', Stop Bit: '. $Z['stop_bit']; + $R_image = 'unnamed.png'; + $TPL =<<%%%NAME%%%%%%INFO%%%' + },{ + xtype: 'spacer', + height: 5 + },{ + border: false, + frame: false, + xtype: 'panel', + html: '
%%%LOINFO%%%
' + },{ + xtype: 'spacer', + height: 5 + },{ + xtype: 'combo', + fieldLabel: 'Module Status', + id: 'mod_ena', + lazyRender:true, + mode: 'local', + forceSelection: true, + triggerAction: 'all', + editable: false, + disableKeyFilter: true, + store: new Ext.data.ArrayStore({ + fields: ['status_val','status_txt'], + data: [[0,'Disabled'],[1,'Enabled']] + }), + value: %%%ENA_VAL%%%, + valueField: 'status_val', + displayField: 'status_txt' + },{ + xtype: 'spacer', + height: 5 + },{ + xtype: 'button', + id: 'mo_edit_btn', + disabled: false, + width: '100%', + text: 'Edit Module Config', + handler: function(){ + } + },{ + xtype: 'spacer', + height: 5 + },{ + xtype: 'button', + id: 'mo_del_btn', + disabled: false, + width: '100%', + text: 'Remove Module', + handler: function(){ + } + },{ + xtype: 'spacer', + height: 5 + },{ + xtype: 'button', + id: 'ua_apply_btn', + disabled: true, + width: '100%', + text: 'Apply Changes', + handler: function(){ + } + }] + +} +EFUFU; + $TPL = str_ireplace( '%%%NAME%%%',$Labels->GetLabel('_ZL_MEDIA_DESC_SHO_') , $TPL ); + $TPL = str_ireplace( '%%%INFO%%%', $Labels->GetLabel('_ZL_MEDIA_DESC_LOO_'), $TPL ); + $TPL = str_ireplace( '%%%LOINFO%%%','' , $TPL ); + $TPL = str_ireplace( '%%%ENA_VAL%%%',$CR['enabled'], $TPL ); + echo $TPL; + break; + case 2: //DCB USB + break; + case 3: //Kafka + $QS="SELECT * FROM `modules_kafka` WHERE `module_id`={$CR['aux_id']}"; + $II = $DATABASE->Query( $QS ); + $CI = $II[0]; + $R_nfo = 'Broker Node:'. $CI['brocker_address'].':'.$CI['brocker_port'].((intval($CI['use_ssl'])>0)?'':''); +$TPL =<<%%%NAME%%%%%%INFO%%%' + },{ + xtype: 'spacer', + height: 5 + },{ + border: false, + frame: false, + xtype: 'panel', + html: '
%%%LOINFO%%%
' + },{ + xtype: 'spacer', + height: 5 + },{ + xtype: 'combo', + fieldLabel: 'Module Status', + id: 'mod_ena', + lazyRender:true, + mode: 'local', + forceSelection: true, + triggerAction: 'all', + editable: false, + disableKeyFilter: true, + store: new Ext.data.ArrayStore({ + fields: ['status_val','status_txt'], + data: [[0,'Disabled'],[1,'Enabled']] + }), + value: %%%ENA_VAL%%%, + valueField: 'status_val', + displayField: 'status_txt' + },{ + xtype: 'spacer', + height: 5 + },{ + xtype: 'button', + id: 'mo_edit_btn', + disabled: false, + width: '100%', + text: 'Edit Module Config', + handler: function(){ + } + },{ + xtype: 'spacer', + height: 5 + },{ + xtype: 'button', + id: 'mo_del_btn', + disabled: false, + width: '100%', + text: 'Remove Module', + handler: function(){ + } + },{ + xtype: 'spacer', + height: 5 + },{ + xtype: 'button', + id: 'ua_apply_btn', + disabled: true, + width: '100%', + text: 'Apply Changes', + handler: function(){ + } + }] + +} +EFUFU; + $TPL = str_ireplace( '%%%NAME%%%',$Labels->GetLabel('_KAFKA_DESC_SHO_') , $TPL ); + $TPL = str_ireplace( '%%%INFO%%%', $Labels->GetLabel('_KAFKA_DESC_LOO_'), $TPL ); + $TPL = str_ireplace( '%%%LOINFO%%%',$R_nfo , $TPL ); + $TPL = str_ireplace( '%%%ENA_VAL%%%',$CR['enabled'], $TPL ); + echo $TPL; + break; + case 7: // SSDP + $TPL =<<%%%NAME%%%%%%INFO%%%' + },{ + xtype: 'spacer', + height: 5 + },{ + border: false, + frame: false, + xtype: 'panel', + html: '
%%%LOINFO%%%
' + },{ + xtype: 'spacer', + height: 5 + },{ + xtype: 'combo', + fieldLabel: 'Module Status', + id: 'mod_ena', + lazyRender:true, + mode: 'local', + forceSelection: true, + triggerAction: 'all', + editable: false, + disableKeyFilter: true, + store: new Ext.data.ArrayStore({ + fields: ['status_val','status_txt'], + data: [[0,'Disabled'],[1,'Enabled']] + }), + value: %%%ENA_VAL%%%, + valueField: 'status_val', + displayField: 'status_txt' + },{ + xtype: 'spacer', + height: 5 + },{ + xtype: 'button', + id: 'mo_del_btn', + disabled: false, + width: '100%', + text: 'Remove Module', + handler: function(){ + } + },{ + xtype: 'spacer', + height: 5 + },{ + xtype: 'button', + id: 'ua_apply_btn', + disabled: true, + width: '100%', + text: 'Apply Changes', + handler: function(){ + } + }] + +} +EFUFU; + $TPL = str_ireplace( '%%%NAME%%%',$Labels->GetLabel('_SSDP_DESC_SHO_') , $TPL ); + $TPL = str_ireplace( '%%%INFO%%%', $Labels->GetLabel('_SSDP_DESC_LOO_'), $TPL ); + $TPL = str_ireplace( '%%%LOINFO%%%',$Labels->GetLabel('_MOD_NO_NEDCONF_'), $TPL ); + $TPL = str_ireplace( '%%%ENA_VAL%%%',$CR['enabled'], $TPL ); + echo $TPL; + break; + case 8: // Onvif + $TPL =<<%%%NAME%%%%%%INFO%%%' + },{ + xtype: 'spacer', + height: 5 + },{ + border: false, + frame: false, + xtype: 'panel', + html: '
%%%LOINFO%%%
' + },{ + xtype: 'spacer', + height: 5 + },{ + xtype: 'combo', + fieldLabel: 'Module Status', + id: 'mod_ena', + lazyRender:true, + mode: 'local', + forceSelection: true, + triggerAction: 'all', + editable: false, + disableKeyFilter: true, + store: new Ext.data.ArrayStore({ + fields: ['status_val','status_txt'], + data: [[0,'Disabled'],[1,'Enabled']] + }), + value: %%%ENA_VAL%%%, + valueField: 'status_val', + displayField: 'status_txt' + },{ + xtype: 'spacer', + height: 5 + },{ + xtype: 'button', + id: 'mo_del_btn', + disabled: false, + width: '100%', + text: 'Remove Module', + handler: function(){ + } + },{ + xtype: 'spacer', + height: 5 + },{ + xtype: 'button', + id: 'ua_apply_btn', + disabled: true, + width: '100%', + text: 'Apply Changes', + handler: function(){ + } + }] +} +EFUFU; + $TPL = str_ireplace( '%%%NAME%%%',$Labels->GetLabel('_ONVIF_DESC_SHO_') , $TPL ); + $TPL = str_ireplace( '%%%INFO%%%', $Labels->GetLabel('_ONVIF_DESC_LOO_'), $TPL ); + $TPL = str_ireplace( '%%%LOINFO%%%',$Labels->GetLabel('_MOD_NO_NEDCONF_'), $TPL ); + $TPL = str_ireplace( '%%%ENA_VAL%%%',$CR['enabled'], $TPL ); + echo $TPL; + break; + case 9://Embed Video Encoder + $QS="SELECT * FROM `network_interfaces` WHERE `id`={$CR['aux_id']}"; + $II = $DATABASE->Query( $QS ); + $CI = $II[0]; + $TPL =<<%%%NAME%%%%%%INFO%%%' + },{ + xtype: 'spacer', + height: 5 + },{ + border: false, + frame: false, + xtype: 'panel', + html: '
%%%LOINFO%%%
' + },{ + xtype: 'spacer', + height: 5 + },{ + xtype: 'combo', + fieldLabel: 'Module Status', + id: 'mod_ena', + lazyRender:true, + mode: 'local', + forceSelection: true, + triggerAction: 'all', + editable: false, + disableKeyFilter: true, + store: new Ext.data.ArrayStore({ + fields: ['status_val','status_txt'], + data: [[0,'Disabled'],[1,'Enabled']] + }), + value: %%%ENA_VAL%%%, + valueField: 'status_val', + displayField: 'status_txt' + },{ + xtype: 'spacer', + height: 5 + },{ + xtype: 'button', + id: 'mo_edit_btn', + disabled: false, + width: '100%', + text: 'Edit Module Config', + handler: function(){ + embedVideoEncoderSettings(0); + } + },{ + xtype: 'spacer', + height: 5 + },{ + xtype: 'button', + id: 'mo_del_btn', + disabled: false, + width: '100%', + text: 'Remove Module', + handler: function(){ + } + },{ + xtype: 'spacer', + height: 5 + },{ + xtype: 'button', + id: 'ua_apply_btn', + disabled: true, + width: '100%', + text: 'Apply Changes', + handler: function(){ + } + }] + +} +EFUFU; + $TPL = str_ireplace( '%%%NAME%%%',$Labels->GetLabel('_EVE_DESC_SHO_') , $TPL ); + $TPL = str_ireplace( '%%%INFO%%%', $Labels->GetLabel('_EVE_DESC_LOO_'), $TPL ); + $TPL = str_ireplace( '%%%LOINFO%%%','' , $TPL ); + $TPL = str_ireplace( '%%%ENA_VAL%%%',$CR['enabled'], $TPL ); + echo $TPL; + break; + case 10: //Modem + $QS="SELECT * FROM `modules_kafka` WHERE `module_id`={$CR['aux_id']}"; + $II = $DATABASE->Query( $QS ); + $CI = $II[0]; + $R_nfo = 'Broker Node:'. $CI['brocker_address'].':'.$CI['brocker_port'].((intval($CI['use_ssl'])>0)?'':''); +$TPL =<<%%%NAME%%%%%%INFO%%%' + },{ + xtype: 'spacer', + height: 5 + },{ + border: false, + frame: false, + xtype: 'panel', + html: '
%%%LOINFO%%%
' + },{ + xtype: 'spacer', + height: 5 + },{ + xtype: 'combo', + fieldLabel: 'Module Status', + id: 'mod_ena', + lazyRender:true, + mode: 'local', + forceSelection: true, + triggerAction: 'all', + editable: false, + disableKeyFilter: true, + store: new Ext.data.ArrayStore({ + fields: ['status_val','status_txt'], + data: [[0,'Disabled'],[1,'Enabled']] + }), + value: %%%ENA_VAL%%%, + valueField: 'status_val', + displayField: 'status_txt' + },{ + xtype: 'spacer', + height: 5 + },{ + xtype: 'button', + id: 'mo_edit_btn', + disabled: false, + width: '100%', + text: 'Edit Module Config', + handler: function(){ + } + },{ + xtype: 'spacer', + height: 5 + },{ + xtype: 'button', + id: 'mo_del_btn', + disabled: false, + width: '100%', + text: 'Remove Module', + handler: function(){ + } + },{ + xtype: 'spacer', + height: 5 + },{ + xtype: 'button', + id: 'ua_apply_btn', + disabled: true, + width: '100%', + text: 'Apply Changes', + handler: function(){ + } + }] + +} +EFUFU; + $TPL = str_ireplace( '%%%NAME%%%',$Labels->GetLabel('_KAFKA_DESC_SHO_') , $TPL ); + $TPL = str_ireplace( '%%%INFO%%%', $Labels->GetLabel('_KAFKA_DESC_LOO_'), $TPL ); + $TPL = str_ireplace( '%%%LOINFO%%%',$R_nfo , $TPL ); + $TPL = str_ireplace( '%%%ENA_VAL%%%',$CR['enabled'], $TPL ); + echo $TPL; + break; + }; + } else { + echo '{ xtype: \'panel\', html: \'Node '.$_POST['NODE'].' Loadded\'}'; + }; + } else { + header('location: /'); + }; +?> \ No newline at end of file diff --git a/lib/controller/getNetworkNodeProps.php b/lib/controller/getNetworkNodeProps.php index abf717c..57d517f 100644 --- a/lib/controller/getNetworkNodeProps.php +++ b/lib/controller/getNetworkNodeProps.php @@ -13,13 +13,20 @@ $Data = str_replace('%%%NODENAME%%%', $Props['name'] , $Data ); switch( $Type ){ case ARGUS_SERVER: + $QS = "SELECT * FROM servers WHERE id = {$Props['aux_id']}"; + $Result = $DATABASE->Query( $QS, false ); + $Server = $Result[0]; //Info $InfoData = ''; $InfoParts = array(); - $InfoParts[] = '{ xtype: \'panel\', html: \'
'.$Server['identity'].'
\'}'; - if($Props['online']){ + $InfoParts[] = '{ xtype: \'panel\', html: \'
'.$Server['version_string'].'
\'}'; + if( $Props['online'] ){ $InfoParts[] = '{ xtype: \'panel\', html: \'
Online
\'}'; - }else{ + $InfoParts[] = '{ xtype: \'panel\', html: \'
CPU(s): '.$Server['cpu_cores'].'
\'}'; + $InfoParts[] = '{ xtype: \'panel\', html: \'
Memory: '.round($Server['val_mem_tottal']/1048576).'Mb
\'}'; + $InfoParts[] = '{ xtype: \'panel\', html: \'
Storage: '.round($Server['val_disk_tottal']/1024).'Mb
\'}'; + $InfoParts[] = '{ xtype: \'panel\', html: \'
Temperature: '.$Server['temp0'].'°C
\'}'; + } else { $InfoParts[] = '{ xtype: \'panel\', html: \'
Offline
\'}'; }; $InfoData = implode( ',', $InfoParts ); @@ -135,20 +142,27 @@ $QS="SELECT * FROM lrf_sensors WHERE id={$Props['aux_id']}"; $RR = $DATABASE->Query( $QS ); $CC = $RR[0]; + $QS="SELECT * FROM lrf_detection_profiles WHERE aux_id={$Props['aux_id']} AND profile_id={$CC['detection_profile_id']} AND master=b'1'"; + $RR = $DATABASE->Query( $QS ); + $MS = $RR[0]; + $QS="SELECT * FROM lrf_detection_profiles WHERE aux_id={$Props['aux_id']} AND profile_id={$CC['detection_profile_id']} AND master=b'0'"; + $RR = $DATABASE->Query( $QS ); + $SL = $RR[0]; + $Data = str_replace('%%%DEV_LABEL%%%', ''.$Props['name'], $Data ); $Data = str_replace('%%%LRF_ID%%%', ''.$Props['aux_id'], $Data ); $Data = str_replace('%%%NODEID%%%', ''.$Node, $Data ); $Data = str_replace('%%%DEVICE_ID%%%', $CC['device_id'] , $Data ); $Data = str_replace('%%%NODENAME%%%', $Props['name'] , $Data ); $Data = str_replace('%%%MAX_RANGE%%%', $CC['max_range'] , $Data ); - $Data = str_replace('%%%M_ORDER%%%', $CC['m_order'] , $Data ); - $Data = str_replace('%%%M_OFFSET%%%', $CC['m_offset'] , $Data ); - $Data = str_replace('%%%M_WIDTH%%%', $CC['m_width'] , $Data ); - $Data = str_replace('%%%M_SST%%%', $CC['m_sst'] , $Data ); - $Data = str_replace('%%%S_ORDER%%%', $CC['s_order'] , $Data ); - $Data = str_replace('%%%S_OFFSET%%%', $CC['s_offset'] , $Data ); - $Data = str_replace('%%%S_WIDTH%%%', $CC['s_width'] , $Data ); - $Data = str_replace('%%%S_SST%%%', $CC['s_sst'] , $Data ); + $Data = str_replace('%%%M_ORDER%%%', $MS['order'] , $Data ); + $Data = str_replace('%%%M_OFFSET%%%', $MS['offset'] , $Data ); + $Data = str_replace('%%%M_WIDTH%%%', $MS['width'] , $Data ); + $Data = str_replace('%%%M_SST%%%', $MS['sst'] , $Data ); + $Data = str_replace('%%%S_ORDER%%%', $SL['order'] , $Data ); + $Data = str_replace('%%%S_OFFSET%%%', $SL['offset'] , $Data ); + $Data = str_replace('%%%S_WIDTH%%%', $SL['width'] , $Data ); + $Data = str_replace('%%%S_SST%%%', $SL['sst'] , $Data ); break; }; case ARGUS_3D_SENSOR:{ diff --git a/lib/controller/getNetworkServerProps.php b/lib/controller/getNetworkSe2rverProps.php similarity index 100% rename from lib/controller/getNetworkServerProps.php rename to lib/controller/getNetworkSe2rverProps.php diff --git a/lib/controller/getNodeSettings.php b/lib/controller/getNodeSettings.php index d44eb2d..eccfd69 100644 --- a/lib/controller/getNodeSettings.php +++ b/lib/controller/getNodeSettings.php @@ -1,4 +1,233 @@ -Data['id'] > 1 ){ + $Z = intval( $_POST['NID'] ); + if( $Z ){ + $QS = "SELECT * FROM `nodes` WHERE `id`={$Z}"; + $NN = $DATABASE->Query( $QS ); + if( count( $NN ) ){ + $Node = $NN[0]; + switch( $Node['type'] ){ + case 0:{ + $QS="SELECT * FROM `servers` WHERE `id`={$Node['aux_id']}"; + $SDD = $DATABASE->Query( $QS ); + $NData = $SDD[0]; + $QS="SELECT * FROM `resources` WHERE `node_id`={$Z} AND ( `type`=101 OR `type`=102 )"; + $CN = $DATABASE->Query( $QS ); + $IL=array(); + foreach( $CN as $N ){ + $QS="SELECT * FROM `networks` WHERE `nif_id`={$N['aux_id']} AND `type`=0"; + $NWD = $DATABASE->Query( $QS ); + $NW = $NWD[0]; + $IL[]="{$N['device']}:{$NW['address']}"; + }; + $NIFO = '' . implode( '', $IL ) . '
'; +?> +{ + xtype: 'tabpanel', + frame: false, + id: 'node_settings_content', + border: false, + activeTab: 0, + items: [{ + xtype: 'panel', + title: 'General Info', + layout: 'hbox', + items:[{ + xtype: 'panel', + flex: 1, + height: 303, + autoScroll: false, + html: '
' + },{ + xtype: 'form', + id: '_ed_small', + flex: 1, + height: 303, + autoScroll: false, + //layout: 'vbox', + labelWidth: 120, + labelAlign: 'right', + items:[{ + xtype: 'textfield', + fieldLabel: 'GetLabel( 'SERV_NAME' );?>', + id: 'node_name', + value: '', + listeners:{ + change: function(){ + settingsChangeNotifier( 'node_name' ); + Ext.getCmp('sasa_bo').enable(); + } + } + },{ + xtype: 'panel', + width: '100%', + html: '
GetLabel( 'SERV_BLD_TAG' ).': '.$NData['version_string'];?>
' + },{ + xtype: 'panel', + width: '100%', + html: '
' + },{ + xtype: 'button', + id: 'sasa_bo', + width: '100%', + disabled: true, + text: 'Apply Changes', + handler: function(){ + } + }] + }] + },{ + xtype: 'panel', + title: 'Resources', + layout: 'hbox', + items:[{ + xtype: 'panel', + flex: 1, + height: 303, + autoScroll: 'auto', + //layout: 'fit', + items:[Query( $QS, false ); + if( count( $Result ) ){ + foreach( $Result as $R ){ + switch( $R['type'] ){ + case 1: + //Uart + $SockDataParts[] = '{ xtype: \'panel\', boder: false, frame: false, html: \''.$Labels->GetLabel('UART_LINE_PROP').' '.(($R['used']==0)?'':'').'\'}'; + break; + case 6: + //USB DC + $SockDataParts[] = '{ xtype: \'panel\', boder: false, frame: false, html: \''.$Labels->GetLabel('UART_LINE_PROP').' '.(($R['used']==0)?'':'').'\'}'; + break; + case 31: + //Video Grabber + $SockDataParts[] = '{ xtype: \'panel\', boder: false, frame: false, html: \''.$Labels->GetLabel('FRAMEGRAB_PROP').' '.(($R['used']==0)?'':'').'\'}'; + break; + case 100: + //Loopback + $SockDataParts[] = '{ xtype: \'panel\', boder: false, frame: false, html: \''.$Labels->GetLabel('LOOPBACK_PROP').' '.(($R['used']==0)?'':'').'\'}'; + break; + case 101: + //Ethernet Interface + $SockDataParts[] = '{ xtype: \'panel\', boder: false, frame: false, html: \''.$Labels->GetLabel('ETHERNET_PROP').' '.(($R['used']==0)?'':'').'\'}'; + break; + case 102: + //WiFi Interface + $SockDataParts[] = '{ xtype: \'panel\', boder: false, frame: false, html: \''.$Labels->GetLabel('WIFI_PROP').' '.(($R['used']==0)?'':'').'\'}'; + break; + case 103: + //Virtual IP Interface + $SockDataParts[] = '{ xtype: \'panel\', boder: false, frame: false, html: \''.$Labels->GetLabel('VIRTUALIP_PROP').' '.(($R['used']==0)?'':'').'\'}'; + break; + case 104: + //VPN Interface + $SockDataParts[] = '{ xtype: \'panel\', boder: false, frame: false, html: \''.$Labels->GetLabel('VPN_TUN_PROP').' '.(($R['used']==0)?'':'').'\'}'; + break; + case 105: + //WAN Interface + $SockDataParts[] = '{ xtype: \'panel\', boder: false, frame: false, html: \''.$Labels->GetLabel('WAN_LINE_PROP').' '.(($R['used']==0)?'':'').'\'}'; + break; + //Media Encoder Sink + case 131: // Video Encoder Sink + $SockDataParts[] = '{ xtype: \'panel\', boder: false, frame: false, html: \''.'Video Sink'.' '.(($R['used']==0)?'':'').'\'}'; + break; + case 132: // Audio Encoder Sink + $SockDataParts[] = '{ xtype: \'panel\', boder: false, frame: false, html: \''.'Audio Sink'.' '.(($R['used']==0)?'':'').'\'}'; + break; + default: + $SockDataParts[] = '{ xtype: \'panel\', boder: false, frame: false, html: \''.$R['device'].' '.(($R['used']==0)?'':'').'\'}'; + }; + }; + echo implode( ',', $SockDataParts ); + }; + ?>] + },{ + xtype: 'panel', + id: 'res_ed_small', + flex: 1, + height: 303, + layout: 'fit', + items:[{ + html:'
GetLabel('_PLS_SEL_LEFT_ITEM_');?>
' + }] + }] + },{ + xtype: 'panel', + title: 'Modules', + layout: 'hbox', + items:[{ + xtype: 'panel', + flex: 1, + height: 303, + autoScroll: 'auto', + tbar:[{ + text: 'Add Module' + }], + items:[Query( $QS, false ); + if( count( $Result ) ){ + foreach( $Result as $R ){ + $QS = "SELECT * FROM server_module_types WHERE id={$R['type']}"; + $MOMO = $DATABASE->Query( $QS, false ); + $MOD = $MOMO[0]; + switch( $R['type'] ){ + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + case 9: + case 10: + $ModPart[] = '{ xtype: \'panel\', boder: false, frame: false, html: \''.$Labels->GetLabel($MOD['name']).'\'}'; + break; + default: + $ModPart[] = '{ xtype: \'panel\', boder: false, frame: false, html: \''.$R['device'].'\'}'; + }; + }; + echo implode( ',', $ModPart ); + }; + ?>] + },{ + xtype: 'panel', + id: 'mod_ed_small', + flex: 1, + height: 303, + layout: 'fit', + items:[{ + html:'
GetLabel('_PLS_SEL_LEFT_ITEM_');?>
' + }] + }] + },{ + xtype: 'panel', + title: 'Network', + items:[] + }], + listeners:{ + afterrender: function(){ + settingsAreChanged = false; + } + }, + updateSettings: function(){ + alert('Update Settings'); + } +} + \ No newline at end of file diff --git a/lib/controller/getResourceEditor.php b/lib/controller/getResourceEditor.php new file mode 100644 index 0000000..83d7a7a --- /dev/null +++ b/lib/controller/getResourceEditor.php @@ -0,0 +1,430 @@ +GetLabel('_RES_ETHERNET_DESC_'); + $QS="SELECT * FROM `network_interfaces` WHERE `id`={$RessourceID}"; + $II = $DATABASE->Query( $QS ); + $CI = $II[0]; + switch( $CI['mode'] ){ + case 0: $MS = $Labels->GetLabel( 'MODE_DISABLED' ); break; + case 1: $MS = $Labels->GetLabel( 'MODE_ETHDYNAMIC' ); break; + case 2: $MS = $Labels->GetLabel( 'MODE_ETHSTATIC' ); break; + case 3: $MS = $Labels->GetLabel( 'MODE_ETHROUTER' ); break; + }; + $QS="SELECT * FROM `networks` WHERE `nif_id`={$RessourceID}"; + $II = $DATABASE->Query( $QS ); + $NetInfo =''; + $IP = array(); + foreach($II as $I){ + if( $I['type'] == 0 ){ + $IP = $I; + $NetInfo .= '
Address IPv4: '.$I['address'].'
Net Mask: '.$I['mask']; + } else { + $NetInfo .= '
Address IPv6: '.$I['address'].'
Net Mask: '.$I['mask']; + }; + }; + if( count( $IP ) ){ + $TArr = explode( '.', $IP['address'] ); + $Base = ''; + } else { + }; + $R_nfo = 'Mode: '.$MS.'
MAC: '.$CI['mac'] . $NetInfo; + $R_image = 'Ethernet-Cable-icon.png'; + $POPUS = 123; + $A_EDIT = ( $CI['mode'] < 2 )?'true':'false'; + $TPL = <<', + },{ + xtype: 'panel', + border: false, + frame: false, + width: 420, + height: 320, + items:[{ + frame: false, + border: false, + html: '

{$TTL}

' + },{ + xtype: 'tabpanel', + id: 'ifo_tab', + activeTab: 0, + items:[{ + title: 'Info', + html: '{$R_nfo}' + },{ + title: 'Settings', + layout: 'form', + labelAlign: 'right', + labelWidth: 150, + items:[{ + xtype: 'combo', + fieldLabel: 'Address Allocation', + lazyRender: true, + id: 'aa_type', + mode: 'local', + forceSelection: true, + triggerAction: 'all', + editable: false, + disableKeyFilter: true, + listeners:{ + change: function(t,n,o){ + if( n < 2 ){ + Ext.getCmp('aa_adr').disable(); + } else { + Ext.getCmp('aa_adr').enable(); + }; + } + }, + store: new Ext.data.ArrayStore({ + fields: ['aa_t','aa_txt'], + data: [ + [0,'Disabled'], + [1,'Dynamic (DHCP)'], + [2,'Static'], + [3,'Router'], + ] + }), + value: {$CI['mode']}, + valueField: 'aa_t', + displayField: 'aa_txt' + },{ + xtype: 'textfield', + id: 'aa_adr', + fieldLabel: 'Address', + value: '{$IP['address']}', + disabled: {$A_EDIT} + },{ + xtype: 'textfield', + id: 'aa_mask', + fieldLabel: 'Net Mask', + value: '{$IP['mask']}', + disabled: {$A_EDIT} + },{ + xtype: 'textfield', + id: 'aa_gtw', + fieldLabel: 'Gateway', + value: '{$IP['gateway']}', + disabled: true + },{ + xtype: 'textfield', + id: 'aa_bcast', + fieldLabel: 'Broadcast', + value: '{$IP['broadcast']}', + disabled: true + },{ + xtype: 'spacer', + height: 100 + },{ + xtype: 'button', + width: '100%', + text: 'Apply Changes' + },{ + xtype: 'spacer', + height: 20 + }] + },{ + title: 'Router', + layout: 'form', + labelAlign: 'right', + labelWidth: 150, + items:[{ + xtype: 'checkbox', + fieldLabel: 'Act as DHCP Server', + },{ + xtype: 'textfield', + fieldLabel: 'Start IP Range' + },{ + xtype: 'textfield', + fieldLabel: 'End IP Range' + }] + }] + }] + },{ + border: false, + width: 10 + }], + koko: {$POPUS} + } +END_TEMPLATE; + return $TPL; + }; + if( $CUser->Data['id'] > 1 ){ + $EID = intval( $_POST['RID'] ); + $QS = "SELECT * FROM resources WHERE id = {$EID}"; + $Result = $DATABASE->Query( $QS, false ); + if( count( $Result ) ){ + $CR = $Result[0]; + switch( $CR['type'] ){ + case 1: //https://bufferwall.com/posts/330881001ji1a/ + $QS = "SELECT * FROM uart_settings WHERE id={$CR['aux_id']}"; + $Result = $DATABASE->Query( $QS ); + $Z = $Result[0]; + $R_name = $Labels->GetLabel('_RES_HW_UART_DESC_'); + $R_dev = $CR['device']; + $R_nfo = 'Speed: ' . $Z['speed'] . ', Bits: ' . $Z['bit'] . ', Parity: ' . $Z['parity'] . ', Stop Bit: '. $Z['stop_bit']; + $R_image = 'unnamed.png'; + $TPL =<<%%%NAME%%%%%%INFO%%%
' + },{ + id: 'uart_spd', + xtype: 'combo', + fieldLabel: '%%%SPD%%%', + lazyRender: true, + mode: 'local', + forceSelection: true, + triggerAction: 'all', + editable: false, + disableKeyFilter: true, + store: new Ext.data.ArrayStore({ + fields: ['speed'], + data: [[1200],[2400],[9600],[19200],[38400],[57600],[115200]] + }), + valueField: 'speed', + displayField: 'speed', + listeners:{ + change: function(){ + settingsChangeNotifier( 'uart_spd' ); + Ext.getCmp('ua_apply_btn').enable(); + } + }, + value: %%%SPD_VAL%%% + },{ + xtype: 'combo', + fieldLabel: 'Bits', + id: 'ued_bit', + lazyRender:true, + mode: 'local', + forceSelection: true, + triggerAction: 'all', + editable: false, + disableKeyFilter: true, + store: new Ext.data.ArrayStore({ + fields: ['bits'], + data: [[5],[6],[7],[8],[9]] + }), + value: %%%BITS_VAL%%%, + valueField: 'bits', + displayField: 'bits' + },{ + xtype: 'combo', + fieldLabel: 'Stop Bit', + lazyRender:true, + id: 'ued_stops', + mode: 'local', + forceSelection: true, + triggerAction: 'all', + editable: false, + disableKeyFilter: true, + store: new Ext.data.ArrayStore({ + fields: ['stops'], + data: [[1],[1.5],[2]] + }), + value: %%%STOPS_VAL%%%, + valueField: 'stops', + displayField: 'stops' + },{ + xtype: 'combo', + fieldLabel: 'Parity', + lazyRender:true, + id: 'ued_parity', + mode: 'local', + forceSelection: true, + triggerAction: 'all', + editable: false, + disableKeyFilter: true, + store: new Ext.data.ArrayStore({ + fields: ['par_val','parity'], + data: [['O','Odd'], ['E','Even'],['N','None']] + }), + value: '%%%PARITY_VAL%%%', + valueField: 'par_val', + displayField: 'parity' + },{ + xtype: 'spacer', + height: 10 + },{ + xtype: 'button', + id: 'ua_apply_btn', + disabled: true, + width: '100%', + text: 'Apply Changes', + handler: function(){ + var UART_SPD = Ext.getCmp('uart_spd').getValue(); + var UART_BIT = Ext.getCmp('ued_bit').getValue(); + var UART_STP = Ext.getCmp('ued_stops').getValue(); + var UART_PAR = Ext.getCmp('ued_parity').getValue(); + Ext.Ajax.request({ + url: '/lib/controller/updateResource.php', + params: { + RID: %%%%RES_ID%%%, + UID: %%%USER_ID%%%, + SID: '%%%SESSION%%%', + USPD: UART_SPD, + UBIT: UART_BIT, + USTP: UART_STP, + UPAR: UART_PAR + }, + success: function( response, opts ){ + data = Ext.decode(response.responseText); + if( data.status ){ + cleanupChangeNotifier(); + editResource( %%%%RES_ID%%% ); + } else { + Ext.Msg.show({ + title:'Error', + msg: data.msg, + buttons: Ext.Msg.OK, + icon: Ext.MessageBox.ERROR, + fn: function(btn, text){ + cleanupChangeNotifier(); + editResource( %%%%RES_ID%%% ); + } + }); + }; + //doRefresh(); + }, + failure: failureAJAXFunction + }); + } + }] + +} +EFUFU; + $TPL = str_ireplace( '%%%NAME%%%', $R_name, $TPL ); + $TPL = str_ireplace( '%%%INFO%%%', $R_dev, $TPL ); + $TPL = str_ireplace( '%%%SPD%%%', $Labels->GetLabel('UART_COM_SPEED'), $TPL ); + $TPL = str_ireplace( '%%%SPD_VAL%%%', $Z['speed'], $TPL ); + $TPL = str_ireplace( '%%%BITS_VAL%%%',$Z['bit'], $TPL ); + $TPL = str_ireplace( '%%%PARITY_VAL%%%',$Z['parity'], $TPL ); + $TPL = str_ireplace( '%%%STOPS_VAL%%%',$Z['stop_bit'], $TPL ); + $TPL = str_ireplace( '%%%%RES_ID%%%',$EID, $TPL ); + $TPL = str_ireplace( '%%%USER_ID%%%',$UserID, $TPL ); + $TPL = str_ireplace( '%%%SESSION%%%',$Session, $TPL ); + echo $TPL; + break; + case 31: //Video In + $R_name = 'Video Frame Grabber'; + $R_dev = $CR['device']; + $QS="SELECT * FROM `media_streams` WHERE `id`={$CR['aux_id']}"; + $II = $DATABASE->Query( $QS ); + $CI = $II[0]; + $R_nfo = 'Frame Size: '.$CI['img_width'].'x'.$CI['img_height'].'
Driver: '.$CI['mrl_proto']; + $R_image = 'RCA-Connector-Plug-icon.png'; + break; + case 101: // Ethernet + $R_name = $Labels->GetLabel('_RES_ETHERNET_DESC_'); + $R_dev = $CR['device']; + $QS="SELECT * FROM `network_interfaces` WHERE `id`={$CR['aux_id']}"; + echo makeEthernetInfo( $CR['aux_id'] ); + exit; + $II = $DATABASE->Query( $QS ); + $CI = $II[0]; + switch( $CI['mode'] ){ + case 0: $MS = $Labels->GetLabel( 'MODE_DISABLED' ); break; + case 1: $MS = $Labels->GetLabel( 'MODE_ETHDYNAMIC' ); break; + case 2: $MS = $Labels->GetLabel( 'MODE_ETHSTATIC' ); break; + case 1: $MS = $Labels->GetLabel( 'MODE_ETHROUTER' ); break; + }; + $QS="SELECT * FROM `networks` WHERE `nif_id`={$CR['aux_id']}"; + $II = $DATABASE->Query( $QS ); + $NetInfo =''; + foreach($II as $I){ + if( $I['type'] == 0 ){ + $NetInfo .= '
Address IPv4: '.$I['address'].'
Net Mask: '.$I['mask']; + } else { + $NetInfo .= '
Address IPv6: '.$I['address'].'
Net Mask: '.$I['mask']; + }; + }; + $R_nfo = 'Mode: '.$MS.'
MAC: '.$CI['mac'] . $NetInfo; + $R_image = 'Ethernet-Cable-icon.png'; + break; + case 102: // WiFi + $R_name = $Labels->GetLabel('_RES_WIFI_DESC_'); + $R_dev = $CR['device']; + $QS="SELECT * FROM `network_interfaces` WHERE `id`={$CR['aux_id']}"; + $II = $DATABASE->Query( $QS ); + $CI = $II[0]; + switch( $CI['mode'] ){ + case 0: $MS = $Labels->GetLabel( 'MODE_DISABLED' ); break; + case 1: $MS = $Labels->GetLabel( 'MODE_ETHDYNAMIC' ); break; + case 2: $MS = $Labels->GetLabel( 'MODE_ETHSTATIC' ); break; + case 3: $MS = $Labels->GetLabel( 'MODE_ACCESS_POINT' ); break; + }; + $QS="SELECT * FROM `networks` WHERE `nif_id`={$CR['aux_id']}"; + $II = $DATABASE->Query( $QS ); + $NetInfo =''; + foreach($II as $I){ + if( $I['type'] == 0 ){ + $NetInfo .= '
Address IPv4: '.$I['address'].'
Net Mask: '.$I['mask']; + } else { + $NetInfo .= '
Address IPv6: '.$I['address'].'
Net Mask: '.$I['mask']; + }; + }; + $R_nfo = 'Mode: '.$MS.'
MAC: '.$CI['mac'] . $NetInfo; + $R_image = 'wifi-modem-Vista-icon.png'; + break; + case 105: + $R_name = $Labels->GetLabel('_RES_WAN_DESC_'); + $R_dev = $CR['device']; + $QS="SELECT * FROM `network_interfaces` WHERE `id`={$CR['aux_id']}"; + $II = $DATABASE->Query( $QS ); + $CI = $II[0]; + switch( $CI['mode'] ){ + case 0: $MS = $Labels->GetLabel( 'MODE_DISABLED' ); break; + case 1: $MS = $Labels->GetLabel( 'MODE_ETHDYNAMIC' ); break; + case 2: $MS = $Labels->GetLabel( 'MODE_ETHSTATIC' ); break; + case 3: $MS = $Labels->GetLabel( 'MODE_ACCESS_POINT' ); break; + }; + $QS="SELECT * FROM `networks` WHERE `nif_id`={$CR['aux_id']}"; + $II = $DATABASE->Query( $QS ); + $NetInfo =''; + foreach($II as $I){ + if( $I['type'] == 0 ){ + $NetInfo .= '
Address IPv4: '.$I['address'].'
Net Mask: '.$I['mask']; + } else { + $NetInfo .= '
Address IPv6: '.$I['address'].'
Net Mask: '.$I['mask']; + }; + }; + $R_nfo = 'Mode: '.$MS.'
MAC: '.$CI['mac'] . $NetInfo; + $R_image = 'wifi-modem-Vista-icon.png'; + break; + }; + } else { + echo '{ xtype: \'panel\', html: \'Node '.$_POST['NODE'].' Loadded\'}'; + }; + } else { + header('location: /'); + }; +?> \ No newline at end of file diff --git a/lib/controller/getSettingsLRF.php b/lib/controller/getSettingsLRF.php index cf90291..d073f20 100644 --- a/lib/controller/getSettingsLRF.php +++ b/lib/controller/getSettingsLRF.php @@ -16,6 +16,12 @@ $R['name'] = $T['name']; $R['data_status'] = intval( $R['data_status'] ); $R['online'] = intval($T['online']); + $QS="SELECT * FROM `lrf_detection_profiles` WHERE `aux_id`={$AID} AND `profile_id`={$R['detection_profile_id']} AND `master`=b'1'"; + $result = $DATABASE->Query( $QS, false ); + $R['master_profile']=$result[0]; + $QS="SELECT * FROM `lrf_detection_profiles` WHERE `aux_id`={$AID} AND `profile_id`={$R['detection_profile_id']} AND `master`=b'0'"; + $result = $DATABASE->Query( $QS, false ); + $R['slave_profile']=$result[0]; $Data = $R; }; }; diff --git a/lib/controller/getStatus.php b/lib/controller/getStatus.php index 4aa36a6..f3f780a 100644 --- a/lib/controller/getStatus.php +++ b/lib/controller/getStatus.php @@ -35,13 +35,13 @@ $CN['CTS'] = $Data['CTS']; $CN['STS'] = $STS; if( ( $CN['CTS'] - $STS ) > 1 ){ //3 seconds offline - //$ServerIsOnLine = false; + $ServerIsOnLine = false; $CN['status'] = 0; } else { $CN['status'] = 1; }; } else { - //$ServerIsOnLine = false; + $ServerIsOnLine = false; $CN['status'] = 0; }; $CN['cpu1'] = intval( $zult[0]['stat_cpu1'] * 2.5 ); diff --git a/lib/controller/listAndDiscoverOnvifProfiles.php b/lib/controller/listAndDiscoverOnvifProfiles.php index 8cd7ab9..1ab33ff 100644 --- a/lib/controller/listAndDiscoverOnvifProfiles.php +++ b/lib/controller/listAndDiscoverOnvifProfiles.php @@ -28,6 +28,7 @@ }; $EUser = $DATABASE->escape( $_POST['GUG'] ); $EPass = $DATABASE->escape( $_POST['GOG'] ); + $AUTH = intval( $_POST['GAT'] ); $QS = "SELECT * FROM cameras WHERE id = {$ECID}"; $Result = $DATABASE->Query( $QS, false ); if( count($Result) ){ @@ -37,6 +38,7 @@ $onvif->setUsername( $EUser ); $onvif->setPassword( $EPass ); $onvif->setIPAddress( $IP ); + $onvif->setAuthMethod( $AUTH ); //$media_server = new zlMediaServer('035c73f7-bb6b-4889-a715-d9eb2d1925cc'); try { $onvif->initialize(); @@ -82,7 +84,7 @@ $DATABASE->Query( $QS, false ); //$CSSS = $DATABASE->getLastInsertID(); }; - $QS = "UPDATE cameras SET access_login='$EUser', access_pass='$EPass', ptz_token='{$Eptz}' WHERE id={$ECID}"; + $QS = "UPDATE cameras SET access_login='$EUser', access_pass='$EPass', auth_mode={$AUTH}, ptz_token='{$Eptz}' WHERE id={$ECID}"; $DATABASE->Query( $QS, false ); } else { $Data['error'] = 'Provided Credentials are Wrong!'; diff --git a/lib/controller/listDiscoveredCameraSources.php b/lib/controller/listMediaSources.php similarity index 66% rename from lib/controller/listDiscoveredCameraSources.php rename to lib/controller/listMediaSources.php index c7f6acd..e2e9a6e 100644 --- a/lib/controller/listDiscoveredCameraSources.php +++ b/lib/controller/listMediaSources.php @@ -1,20 +1,6 @@ '-noname-','dev'=>'unknown'); - }; + //require_once('../php/onvif/toto.php'); if( $CUser->Data['id'] > 1 ){ if( isset( $_POST['cam_sources'] ) ){ if( $_POST['cam_sources'] == 'ipv' ){ @@ -34,12 +20,12 @@ $Data['nodes'][] = $cnode; }; } else { - $QS = "SELECT * FROM `media_streams` WHERE `source_type`='A' AND `source_id`=0"; + $QS = "SELECT `ms`.* , `re`.`node_id` FROM `media_streams` `ms` LEFT JOIN `resources` `re` ON ( `re`.`aux_id` = `ms`.`id` ) WHERE `ms`.`source_type`='A' AND `ms`.`source_id`=0"; $Result = $DATABASE->Query($QS,false); foreach( $Result as $CD ){ $cnode['id'] = $CD['id']; - $cnode['status'] = 'local'; - $T = getDeviceName($CD['mrl']); + $cnode['server'] = getServerID( $CD['node_id'] );//'local'; + $T = getV4L2DeviceName($CD['mrl']); $cnode['name'] = $T['name']; $cnode['hardware']= $T['dev']; $cnode['caps'] = 'Analog'; diff --git a/lib/controller/listServers.php b/lib/controller/listServers.php index 3b780d6..c0546d7 100644 --- a/lib/controller/listServers.php +++ b/lib/controller/listServers.php @@ -5,11 +5,11 @@ $Data['success'] = false; if( isset( $_POST['SITE'] ) ){ $SiteID = intval( $_POST['SITE'] ); - $QS = "SELECT `id`, `name` FROM `nodes` WHERE `site_id`={$SiteID} AND `type`=0"; + $QS = "SELECT `aux_id`, `name` FROM `nodes` WHERE `site_id`={$SiteID} AND `type`=0"; $Result = $DATABASE->Query($QS,false); $Data['servers'] = array(); foreach( $Result as $CD ){ - $cnode['server_id'] = $CD['id']; + $cnode['server_id'] = $CD['aux_id']; $cnode['server_name'] = $CD['name']; $Data['servers'][] = $cnode; }; diff --git a/lib/controller/props/1_node_prop.js b/lib/controller/props/1_node_prop.js index 257191b..f55fda7 100644 --- a/lib/controller/props/1_node_prop.js +++ b/lib/controller/props/1_node_prop.js @@ -10,6 +10,13 @@ height: 100, html: '


%%%DEV_LABEL%%%

' },{ + xtype: 'button', + text: 'Change Settings', + width: '100%', + handler: function(){ + LRF2D2_settings(); + } + },{ xtype:'fieldset', //checkboxToggle:true, collapsible: true, @@ -42,69 +49,6 @@ html: '

Dev Address: %%%DEVICE_ID%%%

' }] },{ - xtype: 'button', - text: 'Change Settings', - width: '100%', - handler: function(){ - var wAddSocket = new Ext.Window({ - title: 'Sensor Settings', - width: 450, - //height: 480, - items:[{ - xtype: 'form', - labelWidth: 120, // label settings here cascade unless overridden - frame: false, - bodyStyle:'padding:5px 5px 0', - defaultType: 'textfield', - items:[{ - fieldLabel: 'Device Name', - id: 'ued_name' - },{ - fieldLabel: 'Device Address', - id: 'ued_address' - },{ - fieldLabel: 'Maximal Range', - id: 'ued_range' - }] - }], - buttons:[{ - text: 'Cancel', - handler: function(){ - wAddSocket.close(); - wAddSocket = null; - } - },{ - text: 'Apply Settings', - handler: function(){ - var val_name = Ext.getCmp('ued_name').getValue(); - var val_addr = Ext.getCmp('ued_address').getValue(); - var val_range = Ext.getCmp('ued_range').getValue(); - Ext.Ajax.request({ - url: '/lib/controller/updateLrfSettings.php', - params: { - SENSOR: %%%LRF_ID%%%, - SADDR: val_addr, - SNAME: val_name, - SRANGE: val_range - }, - success: function( response, opts ){ - wAddSocket.close(); - wAddSocket = null; - loadNodeProperties( %%%NODEID%%% ); - }, - failure: function( response, opts ) { - - } - }); - } - }] - }); - wAddSocket.show(); - Ext.getCmp('ued_name').setValue( Ext.getCmp('dev_name').getValue()); - Ext.getCmp('ued_address').setValue( Ext.getCmp('dev_id').getValue()); - Ext.getCmp('ued_range').setValue( Ext.getCmp('max_range').getValue()); - } - },{ xtype:'fieldset', title: 'Master LRF', collapsible: true, diff --git a/lib/controller/props/loc_prop.js b/lib/controller/props/loc_prop.js index b7dab50..98b8b41 100644 --- a/lib/controller/props/loc_prop.js +++ b/lib/controller/props/loc_prop.js @@ -1,85 +1,119 @@ { xtype: 'form', - labelWidth: 75, // label settings here cascade unless overridden + labelWidth: 40, // label settings here cascade unless overridden frame: false, bodyStyle:'padding:5px 5px 0', defaultType: 'textfield', + labelAlign: 'right', items: [{ - xtype: 'panel', - height: 100, - html: '


%%%NAME%%%

' + xtype: 'panel', + height: 100, + html: '


%%%NAME%%%

' },{ xtype:'fieldset', //checkboxToggle:true, - collapsible: true, + collapsible: true, title: 'Location', autoHeight: true, defaults: { - //width: 180 - }, + //width: 180 + }, defaultType: 'textfield', collapsed: false, items :[{ - fieldLabel: 'Latitude', - name: 'slat', - value: %%%LAT%%%, - id: 'slat', - allowBlank:false + fieldLabel: 'Lat', + name: 'slat', + value: %%%LAT%%%, + id: 'slat', + allowBlank:false },{ - fieldLabel: 'Longitude', - id: 'slon', - value: %%%LON%%%, - name: 'slon', - allowBlank:false + fieldLabel: 'Lon', + id: 'slon', + value: %%%LON%%%, + name: 'slon', + allowBlank:false },{ - fieldLabel: 'Altitude', - id: 'salt', - value: %%%ALT%%%, - name: 'salt', - allowBlank:false - },{ - xtype: 'button', - text: 'Set To Anchor Position', - width: '100%', - handler: setNodeLocationToAnchor - }] + fieldLabel: 'Alt', + id: 'salt', + value: %%%ALT%%%, + name: 'salt', + allowBlank:false + },{ + xtype: 'button', + text: 'Set To Anchor Position', + width: '100%', + handler: setNodeLocationToAnchor + }] },{ xtype:'fieldset', title: 'Orientation', collapsible: true, autoHeight:true, defaults: { - //width: 168 - }, + //width: 168 + }, defaultType: 'textfield', items :[{ fieldLabel: 'Roll', - id: 'sroll', - value: %%%ROLL%%%, + id: 'sroll', + value: %%%ROLL%%%, name: 'sroll', - allowBlank:false + allowBlank:false },{ fieldLabel: 'Pitch', - id: 'spitch', - value: %%%PITCH%%%, + id: 'spitch', + value: %%%PITCH%%%, name: 'spitch', - allowBlank:false + allowBlank:false },{ fieldLabel: 'Yaw', - id: 'syaw', - value: %%%YAW%%%, + id: 'syaw', + value: %%%YAW%%%, name: 'syaw', - allowBlank:false + allowBlank:false },{ - xtype: 'button', - width: '100%', - text: 'Edit Orientation', - handler: orientationEditor - }] + xtype: 'button', + width: '100%', + text: 'Edit Orientation', + handler: orientationEditor + }] },{ - xtype: 'button', - text: 'Update', - width: '100%', - handler: updateLocationOrientation + xtype:'fieldset', + title: 'Diff Position', + collapsible: true, + autoHeight:true, + defaults: { + //width: 168 + }, + defaultType: 'numberfield', + items :[{ + fieldLabel: 'ΔX', + id: 'dx', + value: %%%DX%%%, + name: 'dx', + allowBlank:false + },{ + fieldLabel: 'ΔY', + id: 'dy', + value: %%%DY%%%, + name: 'dy', + allowBlank:false + },{ + fieldLabel: 'ΔZ', + id: 'dz', + value: %%%DZ%%%, + name: 'dz', + allowBlank:false + },{ + xtype: 'button', + width: '100%', + text: 'Set Position', + handler: setNodeLocationByDelta + }] + },{ + xtype: 'button', + text: 'Update', + width: '100%', + handler: updateLocationOrientation }] } \ No newline at end of file diff --git a/lib/controller/updateDetecttionProfile.php b/lib/controller/updateDetecttionProfile.php new file mode 100644 index 0000000..14c5f70 --- /dev/null +++ b/lib/controller/updateDetecttionProfile.php @@ -0,0 +1,40 @@ +Data['id'] > 1 ){ + if( isset( $_POST['NID'] ) ) $NID = intval($_POST['NID']); else $NID = 0; + if( isset( $_POST['PID'] ) ) $PID = intval($_POST['PID']); else $PID = 0; + if( $PID > 3 ) $PID = 3; + if( $NID ){ + $QS = "SELECT `aux_id` FROM `nodes` WHERE `id`={$NID}"; + $RR = $DATABASE->Query( $QS, false ); + $CSID = intval( $RR[0]['aux_id'] ); + if( $CSID ){ + if( isset( $_POST['MOFS'] ) ) $MOFS = intval( $_POST['MOFS'] ); else $MOFS = 10; + if( isset( $_POST['MDEL'] ) ) $MDEL = intval( $_POST['MDEL'] ); else $MDEL = 20; + if( isset( $_POST['MWIT'] ) ) $MWIT = intval( $_POST['MWIT'] ); else $MWIT = 1800; + if( isset( $_POST['MORD'] ) ) $MORD = intval( $_POST['MORD'] ); else $MORD = 5; + if( isset( $_POST['MSST'] ) ) $MSST = intval( $_POST['MSST'] ); else $MSST = 1; + if( isset( $_POST['MFLP'] ) ) $MFLP = intval( $_POST['MFLP'] ); else $MFLP = 16; + if( isset( $_POST['MSUN'] ) ) $MSUN = intval( $_POST['MSUN'] ); else $MSUN = 100; + if( isset( $_POST['MGP'] ) ) $MGP = intval( $_POST['MGP'] ); else $MGP = 8; + if( isset( $_POST['MSPK'] ) ) $MSPK = intval( $_POST['MSPK'] ); else $MSPK = 2; + if( isset( $_POST['SOFS'] ) ) $SOFS = intval( $_POST['SOFS'] ); else $SOFS = 10; + if( isset( $_POST['SDEL'] ) ) $SDEL = intval( $_POST['SDEL'] ); else $SDEL = 20; + if( isset( $_POST['SWIT'] ) ) $SWIT = intval( $_POST['SWIT'] ); else $SWIT = 1800; + if( isset( $_POST['SORD'] ) ) $SORD = intval( $_POST['SORD'] ); else $SORD = 5; + if( isset( $_POST['SSST'] ) ) $SSST = intval( $_POST['SSST'] ); else $SSST = 1; + if( isset( $_POST['SFLP'] ) ) $SFLP = intval( $_POST['SFLP'] ); else $SFLP = 16; + if( isset( $_POST['SSUN'] ) ) $SSUN = intval( $_POST['SSUN'] ); else $SSUN = 100; + if( isset( $_POST['SGP'] ) ) $SGP = intval( $_POST['SGP'] ); else $SGP = 8; + if( isset( $_POST['SSPK'] ) ) $SSPK = intval( $_POST['SSPK'] ); else $SSPK = 2; + $QS = "INSERT INTO `lrf_detection_profiles` SET `aux_id`={$CSID}, `profile_id`={$PID}, `master`=b'1', `order`={$MORD},`offset`={$MOFS},`delta`={$MDEL},`flip`={$MFLP},`width`={$MWIT},`sst`={$MSST},`sun`={$MSUN},`gp`={$MGP},`spikes`={$MSPK} ON DUPLICATE KEY UPDATE `order`={$MORD},`offset`={$MOFS},`delta`={$MDEL},`flip`={$MFLP},`width`={$MWIT},`sst`={$MSST},`sun`={$MSUN},`gp`={$MGP},`spikes`={$MSPK}"; + $DATABASE->Query( $QS ); + $QS = "INSERT INTO `lrf_detection_profiles` SET `aux_id`={$CSID}, `profile_id`={$PID}, `master`=b'0', `order`={$SORD},`offset`={$SOFS},`delta`={$SDEL},`flip`={$SFLP},`width`={$SWIT},`sst`={$SSST},`sun`={$SSUN},`gp`={$SGP},`spikes`={$SSPK} ON DUPLICATE KEY UPDATE `order`={$SORD},`offset`={$SOFS},`delta`={$SDEL},`flip`={$SFLP},`width`={$SWIT},`sst`={$SSST},`sun`={$SSUN},`gp`={$SGP},`spikes`={$SSPK}"; + $DATABASE->Query( $QS ); + $NCMD = 100+$PID; + $QS = "INSERT INTO `nodes_qcq` SET `node_id`={$NID}, `cmd`={$NCMD}"; + $DATABASE->Query( $QS ); + }; + }; + }; +?> \ No newline at end of file diff --git a/lib/controller/updateLocation.php b/lib/controller/updateLocation.php index 1eb1b25..85a11b2 100644 --- a/lib/controller/updateLocation.php +++ b/lib/controller/updateLocation.php @@ -1,55 +1,88 @@ Data['id'] > 1 ){ - $SITE = 0; $NID = 0; - if( isset( $_POST['SITE'] ) ) $SITE = intval($_POST['SITE']); - $TYP = intval($_POST['TYPE']); - if( isset( $_POST['NODE'] ) ) $NID = intval($_POST['NODE']); - $LAT = floatval( $_POST['LAT'] ); - $LON = floatval( $_POST['LON'] ); - if( $TYP > 0 ){ - $ALT = floatval( $_POST['ALT'] ); - if( $TYP > 1 ){ - $PITCH = floatval( $_POST['PITCH'] ); - $ROLL = floatval( $_POST['ROLL'] ); - $YAW = floatval( $_POST['YAW'] ); - }; - }; - if( $TYP == 1 ){ - $QS="UPDATE sites SET anchor_lat={$LAT}, anchor_lon={$LON}, anchor_alt={$ALT} WHERE id ={$SITE}"; - } else { - $QS = "SELECT * FROM nodes WHERE id ={$NID}"; - $Result = $DATABASE->Query( $QS, false ); - foreach( $Result as $CD ){ - switch( $CD['type'] ){ - case ARGUS_ALS_SENSOR: - case ARGUS_LFS_SENSOR: - case ARGUS_PLS_200_SENSOR: - case ARGUS_PLS_360_SENSOR: - case ARGUS_3D_SENSOR: - case ARGUS_NET_PLS_200: - if( $TYP > 0 ){ - $QS="UPDATE lrf_sensors SET lat={$LAT}, lon={$LON}, alt={$ALT}, roll={$ROLL}, pitch={$PITCH}, yaw={$YAW} WHERE id={$CD['aux_id']}"; - } else { - $QS="UPDATE lrf_sensors SET lat={$LAT}, lon={$LON} WHERE id={$CD['aux_id']}"; + $SITE = 0; $NID = 0; + if( isset( $_POST['SITE'] ) ) $SITE = intval($_POST['SITE']); + $TYP = intval($_POST['TYPE']); + if( isset( $_POST['NODE'] ) ) $NID = intval($_POST['NODE']); + $LAT = floatval( $_POST['LAT'] ); + $LON = floatval( $_POST['LON'] ); + if( $TYP > 0 ){ + $ALT = floatval( $_POST['ALT'] ); + if( $TYP == 2 ){ + $PITCH = floatval( $_POST['PITCH'] ); + $ROLL = floatval( $_POST['ROLL'] ); + $YAW = floatval( $_POST['YAW'] ); }; - break; - case ARGUS_ANALOG_STATIC_CAMERA: - case ARGUS_ANALOG_PTZ_CAMERA: - case ARGUS_IP_STATIC_CAMERA: - case ARGUS_IP_PTZ_CAMERA: - if( $TYP > 0 ){ - $QS="UPDATE cameras SET lat={$LAT}, lon={$LON}, alt={$ALT}, roll={$ROLL}, pitch={$PITCH}, yaw={$YAW} WHERE id={$CD['aux_id']}"; - } else { - $QS="UPDATE cameras SET lat={$LAT}, lon={$LON} WHERE id={$CD['aux_id']}"; - }; - break; }; - }; - echo "{ nid: {$NID} }"; - }; - $DATABASE->Query( $QS ); + if( $TYP != 1 ){ + $QS="SELECT `anchor_lat`, `anchor_lon`, `anchor_alt` FROM `sites` WHERE `id`={$SITE}"; + $R = $DATABASE->Query( $QS ); + $SLAT = $R[0]['anchor_lat']; + $SLON = $R[0]['anchor_lon']; + $SALT = $R[0]['anchor_alt']; + $A = new gPoint(); + $A->setLongLat( $SLON, $SLAT ); + $A->convertLLtoTM(); + $XC = $A->E(); + $YC = $A->N(); + $ZC = $A->Z(); + + $QS = "SELECT * FROM nodes WHERE id ={$NID}"; + $Result = $DATABASE->Query( $QS, false ); + $CD = $Result[0]; + switch( $CD['type'] ){ + case ARGUS_ALS_SENSOR: + case ARGUS_LFS_SENSOR: + case ARGUS_PLS_200_SENSOR: + case ARGUS_PLS_360_SENSOR: + case ARGUS_3D_SENSOR: + case ARGUS_NET_PLS_200: + $TBL = 'lrf_sensors'; + break; + case ARGUS_ANALOG_STATIC_CAMERA: + case ARGUS_ANALOG_PTZ_CAMERA: + case ARGUS_IP_STATIC_CAMERA: + case ARGUS_IP_PTZ_CAMERA: + $TBL = 'cameras'; + break; + }; + }; + switch( $TYP ){ + case 0://Short update + $CC = new gPoint(); + $CC->setLongLat( $LON, $LAT ); + $CC->convertLLtoTM(); + $XX = $CC->E(); + $YY = $CC->N(); + $ZO = $CC->Z(); + $DX = $XX - $XC; + $DY = $YY - $YC; + $QS="UPDATE `{$TBL}` SET `x`={$DX}, `y`={$DY} WHERE `id`={$CD['aux_id']}"; + break; + case 1://Anchore update + $QS="UPDATE `sites` SET `anchor_lat`={$LAT}, `anchor_lon`={$LON}, `anchor_alt`={$ALT} WHERE `id`={$SITE}"; + break; + case 2://long update + $CC = new gPoint(); + $CC->setLongLat( $LON, $LAT ); + $CC->convertLLtoTM(); + $XX = $CC->E(); + $YY = $CC->N(); + $ZO = $CC->Z(); + $DX = $XX - $XC; + $DY = $YY - $YC; + $QS="UPDATE `{$TBL}` SET `x`={$XX}, `y`={$YY}, `z`={$ALT}, `x_rot`={$ROLL}, `y_rot`={$PITCH}, `z_rot`={$YAW} WHERE `id`={$CD['aux_id']}"; + break; + case 3://update by diff -> no orientation + $QS="UPDATE `{$TBL}` SET `x`={$LAT}, `y`={$LON}, `z`={$ALT} WHERE `id`={$CD['aux_id']}"; + break; + }; + $DATABASE->Query( $QS ); + echo "{ nid: {$NID}, QS:'{$QS}' }"; } else { - echo "[]"; + echo "[]"; }; ?> \ No newline at end of file diff --git a/lib/controller/updateLrfSettings.php b/lib/controller/updateLrfSettings.php deleted file mode 100644 index 9dc38ac..0000000 --- a/lib/controller/updateLrfSettings.php +++ /dev/null @@ -1,28 +0,0 @@ -Data['id'] > 1 ){ - if( isset( $_POST['SENSOR'] ) ){ - $S_ID = intval($_POST['SENSOR']); - if( $S_ID ){ - $NAME = $DATABASE->escape($_POST['SNAME']); - if(isset($_POST['SADDR'])){ - $ADDR = intval($_POST['SADDR']); - $RANGE = floatval($_POST['SRANGE']); - $QS="UPDATE `lrf_sensors` SET `device_id`={$ADDR}, `max_range`={$RANGE} WHERE id={$S_ID}"; - $DATABASE->Query( $QS ); - //$QS="UPDATE `lrf_sensors` SET `device_id`={$ADDR}, `max_range`={$RANGE}, `label`='{$NAME}' WHERE id={$S_ID}"; - //$DATABASE->Query( $QS ); - } else { - $IP= $DATABASE->escape($_POST['SIPADDR']); - $NAME = $DATABASE->escape($_POST['SNAME']); - $QS="UPDATE `lrf_sensors` SET `ip_address`='{$IP}' WHERE id={$S_ID}"; - $DATABASE->Query( $QS ); - //$QS="UPDATE `lrf_sensors` SET `ip_address`='{$IP}', `label`='{$NAME}' WHERE id={$S_ID}"; - //$DATABASE->Query( $QS ); - }; - $QS="UPDATE `nodes` SET `name`='{$NAME}' WHERE `aux_id`={$S_ID}"; - $DATABASE->Query( $QS ); - }; - }; - }; -?> \ No newline at end of file diff --git a/lib/controller/updateLrfSettings_baseshift.php b/lib/controller/updateLrfSettings_baseshift.php new file mode 100644 index 0000000..0357234 --- /dev/null +++ b/lib/controller/updateLrfSettings_baseshift.php @@ -0,0 +1,43 @@ +Data['id'] > 1 ){ + $NodeID = intval($_POST['NID']); + //$Master = intval($_POST['MST']); + $QS = "SELECT * FROM nodes WHERE id={$NodeID}"; + $Data = array(); + $result = $DATABASE->Query( $QS, false ); + if( count( $result ) ){ + $T = $result[0]; + $AID = $T['aux_id']; + if(isset($_POST['BASH'])){ + $BSH = intval( $_POST['BASH'] ); + $QS = "UPDATE `lrf_sensors` SET `base_shift`={$BSH} WHERE `id`={$AID}"; + $DATABASE->Query( $QS ); + }; + //if( isset( $_POST['SENSOR'] ) ){ + //$S_ID = intval($_POST['SENSOR']); + //if( $S_ID ){ + /* + $NAME = $DATABASE->escape($_POST['SNAME']); + if(isset($_POST['SADDR'])){ + $ADDR = intval($_POST['SADDR']); + $RANGE = floatval($_POST['SRANGE']); + $QS="UPDATE `lrf_sensors` SET `device_id`={$ADDR}, `max_range`={$RANGE} WHERE id={$S_ID}"; + $DATABASE->Query( $QS ); + //$QS="UPDATE `lrf_sensors` SET `device_id`={$ADDR}, `max_range`={$RANGE}, `label`='{$NAME}' WHERE id={$S_ID}"; + //$DATABASE->Query( $QS ); + } else { + $IP= $DATABASE->escape($_POST['SIPADDR']); + $NAME = $DATABASE->escape($_POST['SNAME']); + $QS="UPDATE `lrf_sensors` SET `ip_address`='{$IP}' WHERE id={$S_ID}"; + $DATABASE->Query( $QS ); + //$QS="UPDATE `lrf_sensors` SET `ip_address`='{$IP}', `label`='{$NAME}' WHERE id={$S_ID}"; + //$DATABASE->Query( $QS ); + }; + $QS="UPDATE `nodes` SET `name`='{$NAME}' WHERE `aux_id`={$S_ID}"; + $DATABASE->Query( $QS ); + */ + + }; + }; +?> \ No newline at end of file diff --git a/lib/controller/updateResource.php b/lib/controller/updateResource.php new file mode 100644 index 0000000..a1ab794 --- /dev/null +++ b/lib/controller/updateResource.php @@ -0,0 +1,35 @@ +Data['id'] > 1 ){ + $EID = intval( $_POST['RID'] ); + $QS = "SELECT * FROM resources WHERE id = {$EID}"; + $Result = $DATABASE->Query( $QS, false ); + if( count( $Result ) ){ + $R = $Result[0]; + switch( $R['type'] ){ + case 1:{ + $UART_ID = intval($R['aux_id']); + $UART_SPEED = intval($_POST['USPD']); + $UART_BIT = intval($_POST['UBIT']); + $UART_STOP = floatval($_POST['USTP']); + switch( strtoupper( substr( $_POST['UPAR'], 1 ) ) ){ + case 'E': $UART_PARITY = 'E'; break; + case 'O': $UART_PARITY = 'O'; break; + default: + $UART_PARITY = 'N'; + }; + $QS="UPDATE `uart_settings` SET `speed`={$UART_SPEED}, `bit`={$UART_BIT}, `parity`='{$UART_PARITY}', `stop_bit`={$UART_STOP} WHERE id ={$UART_ID}"; + $DATABASE->Query( $QS ); + break; + }; + }; + $Data['status'] = 1; + } else { + $Data['msg']='Wrong Resource'; + }; + } else { + $Data['msg']='Access Error!'; + }; + echo json_encode( $Data ); +?> \ No newline at end of file diff --git a/lib/controller/uploadDeviceMask.php b/lib/controller/uploadDeviceMask.php index c82b4dd..0e783f9 100644 --- a/lib/controller/uploadDeviceMask.php +++ b/lib/controller/uploadDeviceMask.php @@ -7,45 +7,55 @@ $LRFID = intval($_POST['LID']); $SERIAL = json_decode( $_POST['MDTA'] ); $MHEI = intval($_POST['MIH']); + $MWID = intval($_POST['MIW']); $SHX = intval($_POST['MSHX']); $SHY = intval($_POST['MSHY']); + if( isset( $_POST['DSTD'] ) ) $DSTS = intval( $_POST['DSTD'] ); else $DSTS = 0; $QS = "SELECT * FROM nodes WHERE id={$NodeID} "; $Data = array(); $NPC = 0; $SCHEDULE_JOB = 0; // NOJOB $result = $DATABASE->Query( $QS, false ); + if( $SHX == $SHY ) $Process = 0; else $Process = 1; if( count( $result ) && $MHEI ){ - $SCALE = 288.0 / floatval( $MHEI ); + if( $Process == 1 ){ + $SCALE = 288.0 / floatval( $MHEI ); + } else { + $SCALE = 4096.0 / floatval( $MHEI ); + }; $T = $result[0]; $AID = $T['aux_id']; - $QS = "SELECT * FROM `lrf_masks` WHERE `sensor_id`={$AID} AND `lrf_id`={$LRFID} AND `layer`={$LayerID}"; + $QS = "SELECT id FROM `lrf_masks` WHERE `sensor_id`={$AID} AND `lrf_id`={$LRFID} AND `layer`={$LayerID}"; $result = $DATABASE->Query( $QS, false ); $CV = array(); + $MID = 0; if( count($result) == 0 ){ // No Masks Where Defined $QS = "INSERT INTO `lrf_masks` SET `sensor_id`={$AID}, `lrf_id`={$LRFID}, `layer`={$LayerID}"; $DATABASE->Query( $QS, false ); $MID = $DATABASE->getLastInsertID(); } else { - $CM = $result[0]; - $QS = "SELECT * FROM `lrf_mask_vertexes` WHERE `mask_id`={$CM['id']}"; + $MID = $result[0]['id']; + $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`={$CM['id']}"; + $QS = "DELETE FROM `lrf_mask_vertexes` WHERE `mask_id`={$MID}"; $DATABASE->Query( $QS ); - //$QS = "DELETE FROM `lrf_masks` WHERE `mask_id`={$CM['id']}"; - //$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; - $B = $CCC[1]->fillColor[2] * 255; - $QS = "INSERT INTO `lrf_mask_vertexes` SET `mask_id`={$CM['id']}, `r`={$R}, `g`={$G}, `b`={$B}"; - $DATABASE->Query( $QS, false ); - $VID = $DATABASE->getLastInsertID(); - foreach( $CCC[1]->segments as $SS ){ + }; + + + $SCHEDULE_JOB = 1; // Clear Mask + foreach( $SERIAL[0][1]->children as $CCC ){ + $R = $CCC[1]->fillColor[0] * 255; + $G = $CCC[1]->fillColor[1] * 255; + $B = $CCC[1]->fillColor[2] * 255; + $QS = "INSERT INTO `lrf_mask_vertexes` SET `mask_id`={$MID}, `r`={$R}, `g`={$G}, `b`={$B}"; + $DATABASE->Query( $QS, false ); + $VID = $DATABASE->getLastInsertID(); + foreach( $CCC[1]->segments as $SS ){ + if( $Process == 1 ){ if( count( $SS ) == 2 ){ $X = intval( $SCALE * floatval( intval( $SS[0] ) - $SHX ) ); $Y = intval( $SCALE * floatval( intval( $SS[1] ) - $SHY ) ); @@ -57,24 +67,48 @@ if( $X > 2304 ) $X = 2304; if( $Y < 0 ) $Y = 0; if( $Y > 288 ) $Y = 288; - $QS = "INSERT INTO `lrf_mask_vertex_points` SET `vertex_id`={$VID}, `x`={$X}, `y`={$Y}"; - $DATABASE->Query( $QS, false ); - $NPC++; - $SCHEDULE_JOB = 2; // Update - Set Mask + } else { + if( count( $SS ) == 2 ){ + $X = intval( $SCALE * floatval( intval( $SS[0] ) - $SHX ) ) - 2047; + $Y = intval( $SCALE * floatval( intval( $SS[1] ) - $SHY ) ) - 2047; + } else { + $X = intval( $SCALE * floatval( intval( $SS[0][0] ) - $SHX ) ) - 2047; + $Y = intval( $SCALE * floatval( intval( $SS[0][1] ) - $SHY ) ) - 2047; + }; + if( $X < -2047 ) $X = -2047; + if( $X > 2047 ) $X = 2047; + if( $Y < -2047 ) $Y = -2047; + if( $Y > 2047 ) $Y = 2047; }; + $QS = "INSERT INTO `lrf_mask_vertex_points` SET `vertex_id`={$VID}, `x`={$X}, `y`={$Y}"; + $DATABASE->Query( $QS, false ); + $NPC++; + $SCHEDULE_JOB = 2; // Update - Set Mask }; }; switch( $SCHEDULE_JOB ){ case 1:{ - $CMD = 75+$LayerID; - $QS = "INSERT INTO `nodes_qcq` SET node_id={$NodeID}, `cmd`={$CMD}, `parameter`='{$LRFID}'"; - $DATABASE->Query( $QS, false ); + // 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}"; + $DATABASE->Query( $QS ); break; }; case 2:{ - $CMD = 60+$LayerID; - $QS = "INSERT INTO `nodes_qcq` SET node_id={$NodeID}, `cmd`={$CMD}, `parameter`='{$LRFID}'"; - $DATABASE->Query( $QS, false ); + // Don't Send To Device + if( $DSTS == 0 ){ + $CMD = 67;//60+$LayerID; + $QS = "INSERT INTO `nodes_qcq` SET node_id={$NodeID}, `cmd`={$CMD}, `parameter`='{$LRFID}'"; + echo $QS; + $DATABASE->Query( $QS, false ); + }; break; }; }; diff --git a/lib/defines.php b/lib/defines.php index c796685..86559ee 100644 --- a/lib/defines.php +++ b/lib/defines.php @@ -1,6 +1,6 @@ Data['id'];?>', 'SID': '' @@ -212,7 +212,6 @@ function discoverOnvifSources(){ }); }; - function loadCameraSettings( SC ){ Ext.Ajax.request({ url: '/lib/controller/getCameraSettings.php', @@ -243,7 +242,7 @@ function loadCameraSettings( SC ){ function preloadOnvifCredentials( SC ){ showIPCamPropDialog(); Ext.Ajax.request({ - url: '/lib/controller/getOnvifCredentials.php', + url: '/lib/controller/getIpCamCredentials.php', params: { CID: SC, UID: , @@ -254,6 +253,7 @@ function preloadOnvifCredentials( SC ){ if( data.success ){ Ext.getCmp('cam_login').setValue( data.login ); Ext.getCmp('cam_password').setValue( data.password ); + Ext.getCmp('cam_auth_mode').setValue( data.auth_mode ); Ext.getCmp('acm_btn').enable(); Ext.getCmp('cac_tab').disable(); Ext.getCmp('lens_tab').enable(); @@ -267,6 +267,7 @@ function preloadOnvifCredentials( SC ){ } else { Ext.getCmp('cam_login').setValue(''); Ext.getCmp('cam_password').setValue(''); + Ext.getCmp('cam_auth_mode').setValue( 0 ); Ext.getCmp('acm_btn').disable(); Ext.getCmp('cac_tab').enable(); Ext.getCmp('lens_tab').disable(); @@ -289,6 +290,7 @@ function preloadOnvifCredentials( SC ){ failure: function( response, opts ) { Ext.getCmp('cam_login').setValue(''); Ext.getCmp('cam_password').setValue(''); + Ext.getCmp('cam_auth_mode').setValue( 0 ); Ext.getCmp('cac_tab').enable(); Ext.getCmp('lens_tab').disable(); Ext.getCmp('str_tab').disable(); @@ -299,7 +301,7 @@ function preloadOnvifCredentials( SC ){ }); }; -function discoverOnvifProfiles( CamID, camUser, camPasswd ){ +function discoverOnvifProfiles( CamID, camUser, camPasswd, Auth ){ Ext.Ajax.request({ url: '/lib/controller/listAndDiscoverOnvifProfiles.php', params: { @@ -308,7 +310,8 @@ function discoverOnvifProfiles( CamID, camUser, camPasswd ){ SID: '', CID: CamID, GUG: camUser, - GOG: camPasswd + GOG: camPasswd, + GAT: Auth }, success: function( response, opts ){ var data = Ext.decode( response.responseText ); @@ -365,6 +368,20 @@ function showIPCamPropDialog(){ xtype: 'textfield', fieldLabel: 'GetLabel('_CAM_MAP_NAME_');?>' //width: 200 + },{ + xtype: 'combo', + fieldLabel: 'GetLabel('_CTL_SERVER_NODE_');?>', + lazyRender: true, + id: 'cam_server_id', + //width: 200, + disabled: false, + forceSelection: true, + triggerAction: 'all', + editable: false, + disableKeyFilter: true, + store: ServerListStore, + valueField: 'server_id', + displayField: 'server_name' },{ xtype: 'spacer', height: 5 @@ -409,6 +426,39 @@ function showIPCamPropDialog(){ width: 200 },{ html: ' ' + },{ + html: '

GetLabel('_AUTH_MODE_0_');?>

' + },{ + id: 'cam_auth_mode', + xtype: 'combo', + lazyRender: true, + mode: 'local', + forceSelection: true, + triggerAction: 'all', + editable: false, + disableKeyFilter: true, + store: new Ext.data.ArrayStore({ + fields: ['mode','mode_txt'], + data: [ + [0,'BASIC'], + [1,'DIGEST'], + [2,'DIGEST_IE'], + [3,'BEARER'], + [4,'NEGOTIATE'], + [5,'NTLM'], + [6,'NTLM_WB'], + [7,'ANY'], + [8,'ANYSAFE'], + [9,'ONLY'], + [10,'AWS_SIGV4'] + ] + }), + valueField: 'mode', + displayField: 'mode_txt', + value: 0, + width: 200 + },{ + html: ' ' },{ html: ' ' },{ @@ -419,7 +469,8 @@ function showIPCamPropDialog(){ Ext.getCmp('cac_tab').getEl().mask("Please wait...","x-mask-loading"); var User = Ext.getCmp('cam_login').getValue(); var Passwd = Ext.getCmp('cam_password').getValue(); - discoverOnvifProfiles( SelectedCam, User, Passwd ); + var Auth = Ext.getCmp('cam_auth_mode').getValue(); + discoverOnvifProfiles( SelectedCam, User, Passwd, Auth ); } },{ html: ' ' @@ -833,6 +884,7 @@ function showIPCamPropDialog(){ var CIMAGER = Ext.getCmp('sens_size').getValue(); var CLFL = Ext.getCmp('lens_fl').getValue(); var CZOOM = Ext.getCmp('zoom_val').getValue(); + var SRVID = Ext.getCmp('cam_server_id').getValue(); var AllOK = true; if( CLAB == '' ) { AllOK = false; @@ -854,6 +906,16 @@ function showIPCamPropDialog(){ }); return; }; + if( SRVID == 0 ){ + AllOK = false; + Ext.Msg.show({ + title:'Data Error!', + msg: 'Please Select Server to Connect Camera!', + buttons: Ext.Msg.OK, + icon: Ext.MessageBox.INFO + }); + return; + }; if( ( SelectedCamTYPE == 11 || SelectedCamTYPE == 13 ) && CPTZP == 0 ){ AllOK = false; Ext.Msg.show({ @@ -893,6 +955,7 @@ function showIPCamPropDialog(){ SID: '', CID: SelectedCam, STREAM: SelectedSource, + SRVID: SRVID, LAB: CLAB, UART: CPTZU, PROTOID: CPTZID, @@ -962,6 +1025,20 @@ function showAnalCamPropDialog(){ xtype: 'textfield', fieldLabel: 'GetLabel('_CAM_MAP_NAME_');?>' //width: 200 + },{ + xtype: 'combo', + fieldLabel: 'GetLabel('_CTL_SERVER_NODE_');?>', + lazyRender: true, + id: 'cam_server_id', + //width: 200, + disabled: false, + forceSelection: true, + triggerAction: 'all', + editable: false, + disableKeyFilter: true, + store: ServerListStore, + valueField: 'server_id', + displayField: 'server_name' },{ xtype: 'spacer', height: 5 @@ -1306,6 +1383,7 @@ function showAnalCamPropDialog(){ var CIMAGER = Ext.getCmp('sens_size').getValue(); var CMINF = Ext.getCmp('min_foc').getValue(); var CMAXF = Ext.getCmp('max_foc').getValue(); + var SRVID = Ext.getCmp('cam_server_id').getValue(); var AllOK = true; if( CLAB == '' ) { AllOK = false; @@ -1327,6 +1405,16 @@ function showAnalCamPropDialog(){ }); return; }; + if( SRVID == 0 ){ + AllOK = false; + Ext.Msg.show({ + title:'Data Error!', + msg: 'Please Select Server to Connect Camera!', + buttons: Ext.Msg.OK, + icon: Ext.MessageBox.INFO + }); + return; + }; if( ( SelectedCamTYPE == 11 || SelectedCamTYPE == 13 ) && CPTZP == 0 ){ AllOK = false; Ext.Msg.show({ @@ -1366,6 +1454,7 @@ function showAnalCamPropDialog(){ SID: '', CID: SelectedCam, STREAM: SelectedSource, + SRVID: SRVID, LAB: CLAB, UART: CPTZU, PROTOID: CPTZID, @@ -1380,11 +1469,21 @@ function showAnalCamPropDialog(){ TYPE: SelectedCamTYPE }, success: function( response, opts ){ - reloadNetworkData(); - addAnalogCamDialog.close(); - addAnalogCamDialog = null; - connectAnalCamDialog.close(); - connectAnalCamDialog = null; + var data = Ext.decode(response.responseText); + if( data.success ){ + reloadNetworkData(); + addAnalogCamDialog.close(); + addAnalogCamDialog = null; + connectAnalCamDialog.close(); + connectAnalCamDialog = null; + } else { + Ext.Msg.show({ + title:'Data Error!', + msg: data.msg, + buttons: Ext.Msg.OK, + icon: Ext.MessageBox.ERROR + }); + }; //loadSystemEditor(); }, failure: failureAJAXFunction diff --git a/lib/javascript/jsapi_dynamic/rgoose_dashboard.js b/lib/javascript/jsapi_dynamic/rgoose_dashboard.js index cddd3c4..29c2524 100644 --- a/lib/javascript/jsapi_dynamic/rgoose_dashboard.js +++ b/lib/javascript/jsapi_dynamic/rgoose_dashboard.js @@ -613,10 +613,14 @@ function fetchSiteStatus(){ setDonatStatus( data.nodes[i].id, 0, data.nodes[i].cpu5 ); setDonatStatus( data.nodes[i].id, 1, data.nodes[i].mem ); setDonatStatus( data.nodes[i].id, 2, data.nodes[i].disk ); + document.getElementById('status_'+data.nodes[i].id+'_txt').innerHTML="Server is Online"; + document.getElementById('status_'+data.nodes[i].id+'_img').src = "/style/icons/icons/accept.png"; } else { setDonatStatus( data.nodes[i].id, 0, -1 ); setDonatStatus( data.nodes[i].id, 1, -1 ); setDonatStatus( data.nodes[i].id, 2, -1 ); + document.getElementById('status_'+data.nodes[i].id+'_txt').innerHTML="Server is Offline"; + document.getElementById('status_'+data.nodes[i].id+'_img').src = "/style/icons/icons/stop.png"; }; }; // Sesors @@ -963,7 +967,7 @@ function showServerToolBox( ServerNodeId ){ scale: 'large', iconAlign: 'left', handler: function(){ - doDeviceOperation( currentNodeID, 250 ); + doDeviceOperation( currentNodeID, 250,'', true ); } },{ xtype: 'button', @@ -974,16 +978,19 @@ function showServerToolBox( ServerNodeId ){ scale: 'large', iconAlign: 'left', handler: function(){ - doDeviceOperation( currentNodeID, 251 ); + doDeviceOperation( currentNodeID, 251,'', true ); } },{ xtype: 'button', - text: 'Clear Site', + text: 'Sync Time With Browser', width: '100%', textAlign: 'left', - iconCls: 'server_btn_restart', + iconCls: 'server_btn_timeinit', scale: 'large', - iconAlign: 'left' + iconAlign: 'left', + handler: function(){ + doDeviceOperation( currentNodeID, 252, ((new Date())/1000), true ); + } }] }); }; @@ -995,15 +1002,248 @@ var deviceCtrlNode = ''; function showSensorToolBox( NodeID ){ currentNodeID = NodeID; deviceCtrlNode = NodeID + ':0'; -Data['access']>4 ) $ColSpan = 4; else $ColSpan = 3; ?> if( detectionProfileWindow == null ){ detectionProfileWindow = new Ext.Window({ title: 'GetLabel('_DEV_CTLPANEL_SHRT_');?>', modal: true, - width: , + width: 340, height: 328, + autoScroll: 'auto', closeAction: 'hide', - items:[] + resizable: false, + items:[{ + xtype: 'panel', + title: 'GetLabel('_SPEC_FUNCTI_');?>', + height: 95, + id: 'sf_panel', + frame: true, + flex: 1, + layout: 'vbox', + hidden: true, + items:[{ + xtype: 'button', + text: 'Resolve Trouble', + width: '100%', + iconCls: 'ctrl_panel_cog', + scale: 'large', + iconAlign: 'left', + handler: function(){ + detectionProfileWindow.hide(); + resolveDeviceMistmatch( deviceCtrlNode ); + } + }] + },{ + xtype: 'panel', + title: 'GetLabel('_DET_GENWORKS_');?>', + height: 193, + frame: true, + flex: 1, + layout: 'vbox', + items:[{ + xtype: 'button', + width: '100%', + text: 'Clear Alarm', + scale: 'large', + iconCls: 'ctrl_panel_clean', + iconAlign: 'left', + handler: function(){ + clearDeviceEvents( deviceCtrlNode ); + } + },{ + xtype: 'button', + width: '100%', + text: 'Draw Background', + scale: 'large', + iconCls: 'ctrl_panel_drawscan', + iconAlign: 'left', + handler: function(){ + doDeviceOperation( deviceCtrlNode, 3 ); + } + },{ + xtype: 'button', + width: '100%', + text: 'Force Study Background', + scale: 'large', + iconCls: 'ctrl_panel_study', + iconAlign: 'left', + handler: function(){ + doDeviceOperation( deviceCtrlNode, 2 ); + } + },{ + xtype: 'button', + width: '100%', + buttonAlign: 'left', + //text: '
Button 1
', + text: 'Force Reset Sensor', + scale: 'large', + iconCls: 'ctrl_panel_reset', + iconAlign: 'left', + handler: function(){ + doDeviceOperation( deviceCtrlNode, 1 ); + } + }] + },{ + xtype: 'panel', + title: 'Zone Masking Management', + height: 140, + frame: true, + flex: 1, + layout: 'vbox', + items:[{ + xtype: 'button', + text: 'Mask Editor', + id: 'DMED', + width: '100%', + handler: function(){ + showMaskEditor( true, 0, deviceCtrlNode ); + } + },{ + xtype: 'spacer', + height: 6 + },{ + xtype: 'panel', + frame: false, + border: false, + flex: 1, + width: '100%', + height: 40, + layout: 'hbox', + items:[{ + xtype: 'button', + enableToggle: true, + width: '20%', + scale: 'large', + id: 'mz_btn_0', + iconCls: 'mask_zone1_btn', + iconAlign: 'top', + pressed: false, + disabled: true, + handler: function(){ + Ext.getCmp('MAPPLY').enable(); + } + },{ + xtype: 'button', + enableToggle: true, + width: '20%', + scale: 'large', + id: 'mz_btn_1', + iconCls: 'mask_zone2_btn', + iconAlign: 'top', + pressed: false, + disabled: true, + handler: function(){ + Ext.getCmp('MAPPLY').enable(); + } + },{ + xtype: 'button', + enableToggle: true, + width: '20%', + scale: 'large', + id: 'mz_btn_2', + iconCls: 'mask_zone3_btn', + iconAlign: 'top', + pressed: false, + disabled: true, + handler: function(){ + Ext.getCmp('MAPPLY').enable(); + } + },{ + xtype: 'button', + enableToggle: true, + width: '20%', + scale: 'large', + id: 'mz_btn_3', + iconCls: 'mask_zone4_btn', + iconAlign: 'top', + pressed: false, + disabled: true, + handler: function(){ + Ext.getCmp('MAPPLY').enable(); + } + },{ + xtype: 'button', + enableToggle: true, + width: '20%', + scale: 'large', + id: 'mz_btn_4', + iconCls: 'mask_zone5_btn', + iconAlign: 'top', + pressed: false, + disabled: true, + handler: function(){ + Ext.getCmp('MAPPLY').enable(); + } + }] + },{ + xtype: 'spacer', + height: 6 + },{ + xtype: 'button', + text: 'Apply Zone Masks', + id: 'MAPPLY', + disabled: true, + width: '100%', + handler: function(){ + + } + }] + },{ + xtype: 'panel', + title: 'GetLabel('_DET_SENSITIVITY_');?>', + height: 95, + frame: true, + flex: 1, + layout: 'hbox', + items:[Data['access']>4 ){ + ?>{ + xtype: 'button', + text: 'Factory', + id: 'DDSPBTN0', + width: 80, + iconCls: 'detection_btn_factory', + enableToggle: true, + toggleGroup: 'det_sens_btn_grp', + disabled: true, + scale: 'large', + iconAlign: 'top' + },{ + xtype: 'button', + text: 'Low', + id: 'DDSPBTN1', + width: 80, + iconCls: 'detection_btn_low', + enableToggle: true, + toggleGroup: 'det_sens_btn_grp', + disabled: true, + scale: 'large', + iconAlign: 'top' + },{ + xtype: 'button', + text: 'Meduim', + id: 'DDSPBTN2', + width: 80, + iconCls: 'detection_btn_medium', + enableToggle: true, + toggleGroup: 'det_sens_btn_grp', + disabled: true, + scale: 'large', + iconAlign: 'top' + },{ + xtype: 'button', + text: 'High', + id: 'DDSPBTN3', + width: 80, + iconCls: 'detection_btn_high', + enableToggle: true, + toggleGroup: 'det_sens_btn_grp', + disabled: true, + scale: 'large', + iconAlign: 'top' + }] + }] }); }; detectionProfileWindow.show(); @@ -1022,168 +1262,36 @@ function showSensorToolBox( NodeID ){ var data = Ext.decode( response.responseText ); myMask.hide(); detectionProfileWindow.setTitle( '['+data.name + '] GetLabel('_DEV_CTLPANEL_SHRT_');?>'); - detectionProfileWindow.removeAll( true ); - //detectionProfileWindow.setSize( data.width, data.height ); - if( data.additional !== 'undefined' ){ - var addi = Ext.decode( data.additional ); - detectionProfileWindow.add( addi ); - }; + if(data.masks_array != 'undefined' ){ + for( i = 0; i < 5; i++ ){ + var cE = Ext.getCmp('mz_btn_'+i ); + if( data.masks_array[i]=='E'){ + cE.enable(); + cE.toggle( true, true ); + } else { + cE.toggle( false, true ); + if( data.masks_array[i]=='D' ){ + cE.enable(); + } else { + cE.disable(); + }; + }; + }; + }; if( data.data_status == 3 ){ - detectionProfileWindow.add({ - xtype: 'panel', - layout: 'table', - layoutConfig: { - columns: - }, - items:[{ - xtype: 'spacer', - height: 30, - style: { - marginTop: '13px' - }, - html: '
GetLabel('_DET_SENSITIVITY_');?>
', - colspan: - },Data['access']>4 ){ - ?>{ - xtype: 'button', - text: 'Factory', - id: 'DDSPBTN0', - width: 80, - iconCls: 'detection_btn_factory', - enableToggle: true, - toggleGroup: 'det_sens_btn_grp', - disabled: true, - scale: 'large', - iconAlign: 'top' - }, 1 ){ + for( i=0; i < data.profiles.length; i++ ){ + Ext.getCmp('DDSPBTN'+i ).enable(); + if( i == data.profile_id ) Ext.getCmp('DDSPBTN'+i ).toggle( true, false ); }; - ?>{ - xtype: 'button', - text: 'Low', - id: 'DDSPBTN1', - width: 80, - iconCls: 'detection_btn_low', - enableToggle: true, - toggleGroup: 'det_sens_btn_grp', - disabled: true, - scale: 'large', - iconAlign: 'top' - },{ - xtype: 'button', - text: 'Meduim', - id: 'DDSPBTN2', - width: 80, - iconCls: 'detection_btn_medium', - enableToggle: true, - toggleGroup: 'det_sens_btn_grp', - disabled: true, - scale: 'large', - iconAlign: 'top' - },{ - xtype: 'button', - text: 'High', - id: 'DDSPBTN3', - width: 80, - iconCls: 'detection_btn_high', - enableToggle: true, - toggleGroup: 'det_sens_btn_grp', - disabled: true, - scale: 'large', - iconAlign: 'top' - }] - }); - for( i=0; i < data.profiles.length; i++ ){ - Ext.getCmp('DDSPBTN'+data.profiles[i] ).enable(); - if( i == data.profile_id ) Ext.getCmp('DDSPBTN'+data.profiles[i] ).toggle(); + } else { + Ext.getCmp('DDSPBTN0').toggle( true, false ); + Ext.getCmp('DDSPBTN0').disable(); }; } else if( data.data_status == 4 ){ - detectionProfileWindow.add({ - xtype: 'panel', - //layout: 'fit', - //layoutConfig: { - // columns: 3 - //}, - items:[{ - xtype: 'spacer', - height: 40, - //colspan: 3, - style: { - marginTop: '20px' - }, - html: '
GetLabel('_DET_SENSITIVITY_');?>
', - }Data['access']>4 ){ - ?>,{ - xtype: 'button', - text: 'Resolve Trouble', - width: '100%', - //colspan: 3, - iconCls: 'ctrl_panel_cog', - scale: 'large', - iconAlign: 'left', - handler: function(){ - detectionProfileWindow.hide(); - resolveDeviceMistmatch( deviceCtrlNode ); - } - }] - }); + Ext.getCmp('sf_panel').show(); }; - detectionProfileWindow.add({ - xtype: 'spacer', - height: 30, - style: { - marginTop: '13px' - }, - html: '
GetLabel('_DET_GENWORKS_');?>
', - }); - detectionProfileWindow.add({ - xtype: 'button', - width: '100%', - text: 'Clear Alarm', - scale: 'large', - iconCls: 'ctrl_panel_clean', - iconAlign: 'left' - }); - detectionProfileWindow.add({ - xtype: 'button', - width: '100%', - text: 'Draw Background', - scale: 'large', - iconCls: 'ctrl_panel_drawscan', - iconAlign: 'left', - handler: function(){ - doDeviceOperation( deviceCtrlNode, 3 ); - } - }); - detectionProfileWindow.add({ - xtype: 'button', - width: '100%', - text: 'Force Study Background', - scale: 'large', - iconCls: 'ctrl_panel_study', - iconAlign: 'left', - handler: function(){ - doDeviceOperation( deviceCtrlNode, 2 ); - } - }); - detectionProfileWindow.add({ - xtype: 'button', - width: '100%', - buttonAlign: 'left', - //text: '
Button 1
', - text: 'Force Reset Sensor', - scale: 'large', - iconCls: 'ctrl_panel_reset', - iconAlign: 'left', - handler: function(){ - doDeviceOperation( deviceCtrlNode, 1 ); - } - }); detectionProfileWindow.doLayout(); - //detectionProfileWindow.show(); }, failure: failureAJAXFunction }); diff --git a/lib/javascript/jsapi_dynamic/rgoose_devices.js b/lib/javascript/jsapi_dynamic/rgoose_devices.js index 4b5bece..2f23bb4 100644 --- a/lib/javascript/jsapi_dynamic/rgoose_devices.js +++ b/lib/javascript/jsapi_dynamic/rgoose_devices.js @@ -25,6 +25,30 @@ var UartListStore = new Ext.data.JsonStore({ }) }); +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', @@ -379,6 +403,20 @@ function doDeviceOperation( NodeID, OpCode, Param='', nowait=false ){ }); }; +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; @@ -434,6 +472,61 @@ function loadFullLRF1D2Data( NodeID ){ }); }; +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({ @@ -814,6 +907,448 @@ function LRF1D2_settings(){ }; 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(){ @@ -1300,7 +1835,7 @@ function onMouseDrag(event) { // path.position += event.delta; //} } -var absDrawMapSizes = [[2000,2000],[2304,288]]; +var absDrawMapSizes = [[4096,4096],[2304,288]]; var deviceMapScaling = 1.0; var deviceMapTopShift = 100; var deviceMapLeftShift = 100; @@ -1308,8 +1843,39 @@ 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 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 { @@ -1364,7 +1930,9 @@ function showMaskEditor( fromDevTool, DevType, NodeID ){ id: 'me_b_newp', enableToggle: true, toggleGroup: 'me_topbar_grp', + pressed: false, handler: function( btn ){ + //alert("koko"); if( btn.pressed ) setMaskEditorMode( 0 ); } },{ @@ -1385,6 +1953,71 @@ function showMaskEditor( fromDevTool, DevType, NodeID ){ //alert( 'ClearMask' ); }; } + },{ + text:'1', + enableToggle: true, + toggleGroup: 'me_maskbar_grp', + 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', + 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', + 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', + 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', + handler: function(){ + if( cMaskID != 4 ){ + SaveCurrentMask( NodeID, cMaskID ); + }; + MaskProject = new paper.Project( canvas ); + paper.view.draw(); + cMaskID = 4; + loadDeviceMask( NodeID, cMaskID ); + } }], buttons:[{ text: 'Cancel', @@ -1421,7 +2054,17 @@ function showMaskEditor( fromDevTool, DevType, NodeID ){ }); }; MEPanel.doLayout(); - loadDeviceMask( NodeID ); + //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 ); @@ -1486,11 +2129,14 @@ function setMaskEditorMode( nM ){ if( !MEP.pressed ) MEP.toggle( true ); break; }; + case 4:{ + + }; }; MaskEditorMode = nM; }; -function loadDeviceMask( NodeID, LrfID = 0, LayerID = 0 ){ +function loadDeviceMask( NodeID, LayerID = 0, LrfID = 0 ){ Ext.Ajax.request({ url: '/lib/controller/getDeviceMask.php', params: { @@ -1502,13 +2148,11 @@ function loadDeviceMask( NodeID, LrfID = 0, LayerID = 0 ){ }, success: function( response, opts ){ var data = Ext.decode(response.responseText); - var canvas = document.getElementById('mask_canvas');// Create an empty project and a view for the canvas: - //paper.setup( canvas ); - paper.settings.handleSize = 10; - MaskProject = new paper.Project( canvas ); + if( data.length > 0 ){ for( i = 0; i < data.length; i++ ){ - var path = new paper.Path(); + //var + path = new paper.Path(); path.strokeColor = 'black'; //var lightness = (Math.random() - 0.5) * 0.4 + 0.4; //var hue = Math.random() * 360; @@ -1523,51 +2167,84 @@ function loadDeviceMask( NodeID, LrfID = 0, LayerID = 0 ){ // path.add(event.point); //} if( data[i].points.length > 2 ){ - 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] ); + 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 ); }; - setMaskEditorMode( 1 ); // Observer - canvas.addEventListener( 'mousemove', onMaskMouseMove ); - canvas.addEventListener( 'mousedown', onMaskMouseDown ); - canvas.addEventListener( 'mouseup', onMaskMouseUp ); - canvas.addEventListener( 'mousedrag', onMaskMouseMove ); }, failure: failureAJAXFunction }); }; function onMaskMouseDown( evt ){ - if( MaskEditorMode == 0 ){ - path = new paper.Path(); - path.strokeColor = 'black'; - path.closed = true; - path.opacity = 0.5; - path.moveTo( [ evt.clientX, evt.clientY ] ); - setMaskEditorMode( 4 ); + 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.clientX, evt.clientY ] ); + //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(); + //paper.view.draw(); }; }; diff --git a/lib/javascript/jsapi_dynamic/rgoose_location_editor.js b/lib/javascript/jsapi_dynamic/rgoose_location_editor.js index 52b32dc..c84f883 100644 --- a/lib/javascript/jsapi_dynamic/rgoose_location_editor.js +++ b/lib/javascript/jsapi_dynamic/rgoose_location_editor.js @@ -8,6 +8,7 @@ var SiteLon=; var SiteAlt=; var map = null; +var markers = []; function Events() { this.events = { }; @@ -541,6 +542,16 @@ var SITEZ_Icon = L.icon({ popupAnchor: [0, -15] // point from which the popup should open relative to the iconAnchor }); +var SNAPE_Icon = L.icon({ + iconUrl: '/style/assets/cursor.png', + //shadowUrl: 'leaf-shadow.png', + iconSize: [32, 32], // size of the icon + //shadowSize: [50, 64], // size of the shadow + iconAnchor: [16, 16], // point of the icon which will correspond to marker's location + //shadowAnchor: [4, 62], // the same for the shadow + popupAnchor: [0, -15] // point from which the popup should open relative to the iconAnchor +}); + var locationSelectedNode = 0; function loadLoactionProps( e ){ if( typeof e == 'number' ){ @@ -595,6 +606,9 @@ function updateLocationOrientation(){ }); }; +var iconSaver = null; +var markerSaver = null; + function updateLocation( e ){ locationSelectedNode = e.target.options.mycustomid; Ext.Ajax.request({ @@ -615,6 +629,42 @@ function updateLocation( e ){ }); }; +function markerDblClick( e ){ + if( iconSaver == null ){ + iconSaver = e.target.options.icon; + markerSaver = e.target; + e.target.setIcon( SNAPE_Icon ); + for( i=0; i< markers.length; i++){ + if( markers[i].options.mycustomid != e.target.options.mycustomid ){ + markers[i].setOpacity( 0.1 ); + } else { + markers[i].setOpacity( 1.0 ); + } + }; + } else { + if( e.target.options.mycustomid == markerSaver.options.mycustomid ){ + e.target.setIcon( iconSaver ); + iconSaver = null; + markerSaver = null; + for( i=0; i< markers.length; i++){ + markers[i].setOpacity( 1.0 ); + }; + } else { + markerSaver.setIcon( iconSaver ); + iconSaver = e.target.options.icon; + markerSaver = e.target; + e.target.setIcon( SNAPE_Icon ); + for( i=0; i< markers.length; i++){ + if( markers[i].options.mycustomid != e.target.options.mycustomid ){ + markers[i].setOpacity( 0.1 ); + } else { + markers[i].setOpacity( 1.0 ); + } + }; + }; + }; +}; + function setNodeLocationToAnchor(){ Ext.Ajax.request({ url: '/lib/controller/updateLocation.php', @@ -635,6 +685,29 @@ function setNodeLocationToAnchor(){ }); }; +function setNodeLocationByDelta(){ + var dx = Ext.getCmp('dx').getValue(); + var dy = Ext.getCmp('dy').getValue(); + var dz = Ext.getCmp('dz').getValue(); + Ext.Ajax.request({ + url: '/lib/controller/updateLocation.php', + params: { + NODE: locationSelectedNode, + SITE: , + UID: , + TYPE: 3, + SID: '', + LAT: dx, + LON: dy, + ALT: dz + }, + success: function( response, opts ){ + loadLocationEditor(); + }, + failure: failureAJAXFunction + }); +}; + function loadLocationNodes(){ Ext.Ajax.request({ @@ -649,38 +722,38 @@ function loadLocationNodes(){ for( i=0; i < data.length; i++){ switch( data[i].type ){ case 1:{ - L.marker([data[i].lat, data[i].lon], {draggable: true,icon: ALS_Icon, mycustomid:data[i].id } ).addTo(map).on('click', loadLoactionProps ).on('dragend', updateLocation ); - break; + markers[i] = L.marker([data[i].lat, data[i].lon], {draggable: true,icon: ALS_Icon, mycustomid:data[i].id } ).addTo(map).on('click', loadLoactionProps ).on('dblclick', markerDblClick ).on('dragend', updateLocation ); + break; }; case 2:{ - L.marker([data[i].lat, data[i].lon], {draggable: true,icon: LFS_Icon, mycustomid:data[i].id } ).addTo(map).on('click', loadLoactionProps ).on('dragend', updateLocation ); - break; + markers[i] = L.marker([data[i].lat, data[i].lon], {draggable: true,icon: LFS_Icon, mycustomid:data[i].id } ).addTo(map).on('click', loadLoactionProps ).on('dblclick', markerDblClick ).on('dragend', updateLocation ); + break; }; case 3:{ - L.marker([data[i].lat, data[i].lon], {draggable: true,icon: PLS200_Icon, mycustomid:data[i].id } ).addTo(map).on('click', loadLoactionProps ).on('dragend', updateLocation ); - break; + markers[i] = L.marker([data[i].lat, data[i].lon], {draggable: true,icon: PLS200_Icon, mycustomid:data[i].id } ).addTo(map).on('click', loadLoactionProps ).on('dblclick', markerDblClick ).on('dragend', updateLocation ); + break; }; case 4:{ - L.marker([data[i].lat, data[i].lon], {draggable: true,icon: PLS360_Icon, mycustomid:data[i].id } ).addTo(map).on('click', loadLoactionProps ).on('dragend', updateLocation ); - break; + markers[i] = L.marker([data[i].lat, data[i].lon], {draggable: true,icon: PLS360_Icon, mycustomid:data[i].id } ).addTo(map).on('click', loadLoactionProps ).on('dblclick', markerDblClick ).on('dragend', updateLocation ); + break; }; case 5:{ - L.marker([data[i].lat, data[i].lon], {draggable: true,icon: LRF3D_Icon, mycustomid:data[i].id } ).addTo(map).on('click', loadLoactionProps ).on('dragend', updateLocation ); - break; + markers[i] = L.marker([data[i].lat, data[i].lon], {draggable: true,icon: LRF3D_Icon, mycustomid:data[i].id } ).addTo(map).on('click', loadLoactionProps ).on('dblclick', markerDblClick ).on('dragend', updateLocation ); + break; }; case 6:{ - L.marker([data[i].lat, data[i].lon], {draggable: true,icon: PLSNET200_Icon, mycustomid:data[i].id } ).addTo(map).on('click', loadLoactionProps ).on('dragend', updateLocation ); - break; + markers[i] = L.marker([data[i].lat, data[i].lon], {draggable: true,icon: PLSNET200_Icon, mycustomid:data[i].id } ).addTo(map).on('click', loadLoactionProps ).on('dblclick', markerDblClick ).on('dragend', updateLocation ); + break; }; case 10: case 12:{ - L.marker([data[i].lat, data[i].lon], {draggable: true,icon: FIXCAM_Icon, mycustomid:data[i].id } ).addTo(map).on('click', loadLoactionProps ).on('dragend', updateLocation ); - break; + markers[i] = L.marker([data[i].lat, data[i].lon], {draggable: true,icon: FIXCAM_Icon, mycustomid:data[i].id } ).addTo(map).on('click', loadLoactionProps ).on('dblclick', markerDblClick ).on('dragend', updateLocation ); + break; }; case 11: case 13:{ - L.marker([data[i].lat, data[i].lon], {draggable: true,icon: PTZCAM_Icon, mycustomid:data[i].id } ).addTo(map).on('click', loadLoactionProps ).on('dragend', updateLocation ); - break; + markers[i] = L.marker([data[i].lat, data[i].lon], {draggable: true,icon: PTZCAM_Icon, mycustomid:data[i].id } ).addTo(map).on('click', loadLoactionProps ).on('dblclick', markerDblClick ).on('dragend', updateLocation ); + break; }; }; //bindPopup('A pretty CSS3 popup.
Easily customizable.');//.openPopup(); @@ -1003,9 +1076,9 @@ function loadLocationEditor(){ columnWidth: 0.17, layout: 'fit', id: 'prop_content', - items:{ - html: '
Select Item From Map
' - } + items:[{ + html:'
GetLabel('_PLS_SEL_LEFT_ITEM_');?>
' + }] }); tPanel.doLayout(); map = L.map('location_map',{ @@ -1020,6 +1093,68 @@ function loadLocationEditor(){ keyboard: false }).setView([SiteLat, SiteLon], 17); L.marker([SiteLat, SiteLon], { draggable: false, icon: SITEZ_Icon, zIndexOffset: 1000 } ).addTo(map).on('click', LoadNodesList ).bindPopup("GetLabel('_SYS_ANCHORT_LBL_');?>");//.openPopup(); + var mapLayers = []; + + mapLayers["MyMap"] = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { + attribution: '© OpenStreetMap contributors', + maxNativeZoom: 18, + maxZoom: 24, + }) + // https://leaflet-extras.github.io/leaflet-providers/preview/ + mapLayers["EsriStreet"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}', { + attribution: 'Tiles © Esri — Source: Esri, DeLorme, NAVTEQ, USGS, Intermap, iPC, NRCAN, Esri Japan, METI, Esri China (Hong Kong), Esri (Thailand), TomTom, 2012', + maxZoom: 19 + }); + + mapLayers["EsriSat"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', { + attribution: 'Tiles © Esri — Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community', + maxZoom: 19 + }); + + mapLayers["EsriTopo"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}', { + attribution: 'Tiles © Esri — Esri, DeLorme, NAVTEQ, TomTom, Intermap, iPC, USGS, FAO, NPS, NRCAN, GeoBase, Kadaster NL, Ordnance Survey, Esri Japan, METI, Esri China (Hong Kong), and the GIS User Community', + maxZoom: 24 + }); + + mapLayers["OpenStreetMap"] = L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", { //de/tiles/osmde + attribution: 'Map data © OpenStreetMap contributors', + maxZoom: 19 + }); + + mapLayers["OpenTopoMap"] = L.tileLayer("https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png", { + attribution: 'Kartendaten: © OpenStreetMap-Mitwirkende, SRTM | Kartendarstellung: © OpenTopoMap (CC-BY-SA) ', + maxZoom: 19 + }); + /* + mapLayers["Cycle"] = L.tileLayer('https://tile.thunderforest.com/cycle/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], { + attribution: 'Maps © Thunderforest, Data © OpenStreetMap contributors', + maxZoom: 22 + }); + mapLayers["Landscape"] = L.tileLayer('https://tile.thunderforest.com/landscape/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], { + attribution: 'Maps © Thunderforest, Data © OpenStreetMap contributors', + maxZoom: 22 + }); + mapLayers["Outdoor"] = L.tileLayer('https://tile.thunderforest.com/outdoors/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], { + attribution: 'Maps © Thunderforest, Data © OpenStreetMap contributors', + maxZoom: 22 + }); + */ + + var baseMaps = { + "MyMap": mapLayers["MyMap"], + "OpenStreetMap": mapLayers["OpenStreetMap"], + "OpenTopoMap": mapLayers["OpenTopoMap"], + "EsriSat": mapLayers["EsriSat"], + "EsriStreet": mapLayers["EsriStreet"], + "EsriTopo": mapLayers["EsriTopo"], + //"Bing": mapLayers["Bing"], + //"OSM-Cycle": mapLayers["Cycle"], + //"Landscape": mapLayers["Landscape"], + //"Outdoor": mapLayers["Outdoor"], + }; + L.control.layers( baseMaps ).addTo(map); + + mapLayers["MyMap"].addTo(map); /* Ext.Ajax.request({ url: '/lib/controller/getNetwork.php', diff --git a/lib/javascript/jsapi_dynamic/rgoose_main.js b/lib/javascript/jsapi_dynamic/rgoose_main.js index 89bcef3..8c18b43 100644 --- a/lib/javascript/jsapi_dynamic/rgoose_main.js +++ b/lib/javascript/jsapi_dynamic/rgoose_main.js @@ -168,7 +168,7 @@ Ext.onReady(function(){ height: 120, pack: 'center', align : 'strech', - collapsed: Data['last_content_view']<2)?'false':'true';?>, + collapsed: Data['last_content_view']<3)?'false':'true';?>, items:[{ xtype: 'button', width: '100%', @@ -181,12 +181,14 @@ Ext.onReady(function(){ width: '100%', id:'go_monitor', text: 'GetLabel('_EVT_MONITOR_');?>', + toggled: (initView == 1 ), handler: loadMonitoring },{ xtype: 'button', width: '100%', id:'go_archive', text: 'GetLabel('_EVT_ARCHIVE_');?>', + toggled: (initView == 2 ), handler: loadArchive },{ xtype: 'button', @@ -201,24 +203,27 @@ Ext.onReady(function(){ height: 120, pack: 'center', align : 'strech', - collapsed: Data['last_content_view']>1)?'false':'true';?>, + collapsed: Data['last_content_view']>2)?'false':'true';?>, items:[{ xtype: 'button', width: '100%', id:'sys_edit', text: 'GetLabel('_EDT_CONNECTIONS_');?>', + toggled: (initView == 3 ), handler: loadSystemEditor },{ xtype: 'button', width: '100%', id:'map_edit', text: 'GetLabel('_EDT_LOCATIONS_');?>', + toggled: (initView == 4 ), handler: loadLocationEditor },{ xtype: 'button', width: '100%', id:'soft_update', text: 'GetLabel('_UPGRADE_MNGMNT_');?>', + toggled: (initView == 5 ), handler: loadUpgradeManagmenet }] },{ @@ -285,6 +290,8 @@ Ext.onReady(function(){ case 0: loadDashBoard(); break; case 1: loadMonitoring(); break; case 2: loadArchive(); break; + case 3: loadSystemEditor(); break; + case 4: loadLocationEditor(); break; case 5: loadUpgradeManagmenet(); break; default: loadDashBoard(); diff --git a/lib/javascript/jsapi_dynamic/rgoose_reports.js b/lib/javascript/jsapi_dynamic/rgoose_reports.js index 38491d3..443c662 100644 --- a/lib/javascript/jsapi_dynamic/rgoose_reports.js +++ b/lib/javascript/jsapi_dynamic/rgoose_reports.js @@ -16,6 +16,18 @@ var tlItems = new vis.DataSet(); var selecredActiveSourceFilter = 0; var ActiveZones = null; +var selectedMarkerIcon = L.icon({ + iconUrl: '/style/assets/cursor.png', + iconSize: [32, 32], + iconAnchor: [16, 16]//, + //popupAnchor: [-3, -76], + //shadowUrl: 'my-icon-shadow.png', + //shadowSize: [68, 95], + //shadowAnchor: [22, 94] +}); + +selectedMarker = L.marker([SiteLat, SiteLon], { draggable: false, icon: selectedMarkerIcon } ); + var tlOptions = { groupOrder: 'content', // groupOrder can be a property name or a sorting function stack: true, @@ -33,89 +45,15 @@ var tlMonitoring = false; -// Global Variables -var Dates = new Array(); -var HTTPO_Calendar = null; -var SelectedDay=''; -var CurrentDate=(new Date())/1000; -// Calendar Functions - -function Calendar_QURL(RQT){ - RetVal="feed.php?STY=5&UID="+UserID+"&SID="+SessionID+"&DID="+CDevID+"&CDATE="+CurrentDate; - return RetVal; -}; - -function StartCalendarSession( httpRequestType ){ - var QURL=''; - if (HTTPO_Calendar == null ){ - HTTPO_Calendar = getHTTPObject(); - }; - if (HTTPO_Calendar != null) { - QURL=Calendar_QURL( httpRequestType ); - HTTPO_Calendar.open("GET", QURL , true); - HTTPO_Calendar.send(''); - HTTPO_Calendar.onreadystatechange = HGDT_Calendar; - Ext.MessageBox.wait("GetLabel('_Loading_Histo_');?>","GetLabel('_Please_Wait_');?>",{ - width: '100%', - hidden: true, - progress: true, - closable: false - }); - } else { - Ext.Msg.alert('Status', 'Error Creating AJAX Connection.
Code: CCXL00231'); - }; -}; - -function HGDT_Calendar(){ - switch( HTTPO_Calendar.readyState ){ - case 0: window.status = 'C:Communication is Uninitialized'; - break; - case 1: window.status = 'C:Loading Data'; - break; - case 2: window.status = 'C:Data is Loaded'; - break; - case 3: window.status = 'C:Communication is Interactive'; - break; - case 4: window.status = 'C:Data Load Complete'; - break; - }; - if( HTTPO_Calendar.readyState == 4 ){ - var T_Arr; - //alert(HTTPO_Calendar.responseText); - T_Arr = JSON_parse( HTTPO_Calendar.responseText,'' ); - httpRequestType=T_Arr.type/1; - //alert(httpRequestType); - Dates=new Array(); - for (index=0;index GetMonthLength(CurrentDate) ) SD = GetMonthLength(CurrentDate); + loadCalendarDates(); }; function ShiftFWD(){ CurrentDate=CurrentDate+24*3600*GetMonthLength(CurrentDate); BuildCalendar(); - StartCalendarSession(5); + SMO = GetMonthNum(CurrentDate); + SY = GetYear(CurrentDate); + if( SD > GetMonthLength(CurrentDate) ) SD = GetMonthLength(CurrentDate); + loadCalendarDates(); }; function GetMonthName(UTS){ // Unix Time Stamp @@ -195,26 +139,22 @@ function GetYear(UTS){ // Unix Time Stamp if (y<200)y+=1900; return y; }; - +function GetDay(UTS){ // Unix Time Stamp + CDate=new Date(); + CDate.setTime(UTS*1000); + y=CDate.getDate(); + return y; +}; function selectDate( m, d ){ SY = GetYear(CurrentDate); SMO = m; SD = d; - //a = ''+m+d; - //if (SelectedDay!=''){ - // try{ - // document.getElementById('ds'+SelectedDay).setAttribute("class", 'CalendarDE'); - // document.getElementById('ds'+SelectedDay).setAttribute("className", 'CalendarDE'); - // } catch(e){}; - //}; - //document.getElementById('ds'+a).setAttribute("class", 'CalendarDS'); - //document.getElementById('ds'+a).setAttribute("className", 'CalendarDS'); - //SelectedDay=a; + SelectedDay = SD; getData( 'arch' ); }; -function BuildCalendar(){ +function BuildCalendar( ){ Msh=GetMonthShift(CurrentDate); Mnm=GetMonthName(CurrentDate); Mln=GetMonthLength(CurrentDate); @@ -229,9 +169,13 @@ function BuildCalendar(){ for(;index<(Mln+Msh);index++){ if( CheckDate(index-Msh+1) ){ //InDTA+='
'+(index-Msh+1).toString()+''; - InDTA+='
'+(index-Msh+1).toString()+'
'; + if( SD == index ){ + InDTA+='
'+(index-Msh+1).toString()+'
'; + } else { + InDTA+='
'+(index-Msh+1).toString()+'
'; + }; } else { - if( ( SD - 1 ) == index ){ + if( SD == index ){ InDTA+='
'+(index-Msh+1).toString()+''; } else { InDTA+='
'+(index-Msh+1).toString()+''; @@ -309,7 +253,7 @@ var eventsListStore = new Ext.data.JsonStore({ type: 'string' },{ name: 'event', - type: 'string' + type: 'int' },{ name: 'data', type: 'string', @@ -402,13 +346,29 @@ function PicRenderer( val ){ return ''; }; +function EvtTypeRenderer( val ){ + switch( val ){ + case 6: return 'Device Enters Into Study Mode'; + case 7: return 'Device Is BUSY'; + case 8: return 'Flip Complete'; + case 9: return 'Scan Complete'; + case 10: + case 11: + case 12: + case 13: + case 14: return 'Target'; + case 36: return 'Region Of Interest'; + default: return 'Event ['+val+']'; + }; +}; + var eventsListColModel_ops = { columns: [ - {header: "ID", width: 50, sortable: false, menuDisabled: true, align: 'center', fixed: true, css: 'vertical-align: middle;', dataIndex: 'id' }, - {header: "Date",width: 80, sortable: false, fixed: true, menuDisabled: true, /*renderer: camCapRenderer,*/ dataIndex: 'date' }, + {header: "ID", width: 100, sortable: false, menuDisabled: true, align: 'center', fixed: true, css: 'vertical-align: middle;', dataIndex: 'id' }, + {header: "Date",width: 100, sortable: false, fixed: true, menuDisabled: true, /*renderer: camCapRenderer,*/ dataIndex: 'date' }, {header: "Time", width: 80, sortable: false, menuDisabled: true, align: 'left', css: 'vertical-align: middle;', dataIndex: 'time' }, - {header: "Device", width: 150, sortable: false, fixed: true, menuDisabled: true, align: 'left', css: 'vertical-align: middle;', dataIndex: 'device' }, - {header: "Event", width: 80, sortable: false, dataIndex: 'event' }, + {header: "Device", width: 80, sortable: false, fixed: true, menuDisabled: true, align: 'left', css: 'vertical-align: middle;', dataIndex: 'device' }, + {header: "Event", width: 120, sortable: false, dataIndex: 'event', renderer: EvtTypeRenderer }, {header: "Info", width: 200, sortable: false, dataindex: 'data' }, {header: "", width: 25, sortable: false, dataIndex: 'has_geo', renderer: LocRenderer }, {header: "", width: 25, sortable: false, dataIndex: 'has_images', renderer: PicRenderer } @@ -424,13 +384,15 @@ var eventsListColModel_ops = { } } }; +var SelectedRow = -1; var eventsListSelModel_ops = { singleSelect: true, listeners: { rowselect: function(sm, row, rec ) { loadEventProperties( rec.data ); - //SelectedEvent = rec.data.id; + SelectedEvent = rec.data.id; + SelectedRow = row; //alert( SelectedEvent ); //var CB = Ext.getCmp('con_to_src'); //CB.enable(); @@ -628,6 +590,43 @@ function loadMapZones( SID ){ var cevt = Array(); var coz = Array(); +function showEventsOnMap( data, removeCursor = true ){ + if( removeCursor ) map.removeLayer( selectedMarker ); + if( cevt.length ){ + for( i=0; i< cevt.length; i++ ){ + if( cevt[i]!= null ){ + cevt[i].remove(); + delete( cevt[i] ); + cevt[i] = null; + }; + }; + }; + if( coz.length ){ + for( i=0; i< coz.length; i++ ){ + if( coz[i]!= null ){ + coz[i].remove(); + delete( coz[i] ); + coz[i]=null; + }; + }; + }; + var zz = ( 1.0 / ( data.log.length + 0 ) ); + var idx = 0; + for( i=0; i < data.log.length; i++ ){ + if( data.log[i].has_geo ){ + var cp_color='#FF0000'; + switch( data.log[i].event ){ + case 36: cp_color='#0000FF'; break; + }; + cevt[idx] = L.circleMarker( [data.log[i].geo.lat, data.log[i].geo.lon], {id:data.log[i].id, color: cp_color, radius: 5, stroke: false, fillOpacity: ( 1.0 - i * zz ) } ).on('click', function( e, a ){ + loadEventPropertiesByID( this.options.id ); + } ); + cevt[idx].addTo(map); + idx++; + }; + }; +}; + function LoadMapEventsZ( Mode ){ if( tlLoadLocker ) return; tlLoadLocker = true; @@ -686,25 +685,31 @@ function LoadMapEventsZ( Mode ){ }); }; +function loadEventPropertiesByID( id ){ + var d = eventsListStore.findExact( 'id', id ); + if( d > -1 ) { + var EventRec = eventsListStore.getAt( d ); + loadEventProperties( EventRec.data ); + }; +}; + function loadEventProperties( EventRec ){ - - //alert( 'Node: ' + NodeID ); - var tPanel = Ext.getCmp('prop_content'); tPanel.removeAll();// remove( 0 ); - var tt = '' - map.removeLayer( selectedMarker ); - if( EventRec.has_geo ){ - tt = ''+EventRec.geo.lat+' '+EventRec.geo.lon; - selectedMarker.setLatLng([EventRec.geo.lat, EventRec.geo.lon]); - selectedMarker.addTo( map ); + var tt = ''; + if( selectedMarker!= null ){ + selectedMarker.remove(); + //map.removeLayer( selectedMarker ); + if( EventRec.has_geo ){ + tt = ''+EventRec.geo.lat+' '+EventRec.geo.lon; + selectedMarker.setLatLng([EventRec.geo.lat, EventRec.geo.lon]); + selectedMarker.addTo( map ); + }; }; tPanel.add( { title: 'Event Details', html: '

' + EventRec.device+'

'+tt+'
' } ); - - if( EventRec.has_images ){ for( var i=0; i < EventRec.images.length; i++ ){ tPanel.add( { @@ -714,34 +719,20 @@ function loadEventProperties( EventRec ){ }; }; tPanel.doLayout(); - - /* - Ext.Ajax.request({ - url: '/lib/controller/getEventProps.php', - params: { - NID: , - UID: , - SID: '', - EVENT: EventRec.id - }, - success: function( response, opts ){ - // If the response is JSON, you have to decode it - var data = Ext.decode(response.responseText); - var tPanel = Ext.getCmp('prop_content'); - tPanel.remove(0); - tPanel.add( data ); - tPanel.doLayout(); - }, - failure: function( response, opts ) { - //Ext.fly('some_div').update('Fail!'); - } - }); - */ }; -function getData( Mode ){ +function getData( Mode, ST = 0, ET = 0, SR = 0, DR = 0 ){ if( tlLoadLocker ) return; tlLoadLocker = true; + if( Mode == 'arch' ){ + Ext.MessageBox.wait("Loading Data","Please Wait",{ + width: '100%', + hidden: true, + animate: true, + progress: true, + closable: false + }); + }; Ext.Ajax.request({ url: '/lib/controller/getEventRecords.php', params: { @@ -753,14 +744,41 @@ function getData( Mode ){ SDA: SD, SMO: SMO, SYE: SY, - STM: 0, - ETM: 0, + STM: ST, + ETM: ET, + STR: SR, + DIR: DR }, success: function( response, opts ){ tlLoadLocker = false; var data = Ext.decode(response.responseText); + if( data.updateFROMTO ){ + Ext.getCmp('STimeFROM').setValue( data.STT ); + Ext.getCmp('STimeTO').setValue( data.ENT ); + if( data.SLD > 0 ){ + SMO = GetMonthNum(data.SLD); + SY = GetYear(data.SLD); + SD = GetDay(data.SLD); + BuildCalendar(); + }; + }; eventsListStore.loadData( data, false ); - LoadMapEventsZ( Mode ); + + if( Mode == 'arch' ){ + showEventsOnMap( data, true ); + Ext.MessageBox.hide(); + if( DR > 0 ){ + Ext.getCmp('evtArchLog').getView().focusRow( eventsListStore.getCount() - 1 ); + Ext.getCmp('evtArchLog').getSelectionModel().selectLastRow(); + }; + if( DR < 0 ){ + Ext.getCmp('evtArchLog').getView().focusRow( 0 ); + Ext.getCmp('evtArchLog').getSelectionModel().selectFirstRow(); + }; + } else { + showEventsOnMap( data, false ); + //LoadMapEventsZ( Mode ); + }; }, failure: failureAJAXFunction }); @@ -818,53 +836,113 @@ function loadArchive(){ labelWidth: 50, defaults: { width: 80}, items: [{ - xtype: 'timefield', + xtype: 'combo', id: 'STimeFROM', - width: 120, fieldLabel: 'From', - minValue: '00:00', - maxValue: '24:00', - increment: 30 + editable: false, + typeAhead: true, + triggerAction: 'all', + width: 120, + lazyRender:true, + mode: 'local', + store: new Ext.data.ArrayStore({ + id: 0, + fields: ['ss', 'displayText' ], + data: [] + }), + valueField: 'ss', + displayField: 'displayText' },{ - xtype: 'timefield', + xtype: 'combo', id: 'STimeTO', - width: 120, fieldLabel: 'Till', - minValue: '00:00', - maxValue: '24:00', - increment: 30 + editable: false, + typeAhead: true, + triggerAction: 'all', + width: 120, + lazyRender:true, + mode: 'local', + store: new Ext.data.ArrayStore({ + id: 0, + fields: ['ss', 'displayText' ], + data: [] + }), + valueField: 'ss', + displayField: 'displayText' }], html: '
', buttons: [{ xtype: 'button', - text: 'Display History' + text: 'Display History', + handler: function(){ + var STU = Ext.getCmp('STimeFROM').getValue(); + var ETU = Ext.getCmp('STimeTO').getValue(); + getData( 'arch', STU, ETU ); + } }] },{ title: 'Event Log', frame: false, height: 303, + id: 'evtArchLog', xtype: 'grid', ds: eventsListStore, cm: new Ext.grid.ColumnModel( eventsListColModel_ops ), - sm: new Ext.grid.RowSelectionModel( eventsListSelModel_ops ) + sm: new Ext.grid.RowSelectionModel( eventsListSelModel_ops ), + listeners:{ + keydown: function( e ) { + if( e.getKey() == e.UP ){ + if( SelectedRow == 0 ){ + var id = eventsListStore.getAt( 0 ).id; + getData( 'arch', 0, 0, id, 1 ); + + }; + }; + if( e.getKey() == e.DOWN ){ + if( SelectedRow == ( eventsListStore.getCount() - 1 ) ){ + var id = eventsListStore.getAt( SelectedRow ).id; + getData( 'arch', 0, 0, id, -1 ); + Ext.getCmp('evtArchLog').getSelectionModel().selectFirstRow(); + Ext.getCmp('evtArchLog').focus( false, true ); + }; + }; + } + } }] }] }); tPanel.add({ columnWidth: 0.17, - frame: false, + frame: true, + title: 'Event Information', id: 'prop_content', border: false, items: [{ - title: 'Event Information', - border: true, - frame: true, - html: '

Select an Event from TimeLine to See Information

' + html:'
GetLabel('_PLS_SEL_LEFT_ITEM_');?>
' }] }); tPanel.doLayout(); - + /* + Ext.getCmp('evtLog').getEl().set({tabindex: "0"}); + Ext.getCmp('evtLog').getEl().addKeyMap({ + eventName: "keyup", + binding: [{ + key: Ext.EventObject.SPACE, + fn: function(){ alert("Space key pressed"); } + },{ + key: [Ext.EventObject.LEFT, Ext.EventObject.RIGHT], + shift: true, + fn: function(){ alert("Left or right pressed while pressing shift"); } + }] + }); + */ //BuildCalendar(); loadCalendarDates(); @@ -880,17 +958,6 @@ function loadArchive(){ keyboard: false }).setView([SiteLat, SiteLon], 17); //L.marker([SiteLat, SiteLon], { draggable: false, icon: SITEZ_Icon } ).addTo(map).on('click', LoadNodesList ).bindPopup("GetLabel('_SYS_ANCHORT_LBL_');?>"); - var selectedMarkerIcon = L.icon({ - iconUrl: '/style/assets/cursor.png', - iconSize: [32, 32], - iconAnchor: [16, 16]//, - //popupAnchor: [-3, -76], - //shadowUrl: 'my-icon-shadow.png', - //shadowSize: [68, 95], - //shadowAnchor: [22, 94] - }); - - selectedMarker = L.marker([SiteLat, SiteLon], { draggable: false, icon: selectedMarkerIcon } ); var mapLayers = []; @@ -1057,14 +1124,12 @@ function loadMonitoring(){ }); tPanel.add({ columnWidth: 0.17, - frame: false, + title: 'Event Information', + frame: true, id: 'prop_content', border: false, items: [{ - title: 'Event Information', - border: true, - frame: true, - html: '

Select an Event from TimeLine to See Information

' + html:'
GetLabel('_PLS_SEL_LEFT_ITEM_');?>
' }] }); diff --git a/lib/javascript/jsapi_dynamic/rgoose_swupgrade.js b/lib/javascript/jsapi_dynamic/rgoose_swupgrade.js index 6d67120..e26835b 100644 --- a/lib/javascript/jsapi_dynamic/rgoose_swupgrade.js +++ b/lib/javascript/jsapi_dynamic/rgoose_swupgrade.js @@ -284,7 +284,7 @@ function loadUpgradeManagmenet(){ title: 'Current System Info', width: '100%', //flex: 1, - html: '

Current Web Version:

' + html: '

Current Web Version: 

' },{ title: 'Tasks', //width: 400, diff --git a/lib/javascript/jsapi_dynamic/rgoose_sysmap_editor.js b/lib/javascript/jsapi_dynamic/rgoose_sysmap_editor.js index 8b3e90a..0ac4f11 100644 --- a/lib/javascript/jsapi_dynamic/rgoose_sysmap_editor.js +++ b/lib/javascript/jsapi_dynamic/rgoose_sysmap_editor.js @@ -3,6 +3,20 @@ var resourceInfoWindow = null; +var settingsAreChanged = false; +var settingsChanged = []; + +function settingsChangeNotifier( A ){ + settingsAreChanged = true; + if( !settingsChanged.includes( A ) ){ + settingsChanged[settingsChanged.length] = A; + }; +}; + +function cleanupChangeNotifier(){ + settingsAreChanged = false; + settingsChanged = []; +}; function removeAllFromSite(){ Ext.Msg.show({ @@ -45,6 +59,7 @@ function showResourceInfo( rid ){ modal: true, width: 800, height: 400, + resizable: false, layout: 'fit', closeAction: 'hide', items: [], @@ -79,15 +94,34 @@ function showSettings( nid ){ settingsWindow = new Ext.Window({ title: 'GetLabel('_SETTINGS_');?>', modal: true, + resizable: false, width: 800, height: 400, layout: 'fit', closeAction: 'hide', items: [], buttons:[{ - text: `close`, + text: `GetLabel('_CLOSE_');?>`, handler: function(){ - settingsWindow.hide(); + if( settingsAreChanged ){ + Ext.Msg.show({ + title:'GetLabel('_SETTINGS_CHANGED_');?>', + msg: 'GetLabel('_SET_CHANGED_WOULD_SAVE_');?>', + buttons: Ext.Msg.YESNO, + icon: Ext.MessageBox.WARNING, + fn: function(btn, text){ + if( btn == 'yes' ){ + cleanupChangeNotifier(); + settingsWindow.hide(); + } else { + var TT = Ext.getCmp('node_settings_content'); + TT.updateSettings(); + }; + } + }); + } else { + settingsWindow.hide(); + }; } }] }); @@ -100,6 +134,84 @@ function showSettings( nid ){ }); }; +function editResource( rid ){ + var loadEditor = true; + if( settingsAreChanged ){ + Ext.Msg.show({ + title:'GetLabel('_SETTINGS_CHANGED_');?>', + msg: 'GetLabel('_SET_CHANGED_WOULD_SAVE_');?>', + buttons: Ext.Msg.YESNO, + icon: Ext.MessageBox.WARNING, + fn: function(btn, text){ + if( btn == 'yes' ){ + cleanupChangeNotifier(); + } else { + loadEditor = false; + }; + } + }); + }; + if( loadEditor ){ + Ext.Ajax.request({ + url: '/lib/controller/getResourceEditor.php', + params: { + RID: rid, + UID: , + SID: '', + }, + success: function( response, opts ){ + var data = Ext.decode(response.responseText); + var resourceEdPanel = Ext.getCmp('res_ed_small'); + if( resourceEdPanel ){ + resourceEdPanel.removeAll( true ); + resourceEdPanel.add( data ); + resourceEdPanel.doLayout(); + }; + }, + failure: failureAJAXFunction + }); + }; +}; + +function editModule( mid ){ + var loadEditor = true; + if( settingsAreChanged ){ + Ext.Msg.show({ + title:'GetLabel('_SETTINGS_CHANGED_');?>', + msg: 'GetLabel('_SET_CHANGED_WOULD_SAVE_');?>', + buttons: Ext.Msg.YESNO, + icon: Ext.MessageBox.WARNING, + fn: function(btn, text){ + if( btn == 'yes' ){ + cleanupChangeNotifier(); + } else { + loadEditor = false; + }; + } + }); + }; + if( loadEditor ){ + Ext.Ajax.request({ + url: '/lib/controller/getModuleEditor.php', + params: { + MID: mid, + UID: , + SID: '', + }, + success: function( response, opts ){ + var data = Ext.decode(response.responseText); + var moduleEdPanel = Ext.getCmp('mod_ed_small'); + if( moduleEdPanel ){ + moduleEdPanel.removeAll( true ); + moduleEdPanel.add( data ); + moduleEdPanel.doLayout(); + }; + }, + failure: failureAJAXFunction + }); + }; +}; + function reloadNetworkData(){ Ext.Ajax.request({ url: '/lib/controller/getNetwork.php', @@ -621,7 +733,7 @@ function loadSystemEditor(){ tlInterval = null; timelineObj = null; }; - setUserContent( 2 ); + setUserContent( 3 ); var tPanel = Ext.getCmp('main_portal'); tPanel.removeAll( true ); Ext.getCmp('main_content').setTitle( 'GetLabel('_SYS_MAP_');?>' ); @@ -743,24 +855,6 @@ function loadSystemEditor(){ icon: '/style/assets/adam-1.png', }] } - },{ - xtype: 'button', - id: 'connectstarterbutton', - text: 'GetLabel('_ADD_CONNECTION_');?>', - enableToggle : false, - handler: function(){ - /* - if( InConnectEditMode ){ - Ext.getCmp('connectstarterbutton').toggle( false, false ); - InConnectEditMode = false; - stopCreateConnection(); - } else { - Ext.getCmp('connectstarterbutton').toggle( true, true ); - InConnectEditMode = true; - startCreateConnection(); - };*/ - embedVideoEncoderSettings(0); - } },{ xtype: 'button', id: 'deletecomponentbutton', @@ -794,9 +888,9 @@ function loadSystemEditor(){ frame: false, id: 'prop_content', border: false, - items:{ - html: 'GetLabel('_MSG_SELITEMFROMMAP_');?>' - } + items:[{ + html:'
GetLabel('_PLS_SEL_LEFT_ITEM_');?>
' + }] }); tPanel.doLayout(); diff --git a/lib/php/argus/argus.php b/lib/php/argus/argus.php index bb994a3..6de7401 100644 --- a/lib/php/argus/argus.php +++ b/lib/php/argus/argus.php @@ -47,11 +47,14 @@ global $DATABASE; $QS = "INSERT INTO `connections` SET `site_id`={$SiteID}, `from`={$FromNodeID}, `from_aux`={$FromAuxID}, `to`={$ToNodeID}, `to_aux`={$ToAuxID}, `type`={$Type}"; $DATABASE->Query( $QS, false ); + $QS = "UPDATE `resources` SET `used`=b'1' WHERE `id`={$FromAuxID} OR `id`={$ToAuxID} "; + $DATABASE->Query( $QS, false ); }; function createResource( $NodeID, $AuxID, $Type, $DeviceDesc ){ global $DATABASE; - $QS = "INSERT INTO `resources` SET `node_id`={$NodeID}, `used`=1, `type`={$Type}, `aux_id`={$AuxID}, `device`='{$DeviceDesc}' ON DUPLICATE KEY UPDATE `device`='{$DeviceDesc}'"; + $MD5 = md5( $NodeID.':'.$Type.':'.$DeviceDesc ); + $QS = "INSERT INTO `resources` SET `node_id`={$NodeID}, `used`=0, `type`={$Type}, `md5`='{$MD5}', `aux_id`={$AuxID}, `device`='{$DeviceDesc}', `active`=1 ON DUPLICATE KEY UPDATE `used`=0, `active`=1, `aux_id`={$AuxID}"; $DATABASE->Query( $QS, false ); $RID = $DATABASE->getLastInsertID(); if( $RID == 0 ){ @@ -77,21 +80,40 @@ return $NID; }; - function getServerNode( $SiteID, $Pos = 0 ){ + function getServerNode( $ServerID ){ global $DATABASE; - $QS = "SELECT `id` FROM `nodes` WHERE `site_id`={$SiteID} AND `type`=0"; + $QS = "SELECT `id` FROM `nodes` WHERE `aux_id`={$ServerID} AND `type`=0"; $SS = $DATABASE->Query( $QS, false ); - if( count( $SS ) ){ - if( $Pos ){ - if( isset ($SS[$Pos] ) ){ - return intval($SS[$Pos]['id']); - }; - } else return intval($SS[0]['id']); - }; + if( count( $SS ) ) return intval($SS[0]['id']); + return 0; + }; + function getServerID( $NodeID ){ + global $DATABASE; + $QS = "SELECT `aux_id` FROM `nodes` WHERE `id`={$NodeID} AND type=0"; + $SS = $DATABASE->Query( $QS, false ); + if( count( $SS ) ) return intval($SS[0]['aux_id']); return 0; }; - function getResourceID( $NodeID, $ResType ){ + function getServerIdByUartId( $uart_id ){ + global $DATABASE; + $QS="SELECT * FROM `resources` WHERE `aux_id`={$uart_id} AND `type`=1"; + $RR=$DATABASE->Query( $QS ); + if( count( $RR ) ){ + //HArdware Uart + return getServerID( $RR[0]['node_id'] ); + } else { + //Ethernet2Uart + $QS="SELECT * FROM `resources` WHERE `aux_id`={$uart_id} AND `type`=129"; + $RR=$DATABASE->Query( $QS ); + $R=$RR[0]; + $QS="SELECT * FROM `connections` WHERE `to`={$R['node_id']} AND `type`={CON_TYPE_TCP}"; + $RR=$DATABASE->Query( $QS ); + return getServerID( $R[0]['from'] ); + }; + }; + + function getResourceIDS( $NodeID, $ResType ){ global $DATABASE; $QS = "SELECT `id` FROM `resources` WHERE `node_id`={$NodeID} AND `type`={$ResType}"; $RR = $DATABASE->Query( $QS, false ); @@ -151,59 +173,70 @@ return 0; }; - function addSerialSensor( $SID, $DevType, $Range, $DevName, $UartID, $ProtocolID ){ + function addSerialSensor( $SID, $SSID, $DevType, $Range, $DevName, $UartID, $ProtocolID ){ global $DATABASE; + $NAME = $DATABASE->escape($DevName); - $UARTID = intval($UartID); - $DEVID = intval($ProtocolID); + + $SiteID = intval( $SID ); + $ServerID = intval( $SSID ); + $UARTID = intval( $UartID ); + $DEVID = intval( $ProtocolID ); $BShift = 0; if( $DevType == 3 ) $BShift = -160; + $QS = "INSERT INTO `lrf_sensors` SET `type_id`={$DevType}, `device_id`={$DEVID}, `uart_id`={$UARTID}, `data_status`=1, `max_range`={$Range}, base_shift={$BShift}"; $DATABASE->Query( $QS, false ); $AUXID = $DATABASE->getLastInsertID(); - $QS = "INSERT INTO `nodes` SET `type`={$DevType}, `site_id`={$SID}, `aux_id`={$AUXID}, `name`='{$NAME}'"; + $QS = "INSERT INTO `nodes` SET `type`={$DevType}, `site_id`={$SiteID}, `server_id`={$ServerID}, `aux_id`={$AUXID}, `name`='{$NAME}'"; $DATABASE->Query( $QS, false ); $NODEID = $DATABASE->getLastInsertID(); $PATH_CAM = $NODEID.'_'.$AUXID.'_CAMPORT'; $QS = "INSERT INTO `uart_settings` SET `node_id`={$NODEID}, `type`=1, `speed`=2400, `bit`=8, `parity`='N', `stop_bit`=1.0, `mode`=2, `port`=2, `path`='{$PATH_CAM}'"; $DATABASE->Query( $QS, false ); $CAMUARTID = $DATABASE->getLastInsertID(); - $MM = md5($PATH_CAM); - $QS = "INSERT INTO `resources` SET `node_id`={$NODEID}, `type`=1, `aux_id`={$CAMUARTID}, `device`='{$PATH_CAM}'"; - $DATABASE->Query( $QS, false ); - $CAMRESID = $DATABASE->getLastInsertID(); - + //$MM = md5($PATH_CAM); + //$QS = "INSERT INTO `resources` SET `node_id`={$NODEID}, `type`=1, `aux_id`={$CAMUARTID}, `device`='{$PATH_CAM}'"; + //$DATABASE->Query( $QS, false ); + //$CAMRESID = $DATABASE->getLastInsertID(); + $CAMRESID = createResource( $NODEID, $CAMUARTID, 1, $PATH_CAM ); $PATH_CTL = $NODEID.'_'.$AUXID.'_CTLPORT'; $QS = "INSERT INTO `uart_settings` SET `node_id`={$NODEID}, `type`=1, `speed`=19200, `bit`=8, `parity`='N', `stop_bit`=1.0, `mode`=1, `port`=1, `path`='{$PATH_CTL}'"; $DATABASE->Query( $QS, false ); $CTLUARTID = $DATABASE->getLastInsertID(); - $MM = md5($PATH_CTL); - $QS = "INSERT INTO `resources` SET `node_id`={$NODEID}, `type`=1, `aux_id`={$CTLUARTID}, `device`='{$PATH_CTL}'"; - $DATABASE->Query( $QS, false ); - $CTLRESID = $DATABASE->getLastInsertID(); - + //$MM = md5($PATH_CTL); + //$QS = "INSERT INTO `resources` SET `node_id`={$NODEID}, `type`=1, `aux_id`={$CTLUARTID}, `device`='{$PATH_CTL}'"; + //$DATABASE->Query( $QS, false ); + //$CTLRESID = $DATABASE->getLastInsertID(); + $CTLRESID = createResource( $NODEID, $CTLUARTID, 1, $PATH_CTL ); $QS="SELECT `node_id` as `id`, `id` as `rid` FROM `resources` WHERE `aux_id`={$UARTID} AND `type`=1"; $TR = $DATABASE->Query( $QS, false ); $CNID = $TR[0]['id']; $CAID = $TR[0]['rid']; - $QS = "INSERT INTO `connections` SET `site_id`={$SID}, `to`={$NODEID}, `to_aux`={$CTLRESID}, `from`={$CNID}, `from_aux`={$CAID}, `type`=1"; - $DATABASE->Query( $QS, false ); - $QS = "UPDATE `resources` SET `used`=b'1' WHERE `id`={$CAID}"; - $DATABASE->Query( $QS, false ); + //$QS = "INSERT INTO `connections` SET `site_id`={$SID}, `to`={$NODEID}, `to_aux`={$CTLRESID}, `from`={$CNID}, `from_aux`={$CTLRESID}, `type`=1"; + //$DATABASE->Query( $QS, false ); + //$QS = "UPDATE `resources` SET `used`=b'1' WHERE `id`={$CTLRESID}"; + //$DATABASE->Query( $QS, false ); + //From UART to Sensor + createConnection( $SiteID, $CNID, $CAID, $NODEID, $CTLRESID, 1 ); + return true; }; - function add3DSensor( $SiteID, $ServerNODE, $DevName, $IP, $PORT ){ + function add3DSensor( $SID, $SSID, $DevName, $IP, $PORT ){ global $DATABASE; + $SiteID = intval( $SID ); + $ServerID = intval( $SSID ); + $ServerNODE = getServerNode( $ServerID ); $QS = "INSERT INTO `lrf_sensors` SET `type_id`=5, `ip_address`='{$IP}', `port`='{$PORT}'"; $DATABASE->Query( $QS, false ); $DevID = $DATABASE->getLastInsertID(); - $QS = "INSERT INTO `nodes` SET `type`=5, `site_id`={$SiteID}, `aux_id`={$DevID}, `name`='{$DevName}'"; + $QS = "INSERT INTO `nodes` SET `type`=5, `site_id`={$SiteID}, `server_id`={$ServerID}, `aux_id`={$DevID}, `name`='{$DevName}'"; $DATABASE->Query( $QS, false ); $NodeID = $DATABASE->getLastInsertID(); $ResName = $IP . ':' . $PORT; $ResID = createResource( $NodeID, 0, 101, $ResName ); - $ServerNetResources = getResourceID( $ServerNODE, 101 ); + $ServerNetResources = getResourceIDS( $ServerNODE, 101 ); if( count( $ServerNetResources ) ){ $ServerNetRID = $ServerNetResources[0]; createConnection( $SiteID, $ServerNODE, $ServerNetRID, $NodeID, $ResID, 4 ); @@ -211,8 +244,12 @@ return true; }; - function addAnalogStaticCamera( $SiteID, $ServerNODE, $CamName, $StreamID, $ImagerSize, $F ){ + function addAnalogStaticCamera( $SID, $SSID, $CamName, $STID, $ImagerSize, $F ){ global $DATABASE, $CUser; + $SiteID = intval( $SID ); + $ServerID = intval( $SSID ); + $StreamID = intval( $STID ); + $ServerNODE = getServerNode( $ServerID ); $QS = "SELECT * FROM `media_streams` WHERE `id`={$StreamID}"; $T = $DATABASE->Query( $QS, false ); if( count($T) ){ @@ -223,40 +260,57 @@ $CamID = $DATABASE->getLastInsertID(); $QS = "UPDATE `media_streams` SET `source_id`={$CamID} WHERE `id`={$StreamID}"; $DATABASE->Query( $QS, false ); - $QS = "INSERT INTO `nodes` SET `site_id`={$SiteID}, `type`=10, `aux_id`={$CamID}, `aux_parameter`={$StreamID}, `name`='{$CamName}'"; + $QS = "INSERT INTO `nodes` SET `site_id`={$SiteID}, `server_id`={$ServerID},`type`=10, `aux_id`={$CamID}, `aux_parameter`={$StreamID}, `name`='{$CamName}'"; $DATABASE->Query( $QS, false ); $NodeID = $DATABASE->getLastInsertID(); $QS = "UPDATE `cameras` SET `node_id`={$NodeID} WHERE `id`={$CamID}"; $DATABASE->Query( $QS, false ); - $QS = "INSERT INTO `resources` SET `node_id`={$NodeID}, `type`=30, `aux_id`={$CamID}, `device`='Analog Video'"; - $DATABASE->Query( $QS, false ); - $AV_out_pin = $DATABASE->getLastInsertID(); - $QS = "SELECT `id` FROM `nodes` WHERE `site_id`={$SiteID} AND `type`=0 LIMIT 1"; - $CC = $DATABASE->Query( $QS, false ); - $ServerNODE = $CC[0]['id']; - $QS = "INSERT INTO `connections` SET `site_id`={$SiteID}, `from`={$NodeID}, `from_aux`={$AV_out_pin}, `to`={$ServerNODE}, `to_aux`=0, `type`=4"; - $DATABASE->Query( $QS, false ); + //$QS = "INSERT INTO `resources` SET `node_id`={$NodeID}, `type`=30, `aux_id`={$CamID}, `device`='Analog Video'"; + //$DATABASE->Query( $QS, false ); + //$AV_out_pin = $DATABASE->getLastInsertID(); + $AV_out_pin = createResource( $NodeID, $CamID, 30, 'Analog Video' ); + //$QS = "SELECT `id` FROM `nodes` WHERE `site_id`={$SiteID} AND `type`=0 LIMIT 1"; + //$CC = $DATABASE->Query( $QS, false ); + //$ServerNODE = $CC[0]['id']; + //$QS = "INSERT INTO `connections` SET `site_id`={$SiteID}, `from`={$NodeID}, `from_aux`={$AV_out_pin}, `to`={$ServerNODE}, `to_aux`=0, `type`=4"; + //$DATABASE->Query( $QS, false ); + createConnection( $SiteID, $NodeID, $AV_out_pin, $ServerNODE, 0, 4 ); return true; }; return false; }; - function addIpStaticCamera( $SiteID, $ServerNODE, $CamName, $CamID, $StreamID, $ImagerSize, $F ){ + function addIpStaticCamera( $SID, $SSID, $CNAME, $CID, $STID, $ISZ, $FN ){ global $DATABASE; - $QS = "UPDATE `cameras` SET `imager_type`={$ImagerSize}, `type`=12, `min_f`={$F} WHERE `id`={$CamID}"; - $DATABASE->Query( $QS, false ); - $QS = "UPDATE `media_streams` SET `source_id`={$CamID} WHERE `id`={$StreamID}"; - $DATABASE->Query( $QS, false ); - $QS = "INSERT INTO `nodes` SET `site_id`={$SiteID}, `type`=12, `aux_id`={$CamID}, `aux_parameter`={$StreamID}, `name`='{$CamName}'"; - $DATABASE->Query( $QS, false ); - $NodeID = $DATABASE->getLastInsertID(); - $RMD5 = md5( $CamID.' 30 '.$SiteID ); - $QS = "INSERT INTO `resources` SET `node_id`={$NodeID}, `type`=32, `aux_id`={$CamID}, `device`='Digial Video'"; - $DATABASE->Query( $QS, false ); - $AV_out_pin = $DATABASE->getLastInsertID(); - $QS = "INSERT INTO `connections` SET `site_id`={$SiteID}, `from`={$NodeID}, `from_aux`={$AV_out_pin}, `to`={$ServerNODE}, `to_aux`=0, `type`=4"; - $DATABASE->Query( $QS, false ); - return true; + + $SiteID = intval( $SID ); + $ServerID = intval( $SSID ); + $StreamID = intval( $STID ); + $CamID = intval( $CID ); + $ImagerSize = intval( $ISZ ); + $F = floatval( $FN ); + if( $CamID && $ServerID ){ + $ServerNODE = getServerNode( $ServerID ); + $CamName = $DATABASE->escape( $CNAME ); + $QS = "UPDATE `cameras` SET `imager_type`={$ImagerSize}, `type`=12, `min_f`={$F} WHERE `id`={$CamID}"; + $DATABASE->Query( $QS, false ); + $QS = "UPDATE `media_streams` SET `source_id`={$CamID} WHERE `id`={$StreamID}"; + $DATABASE->Query( $QS, false ); + $QS = "INSERT INTO `nodes` SET `site_id`={$SiteID}, `type`=12, `aux_id`={$CamID}, `aux_parameter`={$StreamID}, `name`='{$CamName}'"; + $DATABASE->Query( $QS, false ); + $NodeID = $DATABASE->getLastInsertID(); + + //$RMD5 = md5( $CamID.' 30 '.$SiteID ); + //$QS = "INSERT INTO `resources` SET `node_id`={$NodeID}, `type`=32, `aux_id`={$CamID}, `device`='Digial Video'"; + //$DATABASE->Query( $QS, false ); + //$AV_out_pin = $DATABASE->getLastInsertID(); + $AV_out_pin = createResource( $NodeID, $CamID, 32, 'Digital Video' ); + //$QS = "INSERT INTO `connections` SET `site_id`={$SiteID}, `from`={$NodeID}, `from_aux`={$AV_out_pin}, `to`={$ServerNODE}, `to_aux`=0, `type`=4"; + //$DATABASE->Query( $QS, false ); + createConnection( $SiteID, $NodeID, $AV_out_pin, $ServerNODE, 0, 4 ); + return true; + }; + return false; }; function addAnalogPtzCamera( $SiteID, $ServerNODE, $CamName, $StreamID, $ImagerSize, $Fmin, $Fmax, $PanMode, $PanAng, $TiltMode, $TiltAng, $Protocol, $Protocol_Aux, $UartID ){ @@ -289,64 +343,78 @@ return true; }; - function addIpPtzCamera( $SiteID, $ServerNODE, $CamName, $CamID, $StreamID, $ImagerSize, $LFL, $Zoom, $PanMode, $PanAng, $TiltMode, $TiltAng, $Protocol, $Protocol_Aux, $UART=0 ){ + function addIpPtzCamera( $SID, $SSID, $CamName, $CID, $STID, $ISZ, $FN, $Zoom, $PanMode, $PanAng, $TiltMode, $TiltAng, $Protocol, $Protocol_Aux, $UART=0 ){ global $DATABASE; - $QS = "SELECT * FROM `cameras` WHERE `id`={$CamID}"; - $CR = $DATABASE->Query( $QS, false ); - $Range = 0.0; - if( count( $CR ) ){ - $CamData = $CR[0]; - $QS = "INSERT INTO `nodes` SET `site_id`={$SiteID}, `type`=13, `aux_id`={$CamID}, `aux_parameter`={$StreamID}, `name`='{$CamName}'"; - $DATABASE->Query( $QS, false ); - $NODEID = $DATABASE->getLastInsertID(); - $DevICE = $CamID .':'.$StreamID.':STREAM'; - $QS = "INSERT INTO `resources` SET `node_id`={$NODEID}, `class`=4, `type`=32, `aux_id`={$StreamID}, `used`=1, `device`='{$DevICE}'"; - $DATABASE->Query( $QS, false ); - $STRRID = $DATABASE->getLastInsertID(); - $INSTRRIR = getResourceID( $ServerNODE, 101 ); - - $QS = "INSERT INTO `connections` SET `site_id`={$SiteID}, `from`={$NODEID}, `from_aux`={$STRRID}, `to`={$ServerNODE}, `to_aux`={$INSTRRIR[0]}, `type`=4"; - $DATABASE->Query( $QS, false ); - switch( $Protocol ){ - case 3:{ - // Onvif - $QS = "UPDATE `cameras` SET `node_id`={$NODEID}, `type`=13, `status`=3, `protocol`={$Protocol}, `imager_type`={$ImagerSize}, `lens_f`={$LFL}, `zoom`={$Zoom}, `pan_model`={$PanMode}, `pan_angles`={$PanAng}, `tilt_model`={$TiltMode}, `tilt_angles`={$TiltAng}, `max_range`={$Range} WHERE `id`={$CamID}"; - $DATABASE->Query( $QS, false ); - $DevICE = $CamID . ':eth0'; - $Key = md5( $DevICE ); - $QS = "INSERT INTO `network_interfaces` SET `device_name`='{$DevICE}', `key`='{$Key}', `mac`='{$CamData['mac']}'"; - $DATABASE->Query( $QS, false ); - $NIFID = $DATABASE->getLastInsertID(); - $DevICE = $CamID .':'.$StreamID.':CTRL'; - $QS = "INSERT INTO `resources` SET `node_id`={$NODEID}, `class`=3, `type`=101, `aux_id`={$NIFID}, `used`=1, `device`='{$DevICE}'"; - $DATABASE->Query( $QS, false ); - $CTLRID = $DATABASE->getLastInsertID(); - - $INCTLNID = $ServerNODE; - $INCTLRID = $INSTRRIR[0]; - $CTLTYP = 4; - break; - }; - default:{ - // any serial control - $QS = "UPDATE `cameras` SET `node_id`={$NODEID}, `type`=13, `status`=3, `protocol`={$Protocol}, `protocol_aux`={$Protocol_Aux}, `uart_id`={$UART}, `imager_type`={$ImagerSize}, `lens_f`={$LFL}, `zoom`={$Zoom}, `pan_model`={$PanMode}, `pan_angles`={$PanAng}, `tilt_model`={$TiltMode}, `tilt_angles`={$TiltAng}, `max_range`={$Range} WHERE `id`={$CamID}"; - $DATABASE->Query( $QS, false ); - $DevICE = $CamID .':'.$StreamID.':CTRL'; - $QS = "INSERT INTO `resources` SET `node_id`={$NODEID}, `class`=1, `type`=1 `aux_id`={$CamID}, `used`=1, `device`='{$DevICE}'"; - $DATABASE->Query( $QS, false ); - $CTLRID = $DATABASE->getLastInsertID(); - $QS = "SELECT `id`, `node_id` FROM `resources` WHERE `type`=1, `aux_id`={$UART}"; - $RR = $DATABASE->Query( $QS, false ); - - $INCTLRID = $RR[0]['id']; - $INCTLNID = $RR[0]['node_id']; - $CTLTYP = 1; - break; + + $SiteID = intval( $SID ); + $ServerID = intval( $SSID ); + $StreamID = intval( $STID ); + $CamID = intval( $CID ); + $ImagerSize = intval( $ISZ ); + $LFL = floatval( $FN ); + if( $CamID && $ServerID ){ + $ServerNODE = getServerNode( $ServerID ); + $QS = "SELECT * FROM `cameras` WHERE `id`={$CamID}"; + $CR = $DATABASE->Query( $QS, false ); + $Range = 0.0; + if( count( $CR ) ){ + $CamData = $CR[0]; + $QS = "INSERT INTO `nodes` SET `site_id`={$SiteID}, `server_id`={$ServerID}, `type`=13, `aux_id`={$CamID}, `aux_parameter`={$StreamID}, `name`='{$CamName}'"; + $DATABASE->Query( $QS, false ); + $NODEID = $DATABASE->getLastInsertID(); + $DevICE = $CamID .':'.$StreamID.':STREAM'; + + //$QS = "INSERT INTO `resources` SET `node_id`={$NODEID}, `class`=4, `type`=32, `aux_id`={$StreamID}, `used`=1, `device`='{$DevICE}'"; + //$DATABASE->Query( $QS, false ); + //$STRRID = $DATABASE->getLastInsertID(); + $STRRID = createResource( $NODEID, $CamID, 32, 'Digital Video' ); + $INSTRRIR = getResourceIDS( $ServerNODE, 101 ); + + $QS = "INSERT INTO `connections` SET `site_id`={$SiteID}, `from`={$NODEID}, `from_aux`={$STRRID}, `to`={$ServerNODE}, `to_aux`={$INSTRRIR[0]}, `type`=4"; + $DATABASE->Query( $QS, false ); + switch( $Protocol ){ + case 3:{ + // Onvif + $QS = "UPDATE `cameras` SET `node_id`={$NODEID}, `type`=13, `status`=3, `protocol`={$Protocol}, `imager_type`={$ImagerSize}, `lens_f`={$LFL}, `zoom`={$Zoom}, `pan_model`={$PanMode}, `pan_angles`={$PanAng}, `tilt_model`={$TiltMode}, `tilt_angles`={$TiltAng}, `max_range`={$Range} WHERE `id`={$CamID}"; + $DATABASE->Query( $QS, false ); + $DevICE = $CamID . ':eth0'; + $Key = md5( $DevICE ); + $QS = "INSERT INTO `network_interfaces` SET `device_name`='{$DevICE}', `key`='{$Key}', `mac`='{$CamData['mac']}'"; + $DATABASE->Query( $QS, false ); + $NIFID = $DATABASE->getLastInsertID(); + $DevICE = $CamID .':'.$StreamID.':CTRL'; + //$QS = "INSERT INTO `resources` SET `node_id`={$NODEID}, `class`=3, `type`=101, `aux_id`={$NIFID}, `used`=1, `device`='{$DevICE}'"; + //$DATABASE->Query( $QS, false ); + //$CTLRID = $DATABASE->getLastInsertID(); + $CTLRID = createResource( $NODEID, $NIFID, 101, $DevICE ); + $INCTLNID = $ServerNODE; + $INCTLRID = $INSTRRIR[0]; + $CTLTYP = 4; + break; + }; + default:{ + // any serial control + $QS = "UPDATE `cameras` SET `node_id`={$NODEID}, `type`=13, `status`=3, `protocol`={$Protocol}, `protocol_aux`={$Protocol_Aux}, `uart_id`={$UART}, `imager_type`={$ImagerSize}, `lens_f`={$LFL}, `zoom`={$Zoom}, `pan_model`={$PanMode}, `pan_angles`={$PanAng}, `tilt_model`={$TiltMode}, `tilt_angles`={$TiltAng}, `max_range`={$Range} WHERE `id`={$CamID}"; + $DATABASE->Query( $QS, false ); + $DevICE = $CamID .':'.$StreamID.':CTRL'; + //$QS = "INSERT INTO `resources` SET `node_id`={$NODEID}, `class`=1, `type`=1 `aux_id`={$CamID}, `used`=1, `device`='{$DevICE}'"; + //$DATABASE->Query( $QS, false ); + //$CTLRID = $DATABASE->getLastInsertID(); + $CTLRID = createResource( $NODEID, $CamID, 1, $DevICE ); + $QS = "SELECT `id`, `node_id` FROM `resources` WHERE `type`=1, `aux_id`={$UART}"; + $RR = $DATABASE->Query( $QS, false ); + + $INCTLRID = $RR[0]['id']; + $INCTLNID = $RR[0]['node_id']; + $CTLTYP = 1; + break; + }; }; + //$QS = "INSERT INTO `connections` SET `site_id`={$SiteID}, `from`={$NODEID}, `from_aux`={$CTLRID}, `to`={$INCTLNID}, `to_aux`={$INCTLRID}, `type`={$CTLTYP}"; + //$DATABASE->Query( $QS, false ); + createConnection( $SiteID, $NODEID, $CTLRID, $INCTLNID, $INCTLRID, $CTLTYP ); + return true; }; - $QS = "INSERT INTO `connections` SET `site_id`={$SiteID}, `from`={$NODEID}, `from_aux`={$CTLRID}, `to`={$INCTLNID}, `to_aux`={$INCTLRID}, `type`={$CTLTYP}"; - $DATABASE->Query( $QS, false ); - return true; }; return false; }; @@ -594,5 +662,56 @@ }; loadNotPicture(); }; + + function getV4L2DeviceName( $Dev ){ + $CMD = 'v4l2-ctl -D -d ' . $Dev; + $Data = `$CMD`; + $TArr = explode( "\n", $Data ); + $RD = array(); + foreach( $TArr as $R ){ + $CL = trim( $R ); + $TB = explode(':', $CL ); + if( stripos( $R, 'Model' )!== false ) $RD['name'] = trim( $TB[1] ); + if( stripos( $R, 'Driver name' )!== false ) $RD['dev'] = trim( $TB[1] ); + }; + if( count( $RD ) ) return $RD; + return array('name'=>'-noname-','dev'=>'unknown'); + }; + function validateCamConnections( $StreamID, $UartID ){ + global $DATABASE; + $QS = "SELECT * FROM `media_streams` WHERE `id`={$StreamID}"; + $SS = $DATABASE->Query( $QS ); + if( count( $SS ) == 0 ) return -5; + $STREAM = $SS[0]; + $CAP_NODE = -1; + $CTL_NODE = -1; + if( $STREAM['source_type'] == 'A' ){ + $QS = "SELECT * FROM `resources` WHERE `aux_id`={$StreamID} AND `type`= 31"; + $RR = $DATABASE->Query( $QS ); + if( count( $RR ) == 0 ) return -4; + $RESOURCE = $RR[0]; + $CAP_NODE = $RESOURCE['node_id']; + }; + if( $UartID ){ + $QS= "SELECT `node_id` FROM `resources` WHERE `aux_id`={$UartID}"; + $UU = $DATABASE->Query( $QS ); + if( count( $UU ) == 0 ) return -3; + $UART_NODE = $UU[0]['node_id']; + $CTL_NODE = getServerID( $UART_NODE ); + if( $CTL_NODE == 0 ){ + // Inderect UART + $QS = "SELECT `from` FROM `connections` WHERE `to`={$UART_NODE}"; + $CC = $DATABASE->Query( $QS ); + if( count( $CC ) == 0 ) return -2; + $CTL_NODE = $CC[0]['from']; + }; + }; + if( $CAP_NODE > 0 && $CTL_NODE > 0 ){ + if( $CAP_NODE != $CTL_NODE ) return -1; + } elseif( $CAP_NODE > 0 || $CTL_NODE > 0 ){ + return ($CAP_NODE>0)?$CAP_NODE:$CTL_NODE; + }; + return 0; + }; ?> \ No newline at end of file diff --git a/lib/php/onvif/oooo.txt b/lib/php/onvif/oooo.txt new file mode 100644 index 0000000..a00a098 --- /dev/null +++ b/lib/php/onvif/oooo.txt @@ -0,0 +1,64 @@ +QU: http://192.168.200.127/onvif/device_service + +------------------ +string(261) "" + +~~~~~~~~~~~~~~~~~~ +string(630) "HTTP/1.1 401 Unauthorized +Date: Sun, 24 Jul 2022 16:40:09 GMT +Server: Apache/2.4.43 (Unix) OpenSSL/1.1.1g +WWW-Authenticate: Digest realm="AXIS_WS_B8A44F2C878D", nonce="E/V0uI/kBQA=6638cbdcec1f1c924eadeb76905d8b9d195293c4", algorithm=MD5, qop="auth" +Content-Type: text/xml; charset=utf-8 +Content-Length: 0 + +HTTP/1.1 200 OK +Date: Sun, 24 Jul 2022 16:40:09 GMT +Server: Apache/2.4.43 (Unix) OpenSSL/1.1.1g +Authentication-Info: rspauth="314438a6a6e3a991ec4c62dce6e80dc2", cnonce="ZWI0OTk4Y2IyYTQwMWZjMzBiZTRlZjQ0YzI5YjNiNjQ=", nc=00000001, qop=auth +Content-Type: application/soap+xml; charset=utf-8 +Content-Length: 3722 + +" + +~~~~~~~~~~~~~~~~~~ +string(3722) " +NTPtrueIST-2IDT,M3.4.4/26,M10.5.0164092022724194092022724" + +~~~~~~~~~~~~~~~~~~ +(Init) An Error Catched! + + + + +Time Is OK + + +QU: http://192.168.200.127/onvif/device_service + +------------------ +string(924) "argusXWPl7lQvtx2+7BmNC+a8AQ==FwNTYmA=2022-07-24T17:39:28.000ZAll" + +~~~~~~~~~~~~~~~~~~ +string(658) "HTTP/1.1 401 Unauthorized +Date: Sun, 24 Jul 2022 16:40:09 GMT +Server: Apache/2.4.43 (Unix) OpenSSL/1.1.1g +WWW-Authenticate: Digest realm="AXIS_WS_B8A44F2C878D", nonce="oUB1uI/kBQA=bde62d90be3bb4fcdfd588e32b4f1cecb871614e", algorithm=MD5, qop="auth" +Content-Type: text/xml; charset=utf-8 +Content-Length: 0 + +HTTP/1.1 400 Bad Request +Date: Sun, 24 Jul 2022 16:40:09 GMT +Server: Apache/2.4.43 (Unix) OpenSSL/1.1.1g +Authentication-Info: rspauth="92c44022653249fb58f336049bb2d41b", cnonce="NmFmMTQ2NmJmNmVhMjFiYzgzYTUyMjIwYWNiMTM3YjI=", nc=00000001, qop=auth +Content-Type: application/soap+xml; charset=utf-8 +Content-Length: 3518 +Connection: close + +" + +~~~~~~~~~~~~~~~~~~ +string(3518) " +SOAP-ENV:Senderter:NotAuthorizedSender not authorizedThe action requested requires authorization and the sender is not authorized" + +~~~~~~~~~~~~~~~~~~ +Caught exception: GetCapabilities: Communication error diff --git a/lib/php/onvif/test_v11.php b/lib/php/onvif/test_v11.php index 7502cf9..2019591 100644 --- a/lib/php/onvif/test_v11.php +++ b/lib/php/onvif/test_v11.php @@ -8,23 +8,30 @@ //exit(); $test=new ponvif(); //$test->setUsername('gagua'); - $test->setUsername('admin'); - $test->setPassword('4GetMyID');//109 + //$test->setUsername('argus'); + //$test->setPassword('QNJ9ydwAmmNM8wd');//109 //$test->setIPAddress('192.168.0.109'); - $test->setIPAddress('192.168.200.106'); + //$test->setIPAddress('192.168.200.127'); + $test->setUsername('admin'); + $test->setPassword('4GetMyID'); + $test->setIPAddress('192.168.200.110'); + //$test->setAuthMethod( 1 ); try { $test->initialize(); - + echo "\n\n\nInit OK\n\n\n"; if ( $test->isFault($sources=$test->getSources())) die("Error getting sources"); - //print_r( $sources ); + print_r( $sources ); $profileToken=$sources[0][0]['profiletoken']; $ptzNodeToken=$sources[0][0]['ptz']['nodetoken']; + //echo "Media: " . $test->media_GetStreamUri($profileToken) . "\n\n"; //echo "Snapshot: " . $test->media_GetSnapshotUri('Profile_2') . "\n\n"; //$PAPA = $test->media_GetVideoSources(); - //$test->ptz_AbsoluteMove($profileToken, -1, -1, 0); + //$test->ptz_AbsoluteMove($profileToken, 0, 0, 0); //$PAPA = $test->ptz_GetStatus($profileToken); - $test->ptz_ContinuousMove( $profileToken, -0.2, 0 ); + $test->ptz_ContinuousMove( $profileToken, -.5, 0 ); + sleep(10); + $test->ptz_Stop($profileToken,1,1); //var_dump( $PAPA ); } catch (Exception $e) { diff --git a/lib/php/onvif/toto.php b/lib/php/onvif/toto.php index c8b818f..5b7d6b7 100644 --- a/lib/php/onvif/toto.php +++ b/lib/php/onvif/toto.php @@ -27,6 +27,7 @@ class Ponvif { protected $discoverymcastip='239.255.255.250'; protected $discoverymcastport=3702; protected $discoveryhideduplicates=true; + protected $AuthMethod = 0; public function setProxyHost($proxyHost) { $this->proxyhost = $proxyHost; } public function getProxyHost() { return $this->proxyhost; } @@ -58,6 +59,7 @@ class Ponvif { public function setDiscoveryMcastPort($discoverymcastport) { $this->discoverymcastport = $discoverymcastport; } public function setDiscoveryHideDuplicates($discoveryhideduplicates) { $this->discoveryhideduplicates = $discoveryhideduplicates; } public function getSnapshotUri() { return $this->snapshoturi; } + public function setAuthMethod( $A ){ $this->AuthMethod = $A; } /* Constructor & Destructor @@ -119,7 +121,7 @@ class Ponvif { try { $datetime=$this->core_GetSystemDateAndTime(); $timestamp=mktime($datetime['Time']['Hour'], $datetime['Time']['Minute'], $datetime['Time']['Second'], - $datetime['Date']['Month'], $datetime['Date']['Day'], $datetime['Date']['Year']); + $datetime['Date']['Month'], $datetime['Date']['Day'], $datetime['Date']['Year']); $this->deltatime=time()-$timestamp-5; } catch (Exception $e) {} @@ -725,12 +727,16 @@ class Ponvif { curl_setopt($soap_do, CURLOPT_TIMEOUT, 2 ); curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true ); curl_setopt($soap_do, CURLOPT_SSL_VERIFYPEER, false); - curl_setopt($soap_do, CURLOPT_VERBOSE, true); + //curl_setopt($soap_do, CURLOPT_VERBOSE, true); //curl_setopt($soap_do, CURLOPT_DEBUG, true); curl_setopt($soap_do, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($soap_do, CURLOPT_POST, true ); curl_setopt($soap_do, CURLOPT_POSTFIELDS, $post_string); curl_setopt($soap_do, CURLOPT_HTTPHEADER, array('Expect:', 'Content-Type: application/soap+xml; charset=utf-8', 'Content-Length: '.strlen($post_string) )); + switch( $this->AuthMethod ){ + case 0: curl_setopt($soap_do, CURLOPT_HTTPAUTH, CURLAUTH_BASIC ); break; + case 1: curl_setopt($soap_do, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST ); break; + }; curl_setopt($soap_do, CURLOPT_USERPWD, $this->username . ":" . $this->password); // HTTP authentication if ( ($result = curl_exec($soap_do)) === false) { $err = curl_error($soap_do); diff --git a/lib/php/onvif/toto2.php b/lib/php/onvif/toto2.php new file mode 100644 index 0000000..1faac64 --- /dev/null +++ b/lib/php/onvif/toto2.php @@ -0,0 +1,838 @@ +proxyhost = $proxyHost; } + public function getProxyHost() { return $this->proxyhost; } + public function setProxyPort($proxyPort) { $this->proxyport = $proxyPort; } + public function getProxyPort() { return $this->proxyport; } + public function setProxyUsername($proxyUsername) { $this->proxyusername = $proxyUsername; } + public function getProxyUsername() { return $this->proxyusername; } + public function setProxyPassword($proxyPassword) { $this->proxypassword = $proxyPassword; } + public function getProxyPassword() { return $this->proxypassword; } + public function setUsername($username) { $this->username = $username; } + public function getUsername() { return $this->username; } + public function setPassword($password) { $this->password = $password; } + public function getPassword() { return $this->password; } + public function getDeviceUri() { return $this->mediauri; } + public function setDeviceUri($deviceUri) { $this->mediauri=$deviceUrl; } + public function getIPAddress($ipAddress) { return $this->ipAddress; } + public function setIPAddress($ipAddress) { $this->ipaddress=$ipAddress; } + public function getSources() { return $this->sources; } + public function getMediaUri() { return $this->mediauri; } + public function getPTZUri() { return $this->ptzuri; } + public function getBaseUrl() { return $this->baseuri; } + public function getSupportedVersion() { return $this->onvifversion; } + public function getCapabilities() { return $this->capabilities; } + public function setBreakOnError($intransingent) { $this->intransingent=$intransingent; } + public function getLastResponse() { return $this->lastresponse; } + public function setDiscoveryTimeout($discoverytimeout) { $this->discoverytimeout = $discoverytimeout; } + public function setDiscoveryBindIp($discoverybindip) { $this->discoverybindip = $discoverybindip; } + public function setDiscoveryMcastIp($discoverymcastip) { $this->discoverymcastip = $discoverymcastip; } + public function setDiscoveryMcastPort($discoverymcastport) { $this->discoverymcastport = $discoverymcastport; } + public function setDiscoveryHideDuplicates($discoveryhideduplicates) { $this->discoveryhideduplicates = $discoveryhideduplicates; } + public function getSnapshotUri() { return $this->snapshoturi; } + public function setDigestMethod( $DM ){ $this->digestMethod = $DM; } + public function getDigestMethod(){ return $this->digestMethod; } + + /* + Constructor & Destructor + */ + public function __construct() + { + // nothing to do + } + + public function __destruct() + { + // nothing to do + } + + /* + WS-Discovery + */ + public function discover(){ + $result = array(); + $timeout = time() + $this->discoverytimeout; + $post_string = 'uuid:84ede3de-7dec-11d0-c360-f01234567890urn:schemas-xmlsoap-org:ws:2005:04:discoveryhttp://schemas.xmlsoap.org/ws/2005/04/discovery/Probedn:NetworkVideoTransmitter'; + try { + if(FALSE == ($sock = @socket_create(AF_INET, SOCK_DGRAM, SOL_UDP))){ + echo('Create socket error: ['.socket_last_error().'] '.socket_strerror(socket_last_error())); + } + //if(FALSE == @socket_bind($sock, $this->discoverybindip, rand(20000, 40000))){ + // echo('Bind socket error: ['.socket_last_error().'] '.socket_strerror(socket_last_error())); + //} + //socket_set_option($sock, IPPROTO_IP, MCAST_JOIN_GROUP, array('group' => $this->discoverymcastip)); + socket_sendto($sock, $post_string, strlen($post_string), 0, $this->discoverymcastip, $this->discoverymcastport); + socket_set_nonblock($sock); + while(time() < $timeout){ + if( FALSE !== @socket_recvfrom($sock, $response, 9999, 0, $from, $this->discoverymcastport)){ + if( $response != NULL && $response != $post_string ){ + $response = $this->_xml2array($response); + if(!$this->isFault($response)){ + $response['Envelope']['Body']['ProbeMatches']['ProbeMatch']['IPAddr'] = $from; + if($this->discoveryhideduplicates){ + $result[$from] = $response['Envelope']['Body']['ProbeMatches']['ProbeMatch']; + }else{ + $result[] = $response['Envelope']['Body']['ProbeMatches']['ProbeMatch']; + } + } + } + } + } + socket_close($sock); + } catch (Exception $e) {} + sort($result); + return $result; + } + + /* + Public functions (basic initialization method and other collaterals) + */ + public function initialize() { + $this->mediauri='http://'.$this->ipaddress.'/onvif/device_service'; + + try { + $datetime=$this->core_GetSystemDateAndTime(); + $timestamp=mktime($datetime['Time']['Hour'], $datetime['Time']['Minute'], $datetime['Time']['Second'], + $datetime['Date']['Month'], $datetime['Date']['Day'], $datetime['Date']['Year']); + $this->deltatime = time()-$timestamp;//-5; + } catch( Exception $e ) { + } + $this->capabilities=$this->core_GetCapabilities(); + echo "\n\n\n\nGet Cap\n\n\n"; + $onvifVersion=$this->_getOnvifVersion($this->capabilities); + $this->mediauri=$onvifVersion['media']; + $this->deviceuri=$onvifVersion['device']; + $this->ptzuri=$onvifVersion['ptz']; + preg_match("/^http(.*)onvif\//",$this->mediauri,$matches); + $this->baseuri=$matches[0]; + $this->onvifversion=array('major'=>$onvifVersion['major'],'minor'=>$onvifVersion['minor']); + $this->videosources=$this->media_GetVideoSources(); + $this->profiles=$this->media_GetProfiles(); + $this->sources=$this->_getActiveSources($this->videosources,$this->profiles); + } + + public function isFault($response) { // Useful to check if response contains a fault + if( is_array( $response ) ){ + if( array_key_exists('Fault', $response ) ) return true; + if( array_key_exists('Envelope', $response ) ) + if( is_array( $response['Envelope'] ) ) + if( array_key_exists('Body', $response['Envelope'] ) ) + if( is_array( $response['Envelope']['Body'] ) ) + if( array_key_exists('Fault', $response['Envelope']['Body'] ) ) return true; + }; + return false; + } + + /* + Public wrappers for a subset of ONVIF primitives + */ + public function core_GetSystemDateAndTime() { + $post_string=''; + if( $this->isFault($response=$this->_send_request($this->mediauri,$post_string)) ){ + if ($this->intransingent) throw new Exception('GetSystemDateAndTime: Communication error'); + } else { + return $response['Envelope']['Body']['GetSystemDateAndTimeResponse']['SystemDateAndTime']['UTCDateTime']; + } + } + + public function core_GetCapabilities() { + $REQ=$this->_makeToken(); + $post_string='%%USERNAME%%%%PASSWORD%%%%NONCE%%%%CREATED%%All'; + $post_string=str_replace(array("%%USERNAME%%", + "%%PASSWORD%%", + "%%NONCE%%", + "%%CREATED%%"), + array($REQ['USERNAME'], + $REQ['PASSDIGEST'], + $REQ['NONCE'], + $REQ['TIMESTAMP']), + $post_string); + if ($this->isFault($response=$this->_send_request($this->mediauri,$post_string))) { + if ($this->intransingent) throw new Exception('GetCapabilities: Communication error'); + } + else + return $response['Envelope']['Body']['GetCapabilitiesResponse']['Capabilities']; + } + + public function media_GetVideoSources() { + $REQ=$this->_makeToken(); + $post_string='%%USERNAME%%%%PASSWORD%%%%NONCE%%%%CREATED%%'; + $post_string=str_replace(array("%%USERNAME%%", + "%%PASSWORD%%", + "%%NONCE%%", + "%%CREATED%%"), + array($REQ['USERNAME'], + $REQ['PASSDIGEST'], + $REQ['NONCE'], + $REQ['TIMESTAMP']), + $post_string); + //echo "POST STRING:" . $post_string . "\n\n"; + if ($this->isFault($response=$this->_send_request($this->mediauri,$post_string))) { + if ($this->intransingent) throw new Exception('GetVideoSources: Communication error'); + } + else + // var_dump( $response ); + return $response['Envelope']['Body']['GetVideoSourcesResponse']['VideoSources']; + } + + public function media_GetProfiles() { + $REQ=$this->_makeToken(); + $post_string='%%USERNAME%%%%PASSWORD%%%%NONCE%%%%CREATED%%'; + $post_string=str_replace(array("%%USERNAME%%", + "%%PASSWORD%%", + "%%NONCE%%", + "%%CREATED%%"), + array($REQ['USERNAME'], + $REQ['PASSDIGEST'], + $REQ['NONCE'], + $REQ['TIMESTAMP']), + $post_string); + if ($this->isFault($response=$this->_send_request($this->mediauri,$post_string))) { + if ($this->intransingent) throw new Exception('GetProfiles: Communication error'); + } + else + return $response['Envelope']['Body']['GetProfilesResponse']['Profiles']; + } + + public function media_GetServices() { + $REQ=$this->_makeToken(); + $post_string='%%USERNAME%%%%PASSWORD%%%%NONCE%%%%CREATED%%false'; + $post_string=str_replace(array("%%USERNAME%%", + "%%PASSWORD%%", + "%%NONCE%%", + "%%CREATED%%"), + array($REQ['USERNAME'], + $REQ['PASSDIGEST'], + $REQ['NONCE'], + $REQ['TIMESTAMP']), + $post_string); + if ($this->isFault($this->_send_request($this->mediauri,$post_string))) { + if ($this->intransingent) throw new Exception('GetServices: Communication error'); + } + } + + public function core_GetDeviceInformation() { + $REQ=$this->_makeToken(); + $post_string='%%USERNAME%%%%PASSWORD%%%%NONCE%%%%CREATED%%'; + $post_string=str_replace(array("%%USERNAME%%", + "%%PASSWORD%%", + "%%NONCE%%", + "%%CREATED%%"), + array($REQ['USERNAME'], + $REQ['PASSDIGEST'], + $REQ['NONCE'], + $REQ['TIMESTAMP']), + $post_string); + if ($this->isFault($response=$this->_send_request($this->mediauri,$post_string))) { + if ($this->intransingent) throw new Exception('GetDeviceInformation: Communication error'); + } + else + return $response['Envelope']['Body']['GetDeviceInformationResponse']; + } + + public function media_GetStreamUri($profileToken,$stream="RTP-Unicast",$protocol="RTSP") { + $REQ=$this->_makeToken(); + $post_string='%%USERNAME%%%%PASSWORD%%%%NONCE%%%%CREATED%%%%STREAM%%%%PROTOCOL%%%%PROFILETOKEN%%'; + $post_string=str_replace( + array("%%USERNAME%%", + "%%PASSWORD%%", + "%%NONCE%%", + "%%CREATED%%", + "%%PROFILETOKEN%%", + "%%STREAM%%", + "%%PROTOCOL%%"), + array($REQ['USERNAME'], + $REQ['PASSDIGEST'], + $REQ['NONCE'], + $REQ['TIMESTAMP'], + $profileToken, + $stream, + $protocol), + $post_string + ); + if ($this->isFault($response=$this->_send_request($this->mediauri,$post_string))) { + if ($this->intransingent) throw new Exception('GetStreamUri: Communication error'); + } + else + return $response['Envelope']['Body']['GetStreamUriResponse']['MediaUri']['Uri']; + } + + public function media_GetSnapshotUri($profileToken) { + $REQ=$this->_makeToken(); + $post_string='%%USERNAME%%%%PASSWORD%%%%NONCE%%%%CREATED%%%%PROFILETOKEN%%'; + $post_string=str_replace(array("%%USERNAME%%", + "%%PASSWORD%%", + "%%NONCE%%", + "%%CREATED%%", + "%%PROFILETOKEN%%"), + array($REQ['USERNAME'], + $REQ['PASSDIGEST'], + $REQ['NONCE'], + $REQ['TIMESTAMP'], + $profileToken), + $post_string); + if ($this->isFault($response=$this->_send_request($this->mediauri,$post_string))) { + if ($this->intransingent) throw new Exception('GetSnapshotUri: Communication error'); + var_dump($response); + } + else + return $response['Envelope']['Body']['GetSnapshotUriResponse']['MediaUri']['Uri']; + } + + public function ptz_GetPresets($profileToken) { + if ($this->ptzuri=='') return array(); + $REQ=$this->_makeToken(); + $post_string='%%USERNAME%%%%PASSWORD%%%%NONCE%%%%CREATED%%%%PROFILETOKEN%%'; + $post_string=str_replace(array("%%USERNAME%%", + "%%PASSWORD%%", + "%%NONCE%%", + "%%CREATED%%", + "%%PROFILETOKEN%%"), + array($REQ['USERNAME'], + $REQ['PASSDIGEST'], + $REQ['NONCE'], + $REQ['TIMESTAMP'], + $profileToken), + $post_string); + if ($this->isFault($response=$this->_send_request($this->ptzuri,$post_string))) { + if ($this->intransingent) throw new Exception('GetPresets: Communication error'); + } + else { + $getpresetsresponse=$response['Envelope']['Body']['GetPresetsResponse']['Preset']; + $presets=array(); + foreach ($getpresetsresponse as $preset) { + $presets[]=array('Token'=>$preset['@attributes']['token'], + 'Name'=>$preset['Name'], + 'PTZPosition'=>$preset['PTZPosition']); + } + return $presets; + } + } + + public function ptz_GetNode($ptzNodeToken) { + if ($this->ptzuri=='') return array(); + $REQ=$this->_makeToken(); + $post_string='%%USERNAME%%%%PASSWORD%%%%NONCE%%%%CREATED%%%%NODETOKEN%%'; + $post_string=str_replace(array("%%USERNAME%%", + "%%PASSWORD%%", + "%%NONCE%%", + "%%CREATED%%", + "%%NODETOKEN%%"), + array($REQ['USERNAME'], + $REQ['PASSDIGEST'], + $REQ['NONCE'], + $REQ['TIMESTAMP'], + $ptzNodeToken), + $post_string); + if ($this->isFault($response=$this->_send_request($this->ptzuri,$post_string))) { + if ($this->intransingent) throw new Exception('GetNode: Communication error'); + } + else + return $response['Envelope']['Body']['GetNodeResponse']; + } + + public function ptz_GotoPreset($profileToken,$presetToken,$speed_pantilt_x,$speed_pantilt_y,$speed_zoom_x) { + if ($this->ptzuri=='') return array(); + $REQ=$this->_makeToken(); + $post_string='%%USERNAME%%%%PASSWORD%%%%NONCE%%%%CREATED%%%%PROFILETOKEN%%%%PRESETTOKEN%%'; + $post_string=str_replace(array("%%USERNAME%%", + "%%PASSWORD%%", + "%%NONCE%%", + "%%CREATED%%", + "%%PROFILETOKEN%%", + "%%PRESETTOKEN%%", + "%%SPEEDPANTILTX%%", + "%%SPEEDPANTILTY%%", + "%%SPEEDZOOMX%%"), + array($REQ['USERNAME'], + $REQ['PASSDIGEST'], + $REQ['NONCE'], + $REQ['TIMESTAMP'], + $profileToken, + $presetToken, + $speed_pantilt_x, + $speed_pantilt_y, + $speed_zoom_x), + $post_string); + if ($this->isFault($this->_send_request($this->ptzuri,$post_string))) { + if ($this->intransingent) throw new Exception('GotoPreset: Communication error'); + } + } + + public function ptz_RemovePreset($profileToken,$presetToken) { + if ($this->ptzuri=='') return array(); + $REQ=$this->_makeToken(); + $post_string='%%USERNAME%%%%PASSWORD%%%%NONCE%%%%CREATED%%%%PROFILETOKEN%%%%PRESETTOKEN%%'; + $post_string=str_replace(array("%%USERNAME%%", + "%%PASSWORD%%", + "%%NONCE%%", + "%%CREATED%%", + "%%PROFILETOKEN%%", + "%%PRESETTOKEN%%"), + array($REQ['USERNAME'], + $REQ['PASSDIGEST'], + $REQ['NONCE'], + $REQ['TIMESTAMP'], + $profileToken, + $presetToken), + $post_string); + if ($this->isFault($this->_send_request($this->ptzuri,$post_string))) { + if ($this->intransingent) throw new Exception('RemovePreset: Communication error'); + } + } + + public function ptz_SetPreset($profileToken,$presetName) { + if ($this->ptzuri=='') return array(); + $REQ=$this->_makeToken(); + $post_string='%%USERNAME%%%%PASSWORD%%%%NONCE%%%%CREATED%%%%PROFILETOKEN%%%%PRESETNAME%%'; + $post_string=str_replace(array("%%USERNAME%%", + "%%PASSWORD%%", + "%%NONCE%%", + "%%CREATED%%", + "%%PROFILETOKEN%%", + "%%PRESETNAME%%"), + array($REQ['USERNAME'], + $REQ['PASSDIGEST'], + $REQ['NONCE'], + $REQ['TIMESTAMP'], + $profileToken, + $presetName), + $post_string); + if ($this->isFault($this->_send_request($this->ptzuri,$post_string))) { + if ($this->intransingent) throw new Exception('SetPreset: Communication error'); + } + } + + public function ptz_RelativeMove($profileToken,$translation_pantilt_x,$translation_pantilt_y,$speed_pantilt_x,$speed_pantilt_y) { + if ($this->ptzuri=='') return array(); + $REQ=$this->_makeToken(); + $post_string='%%USERNAME%%%%PASSWORD%%%%NONCE%%%%CREATED%%%%PROFILETOKEN%%'; + $post_string=str_replace(array("%%USERNAME%%", + "%%PASSWORD%%", + "%%NONCE%%", + "%%CREATED%%", + "%%PROFILETOKEN%%", + "%%TRANSLATIONPANTILTX%%", + "%%TRANSLATIONPANTILTY%%", + "%%SPEEDPANTILTX%%", + "%%SPEEDPANTILTY%%"), + array($REQ['USERNAME'], + $REQ['PASSDIGEST'], + $REQ['NONCE'], + $REQ['TIMESTAMP'], + $profileToken, + $translation_pantilt_x, + $translation_pantilt_y, + $speed_pantilt_x, + $speed_pantilt_y), + $post_string); + if ($this->isFault($this->_send_request($this->ptzuri,$post_string))) { + if ($this->intransingent) throw new Exception('RelativeMove: Communication error'); + } + } + + public function ptz_RelativeMoveZoom($profileToken,$zoom,$speedZoom) { + if ($this->ptzuri=='') return array(); + $REQ=$this->_makeToken(); + $post_string='%%USERNAME%%%%PASSWORD%%%%NONCE%%%%CREATED%%%%PROFILETOKEN%%'; + $post_string=str_replace(array("%%USERNAME%%", + "%%PASSWORD%%", + "%%NONCE%%", + "%%CREATED%%", + "%%PROFILETOKEN%%", + "%%SPEEDZOOM%%", + "%%ZOOM%%"), + array($REQ['USERNAME'], + $REQ['PASSDIGEST'], + $REQ['NONCE'], + $REQ['TIMESTAMP'], + $profileToken, + $speedZoom, + $zoom), + $post_string); + if ($this->isFault($this->_send_request($this->ptzuri,$post_string))) { + if ($this->intransingent) throw new Exception('RelativeMoveZoom: Communication error'); + } + } + + public function ptz_GetStatus( $profileToken ){ + $REQ=$this->_makeToken(); + $post_string='%%USERNAME%%%%PASSWORD%%%%NONCE%%%%CREATED%%%%PROFILETOKEN%%'; + $post_string=str_replace(array("%%USERNAME%%", + "%%PASSWORD%%", + "%%NONCE%%", + "%%CREATED%%", + "%%PROFILETOKEN%%"), + array($REQ['USERNAME'], + $REQ['PASSDIGEST'], + $REQ['NONCE'], + $REQ['TIMESTAMP'], + $profileToken), + $post_string); + if ($this->isFault($response = $this->_send_request($this->ptzuri,$post_string))) { + if ($this->intransingent) throw new Exception('ptz Get Status: Communication error'); + } else { + var_dump( $response ); + $cpos=$response['Envelope']['Body']['GetStatusResponse']['PTZStatus']['Position']; + return $cpos; + }; + } + + public function ptz_AbsoluteMove($profileToken,$position_pantilt_x,$position_pantilt_y,$zoom, $PSpeed=1.0, $TSpeed=1.0, $ZSpeed=1.0 ) { + if ($this->ptzuri=='') return array(); + $REQ=$this->_makeToken(); + $post_string='%%USERNAME%%%%PASSWORD%%%%NONCE%%%%CREATED%%%%PROFILETOKEN%%'; + $post_string=str_replace(array("%%USERNAME%%", + "%%PASSWORD%%", + "%%NONCE%%", + "%%CREATED%%", + "%%PROFILETOKEN%%", + "%%POSITIONPANTILTX%%", + "%%POSITIONPANTILTY%%", + "%%ZOOM%%", + "%%SPEEDPANTILTX%%", + "%%SPEEDPANTILTY%%", + "%%SPEEDZOOMX%%"), + array($REQ['USERNAME'], + $REQ['PASSDIGEST'], + $REQ['NONCE'], + $REQ['TIMESTAMP'], + $profileToken, + $position_pantilt_x, + $position_pantilt_y, + $zoom, + $PSpeed, + $TSpeed, + $ZSpeed), + $post_string); + if ($this->isFault($this->_send_request($this->ptzuri,$post_string))) { + if ($this->intransingent) throw new Exception('AbsoluteMove: Communication error'); + } + } + + public function ptz_ContinuousMove($profileToken,$velocity_pantilt_x,$velocity_pantilt_y) { + if ($this->ptzuri=='') return array(); + $REQ=$this->_makeToken(); + $post_string='%%USERNAME%%%%PASSWORD%%%%NONCE%%%%CREATED%%%%PROFILETOKEN%%'; + $post_string=str_replace(array("%%USERNAME%%", + "%%PASSWORD%%", + "%%NONCE%%", + "%%CREATED%%", + "%%PROFILETOKEN%%", + "%%VELOCITYPANTILTX%%", + "%%VELOCITYPANTILTY%%"), + array($REQ['USERNAME'], + $REQ['PASSDIGEST'], + $REQ['NONCE'], + $REQ['TIMESTAMP'], + $profileToken, + $velocity_pantilt_x, + $velocity_pantilt_y), + $post_string); + if ( $this->isFault($this->_send_request($this->ptzuri,$post_string))) { + if( $this->intransingent ) throw new Exception('ContinuousMove: Communication error'); + } + } + + public function ptz_ContinuousMoveZoom($profileToken,$zoom) { + if ($this->ptzuri=='') return array(); + $REQ=$this->_makeToken(); + $post_string='%%USERNAME%%%%PASSWORD%%%%NONCE%%%%CREATED%%%%PROFILETOKEN%%'; + $post_string=str_replace(array("%%USERNAME%%", + "%%PASSWORD%%", + "%%NONCE%%", + "%%CREATED%%", + "%%PROFILETOKEN%%", + "%%ZOOM%%"), + array($REQ['USERNAME'], + $REQ['PASSDIGEST'], + $REQ['NONCE'], + $REQ['TIMESTAMP'], + $profileToken, + $zoom), + $post_string); + if ($this->isFault($this->_send_request($this->ptzuri,$post_string))) { + if ($this->intransingent) throw new Exception('ContinuousMoveZoom: Communication error'); + } + } + + public function ptz_Stop($profileToken,$pantilt,$zoom) { + if ($this->ptzuri=='') return array(); + $REQ=$this->_makeToken(); + $post_string='%%USERNAME%%%%PASSWORD%%%%NONCE%%%%CREATED%%%%PROFILETOKEN%%%%PANTILT%%%%ZOOM%%'; + $post_string=str_replace(array("%%USERNAME%%", + "%%PASSWORD%%", + "%%NONCE%%", + "%%CREATED%%", + "%%PROFILETOKEN%%", + "%%PANTILT%%", + "%%ZOOM%%"), + array($REQ['USERNAME'], + $REQ['PASSDIGEST'], + $REQ['NONCE'], + $REQ['TIMESTAMP'], + $profileToken, + $pantilt, + $zoom), + $post_string); + if ($this->isFault($this->_send_request($this->ptzuri,$post_string))) { + if ($this->intransingent) throw new Exception('Stop: Communication error'); + } + } + + /* + Internal functions + */ + protected function _makeToken() { + $timestamp=time()-$this->deltatime; + return $this->_passwordDigest($this->username,$this->password,date('Y-m-d\TH:i:s.000\Z',$timestamp)); + } + + protected function _getOnvifVersion($capabilities) { + $version=array(); + if (isset($capabilities['Device']['System']['SupportedVersions']['Major'])) { + // NVT supports a specific onvif version + $version['major']=$capabilities['Device']['System']['SupportedVersions']['Major']; + $version['minor']=$capabilities['Device']['System']['SupportedVersions']['Minor']; + } else { + // NVT supports more onvif versions + $currentma=0; + $currentmi=0; + foreach ($capabilities['Device']['System']['SupportedVersions'] as $cver) { + if ($cver['Major']>$currentma) { $currentma=$cver['Major'];$currentmi=$cver['Minor']; } + } + $version['major']=$currentma; + $version['minor']=$currentmi; + } + $version['media']=$capabilities['Media']['XAddr']; + $version['device']=$capabilities['Device']['XAddr']; + $version['event']=$capabilities['Events']['XAddr']; + if (isset($capabilities['PTZ']['XAddr'])) $version['ptz']=$capabilities['PTZ']['XAddr']; else $version['ptz']=''; + return $version; + } + + protected function _getActiveSources($videoSources,$profiles) { + $sources=array(); + + if (isset($videoSources['@attributes'])) { + // NVT is a camera + $sources[0]['sourcetoken']=$videoSources['@attributes']['token']; + $this->_getProfileData($sources,0,$profiles); + } + else { + // NVT is an encoder + for ($i=0;$i_getProfileData($sources,$i,$profiles); + } + } // for + } + + return $sources; + } + + protected function _getProfileData(&$sources,$i,$profiles) { + $inprofile=0; + for ($y=0; $y < count($profiles); $y++) { + if ($profiles[$y]['VideoSourceConfiguration']['SourceToken']==$sources[$i]['sourcetoken']) { + $sources[$i][$inprofile]['profilename']=$profiles[$y]['Name']; + $sources[$i][$inprofile]['profiletoken']=$profiles[$y]['@attributes']['token']; + if ( isset($profiles[$y]['VideoEncoderConfiguration'])) { + $sources[$i][$inprofile]['encoding']=$profiles[$y]['VideoEncoderConfiguration']['Encoding']; + $sources[$i][$inprofile]['width']=$profiles[$y]['VideoEncoderConfiguration']['Resolution']['Width']; + $sources[$i][$inprofile]['height']=$profiles[$y]['VideoEncoderConfiguration']['Resolution']['Height']; + $sources[$i][$inprofile]['fps']=$profiles[$y]['VideoEncoderConfiguration']['RateControl']['FrameRateLimit']; + $sources[$i][$inprofile]['bitrate']=$profiles[$y]['VideoEncoderConfiguration']['RateControl']['BitrateLimit']; + } + if ( isset($profiles[$y]['PTZConfiguration'])) { + $sources[$i][$inprofile]['ptz']['name']=$profiles[$y]['PTZConfiguration']['Name']; + $sources[$i][$inprofile]['ptz']['nodetoken']=$profiles[$y]['PTZConfiguration']['NodeToken']; + } + $inprofile++; + } + } + } + + protected function _xml2array($response) { + $sxe = new SimpleXMLElement($response); + $dom_sxe = dom_import_simplexml($sxe); + $dom = new DOMDocument('1.0'); + $dom_sxe = $dom->importNode($dom_sxe, true); + $dom_sxe = $dom->appendChild($dom_sxe); + $element = $dom->childNodes->item(0); + foreach ($sxe->getDocNamespaces() as $name => $uri) { + $element->removeAttributeNS($uri, $name); + } + $xmldata=$dom->saveXML(); + $xmldata=substr($xmldata,strpos($xmldata,"")); + $xmldata=substr($xmldata,0,strpos($xmldata,"")+strlen("")); + $xml=simplexml_load_string($xmldata); + $data=json_decode(json_encode((array)$xml),1); + $data=array($xml->getName()=>$data); + return $data; + } + + protected function _passwordDigest( $username, $password, $timestamp = "default", $nonce = "default", $realm='', $cnonce='' ) { + if ($timestamp=='default') $timestamp=date('Y-m-d\TH:i:s.000\Z'); + if ($nonce=='default') $nonce=mt_rand(); + $REQ=array(); + switch( $this->digestMethod ){ + case 'SHA-256': + $H1 = pack('H*', sha1(pack('H*', $nonce) . pack('a*',$timestamp) . pack('a*',$password))); + break; + case 'SHA-256-sess': + case 'SHA-512-256': + case 'SHA-512-256-sess': + case 'MD5': + $H1 = pack('H*', md5( pack('a*', $username) . pack('a*', $realm) . pack('a*', $password) ) ); + //$H2 = + break; + case 'MD5-sess': + $H1 = pack('H*', md5( pack('H*', md5( pack('a*', $username) . pack('a*', $realm) . pack('a*', $password) ) ) . pack('H*', $nonce).pack('H*', $cnonce ) ) ); + + break; + default: + $passdigest=base64_encode(sha1($nonce.$timestamp.$password,true)); // alternative + }; + $REQ['USERNAME']=$username; + $REQ['PASSDIGEST']=base64_encode( $H1 );//$passdigest ); + $REQ['NONCE']=base64_encode(pack('H*', $nonce)); + //$REQ['NONCE']=base64_encode($nonce); // alternative + //$REQ['NONCE']=base64_encode(pack('H*', $nonce)); + $REQ['TIMESTAMP']=$timestamp; + return $REQ; + } + + protected function _send_request($url,$post_string) { + $soap_do = curl_init(); + curl_setopt($soap_do, CURLOPT_URL, $url ); + if ($this->proxyhost!='' && $this->proxyport!='') { + curl_setopt($soap_do, CURLOPT_PROXY, $this->proxyhost); + curl_setopt($soap_do, CURLOPT_PROXYPORT, $this->proxyport); + if ($this->proxyusername!='' && $this->proxypassword!='') + curl_setopt($soap_do, CURLOPT_PROXYUSERPWD, $this->proxyusername.':'.$this->proxypassword); + } + curl_setopt($soap_do, CURLOPT_CONNECTTIMEOUT, 2 ); + curl_setopt($soap_do, CURLOPT_TIMEOUT, 2 ); + curl_setopt($soap_do, CURLOPT_HEADER, true ); + curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true ); + curl_setopt($soap_do, CURLOPT_SSL_VERIFYPEER, false); + //curl_setopt($soap_do, CURLOPT_VERBOSE, true); + //curl_setopt($soap_do, CURLOPT_DEBUG, true); + curl_setopt($soap_do, CURLOPT_SSL_VERIFYHOST, false); + curl_setopt($soap_do, CURLOPT_POST, true ); + curl_setopt($soap_do, CURLOPT_POSTFIELDS, $post_string); + curl_setopt($soap_do, CURLOPT_HTTPHEADER, array('Expect:', 'Content-Type: application/soap+xml; charset=utf-8', 'Content-Length: '.strlen($post_string) )); + curl_setopt($soap_do, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST); + curl_setopt($soap_do, CURLOPT_USERPWD, $this->username . ":" . $this->password ); // HTTP authentication + if ( ($result = curl_exec($soap_do)) === false) { + $err = curl_error($soap_do); + $this->lastresponse=array("Fault"=>$err); + } else { + $headerSize = curl_getinfo( $soap_do, CURLINFO_HEADER_SIZE ); + $headerStr = substr( $result , 0 , $headerSize ); + $bodyStr = substr( $result , $headerSize ); + echo "QU: {$url}\n"; + echo "\n------------------\n"; + var_dump( $post_string ); + echo "\n~~~~~~~~~~~~~~~~~~\n"; + var_dump( $headerStr ); + echo "\n~~~~~~~~~~~~~~~~~~\n"; + var_dump( $bodyStr ); + echo "\n~~~~~~~~~~~~~~~~~~\n"; + $headersTmpArray = explode( "\r\n" , $headerStr ); + $R_CONT = 'text/html'; + $R_CODE = 0; + foreach( $headersTmpArray as $H ){ + $CL = trim( $H ); + if( $CL!= '' ){ + $SS = explode( ' ', $CL ); + $Biba = explode( ':', $CL ); + if( $SS[0] == 'HTTP/1.1' ){ + $R_CODE = intval( $SS[1] ); + $R_REASON = $SS[2]; + } else { + switch( $Biba[0] ){ + case 'WWW-Authenticate':{ + $AA = str_ireplace( ',','', trim( $Biba[1] )); + $AA = str_ireplace( '"','', $AA ); + $BB = explode( ' ', $AA ); + if( $BB[0] == 'Digest' ){ + $this->useDigest = true; + foreach( $BB as $B ){ + $PO = explode( '=', $B ); + switch( $PO[0] ){ + case 'qop': $this->qop=$PO[1]; break; + case 'realm': $this->auth_realm=$PO[1]; break; + case 'algorithm': $this->digestMethod=$PO[1]; break; + case 'nonce':{ + $this->auth_nonce = substr( $B, 6 );//base64_decode( substr( $B, 6 ) ); + break; + }; + }; + }; + }; + break; + }; + case 'Authentication-Info':{ + break; + }; + case 'Content-Type':{ + $R_CONT = str_ireplace( ';', '', $SS[1] ); + }; + }; + }; + }; + }; + if( $R_CODE == 200 ){ + if( $R_CONT != 'text/html' ){ + $this->lastresponse=$this->_xml2array( $bodyStr ); + } else { + $this->lastresponse=array("Fault"=>"Content is TEXT/HTML!"); + }; + } else { + $err = 'Code: '.$R_CODE.' '.$R_REASON; + $this->lastresponse=array("Fault"=>$err); + }; + }; + return $this->lastresponse; + } + +} // end class +?> \ No newline at end of file diff --git a/lib/php/setup_toolkit b/lib/php/setup_toolkit new file mode 120000 index 0000000..6cf89a5 --- /dev/null +++ b/lib/php/setup_toolkit @@ -0,0 +1 @@ +/srv/vault/lib/setup_toolkit \ No newline at end of file diff --git a/lib/php/setup_toolkit/cleanNewTask.php b/lib/php/setup_toolkit/cleanNewTask.php deleted file mode 100644 index 025538f..0000000 --- a/lib/php/setup_toolkit/cleanNewTask.php +++ /dev/null @@ -1,13 +0,0 @@ - \ No newline at end of file diff --git a/lib/php/setup_toolkit/createNewTask.php b/lib/php/setup_toolkit/createNewTask.php deleted file mode 100644 index 3a4be66..0000000 --- a/lib/php/setup_toolkit/createNewTask.php +++ /dev/null @@ -1,66 +0,0 @@ - 0 ){ - switch( $TID ){ - case 1: - if( $PRM!= '' ){ - $TArr = explode( '.', $PRM ); - $TBrr = explode( '_', $TArr[0] ); - createNewTask( $TID, $TBrr[1], "Restore Database Backup" ); - $Data['status'] = 1; - } else { - $Data['error'] = 'No Backup ID Provided!'; - }; - break; - case 2: - createNewTask( $TID, '', "Create Database Backup" ); - $Data['status'] = 1; - break; - case 100:{ - if( $PRM!= '' ){ - $TArr = explode( '.', $PRM ); - $TBrr = explode( '_', $TArr[0] ); - createNewTask( $TID, $GVAULT_PATH.'/'.$TBrr[0].'/'. $PRM , "Delete Package" ); - $Data['status'] = 1; - } else { - $Data['error'] = 'No Snapeshot ID Provided!'; - }; - $Data['status'] = 1; - break; - }; - case 128: - if( $PRM!= '' ){ - $TArr = explode( '.', $PRM ); - $TBrr = explode( '_', $TArr[0] ); - createNewTask( $TID, $GVAULT_PATH.'/'.$TBrr[0].'/'. $PRM , "Restore Full System Snapeshot" ); - $Data['status'] = 1; - } else { - $Data['error'] = 'No Snapeshot ID Provided!'; - }; - $Data['status'] = 1; - break; - case 255: - createNewTask( $TID, '', "Create Full System Snapeshot" ); - $Data['status'] = 1; - break; - default: - $Data['error'] = 'Unrecognized Task ID!'; - }; - } else { - $Data['error'] = 'No Task Type Provided!'; - }; - echo json_encode( $Data ); -?> \ No newline at end of file diff --git a/lib/php/setup_toolkit/getTaskStatus.php b/lib/php/setup_toolkit/getTaskStatus.php deleted file mode 100644 index d792682..0000000 --- a/lib/php/setup_toolkit/getTaskStatus.php +++ /dev/null @@ -1,52 +0,0 @@ -description; - break; - }; - case 2:{ - $Data['status_desc']=$Task->description; - if( file_exists( $GVAULT_PATH.'/task_perc.var' ) ){ - $ACO = intval( file_get_contents( $GVAULT_PATH.'/task_perc.var' ) ); - } else { - $ACO = 0; - }; - break; - }; - }; - - echo json_encode( $Data ); - -?> \ No newline at end of file diff --git a/lib/php/setup_toolkit/list_vault.php b/lib/php/setup_toolkit/list_vault.php deleted file mode 100644 index be5bd3f..0000000 --- a/lib/php/setup_toolkit/list_vault.php +++ /dev/null @@ -1,39 +0,0 @@ - 1 ){ - $CR['id'] = $CID; - $CR['ts'] = date( "Y-m-d H:i", intval($TArr[0])); - $CR['bk_type'] = intval( $TArr[1] ); - $CR['base_version']=$CV; - $CR['file_name']=$CV.'_'.$TArr[0].'.tar.bz2'; - $CR['size']=filesize( $GVAULT_PATH.'/'.$CV.'/'.$CR['file_name'] ); - if( $CR['size'] > 268435456 ){ - $CR['size'] = sprintf("%0.1fGb", $CR['size'] / 1073741824 ); - } else if( $CR['size'] > 716800 ){ - $CR['size'] = sprintf("%0.1fMb", $CR['size'] / 1048576 ); - } else if( $CR['size'] > 1023 ){ - $CR['size'] = sprintf("%0.1fKb", $CR['size'] / 1024 ); - } else { - $CR['size'] = sprintf("%dB", $CR['size'] ); - }; - $Data['backups'][]=$CR; - $CID ++; - }; - }; - }; - $Data['totalCount'] = $CID; - echo json_encode( $Data ); - -?> \ No newline at end of file diff --git a/lib/php/setup_toolkit/upload.php b/lib/php/setup_toolkit/upload.php deleted file mode 100644 index ab56610..0000000 --- a/lib/php/setup_toolkit/upload.php +++ /dev/null @@ -1,54 +0,0 @@ -$ok, "info"=>$info])); - }; - // invalid upload - if( empty( $_FILES ) || $_FILES['file']['error'] ){ - verbose( 0, "Failed to move uploaded file.[" . $_FILES['file']['error'] . "]" ); - }; - // upload destination - //$filePath = __DIR__ . DIRECTORY_SEPARATOR . "../../vault/working_dir/uploads"; - $filePath = $GTEMP_DIR . '/uploads'; - if( !file_exists($filePath) ){ - if (!mkdir($filePath, 0777, true)) { - verbose(0, "Failed to create $filePath"); - }; - }; - $fileName = isset($_REQUEST["name"]) ? $_REQUEST["name"] : $_FILES["file"]["name"]; - $filePath = $filePath . DIRECTORY_SEPARATOR . $fileName; - // dealing with the chunks - $chunk = isset($_REQUEST["chunk"]) ? intval($_REQUEST["chunk"]) : 0; - $chunks = isset($_REQUEST["chunks"]) ? intval($_REQUEST["chunks"]) : 0; - $out = @fopen("{$filePath}.part", $chunk == 0 ? "wb" : "ab"); - if( $out ) { - $in = @fopen($_FILES['file']['tmp_name'], "rb"); - if( $in ){ - while( $buff = fread( $in, 4096 ) ){ - fwrite($out, $buff); - }; - } else { - verbose(0, "Failed to open input stream"); - }; - @fclose($in); - @fclose($out); - @unlink($_FILES['file']['tmp_name']); - } else { - verbose(0, "Failed to open output stream"); - }; - // check if file was uploaded - if (!$chunks || $chunk == $chunks - 1) { - rename("{$filePath}.part", $filePath); - if( createNewTask( 3, $fileName, 'Handle Upload File' ) == 0 ){ - unlink( $filePath ); - verbose(0, "Failed to create new Task"); - }; - }; - verbose(1, "Upload OK"); -?> \ No newline at end of file diff --git a/lib/php/setup_toolkit/vault b/lib/php/setup_toolkit/vault deleted file mode 120000 index 6d7a7c4..0000000 --- a/lib/php/setup_toolkit/vault +++ /dev/null @@ -1 +0,0 @@ -/srv/vault \ No newline at end of file diff --git a/lib/version.var b/lib/version.var new file mode 100644 index 0000000..8a8fb43 --- /dev/null +++ b/lib/version.var @@ -0,0 +1 @@ +20220701 \ No newline at end of file diff --git a/style/assets/10_node.png b/style/assets/10_node.png new file mode 100644 index 0000000..c883043 Binary files /dev/null and b/style/assets/10_node.png differ diff --git a/style/assets/Argus User Guide Breef.doc b/style/assets/Argus User Guide Breef.doc new file mode 100644 index 0000000..486a6c3 Binary files /dev/null and b/style/assets/Argus User Guide Breef.doc differ diff --git a/style/assets/Circle_arrow_left_font_awesome.svg.png b/style/assets/Circle_arrow_left_font_awesome.svg.png new file mode 100644 index 0000000..386624c Binary files /dev/null and b/style/assets/Circle_arrow_left_font_awesome.svg.png differ diff --git a/style/assets/Home-Server-icon (1).png b/style/assets/Home-Server-icon 256.png similarity index 100% rename from style/assets/Home-Server-icon (1).png rename to style/assets/Home-Server-icon 256.png diff --git a/style/assets/Kafka-logo.png b/style/assets/Kafka-logo.png new file mode 100644 index 0000000..6a7083b Binary files /dev/null and b/style/assets/Kafka-logo.png differ diff --git a/style/assets/Kafka.png b/style/assets/Kafka.png new file mode 100644 index 0000000..2b8233b Binary files /dev/null and b/style/assets/Kafka.png differ diff --git a/style/assets/NIC.png b/style/assets/NIC.png new file mode 100644 index 0000000..0233046 Binary files /dev/null and b/style/assets/NIC.png differ diff --git a/style/assets/NICs.png b/style/assets/NICs.png new file mode 100644 index 0000000..c6346a0 Binary files /dev/null and b/style/assets/NICs.png differ diff --git a/style/assets/Untitled-8891.png b/style/assets/Untitled-8891.png deleted file mode 100644 index 9bc015d..0000000 Binary files a/style/assets/Untitled-8891.png and /dev/null differ diff --git a/style/assets/ZL_logo.png b/style/assets/ZL_logo.png new file mode 100644 index 0000000..7372652 Binary files /dev/null and b/style/assets/ZL_logo.png differ diff --git a/style/assets/argus_logo_text_outlined.png b/style/assets/argus_logo_text_outlined.png new file mode 100644 index 0000000..08bd11e Binary files /dev/null and b/style/assets/argus_logo_text_outlined.png differ diff --git a/style/assets/ffmpeg.png b/style/assets/ffmpeg.png new file mode 100644 index 0000000..c10eb46 Binary files /dev/null and b/style/assets/ffmpeg.png differ diff --git a/style/assets/image_processing20210831-10967-z0rra0.png b/style/assets/image_processing20210831-10967-z0rra0.png new file mode 100644 index 0000000..b92d821 Binary files /dev/null and b/style/assets/image_processing20210831-10967-z0rra0.png differ diff --git a/style/assets/images (1).png b/style/assets/images (1).png new file mode 100644 index 0000000..728c888 Binary files /dev/null and b/style/assets/images (1).png differ diff --git a/style/assets/logo.png b/style/assets/logo.png new file mode 100644 index 0000000..b6424bc Binary files /dev/null and b/style/assets/logo.png differ diff --git a/style/assets/modem.png b/style/assets/modem.png new file mode 100644 index 0000000..6f92487 Binary files /dev/null and b/style/assets/modem.png differ diff --git a/style/assets/onvif.png b/style/assets/onvif.png new file mode 100644 index 0000000..74362eb Binary files /dev/null and b/style/assets/onvif.png differ diff --git a/style/assets/rad_c_ico.png b/style/assets/rad_c_ico.png new file mode 100644 index 0000000..1635309 Binary files /dev/null and b/style/assets/rad_c_ico.png differ diff --git a/style/assets/rad_o_ico.png b/style/assets/rad_o_ico.png new file mode 100644 index 0000000..a398707 Binary files /dev/null and b/style/assets/rad_o_ico.png differ diff --git a/style/assets/rad_r_ico.png b/style/assets/rad_r_ico.png new file mode 100644 index 0000000..9c72484 Binary files /dev/null and b/style/assets/rad_r_ico.png differ diff --git a/style/assets/rad_v_ico.png b/style/assets/rad_v_ico.png new file mode 100644 index 0000000..9884bf2 Binary files /dev/null and b/style/assets/rad_v_ico.png differ diff --git a/style/assets/rad_y_ico.png b/style/assets/rad_y_ico.png new file mode 100644 index 0000000..59dd091 Binary files /dev/null and b/style/assets/rad_y_ico.png differ diff --git a/style/assets/rado_ico.psd b/style/assets/rado_ico.psd new file mode 100644 index 0000000..4b0fde2 Binary files /dev/null and b/style/assets/rado_ico.psd differ diff --git a/style/assets/rado_ico_small.psd b/style/assets/rado_ico_small.psd new file mode 100644 index 0000000..42bef32 Binary files /dev/null and b/style/assets/rado_ico_small.psd differ diff --git a/style/assets/rtsp.png b/style/assets/rtsp.png new file mode 100644 index 0000000..1bffc58 Binary files /dev/null and b/style/assets/rtsp.png differ diff --git a/style/assets/screans-1.psd b/style/assets/screans-1.psd new file mode 100644 index 0000000..9b3ff20 Binary files /dev/null and b/style/assets/screans-1.psd differ diff --git a/style/assets/upnp.png b/style/assets/upnp.png new file mode 100644 index 0000000..ffb7176 Binary files /dev/null and b/style/assets/upnp.png differ diff --git a/style/assets/vg.png b/style/assets/vg.png new file mode 100644 index 0000000..fff0e50 Binary files /dev/null and b/style/assets/vg.png differ diff --git a/style/style.css b/style/style.css index 18db756..310ca57 100644 --- a/style/style.css +++ b/style/style.css @@ -354,7 +354,23 @@ object:hover { .server_btn_restart { background-image: url(png/player/019.png) !important; } - +.mask_zone1_btn { + background-image: url(assets/rad_r_ico.png) !important; + /*background-position: 0px 0px !important; + background-size: 32px 32px !important;*/ +} +.mask_zone2_btn { + background-image: url(assets/rad_y_ico.png) !important; +} +.mask_zone3_btn { + background-image: url(assets/rad_v_ico.png) !important; +} +.mask_zone4_btn { + background-image: url(assets/rad_c_ico.png) !important; +} +.mask_zone5_btn { + background-image: url(assets/rad_o_ico.png) !important; +} .ctrl_panel_cog{ background-image: url(png/basic/025.png) !important; @@ -603,5 +619,51 @@ A.CalendarDS:hover { text-align: center; text-decoration: none; } - +.setEd_infoPanel{ + display: block; + border-radius: 5px; + text-align: left; + padding: 5px; + margin-top: 1px; + margin-bottom: 1px; + color: black; + background-color: silver; +} +.setEd_infoPanel#UART{ + color: yellow; + background-color: green; +} +.setEd_infoPanel#ONVIF{ + color: black; + background-color: #8ecdf6; +} +.setEd_infoPanel#SSDP{ + color: black; + background-color: #ffff00; +} +.setEd_infoPanel#EVE{ + color: yellow; + background-color: black; +} +.setEd_infoPanel#NUNU{ + color: yellow; + background-color: #3f4757; + background-image: url('assets/vg.png'); + background-repeat: no-repeat; + background-position: center 30px; + text-align: center; + height: 200px; + background-size: 150px 150px; +} +.server_img_set{ + display: block; + border-radius: 128px; + width: 256px; + height: 256px; + background-color: #4169e1; + background-image: url('assets/Home-Server-icon 256.png'); + background-repeat: no-repeat; + background-position: 25px 15px; + background-size: 220px 220px; +}