The VisAO Camera
frameserver.h
Go to the documentation of this file.
1 /************************************************************
2 * frameserver.h
3 *
4 * Author: Jared R. Males (jrmales@email.arizona.edu)
5 *
6 * Declarations for a class for serving frames over UDP.
7 *
8 * Developed as part of the Magellan Adaptive Optics system.
9 ************************************************************/
10 
11 /** \file frameserver.h
12  * \author Jared R. Males
13  * \brief Declarations for a class for serving frames over UDP.
14  *
15  *
16 */
17 
18 #ifndef __frameserver_h__
19 #define __frameserver_h__
20 
21 
22 #include "VisAOApp_standalone.h"
23 
24 #include "UdpConnection.h"
25 
26 #include "BcuLib/BcuCommon.h"
27 
28 #define FRAME_READY_FIFO_CH 0
29 
30 //#define _debug
31 
32 
33 namespace VisAO
34 {
35 
36 ///a class for serving frames over UDP.
37 /** \todo manage clearing the input ping channel better on frameserver
38  */
40 {
41 public:
42  frameserver(int argc, char **argv) throw (AOException);
43  frameserver(std::string name, const std::string &conffile) throw (AOException);
44 
45  int Create();
46 
47 protected:
48  std::string pingFifoPath;
49 
50  std::string remoteIP;
51 
52  int localPort;
53 
54  int remotePort;
55 
56  //unsigned fileno;
57  //unsigned ndigits;
58 
59  UdpConnection* conn;
60 
61  sharedim_stackS * sis; ///< Manages a VisAO shared memory image stack.
62 
63  int shmem_key;
64 
65  bool attached_to_shmem;
66 
67  sharedimS sim; ///<The sharedim structure retreived from the stack
68 
69  int behind; ///<The number of frames currently behind
70  int total_skipped; ///<The total number of frames skipped
71 
72  int frameSizeDw; ///<Size of the frame in DWORD
73  int packetsPerFrame; ///<No of UDP messages per frame
74 
75  BYTE sendBuff[Constants::MAX_ETH_PACKET_SIZE];
76 
77  ///Calculate frameSizeDW and packetsPerFrame
78  int calc_packetsPerFrame(int frameSizeBytes, int bitsPerPix);
79 
80  int _MAX_TDP_PACKET_SIZE;
81  int _MAX_ETH_PACKET_SIZE;
82 
83 public:
84  int setPingFifoPath(std::string &);
85  std::string getPingFifoPath(){return pingFifoPath;}
86 
87  int setRemoteIp(std::string &);
88  std::string getRemoteIp(){return remoteIP;}
89 
90  int setLocalPort(int);
91  int getLocalPort(){return localPort;}
92 
93  int setRemotePort(int);
94  int getRemotePort(){return remotePort;}
95 
96 
97 
98  int set_sharedim_stack(sharedim_stackS *);
99  sharedim_stackS * get_sharedim_stack(){return sis;}
100 
101  int set_shmem_key(int sk);
102  int get_shmem_key(){return shmem_key;}
103  int connect_shmem();
104 
105  int set_sim(sharedimS s);
106  sharedimS get_sim(){return sim;}
107 
108  int get_total_skipped(){return total_skipped;}
109 
110  virtual int Run();
111 
112  ///Send the frame, packet by packet, as if we're a BCU 47
113  /** \todo modify to allow for the case where the last packet has less than 16 bytes, so the footer starts in 2nd to last packet.
114  */
115  int send_frame();
116 
117 
118 };
119 
120 void frame_ready_handler(int signum, siginfo_t *siginf, void *ucont);
121 
122 //read one of the dio channel fifos
123 int frame_ready(fifo_channel *fc);
124 
125 } //namespace VisAO
126 
127 #endif //__frameserver_h__
128 
virtual int Run()
The application main loop, to be re-implemented in derived classes.
int packetsPerFrame
No of UDP messages per frame.
Definition: frameserver.h:73
int send_frame()
Send the frame, packet by packet, as if we're a BCU 47.
The standalone VisAO application, does not interface with the AO Supervisor.
Declarations for the standalone VisAO application.
sharedim_stackS * sis
Manages a VisAO shared memory image stack.
Definition: frameserver.h:61
a class for serving frames over UDP.
Definition: frameserver.h:39
int frameSizeDw
Size of the frame in DWORD.
Definition: frameserver.h:72
int behind
The number of frames currently behind.
Definition: frameserver.h:69
int total_skipped
The total number of frames skipped.
Definition: frameserver.h:70
int calc_packetsPerFrame(int frameSizeBytes, int bitsPerPix)
Calculate frameSizeDW and packetsPerFrame.
sharedimS sim
The sharedim structure retreived from the stack.
Definition: frameserver.h:67
The namespace of VisAO software.