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 Base::m_ValueCacheValid =
false;
82 GCLOGINFOPUSH( Base::m_pValueLog,
"SetValue( %f )...", Value );
93 typename Base::PostSetValueFinalizer PostSetValueCaller(
this, CallbacksToFire);
99 Base::InternalSetValue(Value,
Verify);
101 #if ! defined( DISABLE_VALUE_CACHING ) || (DISABLE_VALUE_CACHING == 0) 106 Base::m_ValueCacheValid =
true;
107 Base::m_DontDeleteThisCache =
true;
113 Base::InternalCheckError();
118 std::list<CNodeCallback*>::iterator ptrCallback;
119 for( ptrCallback = CallbacksToFire.begin(); ptrCallback != CallbacksToFire.end(); ptrCallback++ )
126 std::list<CNodeCallback*>::iterator ptrCallback;
127 for( ptrCallback = CallbacksToFire.begin(); ptrCallback != CallbacksToFire.end(); ptrCallback++ )
169 while( isspace(c = *s) )
173 if ((sign = (c ==
'-')))
181 v = 10.0 * v + (*s++ -
'0');
192 v += (*s++ -
'0') / fr;
200 if (tolower(*s) ==
'e')
219 std::stringstream Buffer;
223 switch( Base::InternalGetDisplayNotation() )
229 Buffer.setf(std::ios::fixed, std::ios::floatfield);
230 CorrectedBuffer.setf(std::ios::fixed, std::ios::floatfield);
233 Buffer.setf(std::ios::scientific, std::ios::floatfield);
234 CorrectedBuffer.setf(std::ios::scientific, std::ios::floatfield);
236 #pragma BullseyeCoverage off 239 #pragma BullseyeCoverage on 244 Buffer.precision( Precision );
245 CorrectedBuffer.precision( Precision );
256 Buffer >> VerifyValue;
258 double CorrectedValue = Value;
259 bool LimitsExceeded =
false;
262 if( VerifyValue > Base::InternalGetMax() )
264 CorrectedValue = Value -
Correction( Buffer.str().c_str() );
265 LimitsExceeded =
true;
267 else if( VerifyValue < Base::InternalGetMin() )
269 CorrectedValue = Value +
Correction( Buffer.str().c_str() );
270 LimitsExceeded =
true;
276 CorrectedBuffer << CorrectedValue;
277 valueString = CorrectedBuffer.
str().c_str();
281 valueString = Buffer.str().
c_str();
290 typename Base::EntryMethodFinalizer E(
this,
meGetValue, IgnoreCache );
296 #if ! defined( DISABLE_VALUE_CACHING ) || (DISABLE_VALUE_CACHING == 0) 298 if (!IgnoreCache && Base::m_ValueCacheValid && !
Verify)
308 const double Value( Base::InternalGetValue(
Verify, IgnoreCache) );
310 GCLOGINFOPOP( Base::m_pValueLog,
"...GetValue = %f", Value );
315 Base::InternalCheckError();
318 #if ! defined( DISABLE_VALUE_CACHING ) || (DISABLE_VALUE_CACHING == 0) 325 Base::m_ValueCacheValid =
true;
360 typename Base::EntryMethodFinalizer E(
this,
meGetMin );
368 double Minimum = Base::InternalGetMin();
371 GCLOGINFOPOP( Base::m_pRangeLog,
"...GetMin = %f", Minimum );
381 typename Base::EntryMethodFinalizer E(
this,
meGetMax );
389 double Maximum(Base::InternalGetMax());
392 GCLOGINFOPOP( Base::m_pRangeLog,
"...GetMax = %f", Maximum );
405 bool HasInc( Base::InternalHasInc() );
406 #pragma BullseyeCoverage off 408 #pragma BullseyeCoverage on 417 typename Base::EntryMethodFinalizer E(
this,
meGetIncMode );
421 if( ! Base::m_ListOfValidValuesCacheValid )
424 Base::m_ListOfValidValuesCacheValid =
true;
438 typename Base::EntryMethodFinalizer E(
this,
meGetInc );
440 if( !Base::InternalHasInc() )
449 double Inc( Base::InternalGetInc() );
451 GCLOGINFOPOP( Base::m_pRangeLog,
"...GetInc = %f", Inc );
462 GCLOGINFOPUSH( Base::m_pRangeLog,
"GetListOfValidValues...");
463 if( ! Base::m_ListOfValidValuesCacheValid )
466 Base::m_ListOfValidValuesCacheValid =
true;
472 GCLOGINFOPOP( Base::m_pRangeLog,
"...GetListOfValidValues" );
483 return Base::InternalGetRepresentation();
490 return Base::InternalGetUnit();
497 return Base::InternalGetDisplayNotation();
505 int64_t Precision = Base::InternalGetDisplayPrecision();
507 if( Precision == -1 )
510 std::stringstream Buffer;
511 switch( Base::InternalGetDisplayNotation() )
514 Buffer.setf(std::ios::fixed, std::ios::floatfield);
517 Buffer.setf(std::ios::scientific, std::ios::floatfield);
522 #pragma BullseyeCoverage off 525 #pragma BullseyeCoverage on 528 Precision = Buffer.precision();
563 #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,...)
GENICAM_INTERFACE GENAPI_DECL_ABSTRACT bool Verify
#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.
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.
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
GENICAM_INTERFACE GENAPI_DECL_ABSTRACT IFloat
Interface for float properties.
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()()
Lexical analyzer for CIntSwissKnife.
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.