be034cc96d34aa01038f1a292188af801b236043
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 12 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 12 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 12 years ago

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

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

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

Stefan Schuermans authored 13 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 13 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 13 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 13 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 13 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 MCUF sender module implemented

Stefan Schuermans authored 13 years ago

77)    * @param[in] pFrame current frame
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 13 years ago

80) 
Stefan Schuermans added stream name to stream...

Stefan Schuermans authored 12 years ago

81)   /**
82)    * @brief set current frame to none
83)    * @param[in] stream stream name
84)    */
85)   virtual void setNoFrame(const std::string &stream);
Stefan Schuermans MCUF sender module implemented

Stefan Schuermans authored 13 years ago

86) 
Stefan Schuermans now repeating frames after...

Stefan Schuermans authored 13 years ago

87)   /// callback when requsted time reached
88)   virtual void timeCall();
89) 
Stefan Schuermans implemented dynamic destina...

Stefan Schuermans authored 12 years ago

90)   /**
91)    * @brief callback when I/O object is readable
92)    * @param[in] io I/O object that is readable
93)    */
94)   virtual void ioReadCall(Io *io);
95) 
96)   /**
97)    * @brief callback when I/O object is writable
98)    * @param[in] io I/O object that is writable
99)    */
100)   virtual void ioWriteCall(Io *io);
101) 
Stefan Schuermans MCUF sender module implemented

Stefan Schuermans authored 13 years ago

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

Stefan Schuermans authored 12 years ago

103)   /**
104)    * @brief free static destiation list
105)    * @param[in] destList static destination list to free
106)    */
107)   void freeDestList(DestList &destList);
108) 
Stefan Schuermans MCUF sender module implemented

Stefan Schuermans authored 13 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 13 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 13 years ago

127) 
128)   /**
129)    * @brief full update of static destinations,
130)    *        i.e. scan files in playlist directory
Stefan Schuermans now repeating frames after...

Stefan Schuermans authored 13 years ago

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

Stefan Schuermans authored 12 years ago

132)    * @param[in] destList static destinations for protocol
133)    * @param[in] pNoFrameData "no frame" protocaol data
Stefan Schuermans MCUF sender module implemented

Stefan Schuermans authored 13 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 13 years ago

137) 
Stefan Schuermans implemented dynamic destina...

Stefan Schuermans authored 12 years ago

138)   /// remove timed-out dynamic destinations
139)   void removeTimedOutDynDests();
140) 
Stefan Schuermans added stream name to stream...

Stefan Schuermans authored 12 years ago

141)   /**
142)    * @brief send frame to all destinations
143)    * @param[in] pFrame frame to send
144)    */
145)   void sendAllFrame(stBlinkenFrame *pFrame);
146) 
147)   /// send "no frame" to all destinations
148)   void sendAllNoFrame();
149) 
150)   /**
151)    * @brief send data to static/dynamic destinations
Stefan Schuermans sender static destination n...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

157)                  const DynDests dynDests);
158) 
Stefan Schuermans MCUF sender module implemented

Stefan Schuermans authored 13 years ago

159)   /**
160)    * @brief send current frame to address
161)    * @param[in] addr address to send to
Stefan Schuermans now repeating frames after...

Stefan Schuermans authored 13 years ago

162)    * @param[in] proto Blinken protocol identifier
Stefan Schuermans sender static destination n...

Stefan Schuermans authored 12 years ago

163)    TODO: still needed?
Stefan Schuermans MCUF sender module implemented

Stefan Schuermans authored 13 years ago

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

Stefan Schuermans authored 12 years ago

165)   void sendCurFrame(const ADDR &addr, etBlinkenProto proto) const;
Stefan Schuermans MCUF sender module implemented

Stefan Schuermans authored 13 years ago

166) 
167)   /**
Stefan Schuermans now repeating frames after...

Stefan Schuermans authored 13 years ago

168)    * @brief send "no frame" to address
Stefan Schuermans MCUF sender module implemented

Stefan Schuermans authored 13 years ago

169)    * @param[in] addr address to send to
Stefan Schuermans now repeating frames after...

Stefan Schuermans authored 13 years ago

170)    * @param[in] proto Blinken protocol identifier
Stefan Schuermans sender static destination n...

Stefan Schuermans authored 12 years ago

171)    TODO: still needed?
Stefan Schuermans MCUF sender module implemented

Stefan Schuermans authored 13 years ago

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

Stefan Schuermans authored 12 years ago

173)   void sendNoFrame(const ADDR &addr, etBlinkenProto proto) const;
Stefan Schuermans MCUF sender module implemented

Stefan Schuermans authored 13 years ago

174) 
175)   /**
Stefan Schuermans now repeating frames after...

Stefan Schuermans authored 13 years ago

176)    * @brief send frame to address
177)    * @param[in] data protcol data of frame
Stefan Schuermans MCUF sender module implemented

Stefan Schuermans authored 13 years ago

178)    * @param[in] addr address to send to
179)    */
Stefan Schuermans implemented dynamic destina...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 13 years ago

181) 
182)   /**
Stefan Schuermans now repeating frames after...

Stefan Schuermans authored 13 years ago

183)    * @brief convert frame to protocol data
Stefan Schuermans MCUF sender module implemented

Stefan Schuermans authored 13 years ago

184)    * @param[in] pFrame frame
Stefan Schuermans now repeating frames after...

Stefan Schuermans authored 13 years ago

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

Stefan Schuermans authored 13 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 13 years ago

190) 
191)   /**
192)    * @brief get "no frame" protocol data
193)    * @param[in] proto Blinken protocol identifier
194)    * @param[out] data protcol data
195)    */
Stefan Schuermans implemented dynamic destina...

Stefan Schuermans authored 12 years ago

196)   static void noFrame2data(etBlinkenProto proto, std::string &data);
197) 
198)   /// receive data from socket
199)   void receiveFromSock();
Stefan Schuermans MCUF sender module implemented

Stefan Schuermans authored 13 years ago

200) 
201) protected:
Stefan Schuermans sender static destination n...

Stefan Schuermans authored 12 years ago

202)   SettingFile m_fileInStream;    ///< input stream name file
203)   SettingFile m_fileBind;        ///< bind address file
204)   Directory   m_dirDestsBlp;     ///< static BLP destinations directory
205)   Directory   m_dirDestsEblp;    ///< static EBLP destinations directory
206)   Directory   m_dirDestsMcuf;    ///< static MCUF destinations directory
207)   std::string m_nameInStream;    ///< name of input stream
208)   Stream      *m_pInStream;      ///< input stream
209)   SOCK        *m_pSock;          ///< socket to use for sending streams
210)   DestList    m_destListBlp;     ///< static BLP destinations
211)   DestList    m_destListEblp;    ///< static EBLP destinations
212)   DestList    m_destListMcuf;    ///< static MCUF destinations
213)   DynDests    m_dynDestsBlp;     ///< dynamic BLP destinations
214)   DynDests    m_dynDestsEblp;    ///< dynamic EBLP destinations
215)   DynDests    m_dynDestsMcuf;    ///< dynamic MCUF destinations
216)   std::string m_noFrameDataBlp;  ///< "no frame" BLP protocol data
217)   std::string m_noFrameDataEblp; ///< "no frame" EBLP protocol data
218)   std::string m_noFrameDataMcuf; ///< "no frame" MCUF protocol data
219)   std::string m_dataBlp;         ///< current BLP protocol data
220)   std::string m_dataEblp;        ///< current BLP protocol data
221)   std::string m_dataMcuf;        ///< current BLP protocol data