My Project
 All Classes Files Functions Variables Enumerations Enumerator Friends Macros Pages
DioConsumer.h
Go to the documentation of this file.
1 #ifndef GCP_RECEIVER_DIOCONSUMER_H
2 #define GCP_RECEIVER_DIOCONSUMER_H
3 
11 #include "gcp/util/common/GenericTask.h"
12 #include "gcp/util/common/TimeVal.h"
13 #include "gcp/util/common/BoardDataFrameManager.h"
14 
15 #include "gcp/mediator/specific/DioMsg.h"
16 
17 namespace gcp {
18 
19  namespace mediator {
20  class Scanner;
21  }
22 
23  namespace util {
24  class RegMapDataFrameManager;
25  class ArrayMapDataFrameManager;
26  }
27 
28  namespace receiver {
29 
30  class DioClient;
31 
32  class DioConsumer :
33  public gcp::util::GenericTask<gcp::mediator::DioMsg> {
34 
35  public:
36 
37  virtual ~DioConsumer();
38 
39  // Service our message queue
40 
41  virtual void serviceMsgQ();
42 
43  // Process a message specific to this task.
44 
45  virtual void processMsg(gcp::mediator::DioMsg* msg) {};
46 
47  protected:
48 
49  // The DIO client object managed by this thread will have to
50  // contact the DIO server as well as the HardwareManager daemon
51  // for hardware configuration information.
52 
54  std::string dioHost, unsigned short dioPort,
55  std::string hwHost, unsigned short hwPort);
56 
57  // We declare Scanner a friend so that it alone can instantiate
58  // this class.
59 
60  friend class gcp::mediator::Scanner;
61 
62  // Needed to call Scanner::packFrame() on receipt of an event
63 
64  gcp::mediator::Scanner* parent_;
65 
66  // Members pertaining to the data connection to the DIO server
67 
68  std::string dioHost_; // Data server host name
69  unsigned short dioPort_; // Data server TCP port
70 
71  // Members pertaining to the connection to the hardware manager
72 
73  std::string hwHost_; // Hardware manager server host name
74  unsigned short hwPort_; // Hardwarea manager TCP port
75 
76  // A timer that will be used as a timeout in select()
77 
78  gcp::util::TimeVal timer_;
79  struct timeval* timeOut_;
80 
81  // Connects to data server, requests data and converts data stream into
82  // map of vectors, one vector per data channel
83 
84  DioClient* dioClient_;
85 
86  // Set the timeout until the next connection attempt
87 
88  void resetTimeout();
89 
90  // Set the timeout until the next connection attempt
91 
92  void clearTimeout();
93 
94  // Pack a data frame
95 
96  virtual void packFrame() {};
97 
99  void releaseReadFrame();
100 
101  // Copy stored values of persistent items into the register
102  // frame
103 
104  virtual void
106 
107  virtual gcp::util::BoardDataFrameManager& getFrame() {};
108 
109  public:
110 
111  // Check for from the DIO Client
112 
113  void checkForDioData();
114 
115  }; // End class DioConsumer
116 
117  } // End namespace receiver
118 } // End namespace gcp
119 
120 #endif // End #ifndef
121 
Definition: BoardDataFrameManager.h:31
Definition: DioClient.h:28
virtual void serviceMsgQ()
Definition: DioConsumer.cc:45
void resetTimeout()
Definition: DioConsumer.cc:122
void releaseReadFrame()
Definition: DioConsumer.cc:152
Definition: DioMsg.h:16
Definition: Scanner.h:58
virtual ~DioConsumer()
Definition: DioConsumer.cc:34
virtual void processMsg(gcp::mediator::DioMsg *msg)
Definition: DioConsumer.h:45
void checkForDioData()
Definition: DioConsumer.cc:78
DioConsumer(gcp::mediator::Scanner *parent, std::string dioHost, unsigned short dioPort, std::string hwHost, unsigned short hwPort)
Definition: DioConsumer.cc:17
Definition: ArrayMapDataFrameManager.h:28
Definition: TimeVal.h:55
gcp::util::RegMapDataFrameManager * grabReadFrame()
Definition: DioConsumer.cc:144
virtual void copyPersistentRegs(gcp::util::ArrayMapDataFrameManager *frame)
Definition: DioConsumer.cc:162
Definition: RegMapDataFrameManager.h:26
Definition: DioConsumer.h:32
Definition: GenericTask.h:33
void clearTimeout()
Definition: DioConsumer.cc:133