001package jmri.jmrix.roco.z21;
002
003import java.io.DataInputStream;
004import java.io.DataOutputStream;
005import jmri.jmrix.loconet.LnCommandStationType;
006import jmri.jmrix.loconet.LocoNetSystemConnectionMemo;
007
008/**
009 * Override default LocoNet classes to use z21 specific versions.
010 *
011 * @author Paul Bender Copyright (C) 2018
012 */
013public class Z21LnStreamPortController extends jmri.jmrix.loconet.streamport.LnStreamPortController {
014
015    public Z21LnStreamPortController(LocoNetSystemConnectionMemo connectionMemo, DataInputStream in, DataOutputStream out, String pname) {
016        super(connectionMemo, in, out, pname);
017    }
018
019    /**
020     * Set up all of the other objects to operate with a LocoNet connected via
021     * this class.
022     */
023    @Override
024    public void configure() {
025
026        // hardcode options for now
027        setCommandStationType(LnCommandStationType.COMMAND_STATION_STANDALONE);
028        setTurnoutHandling("");
029        setInterrogateOnStart("No");  // same default as turnout handling
030        // connect to a packetizing traffic controller
031        Z21LnStreamPortPacketizer packets = new Z21LnStreamPortPacketizer(this.getSystemConnectionMemo());
032        packets.connectPort(this);
033
034        // setup memo
035        this.getSystemConnectionMemo().setLnTrafficController(packets);
036        // do the common manager config
037        this.getSystemConnectionMemo().configureCommandStation(commandStationType,
038                mTurnoutNoRetry, mTurnoutExtraSpace, false, mInterrogateAtStart, false); // never transponding or Xp slots
039        this.getSystemConnectionMemo().configureManagers();
040
041        // start operation
042        packets.startThreads();
043    }
044
045    @Override
046    public void dispose(){
047        this.getSystemConnectionMemo().dispose();
048        super.dispose();
049    }
050
051}