aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2018-01-17 10:25:20 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2018-01-17 10:25:20 +0100
commit4f7636694a752fa8c652c684a3c9ebf1488ceaa4 (patch)
tree159a5682a287fcb2ddd64d01c3e4dfc82bb5bb74
parentd5db57bf0290133450b7cd10525532415076bf0e (diff)
downloaddabmod-4f7636694a752fa8c652c684a3c9ebf1488ceaa4.tar.gz
dabmod-4f7636694a752fa8c652c684a3c9ebf1488ceaa4.tar.bz2
dabmod-4f7636694a752fa8c652c684a3c9ebf1488ceaa4.zip
Cosmetics for TimestampDecoder
-rw-r--r--src/TimestampDecoder.cpp29
-rw-r--r--src/TimestampDecoder.h16
2 files changed, 15 insertions, 30 deletions
diff --git a/src/TimestampDecoder.cpp b/src/TimestampDecoder.cpp
index 5bede08..b942c37 100644
--- a/src/TimestampDecoder.cpp
+++ b/src/TimestampDecoder.cpp
@@ -24,15 +24,13 @@
along with ODR-DabMod. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <queue>
#include <iostream>
#include <fstream>
#include <string>
-#include <sys/types.h>
#include "PcDebug.h"
#include "TimestampDecoder.h"
-#include "Eti.h"
#include "Log.h"
+#include "Eti.h"
//#define MDEBUG(fmt, args...) fprintf (LOG, "*****" fmt , ## args)
#define MDEBUG(fmt, args...) PDEBUG(fmt, ## args)
@@ -55,10 +53,8 @@ TimestampDecoder::TimestampDecoder(double& offset_s) :
std::shared_ptr<frame_timestamp> TimestampDecoder::getTimestamp()
{
- std::shared_ptr<frame_timestamp> ts =
- std::make_shared<frame_timestamp>();
+ auto ts = std::make_shared<frame_timestamp>();
- /* Push new timestamp into queue */
ts->timestamp_valid = full_timestamp_received;
ts->timestamp_sec = time_secs;
ts->timestamp_pps = time_pps;
@@ -82,8 +78,7 @@ void TimestampDecoder::pushMNSCData(uint8_t framephase, uint16_t mnsc)
struct eti_MNSC_TIME_2 *mnsc2;
struct eti_MNSC_TIME_3 *mnsc3;
- switch (framephase)
- {
+ switch (framephase) {
case 0:
mnsc0 = (struct eti_MNSC_TIME_0*)&mnsc;
enableDecode = (mnsc0->type == 0) &&
@@ -99,10 +94,10 @@ void TimestampDecoder::pushMNSCData(uint8_t framephase, uint16_t mnsc)
temp_time.tm_sec = mnsc1->second_tens * 10 + mnsc1->second_unit;
temp_time.tm_min = mnsc1->minute_tens * 10 + mnsc1->minute_unit;
- if (!mnsc1->sync_to_frame)
- {
+ if (!mnsc1->sync_to_frame) {
enableDecode = false;
- PDEBUG("TimestampDecoder: MNSC time info is not synchronised to frame\n");
+ PDEBUG("TimestampDecoder: "
+ "MNSC time info is not synchronised to frame\n");
}
break;
@@ -118,8 +113,7 @@ void TimestampDecoder::pushMNSCData(uint8_t framephase, uint16_t mnsc)
temp_time.tm_mon = (mnsc3->month_tens * 10 + mnsc3->month_unit) - 1;
temp_time.tm_year = (mnsc3->year_tens * 10 + mnsc3->year_unit) + 100;
- if (enableDecode)
- {
+ if (enableDecode) {
updateTimestampSeconds(mktime(&temp_time));
}
break;
@@ -132,13 +126,11 @@ void TimestampDecoder::pushMNSCData(uint8_t framephase, uint16_t mnsc)
void TimestampDecoder::updateTimestampSeconds(uint32_t secs)
{
- if (inhibit_second_update > 0)
- {
+ if (inhibit_second_update > 0) {
MDEBUG("TimestampDecoder::updateTimestampSeconds(%d) inhibit\n", secs);
inhibit_second_update--;
}
- else
- {
+ else {
MDEBUG("TimestampDecoder::updateTimestampSeconds(%d) apply\n", secs);
time_secs = secs;
full_timestamp_received = true;
@@ -149,8 +141,7 @@ void TimestampDecoder::updateTimestampPPS(uint32_t pps)
{
MDEBUG("TimestampDecoder::updateTimestampPPS(%f)\n", (double)pps / 16384000.0);
- if (time_pps > pps) // Second boundary crossed
- {
+ if (time_pps > pps) { // Second boundary crossed
MDEBUG("TimestampDecoder::updateTimestampPPS crossed second\n");
// The second for the next eight frames will not
diff --git a/src/TimestampDecoder.h b/src/TimestampDecoder.h
index ff52e4c..1a13394 100644
--- a/src/TimestampDecoder.h
+++ b/src/TimestampDecoder.h
@@ -26,14 +26,11 @@
#pragma once
-#include <queue>
+#include <cstdint>
#include <memory>
#include <string>
-#include <time.h>
#include <math.h>
#include <stdio.h>
-#include "Eti.h"
-#include "Log.h"
#include "RemoteControl.h"
struct frame_timestamp
@@ -55,16 +52,14 @@ struct frame_timestamp
this->timestamp_sec += lrintf(offset_secs);
this->timestamp_pps += lrintf(offset_pps * 16384000.0);
- while (this->timestamp_pps >= 16384000)
- {
+ while (this->timestamp_pps >= 16384000) {
this->timestamp_pps -= 16384000;
this->timestamp_sec += 1;
- };
+ }
return *this;
}
- const frame_timestamp operator+(const double diff)
- {
+ const frame_timestamp operator+(const double diff) {
frame_timestamp ts = *this;
ts += diff;
return ts;
@@ -86,8 +81,7 @@ struct frame_timestamp
return ns;
}
- void print(const char* t)
- {
+ void print(const char* t) const {
fprintf(stderr,
"%s <frame_timestamp(%s, %d, %.9f, %d)>\n",
t, this->timestamp_valid ? "valid" : "invalid",