EPICS ARCHIVER V4
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups
Public Types | Static Public Member Functions | List of all members
RawValue Class Reference

Helper class for raw dbr_time_xxx values. More...

#include <RawValue.h>

Public Types

enum  NumberFormat { DEFAULT, DECIMAL, ENGINEERING, EXPONENTIAL }
 Used by getValueString. More...
 
typedef dbr_time_double Data
 Type for accessing the raw data and its common fields. More...
 

Static Public Member Functions

static Dataallocate (DbrType type, DbrCount count, size_t num)
 Allocate space (via calloc) for num samples of type/count. More...
 
static void free (Data *value)
 Free space for num samples of type/count.
 
static size_t getSize (DbrType type, DbrCount count)
 Calculate size of a single value of type/count.
 
static bool equal (DbrType type, DbrCount count, const Data *lhs, const Data *rhs)
 Are two values equal?
 
static bool hasSameValue (DbrType type, DbrCount count, size_t size, const Data *lhs, const Data *rhs)
 Compare the value part of two RawValues, not the time stamp or status! (for full comparison, use equal()). More...
 
static bool hasSameValue (DbrType type, DbrCount count, const Data *lhs, const Data *rhs)
 Compare the value part of two RawValues, not the time stamp or status!
 
static void copy (DbrType type, DbrCount count, Data *lhs, const Data *rhs)
 Full copy (stat, time, value). Only valid for Values of same type.
 
static short getStat (const Data *value)
 Get status.
 
static short getSevr (const Data *value)
 Get severity.
 
static void getStatus (const Data *value, std::string &status)
 Get status/severity as string.
 
static bool isInfo (const Data *value)
 Does the severity represent one of the special ARCH_xxx values that does not carry any value.
 
static bool isAboveZero (DbrType type, const Data *value)
 Check the value to see if it's above zero. More...
 
static void setStatus (Data *value, short status, short severity)
 Set status and severity.
 
static bool parseStatus (const std::string &text, short &stat, short &sevr)
 Parse stat/sevr from text.
 
static const epicsTime getTime (const Data *value)
 Get time stamp.
 
static void getTime (const Data *value, std::string &time)
 Get time stamp as text.
 
static void setTime (Data *value, const epicsTime &stamp)
 Set time stamp.
 
static bool getDouble (DbrType type, DbrCount count, const Data *value, double &d, int i=0)
 Get data as a double or return false. More...
 
static bool getLong (DbrType type, DbrCount count, const Data *value, long &l, int i=0)
 Get data as a long or return false. More...
 
static bool setDouble (DbrType type, DbrCount count, Data *value, double d)
 Set data from a double or return false. More...
 
static size_t formatDouble (double number, NumberFormat format, int prec, char *buffer, size_t max_len)
 Concert value to buffer.
 
static void getValueString (std::string &text, DbrType type, DbrCount count, const Data *value, const class CtrlInfo *info=0, NumberFormat format=DECIMAL, int prec=-1)
 Convert value to txt, using CtrlInfo if available. More...
 
static void toString (std::string &text, DbrType type, DbrCount count, const Data *value, const class CtrlInfo *info=0)
 Convert current value to string. More...
 
static void show (FILE *file, DbrType type, DbrCount count, const Data *value, const class CtrlInfo *info=0)
 Display value, using CtrlInfo if available.
 

Detailed Description

Helper class for raw dbr_time_xxx values.

This class has all static methods, it always requires a hint for type, count and maybe CtrlInfo to properly handle the underlying value. The class also doesn't hold the actual memory of the value, since that might be in the argument of a CA event callback etc.

Member Typedef Documentation

typedef dbr_time_double RawValue::Data

Type for accessing the raw data and its common fields.

(status, severity, time) w/o compiler warnings. Had to pick one of the dbr_time_xxx

Member Enumeration Documentation

Used by getValueString.

Enumerator
DEFAULT 

Decimal or exponential, "%g" format.

DECIMAL 

Decimal notation, 0.000.

ENGINEERING 

Exponential 0.000e000 with exponent = 3*N.

EXPONENTIAL 

Exponential notation.

Member Function Documentation

static Data* RawValue::allocate ( DbrType  type,
DbrCount  count,
size_t  num 
)
static

Allocate space (via calloc) for num samples of type/count.

Exceptions
GenericExceptionon memory error.
static bool RawValue::getDouble ( DbrType  type,
DbrCount  count,
const Data value,
double &  d,
int  i = 0 
)
static

Get data as a double or return false.

Works for scalar short, int, long, float, double

static bool RawValue::getLong ( DbrType  type,
DbrCount  count,
const Data value,
long &  l,
int  i = 0 
)
static

Get data as a long or return false.

Works for scalar enum, short, int, long, float, double

static void RawValue::getValueString ( std::string &  text,
DbrType  type,
DbrCount  count,
const Data value,
const class CtrlInfo info = 0,
NumberFormat  format = DECIMAL,
int  prec = -1 
)
static

Convert value to txt, using CtrlInfo if available.

This gives only the value. Use getTime() and getStatus() for time and status. format picks the format, prec < 0 means: Use precision from CtrlInfo.

static bool RawValue::hasSameValue ( DbrType  type,
DbrCount  count,
size_t  size,
const Data lhs,
const Data rhs 
)
static

Compare the value part of two RawValues, not the time stamp or status! (for full comparison, use equal()).

Both lhs, rhs must have the same type.

static bool RawValue::isAboveZero ( DbrType  type,
const Data value 
)
static

Check the value to see if it's above zero.

For numerics, that's obvious: value>0. Enums are treated like integers, strings are 'zero' if empty (zero length). Arrays are not really handled, we only consider the first element.

static bool RawValue::setDouble ( DbrType  type,
DbrCount  count,
Data value,
double  d 
)
static

Set data from a double or return false.

Works for scalar short, int, long, float, double

static void RawValue::toString ( std::string &  text,
DbrType  type,
DbrCount  count,
const Data value,
const class CtrlInfo info = 0 
)
static

Convert current value to string.

Formatted as "<time><tab><value><tab>status" or just "<time><tab><value>" if the status is empty.


The documentation for this class was generated from the following file: