private string CheckWrite() { //throw new Exception(); string res = ""; if (!objRFID.ReadTagID()) { objRFID.Beep(20); res = "fail"; } else { System.Threading.Thread.Sleep(20); ErrorCode ec = objRFID.IsTagWrited();// ReadData(); switch (ec) { case ErrorCode.CanNotFindTag: objRFID.Beep(20); res = "无法找到标签,请重试!"; //WriteLog(lrtxtLog, str, 1); break; case ErrorCode.OtherException: objRFID.Beep(20); res = "其他异常,请重试"; break; case ErrorCode.ReadFail: res = "读取失败,请重试!"; break; case ErrorCode.ReadSuccessful: //paintBackgroundColor(statusType.PASS); objRFID.Beep(10); //MessageBox.Show("read success"); //break; ModuleObj mo = new ModuleObj(); mo = TagDataFormat.ParserTag(objRFID.rfidConfig.readBuffer); res = mo.ModuleID.ToString(); break; case ErrorCode.TagHasNoData: res = "空标签!"; break; default: break; } } return(res); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtRead_Click(object sender, EventArgs e) { paintBackgroundColor(statusType.START); if (!_RFIDDevice.ReadTagID()) { WriteLog(lrtxtLog, "没有发现标签!", 1); _RFIDDevice.Beep(20); paintBackgroundColor(statusType.FAIL); return; } else { System.Threading.Thread.Sleep(20); ErrorCode ec = _RFIDDevice.IsTagWrited();// ReadData(); switch (ec) { case ErrorCode.CanNotFindTag: paintBackgroundColor(statusType.FAIL); _RFIDDevice.Beep(20); string str = "无法找到标签,请重试!"; WriteLog(lrtxtLog, str, 1); break; case ErrorCode.OtherException: paintBackgroundColor(statusType.FAIL); _RFIDDevice.Beep(20); str = "其他异常,请重试"; WriteLog(lrtxtLog, str, 1); break; case ErrorCode.ReadFail: paintBackgroundColor(statusType.FAIL); _RFIDDevice.Beep(20); str = "读取失败,请重试!"; WriteLog(lrtxtLog, str, 1); break; case ErrorCode.ReadSuccessful: paintBackgroundColor(statusType.PASS); _RFIDDevice.Beep(10); oModuleInfo = TagDataFormat.ParserTag(_RFIDDevice.rConfig.readBuffer); ShowModuleInfo(true); ShowIVCurves(double.Parse(oModuleInfo.Isc), double.Parse(oModuleInfo.Ipm), double.Parse(oModuleInfo.Vpm), double.Parse(oModuleInfo.Voc), oModuleInfo.Module_ID); string storedDataString = Encoding.ASCII.GetString(_RFIDDevice.rConfig.readBuffer); WriteLog(lrtxtLog, storedDataString.Replace("@@", "").Replace("##", ""), 0); _RFIDDevice.Speech("读取成功"); break; case ErrorCode.TagHasNoData: paintBackgroundColor(statusType.FAIL); _RFIDDevice.Beep(20); str = "空标签!"; WriteLog(lrtxtLog, str, 1); break; default: break; } } }