-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathcarousel.cpp
More file actions
89 lines (76 loc) · 2.66 KB
/
Copy pathcarousel.cpp
File metadata and controls
89 lines (76 loc) · 2.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include "carousel.h"
using namespace vbit;
Carousel::Carousel(int mag, PageList *pageList, Debug *debug) :
_mag(mag),
_pageList(pageList),
_debug(debug)
{
//ctor
}
Carousel::~Carousel()
{
//dtor
}
void Carousel::addPage(std::shared_ptr<TTXPageStream> p)
{
// @todo Don't allow duplicate entries
p->SetCarouselFlag(true);
int t = 1;
if (std::shared_ptr<Subpage> s = p->GetSubpage())
t += s->GetCycleTime();
p->SetTransitionTime(t);
_carouselList.push_front(p);
}
std::shared_ptr<TTXPageStream> Carousel::nextCarousel()
{
std::shared_ptr<TTXPageStream> p;
if (_carouselList.size()==0) return nullptr;
for (std::list<std::shared_ptr<TTXPageStream>>::iterator it=_carouselList.begin();it!=_carouselList.end();++it)
{
p=*it;
if (p->GetOneShotFlag())
{
p->SetCarouselFlag(false);
_carouselList.erase(it--);
continue;
}
if (p->GetLock()) // try to lock this page against changes
{
if (p->GetIsMarked() && p->GetCarouselFlag()) // only remove it once
{
std::stringstream ss;
ss << "[Carousel::nextCarousel] Deleted " << std::hex << (p->GetPageNumber());
_debug->Log(Debug::LogLevels::logINFO,ss.str());
p->SetCarouselFlag(false);
_carouselList.erase(it--);
_pageList->RemovePage(p); // try to remove it from the pagelist immediately - will free the lock
continue; // jump back to loop
}
else if ((!(p->IsCarousel())) || p->Special())
{
std::stringstream ss;
ss << "[Carousel::nextCarousel] no longer a carousel " << std::hex << (p->GetPageNumber());
_debug->Log(Debug::LogLevels::logINFO,ss.str());
p->SetCarouselFlag(false);
_carouselList.erase(it--);
}
else
{
if (p->Expired())
{
// We found a carousel that is ready to step
if (std::shared_ptr<Subpage> s = p->GetSubpage()) // make sure there is a subpage
{
if (s->GetSubpageStatus() & PAGESTATUS_C9_INTERRUPTED)
{
// carousel should go out now out of sequence
return p; // return page locked
}
}
}
}
p->FreeLock(); // unlock
}
}
return nullptr;
}