|
|
|
@ -18,6 +18,7 @@ |
|
|
|
# the Free Software Foundation, Inc., 51 Franklin Street, |
|
|
|
# the Free Software Foundation, Inc., 51 Franklin Street, |
|
|
|
# Boston, MA 02110-1301, USA. |
|
|
|
# Boston, MA 02110-1301, USA. |
|
|
|
# |
|
|
|
# |
|
|
|
|
|
|
|
from __future__ import print_function#print without newline print('.', end="") |
|
|
|
|
|
|
|
|
|
|
|
import numpy |
|
|
|
import numpy |
|
|
|
from gnuradio import gr |
|
|
|
from gnuradio import gr |
|
|
|
@ -29,6 +30,7 @@ from multirds.tmc_classes import tmc_dict,tmc_message,language,lcl |
|
|
|
from datetime import datetime |
|
|
|
from datetime import datetime |
|
|
|
from datetime import timedelta |
|
|
|
from datetime import timedelta |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class tmc_parser(gr.sync_block): |
|
|
|
class tmc_parser(gr.sync_block): |
|
|
|
""" |
|
|
|
""" |
|
|
|
docstring for block tmc_parser |
|
|
|
docstring for block tmc_parser |
|
|
|
@ -119,8 +121,7 @@ class tmc_parser(gr.sync_block): |
|
|
|
self.qtwidget.print_tmc_msg(tmc_msg) |
|
|
|
self.qtwidget.print_tmc_msg(tmc_msg) |
|
|
|
#if self.debug: |
|
|
|
#if self.debug: |
|
|
|
# print("new tmc message %s"%tmc_msg) |
|
|
|
# print("new tmc message %s"%tmc_msg) |
|
|
|
def initialize_data_for_PI(self,PI): |
|
|
|
|
|
|
|
self.unfinished_messages[PI]={} |
|
|
|
|
|
|
|
def handle_msg(self,msg): |
|
|
|
def handle_msg(self,msg): |
|
|
|
if time.time()-self.save_data_timer > 3:#every 3 seconds |
|
|
|
if time.time()-self.save_data_timer > 3:#every 3 seconds |
|
|
|
self.save_data_timer=time.time() |
|
|
|
self.save_data_timer=time.time() |
|
|
|
@ -128,12 +129,10 @@ class tmc_parser(gr.sync_block): |
|
|
|
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): |
|
|
|
self.initialize_data_for_PI(PI) |
|
|
|
self.unfinished_messages[PI]={} |
|
|
|
if m["type"]=="3A_meta": |
|
|
|
if m["type"]=="3A_meta": |
|
|
|
self.tmc_meta[PI]=m["data"] |
|
|
|
self.tmc_meta[PI]=m["data"] |
|
|
|
elif m["type"]=="alert-c": |
|
|
|
elif m["type"]=="alert-c": |
|
|
|
#self.qtwidget.updateui() |
|
|
|
|
|
|
|
#print(m) |
|
|
|
|
|
|
|
psn=m["PSN"] |
|
|
|
psn=m["PSN"] |
|
|
|
try: |
|
|
|
try: |
|
|
|
ltn=self.tmc_meta[PI]["LTN"] |
|
|
|
ltn=self.tmc_meta[PI]["LTN"] |
|
|
|
@ -257,27 +256,35 @@ class tmc_parser(gr.sync_block): |
|
|
|
class tmc_parser_Widget(QtGui.QWidget): |
|
|
|
class tmc_parser_Widget(QtGui.QWidget): |
|
|
|
def print_tmc_msg(self,tmc_msg): |
|
|
|
def print_tmc_msg(self,tmc_msg): |
|
|
|
self.logMutex.acquire(1) |
|
|
|
self.logMutex.acquire(1) |
|
|
|
|
|
|
|
print("got mutex,",end="") |
|
|
|
sb=self.logOutput.verticalScrollBar() |
|
|
|
sb=self.logOutput.verticalScrollBar() |
|
|
|
|
|
|
|
print(".",end="") |
|
|
|
oldmax=sb.maximum() |
|
|
|
oldmax=sb.maximum() |
|
|
|
|
|
|
|
print(".",end="") |
|
|
|
auto_scroll= abs(oldmax-sb.value())<60#auto_scroll if scrollbar was at max |
|
|
|
auto_scroll= abs(oldmax-sb.value())<60#auto_scroll if scrollbar was at max |
|
|
|
|
|
|
|
print(".",end="") |
|
|
|
#print("%i %i %r"%(sb.maximum(),sb.value(),auto_scroll)) |
|
|
|
#print("%i %i %r"%(sb.maximum(),sb.value(),auto_scroll)) |
|
|
|
ef=unicode(self.event_filter.text().toUtf8(), encoding="UTF-8").lower() |
|
|
|
ef=unicode(self.event_filter.text().toUtf8(), encoding="UTF-8").lower() |
|
|
|
lf=unicode(self.location_filter.text().toUtf8(), encoding="UTF-8").lower() |
|
|
|
lf=unicode(self.location_filter.text().toUtf8(), encoding="UTF-8").lower() |
|
|
|
filters=[{"type":"location", "str":lf},{"type":"event", "str":ef}] |
|
|
|
filters=[{"type":"location", "str":lf},{"type":"event", "str":ef}] |
|
|
|
if self.parser.tmc_messages.matchFilter(tmc_msg,filters): |
|
|
|
if tmc_dict.matchFilter(tmc_msg,filters): |
|
|
|
|
|
|
|
print("a",end="") |
|
|
|
self.logOutput.append(Qt.QString.fromUtf8(tmc_msg.log_string())) |
|
|
|
self.logOutput.append(Qt.QString.fromUtf8(tmc_msg.log_string())) |
|
|
|
|
|
|
|
print("a",end="") |
|
|
|
self.logOutput.append(Qt.QString.fromUtf8(tmc_msg.multi_str())) |
|
|
|
self.logOutput.append(Qt.QString.fromUtf8(tmc_msg.multi_str())) |
|
|
|
|
|
|
|
print("a",end="") |
|
|
|
#print("new message") |
|
|
|
#print("new message") |
|
|
|
if auto_scroll: |
|
|
|
if auto_scroll: |
|
|
|
sb=self.logOutput.verticalScrollBar() |
|
|
|
#sb=self.logOutput.verticalScrollBar() #disabled 2017-04-28 might be cause of double free |
|
|
|
new_max=sb.maximum() |
|
|
|
new_max=sb.maximum() |
|
|
|
|
|
|
|
print("s",end="") |
|
|
|
sb.setValue(new_max) |
|
|
|
sb.setValue(new_max) |
|
|
|
|
|
|
|
print("s",end="") |
|
|
|
|
|
|
|
print("\tdone") |
|
|
|
# code.interact(local=locals()) |
|
|
|
# code.interact(local=locals()) |
|
|
|
#print("scrolling %i %i %r"%(oldmax,new_max,sb.value())) |
|
|
|
#print("scrolling %i %i %r"%(oldmax,new_max,sb.value())) |
|
|
|
#code.interact(local=locals()) |
|
|
|
#code.interact(local=locals()) |
|
|
|
self.logMutex.release(1) |
|
|
|
self.logMutex.release(1) |
|
|
|
def updateui(self): |
|
|
|
|
|
|
|
print("updating ui") |
|
|
|
|
|
|
|
def filterChanged(self): |
|
|
|
def filterChanged(self): |
|
|
|
self.logMutex.acquire(1) |
|
|
|
self.logMutex.acquire(1) |
|
|
|
self.parser.isDone=False |
|
|
|
self.parser.isDone=False |
|
|
|
|