Omaha #3220 - Performance - Safe Seas, Snow, Fog.

Former-commit-id: 2bb8bc22a6 [formerly 2bb8bc22a6 [formerly f8ee84a324b3653a75aa3c63a793eca412e1bd81]]
Former-commit-id: 9e076f7970
Former-commit-id: 13397de60b
This commit is contained in:
Slav Korolev 2015-01-20 11:55:03 -05:00
parent e1df0f4767
commit dd20df78ee
15 changed files with 299 additions and 374 deletions

View file

@ -82,11 +82,11 @@ import com.vividsolutions.jts.geom.Geometry;
* Oct.31 2012 1297 skorolev Clean code
* Feb 15, 2013 1638 mschenke Changed code to reference DataURI.SEPARATOR instead of URIFilter
* Apr 28, 2014 3086 skorolev Removed local getMonitorAreaConfig method.
* Sep 04, 2014 3220 skorolev Updated configUpdate method and added updateMonitoringArea.
* Sep 23, 2014 3356 njensen Remove unnecessary import
* Oct 16, 2014 3220 skorolev Corrected fogConfig assignment.
* Dec 11, 2014 3220 skorolev Moved refreshing of table in the UI thread.
* Jan 08, 2015 3220 skorolev Replaced MonitoringArea with fogConfig.
* Sep 04, 2014 3220 skorolev
* Sep 23, 2014 3356 njensen Remove unnecessary import
* Jan 27, 2015 3220 skorolev Corrected fogConfig assignment.Moved refreshing of table in the UI thread.
* Updated configUpdate method and added updateMonitoringArea.
* Replaced MonitoringArea with fogConfig.Updated code for better performance.
*
*
* </pre>
@ -104,21 +104,12 @@ public class FogMonitor extends ObsMonitor implements IFogResourceListener {
/** Singleton instance of this class */
private static FogMonitor monitor = null;
/**
* This object contains all observation data necessary for the table dialogs
* and trending plots [this replaces the objects of ObsData and TableData
* below Jan 21, 2010, zhao]
*/
private ObMultiHrsReports obData;
/** data holder for FOG **/
private ObsData obsData;
/** data holder for FOG ALG data **/
private SortedMap<Date, Map<String, FOG_THREAT>> algorithmData = null;
private Date dialogTime = null;
/** list of coordinates for each zone **/
private Map<String, Geometry> zoneGeometries = null;
@ -129,7 +120,7 @@ public class FogMonitor extends ObsMonitor implements IFogResourceListener {
private MonitoringAreaConfigDlg areaDialog = null;
/** area config manager **/
private FSSObsMonitorConfigurationManager fogConfig = null;
private static FSSObsMonitorConfigurationManager fogConfig = null;
/** table data for the station table **/
private final TableData stationTableData = new TableData(
@ -162,7 +153,6 @@ public class FogMonitor extends ObsMonitor implements IFogResourceListener {
initObserver(OBS, this);
obData = new ObMultiHrsReports(CommonConfig.AppName.FOG);
obData.setThresholdMgr(FogThresholdMgr.getInstance());
obData.getZoneTableData();
}
/**
@ -173,14 +163,10 @@ public class FogMonitor extends ObsMonitor implements IFogResourceListener {
public static synchronized FogMonitor getInstance() {
if (monitor == null) {
monitor = new FogMonitor();
// Pre-populate dialog with an observations from DB
monitor.createDataStructures();
monitor.getAdjAreas();
List<String> zones = monitor.fogConfig.getAreaList();
monitor.processProductAtStartup(zones);
monitor.fireMonitorEvent(monitor);
monitor.processProductAtStartup(fogConfig);
}
return monitor;
}
@ -204,7 +190,6 @@ public class FogMonitor extends ObsMonitor implements IFogResourceListener {
// [Jan 21, 2010, zhao]
obData = new ObMultiHrsReports(CommonConfig.AppName.FOG);
obData.setThresholdMgr(FogThresholdMgr.getInstance());
obsData = new ObsData();
algorithmData = new TreeMap<Date, Map<String, FOG_THREAT>>();
@ -247,8 +232,7 @@ public class FogMonitor extends ObsMonitor implements IFogResourceListener {
@Override
public void processProductMessage(final AlertMessage filtered) {
if (fogPattern.matcher(filtered.dataURI).matches()) {
List<String> zones = fogConfig.getAreaList();
processURI(filtered.dataURI, filtered, zones);
processURI(filtered.dataURI, filtered, fogConfig);
}
}
@ -285,8 +269,9 @@ public class FogMonitor extends ObsMonitor implements IFogResourceListener {
@Override
public void configUpdate(IMonitorConfigurationEvent me) {
fogConfig = (FSSObsMonitorConfigurationManager) me.getSource();
obData.getObHourReports().updateZones(fogConfig);
if (zoneDialog != null && !zoneDialog.isDisposed()) {
zoneDialog.refreshZoneTableData(obData);
obData.updateTableCache();
fireMonitorEvent(zoneDialog.getClass().getName());
}
}
@ -320,6 +305,8 @@ public class FogMonitor extends ObsMonitor implements IFogResourceListener {
@Override
protected void process(ObReport result) throws Exception {
obData.addReport(result);
// update table cache
obData.getZoneTableData(result.getRefHour());
// Get zones containing station
List<String> zones = fogConfig.getAreaByStationId(result
.getPlatformId());
@ -328,10 +315,10 @@ public class FogMonitor extends ObsMonitor implements IFogResourceListener {
AreaContainer ac = getTableData().getArea(zn);
if (ac != null) {
ac.addReport(result.getObservationTime(), result);
fireMonitorEvent(this);
}
}
}
fireMonitorEvent(this);
}
/**
@ -351,26 +338,20 @@ public class FogMonitor extends ObsMonitor implements IFogResourceListener {
*/
public void launchDialog(String type, Shell shell) {
if (type.equals("zone")) {
if (zoneDialog == null) {
zoneDialog = new FogZoneTableDlg(shell, obData);
addMonitorListener(zoneDialog);
zoneDialog.addMonitorControlListener(this);
fireMonitorEvent(zoneDialog.getClass().getName());
}
zoneDialog = new FogZoneTableDlg(shell, obData);
addMonitorListener(zoneDialog);
zoneDialog.addMonitorControlListener(this);
zoneDialog.open();
} else if (type.equals("area")) {
if (areaDialog == null) {
areaDialog = new FogMonitoringAreaConfigDlg(shell,
"Fog Monitor Area Configuration");
areaDialog.setCloseCallback(new ICloseCallback() {
areaDialog = new FogMonitoringAreaConfigDlg(shell,
"Fog Monitor Area Configuration");
areaDialog.setCloseCallback(new ICloseCallback() {
@Override
public void dialogClosed(Object returnValue) {
areaDialog = null;
}
});
}
@Override
public void dialogClosed(Object returnValue) {
areaDialog = null;
}
});
areaDialog.open();
}
}
@ -490,21 +471,18 @@ public class FogMonitor extends ObsMonitor implements IFogResourceListener {
*
* @param drawTime
*/
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.monitor.ObsMonitor#updateDialogTime(java.util.Date)
*/
@Override
public void updateDialogTime(Date dialogTime) {
this.dialogTime = dialogTime;
fireMonitorEvent(zoneDialog.getClass().getName());
}
/**
* The date for the dialog to stay in step with
*
* @return
*/
public Date getDialogDate() {
return dialogTime;
}
/*
* (non-Javadoc)
*

View file

@ -71,7 +71,6 @@ public class FogMonitoringAreaConfigDlg extends MonitoringAreaConfigDlg {
*/
public FogMonitoringAreaConfigDlg(Shell parent, String title) {
super(parent, title, AppName.FOG);
FogMonitor.getInstance();
}
/*

View file

@ -58,8 +58,7 @@ import com.raytheon.uf.viz.monitor.ui.dialogs.ZoneTableDlg;
* Dec 03, 2012 15216/15639 zhao fixed a bug related to Link-to-Frame
* Dec 7, 2012 1351 skorolev Changes for non-blocking dialogs.
* Apr 28, 2014 3086 skorolev Updated getConfigMgr method.
* Sep 04, 2014 3220 skorolev Removed "site". Added check on dispose.
* Oct 16, 2014 3220 skorolev Corrected configMgr assignment.
* Jan 27, 2015 3220 skorolev Removed "site".Added check on dispose.Corrected configMgr assignment.Added table cache update.
*
* </pre>
*
@ -80,6 +79,9 @@ public class FogZoneTableDlg extends ZoneTableDlg {
public FogZoneTableDlg(Shell parent, ObMultiHrsReports obData) {
super(parent, obData, CommonConfig.AppName.FOG);
configMgr = FSSObsMonitorConfigurationManager.getFogObsManager();
obData.updateTableCache();
zoneTblData = obData.getZoneTableData();
zoneTblData.sortData();
}
/**
@ -148,7 +150,7 @@ public class FogZoneTableDlg extends ZoneTableDlg {
if (me.getSource() instanceof FogMonitor) {
FogMonitor fog = (FogMonitor) me.getSource();
Date date = fog.getDialogDate();
Date date = fog.getDialogTime();
if (date != null) {
Date nominalTime = date;
ObMultiHrsReports obData = fog.getObData();
@ -164,29 +166,6 @@ public class FogZoneTableDlg extends ZoneTableDlg {
}
}
/**
* Jan 25, 2010, #4281, zhao, Modified to pass an ObMultiHrsReports object
* to table dialog
*
* @Override public void notify(IMonitorEvent me) { if
* (zoneTable.isDisposed()) return;
*
* if (me.getSource() instanceof FogMonitor) { FogMonitor monitor
* = (FogMonitor)me.getSource();
* this.updateTableDlg(monitor.getObData()); }
*
* //if (me.getSource() instanceof FogMonitor) { //
* IMPORTANT!!!!!! For now we just grab the most recent time from
* the OBSTable // When we have the CAVE rendering working we will
* grab it from the CaveResource! // Date date = new Date(); //
* FogMonitor fog = (FogMonitor)me.getSource(); //
* FogDataGenerator fdg = new FogDataGenerator(); // TableData
* tZoneTableData = fdg.generateZoneData(fog.getTableData(),
* fog.getAlgorithmData(), date); //
* updateZoneTable(tZoneTableData, fog.getStationTableData(),
* date); //} }
*/
/*
* (non-Javadoc)
*

View file

@ -81,11 +81,9 @@ import com.vividsolutions.jts.geom.Geometry;
* Oct 26, 2012 1280 skorolev Clean code and made changes for non-blocking dialog
* Oct 30, 2012 1297 skorolev Changed HashMap to Map
* Feb 15, 2013 1638 mschenke Changed code to reference DataURI.SEPARATOR instead of URIFilter
* Apr 28, 2014 3086 skorolev Removed local getMonitorAreaConfig method.
* Sep 04, 2014 3220 skorolev Updated configUpdate method and added updateMonitoringArea.
* Oct 16, 2014 3220 skorolev Corrected ssAreaConfig assignment.
* Dec 11, 2014 3220 skorolev Moved refreshing of table in the UI thread.
* Jan 08, 2015 3220 skorolev Replaced MonitoringArea with ssAreaConfig.
* Jan 27, 2015 3220 skorolev Removed local getMonitorAreaConfig method.Updated configUpdate method and added updateMonitoringArea.
* Corrected ssAreaConfig assignment. Moved refreshing of table in the UI thread.
* Replaced MonitoringArea with ssAreaConfig.Updated code for better performance.
*
* </pre>
*
@ -109,13 +107,7 @@ public class SafeSeasMonitor extends ObsMonitor implements ISSResourceListener {
private SSMonitoringAreaConfigDlg areaDialog = null;
/** configuration manager **/
private FSSObsMonitorConfigurationManager ssAreaConfig = null;
/**
* This object contains all observation data necessary for the table dialogs
* and trending plots
*/
private ObMultiHrsReports obData;
private static FSSObsMonitorConfigurationManager ssAreaConfig = null;
/** table data for the zone table **/
private final TableData zoneTableData = new TableData(
@ -134,9 +126,6 @@ public class SafeSeasMonitor extends ObsMonitor implements ISSResourceListener {
/** List of SAFESEAS resource listeners **/
private final List<ISSResourceListener> safeSeasResources = new ArrayList<ISSResourceListener>();
/** Time which Zone/County dialog shows. **/
private Date dialogTime = null;
/** list of coordinates for each zone **/
private Map<String, Geometry> zoneGeometries = null;
@ -164,7 +153,6 @@ public class SafeSeasMonitor extends ObsMonitor implements ISSResourceListener {
initObserver(OBS, this);
obData = new ObMultiHrsReports(CommonConfig.AppName.SAFESEAS);
obData.setThresholdMgr(SSThresholdMgr.getInstance());
obData.getZoneTableData();
}
/**
@ -173,12 +161,9 @@ public class SafeSeasMonitor extends ObsMonitor implements ISSResourceListener {
public static synchronized SafeSeasMonitor getInstance() {
if (monitor == null) {
monitor = new SafeSeasMonitor();
// Pre-populate dialog with an observation (METAR) for KOMA
monitor.createDataStructures();
monitor.getAdjAreas();
List<String> zones = monitor.ssAreaConfig.getAreaList();
monitor.processProductAtStartup(zones);
monitor.fireMonitorEvent(monitor);
monitor.processProductAtStartup(ssAreaConfig);
}
return monitor;
}
@ -213,26 +198,21 @@ public class SafeSeasMonitor extends ObsMonitor implements ISSResourceListener {
*/
public void launchDialog(String type, Shell shell) {
if (type.equals("zone")) {
if (zoneDialog == null) {
zoneDialog = new SSZoneTableDlg(shell, obData);
addMonitorListener(zoneDialog);
zoneDialog.addMonitorControlListener(this);
fireMonitorEvent(zoneDialog.getClass().getName());
}
zoneDialog = new SSZoneTableDlg(shell, obData);
addMonitorListener(zoneDialog);
zoneDialog.addMonitorControlListener(this);
zoneDialog.open();
} else if (type.equals("area")) {
if (areaDialog == null) {
areaDialog = new SSMonitoringAreaConfigDlg(shell,
"SAFESEAS Monitor Area Configuration");
areaDialog.setCloseCallback(new ICloseCallback() {
areaDialog = new SSMonitoringAreaConfigDlg(shell,
"SAFESEAS Monitor Area Configuration");
areaDialog.setCloseCallback(new ICloseCallback() {
@Override
public void dialogClosed(Object returnValue) {
areaDialog = null;
}
@Override
public void dialogClosed(Object returnValue) {
areaDialog = null;
}
});
}
});
areaDialog.open();
}
}
@ -271,8 +251,7 @@ public class SafeSeasMonitor extends ObsMonitor implements ISSResourceListener {
@Override
public void processProductMessage(final AlertMessage filtered) {
if (ssPattern.matcher(filtered.dataURI).matches()) {
final List<String> zones = ssAreaConfig.getAreaList();
processURI(filtered.dataURI, filtered, zones);
processURI(filtered.dataURI, filtered, ssAreaConfig);
}
}
@ -328,8 +307,11 @@ public class SafeSeasMonitor extends ObsMonitor implements ISSResourceListener {
@Override
public void configUpdate(IMonitorConfigurationEvent me) {
ssAreaConfig = (FSSObsMonitorConfigurationManager) me.getSource();
zoneDialog.refreshZoneTableData(obData);
fireMonitorEvent(zoneDialog.getClass().getName());
obData.getObHourReports().updateZones(ssAreaConfig);
if (zoneDialog != null && !zoneDialog.isDisposed()) {
obData.updateTableCache();
fireMonitorEvent(zoneDialog.getClass().getName());
}
}
/**
@ -383,6 +365,8 @@ public class SafeSeasMonitor extends ObsMonitor implements ISSResourceListener {
@Override
protected void process(ObReport result) throws Exception {
obData.addReport(result);
// update table cache
obData.getZoneTableData(result.getRefHour());
fireMonitorEvent(this);
}
@ -391,30 +375,18 @@ public class SafeSeasMonitor extends ObsMonitor implements ISSResourceListener {
*
* @param dialogTime
*/
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.monitor.ObsMonitor#updateDialogTime(java.util.Date)
*/
@Override
public void updateDialogTime(Date dialogTime) {
this.dialogTime = dialogTime;
fireMonitorEvent(zoneDialog.getClass().getName());
}
/**
* Gets Dialog Time.
*
* @return dialogTime
*/
public Date getDialogTime() {
return dialogTime;
}
/**
* Sets the dialogTime
*
* @param dialogTime
*/
public void setDialogTime(Date dialogTime) {
this.dialogTime = dialogTime;
}
/**
* Adds recourse listener
*
@ -460,7 +432,6 @@ public class SafeSeasMonitor extends ObsMonitor implements ISSResourceListener {
*/
@Override
public ArrayList<Date> getTimeOrderedKeys(IMonitor monitor, String type) {
// Not used
return null;
}

View file

@ -200,14 +200,6 @@ public class SafeSeasResourceData extends AbstractRequestableResourceData {
return fogThreatSS;
}
/** Get the SafeSeasMonitor monitor **/
protected SafeSeasMonitor getFogMonitor() {
if (monitor == null) {
monitor = SafeSeasMonitor.getInstance();
}
return monitor;
}
/**
* @return plotSource
*/

View file

@ -72,7 +72,6 @@ public class SSMonitoringAreaConfigDlg extends MonitoringAreaConfigDlg {
*/
public SSMonitoringAreaConfigDlg(Shell parent, String title) {
super(parent, title, AppName.SAFESEAS);
SafeSeasMonitor.getInstance();
}
@Override

View file

@ -54,10 +54,9 @@ import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants;
* Dec 30, 2009 3424 zhao use ObMultiHrsReports for obs data archive
* Oct 30, 2012 1297 skorolev Changed HashMap to Map
* Nov 10, 2012 1297 skorolev Added initiateProdArray
* Dec 7, 2012 #1351 skorolev Changes for non-blocking dialogs.
* Dec 7, 2012 1351 skorolev Changes for non-blocking dialogs.
* Apr 28, 2014 3086 skorolev Updated getConfigMgr method.
* Sep 04, 2014 3220 skorolev Removed "site". Added check on dispose.
* Oct 16, 2014 3220 skorolev Corrected configMgr assignment.
* Jan 27, 2015 3220 skorolev Removed "site". Added check on dispose.Corrected configMgr assignment.Added table cache update.
*
* </pre>
*
@ -81,6 +80,9 @@ public class SSZoneTableDlg extends ZoneTableDlg {
public SSZoneTableDlg(Shell parent, ObMultiHrsReports obData) {
super(parent, obData, CommonConfig.AppName.SAFESEAS);
configMgr = FSSObsMonitorConfigurationManager.getSsObsManager();
obData.updateTableCache();
zoneTblData = obData.getZoneTableData();
zoneTblData.sortData();
}
/**
@ -280,7 +282,7 @@ public class SSZoneTableDlg extends ZoneTableDlg {
* setZoneSortColumnAndDirection()
*/
@Override
protected void setZoneSortColumnAndDirection() {
public void setZoneSortColumnAndDirection() {
if (zoneTblData != null) {
zoneSortColumn = zoneTblData.getSortColumn();
zoneSortDirection = zoneTblData.getSortDirection();

View file

@ -20,7 +20,6 @@
package com.raytheon.uf.viz.monitor.snow;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.regex.Pattern;
@ -69,10 +68,10 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback;
* Nov. 1, 2012 1297 skorolev Changed HashMap to Map and clean code
* Feb 15, 2013 1638 mschenke Changed code to reference DataURI.SEPARATOR instead of URIFilter
* Apr 28, 2014 3086 skorolev Removed local getMonitorAreaConfig method.
* Sep 04, 2014 3220 skorolev Updated configUpdate method and added updateMonitoringArea.
* Oct 16, 2014 3220 skorolev Corrected snowConfig assignment.
* Dec 11, 2014 3220 skorolev Moved refreshing of table in the UI thread.
* Jan 08, 2015 3220 skorolev Replaced MonitoringArea with snowAreaConfig.
* Jan 27, 2015 3220 skorolev Updated configUpdate method and added updateMonitoringArea.
* Corrected snowConfig assignment.Corrected snowConfig assignment.
* Moved refreshing of table in the UI thread.Replaced MonitoringArea with snowAreaConfig.
* Updated code for better performance.
*
* </pre>
*
@ -96,13 +95,7 @@ public class SnowMonitor extends ObsMonitor implements ISnowResourceListener {
private SnowMonitoringAreaConfigDlg areaDialog = null;
/** SNOW configuration manager **/
private FSSObsMonitorConfigurationManager snowAreaConfig = null;
/**
* This object contains all observation data necessary for the table dialogs
* and trending plots
*/
private ObMultiHrsReports obData;
private static FSSObsMonitorConfigurationManager snowAreaConfig = null;
/** All SNOW datauri start with this */
private final String OBS = "fssobs";
@ -110,9 +103,6 @@ public class SnowMonitor extends ObsMonitor implements ISnowResourceListener {
/** regex wild card filter */
private final String wildCard = "[\\w\\(\\)-_:.]+";
/** Time which Zone/County dialog shows. **/
private Date dialogTime = null;
/** Array of snow listeners **/
private final List<ISnowResourceListener> snowResources = new ArrayList<ISnowResourceListener>();
@ -131,7 +121,6 @@ public class SnowMonitor extends ObsMonitor implements ISnowResourceListener {
initObserver(OBS, this);
obData = new ObMultiHrsReports(CommonConfig.AppName.SNOW);
obData.setThresholdMgr(SnowThresholdMgr.getInstance());
obData.getZoneTableData();
}
/**
@ -142,13 +131,17 @@ public class SnowMonitor extends ObsMonitor implements ISnowResourceListener {
public static synchronized SnowMonitor getInstance() {
if (monitor == null) {
monitor = new SnowMonitor();
List<String> zones = monitor.snowAreaConfig.getAreaList();
monitor.processProductAtStartup(zones);
monitor.fireMonitorEvent(monitor);
monitor.createDataStructures();
monitor.processProductAtStartup(snowAreaConfig);
}
return monitor;
}
private void createDataStructures() {
obData = new ObMultiHrsReports(CommonConfig.AppName.SNOW);
obData.setThresholdMgr(SnowThresholdMgr.getInstance());
}
/**
* Re-initialization of monitor.
*
@ -169,26 +162,21 @@ public class SnowMonitor extends ObsMonitor implements ISnowResourceListener {
*/
public void launchDialog(String type, Shell shell) {
if (type.equals("zone")) {
if (zoneDialog == null) {
zoneDialog = new SnowZoneTableDlg(shell, obData);
addMonitorListener(zoneDialog);
zoneDialog.addMonitorControlListener(this);
fireMonitorEvent(zoneDialog.getClass().getName());
}
zoneDialog = new SnowZoneTableDlg(shell, obData);
addMonitorListener(zoneDialog);
zoneDialog.addMonitorControlListener(this);
zoneDialog.open();
} else if (type.equals("area")) {
if (areaDialog == null) {
areaDialog = new SnowMonitoringAreaConfigDlg(shell,
"SNOW Monitor Area Configuration");
areaDialog.setCloseCallback(new ICloseCallback() {
areaDialog = new SnowMonitoringAreaConfigDlg(shell,
"SNOW Monitor Area Configuration");
areaDialog.setCloseCallback(new ICloseCallback() {
@Override
public void dialogClosed(Object returnValue) {
areaDialog = null;
}
@Override
public void dialogClosed(Object returnValue) {
areaDialog = null;
}
});
}
});
areaDialog.open();
}
}
@ -236,21 +224,7 @@ public class SnowMonitor extends ObsMonitor implements ISnowResourceListener {
@Override
public void processProductMessage(final AlertMessage filtered) {
if (snowPattern.matcher(filtered.dataURI).matches()) {
List<String> zones = snowAreaConfig.getAreaList();
processURI(filtered.dataURI, filtered, zones);
}
}
/**
* Sort by Date.
*
* @author dhladky
*
*/
public class SortByDate implements Comparator<Date> {
@Override
public int compare(Date o1, Date o2) {
return o1.compareTo(o2);
processURI(filtered.dataURI, filtered, snowAreaConfig);
}
}
@ -287,8 +261,9 @@ public class SnowMonitor extends ObsMonitor implements ISnowResourceListener {
@Override
public void configUpdate(IMonitorConfigurationEvent me) {
snowAreaConfig = (FSSObsMonitorConfigurationManager) me.getSource();
obData.getObHourReports().updateZones(snowAreaConfig);
if (zoneDialog != null && !zoneDialog.isDisposed()) {
zoneDialog.refreshZoneTableData(obData);
obData.updateTableCache();
fireMonitorEvent(zoneDialog.getClass().getName());
}
}
@ -318,27 +293,10 @@ public class SnowMonitor extends ObsMonitor implements ISnowResourceListener {
@Override
protected void process(ObReport result) throws Exception {
obData.addReport(result);
obData.getZoneTableData(result.getRefHour());
fireMonitorEvent(this);
}
/**
* Gets Dialog Time.
*
* @return dialogTime
*/
public Date getDialogTime() {
return dialogTime;
}
/**
* Sets dialog time.
*
* @param dialogTime
*/
public void setDialogTime(Date dialogTime) {
this.dialogTime = dialogTime;
}
/**
* Adds a listener.
*
@ -359,16 +317,6 @@ public class SnowMonitor extends ObsMonitor implements ISnowResourceListener {
snowResources.remove(isru);
}
/**
* SnowResource sets the Drawtime.
*
* @param dialogTime
*/
public void updateDialogTime(Date dialogTime) {
this.dialogTime = dialogTime;
fireMonitorEvent(this);
}
/**
* Close SNOW zone table dialog.
*/

View file

@ -71,7 +71,6 @@ public class SnowMonitoringAreaConfigDlg extends MonitoringAreaConfigDlg {
*/
public SnowMonitoringAreaConfigDlg(Shell parent, String title) {
super(parent, title, AppName.SNOW);
SnowMonitor.getInstance();
}
/*

View file

@ -53,8 +53,7 @@ import com.raytheon.uf.viz.monitor.ui.dialogs.ZoneTableDlg;
* Nov. 8, 2012 1297 skorolev Added initiateProdArray method
* Dec 7, 2012 1351 skorolev Changes for non-blocking dialogs
* Apr 28, 2014 3086 skorolev Updated getConfigMgr method.
* Sep 04, 2014 3220 skorolev Removed "site". Added check on dispose.
* Oct 16, 2014 3220 skorolev Corrected configMgr assignment.
* Jan 27, 2015 3220 skorolev Removed "site". Added check on dispose.Corrected configMgr assignment.Added table cache update.
*
* </pre>
*
@ -76,6 +75,9 @@ public class SnowZoneTableDlg extends ZoneTableDlg {
public SnowZoneTableDlg(Shell parent, ObMultiHrsReports obData) {
super(parent, obData, CommonConfig.AppName.SNOW);
configMgr = FSSObsMonitorConfigurationManager.getSnowObsManager();
obData.updateTableCache();
zoneTblData = obData.getZoneTableData();
zoneTblData.sortData();
}
/**

View file

@ -21,6 +21,7 @@ package com.raytheon.uf.viz.monitor;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -32,6 +33,7 @@ import com.raytheon.uf.common.dataplugin.fssobs.FSSObsRecord;
import com.raytheon.uf.common.dataplugin.fssobs.FSSObsRecordTransform;
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
import com.raytheon.uf.common.inventory.exception.DataCubeException;
import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager;
import com.raytheon.uf.common.pointdata.PointDataContainer;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
@ -42,6 +44,7 @@ import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.localization.LocalizationManager;
import com.raytheon.uf.viz.core.notification.NotificationMessage;
import com.raytheon.uf.viz.datacube.DataCubeContainer;
import com.raytheon.uf.viz.monitor.data.ObMultiHrsReports;
import com.raytheon.uf.viz.monitor.data.ObReport;
import com.raytheon.uf.viz.monitor.events.IMonitorConfigurationEvent;
import com.raytheon.uf.viz.monitor.events.IMonitorThresholdEvent;
@ -59,8 +62,7 @@ import com.raytheon.uf.viz.monitor.events.IMonitorThresholdEvent;
* Sep 11, 2013 2277 mschenke Got rid of ScriptCreator references
* Feb 04, 2014 2757 skorolev Added filter for removed stations
* May 08, 2014 3086 skorolev Added current site definition.
* Sep 04, 2014 3220 skorolev Removed cwa and monitorUsefrom vals.
* Jan 08, 2015 3220 skorolev Added zones parameter to processURI.
* Jan 27, 2015 3220 skorolev Removed cwa and monitorUsefrom vals.Added zones parameter to processURI.Updated code for better performance.
*
* </pre>
*
@ -102,6 +104,15 @@ public abstract class ObsMonitor extends Monitor {
/** these are the patterns for the stations **/
protected ArrayList<Pattern> stationPatterns = new ArrayList<Pattern>();
/**
* This object contains all observation data necessary for the table dialogs
* and trending plots
*/
protected ObMultiHrsReports obData;
/** current time of monitor dialog */
protected Date dialogTime;
/** Current CWA **/
public static String cwa = LocalizationManager.getInstance().getSite();
@ -186,10 +197,11 @@ public abstract class ObsMonitor extends Monitor {
*
* @param dataURI
* @param filtered
* @param zones
* @param areaConfig
*/
public void processURI(String dataURI, AlertMessage filtered,
final List<String> zones) {
final FSSObsMonitorConfigurationManager areaConfig) {
List<String> zones = areaConfig.getAreaList();
try {
Map<String, RequestConstraint> constraints = RequestConstraint
.toConstraintMapping(DataURIUtil.createDataURIMap(dataURI));
@ -223,51 +235,55 @@ public abstract class ObsMonitor extends Monitor {
* @param zones
*
*/
public void processProductAtStartup(List<String> zones) {
public void processProductAtStartup(
FSSObsMonitorConfigurationManager areaConfig) {
/**
* Assume this number for MaxNumObsTimes is larger enough to cover data
* of all observations (at least 24 hours' worth of data) in database
* [changed from 10 to 240 on May, 18, 2010 for DR #6015, zhao]
*/
int MaxNumObsTimes = 240;
Map<String, RequestConstraint> vals = new HashMap<String, RequestConstraint>();
try {
vals.put(FSSObsRecord.PLUGIN_NAME_ID, new RequestConstraint(
FSSObsRecord.PLUGIN_NAME));
List<String> zones = areaConfig.getAreaList();
if (!zones.isEmpty()) {
/**
* Assume this number for MaxNumObsTimes is larger enough to cover
* data of all observations (at least 24 hours' worth of data) in
* database [changed from 10 to 240 on May, 18, 2010 for DR #6015,
* zhao]
*/
int MaxNumObsTimes = 240;
Map<String, RequestConstraint> vals = new HashMap<String, RequestConstraint>();
try {
vals.put(FSSObsRecord.PLUGIN_NAME_ID, new RequestConstraint(
FSSObsRecord.PLUGIN_NAME));
DataTime[] dataTimesAvailable = DataCubeContainer.performTimeQuery(
vals, false);
DataTime[] selectedTimes = dataTimesAvailable;
DataTime[] dataTimesAvailable = DataCubeContainer
.performTimeQuery(vals, false);
DataTime[] selectedTimes = dataTimesAvailable;
// Ensure that the latest product is retrieved.
// [Modified: retrieve at most MaxNumObsTimes data
// points, Feb
// 19, 2010, zhao]
if (dataTimesAvailable.length > 0) {
Arrays.sort(dataTimesAvailable);
// at most, MaxNumObsTimes observation times are
// considered
if (dataTimesAvailable.length > MaxNumObsTimes) {
selectedTimes = new DataTime[MaxNumObsTimes];
System.arraycopy(dataTimesAvailable,
dataTimesAvailable.length - MaxNumObsTimes,
selectedTimes, 0, MaxNumObsTimes);
}
// Ensure that the latest product is retrieved.
// [Modified: retrieve at most MaxNumObsTimes data
// points, Feb
// 19, 2010, zhao]
if (dataTimesAvailable.length > 0) {
Arrays.sort(dataTimesAvailable);
// at most, MaxNumObsTimes observation times are
// considered
if (dataTimesAvailable.length > MaxNumObsTimes) {
selectedTimes = new DataTime[MaxNumObsTimes];
System.arraycopy(dataTimesAvailable,
dataTimesAvailable.length - MaxNumObsTimes,
selectedTimes, 0, MaxNumObsTimes);
}
FSSObsRecord[] obsRecords = requestFSSObs(vals, selectedTimes);
for (FSSObsRecord objectToSend : obsRecords) {
// Filter removed stations
if (!zones.isEmpty()) {
ObReport result = GenerateFSSObReport
FSSObsRecord[] obsRecords = requestFSSObs(vals,
selectedTimes);
for (FSSObsRecord objectToSend : obsRecords) {
// Filter removed stations
final ObReport result = GenerateFSSObReport
.generateObReport(objectToSend);
processAtStartup(result);
}
}
} catch (DataCubeException e) {
statusHandler.handle(Priority.PROBLEM,
"No data in database at startup.");
}
} catch (DataCubeException e) {
statusHandler.handle(Priority.PROBLEM,
"No data in database at startup.");
}
}
@ -296,4 +312,35 @@ public abstract class ObsMonitor extends Monitor {
constraints);
return FSSObsRecordTransform.toFSSObsRecords(pdc);
}
public ObMultiHrsReports getObData() {
return obData;
}
public void setObData(ObMultiHrsReports obData) {
this.obData = obData;
}
/**
* The date for the dialog to stay in step with
*
* @return
*/
public Date getDialogTime() {
return dialogTime;
}
public void setDialogTime(Date dialogTime) {
this.dialogTime = dialogTime;
}
/**
* Resource sets the Drawtime.
*
* @param dialogTime
*/
public void updateDialogTime(Date dialogTime) {
this.dialogTime = dialogTime;
fireMonitorEvent(this);
}
}

View file

@ -24,6 +24,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager;
import com.raytheon.uf.common.monitor.data.CommonConfig;
import com.raytheon.uf.common.monitor.data.CommonConfig.AppName;
import com.raytheon.uf.common.status.IUFStatusHandler;
@ -45,8 +46,8 @@ import com.raytheon.uf.viz.monitor.thresholds.AbstractThresholdMgr;
* Oct.29, 2012 1297 skorolev Changed HashMap to Map
* Oct.31, 2012 1297 skorolev Cleaned code.
* Sep 04, 2014 3220 skorolev Added updateZones method.
* Dec 18, 2014 3841 skorolev Corrected updateZones method.
* Jan 08, 2015 3220 skorolev Replaced MonitoringArea with areaConfig.
* Dec 18, 2014 3841 skorolev Corrected updateZones method.
* Jan 27, 2015 3220 skorolev Replaced MonitoringArea with areaConfig.Changed updateZones method.
*
* </pre>
*
@ -107,22 +108,16 @@ public class ObHourReports {
.getAreaByStationId(station);
if (zones.size() == 0) {
statusHandler
.error("Error: station: "
.info("Error: station: "
+ station
+ " is not associated with any zone in the monitoring area");
return;
}
boolean hasZone = false;
for (String zone : zones) {
if (hourReports.containsKey(zone)) {
hasZone = true;
hourReports.get(zone).addReport(report);
}
}
if (hasZone == false) {
statusHandler
.error("Error in addreport() of ObHourReports: unable to add obs report to data archive");
}
}
/**
@ -224,10 +219,12 @@ public class ObHourReports {
/**
* Updates zones in the Hour Reports
*
* @param configMgr
*/
public void updateZones() {
public void updateZones(FSSObsMonitorConfigurationManager configMgr) {
// Updated list of zones
List<String> updtZones = thresholdMgr.getAreaConfigMgr().getAreaList();
List<String> updtZones = configMgr.getAreaList();
// remove zones
hourReports.keySet().retainAll(updtZones);
// add zones

View file

@ -29,6 +29,7 @@ import java.util.Map;
import java.util.Set;
import java.util.SortedMap;
import java.util.TreeMap;
import java.util.concurrent.ConcurrentHashMap;
import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager;
import com.raytheon.uf.common.monitor.data.CommonConfig;
@ -53,9 +54,8 @@ import com.raytheon.uf.viz.monitor.thresholds.AbstractThresholdMgr;
* Dec 24, 2009 3424 zhao added getTrendDataSet() that returns ObTrendDataSet object
* Jan 25, 2010 4281, 3888, 3877 wkwock/zhao added getHistTableData method
* Oct.31, 2012 1297 skorolev Clean code.
* Jan. 29, 2013 15654 zhao add Wind Chill calculation for SNOW
* Sep 04, 2014 3220 skorolev Updated getStationTableData method.
* Jan 08, 2015 3220 skorolev Replaced MonitoringArea with cfgMgr.
* Jan.29, 2013 15654 zhao add Wind Chill calculation for SNOW
* Jan 27, 2015 3220 skorolev Updated getStationTableData method.Replaced MonitoringArea with cfgMgr.Added multiHrsTabData - Table data cache.
*
* </pre>
*
@ -81,9 +81,14 @@ public class ObMultiHrsReports {
private CommonConfig.AppName appName;
/**
* key is nominal time, value is ObHourReports object
* FSSObs records cache. Key is nominal time, value is ObHourReports object
*/
private SortedMap<Date, ObHourReports> multiHrsReports;
private SortedMap<Date, ObHourReports> multiHrsReports = new TreeMap<Date, ObHourReports>();
/**
* Monitor Table data cache. Key is nominal time, value is TableData
*/
private ConcurrentHashMap<Date, TableData> multiHrsTabData = new ConcurrentHashMap<Date, TableData>();
/**
* The maximum number of most recent hours within which observation reports
@ -100,29 +105,10 @@ public class ObMultiHrsReports {
*/
public ObMultiHrsReports(CommonConfig.AppName appName) {
this.appName = appName;
multiHrsReports = new TreeMap<Date, ObHourReports>();
if (appName.equals(AppName.FOG) || appName.equals(AppName.SAFESEAS)) {
initFogAlgCellType();
}
}
/**
* Add an array of ObReport objects to the ObMultiHrsReports object (Don't
* use! VK)
*
* @param result
*/
public void addReports(ObReport[] results) {
for (ObReport report : results) {
/**
* DR #8723: if wind speed is zero, wind direction should be N/A,
* not 0
*/
if (report.getWindSpeed() < 0.0001) { // zero wind speed
report.setWindDir(ObConst.MISSING);
}
addReport(report);
}
}
/**
@ -132,8 +118,6 @@ public class ObMultiHrsReports {
* @return returns multiHrsReports
*/
public void addReport(ObReport report) {
// Date nominalTime = TableUtil
// .getNominalTime(report.getObservationTime());
Date nominalTime = report.getRefHour();
/**
* DR #8723: if wind speed is zero, wind direction should be N/A, not 0
@ -160,22 +144,24 @@ public class ObMultiHrsReports {
report.setWindChill(calcWindChill(report.getTemperature(),
report.getWindSpeed()));
}
}
if (multiHrsReports.containsKey(nominalTime)) {
multiHrsReports.get(nominalTime).addReport(report);
ObHourReports obHourReports;
// new nominal time; create a new ObHourReports object
if (multiHrsReports.isEmpty()
|| !multiHrsReports.containsKey(nominalTime)) {
obHourReports = new ObHourReports(nominalTime, appName,
thresholdMgr);
} else {
// new nominal time; create a new ObHourReports object
// the map is full; delete the oldest entry
if (multiHrsReports.size() >= maxFrames) {
// the map is full; delete the oldest entry
multiHrsReports.remove(multiHrsReports.firstKey());
}
ObHourReports obHourReports = new ObHourReports(nominalTime,
appName, thresholdMgr);
obHourReports.addReport(report);
multiHrsReports.put(nominalTime, obHourReports);
// update multiHrsReports with new data
obHourReports = multiHrsReports.get(nominalTime);
}
obHourReports.addReport(report);
// update data cache
multiHrsReports.put(nominalTime, obHourReports);
}
/**
@ -216,26 +202,31 @@ public class ObMultiHrsReports {
/**
* Returns a zone TableData object for a caller-specified nominal-time. If
* no data available, returns an empty/default zone TableData object (table
* cells filled with "N/A").
* cells filled with "N/A"). Updates multiHrsTabData table cache.
*
* @param nominalTime
* @return
*/
public TableData getZoneTableData(Date nominalTime) {
TableData tabData = null;
if (nominalTime == null || !multiHrsReports.containsKey(nominalTime)) {
return getEmptyZoneTableData();
}
if (appName == AppName.FOG) {
return this.getObHourReports(nominalTime).getFogZoneTableData(
tabData = this.getObHourReports(nominalTime).getFogZoneTableData(
fogAlgCellType);
}
if (appName == AppName.SAFESEAS) {
return this.getObHourReports(nominalTime).getSSZoneTableData(
} else if (appName == AppName.SAFESEAS) {
tabData = this.getObHourReports(nominalTime).getSSZoneTableData(
fogAlgCellType);
}
return this.getObHourReports(nominalTime).getZoneTableData();
// return multiHrsReports.get(nominalTime).getZoneTableData();
} else {
tabData = this.getObHourReports(nominalTime).getZoneTableData();
}
// update table data cache
if (multiHrsTabData.replace(nominalTime, tabData) == null) {
multiHrsTabData.put(nominalTime, tabData);
}
return tabData;
}
/**
@ -248,10 +239,17 @@ public class ObMultiHrsReports {
.getSystemTime().getTime());
ObHourReports hourReports = new ObHourReports(nominalTime, appName,
thresholdMgr);
TableData tabData = null;
if (appName == AppName.FOG) {
return hourReports.getFogZoneTableData(fogAlgCellType);
tabData = hourReports.getFogZoneTableData(fogAlgCellType);
} else {
tabData = hourReports.getZoneTableData();
}
return hourReports.getZoneTableData();
// update cache with empty table data
if (multiHrsTabData.replace(nominalTime, tabData) == null) {
multiHrsTabData.put(nominalTime, tabData);
}
return tabData;
}
/**
@ -483,7 +481,26 @@ public class ObMultiHrsReports {
}
/**
* Gets MultiHrsReports
* Gets table cache
*
* @return
*/
public ConcurrentHashMap<Date, TableData> getMultiHrsTabData() {
return multiHrsTabData;
}
/**
* Sets table cache
*
* @param multiHrsTabData
*/
public void setMultiHrsTabData(
ConcurrentHashMap<Date, TableData> multiHrsTabData) {
this.multiHrsTabData = multiHrsTabData;
}
/**
* Gets data cache
*
* @return SortedMap object <nominal time, ObHourReports object>
*/
@ -492,27 +509,13 @@ public class ObMultiHrsReports {
}
/**
* Gets MultiHrsTableData Returns a SortedMap object (key is nominal time,
* value is zone TableData object)
* Sets data cache
*
* @return
* @param multiHrsReports
*/
public SortedMap<Date, TableData> getMultiHrsTableData() {
SortedMap<Date, TableData> multiHrsTblData = new TreeMap<Date, TableData>();
if (appName == AppName.FOG) {
for (Date nominalTime : multiHrsReports.keySet()) {
multiHrsTblData.put(
nominalTime,
multiHrsReports.get(nominalTime).getFogZoneTableData(
fogAlgCellType));
}
return multiHrsTblData;
}
for (Date nominalTime : multiHrsReports.keySet()) {
multiHrsTblData.put(nominalTime, multiHrsReports.get(nominalTime)
.getZoneTableData());
}
return multiHrsTblData;
public void setMultiHrsReports(
SortedMap<Date, ObHourReports> multiHrsReports) {
this.multiHrsReports = multiHrsReports;
}
/**
@ -549,8 +552,14 @@ public class ObMultiHrsReports {
*/
public ObHourReports getObHourReports() {
if (multiHrsReports.isEmpty()) {
return new ObHourReports(TableUtil.getNominalTime(SimulatedTime
.getSystemTime().getTime()), appName, thresholdMgr);
ObHourReports obHrsReps = new ObHourReports(
TableUtil.getNominalTime(SimulatedTime.getSystemTime()
.getTime()), appName, thresholdMgr);
Date refTm = obHrsReps.getNominalTime();
TableData tabData = obHrsReps.getZoneTableData();
multiHrsTabData.clear();
multiHrsTabData.put(refTm, tabData);
return obHrsReps;
}
return multiHrsReports.get(multiHrsReports.lastKey());
}
@ -635,4 +644,13 @@ public class ObMultiHrsReports {
}
setFogAlgCellType(fogAlgCellType);
}
/**
* Updates table cache
*/
public void updateTableCache() {
for (Date time : multiHrsReports.keySet()) {
getZoneTableData(time);
}
}
}

View file

@ -94,9 +94,8 @@ import com.vividsolutions.jts.io.ParseException;
* Nov.11, 2012 1297 skorolev new abstract initiateProdArray()
* May 13, 2014 3133 njensen Updated getting ObsHistType from configMgr
* May 15, 2014 3086 skorolev Replaced MonitorConfigurationManager with FSSObsMonitorConfigurationManager.
* Sep 15, 2014 3220 skorolev Added refreshZoneTableData method.
* Oct 17, 2014 3220 skorolev Added condition into launchTrendPlot to avoid NPE.
* Nov 03, 2014 3741 skorolev Updated zoom procedures.
* Jan 27, 2015 3220 skorolev Added refreshZoneTableData method.Added condition into launchTrendPlot to avoid NPE.Updated code for better performance.
*
* </pre>
*
@ -260,9 +259,6 @@ public abstract class ZoneTableDlg extends CaveSWTDialog implements
this.site = LocalizationManager.getInstance().getCurrentSite();
dFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
this.obData = obData;
// the zone table data of the latest nominal time:
zoneTblData = obData.getZoneTableData();
zoneTblData.sortData();
nominalTime = obData.getLatestNominalTime();
}
@ -458,12 +454,16 @@ public abstract class ZoneTableDlg extends CaveSWTDialog implements
* their current values
*/
setZoneSortColumnAndDirection();
zoneTblData = obData.getZoneTableData(date);
zoneTblData
.setSortColumnAndDirection(zoneSortColumn, zoneSortDirection);
zoneTblData.sortData();
zoneTable.setTableData(zoneTblData);
zoneTable.table.redraw();
// get tab cache data
zoneTblData = obData.getMultiHrsTabData().get(date);
// update table if there are tab data in cache
if (zoneTblData != null) {
zoneTblData.setSortColumnAndDirection(zoneSortColumn,
zoneSortDirection);
zoneTblData.sortData();
zoneTable.setTableData(zoneTblData);
zoneTable.table.redraw();
}
}
/**
@ -495,7 +495,7 @@ public abstract class ZoneTableDlg extends CaveSWTDialog implements
/**
* Sets Column and Sort Direction for Zone table.
*/
protected void setZoneSortColumnAndDirection() {
public void setZoneSortColumnAndDirection() {
if (zoneTblData != null) {
zoneSortColumn = zoneTblData.getSortColumn();
zoneSortDirection = zoneTblData.getSortDirection();
@ -605,6 +605,9 @@ public abstract class ZoneTableDlg extends CaveSWTDialog implements
*/
@Override
public void zoneTableAction(int rowNum) {
zoneTblData = obData.getZoneTableData(nominalTime);
zoneTblData.sortData();
// set selectedZone to the selected zone
selectedZone = zoneTblData.getTableRows().get(rowNum)
.getTableCellData(0).getCellText();
@ -968,14 +971,4 @@ public abstract class ZoneTableDlg extends CaveSWTDialog implements
}
return varName;
}
/**
* Refreshes Zone Table.
*
* @param obData
*/
public void refreshZoneTableData(ObMultiHrsReports obData) {
obData.getObHourReports().updateZones();
this.updateTableDlg(obData.getObHourReports());
}
}

View file

@ -930,6 +930,7 @@ public class FSSObsMonitorConfigurationManager implements
public void fileUpdated(FileUpdatedMessage message) {
if (message.getFileName().equals(getConfigFileName())) {
try {
readConfigXml();
// inform listeners
for (MonitorConfigListener fl : listeners) {
fl.configChanged(new MonitorConfigEvent(this));