-
Notifications
You must be signed in to change notification settings - Fork 16
/
ttxpagestream.cpp
144 lines (130 loc) · 3.25 KB
/
ttxpagestream.cpp
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#include "ttxpagestream.h"
TTXPageStream::TTXPageStream() :
_transitionTime(0),
_CarouselPage(NULL),
_fileStatus(NEW),
_loadedPacket29(false),
_loadedCustomHeader(false),
_isCarousel(false),
_isSpecial(false),
_isNormal(false),
_isUpdated(false),
_updateCount(0)
{
//ctor
}
TTXPageStream::TTXPageStream(std::string filename) :
TTXPage(filename),
_transitionTime(0),
_CarouselPage(NULL),
_fileStatus(NEW),
_loadedPacket29(false),
_loadedCustomHeader(false),
_isCarousel(false),
_isSpecial(false),
_isNormal(false),
_isUpdated(false),
_updateCount(0)
{
struct stat attrib; // create a file attribute structure
stat(filename.c_str(), &attrib); // get the attributes of the file
_modifiedTime=attrib.st_mtime;
}
TTXPageStream::~TTXPageStream()
{
//dtor
}
TTXLine* TTXPageStream::GetTxRow(uint8_t row)
{
// Return a line OR NULL if the row does not exist
TTXLine* line=NULL;
if (IsCarousel())
{
line=_CarouselPage->GetRow(row);
}
else // single page
{
line=GetRow(row); // _lineCounter is implied
}
if (line!=NULL) // Found a line
{
return line;
}
// No more lines? return NULL.
return NULL;
}
void TTXPageStream::StepNextSubpageNoLoop()
{
if (_CarouselPage==NULL)
_CarouselPage=this;
else
_CarouselPage=_CarouselPage->Getm_SubPage();
}
void TTXPageStream::StepNextSubpage()
{
StepNextSubpageNoLoop();
if (_CarouselPage==NULL) // Last carousel subpage? Loop to beginning
_CarouselPage=this;
}
bool TTXPageStream::LoadPage(std::string filename)
{
bool Loaded=false;
//m_Init(); // Careful! We should move inits to the initialisation list and call the default constructor
m_PageNumber=FIRSTPAGE; // Force to replace the root page rather than add to the carousel
if (m_LoadTTI(filename))
Loaded=true;
return Loaded;
}
bool TTXPageStream::operator==(const TTXPageStream& rhs) const
{
if (this->GetSourcePage()==rhs.GetSourcePage())
return true;
return false;
}
void TTXPageStream::IncrementUpdateCount()
{
_updateCount = (_updateCount + 1) % 8;
}
void TTXPageStream::SetTransitionTime(int cycleTime)
{
if (GetCycleTimeMode() == 'T')
{
vbit::MasterClock *mc = mc->Instance();
_transitionTime = mc->GetMasterClock().seconds + cycleTime;
}
else
{
_cyclesRemaining=cycleTime;
}
}
bool TTXPageStream::Expired(bool StepCycles)
{
// Has carousel timer expired
if (GetCycleTimeMode() == 'T')
{
vbit::MasterClock *mc = mc->Instance();
return _transitionTime <= mc->GetMasterClock().seconds;
}
else
{
if (StepCycles)
{
_cyclesRemaining--;
_cyclesRemaining = (_cyclesRemaining<0)?0:_cyclesRemaining;
}
return _cyclesRemaining == 0;
}
}
bool TTXPageStream::IsCarousel()
{
if (Getm_SubPage()!=NULL) // has subpages
{
return true;
}
if (GetCycleTimeMode() == 'T' && GetPageStatus() & PAGESTATUS_C9_INTERRUPTED)
{
// no subpages, but interrupted sequence flag is set, and page is in timed mode, so treat as a 1 page carousel
return true;
}
return false;
}