Skip to content

Commit

Permalink
use _isSpecial and _isCarousel flags only for managing removal of poi…
Browse files Browse the repository at this point in the history
…nters from special and carousel lists.

Make carousel time a minimum duration and reset timeout on next magazine cycle *unless* interrupted sequence flag is set, in which case output the subpage on strict timings
  • Loading branch information
ZXGuesser committed Sep 15, 2019
1 parent da7d6d5 commit a12c44d
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 117 deletions.
29 changes: 17 additions & 12 deletions carousel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,26 @@ TTXPageStream* Carousel::nextCarousel()
_carouselList.remove(p);
return nullptr;
}

if (p->Expired())
else if ((!(p->IsCarousel())) || (p->Special()))
{
// We found a carousel that is ready to step
p->StepNextSubpage();
p->SetTransitionTime(p->GetCarouselPage()->GetCycleTime());
break;
std::cerr << "[Carousel::nextCarousel] no longer a carousel " << std::hex << p->GetPageNumber() << std::endl;
_carouselList.remove(p);
p->SetCarouselFlag(false);
return nullptr;
}
else
{
if (p->Expired())
{
// We found a carousel that is ready to step
if (p->GetCarouselPage()->GetPageStatus() & PAGESTATUS_C9_INTERRUPTED)
{
// carousel should go out now out of sequence
return p;
}
}
}
p=nullptr;
}
#if 0
char c;
std::cin >> c;
if (c=='x')
exit(3);
#endif
return p;
}
126 changes: 33 additions & 93 deletions filemonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,96 +118,30 @@ void FileMonitor::run()
q->GetPageCount(); // renumber the subpages
int mag=(q->GetPageNumber() >> 16) & 0x7;

if (q->GetSpecialFlag())
if ((!(q->GetSpecialFlag())) && (q->Special()))
{
// Page was 'special'
q->SetSpecialFlag(q->Special());
q->SetCarouselFlag(q->IsCarousel());
if (!(q->Special()))
{
// Page is longer 'special'
// TODO: remove from SpecialPages list
_pageList->GetMagazines()[mag]->GetSpecialPages()->deletePage(q);

if (q->IsCarousel())
{
// Page is a 'carousel', add to Carousel list
_pageList->GetMagazines()[mag]->GetCarousel()->addPage(q);
std::cerr << "[FileMonitor::run] page was special, is now a carousel " << std::hex << q->GetPageNumber() << std::endl;
}
else
{
// Page is 'normal', add to NormalPages list
_pageList->GetMagazines()[mag]->GetNormalPages()->addPage(q);
std::cerr << "[FileMonitor::run] page was special, is now normal " << std::hex << q->GetPageNumber() << std::endl;
_pageList->GetMagazines()[mag]->GetNormalPages()->sortPages(); // TODO: add pages in correct place in list
}
}
else
{
// no change
//std::cerr << "[FileMonitor::run] page remains special " << std::hex << q->GetPageNumber() << std::endl;
}
// page was not 'special' but now is, add to SpecialPages list
q->SetSpecialFlag(true);
_pageList->GetMagazines()[mag]->GetSpecialPages()->addPage(q);
std::cerr << "[FileMonitor::run] page was normal, is now special " << std::hex << q->GetPageNumber() << std::endl;
// page will be removed from NormalPages list by the service thread
// page will be removed from Carousel list by the service thread
}
else if (q->GetCarouselFlag())
else if ((q->GetSpecialFlag()) && (!(q->Special())))
{
// Page was 'carousel'
q->SetSpecialFlag(q->Special());
q->SetCarouselFlag(q->IsCarousel());
if (!(q->IsCarousel()) || q->Special())
{
// Page is no longer a 'carousel'
// TODO: remove from Carousel list
_pageList->GetMagazines()[mag]->GetCarousel()->deletePage(q);

if (q->Special())
{
// Page is 'special', add to SpecialPages list
_pageList->GetMagazines()[mag]->GetSpecialPages()->addPage(q);
std::cerr << "[FileMonitor::run] page was carousel, is now special " << std::hex << q->GetPageNumber() << std::endl;
}
else
{
// Page is 'normal', add to NormalPages list
_pageList->GetMagazines()[mag]->GetNormalPages()->addPage(q);
std::cerr << "[FileMonitor::run] page was carousel, is now normal " << std::hex << q->GetPageNumber() << std::endl;
_pageList->GetMagazines()[mag]->GetNormalPages()->sortPages(); // TODO: add pages in correct place in list
}
}
else
{
// no change
//std::cerr << "[FileMonitor::run] page remains a carousel " << std::hex << q->GetPageNumber() << std::endl;
}
// page was 'special' but now isn't, add to NormalPages list
_pageList->GetMagazines()[mag]->GetNormalPages()->addPage(q);
std::cerr << "[FileMonitor::run] page was special, is now normal " << std::hex << q->GetPageNumber() << std::endl;
_pageList->GetMagazines()[mag]->GetNormalPages()->sortPages(); // TODO: add pages in correct place in list
}
else

