From 173ceacc0d2242f9037491bd9f6536486f08d330 Mon Sep 17 00:00:00 2001 From: David Gillingham Date: Tue, 19 Mar 2013 16:05:40 -0500 Subject: [PATCH] Issue #1447: Update MergeVTEC.py to be current with A1 DR 21434. Change-Id: Ib4a7c76f2e75df875c3cac1716a4a99019edcec9 Former-commit-id: 3ad603518981d6a2eaa303a97e776aa5962da227 [formerly ab6944650a24bebfe7cbb383c6fac07781abbd7d] [formerly 843f474af8cf006e1dceee2c3b9ed31181b17291] [formerly 8ea6d7227bc51fffb7703cffbfe5aee2bd0ce9d8 [formerly 843f474af8cf006e1dceee2c3b9ed31181b17291 [formerly 54d3c1e6f1359c36ef73798ec6d3a2d24c97d31c]]] Former-commit-id: 8ea6d7227bc51fffb7703cffbfe5aee2bd0ce9d8 Former-commit-id: 15ae015d4e8d837d34c8ef660c79da6b2290ef2d [formerly 5f8c8a80f86f1aa6d67a7caa328076a6791bd026] Former-commit-id: a8ed51991565b2b4aa975bbce1f925bec42aa01a --- .../common_static/base/vtec/MergeVTEC.py | 58 ++++++++++--------- 1 file changed, 32 insertions(+), 26 deletions(-) diff --git a/edexOsgi/com.raytheon.uf.edex.activetable/utility/common_static/base/vtec/MergeVTEC.py b/edexOsgi/com.raytheon.uf.edex.activetable/utility/common_static/base/vtec/MergeVTEC.py index c03acde673..d2e3294a46 100644 --- a/edexOsgi/com.raytheon.uf.edex.activetable/utility/common_static/base/vtec/MergeVTEC.py +++ b/edexOsgi/com.raytheon.uf.edex.activetable/utility/common_static/base/vtec/MergeVTEC.py @@ -30,6 +30,7 @@ # Date Ticket# Engineer Description # ------------ ---------- ----------- -------------------------- # 01/25/13 1447 dgilling Initial Creation. +# 03/19/13 1447 dgilling Merge A1 DR 21434. # # @@ -173,6 +174,32 @@ class MergeVTEC(VTECTableUtil.VTECTableUtil): currentYear = time.gmtime(self._time)[0] terminations = ('CAN', 'EXP', 'UPG') + + # Remove all records from the received table for events that + # have been cancelled and compacted in our active table + for rec in activeTable: + if rec['act'] not in terminations: + continue + + recYear = time.gmtime(rec['issueTime'])[0] + + # check if there are other related records + single = True + for rec2 in activeTable: + if self.hazardCompare(rec2, rec, compare2): + rec2Year = time.gmtime(rec2['issueTime'])[0] + if recYear == rec2Year and rec != rec2: + single = False + break + + if single: + # remove all records for this event from the received table + for othRec in otherTable[::-1]: + if self.hazardCompare(rec, othRec, compare2): + othRecYear = time.gmtime(othRec['issueTime'])[0] + if othRecYear == recYear: + otherTable.remove(othRec) + # we process each entry in the other (received) table for othRec in otherTable: @@ -187,20 +214,6 @@ class MergeVTEC(VTECTableUtil.VTECTableUtil): othRecYear = time.gmtime(othRec['issueTime'])[0] - # check our active table for this event. if there is only one record - # and it is a canceled event, then we keep it that way. - - matches = [] - for rec in activeTable: - if self.hazardCompare(rec, othRec, compare2): - atRecYear = time.gmtime(rec['issueTime'])[0] - if othRecYear == atRecYear: - matches.append(rec) - - if len(matches) == 1 and matches[0]['act'] in terminations: - # done with this remote record - continue - # if the remote table has a single canceled record, # copy the record if needed and remove the rest for the event @@ -245,10 +258,7 @@ class MergeVTEC(VTECTableUtil.VTECTableUtil): if not found: # add the remote record - if len(matches) > 0: - newRplaceEntriesAct.append(othRec) - else: - missingEntriesAct.append(othRec) + missingEntriesAct.append(othRec) activeTable.append(othRec) changed = True @@ -257,12 +267,8 @@ class MergeVTEC(VTECTableUtil.VTECTableUtil): if chgRec not in changes: changes.append(chgRec) - # done with this remote record - continue - - # currently active events - if othRec['endTime'] >= self._time: + elif othRec['endTime'] >= self._time: # find a match in otherTable that is in our active table # and replace it if newer, but only if it is from the same @@ -289,8 +295,8 @@ class MergeVTEC(VTECTableUtil.VTECTableUtil): # if a match wasn't found, then we may need to add the record # into our active table if found == 0: - activeTable.append(othRec) #add the record missingEntriesAct.append(othRec) + activeTable.append(othRec) #add the record chgRec = (othRec['officeid'], othRec['pil'], othRec['phensig']) if chgRec not in changes: changes.append(chgRec) @@ -300,7 +306,7 @@ class MergeVTEC(VTECTableUtil.VTECTableUtil): othRecYear = time.gmtime(othRec['issueTime'])[0] if currentYear != othRecYear: - continue #only care about this years + continue #only care about this year # find the highest ETN for the current year per phen/sig # in active table and compare to the other table. If found @@ -325,8 +331,8 @@ class MergeVTEC(VTECTableUtil.VTECTableUtil): #if phen/sig not found, then add it if maxETN is None: - activeTable.append(othRec) #add the record missingEntriesPast.append(othRec) + activeTable.append(othRec) #add the record chgRec = (othRec['officeid'], othRec['pil'], othRec['phensig']) if chgRec not in changes: changes.append(chgRec)