|
应用于时序电源控制
应用示例可查看_MATRIX 和_AUDIO方法,可自行修改相关方法属性及添加方法属性。有任何问题建议可在下方留言,功能持续改进更新
附:
function _SQPOWER(vPort,vMax)
{
this.port = vPort
this.max = vMax;
this.namePowerOn = "btnSQPowerOn";
this.namePowerOff = "btnSQPowerOff";
this.cmdPowerOn = "PWR_CH_ON";
this.cmdPowerOff = "PWR_CH_OFF";
this.imgOn = "btn01blankon.png";
this.imgOff = "btn01blankoff.png";
this.imgPowerOnOn = new Array();
this.imgPowerOnOff = new Array();
this.imgPowerOffOn = new Array();
this.imgPowerOffOff = new Array();
this.status = new Array();
for (var i=0;i<=this.max;i++)
{
this.status[i] = 0;
if(FindGUIObject(this.namePowerOn+i)!=null)
{
this.imgPowerOnOn[i]=getImageOn(this.namePowerOn+i)
this.imgPowerOnOff[i]=getImage(this.namePowerOn+i);
}
else
{
this.imgPowerOnOn[i] = this.imgOn;
this.imgPowerOnOff[i] = this.imgOff;
}
if(FindGUIObject(this.namePowerOff+i)!=null)
{
this.imgPowerOffOn[i]=getImageOn(this.namePowerOff+i)
this.imgPowerOffOff[i]=getImage(this.namePowerOff+i);
}
else
{
this.imgPowerOffOn[i] = this.imgOn;
this.imgPowerOffOff[i] = this.imgOff;
}
}
if(vPort.indexOf('MOD')!=-1)
{
this.port = GetCurrentIOName();
}
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.setOn = function(vId)
{
this.status[vId] =1;
sendCodeName(this.port,this.cmdPowerOn+vId);
setImage(this.namePowerOn+vId,this.imgPowerOnOn[vId]);
setImage(this.namePowerOff+vId,this.imgPowerOffOff[vId]);
this.countPower();
}
this.setOff = function(vId)
{
this.status[vId] =0;
sendCodeName(this.port,this.cmdPowerOff+vId);
setImage(this.namePowerOn+vId,this.imgPowerOnOff[vId]);
setImage(this.namePowerOff+vId,this.imgPowerOffOn[vId]);
this.countPower();
}
this.delayOn = function(vSec,vId)
{
this.status[vId] =1;
delayCodeName(vSec,this.port,this.cmdPowerOn+vId);
setImage(this.namePowerOn+vId,this.imgPowerOnOn[vId]);
setImage(this.namePowerOff+vId,this.imgPowerOffOff[vId]);
this.countPower();
}
this.delayOff = function(vSec,vId)
{
this.status[vId] =0;
delayCodeName(vSec,this.port,this.cmdPowerOff+vId);
setImage(this.namePowerOn+vId,this.imgPowerOnOff[vId]);
setImage(this.namePowerOff+vId,this.imgPowerOffOn[vId]);
this.countPower();
}
this.allOn =function()
{
for(var i=1;i<=this.max;i++)
{
this.delayOn(i,i);
}
setImage(this.namePowerOn+"0",this.imgPowerOnOn[0]);
setImage(this.namePowerOff+"0",this.imgPowerOffOff[0]);
}
this.allOff = function()
{
for(var i=this.max;i>0;i--)
{
this.delayOff(this.max-i,i);
}
setImage(this.namePowerOn+"0",this.imgPowerOnOff[0]);
setImage(this.namePowerOff+"0",this.imgPowerOffOn[0]);
}
this.countPower =function()
{
var totalCount =0;
for(var i=1;i<=this.max;i++)
{
if(this.status[i]==1)
{
totalCount++;
}
}
if(totalCount==0)
{
setImage(this.namePowerOn+"0",this.imgPowerOnOff[0]);
setImage(this.namePowerOff+"0",this.imgPowerOffOn[0]);
}
else if(totalCount == this.max)
{
setImage(this.namePowerOn+"0",this.imgPowerOnOn[0]);
setImage(this.namePowerOff+"0",this.imgPowerOffOff[0]);
}
else
{
setImage(this.namePowerOn+"0",this.imgPowerOnOff[0]);
setImage(this.namePowerOff+"0",this.imgPowerOffOff[0]);
}
}
}
|
|