Issue #2331 Fixed Topo retrieval for smartTools/procedures
Change-Id: Iab9d5216f278836f3b8b2245330fdb2b254a5ae3 Former-commit-id: a7a201ec657a333f6e6f5c3c1d12a3d1f9b50a4c
This commit is contained in:
parent
c9cb2bdb6a
commit
20eeb2796e
16 changed files with 2394 additions and 3333 deletions
|
@ -27,10 +27,11 @@ import org.eclipse.core.commands.ExecutionException;
|
|||
import org.eclipse.ui.commands.IElementUpdater;
|
||||
import org.eclipse.ui.menus.UIElement;
|
||||
|
||||
import com.raytheon.uf.viz.core.VizApp;
|
||||
import com.raytheon.viz.gfe.core.DataManager;
|
||||
import com.raytheon.viz.gfe.core.IParmManager;
|
||||
import com.raytheon.viz.gfe.core.parm.Parm;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.viz.gfe.core.msgs.EnableDisableTopoMsg;
|
||||
import com.raytheon.viz.gfe.core.msgs.EnableDisableTopoMsg.Action;
|
||||
import com.raytheon.viz.gfe.core.msgs.Message;
|
||||
|
||||
/**
|
||||
* Handle the GFE Topography menu item
|
||||
|
@ -38,8 +39,9 @@ import com.raytheon.viz.gfe.core.parm.Parm;
|
|||
* <pre>
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jul 2, 2008 #1160 randerso Initial creation
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jul 2, 2008 #1160 randerso Initial creation
|
||||
* Nov 20, 2013 #2331 randerso Re-implemented using message
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -48,6 +50,8 @@ import com.raytheon.viz.gfe.core.parm.Parm;
|
|||
*/
|
||||
|
||||
public class TopoHandler extends AbstractHandler implements IElementUpdater {
|
||||
private IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(TopoHandler.class);
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
|
@ -58,14 +62,19 @@ public class TopoHandler extends AbstractHandler implements IElementUpdater {
|
|||
*/
|
||||
@Override
|
||||
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||
DataManager dataMgr = DataManager.getCurrentInstance();
|
||||
IParmManager parmMgr = dataMgr.getParmManager();
|
||||
Parm topoParm = parmMgr.getParm(dataMgr.getTopoManager()
|
||||
.getCompositeParmID());
|
||||
boolean wanted = topoParm != null;
|
||||
wanted = !wanted;
|
||||
parmMgr.enableDisableTopoParm(wanted, true);
|
||||
Action lastAction = Message.inquireLastMessage(
|
||||
EnableDisableTopoMsg.class).getAction();
|
||||
|
||||
Action newAction;
|
||||
if (lastAction.equals(Action.ENABLE)) {
|
||||
newAction = Action.DISABLE;
|
||||
} else {
|
||||
newAction = Action.ENABLE;
|
||||
}
|
||||
|
||||
statusHandler.debug("Maps->Topography " + newAction);
|
||||
|
||||
new EnableDisableTopoMsg(newAction, true).send();
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -76,23 +85,11 @@ public class TopoHandler extends AbstractHandler implements IElementUpdater {
|
|||
* org.eclipse.ui.commands.IElementUpdater#updateElement(org.eclipse.ui.
|
||||
* menus.UIElement, java.util.Map)
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
@SuppressWarnings(value = "unchecked")
|
||||
public void updateElement(final UIElement element, Map parameters) {
|
||||
DataManager dataMgr = DataManager.getCurrentInstance();
|
||||
if (dataMgr != null) {
|
||||
IParmManager parmMgr = dataMgr.getParmManager();
|
||||
Parm topoParm = parmMgr.getParm(dataMgr.getTopoManager()
|
||||
.getCompositeParmID());
|
||||
final boolean checked = topoParm != null;
|
||||
|
||||
VizApp.runAsync(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
element.setChecked(checked);
|
||||
}
|
||||
});
|
||||
}
|
||||
element.setChecked(Message
|
||||
.inquireLastMessage(EnableDisableTopoMsg.class).getAction()
|
||||
.equals(EnableDisableTopoMsg.Action.ENABLE));
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -19,24 +19,15 @@
|
|||
**/
|
||||
package com.raytheon.viz.gfe.core.internal;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.gfe.GridDataHistory;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.GridDataHistory.OriginType;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.db.objects.DatabaseID;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.db.objects.GridParmInfo;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.db.objects.ParmID;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.db.objects.DatabaseID.DataType;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.slice.IGridSlice;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.db.objects.GridLocation;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.db.objects.ParmID;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.server.message.ServerResponse;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.slice.ScalarGridSlice;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
import com.raytheon.uf.common.time.TimeRange;
|
||||
import com.raytheon.viz.gfe.Activator;
|
||||
import com.raytheon.viz.gfe.GFEServerException;
|
||||
import com.raytheon.viz.gfe.constants.StatusConstants;
|
||||
import com.raytheon.viz.gfe.core.DataManager;
|
||||
import com.raytheon.viz.gfe.core.ITopoManager;
|
||||
|
||||
|
@ -51,7 +42,8 @@ import com.raytheon.viz.gfe.core.ITopoManager;
|
|||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jul 2, 2008 #1160 randerso Initial creation
|
||||
* Jul 2, 2008 #1160 randerso Initial creation
|
||||
* Nov 20, 2013 #2331 randerso Re-implemented to better match A1 design
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -60,23 +52,14 @@ import com.raytheon.viz.gfe.core.ITopoManager;
|
|||
*/
|
||||
|
||||
public class GFETopoManager implements ITopoManager {
|
||||
private static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(GFETopoManager.class);
|
||||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(GFETopoManager.class);
|
||||
|
||||
private DataManager dataManager;
|
||||
|
||||
private ScalarGridSlice compositeTopo;
|
||||
|
||||
private ParmID compositeTopoId;
|
||||
|
||||
private ParmID editTopoId;
|
||||
|
||||
// private GridLocation gloc;
|
||||
//
|
||||
// private GridParmInfo gpi;
|
||||
|
||||
private GridDataHistory[] gdh;
|
||||
|
||||
private TimeRange validTime;
|
||||
private ParmID compositeParmID;
|
||||
|
||||
/**
|
||||
* Constructor taking a pointer to the DataManager
|
||||
|
@ -86,24 +69,10 @@ public class GFETopoManager implements ITopoManager {
|
|||
public GFETopoManager(DataManager dataManager) {
|
||||
this.dataManager = dataManager;
|
||||
|
||||
// this.gloc =
|
||||
// this.dataManager.getParmManager().compositeGridLocation();
|
||||
|
||||
this.compositeTopoId = new ParmID("Topography", new DatabaseID(
|
||||
this.dataManager.getSiteID(), DataType.GRID, "Topo", "Topo"),
|
||||
"SFC");
|
||||
|
||||
this.editTopoId = new ParmID("Topo", new DatabaseID(this.dataManager
|
||||
.getSiteID(), DataType.GRID, "EditTopo", "Topo"), "SFC");
|
||||
|
||||
// this.gpi = new GridParmInfo(this.compositeTopoId, this.gloc,
|
||||
// GridType.SCALAR, "Feet MSL", "Topography", -16404.0f, 16404.0f,
|
||||
// 0, true, new TimeConstraints(0, 0, 0), false);
|
||||
|
||||
this.validTime = TimeRange.allTimes();
|
||||
|
||||
this.gdh = new GridDataHistory[] { new GridDataHistory(
|
||||
OriginType.OTHER, this.compositeTopoId, this.validTime) };
|
||||
// hard coding this here to match what is done in TopoDatabaseManager
|
||||
// this avoids retrieving the topo data just to get the parm ID.
|
||||
DatabaseID did = new DatabaseID("Topo", DataType.GRID, "Topo", "Topo");
|
||||
this.compositeParmID = new ParmID("Topo", did);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -114,23 +83,20 @@ public class GFETopoManager implements ITopoManager {
|
|||
@Override
|
||||
public synchronized ScalarGridSlice getCompositeTopo() {
|
||||
if (compositeTopo == null) {
|
||||
List<TimeRange> trs = new ArrayList<TimeRange>();
|
||||
trs.add(TimeRange.allTimes());
|
||||
GridLocation gloc = dataManager.getParmManager()
|
||||
.compositeGridLocation();
|
||||
try {
|
||||
List<IGridSlice> slice = dataManager.getClient().getGridData(
|
||||
editTopoId, trs);
|
||||
GridParmInfo gpi = dataManager.getClient().getGridParmInfo(
|
||||
editTopoId);
|
||||
gpi.setParmID(compositeTopoId);
|
||||
|
||||
if (slice != null) {
|
||||
compositeTopo = new ScalarGridSlice(this.validTime, gpi,
|
||||
this.gdh, ((ScalarGridSlice) slice.get(0))
|
||||
.getScalarGrid());
|
||||
ServerResponse<ScalarGridSlice> sr = this.dataManager
|
||||
.getClient().getTopoData(gloc);
|
||||
if (!sr.isOkay()) {
|
||||
statusHandler
|
||||
.error("Error getting topography data from IFPServer: "
|
||||
+ sr.message());
|
||||
}
|
||||
compositeTopo = sr.getPayload();
|
||||
} catch (GFEServerException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Unable to load topography", e);
|
||||
statusHandler.error(
|
||||
"Error getting topography data from IFPServer: ", e);
|
||||
}
|
||||
}
|
||||
return compositeTopo;
|
||||
|
@ -143,6 +109,6 @@ public class GFETopoManager implements ITopoManager {
|
|||
*/
|
||||
@Override
|
||||
public ParmID getCompositeParmID() {
|
||||
return this.compositeTopoId;
|
||||
return this.compositeParmID;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,6 +59,7 @@ import com.raytheon.uf.common.dataplugin.gfe.request.GetKnownSitesRequest;
|
|||
import com.raytheon.uf.common.dataplugin.gfe.request.GetLockTablesRequest;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.request.GetOfficialDbNameRequest;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.request.GetParmListRequest;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.request.GetTopoDataRequest;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.request.GetWXDefinitionRequest;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.request.GridLocRequest;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.request.IscCreateDomainDictRequest;
|
||||
|
@ -78,6 +79,7 @@ import com.raytheon.uf.common.dataplugin.gfe.server.request.LockTableRequest;
|
|||
import com.raytheon.uf.common.dataplugin.gfe.server.request.SaveGridRequest;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.server.request.SendISCRequest;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.slice.IGridSlice;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.slice.ScalarGridSlice;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.weather.WeatherSubKey;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.weather.WxDefinition;
|
||||
import com.raytheon.uf.common.message.WsId;
|
||||
|
@ -115,6 +117,7 @@ import com.raytheon.viz.gfe.core.parm.Parm;
|
|||
* 05/02/13 #1969 randerso Added createNewDb method
|
||||
* 06/06/13 #2073 dgilling Make getGridInventory() better match A1,
|
||||
* fix warnings.
|
||||
* 11/20/2013 #2331 randerso Added getTopoData method
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -768,4 +771,9 @@ public class IFPClient {
|
|||
return makeRequest(request);
|
||||
}
|
||||
|
||||
public ServerResponse<ScalarGridSlice> getTopoData(GridLocation gloc)
|
||||
throws GFEServerException {
|
||||
GetTopoDataRequest request = new GetTopoDataRequest(gloc);
|
||||
return (ServerResponse<ScalarGridSlice>) makeRequest(request, false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,838 +0,0 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.viz.gfe.core.internal;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import javax.measure.converter.ConversionException;
|
||||
import javax.measure.converter.UnitConverter;
|
||||
import javax.measure.unit.NonSI;
|
||||
import javax.measure.unit.SI;
|
||||
|
||||
import org.eclipse.core.runtime.FileLocator;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.gfe.GridDataHistory;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.config.ProjectionData;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.config.ProjectionData.ProjectionType;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.db.objects.DatabaseID;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.db.objects.GFERecord.GridType;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.db.objects.GridLocation;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.db.objects.GridParmInfo;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.db.objects.ParmID;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.db.objects.TimeConstraints;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.discrete.DiscreteKey;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.grid.Grid2DByte;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.grid.Grid2DFloat;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.slice.DiscreteGridSlice;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.slice.IGridSlice;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.slice.ScalarGridSlice;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.slice.VectorGridSlice;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.slice.WeatherGridSlice;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.weather.WeatherKey;
|
||||
import com.raytheon.uf.common.time.TimeRange;
|
||||
import com.raytheon.uf.common.time.util.TimeUtil;
|
||||
import com.raytheon.viz.gfe.Activator;
|
||||
import com.raytheon.viz.gfe.core.DataManager;
|
||||
import com.raytheon.viz.gfe.core.griddata.DiscreteGridData;
|
||||
import com.raytheon.viz.gfe.core.griddata.IGridData;
|
||||
import com.raytheon.viz.gfe.core.griddata.ScalarGridData;
|
||||
import com.raytheon.viz.gfe.core.griddata.VectorGridData;
|
||||
import com.raytheon.viz.gfe.core.parm.MockParm;
|
||||
import com.raytheon.viz.gfe.core.parm.Parm;
|
||||
import com.vividsolutions.jts.geom.Coordinate;
|
||||
|
||||
/**
|
||||
* MockParmManager is a simulated parm manager that can be used for testing
|
||||
*
|
||||
* It does not do any communication with the backend. All interactions are
|
||||
* simulated.
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 02/04/2008 chammack Initial Creation
|
||||
* 03/20/2013 #1774 randerso Use TimeUtil constants
|
||||
* 08/06/2013 #1571 randerso Changed ProjectionData constructor call
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author chammack
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class MockParmManager extends AbstractParmManager {
|
||||
|
||||
private static final int HOURS_OF_DATA = 12;
|
||||
|
||||
private static final int TIME_OFFSET = -6;
|
||||
|
||||
private static final ProjectionData grid211 = new ProjectionData("Grid211",
|
||||
ProjectionType.LAMBERT_CONFORMAL, new Coordinate(-133.459, 12.190),
|
||||
new Coordinate(-49.385, 57.290), new Coordinate(-95.0, 25.0),
|
||||
25.0f, 25.0f, new Point(1, 1), new Point(93, 65), 0.0f, 0.0f, 0.0f);
|
||||
|
||||
private static final GridLocation gloc = new GridLocation("OAX", grid211,
|
||||
new Point(145, 145), new Coordinate(45, 30), new Coordinate(9, 9),
|
||||
"CST6CDT");
|
||||
|
||||
private static final TimeConstraints TC1 = new TimeConstraints(
|
||||
TimeUtil.SECONDS_PER_HOUR, TimeUtil.SECONDS_PER_HOUR, 0);
|
||||
|
||||
private static final TimeConstraints TC2 = new TimeConstraints(
|
||||
13 * TimeUtil.SECONDS_PER_HOUR, TimeUtil.SECONDS_PER_DAY, 13);
|
||||
|
||||
protected Set<Parm> fullParmSet;
|
||||
|
||||
protected List<ParmID> parmIDs;
|
||||
|
||||
protected DatabaseID mutableDb;
|
||||
|
||||
protected TimeRange systemTimeRange;
|
||||
|
||||
protected ParmID[] mockD2DGrids;
|
||||
|
||||
public MockParmManager(DataManager dmgr) {
|
||||
super(dmgr);
|
||||
this.fullParmSet = new LinkedHashSet<Parm>();
|
||||
|
||||
this.parmIDs = new ArrayList<ParmID>();
|
||||
this.mutableDb = new DatabaseID("OAX_GRID__Fcst_00000000_0000");
|
||||
|
||||
DatabaseID dbid = new DatabaseID("OAX_GRID__Fcst_00000000_0000");
|
||||
DatabaseID mockD2Did = new DatabaseID(
|
||||
"OAX_GRID_D2D_NAM12_20080320_0000");
|
||||
|
||||
// Create a bogus set of parms
|
||||
GridParmInfo gpi = new GridParmInfo(new ParmID("T", dbid,
|
||||
ParmID.defaultLevel()), gloc, GridType.SCALAR, "F",
|
||||
"Surface Temperature", -80f, 120f, 0, false, TC1, false);
|
||||
addInternal(gpi, true);
|
||||
|
||||
gpi = new GridParmInfo(new ParmID("Td", dbid, ParmID.defaultLevel()),
|
||||
gloc, GridType.SCALAR, "F", "Dewpoint", -80f, 120f, 0, false,
|
||||
TC1, false);
|
||||
addInternal(gpi, true);
|
||||
|
||||
gpi = new GridParmInfo(new ParmID("MaxT", dbid, ParmID.defaultLevel()),
|
||||
gloc, GridType.SCALAR, "F", "Maximum Temperature", -80f, 120f,
|
||||
0, false, TC2, false);
|
||||
addInternal(gpi, true);
|
||||
|
||||
gpi = new GridParmInfo(new ParmID("HeatIndex", dbid,
|
||||
ParmID.defaultLevel()), gloc, GridType.SCALAR, "F",
|
||||
"Heat Index", -80f, 130f, 0, false, TC1, false);
|
||||
addInternal(gpi, true);
|
||||
|
||||
gpi = new GridParmInfo(new ParmID("WindChill", dbid,
|
||||
ParmID.defaultLevel()), gloc, GridType.SCALAR, "F",
|
||||
"Wind Chill", -120f, 120f, 0, false, TC1, false);
|
||||
addInternal(gpi, false);
|
||||
|
||||
gpi = new GridParmInfo(new ParmID("Wind", dbid, ParmID.defaultLevel()),
|
||||
gloc, GridType.VECTOR, "kts", "Surface Wind", 0.0f, 125.0f, 0,
|
||||
false, TC1, false);
|
||||
addInternal(gpi, true);
|
||||
|
||||
gpi = new GridParmInfo(new ParmID("WindGust", dbid,
|
||||
ParmID.defaultLevel()), gloc, GridType.VECTOR, "kts",
|
||||
"Wind Gust", 0.0f, 125.0f, 0, false, TC1, false);
|
||||
addInternal(gpi, false);
|
||||
|
||||
gpi = new GridParmInfo(new ParmID("Discrete", dbid,
|
||||
ParmID.defaultLevel()), gloc, GridType.DISCRETE, "",
|
||||
"TESTDiscrete", 0.0f, 2.0f, 0, false, TC1, false);
|
||||
addInternal(gpi, true);
|
||||
|
||||
gpi = new GridParmInfo(new ParmID("Hazards", dbid,
|
||||
ParmID.defaultLevel()), gloc, GridType.DISCRETE, "",
|
||||
"TESTHazards", 0.0f, 2.0f, 0, false, TC1, false);
|
||||
addInternal(gpi, true);
|
||||
|
||||
gpi = new GridParmInfo(new ParmID("Weather", dbid,
|
||||
ParmID.defaultLevel()), gloc, GridType.WEATHER, "",
|
||||
"TESTWeather", 0.0f, 2.0f, 0, false, TC1, false);
|
||||
addInternal(gpi, true);
|
||||
|
||||
this.mockD2DGrids = new ParmID[4];
|
||||
this.mockD2DGrids[0] = new ParmID("T", mockD2Did, "MB650");
|
||||
this.mockD2DGrids[1] = new ParmID("T", mockD2Did, "MB750");
|
||||
this.mockD2DGrids[2] = new ParmID("T", mockD2Did, "MB850");
|
||||
this.mockD2DGrids[3] = new ParmID("T", mockD2Did, ParmID.defaultLevel());
|
||||
|
||||
this.systemTimeRange = recalcSystemTimeRange();
|
||||
}
|
||||
|
||||
private void addInternal(GridParmInfo gpi, boolean displayable) {
|
||||
ParmID pid = gpi.getParmID();
|
||||
Parm parm = new MockParm(pid, gpi, true, displayable, this.dataManager);
|
||||
this.parmIDs.add(pid);
|
||||
|
||||
Calendar tmpCal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
|
||||
tmpCal.set(Calendar.MINUTE, 0);
|
||||
tmpCal.set(Calendar.SECOND, 0);
|
||||
tmpCal.set(Calendar.MILLISECOND, 0);
|
||||
|
||||
tmpCal.add(Calendar.HOUR_OF_DAY, TIME_OFFSET);
|
||||
|
||||
// Hack for simulated data
|
||||
float[][] data = null;
|
||||
if ((Activator.getDefault() != null)
|
||||
&& (gpi.getDescriptiveName().equals("Surface Temperature") || gpi
|
||||
.getDescriptiveName().equals("Dewpoint"))) {
|
||||
UnitConverter conv = SI.KELVIN.getConverterTo(NonSI.FAHRENHEIT);
|
||||
|
||||
data = new float[145][145];
|
||||
|
||||
try {
|
||||
String fn = null;
|
||||
if (gpi.getDescriptiveName().equals("Surface Temperature")) {
|
||||
fn = FileLocator.resolve(
|
||||
FileLocator.find(
|
||||
Activator.getDefault().getBundle(),
|
||||
new Path("T.bin"), null)).getPath();
|
||||
} else {
|
||||
fn = FileLocator.resolve(
|
||||
FileLocator.find(
|
||||
Activator.getDefault().getBundle(),
|
||||
new Path("Td.bin"), null)).getPath();
|
||||
}
|
||||
FileInputStream fis = new FileInputStream(fn);
|
||||
DataInputStream dis = new DataInputStream(fis);
|
||||
|
||||
for (int m = 0; m < 145; m++) {
|
||||
for (int n = 0; n < 145; n++) {
|
||||
float f = dis.readFloat();
|
||||
f = (float) conv.convert(f);
|
||||
data[m][n] = f;
|
||||
}
|
||||
}
|
||||
dis.close();
|
||||
fis.close();
|
||||
|
||||
} catch (FileNotFoundException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (ConversionException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
Calendar tmpCal2 = (Calendar) tmpCal.clone();
|
||||
|
||||
Calendar tmpCal3 = (Calendar) tmpCal.clone();
|
||||
tmpCal3.add(Calendar.HOUR_OF_DAY, HOURS_OF_DATA);
|
||||
// TimeRange fullTR = new TimeRange(tmpCal, tmpCal3);
|
||||
|
||||
List<IGridData> mockGD = new ArrayList<IGridData>(HOURS_OF_DATA);
|
||||
|
||||
for (int i = 0; i < HOURS_OF_DATA; i++) {
|
||||
tmpCal2.add(Calendar.HOUR_OF_DAY, 1);
|
||||
if (gpi.getGridType() == GridType.SCALAR) {
|
||||
ScalarGridSlice slice = new ScalarGridSlice(new TimeRange(
|
||||
tmpCal, tmpCal2), gpi, new GridDataHistory[0],
|
||||
new Grid2DFloat(145, 145));
|
||||
Grid2DFloat g2dFloat = slice.getScalarGrid();
|
||||
|
||||
if (data != null) {
|
||||
for (int m = 0; m < g2dFloat.getXdim(); m++) {
|
||||
for (int n = 0; n < g2dFloat.getYdim(); n++) {
|
||||
g2dFloat.set(m, n, data[m][n]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Fake some data in the right range
|
||||
float step = (gpi.getMaxValue() - gpi.getMinValue())
|
||||
/ (g2dFloat.getXdim() + g2dFloat.getYdim());
|
||||
for (int m = 0; m < g2dFloat.getXdim(); m++) {
|
||||
for (int n = 0; n < g2dFloat.getYdim(); n++) {
|
||||
g2dFloat.set(
|
||||
m,
|
||||
n,
|
||||
(((float) m + n) * step)
|
||||
+ gpi.getMinValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mockGD.add(new ScalarGridData(parm, slice));
|
||||
|
||||
} else if (gpi.getGridType() == GridType.VECTOR) {
|
||||
VectorGridSlice slice = new VectorGridSlice(new TimeRange(
|
||||
tmpCal, tmpCal2), gpi, new GridDataHistory[0],
|
||||
new Grid2DFloat(145, 145), new Grid2DFloat(145, 145));
|
||||
Grid2DFloat g2dFloat = slice.getDirGrid();
|
||||
for (int m = 0; m < g2dFloat.getXdim(); m++) {
|
||||
for (int n = 0; n < g2dFloat.getYdim(); n++) {
|
||||
g2dFloat.set(m, n, 90.0f);
|
||||
}
|
||||
}
|
||||
|
||||
g2dFloat = slice.getMagGrid();
|
||||
float step = (gpi.getMaxValue() - gpi.getMinValue())
|
||||
/ (g2dFloat.getXdim() + g2dFloat.getYdim());
|
||||
for (int m = 0; m < g2dFloat.getXdim(); m++) {
|
||||
for (int n = 0; n < g2dFloat.getYdim(); n++) {
|
||||
g2dFloat.set(m, n,
|
||||
(((float) m + n) * step) + gpi.getMinValue());
|
||||
}
|
||||
}
|
||||
|
||||
mockGD.add(new VectorGridData(parm, slice));
|
||||
|
||||
} else if (gpi.getGridType() == GridType.DISCRETE) {
|
||||
ParmID parmId = gpi.getParmID();
|
||||
String siteId = parmId.getDbId().getSiteId();
|
||||
|
||||
DiscreteKey tmpKey = DiscreteKey.defaultKey(siteId, parmId);
|
||||
|
||||
DiscreteKey tmpKey2 = new DiscreteKey(siteId, "BZ.A", parmId);
|
||||
|
||||
DiscreteGridSlice slice = new DiscreteGridSlice(new TimeRange(
|
||||
tmpCal, tmpCal2), gpi, new GridDataHistory[0],
|
||||
new Grid2DByte(145, 145), new DiscreteKey[] { tmpKey,
|
||||
tmpKey2 });
|
||||
Grid2DByte g2dByte = slice.getDiscreteGrid();
|
||||
slice.assign(tmpKey);
|
||||
|
||||
// ADDED TO DISPLAY SOME DISCRETE DATA
|
||||
for (int m = 0; m < g2dByte.getXdim(); m++) {
|
||||
for (int n = 0; n < g2dByte.getYdim(); n++) {
|
||||
if ((m > 80) && (m < 110) && (n > 80) && (n < 110)) {
|
||||
g2dByte.set(m, n, (byte) 1);
|
||||
}
|
||||
if ((m > 90) && (m < 100) && (n > 110) && (n < 140)) {
|
||||
g2dByte.set(m, n, (byte) 1);
|
||||
}
|
||||
}
|
||||
}// ADDED TO DISPLAY SOME DISCRETE DATA
|
||||
|
||||
mockGD.add(new DiscreteGridData(parm, slice));
|
||||
|
||||
} else if (gpi.getGridType() == GridType.WEATHER) {
|
||||
|
||||
String siteId = gpi.getGridLoc().getSiteId();
|
||||
WeatherKey tmpKey = new WeatherKey(siteId,
|
||||
"<NoCov>:<NoWx>:<NoInten>:<NoVis>:");
|
||||
|
||||
WeatherKey tmpKey2 = new WeatherKey(siteId,
|
||||
"Sct:T:<NoInten>:6SM:FL");
|
||||
//
|
||||
// tmpKey2.add(wxDefinition.instanceFromString("T"));
|
||||
|
||||
WeatherGridSlice slice = new WeatherGridSlice(new TimeRange(
|
||||
tmpCal, tmpCal2), gpi, new GridDataHistory[0],
|
||||
new Grid2DByte(145, 145), new WeatherKey[] { tmpKey,
|
||||
tmpKey2 });
|
||||
Grid2DByte g2dByte = slice.getWeatherGrid();
|
||||
slice.assign(tmpKey);
|
||||
|
||||
// ADDED TO DISPLAY SOME DISCRETE DATA
|
||||
for (int m = 0; m < g2dByte.getXdim(); m++) {
|
||||
for (int n = 0; n < g2dByte.getYdim(); n++) {
|
||||
if ((m > 80) && (m < 110) && (n > 80) && (n < 110)) {
|
||||
g2dByte.set(m, n, (byte) 1);
|
||||
}
|
||||
if ((m > 90) && (m < 100) && (n > 110) && (n < 140)) {
|
||||
g2dByte.set(m, n, (byte) 1);
|
||||
}
|
||||
}
|
||||
}// ADDED TO DISPLAY SOME DISCRETE DATA
|
||||
|
||||
mockGD.add(new DiscreteGridData(parm, slice));
|
||||
|
||||
}
|
||||
tmpCal.add(Calendar.HOUR_OF_DAY, 1);
|
||||
}
|
||||
parm.setGrids(mockGD);
|
||||
|
||||
this.fullParmSet.add(parm);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.viz.gfe.core.parm.IParmManager#addParm(com.raytheon.viz.
|
||||
* gfe.core.parm.ParmID, boolean, boolean)
|
||||
*/
|
||||
@Override
|
||||
public Parm addParm(ParmID pid, boolean mutableParm, boolean displayable) {
|
||||
Parm parm = new MockParm(pid, new GridParmInfo(pid, gloc,
|
||||
GridType.SCALAR, "F", "descriptive name", 0f, 100f, 0, false,
|
||||
TC1, false), mutableParm, displayable, this.dataManager);
|
||||
parms.acquireWriteLock();
|
||||
try {
|
||||
if (!this.parms.contains(parm)) {
|
||||
this.parms.add(parm);
|
||||
}
|
||||
} finally {
|
||||
parms.releaseWriteLock();
|
||||
}
|
||||
parm.getDisplayAttributes().setDisplayable(displayable);
|
||||
return parm;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.viz.gfe.core.parm.IParmManager#createVirtualParm(com.raytheon
|
||||
* .viz.gfe.core.parm.ParmID,
|
||||
* com.raytheon.edex.plugin.gfe.db.objects.GridParmInfo,
|
||||
* com.raytheon.edex.plugin.gfe.slice.IGridSlice, boolean, boolean)
|
||||
*/
|
||||
@Override
|
||||
public Parm createVirtualParm(ParmID pid, GridParmInfo gpi,
|
||||
IGridSlice[] data, boolean mutableParm, boolean displayable) {
|
||||
Parm parm = new MockParm(pid, gpi, mutableParm, displayable,
|
||||
this.dataManager);
|
||||
|
||||
IGridData grid = null;
|
||||
if ((data == null) || (data.length == 0)) {
|
||||
grid = null;
|
||||
} else if (gpi.getGridType() == GridType.SCALAR) {
|
||||
grid = new ScalarGridData(parm, data[0]);
|
||||
} else if (gpi.getGridType() == GridType.VECTOR) {
|
||||
grid = new VectorGridData(parm, data[0]);
|
||||
} else if (gpi.getGridType() == GridType.DISCRETE) {
|
||||
grid = new DiscreteGridData(parm, data[0]);
|
||||
}
|
||||
List<IGridData> grids = Arrays.asList(grid);
|
||||
parm.setGrids(grids);
|
||||
return parm;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.gfe.core.parm.IParmManager#getAllParms()
|
||||
*/
|
||||
@Override
|
||||
public Parm[] getAllParms() {
|
||||
parms.acquireReadLock();
|
||||
try {
|
||||
return this.fullParmSet.toArray(new Parm[parms.size()]);
|
||||
} finally {
|
||||
parms.releaseReadLock();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.viz.gfe.core.parm.IParmManager#saveParm(com.raytheon.viz
|
||||
* .gfe.core.parm.Parm)
|
||||
*/
|
||||
@Override
|
||||
public boolean saveParm(Parm parm) {
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.viz.gfe.core.parm.IParmManager#saveParm(com.raytheon.viz
|
||||
* .gfe.core.parm.Parm, com.raytheon.uf.common.time.TimeRange[])
|
||||
*/
|
||||
@Override
|
||||
public boolean saveParm(Parm parm, TimeRange[] timeRanges) {
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.viz.gfe.core.parm.IParmManager#isParmInDatabase(com.raytheon
|
||||
* .viz.gfe.core.parm.ParmID)
|
||||
*/
|
||||
@Override
|
||||
public boolean isParmInDatabase(ParmID parmId) {
|
||||
for (Parm parm : this.fullParmSet) {
|
||||
if (parm.getParmID().equals(parmId)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.gfe.core.IParmManager#getAvailableDbs()
|
||||
*/
|
||||
@Override
|
||||
public List<DatabaseID> getAvailableDbs() {
|
||||
return Arrays.asList(new DatabaseID("OAX_GRID__Fcst_00000000_0000"),
|
||||
new DatabaseID("OAX_GRID_D2D_NAM12_20080320_0000"));
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.gfe.core.IParmManager#getDisplayedDbs()
|
||||
*/
|
||||
@Override
|
||||
public List<DatabaseID> getDisplayedDbs() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.gfe.core.IParmManager#getUndisplayedDbs()
|
||||
*/
|
||||
@Override
|
||||
public List<DatabaseID> getUndisplayedDbs() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.viz.gfe.core.IParmManager#getAvailableParms(com.raytheon
|
||||
* .edex.plugin.gfe.db.objects.DatabaseID)
|
||||
*/
|
||||
@Override
|
||||
public ParmID[] getAvailableParms(DatabaseID dbID) {
|
||||
|
||||
if (dbID.getModelName().equals("Fcst")) {
|
||||
return this.parmIDs.toArray(new ParmID[this.parmIDs.size()]);
|
||||
} else {
|
||||
return this.mockD2DGrids;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.viz.gfe.core.IParmManager#getUniqueParmID(com.raytheon.edex
|
||||
* .plugin.gfe.db.objects.ParmID, java.lang.String, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public ParmID getUniqueParmID(final ParmID pid, final String nameHint,
|
||||
final String categoryHint) {
|
||||
return pid;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.gfe.core.IParmManager#getSystemTimeRange()
|
||||
*/
|
||||
@Override
|
||||
public TimeRange getSystemTimeRange() {
|
||||
return this.systemTimeRange;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.viz.gfe.core.IParmManager#deleteParm(com.raytheon.viz.gfe
|
||||
* .core.parm.Parm[])
|
||||
*/
|
||||
@Override
|
||||
public void deleteParm(final Parm... parms) {
|
||||
if (parms.length == 0) {
|
||||
return; // nothing to do
|
||||
}
|
||||
|
||||
List<Parm> toBeDeleted = new ArrayList<Parm>();
|
||||
|
||||
this.parms.acquireReadLock();
|
||||
try {
|
||||
for (int i = 0; i < parms.length; i++) {
|
||||
if (!this.parms.contains(parms[i])) {
|
||||
throw new IllegalArgumentException(
|
||||
"Attempt to delete unknown parm: "
|
||||
+ parms[i].getParmID().toString());
|
||||
}
|
||||
|
||||
// skip modified parms
|
||||
if (!parms[i].isModified()) {
|
||||
toBeDeleted.add(parms[i]);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Skipping parm: "
|
||||
+ parms[i].getParmID() + " due to modified state.");
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
this.parms.releaseReadLock();
|
||||
}
|
||||
|
||||
// List<ParmID> ids = new ArrayList<ParmID>();
|
||||
this.parms.acquireWriteLock();
|
||||
try {
|
||||
for (int i = 0; i < toBeDeleted.size(); i++) {
|
||||
if (this.parms.contains(toBeDeleted.get(i))) {
|
||||
this.parms.remove(toBeDeleted.get(i));
|
||||
// ids.add(toBeDeleted.get(i).getParmID());
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
this.parms.releaseWriteLock();
|
||||
}
|
||||
|
||||
// continue the command to remove the specified ids
|
||||
// TODO
|
||||
// setParms(null, ids);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.gfe.core.IParmManager#getMutableDatabase()
|
||||
*/
|
||||
@Override
|
||||
public DatabaseID getMutableDatabase() {
|
||||
return this.mutableDb;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.gfe.core.IParmManager#getOrigMutableDatabase()
|
||||
*/
|
||||
@Override
|
||||
public DatabaseID getOrigMutableDatabase() {
|
||||
return this.mutableDb;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.viz.gfe.core.internal.AbstractParmManager#getDataManager()
|
||||
*/
|
||||
@Override
|
||||
protected DataManager getDataManager() {
|
||||
return this.dataManager;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.gfe.core.IParmManager#compositeGridLocation()
|
||||
*/
|
||||
@Override
|
||||
public GridLocation compositeGridLocation() {
|
||||
// TODO: get this value from the server
|
||||
return gloc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Parm getParmInExpr(final String exprName, boolean enableTopo) {
|
||||
return getParmInExpr(exprName, enableTopo, dataManager
|
||||
.getSpatialDisplayManager().getActivatedParm());
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.viz.gfe.core.internal.AbstractParmManager#createParmInternal
|
||||
* (com.raytheon.edex.plugin.gfe.db.objects.ParmID, boolean, boolean)
|
||||
*/
|
||||
@Override
|
||||
protected Parm createParmInternal(ParmID pid, boolean mutableParm,
|
||||
boolean displayable) {
|
||||
|
||||
for (Parm p : this.fullParmSet) {
|
||||
if (p.getParmID().equals(pid)) {
|
||||
return p;
|
||||
}
|
||||
}
|
||||
|
||||
return new MockParm(pid, new GridParmInfo(), mutableParm, displayable,
|
||||
this.dataManager);
|
||||
}
|
||||
|
||||
// -- private
|
||||
// ----------------------------------------------------------------
|
||||
// ParmMgr::setParms()
|
||||
// Adds/removes/displaystatechanges the set of given parms. Handles the
|
||||
// bookkeeping and sends out notifications.
|
||||
// -- implementation
|
||||
// ---------------------------------------------------------
|
||||
// This is the complicated routine which handles all of the bookkeeping
|
||||
// and the notifications. Should never see a NULL parm* given to this
|
||||
// routine.
|
||||
// ---------------------------------------------------------------------------
|
||||
@Override
|
||||
protected void setParms(final Collection<Parm> addParms,
|
||||
final Collection<Parm> removeParms,
|
||||
final Collection<Parm> displayedStateModParms) {
|
||||
// logDebug << "--- setParms(parmsToAdd,parmsToRemov,displayedStateMod):
|
||||
// "
|
||||
// << printAMR(addParms, displayedStateModParms, removeParms) <<
|
||||
// std::endl;
|
||||
|
||||
// update list of parms
|
||||
parms.acquireWriteLock();
|
||||
try {
|
||||
for (Parm addParm : addParms) {
|
||||
if ((addParm != null) && !this.parms.contains(addParm)) {
|
||||
this.parms.add(addParm); // add the additions
|
||||
}
|
||||
}
|
||||
|
||||
for (Parm removeParm : removeParms) {
|
||||
if ((removeParm != null) && this.parms.contains(removeParm)) {
|
||||
this.parms.remove(removeParm);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
parms.releaseWriteLock();
|
||||
}
|
||||
|
||||
// recalculate the system time range changes, send notification
|
||||
TimeRange newSysTR = recalcSystemTimeRange();
|
||||
if (!newSysTR.equals(this.systemTimeRange)) {
|
||||
this.systemTimeRange = newSysTR;
|
||||
// TODO
|
||||
// SystemTimeRangeChangedMsg::send(_msgHand, _systemTimeRange);
|
||||
}
|
||||
|
||||
// send ParmListChanged notification
|
||||
if ((addParms.size() > 0) || (removeParms.size() > 0)) {
|
||||
parms.acquireReadLock();
|
||||
try {
|
||||
fireParmListChanged(
|
||||
this.parms.toArray(new Parm[this.parms.size()]),
|
||||
addParms.toArray(new Parm[addParms.size()]),
|
||||
removeParms.toArray(new Parm[removeParms.size()]));
|
||||
} finally {
|
||||
parms.releaseReadLock();
|
||||
}
|
||||
}
|
||||
|
||||
List<Parm> addedDisplayed = new ArrayList<Parm>();
|
||||
List<Parm> removedDisplayed = new ArrayList<Parm>();
|
||||
for (Parm p : addParms) {
|
||||
if (p.getDisplayAttributes().isDisplayable()) {
|
||||
addedDisplayed.add(p);
|
||||
}
|
||||
}
|
||||
|
||||
for (Parm p : removeParms) {
|
||||
if (p.getDisplayAttributes().isDisplayable()) {
|
||||
removedDisplayed.add(p);
|
||||
}
|
||||
}
|
||||
|
||||
// send DisplayedParmListChanged notification
|
||||
if ((removedDisplayed.size() > 0) || (addedDisplayed.size() > 0)) {
|
||||
parms.acquireReadLock();
|
||||
try {
|
||||
fireDisplayedParmListChanged(this.parms
|
||||
.toArray(new Parm[this.parms.size()]), addedDisplayed
|
||||
.toArray(new Parm[addedDisplayed.size()]),
|
||||
removedDisplayed.toArray(new Parm[removedDisplayed
|
||||
.size()]));
|
||||
} finally {
|
||||
parms.releaseReadLock();
|
||||
}
|
||||
}
|
||||
|
||||
// send AvailableSourcesChanged notification
|
||||
// TODO
|
||||
// if (addedDbs.length() || remDbs.length())
|
||||
// AvailableSourcesChangedMsg::send(_msgHand, nowDbs, remDbs, addedDbs);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.viz.gfe.core.IParmManager#enableDisableTopoParm(boolean,
|
||||
* boolean)
|
||||
*/
|
||||
@Override
|
||||
public void enableDisableTopoParm(boolean wanted, boolean forceVisibility) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DatabaseID> getIscDatabases() {
|
||||
return new ArrayList<DatabaseID>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ParmID getISCParmID(ParmID pid) {
|
||||
return new ParmID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean iscMode() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void purgeDbCacheForSite(String site) {
|
||||
// Do nothing
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.viz.gfe.core.IParmManager#createParm(com.raytheon.uf.common
|
||||
* .dataplugin.gfe.db.objects.ParmID, boolean, boolean)
|
||||
*/
|
||||
@Override
|
||||
public Parm createParm(ParmID pid, boolean mutableParm, boolean displayable) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,88 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.viz.gfe.core.msgs;
|
||||
|
||||
/**
|
||||
* Enable/Disable Topo Message
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Nov 20, 2013 #2331 randerso Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author randerso
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class EnableDisableTopoMsg extends Message {
|
||||
/**
|
||||
* Topo action
|
||||
*/
|
||||
public static enum Action {
|
||||
/** Enable Topo */
|
||||
ENABLE,
|
||||
/** Disable Topo */
|
||||
DISABLE
|
||||
};
|
||||
|
||||
private Action action;
|
||||
|
||||
private boolean forceVisibility;
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
*/
|
||||
public EnableDisableTopoMsg() {
|
||||
action = Action.DISABLE;
|
||||
forceVisibility = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param action
|
||||
* ENABLE or DISABLE
|
||||
* @param forceVisibility
|
||||
* true to force visibility
|
||||
*/
|
||||
public EnableDisableTopoMsg(Action action, boolean forceVisibility) {
|
||||
this.action = action;
|
||||
this.forceVisibility = forceVisibility;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the action
|
||||
*/
|
||||
public Action getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the forceVisibility
|
||||
*/
|
||||
public boolean isForceVisibility() {
|
||||
return forceVisibility;
|
||||
}
|
||||
}
|
|
@ -87,6 +87,7 @@ import com.raytheon.viz.ui.input.InputAdapter;
|
|||
* and time storage and manipulation
|
||||
* 01/22/2013 #1518 randerso Removed use of Map with Parms as keys,
|
||||
* really just needed a list anyway.
|
||||
* 11/20/2013 #2331 randerso Corrected legend for Topography
|
||||
* </pre>
|
||||
*
|
||||
* @author chammack
|
||||
|
@ -127,7 +128,7 @@ public class GFELegendResource extends
|
|||
|
||||
@Override
|
||||
public boolean handleMouseDown(int x, int y, int mouseButton) {
|
||||
if (mouseButton == 1 || mouseButton == 2) {
|
||||
if ((mouseButton == 1) || (mouseButton == 2)) {
|
||||
mouseDownRsc = checkLabelSpace(descriptor,
|
||||
getResourceContainer().getActiveDisplayPane()
|
||||
.getTarget(), x, y);
|
||||
|
@ -152,7 +153,7 @@ public class GFELegendResource extends
|
|||
ResourcePair rsc = checkLabelSpace(descriptor,
|
||||
getResourceContainer().getActiveDisplayPane().getTarget(),
|
||||
x, y);
|
||||
if (rsc != null && rsc == mouseDownRsc) {
|
||||
if ((rsc != null) && (rsc == mouseDownRsc)) {
|
||||
mouseDownRsc = null;
|
||||
if (mouseButton == 1) {
|
||||
ResourceProperties props = rsc.getProperties();
|
||||
|
@ -187,13 +188,13 @@ public class GFELegendResource extends
|
|||
} else {
|
||||
IGridData grid = parm.overlappingGrid(sdm
|
||||
.getSpatialEditorTime());
|
||||
if (grid != null && grid.isOkToEdit()) {
|
||||
if ((grid != null) && grid.isOkToEdit()) {
|
||||
sdm.activateParm(parm);
|
||||
return true;
|
||||
} else if (grid == null) {
|
||||
statusHandler.handle(Priority.SIGNIFICANT,
|
||||
"No Grid to make editable");
|
||||
} else if (grid != null && !grid.isOkToEdit()) {
|
||||
} else if ((grid != null) && !grid.isOkToEdit()) {
|
||||
statusHandler.handle(Priority.SIGNIFICANT,
|
||||
"Grid cannot be edited");
|
||||
}
|
||||
|
@ -312,8 +313,8 @@ public class GFELegendResource extends
|
|||
for (ResourcePair rp : descriptor.getResourceList()) {
|
||||
if (rp.getResource() instanceof GFEResource) {
|
||||
Parm parm = ((GFEResource) rp.getResource()).getParm();
|
||||
if (qvGrid == null
|
||||
|| (qvGrid != null && qvGrid.getParm() == parm)) {
|
||||
if ((qvGrid == null)
|
||||
|| ((qvGrid != null) && (qvGrid.getParm() == parm))) {
|
||||
parms.add(new Pair<Parm, ResourcePair>(parm, rp));
|
||||
if (qvGrid != null) {
|
||||
break;
|
||||
|
@ -400,12 +401,14 @@ public class GFELegendResource extends
|
|||
|
||||
// get the parm name
|
||||
String parmText = parmId.getParmName();
|
||||
sb.append(parmText);
|
||||
|
||||
if (parmId.equals(topoID)) {
|
||||
parmText = "Topography";
|
||||
sb.append(parmText);
|
||||
addSpaces(sb, lengths[0] + lengths[1] + lengths[2] + lengths[3]
|
||||
+ 15);
|
||||
} else {
|
||||
sb.append(parmText);
|
||||
|
||||
int diff = lengths[0] - parmText.length();
|
||||
addSpaces(sb, diff + 1);
|
||||
|
|
|
@ -231,6 +231,11 @@
|
|||
<constructor-arg value="com.raytheon.uf.common.dataplugin.gfe.request.GetLatestModelDbIdRequest"/>
|
||||
<constructor-arg ref="getLatestDbIdHandler"/>
|
||||
</bean>
|
||||
<bean id="getTopoDataHandler" class="com.raytheon.edex.plugin.gfe.server.handler.GetTopoDataHandler"/>
|
||||
<bean factory-bean="handlerRegistry" factory-method="register">
|
||||
<constructor-arg value="com.raytheon.uf.common.dataplugin.gfe.request.GetTopoDataRequest"/>
|
||||
<constructor-arg ref="getTopoDataHandler"/>
|
||||
</bean>
|
||||
|
||||
|
||||
<!-- Service Backup Handlers -->
|
||||
|
|
|
@ -36,8 +36,11 @@ import com.raytheon.edex.plugin.gfe.server.database.NetCDFDatabaseManager;
|
|||
import com.raytheon.edex.plugin.gfe.server.database.TopoDatabaseManager;
|
||||
import com.raytheon.edex.plugin.gfe.server.lock.LockManager;
|
||||
import com.raytheon.uf.common.dataplugin.PluginException;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.db.objects.GridLocation;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.exception.GfeException;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.server.message.ServerResponse;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.server.notify.GfeNotification;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.slice.ScalarGridSlice;
|
||||
import com.raytheon.uf.common.dataplugin.grid.GridRecord;
|
||||
import com.raytheon.uf.common.dataplugin.message.DataURINotificationMessage;
|
||||
import com.raytheon.uf.common.dataplugin.satellite.SatelliteRecord;
|
||||
|
@ -57,7 +60,8 @@ import com.raytheon.uf.edex.database.DataAccessLayerException;
|
|||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* May 30, 2013 2044 randerso Initial creation
|
||||
* May 30, 2013 2044 randerso Initial creation
|
||||
* Nov 20, 2013 #2331 randerso Added getTopoData method
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -350,4 +354,15 @@ public class IFPServer {
|
|||
// timer.getElapsedTime());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get topo data for a GridLocation
|
||||
*
|
||||
* @param gloc
|
||||
* GridLocation for topo data
|
||||
* @return topo gridslice
|
||||
*/
|
||||
public ServerResponse<ScalarGridSlice> getTopoData(GridLocation gloc) {
|
||||
return this.topoMgr.getTopoData(gloc);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -62,6 +62,8 @@ import com.raytheon.uf.edex.database.DataAccessLayerException;
|
|||
* Jul 10, 2009 #2590 njensen Support for multiple sites.
|
||||
* May 04, 2012 #574 dgilling Re-port to better match AWIPS1.
|
||||
* Apr 23, 2013 #1949 rjpeter Removed unused method.
|
||||
* Nov 20, 2013 #2331 randerso Changed return type of getTopoData
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author randerso
|
||||
|
@ -227,9 +229,10 @@ public class TopoDatabase extends VGridDatabase {
|
|||
List<IGridSlice> data = new ArrayList<IGridSlice>(1);
|
||||
GridDataHistory gdh = new GridDataHistory(OriginType.SCRATCH, pid,
|
||||
TR);
|
||||
ServerResponse<IGridSlice> srRetrieve = topoMgr.getTopoData(gloc);
|
||||
ServerResponse<ScalarGridSlice> srRetrieve = topoMgr
|
||||
.getTopoData(gloc);
|
||||
sr.addMessages(srRetrieve);
|
||||
ScalarGridSlice tempgs = (ScalarGridSlice) srRetrieve.getPayload();
|
||||
ScalarGridSlice tempgs = srRetrieve.getPayload();
|
||||
IGridSlice gs = new ScalarGridSlice(TR, gpi,
|
||||
new GridDataHistory[] { gdh }, tempgs.getScalarGrid());
|
||||
data.add(gs);
|
||||
|
|
|
@ -73,6 +73,7 @@ import com.raytheon.uf.common.topo.TopoQuery;
|
|||
* Feb 15, 2013 #1638 mschenke Deleted topo edex plugin, moved code into common topo
|
||||
* Jun 13, 2013 #2044 randerso Refactored to use non-singleton GridParmManager,
|
||||
* code cleanup
|
||||
* Nov 20, 2013 #2331 randerso Changed return type of getTopoData
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -134,9 +135,9 @@ public class TopoDatabaseManager {
|
|||
* @param gloc
|
||||
* @return ServerResponse containing the topo grid slice
|
||||
*/
|
||||
public ServerResponse<IGridSlice> getTopoData(final GridLocation gloc) {
|
||||
ServerResponse<IGridSlice> sr = new ServerResponse<IGridSlice>();
|
||||
IGridSlice data = new ScalarGridSlice();
|
||||
public ServerResponse<ScalarGridSlice> getTopoData(final GridLocation gloc) {
|
||||
ServerResponse<ScalarGridSlice> sr = new ServerResponse<ScalarGridSlice>();
|
||||
ScalarGridSlice data = new ScalarGridSlice();
|
||||
Grid2DFloat grid;
|
||||
String cacheGroupName = calcGroupName(gloc);
|
||||
|
||||
|
@ -189,7 +190,7 @@ public class TopoDatabaseManager {
|
|||
* @param topoGrid
|
||||
* @return
|
||||
*/
|
||||
private IGridSlice makeGridSlice(final GridLocation gloc,
|
||||
private ScalarGridSlice makeGridSlice(final GridLocation gloc,
|
||||
final Grid2DFloat topoGrid) {
|
||||
// find the max/min values in the topography data
|
||||
float maxValue = -Float.MAX_VALUE;
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.edex.plugin.gfe.server.handler;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.gfe.request.GetTopoDataRequest;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.server.message.ServerResponse;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.slice.ScalarGridSlice;
|
||||
import com.raytheon.uf.common.serialization.comm.IRequestHandler;
|
||||
|
||||
/**
|
||||
* Get Topo Data handler
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Nov 20, 2013 #2331 randerso Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author randerso
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class GetTopoDataHandler extends BaseGfeRequestHandler implements
|
||||
IRequestHandler<GetTopoDataRequest> {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.common.serialization.comm.IRequestHandler#handleRequest
|
||||
* (com.raytheon.uf.common.serialization.comm.IServerRequest)
|
||||
*/
|
||||
@Override
|
||||
public ServerResponse<ScalarGridSlice> handleRequest(
|
||||
GetTopoDataRequest request) throws Exception {
|
||||
return getIfpServer(request).getTopoData(request.getGloc());
|
||||
}
|
||||
|
||||
}
|
|
@ -33,6 +33,7 @@ import com.raytheon.uf.common.dataplugin.gfe.reference.ReferenceID;
|
|||
import com.raytheon.uf.common.dataplugin.gfe.server.message.ServerResponse;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.server.notify.UserMessageNotification;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.slice.IGridSlice;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.slice.ScalarGridSlice;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
|
@ -47,6 +48,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
|
|||
* Apr 29, 2008 njensen Initial creation
|
||||
* Jul 25, 2012 #957 dgilling Implement getEditAreaNames().
|
||||
* Jun 13, 2013 #2044 randerso Refactored to use IFPServer
|
||||
* Nov 20, 2013 #2331 randerso Changed return type of getTopoData
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -159,7 +161,7 @@ public class InitClient {
|
|||
public IGridSlice getTopo() throws GfeException {
|
||||
IGridSlice topo = null;
|
||||
GridLocation gloc = ifpServer.getConfig().dbDomain();
|
||||
ServerResponse<IGridSlice> sr = ifpServer.getTopoMgr()
|
||||
ServerResponse<ScalarGridSlice> sr = ifpServer.getTopoMgr()
|
||||
.getTopoData(gloc);
|
||||
if (sr.isOkay()) {
|
||||
topo = sr.getPayload();
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.common.dataplugin.gfe.request;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.gfe.db.objects.GridLocation;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
|
||||
/**
|
||||
* Get Topo Data request
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Nov 20, 2013 #2331 randerso Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author randerso
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
@DynamicSerialize
|
||||
public class GetTopoDataRequest extends AbstractGfeRequest {
|
||||
|
||||
@DynamicSerializeElement
|
||||
private GridLocation gloc;
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
*/
|
||||
public GetTopoDataRequest() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param gloc
|
||||
* GridLocation for topo data
|
||||
*/
|
||||
public GetTopoDataRequest(GridLocation gloc) {
|
||||
this.gloc = gloc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the gloc
|
||||
*/
|
||||
public GridLocation getGloc() {
|
||||
return gloc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param gloc
|
||||
* the gloc to set
|
||||
*/
|
||||
public void setGloc(GridLocation gloc) {
|
||||
this.gloc = gloc;
|
||||
}
|
||||
}
|
|
@ -1,201 +0,0 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.viz.gfe.ui.runtimeui;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import jep.JepException;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.gfe.python.GfePyIncludeUtil;
|
||||
import com.raytheon.uf.common.localization.PathManagerFactoryTest;
|
||||
import com.raytheon.uf.common.python.PyUtil;
|
||||
import com.raytheon.uf.common.python.PythonScript;
|
||||
import com.raytheon.uf.common.time.TimeRange;
|
||||
import com.raytheon.viz.gfe.core.DataManager;
|
||||
import com.raytheon.viz.gfe.core.FakeDataManager;
|
||||
import com.raytheon.viz.gfe.core.IParmManager;
|
||||
import com.raytheon.viz.gfe.core.internal.MockParmManager;
|
||||
import com.raytheon.viz.gfe.core.parm.Parm;
|
||||
import com.raytheon.viz.gfe.core.parm.Parm.CreateFromScratchMode;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
*
|
||||
* <pre>
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jul 24, 2008 wdougherty Initial creation
|
||||
* Sep 05, 2013 #2307 dgilling Code cleanup
|
||||
* </pre>
|
||||
*
|
||||
* @author wdougherty
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
@Ignore
|
||||
// FIXME: This test case is currently broken because of a NullPOinterException
|
||||
// in AbstractSpatialDisplayManager
|
||||
// Activator.getDefault() is returning null at the moment.
|
||||
public class TestSmartScript {
|
||||
|
||||
private static final String SCRIPT_FILE_PATH = new File(
|
||||
"./python/gfe/TestSmartScript.py").getPath();
|
||||
|
||||
private PythonScript testScript = null;
|
||||
|
||||
private DataManager dataMgr;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpBeforeClass() throws Exception {
|
||||
PathManagerFactoryTest.initLocalization();
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
FakeDataManager fakeDataMgr = new FakeDataManager();
|
||||
IParmManager pm = new MockParmManager(fakeDataMgr);
|
||||
fakeDataMgr.setParmManager(pm);
|
||||
dataMgr = fakeDataMgr;
|
||||
|
||||
String includePath = PyUtil.buildJepIncludePath(
|
||||
GfePyIncludeUtil.getCommonPythonIncludePath(),
|
||||
GfePyIncludeUtil.getCommonGfeIncludePath(),
|
||||
GfePyIncludeUtil.getUtilitiesIncludePath());
|
||||
try {
|
||||
testScript = new PythonScript(SCRIPT_FILE_PATH, includePath, this
|
||||
.getClass().getClassLoader());
|
||||
} catch (JepException e) {
|
||||
throw new Exception(e);
|
||||
}
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
if (testScript != null) {
|
||||
testScript.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSortUglyStr() throws Exception {
|
||||
Map<String, Object> argmap = new HashMap<String, Object>(2, 1.0f);
|
||||
argmap.put("uglyStr", "I^AM^THE^CAPTAIN^OF^PINAFORE");
|
||||
argmap.put("dataMgr", dataMgr);
|
||||
String outstr = null;
|
||||
try {
|
||||
outstr = (String) testScript.execute("testSortUglyStr", null,
|
||||
argmap);
|
||||
} catch (JepException e) {
|
||||
throw new Exception(e);
|
||||
}
|
||||
assertEquals("AM^CAPTAIN^I^OF^PINAFORE^THE", outstr);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetIndex() throws Exception {
|
||||
Map<String, Object> argmap = new HashMap<String, Object>(3, 1.0f);
|
||||
argmap.put("dataMgr", dataMgr);
|
||||
|
||||
String key1 = "Twas^Brillig^and^the^slithy^toves";
|
||||
String key2 = "Did^gyre^and^gimbol^in^the^wabe";
|
||||
String key3 = "Twas^Brillig^and";
|
||||
String key4 = "and^slithy^the^toves^Brillig^Twas";
|
||||
List<String> keyList = Arrays.asList(key1, key2, key3, key4);
|
||||
argmap.put("keyList", keyList);
|
||||
|
||||
for (int i = 0; i < keyList.size(); i++) {
|
||||
Integer outInt = null;
|
||||
argmap.put("uglyStr", keyList.get(i));
|
||||
try {
|
||||
outInt = (Integer) testScript.execute("testGetIndex", null,
|
||||
argmap);
|
||||
assertEquals("key" + (i + 1), i, outInt.intValue());
|
||||
} catch (JepException e) {
|
||||
throw new Exception(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetGridShape() throws Exception {
|
||||
try {
|
||||
Map<String, Object> argmap = new HashMap<String, Object>(1, 1.0f);
|
||||
argmap.put("dataMgr", dataMgr);
|
||||
Boolean testResult = (Boolean) testScript.execute(
|
||||
"testGetGridShape", null, argmap);
|
||||
assertTrue("Tuples should match", testResult);
|
||||
} catch (JepException e) {
|
||||
throw new Exception(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetGridInfo() throws Exception {
|
||||
Map<String, Object> argmap = new HashMap<String, Object>(5, 1.0f);
|
||||
argmap.put("dataMgr", dataMgr);
|
||||
argmap.put("model", "Fcst");
|
||||
argmap.put("element", "Hazards");
|
||||
argmap.put("level", "SFC");
|
||||
Parm parm = null;
|
||||
try {
|
||||
parm = (Parm) testScript.execute("getParm", null, argmap);
|
||||
} catch (JepException e) {
|
||||
throw new Exception(e);
|
||||
}
|
||||
assertNotNull("Retrieved Hazards_SFC parm.", parm);
|
||||
|
||||
TimeRange tr = new TimeRange(new Date(), 1000L);
|
||||
boolean created = parm.createFromScratchTR(tr,
|
||||
CreateFromScratchMode.DEFAULT, 1200, 5);
|
||||
assertTrue("createFromScratchTR", created);
|
||||
|
||||
parm.insertNewGrid(new TimeRange[] { tr },
|
||||
CreateFromScratchMode.DEFAULT);
|
||||
|
||||
System.out
|
||||
.println("Class of parm = " + parm.getClass().getSimpleName());
|
||||
|
||||
tr = TimeRange.allTimes();
|
||||
argmap.put("timeRange", tr);
|
||||
try {
|
||||
Boolean passedTest = (Boolean) testScript.execute(
|
||||
"testGetGridInfo", null, argmap);
|
||||
assertTrue("Tests in Python passed", passedTest);
|
||||
} catch (JepException e) {
|
||||
throw new Exception(e);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue