001package jmri.jmrix.purejavacomm; 002 003import jmri.SystemConnectionMemo; 004import jmri.jmrix.AbstractSerialPortController; 005 006/** 007 * Comm port identifier. 008 */ 009public class CommPortIdentifier { 010 011 private final String _portName; 012 013 private CommPortIdentifier(String portName) { 014 this._portName = portName; 015 } 016 017 public static CommPortIdentifier getPortIdentifier(String portName) throws NoSuchPortException { 018 return new CommPortIdentifier(portName); 019 } 020 021 public SerialPort open(SystemConnectionMemo memo, int timeout) throws PortInUseException, NoSuchPortException { 022 jmri.jmrix.SerialPort serialPort = AbstractSerialPortController.activatePort( 023 memo, _portName, log, 1, jmri.jmrix.SerialPort.Parity.NONE); 024 025 if (serialPort != null) { 026 return new SerialPort(serialPort); 027 } else { 028 throw new NoSuchPortException(); 029 } 030 } 031 032 private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(CommPortIdentifier.class); 033}