You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
993 lines
31 KiB
993 lines
31 KiB
//<?php require_once('../../js_asm.php'); ?>
|
|
|
|
function getWidth() {
|
|
return Math.max(
|
|
document.body.scrollWidth,
|
|
document.documentElement.scrollWidth,
|
|
document.body.offsetWidth,
|
|
document.documentElement.offsetWidth,
|
|
document.documentElement.clientWidth
|
|
);
|
|
}
|
|
|
|
function getHeight() {
|
|
return Math.max(
|
|
document.body.scrollHeight,
|
|
document.documentElement.scrollHeight,
|
|
document.body.offsetHeight,
|
|
document.documentElement.offsetHeight,
|
|
document.documentElement.clientHeight
|
|
);
|
|
}
|
|
|
|
function trace( message ){
|
|
//if( console ){
|
|
console.log( message );
|
|
//};
|
|
}
|
|
//https://www.pornhub.com/view_video.php?viewkey=ph5a8a095f04fc7
|
|
function makeFullScreen() {
|
|
var divObj = document.getElementById("theImage");
|
|
//Use the specification method before using prefixed versions
|
|
if (divObj.requestFullscreen) {
|
|
divObj.requestFullscreen();
|
|
} else if (divObj.msRequestFullscreen) {
|
|
divObj.msRequestFullscreen();
|
|
} else if (divObj.mozRequestFullScreen) {
|
|
divObj.mozRequestFullScreen();
|
|
} else if (divObj.webkitRequestFullscreen) {
|
|
divObj.webkitRequestFullscreen();
|
|
} else {
|
|
console.log("Fullscreen API is not supported");
|
|
};
|
|
}
|
|
|
|
var ScreanWidth = getWidth();
|
|
|
|
trace('Width: ' + getWidth() );
|
|
trace('Height: ' + getHeight() );
|
|
|
|
var panelWidth = ScreanWidth*0.9;
|
|
var iW = <?=getPictureWidth();?>;
|
|
var iH = <?=getPictureHeight();?>;
|
|
var imgWidth = panelWidth - 16;
|
|
var imgHeight = ( imgWidth / iW ) * iH;
|
|
var GEWindow = null;
|
|
var VCWindow = null;
|
|
var DCWindow = null;
|
|
var DBWindow = null;
|
|
var BG_Array = null;
|
|
var VideoWindow = null;
|
|
var VideoPlayer = null;
|
|
var VideoIsPlaying = false;
|
|
var VideoIsLooped = false;
|
|
var VideoFlash = null;
|
|
//https://www.w3schools.com/graphics/canvas_drawing.asp
|
|
var updateInterval;
|
|
var lastId = -1;
|
|
var DetectorEnabled = false;
|
|
var SelectedEvent = null;
|
|
var VideoPosInterval = null;
|
|
|
|
var Settings_SST = 1212;
|
|
var Settings_OFFSET = 1212;
|
|
var Settings_MAXRANGE = 1212;
|
|
var Settings_L2L = 1212;
|
|
var Settings_MINSPEED = 1212;
|
|
|
|
var EvtGroupRecord = Ext.data.Record.create([
|
|
'id',
|
|
'ts',
|
|
'type',
|
|
'cnt',
|
|
'has_image',
|
|
'video'
|
|
]);
|
|
var EvtListRecord = Ext.data.Record.create([
|
|
'id',
|
|
'ts',
|
|
'type',
|
|
'range',
|
|
'speed',
|
|
'f_lrf',
|
|
's_lrf'
|
|
]);
|
|
var EvtListDataStore = new Ext.data.Store({
|
|
reader: new Ext.data.JsonReader({
|
|
// The metadata property, with configuration options:
|
|
//totalProperty: "results", // the property which contains the total dataset size (optional)
|
|
root: "rows", // the property which contains an Array of row objects
|
|
idProperty: "id" // the property within each row object that provides an ID for the record (optional)
|
|
},
|
|
EvtListRecord // Ext.data.Record constructor that provides mapping for JSON object
|
|
)
|
|
});
|
|
var EvtGroupDataStore = new Ext.data.Store({
|
|
reader: new Ext.data.JsonReader({
|
|
// The metadata property, with configuration options:
|
|
//totalProperty: "results", // the property which contains the total dataset size (optional)
|
|
root: "rows", // the property which contains an Array of row objects
|
|
idProperty: "id" // the property within each row object that provides an ID for the record (optional)
|
|
},
|
|
EvtGroupRecord // Ext.data.Record constructor that provides mapping for JSON object
|
|
)
|
|
});
|
|
|
|
function smooth(ctx, points){
|
|
if(points == undefined || points.length == 0)
|
|
{
|
|
return true;
|
|
}
|
|
if(points.length == 1)
|
|
{
|
|
ctx.moveTo(points[0].x, points[0].y);
|
|
ctx.lineTo(points[0].x, points[0].y);
|
|
return true;
|
|
}
|
|
if(points.length == 2)
|
|
{
|
|
ctx.moveTo(points[0].x, points[0].y);
|
|
ctx.lineTo(points[1].x, points[1].y);
|
|
return true;
|
|
}
|
|
ctx.moveTo(points[0].x, points[0].y);
|
|
for (var i = 1; i < points.length - 2; i ++)
|
|
{
|
|
var xc = (points[i].x + points[i + 1].x) / 2;
|
|
var yc = (points[i].y + points[i + 1].y) / 2;
|
|
ctx.quadraticCurveTo(points[i].x, points[i].y, xc, yc);
|
|
}
|
|
ctx.quadraticCurveTo(points[i].x, points[i].y, points[i+1].x, points[i+1].y);
|
|
}
|
|
|
|
function drawCurve(points, tension) {
|
|
ctx.beginPath();
|
|
ctx.moveTo(points[0].x, points[0].y);
|
|
|
|
var t = (tension != null) ? tension : 1;
|
|
for (var i = 0; i < points.length - 1; i++) {
|
|
var p0 = (i > 0) ? points[i - 1] : points[0];
|
|
var p1 = points[i];
|
|
var p2 = points[i + 1];
|
|
var p3 = (i != points.length - 2) ? points[i + 2] : p2;
|
|
|
|
var cp1x = p1.x + (p2.x - p0.x) / 6 * t;
|
|
var cp1y = p1.y + (p2.y - p0.y) / 6 * t;
|
|
|
|
var cp2x = p2.x - (p3.x - p1.x) / 6 * t;
|
|
var cp2y = p2.y - (p3.y - p1.y) / 6 * t;
|
|
|
|
ctx.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, p2.x, p2.y);
|
|
}
|
|
ctx.stroke();
|
|
}
|
|
|
|
function clearLiveBip(){
|
|
var canvas = document.getElementById("StatusCanvas");
|
|
var ctx = canvas.getContext("2d");
|
|
ctx.fillStyle = "#FF0000";
|
|
ctx.fillRect(5, 5, 10, 10);
|
|
}
|
|
|
|
function drawStatus(){
|
|
var canvas = document.getElementById("StatusCanvas");
|
|
var ctx = canvas.getContext("2d");
|
|
ctx.fillStyle = "#00FF00";
|
|
ctx.fillRect(5, 5, 10, 10);
|
|
}
|
|
|
|
function drawBackgrounds(){
|
|
if( !DBWindow ) return;
|
|
var canvas = document.getElementById("RangeBGCanvas");
|
|
if( canvas ){
|
|
var ctx = canvas.getContext("2d");
|
|
var x = canvas.width;
|
|
var y = canvas.height;
|
|
if( ctx ){
|
|
if( !BG_Array ){
|
|
// No Data!
|
|
ctx.font = "30px Arial";
|
|
|
|
ctx.fillStyle = "#F0F0F0";
|
|
ctx.fillRect(0, 0, x, y);
|
|
ctx.strokeStyle = "#E0E0E0";
|
|
ctx.lineWidth = 2;
|
|
ctx.strokeRect(2, 2, x-4, y-4);
|
|
ctx.beginPath();
|
|
ctx.moveTo(2, 2);
|
|
ctx.lineTo(x-2, y-2);
|
|
ctx.moveTo(2, y-2);
|
|
ctx.lineTo(x-2, 2);
|
|
ctx.stroke();
|
|
ctx.fillStyle = "#000000";
|
|
ctx.fillText("No DATA!", ( x - ctx.measureText("No DATA!").width )>>> 1, y >>> 1 );
|
|
} else {
|
|
ctx.fillStyle = "#F0F0F0";
|
|
ctx.fillRect(0, 0, x, y);
|
|
var grd = ctx.createLinearGradient(0, 0, 0, y-20);
|
|
grd.addColorStop(0, "#00FF00");
|
|
grd.addColorStop(1, "#0000FF");
|
|
ctx.fillStyle = grd;
|
|
var bw = ( x - 27 ) / 9;
|
|
var mx = y - 20;
|
|
ctx.font = "10px Arial";
|
|
ctx.strokeStyle = "#000000";
|
|
for( i = 0; i < 9; i++ ){
|
|
var cy = ( BG_Array[i] * mx ) / 1024;
|
|
ctx.fillRect( 13 + i*bw, 10, bw-3, cy );
|
|
ctx.strokeText((i+1)+":"+BG_Array[i], 13 + bw / 5 + i*bw, cy >>> 1 );
|
|
};
|
|
};
|
|
};
|
|
};
|
|
}
|
|
|
|
function ChangeHandler( me, nv, ov ){
|
|
if( nv != ov ){
|
|
//alert( 'Changes:' + me.name + ' ' + nv + ' '+ ov );
|
|
Ext.Ajax.request({
|
|
url: '/lib/controller/setVideoSourceParam.php',
|
|
params: {
|
|
param: me.name,
|
|
oval: ov,
|
|
nval: nv
|
|
},
|
|
success: function( response, opts ){
|
|
// If the response is JSON, you have to decode it
|
|
//var obj = Ext.decode(response.responseText);
|
|
//Ext.fly('some_div').update('Success!');
|
|
},
|
|
failure: function( response, opts ) {
|
|
//Ext.fly('some_div').update('Fail!');
|
|
}/*,
|
|
callback: function(options,success,response){
|
|
// use this if you need to perform your own success/failure checking
|
|
}*/
|
|
});
|
|
};
|
|
};
|
|
|
|
function showDetectionConfigWindow(){
|
|
if( DCWindow == null ){
|
|
DCWindow = new Ext.Window({
|
|
title: 'Detection Parameters',
|
|
width: 600,
|
|
height: 220,
|
|
closeAction: 'hide',
|
|
y: 120,
|
|
modal: true,
|
|
items:[{
|
|
xtype: 'form',
|
|
labelAlign: 'right',
|
|
labelWidth: 250,
|
|
items: [{
|
|
xtype: 'numberfield',
|
|
id: 'sst_data',
|
|
fieldLabel: 'Detection SST',
|
|
emptyText: 'No Data'
|
|
},{
|
|
xtype: 'numberfield',
|
|
id: 'offset_data',
|
|
fieldLabel: 'Detection Offset',
|
|
emptyText: 'No Data'
|
|
},{
|
|
xtype: 'numberfield',
|
|
id: 'max_data',
|
|
fieldLabel: 'Maximal Range',
|
|
emptyText: 'No Data'
|
|
},{
|
|
xtype: 'numberfield',
|
|
id: 'l2l_data',
|
|
fieldLabel: 'Distance beetween Layers',
|
|
emptyText: 'No Data',
|
|
disabled: true
|
|
},{
|
|
xtype: 'numberfield',
|
|
id: 'minspeed_data',
|
|
fieldLabel: 'Minimal Speed',
|
|
emptyText: 'No Data',
|
|
disabled: true
|
|
}],
|
|
buttons:[{
|
|
text: 'Submit',
|
|
tooltip:'Set Detection Settings to Device',
|
|
iconCls:'silk-tick',
|
|
handler: function(){
|
|
Settings_SST = Ext.getCmp('sst_data').getValue();
|
|
Settings_OFFSET = Ext.getCmp('offset_data').getValue();
|
|
Settings_MAXRANGE = Ext.getCmp('max_data').getValue();
|
|
Settings_L2L = Ext.getCmp('l2l_data').getValue();
|
|
Settings_MINSPEED = Ext.getCmp('minspeed_data').getValue();
|
|
Ext.Ajax.request({
|
|
url: '/lib/controller/setDetectorParam.php',
|
|
params: {
|
|
data_sst: Settings_SST,
|
|
data_offset: Settings_OFFSET,
|
|
data_maxrange: Settings_MAXRANGE,
|
|
data_l2l: Settings_L2L,
|
|
data_minspeed: Settings_MINSPEED,
|
|
},
|
|
success: function( response, opts ){
|
|
// If the response is JSON, you have to decode it
|
|
//var obj = Ext.decode(response.responseText);
|
|
//Ext.fly('some_div').update('Success!');
|
|
DCWindow.hide();
|
|
},
|
|
failure: function( response, opts ) {
|
|
DCWindow.hide();
|
|
Ext.Msg.alert('Status', 'Error Creating AJAX Connection.<br>Code: CENDL00221');
|
|
}
|
|
});
|
|
}
|
|
},{
|
|
text: 'Cancel',
|
|
tooltip:'Do Not Change Anything!',
|
|
iconCls:'silk-cancel',
|
|
handler: function(){
|
|
DCWindow.hide();
|
|
}
|
|
}]
|
|
}]
|
|
});
|
|
};
|
|
DCWindow.show();
|
|
Ext.getCmp('sst_data').setValue( Settings_SST );
|
|
Ext.getCmp('offset_data').setValue( Settings_OFFSET );
|
|
Ext.getCmp('max_data').setValue( Settings_MAXRANGE );
|
|
Ext.getCmp('l2l_data').setValue( Settings_L2L );
|
|
Ext.getCmp('minspeed_data').setValue( Settings_MINSPEED );
|
|
};
|
|
|
|
function showDetectionBackgroundWindow(){
|
|
if( DBWindow == null ){
|
|
DBWindow = new Ext.Window({
|
|
title: 'Detection Background Ranges',
|
|
width: 614,
|
|
height: 514,
|
|
y: 120,
|
|
modal: true,
|
|
closeAction: 'hide',
|
|
html: '<canvas id="RangeBGCanvas" width="600px" height="480px"></canvas>'
|
|
});
|
|
};
|
|
DBWindow.show();
|
|
drawBackgrounds();
|
|
};
|
|
|
|
function videoPositionUpdater(){
|
|
if(!VideoPlayer) return;
|
|
var cPos = VideoPlayer.currentTime;
|
|
};
|
|
|
|
function setVideoToPlay( src ){
|
|
if( VideoPlayer != null ){
|
|
delete VideoPlayer;
|
|
};
|
|
if( VideoFlash != null ){
|
|
swfobject.removeSWF( "vidflash" );
|
|
Ext.getCmp('video-panel').removeAll( true );
|
|
Ext.getCmp('video-panel').add({ html:'<div id="divvidflash" style="background: black;"></div>'});
|
|
Ext.getCmp('video-panel').update();
|
|
};
|
|
var att = { data: "/lib/flash/player_flv_html5.swf?4", width: iW, height: iH, id: "vidflash", name: "vidflash"};
|
|
var params = { flashvars: "listener=VideoPlayer&src="+src, swliveconnect: "true"};
|
|
VideoFlash = swfobject.createSWF( att, params, "divvidflash" );
|
|
VideoPlayer = new FlashFLVPlayer( VideoFlash );
|
|
// Events
|
|
VideoPlayer.addEventListener("loadstart", function(event) {
|
|
trace("[event] loadstart");
|
|
});
|
|
VideoPlayer.addEventListener("load", function(event) {
|
|
trace("[event] load");
|
|
});
|
|
VideoPlayer.addEventListener("play", function(event) {
|
|
trace("[event] play");
|
|
});
|
|
VideoPlayer.addEventListener("ended", function(event) {
|
|
if( VideoIsLooped ) VideoPlayer.currentTime = 0;
|
|
});
|
|
VideoPlayer.addEventListener("pause", function(event) {
|
|
trace("[event] pause");
|
|
});
|
|
VideoPlayer.addEventListener("playing", function(event) {
|
|
trace("[event] playing");
|
|
});
|
|
VideoPlayer.addEventListener("seeked", function(event) {
|
|
trace("[event] seeked");
|
|
});
|
|
VideoPlayer.addEventListener("loadedmetadata", function(event) {
|
|
trace("[event] loadedmetadata");
|
|
//$('#videoWidth').text(VideoPlayer.videoWidth);
|
|
//$('#videoHeight').text(VideoPlayer.videoHeight);
|
|
});
|
|
VideoPlayer.addEventListener("durationchange", function(event) {
|
|
trace("[event] durationchange : " + VideoPlayer.duration);
|
|
//$('#duration').text(VideoPlayer.duration);
|
|
});
|
|
VideoPlayer.addEventListener("timeupdate", function(event) {
|
|
trace("[event] timeupdate : " + video.currentTime);
|
|
});
|
|
VideoPlayer.addEventListener("error", function(event) {
|
|
trace("[event] error : " + VideoPlayer.networkState);
|
|
});
|
|
VideoPlayer.addEventListener("canplay", function(event) {
|
|
trace("[event] canplay");
|
|
});
|
|
VideoPlayer.addEventListener("canplaythrough", function(event) {
|
|
trace("[event] canplaythrough");
|
|
});
|
|
VideoPlayer.addEventListener("volumechange", function(event) {
|
|
trace("[event] volumechange : " + VideoPlayer.volume);
|
|
});
|
|
// VideoPosition
|
|
VideoPosInterval = window.setInterval( videoPositionUpdater, 100 );
|
|
}
|
|
|
|
function showVideoConfigWindow(){
|
|
if( VCWindow == null ){
|
|
VCWindow = new Ext.Window({
|
|
title: 'Video Configuration',
|
|
width: 500,
|
|
height: 600,
|
|
y: 120,
|
|
modal: true,
|
|
closeAction: 'hide',
|
|
items: new Ext.TabPanel({
|
|
activeTab: 0,
|
|
enableTabScroll: true,
|
|
autoScroll: true,
|
|
items: [
|
|
<?php
|
|
$CC = getVideoSourcesCount();
|
|
if( $CC ){
|
|
$DD = array();
|
|
//$CC++;
|
|
for( $index = 0; $index < $CC; $index++ ){
|
|
$ID = getVideoSourceID( $index );
|
|
$DD[] = buildExtJSForm( getDeviceCtrl( $ID ), $ID );
|
|
};
|
|
$KU = implode( ',', $DD );
|
|
echo $KU;
|
|
};
|
|
?>
|
|
]
|
|
})
|
|
});
|
|
};
|
|
VCWindow.show();
|
|
}
|
|
|
|
function GetEventsLog( gid ){
|
|
//clearLiveBip();
|
|
Ext.Ajax.request({
|
|
url: '/lib/controller/listEvents.php',
|
|
success: function( response, opts ){
|
|
var obj = Ext.decode( response.responseText );
|
|
EvtListDataStore.removeAll();
|
|
if( obj.empty != true ){
|
|
EvtListDataStore.loadData( obj );
|
|
};
|
|
},
|
|
failure: function( response, opts ){
|
|
Ext.Msg.alert('Status', 'Error Creating AJAX Connection.<br>Code: CENDL00225');
|
|
},
|
|
headers: {
|
|
'author': 'gagua'
|
|
},
|
|
params: { id: gid }
|
|
});
|
|
};
|
|
|
|
function GetGroupedEvents( gid ){
|
|
Ext.Ajax.request({
|
|
url: '/lib/controller/listEventGroups.php',
|
|
success: function( response, opts ){
|
|
var obj = Ext.decode( response.responseText );
|
|
if( obj.SW_OK ){
|
|
Ext.getCmp('rec-test').enable();
|
|
Ext.getCmp('lrf-rst').enable();
|
|
Ext.getCmp('ena-dis').enable();
|
|
if( obj.MODE ) {
|
|
DetectorEnabled = true;
|
|
Ext.getCmp('ena-dis').setText('Disable Detection');
|
|
Ext.getCmp('ena-dis').setIconClass('silk-cancel');
|
|
} else {
|
|
DetectorEnabled = false;
|
|
Ext.getCmp('ena-dis').setText('Enable Detection');
|
|
Ext.getCmp('ena-dis').setIconClass('silk-accept');
|
|
};
|
|
} else {
|
|
Ext.getCmp('rec-test').disable();
|
|
};
|
|
Settings_SST = obj.LRF_SST;
|
|
Settings_OFFSET = obj.LRF_OFFSET;
|
|
Settings_MAXRANGE = obj.LRF_MAX;
|
|
Settings_L2L = obj.LRF_DISTANCE;
|
|
Settings_MINSPEED = obj.LRF_SPEED;
|
|
BG_Array = obj.LRF_BG;
|
|
drawBackgrounds();
|
|
drawStatus();
|
|
if( obj.empty == true ){
|
|
if( lastId != 0 ){
|
|
lastId = 0;
|
|
EvtGroupDataStore.removeAll();
|
|
//EvtListDataStore.sync();
|
|
};
|
|
} else {
|
|
if( lastId != obj.rows[0].id ){
|
|
lastId = obj.rows[0].id;
|
|
//todo: Optimise to add just new arived items
|
|
EvtGroupDataStore.loadData( obj );
|
|
//EvtListDataStore.sync();
|
|
};
|
|
};
|
|
},
|
|
failure: function( response, opts ){
|
|
Ext.Msg.alert('Status', 'Error Creating AJAX Connection.<br>Code: CENDL00225');
|
|
},
|
|
headers: {
|
|
'author': 'gagua'
|
|
},
|
|
params: { last_id: lastId }
|
|
});
|
|
};
|
|
|
|
function makeAlarm(){
|
|
Ext.Ajax.request({
|
|
url: '/lib/controller/postAlarm.php',
|
|
success: function( response, opts ){
|
|
},
|
|
failure: function( response, opts ){
|
|
Ext.Msg.alert('Status', 'Error Creating AJAX Connection.<br>Code: CENDL00213');
|
|
},
|
|
headers: {
|
|
'my-header': 'foo'
|
|
},
|
|
params: { last_id: lastId }
|
|
});
|
|
}
|
|
|
|
function resetDetector(){
|
|
Ext.Ajax.request({
|
|
url: '/lib/controller/resetDetector.php',
|
|
success: function( response, opts ){
|
|
},
|
|
failure: function( response, opts ){
|
|
Ext.Msg.alert('Status', 'Error Creating AJAX Connection.<br>Code: CENDL00213');
|
|
},
|
|
headers: {
|
|
'my-header': 'foo'
|
|
},
|
|
params: { last_id: lastId }
|
|
});
|
|
}
|
|
|
|
function detectionEnable(){
|
|
if( DetectorEnabled ){
|
|
chucha = '/lib/controller/disableDetector.php';
|
|
} else {
|
|
chucha = '/lib/controller/enableDetector.php';
|
|
};
|
|
Ext.Ajax.request({
|
|
url: chucha,
|
|
success: function( response, opts ){
|
|
},
|
|
failure: function( response, opts ){
|
|
Ext.Msg.alert('Status', 'Error Creating AJAX Connection.<br>Code: CENDL00213');
|
|
},
|
|
headers: {
|
|
'my-header': 'foo'
|
|
},
|
|
params: { last_id: lastId }
|
|
});
|
|
}
|
|
|
|
function IconRenderer( type ){
|
|
switch( type ){
|
|
case 255:
|
|
return '<img width="16px" src="/style/icons/icons/information.png"/>';
|
|
case 251:
|
|
return '<img width="16px" src="/style/icons/icons/arrow_refresh.png"/>';
|
|
case 250:
|
|
return '<img width="16px" src="/style/icons/icons/information.png"/>';
|
|
case 0:
|
|
return '<img width="16px" src="/style/icons/icons/tick.png"/>';
|
|
case 1:
|
|
return '<img width="16px" src="/style/icons/icons/house.png"/>';
|
|
case 2:
|
|
return '<img width="16px" src="/style/icons/icons/house_link.png"/>';
|
|
case 3:
|
|
return '<img width="16px" src="/style/icons/icons/shield_delete.png"/>';
|
|
case 4:
|
|
return '<img width="16px" src="/style/icons/icons/shield_add.png"/>';
|
|
case 5:
|
|
return '<img width="16px" src="/style/icons/icons/asterisk_yellow.png"/>';
|
|
case 6:
|
|
return '<img width="16px" src="/style/icons/icons/asterisk_orange.png"/>';
|
|
case 7:
|
|
return '<img width="16px" src="/style/icons/icons/information.png"/>';
|
|
case 8:
|
|
return '<img width="16px" src="/style/icons/icons/information.png"/>';
|
|
default:
|
|
return '<img width="16px" src="/style/icons/icons/help.png"/>';
|
|
};
|
|
};
|
|
|
|
function TypeRenderer( type ){
|
|
switch( type ){
|
|
case 255: return 'System Shutted Down';
|
|
case 251: return 'Sensor Reset issued by Operator';
|
|
case 250: return 'Log Cleared by Operator';
|
|
case 0: return 'System Started';
|
|
case 1: return 'System Started Disarmed';
|
|
case 2: return 'System Started Armed';
|
|
case 3: return 'Disarmed by Operator';
|
|
case 4: return 'Armed by Operator';
|
|
case 5: return 'Alarm';
|
|
case 6: return 'Alarm Test by Operator';
|
|
case 7: return 'Parameters Changed by Operator';
|
|
case 8: return 'Log Cleared by Operator';
|
|
default: return 'Unusual Event';
|
|
};
|
|
};
|
|
|
|
function LrfRenderer( value, metadata, record, rowIndex, colIndex, store ){
|
|
var R = value / 1;
|
|
if( R > 0 ){
|
|
var RV = '<svg width="120" height="16">';
|
|
if( R == 1024 ){
|
|
for( i=0; i < 9; i++ ){
|
|
RV = RV + '<circle cx="'+( 120 - ( ( i + 1 ) * 12 + 5 ) )+'" cy="8" r="5" stroke="black" stroke-width="2" fill="darkgrey" />';
|
|
};
|
|
} else {
|
|
R--;
|
|
for( i=0; i < 9; i++ ){
|
|
if( ( R & ( 1 << i ) ) == 0 ){
|
|
RV = RV + '<circle cx="'+( 120 - ( ( i + 1 ) * 12 + 5 ) )+'" cy="8" r="5" stroke="green" stroke-width="2" fill="grey" />';
|
|
} else {
|
|
RV = RV + '<circle cx="'+( 120 - ( ( i + 1 ) * 12 + 5 ) )+'" cy="8" r="5" stroke="red" stroke-width="2" fill="yellow" />';
|
|
};
|
|
};
|
|
};
|
|
return RV + '</svg>';
|
|
};
|
|
return '';
|
|
};
|
|
|
|
function VideoRenderer( value, metadata, record, rowIndex, colIndex, store ){
|
|
if( value ){
|
|
//return '<a href="#" onclick="ViewVideoPreview(\'' + record.data.video + '\');"><img width="16px" src="/style/icons/icons/film.png" alt="' + record.data.video + '" /></a>';
|
|
return '<a href="#" onclick="showEventGroupWindow(\'' + record.data.video + '\','+record.data.id+');"><img width="16px" src="/style/icons/icons/film.png" alt="' + record.data.video + '" /></a>';
|
|
};
|
|
return '';
|
|
};
|
|
|
|
var EvtGroupColModel = new Ext.grid.ColumnModel([
|
|
/*{header: "", width: 38, sortable: false, locked: true, menuDisabled: true, fixed: true, align: 'left', renderer: IconRenderer, dataIndex: 'icon'},
|
|
{header: "Device ID", width: 120, sortable: true, align: 'center', css: 'vertical-align: middle;', dataIndex: 'device_id'},
|
|
{header: "Vehicle ID", width: 120, sortable: true, align: 'left', css: 'vertical-align: middle;', dataIndex: 'name'},
|
|
{header: "Status", width: 95, sortable: true, align: 'center', css: 'vertical-align: middle;', renderer: DevStatusRenderer, dataIndex: 'status'},
|
|
{header: "SMS", width: 36, sortable: false, menuDisabled: true, align: 'center', fixed: true, css: 'vertical-align: middle;', renderer: SMSRenderer, dataIndex: 'sms'},
|
|
{header: "Active Since", width: 85, sortable: true, css: 'vertical-align: middle;', renderer: Ext.util.Format.dateRenderer('m/d/Y'), dataIndex: 'created'},
|
|
{header: "Last Activity", width: 85, sortable: true, css: 'vertical-align: middle;', renderer: Ext.util.Format.dateRenderer('m/d/Y'), dataIndex: 'last_access'}*/
|
|
{header: "", width: 24, sortable: false, menuDisabled: true, align: 'center', fixed: true, css: 'vertical-align: middle;', renderer: IconRenderer, dataIndex: 'type' },
|
|
{header: "Time Stamp", width: 160, sortable: false, menuDisabled: true, align: 'center', fixed: true, css: 'vertical-align: middle;', renderer: Ext.util.Format.dateRenderer('d-m-Y H:i:s'), dataIndex: 'ts' },
|
|
{header: "Event Description", width: 200, sortable: false, menuDisabled: true, align: 'left', css: 'vertical-align: middle;', renderer: TypeRenderer, dataIndex: 'type' },
|
|
{header: "Grouped Events", width: 60, sortable: false, menuDisabled: true, align: 'center', css: 'vertical-align: middle;', dataIndex: 'cnt' },
|
|
/*{header: "Range", width: 60, sortable: false, menuDisabled: true, align: 'center', fixed: true, css: 'vertical-align: middle;', dataIndex: 'range' },
|
|
{header: "LVL 0", width: 130, sortable: false, menuDisabled: true, align: 'center', fixed: true, css: 'vertical-align: middle;', renderer: LrfRenderer, dataIndex: 'f_lrf' },
|
|
{header: "LVL 1", width: 130, sortable: false, menuDisabled: true, align: 'center', fixed: true, css: 'vertical-align: middle;', renderer: LrfRenderer, dataIndex: 's_lrf' },
|
|
{header: "Speed", width: 60, sortable: false, menuDisabled: true, align: 'center', fixed: true, css: 'vertical-align: middle;', dataIndex: 'lrf_id' },
|
|
*/
|
|
{header: "Video", width: 50, sortable: false, menuDisabled: true, align: 'center', fixed: true, css: 'vertical-align: middle;', renderer: VideoRenderer, dataIndex: 'has_image' }
|
|
]);
|
|
|
|
var EvtGroupSelModel = new Ext.grid.RowSelectionModel({
|
|
singleSelect: true,
|
|
listeners: {
|
|
rowselect: function(sm, row, rec) {
|
|
if (!SelectedEvent){
|
|
SelectedEvent = rec;
|
|
SelectedEvent.sm = sm;
|
|
SelectedEvent.rowId = row;
|
|
} else {
|
|
SelectedEvent = rec;
|
|
SelectedEvent.sm = sm;
|
|
SelectedEvent.rowId = row;
|
|
};
|
|
}
|
|
}
|
|
});
|
|
|
|
|
|
var EvtListColModel = new Ext.grid.ColumnModel([
|
|
{header: "", width: 24, sortable: false, menuDisabled: true, align: 'center', fixed: true, css: 'vertical-align: middle;', renderer: IconRenderer, dataIndex: 'type' },
|
|
{header: "Time Stamp", width: 160, sortable: false, menuDisabled: true, align: 'center', fixed: true, css: 'vertical-align: middle;', renderer: Ext.util.Format.dateRenderer('d-m-Y H:i:s'), dataIndex: 'ts' },
|
|
{header: "Event Description", sortable: false, menuDisabled: true, align: 'left', css: 'vertical-align: middle;', renderer: TypeRenderer, dataIndex: 'type' },
|
|
{header: "Range", width: 60, sortable: false, menuDisabled: true, align: 'center', fixed: true, css: 'vertical-align: middle;', dataIndex: 'range' },
|
|
{header: "LVL 0", width: 130, sortable: false, menuDisabled: true, align: 'center', fixed: true, css: 'vertical-align: middle;', renderer: LrfRenderer, dataIndex: 'f_lrf' },
|
|
{header: "LVL 1", width: 130, sortable: false, menuDisabled: true, align: 'center', fixed: true, css: 'vertical-align: middle;', renderer: LrfRenderer, dataIndex: 's_lrf' },
|
|
{header: "Speed", width: 60, sortable: false, menuDisabled: true, align: 'center', fixed: true, css: 'vertical-align: middle;', dataIndex: 'speed' }
|
|
]);
|
|
|
|
var EvtListSelModel = new Ext.grid.RowSelectionModel({
|
|
singleSelect: true,
|
|
listeners: {
|
|
rowselect: function(sm, row, rec) {
|
|
if (!SelectedEvent){
|
|
SelectedEvent = rec;
|
|
SelectedEvent.sm = sm;
|
|
SelectedEvent.rowId = row;
|
|
} else {
|
|
SelectedEvent = rec;
|
|
SelectedEvent.sm = sm;
|
|
SelectedEvent.rowId = row;
|
|
};
|
|
}
|
|
}
|
|
});
|
|
|
|
|
|
function showEventGroupWindow( vsrc, gid ){
|
|
if( GEWindow == null ){
|
|
GEWindow = new Ext.Window({
|
|
title: 'Event Viewer',
|
|
width: iW+20,
|
|
height: iH+300,
|
|
modal: true,
|
|
y: 120,
|
|
resizable: false,
|
|
closeAction: 'hide',
|
|
items: [{
|
|
xtype: 'panel',
|
|
id: 'video-panel',
|
|
html: '<div id="divvidflash" style="background: black; width: '+iW+'px; height: '+iH+'px;"></div>',
|
|
bbar: [{
|
|
iconCls: 'silk-start',
|
|
handler: function(){
|
|
if( VideoPlayer ){
|
|
VideoPlayer.currentTime = 0;
|
|
};
|
|
}
|
|
},{
|
|
text: 'Play',
|
|
iconCls: 'silk-play',
|
|
handler: function(){
|
|
if( VideoPlayer ){
|
|
if( VideoIsPlaying ){
|
|
VideoPlayer.pause();
|
|
VideoIsPlaying = false;
|
|
} else {
|
|
VideoPlayer.play();
|
|
VideoIsPlaying = true;
|
|
};
|
|
};
|
|
}
|
|
},{
|
|
iconCls: 'silk-replay',
|
|
enableToggle: true,
|
|
handler: function(){
|
|
if( VideoPlayer ){
|
|
VideoIsLooped = !VideoIsLooped;
|
|
};
|
|
}
|
|
}]
|
|
},{
|
|
xtype: 'grid',
|
|
title: 'Events Log',
|
|
frame: false,
|
|
id: 'grp_grid',
|
|
forceFit: true,
|
|
ds: EvtListDataStore,
|
|
cm: EvtListColModel,
|
|
sm: EvtListSelModel,
|
|
//autoExpandColumn: 'login',
|
|
height: 235,
|
|
width: '100%',
|
|
border: false,
|
|
listeners: {
|
|
render: function(g) {
|
|
//g.getSelectionModel().selectRow(0);
|
|
},
|
|
delay: 10 // Allow rows to be rendered.
|
|
},
|
|
viewConfig: {
|
|
forceFit:true
|
|
},
|
|
}],
|
|
listeners: {
|
|
beforehide : function(component) {
|
|
if( VideoFlash != null ){
|
|
if(VideoPosInterval) clearInterval( VideoPosInterval );
|
|
VideoPosInterval = null;
|
|
swfobject.removeSWF( "vidflash" );
|
|
Ext.getCmp('video-panel').removeAll( true );
|
|
Ext.getCmp('video-panel').add({ html:'<div id="divvidflash"></div>'});
|
|
VideoFlash = null;
|
|
VideoIsPlaying = false;
|
|
};
|
|
}
|
|
}
|
|
});
|
|
};
|
|
GEWindow.show();
|
|
setVideoToPlay( vsrc );
|
|
GetEventsLog( gid );
|
|
}
|
|
|
|
|
|
Ext.onReady(function() {
|
|
var panel = new Ext.Panel({
|
|
renderTo: 'content',
|
|
width: panelWidth,
|
|
|
|
items:[ {
|
|
xtype: 'panel',
|
|
id: '121',
|
|
title:'Video',
|
|
frame: true,
|
|
html:'<img id="theImage" border=0 src="/cgi-bin/nph-video" width="'+panelWidth+'px" rel="shadowbox" onClick="makeFullScreen();">',
|
|
width: imgWidth+12,
|
|
height: imgHeight+75,
|
|
anchor:'right 50%',
|
|
fbar: [{
|
|
text: 'Force Alarm',
|
|
id: 'rec-test',
|
|
disabled: true,
|
|
iconCls: 'silk-belladd',
|
|
handler: function(){
|
|
Ext.Msg.show({
|
|
title:'Test Record Frames?',
|
|
msg: 'You are about to record 240 frames. Would you like to do so?',
|
|
buttons: Ext.Msg.YESNOCANCEL,
|
|
fn: function(btn, text){
|
|
if( btn == 'yes' ) makeAlarm();
|
|
},
|
|
animEl: '121',
|
|
icon: Ext.MessageBox.QUESTION
|
|
});
|
|
}
|
|
},{
|
|
iconCls: 'silk-cog',
|
|
text: 'Video Config',
|
|
handler: showVideoConfigWindow
|
|
}]
|
|
},{
|
|
title: 'Detector Settings',
|
|
xtype: 'form',
|
|
layout: 'form',
|
|
layoutConfig: {
|
|
type: 'hbox',
|
|
padding: '5',
|
|
align: 'center'
|
|
},
|
|
//html: '<table width="100%" border=0><tr><td>Offset:</td><td><?=20;?></td><td>Max Distance:</td><td>3.00</td><td>Layer Distance:</td><td>0.5</td></tr></table>',
|
|
width: panelWidth,
|
|
buttons:[{
|
|
xtype: 'panel',
|
|
html: '<canvas id="StatusCanvas" width="120px" height="20px"></canvas>'
|
|
},{
|
|
text: 'Show Detection Backgrounds',
|
|
iconCls: 'silk-chart',
|
|
handler: showDetectionBackgroundWindow
|
|
},{
|
|
text: 'Change Detection Settings',
|
|
iconCls: 'silk-cog',
|
|
handler: showDetectionConfigWindow
|
|
},{
|
|
text: 'Reset Sensor',
|
|
id: 'lrf-rst',
|
|
disabled: true,
|
|
iconCls: 'silk-arrow-refresh',
|
|
handler: function(){
|
|
Ext.Msg.show({
|
|
title:'Reset Detector?',
|
|
msg: 'You are about to reset detector. The system will be blind for 1 second. Would you like to do so?',
|
|
buttons: Ext.Msg.YESNOCANCEL,
|
|
fn: function(btn, text){
|
|
if( btn == 'yes' ) resetDetector();
|
|
},
|
|
animEl: '121',
|
|
icon: Ext.MessageBox.WARNING
|
|
});
|
|
}
|
|
},{
|
|
text: 'Enable Detection',
|
|
disabled: true,
|
|
id: 'ena-dis',
|
|
iconCls: 'silk-accept',
|
|
handler: detectionEnable
|
|
}]
|
|
},{
|
|
xtype: 'grid',
|
|
title: 'Events Log',
|
|
frame: true,
|
|
id: 'mygrid',
|
|
forceFit: true,
|
|
ds: EvtGroupDataStore,
|
|
cm: EvtGroupColModel,
|
|
sm: EvtGroupSelModel,
|
|
//autoExpandColumn: 'login',
|
|
height: 350,
|
|
width: '100%',
|
|
border: false,
|
|
listeners: {
|
|
render: function(g) {
|
|
g.getSelectionModel().selectRow(0);
|
|
},
|
|
delay: 10 // Allow rows to be rendered.
|
|
},
|
|
viewConfig: {
|
|
forceFit:true
|
|
},
|
|
bbar: [{
|
|
tooltip:'Clear Log Messages',
|
|
id: 'clrList',
|
|
text: 'Clear',
|
|
iconCls:'silk-cross',
|
|
handler: function(){
|
|
Ext.Msg.show({
|
|
title:'Clear Log Messages?',
|
|
msg: 'You are about to clear log. All data and pictures will be deleted. Would you like to do so?',
|
|
buttons: Ext.Msg.YESNOCANCEL,
|
|
fn: function(btn, text){
|
|
if( btn == 'yes' ){
|
|
Ext.Ajax.request({
|
|
url: '/lib/controller/clearLOG.php',
|
|
success: function( response, opts ){
|
|
var obj = Ext.decode( response.responseText );
|
|
},
|
|
failure: function( response, opts ){
|
|
Ext.Msg.alert('Status', 'Error Creating AJAX Connection.<br>Code: CENDL00215');
|
|
},
|
|
headers: {
|
|
'my-header': 'foo'
|
|
},
|
|
params: { last_id: lastId }
|
|
});
|
|
};
|
|
},
|
|
animEl: 'mygrid',
|
|
icon: Ext.MessageBox.WARNING
|
|
});
|
|
},
|
|
disabled: false
|
|
}]
|
|
}]
|
|
});
|
|
|
|
|
|
Ext.ux.SliderTip = Ext.extend(Ext.Tip, {
|
|
minWidth: 10,
|
|
offsets : [0, -10],
|
|
init : function(slider){
|
|
slider.on('dragstart', this.onSlide, this);
|
|
slider.on('drag', this.onSlide, this);
|
|
slider.on('dragend', this.hide, this);
|
|
slider.on('destroy', this.destroy, this);
|
|
},
|
|
|
|
onSlide : function(slider){
|
|
this.show();
|
|
this.body.update(this.getText(slider));
|
|
this.doAutoWidth();
|
|
this.el.alignTo(slider.thumb, 'b-t?', this.offsets);
|
|
},
|
|
|
|
getText : function(slider){
|
|
return String(slider.getValue());
|
|
}
|
|
});
|
|
|
|
STip = new Ext.ux.SliderTip({
|
|
getText: function(slider){
|
|
return String.format('<b>More Than {0} '+SPEED_TYPE+'</b>', slider.getValue());
|
|
}
|
|
});
|
|
|
|
Ext.QuickTips.init();
|
|
// turn on validation errors beside the field globally
|
|
Ext.form.Field.prototype.msgTarget = 'under';
|
|
|
|
updateInterval = setInterval( GetGroupedEvents, 1000 );
|
|
});
|