/// <summary> /// 添加一个IO端口类BaseIOPort实例。 /// </summary> /// <param name="port">IO端口类实例</param> public void AddHardware(BaseIOPort port) { if (port == null) { return; } switch (port.Type) { case IOType.In: if (_InPortCollection.ContainsKey(port.PortName)) { return; } _InPortCollection.Add(port.PortName, port); port.subscribeMeToIOEvents(this); break; case IOType.Out: if (_OutPortCollection.ContainsKey(port.PortName)) { return; } _OutPortCollection.Add(port.PortName, port); break; } }