001package jmri.jmrix.easydcc.networkdriver;
002
003import java.net.Socket;
004import jmri.jmrix.easydcc.EasyDccNetworkPortController;
005import jmri.jmrix.easydcc.EasyDccSystemConnectionMemo;
006import org.slf4j.Logger;
007import org.slf4j.LoggerFactory;
008
009/**
010 * Implements NetworkDriverAdapter for the EasyDCC system connection.
011 * <p>
012 * This connects an EasyDCC command station via a telnet connection.
013 * Normally controlled by the NetworkDriverFrame class.
014 *
015 * @author Bob Jacobsen Copyright (C) 2001, 2002, 2003
016 */
017public class NetworkDriverAdapter extends EasyDccNetworkPortController {
018
019    public NetworkDriverAdapter() {
020        super(new EasyDccSystemConnectionMemo("E", "EasyDCC via Network")); // pass customized user name
021    }
022
023    /**
024     * Set up all of the other objects to operate with an EasyDCC command
025     * station connected to this port.
026     */
027    @Override
028    public void configure() {
029        // connect to the traffic controller, which is provided via the memo
030        log.debug("set tc for memo {}", getSystemConnectionMemo().getUserName());
031
032        getSystemConnectionMemo().getTrafficController().connectPort(this);
033
034        // do the common manager config
035        getSystemConnectionMemo().configureManagers();
036    }
037
038    @Override
039    public boolean status() {
040        return opened;
041    }
042
043    // private control members
044    private boolean opened = false;
045
046    Socket socket;
047
048    private final static Logger log = LoggerFactory.getLogger(NetworkDriverAdapter.class);
049
050}