ISIS Logo
NetShrVar
An EPICS support module to export National Instruments Network Shared Variables as process variables
Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
NetShrVarInterface Class Reference

Manager class for the NetVar Interaction. Parses an netvarconfig.xml file and provides access to the 9variables described within. More...

#include <NetShrVarInterface.h>

Public Member Functions

 NetShrVarInterface (const char *configSection, const char *configFile, int options)
 section name of configFile to use to configure this asyn port More...
 
size_t nParams ()
 
 ~NetShrVarInterface ()
 
void updateValues ()
 This is called from a polling loop in the driver to update values from buffered subscribers. More...
 
void createParams (asynPortDriver *driver)
 
void report (FILE *fp, int details)
 Helper for EPICS driver report function. More...
 
void readValue (const char *param)
 read a value and update corresponding asyn parameter More...
 
void dataTransferredCallback (void *handle, int error, CallbackData *cb_data)
 called when data has been transferred to the variable More...
 
void dataCallback (void *handle, CNVData data, CallbackData *cb_data)
 called by DataCallback() when new data is available on a subscriber connection More...
 
void statusCallback (void *handle, CNVConnectionStatus status, int error, CallbackData *cb_data)
 called by StatusCallback() when status of a network shared variable changes More...
 
template<typename T >
void setValue (const char *param, const T &value)
 
template<typename T >
void setArrayValue (const char *param, const T *value, size_t nElements)
 
template<typename T >
void readArrayValue (const char *paramName, T *value, size_t nElements, size_t *nIn)
 called externally with m_driver locked More...
 
template<>
void setValue (const char *param, const std::string &value)
 

Static Public Member Functions

static bool varExists (const std::string &path)
 
static bool pathExists (const std::string &path)
 

Private Types

typedef std::map< std::string,
NvItem * > 
params_t
 

Private Member Functions

void updateBytesReadCount (unsigned nbytes)
 
template<typename T >
void getAsynParamValue (int param, T &value)
 
char * envExpand (const char *str)
 expand epics environment strings using previously saved environment based on EPICS macEnvExpand() More...
 
void getParams ()
 
void setValueCNV (const std::string &name, CNVData value)
 
bool checkOption (NetShrVarOptions option)
 
void connectVars ()
 
bool convertTimeStamp (unsigned __int64 timestamp, epicsTimeStamp *epicsTS)
 convert a timestamp obtained from CNVGetDataUTCTimestamp() into an EPICS timestamp timestamp has 100ns granuality More...
 
template<typename T >
void updateParamValue (int param_index, T val, epicsTimeStamp *epicsTS, bool do_asyn_param_callbacks)
 
template<typename T >
void updateParamArrayValue (int param_index, T *val, size_t nElements, epicsTimeStamp *epicsTS, bool do_asyn_param_callbacks)
 
void updateParamCNV (int param_index, CNVData data, epicsTimeStamp *epicsTS, bool do_asyn_param_callbacks)
 
template<CNVDataType cnvType>
void updateParamCNVImpl (int param_index, CNVData data, CNVDataType type, unsigned int nDims, epicsTimeStamp *epicsTS, bool do_asyn_param_callbacks)
 
template<typename T , typename U >
void updateParamArrayValueImpl (int param_index, T *val, size_t nElements)
 
void readVarInit (NvItem *item)
 used to perform an initial read of a subscribed variable More...
 
void setParamStatus (int param_id, asynStatus status, epicsAlarmCondition alarmStat=epicsAlarmNone, epicsAlarmSeverity alarmSevr=epicsSevNone)
 
void getParamStatus (int param_id, asynStatus &status, int &alarmStat, int &alarmSevr)
 
void initAsynParamIds ()
 
void updateConnectedAlarmStatus (const std::string &paramName, int value, const std::string &alarmStr, epicsAlarmCondition stat, epicsAlarmSeverity sevr)
 

Static Private Member Functions

static void epicsExitFunc (void *arg)
 

Private Attributes

std::string m_configSection
 section of configFile to load information from More...
 
std::string m_configFile
 
