My Project
 All Classes Files Functions Variables Enumerations Enumerator Friends Macros Pages
Scanner.h
1 #ifndef GCP_GRABBER_SCANNER_H
2 #define GCP_GRABBER_SCANNER_H
3 
11 #include <valarray>
12 
13 #include "gcp/util/common/GenericTask.h"
14 #include "gcp/util/common/NetStr.h"
15 #include "gcp/util/common/TcpClient.h"
16 #include "gcp/util/common/TimeOut.h"
17 
18 #include "gcp/grabber/common/Image.h"
19 #include "gcp/grabber/common/ScannerMsg.h"
20 
21 namespace gcp {
22  namespace grabber {
23 
24  class FrameGrabber;
25  class Master;
26 
27  class Scanner :
28  public gcp::util::GenericTask<ScannerMsg> {
29 
30  public:
31 
35  Scanner(Master* parent, bool simulate);
36 
40  virtual ~Scanner();
41 
42  private:
43 
44  // A vector of image objects maintained by this task
45 
46  std::vector<Image> images_;
47 
48  // Which image we are currently integrating
49 
50  unsigned count_;
51 
52  unsigned channel_;
53 
54  // An object that will handle timeouts for the Scanner task.
55 
56  gcp::util::TimeOut timeOut_;
57 
58  // A mask of channels to sample on each interval
59 
60  unsigned intervalMask_;
61 
62  // When sendImages() is called, this mask will record which images
63  // remain to be sent
64 
65  unsigned remainMask_;
66  bool storeAsFlatfield_;
67 
68  // Master will access private members of this class.
69 
70  friend class Master;
71 
72  // A private pointer to the parent class
73 
74  Master* parent_;
75 
79  FrameGrabber* fg_;
80 
84  bool simulate_;
85 
90  std::valarray<unsigned short> image_;
91 
95  gcp::util::TcpClient client_;
96 
101  gcp::util::NetStr* netStr_;
102 
106  void parseGreeting();
107 
111  bool connect();
112 
116  void disconnect();
117 
121  void connectScanner(bool reEnable);
122 
126  void disconnectScanner();
127 
133  void processMsg(ScannerMsg* taskMsg);
134 
138  void serviceMsgQ();
139 
143  void sendScannerConnectedMsg(bool connected);
144 
148  static NET_READ_HANDLER(netMsgReadHandler);
149 
153  static NET_SEND_HANDLER(imageSentHandler);
154 
158  static NET_ERROR_HANDLER(netErrorHandler);
159 
163  void addGrabberImage(Image& image);
164 
168  void packImage(Image& image);
169 
170  // Send multiple sequential images
171 
172  void sendImages(unsigned chanMask, bool storeAsFlatfield);
173 
174  // Send an image
175 
176  void sendNextImage();
177  void sendImage(Image& image, bool storeAsFlatfield);
178 
179  }; // End class Scanner
180 
181  } // End namespace grabber
182 }; // End namespace gcp
183 
184 
185 
186 
187 #endif // End #ifndef GCP_GRABBER_SCANNER_H
Definition: NetStr.h:21
virtual ~Scanner()
Definition: Scanner.cc:74
Scanner(Master *parent, bool simulate)
Definition: Scanner.cc:21
Definition: TimeOut.h:20
Definition: TcpClient.h:18
Definition: GenericTask.h:33