rllib  1
Classes | Public Types | Public Member Functions | Private Attributes | List of all members
rlOpcXmlDa Class Reference

#include <rlopcxmlda.h>

Collaboration diagram for rlOpcXmlDa:
Collaboration graph
[legend]

Classes

struct  SHM_HEADER
 

Public Types

enum  OPC_XML_DA_ENUM { OPCXMLDA_ERROR = 256*256*128 }
 

Public Member Functions

 rlOpcXmlDa (const char *mailbox="c:\utomation\bx\pcxmlda.mbx", const char *shared_memory="c:\utomation\hm\pcxmlda.shm", long shared_memory_size=65536)
 
virtual ~rlOpcXmlDa ()
 
const char * stringValue (const char *variable)
 
int intValue (const char *variable)
 
float floatValue (const char *variable)
 
int writeStringValue (const char *variable, const char *value)
 
int writeIntValue (const char *variable, int value)
 
int writeFloatValue (const char *variable, float value)
 
int readErrorCount ()
 
int writeErrorCount ()
 
int shmStatus ()
 

Private Attributes

SHM_HEADERshmheader
 
const char * shmvalues
 
rlMailboxmbx
 
rlSharedMemoryshm
 

Detailed Description

use this class together with opcxmlda_client. opcxmlda_client will fill the shared memory with variables read over opc xml-da. opcxmlda_client will receive outgoing writes through it's mailbox.

This class is for data acquisition within pvserver according to the pvbrowser principle.
It communicates with the daemon opcxmlda_client by the means of a shared memory and a mailbox.

Definition at line 33 of file rlopcxmlda.h.

Member Enumeration Documentation

◆ OPC_XML_DA_ENUM

Enumerator
OPCXMLDA_ERROR 

Definition at line 49 of file rlopcxmlda.h.

50  {
51  OPCXMLDA_ERROR = 256*256*128
52  };

Constructor & Destructor Documentation

◆ rlOpcXmlDa()

rlOpcXmlDa::rlOpcXmlDa ( const char *  mailbox = "c:\\automation\\mbx\\opcxmlda.mbx",
const char *  shared_memory = "c:\\automation\\shm\\opcxmlda.shm",
long  shared_memory_size = 65536 
)

Definition at line 21 of file rlopcxmlda.cpp.

22 {
23  mbx = new rlMailbox(mailbox);
24  shm = new rlSharedMemory(shared_memory,shared_memory_size);
25  shmheader = (SHM_HEADER *) shm->getUserAdr();
26  shmvalues = ((const char *)shmheader) + sizeof(SHM_HEADER);
27 }
rlSharedMemory * shm
Definition: rlopcxmlda.h:74
SHM_HEADER * shmheader
Definition: rlopcxmlda.h:71
rlMailbox * mbx
Definition: rlopcxmlda.h:73
const char * shmvalues
Definition: rlopcxmlda.h:72

◆ ~rlOpcXmlDa()

rlOpcXmlDa::~rlOpcXmlDa ( )
virtual

Definition at line 29 of file rlopcxmlda.cpp.

30 {
31  delete mbx;
32  delete shm;
33 }
rlSharedMemory * shm
Definition: rlopcxmlda.h:74
rlMailbox * mbx
Definition: rlopcxmlda.h:73

Member Function Documentation

◆ floatValue()

float rlOpcXmlDa::floatValue ( const char *  variable)

Definition at line 74 of file rlopcxmlda.cpp.

75 {
76  const char *cptr;
77  float ret;
78 
79  cptr = stringValue(variable);
80  if(isdigit(*cptr) || *cptr == '-')
81  {
82  ret = OPCXMLDA_ERROR;
83  sscanf(cptr,"%f",&ret);
84  return ret;
85  }
86  return OPCXMLDA_ERROR;
87 }
const char * stringValue(const char *variable)
Definition: rlopcxmlda.cpp:35

◆ intValue()

int rlOpcXmlDa::intValue ( const char *  variable)

Definition at line 59 of file rlopcxmlda.cpp.

60 {
61  const char *cptr;
62  int ret;
63 
64  cptr = stringValue(variable);
65  if(isdigit(*cptr))
66  {
67  ret = OPCXMLDA_ERROR;
68  sscanf(cptr,"%d",&ret);
69  return ret;
70  }
71  return OPCXMLDA_ERROR;
72 }
const char * stringValue(const char *variable)
Definition: rlopcxmlda.cpp:35

