public IChannel GetChannel(string ioPara1, int ioPara2, CommunicateType comType) { IChannel channel = null; foreach (KeyValuePair <string, IChannel> c in _Channels) { if (c.Value.CommunicationType == comType) { ISocketSession socketSession = (ISocketSession)c.Value; if (socketSession.RemoteIP == ioPara1 && socketSession.RemotePort == ioPara2) { channel = c.Value; break; } } else if (c.Value.CommunicationType == comType) { IComSession comSession = (IComSession)c.Value; if (ComUtils.PortToString(comSession.Port) == ioPara1 && comSession.Baud == ioPara2) { channel = c.Value; break; } } } return(channel); }
protected void OnChannelChanged(string comPara1, CommunicateType comType, ChannelState channelState) { if (DeviceManager.Count > 0) { if (ServerConfig.ControlMode == ControlMode.Loop || ServerConfig.ControlMode == ControlMode.Self || ServerConfig.ControlMode == ControlMode.Parallel) { IRunDevice[] list = this.DeviceManager.GetDevices(comPara1, comType); if (list != null && list.Length > 0) { foreach (IRunDevice dev in list) { try { dev.ChannelStateChanged(channelState); } catch (Exception ex) { Logger.Error(true, ex.Message); } } } } } }
/// <summary> /// 获得设备列表 /// </summary> /// <param name="ioType"></param> /// <returns></returns> public IRunDevice[] GetDevices(CommunicateType ioType) { List <IRunDevice> list = new List <IRunDevice>(); foreach (KeyValuePair <string, IRunDevice> kv in _Devices) { if (kv.Value.CommunicateType == ioType) { list.Add(kv.Value); } } return(list.ToArray()); }
public IChannel GetChannel(string ioPara1, CommunicateType comType) { IChannel channel = null; foreach (KeyValuePair <string, IChannel> c in _Channels) { if (c.Value.CommunicationType == comType && c.Value.Key == ioPara1) { channel = c.Value; break; } } return(channel); }
/// <summary> /// 获得设备列表 /// </summary> /// <param name="iopara1"></param> /// <param name="ioType"></param> /// <returns></returns> public IRunDevice[] GetDevices(string iopara1, CommunicateType ioType) { List <IRunDevice> list = new List <IRunDevice>(); foreach (KeyValuePair <string, IRunDevice> kv in _Devices) { if ((kv.Value.CommunicateType == ioType && String.CompareOrdinal(kv.Value.DeviceParameter.NET.RemoteIP, iopara1) == 0) || (kv.Value.CommunicateType == ioType && String.CompareOrdinal(kv.Value.DeviceParameter.COM.Port.ToString(), iopara1) == 0)) { list.Add(kv.Value); } } return(list.ToArray()); }
public ICollection <IChannel> GetChannels(CommunicateType ioType) { return(GetValues().Where(v => v.CommunicationType == CommunicateType.NET).ToList()); }
public RS232CommunicateEventArgs(CommunicateType t) { Type = t; }
internal CommunicatePacket(CommunicateType type, object data) { Type = type; Data = data; }