001package jmri.jmrix.loconet.pr2; 002 003import jmri.jmrix.loconet.locobuffer.LocoBufferAdapter; 004import org.slf4j.Logger; 005import org.slf4j.LoggerFactory; 006 007/** 008 * Update the code in jmri.jmrix.loconet.locobuffer so that it refers to the 009 * switch settings on the new Digitrax PR2 010 * 011 * @author Bob Jacobsen Copyright (C) 2004, 2005, 2006 012 */ 013public class PR2Adapter extends LocoBufferAdapter { 014 015 public PR2Adapter() { 016 super(new PR2SystemConnectionMemo()); 017 018 options.remove(option2Name); 019 options.put(option2Name, new Option(Bundle.getMessage("CommandStationTypeLabel"), commandStationOptions(), false)); 020 } 021 022 @Override 023 protected void reportOpen(String portName) { 024 log.info("Connecting PR2 via {} {}", portName, currentSerialPort); 025 } 026 027 /** 028 * Set up all of the other objects to operate with a PR2 connected to this 029 * port. This overrides the version in loconet.locobuffer, but it has to 030 * duplicate much of the functionality there, so the code is basically 031 * copied. 032 */ 033 @Override 034 public void configure() { 035 036 setCommandStationType(getOptionState(option2Name)); 037 setTurnoutHandling(getOptionState(option3Name)); 038 039 // connect to a packetizing traffic controller 040 // that does echoing 041 jmri.jmrix.loconet.pr2.LnPr2Packetizer packets = new jmri.jmrix.loconet.pr2.LnPr2Packetizer(); 042 packets.connectPort(this); 043 044 // create memo 045 this.getSystemConnectionMemo().setLnTrafficController(packets); 046 // do the common manager config 047 this.getSystemConnectionMemo().configureCommandStation(commandStationType, 048 mTurnoutNoRetry, mTurnoutExtraSpace, mTranspondingAvailable, mInterrogateAtStart, mLoconetProtocolAutoDetect); 049 this.getSystemConnectionMemo().configureManagers(); 050 051 // start operation 052 packets.startThreads(); 053 } 054 055 /** 056 * {@inheritDoc} 057 */ 058 @Override 059 public String[] validBaudRates() { 060 return new String[]{"57,600 baud"}; // NOI18N 061 } 062 063 /** 064 * {@inheritDoc} 065 */ 066 @Override 067 public int[] validBaudNumbers() { 068 return new int[]{57600}; 069 } 070 071 @Override 072 public int defaultBaudIndex() { 073 return 0; 074 } 075 076 // Option 1 does flow control, inherited from LocoBufferAdapter 077 078 /** 079 * The PR2 has one mode 080 * @return a String[] containing appropriate options 081 */ 082 public String[] commandStationOptions() { 083 return new String[]{jmri.jmrix.loconet.LnCommandStationType.COMMAND_STATION_PR2_ALONE.getName()}; 084 } 085 086 private final static Logger log = LoggerFactory.getLogger(PR2Adapter.class); 087}