void ReaderXP_TagCompletedEvent(object sender, CSLibrary.Events.OnAccessCompletedEventArgs e) { this.Invoke((System.Threading.ThreadStart) delegate() { if (e.access == TagAccess.READ) { { switch (e.bank) { case Bank.EPC: if (e.success) { //byte [] configword = Program.ReaderXP.Options.TagReadEPC.epc.ToBytes(); } break; case Bank.PC: if (e.success) { } break; case Bank.TID: break; } } } }); }
private void StopLogResultProccess(CSLibrary.Events.OnAccessCompletedEventArgs e) { if (!e.success) { // if process fail if (_ProcessRetry == 0) { // Start Log Fail TagInfoList[_ProcessTagNumber].LogStatus = "Error"; _ProcessTagNumber++; _ProcessState = 0; } else { _ProcessRetry--; } StopLog(); } else { _ProcessState++; _ProcessRetry = 10; StopLog(); } }
void ReaderCE_OnAccessCompleted(object sender, CSLibrary.Events.OnAccessCompletedEventArgs e) { this.Invoke((System.Threading.ThreadStart) delegate() { switch (e.access) { case TagAccess.WRITE: if (e.success && e.bank == Bank.EPC) { //Increase tag count currentCount++; txtSuccessTag.Text = currentCount.ToString(); if (currentCount == nbCount.Value) { ThreadStop(); } } break; case TagAccess.READ: if (e.success && e.bank == Bank.EPC) { Debug.WriteLine("EPC = " + e.data.ToString()); } else { Debug.WriteLine(string.Format("Read {0} error", e.bank)); } break; } }); }
void TagCompletedEvent(object sender, CSLibrary.Events.OnAccessCompletedEventArgs e) { Xamarin.Forms.DependencyService.Get <ISystemSound>().SystemSound(1); if (buttonStartText == "Start") { return; } if (e.success) { sucessCount++; labelSuccessCount = sucessCount.ToString(); RaisePropertyChanged(() => labelSuccessCount); if (sucessCount == numofTags) { buttonStartText = "Start"; RaisePropertyChanged(() => buttonStartText); return; } } else { failCount++; labelFailCount = failCount.ToString(); RaisePropertyChanged(() => labelFailCount); } WriteEPC(); }
void TagCompletedEvent(object sender, CSLibrary.Events.OnAccessCompletedEventArgs e) { if (e.access == CSLibrary.Constants.TagAccess.READ) { switch (e.bank) { case CSLibrary.Constants.Bank.USER: if (e.success) { var entryUSER = BleMvxApplication._reader.rfid.Options.TagReadUser.pData.ToUshorts(); entryX28Text = entryUSER[0].ToString("D"); entryX29Text = toFloat(entryUSER[1]).ToString("0.0#"); entryX2AText = toFloat(entryUSER[2]).ToString("0.0#"); entryX2BText = entryUSER[3].ToString("D"); entryX2CText = entryUSER[4].ToString("D"); entryX2DText = entryUSER[5].ToString("D"); entryX2EText = entryUSER[6].ToString("D"); entryX2FText = entryUSER[7].ToString("D"); RaisePropertyChanged(() => entryX28Text); RaisePropertyChanged(() => entryX29Text); RaisePropertyChanged(() => entryX2AText); RaisePropertyChanged(() => entryX2BText); RaisePropertyChanged(() => entryX2CText); RaisePropertyChanged(() => entryX2DText); RaisePropertyChanged(() => entryX2EText); RaisePropertyChanged(() => entryX2FText); _userDialogs.Alert("Read OK!"); } else { _userDialogs.Alert("Read FAIL!"); } break; } } if (e.access == CSLibrary.Constants.TagAccess.WRITE) { switch (e.bank) { case CSLibrary.Constants.Bank.USER: if (e.success) { _userDialogs.Alert("Write OK!"); } else { _userDialogs.Alert("Write FAIL!"); } break; } } }
public async void TagCompletedEvent(object sender, CSLibrary.Events.OnAccessCompletedEventArgs e) { if (e.access == CSLibrary.Constants.TagAccess.READ) { switch (e.bank) { case CSLibrary.Constants.Bank.USER: if (e.success) { UInt16 value = BleMvxApplication._reader.rfid.Options.TagReadUser.pData.ToUshorts()[0]; var a = value >> 14 & 0x03; var b = value >> 13 & 0x01; var c = value >> 11 & 0x03; var d = value >> 9 & 0x03; var e1 = value >> 8 & 0x01; var f = value >> 7 & 0x01; var g = value >> 6 & 0x01; var h = value >> 4 & 0x03; buttonPadMode.Text = _padModeOptionList[a]; buttonLegacyPCenable.Text = _legacyPCEnable[b]; buttonTamperFunction.Text = _tamperFunction[c]; buttonTNReporting.Text = _tNReporting[d]; buttonAccessPasswordUntraceablePrivilege.Text = _accessPasswordUntraceable[e1]; buttonAccessPasswordTNPrivilege.Text = _accessPasswordTNPrivilege[f]; buttonConfigurationLock.Text = _configurationLock[g]; buttonBackscatterconfiguration.Text = _backscatterConfiguration[h]; await DisplayAlert("", "Read Sucess", "OK"); } else { await DisplayAlert("", "Read Fail!!!", "OK"); } break; } } if (e.access == CSLibrary.Constants.TagAccess.WRITE) { switch (e.bank) { case CSLibrary.Constants.Bank.USER: if (e.success) { await DisplayAlert("", "Write Sucess", "OK"); } else { await DisplayAlert("", "Write Fail!!!", "OK"); } break; } } }
void ReaderXP_OnCompleted(object sender, CSLibrary.Events.OnAccessCompletedEventArgs e) { this.Invoke((System.Threading.ThreadStart) delegate() { if (e.access == TagAccess.KILL) { resultForm1.UpdateResult(e.success); } }); }
void TagCompletedEvent(object sender, CSLibrary.Events.OnAccessCompletedEventArgs e) { InvokeOnMainThread(() => { if (e.access == CSLibrary.Constants.TagAccess.WRITE) { if (e.success) { System.Threading.Thread.Sleep(100); ReadCommunicationBuffer(); } else { labelReadStatusText = "Read Error"; RaisePropertyChanged(() => labelReadStatusText); } } else if (e.access == CSLibrary.Constants.TagAccess.READ) { if (e.success) { UInt16[] CommunicationBuffer = BleMvxApplication._reader.rfid.Options.TagReadUser.pData.ToUshorts(); var AnswerMessageArea = ((CommunicationBuffer[0] >> 10) & 0x3F); var AnswerIdentifierArea = (CommunicationBuffer[0] & 0x3FF); if (AnswerIdentifierArea == 0x330) { if (AnswerMessageArea != 0x00) { System.Threading.Thread.Sleep(100); ReadCommunicationBuffer(); } else { UInt32 RealTimeClockActiveTime = (UInt32)(CommunicationBuffer[1] << 16 | CommunicationBuffer[2]); UInt16 NumberofLoggingEvents = CommunicationBuffer[3]; UInt16 NumberofCommunicationMessages = CommunicationBuffer[4]; labelRealTimeClockActiveTimeText = RealTimeClockActiveTime.ToString(); labelNumberofLoggingEventsText = NumberofLoggingEvents.ToString(); labelNumberofCommunicationMessagesText = NumberofCommunicationMessages.ToString(); labelReadStatusText = "Read Success"; RaisePropertyChanged(() => labelRealTimeClockActiveTimeText); RaisePropertyChanged(() => labelNumberofLoggingEventsText); RaisePropertyChanged(() => labelNumberofCommunicationMessagesText); RaisePropertyChanged(() => labelReadStatusText); } } } } }); }
void ReaderXP_TagCompletedEvent(object sender, CSLibrary.Events.OnAccessCompletedEventArgs e) { this.Invoke((System.Threading.ThreadStart) delegate() { if (e.access == TagAccess.READ) { switch (e.bank) { case Bank.ACC_PWD: if (e.success) { UpdateBankInfo(e.bank, Program.ReaderXP.Options.TagReadAccPwd.password.ToString()); } break; case Bank.EPC: if (e.success) { UpdateBankInfo(e.bank, Program.ReaderXP.Options.TagReadEPC.epc.ToString()); } break; case Bank.KILL_PWD: if (e.success) { UpdateBankInfo(e.bank, Program.ReaderXP.Options.TagReadKillPwd.password.ToString()); } break; case Bank.PC: if (e.success) { UpdateBankInfo(e.bank, Program.ReaderXP.Options.TagReadPC.pc.ToString()); } break; case Bank.TID: if (e.success) { UpdateBankInfo(e.bank, Program.ReaderXP.Options.TagReadTid.tid.ToString()); } break; case Bank.USER: if (e.success) { UpdateBankInfo(e.bank, Program.ReaderXP.Options.TagReadUser.pData.ToString()); } break; } } }); }
void TagCompletedEvent(object sender, CSLibrary.Events.OnAccessCompletedEventArgs e) { InvokeOnMainThread(() => { if (e.access == CSLibrary.Constants.TagAccess.WRITE) { if (e.success) { System.Threading.Thread.Sleep(100); ReadCommunicationBuffer(); } else { labelReadStatusText = "Read Error"; RaisePropertyChanged(() => labelReadStatusText); } } else if (e.access == CSLibrary.Constants.TagAccess.READ) { if (e.success) { UInt16[] CommunicationBuffer = BleMvxApplication._reader.rfid.Options.TagReadUser.pData.ToUshorts(); var AnswerMessageArea = ((CommunicationBuffer[0] >> 10) & 0x3F); if (AnswerMessageArea != 0x01) { System.Threading.Thread.Sleep(100); ReadCommunicationBuffer(); } else { int ReadMeasurementObjectIndex = CommunicationBuffer[0] & 0xff; int Temperature = CommunicationBuffer[1] >> 8 & 0xff; labelReadMeasurementObjectIndexText = ReadMeasurementObjectIndex.ToString(); if ((Temperature & 0x80) == 0x80) { labelTemperatureText = ((-64.0 + (double)(Temperature & 0x7f)) * 0.5).ToString(); } else { labelTemperatureText = ((double)(Temperature) * 0.5).ToString(); } labelReadStatusText = "Read Success"; RaisePropertyChanged(() => labelReadMeasurementObjectIndexText); RaisePropertyChanged(() => labelTemperatureText); RaisePropertyChanged(() => labelReadStatusText); } } } }); }
void TagCompletedEvent(object sender, CSLibrary.Events.OnAccessCompletedEventArgs e) { InvokeOnMainThread(() => { if (e.access == CSLibrary.Constants.TagAccess.READ) { if (e.success) { _retryCount = 100; } } }); }
void TagCompletedEvent(object sender, CSLibrary.Events.OnAccessCompletedEventArgs e) { if (e.access == CSLibrary.Constants.TagAccess.LOCK) { if (e.success) { labelStatus = "SUCCESS"; } else { labelStatus = "FAIL"; } RaisePropertyChanged(() => labelStatus); } }
void ReaderXP_TagCompletedEvent(object sender, CSLibrary.Events.OnAccessCompletedEventArgs e) { this.Invoke((System.Threading.ThreadStart) delegate() { if (e.access == TagAccess.READ) { { switch (e.bank) { case Bank.EPC: if (e.success) { byte [] configword = Program.ReaderXP.Options.TagReadEPC.epc.ToBytes(); checkBox0.Checked = (configword[0] & 0x80) != 0; checkBox1.Checked = (configword[0] & 0x40) != 0; checkBox4.Checked = (configword[0] & 0x08) != 0; checkBox5.Checked = (configword[0] & 0x04) != 0; checkBox6.Checked = (configword[0] & 0x02) != 0; checkBox7.Checked = (configword[0] & 0x01) != 0; checkBox8.Checked = (configword[1] & 0x80) != 0; checkBox9.Checked = (configword[1] & 0x40) != 0; checkBox10.Checked = (configword[1] & 0x20) != 0; checkBox11.Checked = (configword[1] & 0x10) != 0; checkBox12.Checked = (configword[1] & 0x08) != 0; checkBox13.Checked = (configword[1] & 0x04) != 0; checkBox14.Checked = (configword[1] & 0x02) != 0; checkBox15.Checked = (configword[1] & 0x01) != 0; } break; case Bank.PC: if (e.success) { // textBoxPublicPC.Text = Program.ReaderXP.Options.TagReadPC.pc.ToString(); } break; case Bank.TID: // if (checkBoxPublicTID.Checked) // textBoxPublicTID.Text = Program.ReaderXP.Options.TagReadTid.tid.ToString().Substring(0, 24); break; } } } }); }
public async void TagCompletedEvent(object sender, CSLibrary.Events.OnAccessCompletedEventArgs e) { InvokeOnMainThread(() => { if (e.access == CSLibrary.Constants.TagAccess.READ) { switch (e.bank) { case CSLibrary.Constants.Bank.USER: if (e.success) { UInt16 value = BleMvxApplication._reader.rfid.Options.TagReadUser.pData.ToUshorts()[0]; // labelSystemConfigurationWord1Text = "0"+value.ToString("X04"); // RaisePropertyChanged(() => labelSystemConfigurationWord1Text); labelSystemConfigurationWord1Text = value.ToString("X04"); RaisePropertyChanged(() => labelSystemConfigurationWord1Text); _userDialogs.ShowSuccess("Read Sucess"); } else { _userDialogs.ShowError("Read Fail!!!"); } break; } } if (e.access == CSLibrary.Constants.TagAccess.WRITE) { switch (e.bank) { case CSLibrary.Constants.Bank.USER: if (e.success) { _userDialogs.ShowSuccess("Write Sucess"); } else { _userDialogs.ShowError("Write Fail!!!"); } break; } } }); }
void ReaderXP_TagCompletedEvent(object sender, CSLibrary.Events.OnAccessCompletedEventArgs e) { this.Invoke((System.Threading.ThreadStart) delegate() { if (e.access == TagAccess.READ) { switch (e.bank) { case Bank.USER: if (e.success) { // UpdateBankInfo(e.bank, Program.ReaderXP.Options.TagReadUser.pData.ToString()); } break; } } }); }
void TagCompletedEvent(object sender, CSLibrary.Events.OnAccessCompletedEventArgs e) { InvokeOnMainThread(() => { if (_EnableAllTagsLog) { StartLogResultProccess(e); } else if (_DisableAllTagsLog) { StopLogResultProccess(e); } else { _userDialogs.ShowSuccess("Process Error!", 2000); // Error } }); }
public async void TagCompletedEvent(object sender, CSLibrary.Events.OnAccessCompletedEventArgs e) { InvokeOnMainThread(() => { if (e.access == CSLibrary.Constants.TagAccess.READ) { switch (e.bank) { case CSLibrary.Constants.Bank.USER: if (e.success) { entryValueText = BleMvxApplication._reader.rfid.Options.FM13DTReadMemory.data.ToString("X04"); RaisePropertyChanged(() => entryValueText); _userDialogs.ShowSuccess("Read Sucess"); } else { _userDialogs.ShowError("Read Fail!!!"); } break; } } if (e.access == CSLibrary.Constants.TagAccess.WRITE) { switch (e.bank) { case CSLibrary.Constants.Bank.USER: if (e.success) { _userDialogs.ShowSuccess("Write Sucess"); } else { _userDialogs.ShowError("Write Fail!!!"); } break; } } }); }
void TagCompletedEvent(object sender, CSLibrary.Events.OnAccessCompletedEventArgs e) { Device.BeginInvokeOnMainThread(() => { if (e.access != CSLibrary.Constants.TagAccess.WRITE) { return; } if (e.success) { labelLastWriteResult.Text = "Write Success"; _successTagCount++; } else { labelLastWriteResult.Text = "Write Fail"; } BleMvxApplication._reader.rfid.OnAccessCompleted -= new EventHandler <CSLibrary.Events.OnAccessCompletedEventArgs>(TagCompletedEvent); Xamarin.Forms.DependencyService.Get <ISystemSound>().SystemSound(1); _tagCount++; labelTagCount.Text = _tagCount.ToString(); labelSuccessTagCount.Text = _successTagCount.ToString(); switch (_automatic) { case 1: StartAutomaticRegisterTag(); break; case 2: StartAutomatic1RegisterTag(); break; } }); }
void TagCompletedEvent(object sender, CSLibrary.Events.OnAccessCompletedEventArgs e) { InvokeOnMainThread(() => { if (e.access == CSLibrary.Constants.TagAccess.WRITE) { if (e.success) { System.Threading.Thread.Sleep(100); ReadCommunicationBuffer(); } else { labelReadStatusText = "Read Error"; RaisePropertyChanged(() => labelReadStatusText); } } else if (e.access == CSLibrary.Constants.TagAccess.READ) { if (e.success) { UInt16[] CommunicationBuffer = BleMvxApplication._reader.rfid.Options.TagReadUser.pData.ToUshorts(); var AnswerMessageArea = ((CommunicationBuffer[0] >> 10) & 0x3F); var AnswerIdentifierArea = (CommunicationBuffer[0] & 0x3FF); if (AnswerIdentifierArea == 0x310) { if (AnswerMessageArea != 0x00) { System.Threading.Thread.Sleep(100); ReadCommunicationBuffer(); } else { int LoggingCounter = CommunicationBuffer[1]; if (CommunicationBuffer[2] == 0x0) { CommunicationBuffer[2] = 0x0001; } if (CommunicationBuffer[3] == 0x0) { CommunicationBuffer[3] = 0x0100; } DateTime LoggingStart = new DateTime(((CommunicationBuffer[2] >> 8) & 0xff) + 2000, CommunicationBuffer[2] & 0xff, (CommunicationBuffer[3] >> 8) & 0xff, CommunicationBuffer[3] & 0xff, (CommunicationBuffer[4] >> 8) & 0xff, CommunicationBuffer[4] & 0xff); //int a = ((CommunicationBuffer[2] >> 8) & 0xff) + 2000; //var b = CommunicationBuffer[2] & 0xff; //var c = (CommunicationBuffer[3] >> 8) & 0xff; //var d = CommunicationBuffer[3] & 0xff; //var e1 = (CommunicationBuffer[4] >> 8) & 0xff; //var f = CommunicationBuffer[4] & 0xff; //DateTime LoggingStart = new DateTime(a, b, c, d, e1, f); DateTime LoggingInterval = new DateTime(2000, 1, 1, (CommunicationBuffer[5] >> 8) & 0xff, CommunicationBuffer[5] & 0xff, (CommunicationBuffer[6] >> 8) & 0xff); int LoggerCondition = CommunicationBuffer[6] & 0xff; int BatteryVoltage = (CommunicationBuffer[7] >> 4) & 0xfff; int ErrorEventCounter = CommunicationBuffer[7] & 0xf; labelLoggingCounterText = LoggingCounter.ToString(); labelLoggingStartDateText = LoggingStart.ToString("yy/MM/dd"); labelLoggingStartTimeText = LoggingStart.ToString("hh:mm:ss"); labelLoggingIntervalText = LoggingInterval.ToString("hh:mm:ss"); if (LoggerCondition == 0x00) { labelLoggerConditionText += "Logger is in initial State" + System.Environment.NewLine; } else { if ((LoggerCondition & 0x80) != 00) { labelLoggerConditionText += "Logger Start Date/Time is set" + System.Environment.NewLine; } if ((LoggerCondition & 0x40) != 00) { labelLoggerConditionText += "Logger Config Date/Time is set" + System.Environment.NewLine; } if ((LoggerCondition & 0x20) != 00) { labelLoggerConditionText += "Logger Interval Time is set" + System.Environment.NewLine; } if ((LoggerCondition & 0x10) != 00) { labelLoggerConditionText += "Logger is active logging" + System.Environment.NewLine; } if ((LoggerCondition & 0x08) != 00) { labelLoggerConditionText += "Logger is waiting for getting active" + System.Environment.NewLine; } if ((LoggerCondition & 0x04) != 00) { labelLoggerConditionText += "Logger is stopped by command" + System.Environment.NewLine; } if ((LoggerCondition & 0x02) != 00) { labelLoggerConditionText += "Logger is stopped by Out of Logger Memory Data" + System.Environment.NewLine; } if ((LoggerCondition & 0x01) != 00) { labelLoggerConditionText += "Logger is stopped by Power Down Reset" + System.Environment.NewLine; } } labelBatteryVoltageText = BatteryVoltage.ToString() + "mV"; if ((ErrorEventCounter & 0x08) == 0x00) { labelErrorEventCounterText = "No Error detected"; } else { labelErrorEventCounterText = (ErrorEventCounter & 0x07).ToString(); } labelReadStatusText = "Read Success"; RaisePropertyChanged(() => labelLoggingCounterText); RaisePropertyChanged(() => labelLoggingStartDateText); RaisePropertyChanged(() => labelLoggingStartTimeText); RaisePropertyChanged(() => labelLoggingIntervalText); RaisePropertyChanged(() => labelLoggerConditionText); RaisePropertyChanged(() => labelBatteryVoltageText); RaisePropertyChanged(() => labelErrorEventCounterText); RaisePropertyChanged(() => labelReadStatusText); } } } } }); }
void TagCompletedEvent(object sender, CSLibrary.Events.OnAccessCompletedEventArgs e) { if (e.access == CSLibrary.Constants.TagAccess.READ) { switch (e.bank) { case CSLibrary.Constants.Bank.PC: if (e.success) { if (switchPCIsToggled) { entryPC = BleMvxApplication._reader.rfid.Options.TagReadPC.pc.ToString(); RaisePropertyChanged(() => entryPC); labelPCStatus = "Ok"; RaisePropertyChanged(() => labelPCStatus); } _updatedEPCLen = (UInt16)((BleMvxApplication._reader.rfid.Options.TagReadPC.pc.ToUshorts()[0]) >> 11); if (switchEPCIsToggled) { readEPCRetryCnt = 7; ReadEPC(); } } else { if (--readPCRetryCnt == 0) { if (switchPCIsToggled) { labelPCStatus = "Er"; RaisePropertyChanged(() => labelPCStatus); } else if (switchEPCIsToggled) { labelEPCStatus = "Er"; RaisePropertyChanged(() => labelEPCStatus); } } else { ReadPC(); } } break; case CSLibrary.Constants.Bank.EPC: if (e.success) { entryEPC = BleMvxApplication._reader.rfid.Options.TagReadEPC.epc.ToString(); RaisePropertyChanged(() => entryEPC); labelEPCStatus = "Ok"; } else { if (--readEPCRetryCnt == 0) { labelEPCStatus = "Er"; } else { ReadEPC(); } } RaisePropertyChanged(() => labelEPCStatus); break; case CSLibrary.Constants.Bank.ACC_PWD: if (e.success) { entryACCPWD = BleMvxApplication._reader.rfid.Options.TagReadAccPwd.password.ToString(); RaisePropertyChanged(() => entryACCPWD); labelACCPWDStatus = "Ok"; } else { if (--readACCPWDRetryCnt == 0) { labelACCPWDStatus = "Er"; } else { ReadACCPWD(); } } RaisePropertyChanged(() => labelACCPWDStatus); break; case CSLibrary.Constants.Bank.KILL_PWD: if (e.success) { entryKILLPWD = BleMvxApplication._reader.rfid.Options.TagReadKillPwd.password.ToString(); RaisePropertyChanged(() => entryKILLPWD); labelKILLPWDStatus = "Ok"; } else { if (--readKILLPWDRetryCnt == 0) { labelKILLPWDStatus = "Er"; } else { ReadKILLPWD(); } } RaisePropertyChanged(() => labelKILLPWDStatus); break; case CSLibrary.Constants.Bank.TID: if (e.success) { entryTIDUID = BleMvxApplication._reader.rfid.Options.TagReadTid.tid.ToString(); RaisePropertyChanged(() => entryTIDUID); labelTIDUIDStatus = "Ok"; } else { if (--readTIDUIDRetryCnt == 0) { labelTIDUIDStatus = "Er"; } else { ReadTIDUID(); } } RaisePropertyChanged(() => labelTIDUIDStatus); break; case CSLibrary.Constants.Bank.USER: if (e.success) { entryUSER = BleMvxApplication._reader.rfid.Options.TagReadUser.pData.ToString(); RaisePropertyChanged(() => entryUSER); labelUSERStatus = "Ok"; } else { if (--readUSERRetryCnt == 0) { labelUSERStatus = "Er"; } else { ReadUSER(); } } RaisePropertyChanged(() => labelUSERStatus); break; case CSLibrary.Constants.Bank.SPECIFIC: if (e.success) { entryKILLPWD = BleMvxApplication._reader.rfid.Options.TagRead.pData.ToString(); RaisePropertyChanged(() => entryKILLPWD); labelKILLPWDStatus = "Ok"; } else { if (--readKILLPWDRetryCnt == 0) { labelKILLPWDStatus = "Er"; } else { ReadKILLPWD(); } } RaisePropertyChanged(() => labelKILLPWDStatus); break; } } if (e.access == CSLibrary.Constants.TagAccess.WRITE) { switch (e.bank) { case CSLibrary.Constants.Bank.PC: if (e.success) { labelPCStatus = "Ok"; } else { if (--writePCRetryCnt == 0) { labelPCStatus = "Er"; } else { WritePC(); } } RaisePropertyChanged(() => labelPCStatus); break; case CSLibrary.Constants.Bank.EPC: if (e.success) { labelEPCStatus = "Ok"; } else { if (--writeEPCRetryCnt == 0) { labelEPCStatus = "Er"; } else { WriteEPC(); } } RaisePropertyChanged(() => labelEPCStatus); break; case CSLibrary.Constants.Bank.ACC_PWD: if (e.success) { labelACCPWDStatus = "Ok"; } else { if (--writeACCPWDRetryCnt == 0) { labelACCPWDStatus = "Er"; } else { WriteACCPWD(); } } RaisePropertyChanged(() => labelACCPWDStatus); break; case CSLibrary.Constants.Bank.KILL_PWD: if (e.success) { labelKILLPWDStatus = "Ok"; } else { if (--writeKILLPWDRetryCnt == 0) { labelKILLPWDStatus = "Er"; } else { WriteKILLPWD(); } } RaisePropertyChanged(() => labelKILLPWDStatus); break; case CSLibrary.Constants.Bank.USER: if (e.success) { labelUSERStatus = "Ok"; } else { if (--writeUSERRetryCnt == 0) { labelUSERStatus = "Er"; } else { WriteUSER(); } } RaisePropertyChanged(() => labelUSERStatus); break; case CSLibrary.Constants.Bank.SPECIFIC: if (e.success) { labelKILLPWDStatus = "Ok"; } else { if (--writeKILLPWDRetryCnt == 0) { labelKILLPWDStatus = "Er"; } else { WriteKILLPWD(); } } RaisePropertyChanged(() => labelKILLPWDStatus); break; } } }
void TagCompletedEvent(object sender, CSLibrary.Events.OnAccessCompletedEventArgs e) { InvokeOnMainThread(() => { if (e.access == CSLibrary.Constants.TagAccess.READ) { if (e.success) { _retryCount = 100; switch (_readProcedure) { case 0: { UInt16[] data = BleMvxApplication._reader.rfid.Options.TagRead.pData.ToUshorts(); switch ((data[0] >> 8) & 0x03) { case 0: delay = 3; break; case 1: delay = 24; break; case 2: delay = 96; break; default: delay = 3; break; } } break; case 1: { _5_5 = BleMvxApplication._reader.rfid.Options.TagRead.pData.ToString(); RaisePropertyChanged(() => _5_5); UInt16[] data = BleMvxApplication._reader.rfid.Options.TagRead.pData.ToUshorts(); add_12 = data[0]; add_13 = data[1]; add_14 = data[2]; add_15 = data[3]; } break; case 2: _5_3 = BleMvxApplication._reader.rfid.Options.TagRead.pData.ToString(); RaisePropertyChanged(() => _5_3); break; case 3: { _5_4 = BleMvxApplication._reader.rfid.Options.TagRead.pData.ToString(); RaisePropertyChanged(() => _5_4); UInt16[] data = BleMvxApplication._reader.rfid.Options.TagRead.pData.ToUshorts(); CODE = data[4]; } break; } _readProcedure++; Process(); } else { if (--_retryCount > 0) { Process(); } else { if (_readProcedure == 1 || _readProcedure == 0) { _5_5 = "Reading error"; RaisePropertyChanged(() => _5_5); _5_3 = "Stoped"; RaisePropertyChanged(() => _5_3); _5_4 = "Stopped"; RaisePropertyChanged(() => _5_4); } else if (_readProcedure == 2) { _5_3 = "Reading error"; RaisePropertyChanged(() => _5_3); _5_4 = "Stopped"; RaisePropertyChanged(() => _5_4); } else if (_readProcedure == 3) { _5_4 = "Reading error"; RaisePropertyChanged(() => _5_4); } _Temp = "Stopped"; RaisePropertyChanged(() => _Temp); } } } }); }
async void TagCompletedEvent(object sender, CSLibrary.Events.OnAccessCompletedEventArgs e) { InvokeOnMainThread(() => { if (e.access == CSLibrary.Constants.TagAccess.READ) { switch (e.bank) { case CSLibrary.Constants.Bank.SPECIFIC: if (!e.success) { buttonResultText = "Read Test Fail : Offset " + BleMvxApplication._reader.rfid.Options.TagRead.offset.ToString(); break; } else { UInt16[] data = BleMvxApplication._reader.rfid.Options.TagRead.pData.ToUshorts(); BleMvxApplication._LargeContent += BleMvxApplication._reader.rfid.Options.TagRead.pData.ToString(); CSLibrary.Debug.WriteLine("Read Test : Offset " + BleMvxApplication._reader.rfid.Options.TagRead.offset.ToString() + " Result : " + (e.success ? "Success" : "Fail")); CSLibrary.Debug.WriteLine("1"); if (data.Length != BleMvxApplication._reader.rfid.Options.TagRead.count) { buttonResultText = "Read size error : Offset " + (BleMvxApplication._reader.rfid.Options.TagRead.offset).ToString() + " Count " + data.Length.ToString(); break; } CSLibrary.Debug.WriteLine("2"); CSLibrary.Debug.WriteLine("3"); if (_RemainReadSize == 0) { buttonResultText = "Read/Verify Test success time " + (DateTime.Now - _startingTime).TotalSeconds.ToString("F2") + "s"; CSLibrary.Debug.WriteLine("Read Test Finish " + DateTime.Now + "/" + _startingTime); CSLibrary.Debug.WriteLine("4"); } else { BleMvxApplication._reader.rfid.Options.TagRead.offset += _ReadChunkSize; if (_RemainReadSize > _ReadChunkSize) { BleMvxApplication._reader.rfid.Options.TagRead.count = _ReadChunkSize; _RemainReadSize -= _ReadChunkSize; } else { BleMvxApplication._reader.rfid.Options.TagRead.count = _RemainReadSize; _RemainReadSize = 0; } buttonResultText = "Reading... Offset " + BleMvxApplication._reader.rfid.Options.TagRead.offset.ToString(); BleMvxApplication._reader.rfid.StartOperation(CSLibrary.Constants.Operation.TAG_READ); CSLibrary.Debug.WriteLine("5"); } } break; } } CSLibrary.Debug.WriteLine("6"); UpdatePage(); }); }
void TagCompletedEvent(object sender, CSLibrary.Events.OnAccessCompletedEventArgs e) { InvokeOnMainThread(() => { if (e.access == CSLibrary.Constants.TagAccess.WRITE) { if (e.success) { System.Threading.Thread.Sleep(100); ReadCommunicationBuffer(); } else { labelReadStatusText = "Read Error"; RaisePropertyChanged(() => labelReadStatusText); } } else if (e.access == CSLibrary.Constants.TagAccess.READ) { if (e.success) { UInt16[] CommunicationBuffer = BleMvxApplication._reader.rfid.Options.TagReadUser.pData.ToUshorts(); var AnswerMessageArea = ((CommunicationBuffer[0] >> 10) & 0x3F); var AnswerIdentifierArea = (CommunicationBuffer[0] & 0x3FF); if (AnswerIdentifierArea == 0x220) { if (AnswerMessageArea != 0x00) { System.Threading.Thread.Sleep(100); ReadCommunicationBuffer(); } else { var LoggerCondition = (CommunicationBuffer[1] >> 8) & 0xff; if (LoggerCondition == 0x00) { labelLoggerConditionText += "Logger is in initial State" + System.Environment.NewLine; } else { if ((LoggerCondition & 0x80) != 00) { labelLoggerConditionText += "Logger Start Date/Time is set" + System.Environment.NewLine; } if ((LoggerCondition & 0x40) != 00) { labelLoggerConditionText += "Logger Config Date/Time is set" + System.Environment.NewLine; } if ((LoggerCondition & 0x20) != 00) { labelLoggerConditionText += "Logger Interval Time is set" + System.Environment.NewLine; } if ((LoggerCondition & 0x10) != 00) { labelLoggerConditionText += "Logger is active logging" + System.Environment.NewLine; } if ((LoggerCondition & 0x08) != 00) { labelLoggerConditionText += "Logger is waiting for getting active" + System.Environment.NewLine; } if ((LoggerCondition & 0x04) != 00) { labelLoggerConditionText += "Logger is stopped by command" + System.Environment.NewLine; } if ((LoggerCondition & 0x02) != 00) { labelLoggerConditionText += "Logger is stopped by Out of Logger Memory Data" + System.Environment.NewLine; } if ((LoggerCondition & 0x01) != 00) { labelLoggerConditionText += "Logger is stopped by Power Down Reset" + System.Environment.NewLine; } } labelReadStatusText = "Read Success"; RaisePropertyChanged(() => labelLoggerConditionText); RaisePropertyChanged(() => labelReadStatusText); } } } } }); }
void TagCompletedEvent(object sender, CSLibrary.Events.OnAccessCompletedEventArgs e) { if (e.access == CSLibrary.Constants.TagAccess.AUTHENTICATE) { if (e.success) { entryResponse = BleMvxApplication._reader.rfid.Options.TagAuthenticate.pData.ToString(); labelResponseStatus = "Ok"; RaisePropertyChanged(() => entryResponse); } else { labelResponseStatus = "E"; } RaisePropertyChanged(() => labelResponseStatus); } else if (e.access == CSLibrary.Constants.TagAccess.UNTRACEABLE) { if (e.success) { _userDialogs.Alert("UNTRACEABLE command success!"); } else { _userDialogs.Alert("UNTRACEABLE command fail!!!"); } } else if (e.access == CSLibrary.Constants.TagAccess.READ) { switch (e.bank) { case CSLibrary.Constants.Bank.USER: if (e.success) { switch (_currentOperation) { case CURRENTOPERATION.READKEY0: entrySelectedKey0 = BleMvxApplication._reader.rfid.Options.TagReadUser.pData.ToString(); labelKey0Status = "O"; RaisePropertyChanged(() => entrySelectedKey0); RaisePropertyChanged(() => labelKey0Status); break; case CURRENTOPERATION.READKEY1: entrySelectedKey1 = BleMvxApplication._reader.rfid.Options.TagReadUser.pData.ToString(); labelKey1Status = "O"; RaisePropertyChanged(() => entrySelectedKey1); RaisePropertyChanged(() => labelKey1Status); break; } } else { switch (_currentOperation) { case CURRENTOPERATION.READKEY0: labelKey0Status = "E"; RaisePropertyChanged(() => labelKey0Status); break; case CURRENTOPERATION.READKEY1: labelKey1Status = "E"; RaisePropertyChanged(() => labelKey1Status); break; } } break; } } else if (e.access == CSLibrary.Constants.TagAccess.WRITE) { switch (e.bank) { case CSLibrary.Constants.Bank.UNTRACEABLE: if (e.success) { switch (_currentOperation) { case CURRENTOPERATION.ACTIVEKEY0: labelKey0Status = "O"; RaisePropertyChanged(() => labelKey0Status); break; case CURRENTOPERATION.ACTIVEKEY1: labelKey1Status = "O"; RaisePropertyChanged(() => labelKey1Status); break; } } else { switch (_currentOperation) { case CURRENTOPERATION.ACTIVEKEY0: labelKey0Status = "E"; RaisePropertyChanged(() => labelKey0Status); break; case CURRENTOPERATION.ACTIVEKEY1: labelKey1Status = "E"; RaisePropertyChanged(() => labelKey1Status); break; } } break; case CSLibrary.Constants.Bank.USER: if (e.success) { switch (_currentOperation) { case CURRENTOPERATION.WRITEKEY0: case CURRENTOPERATION.ACTIVEKEY0: labelKey0Status = "O"; RaisePropertyChanged(() => labelKey0Status); break; case CURRENTOPERATION.WRITEKEY1: case CURRENTOPERATION.ACTIVEKEY1: labelKey1Status = "O"; RaisePropertyChanged(() => labelKey1Status); break; } } else { switch (_currentOperation) { case CURRENTOPERATION.WRITEKEY0: case CURRENTOPERATION.ACTIVEKEY0: labelKey0Status = "E"; RaisePropertyChanged(() => labelKey0Status); break; case CURRENTOPERATION.WRITEKEY1: case CURRENTOPERATION.ACTIVEKEY1: labelKey1Status = "E"; RaisePropertyChanged(() => labelKey1Status); break; } } break; } } }
async void TagCompletedEvent(object sender, CSLibrary.Events.OnAccessCompletedEventArgs e) { InvokeOnMainThread(() => { if (e.access == CSLibrary.Constants.TagAccess.READ) { switch (e.bank) { case CSLibrary.Constants.Bank.SPECIFIC: if (!e.success) { buttonResultText = "Read Test Fail : Offset " + BleMvxApplication._reader.rfid.Options.TagRead.offset.ToString(); break; } else { int i; UInt16[] data = BleMvxApplication._reader.rfid.Options.TagRead.pData.ToUshorts(); CSLibrary.Debug.WriteLine("Read Test : Offset " + BleMvxApplication._reader.rfid.Options.TagRead.offset.ToString() + " Result : " + (e.success ? "Success" : "Fail")); CSLibrary.Debug.WriteLine("1"); if (data.Length != 32) { CSLibrary.Debug.WriteLine("Size error"); } CSLibrary.Debug.WriteLine("2"); for (i = 0; i < data.Length; i++) { if (data[i] != _CurrentPadding) { buttonResultText = "Read OK, Verify Fail : Offset " + (BleMvxApplication._reader.rfid.Options.TagRead.offset + i).ToString(); break; } } CSLibrary.Debug.WriteLine("3"); if (i == data.Length) { if (_RemainReadSize == 0) { buttonResultText = "Read/Verify Test success time " + (DateTime.Now - _startingTime).TotalSeconds.ToString("F2") + "s"; CSLibrary.Debug.WriteLine("Read Test Finish " + DateTime.Now + "/" + _startingTime); CSLibrary.Debug.WriteLine("4"); } else { BleMvxApplication._reader.rfid.Options.TagRead.offset += 32; _RemainReadSize -= 32; buttonResultText = "Reading... Offset " + BleMvxApplication._reader.rfid.Options.TagRead.offset.ToString(); BleMvxApplication._reader.rfid.StartOperation(CSLibrary.Constants.Operation.TAG_READ); CSLibrary.Debug.WriteLine("5"); } } } break; } } CSLibrary.Debug.WriteLine("6"); if (e.access == CSLibrary.Constants.TagAccess.WRITE) { switch (e.bank) { case CSLibrary.Constants.Bank.SPECIFIC: // Block write bank if (!e.success) { buttonResultText = "Block Write Test Fail : Offset " + BleMvxApplication._reader.rfid.Options.TagBlockWrite.offset.ToString() + " Length " + BleMvxApplication._reader.rfid.Options.TagBlockWrite.count.ToString(); break; } else { if (_RemainWriteSize == 0) { buttonResultText = "Write Test success time " + (DateTime.Now - _startingTime).TotalSeconds.ToString("F2") + "s"; CSLibrary.Debug.WriteLine("Write Test Finish" + DateTime.Now + "/" + _startingTime); } else { BleMvxApplication._reader.rfid.Options.TagBlockWrite.offset += BleMvxApplication._reader.rfid.Options.TagBlockWrite.count; BleMvxApplication._reader.rfid.Options.TagBlockWrite.count = _RemainWriteSize; TurnBlockWriteSize(); FullPadding(); BleMvxApplication._reader.rfid.StartOperation(CSLibrary.Constants.Operation.TAG_BLOCK_WRITE); } } break; } } UpdatePage(); }); }
void TagCompletedEvent(object sender, CSLibrary.Events.OnAccessCompletedEventArgs e) { InvokeOnMainThread(() => { if (e.access == CSLibrary.Constants.TagAccess.WRITE) { if (e.success) { System.Threading.Thread.Sleep(100); ReadCommunicationBuffer(); } else { labelReadStatusText = "Read Error"; RaisePropertyChanged(() => labelReadStatusText); } } else if (e.access == CSLibrary.Constants.TagAccess.READ) { if (e.success) { UInt16[] CommunicationBuffer = BleMvxApplication._reader.rfid.Options.TagReadUser.pData.ToUshorts(); var AnswerMessageArea = ((CommunicationBuffer[0] >> 10) & 0x3F); var AnswerIdentifierArea = (CommunicationBuffer[0] & 0x3FF); if (AnswerIdentifierArea == 0x320) { if (AnswerMessageArea != 0x00) { System.Threading.Thread.Sleep(100); ReadCommunicationBuffer(); } else { DateTime CurrentLogger = new DateTime(((CommunicationBuffer[1] >> 8) & 0xff) + 2000, CommunicationBuffer[1] & 0xff, (CommunicationBuffer[2] >> 8) & 0xff, CommunicationBuffer[2] & 0xff, (CommunicationBuffer[3] >> 8) & 0xff, CommunicationBuffer[3] & 0xff); int CurrentLogCycle = CommunicationBuffer[4]; int CurrentTemperature = CommunicationBuffer[5]; int AlternativeTemperature = CommunicationBuffer[6]; int BatteryVoltage = CommunicationBuffer[7] >> 4 & 0xfff; int ErrorEventCounter = CommunicationBuffer[7] & 0x0f; labelCurrentLoggerDateText = CurrentLogger.ToString("yy/MM/dd"); labelCurrentLoggerTimeText = CurrentLogger.ToString("hh:mm:ss"); labelCurrentLogCycleText = CurrentLogCycle.ToString(); if (CurrentTemperature == 0x100) { labelCurrentTemperatureText = "invalid measurement"; } else { if ((CurrentTemperature & 0x100) == 0x100) { labelCurrentTemperatureText = ((-64.0 + (double)(CurrentTemperature & 0xff)) * 0.25).ToString(); } else { labelCurrentTemperatureText = ((double)(CurrentTemperature) * 0.25).ToString(); } } labelAlternativeTemperatureText = AlternativeTemperature.ToString(); labelBatteryVoltageText = BatteryVoltage.ToString() + "mV"; if ((ErrorEventCounter & 0x08) == 0x00) { labelErrorEventCounterText = "No Error detected"; } else { labelErrorEventCounterText = (ErrorEventCounter & 0x07).ToString(); } labelReadStatusText = "Read Success"; RaisePropertyChanged(() => labelCurrentLoggerDateText); RaisePropertyChanged(() => labelCurrentLoggerTimeText); RaisePropertyChanged(() => labelCurrentLogCycleText); RaisePropertyChanged(() => labelCurrentTemperatureText); RaisePropertyChanged(() => labelAlternativeTemperatureText); RaisePropertyChanged(() => labelBatteryVoltageText); RaisePropertyChanged(() => labelErrorEventCounterText); RaisePropertyChanged(() => labelReadStatusText); } } } } }); }
void TagCompletedEvent(object sender, CSLibrary.Events.OnAccessCompletedEventArgs e) { InvokeOnMainThread(() => { if (e.access == CSLibrary.Constants.TagAccess.WRITE) { if (e.success) { System.Threading.Thread.Sleep(100); ReadCommunicationBuffer(); } else { labelReadStatusText = "Read Error"; RaisePropertyChanged(() => labelReadStatusText); } } else if (e.access == CSLibrary.Constants.TagAccess.READ) { if (e.success) { UInt16[] CommunicationBuffer = BleMvxApplication._reader.rfid.Options.TagReadUser.pData.ToUshorts(); var AnswerMessageArea = ((CommunicationBuffer[0] >> 10) & 0x3F); var AnswerIdentifierArea = (CommunicationBuffer[0] & 0x3FF); if (AnswerIdentifierArea == 0x340) { if (AnswerMessageArea != 0x00) { System.Threading.Thread.Sleep(100); ReadCommunicationBuffer(); } else { string[] LoggerObjectConfigurationOptions = new string [] { "TMP112 Temperature Sensor", "CR2032 Battery Voltage", "EM4325 Temperature Sensor", }; var NumberOfLoggerObject = ((CommunicationBuffer[1] >> 8) & 0xfff); var LoggerObjectConfiguration = (CommunicationBuffer[1] & 0xf); Version HardwareVersion = new Version((CommunicationBuffer[2] >> 8) & 0xff, CommunicationBuffer[2] & 0xff, (CommunicationBuffer[3] >> 8) & 0xff); DateTime HardwareVersionDate = new DateTime(CommunicationBuffer[3] & 0xff + 2000, (CommunicationBuffer[4] >> 8) & 0xff, CommunicationBuffer[4] & 0xff); Version SoftwareVersion = new Version((CommunicationBuffer[5] >> 8) & 0xff, CommunicationBuffer[5] & 0xff, (CommunicationBuffer[6] >> 8) & 0xff); DateTime SoftwareVersionDate = new DateTime(CommunicationBuffer[6] & 0xff + 2000, (CommunicationBuffer[7] >> 8) & 0xff, CommunicationBuffer[7] & 0xff); labelNumberOfLoggerObjectText = NumberOfLoggerObject.ToString(); switch (LoggerObjectConfiguration) { case 0x01: labelLoggerObjectConfigurationText = LoggerObjectConfigurationOptions[0]; break; case 0x02: labelLoggerObjectConfigurationText = LoggerObjectConfigurationOptions[1]; break; case 0x04: labelLoggerObjectConfigurationText = LoggerObjectConfigurationOptions[2]; break; } labelHardwareVersionText = HardwareVersion.ToString(); labelHardwareVersionDateText = HardwareVersionDate.ToString("yy/MM/dd"); labelSoftwareVersionText = SoftwareVersion.ToString(); labelSoftwareVersionDateText = SoftwareVersionDate.ToString("yy/MM/dd"); labelReadStatusText = "Read Success"; RaisePropertyChanged(() => labelNumberOfLoggerObjectText); RaisePropertyChanged(() => labelLoggerObjectConfigurationText); RaisePropertyChanged(() => labelHardwareVersionText); RaisePropertyChanged(() => labelHardwareVersionDateText); RaisePropertyChanged(() => labelSoftwareVersionText); RaisePropertyChanged(() => labelSoftwareVersionDateText); RaisePropertyChanged(() => labelReadStatusText); } } } } }); }
void TagCompletedEvent(object sender, CSLibrary.Events.OnAccessCompletedEventArgs e) { if (!e.success) { GetLog(); } // process result switch (_ProcessState) { // run next step pcocess case 0: case 1: case 2: case 7: case 8: System.Threading.Thread.Sleep(500); _ProcessState++; GetLog(); break; case 3: { UInt16[] TagData = BleMvxApplication._reader.rfid.Options.TagReadUser.pData.ToUshorts(); StartTime = UnixTime(TagData[0] << 16 | TagData[1]); Interval = TagData[2]; TempOffset = 0.25 * (TagData[3]); Total = TagData[4]; //label17.Text = "Total : " + Total.ToString(); if (Total >= 10752) { //label17.Text += " (MemoryBank Full)"; } // read first data set _ProcessState++; GetLog(); } break; case 4: { System.Threading.Thread.Sleep(2500); _ProcessState++; GetLog(); } break; case 5: { if ((BleMvxApplication._reader.rfid.Options.TagReadUser.pData.ToUshorts()[0] & 0x04) != 0x0000) { _ProcessState++; ReadRecord = (UInt16)(Total - ReadOffset); if (ReadRecord > 366) { ReadRecord = 366; } ReadUInt16 = (UInt16)((ReadRecord + 1) / 2); ReadRecordOffset = 0; if (ReadUInt16 > _ReadChunkSize) { ReadRecordSize = _ReadChunkSize; } else { ReadRecordSize = ReadUInt16; } } else { System.Threading.Thread.Sleep(500); } GetLog(); } break; case 6: InvokeOnMainThread(() => { UInt16[] DataPtr = BleMvxApplication._reader.rfid.Options.TagReadUser.pData.ToUshorts(); for (int cnt = 0; cnt < DataPtr.Length; cnt++) { ColdChainTagTempLogInfoViewModel ins; double temp; temp = ((DataPtr[cnt] >> 8) * 0.25) - TempOffset; ins = new ColdChainTagTempLogInfoViewModel(); ins.Index = (TagInfoList.Count + 1).ToString(); ins.Time = StartTime.ToString(); ins.Temp = temp.ToString(); TagInfoList.Add(ins); StartTime = StartTime.AddSeconds(Interval); if (TagInfoList.Count != Total) { temp = ((DataPtr[cnt] & 0xff) * 0.25) - TempOffset; ins = new ColdChainTagTempLogInfoViewModel(); ins.Index = (TagInfoList.Count + 1).ToString(); ins.Time = StartTime.ToString(); ins.Temp = temp.ToString(); TagInfoList.Add(ins); StartTime = StartTime.AddSeconds(Interval); } } if ((ReadRecordOffset + ReadRecordSize) >= ReadUInt16) { ReadOffset += (UInt16)(ReadUInt16 * 2); if (ReadOffset < Total) { _ProcessState = 4; } else { _ProcessState = 7; } } else { ReadUInt16 -= ReadRecordSize; ReadRecordOffset += ReadRecordSize; if (ReadUInt16 > _ReadChunkSize) { ReadRecordSize = _ReadChunkSize; } else { ReadRecordSize = ReadUInt16; } } GetLog(); }); break; } }
void TagCompletedEvent(object sender, CSLibrary.Events.OnAccessCompletedEventArgs e) { if (e.access == CSLibrary.Constants.TagAccess.READ) { switch (e.bank) { case CSLibrary.Constants.Bank.USER: if (e.success) { switch (_currentOperation) { case CURRENTOPERATION.READKEY0: entrySelectedKey0 = BleMvxApplication._reader.rfid.Options.TagReadUser.pData.ToString(); labelKey0Status = "O"; RaisePropertyChanged(() => entrySelectedKey0); RaisePropertyChanged(() => labelKey0Status); break; case CURRENTOPERATION.READKEY1: entrySelectedKey1 = BleMvxApplication._reader.rfid.Options.TagReadUser.pData.ToString(); labelKey1Status = "O"; RaisePropertyChanged(() => entrySelectedKey1); RaisePropertyChanged(() => labelKey1Status); break; } } else { switch (_currentOperation) { case CURRENTOPERATION.READKEY0: labelKey0Status = "E"; RaisePropertyChanged(() => labelKey0Status); break; case CURRENTOPERATION.READKEY1: labelKey1Status = "E"; RaisePropertyChanged(() => labelKey1Status); break; } } if (_currentOperation == CURRENTOPERATION.READKEY0) { ReadKey1(); } break; } } if (e.access == CSLibrary.Constants.TagAccess.WRITE) { switch (e.bank) { case CSLibrary.Constants.Bank.UNTRACEABLE: if (e.success) { switch (_currentOperation) { case CURRENTOPERATION.ACTIVEKEY0: labelKey0Status = "O"; RaisePropertyChanged(() => labelKey0Status); break; case CURRENTOPERATION.ACTIVEKEY1: labelKey1Status = "O"; RaisePropertyChanged(() => labelKey1Status); break; } } else { switch (_currentOperation) { case CURRENTOPERATION.ACTIVEKEY0: labelKey0Status = "E"; RaisePropertyChanged(() => labelKey0Status); break; case CURRENTOPERATION.ACTIVEKEY1: labelKey1Status = "E"; RaisePropertyChanged(() => labelKey1Status); break; } } break; case CSLibrary.Constants.Bank.USER: if (e.success) { switch (_currentOperation) { case CURRENTOPERATION.WRITEKEY0: labelKey0Status = "O"; RaisePropertyChanged(() => labelKey0Status); break; case CURRENTOPERATION.WRITEKEY1: labelKey1Status = "O"; RaisePropertyChanged(() => labelKey1Status); break; } } else { switch (_currentOperation) { case CURRENTOPERATION.WRITEKEY0: labelKey0Status = "E"; RaisePropertyChanged(() => labelKey0Status); break; case CURRENTOPERATION.WRITEKEY1: labelKey1Status = "E"; RaisePropertyChanged(() => labelKey1Status); break; } } if (_currentOperation == CURRENTOPERATION.WRITEKEY0) { WriteKey1(); } break; } } }
void TagCompletedEvent(object sender, CSLibrary.Events.OnAccessCompletedEventArgs e) { InvokeOnMainThread(() => { if (e.access == CSLibrary.Constants.TagAccess.AUTHENTICATE) { if (e.success) { switch (_currentProcess) { case 0: { var Response = BleMvxApplication._reader.rfid.Options.TagAuthenticate.pData.ToString(); string decChallenge; if (TAM1Decrypt(Response, entrySelectedKey0, out decChallenge)) { labelResponseStatus = "Ok"; } else { labelResponseStatus = "Decode Error"; } RaisePropertyChanged(() => entryResponse); if (decChallenge == entryChallenge) { labelResult1Text = "Challenge Match, Success !"; } else { labelResult1Text = "Challenge NOT match, Fail !"; } RaisePropertyChanged(() => labelResult1Text); } break; case 1: { var Response = BleMvxApplication._reader.rfid.Options.TagAuthenticate.pData.ToString(); CSLibrary.Debug.WriteLine("Response Length : " + Response.Length); byte[] DecResponse = null; string result = ""; try { switch (protMode) { case 0: { string decChallenge; string data; if (TAM2ProtMode0Decrypt(Response, entrySelectedKey0, out decChallenge, out data)) { labelResponseStatus = "Ok"; entryResponse = Response; } else { labelResponseStatus = "Decode Error"; entryResponse = ""; } RaisePropertyChanged(() => entryResponse); if (decChallenge == entryChallenge) { labelResult2Text = "Challenge Match, Success !"; labelResult2DateText = data; } else { labelResult2Text = "Challenge NOT match, Fail !"; labelResult2DateText = ""; } } break; case 1: { string decChallenge; string data; if (TAM2ProtMode1Decrypt(Response, entrySelectedKey0, out decChallenge, out data)) { labelResponseStatus = "Ok"; entryResponse = Response; } else { labelResponseStatus = "Decode Error"; entryResponse = ""; } RaisePropertyChanged(() => entryResponse); if (decChallenge == entryChallenge) { labelResult2Text = "Challenge Match, Success !"; labelResult2DateText = data; } else { labelResult2Text = "Challenge NOT match, Fail !"; labelResult2DateText = ""; } } break; case 2: { string decChallenge; string data; if (TAM2ProtMode2Decrypt(Response, entrySelectedKey0, out decChallenge, out data)) { labelResponseStatus = "Ok"; entryResponse = Response; } else { labelResponseStatus = "Decode Error"; entryResponse = ""; } RaisePropertyChanged(() => entryResponse); if (decChallenge == entryChallenge) { labelResult2Text = "Challenge Match, Success !"; labelResult2DateText = data; } else { labelResult2Text = "Challenge NOT match, Fail !"; labelResult2DateText = ""; } } break; case 3: { string decChallenge; string data; if (TAM2ProtMode3Decrypt(Response, entrySelectedKey0, out decChallenge, out data)) { labelResponseStatus = "Ok"; entryResponse = Response; } else { labelResponseStatus = "Decode Error"; entryResponse = ""; } RaisePropertyChanged(() => entryResponse); if (decChallenge == entryChallenge) { labelResult2Text = "Challenge Match, Success !"; labelResult2DateText = data; } else { labelResult2Text = "Challenge NOT match, Fail !"; labelResult2DateText = ""; } } break; } } catch (Exception ex) { } RaisePropertyChanged(() => entryResponse); RaisePropertyChanged(() => labelResponseStatus); RaisePropertyChanged(() => labelResult2Text); RaisePropertyChanged(() => labelResult2DateText); } break; } } else { labelResponseStatus = "E"; switch (_currentProcess) { case 0: labelResult1Text = "Read error"; RaisePropertyChanged(() => labelResult1Text); break; case 1: labelResult2Text = "Read error"; labelResult2DateText = ""; RaisePropertyChanged(() => labelResult2Text); RaisePropertyChanged(() => labelResult2DateText); break; } } RaisePropertyChanged(() => labelResponseStatus); } else if (e.access == CSLibrary.Constants.TagAccess.UNTRACEABLE) { if (e.success) { _userDialogs.Alert("UNTRACEABLE command success!"); } else { _userDialogs.Alert("UNTRACEABLE command fail!!!"); } } else if (e.access == CSLibrary.Constants.TagAccess.READ) { switch (e.bank) { case CSLibrary.Constants.Bank.USER: if (e.success) { switch (_currentOperation) { case CURRENTOPERATION.READKEY0: entrySelectedKey0 = BleMvxApplication._reader.rfid.Options.TagReadUser.pData.ToString(); labelKey0Status = "O"; RaisePropertyChanged(() => entrySelectedKey0); RaisePropertyChanged(() => labelKey0Status); break; case CURRENTOPERATION.READKEY1: entrySelectedKey1 = BleMvxApplication._reader.rfid.Options.TagReadUser.pData.ToString(); labelKey1Status = "O"; RaisePropertyChanged(() => entrySelectedKey1); RaisePropertyChanged(() => labelKey1Status); break; } } else { switch (_currentOperation) { case CURRENTOPERATION.READKEY0: labelKey0Status = "E"; RaisePropertyChanged(() => labelKey0Status); break; case CURRENTOPERATION.READKEY1: labelKey1Status = "E"; RaisePropertyChanged(() => labelKey1Status); break; } } break; } } else if (e.access == CSLibrary.Constants.TagAccess.WRITE) { switch (e.bank) { case CSLibrary.Constants.Bank.UNTRACEABLE: if (e.success) { switch (_currentOperation) { case CURRENTOPERATION.ACTIVEKEY0: labelKey0Status = "O"; RaisePropertyChanged(() => labelKey0Status); break; case CURRENTOPERATION.ACTIVEKEY1: labelKey1Status = "O"; RaisePropertyChanged(() => labelKey1Status); break; } } else { switch (_currentOperation) { case CURRENTOPERATION.ACTIVEKEY0: labelKey0Status = "E"; RaisePropertyChanged(() => labelKey0Status); break; case CURRENTOPERATION.ACTIVEKEY1: labelKey1Status = "E"; RaisePropertyChanged(() => labelKey1Status); break; } } break; case CSLibrary.Constants.Bank.SPECIFIC: if (e.success) { switch (_currentOperation) { case CURRENTOPERATION.WRITEKEY0: case CURRENTOPERATION.ACTIVEKEY0: labelKey0Status = "O"; RaisePropertyChanged(() => labelKey0Status); break; case CURRENTOPERATION.WRITEKEY1: case CURRENTOPERATION.ACTIVEKEY1: labelKey1Status = "O"; RaisePropertyChanged(() => labelKey1Status); break; } } else { switch (_currentOperation) { case CURRENTOPERATION.WRITEKEY0: case CURRENTOPERATION.ACTIVEKEY0: labelKey0Status = "E"; RaisePropertyChanged(() => labelKey0Status); break; case CURRENTOPERATION.WRITEKEY1: case CURRENTOPERATION.ACTIVEKEY1: labelKey1Status = "E"; RaisePropertyChanged(() => labelKey1Status); break; } } break; } } }); }