123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501 |
- var CONST = {
- DeployStep_Begin : 0,
- DeployStep_GetTerminalInfo : 1,
- DeployStep_FetchCenterSettings : 2,
- DeployStep_AccessAuthorize : 3,
- DeployStep_MediaConfig : 4,
- DeployStep_Finished : 5
- };
- var MEDIA_TYPE = {
- CAMERA : 1,
- MICROPHONE : 2,
- LOUNDSPEAKER:4
- }
- var MEDIA_DETAIL_TYPE = {
- MediaDev_OutSpeaker:1,
- MediaDev_InSpeaker:2,
- MediaDev_OutMicrophone:3,
- MediaDev_InMicrophone:4
- }
- var VENDOR = {
- KEBA : 'KEBA',
- CW : 'CW',
- GRG : 'GRG',
- NANTIAN : 'NANTIAN',
- GWI : 'GWI'
- };
- $(function () {
-
- RVC.GuideController = RVC.Object.extend({
- hideAllPage: function () {
- $('#guide_start_page').hide();
- $('#guide_initparam_page').hide();
- $('#guide_sync_centersetting_page').hide();
- $('#guide_access_authorize_page').hide();
- $('#guide_media_config_page').hide();
- $('#guide_finish_page').hide();
- },
- resizeWindow: function () {
- var winHei = $(window).height();
- var popHeight = 480;
- var adjustHeight = 0;
- var blueBackgroundHeight = 0;
- if (winHei < 860) {
- winHei = 860;
- }
- blueBackgroundHeight = winHei - $('.headcontainer').height() - $('#page_footer').height();
- $('#guide_height').height(blueBackgroundHeight);
- adjustHeight = (blueBackgroundHeight - popHeight) * 0.5;
- $('#guide_start_page').css('padding-top', (adjustHeight + 100) + 'px');
- var domWidth = $('body').width();
- var winWidth = $('window').width();
- if (domWidth > winWidth) {
- setTimeout(function () {
- $('body').scrollTop($('.headcontainer').height() + adjustHeight);
- $('body').scrollLeft(($('body').width() - $(window).width()) / 2);
- }, 1000)
- }
- $('#guide_initparam_page').css('padding-top', adjustHeight + 'px');
- },
- beginInstall: function() {
- this.gotoPage(CONST.DeployStep_GetTerminalInfo);
- },
- gotoPage: function(nextStep) {
- var select_page = '';
- switch(nextStep) {
- case CONST.DeployStep_Begin:
- select_page = 'guide_start_page';
- break;
- case CONST.DeployStep_GetTerminalInfo :
- select_page = 'guide_initparam_page';
- break;
- case CONST.DeployStep_FetchCenterSettings:
- select_page = 'guide_sync_centersetting_page';
- break;
- case CONST.DeployStep_AccessAuthorize :
- select_page = 'guide_access_authorize_page';
- break;
- case CONST.DeployStep_MediaConfig :
- select_page = 'guide_media_config_page';
- break;
- case CONST.DeployStep_Finished :
- select_page = 'guide_finish_page';
- break;
- default:
- break;
- }
- if(select_page !== '') {
- this.hideAllPage();
- $('#' + select_page).show();
- } else {
- utilShowToast('无法识别步骤标识:' + nextStep, 3000);
- }
- },
- sectOverPass: function() {
- },
- sectNext: function() {
- }
- });
- RVC.CameraConfigEntity = RVC.EntityController.extend({
- entityName: 'CameraConfigManage',
- className: 'CameraConfigManageService',
- methodID: {
- GetMediaAvailableList: 9,
- SetMediaDevice: 10,
- TestAvailableMedieDev: 11
- },
- methodSignature: {
- GetMediaAvailableList: -1547834445,
- SetMediaDevice: -865058557,
- TestAvailableMedieDev: -2126935432
- },
- GetMediaAvailableList: function(req, callback) {
- this.webSocketInvokeEx(req,
- ({id:this.methodID.GetMediaAvailableList, sig:this.methodSignature.GetMediaAvailableList}),
- callback);
- },
- SetMediaDevice: function(req, callback) {
- this.webSocketInvokeEx(req,
- ({id:this.methodID.SetMediaDevice, sig:this.methodSignature.SetMediaDevice}),
- callback);
- },
- TestAvailableMedieDev: function(req, callback) {
- this.webSocketInvokeEx(req,
- ({id:this.methodID.TestAvailableMedieDev, sig:this.methodSignature.TestAvailableMedieDev}),
- callback);
- }
- });
- function IPConnectableTest(ip)
- {
- let req = new Request();
- req.protocol = 1; //Ping
- req.ip = ip;
- req.port = 0;
- req.reserved1 = 0;
- req.reserved2 = '';
- function showErrTips(val) {
- setTimeout(function () {
- $('#text_guide_initparam_ip_tips').addClass('hide');
- }, 3000);
- $('#text_guide_initparam_ip_tips').removeClass('hide')
- .removeClass('guide_input_descript').addClass('guide_error').html(val);
- }
- function showSuccTips(val) {
- setTimeout(function () {
- $('#text_guide_initparam_ip_tips').addClass('hide');
- }, 3000);
- $('#text_guide_initparam_ip_tips').removeClass('hide')
- .removeClass('guide_error').addClass('guide_input_descript').html(val);
- }
- if(!isValidIpAddress(ip)) {
- showErrTips('无效IP格式');
- return;
- }
- RVC.DeviceControlEntityCtrl.TestConnectivity(req, function(ret) {
- if(ret.errorCode === 0) {
- console.log('Ping 返回成功');
- let result = JSON.parse(ret[RVC.EntityController.sigResponseUUID])
- if(result.result == 0) {
- console.log(ip + ' 可正常连通');
- showSuccTips('可正常连通');
- } else {
- console.log(result.additionalMsg);
- showErrTips(result.additionalMsg);
- }
- } else {
- let tips = ip + ' 测试连接失败:' + ErrorCodeStringfy(ret.errorCode);
- console.error(tips);
- showErrTips(tips);
- }
- });
- }
- function DeployTerminalWithIPAndPort(server_ip, port, access_flag)
- {
- let req = new Request();
- if(!access_flag) {//下载集中配置
- req.currStep = CONST.DeployStep_FetchCenterSettings;
- req.preStep = CONST.DeployStep_GetTerminalInfo;
- //test
- req.nextStep = CONST.DeployStep_MediaConfig; //CONST.DeployStep_AccessAuthorize;
- } else {
- req.currStep = CONST.DeployStep_AccessAuthorize;
- req.preStep = CONST.DeployStep_FetchCenterSettings;
- req.nextStep = CONST.DeployStep_MediaConfig;
- }
- req.param1 = parseInt(port, 10);
- req.param2 = 0;
- req.param3 = server_ip;
- req.param4 = '';
- req.param5 = '';
- req.array1 = [0];
- req.array2 = [''];
- utilStartSubmitDialog();
- RVC.HealthmanagerEntityCtrl.DeployTerminal(req, function(ret) {
- utilStopSubmitDialog();
- if(ret.errorCode === 0) {
- let result = JSON.parse(ret[RVC.EntityController.sigResponseUUID])
- if(result.result == 0) {
- utilStartAlertDialog("操作成功", function() {
- RVC.GuideController.gotoPage(result.nextStep);
- });
- } else {
- utilStartAlertDialog("操作失败:[" + result.result + "] " + result.additionalMsg);
- }
- } else {
- RVC.HealthmanagerEntityCtrl.commErrorCallback(ret);
- }
- });
- }
- function InitTemrinalAbout(server_ip, new_terminalno, vendorName)
- {
- let req = new Request();
- req.currStep = CONST.DeployStep_GetTerminalInfo;
- req.preStep = CONST.DeployStep_Begin;
- req.nextStep = CONST.DeployStep_FetchCenterSettings;
- req.param1 = 0;
- req.param2 = 0;
- req.param3 = server_ip;
- req.param4 = new_terminalno + '|' + vendorName;
- req.param5 = '';
- req.array1 = [0];
- req.array2 = [''];
- utilStartSubmitDialog();
- RVC.HealthmanagerEntityCtrl.DeployTerminal(req, function(ret) {
- utilStopSubmitDialog();
- if(ret.errorCode === 0) {
- let result = JSON.parse(ret[RVC.EntityController.sigResponseUUID])
- if(result.result == 0) {
- utilStartAlertDialog("操作成功", function() {
- RVC.GuideController.gotoPage(result.nextStep);
- });
- } else {
- utilStartAlertDialog("操作失败:[" + result.result + "] " + result.additionalMsg);
- }
- } else {
- RVC.HealthmanagerEntityCtrl.commErrorCallback(ret);
- }
- });
- }
- function PreDeployTerminalWithIPAndPort(server_ip, port, access_flag)
- {
- if(!isValidIpAddress(server_ip)) {
- utilStartAlertDialog("无效IP格式");
- return;
- }
- if(!check_port(port)) {
- utilStartAlertDialog("无效端口号");
- return;
- }
-
- DeployTerminalWithIPAndPort(server_ip, port, access_flag);
- }
- function DownloadCenterSetting(ip, port)
- {
- PreDeployTerminalWithIPAndPort(ip, port, false);
- }
- function AuthorizeTerminal(ip, port)
- {
- PreDeployTerminalWithIPAndPort(ip, port, true);
- }
- function generateDeviceSelect(devices, select_id) {
- var deviceLength = 0;
- if ((devices) instanceof Array) {
- deviceLength = devices.length;
- } else {
- deviceLength = 1
- }
- var devicesHtml = '';
- var selectid = select_id;
- $('#' + selectid).empty();
- for (var loop = 0; loop < deviceLength; loop++) {
- var cur = devices[loop];
- var deviceTemplateData = {
- loop: loop,
- deviceName : cur,
- type: selectid
- };
- var pushHtml = '';
- pushHtml = '<div id="{{type}}_item_{{loop}}" option="{{deviceName}}" class="select_medium hide_with_ellipsis">'
- pushHtml += '{{deviceName}}</div>'
- $('#' + selectid).secureAppend(pushHtml, deviceTemplateData);
- }
- }
- function FulfillMediaDeviceList(flag)
- {
- let req = new Request();
- req.type = 6; //不需要摄像头配置
- req.interest = 0;
- req.reserverd1 = 0;
- req.reserverd2 = '';
- req.reserverd2 = '';
- RVC.CameraConfigEntity.GetMediaAvailableList(req, function(ret) {
- if(ret.errorCode === 0) {
- let result = JSON.parse(ret[RVC.EntityController.sigResponseUUID])
- console.log('device count: ' + result.result);
- var microphones = [];
- var loundspeakers = [];
- var cameras = [];
- for (var n = 0; n < result.AvailableList.length; n++) {
- console.log(result.AvailableList[n] + ' ' + result.ListItemType[n] + ' ' + result.ListItemStatus[n]);
- if(result.ListItemType[n] == MEDIA_TYPE.MICROPHONE) {
- microphones.push(result.AvailableList[n]);
- } else if(result.ListItemType[n] == MEDIA_TYPE.LOUNDSPEAKER) {
- loundspeakers.push(result.AvailableList[n]);
- } else if(result.ListItemType[n] == MEDIA_TYPE.CAMERA) {
- cameras.push(result.AvailableList[n]);
- }
- }
- generateDeviceSelect(loundspeakers, 'gui_media_config_audio_output_outfree_list');
- generateDeviceSelect(loundspeakers, 'gui_media_config_audio_output_infree_list');
- generateDeviceSelect(microphones, 'gui_media_config_audio_input_outfree_list');
- generateDeviceSelect(microphones, 'gui_media_config_audio_input_infree_list');
- if(typeof flag !== 'undefined') {
- $('#gui_media_config_audio_input_infree').empty();
- $('#gui_media_config_audio_input_infree').attr('value', '');
- $('#gui_media_config_audio_input_outfree').empty();
- $('#gui_media_config_audio_input_outfree').attr('value', '');
- $('#gui_media_config_audio_output_infree').empty();
- $('#gui_media_config_audio_output_infree').attr('value', '');
- $('#gui_media_config_audio_output_outfree').empty();
- $('#gui_media_config_audio_output_outfree').attr('value', '');
- utilShowToast("已刷新");
- }
- } else if(typeof flag !== 'undefined'){
- RVC.CameraConfigEntity.commErrorCallback(ret);
- }
- });
- }
- function SaveMediaDeviceConfig()
- {
- //话筒扬声器
- var output_infree = $('#gui_media_config_audio_output_infree').attr('value');
- //外部扬声器
- var output_outfree = $('#gui_media_config_audio_output_outfree').attr('value');
- //话筒麦克风
- var input_infree = $('#gui_media_config_audio_input_infree').attr('value');
- //外部麦克风
- var input_outfree = $('#gui_media_config_audio_input_outfree').attr('value');
- if(output_outfree === '') {
- utilStartAlertDialog('请选择外部扬声器');
- return;
- }
- if(output_infree === '') {
- utilStartAlertDialog('请选择话筒扬声器');
- return;
- }
- if(input_outfree === '') {
- utilStartAlertDialog('请选择外部麦克风');
- return;
- }
- if(input_infree === '') {
- utilStartAlertDialog('请选择话筒麦克风');
- return;
- }
- // if(output_infree == output_outfree) {
- // utilStartAlertDialog('扬声器选取冲突,请重新选择');
- // return;
- // }
- // if(input_infree == input_outfree) {
- // utilStartAlertDialog('麦克风选取冲突,请重新选择');
- // return;
- // }
- let req = new Request();
- req.currStep = CONST.DeployStep_MediaConfig;
- req.preStep = CONST.DeployStep_AccessAuthorize;
- req.nextStep = CONST.DeployStep_Finished;
- req.param1 = 0;
- req.param2 = 0;
- req.param3 = '';
- req.param4 = '';
- req.param5 = '';
- req.array1 = [MEDIA_DETAIL_TYPE.MediaDev_OutSpeaker, MEDIA_DETAIL_TYPE.MediaDev_InSpeaker, MEDIA_DETAIL_TYPE.MediaDev_OutMicrophone, MEDIA_DETAIL_TYPE.MediaDev_InMicrophone];
- req.array2 = [output_outfree, output_infree, input_outfree, input_infree];
- utilStartSubmitDialog();
- RVC.HealthmanagerEntityCtrl.DeployTerminal(req, function(ret) {
- utilStopSubmitDialog();
- if(ret.errorCode === 0) {
- let result = JSON.parse(ret[RVC.EntityController.sigResponseUUID])
- if(result.result == 0) {
- utilStartAlertDialog("操作成功", function() {
- RVC.GuideController.gotoPage(result.nextStep);
- });
- } else {
- utilStartAlertDialog("操作失败:[" + result.result + "] " + result.additionalMsg);
- }
- } else {
- RVC.HealthmanagerEntityCtrl.commErrorCallback(ret);
- }
- });
- }
- $(document).on('click', '#guide_initparam_ip_check #ip_connect_check', function(){
- var ip = $('#guide_server_ip').val();
- console.log('ip: ' + ip);
- IPConnectableTest(ip);
- });
- $(document).on('click', '#guide_initparam_next', function() {
- const ip = $('#guide_server_ip').val();
- const terminalno = $('#guide_initparam_terminalno').val();
- if(!isValidIpAddress(ip)) {
- utilStartAlertDialog("无效IP格式");
- return;
- }
- if(!IsDigital(terminalno)) {
- utilStartAlertDialog("无效终端号格式");
- return;
- }
- var vendorType = $('#gui_initparam_vendor').attr('value');
- if(vendorType === '' || vendorType === 'None') {
- utilStartAlertDialog("请选择设备厂商");
- return;
- }
- InitTemrinalAbout(ip, terminalno, vendorType);
- });
- $(document).on('click', '#guide_sync_centersetting_next', function() {
- const ip = $('#guide_sync_centersetting_server_ip_content').val();
- var port = $('#guide_sync_centersetting_port_content').val();
- DownloadCenterSetting(ip, port);
- });
- $(document).on('click', '#guide_access_authorize_next', function() {
- const ip = $('#guide_access_authorize_server_ip_content').val();
- var port = $('#guide_access_authorize_port_content').val();
- AuthorizeTerminal(ip, port);
- });
- $(document).on('click', '#guide_media_config_refresh', function() {
- FulfillMediaDeviceList(true);
- });
- $(document).on('click', '#guide_media_config_next', function() {
- SaveMediaDeviceConfig();
- });
- if (window.location.href.indexOf('guide.html') !== -1) {
- RVC.GuideController.resizeWindow();
- RVC.Scroll.initScroll('#initparam_content');
- }
- if (window.addEventListener) {
- window.addEventListener('resize', RVC.GuideController.resizeWindow, false);
- } else {
- window.attachEvent('resize', RVC.GuideController.resizeWindow);
- }
- setTimeout(RVC.GuideController.resizeWindow, 200);
- RVC.CameraConfigEntity.init();
- FulfillMediaDeviceList();
- RVC.GuideController.hideAllPage();
- $('#guide_start_page').show();
- });
|