f87ca9819b41e4c91cd3f8597d76cf0f065bb9f0
Stefan Schuermans MCUF sender module implemented

Stefan Schuermans authored 12 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 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 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 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

47) 
Stefan Schuermans implemented dynamic destina...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

80) 
Stefan Schuermans now repeating frames after...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

96) protected:
Stefan Schuermans sender static destination n...

Stefan Schuermans authored 12 years ago

97)   /**
98)    * @brief free static destiation list
99)    * @param[in] destList static destination list to free
100)    */
101)   void freeDestList(DestList &destList);
102) 
Stefan Schuermans MCUF sender module implemented

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

118)    * @param[in] destList static destinations for protocol
Stefan Schuermans MCUF sender module implemented

Stefan Schuermans authored 12 years ago

119)    */
Stefan Schuermans sender static destination n...

Stefan Schuermans authored 12 years ago

120)   void updateDestsLight(DestList &destList);
Stefan Schuermans MCUF sender module implemented

Stefan Schuermans authored 12 years ago

121) 
122)   /**
123)    * @brief full update of static destinations,
124)    *        i.e. scan files in playlist directory
Stefan Schuermans now repeating frames after...

Stefan Schuermans authored 12 years ago

125)    * @param[in] dirDests static destinations directory for protocol
Stefan Schuermans sender static destination n...

Stefan Schuermans authored 12 years ago

126)    * @param[in] destList static destinations for protocol
Stefan Schuermans merged frame processing wit...

Stefan Schuermans authored 12 years ago

127)    * @param[in] pNoFrameData "no frame" protocol data
Stefan Schuermans MCUF sender module implemented

Stefan Schuermans authored 12 years ago

128)    */
Stefan Schuermans sender static destination n...

Stefan Schuermans authored 12 years ago

129)   void updateDestsFull(Directory &dirDests, DestList &destList,
130)                        const std::string *pNoFrameData);
Stefan Schuermans MCUF sender module implemented

Stefan Schuermans authored 12 years ago

131) 
Stefan Schuermans implemented dynamic destina...

Stefan Schuermans authored 12 years ago

132)   /// remove timed-out dynamic destinations
133)   void removeTimedOutDynDests();
134) 
Stefan Schuermans simplified implementation o...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

137) 
138)   /// send "no frame" to all destinations
139)   void sendAllNoFrame();
140) 
141)   /**
142)    * @brief send data to static/dynamic destinations
Stefan Schuermans sender static destination n...

Stefan Schuermans authored 12 years ago

143)    * @param[in] data *pData protocol data to send
144)    * @param[in] destList static destinations
Stefan Schuermans added stream name to stream...

Stefan Schuermans authored 12 years ago

145)    * @param[in] dynDests dynamic destinations
146)    */
Stefan Schuermans sender static destination n...

Stefan Schuermans authored 12 years ago

147)   void sendDests(const std::string *pData, const DestList destList,
Stefan Schuermans added stream name to stream...

Stefan Schuermans authored 12 years ago

148)                  const DynDests dynDests);
149) 
Stefan Schuermans MCUF sender module implemented

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

151)    * @brief send protocol data to address
Stefan Schuermans now repeating frames after...

Stefan Schuermans authored 12 years ago

152)    * @param[in] data protcol data of frame
Stefan Schuermans MCUF sender module implemented

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

156) 
157)   /**
Stefan Schuermans now repeating frames after...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

160)    * @param[in] proto Blinken protocol identifier
161)    * @param[out] data protcol data
Stefan Schuermans MCUF sender module implemented

Stefan Schuermans authored 12 years ago

162)    */
Stefan Schuermans implemented dynamic destina...

Stefan Schuermans authored 12 years ago

163)   static void frame2data(stBlinkenFrame *pFrame, etBlinkenProto proto,
164)                          std::string &data);
Stefan Schuermans now repeating frames after...

Stefan Schuermans authored 12 years ago

165) 
Stefan Schuermans implemented dynamic destina...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

168) 
169) protected:
Stefan Schuermans sender static destination n...

Stefan Schuermans authored 12 years ago

170)   SettingFile m_fileInStream;    ///< input stream name file
171)   SettingFile m_fileBind;        ///< bind address file
172)   Directory   m_dirDestsBlp;     ///< static BLP destinations directory
173)   Directory   m_dirDestsEblp;    ///< static EBLP destinations directory
174)   Directory   m_dirDestsMcuf;    ///< static MCUF destinations directory
175)   std::string m_nameInStream;    ///< name of input stream
176)   Stream      *m_pInStream;      ///< input stream
177)   SOCK        *m_pSock;          ///< socket to use for sending streams
178)   DestList    m_destListBlp;     ///< static BLP destinations
179)   DestList    m_destListEblp;    ///< static EBLP destinations
180)   DestList    m_destListMcuf;    ///< static MCUF destinations
181)   DynDests    m_dynDestsBlp;     ///< dynamic BLP destinations
182)   DynDests    m_dynDestsEblp;    ///< dynamic EBLP destinations
183)   DynDests    m_dynDestsMcuf;    ///< dynamic MCUF destinations
184)   std::string m_noFrameDataBlp;  ///< "no frame" BLP protocol data
185)   std::string m_noFrameDataEblp; ///< "no frame" EBLP protocol data
186)   std::string m_noFrameDataMcuf; ///< "no frame" MCUF protocol data
187)   std::string m_dataBlp;         ///< current BLP protocol data
188)   std::string m_dataEblp;        ///< current BLP protocol data
189)   std::string m_dataMcuf;        ///< current BLP protocol data