001package jmri.jmrix.roco.z21; 002 003import jmri.jmrix.AbstractMRReply; 004import jmri.jmrix.lenz.XNetInitializationManager; 005 006import java.io.DataInputStream; 007import java.io.DataOutputStream; 008 009/** 010 * Override default XpressNet classes to use z21 specific versions. 011 * 012 * @author Paul Bender Copyright (C) 2004, 2010, 2014 013 */ 014public class Z21XNetStreamPortController extends jmri.jmrix.lenz.XNetStreamPortController { 015 016 public Z21XNetStreamPortController(DataInputStream in, DataOutputStream out, String pname) { 017 super(in, out, pname); 018 } 019 020 @Override 021 public void configure() { 022 // connect to a packetizing traffic controller 023 jmri.jmrix.lenz.XNetTrafficController packets = new Z21XNetPacketizer(new jmri.jmrix.lenz.LenzCommandStation()){ 024 @Override 025 protected AbstractMRReply newReply() { 026 return new Z21XNetReply(); 027 } 028 @Override 029 protected void terminate() { 030 // This overrides the default Lenz behavior of turning the power back on 031 // by deliberately doing nothing. 032 } 033 }; 034 packets.connectPort(this); 035 036 this.getSystemConnectionMemo().setXNetTrafficController(packets); 037 this.getSystemConnectionMemo().setThrottleManager(new Z21XNetThrottleManager(this.getSystemConnectionMemo())); 038 039 new XNetInitializationManager() 040 .memo(this.getSystemConnectionMemo()) 041 .setDefaults() 042 .throttleManager(Z21XNetThrottleManager.class) 043 .programmer(Z21XNetProgrammer.class) 044 .programmerManager(Z21XNetProgrammerManager.class) 045 .turnoutManager(Z21XNetTurnoutManager.class) 046 .consistManager(null) 047 .noCommandStation() 048 .init(); 049 jmri.jmrix.ConnectionStatus.instance().setConnectionState(getUserName(), getCurrentPortName(),jmri.jmrix.ConnectionStatus.CONNECTION_UP); 050 } 051 052 @Override 053 public void dispose() { 054 jmri.jmrix.lenz.XNetTrafficController packets = this.getSystemConnectionMemo().getXNetTrafficController(); 055 this.getSystemConnectionMemo().dispose(); 056 packets.terminateThreads(); 057 super.dispose(); 058 } 059 060}