Merge tag 'OB_15.1.1-18' into omaha_16.1.1

15.1.1-18

 Conflicts:
	edexOsgi/com.raytheon.edex.plugin.grib/utility/edex_static/base/grib/postProcessModels/postProcessedModels.xml


Former-commit-id: 383347accebb250ce3c761ad2e1cc0aaa58abde3
This commit is contained in:
Steve Harris 2015-06-16 09:35:56 -05:00
commit 4f4f417efb
9 changed files with 312 additions and 28 deletions

View file

@ -37,10 +37,11 @@ import com.raytheon.uf.common.localization.LocalizationContext;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
import com.raytheon.uf.common.localization.LocalizationFile;
import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.uf.viz.core.localization.CAVELocalizationAdapter;
import com.raytheon.uf.viz.thinclient.preferences.ThinClientPreferenceConstants;
/**
* TODO Add Description
* A {@link BooleanFieldEditor} which adds a button that can be used to
* synchronize localization files with the server.
*
* <pre>
*
@ -48,7 +49,8 @@ import com.raytheon.uf.viz.core.localization.CAVELocalizationAdapter;
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Nov 22, 2011 bsteffen Initial creation
* Nov 22, 2011 bsteffen Initial creation
* May 29, 2015 4532 bsteffen Notify the preference store when sync is running.
*
* </pre>
*
@ -75,8 +77,9 @@ public class SyncLocalizationEditor extends BooleanFieldEditor {
@Override
protected IStatus run(IProgressMonitor monitor) {
IPathManager pathManager = PathManagerFactory
.getPathManager(new CAVELocalizationAdapter());
getPreferenceStore().firePropertyChangeEvent(ThinClientPreferenceConstants.P_SYNC_REMOTE_LOCALIZATION,
false, true);
IPathManager pathManager = PathManagerFactory.getPathManager();
LocalizationType[] types = { LocalizationType.CAVE_CONFIG,
LocalizationType.CAVE_STATIC,
LocalizationType.COMMON_STATIC };
@ -105,6 +108,8 @@ public class SyncLocalizationEditor extends BooleanFieldEditor {
System.out.println("Time to download " + type + ": "
+ (endTime - startTime) + "ms");
}
getPreferenceStore().firePropertyChangeEvent(ThinClientPreferenceConstants.P_SYNC_REMOTE_LOCALIZATION,
true, false);
monitor.done();
return Status.OK_STATUS;
}

View file

@ -25,6 +25,7 @@ import java.util.Date;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.util.IPropertyChangeListener;
@ -53,6 +54,7 @@ import com.raytheon.uf.viz.thinclient.preferences.ThinClientPreferenceConstants;
* Aug 9, 2011 njensen Initial creation
* Aug 13, 2013 2033 mschenke Changed to search all plugins when
* CAVE_STATIC BASE context searched
* May 29, 2015 4532 bsteffen Always use super when sync job is running.
*
* </pre>
*
@ -63,6 +65,12 @@ import com.raytheon.uf.viz.thinclient.preferences.ThinClientPreferenceConstants;
public class ThinClientLocalizationAdapter extends CAVELocalizationAdapter
implements IPropertyChangeListener {
/**
* Whenever there is a sync job running, always call super to allow it to go
* to the server.
*/
private final AtomicInteger syncJobsRunning = new AtomicInteger(0);
private boolean useRemoteFiles = true;
public ThinClientLocalizationAdapter() {
@ -83,6 +91,10 @@ public class ThinClientLocalizationAdapter extends CAVELocalizationAdapter
@Override
public void retrieve(LocalizationFile file)
throws LocalizationOpFailedException {
if (syncJobsRunning.get() > 0) {
super.retrieve(file);
return;
}
try {
File localFile = file.getFile(false);
if (localFile.exists() == false || localFile.length() == 0) {
@ -91,8 +103,15 @@ public class ThinClientLocalizationAdapter extends CAVELocalizationAdapter
} catch (LocalizationOpFailedException e) {
throw e;
} catch (LocalizationException e) {
// Ignore exception
e.printStackTrace();
/*
* At the time of this writing, nothing will actually throw any
* LocalizationException other than LocalizationOpFailedException.
* However since LocalizationFile.getFile(boolean) has a method
* signature indicating it could throw any LocalizationException
* this code should be able to handle any LocalizationException in
* case the implementation of getFile changes in the future.
*/
throw new LocalizationOpFailedException(e);
}
}
@ -108,7 +127,7 @@ public class ThinClientLocalizationAdapter extends CAVELocalizationAdapter
public ListResponse[] listDirectory(LocalizationContext[] contexts,
String path, boolean recursive, boolean filesOnly)
throws LocalizationOpFailedException {
if (useRemoteFiles) {
if (shouldUseRemoteFiles()) {
return super.listDirectory(contexts, path, recursive, filesOnly);
} else {
@ -164,7 +183,7 @@ public class ThinClientLocalizationAdapter extends CAVELocalizationAdapter
public ListResponse[] getLocalizationMetadata(
LocalizationContext[] context, String fileName)
throws LocalizationOpFailedException {
if (useRemoteFiles) {
if (shouldUseRemoteFiles()) {
return super.getLocalizationMetadata(context, fileName);
} else {
List<ListResponse> responses = new ArrayList<ListResponse>(
@ -193,19 +212,30 @@ public class ThinClientLocalizationAdapter extends CAVELocalizationAdapter
@Override
public boolean exists(LocalizationFile file) {
if (useRemoteFiles) {
if (shouldUseRemoteFiles()) {
return super.exists(file);
} else {
return file.getFile().exists();
}
}
private boolean shouldUseRemoteFiles() {
return useRemoteFiles || syncJobsRunning.get() > 0;
}
@Override
public void propertyChange(PropertyChangeEvent event) {
if (ThinClientPreferenceConstants.P_DISABLE_REMOTE_LOCALIZATION
.equals(event.getProperty())) {
useRemoteFiles = !Boolean.valueOf(String.valueOf(event
.getNewValue()));
} else if (ThinClientPreferenceConstants.P_SYNC_REMOTE_LOCALIZATION.equals(event.getProperty())) {
boolean sync = Boolean.valueOf(String.valueOf(event.getNewValue()));
if (sync) {
syncJobsRunning.incrementAndGet();
} else {
syncJobsRunning.decrementAndGet();
}
}
}

View file

@ -19,6 +19,8 @@
**/
package com.raytheon.uf.viz.thinclient.preferences;
import org.eclipse.jface.preference.IPreferenceStore;
/**
* Preference constants for the thin client mode
*
@ -32,6 +34,8 @@ package com.raytheon.uf.viz.thinclient.preferences;
* Jan 14, 2013 1469 bkowal The hdf5 data directory is no longer a preference constant.
* Feb 04, 2014 2704 njensen Consolidate services and pypies proxy addresses
* Jun 24, 2014 3236 njensen Added proxy address options
* May 29, 2015 4532 bsteffen Add sync localization option.
*
*
* </pre>
*
@ -61,6 +65,19 @@ public class ThinClientPreferenceConstants {
public static String P_DISABLE_REMOTE_LOCALIZATION = "disableRemoteLocalization";
/**
* This preference is not stored but is used to send notification through
* the preference store that the {@link #P_CACHE_LOCALIZATION} and
* {@link #P_DISABLE_REMOTE_LOCALIZATION} should be temporarily ignored so
* that the localization files can be synchronized with the server. Before
* performing synchronization, an event should be fired using
* {@link IPreferenceStore#firePropertyChangeEvent(String, Object, Object)}
* with the preference name as {@link #P_SYNC_REMOTE_LOCALIZATION} and a
* newValue of true. When synchronization has completed another event should
* be fired with a newValue of false.
*/
public static String P_SYNC_REMOTE_LOCALIZATION = "syncRemoteFiles";
public static String P_DISABLE_MENU_TIMES = "disableMenuTimes";
public static String P_DISABLE_JMS = "disableJms";

View file

@ -17,6 +17,13 @@ then
echo "CAVE and/or gfeclient not installed on this workstation ..exiting"
exit 1
else
$_GFECLI $_MODULE "$@"
CONFDIR=${HOME}/.runProc-$(hostname)-$$
cleanup() {
rm -rf "$CONFDIR"
}
mkdir -p "$CONFDIR" || exit 1
trap cleanup EXIT
$_GFECLI -configuration $CONFDIR $_MODULE "$@"
fi

View file

@ -166,6 +166,7 @@ import com.vividsolutions.jts.geom.Polygon;
* not be as expected if percentage/area is different between the two products. But the
* chance for that to occur is trivial.
* May 7, 2015 ASM #17438 D. Friedman Clean up debug and performance logging.
* Jun 05, 2015 DR 17428 D. Friedman Fixed duration-related user interface issues. Added duration logging.
* </pre>
*
* @author chammack
@ -1095,15 +1096,25 @@ public class WarngenDialog extends CaveSWTDialog implements
* @param durations
*/
public void setDurations(int[] durations) {
String[] durList = new String[durations.length];
ArrayList<String> durList = new ArrayList<String>(durations.length);
boolean isDefaultDurationInList = false;
durationList.removeAll();
for (int i = 0; i < durations.length; i++) {
if (defaultDuration != null
&& defaultDuration.minutes == durations[i]) {
isDefaultDurationInList = true;
}
DurationData data = new DurationData(durations[i]);
durationList.setData(data.displayString, data);
durList[i] = data.displayString;
durList.add(data.displayString);
}
// Add the default duration to the list if what was missing
if (! isDefaultDurationInList && defaultDuration != null) {
durationList.setData(defaultDuration.displayString, defaultDuration);
durList.add(0, defaultDuration.displayString);
}
durationList.setItems(durList);
durationList.setItems(durList.toArray(new String[durList.size()]));
}
/**
@ -1179,6 +1190,8 @@ public class WarngenDialog extends CaveSWTDialog implements
long t0 = System.currentTimeMillis();
try {
monitor.beginTask("Generating product", 1);
statusHandler.debug("using startTime " + startTime.getTime()
+ " endTime " + endTime.getTime());
String result = TemplateRunner.runTemplate(
warngenLayer, startTime.getTime(),
endTime.getTime(), selectedBullets,
@ -1328,9 +1341,10 @@ public class WarngenDialog extends CaveSWTDialog implements
* Action for Reset button
*/
private void resetPressed() {
statusHandler.debug("resetPressed");
int durationToUse = getSelectedDuration();
warngenLayer.resetState();
warngenLayer.getStormTrackState().duration = ((DurationData) durationList
.getData(durationList.getItem(durationList.getSelectionIndex()))).minutes;
restoreDuration(durationToUse);
durationList.setEnabled(warngenLayer.getConfiguration()
.isEnableDuration());
if (lineOfStorms.getSelection()) {
@ -1366,6 +1380,7 @@ public class WarngenDialog extends CaveSWTDialog implements
warngenLayer.resetInitialFrame();
warngenLayer.setWarningAction(null);
instructionsLabel.setText("Instructions:");
changeStartEndTimes();
warngenLayer.issueRefresh();
}
@ -1430,8 +1445,11 @@ public class WarngenDialog extends CaveSWTDialog implements
* Select one storm
*/
private void selectOneStorm() {
statusHandler.debug("selectOneStorm");
if (warngenLayer.state.followupData == null) {
int savedDuration = warngenLayer.getStormTrackState().duration;
warngenLayer.resetState();
restoreDuration(savedDuration);
warngenLayer.reset("oneStorm");
warngenLayer.clearWarningGeometries();
warngenLayer.getStormTrackState().dragMeLine = null;
@ -1447,8 +1465,11 @@ public class WarngenDialog extends CaveSWTDialog implements
* Select line of storms
*/
private void selectLineOfStorms() {
statusHandler.debug("selectLineOfStorms");
if (warngenLayer.state.followupData == null) {
int savedDuration = warngenLayer.getStormTrackState().duration;
warngenLayer.resetState();
restoreDuration(savedDuration);
warngenLayer.reset("lineOfStorms");
warngenLayer.clearWarningGeometries();
warngenLayer.getStormTrackState().dragMeLine = null;
@ -1596,6 +1617,7 @@ public class WarngenDialog extends CaveSWTDialog implements
* - The button that has been clicked
*/
private void changeTemplate(String templateName) {
statusHandler.debug("changeTemplate: " + templateName);
String lastAreaSource = warngenLayer.getConfiguration()
.getHatchedAreaSource().getAreaSource();
@ -1689,11 +1711,11 @@ public class WarngenDialog extends CaveSWTDialog implements
}
protected void recreateDurations(Combo durList) {
setDurations(warngenLayer.getConfiguration().getDurations());
if (warngenLayer.getConfiguration().getDefaultDuration() != 0) {
setDefaultDuration(warngenLayer.getConfiguration()
.getDefaultDuration());
}
setDurations(warngenLayer.getConfiguration().getDurations());
durList.setText(defaultDuration.displayString);
endTime = DurationUtil.calcEndTime(startTime, defaultDuration.minutes);
end.setText(df.format(endTime.getTime()));
@ -1754,6 +1776,7 @@ public class WarngenDialog extends CaveSWTDialog implements
FollowupData data = (FollowupData) updateListCbo
.getData(updateListCbo.getItem(updateListCbo
.getSelectionIndex()));
statusHandler.debug("updateListSelected: " + (data != null ? data.getDisplayString() : "(null)"));
Mode currMode = warngenLayer.getStormTrackState().mode;
if (data != null) {
// does not refesh if user selected already highlighted option
@ -1863,6 +1886,8 @@ public class WarngenDialog extends CaveSWTDialog implements
|| (action == WarningAction.EXT)) {
recreateDurations(durationList);
}
} else {
statusHandler.debug("updateListSelected");
}
updateListCbo.pack(true);
productType.layout();
@ -1895,6 +1920,7 @@ public class WarngenDialog extends CaveSWTDialog implements
}
private void changeSelected() {
statusHandler.debug("changeSelected");
if ((validPeriodDlg == null) || validPeriodDlg.isDisposed()) {
validPeriodDlg = new ValidPeriodDialog(shell, startTime, endTime);
validPeriodDlg.setCloseCallback(new ICloseCallback() {
@ -1902,6 +1928,7 @@ public class WarngenDialog extends CaveSWTDialog implements
@Override
public void dialogClosed(Object returnValue) {
int duration = (Integer) returnValue;
statusHandler.debug("changeSelected.dialogClosed: " + duration);
if (duration != -1) {
durationList.setEnabled(false);
endTime.add(Calendar.MINUTE, duration);
@ -1926,6 +1953,7 @@ public class WarngenDialog extends CaveSWTDialog implements
private void durationSelected() {
String selection = durationList.getItem(durationList
.getSelectionIndex());
statusHandler.debug("durationSelected: " + selection);
endTime = DurationUtil.calcEndTime(extEndTime != null ? extEndTime
: startTime,
((DurationData) durationList.getData(selection)).minutes);
@ -2292,8 +2320,7 @@ public class WarngenDialog extends CaveSWTDialog implements
updatePolygon(newWarn);
recreateDurations(durationList);
int duration = ((DurationData) durationList.getData(durationList
.getItem(durationList.getSelectionIndex()))).minutes;
int duration = getSelectedDuration();
warngenLayer.getStormTrackState().duration = duration;
startTime = TimeUtil.newCalendar();
@ -2615,4 +2642,39 @@ public class WarngenDialog extends CaveSWTDialog implements
return defaultTemplate;
}
private void restoreDuration(int duration) {
warngenLayer.getStormTrackState().duration =
warngenLayer.getStormTrackState().newDuration = duration;
warngenLayer.getStormTrackState().geomChanged = true;
}
private int getSelectedDuration() {
Exception excToReport= null;
DurationData data = null;
try {
data = (DurationData) durationList.getData(durationList
.getItem(durationList.getSelectionIndex()));
} catch (RuntimeException e) {
excToReport = e;
}
int duration;
if (data != null) {
duration = data.minutes;
} else {
try {
duration = warngenLayer.getConfiguration().getDefaultDuration();
} catch (RuntimeException e) {
if (excToReport == null) {
excToReport = e;
}
duration = 30;
}
statusHandler.handle(Priority.WARN,
"Unable to determine duration from selection in WarnGen dialog. Using default of "
+ duration + " minutes.", excToReport);
}
statusHandler.debug("selected duration is " + duration);
return duration;
}
}

View file

@ -0,0 +1,154 @@
package gov.noaa.nws.crh.edex.grib.decoderpostprocessor;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import com.raytheon.edex.plugin.grib.decoderpostprocessors.ThreeHrPrecipGridProcessor;
import com.raytheon.edex.plugin.grib.exception.GribException;
import com.raytheon.uf.common.dataplugin.PluginException;
import com.raytheon.uf.common.dataplugin.grid.GridConstants;
import com.raytheon.uf.common.dataplugin.grid.GridRecord;
import com.raytheon.uf.edex.database.DataAccessLayerException;
import com.raytheon.uf.edex.database.query.DatabaseQuery;
import com.raytheon.uf.edex.plugin.grid.dao.GridDao;
/**
* Grib post processor implementation to generate 3-hr precipitation grids from
* the alternating (3-hr, 6-hr, 3-hr, 3-hr, 6-hr, etc.) precip grids in the
* GFS20 output.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------- -------- ----------- --------------------------
* Jun 08, 2015 M. Foster Initial Creation
*
*
* </pre>
*
* @author matthew.foster
* @version 1.0
*/
public class GFS20PostProcessor extends ThreeHrPrecipGridProcessor {
@Override
public GridRecord[] process(GridRecord record) throws GribException {
// Post process the data if this is a Total Precipitation grid
if (record.getParameter().getAbbreviation().equals("TP6hr")) {
return super.process(record);
}
return new GridRecord[] { record };
}
/**
* Retrieves a List of GridRecord via DAO query for the given datasetId, parm
* and refTime.
*
* @param datasetId
* The datasetId from which to retrieve the GridRecords
* @param parm
* The parameter for which to retrieve GridRecords
* @param refTime
* The reference (cycle) time for the aforementioned datasetId
* @return
* @throws GribException
*/
@SuppressWarnings("unchecked")
protected List<GridRecord> getPrecipInventory(String datasetId, String parm,
Date refTime) throws GribException {
GridDao dao = null;
try {
dao = new GridDao();
} catch (PluginException e) {
throw new GribException("Error instantiating grib dao!", e);
}
DatabaseQuery query = new DatabaseQuery(GridRecord.class);
query.addQueryParam(GridConstants.PARAMETER_ABBREVIATION, parm);
query.addQueryParam(GridConstants.DATASET_ID, datasetId);
query.addQueryParam("dataTime.refTime", refTime);
query.addOrder("dataTime.fcstTime", true);
try {
return (List<GridRecord>) dao.queryByCriteria(query);
} catch (DataAccessLayerException e) {
throw new GribException(
"Error getting Precip inventory for "+datasetId, e);
}
}
/**
* Generates the 3 hour accumulated grid by taking the difference of the
* current 6-hr accumulation and the previous 3-hr accumulation.
* This function will look in the inventory and generate any 3-hr grids
* that can be generated.
*
* @param record
* The grib record for which to generate the 3 hour accumulated
* precipitation grid
* @return The generated 3-hr precipitation grids
* @throws GribException
*/
protected synchronized GridRecord[] generate3hrPrecipGrids(GridRecord record)
throws GribException {
// The current 6-hr precipitation grid inventory in the database
List<GridRecord> precip6hrInventory = getPrecipInventory(record.getDatasetId(),
"TP6hr", record.getDataTime().getRefTime());
// The current 3-hr precipitation grid inventory in the database
List<GridRecord> precip3hrInventory = getPrecipInventory(record.getDatasetId(),
"TP3hr", record.getDataTime().getRefTime());
// Make a list of the 3-hr forecast times
List<Integer> precip3hrTimes = new ArrayList<Integer>();
for (int i=0; i < precip3hrInventory.size(); i++) {
precip3hrTimes.add(precip3hrInventory.get(i)
.getDataTime().getFcstTime());
}
// Adds the current record to the precip inventory
float[] currentData = (float[]) record.getMessageData();
record.setMessageData(currentData);
precip6hrInventory.add(record);
// Examine each grid in the inventory and generate the 3hr precipitation
// grid if possible
List<GridRecord> generatedRecords = new ArrayList<GridRecord>();
for (int i = 0; i < precip6hrInventory.size(); i++) {
// Check if the 3hr precipitation grid has already been produced
if (!precip3hrTimes.contains(precip6hrInventory.get(i)
.getDataTime().getFcstTime())) {
// If the precipitation grid has not been produced, generate it
List<GridRecord> generated3hrPrecips = generate3hrPrecip(
precip6hrInventory.get(i), precip3hrInventory);
for (GridRecord newRecord : generated3hrPrecips) {
// Add the generated grid to the current inventory
if (newRecord != null) {
precip3hrTimes.add(newRecord.getDataTime()
.getFcstTime());
generatedRecords.add(newRecord);
}
}
}
}
return generatedRecords.toArray(new GridRecord[] {});
}
/**
* {@inheritDoc}
*/
@Override
protected void calculatePrecipValues(float[] inventoryData, float[] newData) {
for (int i = 0; i < inventoryData.length; i++) {
newData[i] = newData[i] - inventoryData[i];
if (newData[i] < 0) {
newData[i] = 0;
}
}
}
}

File diff suppressed because one or more lines are too long

View file

@ -1516,12 +1516,11 @@ class SectionCommon():
pass
# If this is the "default" case
if self._tr == "default" and len(statements) > 0:
if elementName in ["Wind", "Storm Surge"]:
if statements[0].find("If realized, ") == -1:
statements[0] = "If realized, " + statements[0] + \
statements[0][1:]
#if self._tr == "default" and len(statements) > 0:
#
# if elementName in ["Wind", "Storm Surge"]:
# if statements[0].find("If realized, ") == -1:
# statements[0] = "If realized, " + statements[0][0].lower() + statements[0][1:]
return statements

View file

@ -114,9 +114,15 @@
<!-- Post processor definition for HPCqpfNDFD -->
<postProcessedModel>
<modelName>HPCqpfNDFD</modelName>
<processorName>HPCqpfPostProcessor</processorName>
</postProcessedModel>
<modelName>HPCqpfNDFD</modelName>
<processorName>HPCqpfPostProcessor</processorName>
</postProcessedModel>
<!-- Post processor definition for the GFS20 model -->
<postProcessedModel>
<modelName>GFS215|GFS217|GFS20-*</modelName>
<processorName>gov.noaa.nws.crh.edex.grib.decoderpostprocessor.GFS20PostProcessor</processorName>
</postProcessedModel>
</postProcessedModels>