int m_options
 the various NetShrVarOptions currently in use More...
 
asynPortDriver * m_driver
 
params_t m_params
 
pugi::xml_document m_xmlconfig
 
MAC_HANDLE * m_mac_env
 
int m_writer_wait_ms
 how long to wait for a write operation to complete in milliseconds More...
 
int m_b_writer_wait_ms
 how long to wait for a buffered write operation to complete in milliseconds More...
 
my_atomic_uint32_t m_items_read
 
my_atomic_uint64_t m_bytes_read
 
struct timeb m_last_report
 

Detailed Description

Manager class for the NetVar Interaction. Parses an netvarconfig.xml file and provides access to the 9variables described within.

Definition at line 72 of file NetShrVarInterface.h.

Member Typedef Documentation

typedef std::map<std::string,NvItem*> NetShrVarInterface::params_t
private

Definition at line 97 of file NetShrVarInterface.h.

Constructor & Destructor Documentation

NetShrVarInterface::NetShrVarInterface ( const char *  configSection,
const char *  configFile,
int  options 
)

section name of configFile to use to configure this asyn port

Parameters
[in]configSection
[in]configFilePath to the XML input file to load configuration information from.
[in]optionsoptions as per NetShrVarOptions enum

Definition at line 1134 of file NetShrVarInterface.cpp.

References envExpand(), epicsExitFunc(), initCV(), m_configFile, m_last_report, m_mac_env, m_xmlconfig, and onceId.

NetShrVarInterface::~NetShrVarInterface ( )
inline

Definition at line 77 of file NetShrVarInterface.h.

Member Function Documentation

bool NetShrVarInterface::checkOption ( NetShrVarOptions  option)
inlineprivate

Definition at line 124 of file NetShrVarInterface.h.

void NetShrVarInterface::connectVars ( )
private
bool NetShrVarInterface::convertTimeStamp ( unsigned __int64  timestamp,
epicsTimeStamp *  epicsTS 
)
private

convert a timestamp obtained from CNVGetDataUTCTimestamp() into an EPICS timestamp timestamp has 100ns granuality

Definition at line 827 of file NetShrVarInterface.cpp.

Referenced by updateParamCNV().

void NetShrVarInterface::createParams ( asynPortDriver *  driver)

Definition at line 1257 of file NetShrVarInterface.cpp.

References connectVars(), getParams(), and m_driver.

Referenced by NetShrVarDriver::NetShrVarDriver().

void NetShrVarInterface::dataCallback ( void *  handle,
CNVData  data,
CallbackData cb_data 
)

called by DataCallback() when new data is available on a subscriber connection

Definition at line 536 of file NetShrVarInterface.cpp.

References CallbackData::param_index, and updateParamCNV().

Referenced by DataCallback().

void NetShrVarInterface::dataTransferredCallback ( void *  handle,
int  error,
CallbackData cb_data 
)

called when data has been transferred to the variable

Definition at line 503 of file NetShrVarInterface.cpp.

References CallbackData::nv_name, CallbackData::param_index, and setParamStatus().

Referenced by DataTransferredCallback().

char * NetShrVarInterface::envExpand ( const char *  str)
private

expand epics environment strings using previously saved environment based on EPICS macEnvExpand()

Definition at line 1104 of file NetShrVarInterface.cpp.

References m_mac_env.

Referenced by getParams(), and NetShrVarInterface().

void NetShrVarInterface::epicsExitFunc ( void *  arg)
staticprivate

Definition at line 1178 of file NetShrVarInterface.cpp.

Referenced by NetShrVarInterface().

template<typename T >
void NetShrVarInterface::getAsynParamValue ( int  param,
T &  value 
)
private
void NetShrVarInterface::getParams ( )
private
void NetShrVarInterface::getParamStatus ( int  param_id,
asynStatus &  status,
int &  alarmStat,
int &  alarmSevr 
)
private

Definition at line 1462 of file NetShrVarInterface.cpp.

References m_driver.

Referenced by updateParamCNV().

void NetShrVarInterface::initAsynParamIds ( )
private

