Example #1
0
        public override void Communicate(GEIIO.Communicate.IRequestInfo info)
        {
            string hexs = BinaryUtil.ByteToHex(info.Data);

            OnDeviceRuningLog("接收>>" + hexs);

            byte[]       cmds = this.Protocol.GetCommand(info.Data);
            CommandArray cr   = (CommandArray)cmds[0];

            dynamic obj = this.Protocol.DriverAnalysis <byte[]>(cr.ToString(), info.Data, info.BigData);

            if (obj != null)
            {
                if (cr == CommandArray.RealTimeData)
                {
                    _deviceDyn.Dyn = (Dyn)obj;
                    OnDeviceRuningLog("通讯正常");
                    if (this.DeviceParameter.DeviceCode != "1")
                    {
                        Console.WriteLine(">>>>模拟控制命令开始");
                        this.OnDeviceConnector(
                            new FromDevice(this.DeviceParameter.DeviceID, this.DeviceParameter.DeviceCode,
                                           this.DeviceParameter.DeviceAddr, this.DeviceParameter.DeviceName),
                            new DeviceToDevice("1", this.DeviceParameter.DeviceName + "问:大哥,朴大妈为什么还不下课?", null, null));
                    }
                }
                else if (cr == CommandArray.FileData)
                {
                    OnDeviceRuningLog("文件存储路径:" + obj.ToString());
                }
            }
        }
Example #2
0
        public override void Communicate(GEIIO.Communicate.IRequestInfo info)
        {
            try
            {
                string hexs = BinaryUtil.ByteToHex(info.Data);

                Dyn dyn = this.Protocol.DriverAnalysis <String>("61", info.Data, null);
                if (dyn != null)
                {
                    _deviceDyn.Dyn = dyn;
                    OnDeviceRuningLog("接收>>" + dyn.Flow.ToString() + "," + dyn.Signal.ToString());
                }
                Task.Factory.StartNew(() => {
                    if (info.Channel != null)
                    {
                        lock (info.Channel.SyncLock)
                        {
                            ((ISocketSession)info.Channel).TrySend(new byte[] { 0x00, 0x01, 0x03, 0x04, 0x05 }, false);
                        }
                    }
                });

                OnDeviceRuningLog("通讯正常");
            }
            catch (Exception ex)
            {
                OnDeviceRuningLog(ex.Message);
            }
        }
Example #3
0
 public override void CommunicateError(GEIIO.Communicate.IRequestInfo info)
 {
     //UDP
     //info.Channel.Write(System.Text.Encoding.ASCII.GetBytes("aaa"));
     OnDeviceRuningLog("通讯干扰");
 }
Example #4
0
 public override void CommunicateInterrupt(GEIIO.Communicate.IRequestInfo info)
 {
     OnDeviceRuningLog("通讯中断");
 }
Example #5
0
 public override void CommunicateError(GEIIO.Communicate.IRequestInfo info)
 {
     OnDeviceRuningLog("通讯干扰");
 }