public override CommResultState ProcessReceived(byte[] data) { CommResultState r = XGCommandMaker.CheckReceivedData(Station.Address, XGDefinition.DEVICE_TYPE, XGDefinition.FC_QUERY_ADDRESS, data); System.Windows.Forms.MessageBox.Show("re" + data.Length + r.ToString()); return(r); }
//private string getlogstring( int commport, task task ) private string GetLogString(string remoteIP, Task task) { CommCmdBase cmd = task.CommCmd; CommResultState commResultState = task.LastCommResultState; string sLastReceive = string.Empty; if (task.LastReceived != null) { sLastReceive = CT.BytesToString(task.LastReceived); } string s = string.Format("Send\t\t: {0}, {1}\r\nReceived\t: {2}, {3}\r\nCommResult\t: {4}\r\nCmdType\t\t: {5}\r\nRemoteIP\t: {6}\r\n", task.LastSendDateTime, CT.BytesToString(task.LastSendDatas), //task.LastReceivedDateTime, CT.BytesToString( task.LastReceived), task.LastReceivedDateTime, sLastReceive, commResultState.ToString(), cmd.GetType().Name, remoteIP); return(s); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void Process(object sender, EventArgs e) { ArgumentChecker.CheckNotNull(sender); TaskScheduler sch = (TaskScheduler)sender; Task task = sch.ActiveTask; ArgumentChecker.CheckNotNull(task); CommCmdBase cmd = task.CommCmd; CommResultState commResultState = task.LastCommResultState; if (commResultState != CommResultState.Correct) { if (XGConfig.Default.LogCommFail) { string s = string.Format("Send\t\t: {0}, {1}\r\nReceived\t: {2}, {3}\r\nCommResult\t: {4}\r\nCmdType\t\t: {5}\r\n", task.LastSendDateTime, CT.BytesToString(task.LastSendDatas), task.LastReceivedDateTime, CT.BytesToString(task.LastReceived), commResultState.ToString(), cmd.GetType().Name); FileLog.CommFail.Add(s); } return; } if (cmd is ReadRecordCommand) { ReadRecordCommand readRecordCmd = cmd as ReadRecordCommand; ProcessReadRecordCmd(readRecordCmd); } if (cmd is ReadTotalCountCommand) { ReadTotalCountCommand readCountCmd = cmd as ReadTotalCountCommand; ProcessReadTotalCountCmd(readCountCmd, task); } }