CARMA C++
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 "carma/szaarrayutils/regmap.h" // RegMapBlock
14 
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 sza {
28  namespace antenna {
29  namespace control {
30 
31  class SzaShare;
32 
33  class PmacComms {
34 
35  public:
36 
40  PmacComms(SzaShare* share);
41 
45  PmacComms();
46 
50  ~PmacComms();
51 
57  bool connect();
58  bool connect(std::string host);
59 
63  void disconnect();
64 
68  bool pmacIsConnected();
69 
73  void sendCommand(PmacCommand& command);
74 
80  void readResponse(PmacCommand& command);
81 
82  //------------------------------------------------------------
83  // Methods which will be used to read and write register values.
84  // These methods will send a the appropriate command to the pmac,
85  // and time out waiting for a response.
86  //------------------------------------------------------------
87 
92  void readReg(RegMapBlock *blk,
93  unsigned int first, unsigned int nreg,
94  unsigned int *value);
95 
99  void writeReg(RegMapBlock *blk,
100  unsigned int first, unsigned int nreg,
101  unsigned int *value);
102 
106  void* getMem(unsigned short offset, unsigned short length);
107 
111  void* setMem(unsigned short offset, unsigned short length,
112  unsigned char* data);
113 
117  std::string getIpAddress();
118 
122  void setIpAddress(std::string ipAddress);
123 
124  unsigned int ipStringToInt(std::string addr);
125  std::string ipIntToString(unsigned int);
126 
127  private:
128 
132  SzaShare* share_;
133 
137  int fd_;
138 
142  fd_set read_fds_;
143 
147  int fd_set_size_;
148 
152  bool connected_;
153 
158  PmacCommand command_;
159 
163  bool responsePending_;
164 
168  void serviceMsgQ();
169 
174  void zeroReadFds();
175 
180  void registerReadFd(int fd);
181 
186  int waitForNextMessage();
187 
191  int waitForResponse();
192 
200  void* getResponse(PmacCommand& command);
201 
202  }; // End class PmacComms
203 
204  }; // End namespace control
205  }; // End namespace antenna
206 }; // End namespace sza
207 
208 #endif // End #ifndef
Tagged: Thu Nov 13 16:53:43 UTC 2003.