Skip to content

Commit

Permalink
Remove automatic assignment of page function/coding based on page num…
Browse files Browse the repository at this point in the history
…ber.

Implement new .tti row type PF consisting of two comma separated hex digits for page and function as per ETS 300 706 section 9.4.2.1. e.g. PF,8,3 will set page function BTT and page coding CODING_HAMMING_8_4

The function and coding defined by the packet in an OL,28 row will overwrite the value set by a previous PF row and vice versa.
  • Loading branch information
ZXGuesser committed Sep 28, 2017
1 parent 333b788 commit e1561f7
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 78 deletions.
4 changes: 2 additions & 2 deletions packetmag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,11 @@ Packet* PacketMag::GetPacket(Packet* p)
if (_page->Special() != _page->GetSpecialFlag()){
_page->SetSpecialFlag(_page->Special());
if (_page->Special()){
std::cerr << "page became special " << std::hex << _page->GetPageNumber() << std::endl;
//std::cerr << "page became special " << std::hex << _page->GetPageNumber() << std::endl;
_specialPages->addPage(_page);
return nullptr;
} else {
std::cerr << "page became normal " << std::hex << _page->GetPageNumber() << std::endl;
//std::cerr << "page became normal " << std::hex << _page->GetPageNumber() << std::endl;
_specialPages->deletePage(_page);
}
}
Expand Down
149 changes: 74 additions & 75 deletions ttxpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,8 +429,8 @@ int TTXPage::findPageNumber(char* buf)

bool TTXPage::m_LoadTTI(std::string filename)
{
const std::string cmd[]={"DS","SP","DE","CT","PN","SC","PS","MS","OL","FL","RD","RE"};
const int cmdCount = 12; // There are 12 possible commands, maybe DT and RT too on really old files
const std::string cmd[]={"DS","SP","DE","CT","PN","SC","PS","MS","OL","FL","RD","RE","PF"};
const int cmdCount = 13; // There are 13 possible commands, maybe DT and RT too on really old files
unsigned int lineNumber;
int lines=0;
// Open the file
Expand Down Expand Up @@ -571,6 +571,16 @@ bool TTXPage::m_LoadTTI(std::string filename)
std::getline(filein, line); // TODO: Implement this
m_region=std::strtol(line.c_str(), &ptr, 16);
break;
case 12 : // "PF"; - not in the tti spec, page function and coding
std::getline(filein, line);
if (line.length()==3)
{
SetPageFunctionInt(std::strtol(line.substr(0,1).c_str(), &ptr, 16));
SetPageCodingInt(std::strtol(line.substr(2,1).c_str(), &ptr, 16));
}
else
std::cerr << "invalid page function/coding " << line << std::endl;
break;
default:
std::cerr << "Command not understood " << line << std::endl;
} // switch
Expand Down Expand Up @@ -674,60 +684,9 @@ void TTXPage::SetRow(unsigned int rownumber, std::string line)
int triplet = line.at(1) & 0x3F;
triplet |= (line.at(2) & 0x3F) << 6;
triplet |= (line.at(3) & 0x3F) << 12; // first triplet contains page function and coding

switch ((triplet & 0x70) >> 4){
default: // treat codings we don't know yet as normal text.
case 0:
m_pagecoding = CODING_7BIT_TEXT;
break;
case 1:
m_pagecoding = CODING_8BIT_DATA;
break;
case 2:
m_pagecoding = CODING_13_TRIPLETS;
break;
case 3:
m_pagecoding = CODING_HAMMING_8_4;
break;
}

switch (triplet & 0x0F){
default: // treat page functions we don't know as level one pages
case 0:
m_pagefunction = LOP;
break;
case 2:
m_pagefunction = GPOP;
break;
case 3:
m_pagefunction = POP;
break;
case 4:
m_pagefunction = GDRCS;
break;
case 5:
m_pagefunction = DRCS;
break;
case 7:
m_pagefunction = MOT;
break;
case 8:
m_pagefunction = MIP;
break;
case 9:
m_pagefunction = BTT;
break;
case 10:
m_pagefunction = AIT;
break;
case 11:
m_pagefunction = MPT;
break;
case 12:
m_pagefunction = MPT_EX;
break;
}

// function and coding packet 28 override values set by an earlier PF row
SetPageCodingInt((triplet & 0x70) >> 4);
SetPageFunctionInt(triplet & 0x0F);
m_region = 0; // ignore any region from RE line as X/28 sets the character set
}
}
Expand Down Expand Up @@ -967,25 +926,6 @@ 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 Expand Up @@ -1057,3 +997,62 @@ void TTXPage::Copy(TTXPage* src)
// Copy everything else
this->CopyMetaData(src);
}

void TTXPage::SetPageFunctionInt(int pageFunction)
{
switch (pageFunction){
default: // treat page functions we don't know as level one pages
case 0:
m_pagefunction = LOP;
break;
case 2:
m_pagefunction = GPOP;
break;
case 3:
m_pagefunction = POP;
break;
case 4:
m_pagefunction = GDRCS;
break;
case 5:
m_pagefunction = DRCS;
break;
case 6:
m_pagefunction = MOT;
break;
case 7:
m_pagefunction = MIP;
break;
case 8:
m_pagefunction = BTT;
break;
case 9:
m_pagefunction = AIT;
break;
case 10:
m_pagefunction = MPT;
break;
case 11:
m_pagefunction = MPT_EX;
break;
}
}

void TTXPage::SetPageCodingInt(int pageCoding)
{
switch (pageCoding){
default: // treat codings we don't know yet as normal text.
case 0:
m_pagecoding = CODING_7BIT_TEXT;
break;
case 1:
m_pagecoding = CODING_8BIT_DATA;
break;
case 2:
m_pagecoding = CODING_13_TRIPLETS;
break;
case 3:
m_pagecoding = CODING_HAMMING_8_4;
break;
}
}
7 changes: 6 additions & 1 deletion ttxpage.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,15 @@ class TTXPage

inline bool Loaded() const {return m_Loaded;};

// get the function or coding of a page as the enum
PageCoding GetPageCoding() {return m_pagecoding;}
PageFunction GetPageFunction() {return m_pagefunction;}

// set the page function or coding based on their integer representations in ETS 300 706 section 9.4.2.1
void SetPageFunctionInt(int pageFunction);
void SetPageCodingInt(int pageCoding);

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.
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

0 comments on commit e1561f7

Please sign in to comment.