73f8b3775895f79280668f6c3660f3a0c4fe4e5b
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 MCUF sender module implemented

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

86) 
Stefan Schuermans now repeating frames after...

Stefan Schuermans authored 12 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 12 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 12 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 12 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 12 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 12 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 12 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 12 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 simplified implementation o...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

143) 
144)   /// send "no frame" to all destinations
145)   void sendAllNoFrame();
146) 
147)   /**
148)    * @brief send data to static/dynamic destinations
Stefan Schuermans sender static destination n...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

154)                  const DynDests dynDests);
155) 
Stefan Schuermans MCUF sender module implemented

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

162) 
163)   /**
Stefan Schuermans now repeating frames after...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

171) 
172)   /**
173)    * @brief get "no frame" protocol data
174)    * @param[in] proto Blinken protocol identifier
175)    * @param[out] data protcol data
176)    */
Stefan Schuermans implemented dynamic destina...

Stefan Schuermans authored 12 years ago

177)   static void noFrame2data(etBlinkenProto proto, std::string &data);
178) 
179)   /// receive data from socket
180)   void receiveFromSock();
Stefan Schuermans MCUF sender module implemented

Stefan Schuermans authored 12 years ago

181) 
182) protected:
Stefan Schuermans sender static destination n...

Stefan Schuermans authored 12 years ago

183)   SettingFile m_fileInStream;    ///< input stream name file
184)   SettingFile m_fileBind;        ///< bind address file
185)   Directory   m_dirDestsBlp;     ///< static BLP destinations directory
186)   Directory   m_dirDestsEblp;    ///< static EBLP destinations directory
187)   Directory   m_dirDestsMcuf;    ///< static MCUF destinations directory
188)   std::string m_nameInStream;    ///< name of input stream
189)   Stream      *m_pInStream;      ///< input stream
190)   SOCK        *m_pSock;          ///< socket to use for sending streams
191)   DestList    m_destListBlp;     ///< static BLP destinations
192)   DestList    m_destListEblp;    ///< static EBLP destinations
193)   DestList    m_destListMcuf;    ///< static MCUF destinations
194)   DynDests    m_dynDestsBlp;     ///< dynamic BLP destinations
195)   DynDests    m_dynDestsEblp;    ///< dynamic EBLP destinations
196)   DynDests    m_dynDestsMcuf;    ///< dynamic MCUF destinations
197)   std::string m_noFrameDataBlp;  ///< "no frame" BLP protocol data
198)   std::string m_noFrameDataEblp; ///< "no frame" EBLP protocol data
199)   std::string m_noFrameDataMcuf; ///< "no frame" MCUF protocol data
200)   std::string m_dataBlp;         ///< current BLP protocol data
201)   std::string m_dataEblp;        ///< current BLP protocol data
202)   std::string m_dataMcuf;        ///< current BLP protocol data