示例#1
0
文件: diamond.cpp 项目: alimon/oscada
void TMdPrm::vlSet( TVal &vo, const TVariant &vl, const TVariant &pvl )
{
    if(!enableStat() || !owner().startStat()) { vo.setS(EVAL_STR, 0, true); return; }

    if(vl.isEVal() || vl == pvl) return;

    //Send to active reserve station
    if(owner().redntUse()) {
	XMLNode req("set");
	req.setAttr("path", nodePath(0,true)+"/%2fserv%2fattr")->childAdd("el")->setAttr("id", vo.name())->setText(vl.getS());
	SYS->daq().at().rdStRequest(owner().workId(), req);
	return;
    }

    //Direct write
    ResAlloc res(devRes, true);
    BYTE rez = DE_NONE;
    string errRez;
    if(vo.name().compare(0,2,"ao") == 0) {
	int acnl = atoi(vo.name().c_str()+2);
	int ao_cfg = vo.fld().reserve().size() ? strtol(vo.fld().reserve().c_str(),NULL,0) : -1;
	if(ao_cfg > 0) {
	    DSCDASETTINGS dasettings;
	    memset(&dasettings, 0, sizeof(DSCDASETTINGS));
	    dasettings.gain	=  ao_cfg&0x0F;
	    dasettings.polarity	= (ao_cfg&0x10) ? TRUE : FALSE;
	    dasettings.range	= (ao_cfg&0x20) ? TRUE : FALSE;
	    dasettings.daPolEn	= (ao_cfg&0x40) ? TRUE : FALSE;
	    dscDASetSettings(dscb, &dasettings);
	}
	int res = (dev.AO>>8)&0xFF;
	if(!res) res = 12;
	if((rez=dscDAConvert(dscb,acnl,(int)(vmax(0,vmin(100,vl.getR()))*((1<<res)-1)/100))) != DE_NONE)
	{ errRez = errDSC("dscDAConvert"); vo.setR(EVAL_REAL, 0, true); }
    }
示例#2
0
void TMdPrm::vlSet( TVal &vo, const TVariant &vl, const TVariant &pvl )
{
    if(!enableStat() || !owner().startStat())	{ vo.setR(EVAL_REAL, 0, true); return; }

    if(vl.isEVal() || vl == pvl) return;

    if(vo.name().compare(0,4,"gpio") == 0)
	bcm2835_gpio_write(s2i(vo.name().substr(4)), vl.getB()^bool(s2i(vo.fld().reserve())));
}
示例#3
0
void TMdPrm::vlGet( TVal &vo )
{
    if(!enableStat() || !owner().startStat()) {
	if(vo.name() == "err") {
	    if(!enableStat())			vo.setS(_("1:Parameter is disabled."),0,true);
	    else if(!owner().startStat())	vo.setS(_("2:Acquisition/access is stopped."),0,true);
	}
	else vo.setR(EVAL_REAL, 0, true);
	return;
    }

    if(vo.name() == "err") vo.setS("0", 0, true);
    else if(vo.name().compare(0,4,"gpio") == 0)
	vo.setB(bool(bcm2835_gpio_lev(s2i(vo.name().substr(4))))^bool(s2i(vo.fld().reserve())), 0, true);
}