Issue #2655 fix textlightning distribution regex

Change-Id: Ia8900e8baa05d831c984fbf355034ca189364d99

Former-commit-id: 97152c59c6 [formerly 2cd9b9ef13] [formerly cf1dcae597] [formerly cf1dcae597 [formerly a6c562d3f0]] [formerly 97152c59c6 [formerly 2cd9b9ef13] [formerly cf1dcae597] [formerly cf1dcae597 [formerly a6c562d3f0]] [formerly 16d6a29bb9 [formerly cf1dcae597 [formerly a6c562d3f0] [formerly 16d6a29bb9 [formerly 48825cb03da5bde6f8b1252fe2e366119535f8f3]]]]]
Former-commit-id: 16d6a29bb9
Former-commit-id: 21d6500465 [formerly 31fed91d11] [formerly 929d683210] [formerly 9f0b218a58e49d4b5e1b3d5fc506912529507a00 [formerly a4537d42ffe3e0752006e8f23e4ef3cfdcdc8f60] [formerly 929d683210 [formerly 3b918cee5f]]]
Former-commit-id: 6b304adca08e202c8c617842cd82a8720d8b63ce [formerly 4f64c1a64bd338816bfb84b1d7486414f2c46b6f] [formerly 7f3016b679 [formerly 72330e9b62]]
Former-commit-id: 7f3016b679
Former-commit-id: 5a8ff8dbac
This commit is contained in:
Nate Jensen 2014-02-12 15:03:45 -06:00
parent 21f0907d01
commit cfe3a4bbec
4 changed files with 172 additions and 157 deletions

View file

@ -2,13 +2,16 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Textlightning Plug-in
Bundle-SymbolicName: com.raytheon.edex.plugin.textlightning
Bundle-Version: 1.12.1174.qualifier
Bundle-Version: 1.14.0.qualifier
Eclipse-RegisterBuddy: com.raytheon.uf.common.serialization, com.raytheon.edex.common
Bundle-Vendor: RAYTHEON
Require-Bundle: com.raytheon.edex.common,
com.raytheon.uf.edex.decodertools;bundle-version="1.0.0",
javax.persistence
Require-Bundle: com.raytheon.uf.edex.decodertools,
com.raytheon.uf.common.dataplugin
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: com.raytheon.uf.common.dataplugin.binlightning,
Import-Package: com.raytheon.edex.exception,
com.raytheon.edex.plugin,
com.raytheon.uf.common.dataplugin.binlightning,
com.raytheon.uf.common.dataplugin.binlightning.impl,
org.apache.commons.logging
com.raytheon.uf.common.status,
com.raytheon.uf.common.time,
com.raytheon.uf.edex.core

View file

