Esempio n. 1
0
void TMdPrm::vlSet( TVal &valo, const TVariant &pvl )
{
    if(!enableStat())	valo.setS(EVAL_STR, 0, true);

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

    TVariant vl = valo.get(NULL, true);
    if(vl.isEVal() || vl == pvl) return;

    //> Direct write
    XML_N req("opc.tcp");
    req.setAttr("id", "Write")->
	childAdd("node")->setAttr("nodeId", TSYS::strLine(valo.fld().reserve(),0))->
			  setAttr("attributeId", TSYS::int2str(AId_Value))->
			  setAttr("EncodingMask", TSYS::strLine(valo.fld().reserve(),1))->
			  setText(vl.getS());
    owner().reqService(req);
    if(!req.attr("err").empty()) mess_err(nodePath().c_str(), "%s", req.attr("err").c_str());
    else if(strtol(req.childGet(0)->attr("Status").c_str(),NULL,0))
	mess_err(nodePath().c_str(), "Write error status: %s", req.childGet(0)->attr("Status").c_str());
}
Esempio n. 2
0
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); }
    }
Esempio n. 3
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())));
}
Esempio n. 4
0
void Prm::vlGet( TVal &val )
{
    if(val.name() == "err") {
	if(!enableStat()) val.setS(_("1:Parameter is disabled."),0,true);
	else if(!owner().startStat()) val.setS(_("2:Controller is stopped."),0,true);
	else val.setS("0",0,true);
	return;
    }

    if(owner().redntUse()) return;

    try {
	//if( !enableStat() ) return;
	AutoHD<Block> blk = ((Contr &)owner()).blkAt(TSYS::strSepParse(val.fld().reserve(),0,'.'));
	int io_id = blk.at().ioId(TSYS::strSepParse(val.fld().reserve(),1,'.'));
	if( io_id < 0 )	disable();
	else val.set((enableStat()&&owner().startStat()) ? blk.at().get(io_id) : EVAL_STR, 0, true);
    }catch(TError err) { disable(); }
}
Esempio n. 5
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);
}
Esempio n. 6
0
void Prm::vlSet( TVal &vo, const TVariant &vl, const TVariant &pvl )
{
    if(!enableStat() || !owner().startStat())	return;

    //Send to active reserve station
    if(owner().redntUse()) {
	if(vl == pvl) return;
	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
    try {
	AutoHD<Block> blk = ((Contr &)owner()).blkAt(TSYS::strSepParse(vo.fld().reserve(),0,'.'));
	int io_id = blk.at().ioId(TSYS::strSepParse(vo.fld().reserve(),1,'.'));
	if(io_id < 0) disable();
	else {
	    MtxAlloc sres(owner().calcRes, true);
	    blk.at().set(io_id, vl);
	}
    }catch(TError err) { disable(); }
}
Esempio n. 7
0
void SUNXI::vlSet( TParamContr *ip, TVal &vo, const TVariant &vl, const TVariant &pvl )
{
    if(vo.name().compare(0,4,"gpio") == 0)
	sunxi_gpio_output(s2i(vo.name().substr(4)), vl.getB()^bool(s2i(vo.fld().reserve())));
}
Esempio n. 8
0
void SUNXI::vlGet( TParamContr *ip, TVal &vo )
{
    if(vo.name().compare(0,4,"gpio") == 0)
	vo.setB(bool(sunxi_gpio_input(s2i(vo.name().substr(4))))^bool(s2i(vo.fld().reserve())), 0, true);
}