001package jmri.jmrix.dccpp;
002
003import java.io.DataInputStream;
004import java.io.DataOutputStream;
005
006/**
007 * Abstract base for classes representing a DCCpp communications port
008 *
009 * @author Bob Jacobsen Copyright (C) 2001, 2008
010 * @author Paul Bender Copyright (C) 2004,2010,2014
011 * @author Mark Underwood Copyright (C) 2015
012 */
013public class DCCppStreamPortController extends jmri.jmrix.AbstractStreamPortController implements DCCppPortController {
014
015    public DCCppStreamPortController(DataInputStream in, DataOutputStream out, String pname) {
016        super(new DCCppSystemConnectionMemo(), in, out, pname);
017    }
018
019    public DCCppStreamPortController() {
020        super(new DCCppSystemConnectionMemo());
021    }
022
023    @Override
024    public void configure() {
025        // connect to a packetizing traffic controller
026        DCCppTrafficController packets = new DCCppPacketizer(new DCCppCommandStation());
027        packets.connectPort(this);
028
029        this.getSystemConnectionMemo().setDCCppTrafficController(packets);
030
031        new DCCppInitializationManager(this.getSystemConnectionMemo());
032    }
033
034    @Override
035    public DCCppSystemConnectionMemo getSystemConnectionMemo() {
036        return (DCCppSystemConnectionMemo) super.getSystemConnectionMemo();
037    }
038
039    /**
040     * Check that this object is ready to operate. This is a question of
041     * configuration, not transient hardware status.
042     */
043    @Override
044    public boolean status() {
045        return true;
046    }
047
048    /**
049     * Can the port accept additional characters?
050     */
051    @Override
052    public boolean okToSend() {
053        return (true);
054    }
055
056    /**
057     * we need a way to say if the output buffer is empty or full this should
058     * only be set to false by external processes
059     *
060     */
061    @Override
062    synchronized public void setOutputBufferEmpty(boolean s) {
063    }
064
065}
066
067
068