OpcUaCanOpen
CANopen OPC-UA server
AddressSpace::UaCalcItem Class Reference

This class ensure a value which calculates from input variable based on analytic formula. More...

#include <UaCalcItem.h>

Inherits AddressSpace::UaControlVariable, and AddressSpace::UaControlVariable.

Public Types

typedef map< std::string, UaControlVariable * > variableSet
 
typedef map< std::string, UaControlVariable * > variableSet
 

Public Member Functions

virtual void calculateOnChange (Session *pSession, const UaDataValue &dataValue, OpcUa_Boolean checkAccessLevel)
 type of set of variable for formula More...
 
virtual void initCalculation ()
 initial calculation after startup More...
 
 UaCalcItem (const UaString &name, UaNodeId &uaId, const UaNode *parent, NmBuildingAutomation *pNodeConfig, UaVariant &dv, ITEM &citem, UaControlVariableMap &cvs, UaMutexRefCounted *pSharedMutex)
 Constructor. More...
 
bool compile ()
 
virtual ~UaCalcItem (void)
 destructor More...
 
bool pushDataVariable (const string &name, UaControlVariable *obd)
 Connect to the input object. More...
 
bool pushConditionVariable (const string &name, UaControlVariable *obd)
 Connect to the object using in conditional formula. More...
 
bool pushStatusVariable (const string &name, UaControlVariable *obd)
 Connect to the object using in conditional formula. More...
 
bool fExists ()
 
void replaceAll (std::string &str, const std::string &from, const std::string &to)
 
bool checkDouble (const string &str, double &res)
 
OpcUa_StatusCode checkStatus (variableSet &vs)
 
virtual void calculateOnChange (Session *pSession, const UaDataValue &dataValue, OpcUa_Boolean checkAccessLevel)
 type of set of variable for formula More...
 
virtual void initCalculation ()
 initial calculation after startup More...
 
 UaCalcItem (const UaString &name, UaNodeId &uaId, const UaNode *parent, NmBuildingAutomation *pNodeConfig, UaVariant &dv, ITEM &citem, UaControlVariableMap &cvs, UaMutexRefCounted *pSharedMutex)
 Constructor. More...
 
virtual ~UaCalcItem (void)
 destructor More...
 
void pushDataVariable (std::string &name, UaControlVariable *obd)
 Connect to the input object. More...
 
void pushConditionVariable (std::string &name, UaControlVariable *obd)
 Connect to the object using in conditional formula. More...
 
void pushStatusVariable (std::string &name, UaControlVariable *obd)
 Connect to the object using in conditional formula. More...
 
OpcUa_StatusCode checkStatus (variableSet &vs)
 
string & getFormula ()
 
string & getWhenCondition ()
 
string & getStatusCondition ()
 
- Public Member Functions inherited from AddressSpace::UaControlVariable
 UaControlVariable (UaNode *cur, NmBuildingAutomation *pNodeManager, UaVariable *instance, UaMutexRefCounted *pSharedMutex)
 Constructor. More...
 
 UaControlVariable (const UaString &name, const UaNodeId &newNodeId, NmBuildingAutomation *pNodeManager, UaVariant &dv, UaMutexRefCounted *pSharedMutex)
 
virtual ~UaControlVariable ()
 
virtual UaStatus write (UaDataValue &udv)
 
virtual UaStatus read ()
 
virtual UaStatus setValue (Session *pSession, const UaDataValue &dataValue, OpcUa_Boolean checkAccessLevel)
 Redefine setValue function to sent data change signal;. More...
 
virtual UaStatus setValueOnChange (Session *pSession, const UaDataValue &dataValue, OpcUa_Boolean checkAccessLevel)
 Redefine setValue function to sent data change signal;. More...
 
virtual void connectItem (UaControlVariable *item)
 
virtual UaNodeId typeDefinitionId () const
 
virtual void setTypeDefinition (UaNodeId uni)
 set node id of type of variable More...
 
