From 539439976b7d8e0b6f633400ce50ff33cad5cf9c Mon Sep 17 00:00:00 2001 From: Roger Ferrel Date: Wed, 8 May 2013 09:57:13 -0500 Subject: [PATCH] Issue #1973 Changes to properly determine Issue and Purge time when ingesting a warngen. Change-Id: If8045d03084b9085b573cc11c42b6a2f93ffacc8 Former-commit-id: 7636a7fcadd903229fa6fbd5022e880c86c75fad [formerly 3b27e54b31d598957c0100dfdba99c6fece05477] [formerly d1a3e3dc2ffff2563852cfb5d279e25533f91fbc] [formerly 7636a7fcadd903229fa6fbd5022e880c86c75fad [formerly 3b27e54b31d598957c0100dfdba99c6fece05477] [formerly d1a3e3dc2ffff2563852cfb5d279e25533f91fbc] [formerly 938cd275cc6fe13e7656e71615ad5c09cf481a4e [formerly d1a3e3dc2ffff2563852cfb5d279e25533f91fbc [formerly b794f0b882d88cec6f552bf10f7f58096dfd5a69]]]] Former-commit-id: 938cd275cc6fe13e7656e71615ad5c09cf481a4e Former-commit-id: 2370bb293262e8f17f780e4ef984bbf0eb6f8233 [formerly 6523560a484259eb4149653076d32cd440c45842] [formerly 68d47f06839ee2e4b2e5e7f584b42183fbf5fe7d [formerly 2be6266c9be4115898efc89324aa6f3cf24565ac]] Former-commit-id: 01117c6218e4b709fa605225abd1a65f1cc7bab5 [formerly 3aa298611536fa0cf82455f6fcb9ac05ae2f6630] Former-commit-id: a0ff160f7ce376e1a18311a9c34dfa70214af052 --- .../viz/warngen/gui/FollowupData.java | 89 +++++++++++++------ .../viz/warngen/util/CurrentWarnings.java | 5 +- .../WarningDecoder.py | 37 +++++--- 3 files changed, 89 insertions(+), 42 deletions(-) diff --git a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gui/FollowupData.java b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gui/FollowupData.java index c65b664277..b5f39cdc3c 100644 --- a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gui/FollowupData.java +++ b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gui/FollowupData.java @@ -1,3 +1,22 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ package com.raytheon.viz.warngen.gui; import java.util.Calendar; @@ -5,17 +24,37 @@ import java.util.Calendar; import com.raytheon.uf.common.dataplugin.warning.AbstractWarningRecord; import com.raytheon.uf.common.dataplugin.warning.WarningRecord; import com.raytheon.uf.common.time.SimulatedTime; +import com.raytheon.uf.common.time.util.TimeUtil; +/** + * A subclass of Warning Record to create the display strings needed by the GUI. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ *                                     Initial creation
+ * May 7, 2013  1973       rferrel     Changes to properly display Issue Time.
+ * 
+ * 
+ * + * @author rferrel + * @version 1.0 + */ public class FollowupData extends WarningRecord { private static final long serialVersionUID = 1L; - /** String displayed in the drop down update list */ + /** + * String displayed in the drop down update list. + */ public String displayString; /** * String used to test if this object is equivalent to one of the updated - * items in the drop down + * items in the drop down. */ public String equvialentString; @@ -39,21 +78,21 @@ public class FollowupData extends WarningRecord { */ private String getDisplayString(WarningAction status, AbstractWarningRecord record) { - StringBuffer rval = new StringBuffer(); + StringBuilder rval = new StringBuilder(); if (record.getProductClass().equals("T")) { rval.append("T."); } - rval.append(status.toString() + "-"); - rval.append(record.getOfficeid() + "."); - rval.append(record.getPhen() + "."); - rval.append(record.getSig() + "."); + rval.append(status.toString()).append("-"); + rval.append(record.getOfficeid()).append("."); + rval.append(record.getPhen()).append("."); + rval.append(record.getSig()).append("."); rval.append(record.getEtn()); if (status != WarningAction.CAN) { rval.append(buildExpStr(status, record)); } - equvialentString = rval.toString().substring(0, + equvialentString = rval.substring(0, record.getProductClass().equals("T") ? 20 : 18); return rval.toString(); @@ -70,29 +109,27 @@ public class FollowupData extends WarningRecord { */ private String buildExpStr(WarningAction status, AbstractWarningRecord record) { - StringBuffer rval = new StringBuffer(); + StringBuilder rval = new StringBuilder(); Calendar cal = Calendar.getInstance(); cal.setTime(SimulatedTime.getSystemTime().getTime()); - // Positive means not yet expired - long diffMins = (record.getEndTime().getTimeInMillis() - cal - .getTimeInMillis()) / (60 * 1000); - if (diffMins == 0) { - rval.append(" Expired"); - } else if (diffMins > 0) { - rval.append(" Exp in " + diffMins + " min"); + if (status != WarningAction.COR) { + // Positive means not yet expired + long diffMins = (record.getEndTime().getTimeInMillis() - cal + .getTimeInMillis()) / TimeUtil.MILLIS_PER_MINUTE; + if (diffMins == 0) { + rval.append(" Expired"); + } else if (diffMins > 0) { + rval.append(" Exp in ").append(diffMins).append(" min"); + } else { + rval.append(" Exp ").append(-diffMins).append(" min ago"); + } } else { - rval.append(" Exp " + -diffMins + " min ago"); - } - if (status == WarningAction.COR) { - rval.delete(0, rval.length()); - diffMins = (cal.getTimeInMillis() - record.getIssueTime() - .getTimeInMillis()) / (60 * 1000); + long diffMins = (cal.getTimeInMillis() - record.getIssueTime() + .getTimeInMillis()) / TimeUtil.MILLIS_PER_MINUTE; if (diffMins == 0) { rval.append(" Just Issued"); - } else if (diffMins > 0) { - rval.append(" Issued " + diffMins + " min ago"); - } else if (diffMins < 0) { - rval.append(" Issued " + diffMins + " min ago"); + } else { + rval.append(" Issued ").append(diffMins).append(" min ago"); } } return rval.toString(); diff --git a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/util/CurrentWarnings.java b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/util/CurrentWarnings.java index 89a0fe84fe..b019acb30b 100644 --- a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/util/CurrentWarnings.java +++ b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/util/CurrentWarnings.java @@ -69,6 +69,7 @@ import com.vividsolutions.jts.geom.Geometry; * Feb 12, 2013 1500 mschenke Refactored to not request full records and only request full * record when actually retrieving for use * Apr 22, 2013 jsanchez Set the issue time for follow up warnings. + * May 07, 2013 1973 rferrel Corrections when getting Issue time. * * * @@ -304,7 +305,7 @@ public class CurrentWarnings { if (getAction(warning.getAct()) == WarningAction.EXT) { if (rval != null) { rval.setEndTime(warning.getEndTime()); - rval.setIssueTime(warning.getInsertTime()); + rval.setIssueTime(warning.getIssueTime()); } } } @@ -319,7 +320,7 @@ public class CurrentWarnings { rval.setUgczones(warning.getUgczones()); rval.setLoc(warning.getLoc()); rval.setRawmessage(warning.getRawmessage()); - rval.setIssueTime(warning.getInsertTime()); + rval.setIssueTime(warning.getIssueTime()); } } } diff --git a/edexOsgi/com.raytheon.edex.plugin.warning/WarningDecoder.py b/edexOsgi/com.raytheon.edex.plugin.warning/WarningDecoder.py index 9703c467c8..ec9e5d4f28 100644 --- a/edexOsgi/com.raytheon.edex.plugin.warning/WarningDecoder.py +++ b/edexOsgi/com.raytheon.edex.plugin.warning/WarningDecoder.py @@ -32,6 +32,7 @@ # ------------ ---------- ----------- -------------------------- # Initial creation # Feb 19, 2013 1636 rferrel Use TimeTools to get file timestamp. +# May 07, 2013 1973 rferrel Adjust Issue and Purge times to be relative to start time. # # # @author rferrel @@ -142,9 +143,10 @@ class StdWarningDecoder(): def decode(self): #get pil and date-time group + self._adjustIssueTime = True self._productPil, self._issueTime, linePos,\ - self._completeProductPil = self._getPilAndDTG() - + self._completeProductPil, self._issueTimeStr = self._getPilAndDTG() + # If this is a WCL - don't go any further. Run WCL procedure and exit. if self._productPil[0:3] == "WCL": endpoint = "WCLWatch" @@ -182,9 +184,9 @@ class StdWarningDecoder(): purgeTime = None self._checkForDTG(ugcString) if self._hasDTG: - purgeTime = self._dtgFromDDHHMM(ugcString[-7:-1]) + purgeTime = ugcString[-7:-1] else: - purgeTime = self._getPurgeTimeFromVTEC(vtecStrings) + purgeTime = self._getPurgeTimeStrFromVTEC(vtecStrings) vtecList = self._expandVTEC(ugcString, vtecStrings, segCount, segText, cities, purgeTime) segCount = segCount + 1 @@ -202,13 +204,13 @@ class StdWarningDecoder(): else: self._hasDTG = False - def _getPurgeTimeFromVTEC(self, vtecStrings): + def _getPurgeTimeStrFromVTEC(self, vtecStrings): for vtecS, hvtec in vtecStrings: search = re.search(self._vtecRE, vtecS) #print "getting time from ", search.group(8)[-2:] + search.group(9) - endTime = self._dtgFromDDHHMM(str(search.group(8)[-2:]) + str(search.group(9))) - return endTime - return 0 + timeStr = str(search.group(8)[-2:]) + str(search.group(9)) + return timeStr + return None def _usage(self): #Prints out usage information if started without sufficient command @@ -397,7 +399,7 @@ usage: VTECDecoder -f productfilename -d -a activeTableName LogStream.logVerbose("Pil=", pil_search.group(0)) return (self._lines[count+1][0:3], self._dtgFromDDHHMM(dtg_search.group(1)), count+2, - pil_search.group(0)) + pil_search.group(0), dtg_search.group(1)) count = count + 1 if count >= len(self._lines)-1: LogStream.logProblem("Did not find either the product DTG" +\ @@ -405,7 +407,11 @@ usage: VTECDecoder -f productfilename -d -a activeTableName LogStream.exc()) raise Exception, "Product DTG or Pil missing" - def _dtgFromDDHHMM(self, dtgString): + def _dtgFromDDHHMM(self, dtgString, baseTime=None): + if dtgString is None: + return 0.0 + if baseTime is None : + baseTime = self._time #utility function taking a ddhhmm string #group1=day, group2=hour, group3=minute #returns a time object @@ -413,9 +419,9 @@ usage: VTECDecoder -f productfilename -d -a activeTableName wmo_hour = int(dtgString[2:4]) wmo_min = int(dtgString[4:6]) - gmtuple = time.gmtime(self._time) - wmo_year = gmtuple[0] #based on current time - wmo_month = gmtuple[1] #based on current time + gmtuple = time.gmtime(baseTime) + wmo_year = gmtuple[0] + wmo_month = gmtuple[1] current_day = gmtuple[2] if current_day - wmo_day > 15: # next month @@ -773,6 +779,9 @@ usage: VTECDecoder -f productfilename -d -a activeTableName template['seg'] = segment startTime, zeros = self._calcTime(search.group(6), search.group(7), self._issueTime * 1000) + if self._adjustIssueTime : + self._issueTime = self._dtgFromDDHHMM(self._issueTimeStr, startTime/1000.0) + self._adjustIssueTime = False endTime, ufn = self._calcTime(search.group(8), search.group(9), self._maxFutureTime * 1000) template['startTime'] = long(startTime) @@ -782,7 +791,7 @@ usage: VTECDecoder -f productfilename -d -a activeTableName else: template['ufn'] = False template['officeid'] = search.group(2) - template['purgeTime'] = long(purgeTime * 1000) + template['purgeTime'] = long(self._dtgFromDDHHMM(purgeTime, self._issueTime)*1000) template['issueTime'] = long(self._issueTime * 1000) template['state'] = "Decoded" template['xxxid'] = self._completeProductPil[3:]