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 @@
( ConsumerInfo ..). uniset-codegen,
SensorInfo ObjectId.
RTUExchange
==============
...
udev
----------
smonit: processing "precision"
admin: processing "precision"
\ No newline at end of file
#!/bin/sh
ln -s -f /usr/bin/uniset-stop.sh stop.sh
#ln -s -f ../../conf/test.xml test.xml
ln -s -f ./configure.xml test.xml
ln -s -f ../../conf/test.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 @@
Name: uniset
Version: 0.96
Release: eter24
Release: eter26
Summary: UniSet
License: GPL
Group: Development/C++
......@@ -181,7 +181,7 @@ Libraries needed to develop for uniset extentions
%_bindir/%name-smviewer
%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
* Thu Jun 04 2009 Pavel Vainerman <pv@aeu> 0.96-eter23
......
......@@ -492,6 +492,9 @@ void IOControl::iopoll()
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()
......
......@@ -298,6 +298,9 @@ void MBMaster::poll()
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 )
......
......@@ -307,6 +307,9 @@ void MBSlave::execute_rtu()
<< "(execute_rtu): (hb) " << ex << std::endl;
}
}
for( IOMap::iterator it=iomap.begin(); it!=iomap.end(); ++it )
IOBase::processingThreshold(&it->second,shm,force);
}
catch(...){}
}
......@@ -355,6 +358,9 @@ void MBSlave::execute_tcp()
<< "(execute_tcp): (hb) " << ex << std::endl;
}
}
for( IOMap::iterator it=iomap.begin(); it!=iomap.end(); ++it )
IOBase::processingThreshold(&it->second,shm,force);
}
catch(...){}
}
......
......@@ -60,14 +60,15 @@ class RTUExchange:
public IOBase
{
// only for RTU
short nbit; /*!< bit number (for func=[0x01,0x02]) */
short nbit; /*!< bit number) */
VTypes::VType vType; /*!< type of value */
short rnum; /*!< count of registers */
short nbyte; /*!< byte number (1-2) */
RSProperty():
nbit(-1),vType(VTypes::vtUnknown),
rnum(VTypes::wsize(VTypes::vtUnknown)),
reg(0)
nbyte(0),reg(0)
{}
RegInfo* reg;
......@@ -77,6 +78,7 @@ class RTUExchange:
typedef std::list<RSProperty> PList;
typedef std::map<ModbusRTU::ModbusData,RegInfo*> RegMap;
struct RegInfo
{
RegInfo():
......@@ -106,11 +108,13 @@ class RTUExchange:
// optimization
int q_num; /*! number in query */
int q_count; /*! count registers for query */
RegMap::iterator rit;
};
friend std::ostream& operator<<( std::ostream& os, RegInfo& r );
typedef std::map<ModbusRTU::ModbusData,RegInfo*> RegMap;
struct RTUDevice
{
......@@ -177,6 +181,7 @@ class RTUExchange:
void updateRTU(RegMap::iterator& it);
void updateMTR(RegMap::iterator& it);
void updateRTU188(RegMap::iterator& it);
void updateRSProperty( RSProperty* p, bool write_only=false );
virtual void processingMessage( UniSetTypes::VoidMessage *msg );
void sysCommand( UniSetTypes::SystemMessage *msg );
......@@ -236,6 +241,9 @@ class RTUExchange:
bool activated;
int activateTimeout;
bool rs_pre_clean;
bool noQueryOptimization;
};
// -----------------------------------------------------------------------------
#endif // _RS_EXCHANGE_H_
......
#!/bin/sh
ln -s -f /usr/bin/uniset-stop.sh stop.sh
#ln -s -f ../../conf/test.xml test.xml
ln -s -f ./configure.xml test.xml
ln -s -f ../../conf/test.xml test.xml
#!/bin/sh
uniset-start.sh -f ./uniset-rtuexchange --confile test.xml \
--rs-dev /dev/cbsideA0 \
--rs-dev /dev/ttyS0 \
--rs-name RSExchange \
--rs-speed 38400 \
--rs-filter-field rs \
--rs-filter-value 1 \
--dlog-add-levels info,crit,warn,level1
--rs-filter-value 3 \
--dlog-add-levels info,crit,warn \
--rs-force 0 \
--rs-force-out 0 \
#,level3
# --rs-force 1 \
......@@ -411,7 +411,7 @@ void SharedMemory::fastSaveValue(const IOController_i::SensorInfo& si, CORBA::Lo
SharedMemory* SharedMemory::init_smemory( int argc, char* argv[] )
{
string dfile = conf->getArgParam("--datfile",conf->getConfFileName());
dlog[Debug::INFO] << "(smemory): datfile = " << dfile << endl;
if( dfile[0]!='.' && dfile[0]!='/' )
dfile = conf->getConfDir() + dfile;
......
#!/bin/sh
ln -s -f /usr/bin/uniset-stop.sh stop.sh
#ln -s -f ../../conf/test.xml test.xml
ln -s -f ./configure.xml test.xml
ln -s -f ../../conf/test.xml test.xml
......@@ -3,6 +3,6 @@
ulimit -Sc 1000000000000
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
......@@ -33,7 +33,8 @@ static const int NoSafety = -1;
invert(false),
jar_state(false),
ondelay_state(false),
offdelay_state(false)
offdelay_state(false),
t_ai(UniSetTypes::DefaultObjectId)
{}
......@@ -75,6 +76,14 @@ static const int NoSafety = -1;
bool ondelay_state; /*!< */
bool offdelay_state; /*!< */
//
UniSetTypes::ObjectId t_ai; /*!< ,
,
*/
IONotifyController_i::ThresholdInfo ti;
IOController::AIOStateList::iterator ait;
IOController::DIOStateList::iterator dit;
UniSetTypes::uniset_spin_mutex val_lock; /*!< */
......@@ -87,6 +96,7 @@ static const int NoSafety = -1;
static long processingAsAO( 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 void processingThreshold( IOBase* it, SMInterface* shm, bool force );
static bool initItem( IOBase* b, UniXML_iterator& it, SMInterface* shm,
DebugStream* dlog=0, std::string myname="",
int def_filtersize=0, float def_filterT=0.0 );
......
......@@ -16,7 +16,8 @@ namespace VTypes
{
vtUnknown,
vtF2,
vtF4
vtF4,
vtByte
};
std::ostream& operator<<( std::ostream& os, const VType& vt );
......@@ -97,6 +98,48 @@ namespace VTypes
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
// --------------------------------------------------------------------------
......
......@@ -105,17 +105,18 @@ void IOBase::processingAsAI( IOBase* it, long val, SMInterface* shm, bool force
return;
}
// ...
if( !it->nofilter )
if( it->cdiagram ) //
{
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);
}
if( it->cdiagram ) //
{
if( it->craw != val )
{
it->craw = val;
......@@ -130,6 +131,16 @@ void IOBase::processingAsAI( IOBase* it, long val, SMInterface* shm, bool force
IOController_i::CalibrateInfo* cal( &(it->cal) );
if( cal->maxRaw!=0 && cal->maxRaw!=cal->minRaw ) //
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
IOController_i::CalibrateInfo* cal( &(it->cal) );
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
long IOBase::processingAsAO( IOBase* it, SMInterface* shm, bool force )
{
uniset_spin_lock lock(it->val_lock);
long val = it->value;
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);
it->value = val;
}
......@@ -272,7 +286,7 @@ long IOBase::processingAsAO( IOBase* it, SMInterface* shm, bool force )
else
{
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,
......@@ -293,17 +307,17 @@ bool IOBase::processingAsDO( IOBase* it, SMInterface* shm, bool force )
{
uniset_spin_lock lock(it->val_lock);
bool set = it->value;
if( it->stype == UniversalIO::DigitalOutput ||
it->stype == UniversalIO::DigitalInput )
{
if( force )
{
if( it->stype == UniversalIO::DigitalInput || it->stype == UniversalIO::DigitalOutput )
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;
return set;
}
return false;
}
// -----------------------------------------------------------------------------
float IOBase::processingFasAO( IOBase* it, SMInterface* shm, bool force )
......@@ -351,6 +365,26 @@ float IOBase::processingFasAO( IOBase* it, SMInterface* shm, bool force )
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,
DebugStream* dlog, std::string myname,
......@@ -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() )
{
f_T = atof(it.getProp("filterT").c_str());
......@@ -469,10 +500,36 @@ bool IOBase::initItem( IOBase* b, UniXML_iterator& it, SMInterface* shm,
if( b->stype == UniversalIO::AnalogInput )
b->df.setSettings( f_size, f_T );
b->df.init(b->defval);
std::string caldiagram( it.getProp("caldiagram") );
if( !caldiagram.empty() )
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;
}
......
......@@ -16,6 +16,9 @@ std::ostream& operator<<( std::ostream& os, const VType& vt )
VType str2type( const std::string s )
{
if( s == "Byte" )
return vtByte;
if( s == "F2" )
return vtF2;
if( s == "F4" )
......@@ -26,6 +29,8 @@ VType str2type( const std::string s )
// -------------------------------------------------------------------------
string type2str( VType t )
{
if( t == vtByte )
return "Byte";
if( t == vtF2 )
return "F2";
if( t == vtF4 )
......@@ -36,6 +41,8 @@ string type2str( VType t )
// -------------------------------------------------------------------------
int wsize( VType t )
{
if( t == vtByte )
return Byte::wsize();
if( t == vtF2 )
return F2::wsize();
if( t == vtF4 )
......
......@@ -207,11 +207,16 @@ DebugStream::~DebugStream()
//--------------------------------------------------------------------------
const DebugStream& DebugStream::operator=( const DebugStream& r )
{
if( r == *this )
return *this;
dt = r.dt;
show_datetime = r.show_datetime;
fname = r.fname;
if( !r.fname.empty() )
logFile(fname.c_str());
return *this;
}
//--------------------------------------------------------------------------
/// 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