void convertToDouble (const UaDataValue &dataValue)
 Signal. More...
 
 UaControlVariable (UaNode *cur, NmBuildingAutomation *pNodeManager, UaVariable *instance, UaMutexRefCounted *pSharedMutex)
 Constructor. More...
 
 UaControlVariable (const UaString &name, const UaNodeId &newNodeId, NmBuildingAutomation *pNodeManager, UaVariant &dv, UaMutexRefCounted *pSharedMutex)
 
virtual ~UaControlVariable ()
 
virtual UaStatus write (UaDataValue &udv)
 
virtual UaStatus read ()
 
virtual UaStatus setValue (Session *pSession, const UaDataValue &dataValue, OpcUa_Boolean checkAccessLevel)
 Redefine setValue function to sent data change signal;. More...
 
virtual UaStatus setValueOnChange (Session *pSession, const UaDataValue &dataValue, OpcUa_Boolean checkAccessLevel)
 Redefine setValue function to sent data change signal;. More...
 
virtual void connectItem (UaControlVariable *item)
 
virtual UaNodeId typeDefinitionId () const
 
virtual void setTypeDefinition (UaNodeId uni)
 set node id of type of variable More...
 
void convertToDouble (const UaDataValue &dataValue)
 Signal. More...
 

Static Public Member Functions

static mu::value_typegetValueFromItem (const mu::char_type *ind, void *pNode)
 bind function which calculator uses to take data from OpcUa variable More...
 
static mu::value_typegetValueFromWhenItem (const mu::char_type *ind, void *pNode)
 
static mu::value_typegetValueFromStatusItem (const mu::char_type *ind, void *pNode)
 
static double PowFunc (double a_fVal, double b_fVal)
 

Public Attributes

const OpcUa::BaseObjectType * m_pParent
 
NmBuildingAutomationm_pNodeManager
 status logical formula More...
 
- Public Attributes inherited from AddressSpace::UaControlVariable
boost::signals2::signal< void(Session *pSession, const UaDataValue &dataValue, OpcUa_Boolean checkAccessLevel) > valueChange
 write date to hardware More...
 
OpcUa_Double curValue
 

Private Member Functions

 UA_DISABLE_COPY (UaCalcItem)
 
 UA_DISABLE_COPY (UaCalcItem)
 

Private Attributes

expression_t m_formul
 
bind function which calculator uses to take data from OpcUa variable More...
 
expression_t m_whenCondition
 
expression_t m_statusFormula
 
symbol_table_t m_formul_table
 
parser_t parser_d
 
parser_t parser_b
 
parser_t parser_i
 
string m_sFormul
 variables using in status formula More...
 
string m_sWhenCondition
 formula in text form More...
 
string m_sStatusCondition
 condition formula More...
 
bool m_fExists
 status logical formula More...
 
bool m_cExists
 
bool m_sExists
 
variableSet m_whenVar
 
variableSet m_var
 variable using in condition formula More...
 
variableSet m_statusVar
 variables using in formula More...
 
mu::Parser m_whenCondition
 
mu::Parser m_formul
 logical formula if it s true the calculation will be executed More...
 
mu::Parser m_statusFormula
 analytic formula to calculate More...
 
const UaNode * m_pParent
 

Detailed Description

This class ensure a value which calculates from input variable based on analytic formula.

The calculation item takes value when the logical condition formula becomes true.
When the value of control variable is changed it send the signal to this class.
The callback function "calculateOnChange" first of all checks th "when condition" and if it is true calculate the value.

Definition at line 65 of file UaCalcItem.h.

Member Typedef Documentation

◆ variableSet [1/2]

Definition at line 61 of file UaCalcItem.hpp.

◆ variableSet [2/2]

Definition at line 70 of file UaCalcItem.h.

Constructor & Destructor Documentation

◆ UaCalcItem() [1/2]

AddressSpace::UaCalcItem::UaCalcItem ( const UaString &  name,
UaNodeId &  uaId,
const UaNode *  parent,
NmBuildingAutomation pNodeConfig,
UaVariant &  dv,
ITEM citem,
UaControlVariableMap cvs,
UaMutexRefCounted *  pSharedMutex 
)