if ((!(q->Special())) && (!(q->GetCarouselFlag())) && q->IsCarousel())
{
// Page was 'normal'
q->SetSpecialFlag(q->Special());
q->SetCarouselFlag(q->IsCarousel());
if (q->Special() || q->IsCarousel())
{
// Page is no longer 'normal'
// page will be removed from NormalPages list by the service thread

if (q->Special())
{
// Page is 'special', add to SpecialPages list
_pageList->GetMagazines()[mag]->GetSpecialPages()->addPage(q);
std::cerr << "[FileMonitor::run] page was normal, is now special " << std::hex << q->GetPageNumber() << std::endl;
}
else if (q->IsCarousel())
{
// Page is a 'carousel', add to Carousel list
_pageList->GetMagazines()[mag]->GetCarousel()->addPage(q);
std::cerr << "[FileMonitor::run] page was normal, is now a carousel " << std::hex << q->GetPageNumber() << std::endl;
}
}
else
{
// no change
//std::cerr << "[FileMonitor::run] page remains normal " << std::hex << q->GetPageNumber() << std::endl;
}
// 'normal' page was not 'carousel' but now is, add to Carousel list
q->SetCarouselFlag(true);
q->StepNextSubpage(); // ensure we're pointing at a subpage
_pageList->GetMagazines()[mag]->GetCarousel()->addPage(q);
std::cerr << "[FileMonitor::run] page is now a carousel " << std::hex << q->GetPageNumber() << std::endl;
}

if (_pageList->CheckForPacket29(q))
Expand Down Expand Up @@ -237,23 +171,29 @@ void FileMonitor::run()
if (q->Special())
{
// Page is 'special'
q->SetSpecialFlag(q->Special());
q->SetSpecialFlag(true);
q->SetCarouselFlag(false);
_pageList->GetMagazines()[mag]->GetSpecialPages()->addPage(q);
//std::cerr << "[FileMonitor::run] new page is special " << std::hex << q->GetPageNumber() << std::endl;
}
else if (q->IsCarousel())
{
// Page is a 'carousel'
q->SetCarouselFlag(q->IsCarousel());
_pageList->GetMagazines()[mag]->GetCarousel()->addPage(q);
//std::cerr << "[FileMonitor::run] new page is a carousel " << std::hex << q->GetPageNumber() << std::endl;
}
else
{
// Page is 'normal'
q->SetSpecialFlag(false);
_pageList->GetMagazines()[mag]->GetNormalPages()->addPage(q);
//std::cerr << "[FileMonitor::run] new page is normal " << std::hex << q->GetPageNumber() << std::endl;
_pageList->GetMagazines()[mag]->GetNormalPages()->sortPages();

if (q->IsCarousel())
{
// Page is also a 'carousel'
q->SetCarouselFlag(true);
q->StepNextSubpage(); // ensure we're pointing at a subpage
_pageList->GetMagazines()[mag]->GetCarousel()->addPage(q);
//std::cerr << "[FileMonitor::run] new page is a carousel " << std::hex << q->GetPageNumber() << std::endl;
}
else
q->SetCarouselFlag(false);
}

