16 #ifndef DABC_Parameter
17 #define DABC_Parameter
81 virtual bool HasField(
const std::string &name)
const
115 bool _CalcRate(
double& value, std::string& svalue);
121 void SetSynchron(
bool on,
double interval = 1.,
bool everyevnt =
false);
145 virtual const char*
ClassName()
const {
return "Parameter"; }
147 const std::string &
Kind()
const;
190 tgt =
dynamic_cast<T*
>(src);
191 if (!tgt)
return false;
193 if (!refkind)
return true;
194 return tgt->Kind() == refkind;
274 const std::string
Kind()
const;
338 std::string
ArgName(
int n)
const;
350 int FindArg(
const std::string &name)
const;
354 bool GetArg(
int n, std::string& name, std::string& kind,
bool& required, std::string& dflt)
const;
#define DABC_REFERENCE(RefClass, ParentClass, T)
Command definition class.
int FindArg(const std::string &name) const
CommandDefinition & SetArgMinMax(const std::string &name, const RecordField &min, const RecordField &max)
bool HasArg(const std::string &name) const
std::string ArgName(int n) const
Command MakeCommand() const
Create command according command definition, all default and required parameters will be specified.
bool GetArg(int n, std::string &name, std::string &kind, bool &required, std::string &dflt) const
CommandDefinition & AddArg(const std::string &name, const std::string &kind="string", bool required=true, const RecordField &dflt=RecordField())
Represents command with its arguments.
Special info parameter class.
void SetVerbosity(int level)
virtual const char * ParReferenceKind()
void SetInfo(const std::string &info)
static const char * infokind()
std::string GetInfo() const
void SetColor(const std::string &name)
std::string GetColor() const
Lock guard for posix mutex.
Manager of everything in DABC
Base class for most of the DABC classes.
Mutex * ObjectMutex() const
Returns mutex, used for protection of Object data members.
virtual void BuildFieldsMap(RecordFieldsMap *cont)
Fill fields map, which is relevant for the object Objects hierarchy produced from dabc::Manager.
Container for parameter object.
void SetSynchron(bool on, double interval=1., bool everyevnt=false)
Specifies that parameter produce 'modified' events synchronous with changes of parameter.
double fInterval
how often modified events are produced TODO: should we move it in the normal record field?
virtual void ObjectCleanup()
User method to cleanup object content before it will be destroyed Main motivation is to release any r...
bool fDeliverAllEvents
if true, any modification event will be delivered, default off
unsigned ConfirmFromWorker()
Get confirmation from worker, which monitor parameters changes.
const std::string GetActualUnits() const
int fRateWidth
display width of rate variable
double fRateValueSum
sum of values
virtual void BuildFieldsMap(RecordFieldsMap *cont)
Save parameter attributes into container.
TimeStamp fLastChangeTm
last time when parameter was modified
int fRatePrec
display precision of rate variable
void ProcessTimeout(double last_dif)
Method called from manager thread when parameter configured as asynchronous.
virtual std::string FieldName(unsigned cnt) const
bool fMonitored
if true parameter change event will be delivered to the worker
virtual ~ParameterContainer()
ParameterContainer(Reference worker, const std::string &name, const std::string &parkind="", bool hidden=false)
Worker * GetWorker() const
bool fAsynchron
indicates if parameter can produce events asynchronous to the modification of parameter itself it is ...
bool IsDeliverAllEvents() const
If true, all events must be delivered to the consumer.
virtual const char * ClassName() const
Returns class name of the object instance.
virtual bool HasField(const std::string &name) const
void FireModified(const std::string &svalue)
Internal method, used to inform system that parameter is modified If configured, also debug output wi...
int GetDebugLevel() const
double fRateNumSum
sum of accumulated counts
virtual std::string DefaultFiledName() const
bool fRecorded
if true, parameter changes should be reported to worker where it will be recorded
bool fWaitWorker
if true, waiting confirmation from worker
const std::string & Kind() const
virtual RecordField GetField(const std::string &name) const
virtual bool RemoveField(const std::string &name)
virtual unsigned NumFields() const
void FireParEvent(int id)
virtual bool SetField(const std::string &name, const RecordField &v)
bool _CalcRate(double &value, std::string &svalue)
bool fAttrModified
indicate if attribute was modified since last parameter event
virtual bool _CanChangeField(const std::string &)
Method allows in derived classes to block changes of some fields.
double fRateTimeSum
sum of time
EStatistic fStatistic
indicates if statistic is calculated: 0 - off, 1 - rate, 2 - average
std::string fKind
specified kind of parameter (int, double, info, ratemeter), to be used by reference to decide if obje...
bool TakeAttrModified()
Returns true if any parameter attribute was modified since last call to this method.
Parameter & SetMonitored(bool on=true)
Specify if parameter event should be delivered to the worker.
Parameter & DisableRatemeter()
Disable ratemeter functionality.
bool Dflt(const RecordField &v)
Set default parameter value.
void FireConfigured()
Fire parConfigured event for parameter.
bool SetValue(const RecordField &v)
Set parameter value.
Parameter & SetWidthPrecision(unsigned width, unsigned prec)
Set parameter to convert double values to the string - used for ratemeter.
RecordField Value() const
Returns parameter value.
double GetUpperLimit() const
Parameter & SetAverage(bool synchron=false, double interval=1.0)
Converts parameter in statistic variable.
int ExecuteChange(Command cmd)
Specifies that parameter produce 'modified' events synchronous with changes of parameter.
void ScanParamFields(RecordFieldsMap *cont)
Parameter & SetLimits(double low, double up)
double GetLowerLimit() const
bool SubmitSetValue(const RecordField &v)
bool IsAverage() const
Returns true if average calculation is active.
Parameter & SetFld(const std::string &name, const RecordField &v)
bool IsMonitored()
Returns true when parameter event should be delivered to the worker.
void SetLowerLimit(double low)
const std::string GetActualUnits() const
Return actual units of parameter value, taking into account rate (1/s) unit when enabled.
bool IsRatemeter() const
Returns true if rate measurement is activated.
bool NeedTimeout()
Returns true if parameter object requires timeout processing.
Parameter & SetUnits(const std::string &unit)
Set units field of parameter.
const std::string GetUnits() const
Return units of parameter value.
virtual const char * ParReferenceKind()
int GetDebugLevel() const
Parameter & SetRatemeter(bool synchron=false, double interval=1.0)
Converts parameter in ratemeter - all values will be summed up and divided on specified interval.
Parameter & SetDebugOutput(bool on=true, int level=1)
Enable/disable debug output when parameter value is changed.
Parameter & DisableAverage()
Disables averaging functionality.
void SetUpperLimit(double up)
Reference GetWorker() const
Returns reference on the worker.
const std::string Kind() const
Parameter & SetSynchron(bool on, double interval=1., bool everyevnt=false)
Indicate if parameter is should generate events synchron with code which modified it.
Parameter & SetDebugLevel(int level=1)
void FireModified()
Can be called by user to signal framework that parameter was modified.
bool verify_object(Object *src, T *&tgt)
Method used in reference constructor/assignments to verify is object is suitable.
Container for records fields.
virtual bool HasField(const std::string &name) const
virtual bool RemoveField(const std::string &name)
virtual std::string FieldName(unsigned cnt) const
virtual unsigned NumFields() const
std::string AsStr(const std::string &dflt="") const
int64_t AsInt(int64_t dflt=0) const
double AsDouble(double dflt=0.) const
RecordField GetField(const std::string &name) const
bool SetField(const std::string &name, const RecordField &v)
Reference on the arbitrary object
Object * GetObject() const
Return pointer on the object.
Active object, which is working inside dabc::Thread.
@ parConfigured
event only for manager, used to react on reconfiguration of parameter
@ parCreated
produced once when parameter is created
@ parModified
produced when parameter value modified. Either every change or after time interval (default = 1 sec)
@ parDestroy
produced once when parameter is destroyed
Class for acquiring and holding timestamps.