31 #ifndef GENAPI_FLOATT_H 32 #define GENAPI_FLOATT_H 35 #include "../NodeCallback.h" 38 #include "../Counter.h" 40 #include "GenApi/impl/Log.h" 49 # pragma warning( disable : 4706 ) // assignment within conditional expression 75 std::list<CNodeCallback*> CallbacksToFire;
78 typename Base::EntryMethodFinalizer E(
this,
meSetValue );
80 GCLOGINFOPUSH( Base::m_pValueLog,
"SetValue( %f )...", Value );
91 typename Base::PostSetValueFinalizer PostSetValueCaller(
this, CallbacksToFire);
97 Base::InternalSetValue(Value,
Verify);
100 Base::InternalCheckError();
102 #if ! defined( DISABLE_VALUE_CACHING ) || (DISABLE_VALUE_CACHING == 0) 107 Base::m_ValueCacheValid =
true;
108 Base::m_DontDeleteThisCache =
true;
117 std::list<CNodeCallback*>::iterator ptrCallback;
118 for( ptrCallback = CallbacksToFire.begin(); ptrCallback != CallbacksToFire.end(); ptrCallback++ )
125 std::list<CNodeCallback*>::iterator ptrCallback;
126 for( ptrCallback = CallbacksToFire.begin(); ptrCallback != CallbacksToFire.end(); ptrCallback++ )
168 while( isspace(c = *s) )
172 if ((sign = (c ==
'-')))
180 v = 10.0 * v + (*s++ -
'0');
191 v += (*s++ -
'0') / fr;
199 if (tolower(*s) ==
'e')
218 std::stringstream Buffer;
222 switch( Base::InternalGetDisplayNotation() )
228 Buffer.setf(std::ios::fixed, std::ios::floatfield);
229 CorrectedBuffer.setf(std::ios::fixed, std::ios::floatfield);
232 Buffer.setf(std::ios::scientific, std::ios::floatfield);
233 CorrectedBuffer.setf(std::ios::scientific, std::ios::floatfield);
235 #pragma BullseyeCoverage off 238 #pragma BullseyeCoverage on 243 Buffer.precision( Precision );
244 CorrectedBuffer.precision( Precision );
255 Buffer >> VerifyValue;
257 double CorrectedValue = Value;
258 bool LimitsExceeded =
false;
261 if( VerifyValue > Base::InternalGetMax() )
263 CorrectedValue = Value -
Correction( Buffer.str().c_str() );
264 LimitsExceeded =
true;
266 else if( VerifyValue < Base::InternalGetMin() )
268 CorrectedValue = Value +
Correction( Buffer.str().c_str() );
269 LimitsExceeded =
true;
275 CorrectedBuffer << CorrectedValue;
276 valueString = CorrectedBuffer.
str().c_str();
280 valueString = Buffer.str().
c_str();
289 typename Base::EntryMethodFinalizer E(
this,
meGetValue, IgnoreCache );
295 #if ! defined( DISABLE_VALUE_CACHING ) || (DISABLE_VALUE_CACHING == 0) 297 if (!IgnoreCache && Base::m_ValueCacheValid && !
Verify)
307 const double Value( Base::InternalGetValue(
Verify, IgnoreCache) );
309 GCLOGINFOPOP( Base::m_pValueLog,
"...GetValue = %f", Value );
314 Base::InternalCheckError();
317 #if ! defined( DISABLE_VALUE_CACHING ) || (DISABLE_VALUE_CACHING == 0) 324 Base::m_ValueCacheValid =
true;
359 typename Base::EntryMethodFinalizer E(
this,
meGetMin );
367 double Minimum = Base::InternalGetMin();
370 GCLOGINFOPOP( Base::m_pRangeLog,
"...GetMin = %f", Minimum );
380 typename Base::EntryMethodFinalizer E(
this,
meGetMax );
388 double Maximum(Base::InternalGetMax());
391 GCLOGINFOPOP( Base::m_pRangeLog,
"...GetMax = %f", Maximum );
404 bool HasInc( Base::InternalHasInc() );
405 #pragma BullseyeCoverage off 407 #pragma BullseyeCoverage on 416 typename Base::EntryMethodFinalizer E(
this,
meGetIncMode );
420 if( ! Base::m_ListOfValidValuesCacheValid )
423 Base::m_ListOfValidValuesCacheValid =
true;
437 typename Base::EntryMethodFinalizer E(
this,
meGetInc );
439 if( !Base::InternalHasInc() )
448 double Inc( Base::InternalGetInc() );
450 GCLOGINFOPOP( Base::m_pRangeLog,
"...GetInc = %f", Inc );
461 GCLOGINFOPUSH( Base::m_pRangeLog,
"GetListOfValidValues...");
462 if( ! Base::m_ListOfValidValuesCacheValid )
465 Base::m_ListOfValidValuesCacheValid =
true;
471 GCLOGINFOPOP( Base::m_pRangeLog,
"...GetListOfValidValues" );
482 return Base::InternalGetRepresentation();
489 return Base::InternalGetUnit();
496 return Base::InternalGetDisplayNotation();
504 int64_t Precision = Base::InternalGetDisplayPrecision();
506 if( Precision == -1 )
509 std::stringstream Buffer;
510 switch( Base::InternalGetDisplayNotation() )
513 Buffer.setf(std::ios::fixed, std::ios::floatfield);
516 Buffer.setf(std::ios::scientific, std::ios::floatfield);
521 #pragma BullseyeCoverage off 524 #pragma BullseyeCoverage on 527 Precision = Buffer.precision();
562 #endif // GENAPI_FLOATT_H
Definition of value2string and string2value functions.
virtual void InternalFromString(const GENICAM_NAMESPACE::gcstring &ValueStr, bool Verify=true)
Set value of the node as string.
virtual void SetValue(double Value, bool Verify=true)
Implementation of IFloat::SetValue()
virtual double GetMax()
Implementation of IFloat::GetMax()
const _autovector_impl duplicate(T min, T max)
#define RUNTIME_EXCEPTION_NODE
Fires a runtime exception, e.g. throw RUNTIME_EXCEPTION("buh!")
virtual int64_t GetDisplayPrecision() const
Get the DisplayPrecision to be used when converting the float to a string.
virtual GENICAM_NAMESPACE::gcstring GetUnit() const
Implementation of IFloat::GetUnit()
#define GCLOGINFO(cat,...)
#define CHECK_RANGE_FLT_NODE(_Value, _Min, _Max)
Range check for float.
Vector of doubles with reference counting.
virtual EIncMode GetIncMode()
double_autovector_impl m_CurentValidValueSet
The cached list of valie value for the integer.
virtual IFloat & operator=(double Value)
Implementation of IFloat::operator=()
virtual double GetValue(bool Verify=false, bool IgnoreCache=false)
Implementation of IFloat::GetValue()
bool IsReadable(EAccessMode AccessMode)
Tests if readable.
interface GENAPI_DECL_ABSTRACT IFloat
Interface for float properties.
the notation is scientific, e.g. 1.234e2
virtual bool HasInc()
True if the float has a constant increment.
#define INVALID_ARGUMENT_EXCEPTION_NODE
Fires an invalid argument exception, e.g. throw INVALID_ARGUMENT("%ld too large", Value);...
bool IsAvailable(EAccessMode AccessMode)
Tests if available.
Write to cache and register.
double m_ImposedMin
a Value imposed to the minimum
enum GENAPI_NAMESPACE::_ERepresentation ERepresentation
recommended representation of a node value
enum GENAPI_NAMESPACE::_ECachingMode ECachingMode
caching mode of a register
enum GENAPI_NAMESPACE::_EDisplayNotation EDisplayNotation
typedef for float notation
double m_ValueCache
The cache for the float value.
Write to register, write to cache on read.
#define ACCESS_EXCEPTION_NODE
Fires a access error exception, e.g. throw ACCESS_ERROR_EXCEPTION("Not everybody") ...
Invalidate the node and all of its dependents.
interface GENAPI_DECL_ABSTRACT bool Verify
virtual EDisplayNotation GetDisplayNotation() const
Get the way the float should be converted to a string.
#define GCLOGINFOPUSH(cat,...)
This file contains the internal implementation of the autovector.
virtual double_autovector_t GetListOfValidValues(bool bounded=true)
Get list of valid value.
double m_ImposedMax
a Value imposed to the maximum
virtual double GetMin()
Implementation of IFloat::GetMin()
A string class which is a clone of std::string.
double Correction(const char *s)
the notation if either scientific or fixed depending on what is shorter
virtual ECachingMode GetCachingMode() const =0
Get Caching Mode.
bool IsWritable(EAccessMode AccessMode)
Tests if writable.
virtual void SetInvalid(ESetInvalidMode simMode)=0
Invalidate the node resp. the node and all of its dependents.
enum GENAPI_NAMESPACE::_EIncMode EIncMode
typedef for increment mode
Implementation of the IFloat Interface.
virtual void ImposeMin(double Value)
Restrict minimum value.
virtual double operator*()
Implementation of IFloat::operator*()
#define GCLOGINFOPOP(cat,...)
virtual void ImposeMax(double Value)
Restrict maximum value.
virtual double GetInc()
Get the constant increment if there is any.
virtual ERepresentation GetRepresentation()
Implementation of IFloat::GetRepresentation()
virtual const char * c_str(void) const
virtual double operator()()
Implementation of IFloat::operator()()
Part of the generic device API.
Definition of interface INodePrivate.
callback is fired on leaving the tree inside the lock-guarded area
the notation is fixed, e.g. 123.4
virtual CLock & GetLock() const =0
Returns the lock which guards the node map.
bool String2Value(const GENICAM_NAMESPACE::gcstring &ValueStr, T *Value)
Converts a string to an T property.
virtual GENICAM_NAMESPACE::gcstring InternalToString(bool Verify=false, bool IgnoreCache=false)
Get value of the node as string.