if (_pageList->CheckForPacket29(q))
Expand Down
4 changes: 2 additions & 2 deletions normalpages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ TTXPageStream* NormalPages::NextPage()
goto loop; // jump back to try for the next page
}

if (_page->GetSpecialFlag() || _page->GetSpecialFlag())
if (_page->Special())
{
std::cerr << "[NormalPages::NextPage] " << _page->GetSourcePage() << " became Special" << std::endl;
std::cerr << "[NormalPages::NextPage] page became Special" << std::hex << _page->GetPageNumber() << std::endl;
_iter = _NormalPagesList.erase(_iter);
_page = *_iter;
goto loop; // jump back to try for the next page
Expand Down
13 changes: 10 additions & 3 deletions packetmag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ Packet* PacketMag::GetPacket(Packet* p)
/* 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 */
} else {
// got to the end of the special pages
ClearEvent(EVENT_SPECIAL_PAGES);
return nullptr;
}
}
Expand All @@ -151,7 +152,13 @@ Packet* PacketMag::GetPacket(Packet* p)

_thisRow=0;

if (_page->GetCarouselFlag()){
if (_page->IsCarousel()){
if (_page->Expired())
{
// cycle if timer has expired
_page->StepNextSubpage();
_page->SetTransitionTime(_page->GetCarouselPage()->GetCycleTime());
}
thisSubcode=_page->GetCarouselPage()->GetSubCode();
_status=_page->GetCarouselPage()->GetPageStatus();
_region=_page->GetCarouselPage()->GetRegion();
Expand Down Expand Up @@ -195,7 +202,7 @@ Packet* PacketMag::GetPacket(Packet* p)
//p->Parity(13); // don't apply parity here it will screw up the template. parity for the header is done by tx() later
assert(p!=NULL);

if (_page->GetCarouselFlag()){
if (_page->IsCarousel()){
links=_page->GetCarouselPage()->GetLinkSet();
} else {
links=_page->GetLinkSet();
Expand Down Expand Up @@ -332,7 +339,7 @@ Packet* PacketMag::GetPacket(Packet* p)
//std::cerr << "TRACE-F " << std::endl;
// std::cerr << "PACKETSTATE_FASTEXT enters" << std::endl;
p->SetMRAG(_magNumber,27);
if (_page->GetCarouselFlag()){
if (_page->IsCarousel()){
links=_page->GetCarouselPage()->GetLinkSet();
} else {
links=_page->GetLinkSet();
Expand Down
20 changes: 13 additions & 7 deletions pagelist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,22 +407,28 @@ void PageList::PopulatePageTypeLists()
{
TTXPageStream* ptr;
ptr=&(*p);
if (ptr->Special() && !(ptr->GetSpecialFlag()))
if (ptr->Special())
{
// Page is 'special'
ptr->SetSpecialFlag(true);
ptr->SetCarouselFlag(false);
_mag[mag]->GetSpecialPages()->addPage(ptr);
}
else if (ptr->IsCarousel() && !(ptr->GetCarouselFlag()))
{
// Page is a 'carousel'
ptr->SetCarouselFlag(ptr->IsCarousel());
_mag[mag]->GetCarousel()->addPage(ptr);
}
else
{
// Page is 'normal'
ptr->SetSpecialFlag(false);
_mag[mag]->GetNormalPages()->addPage(ptr);

if (ptr->IsCarousel())
{
// Page is also 'carousel'
ptr->SetCarouselFlag(true);
_mag[mag]->GetCarousel()->addPage(ptr);
ptr->StepNextSubpage();
}
else
ptr->SetCarouselFlag(false);
}
}

Expand Down
8 changes: 8 additions & 0 deletions specialpages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ TTXPageStream* SpecialPages::NextPage()
ResetIter();
return nullptr;
}
else if (!(_page->Special()))
{
std::cerr << "[SpecialPages::NextPage()] no longer special " << std::hex << _page->GetPageNumber() << std::endl;
_specialPagesList.remove(_page);
_page->SetSpecialFlag(false);
ResetIter();
return nullptr;
}
}

return _page;
Expand Down

0 comments on commit a12c44d

Please sign in to comment.