12.9.1-11 baseline

Former-commit-id: 6eb6b0909b [formerly 6eb6b0909b [formerly 046d9078b7aa87ff8df98142556713fe38d95c63]]
Former-commit-id: fc405efab7
Former-commit-id: a14374fcd4
This commit is contained in:
Steve Harris 2012-08-30 14:36:12 -05:00
parent 5bb474d33c
commit f401755cde
5 changed files with 114 additions and 74 deletions

View file

@ -415,10 +415,6 @@ public class FFMPResource extends
FFFGDataMgr.getUpdatedInstance(); FFFGDataMgr.getUpdatedInstance();
PluginDataObject[] pdos = (PluginDataObject[]) object; PluginDataObject[] pdos = (PluginDataObject[]) object;
FFMPRecord ffmpRec = (FFMPRecord) pdos[pdos.length - 1]; FFMPRecord ffmpRec = (FFMPRecord) pdos[pdos.length - 1];
if (getTimeOrderedKeys().contains(
ffmpRec.getDataTime().getRefTime())) {
return;
}
// an update clears everything // an update clears everything
clear(); clear();
// only care about the most recent one // only care about the most recent one

View file

@ -128,33 +128,45 @@ public final class GagePPWrite {
* new six hour precip value * new six hour precip value
*/ */
public static void gage_pp_write_rec(String pe, String id, String ts, 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) { short revision_6hour[], double new_hourly_value, double pp_value) {
int is_pc = 0; int is_pc = 0;
int six = 0; int six = 0;
Date dto = obsdate; Date dto = new Date(obsdate.getTime());
Calendar dt = Calendar.getInstance(TimeZone.getTimeZone("GMT")); Calendar dt = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
dt.setTime(dto); dt.setTime(dto);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
sdf.setTimeZone(TimeZone.getTimeZone("GMT")); sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
String obstime = sdf.format(dto);
GagePPOptions opts = options; GagePPOptions opts = options;
int hr = dt.get(Calendar.HOUR_OF_DAY); int hr = dt.get(Calendar.HOUR_OF_DAY);
int min = dt.get(Calendar.MINUTE); 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 sixhroffset = get_offset_code(min);
char sixhrqc = 'M'; char sixhrqc = 'M';
char minoff = sixhroffset; char minoff = sixhroffset;
char qcc = sixhrqc; char qcc = sixhrqc;
hourly_rec = null; hourly_rec = null;
//
String where = "WHERE lid='" + id + "' AND ts='" + ts String where = "WHERE lid='" + id + "' AND ts='" + ts
+ "' AND obsdate ='" + obstime + "'"; + "' AND obsdate ='" + obstime + "'";
if (hr >= 0 && hr <= 6) { if (hr >= 0 && hr <= 6) {
six = 0; six = 0;
} else if (hr >= 7 && hr <= 12) { } else if (hr > 6 && hr <= 12) {
six = 1; six = 1;
} else if (hr >= 13 && hr <= 18) { } else if (hr > 12 && hr <= 18) {
six = 2; six = 2;
} else { } else {
six = 3; six = 3;
@ -178,8 +190,8 @@ public final class GagePPWrite {
} }
if (hourly_rec == null) { if (hourly_rec == null) {
minute_offset[hr - 1] = minoff; setMinOffset(minute_offset, hr, minoff);
hourly_qc[hr - 1] = qcc; setHourlyQC(hourly_qc, hr, qcc);
sixhr_offset[six] = sixhroffset; sixhr_offset[six] = sixhroffset;
sixhr_qc[six] = sixhrqc; sixhr_qc[six] = sixhrqc;
@ -240,25 +252,29 @@ public final class GagePPWrite {
System.out.println("Hourly Rec is null."); System.out.println("Hourly Rec is null.");
} }
old_offset = hourly_rec.getMinuteOffset().toCharArray(); 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(); 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; int use_value = 1;
if (get_hour_slot_value(hourly_rec, hr) != null) { if (get_hour_slot_value(hourly_rec, hr) != null) {
old_hr_value = get_hour_slot_value(hourly_rec, hr); old_hr_value = get_hour_slot_value(hourly_rec, hr);
use_value = use_precip_value(new_hourly_value, old_hr_value, use_value = use_precip_value(new_hourly_value, old_hr_value,
qcc, prev_qc, minute_offset[hr - 1], prev_offset, qcc, prev_qc, minute_offset[slot], prev_offset,
opts.shef_duplicate.name(), revision[hr - 1]); opts.shef_duplicate.name(), revision);
} }
if (use_value == 1) { if (use_value == 1) {
hr_value = new_hourly_value; hr_value = new_hourly_value;
offset = old_offset; offset = old_offset;
offset[hr - 1] = minoff; offset[slot] = minoff;
qc = old_qc; qc = old_qc;
qc[hr - 1] = qcc; qc[qcslot] = qcc;
} else { } else {
hr_value = old_hr_value; hr_value = old_hr_value;
offset = old_offset; offset = old_offset;
@ -482,12 +498,12 @@ public final class GagePPWrite {
Arrays.fill(sixhr_qc, '-'); Arrays.fill(sixhr_qc, '-');
Arrays.fill(sixhr_offset, '-'); Arrays.fill(sixhr_offset, '-');
if (hour_slot == 0) { // if (hour_slot == 0) {
hour_slot = 24; // hour_slot = 24;
dt.add(Calendar.HOUR_OF_DAY, -1); // dt.add(Calendar.HOUR_OF_DAY, -1);
} // }
minute_offset[hour_slot - 1] = zero_offset_code; minute_offset[hour_slot] = zero_offset_code;
hourly_qc[hour_slot - 1] = manual_qc_code; hourly_qc[hour_slot] = manual_qc_code;
set_hour_slot_value(hourly_rec, hour_slot, new_hourly_value); set_hour_slot_value(hourly_rec, hour_slot, new_hourly_value);
return hour_slot; 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. * Returns the offset code based on minute of the hour.
* *
@ -808,122 +864,98 @@ public final class GagePPWrite {
*/ */
switch (hour) { switch (hour) {
case 1: case 1:
precip_value = pHourlyPP.getHour1(); precip_value = pHourlyPP.getHour1();
break; break;
case 2: case 2:
precip_value = pHourlyPP.getHour2(); precip_value = pHourlyPP.getHour2();
break; break;
case 3: case 3:
precip_value = pHourlyPP.getHour3(); precip_value = pHourlyPP.getHour3();
break; break;
case 4: case 4:
precip_value = pHourlyPP.getHour4(); precip_value = pHourlyPP.getHour4();
break; break;
case 5: case 5:
precip_value = pHourlyPP.getHour5(); precip_value = pHourlyPP.getHour5();
break; break;
case 6: case 6:
precip_value = pHourlyPP.getHour6(); precip_value = pHourlyPP.getHour6();
break; break;
case 7: case 7:
precip_value = pHourlyPP.getHour7(); precip_value = pHourlyPP.getHour7();
break; break;
case 8: case 8:
precip_value = pHourlyPP.getHour8(); precip_value = pHourlyPP.getHour8();
break; break;
case 9: case 9:
precip_value = pHourlyPP.getHour9(); precip_value = pHourlyPP.getHour9();
break; break;
case 10: case 10:
precip_value = pHourlyPP.getHour10(); precip_value = pHourlyPP.getHour10();
break; break;
case 11: case 11:
precip_value = pHourlyPP.getHour11(); precip_value = pHourlyPP.getHour11();
break; break;
case 12: case 12:
precip_value = pHourlyPP.getHour12(); precip_value = pHourlyPP.getHour12();
break; break;
case 13: case 13:
precip_value = pHourlyPP.getHour13(); precip_value = pHourlyPP.getHour13();
break; break;
case 14: case 14:
precip_value = pHourlyPP.getHour14(); precip_value = pHourlyPP.getHour14();
break; break;
case 15: case 15:
precip_value = pHourlyPP.getHour15(); precip_value = pHourlyPP.getHour15();
break; break;
case 16: case 16:
precip_value = pHourlyPP.getHour16(); precip_value = pHourlyPP.getHour16();
break; break;
case 17: case 17:
precip_value = pHourlyPP.getHour17(); precip_value = pHourlyPP.getHour17();
break; break;
case 18: case 18:
precip_value = pHourlyPP.getHour18(); precip_value = pHourlyPP.getHour18();
break; break;
case 19: case 19:
precip_value = pHourlyPP.getHour19(); precip_value = pHourlyPP.getHour19();
break; break;
case 20: case 20:
precip_value = pHourlyPP.getHour20(); precip_value = pHourlyPP.getHour20();
break; break;
case 21: case 21:
precip_value = pHourlyPP.getHour21(); precip_value = pHourlyPP.getHour21();
break; break;
case 22: case 22:
precip_value = pHourlyPP.getHour22(); precip_value = pHourlyPP.getHour22();
break; break;
case 23: case 23:
precip_value = pHourlyPP.getHour23(); precip_value = pHourlyPP.getHour23();
break; break;
case 0: case 24:
precip_value = pHourlyPP.getHour24(); precip_value = pHourlyPP.getHour24();
break; break;
@ -1063,7 +1095,7 @@ public final class GagePPWrite {
pHourly.setHour23(precip_value); pHourly.setHour23(precip_value);
break; break;
case 0: case 24:
precip_value = new Short((short) val); precip_value = new Short((short) val);
pHourly.setHour24(precip_value); pHourly.setHour24(precip_value);
break; break;

View file

@ -115,7 +115,7 @@ public class RegenHrFlds {
double new_hourly_value; double new_hourly_value;
short[] revision = new short[24]; short revision;
short[] revision_6hour = new short[4]; short[] revision_6hour = new short[4];
@ -238,15 +238,12 @@ public class RegenHrFlds {
hour_slot = GagePPWrite.gage_pp_init(datetime, hour_slot = GagePPWrite.gage_pp_init(datetime,
gData.id, gData.ts, new_hourly_value, obsdate, gData.id, gData.ts, new_hourly_value, obsdate,
zero_offset_code, manual_qc_code); 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) { for (j = 0; j < NUM_6HOURLY_SLOTS; ++j) {
revision_6hour[j] = 0; revision_6hour[j] = 0;
} }
revision[hour_slot - 1] = 1; revision = 1;
try { try {
GagePPWrite.gage_pp_write_rec("PP", gData.id, GagePPWrite.gage_pp_write_rec("PP", gData.id,
@ -282,6 +279,7 @@ public class RegenHrFlds {
Calendar cl = Calendar.getInstance(TimeZone.getTimeZone("GMT")); Calendar cl = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
cl.setTime(datetime); cl.setTime(datetime);
int hh = cl.get(Calendar.HOUR_OF_DAY); int hh = cl.get(Calendar.HOUR_OF_DAY);
hh = hour_slot;
String hour = "" + hh; String hour = "" + hh;
if (hh < 10) { if (hh < 10) {
hour = "0" + hh; hour = "0" + hh;
@ -357,9 +355,22 @@ public class RegenHrFlds {
private void update_rawPP(Date datetime, String id, String ts, private void update_rawPP(Date datetime, String id, String ts,
char manual_qc_code, int pp_1hr_dur, double pp_value) { 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=" String where = "WHERE lid='" + id + "' AND pe='PP'" + " AND dur="
+ pp_1hr_dur + " AND ts='" + ts + "' AND extremum='Z'" + pp_1hr_dur + " AND ts='" + ts + "' AND extremum='Z'"
+ " AND obstime='" + sdf.format(datetime) + "'"; + " AND obstime='" + sdf.format(dt.getTime()) + "'";
List<Rawpp> rawpp_rec = MPEDataManager.getInstance().getRawPP(where); List<Rawpp> rawpp_rec = MPEDataManager.getInstance().getRawPP(where);
if (rawpp_rec.isEmpty()) { if (rawpp_rec.isEmpty()) {
@ -373,9 +384,9 @@ public class RegenHrFlds {
+ ts + ts
+ "','Z'" + "','Z'"
+ ",'" + ",'"
+ sdf.format(datetime) + sdf.format(dt.getTime())
+ "','" + "','"
+ sdf.format(datetime) + sdf.format(dt.getTime())
+ "','" + "','"
+ manual_qc_code + manual_qc_code
+ "'," + "',"
@ -391,11 +402,11 @@ public class RegenHrFlds {
where = "set value=" + pp_value + ",shef_Qual_Code='" where = "set value=" + pp_value + ",shef_Qual_Code='"
+ manual_qc_code + "',revision=1" + ",quality_Code=" + manual_qc_code + "',revision=1" + ",quality_Code="
+ ShefConstants.QC_MANUAL_PASSED + ",producttime='" + ShefConstants.QC_MANUAL_PASSED + ",producttime='"
+ sdf.format(datetime) + "',postingtime='" + sdf.format(dt.getTime()) + "',postingtime='"
+ sdf.format(datetime) + "' WHERE lid='" + id + sdf.format(dt.getTime()) + "' WHERE lid='" + id
+ "' AND pe='PP'" + " AND dur=" + pp_1hr_dur + " AND ts='" + "' AND pe='PP'" + " AND dur=" + pp_1hr_dur + " AND ts='"
+ ts + "' AND extremum='Z'" + " AND obstime='" + ts + "' AND extremum='Z'" + " AND obstime='"
+ sdf.format(datetime) + "'"; + sdf.format(dt.getTime()) + "'";
MPEDataManager.getInstance().updateRawPP(where); MPEDataManager.getInstance().updateRawPP(where);
} }
} }

View file

@ -269,7 +269,7 @@ public class FFMPGuidanceBasin extends FFMPBasin implements ISerializableObject
} }
/** /**
* Get Youngest Key * Get Closest Key
* *
* @param sourceName * @param sourceName
* @param Date * @param Date
@ -308,19 +308,16 @@ public class FFMPGuidanceBasin extends FFMPBasin implements ISerializableObject
// as long as it is +- expiration from orig date, // as long as it is +- expiration from orig date,
// golden // golden
if (date.after(checkDate)) { if (date.after(checkDate)) {
if ((time1 - time2) > expiration) { if ((time1 - time2) < expiration) {
rdate = checkDate; rdate = checkDate;
break; break;
} }
} else { } else {
if ((time2 - time1) > expiration) { if ((time2 - time1) < expiration) {
rdate = checkDate; rdate = checkDate;
break; break;
} }
} }
rdate = checkDate;
break;
} }
} }
} }

View file

@ -1584,6 +1584,11 @@ public class FFMPGenerator extends CompositeProductGenerator implements
try { try {
File sharePathFile = new File(sharePath + config.getCWA());
if (!sharePathFile.exists()) {
sharePathFile.mkdirs();
}
String fileName = fdc.getFilePath(); String fileName = fdc.getFilePath();
// lock for atomic write and read // lock for atomic write and read
HashMap<String, String> fileNames = new HashMap<String, String>(); HashMap<String, String> fileNames = new HashMap<String, String>();
@ -1655,15 +1660,15 @@ public class FFMPGenerator extends CompositeProductGenerator implements
for (String tmpName : fileNames.keySet()) { for (String tmpName : fileNames.keySet()) {
File file = new File(tmpName); File file = new File(tmpName);
if (file.renameTo(new File(fileNames.get(tmpName)))) { if (file.renameTo(new File(fileNames.get(tmpName)))) {
statusHandler statusHandler.handle(
.handle(Priority.DEBUG, Priority.DEBUG,
"Successful rename: : " "Successful rename: : "
+fileNames.get(tmpName)); + fileNames.get(tmpName));
} else { } else {
statusHandler statusHandler.handle(
.handle(Priority.ERROR, Priority.ERROR,
"UN-Successful rename: : " "UN-Successful rename: : "
+fileNames.get(tmpName)); + fileNames.get(tmpName));
} }
} }
@ -1683,7 +1688,6 @@ public class FFMPGenerator extends CompositeProductGenerator implements
statusHandler.handle(Priority.ERROR, statusHandler.handle(Priority.ERROR,
"IO Error writing buddy files: " + e.getMessage()); "IO Error writing buddy files: " + e.getMessage());
} }
} }
} }