void TMdPrm::vlGet( TVal &val ) { if(val.name() != "err") return; if(!enableStat() || !owner().startStat()) { if(!enableStat()) val.setS(_("1:Parameter is disabled."),0,true); else if(!owner().startStat()) val.setS(_("2:Acquisition is stopped."),0,true); return; } if(owner().redntUse()) return; if(!owner().acq_err.getVal().empty()) val.setS(owner().acq_err.getVal(),0,true); else { //> Check remote attributes for error status uint32_t firstErr = 0; vector<uint32_t> astls; ResAlloc res(nodeRes(), true); for(unsigned i_a = 0; i_a < p_el.fldSize(); i_a++) { astls.push_back(p_el.fldAt(i_a).len()); if(p_el.fldAt(i_a).len() && !firstErr) firstErr = p_el.fldAt(i_a).len(); } res.release(); string aLs; for(unsigned i_a = 0; i_a < astls.size(); i_a++) aLs += TSYS::strMess(":0x%x",astls[i_a]); val.setS(TSYS::strMess(_("0x%x: Attribute's errors %s"),firstErr,aLs.c_str()),0,true); } }
void TMdPrm::vlGet( TVal &val ) { if(val.name() == "err") { if(!owner().startStat())val.setS(_("2:Controller stopped"), 0, true); else if(!enableStat()) val.setS(_("1:Parameter disabled"), 0, true); else if(daErr.size()) val.setS(daErr, 0, true); else val.setS("0", 0, true); } }
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); }
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()); }
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); } }
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(); } }
void TMdPrm::vlSet( TVal &vo, const TVariant &vl, const TVariant &pvl ) { if(!enableStat() || !owner().startStat()) { vo.setI(EVAL_INT, 0, true); 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 { if(mDA) mDA->vlSet(this, vo, vl, pvl); } catch(TError err) { mess_err(nodePath().c_str(),_("Write value to attribute '%s' error: %s"),vo.name().c_str(),err.mess.c_str()); vo.setS(pvl.getS(), 0, true); } }
void TMdPrm::vlGet( TVal &val ) { if(!enableStat() || !owner().startStat()) { if(val.name() == "err") { if(!enableStat()) val.setS(_("1:Parameter disabled."), 0, true); else if(!owner().startStat()) val.setS(_("2:Acquisition stopped."), 0, true); } else val.setS(EVAL_STR, 0, true); return; } if(owner().redntUse()) return; ResAlloc res(devRes, true); if(val.name() == "err") { if(!acqErr.getVal().empty()) val.setS(acqErr.getVal(), 0, true); else if(dscs.op_type == OP_TYPE_INT) val.setS(TSYS::strMess(_("0:AI acquisition into interrupt mode; SampleRate=%g; Drift=%gs; Overflows=%u; LostCycles=%u; SRateCor=%u."), dscaioint.conversion_rate,st_drift,st_overflows,st_lostcycles,st_sRateCor), 0, true); else val.setS("0", 0, true); } else if(!asynchRd) getVals(val.name()); }