예제 #1
0
        void SaveLogSend(object sender, SendDataArgs e)
        {
            LogSend = e._data;
            Thread thread = new Thread(updateSendTextBox);

            thread.Start();
        }
예제 #2
0
        protected void SendData(object source, SendDataArgs e)
        {
            if (e == null)
            {
                return;
            }

            if (e.Data == null || e.Data.Length <= 0)
            {
                Logger.Info(false, e.DeviceName + ",要发送的数据为空");
                return;
            }

            IRunDevice dev = DeviceManager.GetDevice(e.DeviceID);

            if (dev != null)
            {
                if (dev.CommunicateType == CommunicateType.COM)
                {
                    Logger.Info(false, e.DeviceName + ",串口通讯设备无法实现自主发送数据");
                }
                else
                {
                    if (ServerConfig.ControlMode == ControlMode.Self)
                    {
                        ISocketController netController = (ISocketController)ControllerManager.GetController(SocketController.ConstantKey);
                        if (netController != null)
                        {
                            netController.Send(dev, e.Data);
                        }
                        else
                        {
                            Logger.Info(false, e.DeviceName + ",无法找到对应的网络控制器");
                        }
                    }
                    else
                    {
                        Logger.Info(false, e.DeviceName + ",只有控制方式为自主模式的时候,设备才能发送数据");
                    }
                }
            }
            else
            {
                Logger.Info(false, e.DeviceName + "无法获得可发送数据的设备");
            }
        }