Constructor.

Parameters
namethe name of ua node
uaIditem ua node id
pNodeConfigpointer to node manager
dvinitial value of item (usually empty)
formulpointer to formula object
whenConditionpointer to conditional formulas
statusConditionformula status conditions
pSharedMutexpointer to shared mutex (using toolkit)

< set change date by event

< set change date by event

Definition at line 67 of file UaCalcItem.cpp.

◆ ~UaCalcItem() [1/2]

virtual AddressSpace::UaCalcItem::~UaCalcItem ( void  )
inlinevirtual

destructor

Definition at line 100 of file UaCalcItem.h.

◆ UaCalcItem() [2/2]

AddressSpace::UaCalcItem::UaCalcItem ( const UaString &  name,
UaNodeId &  uaId,
const UaNode *  parent,
NmBuildingAutomation pNodeConfig,
UaVariant &  dv,
ITEM citem,
UaControlVariableMap cvs,
UaMutexRefCounted *  pSharedMutex 
)

Constructor.

Parameters
namethe name of ua node
uaIditem ua node id
pNodeConfigpointer to node manager
dvinitial value of item (usually empty)
formulpointer to formula object
whenConditionpointer to conditional formulas
statusConditionformula status conditions
pSharedMutexpointer to shared mutex (using toolkit)

◆ ~UaCalcItem() [2/2]

virtual AddressSpace::UaCalcItem::~UaCalcItem ( void  )
inlinevirtual

destructor

Definition at line 92 of file UaCalcItem.hpp.

Member Function Documentation

◆ calculateOnChange() [1/2]

virtual void AddressSpace::UaCalcItem::calculateOnChange ( Session *  pSession,
const UaDataValue &  dataValue,
OpcUa_Boolean  checkAccessLevel 
)
virtual

type of set of variable for formula

The callback function to calculate the value.

Parameters
dValuethe value of changed control variable

◆ calculateOnChange() [2/2]

void AddressSpace::UaCalcItem::calculateOnChange ( Session *  pSession,
const UaDataValue &  dataValue,
OpcUa_Boolean  checkAccessLevel 
)
virtual

type of set of variable for formula

The callback function to calculate the value.

Parameters
dValuethe value of changed control variable

< boost placeholder for binding argument

bind function which calculator uses to take data from OpcUa variable

< boost placeholder for binding argument

bind function which calculator uses to take data from OpcUa variable

Definition at line 253 of file UaCalcItem.cpp.

◆ checkDouble()

bool AddressSpace::UaCalcItem::checkDouble ( const string &  str,
double &  res 
)
inline

Definition at line 168 of file UaCalcItem.h.

◆ checkStatus() [1/2]

OpcUa_StatusCode AddressSpace::UaCalcItem::checkStatus ( variableSet vs)
inline

Definition at line 148 of file UaCalcItem.hpp.

◆ checkStatus() [2/2]

OpcUa_StatusCode AddressSpace::UaCalcItem::checkStatus ( variableSet vs)
inline

Definition at line 202 of file UaCalcItem.h.

◆ compile()

bool AddressSpace::UaCalcItem::compile ( )

Definition at line 157 of file UaCalcItem.cpp.

◆ fExists()

bool AddressSpace::UaCalcItem::fExists ( )
inline

Definition at line 157 of file UaCalcItem.h.

◆ getFormula()

string& AddressSpace::UaCalcItem::getFormula ( )
inline

Definition at line 169 of file UaCalcItem.hpp.

◆ getStatusCondition()

string& AddressSpace::UaCalcItem::getStatusCondition ( )
inline

Definition at line 171 of file UaCalcItem.hpp.

◆ getValueFromItem()

mu::value_type * AddressSpace::UaCalcItem::getValueFromItem ( const mu::char_type ind,
void *  pNode 
)
static

bind function which calculator uses to take data from OpcUa variable

