7eaa394e64baed2b37cd0cfacc7fb08ddaadbe27
Stefan Schuermans MCUF sender module implemented

Stefan Schuermans authored 13 years ago

1) /* Blinker
2)    Copyright 2011 Stefan Schuermans <stefan@blinkenarea.org>
3)    Copyleft GNU public license - http://www.gnu.org/copyleft/gpl.html
4)    a blinkenarea.org project */
5) 
6) #ifndef SENDER_H
7) #define SENDER_H
8) 
9) #include <list>
Stefan Schuermans implemented dynamic destina...

Stefan Schuermans authored 13 years ago

10) #include <map>
Stefan Schuermans MCUF sender module implemented

Stefan Schuermans authored 13 years ago

11) #include <string>
12) 
Stefan Schuermans implemented dynamic destina...

Stefan Schuermans authored 13 years ago

13) #include <BlinkenLib/BlinkenProto.h>
Stefan Schuermans MCUF sender module implemented

Stefan Schuermans authored 13 years ago

14) #include <BlinkenLib/BlinkenFrame.h>
15) 
16) #include "CallMgr.h"
17) #include "Directory.h"
18) #include "File.h"
Stefan Schuermans implemented dynamic destina...

Stefan Schuermans authored 13 years ago

19) #include "IoCallee.h"
Stefan Schuermans MCUF sender module implemented

Stefan Schuermans authored 13 years ago

20) #include "Module.h"
Stefan Schuermans simplified sender module a...

Stefan Schuermans authored 12 years ago

21) #include "Protocol.h"
Stefan Schuermans MCUF sender module implemented

Stefan Schuermans authored 13 years ago

22) #include "SettingFile.h"
23) #include "StreamMgr.h"
24) #include "StreamRecv.h"
Stefan Schuermans implemented dynamic destina...

Stefan Schuermans authored 13 years ago

25) #include "Time.h"
Stefan Schuermans now repeating frames after...

Stefan Schuermans authored 13 years ago

26) #include "TimeCallee.h"
Stefan Schuermans MCUF sender module implemented

Stefan Schuermans authored 13 years ago

27) 
28) namespace Blinker {
29) 
30) /// stream sender
31) template<typename ADDR, typename SOCK>
Stefan Schuermans implemented dynamic destina...

Stefan Schuermans authored 13 years ago

32) class Sender: public IoCallee, public Module, public StreamRecv,
33)               public TimeCallee
Stefan Schuermans MCUF sender module implemented

Stefan Schuermans authored 13 years ago

34) {
35) protected:
36)   /// static destination
Stefan Schuermans sender static destination n...

Stefan Schuermans authored 13 years ago

37)   class Dest;
38) 
39)   /// static destination list entry
40)   struct DestEntry {
41)     std::string m_name;   ///< name of static destination
42)     Dest        *m_pDest; ///< static destination object
43)     DestEntry(const std::string &name); ///< constructor
Stefan Schuermans MCUF sender module implemented

Stefan Schuermans authored 13 years ago

44)   };
45) 
46)   /// static destinations
Stefan Schuermans sender static destination n...

Stefan Schuermans authored 13 years ago

47)   typedef std::list<DestEntry> DestList;
Stefan Schuermans MCUF sender module implemented

Stefan Schuermans authored 13 years ago

48) 
Stefan Schuermans implemented dynamic destina...

Stefan Schuermans authored 13 years ago

49)   /// dynamic destinations: address -> time of last request
50)   typedef std::map<ADDR, Time> DynDests;
51) 
Stefan Schuermans MCUF sender module implemented

Stefan Schuermans authored 13 years ago

52) public:
53)   /**
54)    * @brief constructor
55)    * @param[in] callMgr callback manager
56)    * @param[in] streamMgr stream manager
57)    * @param[in] dirBase base directory
58)    */
59)   Sender(CallMgr &callMgr, StreamMgr &streamMgr, const Directory &dirBase);
60) 
61)   /// virtual destructor
62)   virtual ~Sender();
63) 
64) private:
65)   /// copy constructor disabled
66)   Sender(const Sender &that);
67) 
68)   /// assignment operator disabled
69)   const Sender & operator=(const Sender &that);
70) 
71) public:
72)   /// check for update of configuration
73)   virtual void updateConfig();
74) 
75)   /**
76)    * @brief set current frame
Stefan Schuermans added stream name to stream...

Stefan Schuermans authored 13 years ago

77)    * @param[in] stream stream name
Stefan Schuermans merged frame processing wit...

Stefan Schuermans authored 12 years ago

78)    * @param[in] pFrame current frame (NULL for none)
Stefan Schuermans MCUF sender module implemented

Stefan Schuermans authored 13 years ago

79)    */
Stefan Schuermans added stream name to stream...

Stefan Schuermans authored 13 years ago

80)   virtual void setFrame(const std::string &stream, stBlinkenFrame *pFrame);
Stefan Schuermans MCUF sender module implemented

Stefan Schuermans authored 13 years ago

81) 
Stefan Schuermans now repeating frames after...

Stefan Schuermans authored 13 years ago

82)   /// callback when requsted time reached
83)   virtual void timeCall();
84) 
Stefan Schuermans implemented dynamic destina...

Stefan Schuermans authored 13 years ago

85)   /**
86)    * @brief callback when I/O object is readable
87)    * @param[in] io I/O object that is readable
88)    */
89)   virtual void ioReadCall(Io *io);
90) 
91)   /**
92)    * @brief callback when I/O object is writable
93)    * @param[in] io I/O object that is writable
94)    */
95)   virtual void ioWriteCall(Io *io);
96) 
Stefan Schuermans MCUF sender module implemented

