Browse Source

added periodic db save

master
Clemens Richter 9 years ago
parent
commit
e931f1ad11
  1. 2
      python/rds_parser_table_qt.py
  2. 4
      python/tmc_parser.py

2
python/rds_parser_table_qt.py

@ -696,7 +696,7 @@ class rds_parser_table_qt(gr.sync_block):#START
self.message_port_pub(pmt.intern('tmc_raw'), send_pmt) self.message_port_pub(pmt.intern('tmc_raw'), send_pmt)
#~ tmc_hash=md5.new(str([PI,tmc_x,tmc_y,tmc_z])).hexdigest() #~ tmc_hash=md5.new(str([PI,tmc_x,tmc_y,tmc_z])).hexdigest()
#~ tmc_T=tmc_x>>4 #0:TMC-message 1:tuning info/service provider name tmc_T=tmc_x>>4 #0:TMC-message 1:tuning info/service provider name
#~ tmc_F=int((tmc_x>>3)&0x1) #identifies the message as a Single Group (F = 1) or Multi Group (F = 0) #~ tmc_F=int((tmc_x>>3)&0x1) #identifies the message as a Single Group (F = 1) or Multi Group (F = 0)
#~ Y15=int(tmc_y>>15) #~ Y15=int(tmc_y>>15)
#~ try: #~ try:

4
python/tmc_parser.py

@ -50,6 +50,7 @@ class tmc_parser(gr.sync_block):
self.TMC_data={} self.TMC_data={}
self.tmc_messages=tmc_dict() self.tmc_messages=tmc_dict()
atexit.register(self.goodbye) atexit.register(self.goodbye)
self.save_data_timer=time.time()
if self.writeDB: if self.writeDB:
#create new DB file #create new DB file
db_name=workdir+'RDS_data'+datetime.now().strftime("%Y%m%d_%H%M%S")+'_TMC.db' db_name=workdir+'RDS_data'+datetime.now().strftime("%Y%m%d_%H%M%S")+'_TMC.db'
@ -120,6 +121,9 @@ class tmc_parser(gr.sync_block):
def initialize_data_for_PI(self,PI): def initialize_data_for_PI(self,PI):
self.unfinished_messages[PI]={} self.unfinished_messages[PI]={}
def handle_msg(self,msg): def handle_msg(self,msg):
if time.time()-self.save_data_timer > 10:#every 10 seconds
self.save_data_timer=time.time()
self.save_data()
m=pmt.to_python(msg) m=pmt.to_python(msg)
PI=m["PI"] PI=m["PI"]
if not self.unfinished_messages.has_key(PI): if not self.unfinished_messages.has_key(PI):

Loading…
Cancel
Save