Merge "Omaha #5271 - include the time span for products that track time span in minutes." into omaha_16.2.2

Former-commit-id: e89d870c8ea9e98e4039d6eb96ca374efd21c815
This commit is contained in:
Bryan Kowal 2016-01-25 13:02:05 -06:00 committed by Gerrit Code Review
commit 8224504f4a
3 changed files with 152 additions and 175 deletions

View file

@ -28,93 +28,106 @@ import com.raytheon.rcm.products.ProductInfo.Selector;
import com.raytheon.rcm.products.RadarProduct;
import com.raytheon.rcm.products.RadarProduct.Param;
/**
* Used to format a {@link RpsList} before it is written.
*
* <pre>
*
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* ? ? ? Initial creation.
* Jan 20, 2016 5271 bkowal Include time span / end hour for products
* that use minutes for the time span.
* </pre>
*
*/
public class RpsListFormatter {
/* See AWIPS-1 ProductRequestList::writeList()
*
*/
public static void formatAwips1RpsList(RpsList list, String fileName, PrintWriter s) {
RadarType radarType = list.getVcp() == 80 || list.getVcp() == 90 ?
RadarType.TDWR : RadarType.WSR;
Calendar cal = Calendar.getInstance();
s.format("RPS List %s %s... %d products\n",
fileName != null ? fileName : "",
String.format("%1$tY:%1$tm:%1$td:%1$tH:%1$tM:%1$tS", cal),
list.getRequests().length);
s.print(" An RPS list contains the fields: Prod-Name, Mnemonic, Prod-Code\n" +
" Number of Data Levels, Resolution, Layer Code, Elevation, Contour Interval,\n" +
" Priority, Req Interval, Map, Lower Layer, Upper Layer, multCut, endHour, timeSpan\n" +
" The record format is: '%-39s %-3s%4d%4d%6d %c%6d%7d%2d%2d%c%3d%3d %c%7d%7d'\n");
/*
* See AWIPS-1 ProductRequestList::writeList()
*/
public static void formatAwips1RpsList(RpsList list, String fileName,
PrintWriter s) {
RadarType radarType = list.getVcp() == 80 || list.getVcp() == 90 ? RadarType.TDWR
: RadarType.WSR;
Calendar cal = Calendar.getInstance();
s.format("RPS List %s %s... %d products\n", fileName != null ? fileName
: "",
String.format("%1$tY:%1$tm:%1$td:%1$tH:%1$tM:%1$tS", cal), list
.getRequests().length);
s.print(" An RPS list contains the fields: Prod-Name, Mnemonic, Prod-Code\n"
+ " Number of Data Levels, Resolution, Layer Code, Elevation, Contour Interval,\n"
+ " Priority, Req Interval, Map, Lower Layer, Upper Layer, multCut, endHour, timeSpan\n"
+ " The record format is: '%-39s %-3s%4d%4d%6d %c%6d%7d%2d%2d%c%3d%3d %c%7d%7d'\n");
for (Request r : list.getRequests()) {
s.println(formatAwips1Request(r, radarType));
}
}
private static final char[] layerCodes = {'L', 'M', 'H'};
public static String formatAwips1Request(Request r, RadarType radarType) {
RadarProduct rp = ProductInfo.getInstance().selectOne(
new Selector(radarType, null, (int) r.productCode, null));
/* Could probably guess how to format the important parts, but this
* is what AWIPS-1 does anyway...
*/
if (rp == null)
throw new IllegalArgumentException("Cannot format unknown product type " +
r.productCode + ".");
/* Note there is no check for rp.contains(ELEVATION) This
* is fine for the current set of products that are available in
* the RPS list editor...
*/
/* // Mimic:
if (_multCuts == 'Y' && _elev > 16384)
{
_elev -= 16384;
for (Request r : list.getRequests()) {
s.println(formatAwips1Request(r, radarType));
}
*/
boolean multiCuts = false;
int elev = r.pdw22;
if (r.getElevationSelection() == Request.ALL_ELEVATIONS &&
r.getElevationAngle() != 0) {
elev = r.getElevationAngle();
multiCuts = true;
}
char layerCode = '-';
if (rp.layer != null) {
try {
layerCode = layerCodes[rp.layer - 1];
} catch (ArrayIndexOutOfBoundsException e) {
// nothing
}
}
int lowerLayer = -1;
int upperLayer = -1;
if (rp.params.contains(Param.LAYER)) {
lowerLayer = r.getBottomAltitude();
upperLayer = r.getTopAltitude();
} else if (rp.params.contains(Param.MINI_VOLUME)) {
lowerLayer = r.getMiniVolume();
}
int endHour = -1;
int timeSpan = -1;
if (rp.params.contains(Param.TIME_SPAN)) {
endHour = r.getEndHour();
timeSpan = r.getTimeSpan();
}
return String.format("%-39.39s %-3.3s%4d%4d%6d %c%6d%7d%2d%2d%c%3d%3d %c%7d%7d",
rp.name, rp.mnemonic,
r.productCode,
rp.levels != null ? rp.levels : 0,
rp.resolution != null ? (int)(rp.resolution * 100) : 0,
layerCode, elev, -1 /*contour interval*/,
r.highPriority ? 1 : 0, r.interval,
r.mapRequested ? 'Y' : 'N',
lowerLayer, upperLayer,
multiCuts ? 'Y' : 'N',
endHour, timeSpan);
}
}
private static final char[] layerCodes = { 'L', 'M', 'H' };
public static String formatAwips1Request(Request r, RadarType radarType) {
RadarProduct rp = ProductInfo.getInstance().selectOne(
new Selector(radarType, null, (int) r.productCode, null));
/*
* Could probably guess how to format the important parts, but this is
* what AWIPS-1 does anyway...
*/
if (rp == null) {
throw new IllegalArgumentException(
"Cannot format unknown product type " + r.productCode + ".");
}
/*
* Note there is no check for rp.contains(ELEVATION) This is fine for
* the current set of products that are available in the RPS list
* editor...
*/
/*
* // Mimic: if (_multCuts == 'Y' && _elev > 16384) { _elev -= 16384; }
*/
boolean multiCuts = false;
int elev = r.pdw22;
if (r.getElevationSelection() == Request.ALL_ELEVATIONS
&& r.getElevationAngle() != 0) {
elev = r.getElevationAngle();
multiCuts = true;
}
char layerCode = '-';
if (rp.layer != null) {
try {
layerCode = layerCodes[rp.layer - 1];
} catch (ArrayIndexOutOfBoundsException e) {
// nothing
}
}
int lowerLayer = -1;
int upperLayer = -1;
if (rp.params.contains(Param.LAYER)) {
lowerLayer = r.getBottomAltitude();
upperLayer = r.getTopAltitude();
} else if (rp.params.contains(Param.MINI_VOLUME)) {
lowerLayer = r.getMiniVolume();
}
int endHour = -1;
int timeSpan = -1;
if (rp.params.contains(Param.TIME_SPAN)
|| rp.params.contains(Param.TIME_SPAN_MINUTES)) {
endHour = r.getEndHour();
timeSpan = r.getTimeSpan();
}
return String.format(
"%-39.39s %-3.3s%4d%4d%6d %c%6d%7d%2d%2d%c%3d%3d %c%7d%7d",
rp.name, rp.mnemonic, r.productCode,
rp.levels != null ? rp.levels : 0,
rp.resolution != null ? (int) (rp.resolution * 100) : 0,
layerCode, elev, -1 /* contour interval */, r.highPriority ? 1
: 0, r.interval, r.mapRequested ? 'Y' : 'N',
lowerLayer, upperLayer, multiCuts ? 'Y' : 'N', endHour,
timeSpan);
}
}

