From e1561f7331611b821f720cfd83e01c7a41f52964 Mon Sep 17 00:00:00 2001 From: ZXGuesser Date: Thu, 28 Sep 2017 16:36:21 +0100 Subject: [PATCH] Remove automatic assignment of page function/coding based on page number. 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. --- packetmag.cpp | 4 +- ttxpage.cpp | 149 +++++++++++++++++++++++++------------------------- ttxpage.h | 7 ++- 3 files changed, 82 insertions(+), 78 deletions(-) diff --git a/packetmag.cpp b/packetmag.cpp index 9e56ab5..c20754c 100644 --- a/packetmag.cpp +++ b/packetmag.cpp @@ -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); } } diff --git a/ttxpage.cpp b/ttxpage.cpp index 6b4311a..e7d801f 100644 --- a/ttxpage.cpp +++ b/ttxpage.cpp @@ -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 @@ -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 @@ -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 } } @@ -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) @@ -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; + } +} diff --git a/ttxpage.h b/ttxpage.h index 7f34262..05abbf5 100644 --- a/ttxpage.h +++ b/ttxpage.h @@ -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)