this function take data from OpcUa variable.

the pointer saved in vector m_var

Parameters
indindex of vector of pointer to variable

std::replace(nam.begin(), nam.end(), '.', '_');

Definition at line 555 of file UaCalcItem.cxx.

◆ getValueFromStatusItem()

mu::value_type * AddressSpace::UaCalcItem::getValueFromStatusItem ( const mu::char_type ind,
void *  pNode 
)
static

Definition at line 601 of file UaCalcItem.cxx.

◆ getValueFromWhenItem()

mu::value_type * AddressSpace::UaCalcItem::getValueFromWhenItem ( const mu::char_type ind,
void *  pNode 
)
static

Definition at line 579 of file UaCalcItem.cxx.

◆ getWhenCondition()

string& AddressSpace::UaCalcItem::getWhenCondition ( )
inline

Definition at line 170 of file UaCalcItem.hpp.

◆ initCalculation() [1/2]

virtual void AddressSpace::UaCalcItem::initCalculation ( )
virtual

initial calculation after startup

◆ initCalculation() [2/2]

void AddressSpace::UaCalcItem::initCalculation ( )
virtual

initial calculation after startup

boost placeholder for binding argument

bind function which calculator uses to take data from OpcUa variable

boost placeholder for binding argument

bind function which calculator uses to take data from OpcUa variable

Definition at line 330 of file UaCalcItem.cpp.

◆ PowFunc()

static double AddressSpace::UaCalcItem::PowFunc ( double  a_fVal,
double  b_fVal 
)
inlinestatic

Definition at line 175 of file UaCalcItem.hpp.

◆ pushConditionVariable() [1/2]

void AddressSpace::UaCalcItem::pushConditionVariable ( std::string &  name,
UaControlVariable obd 
)
inline

Connect to the object using in conditional formula.

Set callback function

Parameters
namename of control variable
obdpointer to the input control variable

Definition at line 121 of file UaCalcItem.hpp.

◆ pushConditionVariable() [2/2]

bool AddressSpace::UaCalcItem::pushConditionVariable ( const string &  name,
UaControlVariable obd 
)
inline

Connect to the object using in conditional formula.

Set callback function

Parameters
namename of control variable
obdpointer to the input control variable

Definition at line 127 of file UaCalcItem.h.

◆ pushDataVariable() [1/2]

void AddressSpace::UaCalcItem::pushDataVariable ( std::string &  name,
UaControlVariable obd 
)
inline

Connect to the input object.

Set callback function

Parameters
namename of control variable
obdpointer to the input control variable

Definition at line 99 of file UaCalcItem.hpp.

◆ pushDataVariable() [2/2]

bool AddressSpace::UaCalcItem::pushDataVariable ( const string &  name,
UaControlVariable obd 
)
inline

Connect to the input object.

Set callback function

Parameters
namename of control variable
obdpointer to the input control variable

Definition at line 107 of file UaCalcItem.h.

◆ pushStatusVariable() [1/2]

void AddressSpace::UaCalcItem::pushStatusVariable ( std::string &  name,
UaControlVariable obd 
)
inline

Connect to the object using in conditional formula.

Set callback function

Parameters
namename of control variable
obdpointer to the input control variable

Definition at line 138 of file UaCalcItem.hpp.

◆ pushStatusVariable() [2/2]

bool AddressSpace::UaCalcItem::pushStatusVariable ( const string &  name,
UaControlVariable obd 
)
inline

Connect to the object using in conditional formula.

Set callback function

Parameters
namename of control variable
obdpointer to the input control variable

Definition at line 146 of file UaCalcItem.h.

◆ replaceAll()

void AddressSpace::UaCalcItem::replaceAll ( std::string &  str,
const std::string &  from,
const std::string &  to 
)
inline

Definition at line 159 of file UaCalcItem.h.

◆ UA_DISABLE_COPY() [1/2]

AddressSpace::UaCalcItem::UA_DISABLE_COPY ( UaCalcItem  )
private

