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); } }
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 dynamic Analysis <T>(byte[] data, T t) { Dyn dyn = new Dyn { CurDT = DateTime.Now, ProHead = this.ProtocolDriver.GetHead(data), DeviceAddr = this.ProtocolDriver.GetAddress(data), Command = this.ProtocolDriver.GetCommand(data), ProEnd = this.ProtocolDriver.GetEnd(data) }; //try //{ //一般下位机是单片的话,接收到数据的高低位需要互换,才能正常解析。 byte[] flow = BinaryUtil.SubBytes(data, 4, 4, true); dyn.Flow = BitConverter.ToSingle(flow, 0); byte[] signal = BinaryUtil.SubBytes(data, 8, 4, true); dyn.Signal = BitConverter.ToSingle(signal, 0); //} //catch(Exception ex) //{ // throw ex; //} return(dyn); }
public override void Communicate(ServerSuperIO.Communicate.IRequestInfo info) { Dyn dyn = this.Protocol.DriverAnalysis <String, String>("61", info.BigData, null, null); if (dyn != null) { _deviceDyn.Dyn = dyn; } OnDeviceRuningLog("通讯正常"); }
public override void Communicate(ServerSuperIO.Communicate.IRequestInfo info) { object obj = this.Protocol.DriverAnalysis("61", info.Data, null); if (obj != null) { Dyn dyn = (Dyn)obj; _deviceDyn.Dyn = dyn; } OnDeviceRuningLog("通讯正常"); }
public override void Communicate(ServerSuperIO.Communicate.IRequestInfo info) { Dyn dyn = this.Protocol.DriverAnalysis <String, String>("61", info.Data, null, null); if (dyn != null) { _deviceDyn.Dyn = dyn; } ((ISocketSession)info.Channel).TrySend(new byte[] { 0x00, 0x01, 0x03, 0x04, 0x05 }, true); OnDeviceRuningLog("通讯正常"); }
public override object Analysis(byte[] data, object obj) { Dyn dyn = new Dyn { CurDT = DateTime.Now, ProHead = this.ProtocolDriver.GetProHead(data), DeviceAddr = this.ProtocolDriver.GetAddress(data), Command = this.ProtocolDriver.GetCommand(data), ProEnd = this.ProtocolDriver.GetProEnd(data) }; //一般下位机是单片的话,接收到数据的高低位需要互换,才能正常解析。 byte[] flow = BinaryUtil.SubBytes(data, 4, 4, true); dyn.Flow = BitConverter.ToSingle(flow, 0); byte[] signal = BinaryUtil.SubBytes(data, 8, 4, true); dyn.Signal = BitConverter.ToSingle(signal, 0); return(dyn); }
public DeviceDyn() : base() { Dyn = new Dyn(); }