90 lines
2.2 KiB
Java
90 lines
2.2 KiB
Java
package jmri.jmrix;
|
|
|
|
import java.io.DataInputStream;
|
|
import java.io.DataOutputStream;
|
|
import java.io.PipedInputStream;
|
|
import java.io.PipedOutputStream;
|
|
|
|
import jmri.SystemConnectionMemo;
|
|
|
|
/**
|
|
* Scaffold for port controller objects.
|
|
*
|
|
* @author Paul Bender Copyright (C) 2016
|
|
*/
|
|
|
|
public class AbstractSerialPortControllerScaffold extends AbstractSerialPortController {
|
|
|
|
DataOutputStream ostream; // Traffic controller writes to this
|
|
public DataInputStream tostream; // so we can read it from this
|
|
|
|
public DataOutputStream tistream; // tests write to this
|
|
DataInputStream istream; // so the traffic controller can read from this
|
|
|
|
@Override
|
|
public void configure() {
|
|
}
|
|
|
|
@Override
|
|
public String getCurrentPortName() {
|
|
return("testport");
|
|
}
|
|
|
|
@Override
|
|
public void recover(){
|
|
}
|
|
|
|
@Override
|
|
public void connect(){
|
|
}
|
|
|
|
public AbstractSerialPortControllerScaffold(SystemConnectionMemo connectionMemo) throws Exception {
|
|
super(connectionMemo);
|
|
PipedInputStream tempPipe;
|
|
tempPipe = new PipedInputStream();
|
|
tostream = new DataInputStream(tempPipe);
|
|
ostream = new DataOutputStream(new PipedOutputStream(tempPipe));
|
|
tempPipe = new PipedInputStream();
|
|
istream = new DataInputStream(tempPipe);
|
|
tistream = new DataOutputStream(new PipedOutputStream(tempPipe));
|
|
}
|
|
|
|
// returns the InputStream from the port
|
|
@Override
|
|
public DataInputStream getInputStream() {
|
|
return istream;
|
|
}
|
|
|
|
// returns the outputStream to the port
|
|
@Override
|
|
public DataOutputStream getOutputStream() {
|
|
return ostream;
|
|
}
|
|
|
|
// check that this object is ready to operate
|
|
@Override
|
|
public boolean status() {
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public String[] validBaudRates(){
|
|
return new String[]{"9600"};
|
|
}
|
|
|
|
@Override
|
|
public int[] validBaudNumbers() {
|
|
return new int[]{9600};
|
|
}
|
|
|
|
/**
|
|
* 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.
|
|
*/
|
|
@Override
|
|
public String openPort(String portName, String appName){
|
|
return "";
|
|
}
|
|
|
|
}
|