wonderly.jeaprs.aprs
Class APRSDigi

java.lang.Object
  |
  +--wonderly.jeaprs.ClientImpl
        |
        +--wonderly.jeaprs.aprs.APRSDigi
All Implemented Interfaces:
Client, java.lang.Runnable

public class APRSDigi
extends ClientImpl
implements java.lang.Runnable

This is a Digipeating module meant to be used for KISS enabled TNCs. When the TNC is not in KISS mode, then this module will work in a since. It will rewrite the path, to remove used path elements, and then forward the packet with the remaining path. It rewrites WIDEN-n and TRACEN-n paths stripping any leading elements and then goes on to decrement the count. This module still needs work and really has never been used on a true KISS TNC.

Version:
1.0
Author:
Gregg Wonderly The information contained in this document is Copyright 2001-2003, Gregg Wonderly, all rights reserved.

Field Summary
 
Fields inherited from class wonderly.jeaprs.ClientImpl
actions, APRS, dirty, evLis, ins, me, name, outs, stopped, strmLis
 
Constructor Summary
APRSDigi()
           
 
Method Summary
 void buildActions()
          Put code in here to register all of the actions that you want to use.
 javax.swing.JPanel buildPanel(javax.swing.JFrame parent)
          Builds the applications user interface.
 wonderly.jeaprs.aprs.packet.APRSEventListener createEventListener()
          This method needs to be implemented by subclasses and should return an APRSEventListener implementation that is applicable for their client.
 java.io.OutputStream createStreamListener()
          This method needs to be implemented by subclasses and should return an OutputStream implementation that is applicable for their client.
protected  void digiPacket(wonderly.jeaprs.aprs.packet.APRSPacket pkt)
           
 java.lang.String getIgnoredCalls()
           
protected  boolean haveHeard(wonderly.jeaprs.aprs.packet.APRSPacket pkt)
           
 boolean isDigiActive()
           
 boolean isDirty()
           
 boolean isRelay()
           
 boolean isWaveAt()
           
 boolean isWide()
           
protected  java.lang.String keyFor(wonderly.jeaprs.aprs.packet.APRSPacket pkt)
           
static void main(java.lang.String[] args)
           
 void run()
           
 void setDigiActive(boolean how)
           
 void setIgnoredCalls(java.lang.String ignored)
           
 void setRelay(boolean how)
           
 void setWaveAt(boolean how)
           
 void setWide(boolean how)
           
 void start()
          Starts this client 'running' or whatever it needs when the user opens the client via the menus.
 void stop()
          Stops the client when the user closes the window or deactivates it via the menus
 
Methods inherited from class wonderly.jeaprs.ClientImpl
addAPRSEventGenerator, addAPRSOutputStream, buildMenu, getAction, getAPRSEventGenerators, getAPRSOutputStreams, getName, getUIFactory, isInputUser, isOutputUser, removeAPRSEventGenerator, removeAPRSOutputStream, setDirty, setName, toString, write, write, write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

APRSDigi

public APRSDigi()
Method Detail

start

public void start()
Description copied from class: ClientImpl
Starts this client 'running' or whatever it needs when the user opens the client via the menus.

Specified by:
start in interface Client
Overrides:
start in class ClientImpl

isDigiActive

public boolean isDigiActive()

setDigiActive

public void setDigiActive(boolean how)

isRelay

public boolean isRelay()

setRelay

public void setRelay(boolean how)

isWide

public boolean isWide()

setWide

public void setWide(boolean how)

isWaveAt

public boolean isWaveAt()

setWaveAt

public void setWaveAt(boolean how)

getIgnoredCalls

public java.lang.String getIgnoredCalls()

setIgnoredCalls

public void setIgnoredCalls(java.lang.String ignored)

stop

public void stop()
Description copied from class: ClientImpl
Stops the client when the user closes the window or deactivates it via the menus

Specified by:
stop in interface Client
Overrides:
stop in class ClientImpl

createStreamListener

public java.io.OutputStream createStreamListener()
Description copied from class: ClientImpl
This method needs to be implemented by subclasses and should return an OutputStream implementation that is applicable for their client. This stream will be written to as data comes through a TNC implementatation, receiving copies of the text lines received by the TNC implementation. A simple mechanism is typically to use a thread and a PipedInputStream and PipedOutputStream pair to receive the data and process it. Just return null if you don't need raw stream events.
	public OutputStream createStreamListener() throws IOException {
		final PipedOutputStream pipe = new PipedOutputStream();
		final PipedInputStream is = new PipedInputStream(pipe);
		new Thread("TNC Stream listener") {
			public void run() {
				try {
					BufferedReader rd = new BufferedReader( new InputStreamReader(is) );
					String str;
					while( (str = rd.readLine()) != null ) {
						System.out.println( "Got TNC line: "+str );
					}
					System.out.println("End of TNC Stream, exiting");
				} finally {
					try {
						is.close();
						pipe.close();
					} catch( Exception ex ) {
						JeAPRS.getUI().reportException(ex);
					}
				}
			}
		}.start();
		return pipe;
	}
	

Specified by:
createStreamListener in class ClientImpl

main

public static void main(java.lang.String[] args)

haveHeard

protected boolean haveHeard(wonderly.jeaprs.aprs.packet.APRSPacket pkt)

keyFor

protected java.lang.String keyFor(wonderly.jeaprs.aprs.packet.APRSPacket pkt)

digiPacket

protected void digiPacket(wonderly.jeaprs.aprs.packet.APRSPacket pkt)

createEventListener

public wonderly.jeaprs.aprs.packet.APRSEventListener createEventListener()
Description copied from class: ClientImpl
This method needs to be implemented by subclasses and should return an APRSEventListener implementation that is applicable for their client. Many times, a simple inner class is all that is needed as in.
  return new APRSEventAdapter() {
		public void message( APRSPacket pkt, APRSMessage msg ) {
			// Do something with message
		}
	};
	
This will create a new object that is an instance of the APRSEventAdapter class. That class implements the APRSEventListener interface with empty methods so that you can just override the methods that you want APRS packets for, and not have to deal with implementing all methods. Just return null here if you don't need an event listener.

Specified by:
createEventListener in class ClientImpl
See Also:
APRSEventAdapter, APRSEventListener

run

public void run()
Specified by:
run in interface java.lang.Runnable

isDirty

public boolean isDirty()
Specified by:
isDirty in interface Client
Overrides:
isDirty in class ClientImpl
Returns:
true if properties of client have changed and need to be saved

buildPanel

public javax.swing.JPanel buildPanel(javax.swing.JFrame parent)
Description copied from class: ClientImpl
Builds the applications user interface. The returned panel should contain all of the controls needed to provide the user with convienent access to the features of this client/module, except for a menu bar. The buildMenu() method can be used to create a menu bar if neededed.

Specified by:
buildPanel in class ClientImpl
See Also:
ClientImpl.buildMenu()

buildActions

public void buildActions()
Description copied from class: ClientImpl
Put code in here to register all of the actions that you want to use.
                actions.put(  "MyAction", act = new AbstractAction( "MyAction" ) {
                        public void actionPerformed( ActionEvent ev ) {
                                //...do something here
                        }
                });
                act.putValue( Action.NAME, "MyAction" );
 

Specified by:
buildActions in class ClientImpl
See Also:
ClientImpl.getAction(String)