Skip to content

Commit

Permalink
read magazine priority values from config file
Browse files Browse the repository at this point in the history
  • Loading branch information
ZXGuesser committed Jul 16, 2019
1 parent a6867c5 commit a22e4c2
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 4 deletions.
38 changes: 37 additions & 1 deletion configure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ Configure::Configure(int argc, char** argv) :
_linesPerField = 16; // default to 16 lines per field

_multiplexedSignalFlag = false; // using this would require changing all the line counting and a way to send full field through raspi-teletext - something for the distant future when everything else is done...

uint8_t priority[8]={9,3,3,6,3,3,5,6}; // 1=High priority,9=low. Note: priority[0] is mag 8

for (int i=0; i<8; i++)
_magazinePriority[i] = priority[i];

//Scan the command line for overriding the pages file.
//std::cerr << "[Configure::Configure] Parameters=" << argc << " " << std::endl;
Expand Down Expand Up @@ -92,7 +97,7 @@ int Configure::LoadConfigFile(std::string filename)

std::vector<std::string>::iterator iter;
// these are all the valid strings for config lines
std::vector<std::string> nameStrings{ "header_template", "initial_teletext_page", "row_adaptive_mode", "network_identification_code", "country_network_identification", "full_field", "status_display", "subtitle_repeats","enable_command_port","command_port","lines_per_field" };
std::vector<std::string> nameStrings{ "header_template", "initial_teletext_page", "row_adaptive_mode", "network_identification_code", "country_network_identification", "full_field", "status_display", "subtitle_repeats","enable_command_port","command_port","lines_per_field","magazine_priority" };

if (filein.is_open()){
std::cerr << "[Configure::LoadConfigFile] opened " << filename << std::endl;
Expand Down Expand Up @@ -246,6 +251,37 @@ int Configure::LoadConfigFile(std::string filename)
error = 1;
}
break;
case 11: // "magazine_priority"
// TODO: implement parsing from config
std::stringstream ss(value);
std::string temps;
int tmp[8];
int i;
for (i=0; i<8; i++)
{
if (std::getline(ss, temps, ','))
{
try {
tmp[i] = stoi(temps);
} catch (const std::invalid_argument& ia) {
error = 1;
break;
}
if (!(tmp[i] > 0 && tmp[i] < 10)) // must be 1-9
{
error = 1;
break;
}
}
else
{
error = 1;
break;
}
}
for (i=0; i<8; i++)
_magazinePriority[i] = tmp[i];
break;
}
} else {
error = 1; // unrecognised config line
Expand Down
3 changes: 3 additions & 0 deletions configure.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include <iostream>
#include <fstream>
#include <sstream>
#include <stdint.h>
#include <cstring>
#include <sys/stat.h>
Expand Down Expand Up @@ -47,6 +48,7 @@ class Configure
bool GetCommandPortEnabled(){return _commandPortEnabled;}
uint8_t GetLinesPerField(){return _linesPerField;}
bool GetReverseFlag(){return _reverseBits;}
int GetMagazinePriority(uint8_t mag){return _magazinePriority[mag];}

private:
int DirExists(char *path);
Expand All @@ -62,6 +64,7 @@ class Configure
uint8_t _linesPerField;
// settings for generation of packet 8/30
bool _multiplexedSignalFlag; // false indicates teletext is multiplexed with video, true means full frame teletext.
int _magazinePriority[8];
uint8_t _initialMag;
uint8_t _initialPage;
uint16_t _initialSubcode;
Expand Down
7 changes: 7 additions & 0 deletions example-vbit.conf
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ header_template=TEEFAX %%# %%a %e %%b C%H:%M/%S
; omit blank rows to increase transmission efficiency (defaults to false)
;row_adaptive_mode=false

; specify number of VBI lines per video field
;lines_per_field=16

; set the priority of each magazine. 1=highest priority, 9=lowest.
; eight comma separated values for magazines 8,1,2,3,4,5,6,7.
;magazine_priority=9,3,3,6,3,3,5,6

; 20 character status message for broadcast service data packet
status_display=TEEFAX

Expand Down
5 changes: 2 additions & 3 deletions service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,14 @@ Service::Service(Configure *configure, PageList *pageList) :
_lineCounter(0),
_fieldCounter(50) // roll over immediately
{
// @todo Put priority into config and add commands to allow updates.
uint8_t priority[8]={9,3,3,6,3,3,5,6}; // 1=High priority,9=low. Note: priority[0] is mag 8
// @todo Add commands to allow updates to priority.

vbit::PacketMag **magList=_pageList->GetMagazines();
// Register all the packet sources
for (uint8_t mag=0;mag<8;mag++)
{
vbit::PacketMag* m=magList[mag];
m->SetPriority(priority[mag]); // set the mags to the desired priorities
m->SetPriority(_configure->GetMagazinePriority(mag)); // set the mags to the desired priorities
_register(m); // use the PacketMags created in pageList rather than duplicating them
}
// Add packet sources for subtitles, databroadcast and packet 830
Expand Down

0 comments on commit a22e4c2

Please sign in to comment.