Stefan Schuermans authored 13 years ago

97) protected:
Stefan Schuermans simplified sender module a...

Stefan Schuermans authored 12 years ago

98)   /// (re-)read protocol
99)   void readProto();
Stefan Schuermans sender static destination n...

Stefan Schuermans authored 13 years ago

100) 
Stefan Schuermans MCUF sender module implemented

Stefan Schuermans authored 13 years ago

101)   /// get input stream and attach to it
102)   void getInStream();
103) 
104)   /// detach from input stream and release it
105)   void releaseInStream();
106) 
107)   /// create socket and bind it
108)   void createSock();
109) 
110)   /// destroy socket
111)   void destroySock();
112) 
113)   /**
114)    * @brief light update of static destinations,
115)    *        i.e. stat all files in current static destination directory
116)    */
Stefan Schuermans simplified sender module a...

Stefan Schuermans authored 12 years ago

117)   void updateDestsLight();
Stefan Schuermans MCUF sender module implemented

Stefan Schuermans authored 13 years ago

118) 
119)   /**
120)    * @brief full update of static destinations,
121)    *        i.e. scan files in playlist directory
122)    */
Stefan Schuermans simplified sender module a...

Stefan Schuermans authored 12 years ago

123)   void updateDestsFull();
Stefan Schuermans MCUF sender module implemented

Stefan Schuermans authored 13 years ago

124) 
Stefan Schuermans implemented dynamic destina...

Stefan Schuermans authored 13 years ago

125)   /// remove timed-out dynamic destinations
126)   void removeTimedOutDynDests();
127) 
Stefan Schuermans simplified implementation o...

Stefan Schuermans authored 13 years ago

128)   /// send current protocol data to all destinations
129)   void sendAllProto();
Stefan Schuermans added stream name to stream...

Stefan Schuermans authored 13 years ago

130) 
131)   /// send "no frame" to all destinations
132)   void sendAllNoFrame();
133) 
134)   /**
135)    * @brief send data to static/dynamic destinations
Stefan Schuermans sender static destination n...

Stefan Schuermans authored 13 years ago

136)    * @param[in] data *pData protocol data to send
Stefan Schuermans added stream name to stream...

Stefan Schuermans authored 13 years ago

137)    */
Stefan Schuermans simplified sender module a...

Stefan Schuermans authored 12 years ago

138)   void sendDests(const std::string *pData);
Stefan Schuermans added stream name to stream...

Stefan Schuermans authored 13 years ago

139) 
Stefan Schuermans MCUF sender module implemented

Stefan Schuermans authored 13 years ago

140)   /**
Stefan Schuermans simplified implementation o...

Stefan Schuermans authored 13 years ago

141)    * @brief send protocol data to address
Stefan Schuermans simplified sender module a...

Stefan Schuermans authored 12 years ago

142)    * @param[in] data protcol data of frame (empty if unknown)
Stefan Schuermans MCUF sender module implemented

Stefan Schuermans authored 13 years ago

143)    * @param[in] addr address to send to
144)    */
Stefan Schuermans simplified implementation o...

Stefan Schuermans authored 13 years ago

145)   void sendProto(const std::string &data, const ADDR &addr) const;
Stefan Schuermans MCUF sender module implemented

Stefan Schuermans authored 13 years ago

146) 
147)   /**
Stefan Schuermans now repeating frames after...

Stefan Schuermans authored 13 years ago

148)    * @brief convert frame to protocol data
Stefan Schuermans merged frame processing wit...

Stefan Schuermans authored 12 years ago

149)    * @param[in] pFrame frame (NULL for none)
Stefan Schuermans now repeating frames after...

Stefan Schuermans authored 13 years ago

150)    * @param[out] data protcol data
Stefan Schuermans MCUF sender module implemented

Stefan Schuermans authored 13 years ago

151)    */
Stefan Schuermans simplified sender module a...

Stefan Schuermans authored 12 years ago

152)   void frame2data(stBlinkenFrame *pFrame, std::string &data) const;
Stefan Schuermans now repeating frames after...

Stefan Schuermans authored 13 years ago

153) 
Stefan Schuermans implemented dynamic destina...

Stefan Schuermans authored 13 years ago

154)   /// receive data from socket
155)   void receiveFromSock();
Stefan Schuermans MCUF sender module implemented

Stefan Schuermans authored 13 years ago

156) 
157) protected:
Stefan Schuermans simplified sender module a...

Stefan Schuermans authored 12 years ago

158)   SettingFile m_fileInStream; ///< input stream name file
159)   SettingFile m_fileBind;     ///< bind address file
160)   SettingFile m_fileProtocol; ///< protocol file
161)   Directory   m_dirDests;     ///< static destinations directory
162)   std::string m_nameInStream; ///< name of input stream
163)   Stream      *m_pInStream;   ///< input stream
164)   SOCK        *m_pSock;       ///< socket to use for sending streams
165)   Protocol    m_protocol;     ///< protocol
166)   bool        m_haveProtocol; ///< if protocol is known
167)   DestList    m_destList;     ///< static destinations
168)   DynDests    m_dynDests;     ///< dynamic destinations
169)   std::string m_noFrameData;  ///< "no frame" protocol data (empty if unknown)
170)   std::string m_data;         ///< current protocol data (empty if unknown)