3d0756408108848263cb2d8ee2e2fa7af2919085
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 "CallMgr.h"
12) #include "Directory.h"
13) #include "File.h"
Stefan Schuermans created template class for...

Stefan Schuermans authored 12 years ago

14) #include "ListTracker.h"
15) #include "ListTracker_impl.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 "StreamMgr.h"
21) #include "StreamRecv.h"
22) 
23) namespace Blinker {
24) 
25) /**
26)  * @brief constructor
27)  * @param[in] callMgr callback manager
28)  * @param[in] streamMgr stream manager
29)  * @param[in] dirBase base directory
30)  */
Stefan Schuermans implemented specialized set...

Stefan Schuermans authored 12 years ago

31) Priority::Priority(CallMgr &callMgr, StreamMgr &streamMgr,
32)                    const Directory &dirBase):
Stefan Schuermans implemented priority based...

Stefan Schuermans authored 12 years ago

33)   Module(callMgr, streamMgr, dirBase),
Stefan Schuermans implemented specialized set...

Stefan Schuermans authored 12 years ago

34)   m_fileOutStream(dirBase.getFile("outstream"), streamMgr),
Stefan Schuermans created template class for...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

37) {
38) }
39) 
40) /// virtual destructor
41) Priority::~Priority()
42) {
43) }
44) 
45) /// check for update of configuration
46) void Priority::updateConfig()
47) {
Stefan Schuermans created template class for...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

104)     m_fileOutStream.setFrame(NULL);