|
应用于电话拔号控制
应用示例可查看_MATRIX 和_AUDIO方法,可自行修改相关方法属性及添加方法属性。有任何问题建议可在下方留言,功能持续改进更新
附:
function _TELCOM(vPort,vB,vN,vD,vS,getCMD,fnGetData)
{
this.modPrj = _SUBPROJECT_;
this.callButton = function(btnName)
{
CallObject(this.modPrj,btnName);
}
this.port = vPort;
if(vPort.indexOf('MOD')!=-1)
{
this.port = GetCurrentIOName();
}
if(this.port.indexOf('COM')!=-1)
{
setComBaud(this.port,vB,vN,vD,vS);
}
this.setBaud = function(vsB,vsN,vsD,vsS)
{
setComBaud(this.port,vsB,vsN,vsD,vsS)
}
this.sendCodeString = function(vString)
{
sendCodeString(this.port,vString);
}
this.delayCodeString = function(vSec,vString)
{
delayCodeString(vSec,this.port,vString);
}
this.sendCodeName = function(vString)
{
sendCodeName(this.port,vString);
}
this.delayCodeName = function(vSec,vString)
{
delayCodeName(vSec,this.port,vString);
}
this.callStatus = 0;
this.dailNumber = "";
this.txtDisplayArray = new Array();
this.btnHookonArray = new Array();
this.btnHookoffArray = new Array();
this.imgonHookonArray = new Array();
this.imgonHookoffArray = new Array();
this.imgoffHookonArray = new Array();
this.imgoffHookoffArray = new Array();
this.txtDialname = 'txtDialnum';
this.btnHandup = "btnHookon";
this.btnHanddown = "btnHookoff";
this.imageonhandup = 'btn01onhookon.png';
this.imageoffhandup = 'btn01onhookoff.png';
this.imageonhanddown = 'btn01offhookon.png';
this.imageoffhanddown = 'btn01offhookoff.png';
this.addName = function(vtxt,vhookon,vhookoff)
{
this.txtDisplayArray.push(vtxt)
this.btnHookonArray.push(vhookon)
this.btnHookoffArray.push(vhookoff)
for(var i=1;i<this.btnHookonArray.length;i++)
{
if(FindGUIObject(this.btnHookonArray[i])!=null)
{
this.imgonHookonArray[i]=getImageOn(this.btnHookonArray[i])
this.imgoffHookonArray[i]=getImage(this.btnHookonArray[i]);
}
}
for(var i=1;i<this.btnHookoffArray.length;i++)
{
if(FindGUIObject(this.btnHookoffArray[i])!=null)
{
this.imgonHookoffArray[i]=getImageOn(this.btnHookoffArray[i])
this.imgoffHookoffArray[i]=getImage(this.btnHookoffArray[i]);
}
}
}
this.setInit = function(txtdial,btnup,btndown)
{
this.txtDialname = txtdial;
this.btnHandup = btnup;
this.btnHanddown = btndown;
this.btnHookonArray[0] = this.btnHandup;
this.btnHookoffArray[0] = this.btnHanddown;
if(FindGUIObject(this.btnHookonArray[0])!=null)
{
this.imgonHookonArray[0]=getImageOn(this.btnHookonArray[0])
this.imgoffHookonArray[0]=getImage(this.btnHookonArray[0]);
}
if(FindGUIObject(this.btnHookoffArray[0])!=null)
{
this.imgonHookoffArray[0]=getImageOn(this.btnHookoffArray[0])
this.imgoffHookoffArray[0]=getImage(this.btnHookoffArray[0]);
}
this.txtDisplayArray[0] = this.txtDialname;
}
this.setInit(this.txtDialname,this.btnHandup,this.btnHanddown);
this.handup = function(vStr)
{
this.callStatus = 1;
if(arguments.length>=1)
{
this.dailNumber = vStr;
}
for(var i=0;i<this.btnHookonArray.length;i++)
{
setButtonImage(this.btnHookonArray[i],this.imgonHookonArray[i]);
}
for(var i=0;i<this.btnHookoffArray.length;i++)
{
setButtonImage(this.btnHookoffArray[i],this.imgoffHookoffArray[i]);
}
if(this.dailNumber.length>0)
{
sendCodeString(this.port,getCMD('dialnumber',this.dailNumber));
}
else
{
sendCodeString(this.port,getCMD('hookon',''));
}
}
this.handdown = function()
{
this.dailNumber = "";
this.callStatus = 0;
sendCodeString(this.port,getCMD('hookoff',''));
for(var i=0;i<this.txtDisplayArray.length;i++)
{
setButtonText(this.txtDisplayArray[i],"");
}
//setButtonText(this.txtDialname,"");
for(var i=0;i<this.btnHookonArray.length;i++)
{
setButtonImage(this.btnHookonArray[i],this.imgoffHookonArray[i]);
}
for(var i=0;i<this.btnHookoffArray.length;i++)
{
setButtonImage(this.btnHookoffArray[i],this.imgonHookoffArray[i]);
}
//setButtonImage(this.btnHandup,this.imageoffhandup);
//setButtonImage(this.btnHanddown,this.imageonhanddown);
}
this.dial = function(vStr)
{
this.dailNumber = this.dailNumber + vStr;
this.showtext();
if(this.callStatus==1)
{
sendCodeString(this.port,getCMD('dialnumber',vStr));
}
}
this.del = function()
{
if(this.dailNumber.length<=1)
{
this.dailNumber = "";
}
else
{
this.dailNumber = this.dailNumber.substring(-1,this.dailNumber.length-1);
}
this.showtext();
}
this.clear = function()
{
this.dailNumber = "";
for(var i=0;i<this.txtDisplayArray.length;i++)
{
setButtonText(this.txtDisplayArray[i],"");
}
//setButtonText(this.txtDialname,"");
}
this.setText = function(vStr)
{
this.dailNumber = vStr;
//for(var i=0;i<this.txtDisplayArray.length;i++)
//{
// //sendLog(this.txtDisplayArray[i],this.dailNumber);
// setAllText(this.txtDisplayArray[i],this.dailNumber);
//}
this.showtext();
}
this.showtext = function()
{
var vshowDialNumber = "";
if(this.dailNumber.length<13)
{
for(var i=0;i<(13-this.dailNumber.length);i++)
{
vshowDialNumber+=" ";
}
vshowDialNumber =vshowDialNumber+this.dailNumber;
}
else
{
vshowDialNumber = "..."+this.dailNumber.substring(this.dailNumber.length-10);
}
for(var i=0;i<this.txtDisplayArray.length;i++)
{
setAllText(this.txtDisplayArray[i],vshowDialNumber);
}
//setButtonText(this.txtDialname,vshowDialNumber);
}
this.getRev = function(vData)
{
fnGetData(vData);
}
if(arguments.length>=7)
{
setStringReceive(this.port,this.getRev);
}
}
|
|