Browse Source

sync_decim: reduced freqency of sync calculations, changed handling of psn encoding for tmc message printing

master
Clemens Richter 9 years ago
parent
commit
ed709cef32
  1. 4
      lib/rds_decoder_redsea_impl.cc
  2. 12
      lib/sync_decim_impl.cc
  3. 1
      lib/sync_decim_impl.h
  4. 20
      python/tmc_classes.py

4
lib/rds_decoder_redsea_impl.cc

@ -316,9 +316,9 @@ int rds_decoder_redsea_impl::work (int noutput_items,
block_number=(block_number+1) % 4; block_number=(block_number+1) % 4;
blocks_counter++; blocks_counter++;
/* 1187.5 bps / 104 bits = 11.4 groups/sec, or 45.7 blocks/sec */ /* 1187.5 bps / 104 bits = 11.4 groups/sec, or 45.7 blocks/sec */
if (blocks_counter==50) { if (blocks_counter==20) {//reduced from 50
last_wrong_blocks_counter=wrong_blocks_counter; last_wrong_blocks_counter=wrong_blocks_counter;
if (wrong_blocks_counter>35) { if (wrong_blocks_counter>14) {//reduced from 35
lout << "@@@@@ Lost Sync (Got " << wrong_blocks_counter lout << "@@@@@ Lost Sync (Got " << wrong_blocks_counter
<< " bad blocks on " << blocks_counter << " bad blocks on " << blocks_counter
<< " total)" << std::endl; << " total)" << std::endl;

12
lib/sync_decim_impl.cc

@ -26,6 +26,7 @@
#include "sync_decim_impl.h" #include "sync_decim_impl.h"
#define DECIM 2 #define DECIM 2
#define lout log && std::cout #define lout log && std::cout
#define SYNC_COUNTER_MAX 5//higher value -> slower sync, less cpu load
//#include <pmt.h> //#include <pmt.h>
namespace gr { namespace gr {
namespace crfa { namespace crfa {
@ -54,6 +55,7 @@ namespace gr {
//init persistant vars //init persistant vars
last_input=0; last_input=0;
mode=COPY; mode=COPY;
dosync_counter=0;
} }
/* /*
* Our virtual destructor. * Our virtual destructor.
@ -104,7 +106,8 @@ namespace gr {
//lout<<noutput_items<<std::endl; //lout<<noutput_items<<std::endl;
/*SYNC:*/ /*SYNC:*/
if(mode==COPY){ if(mode==COPY and dosync_counter==SYNC_COUNTER_MAX){
dosync_counter=0;
float out_noskip; float out_noskip;
float out_skip; float out_skip;
int skip_is_better_counter=0; int skip_is_better_counter=0;
@ -118,10 +121,10 @@ namespace gr {
out_noskip=in[DECIM*i]-in[DECIM*i+1]; out_noskip=in[DECIM*i]-in[DECIM*i+1];
if (std::abs(out_skip)>std::abs(out_noskip)){ if (std::abs(out_skip)>std::abs(out_noskip)){
skip_is_better_counter++; skip_is_better_counter++;
} }
else{ else{
skip_is_better_counter--; skip_is_better_counter--;
} }
//lout<<"state:"<< mode; //lout<<"state:"<< mode;
//lout<<"\t,out_noskip:"<<out_noskip; //lout<<"\t,out_noskip:"<<out_noskip;
@ -137,6 +140,9 @@ namespace gr {
lout<<"switched to noskip"<< std::endl; lout<<"switched to noskip"<< std::endl;
} }
} }
else if(mode==COPY){
dosync_counter++;
}
} }

1
lib/sync_decim_impl.h

@ -46,6 +46,7 @@ namespace gr {
enum {COPY, SKIP, NOSKIP } mode; enum {COPY, SKIP, NOSKIP } mode;
unsigned int skip; unsigned int skip;
void parse_ctrl_msg(pmt::pmt_t pdu); void parse_ctrl_msg(pmt::pmt_t pdu);
int dosync_counter;
}; };
} // namespace crfa } // namespace crfa

20
python/tmc_classes.py

@ -29,7 +29,7 @@
#rename to common.py? #rename to common.py?
from bitstring import BitArray from bitstring import BitArray
import copy import copy,code
language="de"#currently supported: de, en (both partially) language="de"#currently supported: de, en (both partially)
@ -52,6 +52,8 @@ class tmc_event:
self.length_str=None self.length_str=None
self.speed_limit_str=None self.speed_limit_str=None
self.is_cancellation = False self.is_cancellation = False
self.updateClass=999#invalid
self.is_valid=False
try: try:
#Code,Text CEN-English,Text (German),Text (German) kein Quantifier,Text (Quantifier = 1),Text (Quantifier >1),N,Q,T,D,U,C,R ,Comment #Code,Text CEN-English,Text (German),Text (German) kein Quantifier,Text (Quantifier = 1),Text (Quantifier >1),N,Q,T,D,U,C,R ,Comment
event_array=self.tableobj.ecl_dict[ecn] event_array=self.tableobj.ecl_dict[ecn]
@ -390,7 +392,9 @@ class tmc_message:
#m=midnight, nm=midnight nex day, same for forecast and info/silent #m=midnight, nm=midnight nex day, same for forecast and info/silent
#datetime.timedelta(hours=0.25) #datetime.timedelta(hours=0.25)
def getDuration(self):#returns string def getDuration(self):#returns string
if "D" in self.event.durationType and not self.event.nature=="F": if not self.event.is_valid:
return ""
elif "D" in self.event.durationType and not self.event.nature=="F":
return ", "+tmc_message.duration_dict["Info_dyn"][self.tmc_DP] return ", "+tmc_message.duration_dict["Info_dyn"][self.tmc_DP]
elif "L" in self.event.durationType and not self.event.nature=="F": elif "L" in self.event.durationType and not self.event.nature=="F":
return ", "+tmc_message.duration_dict["Info_long"][self.tmc_DP] return ", "+tmc_message.duration_dict["Info_long"][self.tmc_DP]
@ -442,12 +446,20 @@ class tmc_message:
str_list=[str(elem) for elem in self.events] str_list=[str(elem) for elem in self.events]
return str(", ".join(str_list)) return str(", ".join(str_list))
def log_string(self): def log_string(self):
return str(self.event.updateClass)+": "+self.getTime()+": "+self.location_text()+": "+self.events_string()+"; "+self.info_str()+"; "+self.psn.encode("utf-8") retstr=""
try:
retstr=str(self.event.updateClass)+": "+self.getTime()+": "+self.location_text()+": "+self.events_string()+"; "+self.info_str()+"; "+self.psn
except UnicodeDecodeError as e:
print e
code.interact(local=locals())
return retstr
#2017-03-16 fix:self.psn.encode("utf-8"), utf8 decoding happens later #2017-03-16 fix:self.psn.encode("utf-8"), utf8 decoding happens later
#2017-04-10 undid "fix":UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 0: ordinal not in range(128)
#def db_string(self): #def db_string(self):
# return str(self.location)+": "+str(self.event.updateClass)+": "+self.events_string()+"; "+self.info_str() # return str(self.location)+": "+str(self.event.updateClass)+": "+self.events_string()+"; "+self.info_str()
def map_string(self): def map_string(self):
return '<span title="%s">'%self.getDate()+str(self.event.updateClass)+": "+self.getTime()+'</span><span title="%s">'%self.multi_str()+": "+self.events_string()+self.info_str()+"; "+self.psn.encode("utf-8")+"</span>" return '<span title="%s">'%self.getDate()+str(self.event.updateClass)+": "+self.getTime()+'</span><span title="%s">'%self.multi_str()+": "+self.events_string()+self.info_str()+"; "+self.psn+"</span>"
def end_loc(self): def end_loc(self):
return self.location.get_extent_location(self.location,self.tmc_extent,self.tmc_dir) return self.location.get_extent_location(self.location,self.tmc_extent,self.tmc_dir)
def location_text(self): def location_text(self):

Loading…
Cancel
Save