View file

@ -61,9 +61,9 @@ import com.raytheon.rcm.server.StatusManager.RadarStatus;
/**
* Manages current RPS lists and requests for changes to RPS lists.
*
*
* <pre>
*
*
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
@ -73,8 +73,9 @@ import com.raytheon.rcm.server.StatusManager.RadarStatus;
* 2014-02-03 DR 14762 D. Friedman Handle updated national RPS lists.
* 2015-06-10 4498 nabowle Rename Util->RcmUtil
* 2015-09-08 DR 17944 D. Friedman Handle elevation list file updates.
* 2016-01-20 5271 bkowal Fix resource leak.
* </pre>
*
*
*/
public class RPSListManager extends RadarEventAdapter {
@ -181,11 +182,13 @@ public class RPSListManager extends RadarEventAdapter {
return "Error getting radar status";
}
int[] cuts = ElevationInfo.getInstance().getScanElevations(radarID, currentVCP);
int[] cuts = ElevationInfo.getInstance().getScanElevations(radarID,
currentVCP);
if (cuts == null && RcmUtil.getRadarType(rc) == RadarType.WSR)
cuts = gsmCuts;
if (list.getVcp() != RpsList.UNSPECIFIED_VCP && list.getVcp() != currentVCP) {
if (list.getVcp() != RpsList.UNSPECIFIED_VCP
&& list.getVcp() != currentVCP) {
if (store)
return null; // TODO: Should warn instead.
else
@ -240,13 +243,13 @@ public class RPSListManager extends RadarEventAdapter {
rpsList = null;
if (rpsList == null) {
int[] cuts = ElevationInfo.getInstance().
getScanElevations(rc.getRadarID(), gsm.vcp);
int[] cuts = ElevationInfo.getInstance().getScanElevations(
rc.getRadarID(), gsm.vcp);
if (cuts == null && RcmUtil.getRadarType(rc) == RadarType.WSR)
cuts = gsm.cuts;
rpsList = getMergedRpsListForRadar(rc, gsm.opMode, gsm.vcp,
cuts, null);
rpsList = getMergedRpsListForRadar(rc, gsm.opMode, gsm.vcp, cuts,
null);
// TODO: Should persist this (wouldn't need clone code)
if (rpsList != null)
@ -259,7 +262,7 @@ public class RPSListManager extends RadarEventAdapter {
/**
* From AWIPS 1 ProductRequestList::addMiniVolumeProduct() (DCS 3411)
*
*
* For TDWR VCP80, 2 products might be generated in one volume (2 mini
* volumes) for some products. Parameter lowerLayer is used to specify these
* 2 products: 1 - generated at mid volume; 2 - generated at end volume
@ -267,7 +270,7 @@ public class RPSListManager extends RadarEventAdapter {
* implementation ---------------------------------------------------------
* Searches list for mini volume products, add a new entry with lowerLayer 1
* CZ(35-38),ET(41),VIL(57),STI(58),HI(59),TVS(61),MD(141),DMD(149)
*
*
*/
/*
* This must be kept in sync with
@ -279,8 +282,8 @@ public class RPSListManager extends RadarEventAdapter {
return;
/*
* We want to put these products at the end of the list so that they
* do not have priority over existing products.
* We want to put these products at the end of the list so that they do
* not have priority over existing products.
*/
Selector sel = new Selector();
sel.radarType = RadarType.TDWR;
@ -290,8 +293,8 @@ public class RPSListManager extends RadarEventAdapter {
Request r = reqs.get(i);
sel.code = (int) r.productCode;
RadarProduct prod = ProductInfo.getInstance().selectOne(sel);
if (prod != null && prod.params.contains(Param.MINI_VOLUME) &&
r.getMiniVolume() != 1) {
if (prod != null && prod.params.contains(Param.MINI_VOLUME)
&& r.getMiniVolume() != 1) {
Request r2 = r.clone();
r2.setMiniVolume(1);
reqs.add(r2);
@ -321,14 +324,14 @@ public class RPSListManager extends RadarEventAdapter {
Log.warnf("Cannot determine maximum RPS list size for %s",
rc.getRadarID());
if (requestCount < 0)
Log.warnf("Cannot number of requests in RPS list for %s", rc
.getRadarID());
Log.warnf("Cannot number of requests in RPS list for %s",
rc.getRadarID());
if (maxSize >= 0 && requestCount >= 0 && requestCount > maxSize) {
int truncCount = 0;
int i;
for (i = reqs.length - 1; i >= 0; --i) {
truncCount += RpsList.getRequestCount(reqs[i], rc.getRadarID(), rpsList.getVcp(),
RcmUtil.getRadarType(rc));
truncCount += RpsList.getRequestCount(reqs[i], rc.getRadarID(),
rpsList.getVcp(), RcmUtil.getRadarType(rc));
if (requestCount - truncCount <= maxSize)
break;
}
@ -337,8 +340,10 @@ public class RPSListManager extends RadarEventAdapter {
int originalCount = requestCount;
requestCount = requestCount - truncCount;
Log.warnf("Truncated list for %s from %d entries (%d requests) to %d entries (%d requests)",
rc.getRadarID(), reqs.length, originalCount, i, requestCount);
Log.warnf(
"Truncated list for %s from %d entries (%d requests) to %d entries (%d requests)",
rc.getRadarID(), reqs.length, originalCount, i,
requestCount);
// TODO: Also need to send a message to Guardian
reqs = Arrays.copyOf(reqs, i);
rpsList = new RpsList(rpsList.getOpMode(), rpsList.getVcp(), reqs);
@ -346,8 +351,8 @@ public class RPSListManager extends RadarEventAdapter {
Log.warnf("Sending empty RPS list to %s", rc.getRadarID());
}
Log.eventf("%s: Sending RPS list with %d entries (%d requests)", rc.getRadarID(),
rpsList.getRequests().length, requestCount);
Log.eventf("%s: Sending RPS list with %d entries (%d requests)",
rc.getRadarID(), rpsList.getRequests().length, requestCount);
byte[] msg = ProductRequest.encode(rpsList.getRequests());
radarServer.getConnectionManager().sendMessageToRadar(rc.getRadarID(),
msg);
@ -396,8 +401,7 @@ public class RPSListManager extends RadarEventAdapter {
path = new File(dir, rc.getRadarID().toUpperCase()
+ ".currentVCP");
fo = new FileOutputStream(path);
try {
PrintWriter p = new PrintWriter(fo);
try (PrintWriter p = new PrintWriter(fo)) {
p.printf("VCP%d\n", rpsList.getVcp());
p.flush();
} finally {
@ -431,7 +435,7 @@ public class RPSListManager extends RadarEventAdapter {
/**
* Constructs a an RPS list for the given parameters, merging national and
* local lists as appropriate.
*
*
* @param rc
* @param opMode
* @param vcp
@ -487,14 +491,12 @@ public class RPSListManager extends RadarEventAdapter {
maybeAddSPGMiniVolumeProducts(rc, reqs, vcp);
/*
* AWIPS 1 disabled duplicate merging for TDWRs because some requests
* in the national RPS list would disappear. This was due to incorrect
* handling of multi-elevation requests. AWIPS 2 handles
* multi-elevation request correctly. (See DCS 3472, DRs 19386, 20239,
* and 20244.)
*
* if (vcp == 80 || vcp == 90)
* elevList = null;
* AWIPS 1 disabled duplicate merging for TDWRs because some requests in
* the national RPS list would disappear. This was due to incorrect
* handling of multi-elevation requests. AWIPS 2 handles multi-elevation
* request correctly. (See DCS 3472, DRs 19386, 20239, and 20244.)
*
* if (vcp == 80 || vcp == 90) elevList = null;
*/
RadarType radarType = RcmUtil.getRadarType(rc);
@ -518,7 +520,7 @@ public class RPSListManager extends RadarEventAdapter {
* later multi-elevation request that subsumes it to be
* lost when the list is truncated to fix the maximum
* number of products.
*
*
* On the other hand, this could cause products listed
* before index j to be lost because the RPG counts each
* elevation in a multi-elevation request as a separate
@ -599,8 +601,8 @@ public class RPSListManager extends RadarEventAdapter {
private void resetRpsListForRadar(RadarConfig rc) {
String radarID = rc.getRadarID();
RadarStatus status = radarServer.getStatusManager()
.getRadarStatus(radarID);
RadarStatus status = radarServer.getStatusManager().getRadarStatus(
radarID);
byte[] gsmData = null;
if (status != null)
gsmData = status.getCurrentGSM();
@ -609,10 +611,8 @@ public class RPSListManager extends RadarEventAdapter {
if (gsmData != null) {
handleGSM(rc, gsmData);
} else {
Log.debugf(
"RPS-relevant configuration changed for %s, but "
+ "it is not connected. Cannot send a list now.",
radarID);
Log.debugf("RPS-relevant configuration changed for %s, but "
+ "it is not connected. Cannot send a list now.", radarID);
}
}
}

View file

@ -100,9 +100,9 @@ import com.raytheon.uf.viz.radarapps.products.ui.RadarProductUI;
/**
* RPS List Editor window
*
*
* <pre>
*
*
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
@ -111,8 +111,9 @@ import com.raytheon.uf.viz.radarapps.products.ui.RadarProductUI;
* 2013-01-31 DR 15458 D. Friedman Send RPS list so that it will be
* accepted for any VCP.
* 2015-06-10 4498 nabowle Rename Util->RcmUtil
* 2016-01-20 5271 bkowal Code cleanup.
* </pre>
*
*
*/
public class ListEditorWindow {
private static final transient IUFStatusHandler statusHandler = UFStatus
@ -452,8 +453,9 @@ public class ListEditorWindow {
protected void onClose(ShellEvent e) {
e.doit = false;
if (!checkUnsaved())
if (!checkUnsaved()) {
return;
}
// TODO: reset if just going to make invisible...
listEditor.dispose();
}
@ -479,8 +481,9 @@ public class ListEditorWindow {
SendRpsList msg = new SendRpsList();
msg.radarIDs = Arrays.asList(rpg);
msg.requests = Arrays.asList(listEditor.getRpsList().getRequests());
/* Specify that the RadarServer should accept this list no matter
* what VCP the RPG is currently using.
/*
* Specify that the RadarServer should accept this list no matter what
* VCP the RPG is currently using.
*/
msg.vcp = RpsList.UNSPECIFIED_VCP;
String error = null;
@ -566,10 +569,11 @@ public class ListEditorWindow {
RadarProduct rp = ProductInfo.getInstance().getPoductForCode(
req.productCode);
Collection<RadarProduct> variants = ProductInfo.getInstance().select(
new ProductInfo.Selector(null, rp.mnemonic, null, null));
StringBuilder sb = new StringBuilder();
if (rp != null) {
Collection<RadarProduct> variants = ProductInfo.getInstance()
.select(new ProductInfo.Selector(null, rp.mnemonic, null,
null));
if (rp.name != null)
sb.append(rp.name);
/*
@ -645,7 +649,6 @@ public class ListEditorWindow {
sb.append(String.format("Product #%d", req.productCode));
}
return sb.toString();
// return element.toString();
}
private VCPInfo chooseVcp(String message) {
@ -738,45 +741,6 @@ public class ListEditorWindow {
return listEditor.saveList();
}
private void onStoreList() {
if (!sendCheck())
return;
StoreDialog sd = new StoreDialog(getShell(), listEditor);
if (sd.open() == Window.OK) {
if (!checkListLength(sd.getRadarIDs(), sd.getVcps()))
return;
RcmClient client = RadarApps.getRcmSystem().getClient();
for (int vcp : sd.getVcps()) {
SendRpsList msg = new SendRpsList();
msg.radarIDs = sd.getRadarIDs();
if (msg.radarIDs.size() == 0)
return;
msg.requests = Arrays.asList(listEditor.getRpsList()
.getRequests());
msg.vcp = vcp;
msg.store = true;
String error = null;
try {
ReplyObj ro = client.sendRequest(msg, 2000);
error = ro.error;
} catch (IOException e) {
error = e.toString();
}
if (error != null) {
MessageBox mb = new MessageBox(getShell(), SWT.ICON_ERROR
| SWT.OK);
mb.setText("Error");
mb.setMessage(error);
mb.open();
} else
listEditor.setDirty(false);
}
}
}
private boolean sendCheck() {
if (listEditor.getRequestList().size() >= 1)
return true;