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

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