◆ readErrorCount()

int rlOpcXmlDa::readErrorCount ( )

Definition at line 107 of file rlopcxmlda.cpp.

108 {
109  if(shmheader == NULL) return OPCXMLDA_ERROR;
110  return shmheader->readErrorCount;
111 }
SHM_HEADER * shmheader
Definition: rlopcxmlda.h:71

◆ shmStatus()

int rlOpcXmlDa::shmStatus ( )

Definition at line 119 of file rlopcxmlda.cpp.

120 {
121  if(shmheader == NULL) return OPCXMLDA_ERROR;
122  if(shm->status == rlSharedMemory::OK) return 0;
123  return OPCXMLDA_ERROR;
124 }
rlSharedMemory * shm
Definition: rlopcxmlda.h:74
SHM_HEADER * shmheader
Definition: rlopcxmlda.h:71

◆ stringValue()

const char * rlOpcXmlDa::stringValue ( const char *  variable)

Definition at line 35 of file rlopcxmlda.cpp.

36 {
37  int value_offset, delta_index, nmax, i;
38  const char *cptr;
39 
40  if(shmheader == NULL) return "OPCXMLDA_ERROR";
41  if(strcmp(shmheader->ident,"opc") != 0) return "OPCXMLDA_ERROR";
42  value_offset = shmheader->maxItemNameLength + 1;
43  delta_index = value_offset + shmheader->maxNameLength + 1;
44  nmax = shmheader->numItems;
45 
46  cptr = shmvalues;
47  for(i=0; i<nmax; i++)
48  {
49  if(strcmp(cptr,variable) == 0)
50  {
51  return cptr + value_offset;
52  }
53  cptr += delta_index;
54  }
55 
56  return "OPCXMLDA_ERROR";
57 }
SHM_HEADER * shmheader
Definition: rlopcxmlda.h:71
const char * shmvalues
Definition: rlopcxmlda.h:72

◆ writeErrorCount()

int rlOpcXmlDa::writeErrorCount ( )

Definition at line 113 of file rlopcxmlda.cpp.

114 {
115  if(shmheader == NULL) return OPCXMLDA_ERROR;
116  return shmheader->writeErrorCount;
117 }
SHM_HEADER * shmheader
Definition: rlopcxmlda.h:71

◆ writeFloatValue()

int rlOpcXmlDa::writeFloatValue ( const char *  variable,
float  value 
)

Definition at line 101 of file rlopcxmlda.cpp.

102 {
103  mbx->printf("%s,%f\n",variable,value);
104  return 0;
105 }
int printf(const char *format,...)
Definition: rlmailbox.cpp:344
rlMailbox * mbx
Definition: rlopcxmlda.h:73

◆ writeIntValue()

int rlOpcXmlDa::writeIntValue ( const char *  variable,
int  value 
)

Definition at line 95 of file rlopcxmlda.cpp.

96 {
97  mbx->printf("%s,%d\n",variable,value);
98  return 0;
99 }
int printf(const char *format,...)
Definition: rlmailbox.cpp:344
rlMailbox * mbx
Definition: rlopcxmlda.h:73

◆ writeStringValue()

int rlOpcXmlDa::writeStringValue ( const char *  variable,
const char *  value 
)

Definition at line 89 of file rlopcxmlda.cpp.

90 {
91  mbx->printf("%s,%s\n",variable,value);
92  return 0;
93 }
int printf(const char *format,...)
Definition: rlmailbox.cpp:344
rlMailbox * mbx
Definition: rlopcxmlda.h:73

Member Data Documentation

◆ mbx

rlMailbox* rlOpcXmlDa::mbx
private

Definition at line 73 of file rlopcxmlda.h.

◆ shm

rlSharedMemory* rlOpcXmlDa::shm
private

Definition at line 74 of file rlopcxmlda.h.

◆ shmheader

SHM_HEADER* rlOpcXmlDa::shmheader
private

Definition at line 71 of file rlopcxmlda.h.

◆ shmvalues

const char* rlOpcXmlDa::shmvalues
private

Definition at line 72 of file rlopcxmlda.h.


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