jmri.jmrix.loconet.hexfile
Class LnHexFilePort

Show UML class diagram
java.lang.Object
  extended by jmri.jmrix.AbstractPortController
      extended by jmri.jmrix.AbstractSerialPortController
          extended by jmri.jmrix.loconet.LnPortController
              extended by jmri.jmrix.loconet.hexfile.LnHexFilePort
All Implemented Interfaces:
Runnable, PortAdapter, SerialPortAdapter

public class LnHexFilePort
extends LnPortController
implements Runnable, SerialPortAdapter

LnHexFilePort implements a LnPortController via a ASCII-hex input file. See below for the file format There are user-level controls for send next message how long to wait between messages An object of this class should run in a thread of its own so that it can fill the output pipe as needed. The input file is expected to have one message per line. Each line can contain as many bytes as needed, each represented by two Hex characters and separated by a space. Variable whitespace is not (yet) supported


Nested Class Summary
 
Nested classes/interfaces inherited from class jmri.jmrix.AbstractPortController
AbstractPortController.Option
 
Field Summary
(package private) static org.slf4j.Logger log
           
(package private)  BufferedReader sFile
           
 
Fields inherited from class jmri.jmrix.loconet.LnPortController
adaptermemo, commandStationName, commandStationNames, mCanRead, mProgPowersOff, mTurnoutExtraSpace, mTurnoutNoRetry
 
Fields inherited from class jmri.jmrix.AbstractSerialPortController
mBaudRate, mPort
 
Fields inherited from class jmri.jmrix.AbstractPortController
allowConnectionRecovery, mDisabled, mManufacturer, opened, option1Name, option2Name, option3Name, option4Name, options, reconnectinterval, retryAttempts
 
Constructor Summary
LnHexFilePort()
           
 
Method Summary
 void configure()
          Configure all of the other jmrix widgets needed to work with this adapter
 void configureOption3(String value)
          Set the third port option.
 void connect()
          Open the connection
 void dispose()
           
 LocoNetSystemConnectionMemo getAdapterMemo()
           
 DataInputStream getInputStream()
           
 DataOutputStream getOutputStream()
           
 Vector<String> getPortNames()
          Provide a vector of valid port names, each a String.
 LocoNetSystemConnectionMemo getSystemConnectionMemo()
           
 void load(File file)
           
 boolean okToSend()
          Can the port accept additional characters?
 String openPort(String portName, String appName)
          Open a specified port.
 String option3Name()
          Get a String that says what Option 3 represents May be an empty string, but will not be null
 void run()
           
 boolean running()
           
 void setDelay(int newDelay)
          Provide a new message delay value, but don't allow it to go below 2 msec.
 boolean status()
          Check that this object is ready to operate.
 String[] validBaudRates()
          Get an array of valid baud rates; used to display valid options.
 String[] validOption3()
          Get an array of valid values for "option 3"; used to display valid options.
 
Methods inherited from class jmri.jmrix.loconet.LnPortController
setCommandStationType, setDisabled, setTurnoutHandling
 
Methods inherited from class jmri.jmrix.AbstractSerialPortController
closeConnection, configureBaudRate, currentBaudNumber, getCurrentBaudRate, getCurrentPortName, handlePortBusy, handlePortNotFound, reconnect, recover, resetupConnection, setPort, validBaudNumber
 
Methods inherited from class jmri.jmrix.AbstractPortController
configureOption1, configureOption2, configureOption4, getDisabled, getManufacturer, getOption1Name, getOption2Name, getOption3Name, getOption4Name, getOptionChoices, getOptionDisplayName, getOptions, getOptionState, isOptionAdvanced, safeSleep, setClosed, setManufacturer, setOpened, setOptionState
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface jmri.jmrix.SerialPortAdapter
configureBaudRate, configureOption1, configureOption2, configureOption4, getCurrentBaudRate, getCurrentPortName, getManufacturer, handlePortBusy, setManufacturer, setPort
 
