Commit 5f9d11d5 authored by Pavel Vainerman's avatar Pavel Vainerman

(Calibration): добавил функции getMinRaw(),getMaxRaw(),getMinVal(),getMaxVal()

а также параметр crop_result в функции getRawValue()
parent c6e29a5d
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
Name: libuniset Name: libuniset
Version: 1.5 Version: 1.5
Release: alt2 Release: alt3
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++
...@@ -211,6 +211,9 @@ rm -f %buildroot%_libdir/*.la ...@@ -211,6 +211,9 @@ rm -f %buildroot%_libdir/*.la
%exclude %_pkgconfigdir/libUniSet.pc %exclude %_pkgconfigdir/libUniSet.pc
%changelog %changelog
* Thu Nov 22 2012 Pavel Vainerman <pv@altlinux.ru> 1.5-alt3
- (Calibration): add getMinRaw(),getMaxRaw(),getMinVal(),getMaxVal()
* Wed Nov 21 2012 Pavel Vainerman <pv@altlinux.ru> 1.5-alt2 * Wed Nov 21 2012 Pavel Vainerman <pv@altlinux.ru> 1.5-alt2
- new ConfirmMessage format (eterbug #8842) - new ConfirmMessage format (eterbug #8842)
......
...@@ -40,11 +40,20 @@ class Calibration ...@@ -40,11 +40,20 @@ class Calibration
*/ */
long getValue( long raw, bool crop_raw=false ); long getValue( long raw, bool crop_raw=false );
inline long getMinVal(){ return minVal; }
inline long getMaxVal(){ return maxVal; }
/*! /*!
Получение сырого значения по калиброванному Получение сырого значения по калиброванному
\param crop - обрезать значение по крайним точкам,
если результат < minRaw или > maxRaw
Если crop_result=false, то может быть возвращено значение outOfRange.
*/ */
long getRawValue( long cal ); long getRawValue( long cal, bool crop_result=false );
inline long getMinRaw(){ return minRaw; }
inline long getMaxRaw(){ return maxRaw; }
/*! построение характеристрики из конф. файла /*! построение характеристрики из конф. файла
...@@ -131,6 +140,8 @@ class Calibration ...@@ -131,6 +140,8 @@ class Calibration
// список надо отсортировать по x! // список надо отсортировать по x!
typedef std::list<Part> PartsList; typedef std::list<Part> PartsList;
long minRaw, maxRaw, minVal, maxVal;
private: private:
PartsList plist; PartsList plist;
std::string myname; std::string myname;
......
...@@ -94,6 +94,7 @@ Calibration::TypeOfValue Calibration::Part::calcX( TypeOfValue y ) ...@@ -94,6 +94,7 @@ Calibration::TypeOfValue Calibration::Part::calcX( TypeOfValue y )
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
Calibration::Calibration(): Calibration::Calibration():
minRaw(0),maxRaw(0),minVal(0),maxVal(0),
myname("") myname("")
{ {
} }
...@@ -101,13 +102,15 @@ myname("") ...@@ -101,13 +102,15 @@ myname("")
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
Calibration::Calibration( const string name, const string confile ): Calibration::Calibration( const string name, const string confile ):
minRaw(0),maxRaw(0),minVal(0),maxVal(0),
myname(name) myname(name)
{ {
build(name,confile,0); build(name,confile,0);
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
Calibration::Calibration( xmlNode* node ) Calibration::Calibration( xmlNode* node ):
minRaw(0),maxRaw(0),minVal(0),maxVal(0)
{ {
UniXML_iterator it(node); UniXML_iterator it(node);
myname = it.getProp("name"); myname = it.getProp("name");
...@@ -168,6 +171,16 @@ void Calibration::build( const string name, const string confile, xmlNode* root ...@@ -168,6 +171,16 @@ void Calibration::build( const string name, const string confile, xmlNode* root
// cout << myname << "(Calibration::build):" // cout << myname << "(Calibration::build):"
// << "\tadd x=" << p.x << " y=" << p.y << endl; // << "\tadd x=" << p.x << " y=" << p.y << endl;
if( p.y > maxRaw )
maxRaw = p.y;
else if( p.y < minRaw )
minRaw = p.y;
if( p.x > maxVal )
maxVal = p.x;
else if( p.x < minVal )
minVal = p.x;
if( prev ) if( prev )
{ {
// cout << myname << "(Calibration::build):" // cout << myname << "(Calibration::build):"
...@@ -223,7 +236,7 @@ long Calibration::getValue( long raw, bool crop_raw ) ...@@ -223,7 +236,7 @@ long Calibration::getValue( long raw, bool crop_raw )
return it->calcY(raw); return it->calcY(raw);
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
long Calibration::getRawValue( long cal ) long Calibration::getRawValue( long cal, bool crop_cal )
{ {
for( PartsList::iterator it=plist.begin(); it!=plist.end(); ++it ) for( PartsList::iterator it=plist.begin(); it!=plist.end(); ++it )
{ {
......
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