diff --git a/cave/build/static/common/cave/etc/aviation/python/LLWSMonitor.py b/cave/build/static/common/cave/etc/aviation/python/LLWSMonitor.py index f34e95e622..257e31a81e 100644 --- a/cave/build/static/common/cave/etc/aviation/python/LLWSMonitor.py +++ b/cave/build/static/common/cave/etc/aviation/python/LLWSMonitor.py @@ -95,7 +95,6 @@ class Monitor(MonitorP.Monitor): def __compare(self, taf): now = time.time() text, maxval = [], -1.0 - #data = Globals.DRC.getLLWS(self.info['ident']) data = LLWSData.retrieve(self.info['ident'], self.info) if data is None: data = [] diff --git a/cave/com.raytheon.uf.viz.derivparam/src/com/raytheon/uf/viz/derivparam/inv/AbstractInventory.java b/cave/com.raytheon.uf.viz.derivparam/src/com/raytheon/uf/viz/derivparam/inv/AbstractInventory.java index c399c04e02..e4b9877298 100644 --- a/cave/com.raytheon.uf.viz.derivparam/src/com/raytheon/uf/viz/derivparam/inv/AbstractInventory.java +++ b/cave/com.raytheon.uf.viz.derivparam/src/com/raytheon/uf/viz/derivparam/inv/AbstractInventory.java @@ -196,7 +196,6 @@ public abstract class AbstractInventory implements DerivParamUpdateListener { } else { this.derParLibrary = derParLibrary; } - long startTime = System.currentTimeMillis(); DataTree newTree = null; newTree = createBaseTree(); if (newTree == null) { @@ -224,9 +223,6 @@ public abstract class AbstractInventory implements DerivParamUpdateListener { } } } - System.out.println("Time to initialize " - + this.getClass().getSimpleName() + ": " - + (System.currentTimeMillis() - startTime) + "ms"); } @Override diff --git a/cave/com.raytheon.viz.aviation/src/com/raytheon/viz/aviation/AviationDialog.java b/cave/com.raytheon.viz.aviation/src/com/raytheon/viz/aviation/AviationDialog.java index 82797d8303..bd57b506cb 100644 --- a/cave/com.raytheon.viz.aviation/src/com/raytheon/viz/aviation/AviationDialog.java +++ b/cave/com.raytheon.viz.aviation/src/com/raytheon/viz/aviation/AviationDialog.java @@ -27,6 +27,10 @@ import java.util.concurrent.atomic.AtomicInteger; import javax.xml.bind.JAXB; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; @@ -50,6 +54,7 @@ import com.raytheon.uf.common.localization.PathManagerFactory; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; +import com.raytheon.uf.viz.core.datastructure.DataCubeContainer; import com.raytheon.uf.viz.core.localization.LocalizationManager; import com.raytheon.viz.aviation.climatology.ClimateMenuDlg; import com.raytheon.viz.aviation.model.ForecastModel; @@ -95,6 +100,7 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback; * file exists. * 10/02/2012 1229 rferrel Made dialog non-blocking. * 10/09/2012 1229 rferrel Changes for non-blocking TafMonitorDlg. + * 04/10/2013 1735 rferrel Changes for taf monitor speed up. * * * @@ -186,11 +192,21 @@ public class AviationDialog extends CaveSWTDialog implements IBackupRestart { ForecastModel.getInstance().setBackupRestartUtility(this); } + /* + * (non-Javadoc) + * + * @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#constructShellLayout() + */ @Override protected Layout constructShellLayout() { return new GridLayout(1, false); } + /* + * (non-Javadoc) + * + * @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#disposed() + */ @Override protected void disposed() { font.dispose(); @@ -211,6 +227,13 @@ public class AviationDialog extends CaveSWTDialog implements IBackupRestart { } } + /* + * (non-Javadoc) + * + * @see + * com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#initializeComponents(org + * .eclipse.swt.widgets.Shell) + */ @Override protected void initializeComponents(Shell shell) { setReturnValue(false); @@ -271,6 +294,25 @@ public class AviationDialog extends CaveSWTDialog implements IBackupRestart { createLabel(); createList(); createComposite(); + initAcarsSounding(); + } + + /** + * To speed up the display of the monitor this method starts up the Data + * Cube for the acarssounding inventory which can take over a second for the + * initial retrieval. This may cause blocking issues that slows the display + * of the monitor. + */ + private void initAcarsSounding() { + Job job = new Job("AviationDialog") { + + @Override + protected IStatus run(IProgressMonitor monitor) { + DataCubeContainer.getInventory("acarssounding"); + return Status.OK_STATUS; + } + }; + job.schedule(); } /** diff --git a/cave/com.raytheon.viz.aviation/src/com/raytheon/viz/aviation/climatology/CigVisByHourTabComp.java b/cave/com.raytheon.viz.aviation/src/com/raytheon/viz/aviation/climatology/CigVisByHourTabComp.java index d543468737..437080b0ff 100755 --- a/cave/com.raytheon.viz.aviation/src/com/raytheon/viz/aviation/climatology/CigVisByHourTabComp.java +++ b/cave/com.raytheon.viz.aviation/src/com/raytheon/viz/aviation/climatology/CigVisByHourTabComp.java @@ -221,7 +221,7 @@ public class CigVisByHourTabComp extends Composite implements ICigVisTabComp { * Data to set. */ public void setCigVisData(CigVisDistDataManager data) { - data = data; + this.data = data; cigVisCanvasComp.setCigVisData(data); } diff --git a/cave/com.raytheon.viz.aviation/src/com/raytheon/viz/aviation/monitor/MonitorDataUtil.java b/cave/com.raytheon.viz.aviation/src/com/raytheon/viz/aviation/monitor/MonitorDataUtil.java index 15ddf6b9b8..b2fc7318e3 100644 --- a/cave/com.raytheon.viz.aviation/src/com/raytheon/viz/aviation/monitor/MonitorDataUtil.java +++ b/cave/com.raytheon.viz.aviation/src/com/raytheon/viz/aviation/monitor/MonitorDataUtil.java @@ -21,6 +21,7 @@ package com.raytheon.viz.aviation.monitor; import java.text.SimpleDateFormat; import java.util.Arrays; +import java.util.Collections; import java.util.Date; import java.util.HashMap; import java.util.List; @@ -31,18 +32,21 @@ import com.raytheon.edex.plugin.ccfp.CcfpRecord; import com.raytheon.uf.common.dataplugin.acarssounding.ACARSSoundingRecord; import com.raytheon.uf.common.dataplugin.binlightning.BinLightningRecord; import com.raytheon.uf.common.dataplugin.radar.RadarRecord; +import com.raytheon.uf.common.dataquery.requests.DbQueryRequest; import com.raytheon.uf.common.dataquery.requests.RequestConstraint; +import com.raytheon.uf.common.dataquery.requests.RequestConstraint.ConstraintType; +import com.raytheon.uf.common.dataquery.requests.TimeQueryRequest; +import com.raytheon.uf.common.dataquery.responses.DbQueryResponse; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.common.time.DataTime; -import com.raytheon.uf.viz.core.catalog.CatalogQuery; -import com.raytheon.uf.viz.core.catalog.LayerProperty; -import com.raytheon.uf.viz.core.comm.Loader; +import com.raytheon.uf.viz.core.datastructure.DataCubeContainer; import com.raytheon.uf.viz.core.exception.VizException; +import com.raytheon.uf.viz.core.requests.ThriftClient; /** - * Utility functions for data requesting + * Utility functions for data requesting. * *
  * 