Methods inherited from interface jmri.jmrix.PortAdapter
getDisabled, getOption1Name, getOption2Name, getOption3Name, getOption4Name, getOptionChoices, getOptionDisplayName, getOptions, getOptionState, isOptionAdvanced, recover, setDisabled, setOptionState
 

Field Detail

sFile

BufferedReader sFile

log

static org.slf4j.Logger log
Constructor Detail

LnHexFilePort

public LnHexFilePort()
Method Detail

load

public void load(File file)

connect

public void connect()
             throws Exception
Description copied from interface: PortAdapter
Open the connection

Specified by:
connect in interface PortAdapter
Overrides:
connect in class AbstractSerialPortController
Throws:
Exception

run

public void run()
Specified by:
run in interface Runnable

setDelay

public void setDelay(int newDelay)
Provide a new message delay value, but don't allow it to go below 2 msec.


getInputStream

public DataInputStream getInputStream()
Specified by:
getInputStream in interface PortAdapter
Specified by:
getInputStream in class LnPortController

getOutputStream

public DataOutputStream getOutputStream()
Specified by:
getOutputStream in interface PortAdapter
Specified by:
getOutputStream in class LnPortController

status

public boolean status()
Description copied from class: LnPortController
Check that this object is ready to operate. This is a question of configuration, not transient hardware status.

Specified by:
status in interface PortAdapter
Specified by:
status in interface SerialPortAdapter
Specified by:
status in class LnPortController

running

public boolean running()

okToSend

public boolean okToSend()
Description copied from class: LnPortController
Can the port accept additional characters? This might go false for short intervals, but it might also stick off if something goes wrong.

Provide a default implementation for the MS100, etc, in which this is _always_ true, as we rely on the queueing in the port itself.

Overrides:
okToSend in class LnPortController

getPortNames

public Vector<String> getPortNames()
Description copied from interface: SerialPortAdapter
Provide a vector of valid port names, each a String.

Specified by:
getPortNames in interface SerialPortAdapter
Overrides:
getPortNames in class AbstractSerialPortController

openPort

public String openPort(String portName,
                       String appName)
Description copied from interface: SerialPortAdapter
Open a specified port. The appname argument is to be provided to the underlying OS during startup so that it can show on status displays, etc

Specified by:
openPort in interface SerialPortAdapter

configure

public void configure()
Description copied from interface: SerialPortAdapter
Configure all of the other jmrix widgets needed to work with this adapter

Specified by:
configure in interface PortAdapter
Specified by:
configure in interface SerialPortAdapter

validBaudRates

public String[] validBaudRates()
Description copied from interface: SerialPortAdapter
Get an array of valid baud rates; used to display valid options.

Specified by:
validBaudRates in interface SerialPortAdapter

validOption3

public String[] validOption3()
Get an array of valid values for "option 3"; used to display valid options. May not be null, but may have zero entries


option3Name

public String option3Name()
Get a String that says what Option 3 represents May be an empty string, but will not be null


configureOption3

public void configureOption3(String value)
Set the third port option. Only to be used after construction, but before the openPort call

Specified by:
configureOption3 in interface PortAdapter
Specified by:
configureOption3 in interface SerialPortAdapter
Overrides:
configureOption3 in class AbstractPortController

dispose

public void dispose()
Specified by:
dispose in interface PortAdapter
Overrides:
dispose in class AbstractSerialPortController

getAdapterMemo

public LocoNetSystemConnectionMemo getAdapterMemo()

getSystemConnectionMemo

public LocoNetSystemConnectionMemo getSystemConnectionMemo()
Specified by:
getSystemConnectionMemo in interface PortAdapter
Overrides:
getSystemConnectionMemo in class AbstractSerialPortController


Copyright © 1997-2013 JMRI Community.
JMRI, DecoderPro, PanelPro, SoundPro, DispatcherPro and associated logos are our trademarks.

Additional information on copyright, trademarks and licenses is linked here.
Site hosted by: Get JMRI Model Railroad Interface at SourceForge.net. Fast, secure and Free Open Source software downloads