ISIS Logo
NINetVar
An EPICS support module to export National Instruments Network Shared Variables as process variables
NINetVarInterface.h
Go to the documentation of this file.
1 /*************************************************************************\
2 * Copyright (c) 2013 Science and Technology Facilities Council (STFC), GB.
3 * All rights reverved.
4 * This file is distributed subject to a Software License Agreement found
5 * in the file LICENSE.txt that is included with this distribution.
6 \*************************************************************************/
7 
10 
11 #ifndef NINETVAR_INTERFACE_H
12 #define NINETVAR_INTERFACE_H
13 
14 #include <stdio.h>
15 
16 //#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
17 #include <windows.h>
18 
19 #include <string>
20 #include <vector>
21 #include <map>
22 #include <list>
23 #include <stdexcept>
24 #include <sstream>
25 #include <fstream>
26 #include <iostream>
27 
28 #include <epicsMutex.h>
29 #include <epicsThread.h>
30 #include <epicsExit.h>
31 
32 #include <msxml2.h>
33 
34 #include <cvirte.h>
35 #include <userint.h>
36 #include <cvinetv.h>
37 
38 
41 
42 struct NvItem;
43 class asynPortDriver;
44 struct CallbackData;
45 
48 {
49 public:
50  NINetVarInterface(const char* configSection, const char *configFile, int options);
51  long nParams();
52  ~NINetVarInterface() { if (m_pxmldom != NULL) { m_pxmldom->Release(); m_pxmldom = 0; } }
53  void updateValues();
54  void createParams(asynPortDriver* driver);
55  void report(FILE* fp, int details);
56  template<typename T> void setValue(const char* param, const T& value);
57  template<typename T> void setArrayValue(const char* param, const T* value, size_t nElements);
58  void dataTransferredCallback (void * handle, int error, CallbackData* cb_data);
59  void dataCallback (void * handle, CNVData data, CallbackData* cb_data);
60  void statusCallback (void * handle, CNVConnectionStatus status, int error, CallbackData* cb_data);
61  template <typename T> void readArrayValue(const char* paramName, T* value, size_t nElements, size_t* nIn);
62 
63 private:
64  std::string m_configSection;
65  std::string m_configFile;
66  int m_options;
67 // epicsMutex m_lock;
68  IXMLDOMDocument2 *m_pxmldom;
69  asynPortDriver* m_driver;
70  typedef std::map<std::string,NvItem*> params_t;
71  params_t m_params;
72 
73  void getParams();
74  void DomFromCOM();
75  void setValueCNV(const std::string& name, CNVData value);
76  static void epicsExitFunc(void* arg);
77  bool checkOption(NINetVarOptions option) { return ( m_options & static_cast<int>(option) ) != 0; }
78  void connectVars();
79  template<typename T> void updateParamValue(int param_index, T val, bool do_asyn_param_callbacks);
80  template<typename T> void updateParamArrayValue(int param_index, T* val, size_t nElements);
81  void updateParamCNV (int param_index, CNVData data, bool do_asyn_param_callbacks);
82  template<CNVDataType cnvType> void updateParamCNVImpl(int param_index, CNVData data, CNVDataType type, unsigned int nDims, bool do_asyn_param_callbacks);
83  template<typename T,typename U> void updateParamArrayValueImpl(int param_index, T* val, size_t nElements);
84 };
85 
86 #endif /* NINETVAR_INTERFACE_H */
NINetVarInterface(const char *configSection, const char *configFile, int options)
section name of configFile to use to configure this asyn port
details about a network shared variable we have connected to an asyn parameter
int m_options
the various NINetVarOptions currently in use
void dataTransferredCallback(void *handle, int error, CallbackData *cb_data)
called when data has been transferred to the variable
void updateParamValue(int param_index, T val, bool do_asyn_param_callbacks)
std::map< std::string, NvItem * > params_t
void setValue(const char *param, const T &value)
void updateParamArrayValue(int param_index, T *val, size_t nElements)
void updateParamCNVImpl(int param_index, CNVData data, CNVDataType type, unsigned int nDims, bool do_asyn_param_callbacks)
void setArrayValue(const char *param, const T *value, size_t nElements)
void setValueCNV(const std::string &name, CNVData value)
void statusCallback(void *handle, CNVConnectionStatus status, int error, CallbackData *cb_data)
called when status of a network shared variable changes
IXMLDOMDocument2 * m_pxmldom
bool checkOption(NINetVarOptions option)
Stores information to be passed back via a shared variable callback on a subscriber connection...
void dataCallback(void *handle, CNVData data, CallbackData *cb_data)
called when new data is available on a subscriber connection
void createParams(asynPortDriver *driver)
NINetVarOptions
option argument in NINetVarConfigure() of st.cmd not used at present
asynPortDriver * m_driver
void report(FILE *fp, int details)
Helper for EPICS driver report function.
Manager class for the NetVar Interaction. Parses an netvarconfig.xml file and provides access to the ...
std::string m_configSection
section of configFile to load information from
void updateParamCNV(int param_index, CNVData data, bool do_asyn_param_callbacks)
void updateParamArrayValueImpl(int param_index, T *val, size_t nElements)
static void epicsExitFunc(void *arg)
void readArrayValue(const char *paramName, T *value, size_t nElements, size_t *nIn)
std::string m_configFile
Copyright © 2013 Science and Technology Facilities Council | Generated by   doxygen 1.8.8