|
|
|
|
@ -50,6 +50,7 @@ class tmc_parser(gr.sync_block):
|
|
|
|
|
self.tmc_meta={} |
|
|
|
|
self.unfinished_messages={} |
|
|
|
|
self.TMC_data={} |
|
|
|
|
self.dataLock=QtCore.QSemaphore(1) |
|
|
|
|
self.tmc_messages=tmc_dict() |
|
|
|
|
atexit.register(self.goodbye) |
|
|
|
|
self.save_data_timer=time.time() |
|
|
|
|
@ -105,34 +106,45 @@ class tmc_parser(gr.sync_block):
|
|
|
|
|
self.db.commit() |
|
|
|
|
self.dbLock.release(1) |
|
|
|
|
f=open(self.workdir+'google_maps_markers.js', 'w') |
|
|
|
|
self.dataLock.acquire(1) |
|
|
|
|
markerstring=self.tmc_messages.getMarkerString() |
|
|
|
|
self.dataLock.release(1) |
|
|
|
|
markerstring+='\n console.log("loaded "+markers.length+" markers")' |
|
|
|
|
markerstring+='\n document.getElementById("errorid").innerHTML = "loaded "+markers.length+" markers";' |
|
|
|
|
f.write(markerstring) |
|
|
|
|
f.close() |
|
|
|
|
#if self.debug: |
|
|
|
|
# print("saved") |
|
|
|
|
def print_tmc_msg(self,tmc_msg): |
|
|
|
|
print_dbg('printing msg', end="") |
|
|
|
|
if self.writeDB and tmc_msg.event.is_cancellation == False: |
|
|
|
|
try: |
|
|
|
|
self.dbLock.acquire(1) |
|
|
|
|
t=(int(tmc_msg.location.lcn),int(tmc_msg.event.updateClass),tmc_msg.PI,tmc_msg.tmc_hash, |
|
|
|
|
tmc_msg.getTime(),int(tmc_msg.event.ecn),int(tmc_msg.is_single), |
|
|
|
|
int(tmc_msg.tmc_DP),int(tmc_msg.tmc_D),int(tmc_msg.tmc_dir),int(tmc_msg.tmc_extent), |
|
|
|
|
tmc_msg.location_text().decode("utf-8"),tmc_msg.events_string().decode("utf-8"),tmc_msg.info_str().decode("utf-8"),tmc_msg.multi_str().decode("utf-8")) |
|
|
|
|
print_dbg('.', end="") |
|
|
|
|
self.dbLock.acquire(1) |
|
|
|
|
self.db.execute("REPLACE INTO TMC (lcn,updateclass,hash,PI,time,ecn,isSingle,DP,div,dir,extent,locstr,eventstr,infostr,multistr) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",t) |
|
|
|
|
self.dbLock.release(1) |
|
|
|
|
print_dbg('.', end="") |
|
|
|
|
except Exception as e: |
|
|
|
|
if self.log or self.debug: |
|
|
|
|
print("error during db insert msg:%s"%tmc_msg.log_string()) |
|
|
|
|
print(e) |
|
|
|
|
pass |
|
|
|
|
print_dbg("db done") |
|
|
|
|
self.qtwidget.print_tmc_msg(tmc_msg) |
|
|
|
|
print_dbg("done") |
|
|
|
|
#if self.debug: |
|
|
|
|
#print("new tmc message %s"%tmc_msg) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def handle_msg(self,msg): |
|
|
|
|
if time.time()-self.save_data_timer > 3:#every 3 seconds |
|
|
|
|
self.save_data_timer=time.time() |
|
|
|
|
self.save_data() |
|
|
|
|
#self.save_data() |
|
|
|
|
m=pmt.to_python(msg) |
|
|
|
|
PI=m["PI"] |
|
|
|
|
if not self.unfinished_messages.has_key(PI): |
|
|
|
|
@ -160,12 +172,16 @@ class tmc_parser(gr.sync_block):
|
|
|
|
|
if tmc_T == 0: |
|
|
|
|
if tmc_F==1:#single group |
|
|
|
|
tmc_msg=tmc_message(PI,psn,ltn,tmc_x,tmc_y,tmc_z,datetime_received,self) |
|
|
|
|
self.dataLock.acquire(1) |
|
|
|
|
self.tmc_messages.add(tmc_msg) |
|
|
|
|
self.print_tmc_msg(tmc_msg) |
|
|
|
|
self.dataLock.release(1) |
|
|
|
|
elif tmc_F==0 and Y15==1:#1st group of multigroup |
|
|
|
|
ci=int(tmc_x&0x7) |
|
|
|
|
tmc_msg=tmc_message(PI,psn,ltn,tmc_x,tmc_y,tmc_z,datetime_received,self) |
|
|
|
|
self.dataLock.acquire(1) |
|
|
|
|
self.tmc_messages.add(tmc_msg) |
|
|
|
|
self.dataLock.release(1) |
|
|
|
|
#if self.RDS_data[PI]["internals"]["unfinished_TMC"].has_key(ci): |
|
|
|
|
#print("overwriting parital message") |
|
|
|
|
self.unfinished_messages[PI][ci]={"msg":tmc_msg,"time":time.time()} |
|
|
|
|
|