Commit 68709612 authored by Pavel Vainerman's avatar Pavel Vainerman

Добавил обработку поля "precision" для датчиков которые "пишутся"

(передаются во внешние системы). Это обратное преобразование, относительно тех которые "читаются"
parent 7e4bf858
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
Name: libuniset Name: libuniset
Version: 1.0 Version: 1.0
Release: alt58 Release: alt59
Summary: UniSet - library for building distributed industrial control systems Summary: UniSet - library for building distributed industrial control systems
License: GPL License: GPL
Group: Development/C++ Group: Development/C++
...@@ -213,6 +213,9 @@ rm -f %buildroot%_libdir/*.la ...@@ -213,6 +213,9 @@ rm -f %buildroot%_libdir/*.la
%changelog %changelog
* Mon Dec 19 2011 Pavel Vainerman <pv@altlinux.ru> 1.0-alt59
- add precision for output variables
* Wed Nov 30 2011 Pavel Vainerman <pv@altlinux.ru> 1.0-alt58 * Wed Nov 30 2011 Pavel Vainerman <pv@altlinux.ru> 1.0-alt58
- fixed bug in ModbusSlave::readInputStatus(0x02) - fixed bug in ModbusSlave::readInputStatus(0x02)
......
...@@ -115,7 +115,7 @@ ...@@ -115,7 +115,7 @@
</item> </item>
<item id="7" iotype="DO" name="DO_C" priority="Medium" textname="Digital output"/> <item id="7" iotype="DO" name="DO_C" priority="Medium" textname="Digital output"/>
<item id="8" iotype="DO" name="DO1_C" priority="Medium" textname="Digital output"/> <item id="8" iotype="DO" name="DO1_C" priority="Medium" textname="Digital output"/>
<item id="9" default="10" iotype="AO" mbaddr="0x01" mbfunc="0x06" mbreg="0x02" mbtype="rtu" name="AO_AS" priority="Medium" rs="2" textname="Analog output"/> <item id="9" default="1000" iotype="AO" rs_mbaddr="0x01" rs_mbfunc="0x06" rs_mbreg="0x02" precision="2" rs_mbtype="rtu" name="AO_AS" priority="Medium" rs="2" textname="Analog output"/>
<item id="10" default="378" iotype="AI" mbaddr="0x01" mbfunc="0x04" mbreg="0x01" mbtype="rtu" name="AI_AS" precision="45" priority="Medium" rs="1" textname="Analog input" vtype="F2"> <item id="10" default="378" iotype="AI" mbaddr="0x01" mbfunc="0x04" mbreg="0x01" mbtype="rtu" name="AI_AS" precision="45" priority="Medium" rs="1" textname="Analog input" vtype="F2">
<consumers> <consumers>
<consumer cfilter="test1" name="TestProc" type="objects"/> <consumer cfilter="test1" name="TestProc" type="objects"/>
......
...@@ -6,10 +6,12 @@ uniset-start.sh -f ./uniset-rtuexchange --confile test.xml \ ...@@ -6,10 +6,12 @@ uniset-start.sh -f ./uniset-rtuexchange --confile test.xml \
--rs-name RTUExchange \ --rs-name RTUExchange \
--rs-speed 38400 \ --rs-speed 38400 \
--rs-filter-field rs \ --rs-filter-field rs \
--rs-filter-value 1 \ --rs-filter-value 2 \
--dlog-add-levels info,crit,warn,level4,level3 \ --dlog-add-levels info,crit,warn,level4,level3 \
--rs-force 0 \ --rs-force 0 \
--rs-force-out 0 \ --rs-force-out 0 \
--rs-polltime 3000 \ --rs-polltime 3000 \
--rs-set-prop-prefix rs_\
#,level3 #,level3
# --rs-force 1 \ # --rs-force 1 \
...@@ -286,9 +286,8 @@ long IOBase::processingAsAO( IOBase* it, SMInterface* shm, bool force ) ...@@ -286,9 +286,8 @@ long IOBase::processingAsAO( IOBase* it, SMInterface* shm, bool force )
else else
val = it->value; val = it->value;
/*! \todo Разобратся, нужно ли здесь учитывать Precision! */ if( !it->noprecision && it->cal.precision > 0 )
// if( it->cal.precision > 0 ) return lroundf( (float)it->value / pow10(it->cal.precision) );
// val = it->value / lround(pow10(it->cal.precision));
} }
} }
...@@ -349,7 +348,7 @@ float IOBase::processingFasAO( IOBase* it, SMInterface* shm, bool force ) ...@@ -349,7 +348,7 @@ float IOBase::processingFasAO( IOBase* it, SMInterface* shm, bool force )
cal->minCal, cal->maxCal, cal->minRaw, cal->maxRaw, true ); cal->minCal, cal->maxCal, cal->minRaw, cal->maxRaw, true );
} }
if( it->cal.precision > 0 ) if( !it->noprecision && it->cal.precision > 0 )
return ( fval / pow10(it->cal.precision) ); return ( fval / pow10(it->cal.precision) );
} }
} }
......
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