awips2/edexOsgi/com.raytheon.edex.plugin.recco/src/com/raytheon/edex/plugin/recco/RECCODecoder.java
Matt Nash 82300ccdcf Moving 12.1.1 into ss_sync
Former-commit-id: 580e2938d7 [formerly 66be3bec40] [formerly c83e5ff474 [formerly 2a9569942c48542cf708b6c0b9189146fd954c11]]
Former-commit-id: c83e5ff474
Former-commit-id: 1faae42484
2012-01-19 11:53:12 -06:00

188 lines
6.2 KiB
Java

/**
* 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.recco;
import java.util.Calendar;
import com.raytheon.edex.esb.Headers;
import com.raytheon.edex.exception.DecoderException;
import com.raytheon.edex.plugin.AbstractDecoder;
import com.raytheon.edex.plugin.recco.common.RECCORecord;
import com.raytheon.edex.plugin.recco.decoder.ReccoParser;
import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.dataplugin.PluginException;
import com.raytheon.uf.common.pointdata.spatial.AircraftObsLocation;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.edex.decodertools.core.IDecoderConstants;
import com.raytheon.uf.edex.decodertools.core.IDecoderInput;
import com.raytheon.uf.edex.decodertools.time.TimeTools;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
/**
* Decoder strategy for text aircraft RECCO observation data. Most common usage
* is as follows. <code>
* SfcObsDecoder dec = new SfcObsDecoder();
* dec.setMessage();
* while(dec.hasNext())
* {
* PluginDataObject r = dec.decode();
* // do something with record.
* }
* </code>
*
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 20080103 384 jkorman Initial Coding.
* 11/25/08 #1684 chammack Camel Refactor
* </pre>
*
* @author jkorman
* @version 1.0
*/
public class RECCODecoder extends AbstractDecoder {
// Name of the plugin controlling this decoder.
private final String PLUGIN_NAME;
private boolean removeNILs = true;
/**
* @param pluginName
* Name that identifies this decoder.
* @throws DecoderException
*/
public RECCODecoder(String pluginName) {
PLUGIN_NAME = pluginName;
}
/**
* Determine the removeNILs status.
*
* @return Should NIL reports be removed.
*/
public boolean isRemoveNILs() {
return removeNILs;
}
/**
* Set the removeNILs status.
*
* @param removeNILs
* Should NIL reports be removed.
*/
public void setRemoveNILs(boolean removeNILs) {
this.removeNILs = removeNILs;
}
/**
* Get the next decoded data record.
*
* @return One record of decoded data.
* @throws DecoderException
* Thrown if no data is available.
*/
public PluginDataObject[] decode(IDecoderInput input, Headers headers) {
PluginDataObject[] reports = null;
String traceId = null;
try {
traceId = input.getProperty("traceId");
logger.debug(traceId + "- RECCODecoder.decode()");
RECCORecord report = populateRecord(
new ReccoParser(input.getReport(), headers),
input.getWmoHeader());
if (report != null) {
report.setTraceId(traceId);
report.setPluginName(PLUGIN_NAME);
try {
report.constructDataURI();
} catch (PluginException e) {
throw new DecoderException("Unable to construct dataURI", e);
}
reports = new PluginDataObject[] { report };
}
} catch (Exception e) {
logger.error(traceId + "- Error in RECCODecoder", e);
} finally {
if (reports == null) {
reports = new PluginDataObject[0];
}
}
return reports;
}
/**
* @param parser
* The reccon parser that contains the decoded data.
* @return The populated record.
*/
private RECCORecord populateRecord(ReccoParser parser, WMOHeader wmoHeader) {
RECCORecord record = null;
AircraftObsLocation location = null;
if (parser != null) {
// If there is no obstime, don't bother going further.
Calendar oTime = parser.getObservationTime();
if (oTime != null) {
record = new RECCORecord();
location = new AircraftObsLocation();
record.setTimeObs(oTime);
record.setRefHour(TimeTools.copyToNearestHour(oTime));
DataTime dataTime = new DataTime(oTime);
record.setDataTime(dataTime);
record.setWmoHeader(wmoHeader.getWmoHeader());
record.setReportData(parser.getReportData());
if ("222".equals(parser.getObsType())) {
record.setReportType(IDecoderConstants.RECCO_MANOBS);
} else if ("555".equals(parser.getObsType())) {
record.setReportType(IDecoderConstants.RECCO_INTEROBS);
} else if ("777".equals(parser.getObsType())) {
record.setReportType(IDecoderConstants.RECCO_MANOBS);
}
location.setLatitude(parser.getLatitude());
location.setLongitude(parser.getLongitude());
location.setLocation(parser.getLatitude(),
parser.getLongitude());
location.setFlightLevel(parser.getFlightLevel()
.getFlightLevel());
record.setLocation(location);
record.setTemp(parser.getTemperature());
record.setDwpt(parser.getDewpoint());
record.setWindDirection(parser.getWindDirection());
record.setWindSpeed(parser.getWindSpeed());
}
}
return record;
}
}