Пример #1
0
        public override void Communicate(ServerSuperIO.Communicate.IResponseInfo 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)
                {
                    Dyn dyn = (Dyn)obj;

                    this.DeviceDynamic.DynamicData.Write("flow", dyn.Flow);
                    this.DeviceDynamic.DynamicData.Write("signal", dyn.Signal);

                    OnDeviceRuningLog("通讯正常,流量:" + dyn.Flow + ",信号:" + dyn.Signal);
                }
                else if (cr == CommandArray.FileData)
                {
                    OnDeviceRuningLog("文件存储路径:" + obj.ToString());
                }
                //else if (cr == CommandArray.BackControlCommand)
                //{
                //    if (_serviceCallback != null)
                //    {
                //        _serviceCallback.BeginInvoke(new string[] { this.DeviceParameter.DeviceCode, _channelKey }, null, null);
                //    }
                //}
            }
        }
        public override void Communicate(ServerSuperIO.Communicate.IResponseInfo info)
        {
            try
            {
                //string hexs = BinaryUtil.ByteToHex(info.Data);

                Dyn dyn = this.Protocol.DriverAnalysis <String>("61", info.Data, null);
                if (dyn != null)
                {
                    _deviceDyn.Flow   = dyn.Flow;
                    _deviceDyn.Signal = dyn.Signal;
                    OnDeviceRuningLog("接收>>" + dyn.Flow.ToString() + "," + dyn.Signal.ToString());
                }

                Task.Factory.StartNew(() =>
                {
                    if (info.Channel != null)
                    {
                        lock (info.Channel.SyncLock)
                        {
                            ((ISocketSession)info.Channel).StartSend(new byte[] { 0x00, 0x01, 0x03, 0x04, 0x05 }, false, WebSocketFrameType.Binary);
                        }
                    }
                });

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