|
function _AI1000(fnGetData)
{
this.modPrj = _SUBPROJECT_;
this.callButton = function(btnName)
{
CallObject(this.modPrj,btnName);
}
this.port = 'BUS';
setComBaud(this.port,9600,'N',8,1);
this.getULen = function(str)
{
var l = str.length;
var blen = 0;
for(i=0; i<l; i++) {
if ((str.charCodeAt(i) & 0xff00) != 0) {
blen ++;
}
blen ++;
}
var slen= blen.toString();
if(slen.length==0){
slen = "0000";
}else if(slen.length==1){
slen = "000"+slen;
}else if(slen.length==2){
slen = "00"+slen;
}else if(slen.length==3){
slen = "0"+slen;
}
return slen;
}
this.sendRoot = function(vString)
{
var strStart = "UCOM";
var strEnd = "UOFF";
var strJson = JSON.stringify(vString);
var strLen = this.getULen(strJson);
return strStart + strLen + strJson+ strEnd;
}
this.getPort = function()
{
var strText = {"cmd": "1", "action": "serialPort", "command": "getPort"};
sendCodeString('BUS', this.sendRoot(strText));
}
this.setSubtitleShow = function()
{
var strText = {"cmd": "1", "action": "setApp", "command": "showSubtitle"};
sendCodeString('BUS', this.sendRoot(strText));
}
this.delaySubtitleShow = function(vSec)
{
var strText = {"cmd": "1", "action": "setApp", "command": "showSubtitle"};
delayCodeString(vSec,'BUS', this.sendRoot(strText));
}
this.setSubtitleHide = function()
{
var strText = {"cmd": "1", "action": "setApp", "command": "hideSubtitle"};
sendCodeString('BUS', this.sendRoot(strText));
}
this.delaySubtitleHide = function(vSec)
{
var strText = {"cmd": "1", "action": "setApp", "command": "hideSubtitle"};
delayCodeString(vSec,'BUS', this.sendRoot(strText));
}
this.setSubtitleColor = function(v1,v2)
{
var strText = {"cmd": "1", "action": "setApp", "command": "subtitle", "backgroundColor": v1, "alpha": v2};
sendCodeString('BUS', this.sendRoot(strText));
}
this.delaySubtitleColor = function(vSec,v1,v2)
{
var strText = {"cmd": "1", "action": "setApp", "command": "subtitle", "backgroundColor": v1, "alpha": v2};
delayCodeString(vSec,'BUS', this.sendRoot(strText));
}
this.setTranslateShow = function()
{
var strText = {"cmd": "1", "action": "setApp", "command": "showTranslate"};
sendCodeString('BUS', this.sendRoot(strText));
}
this.delayTranslateShow = function(vSec)
{
var strText = {"cmd": "1", "action": "setApp", "command": "showTranslate"};
delayCodeString(vSec,'BUS', this.sendRoot(strText));
}
this.setTranslateHide = function()
{
var strText = {"cmd": "1", "action": "setApp", "command": "hideTranslate"};
sendCodeString('BUS', this.sendRoot(strText));
}
this.delayTranslateHide = function(vSec)
{
var strText = {"cmd": "1", "action": "setApp", "command": "hideTranslate"};
delayCodeString(vSec,'BUS', this.sendRoot(strText));
}
this.setTextShow = function()
{
var strText = {"cmd": "1", "action": "setApp", "command": "showWords"};
sendCodeString('BUS', this.sendRoot(strText));
}
this.delayTextShow = function(vSec)
{
var strText = {"cmd": "1", "action": "setApp", "command": "showWords"};
delayCodeString(vSec,'BUS', this.sendRoot(strText));
}
this.setTextHide = function()
{
var strText = {"cmd": "1", "action": "setApp", "command": "hideWords"};
sendCodeString('BUS', this.sendRoot(strText));
}
this.delayTextHide = function(vSec)
{
var strText = {"cmd": "1", "action": "setApp", "command": "hideWords"};
delayCodeString(vSec,'BUS', this.sendRoot(strText));
}
this.setTextColor = function(v1,v2)
{
var strText = {"cmd": "1", "action": "setApp", "command": "words", "fontColor": v1, "fontSize": v2};
sendCodeString('BUS', this.sendRoot(strText));
}
this.delayTextColor = function(vSec,v1,v2)
{
var strText = {"cmd": "1", "action": "setApp", "command": "words", "fontColor": v1, "fontSize": v2};
delayCodeString(vSec,'BUS', this.sendRoot(strText));
}
this.setAideShow = function()
{
var strText = {"cmd": "1", "action": "setApp", "command": "showAide"};
sendCodeString('BUS', this.sendRoot(strText));
}
this.delayAideShow = function(vSec)
{
var strText = {"cmd": "1", "action": "setApp", "command": "showAide"};
delayCodeString(vSec,'BUS', this.sendRoot(strText));
}
this.setAideHide = function()
{
var strText = {"cmd": "1", "action": "setApp", "command": "hideAide"};
sendCodeString('BUS', this.sendRoot(strText));
}
this.delayAideHide = function(vSec)
{
var strText = {"cmd": "1", "action": "setApp", "command": "hideAide"};
delayCodeString(vSec,'BUS', this.sendRoot(strText));
}
this.setHdmiShow = function()
{
var strText = {"cmd": "1", "action": "setApp", "command": "doVideo"};
sendCodeString('BUS', this.sendRoot(strText));
}
this.delayHdmiShow = function(vSec)
{
var strText = {"cmd": "1", "action": "setApp", "command": "doVideo"};
delayCodeString(vSec,'BUS', this.sendRoot(strText));
}
this.setHdmiHide = function()
{
var strText = {"cmd": "1", "action": "setApp", "command": "stopVideo"};
sendCodeString('BUS', this.sendRoot(strText));
}
this.delayHdmiHide = function(vSec)
{
var strText = {"cmd": "1", "action": "setApp", "command": "stopVideo"};
delayCodeString(vSec,'BUS', this.sendRoot(strText));
}
this.setTTS = function(v1)
{
var strText = {"cmd": "1", "action": "setApp", "command": "doAudio","data":setGBK(v1)};
sendCodeString('BUS', this.sendRoot(strText));
}
this.delayTTS = function(vSec,v1)
{
var strText = {"cmd": "1", "action": "setApp", "command": "doAudio","data":setGBK(v1)};
delayCodeString(vSec,'BUS', this.sendRoot(strText));
}
this.setRawTTS = function(v1)
{
var strText = {"cmd": "1", "action": "setApp", "command": "doAudio","data":v1};
sendCodeString('BUS', this.sendRoot(strText));
}
this.delayRawTTS = function(vSec,v1)
{
var strText = {"cmd": "1", "action": "setApp", "command": "doAudio","data":v1};
delayCodeString(vSec,'BUS', this.sendRoot(strText));
}
this.setAideText = function(v1)
{
var strText ={"cmd": "1", "action": "setApp", "command": "aideData", "data":v1}
sendCodeString('BUS', setGBK(this.sendRoot(strText)));
}
this.delayAideText = function(vSec,v1)
{
var strText ={"cmd": "1", "action": "setApp", "command": "aideData", "data":v1}
delayCodeString(vSec,'BUS', setGBK(this.sendRoot(strText)));
}
this.getInfo = function()
{
var strText = {"cmd": "1", "action": "system", "command": "getAndroid"};
sendCodeString('BUS', this.sendRoot(strText));
}
this.shutDown = function()
{
var strText = {"cmd": "1", "action": "system", "command": "shutDown"};
sendCodeString('BUS', this.sendRoot(strText));
}
this.reboot = function()
{
var strText = {"cmd": "1", "action": "system", "command": "reboot"};
sendCodeString('BUS', this.sendRoot(strText));
}
this.setup = function()
{
var strText = {"cmd": "1", "action": "setApp", "command": "toSetPage"};
sendCodeString('BUS', this.sendRoot(strText));
}
this.uninstall = function()
{
var strText = {"cmd": "1", "action": "system", "command": "deleteSelf"};
sendCodeString('BUS', this.sendRoot(strText));
}
this.setSubtitleConnect = function(vType,vHost,vSN)
{
var strText = "";
if (vType == 0) {
strText = {"cmd": "1", "action": "setApp", "command": "wordsSet", "wordType": 0, "host": "" + vHost + ""};
} else if (vType == 1) {
strText={"cmd":"1","action":"setApp","command":"wordsSet","wordType":1,"host":""+vHost+"","authorizationCode":vSN};
} else {
//如果没有填写参数或这个 参数错误 ,不往下执行!
return
}
sendCodeString('BUS', this.sendRoot(strText));
}
this.setBaud = function(vPort,vSpeed)
{
var strPort = vPort;
if(vPort.indexOf('RS485')!=-1)
{
strPort = "ttyUSB0"
}else{
strPort = "ttyS3"
}
var strText = {"cmd": "1", "action": "serialPort", "command": "openPort", "device": strPort, "baudRate": vSpeed};
sendCodeString('BUS', this.sendRoot(strText));
delayCodeString(5,'BUS', this.sendRoot(strText));
}
this.setPortClose = function(vPort)
{
var strPort = vPort;
if(vPort.indexOf('RS485')!=-1)
{
strPort = "ttyUSB0"
}else{
strPort = "ttyS3"
}
var strText = {"cmd": "1", "action": "serialPort", "command": "closePort", "device": strPort};
sendCodeString('BUS', this.sendRoot(strText));
}
this.sendCodeString = function(vPort,vString)
{
var strPort = vPort;
if(vPort.indexOf('RS485')!=-1 || vPort.indexOf('COM2')!=-1)
{
strPort = "ttyUSB0"
}else{
strPort = "ttyS3"
}
var strText = {"cmd": "1", "action": "serialPort", "command": "sendPort", "device": strPort, "data": vString};
sendCodeString('BUS', this.sendRoot(strText));
}
this.delayCodeString = function(vSec,vPort,vString)
{
var strPort = vPort;
if(vPort.indexOf('RS485')!=-1 || vPort.indexOf('COM2')!=-1)
{
strPort = "ttyUSB0"
}else{
strPort = "ttyS3"
}
var strText = {"cmd": "1", "action": "serialPort", "command": "sendPort", "device": strPort, "data": vString};
delayCodeString(vSec,'BUS', this.sendRoot(strText));
}
this.getRev = function(vData)
{
if(vData.indexOf("action\":\"receiveData")!=-1)
{
vData = setRemoveString(vData,"UCOM");
var vLength = parseInt(vData.substr(0,4),10);
vData = vData.substr(4,vLength);
var jsonData = JSON.parse(vData);
var strData = jsonData.data
if(jsonData.device.indexOf("ttyS3")!=-1)
{
fnGetData('RS232',strData);
}else{
fnGetData('RS485',strData);
fWpBusdealData(strData);
}
}else if(vData.indexOf("action\":\"keyActionUp")!=-1)
{
vData = setRemoveString(vData,"UCOM");
var vLength = parseInt(vData.substr(0,4),10);
vData = vData.substr(4,vLength);
var jsonData = JSON.parse(vData);
var strData = jsonData.keyCode
fnGetData("KeyRelease",strData);
}
else if(vData.indexOf("action\":\"keyActionDown")!=-1)
{
vData = setRemoveString(vData,"UCOM");
var vLength = parseInt(vData.substr(0,4),10);
vData = vData.substr(4,vLength);
var jsonData = JSON.parse(vData);
var strData = jsonData.keyCode
fnGetData("KeyPush",strData);
}
else if(vData.indexOf("action\":\"voice")!=-1)
{
vData = setRemoveString(vData,"UCOM");
var vLength = parseInt(vData.substr(0,4),10);
vData = vData.substr(4,vLength);
var jsonData = JSON.parse(vData);
var strData = jsonData.data
fnGetData("VOICE",strData);
}
//UCOM0120{"cmd":"1","action":"control","uuid":3d9440c1876a11e9b33834298f912f73,"name":"RemoteMenu001Sub004","time":1559724660518}UOFF
else if(vData.indexOf("action\":\"control")!=-1)
{
vData = setRemoveString(vData,"UCOM");
var vLength = parseInt(vData.substr(0,4),10);
vData = vData.substr(4,vLength);
var jsonData = JSON.parse(vData);
var strData = jsonData.name
fnGetData("Button",strData);
}
else if(vData.indexOf("action\":\"lifeCycle")!=-1)
{
vData = setRemoveString(vData,"UCOM");
var vLength = parseInt(vData.substr(0,4),10);
vData = vData.substr(4,vLength);
var jsonData = JSON.parse(vData);
var strData = jsonData.status
fnGetData("Status",strData);
}
else
{
fnGetData('RAW',vData);
}
}
if(arguments.length>=1)
{
setStringReceive(this.port,this.getRev);
}
}
|
|