587ae25b84177c5af73d1794bba555c6643b39bd
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) 
Stefan Schuermans namespace for preprocessor...

Stefan Schuermans authored 12 years ago

6) #ifndef BLINKER_SENDER_H
7) #define BLINKER_SENDER_H
Stefan Schuermans MCUF sender module implemented

Stefan Schuermans authored 12 years ago

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 converted sender to use lis...

Stefan Schuermans authored 12 years ago

22) #include "ListTracker.h"
Stefan Schuermans simplified sender module a...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

43)   class Dest;
44) 
Stefan Schuermans converted sender to use lis...

Stefan Schuermans authored 12 years ago

45)   /// static destination list tracker
46)   typedef ListTracker<Sender, Dest, Directory> DestListTracker;
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 fixed comment typo

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

99) 
Stefan Schuermans MCUF sender module implemented

Stefan Schuermans authored 12 years ago

100)   /// create socket and bind it
101)   void createSock();
102) 
103)   /// destroy socket
104)   void destroySock();
105) 
Stefan Schuermans implemented dynamic destina...

Stefan Schuermans authored 12 years ago

106)   /// remove timed-out dynamic destinations
107)   void removeTimedOutDynDests();
108) 
Stefan Schuermans simplified implementation o...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

111) 
112)   /// send "no frame" to all destinations
113)   void sendAllNoFrame();
114) 
115)   /**
116)    * @brief send data to static/dynamic destinations
Stefan Schuermans sender static destination n...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

120) 
Stefan Schuermans MCUF sender module implemented

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

122)    * @brief send protocol data to address
Stefan Schuermans typo

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

127) 
128)   /**
Stefan Schuermans now repeating frames after...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

130)    * @param[in] pFrame frame (NULL for none)
Stefan Schuermans typo

Stefan Schuermans authored 12 years ago

131)    * @param[out] data protocol data
Stefan Schuermans MCUF sender module implemented

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

134) 
Stefan Schuermans implemented dynamic destina...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

137) 
138) protected:
Stefan Schuermans converted sender to use lis...

Stefan Schuermans authored 12 years ago

139)   InStreamFile    m_fileInStream;    ///< input stream name file
140)   AddrFile        m_fileBind;        ///< bind address file
141)   ProtocolFile    m_fileProtocol;    ///< protocol file
142)   SOCK            *m_pSock;          ///< socket to use for sending streams
143)   DestListTracker m_destListTracker; ///< static destinations tracker
144)   DynDests        m_dynDests;        ///< dynamic destinations
145)   std::string     m_noFrameData;     ///< "no frame" protocol data (empty if unknown)
146)   std::string     m_data;            ///< current protocol data (empty if unknown)
Stefan Schuermans MCUF sender module implemented

Stefan Schuermans authored 12 years ago

147) }; // class Sender
148) 
149) } // namespace Blinker
150) 
Stefan Schuermans namespace for preprocessor...

Stefan Schuermans authored 12 years ago

151) #endif // #ifndef BLINKER_SENDER_H