001package jmri.jmrix.dccpp.serial;
002
003import jmri.util.SystemType;
004
005/**
006 * Handle configuring a DCC++ layout connection via a Serial adaptor.
007 * <p>
008 * This uses the {@link DCCppAdapter} class to do the actual connection.
009 *
010 * @author Mark Underwood Copyright (C) 2015
011 *
012 * @see DCCppAdapter
013 *
014 * Based on jmri.jmrix.lenz.liusb.ConnectionConfig by Paul Bender
015 */
016public class ConnectionConfig extends jmri.jmrix.dccpp.AbstractDCCppSerialConnectionConfig {
017
018    /**
019     * Ctor for an object being created during load process; Swing init is
020     * deferred.
021     * @param p serial port adapter.
022     */
023    public ConnectionConfig(jmri.jmrix.SerialPortAdapter p) {
024        super(p);
025    }
026
027    /**
028     * Ctor for a connection configuration with no preexisting adapter.
029     * {@link #setInstance()} will fill the adapter member.
030     */
031    public ConnectionConfig() {
032        super();
033    }
034
035    @Override
036    public String name() {
037        return "DCC++ Serial Port";
038    }
039
040    @Override
041    protected String[] getPortFriendlyNames() {
042        if (SystemType.isWindows()) {
043            return new String[]{"DCC++ Serial Port", "DCC++_Serial"};
044        }
045        return new String[]{};
046    }
047
048    /**
049     * {@inheritDoc}
050     */
051    @Override
052    protected void setInstance() {
053        if (adapter == null) {
054            adapter = new DCCppAdapter();
055        }
056    }
057
058}