Commit ce99ffae authored by Pavel Vainerman's avatar Pavel Vainerman

add new property: "rtuVType" for type="rtu"

parent 856f2b1c
...@@ -81,6 +81,7 @@ static const int NoSafety = -1; ...@@ -81,6 +81,7 @@ static const int NoSafety = -1;
friend std::ostream& operator<<(std::ostream& os, IOBase& inf ); friend std::ostream& operator<<(std::ostream& os, IOBase& inf );
static void processingFasAI( IOBase* it, float new_val, SMInterface* shm, bool force );
static void processingAsAI( IOBase* it, long new_val, SMInterface* shm, bool force ); static void processingAsAI( IOBase* it, long new_val, SMInterface* shm, bool force );
static void processingAsDI( IOBase* it, bool new_set, SMInterface* shm, bool force ); static void processingAsDI( IOBase* it, bool new_set, SMInterface* shm, bool force );
static long processingAsAO( IOBase* it, SMInterface* shm, bool force ); static long processingAsAO( IOBase* it, SMInterface* shm, bool force );
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
#define _MTR_H_ #define _MTR_H_
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
#include <string> #include <string>
#include <cstring>
#include <cmath>
#include "modbus/ModbusTypes.h" #include "modbus/ModbusTypes.h"
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
class ModbusRTUMaster; class ModbusRTUMaster;
......
...@@ -110,7 +110,7 @@ void IOBase::processingAsAI( IOBase* it, long val, SMInterface* shm, bool force ...@@ -110,7 +110,7 @@ void IOBase::processingAsAI( IOBase* it, long val, SMInterface* shm, bool force
{ {
if( it->df.size() > 1 ) if( it->df.size() > 1 )
it->df.add(val); it->df.add(val);
else
val = it->df.filterRC(val); val = it->df.filterRC(val);
} }
...@@ -140,7 +140,53 @@ void IOBase::processingAsAI( IOBase* it, long val, SMInterface* shm, bool force ...@@ -140,7 +140,53 @@ void IOBase::processingAsAI( IOBase* it, long val, SMInterface* shm, bool force
shm->localSetUndefinedState(it->ait,false,it->si.id); shm->localSetUndefinedState(it->ait,false,it->si.id);
if( it->cal.precision > 0 ) if( it->cal.precision > 0 )
it->value *= lround(pow10(it->cal.precision)); val *= lround(pow10(it->cal.precision));
if( force || it->value != val )
{
if( it->stype == UniversalIO::AnalogInput )
shm->localSaveValue( it->ait,it->si.id,val,shm->ID() );
else if( it->stype == UniversalIO::AnalogOutput )
shm->localSetValue( it->ait,it->si.id,val,shm->ID() );
it->value = val;
}
}
}
// -----------------------------------------------------------------------------
void IOBase::processingFasAI( IOBase* it, float val, SMInterface* shm, bool force )
{
//
if( it->check_channel_break(val) )
{
uniset_spin_lock lock(it->val_lock);
it->value = ChannelBreakValue;
shm->localSetUndefinedState(it->ait,true,it->si.id);
return;
}
// ...
if( !it->nofilter )
{
if( it->df.size() > 1 )
it->df.add(val);
val = it->df.filterRC(val);
}
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);
// "",
//
{
uniset_spin_lock lock(it->val_lock);
if( it->value == ChannelBreakValue )
shm->localSetUndefinedState(it->ait,false,it->si.id);
if( it->cal.precision > 0 )
val *= lroundf(pow10(it->cal.precision));
if( force || it->value != val ) if( force || it->value != val )
{ {
......
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