Issue #1549 Code clean up to properly display gird data ignore the added commented out print statement they will go away.

Change-Id: I7716af97c3a94f2243be1b219ed9f91c7b67c0d8

Former-commit-id: 9ac5a199108a1e1d106a79e67cd6209bd46134cb
This commit is contained in:
Roger Ferrel 2013-02-13 16:44:02 -06:00
parent 3b8bb09da1
commit e26689a487
5 changed files with 82 additions and 31 deletions

View file

@ -142,7 +142,7 @@
# Title: AvnFPS: Lack of customization in QC check
#
#
import logging, os, time, ConfigParser
import logging, os, time, ConfigParser, sys
import Avn, AvnLib, AvnParser
import PointDataView, GfeValues
@ -157,7 +157,7 @@ _Keys = ['Temp', 'DwptT', 'WDir', 'WSpd', 'WGust', 'Obvis', 'Vsby', \
'Ints2', 'Prob2', 'PTyp3', 'Ints3', 'Prob3']
_NumHours = 36
Parameters = ['Sky', 'T', 'Td', 'Wind', 'WindGust', 'PoP', 'Wx', 'WindGust']
Parameters = ['Sky', 'T', 'Td', 'Wind', 'WindGust', 'PoP', 'Wx']
Translate = { 'Sky':'Sky', 'Temp':'T', 'DwptT':'Td', 'WDir':'WindDir', 'WSpd':'WindSpd', 'WGust':'WindGust',
'PoP1h':'PoP', 'Obvis':'Wx', 'PoP':'PoP', 'Tstm':'Wx', 'Tint':'Wx', 'PTyp1':'Wx', 'Prob1':'Wx', 'Ints1':'Wx',
@ -294,7 +294,6 @@ def _cvt(itime, d):
def _getData(pdc, firstTime):
organizedData = {}
data = []
pdc = None
if pdc is not None :
for i in range(pdc.getCurrentSz()):
jpdv = pdc.readRandom(i)
@ -499,11 +498,14 @@ def retrieveData(siteID, timeSeconds):
from com.raytheon.viz.aviation.guidance import GuidanceUtil
from com.raytheon.uf.viz.core.localization import LocalizationManager
#timerStart = time.clock()
#print 'GridData retrieveData, siteID %s, timeSeconds %d' % (siteID, timeSeconds)
config = AvnParser.getTafSiteCfg(siteID)
lat = config['geography']['lat']
lon = config['geography']['lon']
gfeSiteId = LocalizationManager.getInstance().getCurrentSite()
#print '\tgfeSiteId: %s, lat %s, lon %s' % (gfeSiteId, lat, lon)
task = GetPointDataRequest()
task.setSiteID(gfeSiteId);
c = Coordinate(float(lon), float(lat))
@ -516,8 +518,13 @@ def retrieveData(siteID, timeSeconds):
task.setDatabaseID(db)
pdc = GuidanceUtil.getGFEPointData(task)
data = _getData(pdc, timeSeconds * 1000)
#print '\tdata: ', data
#timerEnd = time.clock()
#print '\ttime: ', timerEnd - timerStart
if data is None :
_Logger.info('Data not available for %s', siteID)
_Logger.info('Data not available for %s', siteID)
#sys.stdout.flush()
return data

View file

@ -35,6 +35,7 @@ _Logger = logging.getLogger(Avn.CATEGORY)
# Date Ticket# Engineer Description
# ------------ ---------- ----------- --------------------------
# 07/22/09 njensen Initial Creation.
# 02/13/2013 1549 rferrel Change to properly display grid data.
#
#
#
@ -307,6 +308,7 @@ def tafgen(siteObjs, model, format='short', routine = False, highlightFlightCat=
return tafWithHeader
def __makeHeader(model, data):
#print '__makeHeader data: ', data
if data and data['itime'] and data['itime']['value']:
date = time.strftime('%m/%d/%y %H%M UTC', time.gmtime(data['itime']['value']))
else:
@ -460,12 +462,12 @@ def gridgenRetrieve(siteID):
d = (requestTime, data)
o['data'] = d
obj = pickle.dumps(o)
# print 'return gridgenRetrieve - siteID, data', siteID, d
#print 'return gridgenRetrieve - siteID, data', siteID, d
return obj
def gridgen(siteObjs, format='short', routine=False, highlightFlightCat=True):
siteObjs = JUtil.javaStringListToPylist(siteObjs)
# print 'GuidanceEntry:gridgen format, highlightFlightCat:', format, highlightFlightCat
#print 'GuidanceEntry:gridgen format, highlightFlightCat:', format, highlightFlightCat
currentTime = time.gmtime()
requestTime = time.mktime((currentTime[0], currentTime[1], currentTime[2], currentTime[3],
0, 0, currentTime[6], currentTime[7], currentTime[8])) - time.timezone
@ -496,9 +498,12 @@ def gridgen(siteObjs, format='short', routine=False, highlightFlightCat=True):
o = pickle.loads(siteObj)
siteID = o['siteID']
cacheRequestTime, data = o['data']
if data is not None :
data = data.values()[0]
if not firstSiteID:
firstSiteID = siteID
# print 'gridgen siteID, cacheRequestTime, data: ', cacheRequestTime, data
#print 'gridgen siteID, cacheRequestTime, data: ', siteID, cacheRequestTime, data
if cacheRequestTime != requestTime:
cacheList.append('++Cache out of date :%s' % siteID)
if data:

View file

@ -45,6 +45,7 @@ import com.raytheon.viz.avnconfig.TafSiteConfigFactory;
* config files in execute.
* Oct 19, 2010 7347 rferrel Replace reference to TAF_SITE_CONFIG
* Oct 08, 2012 1229 rferrel Changes to work with non-blocking AvnConfigDlg.
* Feb 13, 2013 1549 rferrel Minor code clean up.
*
* </pre>
*
@ -56,8 +57,15 @@ public class AvnconfigAction extends AbstractHandler {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(AvnconfigAction.class);
private AvnconfigDlg avnfspSetupDlg;
private AvnconfigDlg avnfpsSetupDlg;
/*
* (non-Javadoc)
*
* @see
* org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands
* .ExecutionEvent)
*/
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
// Do nothing when needed configuration files are missing or unreadable.
@ -72,15 +80,12 @@ public class AvnconfigAction extends AbstractHandler {
return null;
}
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getShell();
if (avnfspSetupDlg == null || avnfspSetupDlg.getShell() == null
|| avnfspSetupDlg.isDisposed()) {
avnfspSetupDlg = new AvnconfigDlg(shell);
avnfspSetupDlg.open();
} else {
avnfspSetupDlg.bringToTop();
if (avnfpsSetupDlg == null) {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getShell();
avnfpsSetupDlg = new AvnconfigDlg(shell);
}
avnfpsSetupDlg.open();
return null;
}

View file

@ -22,6 +22,9 @@ package com.raytheon.viz.aviation;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.ShellAdapter;
import org.eclipse.swt.events.ShellEvent;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
@ -61,6 +64,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* 12 Oct 2012 1229 rferrel Changes for non-blocking TafSiteInfoEditorDlg.
* 15 Oct 2012 1229 rferrel Changes for non-blocking TextEditorSetupDlg.
* 15 Oct 2012 1229 rferrel Changed for non-blocking HelpUsageDlg.
* 13 Feb 2013 1549 rferrel Minor code cleanup.
*
* </pre>
*
@ -103,6 +107,8 @@ public class AvnconfigDlg extends CaveSWTDialog {
private HelpUsageDlg usageDlg;
private Rectangle bounds;
/**
* Constructor.
*
@ -221,8 +227,7 @@ public class AvnconfigDlg extends CaveSWTDialog {
String description = "AvnFPS Setup Help";
String helpText = "This application is used to configure AvnFPS.\n\nButton description:\n\nText Editor: use to modify forecaster list and default resource\nfile.\n\nMonitoring rules: use to edit watch rules for TAF monitoring.\n\nTAF Site Info: use to create TAF definition files\n\nTAF Products: use to create lists of TAFs to load into forecast\neditor\n\nTriggers: use to create and install Postgres trigger file.\n\nClimate Data: use to create and update HDF5 climate files.";
usageDlg = new HelpUsageDlg(shell, description,
helpText);
usageDlg = new HelpUsageDlg(shell, description, helpText);
usageDlg.open();
} else {
usageDlg.bringToTop();
@ -351,4 +356,26 @@ public class AvnconfigDlg extends CaveSWTDialog {
private void createBottomMessageControls() {
msgStatusComp = new MessageStatusComp(shell, null, null);
}
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialog#preOpened()
*/
@Override
protected void preOpened() {
super.preOpened();
shell.addShellListener(new ShellAdapter() {
@Override
public void shellClosed(ShellEvent e) {
bounds = shell.getBounds();
}
});
if (bounds != null) {
shell.setBounds(bounds);
}
}
}

View file

@ -49,6 +49,7 @@ import com.raytheon.viz.aviation.resource.ResourceConfigMgr.ResourceTag;
* 28 FEB 2008 938 lvenable Initial creation
* 29 APR 2011 8065 rferrel Add flag to indicate display is current
* and implement data caching
* 13 FEB 2013 1549 rferrel Changes to properly display grid data.
*
* </pre>
*
@ -233,6 +234,13 @@ public class GridViewer extends ViewerTab implements
});
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.jobs.IRequestCompleteListener#requestComplete
* (java.lang.Object)
*/
@Override
public void requestComplete(String[] newGuidance) {
@ -253,20 +261,19 @@ public class GridViewer extends ViewerTab implements
}
generateCache(siteIDs);
reGenerateGuidance();
} else if (newGuidance.length == 1) {
// Assume error message since header takes 2 lines.
textComp.getHeaderStTxt().setText("");
textComp.getDataStTxt().setText(newGuidance[0]);
} else {
if (newGuidance.length > 1) {
StringBuilder sb = new StringBuilder();
String header = newGuidance[0] + "\n" + newGuidance[1];
textComp.getHeaderStTxt().setText(header);
for (int i = 2; i < newGuidance.length; i++) {
sb.append(newGuidance[i]);
sb.append("\n");
}
textComp.getDataStTxt().setText(sb.toString());
} else if (newGuidance.length == 1) {
textComp.getHeaderStTxt().setText("");
textComp.getDataStTxt().setText(newGuidance[0]);
StringBuilder sb = new StringBuilder();
String header = newGuidance[0] + "\n" + newGuidance[1];
textComp.getHeaderStTxt().setText(header);
for (int i = 2; i < newGuidance.length; i++) {
sb.append(newGuidance[i]);
sb.append("\n");
}
textComp.getDataStTxt().setText(sb.toString());
if (!flightCatChk.isDisposed()) {
updateTextMarkers(flightCatChk.getSelection(),