Skip to content

Commit

Permalink
Fixed up typos
Browse files Browse the repository at this point in the history
  • Loading branch information
peterkvt80 committed Sep 27, 2017
2 parents f523569 + eb7b85b commit 333b788
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 20 deletions.
11 changes: 8 additions & 3 deletions packet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void Packet::SetRow(int mag, int row, std::string val, PageCoding coding)
SetPacketText(val);
_coding = coding;

// The following block of code is experimental support for page enhancement
// The following block of code is for page enhancement
// packets read from special OL rows in tti page files.
// If OL,28, packet is used the page file should not contain a non zero RE,
if (coding == CODING_13_TRIPLETS)
Expand All @@ -60,8 +60,13 @@ void Packet::SetRow(int mag, int row, std::string val, PageCoding coding)
SetTriplet(i, triplet);
}
}

// end of experimental page enhancement code
else if (coding == CODING_HAMMING_8_4)
{
for (int i = 0; i<40; i++)
{
_packet[5+i] = HamTab[_packet[5+i] & 0x0F];
}
}
}

Packet::~Packet()
Expand Down
30 changes: 18 additions & 12 deletions packetmag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ Packet* PacketMag::GetPacket(Packet* p)
unsigned int thisSubcode;
int thisStatus;
int* links=NULL;
bool special;
PageFunction func;

static vbit::Packet* filler=new Packet(8,25," "); // filler

Expand Down Expand Up @@ -79,8 +77,14 @@ Packet* PacketMag::GetPacket(Packet* p)
{
// got a special page

if (_page->GetPageFunction() == MIP)
{
// Magazine Inventory Page
ClearEvent(EVENT_FIELD); // enforce 20ms page erasure interval
}

/* 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 */
thisStatus=0x0010;
thisStatus=0x8010;

/* 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 that will be transmitted for this page which needs calculating somehow. */
if (_page->IsCarousel())
Expand Down Expand Up @@ -167,9 +171,7 @@ Packet* PacketMag::GetPacket(Packet* p)
}
}

func = _page->GetPageFunction();
special = (func == GPOP || func == POP || func == GDRCS || func == DRCS || func == MOT || func == MIP);
if (special && _page->GetSpecialFlag()){
if (_page->Special() && _page->GetSpecialFlag()){
// don't let special pages into normal sequence
return nullptr;
}
Expand All @@ -194,11 +196,9 @@ Packet* PacketMag::GetPacket(Packet* p)
}

// the function of a page changes
func = _page->GetPageFunction();
special = (func == GPOP || func == POP || func == GDRCS || func == DRCS || func == MOT || func == MIP);
if (special != _page->GetSpecialFlag()){
_page->SetSpecialFlag(special);
if (special){
if (_page->Special() != _page->GetSpecialFlag()){
_page->SetSpecialFlag(_page->Special());
if (_page->Special()){
std::cerr << "page became special " << std::hex << _page->GetPageNumber() << std::endl;
_specialPages->addPage(_page);
return nullptr;
Expand All @@ -207,6 +207,12 @@ Packet* PacketMag::GetPacket(Packet* p)
_specialPages->deletePage(_page);
}
}

if (!(thisStatus & 0x8000))
{
_page=nullptr;
return nullptr;
}

// Assemble the header. (we can simplify this code or leave it for the optimiser)
thisPageNum=_page->GetPageNumber();
Expand Down Expand Up @@ -383,7 +389,7 @@ bool PacketMag::IsReady(bool force)
// We can always send something unless
// 1) We have just sent out a header and are waiting on a new field
// 2) There are no pages
if ( ((GetEvent(EVENT_FIELD)) || GetEvent(EVENT_SPECIAL_PAGES) || (_state==PACKETSTATE_HEADER)) && (_pageSet->size()>0))
if ( ((GetEvent(EVENT_FIELD)) || (_state==PACKETSTATE_HEADER)) && (_pageSet->size()>0))
{
// If we send a header we want to wait for this to get set GetEvent(EVENT_FIELD)
_priorityCount--;
Expand Down
27 changes: 24 additions & 3 deletions ttxpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,9 @@ void TTXPage::SetRow(unsigned int rownumber, std::string line)
case 2:
m_pagecoding = CODING_13_TRIPLETS;
break;
case 3:
m_pagecoding = CODING_HAMMING_8_4;
break;
}

switch (triplet & 0x0F){
Expand Down Expand Up @@ -870,12 +873,11 @@ int TTXPage::GetPageCount()
int count=0;
unsigned int subcode; // Start from 1.
int code[4];
PageFunction func = GetPageFunction();

// PageFunction func = GetPageFunction();
for (int i=0;i<4;i++) code[i]=0;
for (TTXPage* p=this;p!=nullptr;p=p->m_SubPage)
{
if (func == GPOP || func == POP || func == GDRCS || func == DRCS || func == MOT || func == MIP){
if (Special()){
// "Special" pages (e.g. MOT, POP, GPOP, DRCS, GDRCS, MIP) should be coded sequentially in hexadecimal 0000-000F
subcode = count;
}
Expand Down Expand Up @@ -965,6 +967,25 @@ void TTXPage::SetPageNumber(int page)
//std::cerr << "PageNumber changed from " << std::hex << m_PageNumber << " to ";
m_PageNumber=page;
//std::cerr << std::hex << m_PageNumber << std::endl;

// compare page tens and units to reserved page numbers and set page function and coding as required
switch ((page >> 8) & 0xFF)
{
case 0xF0: // Basic Top Table
m_pagefunction = BTT;
m_pagecoding = CODING_HAMMING_8_4;
break;

case 0xFD: // Magazine Organisation Table
m_pagefunction = MOT;
m_pagecoding = CODING_HAMMING_8_4;
break;

case 0xFE: // Magazine Inventory Page
m_pagefunction = MIP;
m_pagecoding = CODING_HAMMING_8_4;
break;
}
}

int TTXPage::GetFastextLink(int link)
Expand Down
6 changes: 4 additions & 2 deletions ttxpage.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#define MAXROW 28

// @todo more page codings
enum PageCoding {CODING_7BIT_TEXT,CODING_8BIT_DATA,CODING_13_TRIPLETS};
enum PageCoding {CODING_7BIT_TEXT,CODING_8BIT_DATA,CODING_13_TRIPLETS,CODING_HAMMING_8_4};
enum PageFunction {LOP, DATABROADCAST, GPOP, POP, GDRCS, DRCS, MOT, MIP, BTT, AIT, MPT, MPT_EX};

class TTXPage
Expand Down Expand Up @@ -203,6 +203,8 @@ class TTXPage
PageCoding GetPageCoding() {return m_pagecoding;}
PageFunction GetPageFunction() {return m_pagefunction;}

bool Special() {return (m_pagefunction == GPOP || m_pagefunction == POP || m_pagefunction == GDRCS || m_pagefunction == DRCS || m_pagefunction == MOT || m_pagefunction == MIP);} // more convenient way to tell if a page is special.

/** @todo migrate this deep copy into the standard copy constructor
* Warning. Only deep copies the top page. Not for carousels (yet)
*/
Expand Down Expand Up @@ -272,7 +274,7 @@ class TTXPage
*/
bool m_LoadTTX(std::string filename);

bool _elected; /// True if this page has been selected.
bool _Selected; /// True if this page has been selected.

};

Expand Down

0 comments on commit 333b788

Please sign in to comment.