My Project
 All Classes Files Functions Variables Enumerations Enumerator Friends Macros Pages
PmacComms.h
Go to the documentation of this file.
1 #ifndef PMACCOMMS_H
2 #define PMACCOMMS_H
3 
11 // Required C header files from the array control code
12 
13 #include "gcp/control/code/unix/libunix_src/common/regmap.h" // RegMapBlock
14 
15 #include "gcp/antenna/control/specific/PmacCommand.h"
16 
17 #define PMAC_HOST_ADDR "192.6.94.5"
18 #define PMAC_HOST_PORT 1025
19 
25 #define PMAC_TIMEOUT_USEC 600000
26 
27 namespace gcp {
28  namespace antenna {
29  namespace control {
30 
31  class SpecificShare;
32 
33  class PmacComms {
34 
35  public:
36 
40  PmacComms(SpecificShare* share);
41 
45  PmacComms();
46 
50  ~PmacComms();
51 
57  bool connect();
58 
62  void disconnect();
63 
67  bool pmacIsConnected();
68 
72  void sendCommand(PmacCommand& command);
73 
79  void readResponse(PmacCommand& command);
80 
81  //------------------------------------------------------------
82  // Methods which will be used to read and write register values.
83  // These methods will send a the appropriate command to the pmac,
84  // and time out waiting for a response.
85  //------------------------------------------------------------
86 
91  void readReg(RegMapBlock *blk,
92  unsigned int first, unsigned int nreg,
93  unsigned int *value);
94 
98  void writeReg(RegMapBlock *blk,
99  unsigned int first, unsigned int nreg,
100  unsigned int *value);
101 
105  void* getMem(unsigned short offset, unsigned short length);
106 
110  void* setMem(unsigned short offset, unsigned short length,
111  unsigned char* data);
112 
113  private:
114 
118  SpecificShare* share_;
119 
123  int fd_;
124 
128  fd_set read_fds_;
129 
133  int fd_set_size_;
134 
138  bool connected_;
139 
144  PmacCommand command_;
145 
149  bool responsePending_;
150 
154  void serviceMsgQ();
155 
160  void zeroReadFds();
161 
166  void registerReadFd(int fd);
167 
172  int waitForNextMessage();
173 
177  int waitForResponse();
178 
186  void* getResponse(PmacCommand& command);
187 
188  }; // End class PmacComms
189 
190  }; // End namespace control
191  }; // End namespace antenna
192 }; // End namespace gcp
193 
194 #endif // End #ifndef
void disconnect()
Definition: PmacComms.cc:119
void sendCommand(PmacCommand &command)
Definition: PmacComms.cc:59
bool connect()
Definition: PmacComms.cc:149
void readReg(RegMapBlock *blk, unsigned int first, unsigned int nreg, unsigned int *value)
Definition: PmacComms.cc:276
bool pmacIsConnected()
Definition: PmacComms.cc:367
void * setMem(unsigned short offset, unsigned short length, unsigned char *data)
Definition: PmacComms.cc:317
void writeReg(RegMapBlock *blk, unsigned int first, unsigned int nreg, unsigned int *value)
Definition: PmacComms.cc:255
void * getMem(unsigned short offset, unsigned short length)
Definition: PmacComms.cc:302
Definition: PmacCommand.h:29
Definition: PmacComms.h:33
~PmacComms()
Definition: PmacComms.cc:49
void readResponse(PmacCommand &command)
Definition: PmacComms.cc:87
PmacComms()
Definition: PmacComms.cc:39