69ac12fcb8ee5ac55fadc04d3a96a3a7c2d0038a
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) 
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 13 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 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 "Directory.h"
17) #include "File.h"
Stefan Schuermans implemented specialized set...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

19) #include "IoCallee.h"
Stefan Schuermans put all managers in one str...

Stefan Schuermans authored 12 years ago

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

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

25) #include "SettingFile.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 13 years ago

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

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

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

44)   /// static destination list tracker
45)   typedef ListTracker<Sender, Dest, Directory> DestListTracker;
Stefan Schuermans MCUF sender module implemented

Stefan Schuermans authored 13 years ago

46) 
Stefan Schuermans implemented dynamic destina...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 13 years ago

50) public:
51)   /**
52)    * @brief constructor
Stefan Schuermans make modules know their name

Stefan Schuermans authored 12 years ago

53)    * @param[in] name module name
Stefan Schuermans put all managers in one str...

Stefan Schuermans authored 12 years ago

54)    * @param[in] mgrs managers
Stefan Schuermans MCUF sender module implemented

Stefan Schuermans authored 13 years ago

55)    * @param[in] dirBase base directory
56)    */
Stefan Schuermans make modules know their name

Stefan Schuermans authored 12 years ago

57)   Sender(const std::string &name, Mgrs &mgrs, const Directory &dirBase);
Stefan Schuermans MCUF sender module implemented

Stefan Schuermans authored 13 years ago

58) 
59)   /// virtual destructor
60)   virtual ~Sender();
61) 
62) private:
63)   /// copy constructor disabled
64)   Sender(const Sender &that);
65) 
66)   /// assignment operator disabled
67)   const Sender & operator=(const Sender &that);
68) 
69) public:
70)   /// check for update of configuration
71)   virtual void updateConfig();
72) 
73)   /**
74)    * @brief set current frame
Stefan Schuermans added stream name to stream...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 13 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 13 years ago

79) 
Stefan Schuermans fixed comment typo

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 13 years ago

81)   virtual void timeCall();
82) 
Stefan Schuermans implemented dynamic destina...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 13 years ago

95) protected:
Stefan Schuermans simplified sender module a...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

98) 
Stefan Schuermans MCUF sender module implemented

Stefan Schuermans authored 13 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

119) 
Stefan Schuermans MCUF sender module implemented

Stefan Schuermans authored 13 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 13 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 13 years ago

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

Stefan Schuermans authored 13 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 13 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 13 years ago

133) 
Stefan Schuermans implemented dynamic destina...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 13 years ago

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

Stefan Schuermans authored 12 years ago

138)   InStreamFile    m_fileInStream;    ///< input stream name file
139)   AddrFile        m_fileBind;        ///< bind address file
140)   ProtocolFile    m_fileProtocol;    ///< protocol file
141)   SOCK            *m_pSock;          ///< socket to use for sending streams
142)   DestListTracker m_destListTracker; ///< static destinations tracker
143)   DynDests        m_dynDests;        ///< dynamic destinations
Stefan Schuermans 80 char reformatting

Stefan Schuermans authored 12 years ago

144)   std::string     m_noFrameData;     /**< "no frame" protocol data
145)                                           (empty if unknown) */
146)   std::string     m_data;            /**< current protocol data
147)                                           (empty if unknown) */
Stefan Schuermans MCUF sender module implemented

Stefan Schuermans authored 13 years ago

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

Stefan Schuermans authored 12 years ago

152) #endif // #ifndef BLINKER_SENDER_H