@ -22,23 +22,21 @@ package com.raytheon.edex.plugin.textlightning;
import java.util.ArrayList;
import java.util.Calendar;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.raytheon.edex.exception.DecoderException;
import com.raytheon.edex.plugin.AbstractDecoder;
import com.raytheon.edex.plugin.IBinaryDecoder;
import com.raytheon.edex.plugin.textlightning.impl.TextLightningParser;
import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.dataplugin.PluginException;
import com.raytheon.uf.common.dataplugin.binlightning.BinLightningRecord;
import com.raytheon.uf.common.dataplugin.binlightning.impl.LightningStrikePoint;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.common.time.TimeRange;
import com.raytheon.uf.edex.decodertools.time.TimeTools;
/**
* TODO Add Description
* Decoder for text lightning data
*
* <pre>
*
@ -48,6 +46,7 @@ import com.raytheon.uf.edex.decodertools.time.TimeTools;
* ------------ ---------- ----------- --------------------------
* Mar 25, 2010 jsanchez Initial creation
* Aug 30, 2013 2298 rjpeter Make getPluginName abstract
* Feb 12, 2014 2655 njensen Set source
*
* </pre>
*
@ -57,7 +56,9 @@ import com.raytheon.uf.edex.decodertools.time.TimeTools;
public class TextLightningDecoder extends AbstractDecoder implements
IBinaryDecoder {
private final Log logger = LogFactory.getLog(getClass());
private static final IUFStatusHandler logger = UFStatus
.getHandler(TextLightningDecoder.class);
private String traceId = null;
@ -66,6 +67,7 @@ public class TextLightningDecoder extends AbstractDecoder implements
* will return false, decode() will return a null.
*/
public TextLightningDecoder() {
}
/**
@ -116,11 +118,10 @@ public class TextLightningDecoder extends AbstractDecoder implements
if (report != null) {
report.setTraceId(traceId);
try {
report.constructDataURI();
} catch (PluginException e) {
throw new DecoderException("Error constructing datauri", e);
}
// TODO anyone have any idea what the source should actually be
// named?
report.setSource("text");
}
return new PluginDataObject[] { report };

View file

@ -28,15 +28,15 @@ import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.raytheon.uf.common.dataplugin.binlightning.impl.LightningStrikePoint;
import com.raytheon.uf.common.dataplugin.binlightning.impl.LtgMsgType;
import com.raytheon.uf.common.dataplugin.binlightning.impl.LtgStrikeType;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
/**
*
* Parser for text lightning data
*
* <pre>
*
@ -45,6 +45,7 @@ import com.raytheon.uf.common.dataplugin.binlightning.impl.LtgStrikeType;
* ------------ ---------- ----------- --------------------------
* Dec 15, 2009 3983 jsanchez Initial creation
* Feb 27, 2013 DCS 152 jgerth/elau Support for WWLLN
* Feb 12, 2014 2655 njensen Use status handler for logging
*
* </pre>
*
@ -52,77 +53,85 @@ import com.raytheon.uf.common.dataplugin.binlightning.impl.LtgStrikeType;
* @version 1.0
*/
public class TextLightningParser {
/** The logger */
private Log logger = LogFactory.getLog(getClass());
private static final IUFStatusHandler logger = UFStatus
.getHandler(TextLightningParser.class);
int currentReport = -1;
private List<LightningStrikePoint> reports;
// 03/23/2010 13:35:01 72.00 -157.00 -14 1
// 03/23/2010 13:35:01 72.00 -157.00 -14 1
private static final String LIGHTNING_PTRN_A = "(\\d{2,2}/\\d{2,2}/\\d{4,4}) (\\d{2,2}:\\d{2,2}:\\d{2,2})\\s{1,}(\\d{1,2}.\\d{2,2})\\s{1,}( |-\\d{1,3}.\\d{2,2})\\s{1,}( |-\\d{1,2})\\s{1,}(\\d{1,2})";
private static final Pattern LTG_PTRN_A = Pattern.compile(LIGHTNING_PTRN_A);
// 10:03:24:13:35:00.68 72.000 157.000 -14.2 1
// 10:03:24:13:35:00.68 72.000 157.000 -14.2 1
private static final String LIGHTNING_PTRN_B = "(\\d{2,2}:\\d{2,2}:\\d{2,2}:\\d{2,2}:\\d{2,2}:\\d{2,2}\\.\\d{2,2})\\s{1,}(\\d{1,2}\\.\\d{2,})\\s{1,}(-?\\d{1,3}\\.\\d{2,})\\s{1,}(-?\\d{1,3}\\.\\d{1,})\\s{1,}(\\d{1,2}).*";
private static final Pattern LTG_PTRN_B = Pattern.compile(LIGHTNING_PTRN_B);
// 2012-03-14T18:58:00,-5.5021,-45.9669,0.0,1
private static final String LIGHTNING_PTRN_C = "(\\d{4,4}-\\d{2,2}-\\d{2,2})T(\\d{2,2}:\\d{2,2}:\\d{2,2}),(-?\\d{1,2}.\\d{1,4}),(-?\\d{1,3}.\\d{1,4}),(0.0),(1)";
private static final Pattern LTG_PTRN_C = Pattern.compile(LIGHTNING_PTRN_C);
/**
* default constructor.
*/
public TextLightningParser(){
//empty
public TextLightningParser() {
// empty
}
public TextLightningParser(byte [] message){
public TextLightningParser(byte[] message) {
setData(message);
}
/**
* Set the message data and decode all message reports.
* @param message Raw message data.
*
* @param message
* Raw message data.
*/
private void setData(byte [] message) {
private void setData(byte[] message) {
currentReport = -1;
reports = findReports(message);
if((reports != null)&&(reports.size() > 0)) {
if ((reports != null) && (reports.size() > 0)) {
currentReport = 0;
}
}
/**
* Does this parser contain any more reports.
*
* @return Does this parser contain any more reports.
*/
public boolean hasNext() {
boolean next = (reports != null);
if(next) {
next = ((currentReport >= 0)&&(currentReport < reports.size()));
if (next) {
next = ((currentReport >= 0) && (currentReport < reports.size()));
}
if(!next) {
if (!next) {
reports = null;
currentReport = -1;
}
return next;
}
/**
* Get the next available report. Returns a null reference if no
* more reports are available.
* Get the next available report. Returns a null reference if no more
* reports are available.
*
* @return The next available report.
*/
public LightningStrikePoint next() {
LightningStrikePoint report = null;
if(currentReport < 0) {
if (currentReport < 0) {
return report;
}
if(currentReport >= reports.size()) {
if (currentReport >= reports.size()) {
reports = null;
currentReport = -1;
} else {
@ -131,42 +140,41 @@ public class TextLightningParser {
return report;
}
/**
*
*
* @param start
* @return
*/
private List<LightningStrikePoint> findReports(byte [] message) {
List<LightningStrikePoint> reports = new ArrayList<LightningStrikePoint>();
List<String> lines = separateLines(message);
if(lines != null) {
private List<LightningStrikePoint> findReports(byte[] message) {
List<LightningStrikePoint> reports = new ArrayList<LightningStrikePoint>();
List<String> lines = separateLines(message);
if (lines != null) {
LightningStrikePoint strike;
for(String line : lines){
try{
for (String line : lines) {
try {
Matcher m = LTG_PTRN_A.matcher(line);
if(m.matches()){
String[] date = m.group(1).split("/");
String[] time = m.group(2).split(":");
String month = date[0];
String day = date[1];
String year = date[2];
String hour = time[0];
String min = time[1];
String sec = time[2];
if (m.matches()) {
String[] date = m.group(1).split("/");
String[] time = m.group(2).split(":");
String month = date[0];
String day = date[1];
String year = date[2];
String hour = time[0];
String min = time[1];
String sec = time[2];
String latitude = m.group(3);
String longitude= m.group(4);
String longitude = m.group(4);
String strength = m.group(5);
String count = m.group(6);
String count = m.group(6);
strike = new LightningStrikePoint(
Double.parseDouble(latitude),
Double.parseDouble(longitude));
Double.parseDouble(longitude));
strike.setStrikeStrength(Double.parseDouble(strength));
strike.setStrikeCount(Integer.parseInt(count));
strike.setMonth(Integer.parseInt(month));
strike.setDay(Integer.parseInt(day));
strike.setYear(Integer.parseInt(year));
strike.setYear(Integer.parseInt(year));
strike.setHour(Integer.parseInt(hour));
strike.setMinute(Integer.parseInt(min));
strike.setSecond(Integer.parseInt(sec));
@ -174,92 +182,94 @@ public class TextLightningParser {
strike.setMsgType(LtgMsgType.STRIKE_MSG_FL);
strike.setType(LtgStrikeType.STRIKE_CG);
strike.setLightSource("UNKN");
reports.add(strike);
reports.add(strike);
} else {
m = LTG_PTRN_B.matcher(line);
if(m.matches()){
if (m.matches()) {
String[] datetime = m.group(1).split(":");
String year = datetime[0];
String month = datetime[1];
String day = datetime[2];
String hour = datetime[3];
String min = datetime[4];
String sec = datetime[5].substring(0,2);
String msec = datetime[5].substring(3,5);
String year = datetime[0];
String month = datetime[1];
String day = datetime[2];
String hour = datetime[3];
String min = datetime[4];
String sec = datetime[5].substring(0, 2);
String msec = datetime[5].substring(3, 5);
String latitude = m.group(2);
String longitude= m.group(3);
String longitude = m.group(3);
String strength = m.group(4);
String count = m.group(5);
String count = m.group(5);
double lon = Double.parseDouble(longitude);
if(lon > 0) {
if (lon > 0) {
lon = -lon;
}
strike = new LightningStrikePoint(
Double.parseDouble(latitude),lon);
strike.setStrikeStrength(Double.parseDouble(strength));
Double.parseDouble(latitude), lon);
strike.setStrikeStrength(Double
.parseDouble(strength));
strike.setStrikeCount(Integer.parseInt(count));
strike.setMonth(Integer.parseInt(month));
strike.setDay(Integer.parseInt(day));
strike.setYear(Integer.parseInt(year) + 2000);
strike.setYear(Integer.parseInt(year) + 2000);
strike.setHour(Integer.parseInt(hour));
strike.setMinute(Integer.parseInt(min));
strike.setSecond(Integer.parseInt(sec));
strike.setMillis(Integer.parseInt(msec)*10);
strike.setMillis(Integer.parseInt(msec) * 10);
strike.setMsgType(LtgMsgType.STRIKE_MSG_FL);
strike.setType(LtgStrikeType.STRIKE_CG);
strike.setLightSource("UNKN");
reports.add(strike);
reports.add(strike);
} else {
m = LTG_PTRN_C.matcher(line);
if (m.matches()) {
String[] datec = m.group(1).split("-");
String[] timec = m.group(2).split(":");
String year = datec[0];
String month = datec[1];
String day = datec[2];
String hour = timec[0];
String min = timec[1];
String sec = timec[2];
String msec = "0";
String sls = "WWLLN";
m = LTG_PTRN_C.matcher(line);
if (m.matches()) {
String[] datec = m.group(1).split("-");
String[] timec = m.group(2).split(":");
String year = datec[0];
String month = datec[1];
String day = datec[2];
String hour = timec[0];
String min = timec[1];
String sec = timec[2];
String msec = "0";
String sls = "WWLLN";
String latitude = m.group(3);
String longitude= m.group(4);
String strength = m.group(5);
String count = m.group(6);
String latitude = m.group(3);
String longitude = m.group(4);
String strength = m.group(5);
String count = m.group(6);
strike = new LightningStrikePoint(
Double.parseDouble(latitude),Double.parseDouble(longitude));
strike.setStrikeStrength(Double.parseDouble(strength));
strike.setStrikeCount(Integer.parseInt(count));
strike.setMonth(Integer.parseInt(month));
strike.setDay(Integer.parseInt(day));
strike.setYear(Integer.parseInt(year));
strike.setHour(Integer.parseInt(hour));
strike.setMinute(Integer.parseInt(min));
strike.setSecond(Integer.parseInt(sec));
strike.setMillis(Integer.parseInt(msec)*10);
strike.setMsgType(LtgMsgType.STRIKE_MSG_FL);
strike.setType(LtgStrikeType.STRIKE_CG);
strike.setLightSource(sls);
reports.add(strike);
} else {
logger.error("Cannot match lightning input " + line);
}
strike = new LightningStrikePoint(
Double.parseDouble(latitude),
Double.parseDouble(longitude));
strike.setStrikeStrength(Double
.parseDouble(strength));
strike.setStrikeCount(Integer.parseInt(count));
strike.setMonth(Integer.parseInt(month));
strike.setDay(Integer.parseInt(day));
strike.setYear(Integer.parseInt(year));
strike.setHour(Integer.parseInt(hour));
strike.setMinute(Integer.parseInt(min));
strike.setSecond(Integer.parseInt(sec));
strike.setMillis(Integer.parseInt(msec) * 10);
strike.setMsgType(LtgMsgType.STRIKE_MSG_FL);
strike.setType(LtgStrikeType.STRIKE_CG);
strike.setLightSource(sls);
reports.add(strike);
} else {
logger.error("Cannot match lightning input "
+ line);
}
}
}
} catch (NumberFormatException e){
logger.debug("Invalid numerical value", e);
} catch (NumberFormatException e) {
logger.handle(Priority.DEBUG, "Invalid numerical value", e);
}
}
}
return reports;
}
/**
*
* @param message
@ -281,7 +291,7 @@ public class TextLightningParser {
}
}
} catch (Exception e) {
logger.error("Error reading from reader",e);
logger.error("Error reading from reader", e);
} finally {
if (reader != null) {
try {
@ -294,39 +304,40 @@ public class TextLightningParser {
}
return reportLines;
}
public static final void main(String [] args) {
// 10: 03: 24: 13: 35: 00.68 72.000 157.000 -14.2 1
// String LIGHTNING_PTRN_B = "(\\d{2,2}:\\d{2,2}:\\d{2,2}:\\d{2,2}:\\d{2,2}:\\d{2,2}\\.\\d{2,2})\\s{1,}(\\d{1,2}.\\d{2,})\\s{1,}( |-\\d{1,3}.\\d{2,})\\s{1,}( |-\\d{1,2}\\.\\d{1,})\\s{1,}(\\d{1,2})";
// String LIGHTNING_PTRN_B = "(\\d{2,2}:\\d{2,2}:\\d{2,2}:\\d{2,2}:\\d{2,2}:\\d{2,2}\\.\\d{2,2})\\s{1,}(\\d{1,2}\\.\\d{2,})\\s{1,}(-?\\d{1,3}\\.\\d{2,})\\s{1,}(-?\\d{1,3}\\.\\d{1,})\\s{1,}(\\d{1,2}).*";
//
// Pattern LTG_PTRN_B = Pattern.compile(LIGHTNING_PTRN_B);
//
// Matcher m = LTG_PTRN_B.matcher("10:03:24:13:35:00.68 72.000 157.000 -14.2 1");
// if(m.matches()) {
// for(int i = 0;i <= m.groupCount();i++) {
// System.out.println(m.group(i));
// }
// }
public static final void main(String[] args) {
// 10: 03: 24: 13: 35: 00.68 72.000 157.000 -14.2 1
// String LIGHTNING_PTRN_B =
// "(\\d{2,2}:\\d{2,2}:\\d{2,2}:\\d{2,2}:\\d{2,2}:\\d{2,2}\\.\\d{2,2})\\s{1,}(\\d{1,2}.\\d{2,})\\s{1,}( |-\\d{1,3}.\\d{2,})\\s{1,}( |-\\d{1,2}\\.\\d{1,})\\s{1,}(\\d{1,2})";
// String LIGHTNING_PTRN_B =
// "(\\d{2,2}:\\d{2,2}:\\d{2,2}:\\d{2,2}:\\d{2,2}:\\d{2,2}\\.\\d{2,2})\\s{1,}(\\d{1,2}\\.\\d{2,})\\s{1,}(-?\\d{1,3}\\.\\d{2,})\\s{1,}(-?\\d{1,3}\\.\\d{1,})\\s{1,}(\\d{1,2}).*";
//
// Pattern LTG_PTRN_B = Pattern.compile(LIGHTNING_PTRN_B);
//
// Matcher m =
// LTG_PTRN_B.matcher("10:03:24:13:35:00.68 72.000 157.000 -14.2 1");
// if(m.matches()) {
// for(int i = 0;i <= m.groupCount();i++) {
// System.out.println(m.group(i));
// }
// }
TextLightningParser parser = null;
parser = new TextLightningParser("03/23/2010 13:35:01 72.00 -157.00 -14 1\n03/23/2010 13:36:01 72.00 -157.00 -14 1".getBytes());
while(parser.hasNext()) {
parser = new TextLightningParser(
"03/23/2010 13:35:01 72.00 -157.00 -14 1\n03/23/2010 13:36:01 72.00 -157.00 -14 1"
.getBytes());
while (parser.hasNext()) {
System.out.println(parser.next());
}
parser = new TextLightningParser("10:03:24:13:35:00.68 72.000 157.000 -14.2 1\n10:03:24:13:36:00.68 72.000 157.000 -14.2 1".getBytes());
while(parser.hasNext()) {
parser = new TextLightningParser(
"10:03:24:13:35:00.68 72.000 157.000 -14.2 1\n10:03:24:13:36:00.68 72.000 157.000 -14.2 1"
.getBytes());
while (parser.hasNext()) {
System.out.println(parser.next());
}
}
}

View file

@ -19,6 +19,6 @@
further_licensing_information.
-->
<requestPatterns xmlns:ns2="group">
<regex>FAA_*</regex>
<regex>WWLLN_*</regex>
<regex>FAA_</regex>
<regex>WWLLN_</regex>
</requestPatterns>