173870b5a00925b8735decd6b7579cceecaafbbe
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 specialized set...

Stefan Schuermans authored 12 years ago

19) #include "InStreamFile.h"
Stefan Schuermans implemented dynamic destina...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

22) #include "Protocol.h"
Stefan Schuermans implemented specialized set...

Stefan Schuermans authored 12 years ago

23) #include "ProtocolFile.h"
Stefan Schuermans MCUF sender module implemented

Stefan Schuermans authored 12 years ago

24) #include "SettingFile.h"
25) #include "StreamMgr.h"
26) #include "StreamRecv.h"
Stefan Schuermans implemented dynamic destina...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

36) {
37) protected:
Stefan Schuermans implemented specialized set...

Stefan Schuermans authored 12 years ago

38)   /// type for address setting file
39)   typedef SettingFile<ADDR> AddrFile;
40) 
Stefan Schuermans MCUF sender module implemented

Stefan Schuermans authored 12 years ago

41)   /// static destination
Stefan Schuermans sender static destination n...

Stefan Schuermans authored 12 years ago

42)   class Dest;
43) 
44)   /// static destination list entry
45)   struct DestEntry {
46)     std::string m_name;   ///< name of static destination
47)     Dest        *m_pDest; ///< static destination object
48)     DestEntry(const std::string &name); ///< constructor
Stefan Schuermans MCUF sender module implemented

Stefan Schuermans authored 12 years ago

49)   };
50) 
51)   /// static destinations
Stefan Schuermans sender static destination n...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

53) 
Stefan Schuermans implemented dynamic destina...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

86) 
Stefan Schuermans fixed comment typo

Stefan Schuermans authored 12 years ago

87)   /// callback when requested time reached
Stefan Schuermans now repeating frames after...

Stefan Schuermans authored 12 years ago

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 simplified sender module a...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

105) 
Stefan Schuermans MCUF sender module implemented

Stefan Schuermans authored 12 years ago

106)   /// create socket and bind it
107)   void createSock();
108) 
109)   /// destroy socket
110)   void destroySock();
111) 
112)   /**
113)    * @brief light update of static destinations,
114)    *        i.e. stat all files in current static destination directory
115)    */
Stefan Schuermans simplified sender module a...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

123) 
Stefan Schuermans implemented dynamic destina...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

138) 
Stefan Schuermans MCUF sender module implemented

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

152) 
Stefan Schuermans implemented dynamic destina...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

155) 
156) protected:
Stefan Schuermans implemented specialized set...

Stefan Schuermans authored 12 years ago

157)   InStreamFile m_fileInStream; ///< input stream name file
158)   AddrFile     m_fileBind;     ///< bind address file
159)   ProtocolFile m_fileProtocol; ///< protocol file
160)   Directory    m_dirDests;     ///< static destinations directory
161)   SOCK         *m_pSock;       ///< socket to use for sending streams
162)   DestList     m_destList;     ///< static destinations
163)   DynDests     m_dynDests;     ///< dynamic destinations
164)   std::string  m_noFrameData;  ///< "no frame" protocol data (empty if unknown)
165)   std::string  m_data;         ///< current protocol data (empty if unknown)