Merge branch 'development' of ssh://lightning.omaha.us.ray.com:29418/AWIPS2_baseline into development

Former-commit-id: da0afec2c1 [formerly abc2a7fb62 [formerly 165e2e8bfb9527ba1d5c274e351d63196eafa0e9]]
Former-commit-id: abc2a7fb62
Former-commit-id: 9ae530cd1b
This commit is contained in:
Steve Harris 2012-09-13 15:21:40 -05:00
commit 2a42503413
42 changed files with 1416 additions and 190 deletions

View file

@ -43,8 +43,9 @@ xmlns:xlink="http://www.w3.org/1999/xlink" style="stroke: rgb(255,255,255);">
]]>
</style>
<symbol overflow="visible" id="plotData" class="info">
<text id="turbInensity" plotMode="table" class="weather" plotLookupTable="airep_turb_intens_trans.txt" plotParam="FLT_HZD" x="0" y="0">0</text>
<text id="fltLvlText" plotMode="text" plotParam="FLT_LVL" plotFormat="%3.0f" plotUnit="hft" style="text-anchor: end;" x="-15px" y="0px">75</text>
<text id="airepturbIntensity" plotMode="table" class="weather" plotLookupTable="turb_intens_trans.txt" plotParam="TBI" x="0" y="0">0</text>
<text id="airepturbFreq" plotMode="table" class="weather" plotLookupTable="turb_freq_trans.txt" plotParam="TBF" style="text-anchor: end" x="0" y="-10">0</text>
<text id="airepfltLvlText" plotMode="text" plotParam="FLT_LVL" plotFormat="%3.0f" plotUnit="hft" style="text-anchor: end;" x="-15px" y="0px">75</text>
</symbol>
</defs>

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

View file

@ -88,7 +88,8 @@ fi
while [ $exitVal -ne 0 ]
do
curTime=`date +%Y%m%d_%H%M%S`
LOGFILE=${LOGDIR}/alertviz_${curTime}.log
LOGFILE=${LOGDIR}/alertviz_${curTime}_console.log
export LOGFILE_ALERTVIZ=${LOGDIR}/alertviz_${curTime}_admin.log
#first check if we can write to the directory
if [ -w ${LOGDIR} ]; then

View file

@ -116,7 +116,8 @@ fi
export pid=$$
curTime=`date +%Y%m%d_%H%M%S`
LOGFILE=${LOGDIR}/cave_${curTime}_pid_${pid}.log
LOGFILE=${LOGDIR}/cave_${curTime}_pid_${pid}_console.log
export LOGFILE_CAVE=${LOGDIR}/cave_${curTime}_pid_${pid}_alertviz.log
redirect="TRUE"
for flag in $@; do

View file

