/// <summary> /// /// </summary> /// <param name="cp"></param> public void End(ICommuniPort cp) { if (this.Status == TaskStatus.Timeout) { OnEnding(EventArgs.Empty); byte[] bytes = new byte[0]; if (cp != null) { bytes = cp.Read(); } // filte bytes by device // bytes = this.Device.Filters.Filtrate(bytes); this.LastReceivedBytes = bytes; this.LastReceivedDateTime = DateTime.Now; IParseResult pr = this.Opera.ParseReceivedBytes(this.Device, bytes); this.LastParseResult = pr; // // CommuniDetail cd = new CommuniDetail( this.Opera.Text, LastSendBytes, LastExecute, LastReceivedBytes, LastReceivedDateTime, //parseResult.ToString(), //parseResult.IsSuccess pr ); this.Device.CommuniDetails.Add(cd); DeviceCommuniLogger.Log(this.Device, cd); //this.device // // // this.SetStatus(TaskStatus.Executed); OnEnded(EventArgs.Empty); } else { throw new InvalidOperationException("status must be 'Timeout' when call End(...)"); } }
/// <summary> /// /// </summary> /// <param name="device"></param> /// <param name="cd"></param> static public void Log(IDevice device, CommuniDetail cd) { if (Enabled) { string path = string.Format( ".\\CommuniLog\\{0}\\{1}_{2}.txt", device.Station.Name, device.GetType().Name, device.Address); path = PathUtils.MapToStartupPath(path); StreamWriter sw = GetStreamWriter(path); sw.WriteLine(cd.ToString()); sw.WriteLine(); sw.Flush(); sw.Close(); } }
/// <summary> /// /// </summary> /// <param name="device"></param> /// <param name="cd"></param> public static void Log(IDevice device, CommuniDetail cd) { if (Enabled) { string path = string.Format( ".\\CommuniLog\\{0}\\{1}_{2}.txt", device.Station.Name, device.GetType().Name, device.Address); path = PathUtils.MapToStartupPath(path); StreamWriter sw = GetStreamWriter(path); sw.WriteLine(cd.ToString()); sw.WriteLine(); sw.Flush(); sw.Close(); } }
/// <summary> /// /// </summary> /// <param name="cp"></param> public void End(ICommuniPort cp) { if (this.Status == TaskStatus.Timeout) { OnEnding(EventArgs.Empty); byte[] bytes = new byte[0]; if (cp != null) { bytes = cp.Read(); } // filte bytes by device // bytes = this.Device.Filters.Filtrate(bytes); this.LastReceivedBytes = bytes; this.LastReceivedDateTime = DateTime.Now; IParseResult pr = this.Opera.ParseReceivedBytes(this.Device, bytes); this.LastParseResult = pr; // // CommuniDetail cd = new CommuniDetail( this.Opera.Text, LastSendBytes, LastExecute, LastReceivedBytes, LastReceivedDateTime, pr.ToString(), pr.IsSuccess ); this.Device.CommuniDetails.Add(cd); DeviceCommuniLogger.Log(this.Device, cd); //this.device // // // this.SetStatus(TaskStatus.Executed); OnEnded(EventArgs.Empty); } else { throw new InvalidOperationException("status must be 'Timeout' when call End(...)"); } }