예제 #1
0
        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);
        }
예제 #2
0
 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);
                     }
                 }
             }
         }
     }
 }
예제 #3
0
        /// <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());
        }
예제 #4
0
        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);
        }
예제 #5
0
        /// <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());
        }
예제 #6
0
 public ICollection <IChannel> GetChannels(CommunicateType ioType)
 {
     return(GetValues().Where(v => v.CommunicationType == CommunicateType.NET).ToList());
 }
 public RS232CommunicateEventArgs(CommunicateType t)
 {
     Type = t;
 }
예제 #8
0
 internal CommunicatePacket(CommunicateType type, object data)
 {
     Type = type;
     Data = data;
 }