Definition at line 1207 of file NetShrVarInterface.cpp.

References driverName, NvItem::id, m_driver, m_params, and NvItem::type.

Referenced by connectVars().

size_t NetShrVarInterface::nParams ( )

Definition at line 1191 of file NetShrVarInterface.cpp.

References m_configSection, m_xmlconfig, and MAX_PATH_LEN.

bool NetShrVarInterface::pathExists ( const std::string &  path)
static

Definition at line 303 of file NetShrVarInterface.cpp.

References ERROR_CHECK, and getBrowseType().

Referenced by connectVars(), and main().

template<typename T >
void NetShrVarInterface::readArrayValue ( const char *  paramName,
T *  value,
size_t  nElements,
size_t *  nIn 
)

called externally with m_driver locked

<

Todo:
or true? and set timestamp below?

Definition at line 726 of file NetShrVarInterface.cpp.

References NvItem::access, NvItem::array_data, ERROR_CHECK, NvItem::id, m_driver, m_params, NvItem::nv_name, NvItem::reader, NvItem::SingleRead, and updateParamCNV().

Referenced by NetShrVarDriver::readArrayValue().

void NetShrVarInterface::readValue ( const char *  param)

read a value and update corresponding asyn parameter

Definition at line 760 of file NetShrVarInterface.cpp.

References NvItem::access, ERROR_CHECK, NvItem::id, m_driver, m_params, NvItem::nv_name, NvItem::reader, NvItem::SingleRead, and updateParamCNV().

Referenced by NetShrVarDriver::readValue().

void NetShrVarInterface::readVarInit ( NvItem item)
private

used to perform an initial read of a subscribed variable

Definition at line 241 of file NetShrVarInterface.cpp.

References ERROR_CHECK, NvItem::id, NvItem::nv_name, setParamStatus(), and updateParamCNV().

Referenced by connectVars().

void NetShrVarInterface::report ( FILE *  fp,
int  details 
)

Helper for EPICS driver report function.

Definition at line 1522 of file NetShrVarInterface.cpp.

References m_bytes_read, m_configFile, m_configSection, m_items_read, m_last_report, m_options, m_params, and NvItem::report().

Referenced by NetShrVarDriver::report().

template<typename T >
void NetShrVarInterface::setArrayValue ( const char *  param,
const T *  value,
size_t  nElements 
)

Definition at line 1372 of file NetShrVarInterface.cpp.

References ERROR_CHECK, and setValueCNV().

Referenced by NetShrVarDriver::writeArrayValue().

void NetShrVarInterface::setParamStatus ( int  param_id,
asynStatus  status,
epicsAlarmCondition  alarmStat = epicsAlarmNone,
epicsAlarmSeverity  alarmSevr = epicsSevNone 
)
private
template<typename T >
void NetShrVarInterface::setValue ( const char *  param,
const T &  value 
)

Definition at line 1363 of file NetShrVarInterface.cpp.

References ERROR_CHECK, and setValueCNV().

Referenced by NetShrVarDriver::writeOctet(), and NetShrVarDriver::writeValue().

template<>
void NetShrVarInterface::setValue ( const char *  param,
const std::string &  value 
)

Definition at line 1354 of file NetShrVarInterface.cpp.

References ERROR_CHECK, and setValueCNV().

void NetShrVarInterface::setValueCNV ( const std::string &  name,
CNVData  value 
)
private
void NetShrVarInterface::statusCallback ( void *  handle,
CNVConnectionStatus  status,
int  error,
CallbackData cb_data 
)

called by StatusCallback() when status of a network shared variable changes

Definition at line 1074 of file NetShrVarInterface.cpp.

References connectionStatus(), CallbackData::nv_name, CallbackData::param_index, and setParamStatus().

Referenced by StatusCallback().

void NetShrVarInterface::updateBytesReadCount ( unsigned  nbytes)
inlineprivate

Definition at line 108 of file NetShrVarInterface.h.

Referenced by updateParamCNVImpl().

void NetShrVarInterface::updateConnectedAlarmStatus ( const std::string &  paramName,
int  value,
const std::string &  alarmStr,
epicsAlarmCondition  stat,
epicsAlarmSeverity  sevr 
)
private

