The following document contains the results of PMD's CPD 5.3.2.
| File | Line |
|---|---|
| gov/usgs/volcanoes/winston/legacyServer/WWSCommandString.java | 26 |
| gov/usgs/volcanoes/winston/server/wws/WwsCommandString.java | 59 |
}
public String[] getCommandSplits() {
return commandSplits;
}
public String getString(final int i) {
if (i >= commandSplits.length)
return null;
else
return commandSplits[i];
}
public int getInt(final int i) {
int result = Integer.MIN_VALUE;
try {
result = Integer.parseInt(commandSplits[i]);
} catch (final Exception e) {
}
return result;
}
public double getDouble(final int i) {
double result = Double.NaN;
try {
result = Double.parseDouble(commandSplits[i]);
} catch (final Exception e) {
}
return result;
}
public String getID() {
if (commandSplits.length < 2)
return null;
else
return commandSplits[1];
}
public String getWinstonSCNL() {
if (commandSplits.length < 6)
return null;
else {
String loc = "";
if (!commandSplits[5].equals("--"))
loc = "$" + commandSplits[5];
return commandSplits[2] + "$" + commandSplits[3] + "$" + commandSplits[4] + loc;
}
}
public double getT1(final boolean isScnl) {
int ofs = 0;
if (isScnl)
ofs = 1;
if (commandSplits.length < 6 + ofs)
return Double.NaN;
else
return getDouble(5 + ofs);
}
public double getT2(final boolean isScnl) {
int ofs = 0;
if (isScnl)
ofs = 1;
if (commandSplits.length < 7 + ofs)
return Double.NaN;
else
return getDouble(6 + ofs);
}
public int length() {
return commandSplits.length;
}
public boolean isLegal(final int cnt) {
return commandSplits.length == cnt;
}
public boolean isLegalSCNTT(final int cnt) {
if (commandSplits.length != cnt)
return false;
if (Double.isNaN(getT1(false)) || Double.isNaN(getT2(false)))
return false;
return true;
}
public boolean isLegalSCNLTT(final int cnt) {
if (commandSplits.length != cnt)
return false;
if (Double.isNaN(getT1(true)) || Double.isNaN(getT2(true)))
return false;
return true;
}
public String getS() {
if (commandSplits.length <= 2)
return null;
return commandSplits[2];
}
public String getC() {
if (commandSplits.length <= 3)
return null;
return commandSplits[3];
}
public String getN() {
if (commandSplits.length <= 4)
return null;
return commandSplits[4];
}
public String getL() {
if (commandSplits.length <= 5)
return null;
return commandSplits[5];
}
// TODO: fix getL() below.
public String getEarthwormErrorString(final int sid, final String msg) {
return getID() + " " + sid + " " + getS() + " " + getC() + " " + getN() + " " + getL() + " "
+ msg + "\n";
}
} | |
| File | Line |
|---|---|
| gov/usgs/volcanoes/winston/db/Input.java | 348 |
| gov/usgs/volcanoes/winston/db/Input.java | 466 |
if (!filled) {
d = new double[] {i, Integer.MAX_VALUE, Integer.MIN_VALUE, 0, 0};
winston.getStatement().execute("INSERT IGNORE INTO `" + table + "` VALUES (" + i + ","
+ Integer.MAX_VALUE + "," + Integer.MIN_VALUE + ",0,0)");
}
}
heliList[j++] = d;
}
double st = tb.getStartTimeJ2K();
final double dt = 1 / tb.samplingRate();
for (int i = 0; i < tb.numSamples(); i++) {
j = (int) (Math.floor(st) - fst);
final double[] d = heliList[j];
final int sample = tb.samples()[i];
d[1] = Math.min(d[1], sample);
d[2] = Math.max(d[2], sample);
d[4] = (d[4] * d[3] + Math.abs(sample)) / (d[3] + 1);
d[3] = d[3] + 1;
st += dt;
}
for (int i = 0; i < heliList.length; i++) {
final int j2k = (int) Math.round(fst + i);
winston.getStatement()
.execute("UPDATE `" + table + "` SET smin=" + (int) heliList[i][1] + ", smax="
+ (int) heliList[i][2] + ", rcnt=" + (int) heliList[i][3] + ", rsam="
+ heliList[i][4] + " WHERE j2ksec=" + j2k);
opt.putData(j2k, heliList[i]);
} | |
| File | Line |
|---|---|
| gov/usgs/volcanoes/winston/legacyServer/cmd/http/HttpMenuCommand.java | 70 |
| gov/usgs/volcanoes/winston/server/http/cmd/MenuCommand.java | 142 |
final List<String> list = emulator.getWaveServerMenu(true, 0, 0, maxDays);
final String[][] menu = new String[list.size()][8];
int i = 0;
for (final String s : list)
menu[i++] = s.split("\\s");
Arrays.sort(menu, getMenuComparator(sortCol, order));
// display menu items
for (final String[] line : menu) {
if (line.length < 8) {
output.append("can't parse line, skipping. " + Arrays.toString(line));
continue;
}
SimpleDateFormat dateF = new SimpleDateFormat(Time.STANDARD_TIME_FORMAT);
dateF.setTimeZone(timeZone);
final double start = Double.parseDouble(line[6]);
final double end = Double.parseDouble(line[7]);
output.append("<tr>");
output.append("<td>" + line[1] + "</td>");
output.append("<td>" + line[2] + "</td>");
output.append("<td>" + line[3] + "</td>");
output.append("<td>" + line[4] + "</td>");
output.append("<td>" + line[5] + "</td>");
output.append("<td>" + dateF.format(Ew.asEpoch(start)) + "</td>");
output.append("<td>" + dateF.format(Ew.asEpoch(end)) + "</td>");
output.append("<td>" + line[8] + "</td>");
output.append("</tr>\n");
}
output.append("</table>"); | |
| File | Line |
|---|---|
| gov/usgs/volcanoes/winston/server/wws/cmd/GetScnlCommand.java | 34 |
| gov/usgs/volcanoes/winston/server/wws/cmd/GetScnlRawCommand.java | 39 |
public GetScnlCommand() {
super();
isScnl = true;
}
public void doCommand(ChannelHandlerContext ctx, WwsCommandString cmd)
throws MalformedCommandException, UtilException {
if (cmd.length() < (isScnl ? 8 : 7))
throw new MalformedCommandException();
final String id = cmd.getID();
final String chan = getChan(cmd, " ");
final String code = getChan(cmd, "$");
final double startTime = Time.ewToj2k(cmd.getT1(isScnl));
final double endTime = Time.ewToj2k(cmd.getT2(isScnl));
final Integer chanId = getChanId(code);
if (chanId == -1) {
ctx.writeAndFlush(id + " " + id + " 0 " + chan + " FN\n");
return;
}
final double[] timeSpan = getTimeSpan(chanId);
String hdrPreamble = id + " " + chanId + " " + chan + " ";
String errorString = null;
if (endTime < startTime) {
errorString = hdrPreamble + "FB";
} else if (endTime < timeSpan[0]) {
errorString = hdrPreamble + "FL s4";
} else if (startTime > timeSpan[1]) {
errorString = hdrPreamble + "FR s4";
}
if (errorString != null) {
ctx.writeAndFlush(errorString + "\n");
return;
}
final Wave wave; | |
| File | Line |
|---|---|
| gov/usgs/volcanoes/winston/tools/pannel/AdminPanel.java | 36 |
| gov/usgs/volcanoes/winston/tools/pannel/WinstonUpgradePanel.java | 37 |
"Winston Admin"));
setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
final FormLayout layout = new FormLayout("left:p, 4dlu, fill:p:G", "");
final DefaultFormBuilder builder = new DefaultFormBuilder(layout);
builder.setDefaultDialogBorder();
createFields();
builder.append("Current schema", currentVersion);
builder.nextLine();
builder.append("Available upgrade", upgradeDescription);
builder.nextLine();
builder.appendUnrelatedComponentsGapRow();
builder.nextLine();
builder.append("", upgradeB);
add(builder.getPanel());
}
@Override
protected void createFields() {
ug = new Upgrade();
currentVersion = new JTextField(ug.getCurrentVersion());
upgradeDescription = new JTextArea(ug.getUpgraderDescription());
upgradeDescription.setLineWrap(true);
upgradeDescription.setWrapStyleWord(true);
upgradeB = new JButton("upgrade");
upgradeB.setEnabled(ug.upgradeAvailable());
upgradeB.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
start();
}
});
}
@Override
protected void go() {
ug.doUpgrade();
removeAll();
createUI();
}
@Override
public boolean needsWinston() {
return true;
}
} | |
| File | Line |
|---|---|
| gov/usgs/volcanoes/winston/legacyServer/cmd/http/fdsn/station/FdsnStationQuery.java | 310 |
| gov/usgs/volcanoes/winston/server/http/cmd/fdsnws/StationService.java | 232 |
private Element createChannelElement(final Channel c, final Document doc) {
final Element channelElement = doc.createElement("Channel");
final String loc = c.location.equals("--") ? " " : c.location;
channelElement.setAttribute("locationCode", loc);
channelElement.setAttribute("code", c.channel);
Element e;
e = doc.createElement("Latitude");
e.appendChild(doc.createTextNode("" + c.getInstrument().getLatitude()));
channelElement.appendChild(e);
e = doc.createElement("Longitude");
e.appendChild(doc.createTextNode("" + c.getInstrument().getLongitude()));
channelElement.appendChild(e);
e = doc.createElement("Elevation");
e.appendChild(doc.createTextNode("" + c.getInstrument().getHeight()));
channelElement.appendChild(e);
e = doc.createElement("Depth");
e.setAttribute("Supported", "no");
e.appendChild(doc.createTextNode("" + 0));
channelElement.appendChild(e);
return channelElement;
} | |
| File | Line |
|---|---|
| gov/usgs/volcanoes/winston/legacyServer/cmd/http/fdsn/constraint/FdsnGeographicCircleConstraint.java | 26 |
| gov/usgs/volcanoes/winston/server/http/cmd/fdsnws/constraint/GeographicCircleConstraint.java | 40 |
public FdsnGeographicCircleConstraint(final String latitude, final String longitude,
final String minRadius, final String maxRadius) {
final double lat = StringUtils.stringToDouble(latitude, DEFAULT_LATITUDE);
final double lon = StringUtils.stringToDouble(longitude, DEFAULT_LONGITUDE);
point = new Point2D.Double(lat, lon);
this.minRadius = StringUtils.stringToDouble(minRadius, DEFAULT_MINRADIUS);
this.maxRadius = StringUtils.stringToDouble(maxRadius, DEFAULT_MAXRADIUS);
}
public boolean matches(final Channel chan) {
final Instrument i = chan.getInstrument();
final double lat = i.getLatitude();
final double lon = i.getLongitude();
if (Double.isNaN(lat) || Double.isNaN(lon)) {
return false;
}
final Point2D.Double p = new Point2D.Double(lat, lon);
final double radius = Projection.distanceBetweenDegree(point, p);
return (radius >= minRadius && radius <= maxRadius);
}
@Override
public String toString() {
return "FdsnGeographicCircleConstraint: " + point.x + "," + point.y + " " + minRadius + " >< "
+ maxRadius;
}
} | |
| File | Line |
|---|---|
| gov/usgs/volcanoes/winston/legacyServer/cmd/http/fdsn/station/FdsnStationQuery.java | 284 |
| gov/usgs/volcanoes/winston/server/http/cmd/fdsnws/StationService.java | 206 |
private Element createStationElement(final Channel c, final Document doc) {
final Element station = doc.createElement("Station");
station.setAttribute("code", c.station);
Element e;
e = doc.createElement("Latitude");
e.appendChild(doc.createTextNode("" + c.getInstrument().getLatitude()));
station.appendChild(e);
e = doc.createElement("Longitude");
e.appendChild(doc.createTextNode("" + c.getInstrument().getLongitude()));
station.appendChild(e);
e = doc.createElement("Elevation");
e.appendChild(doc.createTextNode("" + c.getInstrument().getHeight()));
station.appendChild(e);
e = doc.createElement("Site");
final Element n = doc.createElement("Name");
n.appendChild(doc.createTextNode(c.getInstrument().getDescription()));
e.appendChild(n);
station.appendChild(e);
return station;
}
private Element createChannelElement(final Channel c, final Document doc) { | |
| File | Line |
|---|---|
| gov/usgs/volcanoes/winston/in/ImportSeed.java | 31 |
| gov/usgs/volcanoes/winston/in/ImportSeisan.java | 35 |
private static final Parameter[] JSAP_PARAMETERS = new Parameter[] {
new FlaggedOption("station", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 's',
"station", "Override station identifier code\n"),
new FlaggedOption("channel", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 'c',
"channel", "Override channel identifier\n"),
new FlaggedOption("network", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 'n',
"network", "Override network identifier\n"),
new FlaggedOption("location", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 'l',
"location", "Override location identifier\n"),
new FlaggedOption("rsamDelta", JSAP.INTEGER_PARSER, "10", JSAP.NOT_REQUIRED, 'r', "rsamDelta",
"Override location identifier\n"),
new FlaggedOption("rsamDuration", JSAP.INTEGER_PARSER, "60", JSAP.NOT_REQUIRED, 'd',
"rsamDuration", "Override location identifier\n"),
new UnflaggedOption("file", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED,
JSAP.GREEDY, "files to import.")};
private String network;
private String station;
private String channel;
private String location;
public ImportSeed() { | |
| File | Line |
|---|---|
| gov/usgs/volcanoes/winston/legacyServer/cmd/http/fdsn/constraint/FdsnTimeWindowConstraint.java | 21 |
| gov/usgs/volcanoes/winston/server/http/cmd/fdsnws/constraint/TimeWindowConstraint.java | 38 |
public FdsnTimeWindowConstraint(final String startBefore, final String startAfter,
final String endBefore, final String endAfter) throws FdsnException {
super();
try {
this.startBefore = dateStringToDouble(startBefore, FAR_IN_FUTURE);
this.startAfter = dateStringToDouble(startAfter, FAR_IN_PAST);
this.endBefore = dateStringToDouble(endBefore, FAR_IN_FUTURE);
this.endAfter = dateStringToDouble(endAfter, FAR_IN_PAST);
} catch (final ParseException e) {
throw new FdsnException(400, "Can't parse time constraint: " + this);
}
}
public boolean matches(final Channel chan) {
final double start = chan.getMinTime();
if (start > startBefore || start < startAfter)
return false;
final double end = chan.getMaxTime();
if (end > endBefore || end < endAfter)
return false;
return true;
}
@Override
public String toString() {
return "FdsnTimeWindowConstraint: " + J2kSec.toDateString(startBefore) + " : "
+ J2kSec.toDateString(startAfter) + " : " + J2kSec.toDateString(endBefore) + " : "
+ J2kSec.toDateString(endAfter);
} | |
| File | Line |
|---|---|
| gov/usgs/volcanoes/winston/legacyServer/cmd/http/HttpRsamCommand.java | 155 |
| gov/usgs/volcanoes/winston/server/http/cmd/RsamCommand.java | 205 |
byte[] png;
final Plot plot = new Plot();
plot.setSize(width, height);
plot.setBackgroundColor(new Color(0.97f, 0.97f, 0.97f));
final MatrixRenderer mr = new MatrixRenderer(rsamData.getData(), false);
final double max = Math.min(plotMax, rsamData.max(1) + rsamData.max(1) * .1);
final double min = Math.max(plotMin, rsamData.min(1) - rsamData.max(1) * .1);
mr.setExtents(startTime + timeZoneOffset, endTime + timeZoneOffset, min, max);
mr.setLocation(70, 35, width - 140, height - 70);
mr.createDefaultAxis();
mr.setXAxisToTime(8, true, true);
final String tzText =
timeZone.getDisplayName(timeZone.inDaylightTime(J2kSec.asDate(endTime)), TimeZone.SHORT);
final String bottomText =
"(" + J2kSec.format(DISPLAY_DATE_FORMAT, startTime + timeZoneOffset) + " to " | |
| File | Line |
|---|---|
| gov/usgs/volcanoes/winston/db/Input.java | 315 |
| gov/usgs/volcanoes/winston/db/Input.java | 440 |
opt.t1 = Math.min(opt.t1, tb.getStartTimeJ2K());
opt.t2 = Math.max(opt.t2, tb.getEndTimeJ2K());
if (!writeLocks) {
setTimeSpan(code, opt.t1, opt.t2);
// setTimeSpan(code, opt.t1, opt.t2);
}
/// ----- now insert/update helicorder/rsam data
table = code + "$$H" + date;
final double fst = Math.floor(tb.getStartTimeJ2K());
final double cet = Math.ceil(tb.getEndTimeJ2K());
final double[][] heliList = new double[((int) Math.round(cet - fst)) + 1][];
int j = 0;
for (int i = (int) Math.round(fst); i <= (int) Math.round(cet); i++) {
double[] d = opt.getData(i);
if (d == null) { | |
| File | Line |
|---|---|
| gov/usgs/volcanoes/winston/legacyServer/cmd/http/HttpMenuCommand.java | 104 |
| gov/usgs/volcanoes/winston/server/http/cmd/MenuCommand.java | 179 |
writeSimpleHTML(output.toString());
}
private Comparator<String[]> getMenuComparator(final int sortCol, final char order) {
return new Comparator<String[]>() {
public int compare(final String[] e1, final String[] e2) {
// numeric columns
if (sortCol == 1 || sortCol == 6 || sortCol == 7) {
final double d1 = Double.parseDouble(e1[sortCol]);
final double d2 = Double.parseDouble(e2[sortCol]);
// Do this the hard way to avoid an int overflow.
// Yes, this bug was encountered in a running system.
final double d = d1 - d2;
if (d == 0)
return 0;
final int i = (d < 0 ? -1 : 1);
if (order == 'a')
return i;
else
return -i;
}
// textual columns
else {
if (order == 'a')
return e1[sortCol].compareTo(e2[sortCol]);
else
return e2[sortCol].compareTo(e1[sortCol]);
}
}
};
} | |
| File | Line |
|---|---|
| gov/usgs/volcanoes/winston/server/http/cmd/FdsnwsCommand.java | 92 |
| gov/usgs/volcanoes/winston/server/http/cmd/GapsCommand.java | 199 |
Template template = cfg.getTemplate("fdsnws/usage.ftl");
Writer sw = new StringWriter();
template.process(root, sw);
String html = sw.toString();
sw.close();
FullHttpResponse response = new DefaultFullHttpResponse(request.getProtocolVersion(),
HttpResponseStatus.OK, Unpooled.copiedBuffer(html, Charset.forName("UTF-8")));
response.headers().set(HttpHeaders.Names.CONTENT_LENGTH, html.length());
response.headers().set(HttpHeaders.Names.CONTENT_TYPE, "text/html; charset=UTF-8");
if (HttpHeaders.isKeepAlive(request)) {
response.headers().set(HttpHeaders.Names.CONNECTION, HttpHeaders.Values.KEEP_ALIVE);
}
ctx.writeAndFlush(response);
} catch (IOException e) {
LOGGER.error(e.getLocalizedMessage());
} catch (TemplateException e) {
LOGGER.error(e.getLocalizedMessage());
}
}
private void dispatch(String service, ChannelHandlerContext ctx, FullHttpRequest request) throws UtilException { | |
| File | Line |
|---|---|
| gov/usgs/volcanoes/winston/server/http/cmd/FdsnwsCommand.java | 92 |
| gov/usgs/volcanoes/winston/server/http/cmd/GapsCommand.java | 199 |
| gov/usgs/volcanoes/winston/server/http/cmd/StatusCommand.java | 128 |
Template template = cfg.getTemplate("fdsnws/usage.ftl");
Writer sw = new StringWriter();
template.process(root, sw);
String html = sw.toString();
sw.close();
FullHttpResponse response = new DefaultFullHttpResponse(request.getProtocolVersion(),
HttpResponseStatus.OK, Unpooled.copiedBuffer(html, Charset.forName("UTF-8")));
response.headers().set(HttpHeaders.Names.CONTENT_LENGTH, html.length());
response.headers().set(HttpHeaders.Names.CONTENT_TYPE, "text/html; charset=UTF-8");
if (HttpHeaders.isKeepAlive(request)) {
response.headers().set(HttpHeaders.Names.CONNECTION, HttpHeaders.Values.KEEP_ALIVE);
}
ctx.writeAndFlush(response);
} catch (IOException e) {
LOGGER.error(e.getLocalizedMessage());
} catch (TemplateException e) {
LOGGER.error(e.getLocalizedMessage());
}
} | |
| File | Line |
|---|---|
| gov/usgs/volcanoes/winston/client/GetScnlHeliRawHandler.java | 30 |
| gov/usgs/volcanoes/winston/client/GetScnlRsamRawHandler.java | 30 |
| gov/usgs/volcanoes/winston/client/GetWaveHandler.java | 29 |
this.isCompressed = isCompressed;
length = -Integer.MAX_VALUE;
buf = null;
}
@Override
public void handle(Object msg) throws IOException {
ByteBuf msgBuf = (ByteBuf) msg;
if (length < 0) {
String header = ClientUtils.readResponseHeader(msgBuf);
if (header == null) {
LOGGER.debug("Still waiting for full response line.");
return;
} else {
String[] parts = header.split(" ");
length = Integer.parseInt(parts[1]);
buf = new ByteArrayOutputStream(length);
LOGGER.debug("Response length: {}", length);
LOGGER.debug("" + buf);
}
}
msgBuf.readBytes(buf, msgBuf.readableBytes());
if (buf.size() == length) {
LOGGER.debug("Received all bytes.");
byte[] bytes = buf.toByteArray();
if (isCompressed) {
bytes = Zip.decompress(bytes);
} | |
| File | Line |
|---|---|
| gov/usgs/volcanoes/winston/legacyServer/cmd/GetMetadataCommand.java | 61 |
| gov/usgs/volcanoes/winston/server/wws/cmd/GetMetadataCommand.java | 84 |
sb.append(String.format("%s %d\n", cmd.getID(), insts.size()));
for (final Instrument inst : insts) {
sb.append("name=");
sb.append(escape(inst.getName()));
sb.append(",");
sb.append("description=");
sb.append(escape(inst.getDescription()));
sb.append(",");
sb.append("longitude=");
sb.append(inst.getLongitude());
sb.append(",");
sb.append("latitude=");
sb.append(inst.getLatitude());
sb.append(",");
sb.append("height=");
sb.append(inst.getHeight());
sb.append(",");
sb.append("timezone=");
sb.append(inst.getTimeZone());
sb.append(",");
appendMap(sb, inst.getMetadata());
sb.append("\n");
} | |
| File | Line |
|---|---|
| gov/usgs/volcanoes/winston/legacyServer/cmd/http/fdsn/constraint/FdsnGeographicSquareConstraint.java | 25 |
| gov/usgs/volcanoes/winston/server/http/cmd/fdsnws/constraint/GeographicSquareConstraint.java | 40 |
public FdsnGeographicSquareConstraint(final String minlatitude, final String maxlatitude,
final String minlongitude, final String maxlongitude) throws FdsnException {
this.minlatitude = StringUtils.stringToDouble(minlatitude, DEFAULT_MINLATITUDE);
this.maxlatitude = StringUtils.stringToDouble(maxlatitude, DEFAULT_MAXLATITUDE);
this.minlongitude = StringUtils.stringToDouble(minlongitude, DEFAULT_MINLONGITUDE);
this.maxlongitude = StringUtils.stringToDouble(maxlongitude, DEFAULT_MAXLONGITUDE);
}
public boolean matches(final Channel chan) {
final Instrument i = chan.getInstrument();
if (i.getLatitude() < minlatitude)
return false;
if (i.getLatitude() > maxlatitude)
return false;
if (i.getLongitude() < minlongitude)
return false;
if (i.getLongitude() > maxlongitude)
return false;
return true;
}
@Override
public String toString() {
return "FdsnGeographcSquareConstraint" + minlatitude + ", " + minlongitude + " -> "
+ maxlatitude + ", " + maxlongitude;
}
} | |
| File | Line |
|---|---|
| gov/usgs/volcanoes/winston/in/ImportSeed.java | 80 |
| gov/usgs/volcanoes/winston/in/ImportSeisan.java | 102 |
map.put(ch, list);
}
return map;
}
public static JSAPResult getArguments(final String[] args) {
JSAPResult config = null;
try {
final SimpleJSAP jsap = new SimpleJSAP(JSAP_PROGRAM_NAME, JSAP_EXPLANATION, JSAP_PARAMETERS);
config = jsap.parse(args);
if (jsap.messagePrinted() || config.getStringArray("file").length == 0) {
// The following error message is useful for catching the case
// when args are missing, but help isn't printed.
if (!config.getBoolean("help"))
System.err.println("Try using the --help flag.");
System.exit(1);
}
} catch (final Exception ex) {
ex.printStackTrace();
System.exit(1);
}
return config;
}
public static void main(final String[] args) {
final JSAPResult config = getArguments(args);
System.out.printf("RSAM parameters: delta=%d, duration=%d.\n", config.getInt("rsamDelta"),
config.getInt("rsamDuration"));
final ImportSeed is = new ImportSeed(config); | |
| File | Line |
|---|---|
| gov/usgs/volcanoes/winston/legacyServer/cmd/StatusCommand.java | 55 |
| gov/usgs/volcanoes/winston/server/wws/cmd/StatusCommand.java | 73 |
sb.append(String.format("Channel count: %d\n", sts.size()));
lines++;
final ArrayList<Double> ages = new ArrayList<Double>();
for (final Channel st : sts)
if (st.getMaxTime() < now && (ageThreshold == 0 || now - st.getMaxTime() < ageThreshold))
ages.add(now - st.getMaxTime());
if (ages.size() == 0)
ages.add(0d);
Double[] d = new Double[ages.size() - 1];
d = ages.toArray(d);
Arrays.sort(d);
sb.append(String.format("Median data age: %s\n", d[(d.length - 1) / 2]));
lines++; | |
| File | Line |
|---|---|
| gov/usgs/volcanoes/winston/legacyServer/cmd/http/AbstractHttpCommand.java | 145 |
| gov/usgs/volcanoes/winston/server/http/HttpBaseCommand.java | 125 |
final DateFormat dateFormat = new SimpleDateFormat(INPUT_DATE_FORMAT);
dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
Date bt;
try {
bt = dateFormat.parse(t1);
startTime = J2kSec.fromDate(bt);
} catch (final ParseException e) {
startTime = Double.NaN;
}
}
return timeOrMaxDays(startTime);
}
/*
* convert time back to UTC
*/
protected Double getStartTime(final String t1, final Double endTime, final long mult,
final TimeZone tz) {
final double startTime = getStartTime(t1, endTime, mult);
return timeOrMaxDays(startTime - (tz.getOffset(J2kSec.asEpoch(endTime))));
}
/**
* parse end time
*
* @param t2
* @return
*/
protected Double getEndTime(final String t2) {
Double endTime = Double.NaN;
if (t2 == null || t2.equalsIgnoreCase("now"))
endTime = J2kSec.now();
else {
final DateFormat dateFormat = new SimpleDateFormat(INPUT_DATE_FORMAT); | |
| File | Line |
|---|---|
| gov/usgs/volcanoes/winston/db/Input.java | 564 |
| gov/usgs/volcanoes/winston/db/InputEW.java | 556 |
checkTableCache.remove(table);
winston.getStatement().execute("DROP TABLE `" + table + "`");
winston.getStatement().execute("DROP TABLE `" + ss[0] + "$$H" + ss[1] + "`");
deleted = true;
LOGGER.info("Deleted table: {}", table);
} catch (final Exception e) {
LOGGER.error("Could not drop old table: {}. Are permissions set properly?", channel);
}
} else {
if (deleted) {
try {
final String nextLowestTable = table;
final ResultSet rs = winston.getStatement()
.executeQuery("SELECT MIN(st) FROM `" + nextLowestTable + "`");
rs.next();
final double t1 = rs.getDouble(1);
setTimeSpan(channel, t1, Double.NaN);
rs.close();
setTime = true;
} catch (final Exception e) {
LOGGER.error("Could not update span after dropping table: ", channel); | |
| File | Line |
|---|---|
| gov/usgs/volcanoes/winston/server/http/cmd/HeliCommand.java | 84 |
| gov/usgs/volcanoes/winston/server/http/cmd/RsamCommand.java | 234 |
png = settings.createPlot(heliData).getPNGBytes();
} catch (PlotException e) {
throw new UtilException(e.getLocalizedMessage());
}
FullHttpResponse response = new DefaultFullHttpResponse(request.getProtocolVersion(),
HttpResponseStatus.OK, Unpooled.copiedBuffer(png));
response.headers().set(HttpHeaders.Names.CONTENT_LENGTH, png.length);
response.headers().set(HttpHeaders.Names.CONTENT_TYPE, "image/png");
int httpRefreshInterval = configFile.getInt("wws.httpRefreshInterval", -1);
if (httpRefreshInterval > 0)
response.headers().set("Refresh", httpRefreshInterval + "; url=" + request.getUri());
if (HttpHeaders.isKeepAlive(request)) {
response.headers().set(HttpHeaders.Names.CONNECTION, HttpHeaders.Values.KEEP_ALIVE);
} | |
| File | Line |
|---|---|
| gov/usgs/volcanoes/winston/legacyServer/cmd/http/HttpGapsCommand.java | 261 |
| gov/usgs/volcanoes/winston/server/http/cmd/GapsCommand.java | 222 |
void writeComputer() {
final StringBuilder header = new StringBuilder();
final StringBuilder output = new StringBuilder();
output.append("# Gap Start\t\tGap End\t\t\tDuration\n");
// Write Computer Data Gaps
gapCount = 0;
totalGapLength = 0;
for (final double[] gap : gaps) {
gapLength = gap[1] - gap[0];
if (gapLength < minGapDuration) {
continue;
} else {
output.append(gap[0] + "\t" + gap[1] + "\t" + gapLength + "\n");
gapCount++;
totalGapLength = totalGapLength + gapLength;
}
}
// Write Computer Winston Gaps
header.append("# Start Time: " + startTimeS + " (" + startTime + ")\n# End Time: " + endTimeE
+ " (" + endTime + ")\n# Total Time: " + totalTime + "\n# Time Zone: " + timeZone
+ "\n# Station: " + code + "\n# Minumum Gap Duration: " + minGapDuration + "\n# GapCount: "
+ gapCount + "\n"); | |
| File | Line |
|---|---|
| gov/usgs/volcanoes/winston/legacyServer/cmd/GetMetadataCommand.java | 102 |
| gov/usgs/volcanoes/winston/server/wws/cmd/GetMetadataCommand.java | 123 |
sb.append(timeOrMaxDays(ch.getMaxTime()));
sb.append(",");
sb.append("alias=");
sb.append(escape(ch.getAlias()));
sb.append(",");
sb.append("unit=");
sb.append(escape(ch.getUnit()));
sb.append(",");
sb.append("linearA=");
sb.append(ch.getLinearA());
sb.append(",");
sb.append("linearB=");
sb.append(ch.getLinearB());
sb.append(",");
appendList(sb, "groups", ch.getGroups());
sb.append(",");
appendMap(sb, ch.getMetadata());
sb.append("\n");
} | |
| File | Line |
|---|---|
| gov/usgs/volcanoes/winston/legacyServer/cmd/http/fdsn/constraint/FdsnChannelConstraint.java | 77 |
| gov/usgs/volcanoes/winston/server/http/cmd/fdsnws/constraint/ChannelConstraint.java | 142 |
return true;
}
public boolean matches(final TraceBuf buf) {
if (buf == null)
return false;
final String net = buf.network();
if (net != null && !net.matches(network))
return false;
final String cha = buf.channel();
if (cha != null && !cha.matches(channel))
return false;
final String sta = buf.station();
if (sta != null && !sta.matches(station))
return false;
final String loc = buf.location();
if (loc != null && !loc.matches(location))
return false;
if (timeConstraint != null)
return timeConstraint.matches(buf);
return true;
}
public FdsnTimeSimpleConstraint getTimeConstraint() { | |
| File | Line |
|---|---|
| gov/usgs/volcanoes/winston/legacyServer/cmd/http/fdsn/station/FdsnStationQuery.java | 259 |
| gov/usgs/volcanoes/winston/server/http/cmd/fdsnws/FdsnwsService.java | 108 |
private Element createRootElement(final Document doc) {
final Element rootElement = doc.createElement("FDSNStationXML");
rootElement.setAttribute("schemaVersion", "1.0");
rootElement.setAttribute("xsi:schemaLocation",
"http://www.fdsn.org/xml/station/fdsn-station-1.0.xsd");
rootElement.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
rootElement.setAttribute("xmlns", "http://www.fdsn.org/xml/station/1");
doc.appendChild(rootElement);
final Element source = doc.createElement("source");
source.appendChild(doc.createTextNode("Winston"));
rootElement.appendChild(source);
final Element module = doc.createElement("module");
module.appendChild(doc.createTextNode("Winston " + Version.VERSION_STRING));
rootElement.appendChild(module);
final Element created = doc.createElement("Created");
created
.appendChild(doc.createTextNode(dateFormat.format(new Date(System.currentTimeMillis())))); | |
| File | Line |
|---|---|
| gov/usgs/volcanoes/winston/legacyServer/cmd/http/AbstractHttpCommand.java | 179 |
| gov/usgs/volcanoes/winston/server/http/HttpBaseCommand.java | 159 |
final DateFormat dateFormat = new SimpleDateFormat(INPUT_DATE_FORMAT);
dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
Date bt;
try {
bt = dateFormat.parse(t2);
endTime = J2kSec.fromDate(bt) - 1;
} catch (final ParseException e) {
endTime = Double.NaN;
}
}
return timeOrMaxDays(endTime);
}
/**
* convert back to UTC
*
*/
protected Double getEndTime(final String t2, final TimeZone tz) {
final Double endTime = getEndTime(t2);
return timeOrMaxDays(endTime - (tz.getOffset(J2kSec.asEpoch(endTime))));
}
/**
* Apply maxDays to time
*
* @param t
* time
* @return greater of t or now less maxDays
*/
protected double timeOrMaxDays(final double t) {
if (maxDays == 0)
return t;
else
return Math.max(t, J2kSec.now() - (maxDays * ONE_DAY)); | |
| File | Line |
|---|---|
| gov/usgs/volcanoes/winston/legacyServer/cmd/GetSCNCommand.java | 40 |
| gov/usgs/volcanoes/winston/legacyServer/cmd/GetSCNLCommand.java | 44 |
double t2 = Time.ewToj2k(cmd.getT2(false));
t2 = timeOrMaxDays(t2);
final double[] bounds = checkTimes(sid, t1, t2);
if (!allowTransaction(bounds)) {
netTools.writeString(cmd.getEarthwormErrorString(sid, getError(bounds)), channel);
return;
}
Wave wave = null;
try {
wave = data.getWave(sid, t1, t2, 0);
} catch (final UtilException e) {
}
if (wave != null)
totalBytes = writeWaveAsAscii(wave, sid, cmd.getID(), cmd.getS(), cmd.getC(), cmd.getN(), | |
| File | Line |
|---|---|
| gov/usgs/volcanoes/winston/tools/pannel/ExportSACPanel.java | 184 |
| gov/usgs/volcanoes/winston/tools/pannel/ImportWSPanel.java | 247 |
}
}
public class TimeRangeDocumentListener implements DocumentListener {
JTextField f;
public TimeRangeDocumentListener(final JTextField f) {
this.f = f;
}
public void insertUpdate(final DocumentEvent e) {
f.setBackground(validateTime() ? Color.white : RED);
}
public void removeUpdate(final DocumentEvent e) {
f.setBackground(validateTime() ? Color.white : RED);
}
public void changedUpdate(final DocumentEvent e) {}
private boolean validateTime() {
try {
Time.parseTimeRange(f.getText());
return true;
} catch (final ParseException ex) {
return false;
}
}
}
} | |
| File | Line |
|---|---|
| gov/usgs/volcanoes/winston/in/ImportSeed.java | 56 |
| gov/usgs/volcanoes/winston/in/ImportSeisan.java | 60 |
public ImportSeed(final JSAPResult config) {
this();
network = config.getString("network");
station = config.getString("station");
channel = config.getString("channel");
location = config.getString("location");
rsamDelta = config.getInt("rsamDelta");
rsamDuration = config.getInt("rsamDuration");
}
@Override
public Map<String, List<Wave>> readFile(final String fn) throws IOException {
final Map<String, List<Wave>> map = new HashMap<String, List<Wave>>();
final SeismicDataFile file = SeismicDataFile.getFile(fn, FileType.SEED); | |
| File | Line |
|---|---|
| gov/usgs/volcanoes/winston/legacyServer/cmd/GetSCNLRawCommand.java | 77 |
| gov/usgs/volcanoes/winston/legacyServer/cmd/GetSCNRawCommand.java | 68 |
channel);
int totalBytes = 0;
if (result != null) {
final String hdr = id + " " + (String) result[0] + "\n";
final int bytes = ((Integer) result[1]).intValue();
final List<?> items = (List<?>) result[2];
final ByteBuffer bb = ByteBuffer.allocate(bytes);
for (final Iterator<?> it = items.iterator(); it.hasNext();) {
bb.put((byte[]) it.next());
}
bb.flip(); | |
| File | Line |
|---|---|
| gov/usgs/volcanoes/winston/legacyServer/WWSClient.java | 282 |
| gov/usgs/volcanoes/winston/legacyServer/WWSClient.java | 353 |
Wave wave = winston.getWave(sta, comp, net, loc, st, et, false);
if (wave != null) {
wave = wave.subset(st, et);
final SeismicDataFile file = SeismicDataFile.getFile(fn, FileType.SAC);
String channel = sta + "_" + comp + "_" + net;
if (loc != null)
channel += "_" + loc;
file.putWave(channel, wave);
try {
file.write();
} catch (final IOException e) {
System.err.println("Couldn't write file: " + e.getLocalizedMessage());
e.printStackTrace();
}
} else {
System.out.println("Wave not found");
}
}
public static void outputSac(final String server, final int port, final Double st, | |
| File | Line |
|---|---|
| gov/usgs/volcanoes/winston/legacyServer/WWSClient.java | 273 |
| gov/usgs/volcanoes/winston/legacyServer/WWSClient.java | 378 |
final WWSClient winston = new WWSClient(s, p);
winston.connect();
final String[] chan = c.split("\\$");
final String sta = chan[0];
final String comp = chan[1];
final String net = chan[2];
final String loc = chan.length == 4 ? chan[3] : null;
Wave wave = winston.getWave(sta, comp, net, loc, st, et, false);
if (wave != null) {
wave = wave.subset(st, et); | |
| File | Line |
|---|---|
| gov/usgs/volcanoes/winston/legacyServer/cmd/http/fdsn/constraint/FdsnChannelConstraint.java | 53 |
| gov/usgs/volcanoes/winston/server/http/cmd/fdsnws/constraint/ChannelConstraint.java | 122 |
public boolean matches(final Channel chan) {
if (chan == null)
return false;
final String net = chan.network;
if (net != null && !net.matches(network))
return false;
final String cha = chan.channel;
if (cha != null && !cha.matches(channel))
return false;
final String sta = chan.station;
if (sta != null && !sta.matches(station))
return false;
final String loc = chan.location;
if (loc != null && !loc.matches(location))
return false; | |
| File | Line |
|---|---|
| gov/usgs/volcanoes/winston/db/Input.java | 271 |
| gov/usgs/volcanoes/winston/db/Input.java | 398 |
try {
final String code = tb.toWinstonString();
ChannelInputOptimizer opt = channelOptimizers.get(code);
if (opt == null) {
opt = new ChannelInputOptimizer(code);
channelOptimizers.put(code, opt);
final double[] span = data.getTimeSpan(code);
opt.t1 = span[0];
opt.t2 = span[1];
}
winston.useDatabase(code);
final double ts = tb.getStartTimeJ2K();
final String date = dateFormat.format(J2kSec.asDate(ts)); | |