Skip to content

Commit

Permalink
implement update counter (S2 bits) for special pages.
Browse files Browse the repository at this point in the history
  • Loading branch information
ZXGuesser committed May 23, 2018
1 parent df7aaa2 commit 5077457
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 14 deletions.
1 change: 1 addition & 0 deletions filemonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ void FileMonitor::run()
// We need a mutex or semaphore to lock out this page while we do that
// lock
p->LoadPage(name); // What if this fails? We can see the bool. What to do ?
p->IncrementUpdateCount();
p->GetPageCount(); // renumber the subpages
int mag=(p->GetPageNumber() >> 16) & 0x7;
if (p->IsCarousel() && !(p->GetCarouselFlag()) && !(p->Special()))
Expand Down
7 changes: 4 additions & 3 deletions packetmag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,17 @@ Packet* PacketMag::GetPacket(Packet* p)
{
_status = _page->GetCarouselPage()->GetPageStatus() & 0x8000; // get transmit flag
_region = _page->GetCarouselPage()->GetRegion();
thisSubcode=_page->GetCarouselPage()->GetSubCode() & 0x000F; // will break if carousel has more than 16 subpages but that would be out of spec anyway.
thisSubcode |= _page->GetCarouselPage()->GetLastPacket() << 8;
thisSubcode = (_page->GetCarouselPage()->GetSubCode() & 0x000F) | (_page->GetCarouselPage()->GetLastPacket() << 8);
}
else
{
_status = _page->GetPageStatus() & 0x8000; // get transmit flag
_region = _page->GetRegion();
thisSubcode = _page->GetLastPacket() << 8; // S3 and S4
thisSubcode = (_page->GetSubCode() & 0x000F) | (_page->GetLastPacket() << 8);
}

thisSubcode |= _page->GetUpdateCount() << 4;

/* rules for the control bits are complicated. There are rules to allow the page to be sent as fragments. Since we aren't doing that, all the flags are left clear except for C9 (interrupted sequence) to keep special pages out of rolling headers */
_status |= 0x0010;
/* rules for the subcode are really complicated. The S1 nibble should be the sub page number, S2 is a counter that increments when the page is updated, S3 and S4 hold the last row number */
Expand Down
28 changes: 17 additions & 11 deletions ttxpagestream.cpp
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
#include "ttxpagestream.h"

TTXPageStream::TTXPageStream() :
_isCarousel(false),
_transitionTime(0),
_CarouselPage(NULL),
_fileStatus(NEW),
_isSpecial(false)
_isCarousel(false),
_transitionTime(0),
_CarouselPage(NULL),
_fileStatus(NEW),
_isSpecial(false),
_updateCount(0)
{
//ctor
}

TTXPageStream::TTXPageStream(std::string filename) :
TTXPage(filename),
_isCarousel(false),
_transitionTime(0),
_CarouselPage(NULL),
_fileStatus(NEW),
_isSpecial(false)
TTXPage(filename),
_isCarousel(false),
_transitionTime(0),
_CarouselPage(NULL),
_fileStatus(NEW),
_isSpecial(false),
_updateCount(0)
{
struct stat attrib; // create a file attribute structure
stat(filename.c_str(), &attrib); // get the attributes of the file
Expand Down Expand Up @@ -88,3 +90,7 @@ bool TTXPageStream::operator==(const TTXPageStream& rhs) const
return true;
return false;
}

void TTXPageStream::IncrementUpdateCount(){
_updateCount = (_updateCount + 1) % 8;
}
6 changes: 6 additions & 0 deletions ttxpagestream.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ class TTXPageStream : public TTXPage

bool GetSpecialFlag() { return _isSpecial; }
void SetSpecialFlag(bool val) { _isSpecial = val; }

int GetUpdateCount() {return _updateCount;}
void IncrementUpdateCount();

///** Access _CurrentPage
//* \return The current value of _CurrentPage
Expand Down Expand Up @@ -142,6 +145,9 @@ class TTXPageStream : public TTXPage
bool _Selected; /// Marked as selected by the inserter P command

bool _isSpecial;

int _updateCount; // update counter for special pages.

};

#endif // _TTXPAGESTREAM_H_

0 comments on commit 5077457

Please sign in to comment.