Definition at line 553 of file NetShrVarInterface.cpp.

References m_driver, and setParamStatus().

Referenced by updateParamValue().

template<typename T >
void NetShrVarInterface::updateParamArrayValue ( int  param_index,
T *  val,
size_t  nElements,
epicsTimeStamp *  epicsTS,
bool  do_asyn_param_callbacks 
)
private
template<typename T , typename U >
void NetShrVarInterface::updateParamArrayValueImpl ( int  param_index,
T *  val,
size_t  nElements 
)
private

Definition at line 618 of file NetShrVarInterface.cpp.

References m_driver, and m_params.

void NetShrVarInterface::updateParamCNV ( int  param_index,
CNVData  data,
epicsTimeStamp *  epicsTS,
bool  do_asyn_param_callbacks 
)
private
template<CNVDataType cnvType>
void NetShrVarInterface::updateParamCNVImpl ( int  param_index,
CNVData  data,
CNVDataType  type,
unsigned int  nDims,
epicsTimeStamp *  epicsTS,
bool  do_asyn_param_callbacks 
)
private
template<typename T >
void NetShrVarInterface::updateParamValue ( int  param_index,
val,
epicsTimeStamp *  epicsTS,
bool  do_asyn_param_callbacks 
)
private
void NetShrVarInterface::updateValues ( )

This is called from a polling loop in the driver to update values from buffered subscribers.

Definition at line 1473 of file NetShrVarInterface.cpp.

References NvItem::access, NvItem::b_subscriber, NvItem::BufferedRead, NvItem::id, m_params, NetShrVarException::ni_message(), NvItem::nv_name, NvItem::Read, setParamStatus(), and updateParamCNV().

Referenced by NetShrVarDriver::updateValues().

bool NetShrVarInterface::varExists ( const std::string &  path)
static

Definition at line 337 of file NetShrVarInterface.cpp.

References ERROR_CHECK.

Member Data Documentation

int NetShrVarInterface::m_b_writer_wait_ms
private

how long to wait for a buffered write operation to complete in milliseconds

Definition at line 102 of file NetShrVarInterface.h.

Referenced by setValueCNV().

my_atomic_uint64_t NetShrVarInterface::m_bytes_read
private

Definition at line 105 of file NetShrVarInterface.h.

Referenced by report().

std::string NetShrVarInterface::m_configFile
private

Definition at line 93 of file NetShrVarInterface.h.

Referenced by NetShrVarInterface(), and report().

std::string NetShrVarInterface::m_configSection
private

section of configFile to load information from

Definition at line 92 of file NetShrVarInterface.h.

Referenced by getParams(), nParams(), and report().

asynPortDriver* NetShrVarInterface::m_driver
private
my_atomic_uint32_t NetShrVarInterface::m_items_read
private

Definition at line 104 of file NetShrVarInterface.h.

Referenced by report().

struct timeb NetShrVarInterface::m_last_report
private

Definition at line 106 of file NetShrVarInterface.h.

Referenced by NetShrVarInterface(), and report().

MAC_HANDLE* NetShrVarInterface::m_mac_env
private

Definition at line 100 of file NetShrVarInterface.h.

Referenced by envExpand(), and NetShrVarInterface().

int NetShrVarInterface::m_options
private

the various NetShrVarOptions currently in use

Definition at line 94 of file NetShrVarInterface.h.

Referenced by report().

params_t NetShrVarInterface::m_params
private
int NetShrVarInterface::m_writer_wait_ms
private

how long to wait for a write operation to complete in milliseconds

Definition at line 101 of file NetShrVarInterface.h.

Referenced by setValueCNV().

pugi::xml_document NetShrVarInterface::m_xmlconfig
private

Definition at line 99 of file NetShrVarInterface.h.

Referenced by getParams(), NetShrVarInterface(), and nParams().


The documentation for this class was generated from the following files:
Copyright © 2013 Science and Technology Facilities Council | Generated by   doxygen 1.8.5