Commit 5598a5d2 authored by Pavel Vaynerman's avatar Pavel Vaynerman

Merge commit 'server/master'

Conflicts: conf/uniset.spec
parents cd2c6456 523ad82b
...@@ -23,9 +23,6 @@ ...@@ -23,9 +23,6 @@
( ConsumerInfo ..). uniset-codegen, ( ConsumerInfo ..). uniset-codegen,
SensorInfo ObjectId. SensorInfo ObjectId.
----------
RTUExchange smonit: processing "precision"
============== admin: processing "precision"
... \ No newline at end of file
udev
#!/bin/sh #!/bin/sh
ln -s -f /usr/bin/uniset-stop.sh stop.sh ln -s -f /usr/bin/uniset-stop.sh stop.sh
#ln -s -f ../../conf/test.xml test.xml ln -s -f ../../conf/test.xml test.xml
ln -s -f ./configure.xml test.xml
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
Name: uniset Name: uniset
Version: 0.96 Version: 0.96
Release: eter24 Release: eter26
Summary: UniSet Summary: UniSet
License: GPL License: GPL
Group: Development/C++ Group: Development/C++
...@@ -181,7 +181,7 @@ Libraries needed to develop for uniset extentions ...@@ -181,7 +181,7 @@ Libraries needed to develop for uniset extentions
%_bindir/%name-smviewer %_bindir/%name-smviewer
%changelog %changelog
* Tue Jun 09 2009 Pavel Vainerman <pv@etersoft.ru> 0.96-eter24 * Mon Jun 08 2009 Pavel Vainerman <pv@aeu> 0.96-eter25
- new build - new build
* Thu Jun 04 2009 Pavel Vainerman <pv@aeu> 0.96-eter23 * Thu Jun 04 2009 Pavel Vainerman <pv@aeu> 0.96-eter23
......
...@@ -492,6 +492,9 @@ void IOControl::iopoll() ...@@ -492,6 +492,9 @@ void IOControl::iopoll()
unideb[Debug::LEVEL3] << myname << "(iopoll): catch ..." << endl; unideb[Debug::LEVEL3] << myname << "(iopoll): catch ..." << endl;
} }
} }
for( IOMap::iterator it=iomap.begin(); it!=iomap.end(); ++it )
IOBase::processingThreshold(&(*it),shm,force);
} }
// -------------------------------------------------------------------------------- // --------------------------------------------------------------------------------
void IOControl::readConfiguration() void IOControl::readConfiguration()
......
...@@ -298,6 +298,9 @@ void MBMaster::poll() ...@@ -298,6 +298,9 @@ void MBMaster::poll()
dlog[Debug::LEVEL3] << myname << "(poll): catch ..." << endl; dlog[Debug::LEVEL3] << myname << "(poll): catch ..." << endl;
} }
} }
for( MBMap::iterator it=mbmap.begin(); it!=mbmap.end(); ++it )
IOBase::processingThreshold(&(*it),shm,force);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
long MBMaster::readReg( MBMap::iterator& p ) long MBMaster::readReg( MBMap::iterator& p )
......
...@@ -307,6 +307,9 @@ void MBSlave::execute_rtu() ...@@ -307,6 +307,9 @@ void MBSlave::execute_rtu()
<< "(execute_rtu): (hb) " << ex << std::endl; << "(execute_rtu): (hb) " << ex << std::endl;
} }
} }
for( IOMap::iterator it=iomap.begin(); it!=iomap.end(); ++it )
IOBase::processingThreshold(&it->second,shm,force);
} }
catch(...){} catch(...){}
} }
...@@ -355,6 +358,9 @@ void MBSlave::execute_tcp() ...@@ -355,6 +358,9 @@ void MBSlave::execute_tcp()
<< "(execute_tcp): (hb) " << ex << std::endl; << "(execute_tcp): (hb) " << ex << std::endl;
} }
} }
for( IOMap::iterator it=iomap.begin(); it!=iomap.end(); ++it )
IOBase::processingThreshold(&it->second,shm,force);
} }
catch(...){} catch(...){}
} }
......
...@@ -17,7 +17,9 @@ initPause(0), ...@@ -17,7 +17,9 @@ initPause(0),
force(false), force(false),
force_out(false), force_out(false),
mbregFromID(false), mbregFromID(false),
activated(false) activated(false),
rs_pre_clean(false),
noQueryOptimization(false)
{ {
cout << "$Id: RTUExchange.cc,v 1.4 2009/01/23 23:56:54 vpashka Exp $" << endl; cout << "$Id: RTUExchange.cc,v 1.4 2009/01/23 23:56:54 vpashka Exp $" << endl;
...@@ -50,6 +52,11 @@ activated(false) ...@@ -50,6 +52,11 @@ activated(false)
speed = "38400"; speed = "38400";
recv_timeout = atoi(conf->getArgParam("--rs-recv-timeout",it.getProp("recv_timeout")).c_str()); recv_timeout = atoi(conf->getArgParam("--rs-recv-timeout",it.getProp("recv_timeout")).c_str());
if( recv_timeout <= 0 )
recv_timeout = 100;
rs_pre_clean = atoi(conf->getArgParam("--rs-pre-clean",it.getProp("pre_clean")).c_str());
noQueryOptimization = atoi(conf->getArgParam("--rs-no-query-optimization",it.getProp("no_query_optimization")).c_str());
mbregFromID = atoi(conf->getArgParam("--mbs-reg-from-id",it.getProp("reg_from_id")).c_str()); mbregFromID = atoi(conf->getArgParam("--mbs-reg-from-id",it.getProp("reg_from_id")).c_str());
dlog[Debug::INFO] << myname << "(init): mbregFromID=" << mbregFromID << endl; dlog[Debug::INFO] << myname << "(init): mbregFromID=" << mbregFromID << endl;
...@@ -63,6 +70,7 @@ activated(false) ...@@ -63,6 +70,7 @@ activated(false)
initPause = 3000; initPause = 3000;
force = atoi(conf->getArgParam("--rs-force",it.getProp("force")).c_str()); force = atoi(conf->getArgParam("--rs-force",it.getProp("force")).c_str());
force_out = atoi(conf->getArgParam("--rs-force-out",it.getProp("force_out")).c_str());
if( shm->isLocalwork() ) if( shm->isLocalwork() )
{ {
...@@ -260,8 +268,9 @@ void RTUExchange::poll() ...@@ -260,8 +268,9 @@ void RTUExchange::poll()
try try
{ {
//#warning For Debug if( rs_pre_clean )
mb->cleanupChannel(); mb->cleanupChannel();
d->rtu->poll(mb); d->rtu->poll(mb);
d->resp_real = true; d->resp_real = true;
} }
...@@ -283,6 +292,7 @@ void RTUExchange::poll() ...@@ -283,6 +292,7 @@ void RTUExchange::poll()
{ {
if( d->dtype==RTUExchange::dtRTU || d->dtype==RTUExchange::dtMTR ) if( d->dtype==RTUExchange::dtRTU || d->dtype==RTUExchange::dtMTR )
{ {
if( rs_pre_clean )
mb->cleanupChannel(); mb->cleanupChannel();
if( pollRTU(d,it) ) if( pollRTU(d,it) )
d->resp_real = true; d->resp_real = true;
...@@ -307,6 +317,18 @@ void RTUExchange::poll() ...@@ -307,6 +317,18 @@ void RTUExchange::poll()
// update SharedMemory... // update SharedMemory...
updateSM(); updateSM();
// check thresholds
for( RTUExchange::RTUDeviceMap::iterator it1=rmap.begin(); it1!=rmap.end(); ++it1 )
{
RTUDevice* d(it1->second);
for( RTUExchange::RegMap::iterator it=d->regmap.begin(); it!=d->regmap.end(); ++it )
{
RegInfo* r(it->second);
for( PList::iterator i=r->slst.begin(); i!=r->slst.end(); ++i )
IOBase::processingThreshold( &(*i),shm,force);
}
}
// printMap(rmap); // printMap(rmap);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -340,7 +362,6 @@ bool RTUExchange::pollRTU( RTUDevice* dev, RegMap::iterator& it ) ...@@ -340,7 +362,6 @@ bool RTUExchange::pollRTU( RTUDevice* dev, RegMap::iterator& it )
ModbusRTU::ReadInputRetMessage ret = mb->read04(dev->mbaddr,p->mbreg+p->offset,p->q_count); ModbusRTU::ReadInputRetMessage ret = mb->read04(dev->mbaddr,p->mbreg+p->offset,p->q_count);
for( int i=0; i<p->q_count; i++,it++ ) for( int i=0; i<p->q_count; i++,it++ )
it->second->mbval = ret.data[i]; it->second->mbval = ret.data[i];
it--; it--;
} }
break; break;
...@@ -380,7 +401,6 @@ bool RTUExchange::pollRTU( RTUDevice* dev, RegMap::iterator& it ) ...@@ -380,7 +401,6 @@ bool RTUExchange::pollRTU( RTUDevice* dev, RegMap::iterator& it )
<< " IGNORE WRITE SINGLE REGISTER q_count=" << p->q_count << " ..." << endl; << " IGNORE WRITE SINGLE REGISTER q_count=" << p->q_count << " ..." << endl;
return false; return false;
} }
ModbusRTU::WriteSingleOutputRetMessage ret = mb->write06(dev->mbaddr,p->mbreg+p->offset,p->mbval); ModbusRTU::WriteSingleOutputRetMessage ret = mb->write06(dev->mbaddr,p->mbreg+p->offset,p->mbval);
} }
break; break;
...@@ -514,8 +534,8 @@ void RTUExchange::processingMessage(UniSetTypes::VoidMessage *msg) ...@@ -514,8 +534,8 @@ void RTUExchange::processingMessage(UniSetTypes::VoidMessage *msg)
{ {
TimerMessage tm(msg); TimerMessage tm(msg);
timerInfo(&tm); timerInfo(&tm);
break;
} }
break;
case Message::SensorInfo: case Message::SensorInfo:
{ {
...@@ -551,7 +571,7 @@ void RTUExchange::sysCommand( UniSetTypes::SystemMessage *sm ) ...@@ -551,7 +571,7 @@ void RTUExchange::sysCommand( UniSetTypes::SystemMessage *sm )
{ {
if( rmap.empty() ) if( rmap.empty() )
{ {
dlog[Debug::CRIT] << myname << "(sysCommand): rmap EMPTY! terminated..." << endl; dlog[Debug::CRIT] << myname << "(sysCommand): ************* rmap EMPTY! terminated... *************" << endl;
raise(SIGTERM); raise(SIGTERM);
return; return;
} }
...@@ -585,8 +605,6 @@ void RTUExchange::sysCommand( UniSetTypes::SystemMessage *sm ) ...@@ -585,8 +605,6 @@ void RTUExchange::sysCommand( UniSetTypes::SystemMessage *sm )
initOutput(); initOutput();
} }
askTimer(tmExchange,polltime);
// //
if( !force ) if( !force )
{ {
...@@ -595,6 +613,7 @@ void RTUExchange::sysCommand( UniSetTypes::SystemMessage *sm ) ...@@ -595,6 +613,7 @@ void RTUExchange::sysCommand( UniSetTypes::SystemMessage *sm )
poll(); poll();
force = false; force = false;
} }
askTimer(tmExchange,polltime);
break; break;
} }
...@@ -669,55 +688,60 @@ void RTUExchange::askSensors( UniversalIO::UIOCommand cmd ) ...@@ -669,55 +688,60 @@ void RTUExchange::askSensors( UniversalIO::UIOCommand cmd )
throw SystemError(err.str()); throw SystemError(err.str());
} }
/* if( force_out )
RSMap::iterator it=rsmap.begin(); return;
for( ; it!=rsmap.end(); ++it )
for( RTUExchange::RTUDeviceMap::iterator it1=rmap.begin(); it1!=rmap.end(); ++it1 )
{
RTUDevice* d(it1->second);
for( RTUExchange::RegMap::iterator it=d->regmap.begin(); it!=d->regmap.end(); ++it )
{ {
if( it->stype != UniversalIO::DigitalOutput && it->stype != UniversalIO::AnalogOutput ) if( it->second->mbfunc != ModbusRTU::fnWriteOutputRegisters &&
it->second->mbfunc != ModbusRTU::fnWriteOutputSingleRegister )
continue; continue;
// if( it->safety == NoSafetyState ) for( PList::iterator i=it->second->slst.begin(); i!=it->second->slst.end(); ++i )
// continue; {
try try
{ {
shm->askSensor(it->si.id,cmd); shm->askSensor(i->si.id,cmd);
} }
catch( UniSetTypes::Exception& ex ) catch( UniSetTypes::Exception& ex )
{ {
dlog[Debug::WARN] << myname << "(askSensors): " << ex << std::endl; dlog[Debug::WARN] << myname << "(askSensors): " << ex << std::endl;
} }
catch(...){} catch(...)
{
dlog[Debug::WARN] << myname << "(askSensors): catch..." << std::endl;
}
}
}
} }
*/
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
void RTUExchange::sensorInfo( UniSetTypes::SensorMessage* sm ) void RTUExchange::sensorInfo( UniSetTypes::SensorMessage* sm )
{ {
/* if( force_out )
RSMap::iterator it=rsmap.begin(); return;
for( ; it!=rsmap.end(); ++it )
{
if( it->stype != UniversalIO::DigitalOutput && it->stype != UniversalIO::AnalogOutput )
continue;
if( it->si.id == sm->id ) for( RTUExchange::RTUDeviceMap::iterator it1=rmap.begin(); it1!=rmap.end(); ++it1 )
{ {
if( it->stype == UniversalIO::DigitalOutput ) // || it->stype == UniversalIO::DigitalInput ) RTUDevice* d(it1->second);
for( RTUExchange::RegMap::iterator it=d->regmap.begin(); it!=d->regmap.end(); ++it )
{ {
uniset_spin_lock lock(it->val_lock); if( it->second->mbfunc != ModbusRTU::fnWriteOutputRegisters &&
it->value = sm->state ? 1 : 0; it->second->mbfunc != ModbusRTU::fnWriteOutputSingleRegister )
} continue;
else if( it->stype == UniversalIO::AnalogOutput ) // || it->stype == UniversalIO::AnalogInput )
for( PList::iterator i=it->second->slst.begin(); i!=it->second->slst.end(); ++i )
{ {
uniset_spin_lock lock(it->val_lock); // cerr << myname << "(sensorInfo): ************ update si.id=" << sm->id
it->value = sm->value; // << " reg=" << ModbusRTU::dat2str(i->reg->mbreg) << endl;
updateRSProperty( &(*i),true);
return;
} }
break;
} }
} }
*/
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
bool RTUExchange::activateObject() bool RTUExchange::activateObject()
...@@ -875,9 +899,13 @@ RTUExchange::RegInfo* RTUExchange::addReg( RegMap& mp, ModbusRTU::ModbusData r, ...@@ -875,9 +899,13 @@ RTUExchange::RegInfo* RTUExchange::addReg( RegMap& mp, ModbusRTU::ModbusData r,
return 0; return 0;
} }
if( dlog.debugging(Debug::INFO) )
{
dlog[Debug::INFO] << myname << "(addReg): reg=" << ModbusRTU::dat2str(r) dlog[Debug::INFO] << myname << "(addReg): reg=" << ModbusRTU::dat2str(r)
<< " already added. Ignore register params for " << xmlit.getProp("name") << " ..." << endl; << " already added. Ignore register params for " << xmlit.getProp("name") << " ..." << endl;
}
it->second->rit = it;
return it->second; return it->second;
} }
...@@ -900,6 +928,8 @@ RTUExchange::RegInfo* RTUExchange::addReg( RegMap& mp, ModbusRTU::ModbusData r, ...@@ -900,6 +928,8 @@ RTUExchange::RegInfo* RTUExchange::addReg( RegMap& mp, ModbusRTU::ModbusData r,
} }
mp.insert(RegMap::value_type(r,ri)); mp.insert(RegMap::value_type(r,ri));
ri->rit = mp.find(r);
return ri; return ri;
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
...@@ -942,6 +972,18 @@ bool RTUExchange::initRSProperty( RSProperty& p, UniXML_iterator& it ) ...@@ -942,6 +972,18 @@ bool RTUExchange::initRSProperty( RSProperty& p, UniXML_iterator& it )
<< " but iotype=" << p.stype << " for " << it.getProp("name") << endl; << " but iotype=" << p.stype << " for " << it.getProp("name") << endl;
} }
string sbyte(it.getProp("nbyte"));
if( !sbyte.empty() )
{
p.nbyte = UniSetTypes::uni_atoi(sbyte.c_str());
if( p.nbyte < 0 || p.nbyte > VTypes::Byte::bsize )
{
dlog[Debug::CRIT] << myname << "(initRSProperty): BAD nbyte=" << p.nbyte
<< ". (0 >= nbyte < " << VTypes::Byte::bsize << ")." << endl;
return false;
}
}
string vt(it.getProp("vtype")); string vt(it.getProp("vtype"));
if( vt.empty() ) if( vt.empty() )
{ {
...@@ -1328,34 +1370,10 @@ std::ostream& operator<<( std::ostream& os, const RTUExchange::DeviceType& dt ) ...@@ -1328,34 +1370,10 @@ std::ostream& operator<<( std::ostream& os, const RTUExchange::DeviceType& dt )
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
std::ostream& operator<<( std::ostream& os, const RTUExchange::RSProperty& p ) std::ostream& operator<<( std::ostream& os, const RTUExchange::RSProperty& p )
{ {
// os << " mbaddr=(" << (int)p.mbaddr << ")" << ModbusRTU::addr2str(p.mbaddr)
// << " mbreg=" << ModbusRTU::dat2str(p.mbreg)
// << " mbfunc=" << p.mbfunc
// << " dtype=" << p.dtype;
/*
switch(p.dtype)
{
case RTUExchange::dtRTU:
os << " nbit=" << p.nbit;
break;
case RTUExchange::dtRTU188:
os << " jack=" << RTUStorage::j2s(p.rtuJack)
<< " chan=" << p.rtuChan;
break;
case RTUExchange::dtMTR:
os << " mtrType=" << MTR::type2str(p.mtrType);
break;
default:
os << "Unknown type parameters ???!!!" << endl;
break;
}
*/
os << " sid=" << p.si.id os << " sid=" << p.si.id
<< " stype=" << p.stype << " stype=" << p.stype
<< " nbit=" << p.nbit << " nbit=" << p.nbit
<< " nbyte=" << p.nbyte
<< " rnum=" << p.rnum << " rnum=" << p.rnum
<< " safety=" << p.safety << " safety=" << p.safety
<< " invert=" << p.invert; << " invert=" << p.invert;
...@@ -1484,6 +1502,9 @@ std::ostream& operator<<( std::ostream& os, RTUExchange::RegInfo& r ) ...@@ -1484,6 +1502,9 @@ std::ostream& operator<<( std::ostream& os, RTUExchange::RegInfo& r )
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void RTUExchange::rtuQueryOptimization( RTUDeviceMap& m ) void RTUExchange::rtuQueryOptimization( RTUDeviceMap& m )
{ {
if( noQueryOptimization )
return;
dlog[Debug::INFO] << myname << "(rtuQueryOptimization): optimization..." << endl; dlog[Debug::INFO] << myname << "(rtuQueryOptimization): optimization..." << endl;
for( RTUExchange::RTUDeviceMap::iterator it1=m.begin(); it1!=m.end(); ++it1 ) for( RTUExchange::RTUDeviceMap::iterator it1=m.begin(); it1!=m.end(); ++it1 )
...@@ -1540,49 +1561,91 @@ void RTUExchange::updateRTU( RegMap::iterator& rit ) ...@@ -1540,49 +1561,91 @@ void RTUExchange::updateRTU( RegMap::iterator& rit )
if( r->mbfunc == fnWriteOutputRegisters || r->mbfunc == fnWriteOutputSingleRegister ) if( r->mbfunc == fnWriteOutputRegisters || r->mbfunc == fnWriteOutputSingleRegister )
save = true; save = true;
// if( !force_out_up && save )
// return;
ModbusRTU::DataBits16 b(r->mbval); ModbusRTU::DataBits16 b(r->mbval);
for( PList::iterator it=r->slst.begin(); it!=r->slst.end(); ++it ) for( PList::iterator it=r->slst.begin(); it!=r->slst.end(); ++it )
{ updateRSProperty( &(*it),false );
}
// -----------------------------------------------------------------------------
void RTUExchange::updateRSProperty( RSProperty* p, bool write_only )
{
using namespace ModbusRTU;
RegInfo* r(p->reg->rit->second);
bool save = false;
if( r->mbfunc == fnWriteOutputRegisters || r->mbfunc == fnWriteOutputSingleRegister )
save = true;
else if( write_only )
return;
try try
{ {
if( it->vType == VTypes::vtUnknown ) if( p->vType == VTypes::vtUnknown )
{ {
if( it->nbit >= 0 ) ModbusRTU::DataBits16 b(r->mbval);
if( p->nbit >= 0 )
{ {
if( save ) if( save )
{ {
bool set = IOBase::processingAsDO( &(*it), shm, force ); bool set = IOBase::processingAsDO( p, shm, force_out );
b.set(it->nbit,set); b.set(p->nbit,set);
r->mbval = b.mdata(); r->mbval = b.mdata();
} }
else else
{ {
bool set = b[it->nbit]; bool set = b[p->nbit];
IOBase::processingAsDI( &(*it), set, shm, force ); IOBase::processingAsDI( p, set, shm, force );
} }
continue; return;
} }
if( it->rnum <= 1 ) if( p->rnum <= 1 )
{ {
if( save ) if( save )
r->mbval = IOBase::processingAsAO( &(*it), shm, force ); r->mbval = IOBase::processingAsAO( p, shm, force_out );
else else
IOBase::processingAsAI( &(*it), r->mbval, shm, force ); IOBase::processingAsAI( p, r->mbval, shm, force );
continue; return;
} }
dlog[Debug::CRIT] << myname << "(updateRTU): IGNORE item: rnum=" << it->rnum dlog[Debug::CRIT] << myname << "(updateRSProperty): IGNORE item: rnum=" << p->rnum
<< " > 1 ?!! for id=" << it->si.id << endl; << " > 1 ?!! for id=" << p->si.id << endl;
continue;
return;
} }
else if( it->vType == VTypes::vtF2 ) else if( p->vType == VTypes::vtByte )
{ {
RegMap::iterator i(rit); if( p->nbyte <= 0 || p->nbyte > VTypes::Byte::bsize )
{
dlog[Debug::CRIT] << myname << "(updateRSProperty): IGNORE item: reg=" << ModbusRTU::dat2str(r->mbreg)
<< " vtype=" << p->vType << " but nbyte=" << p->nbyte << endl;
return;
}
if( save )
{
long v = IOBase::processingAsAO( p, shm, force_out );
VTypes::Byte b(r->mbval);
b.raw.b[p->nbyte-1] = v;
r->mbval = b.raw.w;
}
else
{
VTypes::Byte b(r->mbval);
IOBase::processingAsAI( p, b.raw.b[p->nbyte-1], shm, force );
}
return;
}
else if( p->vType == VTypes::vtF2 )
{
RegMap::iterator i(p->reg->rit);
if( save ) if( save )
{ {
float f = IOBase::processingFasAO( &(*it), shm, force ); float f = IOBase::processingFasAO( p, shm, force_out );
VTypes::F2 f2(f); VTypes::F2 f2(f);
for( int k=0; k<VTypes::F2::wsize(); k++, i++ ) for( int k=0; k<VTypes::F2::wsize(); k++, i++ )
i->second->mbval = f2.raw.v[k]; i->second->mbval = f2.raw.v[k];
...@@ -1596,15 +1659,15 @@ void RTUExchange::updateRTU( RegMap::iterator& rit ) ...@@ -1596,15 +1659,15 @@ void RTUExchange::updateRTU( RegMap::iterator& rit )
VTypes::F2 f(data,VTypes::F2::wsize()); VTypes::F2 f(data,VTypes::F2::wsize());
delete[] data; delete[] data;
IOBase::processingFasAI( &(*it), (float)f, shm, force ); IOBase::processingFasAI( p, (float)f, shm, force );
} }
} }
else if( it->vType == VTypes::vtF4 ) else if( p->vType == VTypes::vtF4 )
{ {
RegMap::iterator i(rit); RegMap::iterator i(p->reg->rit);
if( save ) if( save )
{ {
float f = IOBase::processingFasAO( &(*it), shm, force ); float f = IOBase::processingFasAO( p, shm, force_out );
VTypes::F4 f4(f); VTypes::F4 f4(f);
for( int k=0; k<VTypes::F4::wsize(); k++, i++ ) for( int k=0; k<VTypes::F4::wsize(); k++, i++ )
i->second->mbval = f4.raw.v[k]; i->second->mbval = f4.raw.v[k];
...@@ -1618,38 +1681,38 @@ void RTUExchange::updateRTU( RegMap::iterator& rit ) ...@@ -1618,38 +1681,38 @@ void RTUExchange::updateRTU( RegMap::iterator& rit )
VTypes::F4 f(data,VTypes::F4::wsize()); VTypes::F4 f(data,VTypes::F4::wsize());
delete[] data; delete[] data;
IOBase::processingFasAI( &(*it), (float)f, shm, force ); IOBase::processingFasAI( p, (float)f, shm, force );
} }
} }
} }
catch(IOController_i::NameNotFound &ex) catch(IOController_i::NameNotFound &ex)
{ {
dlog[Debug::LEVEL3] << myname << "(updateRTU):(NameNotFound) " << ex.err << endl; dlog[Debug::LEVEL3] << myname << "(updateRSProperty):(NameNotFound) " << ex.err << endl;
} }
catch(IOController_i::IOBadParam& ex ) catch(IOController_i::IOBadParam& ex )
{ {
dlog[Debug::LEVEL3] << myname << "(updateRTU):(IOBadParam) " << ex.err << endl; dlog[Debug::LEVEL3] << myname << "(updateRSProperty):(IOBadParam) " << ex.err << endl;
} }
catch(IONotifyController_i::BadRange ) catch(IONotifyController_i::BadRange )
{ {
dlog[Debug::LEVEL3] << myname << "(updateRTU): (BadRange)..." << endl; dlog[Debug::LEVEL3] << myname << "(updateRSProperty): (BadRange)..." << endl;
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
dlog[Debug::LEVEL3] << myname << "(updateRTU): " << ex << endl; dlog[Debug::LEVEL3] << myname << "(updateRSProperty): " << ex << endl;
} }
catch(CORBA::SystemException& ex) catch(CORBA::SystemException& ex)
{ {
dlog[Debug::LEVEL3] << myname << "(updateRTU): CORBA::SystemException: " dlog[Debug::LEVEL3] << myname << "(updateRSProperty): CORBA::SystemException: "
<< ex.NP_minorString() << endl; << ex.NP_minorString() << endl;
} }
catch(...) catch(...)
{ {
dlog[Debug::LEVEL3] << myname << "(updateRTU): catch ..." << endl; dlog[Debug::LEVEL3] << myname << "(updateRSProperty): catch ..." << endl;
}
} }
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void RTUExchange::updateMTR( RegMap::iterator& rit ) void RTUExchange::updateMTR( RegMap::iterator& rit )
{ {
RegInfo* r(rit->second); RegInfo* r(rit->second);
...@@ -1666,7 +1729,7 @@ void RTUExchange::updateMTR( RegMap::iterator& rit ) ...@@ -1666,7 +1729,7 @@ void RTUExchange::updateMTR( RegMap::iterator& rit )
if( r->mtrType == MTR::mtT1 ) if( r->mtrType == MTR::mtT1 )
{ {
if( save ) if( save )
r->mbval = IOBase::processingAsAO( &(*it), shm, force ); r->mbval = IOBase::processingAsAO( &(*it), shm, force_out );
else else
{ {
MTR::T1 t(r->mbval); MTR::T1 t(r->mbval);
...@@ -1679,7 +1742,7 @@ void RTUExchange::updateMTR( RegMap::iterator& rit ) ...@@ -1679,7 +1742,7 @@ void RTUExchange::updateMTR( RegMap::iterator& rit )
{ {
if( save ) if( save )
{ {
MTR::T2 t(IOBase::processingAsAO( &(*it), shm, force )); MTR::T2 t(IOBase::processingAsAO( &(*it), shm, force_out ));
r->mbval = t.val; r->mbval = t.val;
} }
else else
...@@ -1695,7 +1758,7 @@ void RTUExchange::updateMTR( RegMap::iterator& rit ) ...@@ -1695,7 +1758,7 @@ void RTUExchange::updateMTR( RegMap::iterator& rit )
RegMap::iterator i(rit); RegMap::iterator i(rit);
if( save ) if( save )
{ {
MTR::T3 t(IOBase::processingAsAO( &(*it), shm, force )); MTR::T3 t(IOBase::processingAsAO( &(*it), shm, force_out ));
for( int k=0; k<MTR::T3::wsize(); k++, i++ ) for( int k=0; k<MTR::T3::wsize(); k++, i++ )
i->second->mbval = t.raw.v[k]; i->second->mbval = t.raw.v[k];
} }
...@@ -1729,7 +1792,7 @@ void RTUExchange::updateMTR( RegMap::iterator& rit ) ...@@ -1729,7 +1792,7 @@ void RTUExchange::updateMTR( RegMap::iterator& rit )
RegMap::iterator i(rit); RegMap::iterator i(rit);
if( save ) if( save )
{ {
MTR::T5 t(IOBase::processingAsAO( &(*it), shm, force )); MTR::T5 t(IOBase::processingAsAO( &(*it), shm, force_out ));
for( int k=0; k<MTR::T5::wsize(); k++, i++ ) for( int k=0; k<MTR::T5::wsize(); k++, i++ )
i->second->mbval = t.raw.v[k]; i->second->mbval = t.raw.v[k];
} }
...@@ -1752,7 +1815,7 @@ void RTUExchange::updateMTR( RegMap::iterator& rit ) ...@@ -1752,7 +1815,7 @@ void RTUExchange::updateMTR( RegMap::iterator& rit )
RegMap::iterator i(rit); RegMap::iterator i(rit);
if( save ) if( save )
{ {
MTR::T6 t(IOBase::processingAsAO( &(*it), shm, force )); MTR::T6 t(IOBase::processingAsAO( &(*it), shm, force_out ));
for( int k=0; k<MTR::T6::wsize(); k++, i++ ) for( int k=0; k<MTR::T6::wsize(); k++, i++ )
i->second->mbval = t.raw.v[k]; i->second->mbval = t.raw.v[k];
} }
...@@ -1775,7 +1838,7 @@ void RTUExchange::updateMTR( RegMap::iterator& rit ) ...@@ -1775,7 +1838,7 @@ void RTUExchange::updateMTR( RegMap::iterator& rit )
RegMap::iterator i(rit); RegMap::iterator i(rit);
if( save ) if( save )
{ {
MTR::T7 t(IOBase::processingAsAO( &(*it), shm, force )); MTR::T7 t(IOBase::processingAsAO( &(*it), shm, force_out ));
for( int k=0; k<MTR::T7::wsize(); k++, i++ ) for( int k=0; k<MTR::T7::wsize(); k++, i++ )
i->second->mbval = t.raw.v[k]; i->second->mbval = t.raw.v[k];
} }
...@@ -1798,7 +1861,7 @@ void RTUExchange::updateMTR( RegMap::iterator& rit ) ...@@ -1798,7 +1861,7 @@ void RTUExchange::updateMTR( RegMap::iterator& rit )
RegMap::iterator i(rit); RegMap::iterator i(rit);
if( save ) if( save )
{ {
float f = IOBase::processingFasAO( &(*it), shm, force ); float f = IOBase::processingFasAO( &(*it), shm, force_out );
MTR::F1 f1(f); MTR::F1 f1(f);
for( int k=0; k<MTR::F1::wsize(); k++, i++ ) for( int k=0; k<MTR::F1::wsize(); k++, i++ )
i->second->mbval = f1.raw.v[k]; i->second->mbval = f1.raw.v[k];
......
...@@ -60,14 +60,15 @@ class RTUExchange: ...@@ -60,14 +60,15 @@ class RTUExchange:
public IOBase public IOBase
{ {
// only for RTU // only for RTU
short nbit; /*!< bit number (for func=[0x01,0x02]) */ short nbit; /*!< bit number) */
VTypes::VType vType; /*!< type of value */ VTypes::VType vType; /*!< type of value */
short rnum; /*!< count of registers */ short rnum; /*!< count of registers */
short nbyte; /*!< byte number (1-2) */
RSProperty(): RSProperty():
nbit(-1),vType(VTypes::vtUnknown), nbit(-1),vType(VTypes::vtUnknown),
rnum(VTypes::wsize(VTypes::vtUnknown)), rnum(VTypes::wsize(VTypes::vtUnknown)),
reg(0) nbyte(0),reg(0)
{} {}
RegInfo* reg; RegInfo* reg;
...@@ -77,6 +78,7 @@ class RTUExchange: ...@@ -77,6 +78,7 @@ class RTUExchange:
typedef std::list<RSProperty> PList; typedef std::list<RSProperty> PList;
typedef std::map<ModbusRTU::ModbusData,RegInfo*> RegMap;
struct RegInfo struct RegInfo
{ {
RegInfo(): RegInfo():
...@@ -106,11 +108,13 @@ class RTUExchange: ...@@ -106,11 +108,13 @@ class RTUExchange:
// optimization // optimization
int q_num; /*! number in query */ int q_num; /*! number in query */
int q_count; /*! count registers for query */ int q_count; /*! count registers for query */
RegMap::iterator rit;
}; };
friend std::ostream& operator<<( std::ostream& os, RegInfo& r ); friend std::ostream& operator<<( std::ostream& os, RegInfo& r );
typedef std::map<ModbusRTU::ModbusData,RegInfo*> RegMap;
struct RTUDevice struct RTUDevice
{ {
...@@ -177,6 +181,7 @@ class RTUExchange: ...@@ -177,6 +181,7 @@ class RTUExchange:
void updateRTU(RegMap::iterator& it); void updateRTU(RegMap::iterator& it);
void updateMTR(RegMap::iterator& it); void updateMTR(RegMap::iterator& it);
void updateRTU188(RegMap::iterator& it); void updateRTU188(RegMap::iterator& it);
void updateRSProperty( RSProperty* p, bool write_only=false );
virtual void processingMessage( UniSetTypes::VoidMessage *msg ); virtual void processingMessage( UniSetTypes::VoidMessage *msg );
void sysCommand( UniSetTypes::SystemMessage *msg ); void sysCommand( UniSetTypes::SystemMessage *msg );
...@@ -236,6 +241,9 @@ class RTUExchange: ...@@ -236,6 +241,9 @@ class RTUExchange:
bool activated; bool activated;
int activateTimeout; int activateTimeout;
bool rs_pre_clean;
bool noQueryOptimization;
}; };
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
#endif // _RS_EXCHANGE_H_ #endif // _RS_EXCHANGE_H_
......
#!/bin/sh #!/bin/sh
ln -s -f /usr/bin/uniset-stop.sh stop.sh ln -s -f /usr/bin/uniset-stop.sh stop.sh
#ln -s -f ../../conf/test.xml test.xml ln -s -f ../../conf/test.xml test.xml
ln -s -f ./configure.xml test.xml
#!/bin/sh #!/bin/sh
uniset-start.sh -f ./uniset-rtuexchange --confile test.xml \ uniset-start.sh -f ./uniset-rtuexchange --confile test.xml \
--rs-dev /dev/cbsideA0 \ --rs-dev /dev/ttyS0 \
--rs-name RSExchange \ --rs-name RSExchange \
--rs-speed 38400 \ --rs-speed 38400 \
--rs-filter-field rs \ --rs-filter-field rs \
--rs-filter-value 1 \ --rs-filter-value 3 \
--dlog-add-levels info,crit,warn,level1 --dlog-add-levels info,crit,warn \
--rs-force 0 \
--rs-force-out 0 \
#,level3 #,level3
# --rs-force 1 \
...@@ -411,7 +411,7 @@ void SharedMemory::fastSaveValue(const IOController_i::SensorInfo& si, CORBA::Lo ...@@ -411,7 +411,7 @@ void SharedMemory::fastSaveValue(const IOController_i::SensorInfo& si, CORBA::Lo
SharedMemory* SharedMemory::init_smemory( int argc, char* argv[] ) SharedMemory* SharedMemory::init_smemory( int argc, char* argv[] )
{ {
string dfile = conf->getArgParam("--datfile",conf->getConfFileName()); string dfile = conf->getArgParam("--datfile",conf->getConfFileName());
dlog[Debug::INFO] << "(smemory): datfile = " << dfile << endl;
if( dfile[0]!='.' && dfile[0]!='/' ) if( dfile[0]!='.' && dfile[0]!='/' )
dfile = conf->getConfDir() + dfile; dfile = conf->getConfDir() + dfile;
......
#!/bin/sh #!/bin/sh
ln -s -f /usr/bin/uniset-stop.sh stop.sh ln -s -f /usr/bin/uniset-stop.sh stop.sh
#ln -s -f ../../conf/test.xml test.xml ln -s -f ../../conf/test.xml test.xml
ln -s -f ./configure.xml test.xml
...@@ -3,6 +3,6 @@ ...@@ -3,6 +3,6 @@
ulimit -Sc 1000000000000 ulimit -Sc 1000000000000
uniset-start.sh -f ./uniset-smemory --smemory-id SharedMemory1 \ uniset-start.sh -f ./uniset-smemory --smemory-id SharedMemory1 \
--confile test.xml \ --confile test.xml --datfile /etc/AEU/configure.xml \
--unideb-add-levels info,crit,warn,level9,system --unideb-add-levels info,crit,warn,level9,system
...@@ -33,7 +33,8 @@ static const int NoSafety = -1; ...@@ -33,7 +33,8 @@ static const int NoSafety = -1;
invert(false), invert(false),
jar_state(false), jar_state(false),
ondelay_state(false), ondelay_state(false),
offdelay_state(false) offdelay_state(false),
t_ai(UniSetTypes::DefaultObjectId)
{} {}
...@@ -75,6 +76,14 @@ static const int NoSafety = -1; ...@@ -75,6 +76,14 @@ static const int NoSafety = -1;
bool ondelay_state; /*!< */ bool ondelay_state; /*!< */
bool offdelay_state; /*!< */ bool offdelay_state; /*!< */
//
UniSetTypes::ObjectId t_ai; /*!< ,
,
*/
IONotifyController_i::ThresholdInfo ti;
IOController::AIOStateList::iterator ait; IOController::AIOStateList::iterator ait;
IOController::DIOStateList::iterator dit; IOController::DIOStateList::iterator dit;
UniSetTypes::uniset_spin_mutex val_lock; /*!< */ UniSetTypes::uniset_spin_mutex val_lock; /*!< */
...@@ -87,6 +96,7 @@ static const int NoSafety = -1; ...@@ -87,6 +96,7 @@ static const int NoSafety = -1;
static long processingAsAO( IOBase* it, SMInterface* shm, bool force ); static long processingAsAO( IOBase* it, SMInterface* shm, bool force );
static float processingFasAO( IOBase* it, SMInterface* shm, bool force ); static float processingFasAO( IOBase* it, SMInterface* shm, bool force );
static bool processingAsDO( IOBase* it, SMInterface* shm, bool force ); static bool processingAsDO( IOBase* it, SMInterface* shm, bool force );
static void processingThreshold( IOBase* it, SMInterface* shm, bool force );
static bool initItem( IOBase* b, UniXML_iterator& it, SMInterface* shm, static bool initItem( IOBase* b, UniXML_iterator& it, SMInterface* shm,
DebugStream* dlog=0, std::string myname="", DebugStream* dlog=0, std::string myname="",
int def_filtersize=0, float def_filterT=0.0 ); int def_filtersize=0, float def_filterT=0.0 );
......
...@@ -16,7 +16,8 @@ namespace VTypes ...@@ -16,7 +16,8 @@ namespace VTypes
{ {
vtUnknown, vtUnknown,
vtF2, vtF2,
vtF4 vtF4,
vtByte
}; };
std::ostream& operator<<( std::ostream& os, const VType& vt ); std::ostream& operator<<( std::ostream& os, const VType& vt );
...@@ -97,6 +98,48 @@ namespace VTypes ...@@ -97,6 +98,48 @@ namespace VTypes
F4mem raw; F4mem raw;
}; };
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
class Byte
{
public:
static const int bsize = 2;
// ------------------------------------------
/*! */
typedef union
{
unsigned short w;
unsigned char b[bsize];
} Bytemem;
// ------------------------------------------
// ...
Byte(){ raw.w = 0; }
Byte( unsigned char b1, unsigned char b2 ){ raw.b[0]=b1; raw.b[1]=b2; }
Byte( const long val )
{
raw.w = val;
}
Byte( const ModbusRTU::ModbusData dat )
{
raw.w = dat;
}
~Byte(){}
// ------------------------------------------
/*! */
static int wsize(){ return 1; }
/*! */
static VType type(){ return vtByte; }
// ------------------------------------------
operator long(){ return lroundf(raw.w); }
unsigned char operator[]( const int i ){ return raw.b[i]; }
Bytemem raw;
};
// --------------------------------------------------------------------------
} // end of namespace VTypes } // end of namespace VTypes
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
......
...@@ -105,17 +105,18 @@ void IOBase::processingAsAI( IOBase* it, long val, SMInterface* shm, bool force ...@@ -105,17 +105,18 @@ void IOBase::processingAsAI( IOBase* it, long val, SMInterface* shm, bool force
return; return;
} }
// ... if( it->cdiagram ) //
if( !it->nofilter )
{ {
if( it->df.size() > 1 ) // ,
it->df.add(val); // ,
if( !it->nofilter && it->df.size() > 1 )
{
if( it->f_median )
val = it->df.median(val);
else
val = it->df.filterRC(val); val = it->df.filterRC(val);
} }
if( it->cdiagram ) //
{
if( it->craw != val ) if( it->craw != val )
{ {
it->craw = val; it->craw = val;
...@@ -130,6 +131,16 @@ void IOBase::processingAsAI( IOBase* it, long val, SMInterface* shm, bool force ...@@ -130,6 +131,16 @@ void IOBase::processingAsAI( IOBase* it, long val, SMInterface* shm, bool force
IOController_i::CalibrateInfo* cal( &(it->cal) ); IOController_i::CalibrateInfo* cal( &(it->cal) );
if( cal->maxRaw!=0 && cal->maxRaw!=cal->minRaw ) // if( cal->maxRaw!=0 && cal->maxRaw!=cal->minRaw ) //
val = UniSetTypes::lcalibrate(val,cal->minRaw,cal->maxRaw,cal->minCal,cal->maxCal,true); val = UniSetTypes::lcalibrate(val,cal->minRaw,cal->maxRaw,cal->minCal,cal->maxCal,true);
// ,
// ,
if( !it->nofilter && it->df.size() > 1 )
{
if( it->f_median )
val = it->df.median(val);
else
val = it->df.filterRC(val);
}
} }
// "", // "",
...@@ -185,7 +196,7 @@ void IOBase::processingFasAI( IOBase* it, float fval, SMInterface* shm, bool for ...@@ -185,7 +196,7 @@ void IOBase::processingFasAI( IOBase* it, float fval, SMInterface* shm, bool for
IOController_i::CalibrateInfo* cal( &(it->cal) ); IOController_i::CalibrateInfo* cal( &(it->cal) );
if( cal->maxRaw!=0 && cal->maxRaw!=cal->minRaw ) // if( cal->maxRaw!=0 && cal->maxRaw!=cal->minRaw ) //
val = UniSetTypes::fcalibrate(val,cal->minRaw,cal->maxRaw,cal->minCal,cal->maxCal,true); val = UniSetTypes::lcalibrate(val,cal->minRaw,cal->maxRaw,cal->minCal,cal->maxCal,true);
// "", // "",
// //
...@@ -246,12 +257,15 @@ void IOBase::processingAsDI( IOBase* it, bool set, SMInterface* shm, bool force ...@@ -246,12 +257,15 @@ void IOBase::processingAsDI( IOBase* it, bool set, SMInterface* shm, bool force
long IOBase::processingAsAO( IOBase* it, SMInterface* shm, bool force ) long IOBase::processingAsAO( IOBase* it, SMInterface* shm, bool force )
{ {
uniset_spin_lock lock(it->val_lock); uniset_spin_lock lock(it->val_lock);
long val = it->value; long val = it->value;
if( force ) if( force )
{ {
if( it->stype == UniversalIO::DigitalInput || it->stype == UniversalIO::DigitalOutput )
val = shm->localGetState(it->dit,it->si.id) ? 1 : 0;
else if( it->stype == UniversalIO::AnalogInput || it->stype == UniversalIO::AnalogOutput )
val = shm->localGetValue(it->ait,it->si.id); val = shm->localGetValue(it->ait,it->si.id);
it->value = val; it->value = val;
} }
...@@ -272,7 +286,7 @@ long IOBase::processingAsAO( IOBase* it, SMInterface* shm, bool force ) ...@@ -272,7 +286,7 @@ long IOBase::processingAsAO( IOBase* it, SMInterface* shm, bool force )
else else
{ {
IOController_i::CalibrateInfo* cal( &(it->cal) ); IOController_i::CalibrateInfo* cal( &(it->cal) );
if( cal->maxRaw!=0 && cal->maxRaw!=cal->minRaw ) // if( cal && cal->maxRaw!=0 && cal->maxRaw!=cal->minRaw ) //
{ {
// !!! // !!!
val = UniSetTypes::lcalibrate(it->value, val = UniSetTypes::lcalibrate(it->value,
...@@ -293,17 +307,17 @@ bool IOBase::processingAsDO( IOBase* it, SMInterface* shm, bool force ) ...@@ -293,17 +307,17 @@ bool IOBase::processingAsDO( IOBase* it, SMInterface* shm, bool force )
{ {
uniset_spin_lock lock(it->val_lock); uniset_spin_lock lock(it->val_lock);
bool set = it->value; bool set = it->value;
if( it->stype == UniversalIO::DigitalOutput ||
it->stype == UniversalIO::DigitalInput )
{
if( force ) if( force )
{
if( it->stype == UniversalIO::DigitalInput || it->stype == UniversalIO::DigitalOutput )
set = shm->localGetState(it->dit,it->si.id); set = shm->localGetState(it->dit,it->si.id);
else if( it->stype == UniversalIO::AnalogInput || it->stype == UniversalIO::AnalogOutput )
set = shm->localGetValue(it->ait,it->si.id) ? true : false;
}
set = it->invert ? !set : set; set = it->invert ? !set : set;
return set; return set;
}
return false;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
float IOBase::processingFasAO( IOBase* it, SMInterface* shm, bool force ) float IOBase::processingFasAO( IOBase* it, SMInterface* shm, bool force )
...@@ -351,6 +365,26 @@ float IOBase::processingFasAO( IOBase* it, SMInterface* shm, bool force ) ...@@ -351,6 +365,26 @@ float IOBase::processingFasAO( IOBase* it, SMInterface* shm, bool force )
return val; return val;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void IOBase::processingThreshold( IOBase* it, SMInterface* shm, bool force )
{
if( it->t_ai == DefaultObjectId )
return;
long val = shm->localGetValue(it->ait,it->t_ai);
bool set = it->value ? true : false;
// cout << "val=" << val << " set=" << set << endl;
//
// lowLimit-
if( val <= (it->ti.lowlimit-it->ti.sensibility) )
set = false;
else if( val >= (it->ti.hilimit+it->ti.sensibility) )
set = true;
// cout << "thresh: set=" << set << endl;
processingAsDI(it,set,shm,force);
}
// -----------------------------------------------------------------------------
bool IOBase::initItem( IOBase* b, UniXML_iterator& it, SMInterface* shm, bool IOBase::initItem( IOBase* b, UniXML_iterator& it, SMInterface* shm,
DebugStream* dlog, std::string myname, DebugStream* dlog, std::string myname,
...@@ -456,9 +490,6 @@ bool IOBase::initItem( IOBase* b, UniXML_iterator& it, SMInterface* shm, ...@@ -456,9 +490,6 @@ bool IOBase::initItem( IOBase* b, UniXML_iterator& it, SMInterface* shm,
} }
} }
for( int i=0; i<f_size; i++ )
b->df.add( b->defval );
if( !it.getProp("filterT").empty() ) if( !it.getProp("filterT").empty() )
{ {
f_T = atof(it.getProp("filterT").c_str()); f_T = atof(it.getProp("filterT").c_str());
...@@ -469,10 +500,36 @@ bool IOBase::initItem( IOBase* b, UniXML_iterator& it, SMInterface* shm, ...@@ -469,10 +500,36 @@ bool IOBase::initItem( IOBase* b, UniXML_iterator& it, SMInterface* shm,
if( b->stype == UniversalIO::AnalogInput ) if( b->stype == UniversalIO::AnalogInput )
b->df.setSettings( f_size, f_T ); b->df.setSettings( f_size, f_T );
b->df.init(b->defval);
std::string caldiagram( it.getProp("caldiagram") ); std::string caldiagram( it.getProp("caldiagram") );
if( !caldiagram.empty() ) if( !caldiagram.empty() )
b->cdiagram = UniSetExtentions::buildCalibrationDiagram(caldiagram); b->cdiagram = UniSetExtentions::buildCalibrationDiagram(caldiagram);
} }
else if( b->stype == UniversalIO::DigitalInput || b->stype == UniversalIO::DigitalOutput )
{
string tai(it.getProp("threshold_aid"));
if( !tai.empty() )
{
b->t_ai = conf->getSensorID(tai);
if( b->t_ai == DefaultObjectId )
{
if( dlog )
dlog[Debug::CRIT] << myname << "(IOBase::readItem): unknown ID for threshold_ai "
<< tai << endl;
return false;
}
b->ti.lowlimit = uni_atoi( it.getProp("lowlimit").c_str() );
b->ti.hilimit = uni_atoi( it.getProp("hilimit").c_str() );
b->ti.sensibility = uni_atoi( it.getProp("sensibility").c_str() );
}
}
// else
// {
// dlog[Debug::CRIT] << myname << "(IOBase::readItem): iotype=: " << stype << " " << sname << endl;
// return false;
// }
return true; return true;
} }
......
...@@ -16,6 +16,9 @@ std::ostream& operator<<( std::ostream& os, const VType& vt ) ...@@ -16,6 +16,9 @@ std::ostream& operator<<( std::ostream& os, const VType& vt )
VType str2type( const std::string s ) VType str2type( const std::string s )
{ {
if( s == "Byte" )
return vtByte;
if( s == "F2" ) if( s == "F2" )
return vtF2; return vtF2;
if( s == "F4" ) if( s == "F4" )
...@@ -26,6 +29,8 @@ VType str2type( const std::string s ) ...@@ -26,6 +29,8 @@ VType str2type( const std::string s )
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
string type2str( VType t ) string type2str( VType t )
{ {
if( t == vtByte )
return "Byte";
if( t == vtF2 ) if( t == vtF2 )
return "F2"; return "F2";
if( t == vtF4 ) if( t == vtF4 )
...@@ -36,6 +41,8 @@ string type2str( VType t ) ...@@ -36,6 +41,8 @@ string type2str( VType t )
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
int wsize( VType t ) int wsize( VType t )
{ {
if( t == vtByte )
return Byte::wsize();
if( t == vtF2 ) if( t == vtF2 )
return F2::wsize(); return F2::wsize();
if( t == vtF4 ) if( t == vtF4 )
......
...@@ -207,11 +207,16 @@ DebugStream::~DebugStream() ...@@ -207,11 +207,16 @@ DebugStream::~DebugStream()
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
const DebugStream& DebugStream::operator=( const DebugStream& r ) const DebugStream& DebugStream::operator=( const DebugStream& r )
{ {
if( r == *this )
return *this;
dt = r.dt; dt = r.dt;
show_datetime = r.show_datetime; show_datetime = r.show_datetime;
fname = r.fname; fname = r.fname;
if( !r.fname.empty() ) if( !r.fname.empty() )
logFile(fname.c_str()); logFile(fname.c_str());
return *this;
} }
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
/// Sets the debugstreams' logfile to f. /// Sets the debugstreams' logfile to f.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment