From 49a1879325f2ecdaf39b4f0c08c1223fa8580d3b Mon Sep 17 00:00:00 2001 From: Steve Harris Date: Wed, 18 Feb 2015 15:47:47 -0600 Subject: [PATCH] Omaha #3220 - reverting #3841, #3873, and most of #3220 Revert "Omaha #3841 - Fixed saving problem for distance and time." This reverts commit b8be69c4294dfd1de0d22074a39da71497b66945 [formerly d6737249fc9d3db54a143345053acdfe889686bf]. Revert "Omaha #3220 - Performance - Safe Seas, Snow, Fog." This reverts commit 9e076f7970d62c25a17f737abe185a63dc12ca7c [formerly f8ee84a324b3653a75aa3c63a793eca412e1bd81]. Revert "Omaha #3220 - Replaced MonitoringArea class with individual area configuration managers." This reverts commit b8ab18d3e1cfe2ff19a52ba588200a81cce676c9 [formerly 00fd20d76a4ea46e9806bad11b1bc5a2acc42d6e]. Revert "Omaha #3841 - Corrected updateZones method." This reverts commit 6ebe11d430744d4352f99d55d4c538995da9e0ad [formerly 4d133cc367ab016b378ada534cff0fcda579e323]. Revert "Omaha #3220 - Moved refreshing of table in the UI thread." This reverts commit fd3a6ea1999d249e16f51c4f876cb6530c93b825 [formerly 7454b39e71eeca348f4f167b8aa70d6ce5253004]. Revert "Omaha #3873 - Fixed assigning timeObs for maritime record." This reverts commit 63026ac59b274945d3d01ca31fc95b9bbef6cf64 [formerly ccdf4928b9527e85684fb0d4eaa67435f8da5559]. Revert "Omaha #3841 - Updated the dialogs for adding and editing a new zone/station." This reverts commit dc1722a8b7b25f74f238e7a75406e48f342468c6 [formerly 5a7e13b6a6db5ca766da3ad957c12077470359e7]. Revert "Omaha #3220 - Corrected area configuration managers for Fog, SAFESEAS and SNOW monitors." This reverts commit 8971f40dc27d9abf07ab204ba0824c1e9da788e3 [formerly 5fb653e5c7f7ffff1daf53487147597a569d7d11]. Former-commit-id: fa81485722db0bcc734095c0639f0ac8875117b5 --- .../uf/viz/monitor/fog/FogMonitor.java | 179 ++- .../fog/threshold/FogThresholdMgr.java | 22 +- .../fog/ui/actions/FogAreaConfigAction.java | 17 +- .../fog/ui/dialogs/FogMonitorMeteoTab.java | 30 +- .../dialogs/FogMonitoringAreaConfigDlg.java | 32 +- .../fog/ui/dialogs/FogZoneTableDlg.java | 55 +- .../viz/monitor/safeseas/SafeSeasMonitor.java | 143 ++- .../resources/SafeSeasResourceData.java | 8 + .../safeseas/threshold/SSThresholdMgr.java | 19 +- .../ui/actions/SafeseasAreaConfigAction.java | 24 +- .../ui/dialogs/SSMonitorMeteoTab.java | 368 +++--- .../ui/dialogs/SSMonitorSwellTab.java | 512 ++++---- .../ui/dialogs/SSMonitoringAreaConfigDlg.java | 25 +- .../safeseas/ui/dialogs/SSZoneTableDlg.java | 31 +- .../uf/viz/monitor/snow/SnowMonitor.java | 139 +- .../snow/threshold/SnowThresholdMgr.java | 21 +- .../snow/ui/actions/SnowAreaConfigAction.java | 21 +- .../snow/ui/dialogs/SnowDisplayMeteoTab.java | 135 +- .../dialogs/SnowMonitoringAreaConfigDlg.java | 25 +- .../snow/ui/dialogs/SnowZoneTableDlg.java | 30 +- .../raytheon/uf/viz/monitor/ObsMonitor.java | 178 ++- .../monitor/data/MonitorAreaThresholds.java | 152 ++- .../uf/viz/monitor/data/ObHourReports.java | 91 +- .../viz/monitor/data/ObMultiHrsReports.java | 259 ++-- .../viz/monitor/data/ObZoneHourReports.java | 1022 ++++++--------- .../uf/viz/monitor/data/TableUtil.java | 39 +- .../thresholds/AbstractThresholdMgr.java | 47 +- .../viz/monitor/thresholds/ThresholdMgr.java | 7 +- .../monitor/ui/dialogs/AddNewStationDlg.java | 5 +- .../viz/monitor/ui/dialogs/AddNewZoneDlg.java | 68 +- .../monitor/ui/dialogs/DeleteStationDlg.java | 5 +- .../monitor/ui/dialogs/EditNewZoneDlg.java | 181 ++- .../ui/dialogs/MonitoringAreaConfigDlg.java | 94 +- .../viz/monitor/ui/dialogs/ZoneTableDlg.java | 55 +- .../uf/common/monitor/MonitorAreaUtils.java | 8 +- .../FSSObsMonitorConfigurationManager.java | 141 +-- .../uf/edex/dat/utils/DatMenuUtil.java | 116 +- .../uf/edex/plugin/fog/common/FogConfig.java | 1 + .../plugin/fssobs/FSSObsDataTransform.java | 1118 ++++++++--------- .../edex/plugin/fssobs/FSSObsGenerator.java | 71 +- .../edex/plugin/fssobs/FSSObsURIFilter.java | 7 +- .../ingest/LocationTablesIngest.java | 11 +- 42 files changed, 2634 insertions(+), 2878 deletions(-) mode change 100644 => 100755 cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/threshold/FogThresholdMgr.java mode change 100644 => 100755 cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/dialogs/FogMonitoringAreaConfigDlg.java mode change 100644 => 100755 cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/dialogs/FogZoneTableDlg.java mode change 100644 => 100755 cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/threshold/SSThresholdMgr.java mode change 100644 => 100755 cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/dialogs/SSMonitoringAreaConfigDlg.java mode change 100644 => 100755 cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/dialogs/SSZoneTableDlg.java mode change 100644 => 100755 cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/threshold/SnowThresholdMgr.java mode change 100644 => 100755 cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/ui/dialogs/SnowMonitoringAreaConfigDlg.java mode change 100644 => 100755 cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/ui/dialogs/SnowZoneTableDlg.java mode change 100755 => 100644 cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/data/MonitorAreaThresholds.java mode change 100644 => 100755 cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/data/ObHourReports.java mode change 100755 => 100644 cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/data/ObZoneHourReports.java mode change 100755 => 100644 cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/thresholds/AbstractThresholdMgr.java mode change 100644 => 100755 edexOsgi/com.raytheon.uf.common.monitor/src/com/raytheon/uf/common/monitor/config/FSSObsMonitorConfigurationManager.java mode change 100644 => 100755 edexOsgi/com.raytheon.uf.edex.dat.utils/src/com/raytheon/uf/edex/dat/utils/DatMenuUtil.java mode change 100644 => 100755 edexOsgi/com.raytheon.uf.edex.plugin.fssobs/src/com/raytheon/uf/edex/plugin/fssobs/FSSObsGenerator.java mode change 100644 => 100755 edexOsgi/com.raytheon.uf.edex.plugin.fssobs/src/com/raytheon/uf/edex/plugin/fssobs/FSSObsURIFilter.java mode change 100644 => 100755 edexOsgi/com.raytheon.uf.edex.plugin.loctables/src/com/raytheon/uf/edex/plugin/loctables/ingest/LocationTablesIngest.java diff --git a/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/FogMonitor.java b/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/FogMonitor.java index 24e20d6f24..36837a48e1 100755 --- a/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/FogMonitor.java +++ b/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/FogMonitor.java @@ -29,6 +29,9 @@ import java.util.SortedMap; import java.util.TreeMap; import java.util.regex.Pattern; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; @@ -37,6 +40,7 @@ import com.raytheon.uf.common.dataplugin.fog.FogRecord.FOG_THREAT; import com.raytheon.uf.common.geospatial.SpatialException; import com.raytheon.uf.common.monitor.MonitorAreaUtils; import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager; +import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager.MonName; import com.raytheon.uf.common.monitor.data.AdjacentWfoMgr; import com.raytheon.uf.common.monitor.data.CommonConfig; import com.raytheon.uf.common.status.IUFStatusHandler; @@ -48,6 +52,7 @@ import com.raytheon.uf.viz.monitor.IMonitor; import com.raytheon.uf.viz.monitor.Monitor; import com.raytheon.uf.viz.monitor.ObsMonitor; import com.raytheon.uf.viz.monitor.data.AreaContainer; +import com.raytheon.uf.viz.monitor.data.MonitoringArea; import com.raytheon.uf.viz.monitor.data.ObMultiHrsReports; import com.raytheon.uf.viz.monitor.data.ObReport; import com.raytheon.uf.viz.monitor.data.ObsData; @@ -59,6 +64,7 @@ import com.raytheon.uf.viz.monitor.fog.threshold.FogThresholdMgr; import com.raytheon.uf.viz.monitor.fog.ui.dialogs.FogMonitoringAreaConfigDlg; import com.raytheon.uf.viz.monitor.fog.ui.dialogs.FogZoneTableDlg; import com.raytheon.uf.viz.monitor.ui.dialogs.MonitoringAreaConfigDlg; +import com.raytheon.uf.viz.monitor.util.MonitorThresholdConfiguration; import com.raytheon.viz.alerts.observers.ProductAlertObserver; import com.raytheon.viz.ui.dialogs.ICloseCallback; import com.vividsolutions.jts.geom.Geometry; @@ -82,11 +88,8 @@ 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 - * 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. + * Sep 04, 2014 3220 skorolev Updated configUpdate method and added updateMonitoringArea. + * Sep 23, 2014 3356 njensen Remove unnecessary import * * * @@ -104,12 +107,21 @@ 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> algorithmData = null; + private Date dialogTime = null; + /** list of coordinates for each zone **/ private Map zoneGeometries = null; @@ -120,7 +132,7 @@ public class FogMonitor extends ObsMonitor implements IFogResourceListener { private MonitoringAreaConfigDlg areaDialog = null; /** area config manager **/ - private static FSSObsMonitorConfigurationManager fogConfig = null; + private FSSObsMonitorConfigurationManager fogConfig = null; /** table data for the station table **/ private final TableData stationTableData = new TableData( @@ -149,10 +161,13 @@ public class FogMonitor extends ObsMonitor implements IFogResourceListener { */ private FogMonitor() { pluginPatterns.add(fogPattern); - fogConfig = FSSObsMonitorConfigurationManager.getFogObsManager(); + fogConfig = new FSSObsMonitorConfigurationManager(MonName.fog.name()); + updateMonitoringArea(); initObserver(OBS, this); obData = new ObMultiHrsReports(CommonConfig.AppName.FOG); obData.setThresholdMgr(FogThresholdMgr.getInstance()); + obData.getZoneTableData(); + readTableConfig(MonitorThresholdConfiguration.FOG_THRESHOLD_CONFIG); } /** @@ -163,10 +178,13 @@ 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(); - monitor.processProductAtStartup(fogConfig); + monitor.processProductAtStartup(MonName.fog.name()); + monitor.fireMonitorEvent(monitor); } + return monitor; } @@ -190,11 +208,12 @@ 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>(); - for (String zone : fogConfig.getAreaList()) { - obsData.addArea(zone, fogConfig.getAreaStations(zone)); + for (String zone : MonitoringArea.getPlatformMap().keySet()) { + obsData.addArea(zone, MonitoringArea.getPlatformMap().get(zone)); } } @@ -232,10 +251,38 @@ public class FogMonitor extends ObsMonitor implements IFogResourceListener { @Override public void processProductMessage(final AlertMessage filtered) { if (fogPattern.matcher(filtered.dataURI).matches()) { - processURI(filtered.dataURI, filtered, fogConfig); + processURI(filtered.dataURI, filtered); } } + /** + * Method that reads the table configuration and updates the zone monitor + * threshold map + * + * @param file + * -- the xml configuration filename + */ + public void readTableConfig(String file) { + // TODO update for Maritime + Map> zones = new HashMap>(); + // create zones and stations list + try { + for (String zone : fogConfig.getAreaList()) { + // add the unique + List stations = fogConfig.getAreaStations(zone); + zones.put(zone, stations); + } + } catch (Exception ve) { + String msg = "FOG Monitor failed to load configuration..." + + this.getClass().getName(); + ErrorDialog.openError(Display.getCurrent().getActiveShell(), + "FOG Monitor failed to load configuration", msg, + new Status(IStatus.ERROR, Activator.PLUGIN_ID, msg, ve)); + + } + MonitoringArea.setPlatformMap(zones); + } + /* * (non-Javadoc) * @@ -269,9 +316,9 @@ public class FogMonitor extends ObsMonitor implements IFogResourceListener { @Override public void configUpdate(IMonitorConfigurationEvent me) { fogConfig = (FSSObsMonitorConfigurationManager) me.getSource(); - obData.getObHourReports().updateZones(fogConfig); + updateMonitoringArea(); if (zoneDialog != null && !zoneDialog.isDisposed()) { - obData.updateTableCache(); + zoneDialog.refreshZoneTableData(obData); fireMonitorEvent(zoneDialog.getClass().getName()); } } @@ -286,6 +333,21 @@ public class FogMonitor extends ObsMonitor implements IFogResourceListener { monitor = null; } + /** + * Finds the zone based on the icao passed into it + * + * @param icao + * @return zone + */ + public String findZone(String icao) { + for (String zone : MonitoringArea.getPlatformMap().keySet()) { + if (MonitoringArea.getPlatformMap().get(zone).contains(icao)) { + return zone; + } + } + return null; + } + /** * Gets the main map * @@ -305,20 +367,14 @@ 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 zones = fogConfig.getAreaByStationId(result - .getPlatformId()); - if (!zones.isEmpty() || zones != null) { - for (String zn : zones) { - AreaContainer ac = getTableData().getArea(zn); - if (ac != null) { - ac.addReport(result.getObservationTime(), result); - } + String zone = findZone(result.getPlatformId()); + if (zone != null) { + AreaContainer ac = getTableData().getArea(zone); + if (ac != null) { + ac.addReport(result.getObservationTime(), result); + fireMonitorEvent(this); } } - fireMonitorEvent(this); } /** @@ -338,20 +394,26 @@ public class FogMonitor extends ObsMonitor implements IFogResourceListener { */ public void launchDialog(String type, Shell shell) { if (type.equals("zone")) { - zoneDialog = new FogZoneTableDlg(shell, obData); - addMonitorListener(zoneDialog); - zoneDialog.addMonitorControlListener(this); + if (zoneDialog == null) { + zoneDialog = new FogZoneTableDlg(shell, obData); + addMonitorListener(zoneDialog); + zoneDialog.addMonitorControlListener(this); + fireMonitorEvent(zoneDialog.getClass().getName()); + } zoneDialog.open(); } else if (type.equals("area")) { - areaDialog = new FogMonitoringAreaConfigDlg(shell, - "Fog Monitor Area Configuration"); - areaDialog.setCloseCallback(new ICloseCallback() { + if (areaDialog == null) { + 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(); } } @@ -383,7 +445,7 @@ public class FogMonitor extends ObsMonitor implements IFogResourceListener { algData = algorithmData.get(time); } else { // by default is nothing in the ALG column - for (String zone : fogConfig.getAreaList()) { + for (String zone : MonitoringArea.getPlatformMap().keySet()) { algData.put(zone, FOG_THREAT.GRAY); } } @@ -471,18 +533,21 @@ 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) * @@ -557,14 +622,9 @@ public class FogMonitor extends ObsMonitor implements IFogResourceListener { @Override protected void processAtStartup(ObReport report) { obData.addReport(report); - List zones = fogConfig.getAreaByStationId(report - .getPlatformId()); - if (!zones.isEmpty() || zones != null) { - for (String zn : zones) { - getTableData().getArea(zn).addReport( - report.getObservationTime(), report); - } - } + String zone = findZone(report.getPlatformId()); + getTableData().getArea(zone).addReport(report.getObservationTime(), + report); } /** @@ -577,11 +637,20 @@ public class FogMonitor extends ObsMonitor implements IFogResourceListener { } /** - * Gets Fog Area configuration dialog + * Reads Table Configuration. + * + * Method that reads the table configuration and updates the zone monitor + * threshold map * - * @return */ - public MonitoringAreaConfigDlg getAreaDialog() { - return areaDialog; + private void updateMonitoringArea() { + Map> zones = new HashMap>(); + // create zones and station list + for (String zone : fogConfig.getAreaList()) { + List stations = fogConfig.getAreaStations(zone); + zones.put(zone, stations); + } + MonitoringArea.setPlatformMap(zones); } + } diff --git a/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/threshold/FogThresholdMgr.java b/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/threshold/FogThresholdMgr.java old mode 100644 new mode 100755 index 800473a97d..85b0a5a589 --- a/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/threshold/FogThresholdMgr.java +++ b/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/threshold/FogThresholdMgr.java @@ -22,6 +22,7 @@ package com.raytheon.uf.viz.monitor.fog.threshold; import java.util.ArrayList; import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager; +import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager.MonName; import com.raytheon.uf.common.monitor.data.CommonConfig.AppName; import com.raytheon.uf.common.monitor.data.ObConst.DataUsageKey; import com.raytheon.uf.viz.monitor.thresholds.AbstractThresholdMgr; @@ -41,7 +42,6 @@ import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants.FogMonitor; * Feb 03, 2014 #2757 skorolev Fixed reInitialize() * May 20, 2014 3086 skorolev Cleaned code. * Sep 04, 2014 3220 skorolev Removed "site". - * Oct 16, 2014 3220 skorolev Corrected areaConfigMgr assignment. * * * @@ -61,7 +61,8 @@ public class FogThresholdMgr extends AbstractThresholdMgr { super("DefaultFogDisplayThresholds.xml", "DefaultFogMonitorThresholds.xml", AppName.FOG.name() .toLowerCase()); - areaConfigMgr = FSSObsMonitorConfigurationManager.getFogObsManager(); + areaConfigMgr = new FSSObsMonitorConfigurationManager( + MonName.fog.name()); init(); } @@ -74,6 +75,7 @@ public class FogThresholdMgr extends AbstractThresholdMgr { if (classInstance == null) { classInstance = new FogThresholdMgr(); } + return classInstance; } @@ -116,4 +118,20 @@ public class FogThresholdMgr extends AbstractThresholdMgr { } return threshKeys; } + + /* + * (non-Javadoc) + * + * @see com.raytheon.uf.viz.monitor.thresholds.AbstractThresholdMgr# + * getMonitorAreaConfigInstance() + */ + @Override + protected FSSObsMonitorConfigurationManager getMonitorAreaConfigInstance() { + if (areaConfigMgr == null) { + areaConfigMgr = new FSSObsMonitorConfigurationManager( + MonName.fog.name()); + } + return areaConfigMgr; + } + } diff --git a/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/actions/FogAreaConfigAction.java b/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/actions/FogAreaConfigAction.java index 468814df30..b8d0d6cfd3 100644 --- a/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/actions/FogAreaConfigAction.java +++ b/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/actions/FogAreaConfigAction.java @@ -25,8 +25,8 @@ import org.eclipse.core.commands.ExecutionException; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.PlatformUI; -import com.raytheon.uf.viz.monitor.fog.FogMonitor; import com.raytheon.uf.viz.monitor.fog.ui.dialogs.FogMonitoringAreaConfigDlg; +import com.raytheon.viz.ui.dialogs.ICloseCallback; /** * The Fog Monitor Action @@ -42,7 +42,6 @@ import com.raytheon.uf.viz.monitor.fog.ui.dialogs.FogMonitoringAreaConfigDlg; * May 08, 2014 3086 skorolev Added CloseCallback to dialog. * Sep 16, 2014 2757 skorolev Added test of dialog on dispose. * Sep 19, 2014 3220 skorolev Added check on dispose. - * Jan 08, 2015 3220 skorolev Used area type for launchDialog. * * * @@ -66,13 +65,19 @@ public class FogAreaConfigAction extends AbstractHandler { */ @Override public Object execute(ExecutionEvent arg0) throws ExecutionException { - FogMonitor fog = FogMonitor.getInstance(); - - if (fog.getAreaDialog() == null || fog.getAreaDialog().isDisposed()) { + if (areaDialog == null || areaDialog.isDisposed()) { Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow() .getShell(); - fog.launchDialog("area", shell); + areaDialog = new FogMonitoringAreaConfigDlg(shell, + "Fog Monitor Area Configuration"); + areaDialog.setCloseCallback(new ICloseCallback() { + @Override + public void dialogClosed(Object returnValue) { + areaDialog = null; + } + }); } + areaDialog.open(); return null; } } diff --git a/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/dialogs/FogMonitorMeteoTab.java b/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/dialogs/FogMonitorMeteoTab.java index b5accc64db..2ffc13567b 100644 --- a/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/dialogs/FogMonitorMeteoTab.java +++ b/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/dialogs/FogMonitorMeteoTab.java @@ -48,7 +48,6 @@ import com.raytheon.uf.viz.monitor.xml.ThresholdsXML; * Date Ticket# Engineer Description * ------------ ---------- ----------- ------------- * May 21, 2014 3086 skorolev Cleaned code. - * Oct 16, 2014 3220 skorolev Added condition to avoid NPE. * * * @@ -179,23 +178,22 @@ public class FogMonitorMeteoTab extends TabItemComp implements ThresholdsXML threshXML = ftm.getThresholdsXmlData(duKey); List areasArray = threshXML.getAreas(); - if (areasArray != null) { - for (AreaXML area : areasArray) { - String areaID = area.getAreaId(); - FogMonitorMeteoData fmmd = new FogMonitorMeteoData(); - fmmd.setAreaID(areaID); - /* - * Visibility - */ - String xmlKey = FogMonitor.FOG_MONITOR_METEO_VIS.getXmlKey(); - fmmd.setMeteoVisR(ftm.getThresholdValue(duKey, threshKeyR, - areaID, xmlKey)); - fmmd.setMeteoVisY(ftm.getThresholdValue(duKey, threshKeyY, - areaID, xmlKey)); + for (AreaXML area : areasArray) { + String areaID = area.getAreaId(); + FogMonitorMeteoData fmmd = new FogMonitorMeteoData(); + fmmd.setAreaID(areaID); - fogDataArray.add(fmmd); - } + /* + * Visibility + */ + String xmlKey = FogMonitor.FOG_MONITOR_METEO_VIS.getXmlKey(); + fmmd.setMeteoVisR(ftm.getThresholdValue(duKey, threshKeyR, areaID, + xmlKey)); + fmmd.setMeteoVisY(ftm.getThresholdValue(duKey, threshKeyY, areaID, + xmlKey)); + + fogDataArray.add(fmmd); } } diff --git a/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/dialogs/FogMonitoringAreaConfigDlg.java b/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/dialogs/FogMonitoringAreaConfigDlg.java old mode 100644 new mode 100755 index e4272b16cf..d569091c20 --- a/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/dialogs/FogMonitoringAreaConfigDlg.java +++ b/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/dialogs/FogMonitoringAreaConfigDlg.java @@ -24,6 +24,7 @@ import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager; +import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager.MonName; import com.raytheon.uf.common.monitor.data.CommonConfig; import com.raytheon.uf.common.monitor.data.CommonConfig.AppName; import com.raytheon.uf.common.monitor.data.ObConst.DataUsageKey; @@ -48,11 +49,7 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback; * Apr 28, 2014 3086 skorolev Updated getConfigManager. * Sep 04, 2014 3220 skorolev Added fireConfigUpdateEvent method. Updated handler. * Sep 19, 2014 2757 skorolev Updated handlers for dialog buttons. - * Oct 16, 2014 3220 skorolev Corrected getInstance() method. * Oct 27, 2014 3667 skorolev Cleaned code. - * Nov 21, 2014 3841 skorolev Corrected handleOkBtnSelection. - * Dec 11, 2014 3220 skorolev Removed unnecessary code. - * Feb 03, 2015 3841 skorolev Replaced resetParams with resetStatus. * * * @@ -72,6 +69,7 @@ public class FogMonitoringAreaConfigDlg extends MonitoringAreaConfigDlg { */ public FogMonitoringAreaConfigDlg(Shell parent, String title) { super(parent, title, AppName.FOG); + FogMonitor.getInstance(); } /* @@ -87,8 +85,13 @@ public class FogMonitoringAreaConfigDlg extends MonitoringAreaConfigDlg { "Fog Monitor Confirm Changes", "Save changes?"); if (choice == SWT.YES) { // Save the config xml file. - saveConfigs(); + resetAndSave(); + /** + * DR#11279: re-initialize threshold manager and the monitor + * using new monitor area configuration + */ FogThresholdMgr.reInitialize(); + fireConfigUpdateEvent(); // Open Threshold Dialog if zones/stations are added. if ((!configMgr.getAddedZones().isEmpty()) || (!configMgr.getAddedStations().isEmpty())) { @@ -98,19 +101,19 @@ public class FogMonitoringAreaConfigDlg extends MonitoringAreaConfigDlg { fogMonitorDlg.setCloseCallback(new ICloseCallback() { @Override public void dialogClosed(Object returnValue) { + // Clean added zones and stations. Close dialog. + configMgr.getAddedZones().clear(); + configMgr.getAddedStations().clear(); setReturnValue(true); close(); } }); fogMonitorDlg.open(); } + // Clean added zones and stations. + configMgr.getAddedZones().clear(); + configMgr.getAddedStations().clear(); } - /** - * DR#11279: re-initialize threshold manager and the monitor - * using new monitor area configuration - */ - fireConfigUpdateEvent(); - resetStatus(); } else { // Return back to continue edit. return; } @@ -127,6 +130,7 @@ public class FogMonitoringAreaConfigDlg extends MonitoringAreaConfigDlg { private void fireConfigUpdateEvent() { final IMonitorConfigurationEvent me = new IMonitorConfigurationEvent( configMgr); + shell.setCursor(getDisplay().getSystemCursor(SWT.CURSOR_WAIT)); Display.getDefault().asyncExec(new Runnable() { @Override public void run() { @@ -144,7 +148,11 @@ public class FogMonitoringAreaConfigDlg extends MonitoringAreaConfigDlg { */ @Override protected FSSObsMonitorConfigurationManager getInstance() { - return FSSObsMonitorConfigurationManager.getFogObsManager(); + if (configMgr == null) { + configMgr = new FSSObsMonitorConfigurationManager( + MonName.fog.name()); + } + return configMgr; } /* diff --git a/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/dialogs/FogZoneTableDlg.java b/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/dialogs/FogZoneTableDlg.java old mode 100644 new mode 100755 index 8b48a1f7c9..948606d33e --- a/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/dialogs/FogZoneTableDlg.java +++ b/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/dialogs/FogZoneTableDlg.java @@ -28,6 +28,7 @@ import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager; +import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager.MonName; import com.raytheon.uf.common.monitor.data.CommonConfig; import com.raytheon.uf.common.monitor.data.ObConst.DataUsageKey; import com.raytheon.uf.common.monitor.data.ObConst.DisplayVarName; @@ -58,9 +59,8 @@ 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. - * Jan 27, 2015 3220 skorolev Removed "site".Added check on dispose.Corrected configMgr assignment. - * Added table cache update. - * Feb 04, 2015 3841 skorolev Corrected notify method for empty table update. + * Sep 04, 2014 3220 skorolev Removed "site". Added check on dispose. + * * * * @author ? @@ -79,10 +79,6 @@ 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(); } /** @@ -149,11 +145,12 @@ public class FogZoneTableDlg extends ZoneTableDlg { // The algorithm output. if (me.getSource() instanceof FogMonitor) { + FogMonitor fog = (FogMonitor) me.getSource(); - ObMultiHrsReports obData = fog.getObData(); - Date date = fog.getDialogTime(); + Date date = fog.getDialogDate(); if (date != null) { Date nominalTime = date; + ObMultiHrsReports obData = fog.getObData(); if (!isLinkedToFrame()) { nominalTime = obData.getLatestNominalTime(); } @@ -162,12 +159,33 @@ public class FogZoneTableDlg extends ZoneTableDlg { .getAlgorithmData(nominalTime)); obData.setFogAlgCellType(fogAlgCellType); this.updateTableDlg(obData.getObHourReports(nominalTime)); - } else { - this.updateZoneTable(obData.getLatestNominalTime()); } } } + /** + * 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) * @@ -276,4 +294,19 @@ public class FogZoneTableDlg extends ZoneTableDlg { protected void shellDisposeAction() { // Not used } + + /* + * (non-Javadoc) + * + * @see com.raytheon.uf.viz.monitor.ui.dialogs.ZoneTableDlg# + * getMonitorAreaConfigInstance() + */ + @Override + protected FSSObsMonitorConfigurationManager getMonitorAreaConfigInstance() { + if (configMgr == null || configMgr.isPopulated()) { + configMgr = new FSSObsMonitorConfigurationManager( + MonName.fog.name()); + } + return configMgr; + } } diff --git a/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/SafeSeasMonitor.java b/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/SafeSeasMonitor.java index dd3ae1a996..746bb8a5b5 100755 --- a/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/SafeSeasMonitor.java +++ b/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/SafeSeasMonitor.java @@ -37,6 +37,7 @@ import com.raytheon.uf.common.dataplugin.fog.FogRecord.FOG_THREAT; import com.raytheon.uf.common.geospatial.SpatialException; import com.raytheon.uf.common.monitor.MonitorAreaUtils; import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager; +import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager.MonName; import com.raytheon.uf.common.monitor.data.AdjacentWfoMgr; import com.raytheon.uf.common.monitor.data.CommonConfig; import com.raytheon.uf.common.status.IUFStatusHandler; @@ -48,6 +49,7 @@ import com.raytheon.uf.viz.monitor.IMonitor; import com.raytheon.uf.viz.monitor.Monitor; import com.raytheon.uf.viz.monitor.ObsMonitor; import com.raytheon.uf.viz.monitor.config.CommonTableConfig.CellType; +import com.raytheon.uf.viz.monitor.data.MonitoringArea; import com.raytheon.uf.viz.monitor.data.ObMultiHrsReports; import com.raytheon.uf.viz.monitor.data.ObReport; import com.raytheon.uf.viz.monitor.data.TableCellData; @@ -59,6 +61,8 @@ import com.raytheon.uf.viz.monitor.safeseas.listeners.ISSResourceListener; import com.raytheon.uf.viz.monitor.safeseas.threshold.SSThresholdMgr; import com.raytheon.uf.viz.monitor.safeseas.ui.dialogs.SSMonitoringAreaConfigDlg; import com.raytheon.uf.viz.monitor.safeseas.ui.dialogs.SSZoneTableDlg; +import com.raytheon.uf.viz.monitor.ui.dialogs.ZoneTableDlg; +import com.raytheon.uf.viz.monitor.util.MonitorThresholdConfiguration; import com.raytheon.viz.alerts.observers.ProductAlertObserver; import com.raytheon.viz.ui.dialogs.ICloseCallback; import com.vividsolutions.jts.geom.Geometry; @@ -81,9 +85,8 @@ 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 - * 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. + * Apr 28, 2014 3086 skorolev Removed local getMonitorAreaConfig method. + * Sep 04, 2014 3220 skorolev Updated configUpdate method and added updateMonitoringArea. * * * @@ -107,7 +110,13 @@ public class SafeSeasMonitor extends ObsMonitor implements ISSResourceListener { private SSMonitoringAreaConfigDlg areaDialog = null; /** configuration manager **/ - private static FSSObsMonitorConfigurationManager ssAreaConfig = null; + private FSSObsMonitorConfigurationManager ssAreaConfig = null; + + /** + * This object contains all observation data necessary for the table dialogs + * and trending plots + */ + private ObMultiHrsReports obData; /** table data for the zone table **/ private final TableData zoneTableData = new TableData( @@ -126,6 +135,9 @@ public class SafeSeasMonitor extends ObsMonitor implements ISSResourceListener { /** List of SAFESEAS resource listeners **/ private final List safeSeasResources = new ArrayList(); + /** Time which Zone/County dialog shows. **/ + private Date dialogTime = null; + /** list of coordinates for each zone **/ private Map zoneGeometries = null; @@ -149,10 +161,14 @@ public class SafeSeasMonitor extends ObsMonitor implements ISSResourceListener { */ private SafeSeasMonitor() { pluginPatterns.add(ssPattern); - ssAreaConfig = FSSObsMonitorConfigurationManager.getSsObsManager(); + ssAreaConfig = new FSSObsMonitorConfigurationManager(MonName.ss.name()); + updateMonitoringArea(); initObserver(OBS, this); obData = new ObMultiHrsReports(CommonConfig.AppName.SAFESEAS); obData.setThresholdMgr(SSThresholdMgr.getInstance()); + obData.getZoneTableData(); + readTableConfig(MonitorThresholdConfiguration.SAFESEAS_THRESHOLD_CONFIG); + } /** @@ -161,9 +177,11 @@ 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(); - monitor.processProductAtStartup(ssAreaConfig); + monitor.processProductAtStartup("ss"); + monitor.fireMonitorEvent(monitor); } return monitor; } @@ -198,21 +216,26 @@ public class SafeSeasMonitor extends ObsMonitor implements ISSResourceListener { */ public void launchDialog(String type, Shell shell) { if (type.equals("zone")) { - zoneDialog = new SSZoneTableDlg(shell, obData); - addMonitorListener(zoneDialog); - zoneDialog.addMonitorControlListener(this); + if (zoneDialog == null) { + zoneDialog = new SSZoneTableDlg(shell, obData); + addMonitorListener(zoneDialog); + zoneDialog.addMonitorControlListener(this); + fireMonitorEvent(zoneDialog.getClass().getName()); + } zoneDialog.open(); } else if (type.equals("area")) { - areaDialog = new SSMonitoringAreaConfigDlg(shell, - "SAFESEAS Monitor Area Configuration"); - areaDialog.setCloseCallback(new ICloseCallback() { + if (areaDialog == null) { + areaDialog = new SSMonitoringAreaConfigDlg(shell, + "Safe Seas 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(); } } @@ -251,7 +274,7 @@ public class SafeSeasMonitor extends ObsMonitor implements ISSResourceListener { @Override public void processProductMessage(final AlertMessage filtered) { if (ssPattern.matcher(filtered.dataURI).matches()) { - processURI(filtered.dataURI, filtered, ssAreaConfig); + processURI(filtered.dataURI, filtered); } } @@ -274,6 +297,31 @@ public class SafeSeasMonitor extends ObsMonitor implements ISSResourceListener { stationTableData.addReplaceDataRow(stationRowData); } + /** + * Reads Table Configuration. + * + * Method that reads the table configuration and updates the zone monitor + * threshold map + * + * @param file + * -- the xml configuration filename + */ + public void readTableConfig(String file) { + Map> zones = new HashMap>(); + // create zones and station list + try { + for (String zone : ssAreaConfig.getAreaList()) { + List stations = ssAreaConfig.getAreaStations(zone); + zones.put(zone, stations); + } + } catch (Exception e) { + statusHandler.handle(Priority.CRITICAL, + "SafeSeas failed to load configuration..." + + this.getClass().getName(), e); + } + MonitoringArea.setPlatformMap(zones); + } + /* * (non-Javadoc) * @@ -307,9 +355,9 @@ public class SafeSeasMonitor extends ObsMonitor implements ISSResourceListener { @Override public void configUpdate(IMonitorConfigurationEvent me) { ssAreaConfig = (FSSObsMonitorConfigurationManager) me.getSource(); - obData.getObHourReports().updateZones(ssAreaConfig); + updateMonitoringArea(); if (zoneDialog != null && !zoneDialog.isDisposed()) { - obData.updateTableCache(); + zoneDialog.refreshZoneTableData(obData); fireMonitorEvent(zoneDialog.getClass().getName()); } } @@ -365,8 +413,6 @@ 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); } @@ -375,18 +421,30 @@ 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 * @@ -432,6 +490,7 @@ public class SafeSeasMonitor extends ObsMonitor implements ISSResourceListener { */ @Override public ArrayList getTimeOrderedKeys(IMonitor monitor, String type) { + // Not used return null; } @@ -485,7 +544,7 @@ public class SafeSeasMonitor extends ObsMonitor implements ISSResourceListener { algData = algorithmData.get(time); } else { // by default is nothing in the Fog column - for (String zone : ssAreaConfig.getAreaList()) { + for (String zone : MonitoringArea.getPlatformMap().keySet()) { algData.put(zone, FOG_THREAT.GRAY); } } @@ -526,6 +585,15 @@ public class SafeSeasMonitor extends ObsMonitor implements ISSResourceListener { return type; } + /** + * Gets zone dialog + * + * @return zoneDialog + */ + public ZoneTableDlg getDialog() { + return zoneDialog; + } + /** * Gets adjacent areas */ @@ -602,11 +670,20 @@ public class SafeSeasMonitor extends ObsMonitor implements ISSResourceListener { } /** - * Gets SAFESEAS Area configuration dialog + * Reads Table Configuration. + * + * Method that reads the table configuration and updates the zone monitor + * threshold map * - * @return */ - public SSMonitoringAreaConfigDlg getAreaDialog() { - return areaDialog; + public void updateMonitoringArea() { + Map> zones = new HashMap>(); + // create zones and station list + for (String zone : ssAreaConfig.getAreaList()) { + List stations = ssAreaConfig.getAreaStations(zone); + zones.put(zone, stations); + } + MonitoringArea.setPlatformMap(zones); } + } diff --git a/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/resources/SafeSeasResourceData.java b/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/resources/SafeSeasResourceData.java index 3ff3df9e7e..9ba761fddd 100644 --- a/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/resources/SafeSeasResourceData.java +++ b/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/resources/SafeSeasResourceData.java @@ -200,6 +200,14 @@ public class SafeSeasResourceData extends AbstractRequestableResourceData { return fogThreatSS; } + /** Get the SafeSeasMonitor monitor **/ + protected SafeSeasMonitor getFogMonitor() { + if (monitor == null) { + monitor = SafeSeasMonitor.getInstance(); + } + return monitor; + } + /** * @return plotSource */ diff --git a/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/threshold/SSThresholdMgr.java b/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/threshold/SSThresholdMgr.java old mode 100644 new mode 100755 index ddfd563744..b863c5d05a --- a/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/threshold/SSThresholdMgr.java +++ b/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/threshold/SSThresholdMgr.java @@ -22,6 +22,7 @@ package com.raytheon.uf.viz.monitor.safeseas.threshold; import java.util.ArrayList; import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager; +import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager.MonName; import com.raytheon.uf.common.monitor.data.CommonConfig.AppName; import com.raytheon.uf.common.monitor.data.ObConst.DataUsageKey; import com.raytheon.uf.viz.monitor.thresholds.AbstractThresholdMgr; @@ -41,7 +42,6 @@ import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants.SafeSeasMonitor; * Feb 03, 2014 #2757 skorolev Fixed reInitialize(). * Apr 28, 2014 3086 skorolev Removed local getMonitorAreaConfig method. * Sep 04, 2014 3220 skorolev Removed "site". - * Oct 16, 2014 3220 skorolev Corrected areaConfigMgr assignment. * * * @@ -59,7 +59,7 @@ public class SSThresholdMgr extends AbstractThresholdMgr { super("DefaultSSDisplayThresholds.xml", "DefaultSSMonitorThresholds.xml", AppName.SAFESEAS.name() .toLowerCase()); - areaConfigMgr = FSSObsMonitorConfigurationManager.getSsObsManager(); + areaConfigMgr = new FSSObsMonitorConfigurationManager(MonName.ss.name()); init(); } @@ -113,4 +113,19 @@ public class SSThresholdMgr extends AbstractThresholdMgr { } return threshKeys; } + + /* + * (non-Javadoc) + * + * @see com.raytheon.uf.viz.monitor.thresholds.AbstractThresholdMgr# + * getMonitorAreaConfigInstance() + */ + @Override + protected FSSObsMonitorConfigurationManager getMonitorAreaConfigInstance() { + if (areaConfigMgr == null) { + areaConfigMgr = new FSSObsMonitorConfigurationManager( + MonName.ss.name()); + } + return areaConfigMgr; + } } diff --git a/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/actions/SafeseasAreaConfigAction.java b/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/actions/SafeseasAreaConfigAction.java index 987d3cb2c6..72cc4046fb 100644 --- a/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/actions/SafeseasAreaConfigAction.java +++ b/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/actions/SafeseasAreaConfigAction.java @@ -25,7 +25,8 @@ import org.eclipse.core.commands.ExecutionException; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.PlatformUI; -import com.raytheon.uf.viz.monitor.safeseas.SafeSeasMonitor; +import com.raytheon.uf.viz.monitor.safeseas.ui.dialogs.SSMonitoringAreaConfigDlg; +import com.raytheon.viz.ui.dialogs.ICloseCallback; /** * The SAFESEAS Action @@ -41,7 +42,6 @@ import com.raytheon.uf.viz.monitor.safeseas.SafeSeasMonitor; * May 08, 2014 3086 skorolev Added CloseCallback to dialog. * Sep 16, 2014 2757 skorolev Added test of dialog on dispose. * Sep 19, 2014 3220 skorolev Added check on dispose. - * Jan 08, 2015 3220 skorolev Used area type for launchDialog. * * * @@ -51,6 +51,11 @@ import com.raytheon.uf.viz.monitor.safeseas.SafeSeasMonitor; public class SafeseasAreaConfigAction extends AbstractHandler { + /** + * SAFESEAS Monitoring Area Configuration Dialog. + */ + private SSMonitoringAreaConfigDlg configDlg; + /* * (non-Javadoc) * @@ -60,14 +65,19 @@ public class SafeseasAreaConfigAction extends AbstractHandler { */ @Override public Object execute(ExecutionEvent arg0) throws ExecutionException { - - SafeSeasMonitor monitor = SafeSeasMonitor.getInstance(); - if (monitor.getAreaDialog() == null - || monitor.getAreaDialog().isDisposed()) { + if (configDlg == null || configDlg.isDisposed()) { Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow() .getShell(); - monitor.launchDialog("area", shell); + configDlg = new SSMonitoringAreaConfigDlg(shell, + "SAFESEAS Monitor Area Configuration"); + configDlg.setCloseCallback(new ICloseCallback() { + @Override + public void dialogClosed(Object returnValue) { + configDlg = null; + } + }); } + configDlg.open(); return null; } } diff --git a/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/dialogs/SSMonitorMeteoTab.java b/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/dialogs/SSMonitorMeteoTab.java index d515866749..d8ceb7207c 100644 --- a/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/dialogs/SSMonitorMeteoTab.java +++ b/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/dialogs/SSMonitorMeteoTab.java @@ -41,309 +41,305 @@ import com.raytheon.uf.viz.monitor.xml.ThresholdsXML; * SAFESEAS Monitor Meteo Table. * *
- * 
+ *
  * SOFTWARE HISTORY
- * 
+ *
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Sep 17, 2014 2757       skorolev    Removed unnecessary printouts.
- * Oct 16, 2014 3220       skorolev    Added condition to avoid NPE.
- * 
+ *
  * 
- * + * * @author skorolev - * @version 1.0 + * @version 1.0 */ -public class SSMonitorMeteoTab extends TabItemComp implements - IUpdateMonitorMeteo { +public class SSMonitorMeteoTab extends TabItemComp implements IUpdateMonitorMeteo +{ private SSMonitorMeteoEditDlg monitorMeteoEditDlg; - + private ArrayList areaIDArray; - + private ArrayList ssDataArray; - - public SSMonitorMeteoTab(TabFolder parent, DataUsageKey duKey) { + + public SSMonitorMeteoTab(TabFolder parent, DataUsageKey duKey) + { super(parent, duKey); } - @Override - protected void createListHeader(Composite parentComp) { + @Override + protected void createListHeader(Composite parentComp) + { Composite lblComp = new Composite(parentComp, SWT.NONE); GridLayout gl = new GridLayout(5, false); - gl.horizontalSpacing = 0; + gl.horizontalSpacing = 0; gl.marginHeight = 0; gl.marginWidth = 0; lblComp.setLayout(gl); - + /* * Create filler label. */ GridData gd = new GridData(75, SWT.DEFAULT); Label fillerLbl = new Label(lblComp, SWT.CENTER); fillerLbl.setLayoutData(gd); - + /* * Meteo */ - Composite meteoComp = createGroupComposite(lblComp, 5, null); - createLabelComp(meteoComp, "Wind", "Speed(kt)", false); - createLabelComp(meteoComp, "Peak", "Wind(kt)", false); + Composite meteoComp = createGroupComposite(lblComp, 5, null); + createLabelComp(meteoComp, "Wind", "Speed(kt)", false); + createLabelComp(meteoComp, "Peak", "Wind(kt)", false); createLabelComp(meteoComp, "Gust", "Speed(kt)", false); createLabelComp(meteoComp, "Wave", "Height(ft)", false); createLabelComp(meteoComp, "Vis(mi)", "", true); - } - + } + @Override - protected void populateList() { - if (ssDataArray == null) { + protected void populateList() + { + if (ssDataArray == null) + { createDataArray(); } - + boolean update = false; - if (dataList.getItemCount() > 0) { + if (dataList.getItemCount() > 0) + { update = true; } - + RangesUtil rangeUtil = RangesUtil.getInstance(); - + areaIDArray = new ArrayList(); - + String tmpVisStr; String currentAreaID; - + double visVal = 0.0; - - StringBuilder sb = null; + + StringBuilder sb = null; SSMonitorMeteoData ssmmd = null; - - for (int i = 0; i < ssDataArray.size(); i++) { + + for (int i = 0; i < ssDataArray.size(); i++) + { sb = new StringBuilder(); - + ssmmd = ssDataArray.get(i); - + currentAreaID = ssmmd.getAreaID(); areaIDArray.add(currentAreaID); - + sb.append(String.format(areaIdFmt, currentAreaID)); - + /* * Wind Speed */ appendIntData(sb, ssmmd.getWindSpeedR(), ssmmd.getWindSpeedY()); - + /* * Peak Wind */ appendIntData(sb, ssmmd.getPeakWindR(), ssmmd.getPeakWindY()); - + /* * Gust Wind */ appendIntData(sb, ssmmd.getGustSpeedR(), ssmmd.getGustSpeedY()); - + /* * Wave Height */ appendIntData(sb, ssmmd.getWaveHgtR(), ssmmd.getWaveHgtY()); - + /* * Visibility - */ - visVal = ssmmd.getVisR(); - tmpVisStr = rangeUtil.getVisString((int) visVal); + */ + visVal = ssmmd.getVisR(); + tmpVisStr = rangeUtil.getVisString((int)visVal); sb.append(String.format(dataFmt, tmpVisStr)); - - visVal = ssmmd.getVisY(); - tmpVisStr = rangeUtil.getVisString((int) visVal); - sb.append(String.format(dataFmt, tmpVisStr)); - + + visVal = ssmmd.getVisY(); + tmpVisStr = rangeUtil.getVisString((int)visVal); + sb.append(String.format(dataFmt, tmpVisStr)); + /* * Append a space and add the data line to the list. */ sb.append(" "); - - if (update == true) { + + if (update == true) + { dataList.setItem(i, sb.toString()); - } else { - dataList.add(sb.toString()); } + else + { + dataList.add(sb.toString()); + } } - + packListControls(); } - - private void createDataArray() { + + private void createDataArray() + { ssDataArray = new ArrayList(); - - SSThresholdMgr sstm = SSThresholdMgr.getInstance(); - + + SSThresholdMgr sstm = SSThresholdMgr.getInstance(); + String xmlKey; - String areaID; - + String areaID; + ThresholdsXML threshXML = sstm.getThresholdsXmlData(duKey); - + ArrayList areasArray = threshXML.getAreas(); - - if (areasArray != null) { - for (AreaXML area : areasArray) { - areaID = area.getAreaId(); - SSMonitorMeteoData ssmmd = new SSMonitorMeteoData(); - - ssmmd.setAreaID(areaID); - - /* - * Wind Speed - */ - xmlKey = SafeSeasMonitor.SS_MON_METEO_WIND_SPEED.getXmlKey(); - ssmmd.setWindSpeedR(sstm.getThresholdValue(duKey, threshKeyR, - areaID, xmlKey)); - ssmmd.setWindSpeedY(sstm.getThresholdValue(duKey, threshKeyY, - areaID, xmlKey)); - - /* - * Peak Wind - */ - xmlKey = SafeSeasMonitor.SS_MON_METEO_PEAK_WIND.getXmlKey(); - ssmmd.setPeakWindR(sstm.getThresholdValue(duKey, threshKeyR, - areaID, xmlKey)); - ssmmd.setPeakWindY(sstm.getThresholdValue(duKey, threshKeyY, - areaID, xmlKey)); - - /* - * Gust Speed - */ - xmlKey = SafeSeasMonitor.SS_MON_METEO_GUST_SPEED.getXmlKey(); - ssmmd.setGustSpeedR(sstm.getThresholdValue(duKey, threshKeyR, - areaID, xmlKey)); - ssmmd.setGustSpeedY(sstm.getThresholdValue(duKey, threshKeyY, - areaID, xmlKey)); - - /* - * Wave Height - */ - xmlKey = SafeSeasMonitor.SS_MON_METEO_WAVE_HT.getXmlKey(); - ssmmd.setWaveHgtR(sstm.getThresholdValue(duKey, threshKeyR, - areaID, xmlKey)); - ssmmd.setWaveHgtY(sstm.getThresholdValue(duKey, threshKeyY, - areaID, xmlKey)); - - /* - * Visibility - */ - xmlKey = SafeSeasMonitor.SS_MON_METEO_VIS.getXmlKey(); - ssmmd.setVisR(sstm.getThresholdValue(duKey, threshKeyR, areaID, - xmlKey)); - ssmmd.setVisY(sstm.getThresholdValue(duKey, threshKeyY, areaID, - xmlKey)); - - /* - * Add data to array. - */ - ssDataArray.add(ssmmd); - } - } else { - - } - } - - private SSMonitorMeteoData getDataAtFirstSelection() { - int index = dataList.getSelectionIndex(); - - return ssDataArray.get(index); - } - - private void updateDataArray(SSMonitorMeteoData ssmmd) { - int[] dataListIndexes = dataList.getSelectionIndices(); - int currentIndex = 0; - - for (int i = 0; i < dataListIndexes.length; i++) { - currentIndex = dataListIndexes[i]; - - ssDataArray.get(currentIndex).updateData(ssmmd); - } - } - - @Override - public void commitDataToXML() { - SSThresholdMgr sstm = SSThresholdMgr.getInstance(); - - String xmlKey; - String areaID; - - for (SSMonitorMeteoData ssmmd : ssDataArray) { - areaID = ssmmd.getAreaID(); - + + for (AreaXML area : areasArray) + { + areaID = area.getAreaId(); + SSMonitorMeteoData ssmmd = new SSMonitorMeteoData(); + + ssmmd.setAreaID(areaID); + /* * Wind Speed */ xmlKey = SafeSeasMonitor.SS_MON_METEO_WIND_SPEED.getXmlKey(); - sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, - ssmmd.getWindSpeedR()); - sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, - ssmmd.getWindSpeedY()); - + ssmmd.setWindSpeedR(sstm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); + ssmmd.setWindSpeedY(sstm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); + /* * Peak Wind */ xmlKey = SafeSeasMonitor.SS_MON_METEO_PEAK_WIND.getXmlKey(); - sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, - ssmmd.getPeakWindR()); - sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, - ssmmd.getPeakWindY()); - + ssmmd.setPeakWindR(sstm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); + ssmmd.setPeakWindY(sstm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); + /* * Gust Speed */ xmlKey = SafeSeasMonitor.SS_MON_METEO_GUST_SPEED.getXmlKey(); - sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, - ssmmd.getGustSpeedR()); - sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, - ssmmd.getGustSpeedY()); - + ssmmd.setGustSpeedR(sstm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); + ssmmd.setGustSpeedY(sstm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); + /* * Wave Height */ xmlKey = SafeSeasMonitor.SS_MON_METEO_WAVE_HT.getXmlKey(); - sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, - ssmmd.getWaveHgtR()); - sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, - ssmmd.getWaveHgtY()); + ssmmd.setWaveHgtR(sstm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); + ssmmd.setWaveHgtY(sstm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); /* * Visibility */ xmlKey = SafeSeasMonitor.SS_MON_METEO_VIS.getXmlKey(); - sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, - ssmmd.getVisR()); - sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, - ssmmd.getVisY()); + ssmmd.setVisR(sstm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); + ssmmd.setVisY(sstm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); + + /* + * Add data to array. + */ + ssDataArray.add(ssmmd); } } + + private SSMonitorMeteoData getDataAtFirstSelection() + { + int index = dataList.getSelectionIndex(); + + return ssDataArray.get(index); + } + + private void updateDataArray(SSMonitorMeteoData ssmmd) + { + int[] dataListIndexes = dataList.getSelectionIndices(); + int currentIndex = 0; + + for (int i = 0; i < dataListIndexes.length; i++) + { + currentIndex = dataListIndexes[i]; + + ssDataArray.get(currentIndex).updateData(ssmmd); + } + } + + @Override + public void commitDataToXML() + { + SSThresholdMgr sstm = SSThresholdMgr.getInstance(); + + String xmlKey; + String areaID; + + for (SSMonitorMeteoData ssmmd : ssDataArray) + { + areaID = ssmmd.getAreaID(); + + /* + * Wind Speed + */ + xmlKey = SafeSeasMonitor.SS_MON_METEO_WIND_SPEED.getXmlKey(); + sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, ssmmd.getWindSpeedR()); + sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, ssmmd.getWindSpeedY()); + + /* + * Peak Wind + */ + xmlKey = SafeSeasMonitor.SS_MON_METEO_PEAK_WIND.getXmlKey(); + sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, ssmmd.getPeakWindR()); + sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, ssmmd.getPeakWindY()); + + /* + * Gust Speed + */ + xmlKey = SafeSeasMonitor.SS_MON_METEO_GUST_SPEED.getXmlKey(); + sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, ssmmd.getGustSpeedR()); + sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, ssmmd.getGustSpeedY()); + + /* + * Wave Height + */ + xmlKey = SafeSeasMonitor.SS_MON_METEO_WAVE_HT.getXmlKey(); + sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, ssmmd.getWaveHgtR()); + sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, ssmmd.getWaveHgtY()); + + /* + * Visibility + */ + xmlKey = SafeSeasMonitor.SS_MON_METEO_VIS.getXmlKey(); + sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, ssmmd.getVisR()); + sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, ssmmd.getVisY()); + } + } @Override - public void reloadData() { + public void reloadData() + { dataList.removeAll(); ssDataArray.clear(); ssDataArray = null; - - populateList(); + + populateList(); } @Override - protected void editDataAction() { + protected void editDataAction() + { SSMonitorMeteoData ssmmd = getDataAtFirstSelection(); - - if (monitorMeteoEditDlg == null) { - monitorMeteoEditDlg = new SSMonitorMeteoEditDlg(getParent() - .getShell(), ssmmd, this); + + if (monitorMeteoEditDlg == null) + { + monitorMeteoEditDlg = new SSMonitorMeteoEditDlg(getParent().getShell(), ssmmd, this); monitorMeteoEditDlg.open(); monitorMeteoEditDlg = null; } } + + @Override - public void updateThresholdData(SSMonitorMeteoData ssmmd) { + public void updateThresholdData(SSMonitorMeteoData ssmmd) + { updateDataArray(ssmmd); - populateList(); + populateList(); } } diff --git a/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/dialogs/SSMonitorSwellTab.java b/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/dialogs/SSMonitorSwellTab.java index 622bacbcf8..a28cc5db93 100644 --- a/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/dialogs/SSMonitorSwellTab.java +++ b/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/dialogs/SSMonitorSwellTab.java @@ -36,404 +36,312 @@ import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants.SafeSeasMonitor; import com.raytheon.uf.viz.monitor.xml.AreaXML; import com.raytheon.uf.viz.monitor.xml.ThresholdsXML; -/** - * SAFESEAS Monitor Swell Table. - * - *
- * 
- * SOFTWARE HISTORY
- * 
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Oct 16, 2014 3220       skorolev    Added condition to avoid NPE.
- * 
- * 
- * - * @author - * @version 1.0 - */ -public class SSMonitorSwellTab extends TabItemComp implements - IUpdateDisplayMonitorSwell { +public class SSMonitorSwellTab extends TabItemComp implements IUpdateDisplayMonitorSwell +{ private SSDispMonSwellEditDlg monitorSwellEditDlg; - + private ArrayList areaIDArray; - + private ArrayList ssDataArray; - - public SSMonitorSwellTab(TabFolder parent, DataUsageKey duKey) { + + public SSMonitorSwellTab(TabFolder parent, DataUsageKey duKey) + { super(parent, duKey, true); } - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.viz.monitor.ui.dialogs.TabItemComp#createListHeader(org - * .eclipse.swt.widgets.Composite) - */ - @Override - protected void createListHeader(Composite parentComp) { + @Override + protected void createListHeader(Composite parentComp) + { Composite lblComp = new Composite(parentComp, SWT.NONE); GridLayout gl = new GridLayout(5, false); - gl.horizontalSpacing = 0; + gl.horizontalSpacing = 0; gl.marginHeight = 0; gl.marginWidth = 0; lblComp.setLayout(gl); - + /* * Create filler label. */ GridData gd = new GridData(75, SWT.DEFAULT); Label fillerLbl = new Label(lblComp, SWT.CENTER); fillerLbl.setLayoutData(gd); - + /* * Primary Swell */ - Composite priSwellComp = createGroupComposite(lblComp, 4, - "Primary Swell"); + Composite priSwellComp = createGroupComposite(lblComp, 4, "Primary Swell"); createLabelComp(priSwellComp, "Height(ft)", "", false); createLabelComp(priSwellComp, "Periods(s)", "", false); createLabelComp(priSwellComp, "Dir(deg)", "(from)", false); - createLabelComp(priSwellComp, "Dir(deg)", "(to)", false); - + createLabelComp(priSwellComp, "Dir(deg)", "(to)", false); + /* * Secondary Swell */ - Composite secSwellComp = createGroupComposite(lblComp, 4, - "Secondary Swell"); + Composite secSwellComp = createGroupComposite(lblComp, 4, "Secondary Swell"); createLabelComp(secSwellComp, "Height(ft)", "", false); createLabelComp(secSwellComp, "Periods(s)", "", false); createLabelComp(secSwellComp, "Dir(deg)", "(from)", false); createLabelComp(secSwellComp, "Dir(deg)", "(to)", false); - } - - /* - * (non-Javadoc) - * - * @see com.raytheon.uf.viz.monitor.ui.dialogs.TabItemComp#populateList() - */ + } + @Override - protected void populateList() { - if (ssDataArray == null) { + protected void populateList() + { + if (ssDataArray == null) + { createDataArray(); } - + boolean update = false; - if (dataList.getItemCount() > 0) { + if (dataList.getItemCount() > 0) + { update = true; } - + areaIDArray = new ArrayList(); - + String currentAreaID; - - StringBuilder sb = null; + + StringBuilder sb = null; SSDispMonSwellData sssd = null; - - for (int i = 0; i < ssDataArray.size(); i++) { + + for (int i = 0; i < ssDataArray.size(); i++) + { sb = new StringBuilder(); - + sssd = ssDataArray.get(i); - + currentAreaID = sssd.getAreaID(); areaIDArray.add(currentAreaID); - - sb.append(String.format(areaIdFmt, currentAreaID)); - + + sb.append(String.format(areaIdFmt, currentAreaID)); + /* * Primary Swell */ - appendIntData(sb, sssd.getPriSwellHeightR(), - sssd.getPriSwellHeightY()); - - double higherThreshold = Math.max(sssd.getPriSwellPeriodR(), - sssd.getPriSwellPeriodY()); - double lowerThreshold = Math.min(sssd.getPriSwellPeriodR(), - sssd.getPriSwellPeriodY()); - if (rankSwellPeriodHigh) { - sssd.setRankSwellPeriodHigh(true); - sssd.setPriSwellPeriodR(higherThreshold); - sssd.setPriSwellPeriodY(lowerThreshold); + appendIntData(sb, sssd.getPriSwellHeightR(), sssd.getPriSwellHeightY()); + + double higherThreshold = Math.max(sssd.getPriSwellPeriodR(), sssd.getPriSwellPeriodY()); + double lowerThreshold = Math.min(sssd.getPriSwellPeriodR(), sssd.getPriSwellPeriodY()); + if ( rankSwellPeriodHigh ) { + sssd.setRankSwellPeriodHigh(true); + sssd.setPriSwellPeriodR(higherThreshold); + sssd.setPriSwellPeriodY(lowerThreshold); } else { - sssd.setRankSwellPeriodHigh(false); - sssd.setPriSwellPeriodR(lowerThreshold); - sssd.setPriSwellPeriodY(higherThreshold); + sssd.setRankSwellPeriodHigh(false); + sssd.setPriSwellPeriodR(lowerThreshold); + sssd.setPriSwellPeriodY(higherThreshold); } - appendIntData(sb, sssd.getPriSwellPeriodR(), - sssd.getPriSwellPeriodY()); - - appendIntData(sb, sssd.getPriSwellDirFromR(), - sssd.getPriSwellDirFromY()); - appendIntData(sb, sssd.getPriSwellDirToR(), - sssd.getPriSwellDirToY()); - + appendIntData(sb, sssd.getPriSwellPeriodR(), sssd.getPriSwellPeriodY()); + + appendIntData(sb, sssd.getPriSwellDirFromR(), sssd.getPriSwellDirFromY()); + appendIntData(sb, sssd.getPriSwellDirToR(), sssd.getPriSwellDirToY()); + /* * Secondary Swell */ - appendIntData(sb, sssd.getSecSwellHeightR(), - sssd.getSecSwellHeightY()); - - higherThreshold = Math.max(sssd.getSecSwellPeriodR(), - sssd.getSecSwellPeriodY()); - lowerThreshold = Math.min(sssd.getSecSwellPeriodR(), - sssd.getSecSwellPeriodY()); - if (rankSwellPeriodHigh) { - // sssd.setRankSwellPeriodHigh(true); - sssd.setSecSwellPeriodR(higherThreshold); - sssd.setSecSwellPeriodY(lowerThreshold); + appendIntData(sb, sssd.getSecSwellHeightR(), sssd.getSecSwellHeightY()); + + higherThreshold = Math.max(sssd.getSecSwellPeriodR(), sssd.getSecSwellPeriodY()); + lowerThreshold = Math.min(sssd.getSecSwellPeriodR(), sssd.getSecSwellPeriodY()); + if ( rankSwellPeriodHigh ) { + //sssd.setRankSwellPeriodHigh(true); + sssd.setSecSwellPeriodR(higherThreshold); + sssd.setSecSwellPeriodY(lowerThreshold); } else { - // sssd.setRankSwellPeriodHigh(false); - sssd.setSecSwellPeriodR(lowerThreshold); - sssd.setSecSwellPeriodY(higherThreshold); + //sssd.setRankSwellPeriodHigh(false); + sssd.setSecSwellPeriodR(lowerThreshold); + sssd.setSecSwellPeriodY(higherThreshold); } - appendIntData(sb, sssd.getSecSwellPeriodR(), - sssd.getSecSwellPeriodY()); - - appendIntData(sb, sssd.getSecSwellDirFromR(), - sssd.getSecSwellDirFromY()); - appendIntData(sb, sssd.getSecSwellDirToR(), - sssd.getSecSwellDirToY()); - + appendIntData(sb, sssd.getSecSwellPeriodR(), sssd.getSecSwellPeriodY()); + + appendIntData(sb, sssd.getSecSwellDirFromR(), sssd.getSecSwellDirFromY()); + appendIntData(sb, sssd.getSecSwellDirToR(), sssd.getSecSwellDirToY()); + /* * Append a space and add the data line to the list. */ sb.append(" "); - - if (update == true) { + + if (update == true) + { dataList.setItem(i, sb.toString()); - } else { - dataList.add(sb.toString()); } + else + { + dataList.add(sb.toString()); + } } - + packListControls(); } - - /** - * Create Data Array. - */ - private void createDataArray() { + + private void createDataArray() + { ssDataArray = new ArrayList(); - - SSThresholdMgr sstm = SSThresholdMgr.getInstance(); - + + SSThresholdMgr sstm = SSThresholdMgr.getInstance(); + String xmlKey; - String areaID; - + String areaID; + ThresholdsXML threshXML = sstm.getThresholdsXmlData(duKey); - + ArrayList areasArray = threshXML.getAreas(); - - if (areasArray != null) { - for (AreaXML area : areasArray) { - areaID = area.getAreaId(); - SSDispMonSwellData sssd = new SSDispMonSwellData(); - - sssd.setAreaID(areaID); - - /* - * Primary Swell - */ - xmlKey = SafeSeasMonitor.SS_MON_SWELL_PRIM_HT.getXmlKey(); - sssd.setPriSwellHeightR(sstm.getThresholdValue(duKey, - threshKeyR, areaID, xmlKey)); - sssd.setPriSwellHeightY(sstm.getThresholdValue(duKey, - threshKeyY, areaID, xmlKey)); - - xmlKey = SafeSeasMonitor.SS_MON_SWELL_PRIM_PD.getXmlKey(); - sssd.setPriSwellPeriodR(sstm.getThresholdValue(duKey, - threshKeyR, areaID, xmlKey)); - sssd.setPriSwellPeriodY(sstm.getThresholdValue(duKey, - threshKeyY, areaID, xmlKey)); - - xmlKey = SafeSeasMonitor.SS_MON_SWELL_PRIM_DIR_FROM.getXmlKey(); - sssd.setPriSwellDirFromR(sstm.getThresholdValue(duKey, - threshKeyR, areaID, xmlKey)); - sssd.setPriSwellDirFromY(sstm.getThresholdValue(duKey, - threshKeyY, areaID, xmlKey)); - - xmlKey = SafeSeasMonitor.SS_MON_SWELL_PRIM_DIR_TO.getXmlKey(); - sssd.setPriSwellDirToR(sstm.getThresholdValue(duKey, - threshKeyR, areaID, xmlKey)); - sssd.setPriSwellDirToY(sstm.getThresholdValue(duKey, - threshKeyY, areaID, xmlKey)); - - /* - * Secondary Swell - */ - xmlKey = SafeSeasMonitor.SS_MON_SWELL_SEC_HT.getXmlKey(); - sssd.setSecSwellHeightR(sstm.getThresholdValue(duKey, - threshKeyR, areaID, xmlKey)); - sssd.setSecSwellHeightY(sstm.getThresholdValue(duKey, - threshKeyY, areaID, xmlKey)); - - xmlKey = SafeSeasMonitor.SS_MON_SWELL_SEC_PD.getXmlKey(); - sssd.setSecSwellPeriodR(sstm.getThresholdValue(duKey, - threshKeyR, areaID, xmlKey)); - sssd.setSecSwellPeriodY(sstm.getThresholdValue(duKey, - threshKeyY, areaID, xmlKey)); - - xmlKey = SafeSeasMonitor.SS_MON_SWELL_SEC_DIR_FROM.getXmlKey(); - sssd.setSecSwellDirFromR(sstm.getThresholdValue(duKey, - threshKeyR, areaID, xmlKey)); - sssd.setSecSwellDirFromY(sstm.getThresholdValue(duKey, - threshKeyY, areaID, xmlKey)); - - xmlKey = SafeSeasMonitor.SS_MON_SWELL_SEC_DIR_TO.getXmlKey(); - sssd.setSecSwellDirToR(sstm.getThresholdValue(duKey, - threshKeyR, areaID, xmlKey)); - sssd.setSecSwellDirToY(sstm.getThresholdValue(duKey, - threshKeyY, areaID, xmlKey)); - - /* - * Add data to array. - */ - ssDataArray.add(sssd); - } - } - } - - /** - * Gets Data at first selection. - * - * @return - */ - private SSDispMonSwellData getDataAtFirstSelection() { - int index = dataList.getSelectionIndex(); - - return ssDataArray.get(index); - } - - /** - * Update Data Array. - * - * @param sssd - */ - private void updateDataArray(SSDispMonSwellData sssd) { - int[] dataListIndexes = dataList.getSelectionIndices(); - int currentIndex = 0; - - for (int i = 0; i < dataListIndexes.length; i++) { - currentIndex = dataListIndexes[i]; - - ssDataArray.get(currentIndex).updateData(sssd); - } - } - - /* - * (non-Javadoc) - * - * @see com.raytheon.uf.viz.monitor.ui.dialogs.TabItemComp#commitDataToXML() - */ - @Override - public void commitDataToXML() { - SSThresholdMgr sstm = SSThresholdMgr.getInstance(); - - String xmlKey; - String areaID; - - for (SSDispMonSwellData sssd : ssDataArray) { - areaID = sssd.getAreaID(); + + for (AreaXML area : areasArray) + { + areaID = area.getAreaId(); + SSDispMonSwellData sssd = new SSDispMonSwellData(); + + sssd.setAreaID(areaID); /* * Primary Swell */ xmlKey = SafeSeasMonitor.SS_MON_SWELL_PRIM_HT.getXmlKey(); - sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, - sssd.getPriSwellHeightR()); - sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, - sssd.getPriSwellHeightY()); - + sssd.setPriSwellHeightR(sstm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); + sssd.setPriSwellHeightY(sstm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); + xmlKey = SafeSeasMonitor.SS_MON_SWELL_PRIM_PD.getXmlKey(); - sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, - sssd.getPriSwellPeriodR()); - sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, - sssd.getPriSwellPeriodY()); - + sssd.setPriSwellPeriodR(sstm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); + sssd.setPriSwellPeriodY(sstm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); + xmlKey = SafeSeasMonitor.SS_MON_SWELL_PRIM_DIR_FROM.getXmlKey(); - sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, - sssd.getPriSwellDirFromR()); - sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, - sssd.getPriSwellDirFromY()); - + sssd.setPriSwellDirFromR(sstm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); + sssd.setPriSwellDirFromY(sstm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); + xmlKey = SafeSeasMonitor.SS_MON_SWELL_PRIM_DIR_TO.getXmlKey(); - sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, - sssd.getPriSwellDirToR()); - sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, - sssd.getPriSwellDirToY()); - + sssd.setPriSwellDirToR(sstm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); + sssd.setPriSwellDirToY(sstm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); + /* * Secondary Swell */ xmlKey = SafeSeasMonitor.SS_MON_SWELL_SEC_HT.getXmlKey(); - sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, - sssd.getSecSwellHeightR()); - sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, - sssd.getSecSwellHeightY()); - + sssd.setSecSwellHeightR(sstm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); + sssd.setSecSwellHeightY(sstm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); + xmlKey = SafeSeasMonitor.SS_MON_SWELL_SEC_PD.getXmlKey(); - sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, - sssd.getSecSwellPeriodR()); - sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, - sssd.getSecSwellPeriodY()); - + sssd.setSecSwellPeriodR(sstm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); + sssd.setSecSwellPeriodY(sstm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); + xmlKey = SafeSeasMonitor.SS_MON_SWELL_SEC_DIR_FROM.getXmlKey(); - sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, - sssd.getSecSwellDirFromR()); - sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, - sssd.getSecSwellDirFromY()); - + sssd.setSecSwellDirFromR(sstm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); + sssd.setSecSwellDirFromY(sstm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); + xmlKey = SafeSeasMonitor.SS_MON_SWELL_SEC_DIR_TO.getXmlKey(); - sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, - sssd.getSecSwellDirToR()); - sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, - sssd.getSecSwellDirToY()); + sssd.setSecSwellDirToR(sstm.getThresholdValue(duKey, threshKeyR, areaID, xmlKey)); + sssd.setSecSwellDirToY(sstm.getThresholdValue(duKey, threshKeyY, areaID, xmlKey)); + + /* + * Add data to array. + */ + ssDataArray.add(sssd); } } - - /* - * (non-Javadoc) - * - * @see com.raytheon.uf.viz.monitor.ui.dialogs.TabItemComp#reloadData() - */ + + private SSDispMonSwellData getDataAtFirstSelection() + { + int index = dataList.getSelectionIndex(); + + return ssDataArray.get(index); + } + + private void updateDataArray(SSDispMonSwellData sssd) + { + int[] dataListIndexes = dataList.getSelectionIndices(); + int currentIndex = 0; + + for (int i = 0; i < dataListIndexes.length; i++) + { + currentIndex = dataListIndexes[i]; + + ssDataArray.get(currentIndex).updateData(sssd); + } + } + @Override - public void reloadData() { + public void commitDataToXML() + { + SSThresholdMgr sstm = SSThresholdMgr.getInstance(); + + String xmlKey; + String areaID; + + for (SSDispMonSwellData sssd : ssDataArray) + { + areaID = sssd.getAreaID(); + + /* + * Primary Swell + */ + xmlKey = SafeSeasMonitor.SS_MON_SWELL_PRIM_HT.getXmlKey(); + sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, sssd.getPriSwellHeightR()); + sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, sssd.getPriSwellHeightY()); + + xmlKey = SafeSeasMonitor.SS_MON_SWELL_PRIM_PD.getXmlKey(); + sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, sssd.getPriSwellPeriodR()); + sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, sssd.getPriSwellPeriodY()); + + xmlKey = SafeSeasMonitor.SS_MON_SWELL_PRIM_DIR_FROM.getXmlKey(); + sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, sssd.getPriSwellDirFromR()); + sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, sssd.getPriSwellDirFromY()); + + xmlKey = SafeSeasMonitor.SS_MON_SWELL_PRIM_DIR_TO.getXmlKey(); + sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, sssd.getPriSwellDirToR()); + sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, sssd.getPriSwellDirToY()); + + /* + * Secondary Swell + */ + xmlKey = SafeSeasMonitor.SS_MON_SWELL_SEC_HT.getXmlKey(); + sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, sssd.getSecSwellHeightR()); + sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, sssd.getSecSwellHeightY()); + + xmlKey = SafeSeasMonitor.SS_MON_SWELL_SEC_PD.getXmlKey(); + sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, sssd.getSecSwellPeriodR()); + sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, sssd.getSecSwellPeriodY()); + + xmlKey = SafeSeasMonitor.SS_MON_SWELL_SEC_DIR_FROM.getXmlKey(); + sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, sssd.getSecSwellDirFromR()); + sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, sssd.getSecSwellDirFromY()); + + xmlKey = SafeSeasMonitor.SS_MON_SWELL_SEC_DIR_TO.getXmlKey(); + sstm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, sssd.getSecSwellDirToR()); + sstm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, sssd.getSecSwellDirToY()); + } + } + + @Override + public void reloadData() + { dataList.removeAll(); ssDataArray.clear(); ssDataArray = null; - - populateList(); + + populateList(); } - /* - * (non-Javadoc) - * - * @see com.raytheon.uf.viz.monitor.ui.dialogs.TabItemComp#editDataAction() - */ @Override - protected void editDataAction() { + protected void editDataAction() + { SSDispMonSwellData sssd = getDataAtFirstSelection(); - - if (monitorSwellEditDlg == null) { - monitorSwellEditDlg = new SSDispMonSwellEditDlg(getParent() - .getShell(), sssd, this, false); + + if (monitorSwellEditDlg == null) + { + monitorSwellEditDlg = new SSDispMonSwellEditDlg(getParent().getShell(), sssd, this, false); monitorSwellEditDlg.open(); monitorSwellEditDlg = null; } - } + } - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.viz.monitor.safeseas.ui.dialogs.IUpdateDisplayMonitorSwell - * #updateThresholdData(com.raytheon.uf.viz.monitor.safeseas.threshold. - * SSDispMonSwellData) - */ @Override - public void updateThresholdData(SSDispMonSwellData sssd) { + public void updateThresholdData(SSDispMonSwellData sssd) + { updateDataArray(sssd); - populateList(); + populateList(); } } + diff --git a/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/dialogs/SSMonitoringAreaConfigDlg.java b/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/dialogs/SSMonitoringAreaConfigDlg.java old mode 100644 new mode 100755 index 645a823980..2a50f58064 --- a/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/dialogs/SSMonitoringAreaConfigDlg.java +++ b/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/dialogs/SSMonitoringAreaConfigDlg.java @@ -24,6 +24,7 @@ import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager; +import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager.MonName; import com.raytheon.uf.common.monitor.data.CommonConfig; import com.raytheon.uf.common.monitor.data.CommonConfig.AppName; import com.raytheon.uf.common.monitor.data.ObConst.DataUsageKey; @@ -48,11 +49,7 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback; * Apr 28, 2014 3086 skorolev Updated getConfigManager. * Sep 04, 2014 3220 skorolev Added fireConfigUpdateEvent method. Updated handler. * Sep 19, 2014 2757 skorolev Updated handlers for dialog buttons. - * Oct 16, 2014 3220 skorolev Corrected getInstance() method. * Oct 27, 2014 3667 skorolev Cleaned code. - * Nov 21, 2014 3841 skorolev Corrected handleOkBtnSelection. - * Dec 11, 2014 3220 skorolev Removed unnecessary code. - * Feb 03, 2015 3841 skorolev Replaced resetParams with resetStatus. * * * @@ -73,6 +70,7 @@ public class SSMonitoringAreaConfigDlg extends MonitoringAreaConfigDlg { */ public SSMonitoringAreaConfigDlg(Shell parent, String title) { super(parent, title, AppName.SAFESEAS); + SafeSeasMonitor.getInstance(); } @Override @@ -82,11 +80,12 @@ public class SSMonitoringAreaConfigDlg extends MonitoringAreaConfigDlg { "SAFESEAS Monitor Confirm Changes", "Save changes?"); if (choice == SWT.YES) { // Save the config xml file. - saveConfigs(); + resetAndSave(); SSThresholdMgr.reInitialize(); + fireConfigUpdateEvent(); + // Open Threshold Dialog if zones/stations are added. if ((!configMgr.getAddedZones().isEmpty()) || (!configMgr.getAddedStations().isEmpty())) { - // Open Threshold Dialog if zones/stations are added. if (editDialog() == SWT.YES) { ssMonitorDlg = new SSDispMonThreshDlg(shell, CommonConfig.AppName.SAFESEAS, @@ -94,15 +93,19 @@ public class SSMonitoringAreaConfigDlg extends MonitoringAreaConfigDlg { ssMonitorDlg.setCloseCallback(new ICloseCallback() { @Override public void dialogClosed(Object returnValue) { + // Clean added zones and stations. Close dialog. + configMgr.getAddedZones().clear(); + configMgr.getAddedStations().clear(); setReturnValue(true); close(); } }); ssMonitorDlg.open(); } + // Clean added zones and stations. + configMgr.getAddedZones().clear(); + configMgr.getAddedStations().clear(); } - fireConfigUpdateEvent(); - resetStatus(); } else { // Return back to continue edit. return; } @@ -119,6 +122,7 @@ public class SSMonitoringAreaConfigDlg extends MonitoringAreaConfigDlg { private void fireConfigUpdateEvent() { final IMonitorConfigurationEvent me = new IMonitorConfigurationEvent( configMgr); + shell.setCursor(getDisplay().getSystemCursor(SWT.CURSOR_WAIT)); Display.getDefault().asyncExec(new Runnable() { @Override public void run() { @@ -136,7 +140,10 @@ public class SSMonitoringAreaConfigDlg extends MonitoringAreaConfigDlg { */ @Override public FSSObsMonitorConfigurationManager getInstance() { - return FSSObsMonitorConfigurationManager.getSsObsManager(); + if (configMgr == null) { + configMgr = new FSSObsMonitorConfigurationManager(MonName.ss.name()); + } + return configMgr; } /* diff --git a/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/dialogs/SSZoneTableDlg.java b/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/dialogs/SSZoneTableDlg.java old mode 100644 new mode 100755 index d4041dcde5..a5ddd8f56f --- a/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/dialogs/SSZoneTableDlg.java +++ b/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/dialogs/SSZoneTableDlg.java @@ -29,6 +29,7 @@ import org.eclipse.swt.widgets.Shell; import com.raytheon.uf.common.dataplugin.fog.FogRecord.FOG_THREAT; import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager; +import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager.MonName; import com.raytheon.uf.common.monitor.data.CommonConfig; import com.raytheon.uf.common.monitor.data.ObConst.DataUsageKey; import com.raytheon.uf.common.monitor.data.ObConst.DisplayVarName; @@ -54,11 +55,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. - * Jan 27, 2015 3220 skorolev Removed "site". Added check on dispose.Corrected configMgr assignment. - * Added table cache update. - * Feb 04, 2015 3841 skorolev Corrected notify method for empty table update. + * Sep 04, 2014 3220 skorolev Removed "site". Added check on dispose. * * * @@ -81,10 +80,6 @@ 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(); } /** @@ -155,10 +150,10 @@ public class SSZoneTableDlg extends ZoneTableDlg { if (me.getSource() instanceof SafeSeasMonitor) { SafeSeasMonitor monitor = (SafeSeasMonitor) me.getSource(); - ObMultiHrsReports obData = monitor.getObData(); Date date = monitor.getDialogTime(); if (date != null) { Date nominalTime = date; + ObMultiHrsReports obData = monitor.getObData(); if (!isLinkedToFrame()) { nominalTime = obData.getLatestNominalTime(); } @@ -167,8 +162,6 @@ public class SSZoneTableDlg extends ZoneTableDlg { obData.setFogAlgCellType(monitor.getAlgCellTypes(fogAlgThreats)); this.updateTableDlg(monitor.getObData().getObHourReports( nominalTime)); - } else { - this.updateZoneTable(obData.getLatestNominalTime()); } } } @@ -286,7 +279,7 @@ public class SSZoneTableDlg extends ZoneTableDlg { * setZoneSortColumnAndDirection() */ @Override - public void setZoneSortColumnAndDirection() { + protected void setZoneSortColumnAndDirection() { if (zoneTblData != null) { zoneSortColumn = zoneTblData.getSortColumn(); zoneSortDirection = zoneTblData.getSortDirection(); @@ -326,4 +319,18 @@ public class SSZoneTableDlg extends ZoneTableDlg { } } } + + /* + * (non-Javadoc) + * + * @see com.raytheon.uf.viz.monitor.ui.dialogs.ZoneTableDlg# + * getMonitorAreaConfigInstance() + */ + @Override + protected FSSObsMonitorConfigurationManager getMonitorAreaConfigInstance() { + if (configMgr == null || configMgr.isPopulated()) { + configMgr = new FSSObsMonitorConfigurationManager(MonName.ss.name()); + } + return configMgr; + } } diff --git a/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/SnowMonitor.java b/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/SnowMonitor.java index e06bb0f928..14c200bd77 100755 --- a/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/SnowMonitor.java +++ b/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/SnowMonitor.java @@ -20,14 +20,18 @@ package com.raytheon.uf.viz.monitor.snow; import java.util.ArrayList; +import java.util.Comparator; import java.util.Date; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.regex.Pattern; import org.eclipse.swt.widgets.Shell; import com.raytheon.uf.common.dataplugin.annotations.DataURI; import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager; +import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager.MonName; import com.raytheon.uf.common.monitor.data.CommonConfig; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; @@ -36,6 +40,7 @@ import com.raytheon.uf.viz.core.notification.NotificationMessage; import com.raytheon.uf.viz.monitor.IMonitor; import com.raytheon.uf.viz.monitor.Monitor; import com.raytheon.uf.viz.monitor.ObsMonitor; +import com.raytheon.uf.viz.monitor.data.MonitoringArea; import com.raytheon.uf.viz.monitor.data.ObMultiHrsReports; import com.raytheon.uf.viz.monitor.data.ObReport; import com.raytheon.uf.viz.monitor.events.IMonitorConfigurationEvent; @@ -68,10 +73,7 @@ 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. - * 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. + * Sep 04, 2014 3220 skorolev Updated configUpdate method and added updateMonitoringArea. * * * @@ -95,7 +97,13 @@ public class SnowMonitor extends ObsMonitor implements ISnowResourceListener { private SnowMonitoringAreaConfigDlg areaDialog = null; /** SNOW configuration manager **/ - private static FSSObsMonitorConfigurationManager snowAreaConfig = null; + private FSSObsMonitorConfigurationManager snowConfig = null; + + /** + * This object contains all observation data necessary for the table dialogs + * and trending plots + */ + private ObMultiHrsReports obData; /** All SNOW datauri start with this */ private final String OBS = "fssobs"; @@ -103,6 +111,9 @@ 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 snowResources = new ArrayList(); @@ -117,10 +128,12 @@ public class SnowMonitor extends ObsMonitor implements ISnowResourceListener { */ private SnowMonitor() { pluginPatterns.add(snowPattern); - snowAreaConfig = FSSObsMonitorConfigurationManager.getSnowObsManager(); + snowConfig = new FSSObsMonitorConfigurationManager(MonName.snow.name()); + updateMonitoringArea(); initObserver(OBS, this); obData = new ObMultiHrsReports(CommonConfig.AppName.SNOW); obData.setThresholdMgr(SnowThresholdMgr.getInstance()); + obData.getZoneTableData(); } /** @@ -131,17 +144,12 @@ public class SnowMonitor extends ObsMonitor implements ISnowResourceListener { public static synchronized SnowMonitor getInstance() { if (monitor == null) { monitor = new SnowMonitor(); - monitor.createDataStructures(); - monitor.processProductAtStartup(snowAreaConfig); + monitor.processProductAtStartup("snow"); + monitor.fireMonitorEvent(monitor); } return monitor; } - private void createDataStructures() { - obData = new ObMultiHrsReports(CommonConfig.AppName.SNOW); - obData.setThresholdMgr(SnowThresholdMgr.getInstance()); - } - /** * Re-initialization of monitor. * @@ -162,21 +170,26 @@ public class SnowMonitor extends ObsMonitor implements ISnowResourceListener { */ public void launchDialog(String type, Shell shell) { if (type.equals("zone")) { - zoneDialog = new SnowZoneTableDlg(shell, obData); - addMonitorListener(zoneDialog); - zoneDialog.addMonitorControlListener(this); + if (zoneDialog == null) { + zoneDialog = new SnowZoneTableDlg(shell, obData); + addMonitorListener(zoneDialog); + zoneDialog.addMonitorControlListener(this); + fireMonitorEvent(zoneDialog.getClass().getName()); + } zoneDialog.open(); } else if (type.equals("area")) { - areaDialog = new SnowMonitoringAreaConfigDlg(shell, - "SNOW Monitor Area Configuration"); - areaDialog.setCloseCallback(new ICloseCallback() { + if (areaDialog == null) { + 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(); } } @@ -224,10 +237,40 @@ public class SnowMonitor extends ObsMonitor implements ISnowResourceListener { @Override public void processProductMessage(final AlertMessage filtered) { if (snowPattern.matcher(filtered.dataURI).matches()) { - processURI(filtered.dataURI, filtered, snowAreaConfig); + processURI(filtered.dataURI, filtered); } } + /** + * Sort by Date. + * + * @author dhladky + * + */ + public class SortByDate implements Comparator { + @Override + public int compare(Date o1, Date o2) { + return o1.compareTo(o2); + } + } + + /** + * Reads Table Configuration. + * + * Method that reads the table configuration and updates the zone monitor + * threshold map + * + */ + public void updateMonitoringArea() { + Map> zones = new HashMap>(); + // create zones and station list + for (String zone : snowConfig.getAreaList()) { + List stations = snowConfig.getAreaStations(zone); + zones.put(zone, stations); + } + MonitoringArea.setPlatformMap(zones); + } + /* * (non-Javadoc) * @@ -260,10 +303,10 @@ public class SnowMonitor extends ObsMonitor implements ISnowResourceListener { */ @Override public void configUpdate(IMonitorConfigurationEvent me) { - snowAreaConfig = (FSSObsMonitorConfigurationManager) me.getSource(); - obData.getObHourReports().updateZones(snowAreaConfig); + snowConfig = (FSSObsMonitorConfigurationManager) me.getSource(); + updateMonitoringArea(); if (zoneDialog != null && !zoneDialog.isDisposed()) { - obData.updateTableCache(); + zoneDialog.refreshZoneTableData(obData); fireMonitorEvent(zoneDialog.getClass().getName()); } } @@ -293,10 +336,27 @@ 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. * @@ -317,6 +377,16 @@ 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. */ @@ -348,7 +418,7 @@ public class SnowMonitor extends ObsMonitor implements ISnowResourceListener { } /** - * Gets SNOW Zone Dialog. + * Gets Zone Dialog. * * @return zoneDialog */ @@ -356,15 +426,6 @@ public class SnowMonitor extends ObsMonitor implements ISnowResourceListener { return zoneDialog; } - /** - * Gets SNOW Area configuration dialog - * - * @return - */ - public SnowMonitoringAreaConfigDlg getAreaDialog() { - return areaDialog; - } - /** * Sets the zoneDialog * diff --git a/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/threshold/SnowThresholdMgr.java b/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/threshold/SnowThresholdMgr.java old mode 100644 new mode 100755 index 12382e0fa6..3a17128bec --- a/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/threshold/SnowThresholdMgr.java +++ b/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/threshold/SnowThresholdMgr.java @@ -22,6 +22,7 @@ package com.raytheon.uf.viz.monitor.snow.threshold; import java.util.ArrayList; import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager; +import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager.MonName; import com.raytheon.uf.common.monitor.data.CommonConfig.AppName; import com.raytheon.uf.common.monitor.data.ObConst.DataUsageKey; import com.raytheon.uf.viz.monitor.thresholds.AbstractThresholdMgr; @@ -41,7 +42,6 @@ import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants.SnowMonitor; * Feb 03, 2014 #2757 skorolev Fixed reInitialize() * May 21, 2014 3086 skorolev Cleaned code. * Sep 04, 2014 3220 skorolev Removed "site". - * Oct 16, 2014 3220 skorolev Corrected areaConfigMgr assignment. * * * @@ -58,7 +58,9 @@ public class SnowThresholdMgr extends AbstractThresholdMgr { super("DefaultSnowDisplayThresholds.xml", "DefaultSnowMonitorThresholds.xml", AppName.SNOW.name() .toLowerCase()); - areaConfigMgr = FSSObsMonitorConfigurationManager.getSnowObsManager(); + + areaConfigMgr = new FSSObsMonitorConfigurationManager( + MonName.snow.name()); init(); } @@ -112,4 +114,19 @@ public class SnowThresholdMgr extends AbstractThresholdMgr { } return threshKeys; } + + /* + * (non-Javadoc) + * + * @see com.raytheon.uf.viz.monitor.thresholds.AbstractThresholdMgr# + * getMonitorAreaConfigInstance() + */ + @Override + protected FSSObsMonitorConfigurationManager getMonitorAreaConfigInstance() { + if (areaConfigMgr == null) { + areaConfigMgr = new FSSObsMonitorConfigurationManager( + MonName.snow.name()); + } + return areaConfigMgr; + } } diff --git a/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/ui/actions/SnowAreaConfigAction.java b/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/ui/actions/SnowAreaConfigAction.java index a0f050c516..b4fa508d61 100644 --- a/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/ui/actions/SnowAreaConfigAction.java +++ b/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/ui/actions/SnowAreaConfigAction.java @@ -25,7 +25,8 @@ import org.eclipse.core.commands.ExecutionException; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.PlatformUI; -import com.raytheon.uf.viz.monitor.snow.SnowMonitor; +import com.raytheon.uf.viz.monitor.snow.ui.dialogs.SnowMonitoringAreaConfigDlg; +import com.raytheon.viz.ui.dialogs.ICloseCallback; /** * The Snow Area Action @@ -50,6 +51,11 @@ import com.raytheon.uf.viz.monitor.snow.SnowMonitor; public class SnowAreaConfigAction extends AbstractHandler { + /** + * SNOW Monitoring Area Configuration Dialog. + */ + private SnowMonitoringAreaConfigDlg configDlg; + /* * (non-Javadoc) * @@ -59,12 +65,19 @@ public class SnowAreaConfigAction extends AbstractHandler { */ @Override public Object execute(ExecutionEvent arg0) throws ExecutionException { - SnowMonitor snow = SnowMonitor.getInstance(); - if (snow.getAreaDialog() == null || snow.getAreaDialog().isDisposed()) { + if (configDlg == null || configDlg.isDisposed()) { Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow() .getShell(); - snow.launchDialog("area", shell); + configDlg = new SnowMonitoringAreaConfigDlg(shell, + "SNOW Monitor Area Configuration"); + configDlg.setCloseCallback(new ICloseCallback() { + @Override + public void dialogClosed(Object returnValue) { + configDlg = null; + } + }); } + configDlg.open(); return null; } } \ No newline at end of file diff --git a/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/ui/dialogs/SnowDisplayMeteoTab.java b/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/ui/dialogs/SnowDisplayMeteoTab.java index 698af9d305..eb34fa2508 100644 --- a/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/ui/dialogs/SnowDisplayMeteoTab.java +++ b/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/ui/dialogs/SnowDisplayMeteoTab.java @@ -48,7 +48,6 @@ import com.raytheon.uf.viz.monitor.xml.ThresholdsXML; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * May 21, 2014 3086 skorolev Cleaned code. - * Oct 16, 2014 3220 skorolev Added condition to avoid NPE. * * * @@ -214,86 +213,84 @@ public class SnowDisplayMeteoTab extends TabItemComp implements List areasArray = threshXML.getAreas(); - if (areasArray != null) { - for (AreaXML area : areasArray) { - areaID = area.getAreaId(); - SnowDisplayMeteoData sdmd = new SnowDisplayMeteoData(); + for (AreaXML area : areasArray) { + areaID = area.getAreaId(); + SnowDisplayMeteoData sdmd = new SnowDisplayMeteoData(); - sdmd.setAreaID(areaID); + sdmd.setAreaID(areaID); - /* Tempature */ - xmlKey = SnowDisplay.SNOW_DISP_METEO_TEMP.getXmlKey(); - sdmd.setTempR(stm.getThresholdValue(duKey, threshKeyR, areaID, - xmlKey)); - sdmd.setTempY(stm.getThresholdValue(duKey, threshKeyY, areaID, - xmlKey)); + /* Tempature */ + xmlKey = SnowDisplay.SNOW_DISP_METEO_TEMP.getXmlKey(); + sdmd.setTempR(stm.getThresholdValue(duKey, threshKeyR, areaID, + xmlKey)); + sdmd.setTempY(stm.getThresholdValue(duKey, threshKeyY, areaID, + xmlKey)); - /* Dew point */ - xmlKey = SnowDisplay.SNOW_DISP_METEO_DEWPT.getXmlKey(); - sdmd.setDewpointR(stm.getThresholdValue(duKey, threshKeyR, - areaID, xmlKey)); - sdmd.setDewpointY(stm.getThresholdValue(duKey, threshKeyY, - areaID, xmlKey)); + /* Dew point */ + xmlKey = SnowDisplay.SNOW_DISP_METEO_DEWPT.getXmlKey(); + sdmd.setDewpointR(stm.getThresholdValue(duKey, threshKeyR, areaID, + xmlKey)); + sdmd.setDewpointY(stm.getThresholdValue(duKey, threshKeyY, areaID, + xmlKey)); - /* Visibility */ - xmlKey = SnowDisplay.SNOW_DISP_METEO_VIS.getXmlKey(); - sdmd.setVisR(stm.getThresholdValue(duKey, threshKeyR, areaID, - xmlKey)); - sdmd.setVisY(stm.getThresholdValue(duKey, threshKeyY, areaID, - xmlKey)); + /* Visibility */ + xmlKey = SnowDisplay.SNOW_DISP_METEO_VIS.getXmlKey(); + sdmd.setVisR(stm.getThresholdValue(duKey, threshKeyR, areaID, + xmlKey)); + sdmd.setVisY(stm.getThresholdValue(duKey, threshKeyY, areaID, + xmlKey)); - /* SLP */ - xmlKey = SnowDisplay.SNOW_DISP_METEO_SLP.getXmlKey(); - sdmd.setSlpR(stm.getThresholdValue(duKey, threshKeyR, areaID, - xmlKey)); - sdmd.setSlpY(stm.getThresholdValue(duKey, threshKeyY, areaID, - xmlKey)); + /* SLP */ + xmlKey = SnowDisplay.SNOW_DISP_METEO_SLP.getXmlKey(); + sdmd.setSlpR(stm.getThresholdValue(duKey, threshKeyR, areaID, + xmlKey)); + sdmd.setSlpY(stm.getThresholdValue(duKey, threshKeyY, areaID, + xmlKey)); - /* Hourly Precipitation */ - xmlKey = SnowDisplay.SNOW_DISP_METEO_HOURLY_PRECIP.getXmlKey(); - sdmd.setHrPrecipR(stm.getThresholdValue(duKey, threshKeyR, - areaID, xmlKey)); - sdmd.setHrPrecipY(stm.getThresholdValue(duKey, threshKeyY, - areaID, xmlKey)); + /* Hourly Precipitation */ + xmlKey = SnowDisplay.SNOW_DISP_METEO_HOURLY_PRECIP.getXmlKey(); + sdmd.setHrPrecipR(stm.getThresholdValue(duKey, threshKeyR, areaID, + xmlKey)); + sdmd.setHrPrecipY(stm.getThresholdValue(duKey, threshKeyY, areaID, + xmlKey)); - /* Wind Chill */ - xmlKey = SnowDisplay.SNOW_DISP_METEO_WIND_CHILL.getXmlKey(); - sdmd.setWindChillR(stm.getThresholdValue(duKey, threshKeyR, - areaID, xmlKey)); - sdmd.setWindChillY(stm.getThresholdValue(duKey, threshKeyY, - areaID, xmlKey)); + /* Wind Chill */ + xmlKey = SnowDisplay.SNOW_DISP_METEO_WIND_CHILL.getXmlKey(); + sdmd.setWindChillR(stm.getThresholdValue(duKey, threshKeyR, areaID, + xmlKey)); + sdmd.setWindChillY(stm.getThresholdValue(duKey, threshKeyY, areaID, + xmlKey)); - /* Frost Bite */ - xmlKey = SnowDisplay.SNOW_DISP_METEO_FROSTBITE.getXmlKey(); - sdmd.setFrostBiteR(stm.getThresholdValue(duKey, threshKeyR, - areaID, xmlKey)); - sdmd.setFrostBiteY(stm.getThresholdValue(duKey, threshKeyY, - areaID, xmlKey)); + /* Frost Bite */ + xmlKey = SnowDisplay.SNOW_DISP_METEO_FROSTBITE.getXmlKey(); + sdmd.setFrostBiteR(stm.getThresholdValue(duKey, threshKeyR, areaID, + xmlKey)); + sdmd.setFrostBiteY(stm.getThresholdValue(duKey, threshKeyY, areaID, + xmlKey)); - /* Snow Depth */ - xmlKey = SnowDisplay.SNOW_DISP_METEO_SNOW_DEPTH.getXmlKey(); - sdmd.setSnowDepthR(stm.getThresholdValue(duKey, threshKeyR, - areaID, xmlKey)); - sdmd.setSnowDepthY(stm.getThresholdValue(duKey, threshKeyY, - areaID, xmlKey)); + /* Snow Depth */ + xmlKey = SnowDisplay.SNOW_DISP_METEO_SNOW_DEPTH.getXmlKey(); + sdmd.setSnowDepthR(stm.getThresholdValue(duKey, threshKeyR, areaID, + xmlKey)); + sdmd.setSnowDepthY(stm.getThresholdValue(duKey, threshKeyY, areaID, + xmlKey)); - /* SNINCR Hourly */ - xmlKey = SnowDisplay.SNOW_DISP_METEO_SNINCR_HOURLY.getXmlKey(); - sdmd.setSnincrHrlyR(stm.getThresholdValue(duKey, threshKeyR, - areaID, xmlKey)); - sdmd.setSnincrHrlyY(stm.getThresholdValue(duKey, threshKeyY, - areaID, xmlKey)); + /* SNINCR Hourly */ + xmlKey = SnowDisplay.SNOW_DISP_METEO_SNINCR_HOURLY.getXmlKey(); + sdmd.setSnincrHrlyR(stm.getThresholdValue(duKey, threshKeyR, + areaID, xmlKey)); + sdmd.setSnincrHrlyY(stm.getThresholdValue(duKey, threshKeyY, + areaID, xmlKey)); - /* SNINCR Total */ - xmlKey = SnowDisplay.SNOW_DISP_METEO_SNINCR_TOTAL.getXmlKey(); - sdmd.setSnincrTotR(stm.getThresholdValue(duKey, threshKeyR, - areaID, xmlKey)); - sdmd.setSnincrTotY(stm.getThresholdValue(duKey, threshKeyY, - areaID, xmlKey)); + /* SNINCR Total */ + xmlKey = SnowDisplay.SNOW_DISP_METEO_SNINCR_TOTAL.getXmlKey(); + sdmd.setSnincrTotR(stm.getThresholdValue(duKey, threshKeyR, areaID, + xmlKey)); + sdmd.setSnincrTotY(stm.getThresholdValue(duKey, threshKeyY, areaID, + xmlKey)); - /* Add data to array. */ - snowDataArray.add(sdmd); - } + /* Add data to array. */ + snowDataArray.add(sdmd); } } diff --git a/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/ui/dialogs/SnowMonitoringAreaConfigDlg.java b/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/ui/dialogs/SnowMonitoringAreaConfigDlg.java old mode 100644 new mode 100755 index 79e7c74f3f..2b5ef442c7 --- a/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/ui/dialogs/SnowMonitoringAreaConfigDlg.java +++ b/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/ui/dialogs/SnowMonitoringAreaConfigDlg.java @@ -24,6 +24,7 @@ import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager; +import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager.MonName; import com.raytheon.uf.common.monitor.data.CommonConfig; import com.raytheon.uf.common.monitor.data.CommonConfig.AppName; import com.raytheon.uf.common.monitor.data.ObConst.DataUsageKey; @@ -48,12 +49,7 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback; * Apr 28, 2014 3086 skorolev Updated snowConfigManager. * Sep 04, 2014 3220 skorolev Added fireConfigUpdateEvent method. Updated handler. * Sep 19, 2014 2757 skorolev Updated handlers for dialog buttons. - * Oct 16, 2014 3220 skorolev Corrected getInstance() method. * Oct 27, 2014 3667 skorolev Cleaned code. - * Nov 21, 2014 3841 skorolev Corrected handleOkBtnSelection. - * Dec 11, 2014 3220 skorolev Removed unnecessary code. - * Feb 03, 2015 3841 skorolev Replaced resetParams with resetStatus. - * * * * @author mpduff @@ -72,6 +68,7 @@ public class SnowMonitoringAreaConfigDlg extends MonitoringAreaConfigDlg { */ public SnowMonitoringAreaConfigDlg(Shell parent, String title) { super(parent, title, AppName.SNOW); + SnowMonitor.getInstance(); } /* @@ -87,8 +84,9 @@ public class SnowMonitoringAreaConfigDlg extends MonitoringAreaConfigDlg { "SNOW Monitor Confirm Changes", "Save changes?"); if (choice == SWT.YES) { // Save the config xml file. - saveConfigs(); + resetAndSave(); SnowThresholdMgr.reInitialize(); + fireConfigUpdateEvent(); // Open Threshold Dialog if zones/stations are added. if ((!configMgr.getAddedZones().isEmpty()) || (!configMgr.getAddedStations().isEmpty())) { @@ -103,15 +101,19 @@ public class SnowMonitoringAreaConfigDlg extends MonitoringAreaConfigDlg { @Override public void dialogClosed(Object returnValue) { + // Clean added zones and stations. Close dialog. + configMgr.getAddedZones().clear(); + configMgr.getAddedStations().clear(); setReturnValue(true); close(); } }); snowMonitorDlg.open(); } + // Clean added zones and stations. + configMgr.getAddedZones().clear(); + configMgr.getAddedStations().clear(); } - fireConfigUpdateEvent(); - resetStatus(); } else { // Return back to continue edit. return; } @@ -131,7 +133,11 @@ public class SnowMonitoringAreaConfigDlg extends MonitoringAreaConfigDlg { */ @Override protected FSSObsMonitorConfigurationManager getInstance() { - return FSSObsMonitorConfigurationManager.getSnowObsManager(); + if (configMgr == null) { + configMgr = new FSSObsMonitorConfigurationManager( + MonName.snow.name()); + } + return configMgr; } /* @@ -151,6 +157,7 @@ public class SnowMonitoringAreaConfigDlg extends MonitoringAreaConfigDlg { private void fireConfigUpdateEvent() { final IMonitorConfigurationEvent me = new IMonitorConfigurationEvent( configMgr); + shell.setCursor(getDisplay().getSystemCursor(SWT.CURSOR_WAIT)); Display.getDefault().asyncExec(new Runnable() { @Override public void run() { diff --git a/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/ui/dialogs/SnowZoneTableDlg.java b/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/ui/dialogs/SnowZoneTableDlg.java old mode 100644 new mode 100755 index af4cf204d2..875373938b --- a/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/ui/dialogs/SnowZoneTableDlg.java +++ b/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/ui/dialogs/SnowZoneTableDlg.java @@ -26,6 +26,7 @@ import java.util.List; import org.eclipse.swt.widgets.Shell; import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager; +import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager.MonName; import com.raytheon.uf.common.monitor.data.CommonConfig; import com.raytheon.uf.common.monitor.data.ObConst.DataUsageKey; import com.raytheon.uf.common.monitor.data.ObConst.DisplayVarName; @@ -53,9 +54,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. - * Jan 27, 2015 3220 skorolev Removed "site". Added check on dispose.Corrected configMgr assignment. - * Added table cache update. - * Feb 04, 2015 3841 skorolev Corrected notify method for empty table update. + * Sep 04, 2014 3220 skorolev Removed "site". Added check on dispose. * * * @@ -76,10 +75,6 @@ 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(); } /** @@ -148,15 +143,12 @@ public class SnowZoneTableDlg extends ZoneTableDlg { if (me.getSource() instanceof SnowMonitor) { SnowMonitor monitor = (SnowMonitor) me.getSource(); - ObMultiHrsReports obData = monitor.getObData(); Date date = monitor.getDialogTime(); if (date != null) { if (!isLinkedToFrame()) { - date = obData.getLatestNominalTime(); + date = monitor.getObData().getLatestNominalTime(); } - this.updateTableDlg(obData.getObHourReports(date)); - } else { - this.updateZoneTable(obData.getLatestNominalTime()); + this.updateTableDlg(monitor.getObData().getObHourReports(date)); } } } @@ -264,4 +256,18 @@ public class SnowZoneTableDlg extends ZoneTableDlg { protected void shellDisposeAction() { // Not used } + + /* + * (non-Javadoc) + * + * @see com.raytheon.uf.viz.monitor.ui.dialogs.ZoneTableDlg#getInstance() + */ + @Override + protected FSSObsMonitorConfigurationManager getMonitorAreaConfigInstance() { + if (configMgr == null || configMgr.isPopulated()) { + configMgr = new FSSObsMonitorConfigurationManager( + MonName.snow.name()); + } + return configMgr; + } } diff --git a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ObsMonitor.java b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ObsMonitor.java index 9db941610b..a1045c3bac 100755 --- a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ObsMonitor.java +++ b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ObsMonitor.java @@ -21,19 +21,18 @@ 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; import java.util.regex.Pattern; +import org.eclipse.swt.widgets.Display; + import com.raytheon.uf.common.dataplugin.PluginDataObject; import com.raytheon.uf.common.dataplugin.annotations.DataURIUtil; 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; @@ -44,7 +43,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.MonitoringArea; import com.raytheon.uf.viz.monitor.data.ObReport; import com.raytheon.uf.viz.monitor.events.IMonitorConfigurationEvent; import com.raytheon.uf.viz.monitor.events.IMonitorThresholdEvent; @@ -62,7 +61,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. - * Jan 27, 2015 3220 skorolev Removed cwa and monitorUsefrom vals.Added zones parameter to processURI.Updated code for better performance. + * Sep 04, 2014 3220 skorolev Removed cwa and monitorUsefrom vals. * * * @@ -104,15 +103,6 @@ public abstract class ObsMonitor extends Monitor { /** these are the patterns for the stations **/ protected ArrayList stationPatterns = new ArrayList(); - /** - * 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(); @@ -197,30 +187,45 @@ public abstract class ObsMonitor extends Monitor { * * @param dataURI * @param filtered - * @param areaConfig */ - public void processURI(String dataURI, AlertMessage filtered, - final FSSObsMonitorConfigurationManager areaConfig) { - List zones = areaConfig.getAreaList(); + public void processURI(String dataURI, AlertMessage filtered) { try { Map constraints = RequestConstraint .toConstraintMapping(DataURIUtil.createDataURIMap(dataURI)); FSSObsRecord[] pdos = requestFSSObs(constraints, null); if (pdos.length > 0 && pdos[0].getTimeObs() != null) { final FSSObsRecord objectToSend = pdos[0]; - if (!zones.isEmpty()) { - ObReport result = GenerateFSSObReport - .generateObReport(objectToSend); - statusHandler.handle(Priority.INFO, "New FSSrecord ===> " - + objectToSend.getDataURI()); - try { - process(result); - } catch (Exception e) { - statusHandler - .handle(Priority.PROBLEM, - "An error has occured processing the incoming messages.", - e); - } + try { + Display.getDefault().asyncExec(new Runnable() { + public void run() { + try { + // Filter removed stations + ArrayList zones = MonitoringArea + .getZoneIds(objectToSend + .getPlatformId()); + if (!zones.isEmpty()) { + ObReport result = GenerateFSSObReport + .generateObReport(objectToSend); + statusHandler + .handle(Priority.INFO, + "New FSSrecord ===> " + + objectToSend + .getDataURI()); + process(result); + } + } catch (Exception e) { + statusHandler + .handle(Priority.PROBLEM, + "An error has occured processing the incoming messages.", + e); + } + } + }); + } catch (Exception e) { + statusHandler + .handle(Priority.PROBLEM, + "An error has occured processing incoming dataURIs.", + e); } } } catch (final Exception e) { @@ -232,58 +237,56 @@ public abstract class ObsMonitor extends Monitor { /** * Process products at startup * - * @param zones + * @param monitorName * */ - public void processProductAtStartup( - FSSObsMonitorConfigurationManager areaConfig) { + public void processProductAtStartup(String monitorName) { - List 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 vals = new HashMap(); - try { - vals.put(FSSObsRecord.PLUGIN_NAME_ID, new RequestConstraint( - FSSObsRecord.PLUGIN_NAME)); + /** + * 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 vals = new HashMap(); + 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 - final ObReport result = GenerateFSSObReport + FSSObsRecord[] obsRecords = requestFSSObs(vals, selectedTimes); + for (FSSObsRecord objectToSend : obsRecords) { + // Filter removed stations + ArrayList zones = MonitoringArea + .getZoneIds(objectToSend.getPlatformId()); + if (!zones.isEmpty()) { + 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. " + monitorName); } } @@ -312,35 +315,4 @@ 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); - } } diff --git a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/data/MonitorAreaThresholds.java b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/data/MonitorAreaThresholds.java old mode 100755 new mode 100644 index 580ee6470c..b7a517d59e --- a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/data/MonitorAreaThresholds.java +++ b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/data/MonitorAreaThresholds.java @@ -20,10 +20,8 @@ package com.raytheon.uf.viz.monitor.data; 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.ObConst; import com.raytheon.uf.common.monitor.data.ObConst.ChosenAppKey; import com.raytheon.uf.common.monitor.data.ObConst.ThreatLevel; @@ -42,7 +40,6 @@ import com.raytheon.uf.common.monitor.data.ObConst.VarName; * Feb 17, 2009 1999 grichard Initial creation. * 3/16/2009 2047 grichard Add threat monitoring routines. * Dec 24, 2009 3424 zhao added getDualValuedThresholdMap and getSingleValuedThresholdMap - * Jan 12, 2015 3220 skorolev Replaced MonitoringArea with areaConfig. * * * @@ -65,6 +62,56 @@ public final class MonitorAreaThresholds { // Map containing the display thresholds private static Map zoneDisplayThresholds = new HashMap(); + /** + * This method receives an observation report and a variable name, and + * returns the threat level of that single variable. + * + * @param report + * -- the observation report + * @param varName + * -- the variable name within the report + * @return -- the threat level + */ + public static ObConst.ThreatLevel getThreatLevel(ObReport report, + VarName varName) { + + ThreatLevel threatLevel = ThreatLevel.GRAY; + ThreatLevel temp = ThreatLevel.GRAY; + float varValue = ObConst.MISSING; + + try { + varValue = getReportVarValue(report, varName); + + String zoneId = report.getZoneId(); + // TEMPORARILY USE DEFAULT ZONE ID, NAMELY, DEFAULT STATION. + zoneId = ObConst.DEFAULT_STATION_NAME; + if (report.isStationary()) { + if (MonitoringArea.listZonesToPlatform(report.getPlatformId()) + .isEmpty()) { + // use the default zone if there are no zones + temp = getZoneThreatLevel(zoneId, varName, varValue); + if (temp.ordinal() < threatLevel.ordinal()) { + threatLevel = temp; + } + } else { + for (String z : MonitoringArea.listZonesToPlatform(report + .getPlatformId())) { + temp = getZoneThreatLevel(z, varName, varValue); + if (temp.ordinal() < threatLevel.ordinal()) { + threatLevel = temp; + } + } + } + } else { + temp = getZoneThreatLevel(zoneId, varName, varValue); + } + } catch (Exception e) { + // return the default threat level + } + + return threatLevel; + } + /** * This method receives an observation report and a variable name, and * returns the threat level of that single variable. @@ -80,13 +127,12 @@ public final class MonitorAreaThresholds { ThreatLevel threatLevel = ThreatLevel.GRAY; ThreatLevel temp = ThreatLevel.GRAY; - String station = report.getPlatformId(); + try { if (report.isStationary()) { if (chosenAppKey == ChosenAppKey.SAFESEAS) { - List ssZones = FSSObsMonitorConfigurationManager - .getSsObsManager().getAreaByStationId(station); - if (ssZones.isEmpty()) { + if (MonitoringArea.listZonesToPlatform( + report.getPlatformId()).isEmpty()) { // use the default zone if there are no zones for (VarName v : VarName.values()) { if (v == VarName.TEMPERATURE @@ -104,7 +150,8 @@ public final class MonitorAreaThresholds { } } } else { - for (String z : ssZones) { + for (String z : MonitoringArea + .listZonesToPlatform(report.getPlatformId())) { for (VarName v : VarName.values()) { if (v == VarName.TEMPERATURE || v == VarName.WIND_CHILL @@ -122,9 +169,8 @@ public final class MonitorAreaThresholds { } } } else if (chosenAppKey == ChosenAppKey.SNOW) { - List snowZones = FSSObsMonitorConfigurationManager - .getSnowObsManager().getAreaByStationId(station); - if (snowZones.isEmpty()) { + if (MonitoringArea.listZonesToPlatform( + report.getPlatformId()).isEmpty()) { // use the default zone if there are no zones for (VarName v : VarName.values()) { if (v == VarName.PRIM_SWELL_HT) { @@ -139,7 +185,8 @@ public final class MonitorAreaThresholds { } } else { - for (String z : snowZones) { + for (String z : MonitoringArea + .listZonesToPlatform(report.getPlatformId())) { for (VarName v : VarName.values()) { if (v == VarName.PRIM_SWELL_HT) { break; @@ -152,10 +199,9 @@ public final class MonitorAreaThresholds { } } } - } else {// chosenAppKey = FOG - List fogZones = FSSObsMonitorConfigurationManager - .getFogObsManager().getAreaByStationId(station); - if (fogZones.isEmpty()) { + } else { + if (MonitoringArea.listZonesToPlatform( + report.getPlatformId()).isEmpty()) { // use the default zone if there are no zones temp = getZoneThreatLevel(ObConst.DEFAULT_STATION_NAME, VarName.PRES_WX, report.getPresentWx()); @@ -163,21 +209,20 @@ public final class MonitorAreaThresholds { threatLevel = temp; } temp = getZoneThreatLevel(ObConst.DEFAULT_STATION_NAME, - VarName.VISIBILITY, - getReportVarValue(report, VarName.VISIBILITY)); + VarName.VISIBILITY, getReportVarValue(report, + VarName.VISIBILITY)); if (temp.ordinal() < threatLevel.ordinal()) { threatLevel = temp; } } else { - for (String z : fogZones) { + for (String z : MonitoringArea + .listZonesToPlatform(report.getPlatformId())) { temp = getZoneThreatLevel(z, VarName.PRES_WX, report.getPresentWx()); if (temp.ordinal() < threatLevel.ordinal()) { threatLevel = temp; } - temp = getZoneThreatLevel( - z, - VarName.VISIBILITY, + temp = getZoneThreatLevel(z, VarName.VISIBILITY, getReportVarValue(report, VarName.VISIBILITY)); if (temp.ordinal() < threatLevel.ordinal()) { @@ -186,7 +231,6 @@ public final class MonitorAreaThresholds { } } } - // report is not Stationary } else { if (chosenAppKey == ChosenAppKey.SAFESEAS) { String zoneId = report.getZoneId(); @@ -199,8 +243,8 @@ public final class MonitorAreaThresholds { } else if (v == VarName.STATIONARY) { break; } - temp = getZoneThreatLevel(zoneId, v, - getReportVarValue(report, v)); + temp = getZoneThreatLevel(zoneId, v, getReportVarValue( + report, v)); if (temp.ordinal() < threatLevel.ordinal()) { threatLevel = temp; } @@ -213,13 +257,13 @@ public final class MonitorAreaThresholds { if (v == VarName.PRIM_SWELL_HT) { break; } - temp = getZoneThreatLevel(zoneId, v, - getReportVarValue(report, v)); + temp = getZoneThreatLevel(zoneId, v, getReportVarValue( + report, v)); if (temp.ordinal() < threatLevel.ordinal()) { threatLevel = temp; } } - } else {// chosenAppKey = FOG + } else { String zoneId = report.getZoneId(); // TEMPORARILY USE DEFAULT ZONE ID, NAMELY, DEFAULT STATION. zoneId = ObConst.DEFAULT_STATION_NAME; @@ -561,44 +605,32 @@ public final class MonitorAreaThresholds { } return result; } - + /** * [Dec 24, 2009, zhao] - * - * @param zone - * the zone ID - * @param varName - * enumerated-type variable name - * @return single-valued threshold map, or null if the variable name is - * invalid or if the map contains no mapping for the key + * @param zone the zone ID + * @param varName enumerated-type variable name + * @return single-valued threshold map, or null if the variable + * name is invalid or if the map contains no mapping for the key */ - public static Map getSingleValuedThresholdMap( - String zone, ObConst.VarName varName) { - if (varName == VarName.WIND_DIR || varName == VarName.PRIM_SWELL_DIR - || varName == VarName.SEC_SWELL_DIR) { - return null; - } - return zoneMonitorThresholds.get(zone).getSingleValuedThresholdMap( - varName); + public static Map getSingleValuedThresholdMap(String zone, ObConst.VarName varName) { + if (varName == VarName.WIND_DIR || varName == VarName.PRIM_SWELL_DIR || varName == VarName.SEC_SWELL_DIR ) { + return null; + } + return zoneMonitorThresholds.get(zone).getSingleValuedThresholdMap(varName); } - + /** * [Dec 24, 2009, zhao] - * - * @param zone - * the zone ID - * @param varName - * enumerated-type variable name - * @return duel-valued threshold map, or null if the variable name is - * invalid or if the map contains no mapping for the key + * @param zone the zone ID + * @param varName enumerated-type variable name + * @return duel-valued threshold map, or null if the variable + * name is invalid or if the map contains no mapping for the key */ - public static Map getDualValuedThresholdMap( - String zone, ObConst.VarName varName) { - if (varName != VarName.WIND_DIR || varName != VarName.PRIM_SWELL_DIR - || varName != VarName.SEC_SWELL_DIR) { - return null; - } - return zoneMonitorThresholds.get(zone).getDualValuedThresholdMap( - varName); + public static Map getDualValuedThresholdMap(String zone, ObConst.VarName varName) { + if (varName != VarName.WIND_DIR || varName != VarName.PRIM_SWELL_DIR || varName != VarName.SEC_SWELL_DIR ) { + return null; + } + return zoneMonitorThresholds.get(zone).getDualValuedThresholdMap(varName); } } diff --git a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/data/ObHourReports.java b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/data/ObHourReports.java old mode 100644 new mode 100755 index 580b4ee819..d4a4ff156f --- a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/data/ObHourReports.java +++ b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/data/ObHourReports.java @@ -23,8 +23,9 @@ import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Set; +import java.util.concurrent.CopyOnWriteArrayList; -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; @@ -40,14 +41,12 @@ import com.raytheon.uf.viz.monitor.thresholds.AbstractThresholdMgr; *
  * 
  * SOFTWARE HISTORY
- * Date           Ticket#    Engineer   Description
+ * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Dec. 1, 2009  3424       zhao       Initial creation.
  * 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 27, 2015  3220       skorolev   Replaced MonitoringArea with areaConfig.Changed updateZones method.
+ * Oct.31  2012  1297       skorolev   Cleaned code.
+ * Sep 04  2014  3220       skorolev   Added updateZones method.
  * 
  * 
* @@ -74,9 +73,6 @@ public class ObHourReports { */ private Map hourReports; - /** - * current threshold manager - */ private AbstractThresholdMgr thresholdMgr; /** @@ -90,8 +86,9 @@ public class ObHourReports { this.appName = appName; this.thresholdMgr = thresholdMgr; hourReports = new HashMap(); - List zones = thresholdMgr.getAreaConfigMgr().getAreaList(); - for (String zone : zones) { + Map> zoneStationMap = MonitoringArea + .getPlatformMap(); + for (String zone : zoneStationMap.keySet()) { hourReports.put(zone, new ObZoneHourReports(nominalTime, zone, appName, thresholdMgr)); } @@ -104,25 +101,28 @@ public class ObHourReports { */ public void addReport(ObReport report) { String station = report.getPlatformId(); - List zones = thresholdMgr.getAreaConfigMgr() - .getAreaByStationId(station); + List zones = MonitoringArea.getZoneIds(station); if (zones.size() == 0) { statusHandler - .info("Error: station: " + .error("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"); + } } /** - * Gets HourReports - * * @return hourReports */ public Map getHourReports() { @@ -186,8 +186,8 @@ public class ObHourReports { } /** - * Gets ObZoneHourReports Returns the ObZoneHourReports object of a - * caller-specified zone. If such object not available, returns null. + * Returns the ObZoneHourReports object of a caller-specified zone. If such + * object not available, returns null. * * @param zone * @return hour reports @@ -200,8 +200,6 @@ public class ObHourReports { } /** - * Gets NominalTime - * * @return nominalTime */ public Date getNominalTime() { @@ -209,8 +207,6 @@ public class ObHourReports { } /** - * Gets AppName - * * @return appName */ public CommonConfig.AppName getAppName() { @@ -219,31 +215,32 @@ public class ObHourReports { /** * Updates zones in the Hour Reports - * - * @param configMgr */ - public void updateZones(FSSObsMonitorConfigurationManager configMgr) { - // Updated list of zones - List updtZones = configMgr.getAreaList(); - // remove zones - hourReports.keySet().retainAll(updtZones); - // add zones - for (String zone : updtZones) { - if (!hourReports.keySet().contains(zone)) { - hourReports.put(zone, new ObZoneHourReports(nominalTime, zone, - appName, thresholdMgr)); + public void updateZones() { + Map> zoneStationMap = MonitoringArea + .getPlatformMap(); + // remove zones or stations + List hourZones = new CopyOnWriteArrayList( + hourReports.keySet()); + for (String zone : hourZones) { + if (hourReports.keySet().contains(zone)) { + List stations = new CopyOnWriteArrayList( + hourReports.get(zone).getZoneHourReports().keySet()); + for (String stn : stations) { + if (!zoneStationMap.get(zone).contains(stn)) { + hourReports.get(zone).getZoneHourReports().remove(stn); + } + } + if (!zoneStationMap.keySet().contains(zone)) { + hourReports.remove(zone); + } } } - // add and(or) remove stations - for (String zone : updtZones) { - // Updated list of stations in this zone - List updtStns = thresholdMgr.getAreaConfigMgr() - .getAreaStations(zone); - // remove stations - hourReports.get(zone).getZoneHourReports().keySet() - .retainAll(updtStns); - // add stations - for (String stn : updtStns) { + // add zones + for (String zone : zoneStationMap.keySet()) { + List stations = new CopyOnWriteArrayList( + zoneStationMap.get(zone)); + for (String stn : stations) { if (!hourReports.get(zone).getZoneHourReports() .containsKey(stn)) { hourReports @@ -254,8 +251,10 @@ public class ObHourReports { stn, appName, thresholdMgr)); } } - // update hourReports for current zone - hourReports.get(zone).getZoneHourReports(); + if (!hourReports.containsKey(zone)) { + hourReports.put(zone, new ObZoneHourReports(nominalTime, zone, + appName, thresholdMgr)); + } } } } diff --git a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/data/ObMultiHrsReports.java b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/data/ObMultiHrsReports.java index 655df52e99..9ab69e8dc1 100644 --- a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/data/ObMultiHrsReports.java +++ b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/data/ObMultiHrsReports.java @@ -24,14 +24,11 @@ import java.util.Calendar; import java.util.Date; import java.util.HashMap; import java.util.Iterator; -import java.util.List; 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; import com.raytheon.uf.common.monitor.data.CommonConfig.AppName; import com.raytheon.uf.common.monitor.data.ObConst; @@ -54,11 +51,9 @@ 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 - * Jan 27, 2015 3220 skorolev Updated getStationTableData method.Replaced MonitoringArea with cfgMgr. - * Added multiHrsTabData - Table data cache. - * Feb 04, 2015 3841 skorolev Corrected getEmptyZoneTableData method. - * + * Jan. 29, 2013 15654 zhao add Wind Chill calculation for SNOW + * Sep 04, 2014 3220 skorolev Updated getStationTableData method. + * * * * @author zhao @@ -83,14 +78,9 @@ public class ObMultiHrsReports { private CommonConfig.AppName appName; /** - * FSSObs records cache. Key is nominal time, value is ObHourReports object + * key is nominal time, value is ObHourReports object */ - private SortedMap multiHrsReports = new TreeMap(); - - /** - * Monitor Table data cache. Key is nominal time, value is TableData - */ - private ConcurrentHashMap multiHrsTabData = new ConcurrentHashMap(); + private SortedMap multiHrsReports; /** * The maximum number of most recent hours within which observation reports @@ -107,10 +97,29 @@ public class ObMultiHrsReports { */ public ObMultiHrsReports(CommonConfig.AppName appName) { this.appName = appName; + multiHrsReports = new TreeMap(); 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); + } } /** @@ -120,6 +129,8 @@ 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 @@ -140,54 +151,50 @@ public class ObMultiHrsReports { /** * DR15654: set Wind Chill for SNOW */ - if (appName == AppName.SNOW) { - if (report.getTemperature() != ObConst.MISSING - && report.getWindSpeed() != ObConst.MISSING) { - report.setWindChill(calcWindChill(report.getTemperature(), - report.getWindSpeed())); + if ( appName == AppName.SNOW ) { + if ( report.getTemperature() != ObConst.MISSING && report.getWindSpeed() != ObConst.MISSING ) { + report.setWindChill(calcWindChill( report.getTemperature(), report.getWindSpeed() )); } + } - ObHourReports obHourReports; - // new nominal time; create a new ObHourReports object - if (multiHrsReports.isEmpty() - || !multiHrsReports.containsKey(nominalTime)) { - obHourReports = new ObHourReports(nominalTime, appName, - thresholdMgr); + + if (multiHrsReports.containsKey(nominalTime)) { + multiHrsReports.get(nominalTime).addReport(report); } else { - // the map is full; delete the oldest entry + // new nominal time; create a new ObHourReports object if (multiHrsReports.size() >= maxFrames) { + // the map is full; delete the oldest entry multiHrsReports.remove(multiHrsReports.firstKey()); } - // update multiHrsReports with new data - obHourReports = multiHrsReports.get(nominalTime); + ObHourReports obHourReports = new ObHourReports(nominalTime, + appName, thresholdMgr); + obHourReports.addReport(report); + multiHrsReports.put(nominalTime, obHourReports); } - obHourReports.addReport(report); - // update data cache - multiHrsReports.put(nominalTime, obHourReports); } - /** - * DR 15654: Wind Chill calculation formula based on - * http://www.nws.noaa.gov/om/windchill/ as of Jan. 29, 2013 - * - * @param temp - * in degree F - * @param windSpd - * in knots - * @return wind chill in degree F - */ - private float calcWindChill(float temp, float windSpd) { - if (temp > 50.0 || windSpd < 3.0) { - return ObConst.MISSING; - } - /** - * 1 knots = 1.15078 mph - */ - float spd = (float) Math.pow(1.15078 * windSpd, 0.16); - return 35.74f + 0.6215f * temp - 35.75f * spd + 0.4275f * temp * spd; - } + /** + * DR 15654: + * Wind Chill calculation formula based on + * http://www.nws.noaa.gov/om/windchill/ + * as of Jan. 29, 2013 + * + * @param temperature in degree F + * @param windSpeed in knots + * @return wind chill in degree F + */ + private float calcWindChill(float temp, float windSpd) { + if ( temp > 50.0 || windSpd < 3.0 ) { + return ObConst.MISSING; + } + /** + * 1 knots = 1.15078 mph + */ + float spd = (float) Math.pow(1.15078*windSpd, 0.16); + return 35.74f + 0.6215f*temp - 35.75f*spd + 0.4275f*temp*spd; + } - /** + /** * Returns a zone TableData object of the latest nominal time. If no data * available (the map is empty), returns an empty zone TableData object * (table cells filled with "N/A"). @@ -204,31 +211,26 @@ 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"). Updates multiHrsTabData table cache. + * cells filled with "N/A"). * * @param nominalTime * @return */ public TableData getZoneTableData(Date nominalTime) { - TableData tabData = null; if (nominalTime == null || !multiHrsReports.containsKey(nominalTime)) { return getEmptyZoneTableData(); } if (appName == AppName.FOG) { - tabData = this.getObHourReports(nominalTime).getFogZoneTableData( + return this.getObHourReports(nominalTime).getFogZoneTableData( fogAlgCellType); - } else if (appName == AppName.SAFESEAS) { - tabData = this.getObHourReports(nominalTime).getSSZoneTableData( + } + if (appName == AppName.SAFESEAS) { + return this.getObHourReports(nominalTime).getSSZoneTableData( fogAlgCellType); + } - } else { - tabData = this.getObHourReports(nominalTime).getZoneTableData(); - } - // update table data cache - if (multiHrsTabData.replace(nominalTime, tabData) == null) { - multiHrsTabData.put(nominalTime, tabData); - } - return tabData; + return this.getObHourReports(nominalTime).getZoneTableData(); + // return multiHrsReports.get(nominalTime).getZoneTableData(); } /** @@ -241,27 +243,15 @@ public class ObMultiHrsReports { .getSystemTime().getTime()); ObHourReports hourReports = new ObHourReports(nominalTime, appName, thresholdMgr); - TableData tabData = null; if (appName == AppName.FOG) { - tabData = hourReports.getFogZoneTableData(fogAlgCellType); - } else { - tabData = hourReports.getZoneTableData(); + return hourReports.getFogZoneTableData(fogAlgCellType); } - // update data cache - multiHrsReports.put(nominalTime, hourReports); - // update cache with empty table data - if (multiHrsTabData.replace(nominalTime, tabData) == null) { - multiHrsTabData.put(nominalTime, tabData); - } - return tabData; + return hourReports.getZoneTableData(); } /** * Returns the station TableData object for the latest nominal time. If no * data available, an empty/default station TableData object is returned - * - * @param zone - * @return */ public TableData getStationTableData(String zone) { if (multiHrsReports.isEmpty()) { @@ -274,13 +264,9 @@ public class ObMultiHrsReports { * Returns a station TableData object for a caller-specified nominal-time * and zone ID. If no data available, an empty/default station TableData * object is returned. - * - * @param nominalTime - * @param zone - * @return */ public TableData getStationTableData(Date nominalTime, String zone) { - if (zone.equals("")) { + if(zone.equals("")){ return this.getEmptyZoneTableData(); } if (nominalTime == null) { @@ -310,7 +296,6 @@ public class ObMultiHrsReports { * @param zone * @param Station * @param varName - * @param productName * @return ObTrendDataSet object, or null if no data available */ public ObTrendDataSet getTrendDataSet(String zone, String station, @@ -388,15 +373,12 @@ public class ObMultiHrsReports { } /** - * Gets Histogram Table Data * - * @param zone - * : current zone * @param station - * : station ID + * station ID * @param obsType - * : ObsHistType - * @return + * ObsHistType + * @return TableData object for obs history table */ public TableData getHistTableData(String zone, String station, ObsHistType obsType) { @@ -485,46 +467,41 @@ public class ObMultiHrsReports { } /** - * Gets table cache + * Returns a SortedMap object * - * @return - */ - public ConcurrentHashMap getMultiHrsTabData() { - return multiHrsTabData; - } - - /** - * Sets table cache - * - * @param multiHrsTabData - */ - public void setMultiHrsTabData( - ConcurrentHashMap multiHrsTabData) { - this.multiHrsTabData = multiHrsTabData; - } - - /** - * Gets data cache - * - * @return SortedMap object + * @return multiHrsReports */ public SortedMap getMultiHrsReports() { return multiHrsReports; } /** - * Sets data cache + * Returns a SortedMap object (key is nominal time, value is zone TableData + * object) * - * @param multiHrsReports + * @return */ - public void setMultiHrsReports( - SortedMap multiHrsReports) { - this.multiHrsReports = multiHrsReports; + public SortedMap getMultiHrsTableData() { + SortedMap multiHrsTblData = new TreeMap(); + 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; } /** - * Gets the Latest NominalTime Returns the latest nominal time if the map is - * not empty; otherwise, returns the nominal time of the present date-time + * Returns the latest nominal time if the map is not empty; otherwise, + * returns the nominal time of the present date-time * * @return */ @@ -540,38 +517,31 @@ public class ObMultiHrsReports { } /** - * Gets Nominal Times + * Returns a set of nominal times * - * @return a set of nominal times + * @return */ public Set getNominalTimes() { return multiHrsReports.keySet(); } /** - * Gets ObHourReports Returns the ObHourReports object of the latest nominal - * time. If no data available, returns an empty ObHourReports object. + * Returns the ObHourReports object of the latest nominal time. If no data + * available, returns an empty ObHourReports object. * * @return */ public ObHourReports getObHourReports() { if (multiHrsReports.isEmpty()) { - 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 new ObHourReports(TableUtil.getNominalTime(SimulatedTime + .getSystemTime().getTime()), appName, thresholdMgr); } return multiHrsReports.get(multiHrsReports.lastKey()); } /** - * Gets ObHourReports Returns an ObHourReports object of a caller-specified - * nominal time. If no data available, returns an empty ObHourReports - * object. + * Returns an ObHourReports object of a caller-specified nominal time. If no + * data available, returns an empty ObHourReports object. * * @param nominalTime * @return @@ -604,7 +574,6 @@ public class ObMultiHrsReports { } /** - * Gets Threshold Manager * * @return the threshold manager */ @@ -622,7 +591,6 @@ public class ObMultiHrsReports { } /** - * Gets map of types for ALG cell * * @return fogAlgCellType */ @@ -635,26 +603,11 @@ public class ObMultiHrsReports { */ private void initFogAlgCellType() { fogAlgCellType = new HashMap(); - FSSObsMonitorConfigurationManager cfgMgr = null; - if (appName.equals(CommonConfig.AppName.FOG)) { - cfgMgr = FSSObsMonitorConfigurationManager.getFogObsManager(); - } else if (appName.equals(CommonConfig.AppName.SAFESEAS)) { - cfgMgr = FSSObsMonitorConfigurationManager.getSsObsManager(); - } - List zones = cfgMgr.getAreaList(); + Set zones = MonitoringArea.getPlatformMap().keySet(); Iterator itr = zones.iterator(); while (itr.hasNext()) { fogAlgCellType.put(itr.next(), CellType.NotAvailable); } setFogAlgCellType(fogAlgCellType); } - - /** - * Updates table cache - */ - public void updateTableCache() { - for (Date time : multiHrsReports.keySet()) { - getZoneTableData(time); - } - } } diff --git a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/data/ObZoneHourReports.java b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/data/ObZoneHourReports.java old mode 100755 new mode 100644 index 51a117f059..2eab2d8cc6 --- a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/data/ObZoneHourReports.java +++ b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/data/ObZoneHourReports.java @@ -21,22 +21,18 @@ package com.raytheon.uf.viz.monitor.data; import java.util.Date; import java.util.HashMap; -import java.util.List; import com.raytheon.uf.common.monitor.data.CommonConfig; import com.raytheon.uf.common.monitor.data.ObConst; import com.raytheon.uf.common.monitor.data.ObConst.DataUsageKey; -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.monitor.config.CommonTableConfig.CellType; import com.raytheon.uf.viz.monitor.thresholds.AbstractThresholdMgr; import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants; /** - * This class is a container of ObStnHourReports objects for caller-specified - * zone and nominal date-time (this class corresponds to the RcZoneHourReports - * c++ class in AWIPS 1) + * This class is a container of ObStnHourReports objects for + * caller-specified zone and nominal date-time + * (this class corresponds to the RcZoneHourReports c++ class in AWIPS 1) * *
  * 
@@ -44,8 +40,7 @@ import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants;
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Dec. 1, 2009  3424       zhao       Initial creation.
- * Jan 25, 2010  4281       zhao       Modified updateWorstValuesFog method.
- * Jan 08, 2015  3220       skorolev   Replaced MonitoringArea with areaConfig.
+ * Jan 25, 2010  4281       zhao       Modified updateWorstValuesFog method 
  * 
  * 
* @@ -54,645 +49,374 @@ import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants; */ public class ObZoneHourReports { - - private final IUFStatusHandler statusHandler = UFStatus - .getHandler(ObZoneHourReports.class); - - /** the nominal time and zone ID of this ObZoneHourReports object */ - private Date nominalTime; - - /** Monitoring area */ - private String zone; - - /** Thresholds manager */ - private AbstractThresholdMgr thresholdMgr; - - /** application name (snow, fog, safeseas, etc) */ - private CommonConfig.AppName appName; - - /** key is station id, value is ObStnHourReports object */ - private HashMap zoneHourReports; - - /** - * this object stores worst values of the observation variables reported - * during this nominal hour for this zone - */ - private ObReport worstValues; - - /** - * Constructor - * - * @param nominalTime - * @param zone - * @param appName - * @param thresholdMgr - */ - public ObZoneHourReports(Date nominalTime, String zone, - CommonConfig.AppName appName, AbstractThresholdMgr thresholdMgr) { - this.nominalTime = nominalTime; - this.zone = zone; - this.appName = appName; - this.thresholdMgr = thresholdMgr; - zoneHourReports = new HashMap(); - List stations = thresholdMgr.getAreaConfigMgr() - .getAreaStations(zone); - for (String station : stations) { - zoneHourReports.put(station, new ObStnHourReports(nominalTime, - zone, station, appName, thresholdMgr)); - } - InitWorstValues(); - } - - /** - * Initiates the worst values. - */ - private void InitWorstValues() { - worstValues = new ObReport(); - worstValues.setZoneId(zone); - // the ObReport's init() sets "zone id" to - // "" !!! - } - - /** - * The worst direction - * - * @param xmlKeyFrom - * : XML key of a directional obs from variable - * @param xmlKeyTo - * : XML key of a directional obs to variable - * @param dirCurrent - * : the current worst value - * @param dirNew - * : the value contained in a new obs report - * @return : the value of worse threat level - */ - private float worseDirection(String xmlKeyFrom, String xmlKeyTo, - float dirCurrent, float dirNew) { - /** - * decide which one of the two wind directions is worse by comparing - * their corresponding threat levels - */ - if (dirNew == ObConst.MISSING) { - return dirCurrent; - } - - if (dirCurrent == ObConst.MISSING) { - return dirNew; - } - - CellType cellTypeCurrent = thresholdMgr - .getDirectionalThresholdValueCellType(DataUsageKey.DISPLAY, - zone, xmlKeyFrom, xmlKeyTo, dirCurrent); - - if (cellTypeCurrent == CellType.R) { - /** - * already worst threat level - */ - return dirCurrent; - } - - CellType cellTypeNew = thresholdMgr - .getDirectionalThresholdValueCellType(DataUsageKey.DISPLAY, - zone, xmlKeyFrom, xmlKeyTo, dirNew); - - /** - * CellType is enumerated in the order R, Y, G, N/A, ... - */ - if (cellTypeNew.compareTo(cellTypeCurrent) < 0) { - /** - * dirNew corresponds to a higher threat level - */ - return dirNew; - } - - return dirCurrent; - } - - /** - * Adds report - * - * @param report - */ - public void addReport(ObReport report) { - String station = report.getPlatformId(); - if (zoneHourReports.containsKey(station)) { - zoneHourReports.get(station).addReport(report); - } else { - statusHandler.handle(Priority.ERROR, "Unrecognized station ID: " - + station + " (app = " + appName + ")"); - } - } - - /** - * Gets StationTableData - * - * @return - */ - public TableData getStationTableData() { - TableData tblData = new TableData(appName); - for (String station : zoneHourReports.keySet()) { - tblData.addTableRowData(this.getObStnHourReports(station) - .getStationTableRowData()); - } - return tblData; - } - - /** - * Returns a row of a zone table based on all reports within the nominal - * hour for the specified zone. If no data available, an empty/default row - * of table data is returned. - * - * @return - */ - public TableRowData getZoneTableRowData() { - TableRowData tblRowData = null; - - if (appName == CommonConfig.AppName.FOG) { - updateFogWorstValues(); - tblRowData = TableUtil.getFogTableRowData(zone, zone, worstValues, - thresholdMgr, CellType.NotAvailable); - } else if (appName == CommonConfig.AppName.SAFESEAS) { - updateSafeseasWorstValues(); - tblRowData = TableUtil.getSafeseasTableRowData(zone, zone, - worstValues, thresholdMgr, CellType.NotAvailable); - } else if (appName == CommonConfig.AppName.SNOW) { - updateSnowWorstValues(); - tblRowData = TableUtil.getSnowTableRowData(zone, zone, worstValues, - thresholdMgr); - } else { - System.out.println("unrecognized appName: " + appName); - } - return tblRowData; - } - - /** - * Gets Fog Zone Table Row Data - * - * @param algCellType - * @return - */ - public TableRowData getFogZoneTableRowData(CellType algCellType) { - updateFogWorstValues(); - return TableUtil.getFogTableRowData(zone, zone, worstValues, - thresholdMgr, algCellType); - } - - /** - * Gets SAFESEAS Zone Table Row Data - * - * @param algCellType - * : Type of ALG cell in the table - * @return - */ - public TableRowData getSSZoneTableRowData(CellType algCellType) { - updateSafeseasWorstValues(); - return TableUtil.getSafeseasTableRowData(zone, zone, worstValues, - thresholdMgr, algCellType); - } - - /** - * Updates Fog Worst Values - */ - private void updateFogWorstValues() { - if (zoneHourReports.isEmpty()) { - return; - } - InitWorstValues(); - for (String station : zoneHourReports.keySet()) { - ObReport report = zoneHourReports.get(station).getLatestObReport(); - if (report != null) { - if (report.getVisibility() != ObConst.MISSING) { - worstValues - .setVisibility(worstValues.getVisibility() == ObConst.MISSING ? report - .getVisibility() : Math.min( - worstValues.getVisibility(), - report.getVisibility())); - } - - worstValues.setPresentWx(worstValues.getPresentWx() - + report.getPresentWx()); - - if (report.getCeiling() != ObConst.MISSING) { - worstValues - .setCeiling(worstValues.getCeiling() == ObConst.MISSING ? report - .getCeiling() : Math.min( - worstValues.getCeiling(), - report.getCeiling())); - } - - if (report.getWindDir() != ObConst.MISSING) { - worstValues - .setWindDir(worseDirection( - MonitorConfigConstants.FogDisplay.FOG_DISP_WIND_DIR_FROM - .getXmlKey(), - MonitorConfigConstants.FogDisplay.FOG_DISP_WIND_DIR_TO - .getXmlKey(), worstValues - .getWindDir(), report.getWindDir())); - } - - if (report.getWindSpeed() != ObConst.MISSING) { - worstValues - .setWindSpeed(worstValues.getWindSpeed() == ObConst.MISSING ? report - .getWindSpeed() : Math.max( - worstValues.getWindSpeed(), - report.getWindSpeed())); - } - - if (report.getMaxWindSpeed() != ObConst.MISSING) { - worstValues - .setMaxWindSpeed(worstValues.getMaxWindSpeed() == ObConst.MISSING ? report - .getMaxWindSpeed() : Math.max( - worstValues.getMaxWindSpeed(), - report.getMaxWindSpeed())); - } - - if (report.getWindGust() != ObConst.MISSING) { - worstValues - .setWindGust(worstValues.getWindGust() == ObConst.MISSING ? report - .getWindGust() : Math.max( - worstValues.getWindGust(), - report.getWindGust())); - } - - if (report.getTemperature() != ObConst.MISSING) { - worstValues - .setTemperature(worstValues.getTemperature() == ObConst.MISSING ? report - .getTemperature() : Math.max( - worstValues.getTemperature(), - report.getTemperature())); - } - - if (report.getDewpoint() != ObConst.MISSING) { - worstValues - .setDewpoint(worstValues.getDewpoint() == ObConst.MISSING ? report - .getDewpoint() : Math.max( - worstValues.getDewpoint(), - report.getDewpoint())); - } - - if (report.getDewpointDepr() != ObConst.MISSING) { - worstValues - .setDewpointDepr(worstValues.getDewpointDepr() == ObConst.MISSING ? report - .getDewpointDepr() : Math.min( - worstValues.getDewpointDepr(), - report.getDewpointDepr())); - } - - if (report.getRelativeHumidity() != ObConst.MISSING) { - worstValues.setRelativeHumidity(worstValues - .getRelativeHumidity() == ObConst.MISSING ? report - .getRelativeHumidity() : Math.max( - worstValues.getRelativeHumidity(), - report.getRelativeHumidity())); - } - } - } - } - - /** - * Updates SNOW Worst Values - */ - private void updateSnowWorstValues() { - if (zoneHourReports.isEmpty()) { - return; - } - InitWorstValues(); - for (String station : zoneHourReports.keySet()) { - ObReport report = zoneHourReports.get(station).getLatestObReport(); - if (report != null) { - worstValues.setPresentWx(worstValues.getPresentWx() - + report.getPresentWx()); - - if (report.getWindDir() != ObConst.MISSING) { - worstValues - .setWindDir(worseDirection( - MonitorConfigConstants.SnowDisplay.SNOW_DISP_WIND_DIR_FROM - .getXmlKey(), - MonitorConfigConstants.SnowDisplay.SNOW_DISP_WIND_DIR_TO - .getXmlKey(), worstValues - .getWindDir(), report.getWindDir())); - } - - if (report.getWindSpeed() != ObConst.MISSING) { - worstValues - .setWindSpeed(worstValues.getWindSpeed() == ObConst.MISSING ? report - .getWindSpeed() : Math.max( - worstValues.getWindSpeed(), - report.getWindSpeed())); - } - - if (report.getMaxWindSpeed() != ObConst.MISSING) { - worstValues - .setMaxWindSpeed(worstValues.getMaxWindSpeed() == ObConst.MISSING ? report - .getMaxWindSpeed() : Math.max( - worstValues.getMaxWindSpeed(), - report.getMaxWindSpeed())); - } - - if (report.getWindGust() != ObConst.MISSING) { - worstValues - .setWindGust(worstValues.getWindGust() == ObConst.MISSING ? report - .getWindGust() : Math.max( - worstValues.getWindGust(), - report.getWindGust())); - } - - if (report.getTemperature() != ObConst.MISSING) { - worstValues - .setTemperature(worstValues.getTemperature() == ObConst.MISSING ? report - .getTemperature() : Math.min( - worstValues.getTemperature(), - report.getTemperature())); - } - - if (report.getDewpoint() != ObConst.MISSING) { - worstValues - .setDewpoint(worstValues.getDewpoint() == ObConst.MISSING ? report - .getDewpoint() : Math.min( - worstValues.getDewpoint(), - report.getDewpoint())); - } - - if (report.getVisibility() != ObConst.MISSING) { - worstValues - .setVisibility(worstValues.getVisibility() == ObConst.MISSING ? report - .getVisibility() : Math.min( - worstValues.getVisibility(), - report.getVisibility())); - } - - if (report.getSeaLevelPress() != ObConst.MISSING) { - worstValues - .setSeaLevelPress(worstValues.getSeaLevelPress() == ObConst.MISSING ? report - .getSeaLevelPress() : Math.min( - worstValues.getSeaLevelPress(), - report.getSeaLevelPress())); - } - - if (report.getWindChill() != ObConst.MISSING) { - worstValues - .setWindChill(worstValues.getWindChill() == ObConst.MISSING ? report - .getWindChill() : Math.min( - worstValues.getWindChill(), - report.getWindChill())); - } - - if (report.getFrostbiteTime() != ObConst.MISSING) { - worstValues - .setFrostbiteTime(worstValues.getFrostbiteTime() == ObConst.MISSING ? report - .getFrostbiteTime() : Math.min( - worstValues.getFrostbiteTime(), - report.getFrostbiteTime())); - } - - if (report.getHourlyPrecip() != ObConst.MISSING) { - worstValues - .setHourlyPrecip(worstValues.getHourlyPrecip() == ObConst.MISSING ? report - .getHourlyPrecip() : Math.max( - worstValues.getHourlyPrecip(), - report.getHourlyPrecip())); - } - - if (report.getSnowDepth() != ObConst.MISSING) { - worstValues - .setSnowDepth(worstValues.getSnowDepth() == ObConst.MISSING ? report - .getSnowDepth() : Math.max( - worstValues.getSnowDepth(), - report.getSnowDepth())); - } - - if (report.getSnincrHourly() != ObConst.MISSING) { - worstValues - .setSnincrHourly(worstValues.getSnincrHourly() == ObConst.MISSING ? report - .getSnincrHourly() : Math.max( - worstValues.getSnincrHourly(), - report.getSnincrHourly())); - } - - if (report.getSnincrTotal() != ObConst.MISSING) { - worstValues - .setSnincrTotal(worstValues.getSnincrTotal() == ObConst.MISSING ? report - .getSnincrTotal() : Math.max( - worstValues.getSnincrTotal(), - report.getSnincrTotal())); - } - } - } - } - - /** - * Updates SAFESEAS Worst Values - */ - private void updateSafeseasWorstValues() { - if (zoneHourReports.isEmpty()) { - return; - } - InitWorstValues(); - for (String station : zoneHourReports.keySet()) { - ObReport report = zoneHourReports.get(station).getLatestObReport(); - if (report != null) { - if (report.getWindDir() != ObConst.MISSING) { - worstValues - .setWindDir(worstValues.getWindDir() == ObConst.MISSING ? report - .getWindDir() - : worseDirection( - MonitorConfigConstants.SafeSeasDisplay.SS_DISP_WIND_DIR_FROM - .getXmlKey(), - MonitorConfigConstants.SafeSeasDisplay.SS_DISP_WIND_DIR_TO - .getXmlKey(), worstValues - .getWindDir(), report - .getWindDir())); - } - - if (report.getWindSpeed() != ObConst.MISSING) { - worstValues - .setWindSpeed(worstValues.getWindSpeed() == ObConst.MISSING ? report - .getWindSpeed() : Math.max( - worstValues.getWindSpeed(), - report.getWindSpeed())); - } - - if (report.getMaxWindSpeed() != ObConst.MISSING) { - worstValues - .setMaxWindSpeed(worstValues.getMaxWindSpeed() == ObConst.MISSING ? report - .getMaxWindSpeed() : Math.max( - worstValues.getMaxWindSpeed(), - report.getMaxWindSpeed())); - } - - if (report.getWindGust() != ObConst.MISSING) { - worstValues - .setWindGust(worstValues.getWindGust() == ObConst.MISSING ? report - .getWindGust() : Math.max( - worstValues.getWindGust(), - report.getWindGust())); - } - - if (report.getVisibility() != ObConst.MISSING) { - worstValues - .setVisibility(worstValues.getVisibility() == ObConst.MISSING ? report - .getVisibility() : Math.min( - worstValues.getVisibility(), - report.getVisibility())); - } - - if (report.getTemperature() != ObConst.MISSING) { - worstValues - .setTemperature(worstValues.getTemperature() == ObConst.MISSING ? report - .getTemperature() : Math.max( - worstValues.getTemperature(), - report.getTemperature())); - } - - if (report.getDewpoint() != ObConst.MISSING) { - worstValues - .setDewpoint(worstValues.getDewpoint() == ObConst.MISSING ? report - .getDewpoint() : Math.max( - worstValues.getDewpoint(), - report.getDewpoint())); - } - - if (report.getSeaLevelPress() != ObConst.MISSING) { - worstValues - .setSeaLevelPress(worstValues.getSeaLevelPress() == ObConst.MISSING ? report - .getSeaLevelPress() : Math.min( - worstValues.getSeaLevelPress(), - report.getSeaLevelPress())); - } - - if (report.getSeaSurfaceTemp() != ObConst.MISSING) { - worstValues.setSeaSurfaceTemp(worstValues - .getSeaSurfaceTemp() == ObConst.MISSING ? report - .getSeaSurfaceTemp() : Math.max( - worstValues.getSeaSurfaceTemp(), - report.getSeaSurfaceTemp())); - } - - if (report.getHighResWaveHeight() != ObConst.MISSING) { - worstValues.setHighResWaveHeight(worstValues - .getHighResWaveHeight() == ObConst.MISSING ? report - .getHighResWaveHeight() : Math.max( - worstValues.getHighResWaveHeight(), - report.getHighResWaveHeight())); - } - - if (report.getWaveSteepness() != ObConst.MISSING) { - worstValues - .setWaveSteepness(worstValues.getWaveSteepness() == ObConst.MISSING ? report - .getWaveSteepness() : Math.max( - worstValues.getWaveSteepness(), - report.getWaveSteepness())); - } - - if (report.getPSwellHeight() != ObConst.MISSING) { - worstValues - .setPSwellHeight(worstValues.getPSwellHeight() == ObConst.MISSING ? report - .getPSwellHeight() : Math.max( - worstValues.getPSwellHeight(), - report.getPSwellHeight())); - } - - if (report.getPSwellPeriod() != ObConst.MISSING) { - worstValues - .setPSwellPeriod(worstValues.getPSwellPeriod() == ObConst.MISSING ? report - .getPSwellPeriod() : Math.max( - worstValues.getPSwellPeriod(), - report.getPSwellPeriod())); - } - - if (report.getPSwellDir() != ObConst.MISSING) { - worstValues - .setPSwellDir(worstValues.getPSwellDir() == ObConst.MISSING ? report - .getPSwellDir() - : worseDirection( - MonitorConfigConstants.SafeSeasDisplay.SS_DISP_SWELL_PRIM_DIR_FROM - .getXmlKey(), - MonitorConfigConstants.SafeSeasDisplay.SS_DISP_SWELL_PRIM_DIR_TO - .getXmlKey(), worstValues - .getPSwellDir(), report - .getPSwellDir())); - } - - if (report.getSSwellHeight() != ObConst.MISSING) { - worstValues - .setSSwellHeight(worstValues.getSSwellHeight() == ObConst.MISSING ? report - .getSSwellHeight() : Math.max( - worstValues.getSSwellHeight(), - report.getSSwellHeight())); - } - - if (report.getSSwellPeriod() != ObConst.MISSING) { - worstValues - .setSSwellPeriod(worstValues.getSSwellPeriod() == ObConst.MISSING ? report - .getSSwellPeriod() : Math.max( - worstValues.getSSwellPeriod(), - report.getSSwellPeriod())); - } - - if (report.getSSwellDir() != ObConst.MISSING) { - worstValues - .setSSwellDir(worstValues.getSSwellDir() == ObConst.MISSING ? report - .getSSwellDir() - : worseDirection( - MonitorConfigConstants.SafeSeasDisplay.SS_DISP_SWELL_SEC_DIR_FROM - .getXmlKey(), - MonitorConfigConstants.SafeSeasDisplay.SS_DISP_SWELL_SEC_DIR_TO - .getXmlKey(), worstValues - .getSSwellDir(), report - .getSSwellDir())); - } - } - } - } - - /** - * Returns the ObStnHourReports object of a caller-specified station. If - * such object not available, returns null. - * - * @param station - * @return - */ - public ObStnHourReports getObStnHourReports(String station) { - if (!zoneHourReports.containsKey(station)) { - return null; - } - return zoneHourReports.get(station); - } - - /** - * Gets Zone Hour Reports - * - * @return - */ - public HashMap getZoneHourReports() { - return zoneHourReports; - } - - /** - * Gets Nominal Time - * - * @return - */ - public Date getNominalTime() { - return nominalTime; - } - - /** - * Gets Zone - * - * @return - */ - public String getZone() { - return zone; - } - - /** - * Gets AppName - * - * @return - */ - public CommonConfig.AppName getAppName() { - return appName; - } + + /** + * the nominal time and zone ID of this ObZoneHourReports object + */ + private Date nominalTime; + private String zone; + + /** + * Thresholds manager + */ + private AbstractThresholdMgr thresholdMgr; + + /** + * application name (snow, fog, safeseas, etc) + */ + private CommonConfig.AppName appName; + + /** + * key is station id, value is ObStnHourReports object + */ + private HashMap zoneHourReports; + + /** + * this object stores worst values of the observation variables + * reported during this nominal hour for this zone + */ + private ObReport worstValues; + + public ObZoneHourReports(Date nominalTime, String zone, CommonConfig.AppName appName, AbstractThresholdMgr thresholdMgr) { + this.nominalTime = nominalTime; + this.zone = zone; + this.appName = appName; + this.thresholdMgr =thresholdMgr; + zoneHourReports = new HashMap(); + for ( String station : MonitoringArea.getPlatformMap().get(zone) ) { + zoneHourReports.put(station, new ObStnHourReports(nominalTime, zone, station, appName, thresholdMgr)); + } + InitWorstValues(); + } + + private void InitWorstValues() { + worstValues = new ObReport(); + worstValues.setZoneId(zone); // the ObReport's init() sets "zone id" to "" !!! + } + + /** + * @param xmlKey : XML key of a directional obs variable + * @param dirCurrent : the current worst value + * @param dirNew : the value contained in a new obs report + * @return : the value of worse threat level + */ + private float worseDirection(String xmlKeyFrom, String xmlKeyTo, float dirCurrent, float dirNew) { + /** + * decide which one of the two wind directions is worse + * by comparing their corresponding threat levels + */ + if ( dirNew == ObConst.MISSING ) { + return dirCurrent; + } + + if ( dirCurrent == ObConst.MISSING ) { + return dirNew; + } + + CellType cellTypeCurrent = thresholdMgr.getDirectionalThresholdValueCellType(DataUsageKey.DISPLAY, zone, xmlKeyFrom, xmlKeyTo, dirCurrent); + + if ( cellTypeCurrent == CellType.R ) { + /** + * already worst threat level + */ + return dirCurrent; + } + + CellType cellTypeNew = thresholdMgr.getDirectionalThresholdValueCellType(DataUsageKey.DISPLAY, zone, xmlKeyFrom, xmlKeyTo, dirNew); + + /** + * CellType is enumerated in the order R, Y, G, N/A, ... + */ + if ( cellTypeNew.compareTo(cellTypeCurrent) < 0 ) { + /** + * dirNew corresponds to a higher threat level + */ + return dirNew; + } + + return dirCurrent; + } + + public void addReport(ObReport report) { + String station = report.getPlatformId(); + if ( zoneHourReports.containsKey(station) ) { + zoneHourReports.get(station).addReport(report); + } else { + System.out.println("Error: unrecognized station ID: " + station + " (app = " + appName +")"); + } + //updateWorstValues(report); + } + + public TableData getStationTableData() { + TableData tblData = new TableData(appName); + for ( String station : zoneHourReports.keySet() ) { + tblData.addTableRowData(this.getObStnHourReports(station).getStationTableRowData()); + } + return tblData; + } + + /** + * Returns a row of a zone table based on all reports within the nominal hour + * for the specified zone. + * If no data available, an empty/default row of table data is returned. + * @return + */ + public TableRowData getZoneTableRowData() { + TableRowData tblRowData = null; + + if ( appName==CommonConfig.AppName.FOG ) { + updateFogWorstValues(); + tblRowData = TableUtil.getFogTableRowData(zone, zone, worstValues, thresholdMgr, CellType.NotAvailable); + } else if ( appName==CommonConfig.AppName.SAFESEAS ) { + updateSafeseasWorstValues(); + tblRowData = TableUtil.getSafeseasTableRowData(zone, zone, worstValues, thresholdMgr, CellType.NotAvailable); + } else if ( appName==CommonConfig.AppName.SNOW ) { + updateSnowWorstValues(); + tblRowData = TableUtil.getSnowTableRowData(zone, zone, worstValues, thresholdMgr); + } else { + System.out.println("unrecognized appName: " + appName); + } + return tblRowData; + } + + public TableRowData getFogZoneTableRowData(CellType algCellType) { + updateFogWorstValues(); + return TableUtil.getFogTableRowData(zone, zone, worstValues, thresholdMgr, algCellType); + } + + public TableRowData getSSZoneTableRowData(CellType algCellType) { + updateSafeseasWorstValues(); + return TableUtil.getSafeseasTableRowData(zone, zone, worstValues, thresholdMgr, algCellType); + } + + private void updateFogWorstValues() { + if ( zoneHourReports.isEmpty() ) { + return; + } + InitWorstValues(); + for ( String station : zoneHourReports.keySet() ) { + ObReport report = zoneHourReports.get(station).getLatestObReport(); + if ( report != null ) { + if ( report.getVisibility() != ObConst.MISSING ) { + worstValues.setVisibility(worstValues.getVisibility()==ObConst.MISSING?report.getVisibility():Math.min(worstValues.getVisibility(),report.getVisibility())); + } + + worstValues.setPresentWx(worstValues.getPresentWx()+report.getPresentWx()); + + if ( report.getCeiling() != ObConst.MISSING ) { + worstValues.setCeiling(worstValues.getCeiling()==ObConst.MISSING?report.getCeiling():Math.min(worstValues.getCeiling(),report.getCeiling())); + } + + if ( report.getWindDir() != ObConst.MISSING ) { + worstValues.setWindDir(worseDirection(MonitorConfigConstants.FogDisplay.FOG_DISP_WIND_DIR_FROM.getXmlKey(), MonitorConfigConstants.FogDisplay.FOG_DISP_WIND_DIR_TO.getXmlKey(), worstValues.getWindDir(),report.getWindDir())); + } + + if ( report.getWindSpeed() != ObConst.MISSING ) { + worstValues.setWindSpeed(worstValues.getWindSpeed()==ObConst.MISSING?report.getWindSpeed():Math.max(worstValues.getWindSpeed(),report.getWindSpeed())); + } + + if ( report.getMaxWindSpeed() != ObConst.MISSING ) { + worstValues.setMaxWindSpeed(worstValues.getMaxWindSpeed()==ObConst.MISSING?report.getMaxWindSpeed():Math.max(worstValues.getMaxWindSpeed(),report.getMaxWindSpeed())); + } + + if ( report.getWindGust() != ObConst.MISSING ) { + worstValues.setWindGust(worstValues.getWindGust()==ObConst.MISSING?report.getWindGust():Math.max(worstValues.getWindGust(),report.getWindGust())); + } + + if ( report.getTemperature() != ObConst.MISSING ) { + worstValues.setTemperature(worstValues.getTemperature()==ObConst.MISSING?report.getTemperature():Math.max(worstValues.getTemperature(),report.getTemperature())); + } + + if ( report.getDewpoint() != ObConst.MISSING ) { + worstValues.setDewpoint(worstValues.getDewpoint()==ObConst.MISSING?report.getDewpoint():Math.max(worstValues.getDewpoint(),report.getDewpoint())); + } + + if ( report.getDewpointDepr() != ObConst.MISSING ) { + worstValues.setDewpointDepr(worstValues.getDewpointDepr()==ObConst.MISSING?report.getDewpointDepr():Math.min(worstValues.getDewpointDepr(),report.getDewpointDepr())); + } + + if ( report.getRelativeHumidity() != ObConst.MISSING ) { + worstValues.setRelativeHumidity(worstValues.getRelativeHumidity()==ObConst.MISSING?report.getRelativeHumidity():Math.max(worstValues.getRelativeHumidity(),report.getRelativeHumidity())); + } + } + } + } + + private void updateSnowWorstValues() { + if ( zoneHourReports.isEmpty() ) { + return; + } + InitWorstValues(); + for ( String station : zoneHourReports.keySet() ) { + ObReport report = zoneHourReports.get(station).getLatestObReport(); + if ( report != null ) { + worstValues.setPresentWx(worstValues.getPresentWx()+report.getPresentWx()); + + if ( report.getWindDir() != ObConst.MISSING ) { + worstValues.setWindDir(worseDirection(MonitorConfigConstants.SnowDisplay.SNOW_DISP_WIND_DIR_FROM.getXmlKey(), MonitorConfigConstants.SnowDisplay.SNOW_DISP_WIND_DIR_TO.getXmlKey(), worstValues.getWindDir(),report.getWindDir())); + } + + if ( report.getWindSpeed() != ObConst.MISSING ) { + worstValues.setWindSpeed(worstValues.getWindSpeed()==ObConst.MISSING?report.getWindSpeed():Math.max(worstValues.getWindSpeed(),report.getWindSpeed())); + } + + if ( report.getMaxWindSpeed() != ObConst.MISSING ) { + worstValues.setMaxWindSpeed(worstValues.getMaxWindSpeed()==ObConst.MISSING?report.getMaxWindSpeed():Math.max(worstValues.getMaxWindSpeed(),report.getMaxWindSpeed())); + } + + if ( report.getWindGust() != ObConst.MISSING ) { + worstValues.setWindGust(worstValues.getWindGust()==ObConst.MISSING?report.getWindGust():Math.max(worstValues.getWindGust(),report.getWindGust())); + } + + if ( report.getTemperature() != ObConst.MISSING ) { + worstValues.setTemperature(worstValues.getTemperature()==ObConst.MISSING?report.getTemperature():Math.min(worstValues.getTemperature(),report.getTemperature())); + } + + if ( report.getDewpoint() != ObConst.MISSING ) { + worstValues.setDewpoint(worstValues.getDewpoint()==ObConst.MISSING?report.getDewpoint():Math.min(worstValues.getDewpoint(),report.getDewpoint())); + } + + if ( report.getVisibility() != ObConst.MISSING ) { + worstValues.setVisibility(worstValues.getVisibility()==ObConst.MISSING?report.getVisibility():Math.min(worstValues.getVisibility(),report.getVisibility())); + } + + if ( report.getSeaLevelPress() != ObConst.MISSING ) { + worstValues.setSeaLevelPress(worstValues.getSeaLevelPress()==ObConst.MISSING?report.getSeaLevelPress():Math.min(worstValues.getSeaLevelPress(),report.getSeaLevelPress())); + } + + if ( report.getWindChill() != ObConst.MISSING ) { + worstValues.setWindChill(worstValues.getWindChill()==ObConst.MISSING?report.getWindChill():Math.min(worstValues.getWindChill(),report.getWindChill())); + } + + if ( report.getFrostbiteTime() != ObConst.MISSING ) { + worstValues.setFrostbiteTime(worstValues.getFrostbiteTime()==ObConst.MISSING?report.getFrostbiteTime():Math.min(worstValues.getFrostbiteTime(),report.getFrostbiteTime())); + } + + if ( report.getHourlyPrecip() != ObConst.MISSING ) { + worstValues.setHourlyPrecip(worstValues.getHourlyPrecip()==ObConst.MISSING?report.getHourlyPrecip():Math.max(worstValues.getHourlyPrecip(),report.getHourlyPrecip())); + } + + if ( report.getSnowDepth() != ObConst.MISSING ) { + worstValues.setSnowDepth(worstValues.getSnowDepth()==ObConst.MISSING?report.getSnowDepth():Math.max(worstValues.getSnowDepth(),report.getSnowDepth())); + } + + if ( report.getSnincrHourly() != ObConst.MISSING ) { + worstValues.setSnincrHourly(worstValues.getSnincrHourly()==ObConst.MISSING?report.getSnincrHourly():Math.max(worstValues.getSnincrHourly(),report.getSnincrHourly())); + } + + if ( report.getSnincrTotal() != ObConst.MISSING ) { + worstValues.setSnincrTotal(worstValues.getSnincrTotal()==ObConst.MISSING?report.getSnincrTotal():Math.max(worstValues.getSnincrTotal(),report.getSnincrTotal())); + } + } + } + } + + private void updateSafeseasWorstValues() { + if ( zoneHourReports.isEmpty() ) { + return; + } + InitWorstValues(); + for ( String station : zoneHourReports.keySet() ) { + ObReport report = zoneHourReports.get(station).getLatestObReport(); + if ( report != null ) { + if ( report.getWindDir() != ObConst.MISSING ) { + worstValues.setWindDir(worstValues.getWindDir()==ObConst.MISSING?report.getWindDir():worseDirection(MonitorConfigConstants.SafeSeasDisplay.SS_DISP_WIND_DIR_FROM.getXmlKey(), MonitorConfigConstants.SafeSeasDisplay.SS_DISP_WIND_DIR_TO.getXmlKey(), worstValues.getWindDir(),report.getWindDir())); + } + + if ( report.getWindSpeed() != ObConst.MISSING ) { + worstValues.setWindSpeed(worstValues.getWindSpeed()==ObConst.MISSING?report.getWindSpeed():Math.max(worstValues.getWindSpeed(),report.getWindSpeed())); + } + + if ( report.getMaxWindSpeed() != ObConst.MISSING ) { + worstValues.setMaxWindSpeed(worstValues.getMaxWindSpeed()==ObConst.MISSING?report.getMaxWindSpeed():Math.max(worstValues.getMaxWindSpeed(),report.getMaxWindSpeed())); + } + + if ( report.getWindGust() != ObConst.MISSING ) { + worstValues.setWindGust(worstValues.getWindGust()==ObConst.MISSING?report.getWindGust():Math.max(worstValues.getWindGust(),report.getWindGust())); + } + + if ( report.getVisibility() != ObConst.MISSING ) { + worstValues.setVisibility(worstValues.getVisibility()==ObConst.MISSING?report.getVisibility():Math.min(worstValues.getVisibility(),report.getVisibility())); + } + + if ( report.getTemperature() != ObConst.MISSING ) { + worstValues.setTemperature(worstValues.getTemperature()==ObConst.MISSING?report.getTemperature():Math.max(worstValues.getTemperature(),report.getTemperature())); + } + + if ( report.getDewpoint() != ObConst.MISSING ) { + worstValues.setDewpoint(worstValues.getDewpoint()==ObConst.MISSING?report.getDewpoint():Math.max(worstValues.getDewpoint(),report.getDewpoint())); + } + + if ( report.getSeaLevelPress() != ObConst.MISSING ) { + worstValues.setSeaLevelPress(worstValues.getSeaLevelPress()==ObConst.MISSING?report.getSeaLevelPress():Math.min(worstValues.getSeaLevelPress(),report.getSeaLevelPress())); + } + + if ( report.getSeaSurfaceTemp() != ObConst.MISSING ) { + worstValues.setSeaSurfaceTemp(worstValues.getSeaSurfaceTemp()==ObConst.MISSING?report.getSeaSurfaceTemp():Math.max(worstValues.getSeaSurfaceTemp(),report.getSeaSurfaceTemp())); + } + + if ( report.getHighResWaveHeight() != ObConst.MISSING ) { + worstValues.setHighResWaveHeight(worstValues.getHighResWaveHeight()==ObConst.MISSING?report.getHighResWaveHeight():Math.max(worstValues.getHighResWaveHeight(),report.getHighResWaveHeight())); + } + + if ( report.getWaveSteepness() != ObConst.MISSING ) { + worstValues.setWaveSteepness(worstValues.getWaveSteepness()==ObConst.MISSING?report.getWaveSteepness():Math.max(worstValues.getWaveSteepness(),report.getWaveSteepness())); + } + + if ( report.getPSwellHeight() != ObConst.MISSING ) { + worstValues.setPSwellHeight(worstValues.getPSwellHeight()==ObConst.MISSING?report.getPSwellHeight():Math.max(worstValues.getPSwellHeight(),report.getPSwellHeight())); + } + + if ( report.getPSwellPeriod() != ObConst.MISSING ) { + worstValues.setPSwellPeriod(worstValues.getPSwellPeriod()==ObConst.MISSING?report.getPSwellPeriod():Math.max(worstValues.getPSwellPeriod(),report.getPSwellPeriod())); + } + + if ( report.getPSwellDir() != ObConst.MISSING ) { + worstValues.setPSwellDir(worstValues.getPSwellDir()==ObConst.MISSING?report.getPSwellDir():worseDirection(MonitorConfigConstants.SafeSeasDisplay.SS_DISP_SWELL_PRIM_DIR_FROM.getXmlKey(), MonitorConfigConstants.SafeSeasDisplay.SS_DISP_SWELL_PRIM_DIR_TO.getXmlKey(), worstValues.getPSwellDir(),report.getPSwellDir())); + } + + if ( report.getSSwellHeight() != ObConst.MISSING ) { + worstValues.setSSwellHeight(worstValues.getSSwellHeight()==ObConst.MISSING?report.getSSwellHeight():Math.max(worstValues.getSSwellHeight(),report.getSSwellHeight())); + } + + if ( report.getSSwellPeriod() != ObConst.MISSING ) { + worstValues.setSSwellPeriod(worstValues.getSSwellPeriod()==ObConst.MISSING?report.getSSwellPeriod():Math.max(worstValues.getSSwellPeriod(),report.getSSwellPeriod())); + } + + if ( report.getSSwellDir() != ObConst.MISSING ) { + worstValues.setSSwellDir(worstValues.getSSwellDir()==ObConst.MISSING?report.getSSwellDir():worseDirection(MonitorConfigConstants.SafeSeasDisplay.SS_DISP_SWELL_SEC_DIR_FROM.getXmlKey(), MonitorConfigConstants.SafeSeasDisplay.SS_DISP_SWELL_SEC_DIR_TO.getXmlKey(), worstValues.getSSwellDir(),report.getSSwellDir())); + } + } + } + } + + /** + * Returns the ObStnHourReports object of a caller-specified station. + * If such object not available, returns null. + * @param station + * @return + */ + public ObStnHourReports getObStnHourReports(String station) { + if ( !zoneHourReports.containsKey(station) ) { + return null; + } + return zoneHourReports.get(station); + } + + public HashMap getZoneHourReports() { + return zoneHourReports; + } + + public Date getNominalTime() { + return nominalTime; + } + + public String getZone() { + return zone; + } + + public CommonConfig.AppName getAppName() { + return appName; + } } diff --git a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/data/TableUtil.java b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/data/TableUtil.java index 4d17f1aecb..3f5cf9ffce 100644 --- a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/data/TableUtil.java +++ b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/data/TableUtil.java @@ -25,12 +25,10 @@ import java.util.Date; import com.raytheon.uf.common.geospatial.ISpatialQuery; import com.raytheon.uf.common.geospatial.SpatialQueryFactory; import com.raytheon.uf.common.monitor.MonitorAreaUtils; -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.monitor.data.ObConst; import com.raytheon.uf.common.monitor.data.ObConst.DataUsageKey; -import com.raytheon.uf.common.monitor.xml.AreaIdXML; import com.raytheon.uf.viz.monitor.config.CommonTableConfig; import com.raytheon.uf.viz.monitor.config.CommonTableConfig.CellType; import com.raytheon.uf.viz.monitor.config.CommonTableConfig.ObsHistType; @@ -52,8 +50,6 @@ import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants; * May 23, 2012 14410 zhao Modified getCellTypeForBlizWarn and getCellTypeForHsnowWarn modules * Feb 28, 2013 14410 zhao Modified getCellTypeForBlizWarn * May 23, 2014 3086 skorolev Corrected ObsHistType. Cleaned code. - * Nov 21, 2014 3841 skorolev Added coordinates in the hover text for a newly added zones. - * Jan 08, 2015 3220 skorolev Corrected code for Fog and SNOW table data. * * * @@ -114,13 +110,9 @@ public final class TableUtil { isZone = true; } - String hoverText = ""; + String hoverText = null; if (isZone) { - AreaIdXML zoneXML = FSSObsMonitorConfigurationManager - .getFogObsManager().getAreaXml(zone); - if (zoneXML != null) { - hoverText = getZoneHoverText(zoneXML); - } + hoverText = getZoneHoverText(areaId); } else { hoverText = getStationHoverText(areaId); } @@ -328,8 +320,7 @@ public final class TableUtil { * dialog) * @param zone * @param report - * @param tm - * Abstract Threshold Manager + * @param tm Abstract Threshold Manager * @param fogCellType * @return */ @@ -345,13 +336,9 @@ public final class TableUtil { isZone = true; } - String hoverText = ""; + String hoverText = null; if (isZone) { - AreaIdXML zoneXML = FSSObsMonitorConfigurationManager - .getSsObsManager().getAreaXml(zone); - if (zoneXML != null) { - hoverText = getZoneHoverText(zoneXML); - } + hoverText = getZoneHoverText(areaId); } else { hoverText = getStationHoverText(areaId); } @@ -650,13 +637,9 @@ public final class TableUtil { isZone = true; } - String hoverText = ""; + String hoverText = null; if (isZone) { - AreaIdXML zoneXML = FSSObsMonitorConfigurationManager - .getSnowObsManager().getAreaXml(zone); - if (zoneXML != null) { - hoverText = getZoneHoverText(zoneXML); - } + hoverText = getZoneHoverText(areaId); } else { hoverText = getStationHoverText(areaId); } @@ -901,9 +884,8 @@ public final class TableUtil { * @param zone * @return */ - private static String getZoneHoverText(AreaIdXML zoneXML) { + private static String getZoneHoverText(String zone) { - String zone = zoneXML.getAreaId(); ISpatialQuery sq = null; String sql = null; String hoverText = zone.substring(0, 2) + ", "; @@ -932,11 +914,6 @@ public final class TableUtil { } else { hoverText += (String) results[0].toString(); } - } else { - if (zoneXML.getCLat() != null) { - hoverText += "(" + zoneXML.getCLat() + ", " - + zoneXML.getCLon() + ")"; - } } } catch (Exception e) { e.printStackTrace(); diff --git a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/thresholds/AbstractThresholdMgr.java b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/thresholds/AbstractThresholdMgr.java old mode 100755 new mode 100644 index 0cd16240da..fc61dc7d91 --- a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/thresholds/AbstractThresholdMgr.java +++ b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/thresholds/AbstractThresholdMgr.java @@ -33,9 +33,6 @@ import com.raytheon.uf.common.localization.PathManagerFactory; import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager; import com.raytheon.uf.common.monitor.data.ObConst; import com.raytheon.uf.common.monitor.data.ObConst.DataUsageKey; -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.localization.LocalizationManager; import com.raytheon.uf.viz.monitor.config.CommonTableConfig.CellType; import com.raytheon.uf.viz.monitor.filename.DefaultFilenameMgr; @@ -56,8 +53,6 @@ import com.raytheon.uf.viz.monitor.xml.ThresholdsXML; * Mar 22, 2010 #4282 zhao obtain zone IDs from monitoring-area-config-manager * Feb 16, 2011 #7346 zhao added getDirectionalThresholdValueCellType(...) * Apr 28, 2014 3086 skorolev Updated getAreaConfigMgr method. - * Oct 17, 2014 3220 skorolev Replaced System.out.print with debug statusHandler. - * Jan 08, 2015 3220 skorolev Added getAreaConfigMgr. * * * @@ -66,13 +61,10 @@ import com.raytheon.uf.viz.monitor.xml.ThresholdsXML; */ public abstract class AbstractThresholdMgr { - private final IUFStatusHandler statusHandler = UFStatus - .getHandler(AbstractThresholdMgr.class); - /** * Monitor Area Configuration Manager. */ - public FSSObsMonitorConfigurationManager areaConfigMgr; + protected FSSObsMonitorConfigurationManager areaConfigMgr; /** * Default file name for the FOG display thresholds. @@ -142,6 +134,7 @@ public abstract class AbstractThresholdMgr { this.defMonitorThreshName = defMonitorThreshName; this.appName = appName; this.site = LocalizationManager.getInstance().getCurrentSite(); + this.areaConfigMgr = getMonitorAreaConfigInstance(); } /** @@ -208,7 +201,7 @@ public abstract class AbstractThresholdMgr { LocalizationFile locFile = pm.getLocalizationFile(context, pathAndFileName); - statusHandler.handle(Priority.DEBUG, "--- validate path = " + System.out.println("--- validate path = " + locFile.getFile().getAbsolutePath()); return locFile.getFile().exists(); @@ -533,8 +526,7 @@ public abstract class AbstractThresholdMgr { ArrayList threshKeys = getThresholdKeys(DataUsageKey.DISPLAY); - statusHandler.handle(Priority.DEBUG, "---- " - + currFullDisplayXmlFileName); + System.out.println("---- " + currFullDisplayXmlFileName); displayThreshMgr.createConfigFromDefaults( currFullDisplayXmlFileName, areaIDs, threshKeys); @@ -772,17 +764,14 @@ public abstract class AbstractThresholdMgr { ArrayList areasArray = displayXML.getAreas(); for (AreaXML area : areasArray) { - statusHandler.handle(Priority.DEBUG, "--- " + area.getAreaId()); + System.out.println("--- " + area.getAreaId()); ArrayList atXmlArray = area.getAreaThresholds(); for (AreaThresholdXML atXml : atXmlArray) { - statusHandler.handle(Priority.DEBUG, - "****** " + atXml.getKey()); - statusHandler.handle(Priority.DEBUG, - " R " + atXml.getRed()); - statusHandler.handle(Priority.DEBUG, - " Y " + atXml.getYellow()); + System.out.println("****** " + atXml.getKey()); + System.out.println(" R " + atXml.getRed()); + System.out.println(" Y " + atXml.getYellow()); } } } @@ -795,27 +784,23 @@ public abstract class AbstractThresholdMgr { ArrayList areasArray = threshXmlCopy.getAreas(); for (AreaXML area : areasArray) { - statusHandler.handle(Priority.DEBUG, "--- " + area.getAreaId()); + System.out.println("--- " + area.getAreaId()); ArrayList atXmlArray = area.getAreaThresholds(); for (AreaThresholdXML atXml : atXmlArray) { - statusHandler.handle(Priority.DEBUG, - "****** " + atXml.getKey()); - statusHandler.handle(Priority.DEBUG, - " R " + atXml.getRed()); - statusHandler.handle(Priority.DEBUG, - " Y " + atXml.getYellow()); + System.out.println("****** " + atXml.getKey()); + System.out.println(" R " + atXml.getRed()); + System.out.println(" Y " + atXml.getYellow()); } } } /** - * Gets current Area configuration manager. + * Gets Monitor Area Configuration manager. * - * @return + * @return manager */ - public FSSObsMonitorConfigurationManager getAreaConfigMgr() { - return areaConfigMgr; - } + protected abstract FSSObsMonitorConfigurationManager getMonitorAreaConfigInstance(); + } diff --git a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/thresholds/ThresholdMgr.java b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/thresholds/ThresholdMgr.java index da44082991..09b94134d1 100644 --- a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/thresholds/ThresholdMgr.java +++ b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/thresholds/ThresholdMgr.java @@ -50,7 +50,6 @@ import com.raytheon.uf.viz.monitor.xml.ThresholdsXML; * ------------ ---------- ----------- -------------------------- * Dec 15, 2009 #3963 lvenable Initial creation * Dec 4, 2012 #1351 skorolev Cleaned code - * Oct 16, 2014 #3220 skorolev Added error message when Default threshold configuration file is corrupted or empty. * * * @@ -146,11 +145,7 @@ public class ThresholdMgr { ThresholdsXML.class); createXmlFromDefaults(cfgXmlDefaults, areaIDs, keys); } catch (Exception e) { - statusHandler - .handle(Priority.ERROR, - "Default threshold configuration file " - + fullDefaultPathName - + " is corrupted.\nDelete the files in the folder on the server side and restart CAVE."); + statusHandler.handle(Priority.ERROR, e.getMessage()); return false; } return true; diff --git a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/AddNewStationDlg.java b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/AddNewStationDlg.java index 9e5d768b4d..a1b6dd37b2 100644 --- a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/AddNewStationDlg.java +++ b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/AddNewStationDlg.java @@ -56,7 +56,6 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * Nov 20, 2012 1297 skorolev Changes for non-blocking dialog. * Apr 23, 2014 3054 skorolev Added MESONET handling. * Apr 28, 2014 3086 skorolev Removed local getAreaConfigMgr method. - * Nov 21, 2014 3841 skorolev Corrected handleAddNewStation method. * * * @@ -262,8 +261,8 @@ public class AddNewStationDlg extends CaveSWTDialog { return; } macDlg.addNewStationAction(stn); - macDlg.configMgr.addStation(area, stn, type, false); - macDlg.configMgr.getStations().add(stn); + macDlg.getInstance().addStation(area, stn, type, false); + macDlg.getInstance().getStations().add(stn); } /** diff --git a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/AddNewZoneDlg.java b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/AddNewZoneDlg.java index 02766e0a78..4b5a8c87a2 100644 --- a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/AddNewZoneDlg.java +++ b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/AddNewZoneDlg.java @@ -28,6 +28,7 @@ import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Layout; +import org.eclipse.swt.widgets.MessageBox; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; @@ -48,7 +49,6 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * Nov 20, 2012 1297 skorolev Changes for non-blocking dialog. * Apr 23, 2014 3054 skorolev Deleted unnecessary parameter in addArea method. * Apr 28, 2014 3086 skorolev Removed local getAreaConfigMgr method. - * Nov 21, 2014 3841 skorolev Corrected handleAddNewAction method. * * * @@ -234,12 +234,9 @@ public class AddNewZoneDlg extends CaveSWTDialog { addBtn.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { - String areaId = idTF.getText(); String latString = centroidLatTF.getText(); String lonString = centroidLonTF.getText(); - if (macDlg.formIsValid(areaId, latString, lonString)) { - handleAddNewAction(areaId, latString, lonString); - } + handleAddNewAction(latString, lonString); } }); @@ -259,32 +256,61 @@ public class AddNewZoneDlg extends CaveSWTDialog { /** * Adds a new zone. * - * @param areaId * @param latString * @param lonString - * @throws NumberFormatException */ - private void handleAddNewAction(String areaId, String latString, - String lonString) throws NumberFormatException { + private void handleAddNewAction(String latString, String lonString) { + String areaId = idTF.getText(); + if (areaId.equals("") || areaId.length() != 6 + || (areaId.charAt(2) != 'C' && areaId.charAt(2) != 'Z')) { + displayInputErrorMsg("Invalid Area ID = '" + areaId + + "' entered. Please enter a correctly formatted Area ID."); + return; + } if (macDlg.isExistingZone(areaId)) { - macDlg.displayInputErrorMsg("The Area ID, " + displayInputErrorMsg("The Area ID, " + areaId + ", is already in your Monitoring Area or among your Additional Zones."); return; } - double lat = Double.parseDouble(latString.trim()); - double lon = Double.parseDouble(lonString.trim()); - ZoneType type = ZoneType.REGULAR; - if (appName != AppName.SNOW) { - if (marineZoneRdo.getSelection() || idTF.getText().charAt(2) == 'Z') { - type = ZoneType.MARITIME; - } - } - if (lat > 90.0 || lat < -90.0 || lon > 180.0 || lon < -180.0) { + if (latString == null || latString.isEmpty() || lonString == null + || lonString.isEmpty()) { macDlg.latLonErrorMsg(latString, lonString); return; + } else { + try { + double lat = Double.parseDouble(latString.trim()); + double lon = Double.parseDouble(lonString.trim()); + ZoneType type = ZoneType.REGULAR; + if (appName != AppName.SNOW) { + if (marineZoneRdo.getSelection()) { + type = ZoneType.MARITIME; + } + } + if (lat > 90.0 || lat < -90.0 || lon > 180.0 || lon < -180.0) { + macDlg.latLonErrorMsg(latString, lonString); + return; + } + macDlg.configMgr.addArea(areaId, lat, lon, type); + macDlg.addNewZoneAction(areaId, centroidLatTF.getText(), + centroidLonTF.getText()); + } catch (NumberFormatException e) { + macDlg.latLonErrorMsg(latString, lonString); + return; + } } - macDlg.configMgr.addArea(areaId, lat, lon, type); - macDlg.addZoneToMA(areaId); + } + + /** + * Displays Input Error Message + * + * @param msg + */ + private void displayInputErrorMsg(String msg) { + MessageBox messageBox = new MessageBox(shell, SWT.ICON_INFORMATION + | SWT.OK); + messageBox.setText("Invalid input"); + messageBox.setMessage(msg); + messageBox.open(); } } diff --git a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/DeleteStationDlg.java b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/DeleteStationDlg.java index 1148f91e7d..c7955eef71 100644 --- a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/DeleteStationDlg.java +++ b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/DeleteStationDlg.java @@ -50,7 +50,6 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * Nov 20, 2012 1297 skorolev Changes for non-blocking dialog. * Apr 23, 2014 3054 skorolev Fixed issue with deleting a new station. * Apr 28, 2014 3086 skorolev Removed local getAreaConfigMgr method. - * Nov 21, 2014 3841 skorolev Corrected deleteSelected method. * * * @@ -190,8 +189,8 @@ public class DeleteStationDlg extends CaveSWTDialog { if (stationList.getSelectionIndex() != -1) { int idx = stationList.getSelectionIndex(); String selection = stationList.getItem(idx); - retval = macDlg.configMgr.getAddedStations().get(idx); - macDlg.configMgr.getAddedStations().remove(idx); + retval = configMgr.getAddedStations().get(idx); + configMgr.getAddedStations().remove(idx); stationList.remove(selection); populate(); } else { diff --git a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/EditNewZoneDlg.java b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/EditNewZoneDlg.java index 3a1f93a1d3..d3822667e7 100644 --- a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/EditNewZoneDlg.java +++ b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/EditNewZoneDlg.java @@ -19,8 +19,6 @@ **/ package com.raytheon.uf.viz.monitor.ui.dialogs; -import java.util.ArrayList; - import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; @@ -39,7 +37,6 @@ import org.eclipse.swt.widgets.Text; import com.raytheon.uf.common.monitor.data.CommonConfig.AppName; import com.raytheon.uf.common.monitor.xml.AreaIdXML; import com.raytheon.uf.common.monitor.xml.AreaIdXML.ZoneType; -import com.raytheon.uf.common.monitor.xml.StationIdXML; import com.raytheon.viz.ui.dialogs.CaveSWTDialog; /** @@ -56,8 +53,6 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * Apr 23, 2014 3054 skorolev Fixed issues with removing a new zone from list. * Apr 28, 2014 3086 skorolev Removed local getAreaConfigMgr method. * Nov 10, 2014 3741 skorolev Fixed configXML issue. - * Nov 21, 2014 3841 skorolev Content of ID field made an editable. - * Feb 03, 2015 3841 skorolev Fixed deleteSelected method. * * * @@ -90,11 +85,17 @@ public class EditNewZoneDlg extends CaveSWTDialog { /** Control font. */ private Font controlFont; + /** Marine station radio button. */ + private Button marineRdo; + + /** None Marine station radio button. */ + private Button nonMarineRdo; + /** Bottom label */ private Label bottomLbl; /** Deleted zone */ - private boolean delZone = false; + private String delZone; /** * Constructor. @@ -226,6 +227,21 @@ public class EditNewZoneDlg extends CaveSWTDialog { lonTF = new Text(textButtonComp, SWT.BORDER); lonTF.setLayoutData(gd); + gd = new GridData(); + gd.horizontalSpan = 2; + gd.verticalIndent = 15; + marineRdo = new Button(textButtonComp, SWT.RADIO); + marineRdo.setLayoutData(gd); + marineRdo.setSelection(false); + marineRdo.setText("Marine Station"); + + gd = new GridData(); + gd.horizontalSpan = 2; + nonMarineRdo = new Button(textButtonComp, SWT.RADIO); + nonMarineRdo.setLayoutData(gd); + nonMarineRdo.setSelection(true); + nonMarineRdo.setText("Non-Marine Station"); + gd = new GridData(SWT.CENTER, SWT.DEFAULT, false, true); gd.widthHint = 80; gd.verticalIndent = 5; @@ -235,17 +251,7 @@ public class EditNewZoneDlg extends CaveSWTDialog { saveBtn.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { - if (zoneList.getItemCount() != 0) { - String area = zoneList.getItem(zoneList.getSelectionIndex()); - String areaStr = idTF.getText(); - String latStr = latTF.getText(); - String lonStr = lonTF.getText(); - if (macDlg.formIsValid(areaStr, latStr, lonStr)) { - saveSelected(area, areaStr, latStr, lonStr); - } - } else { - bottomLbl.setText("No zones have been edited."); - } + saveSelected(); } }); gd = new GridData(SWT.CENTER, SWT.DEFAULT, false, true); @@ -304,21 +310,7 @@ public class EditNewZoneDlg extends CaveSWTDialog { * Populate list of added zones. */ private void populate() { - java.util.List newList = new ArrayList(); - java.util.List maList = macDlg.configMgr.getConfigXml() - .getAreaIds(); - for (AreaIdXML maZone : maList) { - if (maZone.getCLat() != null) { - newList.add(maZone.getAreaId()); - } - } - java.util.List adtnlList = macDlg.configMgr - .getAdjAreaConfigXml().getAreaIds(); - for (AreaIdXML aZone : adtnlList) { - if (aZone.getCLat() != null) { - newList.add(aZone.getAreaId()); - } - } + java.util.List newList = macDlg.configMgr.getAddedZones(); zoneList.setItems(newList.toArray(new String[newList.size()])); } @@ -328,25 +320,26 @@ public class EditNewZoneDlg extends CaveSWTDialog { private void handleZoneSelection() { String zone = zoneList.getItem(zoneList.getSelectionIndex()); AreaIdXML areaXml = macDlg.configMgr.getAreaXml(zone); - AreaIdXML adjAreaXml = macDlg.configMgr.getAdjAreaXML(zone); // DR #7343: a null areaXml causes an "Unhandled event loop exception" if (areaXml != null) { idTF.setText(areaXml.getAreaId()); - // idTF.setEnabled(false); + idTF.setEnabled(false); latTF.setText(String.valueOf(areaXml.getCLat())); lonTF.setText(String.valueOf(areaXml.getCLon())); - } else if (adjAreaXml != null) { - idTF.setText(adjAreaXml.getAreaId()); - // idTF.setEnabled(false); - latTF.setText(String.valueOf(adjAreaXml.getCLat())); - lonTF.setText(String.valueOf(adjAreaXml.getCLon())); + if (areaXml.getType() == ZoneType.REGULAR) { + nonMarineRdo.setSelection(true); + marineRdo.setSelection(false); + } else { + nonMarineRdo.setSelection(false); + marineRdo.setSelection(true); + } } } /** * Delete selected zones. */ - private Boolean deleteSelected() { + private String deleteSelected() { if (zoneList.getItemCount() != 0) { if (zoneList.getSelectionIndex() == -1) { MessageBox messageBox = new MessageBox(shell, @@ -355,86 +348,62 @@ public class EditNewZoneDlg extends CaveSWTDialog { messageBox.setMessage("Please select zone to be deleted."); messageBox.open(); zoneList.select(0); - return false; + return null; } String area = zoneList.getItem(zoneList.getSelectionIndex()); zoneList.remove(zoneList.getSelectionIndex()); - zoneList.select(0); - if (zoneList.getItemCount() != 0) { - handleZoneSelection(); - } else { - idTF.setText(""); - latTF.setText(""); - lonTF.setText(""); - } - if (macDlg.getMaZones().contains(area)) { - macDlg.getMaZones().remove(area); - macDlg.configMgr.removeArea(area); - } - if (macDlg.getAdditionalZones().contains(area)) { - macDlg.getAdditionalZones().remove(area); - macDlg.configMgr.removeAdjArea(area); - } - macDlg.maZonesRemoved = true; - return true; + macDlg.configMgr.removeArea(area); + idTF.setText(""); + latTF.setText(""); + lonTF.setText(""); + return area; } else { bottomLbl.setText("No zones have been deleted."); } - return false; + return null; } /** * Save selected zones. */ - /** - * @param area - * Original zone ID - * @param areaStr - * New zone ID - * @param latStr - * Latitude - * @param lonStr - * Longitude - * @throws NumberFormatException - */ - private void saveSelected(String area, String areaStr, String latStr, - String lonStr) throws NumberFormatException { + private void saveSelected() { - ArrayList stationIds = macDlg.configMgr.getAreaXml(area) - .getStationIds(); - - double lat = Double.parseDouble(latStr); - double lon = Double.parseDouble(lonStr); - if (lat > 90.0 || lat < -90.0 || lon > 180.0 || lon < -180.0) { - macDlg.latLonErrorMsg(latStr, lonStr); - return; - } - ZoneType type = ZoneType.REGULAR; - if (areaStr.charAt(2) != 'C') { - type = (ZoneType.MARITIME); - } - AreaIdXML areaXML = new AreaIdXML(); - areaXML.setAreaId(areaStr); - areaXML.setCLat(lat); - areaXML.setCLon(lon); - areaXML.setType(type); - areaXML.setStationIds(stationIds); - // Replace previously added zone - if (macDlg.configMgr.getAreaList().contains(area)) { - if (macDlg.getMaZones().contains(area)) { - macDlg.getMaZones().remove(area); + if (zoneList.getItemCount() != 0) { + String area = zoneList.getItem(zoneList.getSelectionIndex()); + String latStr = latTF.getText(); + String lontStr = lonTF.getText(); + if (latStr == null || latStr.isEmpty() || lontStr == null + || lontStr.isEmpty()) { + macDlg.latLonErrorMsg(latStr, lontStr); + return; + } else { + try { + double lat = Double.parseDouble(latStr); + double lon = Double.parseDouble(lontStr); + if (lat > 90.0 || lat < -90.0 || lon > 180.0 + || lon < -180.0) { + macDlg.latLonErrorMsg(latStr, lontStr); + return; + } + ZoneType type = ZoneType.REGULAR; + if (marineRdo.getSelection()) { + type = ZoneType.MARITIME; + } + // Replace previously added zone + macDlg.configMgr.removeArea(area); + macDlg.configMgr.removeAddedArea(area); + macDlg.configMgr.addArea(area, lat, lon, type); + populate(); + // Return cursor to the top of the list. + zoneList.select(0); + } catch (NumberFormatException e) { + macDlg.latLonErrorMsg(latStr, lontStr); + return; + } } - macDlg.configMgr.removeAddedArea(area); - macDlg.configMgr.removeArea(area); - macDlg.configMgr.addArea(areaXML); - } else if (macDlg.getAdditionalZones().contains(area)) { - macDlg.getAdditionalZones().remove(area); - macDlg.configMgr.removeAdjArea(area); - macDlg.configMgr.addAdjArea(areaXML); + } else { + bottomLbl.setText("No zones have been edited."); } - populate(); - // Return cursor to the list. - zoneList.select(zoneList.indexOf(areaStr)); } /* diff --git a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/MonitoringAreaConfigDlg.java b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/MonitoringAreaConfigDlg.java index 81e5158952..3edac6d690 100644 --- a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/MonitoringAreaConfigDlg.java +++ b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/MonitoringAreaConfigDlg.java @@ -45,7 +45,7 @@ import org.eclipse.swt.widgets.Text; 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.monitor.xml.AreaIdXML; +import com.raytheon.uf.common.monitor.xml.AreaIdXML.ZoneType; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; @@ -78,9 +78,6 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback; * Sep 24, 2014 2757 skorolev Fixed problem with adding and removing zones. * Oct 27, 2014 3667 skorolev Corrected functionality of dialog. Cleaned code. * Nov 12, 2014 3650 skorolev Added confirmation box for unsaved changes in the dialog. - * Nov 21, 2014 3841 skorolev Added formIsValid method. - * Dec 18, 2014 3841 skorolev Corrected addZoneStn method. - * Feb 03, 2015 3841 skorolev Fixed saving problem for distance and time. * * * @@ -880,7 +877,6 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements * Handles the Add New button click. */ private void handleAddNewAction() { - // Zone configure if (zoneRdo.getSelection() == true) { if (addNewZoneDlg == null) { addNewZoneDlg = new AddNewZoneDlg(shell, appName, this); @@ -896,9 +892,9 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements }); } addNewZoneDlg.open(); - } else { // Station configure - if (maRegionalList.getSelectionIndex() != -1) { - String area = maRegionalList.getItem(maRegionalList + } else { + if (associatedList.getSelectionIndex() != -1) { + String area = associatedList.getItem(associatedList .getSelectionIndex()); if (addNewStnDlg == null) { addNewStnDlg = new AddNewStationDlg(shell, appName, area, @@ -919,9 +915,9 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements MessageBox messageBox = new MessageBox(shell, SWT.ICON_INFORMATION | SWT.NONE); messageBox.setText("Selection error."); - messageBox.setMessage("Please select a monitoring zone."); + messageBox.setMessage("Please select associated zone."); messageBox.open(); - maRegionalList.select(0); + associatedList.select(0); } } } @@ -936,8 +932,10 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements editDlg.setCloseCallback(new ICloseCallback() { @Override public void dialogClosed(Object returnValue) { - if ((boolean) returnValue) { + if (returnValue instanceof String) { // Update the edit dialog + String selectedZone = returnValue.toString(); + maZones.remove(selectedZone); populateLeftLists(); } editDlg = null; @@ -1086,20 +1084,20 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements if (mode == Mode.Zone) { String zone = additionalList.getItem(additionalList .getSelectionIndex()); - AreaIdXML zoneXML = configMgr.getAdjAreaXML(zone); additionalList.remove(additionalList.getSelectionIndex()); maZones.add(zone); Collections.sort(maZones); monitorAreaList .setItems(maZones.toArray(new String[maZones.size()])); monitorAreaList.setSelection(maZones.indexOf(zone)); + handleMonitorAreaListSelection(); additionalZones.remove(zone); - configMgr.addArea(zoneXML); + configMgr.addArea(zone, zone.charAt(2) == 'Z' ? ZoneType.MARITIME + : ZoneType.REGULAR); if (!configMgr.getAddedZones().contains(zone)) { configMgr.getAddedZones().add(zone); } configMgr.removeAdjArea(zone); - handleMonitorAreaListSelection(); } else { // Station mode if (associatedList.getSelectionCount() == 0) { showMessage(shell, SWT.ERROR, "Selection Needed", @@ -1144,8 +1142,6 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements monitorAreaList.remove(monitorAreaList.getSelectionIndex()); associatedList.removeAll(); if (mode == Mode.Zone) { - // entry is a zone to remove. - AreaIdXML zoneXML = configMgr.getAreaXml(entry); if (!additionalZones.contains(entry)) { additionalZones.add(entry); } @@ -1158,9 +1154,11 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements if (configMgr.getAddedZones().contains(entry)) { configMgr.getAddedZones().remove(entry); } - configMgr.addAdjArea(zoneXML); + + configMgr.addAdjArea(entry, + entry.charAt(2) == 'Z' ? ZoneType.MARITIME + : ZoneType.REGULAR); } else { // Station mode - // entry is a station to remove. additionalStns.add(entry); Collections.sort(additionalStns); additionalList.setItems(additionalStns @@ -1239,12 +1237,13 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements } else { // Station mode if (regionalRdo.getSelection()) { // entry is a zone selected from additional zones - AreaIdXML zoneXML = configMgr.getAdjAreaXML(entry); maZones.add(entry); Collections.sort(maZones); additionalZones.remove(entry); maRegionalList.remove(maRegionalList.getSelectionIndex()); - configMgr.addArea(zoneXML); + configMgr.addArea(entry, + entry.charAt(2) == 'Z' ? ZoneType.MARITIME + : ZoneType.REGULAR); } String stn = monitorAreaList.getItem(monitorAreaList .getSelectionIndex()); @@ -1338,10 +1337,11 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements } /** - * Saving configuration parameters. + * Reset and Saving configuration parameters. */ - protected void saveConfigs() { + protected void resetAndSave() { getValues(); + resetStatus(); configMgr.saveConfigXml(); configMgr.saveAdjacentAreaConfigXml(); } @@ -1410,27 +1410,6 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements return false; } - public boolean formIsValid(String area, String latString, String lonString) { - boolean retVal = true; - if (area.equals("") || area.length() != 6 - || (area.charAt(2) != 'C' && area.charAt(2) != 'Z')) { - displayInputErrorMsg("Invalid Area ID = '" - + area - + "' entered.\n" - + "Please enter a correctly formatted Area ID:\n" - + "Zone ID must have six characters.\n" - + "A third character should be C for county and Z for marine zone.\n" - + "Use only capital characters."); - retVal = false; - } - if (latString == null || latString.isEmpty() || lonString == null - || lonString.isEmpty()) { - latLonErrorMsg(latString, lonString); - retVal = false; - } - return retVal; - } - /* * (non-Javadoc) * @@ -1558,35 +1537,6 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements return state; } - public java.util.List getMaZones() { - return maZones; - } - - public java.util.List getMaStations() { - return maStations; - } - - public java.util.List getAdditionalZones() { - return additionalZones; - } - - public java.util.List getAdditionalStns() { - return additionalStns; - } - - /** - * Displays Input Error Message - * - * @param msg - */ - public void displayInputErrorMsg(String msg) { - MessageBox messageBox = new MessageBox(shell, SWT.ICON_INFORMATION - | SWT.OK); - messageBox.setText("Invalid input"); - messageBox.setMessage(msg); - messageBox.open(); - } - /** * Gets Configuration manager. * diff --git a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/ZoneTableDlg.java b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/ZoneTableDlg.java index 63fa192cfd..650aa52876 100755 --- a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/ZoneTableDlg.java +++ b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/ZoneTableDlg.java @@ -94,8 +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. * 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. * * * @@ -259,6 +259,9 @@ 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(); } @@ -454,16 +457,12 @@ public abstract class ZoneTableDlg extends CaveSWTDialog implements * their current values */ setZoneSortColumnAndDirection(); - // 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(); - } + zoneTblData = obData.getZoneTableData(date); + zoneTblData + .setSortColumnAndDirection(zoneSortColumn, zoneSortDirection); + zoneTblData.sortData(); + zoneTable.setTableData(zoneTblData); + zoneTable.table.redraw(); } /** @@ -495,7 +494,7 @@ public abstract class ZoneTableDlg extends CaveSWTDialog implements /** * Sets Column and Sort Direction for Zone table. */ - public void setZoneSortColumnAndDirection() { + protected void setZoneSortColumnAndDirection() { if (zoneTblData != null) { zoneSortColumn = zoneTblData.getSortColumn(); zoneSortDirection = zoneTblData.getSortDirection(); @@ -605,9 +604,6 @@ 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(); @@ -739,14 +735,10 @@ public abstract class ZoneTableDlg extends CaveSWTDialog implements .getTableCellData(0).getCellText(); // Set dialog index String dialogID = appName.name() + station; - ObsHistType histType = null; - if (configMgr != null) { - String strHistType = configMgr - .getStationType(selectedZone, station); - histType = ObsHistType.valueOf(strHistType); - } - if (histType == null) - return; + String strHistType = getMonitorAreaConfigInstance().getStationType( + selectedZone, station); + ObsHistType histType = ObsHistType.valueOf(strHistType); + /** * For Snow monitor, no history table is displayed for a Maritime * station @@ -971,4 +963,21 @@ public abstract class ZoneTableDlg extends CaveSWTDialog implements } return varName; } + + /** + * Gets Configuration manager. + * + * @return manager + */ + protected abstract FSSObsMonitorConfigurationManager getMonitorAreaConfigInstance(); + + /** + * Refreshes Zone Table. + * + * @param obData + */ + public void refreshZoneTableData(ObMultiHrsReports obData) { + obData.getObHourReports().updateZones(); + this.updateTableDlg(obData.getObHourReports()); + } } diff --git a/edexOsgi/com.raytheon.uf.common.monitor/src/com/raytheon/uf/common/monitor/MonitorAreaUtils.java b/edexOsgi/com.raytheon.uf.common.monitor/src/com/raytheon/uf/common/monitor/MonitorAreaUtils.java index c0b203e847..e5ed56f511 100644 --- a/edexOsgi/com.raytheon.uf.common.monitor/src/com/raytheon/uf/common/monitor/MonitorAreaUtils.java +++ b/edexOsgi/com.raytheon.uf.common.monitor/src/com/raytheon/uf/common/monitor/MonitorAreaUtils.java @@ -35,7 +35,6 @@ import com.vividsolutions.jts.io.WKTWriter; * Apr 30, 2014 3086 skorolev Replaced MonitorConfigurationManager with FSSObsMonitorConfigurationManager * Oct 17, 2014 2757 skorolev Corrected SQL in the getAdjacentZones to avoid duplicates. * Nov 03, 2014 3741 skorolev Updated getZoneCenter and added getStationCenter methods. - * Dec 02, 2014 3841 skorolev Fixed possible duplicates in SQL expression. * * * @@ -192,8 +191,7 @@ public class MonitorAreaUtils { + zoneEnvelope + "', -1), the_geom) " + "and (catalogtype = 1 or catalogtype = 33 or catalogtype = 32 or catalogtype = 1000) order by stationid asc"; - // 1= CAT_TYPE_ICAO, 33=CAT_TYPE_CMAN , - // 32=CAT_TYPE_BUOY_FXD 1000=CAT_TYPE_MESONET see ObStation.java + ISpatialQuery sq = SpatialQueryFactory.create(); Object[] results = sq.dbRequest(sql, META_DB); if (results.length != 0) { @@ -601,9 +599,7 @@ public class MonitorAreaUtils { Coordinate stnCenter = null; ISpatialQuery sq = null; String sql = "select AsBinary(the_geom) from common_obs_spatial where stationid = '" - + stationid - + "'" - + "and (catalogtype = 1 or catalogtype = 33 or catalogtype = 32 or catalogtype = 1000)"; + + stationid + "'"; sq = SpatialQueryFactory.create(); Object results[] = sq.dbRequest(sql, "metadata"); if (results.length > 0) { diff --git a/edexOsgi/com.raytheon.uf.common.monitor/src/com/raytheon/uf/common/monitor/config/FSSObsMonitorConfigurationManager.java b/edexOsgi/com.raytheon.uf.common.monitor/src/com/raytheon/uf/common/monitor/config/FSSObsMonitorConfigurationManager.java old mode 100644 new mode 100755 index c1dad12e96..8e360b004e --- a/edexOsgi/com.raytheon.uf.common.monitor/src/com/raytheon/uf/common/monitor/config/FSSObsMonitorConfigurationManager.java +++ b/edexOsgi/com.raytheon.uf.common.monitor/src/com/raytheon/uf/common/monitor/config/FSSObsMonitorConfigurationManager.java @@ -67,7 +67,6 @@ import com.raytheon.uf.common.status.UFStatus.Priority; * May 13 2014 3133 njensen getStationType returns String instead of ObsHistType * May 15 2014 3086 skorolev Renamed from MonitorConfigurationManager. Replaces three separate area configuration managers with one. * Sep 04 2014 3220 skorolev Added fileUpdated method. - * Nov 21 2014 3841 skorolev Corrected addArea, addAdjArea and added getAdjAreaConfigXml. * * * @@ -128,21 +127,15 @@ public class FSSObsMonitorConfigurationManager implements ss, fog, snow }; - /** Instance of SAFESEAS monitor configuration manager. */ - private static FSSObsMonitorConfigurationManager ssInstance = new FSSObsMonitorConfigurationManager( - MonName.ss.name()); - - /** Instance of Fog monitor configuration manager. */ - private static FSSObsMonitorConfigurationManager fogInstance = new FSSObsMonitorConfigurationManager( - MonName.fog.name()); - - /** Instance of SNOW monitor configuration manager. */ - private static FSSObsMonitorConfigurationManager snowInstance = new FSSObsMonitorConfigurationManager( - MonName.snow.name()); - /** Localization Area Configuration File. */ private LocalizationFile lacf = null; + /** Configuration XML is updated and saved */ + protected boolean isPopulated; + + /** Singleton instance of this class */ + private static FSSObsMonitorConfigurationManager instance = null; + /** * Private Constructor * @@ -150,6 +143,7 @@ public class FSSObsMonitorConfigurationManager implements */ public FSSObsMonitorConfigurationManager(String monitorName) { setMonitorName(monitorName); + setPopulated(false); // Avoid confusion in file path if (monitorName == MonName.ss.name()) { pluginName = "safeseas"; @@ -169,6 +163,21 @@ public class FSSObsMonitorConfigurationManager implements readConfigXml(); } + /** + * Get an instance of Configuration manager for FSSObs monitors. + * + * @param monitor + * Name of monitor + * @return Instance of manager + */ + public static synchronized FSSObsMonitorConfigurationManager getInstance( + String monitor) { + if (instance == null) { + instance = new FSSObsMonitorConfigurationManager(monitor); + } + return instance; + } + /** * Reads the XML configuration data for the current XML file name. filename: * monitor area config file name adjAreaFileName: adjacent areas config file @@ -184,11 +193,11 @@ public class FSSObsMonitorConfigurationManager implements LocalizationType.COMMON_STATIC, LocalizationLevel.SITE); this.currentSite = lc.getContextName(); lacf = pm.getLocalizationFile(lc, configFileName); - lacf.addFileUpdatedObserver(this); String monitorAreaFilePath = lacf.getFile().getAbsolutePath(); MonAreaConfigXML configXmltmp = jaxb .unmarshalFromXmlFile(monitorAreaFilePath.toString()); configXml = configXmltmp; + setPopulated(true); } catch (Exception e) { statusHandler .handle(Priority.WARN, @@ -318,6 +327,7 @@ public class FSSObsMonitorConfigurationManager implements newXmlFile.save(); lacf = newXmlFile; lacf.addFileUpdatedObserver(this); + setPopulated(true); } catch (Exception e) { statusHandler.handle(Priority.ERROR, e.getMessage()); } @@ -358,18 +368,21 @@ public class FSSObsMonitorConfigurationManager implements * @param type * Type of zone */ - public void addArea(AreaIdXML areaXML) { + public void addArea(String areaId, ZoneType type) { List areaXmlList = configXml.getAreaIds(); boolean areaExists = false; - String areaId = areaXML.getAreaId(); for (AreaIdXML area : areaXmlList) { if (area.getAreaId().equals(areaId)) { + area.setType(type); areaExists = true; break; } } if (areaExists == false) { - configXml.addAreaId(areaXML); + AreaIdXML area = new AreaIdXML(); + area.setAreaId(areaId); + area.setType(type); + configXml.addAreaId(area); if (!addedZones.contains(areaId)) { addedZones.add(areaId); } @@ -528,11 +541,11 @@ public class FSSObsMonitorConfigurationManager implements } /** - * Gets the zones where station is monitoring + * Gets an area of a station. * * @param stationId - * The station to get the zones - * @return List of zones + * The station to get the area + * @return List of areas */ public List getAreaByStationId(String stationId) { List results = new ArrayList(); @@ -672,23 +685,6 @@ public class FSSObsMonitorConfigurationManager implements return null; } - /** - * Gets an AdjAreaXml. - * - * @param zone - * from additional list - * @return - */ - public AreaIdXML getAdjAreaXML(String zone) { - List areaList = adjAreaConfigXml.getAreaIds(); - for (AreaIdXML adjAreaXml : areaList) { - if (adjAreaXml.getAreaId().equals(zone)) { - return adjAreaXml; - } - } - return null; - } - /** * Removes an area from the monitoring area. * @@ -792,15 +788,6 @@ public class FSSObsMonitorConfigurationManager implements return configXml; } - /** - * Gets Adjacent Configuration Xml - * - * @return the adjAreaConfigXml - */ - public MonAreaConfigXML getAdjAreaConfigXml() { - return adjAreaConfigXml; - } - /** * Gets Added Zones * @@ -930,7 +917,6 @@ 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)); @@ -967,6 +953,24 @@ public class FSSObsMonitorConfigurationManager implements FSSObsMonitorConfigurationManager.monitorName = monitorName; } + /** + * Flag is true if config file updated and saved. + * + * @return + */ + public boolean isPopulated() { + return isPopulated; + } + + /** + * Sets flag indicating that config file has been updated and saved. + * + * @param isPopulated + */ + public void setPopulated(boolean isPopulated) { + this.isPopulated = isPopulated; + } + /** * Remove Adjacent Area. * @@ -985,49 +989,24 @@ public class FSSObsMonitorConfigurationManager implements /** * Add Adjacent Area. * - * @param area + * @param areaId + * @param type */ - public void addAdjArea(AreaIdXML areaXML) { + public void addAdjArea(String areaId, ZoneType type) { List adjAreaList = adjAreaConfigXml.getAreaIds(); boolean areaExists = false; for (AreaIdXML area : adjAreaList) { - if (area.getAreaId().equals(areaXML.getAreaId())) { + if (area.getAreaId().equals(areaId)) { + area.setType(type); areaExists = true; break; } } if (areaExists == false) { - adjAreaConfigXml.addAreaId(areaXML); + AreaIdXML area = new AreaIdXML(); + area.setAreaId(areaId); + area.setType(type); + adjAreaConfigXml.addAreaId(area); } } - - /** - * Get Fog monitor area configuration manager. - * - * @return - */ - public static FSSObsMonitorConfigurationManager getFogObsManager() { - fogInstance.readConfigXml(); - return fogInstance; - } - - /** - * Get SAFESEAS monitor area configuration manager. - * - * @return - */ - public static FSSObsMonitorConfigurationManager getSsObsManager() { - ssInstance.readConfigXml(); - return ssInstance; - } - - /** - * Get SNOW monitor area configuration manager. - * - * @return - */ - public static FSSObsMonitorConfigurationManager getSnowObsManager() { - snowInstance.readConfigXml(); - return snowInstance; - } } diff --git a/edexOsgi/com.raytheon.uf.edex.dat.utils/src/com/raytheon/uf/edex/dat/utils/DatMenuUtil.java b/edexOsgi/com.raytheon.uf.edex.dat.utils/src/com/raytheon/uf/edex/dat/utils/DatMenuUtil.java old mode 100644 new mode 100755 index ca1219d22d..4bd4e31100 --- a/edexOsgi/com.raytheon.uf.edex.dat.utils/src/com/raytheon/uf/edex/dat/utils/DatMenuUtil.java +++ b/edexOsgi/com.raytheon.uf.edex.dat.utils/src/com/raytheon/uf/edex/dat/utils/DatMenuUtil.java @@ -43,6 +43,7 @@ import com.raytheon.uf.common.monitor.config.FFMPRunConfigurationManager; import com.raytheon.uf.common.monitor.config.FFMPSourceConfigurationManager; import com.raytheon.uf.common.monitor.config.FFMPSourceConfigurationManager.DATA_TYPE; import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager; +import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager.MonName; import com.raytheon.uf.common.monitor.config.SCANRunSiteConfigurationManager; import com.raytheon.uf.common.monitor.xml.FFMPRunXML; import com.raytheon.uf.common.monitor.xml.ProductRunXML; @@ -478,29 +479,30 @@ public class DatMenuUtil extends AbstractMenuUtil { } /** - * Creates SAFESEAS Menu. + * Creates Safeseas Menu. */ private void createSafeseasMenu() { FSSObsMonitorConfigurationManager ssConfig = FSSObsMonitorConfigurationManager - .getSsObsManager(); - Set ssStns = ssConfig.getStationIDs(); - StringBuilder stations = new StringBuilder(); - for (String s : ssStns) { - if (stations.length() > 0) { - stations.append(","); + .getInstance(MonName.ss.name()); + Set ssStns = ssConfig.getStationIDs(); + StringBuilder stations = new StringBuilder(); + for (String s : ssStns) { + if (stations.length() > 0) { + stations.append(","); + } + stations.append(s); } - stations.append(s); - } - String ssStations = stations.toString(); - CommonMenuContributionFile safeMenuContributionFile = new CommonMenuContributionFile(); - safeMenuContributionFile.contribution = new CommonIncludeMenuItem[1]; - safeMenuContributionFile.contribution[0] = new CommonIncludeMenuItem(); - safeMenuContributionFile.contribution[0] = processOtherContribution( - ssStations, "menus/safeseas/baseSafeSeas.xml", - "menu:obs?before=EndOfMaritime", "SAFESEAS", - safeMenuContributionFile.contribution[0]); - toXml(safeMenuContributionFile, "menus" + File.separator + "safeseas" - + File.separator + "index.xml"); + String ssStations = stations.toString(); + CommonMenuContributionFile safeMenuContributionFile = new CommonMenuContributionFile(); + safeMenuContributionFile.contribution = new CommonIncludeMenuItem[1]; + safeMenuContributionFile.contribution[0] = new CommonIncludeMenuItem(); + safeMenuContributionFile.contribution[0] = processOtherContribution( + ssStations, "menus/safeseas/baseSafeSeas.xml", + "menu:obs?before=EndOfMaritime", "SAFESEAS", + safeMenuContributionFile.contribution[0]); + toXml(safeMenuContributionFile, "menus" + File.separator + + "safeseas" + File.separator + "index.xml"); + ssConfig = null; } /** @@ -508,51 +510,53 @@ public class DatMenuUtil extends AbstractMenuUtil { */ private void createFogMenu() { FSSObsMonitorConfigurationManager fogConfig = FSSObsMonitorConfigurationManager - .getFogObsManager(); - Set fogStns = fogConfig.getStationIDs(); - StringBuilder stations = new StringBuilder(); - for (String s : fogStns) { - if (stations.length() > 0) { - stations.append(","); + .getInstance(MonName.fog.name()); + Set fogStns = fogConfig.getStationIDs(); + StringBuilder stations = new StringBuilder(); + for (String s : fogStns) { + if (stations.length() > 0) { + stations.append(","); + } + stations.append(s); } - stations.append(s); - } - String fogStations = stations.toString(); - CommonMenuContributionFile fogMenuContributionFile = new CommonMenuContributionFile(); - fogMenuContributionFile.contribution = new CommonIncludeMenuItem[1]; - fogMenuContributionFile.contribution[0] = new CommonIncludeMenuItem(); - fogMenuContributionFile.contribution[0] = processOtherContribution( - fogStations, "menus/fog/baseFog.xml", - "menu:obs?after=FOGPLACEHOLDER", "Fog Monitor", - fogMenuContributionFile.contribution[0]); - toXml(fogMenuContributionFile, "menus" + File.separator + "fog" - + File.separator + "index.xml"); + String fogStations = stations.toString(); + CommonMenuContributionFile fogMenuContributionFile = new CommonMenuContributionFile(); + fogMenuContributionFile.contribution = new CommonIncludeMenuItem[1]; + fogMenuContributionFile.contribution[0] = new CommonIncludeMenuItem(); + fogMenuContributionFile.contribution[0] = processOtherContribution( + fogStations, "menus/fog/baseFog.xml", + "menu:obs?after=FOGPLACEHOLDER", "Fog Monitor", + fogMenuContributionFile.contribution[0]); + toXml(fogMenuContributionFile, "menus" + File.separator + "fog" + + File.separator + "index.xml"); + fogConfig = null; } /** - * Creates SNOW Menu. + * Creates Snow Menu. */ private void createSnowMenu() { FSSObsMonitorConfigurationManager snowConfig = FSSObsMonitorConfigurationManager - .getSnowObsManager(); - Set snowStns = snowConfig.getStationIDs(); - StringBuilder stations = new StringBuilder(); - for (String s : snowStns) { - if (stations.length() > 0) { - stations.append(","); + .getInstance(MonName.snow.name()); + Set snowStns = snowConfig.getStationIDs(); + StringBuilder stations = new StringBuilder(); + for (String s : snowStns) { + if (stations.length() > 0) { + stations.append(","); + } + stations.append(s); } - stations.append(s); - } - String snowStations = stations.toString(); - CommonMenuContributionFile snowMenuContributionFile = new CommonMenuContributionFile(); - snowMenuContributionFile.contribution = new CommonIncludeMenuItem[1]; - snowMenuContributionFile.contribution[0] = new CommonIncludeMenuItem(); - snowMenuContributionFile.contribution[0] = processOtherContribution( - snowStations, "menus/snow/baseSnow.xml", - "menu:obs?after=SNOWPLACEHOLDER", "SNOW", - snowMenuContributionFile.contribution[0]); - toXml(snowMenuContributionFile, "menus" + File.separator + "snow" - + File.separator + "index.xml"); + String snowStations = stations.toString(); + CommonMenuContributionFile snowMenuContributionFile = new CommonMenuContributionFile(); + snowMenuContributionFile.contribution = new CommonIncludeMenuItem[1]; + snowMenuContributionFile.contribution[0] = new CommonIncludeMenuItem(); + snowMenuContributionFile.contribution[0] = processOtherContribution( + snowStations, "menus/snow/baseSnow.xml", + "menu:obs?after=SNOWPLACEHOLDER", "SNOW", + snowMenuContributionFile.contribution[0]); + toXml(snowMenuContributionFile, "menus" + File.separator + "snow" + + File.separator + "index.xml"); + snowConfig = null; } /** diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.fog/src/com/raytheon/uf/edex/plugin/fog/common/FogConfig.java b/edexOsgi/com.raytheon.uf.edex.plugin.fog/src/com/raytheon/uf/edex/plugin/fog/common/FogConfig.java index 95493dcd88..d94718077d 100644 --- a/edexOsgi/com.raytheon.uf.edex.plugin.fog/src/com/raytheon/uf/edex/plugin/fog/common/FogConfig.java +++ b/edexOsgi/com.raytheon.uf.edex.plugin.fog/src/com/raytheon/uf/edex/plugin/fog/common/FogConfig.java @@ -132,6 +132,7 @@ public class FogConfig { // our new coverage boundaries including adjacent areas Geometry monitorAreaGeo = AdjacentWfoMgr.getAdjacentAreas(getCwa()); // (SK) Geometry monitorAreaGeo = + // FogDbUtils.getMonitoringAreaGeometry(filter.getCwaGeometry(),getCwa()); setCenter(monitorAreaGeo.getCentroid().getCoordinate()); Coordinate[] coords = monitorAreaGeo.getEnvelope().getCoordinates(); this.upperLeftCorner = coords[1]; diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.fssobs/src/com/raytheon/uf/edex/plugin/fssobs/FSSObsDataTransform.java b/edexOsgi/com.raytheon.uf.edex.plugin.fssobs/src/com/raytheon/uf/edex/plugin/fssobs/FSSObsDataTransform.java index 3add4ab13a..ba591d6da5 100644 --- a/edexOsgi/com.raytheon.uf.edex.plugin.fssobs/src/com/raytheon/uf/edex/plugin/fssobs/FSSObsDataTransform.java +++ b/edexOsgi/com.raytheon.uf.edex.plugin.fssobs/src/com/raytheon/uf/edex/plugin/fssobs/FSSObsDataTransform.java @@ -34,7 +34,7 @@ import com.raytheon.uf.common.time.util.TimeUtil; import com.raytheon.uf.edex.decodertools.time.TimeTools; /** - * Provides a transform from FSSObsRecord to PointDataContainer and vice versa. + * TODO Add Description * *
  * 
@@ -42,9 +42,8 @@ import com.raytheon.uf.edex.decodertools.time.TimeTools;
  * 
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
- * Dec  3, 2010            skorolev    Initial creation
+ * Dec 3, 2010            skorolev     Initial creation
  * Jul 23, 2014 3410       bclement    location changed to floats
- * Dec 04, 2014 3873       skorolev    Fixed assigning timeObs for maritime record.
  * 
  * 
* @@ -54,663 +53,640 @@ import com.raytheon.uf.edex.decodertools.time.TimeTools; public class FSSObsDataTransform { - private FSSObsDAO dao; + private FSSObsDAO dao; - private static PointDataDescription fsspdd; + private static PointDataDescription fsspdd; - public static PointDataContainer pdc; + public static PointDataContainer pdc; - public FSSObsDataTransform() throws JAXBException, PluginException { - this.dao = new FSSObsDAO("fssobs"); - fsspdd = dao.getPointDataDescription(null); - this.setPdc(PointDataContainer.build(fsspdd)); - } + public FSSObsDataTransform() throws JAXBException, PluginException { + this.dao = new FSSObsDAO("fssobs"); + fsspdd = dao.getPointDataDescription(null); + this.setPdc(PointDataContainer.build(fsspdd)); + } - public static final float MISSING = -9999.0f; + public static final float MISSING = -9999.0f; - // ------------------ params in the FSSObsRecord---------------------------- + // ------------------ params in the FSSObsRecord---------------------------- - private static final String CEILING = "ceiling"; + private static final String CEILING = "ceiling"; + private static final String DEWPOINT = "dewpoint"; + private static final String DEWPOINT_DEPR = "dewpointDepr"; + private static final String FROSTBITE_TIME = "frostbiteTime"; + private static final String HORIZONTAL_VIS = "horzVisibility"; + private static final String HOURLY_PRECIP = "hourlyPrecip"; + private static final String MAX_WIND_SPEED = "maxWindSpeed"; + private static final String PLATFORM_ID = "platformId"; + private static final String PRES_WEATHER = "presWeather"; + private static final String PRESS_CHANGE3_HOUR = "pressChange3Hour"; + private static final String PRESS_CHANGE_CHAR = "pressChangeChar"; + private static final String PRESS_ALTIMETER = "pressureAltimeter"; + private static final String PRI_SWELL_WV_DIR = "primarySwellWaveDir"; + private static final String PRI_SWELL_WV_HGT = "primarySwellWaveHeight"; + private static final String PRI_SWELL_WV_PD = "primarySwellWavePeriod"; + private static final String RAW_MESSAGE = "rawMessage"; + private static final String REL_HUMIDITY = "relativeHumidity"; + private static final String SEA_LEVEL_PRESS = "seaLevelPress"; + private static final String SEA_SFC_TEMP = "seaSurfaceTemp"; + private static final String SEC_SWELL_WV_DIR = "secondarySwellWaveDir"; + private static final String SEC_SWELL_WV_HGT = "secondarySwellWaveHeight"; + private static final String SEC_SWELL_WV_PD = "secondarySwellWavePeriod"; + private static final String SKY_COVER = "skyCover"; + private static final String SNOW_INC_HOURLY = "snincrHourly"; + private static final String SNOW_INC_TOTAL = "snincrTotal"; + private static final String SNOW_DEPTH = "snowDepth"; + private static final String STATION_NAME = "stnName"; + private static final String TEMPERATURE = "temperature"; + private static final String TIME_OBS = "timeObs"; + private static final String REF_HOUR = "refHour"; + private static final String CLOUD_AMOUNT_TOT = "totCloudAmount"; + private static final String VISIBILITY = "visibility"; + private static final String WV_HGT = "waveHeight"; + private static final String WV_PD = "wavePeriod"; + private static final String WV_STEEPNESS = "waveSteepness"; + private static final String WIND_DIR = "windDir"; + private static final String WIND_GUST = "windGust"; + private static final String WIND_SPEED = "windSpeed"; - private static final String DEWPOINT = "dewpoint"; + // ------------------Common params (From OBS + // plugin)---------------------------- + private static final String ALTIMETER = "altimeter"; - private static final String DEWPOINT_DEPR = "dewpointDepr"; + // private static final String WIND_DIR_STR = "windDirStr"; - private static final String FROSTBITE_TIME = "frostbiteTime"; + // private static final String DP_FROM_TENTHS = "dpFromTenths"; - private static final String HORIZONTAL_VIS = "horzVisibility"; + // private static final String TEMP_FROM_TENTHS = "tempFromTenths"; - private static final String HOURLY_PRECIP = "hourlyPrecip"; + private static final String VERT_VISIBILITY = "vertVisibility"; - private static final String MAX_WIND_SPEED = "maxWindSpeed"; + private static final String LONGITUDE = "longitude"; - private static final String PLATFORM_ID = "platformId"; + private static final String LATITUDE = "latitude"; - private static final String PRES_WEATHER = "presWeather"; + private static final String ELEVATION = "elevation"; - private static final String PRESS_CHANGE3_HOUR = "pressChange3Hour"; + private static final String STATION_ID = "stationId"; - private static final String PRESS_CHANGE_CHAR = "pressChangeChar"; + private static final String REPORT_TYPE = "reportType"; - private static final String PRESS_ALTIMETER = "pressureAltimeter"; + private static final String RAW_METAR = "rawMETAR"; - private static final String PRI_SWELL_WV_DIR = "primarySwellWaveDir"; + private static final String SKY_COVER_TYPE = "skyCoverType"; - private static final String PRI_SWELL_WV_HGT = "primarySwellWaveHeight"; + private static final String SKY_LAYER_BASE = "skyLayerBase"; - private static final String PRI_SWELL_WV_PD = "primarySwellWavePeriod"; + // ---------------From SFCOBS ------------------------------------- - private static final String RAW_MESSAGE = "rawMessage"; + private static final String RAW_REPORT = "rawReport"; - private static final String REL_HUMIDITY = "relativeHumidity"; + private static final String HI_RES_WV_HGT = "highResWaveHeight"; - private static final String SEA_LEVEL_PRESS = "seaLevelPress"; + private static final String PEAK_WIND_SPEED = "peakWindSpeed"; - private static final String SEA_SFC_TEMP = "seaSurfaceTemp"; + private static final String PRECIP1_HOUR = "precip1Hour"; - private static final String SEC_SWELL_WV_DIR = "secondarySwellWaveDir"; + public static final String OBS_PARAMS_LIST; - private static final String SEC_SWELL_WV_HGT = "secondarySwellWaveHeight"; + // ----------------From LDADMESOWEST------------------------------- - private static final String SEC_SWELL_WV_PD = "secondarySwellWavePeriod"; + private static final String STORAGE_TYPE = "storageType"; - private static final String SKY_COVER = "skyCover"; + private static final String DATA_PROVIDER = "dataProvider"; - private static final String SNOW_INC_HOURLY = "snincrHourly"; + private static final String HOME_WFO = "homeWFO"; - private static final String SNOW_INC_TOTAL = "snincrTotal"; + private static final String OBSERVATION_TIME = "observationTime"; - private static final String SNOW_DEPTH = "snowDepth"; + private static final String PROVIDER_ID = "providerId"; - private static final String STATION_NAME = "stnName"; + private static final String HANDBOOK5_ID = "handbook5Id"; - private static final String TEMPERATURE = "temperature"; + private static final String STATION_TYPE = "stationType"; - private static final String TIME_OBS = "timeObs"; + private static final String REPORT_TIME = "reportTime"; - private static final String REF_HOUR = "refHour"; + private static final String RECEIVED_TIME = "receivedTime"; - private static final String CLOUD_AMOUNT_TOT = "totCloudAmount"; + private static final String NUMERICAL_WMO_ID = "numericWMOid"; - private static final String VISIBILITY = "visibility"; + private static final String DATA_PLATFORM_TYPE = "dataPlatformType"; - private static final String WV_HGT = "waveHeight"; + private static final String PLATFORM_TRUE_DIRECTION = "platformTrueDirection"; - private static final String WV_PD = "wavePeriod"; + private static final String PLARFORM_TRUE_SPEED = "platformTrueSpeed"; - private static final String WV_STEEPNESS = "waveSteepness"; + private static final String TEMP_CHANGE_TIME = "tempChangeTime"; - private static final String WIND_DIR = "windDir"; + private static final String WET_BULB_TEMPERATURE = "wetBulbTemperature"; - private static final String WIND_GUST = "windGust"; + private static final String RH_CHANGE_TIME = "rhChangeTime"; - private static final String WIND_SPEED = "windSpeed"; + private static final String STATION_PRESSURE = "stationPressure"; - // ------------------Common params (From OBS - // plugin)---------------------------- - private static final String ALTIMETER = "altimeter"; + private static final String STATION_PRESS_CHANGE_TIME = "stationPressChangeTime"; - // private static final String WIND_DIR_STR = "windDirStr"; + private static final String WIND_DIR_CHANGE_TIME = "windDirChangeTime"; - // private static final String DP_FROM_TENTHS = "dpFromTenths"; + private static final String WIND_SPEED_CHANGE_TIME = "windSpeedChangeTime"; - // private static final String TEMP_FROM_TENTHS = "tempFromTenths"; + private static final String WIND_GUST_CHANGE_TIME = "windGustChangeTime"; - private static final String VERT_VISIBILITY = "vertVisibility"; + private static final String WIND_DIR_MIN = "windDirMin"; - private static final String LONGITUDE = "longitude"; + private static final String WIND_DIR_MAX = "windDirMax"; - private static final String LATITUDE = "latitude"; + private static final String VISIBILITY_STATUS = "visibilityStatus"; - private static final String ELEVATION = "elevation"; + private static final String TOTAL_CLOUD_COVER = "totalCloudCover"; - private static final String STATION_ID = "stationId"; + private static final String CLOUD_BASE_HEIGHT = "cloudBaseHeight"; - private static final String REPORT_TYPE = "reportType"; + private static final String LOW_LEVEL_CLOUD_TYPE = "lowLevelCloudType"; - private static final String RAW_METAR = "rawMETAR"; + private static final String MID_LEVEL_CLOUD_TYPE = "midLevelCloudType"; - private static final String SKY_COVER_TYPE = "skyCoverType"; + private static final String HIGH_LEVEL_CLOUD_TYPE = "highLevelCloudType"; - private static final String SKY_LAYER_BASE = "skyLayerBase"; + private static final String MAX_TEMP_RECORD_PERIOD = "maxTempRecordPeriod"; - // ---------------From SFCOBS ------------------------------------- + private static final String MAXIMUM_TEMPERATURE = "maximumTemperature"; - private static final String RAW_REPORT = "rawReport"; + private static final String MIN_TEMP_RECORD_PERIOD = "minTempRecordPeriod"; - private static final String HI_RES_WV_HGT = "highResWaveHeight"; + private static final String MINIMUM_TEMPERATURE = "minimumTemperature"; - private static final String PEAK_WIND_SPEED = "peakWindSpeed"; + private static final String PRECIP_ACCUM = "precipAccum"; - private static final String PRECIP1_HOUR = "precip1Hour"; + private static final String PRECIP_TYPE = "precipType"; - private static final String TIME_NOMINAL = "timeNominal"; + private static final String PRECIP_INTENSITY = "precipIntensity"; - public static final String OBS_PARAMS_LIST; + private static final String TIME_SINCE_LAST_PCP = "timeSinceLastPcp"; - // ----------------From LDADMESOWEST------------------------------- + private static final String SOLAR_RADIATION = "solarRadiation"; - private static final String STORAGE_TYPE = "storageType"; + private static final String SOLAR_RAD_CHANGE_TIME = "solarRadChangeTime"; - private static final String DATA_PROVIDER = "dataProvider"; + private static final String SEA_SURFACE_TEMP = "seaSurfaceTemp"; - private static final String HOME_WFO = "homeWFO"; + private static final String WAVE_PERIOD = "wavePeriod"; - private static final String OBSERVATION_TIME = "observationTime"; + private static final String WAVE_HEIGHT = "waveHeight"; - private static final String PROVIDER_ID = "providerId"; + private static final String RAW_MESONET = "rawMessage"; - private static final String HANDBOOK5_ID = "handbook5Id"; + private static final String PRESSURE = "pressure"; - private static final String STATION_TYPE = "stationType"; + private static final String SEA_LEVEL_PRESSURE = "seaLevelPressure"; - private static final String REPORT_TIME = "reportTime"; + private static final String PRECIP_RATE = "precipRate"; - private static final String RECEIVED_TIME = "receivedTime"; + private static final String FUEL_TEMPERATURE = "fuelTemperature"; - private static final String NUMERICAL_WMO_ID = "numericWMOid"; + private static final String FUEL_MOISTURE = "fuelMoisture"; - private static final String DATA_PLATFORM_TYPE = "dataPlatformType"; + private static final String SOIL_TEMPERATURE = "soilTemperature"; - private static final String PLATFORM_TRUE_DIRECTION = "platformTrueDirection"; + private static final String SOIL_MOISTURE = "soilMoisture"; - private static final String PLARFORM_TRUE_SPEED = "platformTrueSpeed"; + static { + StringBuffer sb = new StringBuffer(); + sb.append("altimeter,"); + sb.append("windGust,"); + sb.append("windSpeed,"); + sb.append("windDir,"); + sb.append("dewpoint,"); + sb.append("temperature,"); + sb.append("precip1Hour,"); + sb.append("seaLevelPress,"); + sb.append("pressChange3Hour,"); + sb.append("pressChangeChar,"); + sb.append("visibility,"); + sb.append("vertVisibility,"); + sb.append("longitude,"); + sb.append("latitude,"); + sb.append("elevation,"); + sb.append("stationId,"); + sb.append("reportType,"); + sb.append("skyCover,"); + sb.append("skyCoverType,"); + sb.append("skyLayerBase,"); + sb.append("presWeather,"); + sb.append("rawMETAR,"); + sb.append("timeObs "); - private static final String TEMP_CHANGE_TIME = "tempChangeTime"; + OBS_PARAMS_LIST = sb.toString(); + } - private static final String WET_BULB_TEMPERATURE = "wetBulbTemperature"; - - private static final String RH_CHANGE_TIME = "rhChangeTime"; - - private static final String STATION_PRESSURE = "stationPressure"; - - private static final String STATION_PRESS_CHANGE_TIME = "stationPressChangeTime"; - - private static final String WIND_DIR_CHANGE_TIME = "windDirChangeTime"; - - private static final String WIND_SPEED_CHANGE_TIME = "windSpeedChangeTime"; - - private static final String WIND_GUST_CHANGE_TIME = "windGustChangeTime"; - - private static final String WIND_DIR_MIN = "windDirMin"; - - private static final String WIND_DIR_MAX = "windDirMax"; - - private static final String VISIBILITY_STATUS = "visibilityStatus"; - - private static final String TOTAL_CLOUD_COVER = "totalCloudCover"; - - private static final String CLOUD_BASE_HEIGHT = "cloudBaseHeight"; - - private static final String LOW_LEVEL_CLOUD_TYPE = "lowLevelCloudType"; - - private static final String MID_LEVEL_CLOUD_TYPE = "midLevelCloudType"; - - private static final String HIGH_LEVEL_CLOUD_TYPE = "highLevelCloudType"; - - private static final String MAX_TEMP_RECORD_PERIOD = "maxTempRecordPeriod"; - - private static final String MAXIMUM_TEMPERATURE = "maximumTemperature"; - - private static final String MIN_TEMP_RECORD_PERIOD = "minTempRecordPeriod"; - - private static final String MINIMUM_TEMPERATURE = "minimumTemperature"; - - private static final String PRECIP_ACCUM = "precipAccum"; - - private static final String PRECIP_TYPE = "precipType"; - - private static final String PRECIP_INTENSITY = "precipIntensity"; - - private static final String TIME_SINCE_LAST_PCP = "timeSinceLastPcp"; - - private static final String SOLAR_RADIATION = "solarRadiation"; - - private static final String SOLAR_RAD_CHANGE_TIME = "solarRadChangeTime"; - - private static final String SEA_SURFACE_TEMP = "seaSurfaceTemp"; - - private static final String WAVE_PERIOD = "wavePeriod"; - - private static final String WAVE_HEIGHT = "waveHeight"; - - private static final String RAW_MESONET = "rawMessage"; - - private static final String PRESSURE = "pressure"; - - private static final String SEA_LEVEL_PRESSURE = "seaLevelPressure"; - - private static final String PRECIP_RATE = "precipRate"; - - private static final String FUEL_TEMPERATURE = "fuelTemperature"; - - private static final String FUEL_MOISTURE = "fuelMoisture"; - - private static final String SOIL_TEMPERATURE = "soilTemperature"; - - private static final String SOIL_MOISTURE = "soilMoisture"; - - static { - StringBuffer sb = new StringBuffer(); - sb.append("altimeter,"); - sb.append("windGust,"); - sb.append("windSpeed,"); - sb.append("windDir,"); - sb.append("dewpoint,"); - sb.append("temperature,"); - sb.append("precip1Hour,"); - sb.append("seaLevelPress,"); - sb.append("pressChange3Hour,"); - sb.append("pressChangeChar,"); - sb.append("visibility,"); - sb.append("vertVisibility,"); - sb.append("longitude,"); - sb.append("latitude,"); - sb.append("elevation,"); - sb.append("stationId,"); - sb.append("reportType,"); - sb.append("skyCover,"); - sb.append("skyCoverType,"); - sb.append("skyLayerBase,"); - sb.append("presWeather,"); - sb.append("rawMETAR,"); - sb.append("timeObs "); - - OBS_PARAMS_LIST = sb.toString(); - } - - public static FSSObsRecord fromMetarRecord(PointDataContainer container) - throws JAXBException { - container.setCurrentSz(container.getAllocatedSz()); - PointDataView pdv = container.readRandom(0); - FSSObsRecord fssr = new FSSObsRecord(); - fssr.setReportType(pdv.getString(REPORT_TYPE)); - SurfaceObsLocation loc = new SurfaceObsLocation(); - loc.setStationId(pdv.getString(STATION_ID)); + public static FSSObsRecord fromMetarRecord(PointDataContainer container) + throws JAXBException { + container.setCurrentSz(container.getAllocatedSz()); + PointDataView pdv = container.readRandom(0); + FSSObsRecord fssr = new FSSObsRecord(); + fssr.setReportType(pdv.getString(REPORT_TYPE)); + SurfaceObsLocation loc = new SurfaceObsLocation(); + loc.setStationId(pdv.getString(STATION_ID)); float lat = pdv.getNumber(LATITUDE).floatValue(); float lon = pdv.getNumber(LONGITUDE).floatValue(); - loc.assignLocation(lat, lon); - loc.setElevation(pdv.getNumber(ELEVATION).intValue()); - fssr.setLocation(loc); - String stId = FSSObsUtils.getStationName(loc.getStationId()); - fssr.setPlatformId(loc.getStationId()); - fssr.setStnName(stId); - fssr.setRawMessage(pdv.getString(RAW_METAR)); - fssr.setDataTime(new DataTime(pdv.getDate(TIME_OBS))); - fssr.setTimeObs(pdv.getCalendar(TIME_OBS)); - fssr.setRefHour(TimeTools.roundToNearestHour(fssr.getTimeObs())); - // in mbar - fssr.setSeaLevelPress(pdv.getNumber(SEA_LEVEL_PRESS).floatValue()); - // in mmHg - fssr.setPressureAltimeter(pdv.getNumber(ALTIMETER).floatValue()); - fssr.setPressChange3Hour(pdv.getNumber(PRESS_CHANGE3_HOUR).floatValue()); - fssr.setPressChangeChar(pdv.getString(PRESS_CHANGE_CHAR)); - // in Fahrenheit - if (pdv.getFloat(DEWPOINT) != MISSING) { - fssr.setDewpoint(1.8f * pdv.getFloat(DEWPOINT) + 32.0f); - } - if (pdv.getFloat(TEMPERATURE) != MISSING) { - fssr.setTemperature(1.8f * pdv.getFloat(TEMPERATURE) + 32.0f); - } - // in meters - fssr.setVisibility(pdv.getNumber(VISIBILITY).floatValue()); - Number[] levels = pdv.getNumberAllLevels(SKY_LAYER_BASE); - String[] skyCov = pdv.getStringAllLevels(SKY_COVER_TYPE); - if (pdv.getNumber(VERT_VISIBILITY).floatValue() >= 0 - && pdv.getNumber(VERT_VISIBILITY).floatValue() < 1e20f - && pdv.getNumber(VERT_VISIBILITY).floatValue() != MISSING) { - fssr.setCeiling(pdv.getNumber(VERT_VISIBILITY).floatValue() / 100f); - } else { - // in feet - float ceiling = FSSObsUtils.findMetarCeilingFromLayers(skyCov, - levels); - fssr.setCeiling(ceiling); - } - fssr.setSkyCover(pdv.getStringAllLevels(SKY_COVER)); - // in inch - fssr.setHourlyPrecip(pdv.getFloat(PRECIP1_HOUR)); - - // fssr.setWindDir(Float.valueOf(pdv.getString(WIND_DIR_STR))); - fssr.setWindDir(pdv.getFloat(WIND_DIR)); - // in knotes - if (pdv.getNumber(WIND_GUST).floatValue() != MISSING) { - fssr.setWindGust(pdv.getNumber(WIND_GUST).floatValue()); - } - if (pdv.getNumber(WIND_SPEED).floatValue() != MISSING) { - fssr.setWindSpeed(pdv.getNumber(WIND_SPEED).floatValue()); - } - - fssr.setPresWeather(pdv.getStringAllLevels(PRES_WEATHER)); - - return fssr; - } - - public static final String HDR_PARAMS_LIST; - static { - StringBuffer sb = new StringBuffer(); - - sb.append("stationId,"); - sb.append("latitude,"); - sb.append("longitude,"); - sb.append("elevation,"); - sb.append("timeObs,"); - sb.append("timeNominal,"); - sb.append("reportType,"); - sb.append("rawReport,"); - sb.append("wmoHeader,"); - - HDR_PARAMS_LIST = sb.toString(); - } - - public static String SFCOBS_PARAMS_LIST = null; - static { - StringBuffer sb = new StringBuffer(); - sb.append(HDR_PARAMS_LIST); - - sb.append("temperature,"); - sb.append("dewpoint,"); - - sb.append("windSpeed,"); - sb.append("windDir,"); - sb.append("windGust,"); - - sb.append("peakWindSpeedTime,"); - sb.append("peakWindDir,"); - sb.append("peakWindSpeed,"); - - sb.append("seaLevelPress,"); - sb.append("altimeter,"); - sb.append("pressChangeChar,"); - sb.append("pressChange3Hour,"); - - sb.append("visibility,"); - sb.append("presWeather,"); - - sb.append("totCloudAmount,"); - sb.append("precip1Hour,"); - sb.append("seaSurfaceTemp,"); - sb.append("waveHeight,"); - sb.append("wavePeriod,"); - sb.append("waveSteepness,"); - - sb.append("highResWaveHeight,"); - - sb.append("primarySwellWaveDir,"); - sb.append("primarySwellWavePeriod,"); - sb.append("primarySwellWaveHeight,"); - - sb.append("secondarySwellWaveDir,"); - sb.append("secondarySwellWavePeriod,"); - sb.append("secondarySwellWaveHeight "); - - SFCOBS_PARAMS_LIST = sb.toString(); - } - - private static final String[] MESOWEST_PARAMS = { PRESS_CHANGE3_HOUR, - PRESS_CHANGE_CHAR, ALTIMETER, WIND_GUST, WIND_SPEED, DEWPOINT, - TEMPERATURE, PRES_WEATHER, VISIBILITY, LONGITUDE, LATITUDE, - STATION_NAME, STORAGE_TYPE, ELEVATION, STATION_ID, DATA_PROVIDER, - HOME_WFO, OBSERVATION_TIME, PROVIDER_ID, HANDBOOK5_ID, - STATION_TYPE, REPORT_TIME, RECEIVED_TIME, NUMERICAL_WMO_ID, - DATA_PLATFORM_TYPE, PLATFORM_TRUE_DIRECTION, PLARFORM_TRUE_SPEED, - TEMP_CHANGE_TIME, WET_BULB_TEMPERATURE, RH_CHANGE_TIME, - STATION_PRESSURE, STATION_PRESS_CHANGE_TIME, WIND_DIR_CHANGE_TIME, - WIND_SPEED_CHANGE_TIME, WIND_GUST_CHANGE_TIME, WIND_DIR_MIN, - WIND_DIR_MAX, VISIBILITY_STATUS, TOTAL_CLOUD_COVER, - CLOUD_BASE_HEIGHT, LOW_LEVEL_CLOUD_TYPE, MID_LEVEL_CLOUD_TYPE, - HIGH_LEVEL_CLOUD_TYPE, MAX_TEMP_RECORD_PERIOD, MAXIMUM_TEMPERATURE, - MIN_TEMP_RECORD_PERIOD, MINIMUM_TEMPERATURE, PRECIP_ACCUM, - PRECIP_TYPE, PRECIP_INTENSITY, TIME_SINCE_LAST_PCP, - SOLAR_RADIATION, SOLAR_RAD_CHANGE_TIME, SEA_SURFACE_TEMP, - WAVE_PERIOD, WAVE_HEIGHT, RAW_MESONET, "relHumidity", WIND_DIR, - PRESSURE, SEA_LEVEL_PRESSURE, PRECIP_RATE, FUEL_TEMPERATURE, - FUEL_MOISTURE, SOIL_TEMPERATURE, SOIL_MOISTURE, REPORT_TYPE }; - - public static final String MESOWEST_PARAMS_LIST; - static { - StringBuffer sb = new StringBuffer(); - boolean first = true; - for (String s : MESOWEST_PARAMS) { - if (!first) { - sb.append(", "); - } else { - first = false; - } - sb.append(s); - } - MESOWEST_PARAMS_LIST = sb.toString(); - } - - public static FSSObsRecord fromMaritimeRecord(PointDataContainer container) - throws JAXBException { - container.setCurrentSz(container.getAllocatedSz()); - PointDataView pdv = container.readRandom(0); - - FSSObsRecord fssr = new FSSObsRecord(); - SurfaceObsLocation loc = new SurfaceObsLocation(); - loc.setStationId(pdv.getString(STATION_ID)); - float lat = pdv.getNumber(LATITUDE).floatValue(); - float lon = pdv.getNumber(LONGITUDE).floatValue(); - loc.assignLocation(lat, lon); - loc.setElevation(pdv.getNumber(ELEVATION).intValue()); - fssr.setLocation(loc); - String stId = FSSObsUtils.getStationName(loc.getStationId()); - fssr.setPlatformId(loc.getStationId()); - fssr.setStnName(stId); - fssr.setRawMessage(pdv.getString(RAW_REPORT)); - fssr.setDataTime(new DataTime(pdv.getDate(TIME_OBS))); - fssr.setTimeObs(pdv.getCalendar(TIME_OBS)); - fssr.setRefHour(pdv.getCalendar(TIME_NOMINAL)); - // in mbar - if (pdv.getFloat(SEA_LEVEL_PRESS) != MISSING) { - fssr.setSeaLevelPress(pdv.getFloat(SEA_LEVEL_PRESS) / 100); - } - fssr.setPressureAltimeter(pdv.getNumber(ALTIMETER).floatValue()); - fssr.setPressChange3Hour(pdv.getFloat(PRESS_CHANGE3_HOUR)); - fssr.setPressChangeChar(String.valueOf(pdv.getInt(PRESS_CHANGE_CHAR))); - - // http://www.hpc.ncep.noaa.gov/html/tempconversion.shtml - // in Fahrenheit - if (pdv.getFloat(DEWPOINT) != MISSING) { - fssr.setDewpoint(1.8f * (pdv.getFloat(DEWPOINT) - 273.15f) + 32.0f); - } - if (pdv.getFloat(TEMPERATURE) != MISSING) { - fssr.setTemperature(1.8f * (pdv.getFloat(TEMPERATURE) - 273.15f) + 32.0f); - } - if (pdv.getNumber(SEA_SFC_TEMP).floatValue() != MISSING) { - fssr.setSeaSurfaceTemp(1.8f * (pdv.getNumber(SEA_SFC_TEMP) - .floatValue() - 273.15f) + 32.0f); - } - // in nautical miles - fssr.setHorzVisibility(pdv.getNumber(VISIBILITY).floatValue()); - - fssr.setWindDir(pdv.getNumber(WIND_DIR).floatValue()); - // in knotes - if (pdv.getNumber(WIND_GUST).floatValue() != MISSING) { - fssr.setWindGust(pdv.getNumber(WIND_GUST).floatValue()); - } - if (pdv.getNumber(WIND_SPEED).floatValue() != MISSING) { - fssr.setWindSpeed(pdv.getNumber(WIND_SPEED).floatValue()); - } - if (pdv.getFloat(PEAK_WIND_SPEED) != MISSING) { - fssr.setMaxWindSpeed(pdv.getFloat(PEAK_WIND_SPEED)); - } - fssr.setReportType(String.valueOf(pdv.getInt(REPORT_TYPE))); - String[] pw = new String[25]; - pw[0] = pdv.getString(PRES_WEATHER); - fssr.setPresWeather(pw); - - fssr.setHighResWaveHeight(pdv.getFloat(HI_RES_WV_HGT)); - fssr.setHourlyPrecip(pdv.getFloat(PRECIP1_HOUR)); - - fssr.setPrimarySwellWaveDir(pdv.getNumber(PRI_SWELL_WV_DIR) - .doubleValue()); - fssr.setPrimarySwellWaveHeight(pdv.getNumber(PRI_SWELL_WV_HGT) - .doubleValue()); - fssr.setPrimarySwellWavePeriod(pdv.getNumber(PRI_SWELL_WV_PD) - .intValue()); - fssr.setSecondarySwellWaveDir(pdv.getNumber(SEC_SWELL_WV_DIR) - .doubleValue()); - fssr.setSecondarySwellWaveHeight(pdv.getNumber(SEC_SWELL_WV_HGT) - .doubleValue()); - fssr.setSecondarySwellWavePeriod(pdv.getNumber(SEC_SWELL_WV_PD) - .intValue()); - fssr.setWaveHeight(pdv.getNumber(WV_HGT).doubleValue()); - fssr.setWavePeriod(pdv.getNumber(WV_PD).intValue()); - fssr.setWaveSteepness(pdv.getNumber(WV_STEEPNESS).floatValue()); - fssr.setTotCloudAmount(pdv.getInt(CLOUD_AMOUNT_TOT)); - - return fssr; - // TODO : Intermediate winds - } - - /** - * @param result - * @return - */ - public static FSSObsRecord fromLdadmesowestRecord( - PointDataContainer container) throws JAXBException { - container.setCurrentSz(container.getAllocatedSz()); - PointDataView pdv = container.readRandom(0); - FSSObsRecord fssr = new FSSObsRecord(); - fssr.setReportType(pdv.getString(REPORT_TYPE)); - SurfaceObsLocation loc = new SurfaceObsLocation(); - loc.setStationId(pdv.getString(STATION_ID)); - float lat = pdv.getNumber(LATITUDE).floatValue(); - float lon = pdv.getNumber(LONGITUDE).floatValue(); - loc.assignLocation(lat, lon); - loc.setElevation(pdv.getNumber(ELEVATION).intValue()); - fssr.setLocation(loc); - String stId = FSSObsUtils.getStationName(loc.getStationId()); - fssr.setPlatformId(loc.getStationId()); - fssr.setStnName(stId + pdv.getString(DATA_PROVIDER)); - fssr.setRawMessage(pdv.getString(RAW_MESSAGE)); - fssr.setDataTime(new DataTime(new Date(pdv.getNumber(OBSERVATION_TIME) - .longValue()))); - long to = pdv.getLong(OBSERVATION_TIME); + loc.assignLocation(lat, lon); + loc.setElevation(pdv.getNumber(ELEVATION).intValue()); + fssr.setLocation(loc); + String stId = FSSObsUtils.getStationName(loc.getStationId()); + fssr.setPlatformId(loc.getStationId()); + fssr.setStnName(stId); + fssr.setRawMessage(pdv.getString(RAW_METAR)); + fssr.setDataTime(new DataTime(new Date(pdv.getNumber(TIME_OBS) + .longValue()))); + long to = pdv.getLong(TIME_OBS); fssr.setTimeObs(TimeUtil.newGmtCalendar(new Date(to))); - fssr.setRefHour(TimeTools.roundToNearestHour(fssr.getTimeObs())); - // fssr.setCeiling(pdv.getNumber(CLOUD_BASE_HEIGHT).floatValue()); - if (pdv.getFloat(DEWPOINT) != MISSING) { - fssr.setDewpoint(1.8f * (pdv.getFloat(DEWPOINT) - 273.15f) + 32.0f); - } - fssr.setRelativeHumidity(pdv.getFloat("relHumidity")); - if (pdv.getFloat(TEMPERATURE) != MISSING) { - fssr.setTemperature(1.8f * (pdv.getFloat(TEMPERATURE) - 273.15f) + 32.0f); - } - // fssr.setHighResWaveHeight(highResWaveHeight); - // fssr.setHorzVisibility(horzVisibility); - // fssr.setHourlyPrecip(pdv.getFloat(HOURLY_PRECIP)); - // fssr.setMaxWindSpeed(maxWindSpeed); - fssr.setMessageData(pdv.getString(RAW_MESSAGE)); - fssr.setPressChange3Hour(pdv.getFloat(PRESS_CHANGE3_HOUR)); - fssr.setPressChangeChar(String.valueOf(pdv.getInt(PRESS_CHANGE_CHAR))); - fssr.setPressureAltimeter(pdv.getFloat(ALTIMETER)); // in Pascal - // fssr.setPresWeather(pdv.getStringAllLevels(PRES_WEATHER)); - // fssr.setPrimarySwellWaveDir(primarySwellWaveDir); - // fssr.setPrimarySwellWaveHeight(primarySwellWaveHeight); - // fssr.setPrimarySwellWavePeriod(primarySwellWavePeriod); - if (pdv.getFloat(SEA_LEVEL_PRESSURE) != MISSING) { - fssr.setSeaLevelPress(pdv.getFloat(SEA_LEVEL_PRESSURE) / 100); - } - if (pdv.getFloat(SEA_SURFACE_TEMP) != MISSING) { - fssr.setSeaSurfaceTemp(1.8f * (pdv.getFloat(SEA_SURFACE_TEMP) - 273.15f) + 32.0f); - } - // fssr.setSecondarySwellWaveDir(secondarySwellWaveDir); - // fssr.setSecondarySwellWaveHeight(secondarySwellWaveHeight); - // fssr.setSecondarySwellWavePeriod(secondarySwellWavePeriod); - // fssr.setSkyCover(pdv.getStringAllLevels(SKY_COVER)); - // fssr.setTotCloudAmount(pdv.getInt(TOTAL_CLOUD_COVER)); - fssr.setVisibility(pdv.getFloat(VISIBILITY)); - fssr.setWaveHeight(pdv.getNumber(WAVE_HEIGHT).doubleValue()); - fssr.setWindDir(pdv.getFloat(WIND_DIR)); - fssr.setWindGust(pdv.getFloat(WIND_GUST)); - fssr.setWindSpeed(pdv.getFloat(WIND_SPEED)); + // nominalTime + fssr.setRefHour(TimeTools.roundToNearestHour(fssr.getTimeObs())); + // in mbar + fssr.setSeaLevelPress(pdv.getNumber(SEA_LEVEL_PRESS).floatValue()); + // in mmHg + fssr.setPressureAltimeter(pdv.getNumber(ALTIMETER).floatValue()); + // Double pa = + // DecoderTools.inToPa(pdv.getNumber(ALTIMETER).doubleValue()); + // fssr.setPressureAltimeter(pa.floatValue()); + fssr.setPressChange3Hour(pdv.getNumber(PRESS_CHANGE3_HOUR).floatValue()); + fssr.setPressChangeChar(pdv.getString(PRESS_CHANGE_CHAR)); + // in Fahrenheit + if (pdv.getFloat(DEWPOINT) != MISSING) { + fssr.setDewpoint(1.8f * pdv.getFloat(DEWPOINT) + 32.0f); + } + if (pdv.getFloat(TEMPERATURE) != MISSING) { + fssr.setTemperature(1.8f * pdv.getFloat(TEMPERATURE) + 32.0f); + } + // in meters + fssr.setVisibility(pdv.getNumber(VISIBILITY).floatValue()); + Number[] levels = pdv.getNumberAllLevels(SKY_LAYER_BASE); + String[] skyCov = pdv.getStringAllLevels(SKY_COVER_TYPE); + if (pdv.getNumber(VERT_VISIBILITY).floatValue() >= 0 + && pdv.getNumber(VERT_VISIBILITY).floatValue() < 1e20f + && pdv.getNumber(VERT_VISIBILITY).floatValue() != MISSING) { + fssr.setCeiling(pdv.getNumber(VERT_VISIBILITY).floatValue() / 100f); + } else { + // in feet + float ceiling = FSSObsUtils.findMetarCeilingFromLayers(skyCov, + levels); + fssr.setCeiling(ceiling); + } + fssr.setSkyCover(pdv.getStringAllLevels(SKY_COVER)); + // in inch + fssr.setHourlyPrecip(pdv.getFloat(PRECIP1_HOUR)); - return fssr; - } + // fssr.setWindDir(Float.valueOf(pdv.getString(WIND_DIR_STR))); + fssr.setWindDir(pdv.getFloat(WIND_DIR)); + // in knotes + if (pdv.getNumber(WIND_GUST).floatValue() != MISSING) { + fssr.setWindGust(pdv.getNumber(WIND_GUST).floatValue()); + } + if (pdv.getNumber(WIND_SPEED).floatValue() != MISSING) { + fssr.setWindSpeed(pdv.getNumber(WIND_SPEED).floatValue()); + } - public static PointDataView buildView(FSSObsRecord record) { - pdc = PointDataContainer.build(fsspdd); - PointDataView pdv = pdc.append(); + fssr.setPresWeather(pdv.getStringAllLevels(PRES_WEATHER)); - pdv.setFloat(CEILING, record.getCeiling()); - pdv.setFloat(DEWPOINT, record.getDewpoint()); - pdv.setFloat(DEWPOINT_DEPR, record.getDewpointDepr()); - pdv.setFloat(FROSTBITE_TIME, record.getFrostbiteTime()); - pdv.setFloat(HORIZONTAL_VIS, record.getHorzVisibility()); - pdv.setFloat(HOURLY_PRECIP, record.getHourlyPrecip()); - pdv.setFloat(MAX_WIND_SPEED, record.getMaxWindSpeed()); - pdv.setString(PLATFORM_ID, record.getPlatformId()); - String[] weatherCondition = record.getPresWeather(); - if (weatherCondition != null) { - for (int i = 0; i < weatherCondition.length; i++) { - if (weatherCondition[i] != null) { - pdv.setString(PRES_WEATHER, weatherCondition[i], i); - } - } - } - pdv.setFloat(PRESS_CHANGE3_HOUR, record.getPressChange3Hour()); - pdv.setString(PRESS_CHANGE_CHAR, record.getPressChangeChar()); - pdv.setFloat(PRESS_ALTIMETER, record.getPressureAltimeter()); - pdv.setFloat(PRI_SWELL_WV_DIR, record.getPrimarySwellWaveDir() - .floatValue()); - pdv.setFloat(PRI_SWELL_WV_HGT, record.getPrimarySwellWaveHeight() - .floatValue()); - pdv.setInt(PRI_SWELL_WV_PD, record.getPrimarySwellWavePeriod()); - pdv.setString(RAW_MESSAGE, record.getRawMessage()); - pdv.setFloat(REL_HUMIDITY, record.getRelativeHumidity()); - pdv.setFloat(SEA_LEVEL_PRESS, record.getSeaLevelPress()); - pdv.setFloat(SEA_SFC_TEMP, record.getSeaSurfaceTemp()); - pdv.setFloat(SEC_SWELL_WV_DIR, record.getSecondarySwellWaveDir() - .floatValue()); - pdv.setFloat(SEC_SWELL_WV_HGT, record.getSecondarySwellWaveHeight() - .floatValue()); - pdv.setInt(SEC_SWELL_WV_PD, record.getSecondarySwellWavePeriod()); - if (record.getSkyCover() != null) { - String[] skyList = record.getSkyCover(); - for (int i = 0; i < skyList.length; i++) { - if (skyList[i] != null) { - pdv.setString(SKY_COVER, skyList[i], i); - } - } - } - pdv.setFloat(SNOW_INC_HOURLY, record.getSnincrHourly()); - pdv.setFloat(SNOW_INC_TOTAL, record.getSnincrTotal()); - pdv.setFloat(SNOW_DEPTH, record.getSnowDepth()); - pdv.setString(STATION_NAME, record.getStnName()); - pdv.setFloat(TEMPERATURE, record.getTemperature()); - pdv.setLong(TIME_OBS, record.getTimeObs().getTimeInMillis()); - pdv.setLong(REF_HOUR, record.getRefHour().getTimeInMillis()); - pdv.setInt(CLOUD_AMOUNT_TOT, record.getTotCloudAmount()); - pdv.setFloat(VISIBILITY, record.getVisibility()); - pdv.setFloat(WV_HGT, record.getWaveHeight().floatValue()); - pdv.setInt(WV_PD, record.getWavePeriod()); - pdv.setFloat(WV_STEEPNESS, record.getWaveSteepness()); - pdv.setFloat(WIND_DIR, record.getWindDir()); - pdv.setFloat(WIND_SPEED, record.getWindSpeed()); - pdv.setFloat(WIND_GUST, record.getWindGust()); - pdv.setFloat(HI_RES_WV_HGT, record.getHighResWaveHeight()); + return fssr; + } - // pdv.setLong(TIME_NOMINAL, record.getRefHour().getTimeInMillis()); + public static final String HDR_PARAMS_LIST; + static { + StringBuffer sb = new StringBuffer(); - record.setPointDataView(pdv); - return pdv; - } + sb.append("stationId,"); + sb.append("latitude,"); + sb.append("longitude,"); + sb.append("elevation,"); + sb.append("timeObs,"); + sb.append("timeNominal,"); + sb.append("reportType,"); + sb.append("rawReport,"); + sb.append("wmoHeader,"); - /** - * @param pdc - * the pdc to set - */ - public void setPdc(PointDataContainer pdc) { + HDR_PARAMS_LIST = sb.toString(); + } + + public static String SFCOBS_PARAMS_LIST = null; + static { + StringBuffer sb = new StringBuffer(); + sb.append(HDR_PARAMS_LIST); + + sb.append("temperature,"); + sb.append("dewpoint,"); + + sb.append("windSpeed,"); + sb.append("windDir,"); + sb.append("windGust,"); + + sb.append("peakWindSpeedTime,"); + sb.append("peakWindDir,"); + sb.append("peakWindSpeed,"); + + sb.append("seaLevelPress,"); + sb.append("altimeter,"); + sb.append("pressChangeChar,"); + sb.append("pressChange3Hour,"); + + sb.append("visibility,"); + sb.append("presWeather,"); + + sb.append("totCloudAmount,"); + sb.append("precip1Hour,"); + sb.append("seaSurfaceTemp,"); + sb.append("waveHeight,"); + sb.append("wavePeriod,"); + sb.append("waveSteepness,"); + + sb.append("highResWaveHeight,"); + + sb.append("primarySwellWaveDir,"); + sb.append("primarySwellWavePeriod,"); + sb.append("primarySwellWaveHeight,"); + + sb.append("secondarySwellWaveDir,"); + sb.append("secondarySwellWavePeriod,"); + sb.append("secondarySwellWaveHeight "); + + SFCOBS_PARAMS_LIST = sb.toString(); + } + + private static final String[] MESOWEST_PARAMS = { PRESS_CHANGE3_HOUR, + PRESS_CHANGE_CHAR, ALTIMETER, WIND_GUST, WIND_SPEED, DEWPOINT, + TEMPERATURE, PRES_WEATHER, VISIBILITY, LONGITUDE, LATITUDE, + STATION_NAME, STORAGE_TYPE, ELEVATION, STATION_ID, DATA_PROVIDER, + HOME_WFO, OBSERVATION_TIME, PROVIDER_ID, HANDBOOK5_ID, + STATION_TYPE, REPORT_TIME, RECEIVED_TIME, NUMERICAL_WMO_ID, + DATA_PLATFORM_TYPE, PLATFORM_TRUE_DIRECTION, PLARFORM_TRUE_SPEED, + TEMP_CHANGE_TIME, WET_BULB_TEMPERATURE, RH_CHANGE_TIME, + STATION_PRESSURE, STATION_PRESS_CHANGE_TIME, WIND_DIR_CHANGE_TIME, + WIND_SPEED_CHANGE_TIME, WIND_GUST_CHANGE_TIME, WIND_DIR_MIN, + WIND_DIR_MAX, VISIBILITY_STATUS, TOTAL_CLOUD_COVER, + CLOUD_BASE_HEIGHT, LOW_LEVEL_CLOUD_TYPE, MID_LEVEL_CLOUD_TYPE, + HIGH_LEVEL_CLOUD_TYPE, MAX_TEMP_RECORD_PERIOD, MAXIMUM_TEMPERATURE, + MIN_TEMP_RECORD_PERIOD, MINIMUM_TEMPERATURE, PRECIP_ACCUM, + PRECIP_TYPE, PRECIP_INTENSITY, TIME_SINCE_LAST_PCP, + SOLAR_RADIATION, SOLAR_RAD_CHANGE_TIME, SEA_SURFACE_TEMP, + WAVE_PERIOD, WAVE_HEIGHT, RAW_MESONET, "relHumidity", WIND_DIR, + PRESSURE, SEA_LEVEL_PRESSURE, PRECIP_RATE, FUEL_TEMPERATURE, + FUEL_MOISTURE, SOIL_TEMPERATURE, SOIL_MOISTURE, REPORT_TYPE }; + + public static final String MESOWEST_PARAMS_LIST; + static { + StringBuffer sb = new StringBuffer(); + boolean first = true; + for (String s : MESOWEST_PARAMS) { + if (!first) { + sb.append(", "); + } else { + first = false; + } + sb.append(s); + } + MESOWEST_PARAMS_LIST = sb.toString(); + } + + public static FSSObsRecord fromMaritimeRecord(PointDataContainer container) + throws JAXBException { + container.setCurrentSz(container.getAllocatedSz()); + PointDataView pdv = container.readRandom(0); + + FSSObsRecord fssr = new FSSObsRecord(); + SurfaceObsLocation loc = new SurfaceObsLocation(); + loc.setStationId(pdv.getString(STATION_ID)); + float lat = pdv.getNumber(LATITUDE).floatValue(); + float lon = pdv.getNumber(LONGITUDE).floatValue(); + loc.assignLocation(lat, lon); + loc.setElevation(pdv.getNumber(ELEVATION).intValue()); + fssr.setLocation(loc); + String stId = FSSObsUtils.getStationName(loc.getStationId()); + fssr.setPlatformId(loc.getStationId()); + fssr.setStnName(stId); + + fssr.setRawMessage(pdv.getString(RAW_REPORT)); + fssr.setDataTime(new DataTime(new Date(pdv.getNumber(TIME_OBS) + .longValue()))); + long to = pdv.getLong(TIME_OBS); + fssr.setTimeObs(TimeUtil.newGmtCalendar(new Date(to))); + // TODO: check nominalTime + fssr.setRefHour(TimeTools.roundToNearestHour(fssr.getTimeObs())); + + // in mbar + if (pdv.getFloat(SEA_LEVEL_PRESS) != MISSING) { + fssr.setSeaLevelPress(pdv.getFloat(SEA_LEVEL_PRESS) / 100); + } + fssr.setPressureAltimeter(pdv.getNumber(ALTIMETER).floatValue()); + // Double pa = + // DecoderTools.inToPa(pdv.getNumber(ALTIMETER).doubleValue()); + // if (pdv.getNumber(ALTIMETER).doubleValue() != MISSING) { + // fssr.setPressure(pa.floatValue()); + // } + fssr.setPressChange3Hour(pdv.getFloat(PRESS_CHANGE3_HOUR)); + fssr.setPressChangeChar(String.valueOf(pdv.getInt(PRESS_CHANGE_CHAR))); + + // http://www.hpc.ncep.noaa.gov/html/tempconversion.shtml + // in Fahrenheit + if (pdv.getFloat(DEWPOINT) != MISSING) { + fssr.setDewpoint(1.8f * (pdv.getFloat(DEWPOINT) - 273.15f) + 32.0f); + } + if (pdv.getFloat(TEMPERATURE) != MISSING) { + fssr.setTemperature(1.8f * (pdv.getFloat(TEMPERATURE) - 273.15f) + 32.0f); + } + if (pdv.getNumber(SEA_SFC_TEMP).floatValue() != MISSING) { + fssr.setSeaSurfaceTemp(1.8f * (pdv.getNumber(SEA_SFC_TEMP) + .floatValue() - 273.15f) + 32.0f); + } + // in nautical miles + fssr.setHorzVisibility(pdv.getNumber(VISIBILITY).floatValue()); + + fssr.setWindDir(pdv.getNumber(WIND_DIR).floatValue()); + // in knotes + if (pdv.getNumber(WIND_GUST).floatValue() != MISSING) { + fssr.setWindGust(pdv.getNumber(WIND_GUST).floatValue()); + } + if (pdv.getNumber(WIND_SPEED).floatValue() != MISSING) { + fssr.setWindSpeed(pdv.getNumber(WIND_SPEED).floatValue()); + } + if (pdv.getFloat(PEAK_WIND_SPEED) != MISSING) { + fssr.setMaxWindSpeed(pdv.getFloat(PEAK_WIND_SPEED)); + } + fssr.setReportType(String.valueOf(pdv.getInt(REPORT_TYPE))); + String[] pw = new String[25]; + pw[0] = pdv.getString(PRES_WEATHER); + fssr.setPresWeather(pw); + + fssr.setHighResWaveHeight(pdv.getFloat(HI_RES_WV_HGT)); + fssr.setHourlyPrecip(pdv.getFloat(PRECIP1_HOUR)); + + fssr.setPrimarySwellWaveDir(pdv.getNumber(PRI_SWELL_WV_DIR) + .doubleValue()); + fssr.setPrimarySwellWaveHeight(pdv.getNumber(PRI_SWELL_WV_HGT) + .doubleValue()); + fssr.setPrimarySwellWavePeriod(pdv.getNumber(PRI_SWELL_WV_PD) + .intValue()); + fssr.setSecondarySwellWaveDir(pdv.getNumber(SEC_SWELL_WV_DIR) + .doubleValue()); + fssr.setSecondarySwellWaveHeight(pdv.getNumber(SEC_SWELL_WV_HGT) + .doubleValue()); + fssr.setSecondarySwellWavePeriod(pdv.getNumber(SEC_SWELL_WV_PD) + .intValue()); + fssr.setWaveHeight(pdv.getNumber(WV_HGT).doubleValue()); + fssr.setWavePeriod(pdv.getNumber(WV_PD).intValue()); + fssr.setWaveSteepness(pdv.getNumber(WV_STEEPNESS).floatValue()); + fssr.setTotCloudAmount(pdv.getInt(CLOUD_AMOUNT_TOT)); + + return fssr; + // TODO : Intermediate winds + } + + /** + * @param result + * @return + */ + public static FSSObsRecord fromLdadmesowestRecord( + PointDataContainer container) throws JAXBException { + container.setCurrentSz(container.getAllocatedSz()); + PointDataView pdv = container.readRandom(0); + FSSObsRecord fssr = new FSSObsRecord(); + fssr.setReportType(pdv.getString(REPORT_TYPE)); + SurfaceObsLocation loc = new SurfaceObsLocation(); + loc.setStationId(pdv.getString(STATION_ID)); + float lat = pdv.getNumber(LATITUDE).floatValue(); + float lon = pdv.getNumber(LONGITUDE).floatValue(); + loc.assignLocation(lat, lon); + loc.setElevation(pdv.getNumber(ELEVATION).intValue()); + fssr.setLocation(loc); + String stId = FSSObsUtils.getStationName(loc.getStationId()); + fssr.setPlatformId(loc.getStationId()); + fssr.setStnName(stId + pdv.getString(DATA_PROVIDER)); + fssr.setRawMessage(pdv.getString(RAW_MESSAGE)); + fssr.setDataTime(new DataTime(new Date(pdv.getNumber(OBSERVATION_TIME) + .longValue()))); + long to = pdv.getLong(OBSERVATION_TIME); + fssr.setTimeObs(TimeUtil.newGmtCalendar(new Date(to))); + fssr.setRefHour(TimeTools.roundToNearestHour(fssr.getTimeObs())); + // fssr.setCeiling(pdv.getNumber(CLOUD_BASE_HEIGHT).floatValue()); + if (pdv.getFloat(DEWPOINT) != MISSING) { + fssr.setDewpoint(1.8f * (pdv.getFloat(DEWPOINT) - 273.15f) + 32.0f); + } + fssr.setRelativeHumidity(pdv.getFloat("relHumidity")); + if (pdv.getFloat(TEMPERATURE) != MISSING) { + fssr.setTemperature(1.8f * (pdv.getFloat(TEMPERATURE) - 273.15f) + 32.0f); + } + // fssr.setHighResWaveHeight(highResWaveHeight); + // fssr.setHorzVisibility(horzVisibility); + // fssr.setHourlyPrecip(pdv.getFloat(HOURLY_PRECIP)); + // fssr.setMaxWindSpeed(maxWindSpeed); + fssr.setMessageData(pdv.getString(RAW_MESSAGE)); + fssr.setPressChange3Hour(pdv.getFloat(PRESS_CHANGE3_HOUR)); + fssr.setPressChangeChar(String.valueOf(pdv.getInt(PRESS_CHANGE_CHAR))); + fssr.setPressureAltimeter(pdv.getFloat(ALTIMETER)); // in Pascal + // fssr.setPresWeather(pdv.getStringAllLevels(PRES_WEATHER)); + // fssr.setPrimarySwellWaveDir(primarySwellWaveDir); + // fssr.setPrimarySwellWaveHeight(primarySwellWaveHeight); + // fssr.setPrimarySwellWavePeriod(primarySwellWavePeriod); + if (pdv.getFloat(SEA_LEVEL_PRESSURE) != MISSING) { + fssr.setSeaLevelPress(pdv.getFloat(SEA_LEVEL_PRESSURE) / 100); + } + if (pdv.getFloat(SEA_SURFACE_TEMP) != MISSING) { + fssr.setSeaSurfaceTemp(1.8f * (pdv.getFloat(SEA_SURFACE_TEMP) - 273.15f) + 32.0f); + } + // fssr.setSecondarySwellWaveDir(secondarySwellWaveDir); + // fssr.setSecondarySwellWaveHeight(secondarySwellWaveHeight); + // fssr.setSecondarySwellWavePeriod(secondarySwellWavePeriod); + // fssr.setSkyCover(pdv.getStringAllLevels(SKY_COVER)); + // fssr.setTotCloudAmount(pdv.getInt(TOTAL_CLOUD_COVER)); + fssr.setVisibility(pdv.getFloat(VISIBILITY)); + fssr.setWaveHeight(pdv.getNumber(WAVE_HEIGHT).doubleValue()); + fssr.setWindDir(pdv.getFloat(WIND_DIR)); + fssr.setWindGust(pdv.getFloat(WIND_GUST)); + fssr.setWindSpeed(pdv.getFloat(WIND_SPEED)); + + return fssr; + } + + public static PointDataView buildView(FSSObsRecord record) { + pdc = PointDataContainer.build(fsspdd); + PointDataView pdv = pdc.append(); + + pdv.setFloat(CEILING, record.getCeiling()); + pdv.setFloat(DEWPOINT, record.getDewpoint()); + pdv.setFloat(DEWPOINT_DEPR, record.getDewpointDepr()); + pdv.setFloat(FROSTBITE_TIME, record.getFrostbiteTime()); + pdv.setFloat(HORIZONTAL_VIS, record.getHorzVisibility()); + pdv.setFloat(HOURLY_PRECIP, record.getHourlyPrecip()); + pdv.setFloat(MAX_WIND_SPEED, record.getMaxWindSpeed()); + pdv.setString(PLATFORM_ID, record.getPlatformId()); + String[] weatherCondition = record.getPresWeather(); + if (weatherCondition != null) { + for (int i = 0; i < weatherCondition.length; i++) { + if (weatherCondition[i] != null) { + pdv.setString(PRES_WEATHER, weatherCondition[i], i); + } + } + } + pdv.setFloat(PRESS_CHANGE3_HOUR, record.getPressChange3Hour()); + pdv.setString(PRESS_CHANGE_CHAR, record.getPressChangeChar()); + pdv.setFloat(PRESS_ALTIMETER, record.getPressureAltimeter()); + pdv.setFloat(PRI_SWELL_WV_DIR, record.getPrimarySwellWaveDir() + .floatValue()); + pdv.setFloat(PRI_SWELL_WV_HGT, record.getPrimarySwellWaveHeight() + .floatValue()); + pdv.setInt(PRI_SWELL_WV_PD, record.getPrimarySwellWavePeriod()); + pdv.setString(RAW_MESSAGE, record.getRawMessage()); + pdv.setFloat(REL_HUMIDITY, record.getRelativeHumidity()); + pdv.setFloat(SEA_LEVEL_PRESS, record.getSeaLevelPress()); + pdv.setFloat(SEA_SFC_TEMP, record.getSeaSurfaceTemp()); + pdv.setFloat(SEC_SWELL_WV_DIR, record.getSecondarySwellWaveDir() + .floatValue()); + pdv.setFloat(SEC_SWELL_WV_HGT, record.getSecondarySwellWaveHeight() + .floatValue()); + pdv.setInt(SEC_SWELL_WV_PD, record.getSecondarySwellWavePeriod()); + if (record.getSkyCover() != null) { + String[] skyList = record.getSkyCover(); + for (int i = 0; i < skyList.length; i++) { + if (skyList[i] != null) { + pdv.setString(SKY_COVER, skyList[i], i); + } + } + } + pdv.setFloat(SNOW_INC_HOURLY, record.getSnincrHourly()); + pdv.setFloat(SNOW_INC_TOTAL, record.getSnincrTotal()); + pdv.setFloat(SNOW_DEPTH, record.getSnowDepth()); + pdv.setString(STATION_NAME, record.getStnName()); + pdv.setFloat(TEMPERATURE, record.getTemperature()); + pdv.setLong(TIME_OBS, record.getTimeObs().getTimeInMillis()); + pdv.setLong(REF_HOUR, record.getRefHour().getTimeInMillis()); + pdv.setInt(CLOUD_AMOUNT_TOT, record.getTotCloudAmount()); + pdv.setFloat(VISIBILITY, record.getVisibility()); + pdv.setFloat(WV_HGT, record.getWaveHeight().floatValue()); + pdv.setInt(WV_PD, record.getWavePeriod()); + pdv.setFloat(WV_STEEPNESS, record.getWaveSteepness()); + pdv.setFloat(WIND_DIR, record.getWindDir()); + pdv.setFloat(WIND_SPEED, record.getWindSpeed()); + pdv.setFloat(WIND_GUST, record.getWindGust()); + pdv.setFloat(HI_RES_WV_HGT, record.getHighResWaveHeight()); + + // pdv.setLong(TIME_NOMINAL, record.getRefHour().getTimeInMillis()); + + record.setPointDataView(pdv); + return pdv; + } + + /** + * @param pdc + * the pdc to set + */ + public void setPdc(PointDataContainer pdc) { FSSObsDataTransform.pdc = pdc; - } + } - /** - * @return the pdc - */ - public PointDataContainer getPdc() { - return pdc; - } + /** + * @return the pdc + */ + public PointDataContainer getPdc() { + return pdc; + } } diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.fssobs/src/com/raytheon/uf/edex/plugin/fssobs/FSSObsGenerator.java b/edexOsgi/com.raytheon.uf.edex.plugin.fssobs/src/com/raytheon/uf/edex/plugin/fssobs/FSSObsGenerator.java old mode 100644 new mode 100755 index 00602856bf..1097c03a3d --- a/edexOsgi/com.raytheon.uf.edex.plugin.fssobs/src/com/raytheon/uf/edex/plugin/fssobs/FSSObsGenerator.java +++ b/edexOsgi/com.raytheon.uf.edex.plugin.fssobs/src/com/raytheon/uf/edex/plugin/fssobs/FSSObsGenerator.java @@ -21,14 +21,13 @@ package com.raytheon.uf.edex.plugin.fssobs; import java.util.HashSet; -import java.util.List; -import java.util.Set; import com.raytheon.edex.site.SiteUtil; import com.raytheon.edex.urifilter.URIFilter; import com.raytheon.edex.urifilter.URIGenerateMessage; import com.raytheon.uf.common.dataplugin.fssobs.FSSObsRecord; import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager; +import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager.MonName; import com.raytheon.uf.common.monitor.events.MonitorConfigEvent; import com.raytheon.uf.common.monitor.events.MonitorConfigListener; import com.raytheon.uf.common.status.IUFStatusHandler; @@ -70,17 +69,10 @@ public class FSSObsGenerator extends CompositeProductGenerator implements /** Product */ private static final String productType = "fssobs"; - /** All stations to be filtered. */ - private Set allStations = null; + /** Sets of all stations to filter for */ + private HashSet allStations = null; - /** Fog monitor area configuration file */ - public FSSObsMonitorConfigurationManager fogAreaConfig = null; - - /** SAFESEAS monitor area configuration file */ - public FSSObsMonitorConfigurationManager ssAreaConfig = null; - - /** SNOW monitor area configuration file */ - public FSSObsMonitorConfigurationManager snowAreaConfig = null; + private FSSObsMonitorConfigurationManager currManager = null; /** * Public construction @@ -148,14 +140,12 @@ public class FSSObsGenerator extends CompositeProductGenerator implements + " process Filter Config..."); allStations = new HashSet(); - List ssStations = getSSAreaConfig().getStations(); - allStations.addAll(ssStations); - - List fogStations = getFogAreaConfig().getStations(); - allStations.addAll(fogStations); - - List snowStations = getSnowAreaConfig().getStations(); - allStations.addAll(snowStations); + for (MonName mname : MonName.values()) { + currManager = new FSSObsMonitorConfigurationManager(mname.name()); + currManager.addListener(this); + allStations.addAll(currManager.getStations()); + currManager = null; + } } /** @@ -197,45 +187,4 @@ public class FSSObsGenerator extends CompositeProductGenerator implements dmu.createMenus(); } } - - /** - * Gets Fog monitor area configuration file. - * - * @return - */ - public FSSObsMonitorConfigurationManager getFogAreaConfig() { - if (fogAreaConfig == null) { - fogAreaConfig = FSSObsMonitorConfigurationManager - .getFogObsManager(); - fogAreaConfig.addListener(this); - } - return fogAreaConfig; - } - - /** - * Gets SAFESEAS monitor area configuration file. - * - * @return - */ - public FSSObsMonitorConfigurationManager getSSAreaConfig() { - if (ssAreaConfig == null) { - ssAreaConfig = FSSObsMonitorConfigurationManager.getSsObsManager(); - ssAreaConfig.addListener(this); - } - return ssAreaConfig; - } - - /** - * Gets SNOW monitor area configuration file. - * - * @return - */ - public FSSObsMonitorConfigurationManager getSnowAreaConfig() { - if (snowAreaConfig == null) { - snowAreaConfig = FSSObsMonitorConfigurationManager - .getSnowObsManager(); - snowAreaConfig.addListener(this); - } - return snowAreaConfig; - } } diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.fssobs/src/com/raytheon/uf/edex/plugin/fssobs/FSSObsURIFilter.java b/edexOsgi/com.raytheon.uf.edex.plugin.fssobs/src/com/raytheon/uf/edex/plugin/fssobs/FSSObsURIFilter.java old mode 100644 new mode 100755 index deb3181019..d8625acb0b --- a/edexOsgi/com.raytheon.uf.edex.plugin.fssobs/src/com/raytheon/uf/edex/plugin/fssobs/FSSObsURIFilter.java +++ b/edexOsgi/com.raytheon.uf.edex.plugin.fssobs/src/com/raytheon/uf/edex/plugin/fssobs/FSSObsURIFilter.java @@ -3,7 +3,7 @@ package com.raytheon.uf.edex.plugin.fssobs; import java.text.SimpleDateFormat; import java.util.Date; import java.util.HashMap; -import java.util.Set; +import java.util.HashSet; import java.util.TimeZone; import java.util.regex.Pattern; @@ -23,7 +23,6 @@ import com.vividsolutions.jts.geom.Coordinate; * Dec 5, 2012 #1351 skorolev Cleaned code * Feb 15, 2013 1638 mschenke Moved DataURINotificationMessage to uf.common.dataplugin * Sep 04, 2014 3220 skorolev Removed CWA from filter. - * Oct 17, 2014 3220 skorolev Replaced HashSet with Set. * * * @@ -54,7 +53,7 @@ public class FSSObsURIFilter extends URIFilter { private String dataType; /** All filtered stations */ - private Set stations = null; + private HashSet stations = null; /** Date format **/ private static String datePattern = "yyyy-MM-dd_HH:mm:ss.S"; @@ -73,7 +72,7 @@ public class FSSObsURIFilter extends URIFilter { * @param stations * for FSSObs filter */ - public FSSObsURIFilter(String name, Set stations) { + public FSSObsURIFilter(String name, HashSet stations) { super(name); logger.info("FSSObsFilter " + name + " Filter construction..."); setDataTypes(new String[] { "obs", "sfcobs", "ldadmesonet" }); diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.loctables/src/com/raytheon/uf/edex/plugin/loctables/ingest/LocationTablesIngest.java b/edexOsgi/com.raytheon.uf.edex.plugin.loctables/src/com/raytheon/uf/edex/plugin/loctables/ingest/LocationTablesIngest.java old mode 100644 new mode 100755 index ab93380713..a4c4376018 --- a/edexOsgi/com.raytheon.uf.edex.plugin.loctables/src/com/raytheon/uf/edex/plugin/loctables/ingest/LocationTablesIngest.java +++ b/edexOsgi/com.raytheon.uf.edex.plugin.loctables/src/com/raytheon/uf/edex/plugin/loctables/ingest/LocationTablesIngest.java @@ -29,6 +29,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager; +import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager.MonName; import com.raytheon.uf.edex.ndm.ingest.IDataSetIngester; import com.raytheon.uf.edex.ndm.ingest.INationalDatasetSubscriber; import com.raytheon.uf.edex.plugin.loctables.util.CommonObsSpatialBuilder; @@ -55,7 +56,6 @@ import com.raytheon.uf.edex.plugin.loctables.util.store.ObStationStoreStrategy; * Mar 06, 2014 2876 mpduff New NDM plugin. * Apr 28, 2014 3086 skorolev Updated setupLocalFiles method * Sep 04, 2014 3220 skorolev Removed parameter currentSite from FSSObs configuration managers. - * Oct 17, 2014 3220 skorolev Corrected FSSObsMonitorConfigurationManager instances. * * * @@ -128,9 +128,12 @@ public class LocationTablesIngest implements INationalDatasetSubscriber { private void setupLocalFiles() { List monitors = new ArrayList(); - monitors.add(FSSObsMonitorConfigurationManager.getSsObsManager()); - monitors.add(FSSObsMonitorConfigurationManager.getFogObsManager()); - monitors.add(FSSObsMonitorConfigurationManager.getSnowObsManager()); + monitors.add(FSSObsMonitorConfigurationManager.getInstance(MonName.fog + .name())); + monitors.add(FSSObsMonitorConfigurationManager.getInstance(MonName.ss + .name())); + monitors.add(FSSObsMonitorConfigurationManager.getInstance(MonName.snow + .name())); } /**