◆ UA_DISABLE_COPY() [2/2]

AddressSpace::UaCalcItem::UA_DISABLE_COPY ( UaCalcItem  )
private

Member Data Documentation

◆ m_cExists

bool AddressSpace::UaCalcItem::m_cExists
private

Definition at line 290 of file UaCalcItem.h.

◆ m_fExists

bool AddressSpace::UaCalcItem::m_fExists
private

status logical formula

logical formula to calculate the status of variable

Definition at line 289 of file UaCalcItem.h.

◆ m_formul [1/2]

mu::Parser AddressSpace::UaCalcItem::m_formul
private

logical formula if it s true the calculation will be executed

Definition at line 185 of file UaCalcItem.hpp.

◆ m_formul [2/2]

expression_t AddressSpace::UaCalcItem::m_formul
private


bind function which calculator uses to take data from OpcUa variable

double getValueFromItem(std::string); double getValueFromWhenItem(std::string); double getValueFromStatusItem(std::string);

Definition at line 273 of file UaCalcItem.h.

◆ m_formul_table

symbol_table_t AddressSpace::UaCalcItem::m_formul_table
private

Definition at line 277 of file UaCalcItem.h.

◆ m_pNodeManager

NmBuildingAutomation * AddressSpace::UaCalcItem::m_pNodeManager

status logical formula

Definition at line 262 of file UaCalcItem.h.

◆ m_pParent [1/2]

const UaNode* AddressSpace::UaCalcItem::m_pParent
private

Definition at line 200 of file UaCalcItem.hpp.

◆ m_pParent [2/2]

const OpcUa::BaseObjectType* AddressSpace::UaCalcItem::m_pParent

Definition at line 261 of file UaCalcItem.h.

◆ m_sExists

bool AddressSpace::UaCalcItem::m_sExists
private

Definition at line 291 of file UaCalcItem.h.

◆ m_sFormul

string AddressSpace::UaCalcItem::m_sFormul
private

variables using in status formula

Definition at line 285 of file UaCalcItem.h.

◆ m_sStatusCondition

string AddressSpace::UaCalcItem::m_sStatusCondition
private

condition formula

Definition at line 287 of file UaCalcItem.h.

◆ m_statusFormula [1/2]

mu::Parser AddressSpace::UaCalcItem::m_statusFormula
private

analytic formula to calculate

Definition at line 186 of file UaCalcItem.hpp.

◆ m_statusFormula [2/2]

expression_t AddressSpace::UaCalcItem::m_statusFormula
private

Definition at line 275 of file UaCalcItem.h.

◆ m_statusVar

variableSet AddressSpace::UaCalcItem::m_statusVar
private

variables using in formula

Definition at line 295 of file UaCalcItem.h.

◆ m_sWhenCondition

string AddressSpace::UaCalcItem::m_sWhenCondition
private

formula in text form

Definition at line 286 of file UaCalcItem.h.

◆ m_var

variableSet AddressSpace::UaCalcItem::m_var
private

variable using in condition formula

Definition at line 294 of file UaCalcItem.h.

◆ m_whenCondition [1/2]

mu::Parser AddressSpace::UaCalcItem::m_whenCondition
private

Definition at line 184 of file UaCalcItem.hpp.

◆ m_whenCondition [2/2]

expression_t AddressSpace::UaCalcItem::m_whenCondition
private

Definition at line 274 of file UaCalcItem.h.

◆ m_whenVar

variableSet AddressSpace::UaCalcItem::m_whenVar
private

Definition at line 293 of file UaCalcItem.h.

◆ parser_b

parser_t AddressSpace::UaCalcItem::parser_b
private

Definition at line 282 of file UaCalcItem.h.

◆ parser_d

parser_t AddressSpace::UaCalcItem::parser_d
private

Definition at line 281 of file UaCalcItem.h.

◆ parser_i

parser_t AddressSpace::UaCalcItem::parser_i
private

Definition at line 283 of file UaCalcItem.h.


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