aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/DabMux.cpp11
-rw-r--r--src/MuxElements.cpp33
-rw-r--r--src/MuxElements.h7
-rw-r--r--src/ParserConfigfile.cpp32
4 files changed, 59 insertions, 24 deletions
diff --git a/src/DabMux.cpp b/src/DabMux.cpp
index 734643c..c090738 100644
--- a/src/DabMux.cpp
+++ b/src/DabMux.cpp
@@ -77,6 +77,8 @@ typedef DWORD32 uint32_t;
# include <net/if_packet.h>
#endif
+#include <time.h>
+
#ifdef _WIN32
# pragma warning ( disable : 4103 )
# include "Eti.h"
@@ -1631,6 +1633,14 @@ int main(int argc, char *argv[])
fig0_9->ext = 0;
fig0_9->lto = 0; // Unique LTO for ensemble
+
+ if (ensemble->lto_auto) {
+ time_t now = time(NULL);
+ struct tm* ltime = localtime(&now);
+ time_t now2 = timegm(ltime);
+ ensemble->lto = (now2 - now) / 1800;
+ }
+
if (ensemble->lto >= 0) {
fig0_9->ensembleLto = ensemble->lto;
}
@@ -1638,6 +1648,7 @@ int main(int argc, char *argv[])
/* Convert to 1-complement representation */
fig0_9->ensembleLto = (-ensemble->lto) | (1<<5);
}
+
fig0_9->ensembleEcc = ensemble->ecc;
fig0_9->tableId = ensemble->international_table;
index += 5;
diff --git a/src/MuxElements.cpp b/src/MuxElements.cpp
index 03e9bbf..c7ac076 100644
--- a/src/MuxElements.cpp
+++ b/src/MuxElements.cpp
@@ -389,18 +389,24 @@ void dabEnsemble::set_parameter(const string& parameter, const string& value)
ss.exceptions ( stringstream::failbit | stringstream::badbit );
if (parameter == "localtimeoffset") {
- int new_lto = atol(value.c_str());
-
- if (new_lto < -24) {
- throw ParameterError("Desired local time offset too small."
- " Minimum -24" );
- }
- else if (new_lto > 24) {
- throw ParameterError("Desired local time offset too large."
- " Maximum 24" );
+ if (value == "auto") {
+ lto_auto = true;
}
+ else {
+ lto_auto = false;
+ int new_lto = atol(value.c_str());
+
+ if (new_lto < -24) {
+ throw ParameterError("Desired local time offset too small."
+ " Minimum -24" );
+ }
+ else if (new_lto > 24) {
+ throw ParameterError("Desired local time offset too large."
+ " Maximum 24" );
+ }
- this->lto = new_lto;
+ this->lto = new_lto;
+ }
}
else {
stringstream ss;
@@ -414,7 +420,12 @@ const string dabEnsemble::get_parameter(const string& parameter) const
{
stringstream ss;
if (parameter == "localtimeoffset") {
- ss << this->lto;
+ if (this->lto_auto) {
+ ss << "auto(" << this->lto << ")";
+ }
+ else {
+ ss << this->lto;
+ }
}
else {
ss << "Parameter '" << parameter <<
diff --git a/src/MuxElements.h b/src/MuxElements.h
index e6752e5..9895956 100644
--- a/src/MuxElements.h
+++ b/src/MuxElements.h
@@ -94,7 +94,7 @@ class dabEnsemble : public RemoteControllable {
: RemoteControllable("ensemble")
{
RC_ADD_PARAMETER(localtimeoffset,
- "local time offset, -24 to +24 [half-hours]");
+ "local time offset, 'auto' or -24 to +24 [half-hours]");
}
/* Remote control */
@@ -109,8 +109,13 @@ class dabEnsemble : public RemoteControllable {
uint8_t ecc;
DabLabel label;
uint8_t mode;
+
+ /* Use the local time to calculate the lto */
+ bool lto_auto;
+
int lto; // local time offset in half-hours
// range: -24 to +24
+
int international_table;
std::vector<DabService*> services;
diff --git a/src/ParserConfigfile.cpp b/src/ParserConfigfile.cpp
index b477f1d..f515a5c 100644
--- a/src/ParserConfigfile.cpp
+++ b/src/ParserConfigfile.cpp
@@ -191,18 +191,26 @@ void parse_configfile(string configuration_file,
ensemble->international_table = pt_ensemble.get("international-table", 0);
- double lto_hours = pt_ensemble.get("local-time-offset", 0.0);
- if (round(lto_hours * 2) != lto_hours * 2) {
- etiLog.level(error) << "Ensemble local time offset " <<
- lto_hours << "h cannot be expressed in half-hour blocks.";
- throw runtime_error("ensemble local-time-offset definition error");
- }
- if (lto_hours > 12 || lto_hours < -12) {
- etiLog.level(error) << "Ensemble local time offset " <<
- lto_hours << "h out of bounds [-12, +12].";
- throw runtime_error("ensemble local-time-offset definition error");
- }
- ensemble->lto = abs(rint(lto_hours * 2));
+ string lto_auto = pt_ensemble.get("local-time-offset", "");
+ if (lto_auto == "auto") {
+ ensemble->lto_auto = true;
+ ensemble->lto = 0;
+ }
+ else {
+ double lto_hours = pt_ensemble.get("local-time-offset", 0.0);
+ if (round(lto_hours * 2) != lto_hours * 2) {
+ etiLog.level(error) << "Ensemble local time offset " <<
+ lto_hours << "h cannot be expressed in half-hour blocks.";
+ throw runtime_error("ensemble local-time-offset definition error");
+ }
+ if (lto_hours > 12 || lto_hours < -12) {
+ etiLog.level(error) << "Ensemble local time offset " <<
+ lto_hours << "h out of bounds [-12, +12].";
+ throw runtime_error("ensemble local-time-offset definition error");
+ }
+ ensemble->lto_auto = false;
+ ensemble->lto = abs(rint(lto_hours * 2));
+ }
int success = -5;
string ensemble_label = pt_ensemble.get<string>("label");