示例#1
0
        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);
        }
示例#2
0
        public ComPort this[ComPortHandle portHandle]
        {
            get
            {
                if (Exists(portHandle) == false)
                {
                    throw new ArgumentException("ComPort " + portHandle + " does not exist.");
                }

                return(_ports[portHandle]);
            }
        }
示例#3
0
        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);
        }
示例#4
0
 internal ComPortNull(ComPortHandle handle)
 {
     this.ComPortHandle = handle;
 }
示例#5
0
 private bool Exists(ComPortHandle handle)
 {
     return(_ports.ContainsKey(handle) && ((_ports[handle] is ComPortNull) == false));
 }
示例#6
0
 private ComPort GetComPort(int nativeHandle)
 {
     return(this.Emulator.ComPortCollection.DeviceGet(ComPortHandle.ConvertFromNative(nativeHandle)));
 }