Esempio n. 1
0
 /// <summary>
 /// Decodes the toptext multi page.
 /// </summary>
 /// <param name="cache">The cache.</param>
 private void DecodeMultiPage(TeletextPageCache cache)
 {
     // multi page contains the number of subpages transmitted for each page (100-899);
     if (!cache.PageExists(TOP_MULTI_PAGE))
     {
         return;
     }
     byte[] multiPage = cache.GetPage(TOP_MULTI_PAGE, 0);
     for (int pageNr = 100; pageNr <= 899; pageNr++)
     {
         int  row  = ((pageNr - 100) / 40) + 1;
         int  col  = ((pageNr - 100) % 40) + 2;
         byte data = Hamming.Decode[multiPage[row * 42 + col]];
         if (data == NotPresent)
         {
             //page is offair
             _pageSubCount[pageNr] = 0;
         }
         else if (data == 0x0a)
         {
             //page has > 10 subpages
             _pageSubCount[pageNr] = 10; //( or more)
         }
         else
         {
             int numberOfSubPages = data - 1;
             _pageSubCount[pageNr] = numberOfSubPages;
         }
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Decodes the additional toptext pages.
        /// </summary>
        /// <param name="cache">The cache.</param>
        private void DecodeAdditionalPages(TeletextPageCache cache)
        {
            //addditional pages carry information to display on line 24
            //
            for (int pageNr = TOP_ADDITIONAL_PAGE; pageNr < 0x1fd; ++pageNr)
            {
                if (!cache.PageExists(pageNr))
                {
                    continue;
                }
                byte[] additionalPage = cache.GetPage(pageNr, 0);
                int    lineCounter    = 0;
                while (true)
                {
                    int  row       = 1 + (lineCounter / 2);
                    int  col       = (20 * (lineCounter % 2));
                    byte magazine  = Hamming.Decode[additionalPage[row * 42 + 2 + col]];
                    byte pageTens  = Hamming.Decode[additionalPage[row * 42 + 3 + col]];
                    byte pageUnits = Hamming.Decode[additionalPage[row * 42 + 4 + col]];
                    if (magazine >= 0 && magazine <= 7)
                    {
                        if (pageTens >= 0x0 && pageTens <= 9)
                        {
                            if (pageUnits >= 0x0 && pageUnits <= 9)
                            {
                                string description = String.Empty;
                                for (int i = 1; i < 12; ++i)
                                {
                                    row = 1 + (lineCounter / 2);
                                    col = 9 + i + (20 * (lineCounter % 2));

                                    description += (char)(additionalPage[row * 42 + col] & 0x7f);
                                }
                                if (magazine == 0)
                                {
                                    magazine = 8;
                                }
                                int pageNo = magazine * 100 + pageTens * 10 + pageUnits;
                                if (pageNo >= 100 && pageNo <= 899)
                                {
                                    _pageDescription[pageNo] = description;
                                }
                            }
                        }
                    }
                    lineCounter++;
                    if (lineCounter >= 43)
                    {
                        break;
                    }
                }
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Decodes the basic toptext page.
 /// </summary>
 /// <param name="cache">The cache.</param>
 /// <returns></returns>
 private bool DecodeBasicPage(TeletextPageCache cache)
 {
     //basic toppage contains information which teletext pages are onair
     //and if onair if it has subpages or not
     //also contains the type for each page
     if (!cache.PageExists(TOP_BASIC_PAGE))
     {
         return(false);
     }
     byte[] basicPage = cache.GetPage(TOP_BASIC_PAGE, 0);
     for (int pageNr = 100; pageNr <= 899; pageNr++)
     {
         int  row  = ((pageNr - 100) / 40) + 1;
         int  col  = ((pageNr - 100) % 40) + 2;
         byte data = Hamming.Decode[basicPage[row * 42 + col]];
         if (data == ProgramInfoBlockPageMulti ||
             data == BlockPageMulti ||
             data == GroupPageMulti ||
             data == NormalPageMulti ||
             data == NormalPageMultiInfo
             )
         {
             //page is onair and has subpages
             _pageType[pageNr] = data;
         }
         if (data == ProgramInfoBlockPageSingle ||
             data == BlockPageSingle ||
             data == GroupPageSingle ||
             data == NormalPage ||
             data == NormalPageInfo)
         {
             //page is onair and has subpages
             _pageType[pageNr] = data;
         }
         if (data == NotPresent)
         {
             //page is not onair
             _pageType[pageNr]     = data;
             _pageSubCount[pageNr] = 0;
         }
     }
     return(true);
 }
Esempio n. 4
0
    /// <summary>
    /// Decodes the additional toptext pages.
    /// </summary>
    /// <param name="cache">The cache.</param>
    private void DecodeAdditionalPages(TeletextPageCache cache)
    {
      //addditional pages carry information to display on line 24
      //
      for (int pageNr = TOP_ADDITIONAL_PAGE; pageNr < 0x1fd; ++pageNr)
      {
        if (!cache.PageExists(pageNr))
          continue;
        byte[] additionalPage = cache.GetPage(pageNr, 0);
        int lineCounter = 0;
        while (true)
        {
          int row = 1 + (lineCounter / 2);
          int col = (20 * (lineCounter % 2));
          byte magazine = Hamming.Decode[additionalPage[row * 42 + 2 + col]];
          byte pageTens = Hamming.Decode[additionalPage[row * 42 + 3 + col]];
          byte pageUnits = Hamming.Decode[additionalPage[row * 42 + 4 + col]];
          if (magazine >= 0 && magazine <= 7)
          {
            if (pageTens >= 0x0 && pageTens <= 9)
            {
              if (pageUnits >= 0x0 && pageUnits <= 9)
              {
                string description = String.Empty;
                for (int i = 1; i < 12; ++i)
                {
                  row = 1 + (lineCounter / 2);
                  col = 9 + i + (20 * (lineCounter % 2));

                  description += (char)(additionalPage[row * 42 + col] & 0x7f);
                }
                if (magazine == 0)
                  magazine = 8;
                int pageNo = magazine * 100 + pageTens * 10 + pageUnits;
                if (pageNo >= 100 && pageNo <= 899)
                {
                  _pageDescription[pageNo] = description;
                }
              }
            }
          }
          lineCounter++;
          if (lineCounter >= 43)
            break;
        }
      }
    }
Esempio n. 5
0
 /// <summary>
 /// Decodes the toptext multi page.
 /// </summary>
 /// <param name="cache">The cache.</param>
 private void DecodeMultiPage(TeletextPageCache cache)
 {
   // multi page contains the number of subpages transmitted for each page (100-899);
   if (!cache.PageExists(TOP_MULTI_PAGE))
     return;
   byte[] multiPage = cache.GetPage(TOP_MULTI_PAGE, 0);
   for (int pageNr = 100; pageNr <= 899; pageNr++)
   {
     int row = ((pageNr - 100) / 40) + 1;
     int col = ((pageNr - 100) % 40) + 2;
     byte data = Hamming.Decode[multiPage[row * 42 + col]];
     if (data == NotPresent)
     {
       //page is offair
       _pageSubCount[pageNr] = 0;
     }
     else if (data == 0x0a)
     {
       //page has > 10 subpages
       _pageSubCount[pageNr] = 10; //( or more)
     }
     else
     {
       int numberOfSubPages = data - 1;
       _pageSubCount[pageNr] = numberOfSubPages;
     }
   }
 }
Esempio n. 6
0
 /// <summary>
 /// Decodes the basic toptext page.
 /// </summary>
 /// <param name="cache">The cache.</param>
 /// <returns></returns>
 private bool DecodeBasicPage(TeletextPageCache cache)
 {
   //basic toppage contains information which teletext pages are onair
   //and if onair if it has subpages or not
   //also contains the type for each page
   if (!cache.PageExists(TOP_BASIC_PAGE))
     return false;
   byte[] basicPage = cache.GetPage(TOP_BASIC_PAGE, 0);
   for (int pageNr = 100; pageNr <= 899; pageNr++)
   {
     int row = ((pageNr - 100) / 40) + 1;
     int col = ((pageNr - 100) % 40) + 2;
     byte data = Hamming.Decode[basicPage[row * 42 + col]];
     if (data == ProgramInfoBlockPageMulti ||
         data == BlockPageMulti ||
         data == GroupPageMulti ||
         data == NormalPageMulti ||
         data == NormalPageMultiInfo
       )
     {
       //page is onair and has subpages
       _pageType[pageNr] = data;
     }
     if (data == ProgramInfoBlockPageSingle ||
         data == BlockPageSingle ||
         data == GroupPageSingle ||
         data == NormalPage ||
         data == NormalPageInfo)
     {
       //page is onair and has subpages
       _pageType[pageNr] = data;
     }
     if (data == NotPresent)
     {
       //page is not onair
       _pageType[pageNr] = data;
       _pageSubCount[pageNr] = 0;
     }
   }
   return true;
 }