69ac12fcb8ee5ac55fadc04d3a96a3a7c2d0038a
Stefan Schuermans implemented priority based...

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) #include <list>
7) #include <string>
8) 
9) #include <BlinkenLib/BlinkenFrame.h>
10) 
11) #include "Directory.h"
12) #include "File.h"
Stefan Schuermans created template class for...

Stefan Schuermans authored 12 years ago

13) #include "ListTracker.h"
14) #include "ListTracker_impl.h"
Stefan Schuermans put all managers in one str...

Stefan Schuermans authored 12 years ago

15) #include "Mgrs.h"
Stefan Schuermans implemented priority based...

Stefan Schuermans authored 12 years ago

16) #include "Module.h"
17) #include "Priority.h"
18) #include "PriorityInput.h"
Stefan Schuermans implemented specialized set...

Stefan Schuermans authored 12 years ago

19) #include "OutStreamFile.h"
Stefan Schuermans implemented priority based...

Stefan Schuermans authored 12 years ago

20) #include "StreamRecv.h"
21) 
22) namespace Blinker {
23) 
24) /**
25)  * @brief constructor
Stefan Schuermans make modules know their name

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

27)  * @param[in] mgrs managers
Stefan Schuermans implemented priority based...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

30) Priority::Priority(const std::string &name, Mgrs &mgrs,
31)                    const Directory &dirBase):
32)   Module(name, mgrs, dirBase),
Stefan Schuermans put all managers in one str...

Stefan Schuermans authored 12 years ago

33)   m_fileOutStream(dirBase.getFile("outstream"), mgrs.m_streamMgr),
Stefan Schuermans created template class for...

Stefan Schuermans authored 12 years ago

34)   m_inListTracker(*this, dirBase.getSubdir("inputs")),
35)   m_itCurIn(m_inListTracker.m_list.rend())
Stefan Schuermans implemented priority based...

Stefan Schuermans authored 12 years ago

36) {
Stefan Schuermans add forgotten call to init...

Stefan Schuermans authored 12 years ago

37)   m_inListTracker.init();
Stefan Schuermans implemented priority based...

Stefan Schuermans authored 12 years ago

38) }
39) 
40) /// virtual destructor
41) Priority::~Priority()
42) {
Stefan Schuermans add forgotten call to init...

Stefan Schuermans authored 12 years ago

43)   m_inListTracker.clear();
Stefan Schuermans implemented priority based...

Stefan Schuermans authored 12 years ago

44) }
45) 
46) /// check for update of configuration
47) void Priority::updateConfig()
48) {
Stefan Schuermans created template class for...

Stefan Schuermans authored 12 years ago

49)   // input list update
50)   m_inListTracker.updateConfig();
Stefan Schuermans implemented priority based...

Stefan Schuermans authored 12 years ago

51) 
52)   // output stream name file was modified -> re-get output stream
Stefan Schuermans implemented specialized set...

Stefan Schuermans authored 12 years ago

53)   if (m_fileOutStream.checkModified())
54)     m_fileOutStream.update();
Stefan Schuermans implemented priority based...

Stefan Schuermans authored 12 years ago

55) }
56) 
57) /**
58)  * @brief select specific input (called by inputs)
59)  * @param[in] input input to select
60)  */
61) void Priority::select(const Input *pInput)
62) {
63)   // search inputs for passed input
Stefan Schuermans created template class for...

Stefan Schuermans authored 12 years ago

64)   m_itCurIn = m_inListTracker.m_list.rbegin();
65)   while (m_itCurIn != m_inListTracker.m_list.rend() &&
66)          m_itCurIn->m_pObj != pInput)
Stefan Schuermans implemented priority based...

Stefan Schuermans authored 12 years ago

67)     ++m_itCurIn;
68) 
69)   // send current frame
70)   curFrame();
71) }
72) 
73) /// select lower priority input (called by inputs)
74) void Priority::selectLower()
75) {
76)   stBlinkenFrame *pFrame;
77) 
78)   // search inputs with lower priority until a frame is found
Stefan Schuermans created template class for...

Stefan Schuermans authored 12 years ago

79)   while (m_itCurIn != m_inListTracker.m_list.rend()) {
Stefan Schuermans implemented priority based...

Stefan Schuermans authored 12 years ago

80)     // check for frame
Stefan Schuermans created template class for...

Stefan Schuermans authored 12 years ago

81)     if ((pFrame = m_itCurIn->m_pObj->getCurFrame())) {
Stefan Schuermans implemented priority based...

Stefan Schuermans authored 12 years ago

82)       // frame found -> keep this input as current, send frame
Stefan Schuermans implemented specialized set...

Stefan Schuermans authored 12 years ago

83)       m_fileOutStream.setFrame(pFrame);
Stefan Schuermans implemented priority based...

Stefan Schuermans authored 12 years ago

84)       return;
85)     }
86)     // try next input
87)     ++m_itCurIn;
88)   }
89) 
90)   // no input has got a frame -> send no frame
Stefan Schuermans implemented specialized set...

Stefan Schuermans authored 12 years ago

91)   m_fileOutStream.setFrame(NULL);
Stefan Schuermans implemented priority based...

Stefan Schuermans authored 12 years ago

92) }
93) 
94) /// send current frame to output stream
95) void Priority::curFrame()
96) {
97)   stBlinkenFrame *pFrame;
98) 
99)   // current input available and frame it it available -> send frame
Stefan Schuermans created template class for...

Stefan Schuermans authored 12 years ago

100)   if (m_itCurIn != m_inListTracker.m_list.rend() &&
101)       (pFrame = m_itCurIn->m_pObj->getCurFrame()))
Stefan Schuermans implemented specialized set...

Stefan Schuermans authored 12 years ago

102)     m_fileOutStream.setFrame(pFrame);
Stefan Schuermans implemented priority based...

Stefan Schuermans authored 12 years ago

103)   // no frame available -> send this information
104)   else
Stefan Schuermans implemented specialized set...

Stefan Schuermans authored 12 years ago

105)     m_fileOutStream.setFrame(NULL);