001package jmri.jmrix.nce.networkdriver;
002
003import jmri.jmrix.nce.NceNetworkPortController;
004import jmri.jmrix.nce.NceSystemConnectionMemo;
005import jmri.jmrix.nce.NceTrafficController;
006
007/**
008 * Implements SerialPortAdapter for the NCE system network connection.
009 * <p>
010 * This connects an NCE command station via a telnet connection. Normally
011 * controlled by the NetworkDriverFrame class.
012 *
013 * @author Bob Jacobsen Copyright (C) 2001, 2002, 2003
014 */
015public class NetworkDriverAdapter extends NceNetworkPortController {
016
017    public NetworkDriverAdapter() {
018        super(new NceSystemConnectionMemo());
019        option2Name = "Eprom";
020        // the default is 2006 or later
021        options.put(option2Name, new Option("Command Station EPROM", new String[]{"2006 or later", "2004 or earlier"}));
022        setManufacturer(jmri.jmrix.nce.NceConnectionTypeList.NCE);
023    }
024
025    /**
026     * set up all of the other objects to operate with an NCE command station
027     * connected to this port
028     */
029    @Override
030    public void configure() {
031        NceTrafficController tc = new NceTrafficController();
032        this.getSystemConnectionMemo().setNceTrafficController(tc);
033        tc.setAdapterMemo(this.getSystemConnectionMemo());
034
035        // set the command options, Note that the NetworkDriver uses
036        // the second option for EPROM revision
037        if (getOptionState(option2Name).equals(getOptionChoices(option2Name)[0])) {
038            // setting binary mode
039            this.getSystemConnectionMemo().configureCommandStation(NceTrafficController.OPTION_2006);
040            this.getSystemConnectionMemo().setNceCmdGroups(~NceTrafficController.CMDS_USB);
041        } else {
042            this.getSystemConnectionMemo().configureCommandStation(NceTrafficController.OPTION_2004);
043            this.getSystemConnectionMemo().setNceCmdGroups(~NceTrafficController.CMDS_USB);
044        }
045
046        tc.connectPort(this);
047
048        this.getSystemConnectionMemo().configureManagers();
049    }
050
051}