ngc 1.5.0
 
Loading...
Searching...
No Matches
ngcdcsRTD.hpp
Go to the documentation of this file.
1
8#ifndef ngcdcsRTD_H
9#define ngcdcsRTD_H
10
11
12#ifndef __cplusplus
13#error This is a C++ include file and cannot be used from plain C
14#endif
15
16#include <ngc/core/ngcbSHM.hpp>
17
21#define ngcdcsRTD_MAX_ACQ 24
22
28 char host[64];
29
32
34 int nx;
35
37 int ny;
38
41 memset(host, 0, sizeof(host));
42 dataPort = 0; nx = 0; ny = 0;
43 }
44};
45
53
57class ngcdcsRTD: public ngcbSHMDB
58{
59public:
61 explicit ngcdcsRTD(const char *s, ngcdcs_rtdshm_t *initVal = NULL)
62 : ngcbSHMDB("ngcdcsrtd", s, initVal, sizeof(ngcdcs_rtdshm_t)) {
63 shm_ = static_cast<ngcdcs_rtdshm_t *>(shmBuf);
64 server_ = (initVal != NULL);
65 }
66
68 virtual ~ngcdcsRTD() {
69 shm_ = NULL;
70 }
71
73 void Cfg(int idx, const ngcdcs_rtdacq_t &acq) {
74 if (server_ && (CheckIdx_(idx) == 0))
75 {
76 if (Lock() != -1)
77 {
78 memcpy(&shm_->acq[idx], &acq, sizeof(ngcdcs_rtdacq_t));
79 Unlock();
80 }
81 }
82 }
83
85 int GetCfg(int idx, ngcdcs_rtdacq_t *acq) {
86 if (CheckIdx_(idx) != 0) return (-1);
87 else if (Lock() != 0) return (-1);
88 else
89 {
90 memcpy(acq, &shm_->acq[idx], sizeof(ngcdcs_rtdacq_t));
91 Unlock();
92 }
93 return (0);
94 }
95
96protected:
97
98private:
100 ngcdcs_rtdshm_t *shm_;
101
103 int server_;
104
106 int CheckIdx_(int idx) {
107 if ((idx < 0) || (idx >= ngcdcsRTD_MAX_ACQ))
108 {
109 strcpy(ErrMsg(), "invalid acquisition module index");
110 return (-1);
111 }
112 else
113 {
114 return (0);
115 }
116 }
117};
118
119#endif
void * shmBuf
Shared memory buffer.
Definition ngcbSHMDB.hpp:58
ngcbSHMDB(const char *app, const char *s, void *initBuffer=NULL, size_t size=0)
Constructor.
Definition ngcbSHMDB.hpp:61
int Lock()
Lock shared memory.
Definition ngcbSHMDB.hpp:279
void Unlock()
Unlock shared memory.
Definition ngcbSHMDB.hpp:320
char * ErrMsg()
Error message.
Definition ngcbSHMDB.hpp:276
ngcdcsRTD(const char *s, ngcdcs_rtdshm_t *initVal=NULL)
Constructor.
Definition ngcdcsRTD.hpp:61
int GetCfg(int idx, ngcdcs_rtdacq_t *acq)
Get connection configuration.
Definition ngcdcsRTD.hpp:85
void Cfg(int idx, const ngcdcs_rtdacq_t &acq)
Configure.
Definition ngcdcsRTD.hpp:73
virtual ~ngcdcsRTD()
Destructor.
Definition ngcdcsRTD.hpp:68
#define ngcdcsRTD_MAX_ACQ
Definition ngcdcsRTD.hpp:21
Definition ngcdcsRTD.hpp:26
int ny
Maximum Y-dimension.
Definition ngcdcsRTD.hpp:37
char host[64]
Host name.
Definition ngcdcsRTD.hpp:28
int dataPort
Data port number.
Definition ngcdcsRTD.hpp:31
int nx
Maximum X-dimension.
Definition ngcdcsRTD.hpp:34
ngcdcs_rtdacq_t()
Constructor.
Definition ngcdcsRTD.hpp:40
Definition ngcdcsRTD.hpp:49
ngcdcs_rtdacq_t acq[ngcdcsRTD_MAX_ACQ]
Acquisition process configuration structures.
Definition ngcdcsRTD.hpp:51