Merge "Issue #1973 Changes to properly determine Issue and Purge time when ingesting a warngen." into development

Former-commit-id: 3abbb84fdb4b2a9e52757d4b5f2e8cb9fb94899e
This commit is contained in:
Richard Peter 2013-05-15 12:44:48 -05:00 committed by Gerrit Code Review
commit 0523d790f8
3 changed files with 89 additions and 42 deletions

View file

@ -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.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Initial creation
* May 7, 2013 1973 rferrel Changes to properly display Issue Time.
*
* </pre>
*
* @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();

View file

@ -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.
*
* </pre>
*
@ -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());
}
}
}

View file

@ -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.
# </pre>
#
# @author rferrel
@ -142,8 +143,9 @@ 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":
@ -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:]