internal override void RegisterInternal(EmulatorComponent ec) { VerifyAccess(); ComPort comPort = ec as ComPort; if (comPort == null) { throw new Exception("Attempt to register a non ComPort with ComPortCollection."); } ComPortHandle handle = comPort.ComPortHandle; Debug.Assert(!(comPort is ComPortNull)); if (Exists(handle)) { throw new Exception("Duplicate " + handle + " ComPorts found."); } _ports[handle] = comPort; _validPorts.Add(comPort); base.RegisterInternal(ec); }
public ComPort this[ComPortHandle portHandle] { get { if (Exists(portHandle) == false) { throw new ArgumentException("ComPort " + portHandle + " does not exist."); } return(_ports[portHandle]); } }
internal ComPort DeviceGet(ComPortHandle portHandle) { ComPort port; if (_ports.TryGetValue(portHandle, out port) == false) { port = new ComPortNull(portHandle); _ports.Add(portHandle, port); } if (port is ComPortNull && portHandle.TransportType != TransportType.Debug) { ComPortNull nullPort = (ComPortNull)port; if (nullPort.DisplayWarning || Emulator.Verbose) { Trace.WriteLine("Warning: System attempts to access COM Port " + portHandle + " that was not configured."); nullPort.TurnOffWarning(); } } return(port); }
internal ComPortNull(ComPortHandle handle) { this.ComPortHandle = handle; }
private bool Exists(ComPortHandle handle) { return(_ports.ContainsKey(handle) && ((_ports[handle] is ComPortNull) == false)); }
private ComPort GetComPort(int nativeHandle) { return(this.Emulator.ComPortCollection.DeviceGet(ComPortHandle.ConvertFromNative(nativeHandle))); }