baf52dacd8003c3ac6d43bfef7073aae9e871e3b
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 put all managers in one str...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

27)  * @param[in] dirBase base directory
28)  */
Stefan Schuermans put all managers in one str...

Stefan Schuermans authored 12 years ago

29) Priority::Priority(Mgrs &mgrs, const Directory &dirBase):
30)   Module(mgrs, dirBase),
31)   m_fileOutStream(dirBase.getFile("outstream"), mgrs.m_streamMgr),
Stefan Schuermans created template class for...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

47)   // input list update
48)   m_inListTracker.updateConfig();
Stefan Schuermans implemented priority based...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

51)   if (m_fileOutStream.checkModified())
52)     m_fileOutStream.update();
Stefan Schuermans implemented priority based...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

103)     m_fileOutStream.setFrame(NULL);