@@ -50,6 +54,7 @@ import com.raytheon.uf.viz.core.exception.VizException;
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Sep 10, 2009            njensen     Initial creation
+ * Apr 10, 2013 1735       rferrel     Convert to ThinClient and DbQueryRequests.
  * 
  * 
* @@ -72,22 +77,24 @@ public class MonitorDataUtil { * Get the lightning data newer than a particular time * * @param time - * @return + * @return records */ public static BinLightningRecord[] getLightningData(long time) { + DbQueryRequest request = new DbQueryRequest(); + request.setEntityClass(BinLightningRecord.class); + Map map = new HashMap(); map.put("pluginName", new RequestConstraint("binlightning")); map.put("startTime", new RequestConstraint(SDF.format(new Date(time)), RequestConstraint.ConstraintType.GREATER_THAN_EQUALS)); - LayerProperty lp = new LayerProperty(); - lp.setNumberOfImages(999); + request.setConstraints(map); + request.setLimit(999); + try { - lp.setEntryQueryParameters(map); - List objs = Loader.loadData(lp, "select", 10000); - BinLightningRecord[] records = new BinLightningRecord[objs.size()]; - for (int i = 0; i < records.length; i++) { - records[i] = (BinLightningRecord) objs.get(i); - } + DbQueryResponse response = (DbQueryResponse) ThriftClient + .sendRequest(request); + BinLightningRecord[] records = response + .getEntityObjects(BinLightningRecord.class); return records; } catch (VizException e) { statusHandler.handle(Priority.PROBLEM, @@ -96,39 +103,49 @@ public class MonitorDataUtil { return new BinLightningRecord[0]; } + /** + * Obtain ccfp records greater then or equal to time. + * + * @param time + * @return records + */ + @SuppressWarnings("unchecked") public static CcfpRecord[] getCcfpData(long time) { Map map = new HashMap(); - map.put("pluginName", new RequestConstraint("ccfp")); map.put("dataTime.refTime", new RequestConstraint(SDF.format(new Date(time)), RequestConstraint.ConstraintType.GREATER_THAN_EQUALS)); try { - String[] catalog = CatalogQuery.performQuery("dataTime", map); - String[] times = catalog; - DataTime[] dts = null; - Arrays.sort(catalog); - if (catalog.length > 3) { - dts = new DataTime[3]; - dts[0] = new DataTime(catalog[catalog.length - 1]); - dts[1] = new DataTime(catalog[catalog.length - 2]); - dts[2] = new DataTime(catalog[catalog.length - 3]); - } else { - dts = new DataTime[times.length]; - for (int i = 0; i < catalog.length; i++) { - dts[i] = new DataTime(catalog[catalog.length - i - 1]); - } - } - map.remove("dataTime.refTime"); - LayerProperty lp = new LayerProperty(); - lp.setNumberOfImages(999); - lp.setSelectedEntryTimes(dts); + TimeQueryRequest tqRequest = new TimeQueryRequest(); + tqRequest.setPluginName("ccfp"); + tqRequest.setQueryTerms(map); - lp.setEntryQueryParameters(map); - List objs = Loader.loadData(lp, "select", 10000); - CcfpRecord[] records = new CcfpRecord[objs.size()]; - for (int i = 0; i < records.length; i++) { - records[i] = (CcfpRecord) objs.get(i); + List dtList = (List) ThriftClient + .sendRequest(tqRequest); + String[] dts = new String[dtList.size()]; + for (int index = 0; index < dts.length; ++index) { + dts[index] = dtList.get(index).toString(); } + map.put("pluginName", new RequestConstraint("ccfp")); + Arrays.sort(dts, Collections.reverseOrder()); + + if (dts.length > 3) { + dts = Arrays.copyOf(dts, 3); + } + + map.remove("dataTime.refTime"); + + DbQueryRequest request = new DbQueryRequest(); + request.setEntityClass(CcfpRecord.class); + request.setLimit(999); + request.setConstraints(map); + RequestConstraint dataTimeRC = new RequestConstraint(); + dataTimeRC.setConstraintType(ConstraintType.IN); + dataTimeRC.setConstraintValueList(dts); + request.addConstraint("dataTime", dataTimeRC); + DbQueryResponse response = (DbQueryResponse) ThriftClient + .sendRequest(request); + CcfpRecord[] records = response.getEntityObjects(CcfpRecord.class); return records; } catch (VizException e) { statusHandler.handle(Priority.PROBLEM, @@ -138,6 +155,13 @@ public class MonitorDataUtil { return new CcfpRecord[0]; } + /** + * Get the most recent radar vertical wind profile. + * + * @param radar + * @param time + * @return records + */ public static RadarRecord[] getVerticalWindProfile(String radar, long time) { Map map = new HashMap(); map.put("pluginName", new RequestConstraint("radar")); @@ -147,28 +171,37 @@ public class MonitorDataUtil { map.put("icao", new RequestConstraint(radar.toLowerCase())); map.put("mnemonic", new RequestConstraint("VWP")); - LayerProperty lp = new LayerProperty(); + DbQueryRequest request = new DbQueryRequest(); + request.setEntityClass(RadarRecord.class); + try { - lp.setEntryQueryParameters(map); - DataTime[] dt = lp.getEntryTimes(); + DataTime[] dt = DataCubeContainer.performTimeQuery(map, true); + map.remove("dataTime.refTime"); + request.setConstraints(map); if (dt.length > 0) { - lp.setSelectedEntryTimes(new DataTime[] { dt[dt.length - 1] }); - } - - List objs = Loader.loadData(lp, "select", 10000); - - RadarRecord[] records = new RadarRecord[objs.size()]; - for (int i = 0; i < records.length; i++) { - records[i] = (RadarRecord) objs.get(i); + request.addConstraint("dataTime", + new RequestConstraint(SDF.format(dt[0].getRefTime()))); } + DbQueryResponse response = (DbQueryResponse) ThriftClient + .sendRequest(request); + RadarRecord[] records = response + .getEntityObjects(RadarRecord.class); return records; } catch (VizException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + statusHandler.handle(Priority.ERROR, + "Error retrieving radar vertical wind profile data", e); } return null; } + /** + * Get ACARS most recent sounding record for a station that is greater then + * or equal to time. + * + * @param stationId + * @param time + * @return records + */ public static ACARSSoundingRecord[] getAcarsSoundingRecords( String stationId, long time) { Map map = new HashMap(); @@ -179,24 +212,26 @@ public class MonitorDataUtil { map.put("location.stationId", new RequestConstraint(stationId.substring(1))); - LayerProperty lp = new LayerProperty(); + DbQueryRequest request = new DbQueryRequest(); + request.setEntityClass(ACARSSoundingRecord.class); + try { - lp.setEntryQueryParameters(map); - DataTime[] dt = lp.getEntryTimes(); + DataTime[] dt = DataCubeContainer.performTimeQuery(map, true); + map.remove("dataTime.refTime"); + request.setConstraints(map); + if (dt.length > 0) { - lp.setSelectedEntryTimes(new DataTime[] { dt[dt.length - 1] }); - } - - List objs = Loader.loadData(lp, "select", 10000); - - ACARSSoundingRecord[] records = new ACARSSoundingRecord[objs.size()]; - for (int i = 0; i < records.length; i++) { - records[i] = (ACARSSoundingRecord) objs.get(i); + request.addConstraint("dataTime", + new RequestConstraint(SDF.format(dt[0].getRefTime()))); } + DbQueryResponse response = (DbQueryResponse) ThriftClient + .sendRequest(request); + ACARSSoundingRecord[] records = response + .getEntityObjects(ACARSSoundingRecord.class); return records; } catch (VizException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + statusHandler.handle(Priority.ERROR, + "Error retrieving Acars Sounding Records data", e); } return null; } diff --git a/cave/com.raytheon.viz.aviation/src/com/raytheon/viz/aviation/monitor/PythonMonitorJob.java b/cave/com.raytheon.viz.aviation/src/com/raytheon/viz/aviation/monitor/PythonMonitorJob.java index a91116c3ff..9959d9932d 100644 --- a/cave/com.raytheon.viz.aviation/src/com/raytheon/viz/aviation/monitor/PythonMonitorJob.java +++ b/cave/com.raytheon.viz.aviation/src/com/raytheon/viz/aviation/monitor/PythonMonitorJob.java @@ -112,7 +112,7 @@ public class PythonMonitorJob extends AbstractQueueJob { * Places request on static queue. * * @param req - * @return + * @return true if request is accepted. */ public static boolean offerRequest(MonitorRequest req) { try { diff --git a/cave/com.raytheon.viz.aviation/src/com/raytheon/viz/aviation/observer/TafMonitorDlg.java b/cave/com.raytheon.viz.aviation/src/com/raytheon/viz/aviation/observer/TafMonitorDlg.java index 5e1ae19c40..ae7c415a3a 100644 --- a/cave/com.raytheon.viz.aviation/src/com/raytheon/viz/aviation/observer/TafMonitorDlg.java +++ b/cave/com.raytheon.viz.aviation/src/com/raytheon/viz/aviation/observer/TafMonitorDlg.java @@ -288,6 +288,11 @@ public class TafMonitorDlg extends CaveSWTDialog implements currentDlg = this; } + /* + * (non-Javadoc) + * + * @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#constructShellLayout() + */ @Override protected Layout constructShellLayout() { // Create the main layout for the shell. @@ -297,6 +302,11 @@ public class TafMonitorDlg extends CaveSWTDialog implements return mainLayout; } + /* + * (non-Javadoc) + * + * @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#disposed() + */ @Override protected void disposed() { SiteGridManager.clear(); @@ -304,6 +314,13 @@ public class TafMonitorDlg extends CaveSWTDialog implements tveDlg.disposeDialog(); } + /* + * (non-Javadoc) + * + * @see + * com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#initializeComponents(org + * .eclipse.swt.widgets.Shell) + */ @Override protected void initializeComponents(Shell shell) { setReturnValue(false); @@ -323,6 +340,11 @@ public class TafMonitorDlg extends CaveSWTDialog implements }); } + /* + * (non-Javadoc) + * + * @see com.raytheon.viz.ui.dialogs.CaveSWTDialog#preOpened() + */ @Override protected void preOpened() { checkNow(); diff --git a/edexOsgi/com.raytheon.uf.common.dataquery/src/com/raytheon/uf/common/dataquery/responses/DbQueryResponse.java b/edexOsgi/com.raytheon.uf.common.dataquery/src/com/raytheon/uf/common/dataquery/responses/DbQueryResponse.java index 62fcae6ef6..8ccf58cdd5 100644 --- a/edexOsgi/com.raytheon.uf.common.dataquery/src/com/raytheon/uf/common/dataquery/responses/DbQueryResponse.java +++ b/edexOsgi/com.raytheon.uf.common.dataquery/src/com/raytheon/uf/common/dataquery/responses/DbQueryResponse.java @@ -66,13 +66,17 @@ public class DbQueryResponse implements ISerializableObject { return getResults().size(); } - @SuppressWarnings("unchecked") public T[] getEntityObjects(Class entityType) { + return getFieldObjects(ENTITY_RESULT_KEY, entityType); + } + + @SuppressWarnings("unchecked") + public T[] getFieldObjects(String fieldKey, Class fieldType) { List> results = getResults(); - T[] entities = (T[]) Array.newInstance(entityType, results.size()); + T[] entities = (T[]) Array.newInstance(fieldType, results.size()); int i = 0; for (Map result : results) { - entities[i++] = entityType.cast(result.get(ENTITY_RESULT_KEY)); + entities[i++] = fieldType.cast(result.get(fieldKey)); } return entities; }