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());
}