void ReadUserData(ushort Offset, ushort Count, ref CSLibrary.Structures.S_DATA data) { Console.Write("Read User Data Offset:{0} Count:{1}", Offset, Count); BleMvxApplication._reader.rfid.Options.TagWriteUser.accessPassword = 0; BleMvxApplication._reader.rfid.Options.TagReadUser.offset = Offset; BleMvxApplication._reader.rfid.Options.TagReadUser.count = Count; BleMvxApplication._reader.rfid.Options.TagReadUser.pData = data; BleMvxApplication._reader.rfid.StartOperation(CSLibrary.Constants.Operation.TAG_READ_USER); }
/// <summary> /// /// </summary> /// <returns></returns> private void StopLog() { switch (_ProcessState) { case 0: { for (; _ProcessTagNumber < TagInfoList.Count; _ProcessTagNumber++) { if (TagInfoList[_ProcessTagNumber].LogStatus != "Stop") { break; } } if (_ProcessTagNumber >= TagInfoList.Count) { _userDialogs.ShowSuccess("Stop Log Finish!", 2000); _DisableAllTagsLog = false; return; } BleMvxApplication._reader.rfid.Options.TagSelected.epcMask = new CSLibrary.Structures.S_MASK(TagInfoList[_ProcessTagNumber].EPC); BleMvxApplication._reader.rfid.Options.TagSelected.flags = CSLibrary.Constants.SelectMaskFlags.ENABLE_TOGGLE; BleMvxApplication._reader.rfid.Options.TagSelected.epcMaskOffset = 0; BleMvxApplication._reader.rfid.Options.TagSelected.epcMaskLength = (uint)BleMvxApplication._reader.rfid.Options.TagSelected.epcMask.Length * 8; BleMvxApplication._reader.rfid.StartOperation(CSLibrary.Constants.Operation.TAG_SELECTED); BleMvxApplication._reader.rfid.Options.TagWriteUser.accessPassword = 0x0; BleMvxApplication._reader.rfid.Options.TagWriteUser.offset = 260; BleMvxApplication._reader.rfid.Options.TagWriteUser.count = 1; BleMvxApplication._reader.rfid.Options.TagWriteUser.pData = new UInt16[1]; BleMvxApplication._reader.rfid.Options.TagWriteUser.pData[0] = 0x0002; BleMvxApplication._reader.rfid.StartOperation(CSLibrary.Constants.Operation.TAG_WRITE_USER); } break; case 1: { BleMvxApplication._reader.rfid.Options.TagWriteUser.offset = 240; BleMvxApplication._reader.rfid.Options.TagWriteUser.count = 1; BleMvxApplication._reader.rfid.Options.TagWriteUser.pData = new UInt16[1]; BleMvxApplication._reader.rfid.Options.TagWriteUser.pData[0] = 0xa600; BleMvxApplication._reader.rfid.StartOperation(CSLibrary.Constants.Operation.TAG_WRITE_USER); } break; case 2: { BleMvxApplication._reader.rfid.Options.TagWriteUser.offset = 240; BleMvxApplication._reader.rfid.Options.TagWriteUser.count = 1; BleMvxApplication._reader.rfid.Options.TagWriteUser.pData = new UInt16[1]; BleMvxApplication._reader.rfid.Options.TagWriteUser.pData[0] = 0xa600; BleMvxApplication._reader.rfid.StartOperation(CSLibrary.Constants.Operation.TAG_WRITE_USER); } break; case 3: { BleMvxApplication._reader.rfid.Options.TagReadUser.offset = 264; BleMvxApplication._reader.rfid.Options.TagReadUser.count = 1; BleMvxApplication._reader.rfid.Options.TagReadUser.pData = new CSLibrary.Structures.S_DATA(new UInt16[1]); BleMvxApplication._reader.rfid.StartOperation(CSLibrary.Constants.Operation.TAG_READ_USER); } break; case 4: { TagInfoList[_ProcessTagNumber].T1 = "OK"; TagInfoList[_ProcessTagNumber].T2 = "OK"; if ((BleMvxApplication._reader.rfid.Options.TagReadUser.pData.ToUshorts()[0] & 0x0006) != 0x0000) { if ((BleMvxApplication._reader.rfid.Options.TagReadUser.pData.ToUshorts()[0] & 0x0002) != 0x0000) { TagInfoList[_ProcessTagNumber].T1 = "Fail"; } if ((BleMvxApplication._reader.rfid.Options.TagReadUser.pData.ToUshorts()[0] & 0x0004) != 0x0000) { TagInfoList[_ProcessTagNumber].T2 = "Fail"; } // Show Temperature alarm on LED BleMvxApplication._reader.rfid.Options.TagWriteUser.offset = 264; BleMvxApplication._reader.rfid.Options.TagWriteUser.count = 1; BleMvxApplication._reader.rfid.Options.TagWriteUser.pData[0] = (UInt16)(BleMvxApplication._reader.rfid.Options.TagReadUser.pData.ToUshorts()[0] | 0x01); BleMvxApplication._reader.rfid.StartOperation(CSLibrary.Constants.Operation.TAG_WRITE_USER); } else { _ProcessState++; StopLog(); } } break; case 5: { BleMvxApplication._reader.rfid.Options.TagWriteUser.offset = 240; BleMvxApplication._reader.rfid.Options.TagWriteUser.count = 1; BleMvxApplication._reader.rfid.Options.TagWriteUser.pData = new UInt16[1]; BleMvxApplication._reader.rfid.Options.TagWriteUser.pData[0] = 0x0000; BleMvxApplication._reader.rfid.StartOperation(CSLibrary.Constants.Operation.TAG_WRITE_USER); } break; case 6: { CSLibrary.Structures.S_DATA value = new CSLibrary.Structures.S_DATA("0000"); ReadUserData(240, 1, ref value); } break; case 7: { TagInfoList[_ProcessTagNumber].LogStatus = "Stop"; TagInfoList[_ProcessTagNumber].B = ""; _ProcessTagNumber++; _ProcessState = 0; StopLog(); } break; } }
/// <summary> /// return /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <returns></returns> private void StartLog() { switch (_ProcessState) { case 0: { for (; _ProcessTagNumber < TagInfoList.Count; _ProcessTagNumber++) { if (TagInfoList[_ProcessTagNumber].LogStatus != "Recording") { break; } } if (_ProcessTagNumber >= TagInfoList.Count) { _userDialogs.ShowSuccess("Start Log Finish!", 2000); _EnableAllTagsLog = false; return; } BleMvxApplication._reader.rfid.Options.TagSelected.epcMask = new CSLibrary.Structures.S_MASK(TagInfoList[_ProcessTagNumber].EPC); BleMvxApplication._reader.rfid.Options.TagSelected.flags = CSLibrary.Constants.SelectMaskFlags.ENABLE_TOGGLE; BleMvxApplication._reader.rfid.Options.TagSelected.epcMaskOffset = 0; BleMvxApplication._reader.rfid.Options.TagSelected.epcMaskLength = (uint)BleMvxApplication._reader.rfid.Options.TagSelected.epcMask.Length * 8; BleMvxApplication._reader.rfid.StartOperation(CSLibrary.Constants.Operation.TAG_SELECTED); BleMvxApplication._reader.rfid.Options.TagWriteUser.accessPassword = 0x0; BleMvxApplication._reader.rfid.Options.TagWriteUser.offset = 240; BleMvxApplication._reader.rfid.Options.TagWriteUser.count = 1; BleMvxApplication._reader.rfid.Options.TagWriteUser.pData = new UInt16[1]; BleMvxApplication._reader.rfid.Options.TagWriteUser.pData[0] = 0xa600; BleMvxApplication._reader.rfid.StartOperation(CSLibrary.Constants.Operation.TAG_WRITE_USER); } break; case 1: { UInt32 uut = (UInt32)UnixTime(DateTime.Now); UInt16 Offset = (UInt16)(Math.Abs(BleMvxApplication._coldChain_TempOffset) * 4); BleMvxApplication._reader.rfid.Options.TagWriteUser.offset = 0; BleMvxApplication._reader.rfid.Options.TagWriteUser.count = 4; BleMvxApplication._reader.rfid.Options.TagWriteUser.pData = new UInt16[4]; BleMvxApplication._reader.rfid.Options.TagWriteUser.pData[0] = (UInt16)(uut >> 16); BleMvxApplication._reader.rfid.Options.TagWriteUser.pData[1] = (UInt16)(uut & 0xffff); BleMvxApplication._reader.rfid.Options.TagWriteUser.pData[2] = (UInt16)BleMvxApplication._coldChain_LogInterval; BleMvxApplication._reader.rfid.Options.TagWriteUser.pData[3] = (UInt16)(Offset); BleMvxApplication._reader.rfid.StartOperation(CSLibrary.Constants.Operation.TAG_WRITE_USER); } break; case 2: { //UInt16 OTemp1 = (UInt16)(double.Parse(textBox_OTH1.Text) * 4); //UInt16 UTemp1 = (UInt16)(double.Parse(textBox_UTH1.Text) * 4); //UInt16 Count = (UInt16)((UInt16.Parse(textBox_THC1.Text) << 3) | (UInt16.Parse(textBox_THC2.Text) << 9)); UInt16 OTemp1 = (UInt16)(BleMvxApplication._coldChain_Temp1THOver * 4); UInt16 UTemp1 = (UInt16)(BleMvxApplication._coldChain_Temp1THUnder * 4); UInt16 Count = (UInt16)((BleMvxApplication._coldChain_Temp1THCount << 3) | (BleMvxApplication._coldChain_Temp2THCount << 9)); BleMvxApplication._reader.rfid.Options.TagWriteUser.offset = 262; BleMvxApplication._reader.rfid.Options.TagWriteUser.count = 3; BleMvxApplication._reader.rfid.Options.TagWriteUser.pData = new UInt16[3]; BleMvxApplication._reader.rfid.Options.TagWriteUser.pData[0] = (UInt16)(OTemp1); BleMvxApplication._reader.rfid.Options.TagWriteUser.pData[1] = (UInt16)(UTemp1); BleMvxApplication._reader.rfid.Options.TagWriteUser.pData[2] = Count; BleMvxApplication._reader.rfid.StartOperation(CSLibrary.Constants.Operation.TAG_WRITE_USER); } break; case 3: { //UInt16 UTemp2 = (UInt16)(double.Parse(textBox_UTH2.Text) * 4); //UInt16 OTemp2 = (UInt16)(double.Parse(textBox_OTH2.Text) * 4); UInt16 UTemp2 = (UInt16)(BleMvxApplication._coldChain_Temp2THUnder * 4); UInt16 OTemp2 = (UInt16)(BleMvxApplication._coldChain_Temp2THOver * 4); BleMvxApplication._reader.rfid.Options.TagWriteUser.offset = 266; BleMvxApplication._reader.rfid.Options.TagWriteUser.count = 2; BleMvxApplication._reader.rfid.Options.TagWriteUser.pData = new UInt16[2]; BleMvxApplication._reader.rfid.Options.TagWriteUser.pData[0] = (UInt16)(OTemp2); BleMvxApplication._reader.rfid.Options.TagWriteUser.pData[1] = (UInt16)(UTemp2); BleMvxApplication._reader.rfid.StartOperation(CSLibrary.Constants.Operation.TAG_WRITE_USER); } break; case 4: { BleMvxApplication._reader.rfid.Options.TagWriteUser.offset = 260; BleMvxApplication._reader.rfid.Options.TagWriteUser.count = 1; BleMvxApplication._reader.rfid.Options.TagWriteUser.pData = new UInt16[1]; BleMvxApplication._reader.rfid.Options.TagWriteUser.pData[0] = 0x0001; BleMvxApplication._reader.rfid.StartOperation(CSLibrary.Constants.Operation.TAG_WRITE_USER); } break; case 5: { BleMvxApplication._reader.rfid.Options.TagWriteUser.offset = 240; BleMvxApplication._reader.rfid.Options.TagWriteUser.count = 1; BleMvxApplication._reader.rfid.Options.TagWriteUser.pData = new UInt16[1]; BleMvxApplication._reader.rfid.Options.TagWriteUser.pData[0] = 0xa000; BleMvxApplication._reader.rfid.StartOperation(CSLibrary.Constants.Operation.TAG_WRITE_USER); } break; case 6: { CSLibrary.Structures.S_DATA value = new CSLibrary.Structures.S_DATA("0000"); ReadUserData(240, 1, ref value); } break; case 7: { TagInfoList[_ProcessTagNumber].LogStatus = "Recording"; TagInfoList[_ProcessTagNumber].T1 = ""; TagInfoList[_ProcessTagNumber].T2 = ""; _ProcessTagNumber++; _ProcessState = 0; StartLog(); } break; } }