|
应用于主机接口弱电继电器控制
应用示例可查看_MATRIX 和_AUDIO方法,可自行修改相关方法属性及添加方法属性。有任何问题建议可在下方留言,功能持续改进更新
附:
function _RELAY(vMax)
{
this.max = vMax;
this.namePowerOn = "btnRelayOn";
this.namePowerOff = "btnRelayOff";
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;
}
}
this.setOn = function(vId)
{
this.status[vId] =1;
setRelayOn(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;
setRelayOff(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;
delayRelayOn(vSec,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;
delayRelayOff(vSec,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]);
}
}
}
|
|