//
var UartListStore = new Ext.data.JsonStore({
root: 'ports',
totalProperty: 'totalCount',
idProperty: 'uart_id',
remoteSort: false,
baseParams: {
UID: '=$CUser->Data['id'];?>',
SID: '=$Session;?>',
SITE: =$SiteID;?>
},
fields: [{
name: 'uart_id',
type: 'int'
},{
name: 'uart_name',
type: 'string'
}],
proxy : new Ext.data.HttpProxy({
method: 'POST',
prettyUrls: false,
url: '/lib/controller/listUarts.php'
})
});
var ServerListStore = new Ext.data.JsonStore({
root: 'servers',
totalProperty: 'totalCount',
idProperty: 'server_id',
remoteSort: false,
baseParams: {
UID: '=$CUser->Data['id'];?>',
SID: '=$Session;?>',
SITE: =$SiteID;?>
},
fields: [{
name: 'server_id',
type: 'int'
},{
name: 'server_name',
type: 'string'
}],
proxy : new Ext.data.HttpProxy({
method: 'POST',
prettyUrls: false,
url: '/lib/controller/listServers.php'
})
});
function loadSettingsLidar3D( NodeID, Master ){
SelectedNodeID = NodeID;
Ext.Ajax.request({
url: '/lib/controller/getSettingsLidsr3D.php',
params: {
NID: NodeID,
MST: ((Master)?1:0),
UID: =$UserID;?>,
SID: '=$Session;?>',
},
success: function( response, opts ){
// If the response is JSON, you have to decode it
var data = Ext.decode(response.responseText);
Ext.getCmp('setting_master_ip').setValue( data.ip_address );
Ext.getCmp('setting_master_port').setValue( data.port );
Ext.getCmp('setting_slave_ip').setValue( data.aux_ip_address );
Ext.getCmp('setting_slave_port').setValue( data.aux_port );
Ext.getCmp('setting_lat').setValue( data.lat );
Ext.getCmp('setting_lon').setValue( data.lon );
Ext.getCmp('setting_alt').setValue( data.alt );
Ext.getCmp('setting_roll').setValue( data.roll );
Ext.getCmp('setting_pitch').setValue( data.pitch );
Ext.getCmp('setting_yaw').setValue( data.yaw );
},
failure: failureAJAXFunction
});
};
function saveSettingsLidar3D( ){
if( SelectedNodeID == 0 ) return;
t1 = Ext.getCmp('setting_master_ip').getValue();
t2 = Ext.getCmp('setting_master_port').getValue();
t3 = Ext.getCmp('setting_slave_ip').getValue();
t4 = Ext.getCmp('setting_slave_port').getValue();
t5 = Ext.getCmp('setting_lat').getValue();
t6 = Ext.getCmp('setting_lon').getValue();
t7 = Ext.getCmp('setting_alt').getValue();
t8 = Ext.getCmp('setting_roll').getValue();
t9 = Ext.getCmp('setting_pitch').getValue();
t10 = Ext.getCmp('setting_yaw').getValue();
Ext.Ajax.request({
url: '/lib/controller/setSettingsLidsr3D.php',
params: {
NID: SelectedNodeID,
UID: =$UserID;?>,
SID: '=$Session;?>',
MIP: t1,
MPP: t2,
SIP: t3,
SPP: t4,
LAT: t5,
LON: t6,
ALT: t7,
ROL: t8,
PCH: t9,
YAW: t10
},
success: function( response, opts ){
// If the response is JSON, you have to decode it
var data = Ext.decode(response.responseText);
if( data.success == true ) {
Ext.Msg.show({
title:'Info Message',
msg: 'Settings are sucessfully saved.',
buttons: Ext.Msg.OK,//YESNOCANCEL,
fn: function(){
SettingsLidar3D.hide();
},
//animEl: 'elId',
icon: Ext.MessageBox.INFO //QUESTION
});
} else {
Ext.Msg.show({
title:'Error Message',
msg: data['error'],
buttons: Ext.Msg.OK,//YESNOCANCEL,
fn: function(){
SettingsLidar3D.hide();
},
//animEl: 'elId',
icon: Ext.MessageBox.ERROR //QUESTION
});
};
},
failure: failureAJAXFunction
});
};
function editSettingsLidar3D( NodeID, Master ){
if( SettingsLidar3D == null ){
SettingsLidar3D = new Ext.Window({
modal: true,
title: '=$Labels->GetLabel("_EDIT_LRF3D_SETTINGS_");?>',
width: 773,
height: 600,
layout: 'fit',
closeAction: 'hide',
listeners:{
beforehide : function(){
Ext.getCmp('connectstarterbutton').toggle( false, false );
}
},
items:[{
layout: 'table',
border: false,
defaults: {
// applied to each contained panel
bodyStyle:'padding-top:10px;padding-left:20px;padding-right:20px;padding-bottom:10px;'
},
layoutConfig: {
// The total column count must be specified here
columns: 4
},
items: [{
border: false,
html: 'Master IP Address:'
},{
xtype: 'textfield',
id: 'setting_master_ip',
width: '70%'
},{
border: false,
html: 'Port:'
},{
xtype: 'textfield',
id: 'setting_master_port',
width: '30%'
},{
border: false,
html: 'Slave IP Address:'
},{
xtype: 'textfield',
id: 'setting_slave_ip',
width: '70%'
},{
border: false,
html: 'Port:'
},{
xtype: 'textfield',
id: 'setting_slave_port',
width: '30%'
},{
border: false,
html: 'Position Lat/Lon/Alt:'
},{
xtype: 'textfield',
id: 'setting_lat',
width: '30%'
},{
xtype: 'textfield',
id: 'setting_lon',
width: '30%'
},{
xtype: 'textfield',
id: 'setting_alt',
width: '30%'
},{
border: false,
html: 'Orientation Roll/Pitch/Yaw:'
},{
xtype: 'textfield',
id: 'setting_roll',
width: '30%'
},{
xtype: 'textfield',
id: 'setting_pitch',
width: '30%'
},{
xtype: 'textfield',
id: 'setting_yaw',
width: '30%'
}]
}],
bbar: [{
text: '=$Labels->GetLabel("_CANCEL_");?>',
handler: function(){
SettingsLidar3D.hide();
}
},{
text: '=$Labels->GetLabel("_SAVE_");?>',
handler: SaveSettingsLidar3D
}]
});
};
SettingsLidar3D.show();
loadSettingsLidar3D( NodeID, Master );
};
var devicesStore = new Ext.data.JsonStore({
root: 'nodes',
totalProperty: 'totalCount',
idProperty: 'id',
remoteSort: true,
fields: [{
name: 'id',
type: 'int'
},{
name: 'name',
type: 'string'
},{
name: 'hardware',
type: 'string'
},{
name: 'caps',
type: 'int'
},{
name: 'ip',
type: 'string'
},{
name: 'mac',
type: 'string'
}],
proxy : new Ext.data.HttpProxy({
method: 'POST',
prettyUrls: false,
url: '/lib/controller/listDiscoveredCameraSources.php',
headers: {
'UID': '=$CUser->Data['id'];?>',
'SID': '=$Session;?>'
}
})
});
var LRF1D2_st_win = null;
var LRF2D2_st_win = null;
var LRF16D3_st_win = null;
function doDeviceOperation( NodeID, OpCode, Param='' ){
Ext.Ajax.request({
url: '/lib/controller/doDeviceOperation.php',
params: {
NID: NodeID,
UID: '=$CUser->Data['id'];?>',
CMD: OpCode,
SID: '=$Session;?>',
PARAM: Param
},
success: function( response, opts ){
var data = Ext.decode(response.responseText);
if( !data.success ){
Ext.Msg.show({
title:'Node Command Status',
msg: data.msg,
buttons: Ext.Msg.OK,
//fn: processResult,
//animEl: 'upddiBTN',
icon: Ext.MessageBox.ERROR
});
} else {
Ext.Msg.show({
title:'Node Command Status',
msg: data.query,
buttons: Ext.Msg.OK,
//fn: processResult,
//animEl: 'upddiBTN',
icon: Ext.MessageBox.INFO
});
};
},
failure: failureAJAXFunction
});
};
function loadFullLRF1D2Data( NodeID ){
if( LRF1D2_st_win == null ) return;
Ext.Ajax.request({
url: '/lib/controller/getSettingsLRF.php',
params: {
NID: NodeID,
UID: '=$CUser->Data['id'];?>',
SID: '=$Session;?>',
},
success: function( response, opts ){
if( LRF1D2_st_win!= null ){
var data = Ext.decode(response.responseText);
if( data.online ){
switch( data.data_status ){
case 0: Ext.getCmp('dev_online').update('
ONLINE/Data Incomplete
'); break;
case 1: Ext.getCmp('dev_online').update('ONLINE/Synced
'); break;
case 2: Ext.getCmp('dev_online').update('ONLINE/Data Not Applyed
'); break;
};
} else {
switch( data.data_status ){
case 0: Ext.getCmp('dev_online').update('OFFLINE/Data Incomplete
'); break;
case 1: Ext.getCmp('dev_online').update('OFFLINE/Synced
'); break;
case 2: Ext.getCmp('dev_online').update('OFFLINE/Data Not Applyed
'); break;
};
};
Ext.getCmp('dev_name').setValue( data.name );
Ext.getCmp('serial_num').setValue( data.serial );
Ext.getCmp('version_id').setValue( data.version );
Ext.getCmp('device_id').setValue( data.device_id );
Ext.getCmp('com_spd').setValue( data.com_spd );
Ext.getCmp('max_range').setValue( data.max_range );
Ext.getCmp('base_shift').setValue( data.base_shift );
Ext.getCmp('com_spd').setValue( data.uart_speed );
Ext.getCmp('mlrf_offset').setValue( data.m_offset );
Ext.getCmp('slrf_offset').setValue( data.s_offset );
Ext.getCmp('mlrf_delta').setValue( data.m_delta );
Ext.getCmp('slrf_delta').setValue( data.s_delta );
Ext.getCmp('mlrf_width').setValue( data.m_width );
Ext.getCmp('slrf_width').setValue( data.s_width );
Ext.getCmp('mlrf_order').setValue( data.m_order );
Ext.getCmp('slrf_order').setValue( data.s_order );
Ext.getCmp('mlrf_sst').setValue( data.m_sst );
Ext.getCmp('slrf_sst').setValue( data.s_sst );
Ext.getCmp('mlrf_flip').setValue( data.m_flip );
Ext.getCmp('slrf_flip').setValue( data.s_flip );
Ext.getCmp('mlrf_sun').setValue( data.m_sun );
Ext.getCmp('slrf_sun').setValue( data.s_sun );
};
},
failure: failureAJAXFunction
});
};
function LRF1D2_settings(){
if( LRF1D2_st_win == null ){
LRF1D2_st_win = new Ext.Window({
title: 'Sensor Settings',
modal: true,
width: 800,
height: 600,
closeAction: 'hide',
items:{
xtype: 'tabpanel',
activeTab: 0,
items:[{
title: 'General Settings',
xtype: 'form',
layout: 'table',
defaults: {
bodyStyle:'padding:20px'
},
layoutConfig: {
columns: 3
},
items:[{
html: 'Status',
frame: false,
border: false
},{
html: 'ONLINE
',
id: 'dev_online',
frame: false,
border: false
},{},{
html: 'Device Title',
frame: false,
border: false
},{
xtype: 'field',
id: 'dev_name',
readOnly: false,
value: 'KOKO'
},{},{
html: 'Serial Number',
frame: false,
border: false
},{
xtype: 'field',
id: 'serial_num',
readOnly: true,
value: '1212'
},{},{
html: 'Version ID',
frame: false,
border: false
},{
xtype: 'field',
id: 'version_id',
readOnly: true,
value: 'LiberManDA122'
},{},{
html: 'Device Adress',
frame: false,
border: false
},{
xtype: 'numberfield',
id: 'device_id'
},{
xtype: 'button',
id: 'upddiBTN',
text: 'Update Device Address',
handler: function(){
Ext.Msg.show({
title:'Update Device Address?',
msg: 'Are you sure to do so?',
buttons: Ext.Msg.YESNOCANCEL,
//fn: processResult,
animEl: 'upddiBTN',
icon: Ext.MessageBox.QUESTION
});
}
},{
html: 'Device COM Speed',
frame: false,
border: false
},{
xtype: 'combo',
id: 'com_spd',
editable: false,
typeAhead: true,
triggerAction: 'all',
width: '100%',
lazyRender:true,
mode: 'local',
store: new Ext.data.ArrayStore({
id: 0,
fields: ['mySPD', 'displayText' ],
data: [[4800,'4800'],[9600,'9600'],[14400,'14400'],[19200,'19200'],[38400, '38400'],[56000,'56000'],[57600,'57600'],[115200,'115200']]
}),
valueField: 'mySPD',
displayField: 'displayText'
},{
xtype: 'button',
id: 'updspBTN',
text: 'Set Device Speed',
handler: function(){
Ext.Msg.show({
title:'Update Device Speed?',
msg: 'Are you sure to do so?',
buttons: Ext.Msg.YESNOCANCEL,
//fn: processResult,
animEl: 'upddiBTN',
icon: Ext.MessageBox.QUESTION
});
}
},{
html: 'Detection Maximal Range',
frame: false,
border: false
},{
xtype: 'numberfield',
id: 'max_range',
readOnly: true,
value: '1212'
},{},{
html: 'Base Shift',
frame: false,
border: false
},{
xtype: 'numberfield',
id: 'base_shift',
readOnly: true,
value: '1212'
},{}]
},{
title: 'Mantenence',
xtype: 'form',
layout: 'table',
defaults: {
bodyStyle:'padding:20px'
},
layoutConfig: {
columns: 2
},
items:[{
html: 'Restart Device',
frame: false,
border: false
},{
xtype: 'button',
id: 'rstBTN',
text: 'Full Reset',
handler: function(){
Ext.Msg.show({
title:'Reset Device?',
msg: 'You are closing a tab that has unsaved changes. Would you like to save your changes?',
buttons: Ext.Msg.YESNOCANCEL,
//fn: processResult,
animEl: 'rstBTN',
icon: Ext.MessageBox.QUESTION
});
}
}]
},{
title: 'Detection Settings',
xtype: 'form',
layout: 'table',
defaults: {
bodyStyle:'padding:20px'
},
layoutConfig: {
columns: 4
},
items:[{
html: 'Master Offset',
frame: false,
border: false
},{
xtype: 'numberfield',
id: 'mlrf_offset',
name: 'mlrf_offset',
allowBlank: false,
allowDecimals: false,
maxText: 'The Range is: 0 - 60',
maxValue: 60,
minText: 'No Negative Values Allowed',
minValue: 0,
},{
html: 'Slave Offset',
frame: false,
border: false
},{
xtype: 'numberfield',
id: 'slrf_offset',
name: 'slrf_offset',
allowBlank: false,
allowDecimals: false,
maxText: 'The Range is: 0 - 60',
maxValue: 60,
minText: 'No Negative Values Allowed',
minValue: 0,
},{
html: 'Master Delta',
frame: false,
border: false
},{
xtype: 'numberfield',
id: 'mlrf_delta',
name: 'mlrf_delta',
allowBlank: false,
allowDecimals: false,
maxText: 'The Range is: 0 - 320',
maxValue: 320,
minText: 'No Negative Values Allowed',
minValue: 0
},{
html: 'Slave Delta',
frame: false,
border: false
},{
xtype: 'numberfield',
id: 'slrf_delta',
name: 'slrf_delta',
allowBlank: false,
allowDecimals: false,
maxText: 'The Range is: 0 - 320',
maxValue: 320,
minText: 'No Negative Values Allowed',
minValue: 0
},{
html: 'Master Width',
frame: false,
border: false
},{
xtype: 'numberfield',
id: 'mlrf_width',
name: 'mlrf_width',
allowBlank: false,
allowDecimals: false,
maxText: 'The Range is: 1800 - 16000',
maxValue: 16000,
minText: 'The Range is: 1800 - 16000',
minValue: 1800
},{
html: 'Slave Width',
frame: false,
border: false
},{
xtype: 'numberfield',
id: 'slrf_width',
name: 'slrf_width',
allowBlank: false,
allowDecimals: false,
maxText: 'The Range is: 1800 - 16000',
maxValue: 16000,
minText: 'The Range is: 1800 - 16000',
minValue: 1800
},{
html: 'Master Order',
frame: false,
border: false
},{
xtype: 'numberfield',
id: 'mlrf_order',
name: 'mlrf_order',
allowBlank: false,
allowDecimals: false,
maxText: 'The Range is: 0 - 10',
maxValue: 10,
minText: 'No Negative Values Allowed',
minValue: 0
},{
html: 'Slave Order',
frame: false,
border: false
},{
xtype: 'numberfield',
id: 'slrf_order',
name: 'slrf_order',
allowBlank: false,
allowDecimals: false,
maxText: 'The Range is: 0 - 10',
maxValue: 10,
minText: 'No Negative Values Allowed',
minValue: 0
},{
html: 'Master SST',
frame: false,
border: false
},{
xtype: 'numberfield',
id: 'mlrf_sst',
name: 'mlrf_sst',
allowBlank: false,
allowDecimals: false,
maxText: 'The Range is: 0 - 100',
maxValue: 100,
minText: 'No Negative Values Allowed',
minValue: 0
},{
html: 'Slave SST',
frame: false,
border: false
},{
xtype: 'numberfield',
id: 'slrf_sst',
name: 'slrf_sst',
allowBlank: false,
allowDecimals: false,
maxText: 'The Range is: 0 - 100',
maxValue: 100,
minText: 'No Negative Values Allowed',
minValue: 0
},{
html: 'Mastr Flip',
frame: false,
border: false
},{
xtype: 'numberfield',
id: 'mlrf_flip',
name: 'mlrf_flip',
allowBlank: false,
allowDecimals: false,
maxText: 'The Range is: 8 - 128',
maxValue: 128,
minText: 'The Range is: 8 - 128',
minValue: 8
},{
html: 'Slave Flip',
frame: false,
border: false
},{
xtype: 'numberfield',
id: 'slrf_flip',
name: 'slrf_flip',
allowBlank: false,
allowDecimals: false,
maxText: 'The Range is: 8 - 128',
maxValue: 128,
minText: 'The Range is: 8 - 128',
minValue: 8
},{
html: 'Master Sun',
frame: false,
border: false
},{
xtype: 'numberfield',
id: 'mlrf_sun',
name: 'mlrf_sun',
allowBlank: false,
allowDecimals: false,
maxText: 'The Range is: 0 - 100',
maxValue: 100,
minText: 'No Negative Values Allowed',
minValue: 0
},{
html: 'Slave Sun',
frame: false,
border: false
},{
xtype: 'numberfield',
id: 'slrf_sun',
name: 'slrf_sun',
allowBlank: false,
allowDecimals: false,
maxText: 'The Range is: 0 - 100',
maxValue: 100,
minText: 'No Negative Values Allowed',
minValue: 0
}]
},{
title: 'Embed Options'
},{
title: 'Target Width Table'
}]
}
});
};
LRF1D2_st_win.show();
loadFullLRF1D2Data( SelectedNodeID );
};
function LRF2D2_settings(){
};
function LRF16D3_settings(){
};
var currentResolveDeviceNode = 0;
var ResolveDeviceNodeWin = null;
function resolveDeviceMistmatch( NodeID ){
currentResolveDeviceNode = NodeID;
if( ResolveDeviceNodeWin == null ){
ResolveDeviceNodeWin = new Ext.Window({
title: '=$Labels->GetLabel('_WDEV_MISTMATCH_');?>',
modal: true,
width: 500,
height: 200,
closeAction: 'hide',
items:[{
xtype: 'spacer',
style: {
marginTop: '13px'
},
html: '=$Labels->GetLabel('_DEV_MISTMATT1_');?>',
height: 30
},{
xtype: 'button',
width: '100%',
text: 'It is Newly Connected Device',
handler: function(){
Ext.Ajax.request({
url: '/lib/controller/validateNode.php',
params: {
NID: currentResolveDeviceNode,
UID: '=$CUser->Data['id'];?>',
SID: '=$Session;?>',
MET: 1
},
success: function( response, opts ){
ResolveDeviceNodeWin.hide();
},
failure: failureAJAXFunction
});
}
},{
xtype: 'button',
width: '100%',
text: 'Apply Existing Detection Profiles to Newly Connected Device',
handler: function(){
Ext.Ajax.request({
url: '/lib/controller/validateNode.php',
params: {
NID: currentResolveDeviceNode,
UID: '=$CUser->Data['id'];?>',
SID: '=$Session;?>',
MET: 1
},
success: function( response, opts ){
ResolveDeviceNodeWin.hide();
},
failure: failureAJAXFunction
});
}
},{
xtype: 'button',
width: '100%',
text: 'Discard old Detection Profiles and Start Device Setup Wizard',
handler: function(){
ResolveDeviceNodeWin.hide();
startDeviceDetectionWizard( currentResolveDeviceNode );
}
},{
xtype: 'button',
width: '100%',
text: 'Discard old Detection Profiles and Load Factory Settings from Device'
},{
xtype: 'button',
width: '100%',
text: 'Discard this Connection for NOW'
}]
});
};
ResolveDeviceNodeWin.show();
};
var DeviceDetectionWizardWnd = null;
var DDWizardActiveDevice = '';
var RangeSetBlocker = false;
function startDeviceDetectionWizard( NodeID ){
DDWizardActiveDevice = NodeID
if( DeviceDetectionWizardWnd == null ){
DeviceDetectionWizardWnd = new Ext.Window({
title: '=$Labels->GetLabel('_WDEV_DET_WIZT_');?>',
modal: true,
width: 500,
height: 208,
closeAction: 'hide',
items:[{
xtype: 'tabpanel',
activeTab: 1,
items: [{
title: '=$Labels->GetLabel('_WDEV_DET_WIZ0_');?>',
frame: false,
xtype: 'form',
items:[{
xtype: 'spacer',
height: 20
},{
xtype: 'combo',
id: 'DDWizST',
fieldLabel: '=$Labels->GetLabel('_DEV_TYPE_FLD_');?>',
typeAhead: true,
triggerAction: 'all',
lazyRender:true,
mode: 'local',
store: new Ext.data.ArrayStore({
id: 0,
fields: [
'dtId',
'dtText'
],
data: [
[1, '=$Labels->GetLabel('_DEV_TYPE_ALS_');?>'],
[2, '=$Labels->GetLabel('_DEV_TYPE_LFS_');?>'],
[3, '=$Labels->GetLabel('_DEV_TYPE_PLS200_');?>'],
[4, '=$Labels->GetLabel('_DEV_TYPE_PLS360_');?>'],
[5, '=$Labels->GetLabel('_DEV_TYPE_3D_');?>'],
[6, '=$Labels->GetLabel('_DEV_TYPE_NPLS200_');?>']
]
}),
valueField: 'dtId',
displayField: 'dtText'
},{
xtype: 'numberfield',
id: 'DDWizSR',
fieldLabel: '=$Labels->GetLabel('_DEV_RANGE_FLD_');?>',
minValue: 15.0,
maxValue: 300.0,
listeners:{
change: function( m, nv, ov ){
if( RangeSetBlocker ) return;
RangeSetBlocker = true;
Ext.getCmp('DDWizSRS').setValue( nv );
RangeSetBlocker = false;
}
}
},{
xtype: 'slider',
id: 'DDWizSRS',
fieldLabel: '=$Labels->GetLabel('_DEV_RANGE_FLD_');?>',
minValue: 15.0,
maxValue: 300.0,
listeners:{
change: function( m, nv, ov ){
if( RangeSetBlocker ) return;
RangeSetBlocker = true;
Ext.getCmp('DDWizSR').setValue( nv );
RangeSetBlocker = false;
}
}
},{
xtype: 'spacer',
height: 10
}]
},{
title: '=$Labels->GetLabel('_WDEV_DET_WIZ1_');?>',
frame: false,
xtype: 'form',
labelWidth: 120,
items:[{
xtype: 'spacer',
height: 20
},{
xtype: 'combo',
id: 'DDWizIT',
fieldLabel: '=$Labels->GetLabel('_DEV_ITYPE_FLD_');?>',
typeAhead: true,
triggerAction: 'all',
lazyRender:true,
mode: 'local',
value: 1,
store: new Ext.data.ArrayStore({
id: 0,
fields: [
'dpId',
'dpText'
],
data: [
[1, '=$Labels->GetLabel('_DEV_PL_HORI_');?>'],
[2, '=$Labels->GetLabel('_DEV_PL_VERT_');?>'],
[3, '=$Labels->GetLabel('_DEV_PL_ANG_');?>']
]
}),
valueField: 'dpId',
displayField: 'dpText'
}]
},{
title: '=$Labels->GetLabel('_WDEV_DET_WIZ2_');?>',
html: 'Another one'
},{
title: '=$Labels->GetLabel('_WDEV_DET_WIZ3_');?>',
html: 'Another one'
}]
}],
bbar:[{
text: 'Create Profiles And Finish',
handler: function(){
DeviceDetectionWizardWnd.hide();
}
},{
text: 'Advanced Config',
handler: function(){
DeviceDetectionWizardWnd.hide();
startAdvancedDeviceDetection( DDWizardActiveDevice );
}
}]
});
};
Ext.Ajax.request({
url: '/lib/controller/getNodeBasicNfo.php',
params: {
NID: DDWizardActiveDevice,
UID: '=$CUser->Data['id'];?>',
SID: '=$Session;?>'
},
success: function( response, opts ){
var data = Ext.decode(response.responseText);
DeviceDetectionWizardWnd.setTitle( '=$Labels->GetLabel('_WDEV_DET_WIZT_');?> [' + data.name+']' );
Ext.getCmp('DDWizST').setValue( data.type );
RangeSetBlocker = true;
Ext.getCmp('DDWizSR').setValue( data.range );
Ext.getCmp('DDWizSRS').setValue( data.range );
RangeSetBlocker = false;
DeviceDetectionWizardWnd.show();
},
failure: failureAJAXFunction
});
};
var DeviceDetectionAdvancedWnd = null;
var DeviceDetectionProfileNames = ['factory default', 'low sens', 'medium sens', 'high sens'];
function loadAdvancedDeviceDetectionSettings(){
Ext.getCmp('ADD_TP').removeAll( false );
Ext.Ajax.request({
url: '/lib/controller/getNodeAdvancedNfo.php',
params: {
NID: DDWizardActiveDevice,
UID: '=$CUser->Data['id'];?>',
SID: '=$Session;?>'
},
success: function( response, opts ){
var data = Ext.decode(response.responseText);
DeviceDetectionAdvancedWnd.setTitle( '=$Labels->GetLabel('_WDEV_DET_WIZT_');?> [' + data.name+']' );
if( data.profiles.length > 0 ){
if( data.profiles.length > 3 ) Ext.getCmp('ADD_PADD_BTN').disable();
switch( data.type ){
case 1:
case 5:{
for( i = 0; i < data.profiles.length / 2; i++){
};
break;
};
case 2:
case 3:
case 4:
case 6:{
for( i = 0; i < data.profiles.length; i++){
Ext.getCmp('ADD_TP').add({
title: DeviceDetectionProfileNames[ data.profiles[i].id ],
xtype: 'form',
frame: false,
items:[{xtype: 'spacer', height: 10 },{
xtype: 'numberfield',
id: 'OFFSET_P'+data.profiles[i].id,
fieldLabel: 'OFFSET',
minValue: 15.0,
maxValue: 300.0,
value: data.profiles[i].offset
},{
xtype: 'numberfield',
id: 'DELTA_P'+data.profiles[i].id,
fieldLabel: 'DELTA',
minValue: 15.0,
maxValue: 300.0,
value: data.profiles[i].delta
},{
xtype: 'numberfield',
id: 'WIDTH_P'+data.profiles[i].id,
fieldLabel: 'WIDTH',
minValue: 15.0,
maxValue: 300.0,
value: data.profiles[i].width
},{
xtype: 'numberfield',
id: 'SST_P'+data.profiles[i].id,
fieldLabel: 'SST',
minValue: 15.0,
maxValue: 300.0,
value: data.profiles[i].sst
},{
xtype: 'numberfield',
id: 'FLIP_P'+data.profiles[i].id,
fieldLabel: 'FLIP',
minValue: 15.0,
maxValue: 300.0,
value: data.profiles[i].flip
},{
xtype: 'numberfield',
id: 'SUN_P'+data.profiles[i].id,
fieldLabel: 'SUN',
minValue: 15.0,
maxValue: 300.0,
value: data.profiles[i].sun
}]
});
};
break;
};
};
//
} else {
Ext.getCmp('ADD_TP').add({
title: 'Error!',
html: 'No Profiles Defined'
});
};
DeviceDetectionAdvancedWnd.show();
},
failure: failureAJAXFunction
});
};
function startAdvancedDeviceDetection( NodeID ){
DDWizardActiveDevice = NodeID;
if( DeviceDetectionAdvancedWnd == null ){
DeviceDetectionAdvancedWnd = new Ext.Window({
title: '=$Labels->GetLabel('_WDEV_DET_WIZT_');?>',
modal: true,
width: 500,
height: 300,
closeAction: 'hide',
items:[{
xtype: 'tabpanel',
id: 'ADD_TP',
frame: false,
border: false,
activeTab: 0,
items: []
}],
bbar:[{
id: 'ADD_PADD_BTN',
text: 'Add Detection Profile',
handler: function(){
Ext.Ajax.request({
url: '/lib/controller/addDetectionProfile.php',
params: {
NID: DDWizardActiveDevice,
UID: '=$CUser->Data['id'];?>',
SID: '=$Session;?>'
},
success: function( response, opts ){
loadAdvancedDeviceDetectionSettings();
},
failure: failureAJAXFunction
});
}
},{
text: 'Apply And Finish'
},{
text: 'Use Wizard'
}]
});
};
loadAdvancedDeviceDetectionSettings();
};
var maskEditorDiv = null;
var MEPanel = null;
function handleFSMaskEditorClose( event ){
if ( document.fullscreenElement ||
document.webkitFullscreenElement ||
document.mozFullScreenElement ||
document.msFullscreenElement ){
} else {
MEPanel.destroy();
maskEditorDiv.remove();
maskEditorDiv = null;
MEPanel = null;
document.removeEventListener( 'fullscreenchange', handleFSMaskEditorClose );
};
};
function hideMaskEditor(){
if(
document.fullscreenElement ||
document.webkitFullscreenElement ||
document.mozFullScreenElement ||
document.msFullscreenElement
){
if( document.exitFullscreen ){
document.exitFullscreen();
}else if( document.mozCancelFullScreen ){
document.mozCancelFullScreen();
}else if( document.webkitExitFullscreen ){
document.webkitExitFullscreen();
}else if( document.msExitFullscreen ){
document.msExitFullscreen();
};
// Removal Done by event!
//maskEditorDiv.remove();
//maskEditorDiv = null;
//document.removeEventListener( 'fullscreenchange', handleFSMaskEditorClose );
};
};
var values = {
paths: 50,
minPoints: 5,
maxPoints: 15,
minRadius: 30,
maxRadius: 90
};
var hitOptions = {
segments: true,
stroke: true,
fill: true,
tolerance: 10
};
var polycolors = new Array();
var polyindex = 0;
var poligones = new Array();
var segment = null;
var path = null;
var MaskProject = null;
var MaskEditorMode = 0;
function onMouseDown(event) {
segment = path = null;
var hitResult = MaskProject.hitTest( event.point, hitOptions );
if (!hitResult) return;
if( event.modifiers.shift ){
if (hitResult.type == 'segment') {
hitResult.segment.remove();
};
return;
};
if( hitResult ){
path = hitResult.item;
if( hitResult.type == 'segment' ){
segment = hitResult.segment;
path.fullySelected = false;
segment.selected = true;
} else if( hitResult.type == 'stroke' ){
var location = hitResult.location;
segment = path.insert(location.index + 1, event.point);
//path.smooth();
path.fullySelected = false;
segment.selected = true;
} else if ( hitResult.type == 'fill' ){
path.fullySelected = true;
};
}
//movePath = ;
//if( movePath ) MaskProject.activeLayer.addChild(hitResult.item);
}
function onMouseMove(event) {
MaskProject.activeLayer.selected = false;
if( event.item ) {
//event.item.selected = true;
event.item.fullySelected = true;
};
}
function onMouseDrag(event) {
if( segment ){
//segment.point += event.delta;
segment.point = event.point;
//path.smooth();
};
//else if (path) {
// path.position += event.delta;
//}
}
var absDrawMapSizes = [[0,0],[2304,288]];
var deviceMapScaling = 1.0;
var deviceMapTopShift = 100;
var deviceMapLeftShift = 100;
var cMapImageWidth = 0;
var cMapImageHeight = 0;
var cMapCanvasWidth = 0;
var cMapCanvasHeight = 0;
function showMaskEditor( fromDevTool, DevType, NodeID ){
//alert( "DevType: "+DevType + " Dev Map size: "+ absDrawMapSizes[DevType][0]+"x"+absDrawMapSizes[DevType][1] );
deviceMapScaling = ( window.screen.height * window.devicePixelRatio - 130 - ( deviceMapTopShift * 2 )) / absDrawMapSizes[DevType][1];
cMapImageHeight = deviceMapScaling * absDrawMapSizes[DevType][1];
cMapImageWidth = deviceMapScaling * absDrawMapSizes[DevType][0];
cMapCanvasWidth = cMapImageWidth + (deviceMapLeftShift * 2);
cMapCanvasHeight = cMapImageHeight + (deviceMapTopShift * 2);
if( fromDevTool ){
detectionProfileWindow.hide();
};
if(
document.fullscreenElement ||
document.webkitFullscreenElement ||
document.mozFullScreenElement ||
document.msFullscreenElement
){
//fs mode allready
hideMaskEditor();
}else{
if( maskEditorDiv == null ){
maskEditorDiv = document.createElement("div");
maskEditorDiv.style.height="200px";
maskEditorDiv.style.width="200px";
//maskEditorDiv.style.backgroundImage = "url('your_image.png')";
//append div as a child to body
document.body.appendChild( maskEditorDiv );
//var elem = document.createElement("img"); 'getDeviceMap.php?NID='+NodeID
//elem.setAttribute("src", "/lib/controller/data/device_draws/75c85fec4be204fc0bc0452f53b5a3df_map.png");
//elem.setAttribute("height", "80%");
//elem.setAttribute("width", "130");
//maskEditorDiv.appendChild( elem );
//alert( window.screen.width * window.devicePixelRatio + "x" + window.screen.height * window.devicePixelRatio);
if( MEPanel == null ){
var ww = window.screen.width * window.devicePixelRatio;
var hh = window.screen.height * window.devicePixelRatio;
MEPanel = new Ext.Panel( {
title: 'Mask Editor',
renderTo: maskEditorDiv,
width: ww,
height: hh,
frame: true,
autoScroll: true,
items:[{
xtype: 'panel',
width: cMapCanvasWidth,
html: ''
}],
tbar:[{
text:'New Polygone',
id: 'me_b_newp',
enableToggle: true,
toggleGroup: 'me_topbar_grp',
handler: function( btn ){
if( btn.pressed ) setMaskEditorMode( 0 );
}
},{
text:'Delete Polygone',
id: 'me_b_delp',
enableToggle: true,
toggleGroup: 'me_topbar_grp'
},{
text:'Delete Point',
id: 'me_b_delpo',
enableToggle: true,
toggleGroup: 'me_topbar_grp'
},{
text:'Clear Mask',
id: 'me_b_delm',
handler: function(){
if( MaskProject!= null ){
alert( 'ClearMask' );
};
}
}],
buttons:[{
text: 'Cancel',
handler: function(){
hideMaskEditor();
}
},{
text:'Save Mask and Close',
handler: function(){
var serial = MaskProject.exportJSON();
Ext.Ajax.request({
url: '/lib/controller/uploadDeviceMask.php',
params: {
NID: NodeID,
UID: '=$CUser->Data['id'];?>',
SID: '=$Session;?>',
MID: 0,
LID: 0,
MDTA: serial,
MIH: cMapImageHeight,
//MSF: deviceMapScaling,
MSHX: deviceMapLeftShift,
MSHY: deviceMapTopShift
},
success: function( response, opts ){
var data = Ext.decode(response.responseText);
hideMaskEditor();
},
failure: failureAJAXFunction
});
}
}]
});
};
MEPanel.doLayout();
loadDeviceMask( NodeID );
};
//maskEditorDiv = $('#container').get(0);
//var maskEditorDiv = document.getElementById( id ); //Ext.getCmp( id );
if( maskEditorDiv.requestFullscreen ){
maskEditorDiv.requestFullscreen();
}else if( maskEditorDiv.mozRequestFullScreen ){
maskEditorDiv.mozRequestFullScreen();
}else if( maskEditorDiv.webkitRequestFullscreen ){
maskEditorDiv.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
}else if( maskEditorDiv.msRequestFullscreen ){
maskEditorDiv.msRequestFullscreen();
};
document.addEventListener( 'fullscreenchange', handleFSMaskEditorClose );
};
};
function setMaskEditorMode( nM ){
switch( nM ){
case 0:{
var MEP = Ext.getCmp('me_b_newp');
if( !MEP.pressed ) MEP.toggle( true );
var caca = document.getElementById('mask_canvas');
caca.style.cursor = 'crosshair';
break;
};
case 1:{
var MEP = Ext.getCmp('me_b_newp');
if( !MEP.pressed ) MEP.toggle( false );
MEP = Ext.getCmp('me_b_delp');
if( !MEP.pressed ) MEP.toggle( false );
MEP = Ext.getCmp('me_b_delpo');
if( !MEP.pressed ) MEP.toggle( false );
if( MaskProject!= null ){
if( MaskProject.isEmpty() ){
MEP = Ext.getCmp('me_b_delp');
MEP.disable();
MEP = Ext.getCmp('me_b_delpo');
MEP.disable();
MEP = Ext.getCmp('me_b_delm');
MEP.disable();
setMaskEditorMode( 0 );
} else {
MEP = Ext.getCmp('me_b_delp');
MEP.enable();
MEP = Ext.getCmp('me_b_delpo');
MEP.enable();
MEP = Ext.getCmp('me_b_delm');
MEP.enable();
};
};
var caca = document.getElementById('mask_canvas');
caca.style.cursor = 'default';
break;
};
case 2:{
var MEP = Ext.getCmp('me_b_delp');
if( !MEP.pressed ) MEP.toggle( true );
break;
};
case 3:{
var MEP = Ext.getCmp('me_b_delpo');
if( !MEP.pressed ) MEP.toggle( true );
break;
};
};
MaskEditorMode = nM;
};
function loadDeviceMask( NodeID, LrfID = 0, LayerID = 0 ){
Ext.Ajax.request({
url: '/lib/controller/getDeviceMask.php',
params: {
NID: NodeID,
UID: '=$CUser->Data['id'];?>',
SID: '=$Session;?>',
MID: LayerID,
LID: LrfID
},
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();
path.strokeColor = 'black';
//var lightness = (Math.random() - 0.5) * 0.4 + 0.4;
//var hue = Math.random() * 360;
//path.fillColor = { hue: hue, saturation: 1, lightness: lightness };
path.fillColor = data[i].colour;
path.closed = true;
path.opacity = 0.5;
//path.onMouseMove = onMouseMove;
path.onMouseDown = onMouseDown;
path.onMouseDrag = onMouseDrag;
//path.onMouseUp = function( event ){
// path.add(event.point);
//}
if( data[i].points.length > 2 ){
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] );
};
path.fullySelected = true;
paper.view.draw();
};
poligones.push(path);
};
};
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 );
};
};
function onMaskMouseUp( evt ){
if( MaskEditorMode == 4 ){
path.lineTo( [ evt.clientX, evt.clientY ] );
setMaskEditorMode( 1 );
};
};
function onMaskMouseMove( event ){
if( MaskEditorMode == 4 ){
paper.view.draw();
};
};