@ -632,7 +632,7 @@ public class AlertVisualization implements ITimerAction, IAudioAction,
|| statMsg.getSourceKey().equals("GDN_ADMIN");
if (isGdnAdminMessage) {
Container.logInternal(statMsg);
// Container.logInternal(statMsg);
if ((statMsg.getDetails() != null)
&& (statMsg.getDetails().contains("Error")
|| statMsg.getDetails().contains("Exception")

View file

@ -29,3 +29,5 @@ Import-Package: com.raytheon.uf.common.python,
com.raytheon.uf.viz.python.swt,
com.raytheon.uf.viz.python.swt.widgets
Bundle-ActivationPolicy: lazy
Eclipse-BuddyPolicy: ext, registered, global
Eclipse-RegisterBuddy: org.apache.log4j

View file

@ -6,4 +6,5 @@ bin.includes = META-INF/,\
lib/derbyrun.jar,\
lib/derby.jar,\
statusMessage.xsd,\
config.xml
config.xml,\
log4j-alertviz.xml

View file

@ -0,0 +1,79 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<!-- general application log -->
<appender name="console" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%-5p %d [%t] %c{1}: %m%n"/>
</layout>
<filter class="org.apache.log4j.varia.LevelRangeFilter">
<param name="levelMin" value="DEBUG" />
<param name="levelMax" value="INFO" />
</filter>
</appender>
<appender name="errConsole" class="org.apache.log4j.ConsoleAppender">
<param name="Target" value="System.err"/>
<param name="Threshold" value="WARN" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%-5p %d [%t] %c{1}: %m%n"/>
</layout>
</appender>
<appender name="AlertVizAdminLogAppender" class="com.raytheon.uf.viz.alertviz.EnvConfigurableRollingFileAppender">
<param name="envLogVar" value="LOGFILE_ALERTVIZ" />
<param name="maxFileSize" value="2GB"/>
<param name="maxBackupIndex" value="5"/>
<param name="Append" value="true"/>
<layout class="org.apache.log4j.EnhancedPatternLayout">
<param name="ConversionPattern" value="%-5p %d [%t] : %m%n"/>
</layout>
</appender>
<logger name="AlertVizAdminLogger" additivity="false">
<level value="ALL"/>
<appender-ref ref="AlertVizAdminLogAppender"/>
</logger>
<logger name="com.raytheon">
<level value="INFO"/>
</logger>
<logger name="com.tc">
<level value="WARN"/>
</logger>
<logger name="mx4j">
<level value="ERROR"/>
</logger>
<logger name="org.apache">
<level value="INFO"/>
</logger>
<logger name="org.apache.activemq.spring">
<level value="WARN"/>
</logger>
<logger name="org.apache.commons.beanutils">
<level value="WARN"/>
</logger>
<logger name="org.apache.qpid">
<level value="WARN"/>
</logger>
<logger name="org.geotools">
<level value="WARN"/>
</logger>
<logger name="org.apache.xbean.spring">
<level value="WARN"/>
</logger>
<logger name="org.springframework">
<level value="ERROR"/>
</logger>
<logger name="uk.ltd.getahead">
<level value="WARN"/>
</logger>
<!-- default logging -->
<root>
<level value="INFO"/>
<appender-ref ref="console"/>
<appender-ref ref="errConsole"/>
</root>
</log4j:configuration>

View file

@ -230,7 +230,7 @@ public class AlertvizJob extends Job {
e);
StatusMessage sm = new StatusMessage();
sm.setPriority(Priority.CRITICAL);
sm.setMachine("LOCAL");
sm.setMachineToCurrent();
sm.setCategory("GDN_ADMIN");
sm.setSourceKey("GDN_ADMIN");
sm.setMessage(e.getMessage());

View file

@ -36,7 +36,7 @@ import com.raytheon.uf.viz.alertviz.config.Category;
import com.raytheon.uf.viz.alertviz.config.Configuration;
import com.raytheon.uf.viz.alertviz.config.ForcedConfiguration;
import com.raytheon.uf.viz.alertviz.config.Source;
import com.raytheon.uf.viz.alertviz.internal.ArchiveLogJob;
import com.raytheon.uf.viz.alertviz.internal.PurgeLogJob;
import com.raytheon.uf.viz.alertviz.internal.LogMessageDAO;
import com.raytheon.uf.viz.core.VizApp;
@ -63,8 +63,8 @@ public class Container implements IConfigurationChangedListener {
public static final String SOURCE_MISSING = "Source was not found";
private transient static final org.apache.log4j.Logger internalLogger = Logger
.getLogger("AlertVizLogger");
private transient static final org.apache.log4j.Logger adminLogger = Logger
.getLogger("AlertVizAdminLogger");
private Configuration configuration;
@ -96,7 +96,7 @@ public class Container implements IConfigurationChangedListener {
.getForcedConfiguration();
ConfigurationManager.getInstance().addListener(this);
this.callbacks = callbacks;
ArchiveLogJob archive = new ArchiveLogJob();
PurgeLogJob archive = new PurgeLogJob();
archive.schedule();
}
@ -171,7 +171,7 @@ public class Container implements IConfigurationChangedListener {
// for now, just send to the regular log
StatusMessage sm = new StatusMessage();
sm.setPriority(priority);
sm.setMachine("LOCAL");
sm.setMachineToCurrent();
sm.setSourceKey("GDN_ADMIN");
sm.setCategory("GDN)ADMIN");
sm.setMessage(msg);
@ -319,24 +319,25 @@ public class Container implements IConfigurationChangedListener {
String cat = message.getCategory();
String source = message.getSourceKey();
if ((cat != null && cat.equalsIgnoreCase("GDN_ADMIN"))
|| (source != null && source.equalsIgnoreCase("GDN_ADMIN"))) {
boolean isInternal = (cat != null && cat.equalsIgnoreCase("GDN_ADMIN"))
|| (source != null && source.equalsIgnoreCase("GDN_ADMIN"));
if (isInternal) {
switch (message.getPriority()) {
case CRITICAL:
internalLogger.fatal(message);
adminLogger.fatal(message);
break;
case SIGNIFICANT:
internalLogger.error(message);
adminLogger.error(message);
break;
case PROBLEM:
internalLogger.warn(message);
adminLogger.warn(message);
break;
case EVENTA: // fall through
case EVENTB:
internalLogger.info(message);
adminLogger.info(message);
break;
case VERBOSE:
internalLogger.debug(message);
adminLogger.debug(message);
break;
}
}

View file

@ -0,0 +1,80 @@
/**
* 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.viz.alertviz;
import org.apache.log4j.RollingFileAppender;
import org.apache.log4j.helpers.LogLog;
/**
* RollingFileAppender retrieves the value set for property EnvLogVar from the
* system environment to define the log file.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Sep 10, 2012 bgonzale Initial creation
*
* </pre>
*
* @author bgonzale
* @version 1.0
*/
public class EnvConfigurableRollingFileAppender extends RollingFileAppender {
private String envLogVar;
/**
* @param envLogVar
* the envLogVar to set
*/
public void setEnvLogVar(String envLogVar) {
this.envLogVar = envLogVar;
setFileFromEnv();
}
/**
* @return the envLogVar
*/
public String getEnvLogVar() {
return envLogVar;
}
private void setFileFromEnv() {
if (envLogVar == null || envLogVar.isEmpty()) {
LogLog.error("Appender [" + name
+ "] requires EnvLogVar to be set.");
} else {
String file = System.getenv(envLogVar);
if (file == null || file.isEmpty()) {
LogLog.error("Appender [" + name
+ "] needs environment variable, " + envLogVar
+ ", to be set.");
} else {
setFile(file);
}
}
}
}

View file

@ -19,6 +19,7 @@
**/
package com.raytheon.uf.viz.alertviz;
import org.apache.log4j.Logger;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.ErrorDialog;
@ -50,6 +51,9 @@ import com.raytheon.uf.viz.core.status.VizStatusInternal;
public class SystemStatusHandler extends AbstractStatusHandler {
private transient static final org.apache.log4j.Logger logger = Logger
.getLogger("CaveLogger");
private static final String WORKSTATION = "WORKSTATION";
/*
@ -66,14 +70,13 @@ public class SystemStatusHandler extends AbstractStatusHandler {
if (status instanceof VizStatusInternal) {
VizStatusInternal vs = (VizStatusInternal) status;
sm = new StatusMessage(vs.getSource(), vs.getCategory(),
vs.getPriority(), vs.getPluginName(), vs.getMessage(),
vs.getException());
sm = vs.toStatusMessage();
} else {
sm = from(status);
}
try {
logStatus(sm);
AlertVizClient.sendMessage(sm);
} catch (final AlertvizException e) {
// not a good situation, since we can't communicate with the log
@ -111,7 +114,7 @@ public class SystemStatusHandler extends AbstractStatusHandler {
StatusMessage sm = new StatusMessage();
sm.setCategory(WORKSTATION);
sm.setMachine("LOCAL");
sm.setMachineToCurrent();
switch (status.getSeverity()) {
case Status.ERROR:
sm.setPriority(Priority.SIGNIFICANT);
@ -184,4 +187,26 @@ public class SystemStatusHandler extends AbstractStatusHandler {
int count) throws AlertvizException {
return LogMessageDAO.getInstance().load(count, category);
}
private void logStatus(StatusMessage status) {
switch (status.getPriority()) {
case CRITICAL:
logger.fatal(status);
break;
case SIGNIFICANT:
logger.error(status);
break;
case PROBLEM:
logger.warn(status);
break;
case EVENTA: // fall through
case EVENTB:
logger.info(status);
break;
case VERBOSE:
logger.debug(status);
break;
}
}
}

View file

@ -250,7 +250,7 @@ public class LogMessageDAO {
}
public void save(StatusMessage sm) throws AlertvizException {
// Container.logInternal(sm);
Container.logInternal(sm);
synchronized (this) {
boolean errorOccurred = false;
ResultSet rs = null;

View file

@ -19,7 +19,6 @@
**/
package com.raytheon.uf.viz.alertviz.internal;
import java.io.File;
import java.sql.Timestamp;
import org.eclipse.core.runtime.IProgressMonitor;
@ -32,13 +31,9 @@ import org.eclipse.swt.widgets.Display;
import com.raytheon.uf.viz.alertviz.Activator;
import com.raytheon.uf.viz.alertviz.AlertvizException;
import com.raytheon.uf.viz.alertviz.Constants;
import com.raytheon.uf.viz.alertviz.LogUtil;
import com.raytheon.uf.viz.alertviz.LogUtil.Order;
import com.raytheon.uf.viz.core.VizApp;
import com.raytheon.uf.viz.core.localization.LocalizationManager;
/**
* Purges the database, and archives the old log entries to a text file
* Purges old database entries.
*
* <pre>
* SOFTWARE HISTORY
@ -50,26 +45,16 @@ import com.raytheon.uf.viz.core.localization.LocalizationManager;
* @author chammack
* @version 1.0
*/
public class ArchiveLogJob extends Job {
private int numberOfLogsToKeep;
public class PurgeLogJob extends Job {
private int ageOfLogInHours;
private static final int DEFAULT_NUMBER_OF_LOGS = 10;
private static final int DEFAULT_AGE_OF_LOG_IN_HRS = 12;
private static final int MILLISECONDS_IN_HOUR = 60 * 60 * 1000;
public ArchiveLogJob() {
super("Archive Log");
this.setSystem(true);
numberOfLogsToKeep = Activator.getDefault().getPreferenceStore()
.getInt(Constants.P_NUMBER_OF_LOGS);
if (numberOfLogsToKeep == 0) {
this.numberOfLogsToKeep = DEFAULT_NUMBER_OF_LOGS;
}
public PurgeLogJob() {
super("Archive Log Purge");
ageOfLogInHours = Activator.getDefault().getPreferenceStore()
.getInt(Constants.P_MAX_AGE_OF_LOGS);
@ -90,14 +75,8 @@ public class ArchiveLogJob extends Job {
long now = System.currentTimeMillis();
if ((now - lastPurgeInMs) > (ageOfLogInHours * MILLISECONDS_IN_HOUR)) {
String s = LocalizationManager.getUserDir() + "textLogs"
+ File.separator + VizApp.getHostName()
+ File.separator + "log";
LogUtil.rollLogs(s, numberOfLogsToKeep);
Timestamp ts = new Timestamp(now
- (ageOfLogInHours * MILLISECONDS_IN_HOUR));
LogUtil.saveLogToFile(new File(s + ".0"), ts, Order.BEFORE);
LogMessageDAO.getInstance().purge(ts);
}
} catch (AlertvizException e) {
@ -111,7 +90,7 @@ public class ArchiveLogJob extends Job {
.openError(
Display.getDefault().getActiveShell(),
"Error",
"Error rotating saving and rotating logs. Archived logs may not be stored",
"Error purging logs.",
s);
}

View file

@ -34,7 +34,7 @@ Require-Bundle: org.eclipse.ui,
com.raytheon.uf.common.geospatial;bundle-version="1.12.1174"
Bundle-ActivationPolicy: lazy
Eclipse-BuddyPolicy: ext, registered, global
Eclipse-RegisterBuddy: org.apache.velocity, com.raytheon.edex.common, com.raytheon.uf.common.serialization, com.raytheon.uf.common.serialization.comm, com.raytheon.uf.common.status, com.raytheon.uf.common.dataplugin.level
Eclipse-RegisterBuddy: org.apache.velocity, org.apache.log4j, com.raytheon.edex.common, com.raytheon.uf.common.serialization, com.raytheon.uf.common.serialization.comm, com.raytheon.uf.common.status, com.raytheon.uf.common.dataplugin.level
Export-Package: com.raytheon.uf.viz.core,
com.raytheon.uf.viz.core.alerts,
com.raytheon.uf.viz.core.auth,

View file

@ -5,4 +5,5 @@ bin.includes = META-INF/,\
plugin.xml,\
config.xml,\
scriptTemplates/,\
schema/
schema/,\
log4j-viz-core.xml

View file

@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender name="console" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%-5p %d [%t] %c{1}: %m%n"/>
</layout>
<filter class="org.apache.log4j.varia.LevelRangeFilter">
<param name="levelMin" value="DEBUG" />
<param name="levelMax" value="INFO" />
</filter>
</appender>
<appender name="errConsole" class="org.apache.log4j.ConsoleAppender">
<param name="Target" value="System.err"/>
<param name="Threshold" value="WARN" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%-5p %d [%t] %c{1}: %m%n"/>
</layout>
</appender>
<appender name="CaveLogAppender" class="com.raytheon.uf.viz.alertviz.EnvConfigurableRollingFileAppender">
<param name="envLogVar" value="LOGFILE_CAVE" />
<param name="maxFileSize" value="2GB"/>
<param name="maxBackupIndex" value="5"/>
<param name="Append" value="true"/>
<layout class="org.apache.log4j.EnhancedPatternLayout">
<param name="ConversionPattern" value="%-5p %d [%t] %m%n"/>
</layout>
</appender>
<appender name="AsyncCaveLogAppender" class="org.apache.log4j.AsyncAppender">
<param name="BufferSize" value="500"/>
<appender-ref ref="CaveLogAppender"/>
</appender>
<logger name="CaveLogger" additivity="false">
<level value="ALL"/>
<appender-ref ref="AsyncCaveLogAppender"/>
</logger>
<logger name="com.raytheon">
<level value="INFO"/>
</logger>
<logger name="com.tc">
<level value="WARN"/>
</logger>
<logger name="mx4j">
<level value="ERROR"/>
</logger>
<logger name="org.apache">
<level value="INFO"/>
</logger>
<logger name="org.apache.activemq.spring">
<level value="WARN"/>
</logger>
<logger name="org.apache.commons.beanutils">
<level value="WARN"/>
</logger>
<logger name="org.apache.qpid">
<level value="WARN"/>
</logger>
<logger name="org.geotools">
<level value="WARN"/>
</logger>
<logger name="org.apache.xbean.spring">
<level value="WARN"/>
</logger>
<logger name="org.springframework">
<level value="ERROR"/>
</logger>
<logger name="uk.ltd.getahead">
<level value="WARN"/>
</logger>
<root>
<level value="INFO"/>
<appender-ref ref="console"/>
<appender-ref ref="errConsole"/>
</root>
</log4j:configuration>

View file

@ -88,8 +88,9 @@ public class VizStatusHandler implements IUFStatusHandler {
this.source = factory.getSource(source, pluginId);
}
}
StatusManager.getManager().handle(
new VizStatusInternal(status, category, source, pluginId));
VizStatusInternal vizStatus = new VizStatusInternal(status, category,
source, pluginId);
StatusManager.getManager().handle(vizStatus);
}
@Override

View file

@ -22,6 +22,7 @@ package com.raytheon.uf.viz.core.status;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import com.raytheon.uf.common.message.StatusMessage;
import com.raytheon.uf.common.status.UFStatus;
/**
@ -170,4 +171,9 @@ public class VizStatusInternal extends UFStatus implements IStatus {
return pluginName;
}
public StatusMessage toStatusMessage() {
return new StatusMessage(this.source, this.category, this.priority,
this.pluginName, this.message, this.exception);
}
}

View file

@ -19,6 +19,8 @@
**/
package com.raytheon.uf.viz.monitor.scan.commondialogs;
import java.util.Set;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.FocusAdapter;
import org.eclipse.swt.events.FocusEvent;
@ -40,8 +42,12 @@ import org.eclipse.swt.widgets.Text;
import com.raytheon.uf.common.monitor.scan.config.AbsConfigMgr;
import com.raytheon.uf.common.monitor.scan.config.SCANConfig;
import com.raytheon.uf.common.monitor.scan.config.SCANConfigEnums.ScanTables;
import com.raytheon.uf.viz.monitor.scan.ScanMonitor;
import com.raytheon.uf.viz.monitor.scan.tables.AbstractTableDlg;
import com.raytheon.uf.viz.monitor.scan.tables.SCANAlarmAlertManager;
import com.raytheon.uf.viz.monitor.scan.tables.SCANCellTableDlg;
import com.raytheon.uf.viz.monitor.scan.tables.SCANAlarmAlertManager.AlarmType;
import com.raytheon.uf.viz.monitor.scan.tables.SCANAlarmAlertManager.AlertedAlarms;
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
public class SCANAlarmThreshDlg extends CaveSWTDialog implements
@ -239,6 +245,16 @@ public class SCANAlarmThreshDlg extends CaveSWTDialog implements
@Override
public void widgetSelected(SelectionEvent e) {
alarmChoiceChanged();
String columnName = attributeCbo.getText();
mgr.clearAlertedAlarms(site, scanTable);
AbstractTableDlg tableDlg = ScanMonitor.getInstance()
.getDialog(scanTable, site);
tableDlg.updateThresh(columnName);
if (mgr.getAlertedAlarmCount(site, scanTable) == 0) {
tableDlg.turnOffAlarm();
} else {
tableDlg.turnOnAlarm();
}
shell.dispose();
}
});

View file

@ -157,7 +157,7 @@ public class ScanResource extends
VizApp.runAsync(new Runnable() {
@Override
public void run() {
if (getScanDrawer().font != null) {
if (gc != null && getScanDrawer().font != null) {
getScanDrawer().font.setMagnification(getCapability(
MagnificationCapability.class).getMagnification()
.floatValue());
@ -560,7 +560,7 @@ public class ScanResource extends
* @return
*/
public ScanDrawer getScanDrawer() {
if (drawer == null) {
if (drawer == null && gc != null) {
if (getTable().equals(ScanTables.CELL)) {
drawer = new ScanDrawer(SCANConfig.getInstance()
.getStormCellConfig(), gc, getScan()

View file

@ -765,4 +765,8 @@ public abstract class AbstractTableDlg extends Dialog implements IMonitor,
protected abstract void handleRankMenuEvent(SelectionEvent event);
public abstract void updateThresh(String attr);
public abstract void turnOffAlarm();
public abstract void turnOnAlarm();
}

View file

@ -21,10 +21,13 @@ package com.raytheon.uf.viz.monitor.scan.tables;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
@ -36,6 +39,7 @@ import com.raytheon.uf.common.monitor.scan.config.SCANConfigEnums;
import com.raytheon.uf.common.monitor.scan.config.SCANConfigEnums.ScanTables;
import com.raytheon.uf.viz.monitor.scan.ScanMonitor;
import com.raytheon.uf.viz.monitor.scan.data.ScanDataGenerator;
import com.raytheon.uf.viz.monitor.scan.tables.SCANAlarmAlertManager.AlarmType;
/**
* Manager class to hold between scan dialog and alarming capabilities
@ -74,11 +78,11 @@ public class SCANAlarmAlertManager {
private static SCANAlarmAlertManager instance = null;
private HashMap<String, HashMap<ScanTables, List<ScheduledAlarms>>> scheduledAlarmsMap;
private Map<String, Map<ScanTables, List<ScheduledAlarms>>> scheduledAlarmsMap;
private HashMap<String, HashMap<ScanTables, Set<AlertedAlarms>>> alertedAlarmsMap;
private Map<String, Map<ScanTables, Set<AlertedAlarms>>> alertedAlarmsMap;
private HashMap<String, HashMap<ScanTables, List<String>>> idents;
private Map<String, Map<ScanTables, List<String>>> idents;
private boolean ring = false;
@ -98,7 +102,7 @@ public class SCANAlarmAlertManager {
public void addSite(String site) {
if (!scheduledAlarmsMap.containsKey(site)) {
HashMap<ScanTables, List<ScheduledAlarms>> siteScheduledAlarmsMap = new HashMap<ScanTables, List<ScheduledAlarms>>();
Map<ScanTables, List<ScheduledAlarms>> siteScheduledAlarmsMap = Collections.synchronizedMap(new HashMap<ScanTables, List<ScheduledAlarms>>());
siteScheduledAlarmsMap.put(ScanTables.DMD,
new CopyOnWriteArrayList<ScheduledAlarms>());
siteScheduledAlarmsMap.put(ScanTables.CELL,
@ -107,7 +111,7 @@ public class SCANAlarmAlertManager {
}
if (!alertedAlarmsMap.containsKey(site)) {
HashMap<ScanTables, Set<AlertedAlarms>> siteAlertedAlarmsSet = new HashMap<ScanTables, Set<AlertedAlarms>>();
Map<ScanTables, Set<AlertedAlarms>> siteAlertedAlarmsSet = Collections.synchronizedMap(new HashMap<ScanTables, Set<AlertedAlarms>>());
siteAlertedAlarmsSet.put(ScanTables.DMD,
new HashSet<AlertedAlarms>());
siteAlertedAlarmsSet.put(ScanTables.CELL,
@ -116,7 +120,7 @@ public class SCANAlarmAlertManager {
}
if (!idents.containsKey(site)) {
HashMap<ScanTables, List<String>> siteIdents = new HashMap<ScanTables, List<String>>();
Map<ScanTables, List<String>> siteIdents = new HashMap<ScanTables, List<String>>();
siteIdents.put(ScanTables.CELL, new ArrayList<String>());
siteIdents.put(ScanTables.DMD, new ArrayList<String>());
idents.put(site, siteIdents);
@ -126,15 +130,15 @@ public class SCANAlarmAlertManager {
private SCANAlarmAlertManager() {
if (scheduledAlarmsMap == null) {
scheduledAlarmsMap = new HashMap<String, HashMap<ScanTables, List<ScheduledAlarms>>>();
scheduledAlarmsMap = Collections.synchronizedMap(new HashMap<String, Map<ScanTables, List<ScheduledAlarms>>>());
}
if (alertedAlarmsMap == null) {
alertedAlarmsMap = new HashMap<String, HashMap<ScanTables, Set<AlertedAlarms>>>();
alertedAlarmsMap = Collections.synchronizedMap(new HashMap<String, Map<ScanTables, Set<AlertedAlarms>>>());
}
if (idents == null) {
idents = new HashMap<String, HashMap<ScanTables, List<String>>>();
idents = new HashMap<String, Map<ScanTables, List<String>>>();
}
}
@ -438,7 +442,7 @@ public class SCANAlarmAlertManager {
return count;
}
public boolean containsAlarm(String site, ScanTables tableType,
AlarmType type, String colName, String ident) {
for (AlertedAlarms alarm : alertedAlarmsMap.get(site).get(tableType)) {
@ -493,9 +497,10 @@ public class SCANAlarmAlertManager {
alarm.cleared = true;
}
}
public void removeAlertedAlarms(String site, ScanTables tableType) {
alertedAlarmsMap.get(site).get(tableType).clear();
setRing(false);
}
/**
@ -603,4 +608,5 @@ public class SCANAlarmAlertManager {
+ this.row + "\nCol #:" + this.col + "\nCleared: " + cleared + "\n";
}
}
}

View file

@ -475,8 +475,7 @@ public class SCANCellTableDlg extends AbstractTableDlg implements
alarmDlg.open();
if (!alarmBtn.isDisposed()
&& (mgr.getAlertedAlarmCount(site, scanTable) == 0)) {
alarmBtn.setVisible(false);
mgr.setRing(false);
turnOffAlarm();
}
}
});
@ -488,7 +487,23 @@ public class SCANCellTableDlg extends AbstractTableDlg implements
timeLbl.setLayoutData(gd);
}
// private void resetButtonForegroundColor(Button btn)
@Override
public void turnOffAlarm() {
if (alarmBtn != null && !alarmBtn.isDisposed()) {
alarmBtn.setVisible(false);
}
mgr.setRing(false);
}
@Override
public void turnOnAlarm() {
if (alarmBtn != null && !alarmBtn.isDisposed()) {
alarmBtn.setVisible(true);
}
mgr.setRing(true);
}
// private void resetButtonForegroundColor(Button btn)
// {
// btn.setForeground(display.getSystemColor(SWT.COLOR_WHITE));
// }

View file

@ -514,8 +514,7 @@ public class SCANDmdTableDlg extends AbstractTableDlg implements
alarmsDlg.open();
if (!alarmBtn.isDisposed()
&& mgr.getAlertedAlarms(site, scanTable).isEmpty()) {
alarmBtn.setVisible(false);
mgr.setRing(false);
turnOffAlarm();
}
}
});
@ -1299,4 +1298,19 @@ public class SCANDmdTableDlg extends AbstractTableDlg implements
dmdTableComp.alarmSelection(ident);
}
public void turnOffAlarm() {
if (alarmBtn != null && !alarmBtn.isDisposed()) {
alarmBtn.setVisible(false);
}
mgr.setRing(false);
}
public void turnOnAlarm() {
if (alarmBtn != null && !alarmBtn.isDisposed()) {
alarmBtn.setVisible(true);
}
mgr.setRing(true);
}
}

View file

@ -647,4 +647,14 @@ public class SCANMesoTableDlg extends AbstractTableDlg implements
return false;
}
@Override
public void turnOffAlarm() {
mgr.setRing(false);
}
@Override
public void turnOnAlarm() {
mgr.setRing(true);
}
}

View file

@ -609,4 +609,14 @@ public class SCANTvsTableDlg extends AbstractTableDlg implements
// Not currently used for TVS
return false;
}
@Override
public void turnOffAlarm() {
mgr.setRing(false);
}
@Override
public void turnOnAlarm() {
mgr.setRing(true);
}
}

View file

@ -20,12 +20,11 @@ Developed on the Raytheon Visualization Environment (viz)
<launcherArgs>
<programArgs>-data @user.home/caveData -user @user.home/caveData -clean</programArgs>
<programArgsLin>-consoleLog</programArgsLin>
<vmArgs>-Xincgc -Xmx256M -Xss2024k -Dosgi.instance.area.readOnly=true -Dosgi.hook.configurators.exclude=org.eclipse.core.runtime.internal.adaptor.EclipseLogHook,org.eclipse.core.runtime.internal.adaptor.EclipseErrorHandler -Dorg.eclipse.update.reconcile=false -Dqpid.dest_syntax=BURL -Dorg.eclipse.update.reconcile=false -XX:MaxPermSize=128m -Dorg.eclipse.ui/KEY_CONFIGURATION_ID=com.raytheon.viz.ui.awips.scheme -Dawips.mode=pypies -Dqpid.dest_syntax=BURL -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false</vmArgs>
<vmArgs>-Xincgc -Xmx256M -Xss2024k -Dosgi.instance.area.readOnly=true -Dosgi.hook.configurators.exclude=org.eclipse.core.runtime.internal.adaptor.EclipseLogHook,org.eclipse.core.runtime.internal.adaptor.EclipseErrorHandler -Dorg.eclipse.update.reconcile=false -Dqpid.dest_syntax=BURL -Dorg.eclipse.update.reconcile=false -XX:MaxPermSize=128m -Dorg.eclipse.ui/KEY_CONFIGURATION_ID=com.raytheon.viz.ui.awips.scheme -Dawips.mode=pypies -Dqpid.dest_syntax=BURL -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dlog4j.configuration=log4j-alertviz.xml</vmArgs>
</launcherArgs>
<windowImages/>
<launcher name="alertviz">
<solaris/>
<win useIco="false">
@ -39,7 +38,6 @@ Developed on the Raytheon Visualization Environment (viz)
</win>
</launcher>
<vm>
<linux include="true">jdk1.6.0</linux>
<windows include="true">jdk1.6.0</windows>

View file

@ -18,7 +18,7 @@
<programArgsLin>-consoleLog</programArgsLin>
<vmArgs>-Xincgc -Xmx1280M -Dosgi.instance.area.readOnly=true
-Dosgi.hook.configurators.exclude=org.eclipse.core.runtime.internal.adaptor.EclipseLogHook,org.eclipse.core.runtime.internal.adaptor.EclipseErrorHandler
-XX:+UnlockDiagnosticVMOptions -XX:+UnsyncloadClass -Dorg.eclipse.update.reconcile=false -XX:MaxPermSize=128m -Dorg.eclipse.ui/KEY_CONFIGURATION_ID=com.raytheon.viz.ui.awips.scheme -Dawips.mode=pypies -Dqpid.dest_syntax=BURL -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -XX:OnOutOfMemoryError=&quot;capture -t no -p $pid &amp;&quot;</vmArgs>
-XX:+UnlockDiagnosticVMOptions -XX:+UnsyncloadClass -Dorg.eclipse.update.reconcile=false -XX:MaxPermSize=128m -Dorg.eclipse.ui/KEY_CONFIGURATION_ID=com.raytheon.viz.ui.awips.scheme -Dawips.mode=pypies -Dqpid.dest_syntax=BURL -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -XX:OnOutOfMemoryError=&quot;capture -t no -p $pid &amp;&quot; -Dlog4j.configuration=log4j-viz-core.xml</vmArgs>
<vmArgsWin>-Dfile.encoding=UTF-8</vmArgsWin>
</launcherArgs>

View file

@ -17,7 +17,7 @@
<programArgs>-data @user.home/caveData -user @user.home/caveData -clean -consoleLog -alertviz</programArgs>
<vmArgs>-Xincgc -Xmx1024M -Dosgi.instance.area.readOnly=true
-Dosgi.hook.configurators.exclude=org.eclipse.core.runtime.internal.adaptor.EclipseLogHook,org.eclipse.core.runtime.internal.adaptor.EclipseErrorHandler
-XX:+UnlockDiagnosticVMOptions -XX:+UnsyncloadClass -Dorg.eclipse.update.reconcile=false -XX:MaxPermSize=128m -Dorg.eclipse.ui/KEY_CONFIGURATION_ID=com.raytheon.viz.ui.awips.scheme -Dawips.mode=pypies -Dqpid.dest_syntax=BURL -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false</vmArgs>
-XX:+UnlockDiagnosticVMOptions -XX:+UnsyncloadClass -Dorg.eclipse.update.reconcile=false -XX:MaxPermSize=128m -Dorg.eclipse.ui/KEY_CONFIGURATION_ID=com.raytheon.viz.ui.awips.scheme -Dawips.mode=pypies -Dqpid.dest_syntax=BURL -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dlog4j.configuration=log4j-viz-core.xml</vmArgs>
<vmArgsWin>-Dfile.encoding=UTF-8</vmArgsWin>
</launcherArgs>
@ -36,7 +36,6 @@
</launcher>
<vm>
<linux include="true">jdk1.6.0</linux>
<windows include="true">jdk1.6.0</windows>
</vm>

View file

@ -105,7 +105,7 @@ public class SiteAbbreviationUtil {
public static String getTtaaii(String afosId) {
String query = "SELECT wmottaaii FROM afos_to_awips WHERE afosid = '"
+ afosId + "';";
String rval = "blank";
String rval = "-";
try {
List<Object[]> results = DirectDbQuery.executeQuery(query,

View file

@ -44,15 +44,6 @@
</layout>
</appender-->
<appender name="AlertVizInternalLogAppender" class="org.apache.log4j.rolling.RollingFileAppender">
<rollingPolicy class="org.apache.log4j.rolling.TimeBasedRollingPolicy">
<param name="FileNamePattern" value="${user.home}/caveData/logs/alertviz-%d{yyyyMMdd}.log"/>
</rollingPolicy>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%-5p %d [%t] %c{1}: %m%n"/>
</layout>
</appender>
<logger name="gov.noaa.nws.ncep">
<level value="INFO"/>
<appender-ref ref="NcepILogAppender"/>
@ -65,11 +56,6 @@
<appender-ref ref="NcepDailyRollingFileAppender"/>
</logger>
<logger name="AlertVizLogger" additivity="false">
<level value="ALL"/>
<appender-ref ref="AlertVizInternalLogAppender"/>
</logger>
<logger name="com.raytheon">
<level value="INFO"/>
</logger>

View file

@ -3,5 +3,6 @@
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="unit-test"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -12,7 +12,8 @@ Require-Bundle: org.apache.commons.logging,
javax.measure,
org.geotools,
javax.persistence,
org.apache.camel;bundle-version="1.0.0";resolution:=optional
org.apache.camel;bundle-version="1.0.0";resolution:=optional,
org.junit;bundle-version="1.0.0"
Export-Package: com.raytheon.edex.plugin.airep,
com.raytheon.edex.plugin.airep.decoder
Bundle-RequiredExecutionEnvironment: JavaSE-1.6

View file

@ -57,6 +57,9 @@ import com.raytheon.uf.edex.wmo.message.WMOHeader;
* 20080103 384 jkorman Initial Coding.
* 20080408 1039 jkorman Added traceId for tracing data.
* 11/11/08 1684 chammack Camel Refactor
* ======================================
* AWIPS2 DR Work
* 20120911 1011 jkorman Added decode of AIREP turbulence.
* </pre>
*
* @author jkorman
@ -99,10 +102,11 @@ public class AirepDecoder extends AbstractDecoder {
String traceId = null;
try {
// traceId = getTraceId(hdrMap);
logger.debug(traceId + "- AirepDecoder.decode()");
WMOHeader wmoHeader = input.wmoHeader;
if(wmoHeader != null) {
traceId = wmoHeader.getWmoHeader().replace(" ", "_");
logger.info(traceId + "- AirepDecoder.decode()");
Calendar refTime = TimeTools.findDataTime(
wmoHeader.getYYGGgg(), header);
if(refTime != null) {
@ -170,11 +174,28 @@ public class AirepDecoder extends AbstractDecoder {
record.setLocation(location);
AIREPWeather wx = parser.getWeatherGroup();
int flightConditions = -1;
if (wx != null) {
record.setFlightConditions(wx.getFlightConditions());
flightConditions = wx.getFlightConditions();
record.setFlightHazard(wx.getHazard());
record.setFlightWeather(wx.getWeather());
}
AirepParser.Turbulence turb = parser.getTurbulence();
int t = -1;
if(turb != null) {
t = turb.getTurbulence() << 4;
}
if(flightConditions > -1) {
if(t > -1) {
record.setFlightConditions(flightConditions | t);
} else {
record.setFlightConditions(flightConditions);
}
} else {
if(t > -1) {
record.setFlightConditions(t);
}
}
}
}
return record;

View file

@ -54,6 +54,9 @@ import com.raytheon.uf.edex.wmo.message.WMOHeader;
* ------------ ---------- ----------- --------------------------
* 20080103 384 jkorman Initial Coding.
* 11/13/2008 1684 chammack Camel Refactor
* ======================================
* AWIPS2 DR Work
* 20120911 1011 jkorman Properly handle trailing end of report.
* </pre>
*
* @author jkorman
@ -69,6 +72,10 @@ public class AirepSeparator extends AbstractRecordSeparator {
private static final String AIREP_MSG_LINE = "(ARP|ARS)";
private static final String EOR_E = "=";
private static final String EOR_S = ";";
private WMOHeader wmoHeader = null;
private byte[] messageData = null;
@ -133,6 +140,14 @@ public class AirepSeparator extends AbstractRecordSeparator {
if ((reports != null) && (reports.size() > 0)) {
currentReport = 0;
for (int i = 0; i < reports.size(); i++) {
String s = reports.get(i);
if (s != null) {
if (s.endsWith(EOR_E) || s.endsWith(EOR_S)) {
reports.set(i, s.substring(0, s.length() - 1));
}
}
}
} else {
logger.info("No reports found in data");
}

View file

@ -19,17 +19,19 @@
**/
package com.raytheon.edex.plugin.airep.decoder;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TimeZone;
import java.util.regex.Pattern;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.raytheon.edex.esb.Headers;
import com.raytheon.uf.common.dataplugin.airep.AirepRecord;
import com.raytheon.uf.edex.decodertools.aircraft.AircraftFlightLevel;
import com.raytheon.uf.edex.decodertools.aircraft.AircraftLatitude;
import com.raytheon.uf.edex.decodertools.aircraft.AircraftLongitude;
@ -37,7 +39,6 @@ import com.raytheon.uf.edex.decodertools.aircraft.AircraftRemarks;
import com.raytheon.uf.edex.decodertools.core.BasePoint;
import com.raytheon.uf.edex.decodertools.core.PlatformLocationProxy;
import com.raytheon.uf.edex.decodertools.time.TimeTools;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
/**
* The AirepParser takes a String that should contain a single AIREP observation
@ -52,12 +53,65 @@ import com.raytheon.uf.edex.wmo.message.WMOHeader;
* 20080103 384 jkorman Initial Coding.
* 20080423 1016 jkorman Added range checking for wind speed.
* Zero'd second/milliseconds on timeObs.
* ======================================
* AWIPS2 DR Work
* 20120911 1011 jkorman Added decode of AIREP turbulence, corrected
* parse of run together latlon.
* </pre>
*/
public class AirepParser {
/** The logger */
private Log logger = LogFactory.getLog(getClass());
public static class Turbulence {
private int turbulence = 0x80;
/**
* Create an initialized turbulence object.
*/
public Turbulence() {
}
/**
* Set the turbulence intensity.
*
* @param The
* turbulence intensity.
*/
public void setIntensity(int intensity) {
turbulence |= intensity;
}
/**
* Set the turbulence frequency.
*
* @param The
* turbulence frequency.
*/
public void setFrequency(int frequency) {
turbulence |= frequency;
}
/**
* Set the turbulence type.
*
* @param The
* turbulence type.
*/
public void setType(int type) {
turbulence |= type;
}
/**
* Get the turbulence value.
*
* @return The turbulence value.
*/
public int getTurbulence() {
return turbulence;
}
}
private static final boolean WANT_DELIMITERS = false;
// Only going to delimit aireps with spaces and carriage control.
@ -65,6 +119,109 @@ public class AirepParser {
private static final int MAX_WIND_SPEED = 500;
private static final Set<String> TURB_TERM_WORDS = new HashSet<String>();
static {
TURB_TERM_WORDS.add("IC");
TURB_TERM_WORDS.add("RM");
TURB_TERM_WORDS.add("MID");
TURB_TERM_WORDS.add("WX");
}
private static final Map<String, String> TURB_WORDS = new HashMap<String, String>();
static {
TURB_WORDS.put("TB", "TB");
TURB_WORDS.put("TURB", "TB");
TURB_WORDS.put("TRBC", "TB");
}
private static final Map<String, Integer> TURB_TYPE = new HashMap<String, Integer>();
static {
TURB_TYPE.put("CAT", AirepRecord.TURB_TYPE_CAT);
TURB_TYPE.put("CHOP", AirepRecord.TURB_TYPE_CHOP);
TURB_TYPE.put("CHP", AirepRecord.TURB_TYPE_CHOP);
TURB_TYPE.put("LLWS", AirepRecord.TURB_TYPE_LLWS);
}
private static final Map<String, Integer> TURB_FREQ = new HashMap<String, Integer>();
static {
TURB_FREQ.put("OCN", AirepRecord.TURB_FREQ_OCN);
TURB_FREQ.put("OCNL", AirepRecord.TURB_FREQ_OCN);
TURB_FREQ.put("OCA", AirepRecord.TURB_FREQ_OCN);
TURB_FREQ.put("OCC", AirepRecord.TURB_FREQ_OCN);
TURB_FREQ.put("OCS", AirepRecord.TURB_FREQ_OCN);
TURB_FREQ.put("ISO", AirepRecord.TURB_FREQ_OCN);
TURB_FREQ.put("INT", AirepRecord.TURB_FREQ_INT);
TURB_FREQ.put("INTMT", AirepRecord.TURB_FREQ_INT);
TURB_FREQ.put("INTERMITTENT", AirepRecord.TURB_FREQ_INT);
TURB_FREQ.put("INTM", AirepRecord.TURB_FREQ_INT);
TURB_FREQ.put("CON", AirepRecord.TURB_FREQ_CON);
TURB_FREQ.put("CONT", AirepRecord.TURB_FREQ_CON);
TURB_FREQ.put("STE", AirepRecord.TURB_FREQ_CON);
TURB_FREQ.put("CNT", AirepRecord.TURB_FREQ_CON);
TURB_FREQ.put("CON", AirepRecord.TURB_FREQ_CON);
TURB_FREQ.put("CONS", AirepRecord.TURB_FREQ_CON);
TURB_FREQ.put("STD", AirepRecord.TURB_FREQ_CON);
TURB_FREQ.put("CNS", AirepRecord.TURB_FREQ_CON);
}
private static final Map<String, Integer> TURB_INT = new HashMap<String, Integer>();
static {
TURB_INT.put("ZERO", AirepRecord.TURB_NEG);
TURB_INT.put("0", AirepRecord.TURB_NEG);
TURB_INT.put("NIL", AirepRecord.TURB_NEG);
TURB_INT.put("NEG", AirepRecord.TURB_NEG);
TURB_INT.put("SMTH", AirepRecord.TURB_NEG);
TURB_INT.put("SMT", AirepRecord.TURB_NEG);
TURB_INT.put("SM H", AirepRecord.TURB_NEG);
TURB_INT.put("NONE", AirepRecord.TURB_NEG);
TURB_INT.put("SMOOTH", AirepRecord.TURB_NEG);
TURB_INT.put("SMTHU", AirepRecord.TURB_NEG);
TURB_INT.put("NEGATIVE", AirepRecord.TURB_NEG);
TURB_INT.put("SMOOTHLGT", AirepRecord.TURB_NEG_LGT);
TURB_INT.put("ONE", AirepRecord.TURB_LGT);
TURB_INT.put("1", AirepRecord.TURB_LGT);
TURB_INT.put("SLIGHT", AirepRecord.TURB_LGT);
TURB_INT.put("LT", AirepRecord.TURB_LGT);
TURB_INT.put("LGT", AirepRecord.TURB_LGT);
TURB_INT.put("LIT", AirepRecord.TURB_LGT);
TURB_INT.put("LIG", AirepRecord.TURB_LGT);
TURB_INT.put("LGHT", AirepRecord.TURB_LGT);
TURB_INT.put("LGTMOD", AirepRecord.TURB_LGT_MOD);
TURB_INT.put("LGT-MOD", AirepRecord.TURB_LGT_MOD);
TURB_INT.put("SLIGHT-MOD", AirepRecord.TURB_LGT_MOD);
TURB_INT.put("TWO", AirepRecord.TURB_MOD);
TURB_INT.put("2", AirepRecord.TURB_MOD);
TURB_INT.put("MOD", AirepRecord.TURB_MOD);
TURB_INT.put("MDT", AirepRecord.TURB_MOD);
TURB_INT.put("TWO", AirepRecord.TURB_MOD);
TURB_INT.put("MODSEV", AirepRecord.TURB_MOD_SEV);
TURB_INT.put("MODSVR", AirepRecord.TURB_MOD_SEV);
TURB_INT.put("MDTSEV", AirepRecord.TURB_MOD_SEV);
TURB_INT.put("MDTSVR", AirepRecord.TURB_MOD_SEV);
TURB_INT.put("MODSEV", AirepRecord.TURB_MOD_SEV);
TURB_INT.put("MOD-SEV", AirepRecord.TURB_MOD_SEV);
TURB_INT.put("MDT-SEV", AirepRecord.TURB_MOD_SEV);
TURB_INT.put("MOD-SVR", AirepRecord.TURB_MOD_SEV);
TURB_INT.put("MDT-SVR", AirepRecord.TURB_MOD_SEV);
TURB_INT.put("THREE", AirepRecord.TURB_SEV);
TURB_INT.put("3", AirepRecord.TURB_SEV);
TURB_INT.put("SEV", AirepRecord.TURB_SEV);
TURB_INT.put("SVR", AirepRecord.TURB_SEV);
TURB_INT.put("XTRM", AirepRecord.TURB_XTRM);
TURB_INT.put("EXTRM", AirepRecord.TURB_XTRM);
TURB_INT.put("EXTRE", AirepRecord.TURB_XTRM);
}
// Once set the obs data cannot be changed!
private final String reportData;
@ -100,7 +257,7 @@ public class AirepParser {
final Pattern TEMP_LONG = Pattern.compile("^(MS|PS)\\d{2}");
// Parsed and/or decoded observation elements.
private ArrayList<Object> theElements = new ArrayList<Object>();
private ArrayList<Object> reportElements = new ArrayList<Object>();
private String aircraftId = null;
@ -116,6 +273,8 @@ public class AirepParser {
private Double temperature = null;
private Turbulence turbulence = null;
private AIREPWeather weatherGroup = null;
private Integer windDirection = null;
@ -125,7 +284,6 @@ public class AirepParser {
private AircraftRemarks rptRemarks = null;
private Calendar refTime;
/**
* Create the parser for and decode an observation from a String.
@ -156,15 +314,12 @@ public class AirepParser {
*/
ArrayList<?> parseElementsTestPoint() {
ArrayList<Object> retElements = new ArrayList<Object>();
retElements.addAll(theElements);
retElements.addAll(reportElements);
return retElements;
} // parseElementsTestPoint()
/**
* Parse the AIREP observation into individual elements. Note that during
* parse or decode the order of the elements does not change. The only
* exception to this rule is that all elements identified as
* comments/remarks are placed at the end of the observation elements.
* Parse the AIREP observation into individual elements.
*/
private void parseElements() {
StringTokenizer st = new StringTokenizer(reportData, DELIMITER,
@ -178,7 +333,9 @@ public class AirepParser {
if ((o != null) && (reportType == null)) {
reportType = ((AIREPObsType) o).getValue();
} else {
theElements.add(s);
if (s.length() > 0) {
reportElements.add(s);
}
}
}
}
@ -191,8 +348,8 @@ public class AirepParser {
// run back through the data to see if there is a waypoint. If we
// get to the time information, quit, it's not there.
if ((latitude == null) && (longitude == null)) {
for (int i = 0; i < theElements.size(); i++) {
Object o = theElements.get(i);
for (int i = 0; i < reportElements.size(); i++) {
Object o = reportElements.get(i);
if (o instanceof String) {
BasePoint wayPoint = PlatformLocationProxy.lookup(
(String) o, null);
@ -220,12 +377,17 @@ public class AirepParser {
observationTime = null;
return;
}
determineAircraftId();
decodeFlightLevel();
decodeTemperature();
decodeTurb();
decodeWeatherGroup();
decodeWinds();
collectRemarks();
determineAircraftId();
} // parseElements()
/**
@ -234,12 +396,12 @@ public class AirepParser {
* data as the id.
*/
private void determineAircraftId() {
for (int i = 0; i < theElements.size(); i++) {
Object o = theElements.get(i);
if (o instanceof Double) {
for (int i = 0; i < reportElements.size(); i++) {
Object o = reportElements.get(i);
// Search only up to the obs time.
if (observationTime.equals(o)) {
break;
}
if (o instanceof String) {
} else if (o instanceof String) {
aircraftId = (String) o;
break;
}
@ -263,13 +425,13 @@ public class AirepParser {
* which is then processed normally.
*/
private void splitLatLon() {
for (int i = 0; i < theElements.size(); i++) {
Object o = theElements.get(i);
for (int i = 0; i < reportElements.size(); i++) {
Object o = reportElements.get(i);
if (o instanceof String) {
String[] latLon = AircraftLatitude.splitLatLon((String) o);
if ((latLon != null)&&(latLon.length ==2)) {
theElements.add(i, latLon[0]);
theElements.set(i, latLon[1]);
if ((latLon != null) && (latLon.length == 2)) {
reportElements.set(i, latLon[1]);
reportElements.add(i, latLon[0]);
break;
}
}
@ -283,13 +445,13 @@ public class AirepParser {
*/
private void decodeLatitude() {
if (latitude == null) {
for (int i = 0; i < theElements.size(); i++) {
Object o = theElements.get(i);
for (int i = 0; i < reportElements.size(); i++) {
Object o = reportElements.get(i);
if (o instanceof String) {
AircraftLatitude lat = AircraftLatitude
.aircraftLatitudeFactory((String) o);
if (lat != null) {
theElements.set(i, lat);
reportElements.set(i, lat);
latitude = lat.decodeLatitude();
break;
}
@ -305,13 +467,13 @@ public class AirepParser {
*/
private void decodeLongitude() {
if (longitude == null) {
for (int i = 0; i < theElements.size(); i++) {
Object o = theElements.get(i);
for (int i = 0; i < reportElements.size(); i++) {
Object o = reportElements.get(i);
if (o instanceof String) {
AircraftLongitude lon = AircraftLongitude
.aircraftLongitudeFactory((String) o);
if (lon != null) {
theElements.set(i, lon);
reportElements.set(i, lon);
longitude = lon.decodeLongitude();
break;
}
@ -326,8 +488,8 @@ public class AirepParser {
* observation elements collection.
*/
private void decodeTime() {
for (int i = 0; i < theElements.size(); i++) {
Object o = theElements.get(i);
for (int i = 0; i < reportElements.size(); i++) {
Object o = reportElements.get(i);
if (o instanceof String) {
String s = (String) o;
if (TIME.matcher(s).matches()) {
@ -336,7 +498,7 @@ public class AirepParser {
int minute = Integer.parseInt(s.substring(2));
if (refTime != null) {
observationTime = TimeTools.copy(refTime);
observationTime.set(Calendar.HOUR_OF_DAY, hour);
observationTime.set(Calendar.MINUTE, minute);
@ -348,7 +510,7 @@ public class AirepParser {
observationTime.add(Calendar.DAY_OF_MONTH, -1);
}
theElements.set(i, observationTime);
reportElements.set(i, observationTime);
}
break;
}
@ -357,21 +519,21 @@ public class AirepParser {
}
private void decodeFlightLevel() {
for (int i = 0; i < theElements.size(); i++) {
Object o = theElements.get(i);
for (int i = 0; i < reportElements.size(); i++) {
Object o = reportElements.get(i);
if (o instanceof String) {
String s = (String) o;
if (FL_SHORT.matcher(s).matches()) {
double fLevel = Integer.parseInt(s.substring(1)) * 100;
flightLevel = new AircraftFlightLevel(fLevel);
theElements.set(i, flightLevel);
reportElements.set(i, flightLevel);
break;
} else if (FL_LONG.matcher(s).matches()) {
double fLevel = Integer.parseInt(s.substring(1)) * 100;
flightLevel = new AircraftFlightLevel(fLevel);
theElements.set(i, flightLevel);
reportElements.set(i, flightLevel);
break;
}
}
@ -382,8 +544,8 @@ public class AirepParser {
* Decode the temperature information in this observation.
*/
private void decodeTemperature() {
for (int i = 0; i < theElements.size(); i++) {
Object o = theElements.get(i);
for (int i = 0; i < reportElements.size(); i++) {
Object o = reportElements.get(i);
if (o instanceof String) {
double temp = Double.NaN;
String s = (String) o;
@ -396,7 +558,7 @@ public class AirepParser {
temp *= -1;
}
temperature = new Double(temp);
theElements.set(i, temperature);
reportElements.set(i, temperature);
}
break;
} else if (TEMP_SHORT.matcher(s).matches()) {
@ -408,7 +570,7 @@ public class AirepParser {
temp *= -1;
}
temperature = new Double(temp);
theElements.set(i, temperature);
reportElements.set(i, temperature);
}
break;
}
@ -416,18 +578,256 @@ public class AirepParser {
}
}
/**
* Decode airep turbulence</br>Encoded turbulence for storage.
* <table>
* <tr>
* <td>T</td>
* <td>Int</td>
* <td>Type</td>
* <td>Freg</td>
* </tr>
* <tr>
* <td>1</td>
* <td>111</td>
* <td>11</td>
* <td>11</td>
* </tr>
* <tr>
* <td></td>
* <td></td>
* <td></td>
* <td>00</td>
* <td>no frequency</td>
* </tr>
* <tr>
* <td></td>
* <td></td>
* <td></td>
* <td>01</td>
* <td>Ocnl</td>
* </tr>
* <tr>
* <td></td>
* <td></td>
* <td></td>
* <td>10</td>
* <td>Isolated</td>
* </tr>
* <tr>
* <td></td>
* <td></td>
* <td></td>
* <td>11</td>
* <td>Continous</td>
* </tr>
* <tr>
* <td></td>
* <td></td>
* <td>00</td>
* <td></td>
* <td>No type reported</td>
* </tr>
* <tr>
* <td></td>
* <td></td>
* <td>01</td>
* <td></td>
* <td>CAT 4</td>
* </tr>
* <tr>
* <td></td>
* <td></td>
* <td>10</td>
* <td></td>
* <td>Chop 6</td>
* </tr>
* <tr>
* <td></td>
* <td></td>
* <td>11</td>
* <td></td>
* <td>LLWS 7</td>
* </tr>
* <tr>
* <td></td>
* <td>000</td>
* <td></td>
* <td></td>
* <td>No Intensity</td>
* </tr>
* <tr>
* <td></td>
* <td>001</td>
* <td></td>
* <td></td>
* <td>Smooth-Light</td>
* </tr>
* <tr>
* <td></td>
* <td>010</td>
* <td></td>
* <td></td>
* <td>Light</td>
* </tr>
* <tr>
* <td></td>
* <td>011</td>
* <td></td>
* <td></td>
* <td>Light - Mod</td>
* </tr>
* <tr>
* <td></td>
* <td>100</td>
* <td></td>
* <td></td>
* <td>Mod</td>
* </tr>
* <tr>
* <td></td>
* <td>101</td>
* <td></td>
* <td></td>
* <td>Mod - Severe</td>
* </tr>
* <tr>
* <td></td>
* <td>110</td>
* <td></td>
* <td></td>
* <td>Severe</td>
* </tr>
* <tr>
* <td></td>
* <td>111</td>
* <td></td>
* <td></td>
* <td>Extreme</td>
* </tr>
* </table>
*/
private void decodeTurb() {
int intensity = -1;
int i = 0;
for (; i < reportElements.size(); i++) {
Object o = reportElements.get(i);
if (TURB_WORDS.get(o) != null) {
// We have turbulence of some type.
turbulence = new Turbulence();
reportElements.remove(i);
break;
}
}
if (i > 0) {
while (i < reportElements.size()) {
Object o = reportElements.get(i);
// Check words that absolutely terminate search for turbulence.
if (TURB_TERM_WORDS.contains(o)) {
break;
} else {
if (i < reportElements.size()) {
o = reportElements.get(i);
Integer n = null;
if ((n = TURB_FREQ.get(o)) != null) {
turbulence.setFrequency(n);
reportElements.remove(i);
} else if ((n = TURB_TYPE.get(o)) != null) {
turbulence.setType(n);
reportElements.remove(i);
} else if ((n = TURB_INT.get(o)) != null) {
if (intensity < 0) {
intensity = n;
} else {
if (n > intensity) {
intensity = n;
}
}
reportElements.remove(i);
} else if ("NOT".equals(o)) {
reportElements.remove(i);
if (i < reportElements.size()) {
if ("REPORTED".equals(reportElements.get(i))) {
reportElements.remove(i);
intensity = TURB_INT.get("NEG");
}
}
} else if ("CODE".equals(o)) {
reportElements.remove(i);
} else {
// Check to see if we have a turbulence range. In these cases if
// more than one turbulence is found, report the most severe.
if (o instanceof String) {
String s = (String) o;
// Two possible turbulence ranges we may have to work with.
Integer turbA = null;
Integer turbB = null;
if (s.length() > 3) {
if ((turbA = TURB_INT.get(s.substring(0, 3))) != null) {
int pos = 3;
// so now start at position 3 and check for possible
// matches.
while (pos < s.length()) {
if ((turbB = TURB_INT.get(s
.substring(pos))) != null) {
break;
} else {
pos++;
}
}
}
}
if (turbA != null) {
if (turbB != null) {
if (turbB > turbA) {
intensity = turbB;
} else {
intensity = turbA;
}
} else {
intensity = turbA;
}
} else {
if (turbB != null) {
intensity = turbB;
}
}
if (intensity > -1) {
reportElements.remove(i);
} else {
i++;
}
} else {
i++;
}
}
}
}
}
}
if (intensity > 0) {
// Check if we found a frequency or type without
// an intensity.
if (intensity < 0x10) {
// if so then set it to light
intensity |= AirepRecord.TURB_LGT;
}
turbulence.setIntensity(intensity);
}
}
/**
* Attempt to locate and decode the 3 digit hazards and weather group.
*/
private void decodeWeatherGroup() {
for (int i = 0; i < theElements.size(); i++) {
Object o = theElements.get(i);
for (int i = 0; i < reportElements.size(); i++) {
Object o = reportElements.get(i);
if (o instanceof String) {
String s = (String) o;
if (s.length() == 3) {
if (WX_GROUP.matcher(s).find()) {
weatherGroup = new AIREPWeather(s);
theElements.set(i, weatherGroup);
reportElements.set(i, weatherGroup);
break;
}
}
@ -445,15 +845,15 @@ public class AirepParser {
private void decodeWinds() {
// By now we should have found the flight level data.
int i = 0;
for (; i < theElements.size(); i++) {
if (theElements.get(i) instanceof AircraftFlightLevel) {
for (; i < reportElements.size(); i++) {
if (reportElements.get(i) instanceof AircraftFlightLevel) {
i++;
break;
}
} // for()
for (; i < theElements.size(); i++) {
Object o = theElements.get(i);
for (; i < reportElements.size(); i++) {
Object o = reportElements.get(i);
if (o instanceof String) {
String s = (String) o;
if (s != null) {
@ -497,8 +897,8 @@ public class AirepParser {
}
windDirection = new Double(value).intValue(); // windDirection.fromDegree(value);
theElements.set(i, windDirection);
theElements.add(i + 1, windSpeed);
reportElements.set(i, windDirection);
reportElements.add(i + 1, windSpeed);
} catch (Exception nothing) {
String msg = String.format(
"Error decoding winds: [%s] [%s]", windSpd,
@ -519,16 +919,16 @@ public class AirepParser {
* token to the end of the data.
*/
private void decodeMID() {
for (int i = 0; i < theElements.size(); i++) {
Object o = theElements.get(i);
for (int i = 0; i < reportElements.size(); i++) {
Object o = reportElements.get(i);
if (o instanceof String) {
String s = (String) o;
if ("MID".equals(s)) {
AircraftRemarks remarks = new AircraftRemarks(s);
for (i++; i < theElements.size();) {
for (i++; i < reportElements.size();) {
remarks.addRemarks(" ");
remarks.addRemarks((String) theElements.get(i));
theElements.remove(i);
remarks.addRemarks((String) reportElements.get(i));
reportElements.remove(i);
}
rptRemarks = remarks;
}
@ -544,21 +944,24 @@ public class AirepParser {
private void collectRemarks() {
boolean timeFound = false;
int i = 0;
for (; i < theElements.size(); i++) {
Object o = theElements.get(i);
for (; i < reportElements.size(); i++) {
Object o = reportElements.get(i);
if (timeFound = (o instanceof Calendar)) {
i++;
break;
}
} // for
if (timeFound) {
StringBuffer remarksBuffer = new StringBuffer();
for (; i < theElements.size(); i++) {
Object o = theElements.get(i);
// i is pointing to the next element to examine.
for (; i < reportElements.size();) {
Object o = reportElements.get(i);
if (o instanceof String) {
theElements.remove(i);
i--;
reportElements.remove(i);
remarksBuffer.append(o);
remarksBuffer.append(" ");
} else {
i++;
}
} // for
if (remarksBuffer.length() > 0) {
@ -651,6 +1054,15 @@ public class AirepParser {
return temperature;
} // getAirTemperature()
/**
* Get the decoded turbulence data.
*
* @return The decoded turbulence.
*/
public Turbulence getTurbulence() {
return turbulence;
}
public AIREPWeather getWeatherGroup() {
return weatherGroup;
} // getWeatherGroup()
@ -683,24 +1095,4 @@ public class AirepParser {
return (rptRemarks != null) ? rptRemarks.toString() : "";
} // getRemarks()
public static void main(String [] args) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
sdf.setTimeZone(TimeZone.getTimeZone("ZULU"));
Calendar refTime = TimeTools.getBaseCalendar(2011, 12, 14);
refTime.set(Calendar.HOUR_OF_DAY, 17);
refTime.set(Calendar.MINUTE, 15);
refTime.set(Calendar.SECOND, 00);
refTime.set(Calendar.MILLISECOND, 0);
String data = "ARP UAL121 4400N 05700W 1640 F390 MS00 000/099KT TB MOD SK CLEAR=";
AirepParser p = new AirepParser(data,refTime);
System.out.println(sdf.format(p.getObservationTime().getTime()));
data = "ARP UAL121 4400N 05700W 1840 F390 MS00 000/099KT TB MOD SK CLEAR=";
p = new AirepParser(data,refTime);
System.out.println(sdf.format(p.getObservationTime().getTime()));
}
} // AirepParser

View file

@ -0,0 +1,287 @@
/**
* 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 test.airep;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.TimeZone;
import org.junit.Test;
import com.raytheon.edex.plugin.airep.AirepSeparator;
import com.raytheon.edex.plugin.airep.decoder.AirepParser;
import com.raytheon.uf.common.dataplugin.airep.AirepRecord;
import com.raytheon.uf.edex.decodertools.time.TimeTools;
/**
* Various tests against the AirepParser. Extracted some from "mains" that held
* test code.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Sep 7, 2012 jkorman Initial creation
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
public class TestAIREPParser {
public static final String WMO_CRCRLF = "\r\r\n";
public static final String WMO_LEAD = "\01";
public static final String WMO_TRAIL = WMO_CRCRLF + "\03";
public static final int TURB_BIT = 0x80;
@Test
public void testAIREPSeparator() {
String data = WMO_LEAD + WMO_CRCRLF + "205" + WMO_CRCRLF + "UAPA01 KWBC 071554" +
WMO_CRCRLF + "ARP DAL278 3336N 165E 1543 F320 MS40 110/010KT TB 1=" +
WMO_CRCRLF + "ARP PAL110 12N 130E 1544 F370 MS48 090/025KT=" +
WMO_CRCRLF + "ARP UAL595 3746N 08107W 1504 F370 MS46 294/058KT TB LGT RM B752 OV" +
WMO_CRCRLF + " BKW=" + WMO_TRAIL;
String report = null;
AirepSeparator sep = AirepSeparator.separate(data.getBytes(), null);
assertNotNull(sep);
assertTrue(sep.hasNext());
report = sep.next().report;
assertEquals("ARP DAL278 3336N 165E 1543 F320 MS40 110/010KT TB 1",report);
report = sep.next().report;
assertEquals("ARP PAL110 12N 130E 1544 F370 MS48 090/025KT",report);
report = sep.next().report;
assertEquals("ARP UAL595 3746N 08107W 1504 F370 MS46 294/058KT TB LGT RM B752 OV\r BKW",report);
}
@Test
public void testLockup() {
String data = WMO_LEAD + WMO_CRCRLF + "494" + WMO_CRCRLF + "UAUS31 KWBC 112254" +
WMO_CRCRLF + "ARP UAL819 4626N 10618W 2248 F360 TB CONT LGT CHOP RM B752 OV" +
WMO_CRCRLF + " MLS270015=" + WMO_TRAIL;
String report = null;
AirepSeparator sep = AirepSeparator.separate(data.getBytes(), null);
assertNotNull(sep);
assertTrue(sep.hasNext());
AirepParser p = null;
Calendar c = TimeTools.getSystemCalendar(2012, 9, 10, 16, 10);
// The following are in degrees minutes
p = new AirepParser(sep.next().report, c);
assertNotNull(p);
}
/**
* Various forms of location identification.
*/
@Test
public void testPositionDecode() {
AirepParser p = null;
Calendar c = TimeTools.getSystemCalendar(2012, 9, 10, 16, 10);
// The following are in degrees minutes
p = new AirepParser("ARP DAL278 3336N 165E 1543 F320 MS40 110/010KT TB LGT=", c);
assertEquals("DAL278", p.getAircraftId());
assertEquals(33.6, p.getLatitude(), 0.01);
assertEquals(165.0, p.getLongitude(), 0.01);
p = new AirepParser("ARP DAL278 3336N 165W 1543 F320 MS40 110/010KT TB LGT=", c);
assertEquals("DAL278", p.getAircraftId());
assertEquals(33.6, p.getLatitude(), 0.01);
assertEquals(-165.0, p.getLongitude(), 0.01);
p = new AirepParser("ARP DAL278 N3336 E165 1543 F320 MS40 110/010KT TB LGT=", c);
assertEquals("DAL278", p.getAircraftId());
assertEquals(33.6, p.getLatitude(), 0.01);
assertEquals(165.0, p.getLongitude(), 0.01);
p = new AirepParser("ARP DAL278 N3336 W165 1543 F320 MS40 110/010KT TB LGT=", c);
assertEquals("DAL278", p.getAircraftId());
assertEquals(33.6, p.getLatitude(), 0.01);
assertEquals(-165.0, p.getLongitude(), 0.01);
// These are in decimal degrees!
p = new AirepParser("ARP DAL278 N33.36W089.25 1543 F320 MS40 110/010KT TB LGT=", c);
assertEquals("DAL278", p.getAircraftId());
assertEquals(33.36, p.getLatitude(), 0.01);
assertEquals(-89.25, p.getLongitude(), 0.01);
p = new AirepParser("ARP DAL278 33.36N089.25W 1543 F320 MS40 110/010KT TB LGT=", c);
assertEquals("DAL278", p.getAircraftId());
assertEquals(33.36, p.getLatitude(), 0.01);
assertEquals(-89.25, p.getLongitude(), 0.01);
}
/**
* Test various turbulence decoding.
*/
@Test
public void testAIREPParser() {
Calendar c = TimeTools.getSystemCalendar(2012, 9, 10, 16, 10);
AirepParser p = new AirepParser("ARP DAL278 3336N 165E 1543 F320 MS40 110/010KT TB LGT=", c);
AirepParser.Turbulence t = p.getTurbulence();
assertNotNull(t);
assertEquals(0x80 | AirepRecord.TURB_LGT, t.getTurbulence());
p = new AirepParser("ARP DAL278 3336N 165E 1543 F320 MS40 110/010KT TB MOD=", c);
t = p.getTurbulence();
assertNotNull(t);
assertEquals(TURB_BIT | AirepRecord.TURB_MOD, t.getTurbulence());
p = new AirepParser("ARP DAL278 3336N 165E 1543 F320 MS40 110/010KT TB MDT=", c);
t = p.getTurbulence();
assertNotNull(t);
assertEquals(0x40 | TURB_BIT, t.getTurbulence());
p = new AirepParser("ARP DAL278 3336N 165E 1543 F320 MS40 110/010KT TB LGT OCN MDT CAT=", c);
t = p.getTurbulence();
assertNotNull(t);
assertEquals(TURB_BIT | AirepRecord.TURB_MOD | AirepRecord.TURB_TYPE_CAT | AirepRecord.TURB_FREQ_OCN, t.getTurbulence());
p = new AirepParser("ARP DAL278 3336N 165E 1543 F320 MS40 110/010KT TB LGT CAT OCN MDT=", c);
t = p.getTurbulence();
assertNotNull(t);
assertEquals(TURB_BIT | AirepRecord.TURB_MOD | AirepRecord.TURB_TYPE_CAT | AirepRecord.TURB_FREQ_OCN, t.getTurbulence());
p = new AirepParser("ARP DAL278 3336N 165E 1543 F320 MS40 110/010KT TB SVR=", c);
t = p.getTurbulence();
assertNotNull(t);
assertEquals(TURB_BIT | AirepRecord.TURB_SEV, t.getTurbulence());
p = new AirepParser("ARP DAL278 3336N 165E 1543 F320 MS40 110/010KT TB XTRM=", c);
t = p.getTurbulence();
assertNotNull(t);
assertEquals(TURB_BIT | AirepRecord.TURB_XTRM, t.getTurbulence());
p = new AirepParser("ARP HAL4 2714N 14713W 0957 F350 MS46 270/052KT TB 1=", c);
t = p.getTurbulence();
assertNotNull(t);
assertEquals(TURB_BIT | AirepRecord.TURB_LGT, t.getTurbulence());
// Compound turbulence value
p = new AirepParser("ARP UAL761 3825N 11042W 1557 F340 MS44 235/030KT TB LGT-MOD RM\r\r\n A320 OV HVE=", c);
t = p.getTurbulence();
assertNotNull(t);
assertEquals(TURB_BIT | AirepRecord.TURB_LGT_MOD, t.getTurbulence());
// Compound turbulence value
p = new AirepParser("ARP UAL761 3825N 11042W 1557 F340 MS44 235/030KT TB LGTMOD RM\r\r\n A320 OV HVE=", c);
t = p.getTurbulence();
assertNotNull(t);
assertEquals(TURB_BIT | AirepRecord.TURB_LGT_MOD, t.getTurbulence());
// Two adjacent intensities-assume the strongest!
p = new AirepParser("ARP UAL761 3825N 11042W 1557 F340 MS44 235/030KT TB LGT MOD RM\r\r\n A320 OV HVE=", c);
t = p.getTurbulence();
assertNotNull(t);
assertEquals(TURB_BIT | AirepRecord.TURB_MOD, t.getTurbulence());
// Checks that the intensity and frequency is extracted from non-reported data.
p = new AirepParser("ARP UAL761 3825N 11042W 1557 F340 TB OCNL MOD TURBC IN CLOUD TOPS\r\r\n RM A320 OV HVE=", c);
t = p.getTurbulence();
assertNotNull(t);
assertEquals(TURB_BIT | AirepRecord.TURB_MOD | AirepRecord.TURB_FREQ_OCN, t.getTurbulence());
}
@Test
public void testAIREPTimes() {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
sdf.setTimeZone(TimeZone.getTimeZone("ZULU"));
Calendar refTime = TimeTools.getBaseCalendar(2011, 12, 14);
refTime.set(Calendar.HOUR_OF_DAY, 17);
refTime.set(Calendar.MINUTE, 15);
refTime.set(Calendar.SECOND, 00);
refTime.set(Calendar.MILLISECOND, 0);
AirepParser p = new AirepParser("ARP UAL121 4400N 05700W 1640 F390 MS00 000/099KT TB MOD SK CLEAR=",refTime);
Calendar c = p.getObservationTime();
assertNotNull(c);
assertEquals(14, c.get(Calendar.DAY_OF_MONTH));
assertEquals(16, c.get(Calendar.HOUR_OF_DAY));
assertEquals(40, c.get(Calendar.MINUTE));
}
/**
* Test that an observation time greater than the reference time rolls
* back to the previous day.
*/
@Test
public void testAIREPDateRollback() {
Calendar refTime = TimeTools.getBaseCalendar(2011, 12, 14);
refTime.set(Calendar.HOUR_OF_DAY, 17);
refTime.set(Calendar.MINUTE, 15);
refTime.set(Calendar.SECOND, 00);
refTime.set(Calendar.MILLISECOND, 0);
String data = "ARP UAL121 4400N 05700W 1840 F390 MS00 000/099KT TB MOD SK CLEAR=";
AirepParser p = new AirepParser(data,refTime);
Calendar c = p.getObservationTime();
assertNotNull(c);
assertEquals(13, c.get(Calendar.DAY_OF_MONTH));
assertEquals(18, c.get(Calendar.HOUR_OF_DAY));
assertEquals(40, c.get(Calendar.MINUTE));
}
/**
* Test various reported winds
*/
@Test
public void testAIREPWinds() {
Calendar c = TimeTools.getSystemCalendar(2012, 9, 10, 16, 10);
AirepParser p = null;
// Winds with "KT"
p = new AirepParser("ARP DAL278 3336N 165E 1543 F320 MS40 110/010KT TB LGT=", c);
assertNotNull(p);
assertEquals(110, p.getWindDirection());
assertEquals(10, p.getWindSpeed());
// Winds with "KTS"
p = new AirepParser("ARP DAL278 3336N 165E 1543 F320 MS40 265/010KTS TB LGT=", c);
assertNotNull(p);
assertEquals(265, p.getWindDirection());
assertEquals(10, p.getWindSpeed());
// Winds with no units - assume knots
p = new AirepParser("ARP DAL278 3336N 165E 1543 F320 MS40 265/010 TB LGT=", c);
assertNotNull(p);
assertEquals(265, p.getWindDirection());
assertEquals(10, p.getWindSpeed());
}
}

View file

@ -55,6 +55,10 @@ import com.raytheon.uf.edex.wmo.message.WMOHeader;
* ------------ ---------- ----------- --------------------------
* 20080103 384 jkorman Initial Coding.
* 20080219 861 jkorman Clean up javadoc.
* ======================================
* AWIPS2 DR Work
* 20120911 1011 jkorman Changed to handle end of report
* properly.
* </pre>
*
* @author jkorman
@ -66,6 +70,10 @@ public class PirepSeparator extends AbstractRecordSeparator {
private static final String PIREP_HDR = "[\\r\\n]*.*(UA|UUA) +/OV";
private static final String EOR_E = "=";
private static final String EOR_S = ";";
private WMOHeader wmoHeader = null;
private byte[] messageData = null;
@ -183,6 +191,9 @@ public class PirepSeparator extends AbstractRecordSeparator {
} else {
observation = message.substring(bodyRecords.get(i)).trim();
}
if(observation.endsWith(EOR_E) || observation.endsWith(EOR_S)) {
observation = observation.substring(0, observation.length() - 1);
}
reports.add(observation);
}
bodyRecords = null;

View file

@ -24,6 +24,8 @@ import java.util.List;
import org.junit.Test;
import static org.junit.Assert.*;
import com.raytheon.edex.plugin.pirep.PirepSeparator;
import com.raytheon.edex.plugin.pirep.decoder.PirepTools;
import com.raytheon.edex.plugin.pirep.decoder.TEI;
import com.raytheon.edex.plugin.pirep.decoder.TEIInfo;
@ -115,4 +117,26 @@ public class TestTEIInfo {
assertEquals(TEI.WV, parts.get(6).getTei());
}
/**
* Test that "/SKC" does not get confused with the "/SK" TEI.
*/
@Test
public void testNoTurbDecode() {
final String data = "UBUS01 KMSC 061800\nCAO UA /OV DHT310017 /TM 1850 /FL125 /TP BE35 /WX FV30SM /TA 12\n/WV 24021KT /TB NEG=";
PirepSeparator sep = PirepSeparator.separate(data.getBytes(), null);
while(sep.hasNext()) {
List<TEIInfo> parts = TEIInfo.findTEIs(sep.next().getReport());
PirepTools tools = null;
for(TEIInfo info : parts) {
System.out.println(info.getTeiText());
if(TEI.TB.equals(info.getTei())) {
tools = new PirepTools(info.getTeiText());
System.out.println(tools.decodeTurbulenceData());
}
}
}
}
}

View file

@ -68,6 +68,10 @@ import com.vividsolutions.jts.geom.Geometry;
* 20080107 720 jkorman remove default assignments from attributes.
* 20120405 435 dgilling Prevent NullPointerExceptions in
* buildMessageData().
* ======================================
* AWIPS2 DR Work
* 20120911 1011 jkorman Added ability to report turbulence from decoded
* TB group.
* </pre>
*
* @author jkorman
@ -98,6 +102,34 @@ public class AirepRecord extends PluginDataObject implements ISpatialEnabled,
private static final HashMap<String, String> PARM_MAP = new HashMap<String, String>();
public static final int TURB_TYPE_CAT = 0x4;
public static final int TURB_TYPE_CHOP = 0x8;
public static final int TURB_TYPE_LLWS = 0xC;
public static final int TURB_FREQ_OCN = 0x1;
public static final int TURB_FREQ_INT = 0x2;
public static final int TURB_FREQ_CON = 0x3;
public static final int TURB_NEG = 0x00;
public static final int TURB_NEG_LGT = 0x10;
public static final int TURB_LGT = 0x20;
public static final int TURB_LGT_MOD = 0x30;
public static final int TURB_MOD = 0x40;
public static final int TURB_MOD_SEV = 0x50;
public static final int TURB_SEV = 0x60;
public static final int TURB_XTRM = 0x70;
// private static final HashMap<Integer, String> WX_MAP = new
// HashMap<Integer, String>();
@ -121,6 +153,18 @@ public class AirepRecord extends PluginDataObject implements ISpatialEnabled,
// WX_MAP.put(9, "TSRA");
}
private static final HashMap<String, Integer> TURB_MAP = new HashMap<String, Integer>();
static {
TURB_MAP.put("NEG", new Integer(TURB_NEG));
TURB_MAP.put("SMOOTHLGT", new Integer(TURB_NEG_LGT));
TURB_MAP.put("LGT", new Integer(TURB_LGT));
TURB_MAP.put("LGTMOD", new Integer(TURB_LGT_MOD));
TURB_MAP.put("MOD", new Integer(TURB_MOD));
TURB_MAP.put("MODSEV", new Integer(TURB_MOD_SEV));
TURB_MAP.put("SEV", new Integer(TURB_SEV));
TURB_MAP.put("EXTRM", new Integer(TURB_XTRM));
}
@Column
@DynamicSerializeElement
@XmlAttribute
@ -550,13 +594,89 @@ public class AirepRecord extends PluginDataObject implements ISpatialEnabled,
return null;
}
/**
* Get the String representation of various AIREP parameters.
*
* @param The
* parameter value to get.
* @return A String array representing the value. A null reference may be
* returned if the parameter does not exist or cannot be
* represented.
*/
@Override
public String[] getStrings(String paramName) {
String[] retValue = null;
String value = null;
if ("FLT_HZD".matches(paramName) && flightHazard != null) {
String[] flightHazards = { flightHazard.toString() };
return flightHazards;
if (flightHazard != null) {
retValue = new String[] { flightHazard.toString() };
}
} else if ("TBI".matches(paramName) && (flightConditions != null)) {
int turb = flightConditions >> 4;
// Is there turbulence to decode?
if ((turb & 0x80) > 0) {
// get the intensity
switch (turb & 0x70) {
case TURB_NEG: {
value = "NEG";
break;
}
case TURB_NEG_LGT: {
value = "SMOOTHLGT";
break;
}
case TURB_LGT: {
value = "LGT";
break;
}
case TURB_LGT_MOD: {
value = "LGTMOD";
break;
}
case TURB_MOD: {
value = "MOD";
break;
}
case TURB_MOD_SEV: {
value = "MODSEV";
break;
}
case TURB_SEV: {
value = "SEV";
break;
}
case TURB_XTRM: {
value = "EXTRM";
break;
}
}
}
} else if ("TBF".matches(paramName) && (flightConditions != null)) {
int turb = flightConditions >> 4;
// Is there turbulence to decode?
if ((turb & 0x80) > 0) {
// get the intensity
switch (turb & 0x03) {
case TURB_FREQ_OCN: {
value = "OCN";
break;
}
case TURB_FREQ_INT: {
value = "INT";
break;
}
case TURB_FREQ_CON: {
value = "CON";
break;
}
}
}
}
return null;
if (value != null) {
retValue = new String[] { value };
}
return retValue;
}
@Override
@ -622,8 +742,41 @@ public class AirepRecord extends PluginDataObject implements ISpatialEnabled,
messageData.append(windSpeed.intValue());
messageData.append("KT");
}
messageData.append("TB");
if(flightConditions != null) {
int turb = flightConditions >> 4;
if ((turb & 0x80) > 0) {
messageData.append(" TB");
String[] data = getStrings("TBF");
if ((data != null) && (data.length == 1)) {
messageData.append(" ");
messageData.append(data[0]);
}
data = getStrings("TBI");
if ((data != null) && (data.length == 1)) {
messageData.append(" ");
messageData.append(data[0]);
}
String type = null;
switch (turb & 0xC) {
case TURB_TYPE_CAT: {
type = "CAT";
break;
}
case TURB_TYPE_CHOP: {
type = "CHOP";
break;
}
case TURB_TYPE_LLWS: {
type = "LLWS";
break;
}
}
if (type != null) {
messageData.append(" ");
messageData.append(type);
}
}
}
return messageData.toString();
}

View file

@ -21,6 +21,7 @@ package com.raytheon.uf.common.message;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.management.ManagementFactory;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@ -62,8 +63,6 @@ public class StatusMessage implements ISerializableObject, IMessage {
private static final int MAX_MESSAGE_LENGTH = 1024;
private static final String LOCAL = "LOCAL";
/**
* The source of the message
*/
@ -162,7 +161,7 @@ public class StatusMessage implements ISerializableObject, IMessage {
this.category = category;
this.priority = priority;
this.plugin = plugin;
this.setMachine(LOCAL);
this.setMachineToCurrent();
buildMessageAndDetails(message, throwable, this);
}
@ -287,6 +286,13 @@ public class StatusMessage implements ISerializableObject, IMessage {
this.machine = machine;
}
/**
* Set to the current machine.
*/
public void setMachineToCurrent() {
this.machine = ManagementFactory.getRuntimeMXBean().getName();
}
/**
* @return the message
*/
@ -405,7 +411,6 @@ public class StatusMessage implements ISerializableObject, IMessage {
@Override
public String toString() {
Priority p = getPriority();
String statusMsg = getMessage();
String detailsMsg = getDetails();
boolean useBothMsgs = detailsMsg.length() > statusMsg.length();

View file

@ -237,7 +237,7 @@ public class EDEXUtil implements ApplicationContextAware {
sm.setPlugin(pluginName);
sm.setCategory(category);
sm.setMessage(message);
sm.setMachine(Integer.toString(getServerId()));
sm.setMachineToCurrent();
sm.setSourceKey(source);
sm.setDetails(details);
sm.setEventTime(new Date());