From a1dc6ac50bf64dd6017c79f36ca15a3f30d6acca Mon Sep 17 00:00:00 2001 From: Jonathan Sanchez Date: Thu, 15 Aug 2013 10:56:37 -0500 Subject: [PATCH] Issue #2243 Resolved timing issues. Change-Id: Ia0386bf21087cb2a00175e35ecfeae5206797a34 Former-commit-id: 78b655fd1f9da52c3baaa378c98eacad0f451004 [formerly 2b849d7003690256b126410e518c309e8c2c561a] [formerly 78b655fd1f9da52c3baaa378c98eacad0f451004 [formerly 2b849d7003690256b126410e518c309e8c2c561a] [formerly bc30396b631b11f868d93e231f00faaa1b40b24a [formerly 5833ecad04c31502b4e2991853e6aabeda4919f2]]] Former-commit-id: bc30396b631b11f868d93e231f00faaa1b40b24a Former-commit-id: 19853a4b5754db4f938c86c049d0385ab9cb6075 [formerly fca67fb4cac4d669611754698be5e6aaceda0c25] Former-commit-id: dbb60f2c13cb0e4f936f34e0431fe053b32bda70 --- .../viz/warngen/gui/FollowupData.java | 18 ++++++++++----- .../viz/warngen/gui/WarngenDialog.java | 5 ++++- .../viz/warngen/util/FollowUpUtil.java | 22 ++++++++----------- 3 files changed, 25 insertions(+), 20 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 e83d22f8e9..8f9dcc32b1 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 @@ -36,7 +36,7 @@ import com.raytheon.uf.common.time.util.TimeUtil; * Initial creation * May 7, 2013 1973 rferrel Changes to properly display Issue Time. * Aug 7, 2013 2243 jsanchez Set all the attributes of an AbstractWarningRecord and added an expiration string. Removed calendar object. - * + * Aug 15,2013 2243 jsanchez Improved the expiration string off by one minute. * * * @author rferrel @@ -139,9 +139,11 @@ public class FollowupData extends WarningRecord { StringBuilder rval = new StringBuilder(); long timeInMillis = SimulatedTime.getSystemTime().getMillis(); if (status != WarningAction.COR) { - // Positive means not yet expired - long diffMins = (record.getEndTime().getTimeInMillis() - timeInMillis) - / TimeUtil.MILLIS_PER_MINUTE; + // use double to keep precision until it's casted to an integer + double diffMillis = record.getEndTime().getTimeInMillis() + - timeInMillis; + int diffMins = (int) Math.round(diffMillis + / TimeUtil.MILLIS_PER_MINUTE); if (diffMins == 0) { rval.append(" Expired"); } else if (diffMins > 0) { @@ -150,8 +152,12 @@ public class FollowupData extends WarningRecord { rval.append(" Exp ").append(-diffMins).append(" min ago"); } } else { - long diffMins = (timeInMillis - record.getIssueTime() - .getTimeInMillis()) / TimeUtil.MILLIS_PER_MINUTE; + // use double to keep precision until it's casted to an integer + double diffMillis = timeInMillis + - record.getIssueTime().getTimeInMillis(); + int diffMins = (int) Math.round(diffMillis + / TimeUtil.MILLIS_PER_MINUTE); + if (diffMins == 0) { rval.append(" Just Issued"); } else { diff --git a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gui/WarngenDialog.java b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gui/WarngenDialog.java index 60ccbee24d..02b319c787 100644 --- a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gui/WarngenDialog.java +++ b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gui/WarngenDialog.java @@ -936,6 +936,7 @@ public class WarngenDialog extends CaveSWTDialog implements // Select the previously selected item. invalidFollowUpAction = false; if (currentSelection != null) { + // isValid checks if the current selection is still in the list boolean isValid = false; for (int i = 0; i < updateListCbo.getItemCount(); i++) { if (updateListCbo.getItem(i).startsWith( @@ -954,7 +955,9 @@ public class WarngenDialog extends CaveSWTDialog implements // up option could be removed due to an action such as a CAN or an // EXP. If an action removes the follow up, then no warning message // should be displayed. - if (!timeRange.contains(SimulatedTime.getSystemTime().getTime())) { + if (!isValid + && !timeRange.contains(SimulatedTime.getSystemTime() + .getTime())) { invalidFollowUpAction = true; preventFollowUpAction(currentSelection); } diff --git a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/util/FollowUpUtil.java b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/util/FollowUpUtil.java index ff94f45f3b..04b3dca957 100644 --- a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/util/FollowUpUtil.java +++ b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/util/FollowUpUtil.java @@ -32,6 +32,7 @@ import com.raytheon.viz.warngen.text.ICommonPatterns; * Mar 13, 2013 DR 15892 D. Friedman Handle SMW format in canceledAreasFromText * Aug 6, 2013 2243 jsanchez Updated the time ranges to be removed from the follow up list correctly. * Aug 13, 2013 2243 jsanchez Removed calendar object. + * Aug 15, 2013 2243 jsanchez Reset the time ranges to the correct values. * * * @@ -314,45 +315,40 @@ public class FollowUpUtil { TimeRange rval = null; - // The time ranges are offset by 1 minute so that after a refresh and on - // the final minute of the time range the follow up data will be - // removed. For example, if a CON is only a available until 5 minutes - // before a warnings expiration, when the time reaches 5 minutes the - // follow up data for a CON is correctly removed. if (action == WarningAction.NEW) { /* Calculate NEW Time Range */ start.setTime(record.getEndTime().getTime()); - start.add(Calendar.MINUTE, -21); + start.add(Calendar.MINUTE, -20); end.setTime(record.getEndTime().getTime()); - end.add(Calendar.MINUTE, 29); + end.add(Calendar.MINUTE, 30); rval = new TimeRange(start, end); } else if (action == WarningAction.COR) { /* Calculate COR Time Range */ end.setTime(record.getIssueTime().getTime()); - end.add(Calendar.MINUTE, 9); + end.add(Calendar.MINUTE, 10); rval = new TimeRange(record.getStartTime(), end); } else if (action == WarningAction.CAN) { /* Calculate CAN Time Range */ end.setTime(record.getEndTime().getTime()); - end.add(Calendar.MINUTE, -11); + end.add(Calendar.MINUTE, -10); rval = new TimeRange(record.getStartTime(), end); } else if (action == WarningAction.CON) { /* Calculate CON Time Range */ end.setTime(record.getEndTime().getTime()); - end.add(Calendar.MINUTE, -6); + end.add(Calendar.MINUTE, -5); rval = new TimeRange(record.getStartTime(), end); } else if (action == WarningAction.EXP) { /* Calculate EXP Time Range */ start.setTime(record.getEndTime().getTime()); - start.add(Calendar.MINUTE, -11); + start.add(Calendar.MINUTE, -10); end.setTime(record.getEndTime().getTime()); - end.add(Calendar.MINUTE, 9); + end.add(Calendar.MINUTE, 10); rval = new TimeRange(start, end); } else if (action == WarningAction.EXT) { /* Calculate EXT Time Range */ start.setTime(record.getStartTime().getTime()); end.setTime(record.getEndTime().getTime()); - end.add(Calendar.MINUTE, -6); + end.add(Calendar.MINUTE, -5); rval = new TimeRange(start, end); }