From f401755cde5d3b2acb6dc703e2c868a3967f52e0 Mon Sep 17 00:00:00 2001 From: Steve Harris Date: Thu, 30 Aug 2012 14:36:12 -0500 Subject: [PATCH] 12.9.1-11 baseline Former-commit-id: 6eb6b0909b91c3d27b41715b1b11b88da5baa299 [formerly 6eb6b0909b91c3d27b41715b1b11b88da5baa299 [formerly 046d9078b7aa87ff8df98142556713fe38d95c63]] Former-commit-id: fc405efab738e719ee972bce55c32892d445c356 Former-commit-id: a14374fcd4130f1d10b18247abd57ecb7357c18b --- .../viz/monitor/ffmp/ui/rsc/FFMPResource.java | 4 - .../viz/hydrocommon/whfslib/GagePPWrite.java | 124 +++++++++++------- .../raytheon/viz/mpe/core/RegenHrFlds.java | 33 +++-- .../dataplugin/ffmp/FFMPGuidanceBasin.java | 9 +- .../uf/edex/plugin/ffmp/FFMPGenerator.java | 18 ++- 5 files changed, 114 insertions(+), 74 deletions(-) diff --git a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPResource.java b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPResource.java index f8ab8c1d17..fad201b45c 100644 --- a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPResource.java +++ b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPResource.java @@ -415,10 +415,6 @@ public class FFMPResource extends FFFGDataMgr.getUpdatedInstance(); PluginDataObject[] pdos = (PluginDataObject[]) object; FFMPRecord ffmpRec = (FFMPRecord) pdos[pdos.length - 1]; - if (getTimeOrderedKeys().contains( - ffmpRec.getDataTime().getRefTime())) { - return; - } // an update clears everything clear(); // only care about the most recent one diff --git a/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/whfslib/GagePPWrite.java b/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/whfslib/GagePPWrite.java index 40267ea053..c32e5a4a41 100644 --- a/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/whfslib/GagePPWrite.java +++ b/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/whfslib/GagePPWrite.java @@ -128,33 +128,45 @@ public final class GagePPWrite { * new six hour precip value */ public static void gage_pp_write_rec(String pe, String id, String ts, - Date obsdate, GagePPOptions options, short revision[], + Date obsdate, GagePPOptions options, short revision, short revision_6hour[], double new_hourly_value, double pp_value) { int is_pc = 0; int six = 0; - Date dto = obsdate; + Date dto = new Date(obsdate.getTime()); + Calendar dt = Calendar.getInstance(TimeZone.getTimeZone("GMT")); dt.setTime(dto); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); sdf.setTimeZone(TimeZone.getTimeZone("GMT")); - String obstime = sdf.format(dto); GagePPOptions opts = options; int hr = dt.get(Calendar.HOUR_OF_DAY); int min = dt.get(Calendar.MINUTE); + + // + if (hr==0) { + hr=24; + dt.add(Calendar.DAY_OF_MONTH, -1); + dto=dt.getTime(); + } + + String obstime = sdf.format(dto); + char sixhroffset = get_offset_code(min); char sixhrqc = 'M'; char minoff = sixhroffset; char qcc = sixhrqc; hourly_rec = null; + + // String where = "WHERE lid='" + id + "' AND ts='" + ts + "' AND obsdate ='" + obstime + "'"; if (hr >= 0 && hr <= 6) { six = 0; - } else if (hr >= 7 && hr <= 12) { + } else if (hr > 6 && hr <= 12) { six = 1; - } else if (hr >= 13 && hr <= 18) { + } else if (hr > 12 && hr <= 18) { six = 2; } else { six = 3; @@ -178,8 +190,8 @@ public final class GagePPWrite { } if (hourly_rec == null) { - minute_offset[hr - 1] = minoff; - hourly_qc[hr - 1] = qcc; + setMinOffset(minute_offset, hr, minoff); + setHourlyQC(hourly_qc, hr, qcc); sixhr_offset[six] = sixhroffset; sixhr_qc[six] = sixhrqc; @@ -240,25 +252,29 @@ public final class GagePPWrite { System.out.println("Hourly Rec is null."); } old_offset = hourly_rec.getMinuteOffset().toCharArray(); - prev_offset = old_offset[hr - 1]; + int slot = getOffset(old_offset, hr); + slot=hr-1; + prev_offset = old_offset[slot]; old_qc = hourly_rec.getHourlyQc().toCharArray(); - prev_qc = old_qc[hr - 1]; + int qcslot = getOffset(old_qc, hr); + qcslot=hr-1; + prev_qc = old_qc[qcslot]; int use_value = 1; if (get_hour_slot_value(hourly_rec, hr) != null) { old_hr_value = get_hour_slot_value(hourly_rec, hr); use_value = use_precip_value(new_hourly_value, old_hr_value, - qcc, prev_qc, minute_offset[hr - 1], prev_offset, - opts.shef_duplicate.name(), revision[hr - 1]); + qcc, prev_qc, minute_offset[slot], prev_offset, + opts.shef_duplicate.name(), revision); } if (use_value == 1) { hr_value = new_hourly_value; offset = old_offset; - offset[hr - 1] = minoff; + offset[slot] = minoff; qc = old_qc; - qc[hr - 1] = qcc; + qc[qcslot] = qcc; } else { hr_value = old_hr_value; offset = old_offset; @@ -482,12 +498,12 @@ public final class GagePPWrite { Arrays.fill(sixhr_qc, '-'); Arrays.fill(sixhr_offset, '-'); - if (hour_slot == 0) { - hour_slot = 24; - dt.add(Calendar.HOUR_OF_DAY, -1); - } - minute_offset[hour_slot - 1] = zero_offset_code; - hourly_qc[hour_slot - 1] = manual_qc_code; +// if (hour_slot == 0) { +// hour_slot = 24; +// dt.add(Calendar.HOUR_OF_DAY, -1); +// } + minute_offset[hour_slot] = zero_offset_code; + hourly_qc[hour_slot] = manual_qc_code; set_hour_slot_value(hourly_rec, hour_slot, new_hourly_value); return hour_slot; } @@ -507,6 +523,46 @@ public final class GagePPWrite { } } + /** + * + * @param qc + * @param hour + * @param value + */ + public static final void setMinOffset(char [] minOffset, int hour, char value) { + if(hour == 0) { + hour = 23; + } else { + hour--; + } + minOffset[hour] = value; + } + + // get the correct offset slot in array based on hour + public static final int getOffset(char[] minOffset, int hour){ + int slot = 0; + if(hour == 0){ + slot = 23; + }else { + slot = hour--; + } + return slot; + } + /** + * + * @param qc + * @param hour + * @param value + */ + public static final void setHourlyQC(char [] qc, int hour, char value) { + if(hour == 0) { + hour = 23; + } else { + hour--; + } + qc[hour] = value; + } + /** * Returns the offset code based on minute of the hour. * @@ -808,122 +864,98 @@ public final class GagePPWrite { */ switch (hour) { case 1: - precip_value = pHourlyPP.getHour1(); break; case 2: - precip_value = pHourlyPP.getHour2(); break; case 3: - precip_value = pHourlyPP.getHour3(); break; case 4: - precip_value = pHourlyPP.getHour4(); break; case 5: - precip_value = pHourlyPP.getHour5(); break; case 6: - precip_value = pHourlyPP.getHour6(); break; case 7: - precip_value = pHourlyPP.getHour7(); break; case 8: - precip_value = pHourlyPP.getHour8(); break; case 9: - precip_value = pHourlyPP.getHour9(); break; case 10: - precip_value = pHourlyPP.getHour10(); break; case 11: - precip_value = pHourlyPP.getHour11(); break; case 12: - precip_value = pHourlyPP.getHour12(); break; case 13: - precip_value = pHourlyPP.getHour13(); break; case 14: - precip_value = pHourlyPP.getHour14(); break; case 15: - precip_value = pHourlyPP.getHour15(); break; case 16: - precip_value = pHourlyPP.getHour16(); break; case 17: - precip_value = pHourlyPP.getHour17(); break; case 18: - precip_value = pHourlyPP.getHour18(); break; case 19: - precip_value = pHourlyPP.getHour19(); break; case 20: - precip_value = pHourlyPP.getHour20(); break; case 21: - precip_value = pHourlyPP.getHour21(); break; case 22: - precip_value = pHourlyPP.getHour22(); break; case 23: - precip_value = pHourlyPP.getHour23(); break; - case 0: - + case 24: precip_value = pHourlyPP.getHour24(); break; @@ -1063,7 +1095,7 @@ public final class GagePPWrite { pHourly.setHour23(precip_value); break; - case 0: + case 24: precip_value = new Short((short) val); pHourly.setHour24(precip_value); break; @@ -1098,4 +1130,4 @@ public final class GagePPWrite { return retVal; } -} \ No newline at end of file +} diff --git a/cave/com.raytheon.viz.mpe/src/com/raytheon/viz/mpe/core/RegenHrFlds.java b/cave/com.raytheon.viz.mpe/src/com/raytheon/viz/mpe/core/RegenHrFlds.java index e8cdad8fc6..4e4c8c36d6 100644 --- a/cave/com.raytheon.viz.mpe/src/com/raytheon/viz/mpe/core/RegenHrFlds.java +++ b/cave/com.raytheon.viz.mpe/src/com/raytheon/viz/mpe/core/RegenHrFlds.java @@ -115,7 +115,7 @@ public class RegenHrFlds { double new_hourly_value; - short[] revision = new short[24]; + short revision; short[] revision_6hour = new short[4]; @@ -238,15 +238,12 @@ public class RegenHrFlds { hour_slot = GagePPWrite.gage_pp_init(datetime, gData.id, gData.ts, new_hourly_value, obsdate, zero_offset_code, manual_qc_code); - for (j = 0; j < NUM_HOURLY_SLOTS; ++j) { - revision[j] = 0; - } for (j = 0; j < NUM_6HOURLY_SLOTS; ++j) { revision_6hour[j] = 0; } - revision[hour_slot - 1] = 1; + revision = 1; try { GagePPWrite.gage_pp_write_rec("PP", gData.id, @@ -282,6 +279,7 @@ public class RegenHrFlds { Calendar cl = Calendar.getInstance(TimeZone.getTimeZone("GMT")); cl.setTime(datetime); int hh = cl.get(Calendar.HOUR_OF_DAY); + hh = hour_slot; String hour = "" + hh; if (hh < 10) { hour = "0" + hh; @@ -357,9 +355,22 @@ public class RegenHrFlds { private void update_rawPP(Date datetime, String id, String ts, char manual_qc_code, int pp_1hr_dur, double pp_value) { + Date dto = new Date(datetime.getTime()); + Calendar dt = Calendar.getInstance(TimeZone.getTimeZone("GMT")); + dt.setTime(dto); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + sdf.setTimeZone(TimeZone.getTimeZone("GMT")); + int hr = dt.get(Calendar.HOUR_OF_DAY); + + // + if (hr==0) { + hr=24; + dt.add(Calendar.DAY_OF_MONTH, -1); + } + String where = "WHERE lid='" + id + "' AND pe='PP'" + " AND dur=" + pp_1hr_dur + " AND ts='" + ts + "' AND extremum='Z'" - + " AND obstime='" + sdf.format(datetime) + "'"; + + " AND obstime='" + sdf.format(dt.getTime()) + "'"; List rawpp_rec = MPEDataManager.getInstance().getRawPP(where); if (rawpp_rec.isEmpty()) { @@ -373,9 +384,9 @@ public class RegenHrFlds { + ts + "','Z'" + ",'" - + sdf.format(datetime) + + sdf.format(dt.getTime()) + "','" - + sdf.format(datetime) + + sdf.format(dt.getTime()) + "','" + manual_qc_code + "'," @@ -391,11 +402,11 @@ public class RegenHrFlds { where = "set value=" + pp_value + ",shef_Qual_Code='" + manual_qc_code + "',revision=1" + ",quality_Code=" + ShefConstants.QC_MANUAL_PASSED + ",producttime='" - + sdf.format(datetime) + "',postingtime='" - + sdf.format(datetime) + "' WHERE lid='" + id + + sdf.format(dt.getTime()) + "',postingtime='" + + sdf.format(dt.getTime()) + "' WHERE lid='" + id + "' AND pe='PP'" + " AND dur=" + pp_1hr_dur + " AND ts='" + ts + "' AND extremum='Z'" + " AND obstime='" - + sdf.format(datetime) + "'"; + + sdf.format(dt.getTime()) + "'"; MPEDataManager.getInstance().updateRawPP(where); } } diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPGuidanceBasin.java b/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPGuidanceBasin.java index 876c5fe201..c08bf448ea 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPGuidanceBasin.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPGuidanceBasin.java @@ -269,7 +269,7 @@ public class FFMPGuidanceBasin extends FFMPBasin implements ISerializableObject } /** - * Get Youngest Key + * Get Closest Key * * @param sourceName * @param Date @@ -308,19 +308,16 @@ public class FFMPGuidanceBasin extends FFMPBasin implements ISerializableObject // as long as it is +- expiration from orig date, // golden if (date.after(checkDate)) { - if ((time1 - time2) > expiration) { + if ((time1 - time2) < expiration) { rdate = checkDate; break; } } else { - if ((time2 - time1) > expiration) { + if ((time2 - time1) < expiration) { rdate = checkDate; break; } } - - rdate = checkDate; - break; } } } diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.ffmp/src/com/raytheon/uf/edex/plugin/ffmp/FFMPGenerator.java b/edexOsgi/com.raytheon.uf.edex.plugin.ffmp/src/com/raytheon/uf/edex/plugin/ffmp/FFMPGenerator.java index c45c8b5a7c..bd2084624c 100644 --- a/edexOsgi/com.raytheon.uf.edex.plugin.ffmp/src/com/raytheon/uf/edex/plugin/ffmp/FFMPGenerator.java +++ b/edexOsgi/com.raytheon.uf.edex.plugin.ffmp/src/com/raytheon/uf/edex/plugin/ffmp/FFMPGenerator.java @@ -1584,6 +1584,11 @@ public class FFMPGenerator extends CompositeProductGenerator implements try { + File sharePathFile = new File(sharePath + config.getCWA()); + if (!sharePathFile.exists()) { + sharePathFile.mkdirs(); + } + String fileName = fdc.getFilePath(); // lock for atomic write and read HashMap fileNames = new HashMap(); @@ -1655,15 +1660,15 @@ public class FFMPGenerator extends CompositeProductGenerator implements for (String tmpName : fileNames.keySet()) { File file = new File(tmpName); if (file.renameTo(new File(fileNames.get(tmpName)))) { - statusHandler - .handle(Priority.DEBUG, + statusHandler.handle( + Priority.DEBUG, "Successful rename: : " - +fileNames.get(tmpName)); + + fileNames.get(tmpName)); } else { - statusHandler - .handle(Priority.ERROR, + statusHandler.handle( + Priority.ERROR, "UN-Successful rename: : " - +fileNames.get(tmpName)); + + fileNames.get(tmpName)); } } @@ -1683,7 +1688,6 @@ public class FFMPGenerator extends CompositeProductGenerator implements statusHandler.handle(Priority.ERROR, "IO Error writing buddy files: " + e.getMessage()); } - } }