Пример #1
0
 /// <summary>
 /// Parse tag opspec result type
 /// </summary>
 /// <param name="opSpecResult"></param>
 /// <param name="tag"></param>
 private void ParseTagOpSpecResultType(UNION_AccessCommandOpSpecResult opSpecResult, ref TagReadData tag)
 {
     // TODO: Generalize ReaderCodeExceptions to cover all types of readers, not just Serial
     if (opSpecResult[0].GetType() == typeof(PARAM_C1G2ReadOpSpecResult))
     {
         switch (((PARAM_C1G2ReadOpSpecResult)opSpecResult[0]).Result)
         {
             case ENUM_C1G2ReadResultType.Success:
                 tag._data = ByteConv.ConvertFromUshortArray(((PARAM_C1G2ReadOpSpecResult)opSpecResult[0]).ReadData.data.ToArray());
                 tagOpResponse = ((PARAM_C1G2ReadOpSpecResult)opSpecResult[0]).ReadData.data.ToArray();
                 break;
             case ENUM_C1G2ReadResultType.No_Response_From_Tag:
                 throw new ReaderCodeException("No response from tag", FAULT_PROTOCOL_NO_DATA_READ_Exception.StatusCode);
             case ENUM_C1G2ReadResultType.Nonspecific_Reader_Error:
                 throw new ReaderException("Non-specific reader error");
             case ENUM_C1G2ReadResultType.Nonspecific_Tag_Error:
                 throw new ReaderCodeException("Non-specific tag error", FAULT_GENERAL_TAG_ERROR_Exception.StatusCode);
             case ENUM_C1G2ReadResultType.Memory_Locked_Error:
                 throw new ReaderCodeException("Tag memory locked error", FAULT_GEN2_PROTOCOL_MEMORY_LOCKED_Exception.StatusCode);
             case ENUM_C1G2ReadResultType.Memory_Overrun_Error:
                 throw new ReaderCodeException("Tag memory overrun error", FAULT_GEN2_PROTOCOL_MEMORY_OVERRUN_BAD_PC_Exception.StatusCode);
         }
     }
     else if (opSpecResult[0].GetType() == typeof(PARAM_C1G2WriteOpSpecResult))
     {
         switch (((PARAM_C1G2WriteOpSpecResult)opSpecResult[0]).Result)
         {
             case ENUM_C1G2WriteResultType.Success:
                 break;
             case ENUM_C1G2WriteResultType.Insufficient_Power:
                 throw new ReaderCodeException("Insufficient power", FAULT_GEN2_PROTOCOL_INSUFFICIENT_POWER_Exception.StatusCode);
             case ENUM_C1G2WriteResultType.Tag_Memory_Locked_Error:
                 throw new ReaderCodeException("Tag memory locked error", FAULT_GEN2_PROTOCOL_MEMORY_LOCKED_Exception.StatusCode);
             case ENUM_C1G2WriteResultType.No_Response_From_Tag:
                 throw new ReaderCodeException("No response from tag", FAULT_PROTOCOL_NO_DATA_READ_Exception.StatusCode);
             case ENUM_C1G2WriteResultType.Nonspecific_Reader_Error:
                 throw new ReaderException("Non-specific reader error");
             case ENUM_C1G2WriteResultType.Nonspecific_Tag_Error:
                 throw new ReaderCodeException("Non-specific tag error", FAULT_GENERAL_TAG_ERROR_Exception.StatusCode);
             case ENUM_C1G2WriteResultType.Tag_Memory_Overrun_Error:
                 throw new ReaderCodeException("Tag memory overrun error", FAULT_GEN2_PROTOCOL_MEMORY_OVERRUN_BAD_PC_Exception.StatusCode);
         }
     }
     else if (opSpecResult[0].GetType() == typeof(PARAM_C1G2KillOpSpecResult))
     {
         switch (((PARAM_C1G2KillOpSpecResult)opSpecResult[0]).Result)
         {
             case ENUM_C1G2KillResultType.Success:
                 break;
             case ENUM_C1G2KillResultType.Insufficient_Power:
                 throw new ReaderCodeException("Insufficient power", FAULT_GEN2_PROTOCOL_INSUFFICIENT_POWER_Exception.StatusCode);
             case ENUM_C1G2KillResultType.No_Response_From_Tag:
                 throw new ReaderCodeException("No response from tag", FAULT_PROTOCOL_NO_DATA_READ_Exception.StatusCode);
             case ENUM_C1G2KillResultType.Nonspecific_Reader_Error:
                 throw new ReaderException("Non-specific reader error");
             case ENUM_C1G2KillResultType.Nonspecific_Tag_Error:
                 throw new ReaderCodeException("Non-specific tag error", FAULT_GENERAL_TAG_ERROR_Exception.StatusCode);
             case ENUM_C1G2KillResultType.Zero_Kill_Password_Error:
                 throw new ReaderException("Zero kill password error");
         }
     }
     else if (opSpecResult[0].GetType() == typeof(PARAM_C1G2BlockWriteOpSpecResult))
     {
         switch (((PARAM_C1G2BlockWriteOpSpecResult)opSpecResult[0]).Result)
         {
             case ENUM_C1G2BlockWriteResultType.Success:
                 break;
             case ENUM_C1G2BlockWriteResultType.Insufficient_Power:
                 throw new ReaderCodeException("Insufficient power", FAULT_GEN2_PROTOCOL_INSUFFICIENT_POWER_Exception.StatusCode);
             case ENUM_C1G2BlockWriteResultType.Tag_Memory_Locked_Error:
                 throw new ReaderCodeException("Tag memory locked error", FAULT_GEN2_PROTOCOL_MEMORY_LOCKED_Exception.StatusCode);
             case ENUM_C1G2BlockWriteResultType.No_Response_From_Tag:
                 throw new ReaderCodeException("No response from tag", FAULT_PROTOCOL_NO_DATA_READ_Exception.StatusCode);
             case ENUM_C1G2BlockWriteResultType.Nonspecific_Reader_Error:
                 throw new ReaderException("Non-specific reader error");
             case ENUM_C1G2BlockWriteResultType.Nonspecific_Tag_Error:
                 throw new ReaderCodeException("Non-specific tag error", FAULT_GENERAL_TAG_ERROR_Exception.StatusCode);
             case ENUM_C1G2BlockWriteResultType.Tag_Memory_Overrun_Error:
                 throw new ReaderCodeException("Tag memory overrun error", FAULT_GEN2_PROTOCOL_MEMORY_OVERRUN_BAD_PC_Exception.StatusCode);
         }
     }
     else if (opSpecResult[0].GetType() == typeof(PARAM_C1G2LockOpSpecResult))
     {
         switch (((PARAM_C1G2LockOpSpecResult)opSpecResult[0]).Result)
         {
             case ENUM_C1G2LockResultType.Success:
                 break;
             case ENUM_C1G2LockResultType.Insufficient_Power:
                 throw new ReaderCodeException("Insufficient power", FAULT_GEN2_PROTOCOL_INSUFFICIENT_POWER_Exception.StatusCode);
             case ENUM_C1G2LockResultType.No_Response_From_Tag:
                 throw new ReaderCodeException("No response from tag", FAULT_PROTOCOL_NO_DATA_READ_Exception.StatusCode);
             case ENUM_C1G2LockResultType.Nonspecific_Reader_Error:
                 throw new ReaderException("Non-specific reader error");
             case ENUM_C1G2LockResultType.Nonspecific_Tag_Error:
                 throw new ReaderCodeException("Non-specific tag error", FAULT_GENERAL_TAG_ERROR_Exception.StatusCode);
         }
     }
     else if (opSpecResult[0].GetType() == typeof(PARAM_C1G2BlockEraseOpSpecResult))
     {
         switch (((PARAM_C1G2BlockEraseOpSpecResult)opSpecResult[0]).Result)
         {
             case ENUM_C1G2BlockEraseResultType.Success:
                 break;
             case ENUM_C1G2BlockEraseResultType.Insufficient_Power:
                 throw new ReaderCodeException("Insufficient power", FAULT_GEN2_PROTOCOL_INSUFFICIENT_POWER_Exception.StatusCode);
             case ENUM_C1G2BlockEraseResultType.No_Response_From_Tag:
                 throw new ReaderCodeException("No response from tag", FAULT_PROTOCOL_NO_DATA_READ_Exception.StatusCode);
             case ENUM_C1G2BlockEraseResultType.Nonspecific_Reader_Error:
                 throw new ReaderException("Non-specific reader error");
             case ENUM_C1G2BlockEraseResultType.Nonspecific_Tag_Error:
                 throw new ReaderCodeException("Non-specific tag error", FAULT_GENERAL_TAG_ERROR_Exception.StatusCode);
             case ENUM_C1G2BlockEraseResultType.Tag_Memory_Locked_Error:
                 throw new ReaderCodeException("Tag memory locked error", FAULT_GEN2_PROTOCOL_MEMORY_LOCKED_Exception.StatusCode);
             case ENUM_C1G2BlockEraseResultType.Tag_Memory_Overrun_Error:
                 throw new ReaderCodeException("Tag memory overrun error", FAULT_GEN2_PROTOCOL_MEMORY_OVERRUN_BAD_PC_Exception.StatusCode);
         }
     }
     else if (opSpecResult[0].GetType() == typeof(PARAM_ThingMagicBlockPermalockOpSpecResult))
     {
         ParseCustomTagOpSpecResultType(((PARAM_ThingMagicBlockPermalockOpSpecResult)opSpecResult[0]).Result);
         if (((PARAM_ThingMagicBlockPermalockOpSpecResult)opSpecResult[0]).Result.Equals(ENUM_ThingMagicCustomTagOpSpecResultType.Success))
         {
             tagOpResponse = ByteConv.ConvertFromUshortArray(((PARAM_ThingMagicBlockPermalockOpSpecResult)opSpecResult[0]).PermalockStatus.data.ToArray());
         }
     }
     else if (opSpecResult[0].GetType() == typeof(PARAM_ThingMagicWriteTagOpSpecResult))
     {
         ParseCustomTagOpSpecResultType(((PARAM_ThingMagicWriteTagOpSpecResult)opSpecResult[0]).Result);
     }
     else if (opSpecResult[0].GetType() == typeof(PARAM_ThingMagicHiggs2PartialLoadImageOpSpecResult))
     {
         ParseCustomTagOpSpecResultType(((PARAM_ThingMagicHiggs2PartialLoadImageOpSpecResult)opSpecResult[0]).Result);
     }
     else if (opSpecResult[0].GetType() == typeof(PARAM_ThingMagicHiggs2FullLoadImageOpSpecResult))
     {
         ParseCustomTagOpSpecResultType(((PARAM_ThingMagicHiggs2FullLoadImageOpSpecResult)opSpecResult[0]).Result);
     }
     else if (opSpecResult[0].GetType() == typeof(PARAM_ThingMagicNXPG2XResetReadProtectOpSpecResult))
     {
         ParseCustomTagOpSpecResultType(((PARAM_ThingMagicNXPG2XResetReadProtectOpSpecResult)opSpecResult[0]).Result);
     }
     else if (opSpecResult[0].GetType() == typeof(PARAM_ThingMagicHiggs3FastLoadImageOpSpecResult))
     {
         ParseCustomTagOpSpecResultType(((PARAM_ThingMagicHiggs3FastLoadImageOpSpecResult)opSpecResult[0]).Result);
     }
     else if (opSpecResult[0].GetType() == typeof(PARAM_ThingMagicHiggs3LoadImageOpSpecResult))
     {
         ParseCustomTagOpSpecResultType(((PARAM_ThingMagicHiggs3LoadImageOpSpecResult)opSpecResult[0]).Result);
     }
     else if (opSpecResult[0].GetType() == typeof(PARAM_ThingMagicHiggs3BlockReadLockOpSpecResult))
     {
         ParseCustomTagOpSpecResultType(((PARAM_ThingMagicHiggs3BlockReadLockOpSpecResult)opSpecResult[0]).Result);
     }
     else if (opSpecResult[0].GetType() == typeof(PARAM_ThingMagicNXPG2ICalibrateOpSpecResult))
     {
         ParseCustomTagOpSpecResultType(((PARAM_ThingMagicNXPG2ICalibrateOpSpecResult)opSpecResult[0]).Result);
         if (((PARAM_ThingMagicNXPG2ICalibrateOpSpecResult)opSpecResult[0]).Result.Equals(ENUM_ThingMagicCustomTagOpSpecResultType.Success))
         {
             tagOpResponse = ((PARAM_ThingMagicNXPG2ICalibrateOpSpecResult)opSpecResult[0]).CalibrateData.ToArray();
         }
     }
     else if (opSpecResult[0].GetType() == typeof(PARAM_ThingMagicNXPG2IChangeConfigOpSpecResult))
     {
         ParseCustomTagOpSpecResultType(((PARAM_ThingMagicNXPG2IChangeConfigOpSpecResult)opSpecResult[0]).Result);
         if (((PARAM_ThingMagicNXPG2IChangeConfigOpSpecResult)opSpecResult[0]).Result.Equals(ENUM_ThingMagicCustomTagOpSpecResultType.Success))
         {
             Gen2.NXP.G2I.ConfigWord word = new Gen2.NXP.G2I.ConfigWord();
             tagOpResponse = word.GetConfigWord(((PARAM_ThingMagicNXPG2IChangeConfigOpSpecResult)opSpecResult[0]).ConfigData);
         }
     }
     else if (opSpecResult[0].GetType() == typeof(PARAM_ThingMagicNXPG2IChangeEASOpSpecResult))
     {
         ParseCustomTagOpSpecResultType(((PARAM_ThingMagicNXPG2IChangeEASOpSpecResult)opSpecResult[0]).Result);
     }
     else if (opSpecResult[0].GetType() == typeof(PARAM_ThingMagicNXPG2IResetReadProtectOpSpecResult))
     {
         ParseCustomTagOpSpecResultType(((PARAM_ThingMagicNXPG2IResetReadProtectOpSpecResult)opSpecResult[0]).Result);
     }
     else if (opSpecResult[0].GetType() == typeof(PARAM_ThingMagicNXPG2ISetReadProtectOpSpecResult))
     {
         ParseCustomTagOpSpecResultType(((PARAM_ThingMagicNXPG2ISetReadProtectOpSpecResult)opSpecResult[0]).Result);
     }
     else if (opSpecResult[0].GetType() == typeof(PARAM_ThingMagicNXPG2XCalibrateOpSpecResult))
     {
         ParseCustomTagOpSpecResultType(((PARAM_ThingMagicNXPG2XCalibrateOpSpecResult)opSpecResult[0]).Result);
         if (((PARAM_ThingMagicNXPG2XCalibrateOpSpecResult)opSpecResult[0]).Result.Equals(ENUM_ThingMagicCustomTagOpSpecResultType.Success))
         {
             tagOpResponse = ((PARAM_ThingMagicNXPG2XCalibrateOpSpecResult)opSpecResult[0]).CalibrateData.ToArray();
         }
     }
     else if (opSpecResult[0].GetType() == typeof(PARAM_ThingMagicNXPG2XChangeEASOpSpecResult))
     {
         ParseCustomTagOpSpecResultType(((PARAM_ThingMagicNXPG2XChangeEASOpSpecResult)opSpecResult[0]).Result);
     }
     else if (opSpecResult[0].GetType() == typeof(PARAM_ThingMagicNXPG2XSetReadProtectOpSpecResult))
     {
         ParseCustomTagOpSpecResultType(((PARAM_ThingMagicNXPG2XSetReadProtectOpSpecResult)opSpecResult[0]).Result);
     }
     else if (opSpecResult[0].GetType() == typeof(PARAM_ThingMagicImpinjMonza4QTReadWriteOpSpecResult))
     {
         ParseCustomTagOpSpecResultType(((PARAM_ThingMagicImpinjMonza4QTReadWriteOpSpecResult)opSpecResult[0]).Result);
         if (((PARAM_ThingMagicImpinjMonza4QTReadWriteOpSpecResult)opSpecResult[0]).Result.Equals(ENUM_ThingMagicCustomTagOpSpecResultType.Success))
         {
             Gen2.Impinj.Monza4.QTPayload qtPayload = new Gen2.Impinj.Monza4.QTPayload();
             int res = ((PARAM_ThingMagicImpinjMonza4QTReadWriteOpSpecResult)opSpecResult[0]).Payload;
             //Construct QTPayload
             if ((res & 0x8000) != 0)
             {
                 qtPayload.QTSR = true;
             }
             if ((res & 0x4000) != 0)
             {
                 qtPayload.QTMEM = true;
             }
             tagOpResponse = qtPayload;
         }
     }
     else if (opSpecResult[0].GetType() == typeof(PARAM_ThingMagicNXPG2IEASAlarmOpSpecResult))
     {
         ParseCustomTagOpSpecResultType(((PARAM_ThingMagicNXPG2IEASAlarmOpSpecResult)opSpecResult[0]).Result);
         if (((PARAM_ThingMagicNXPG2IEASAlarmOpSpecResult)opSpecResult[0]).Result.Equals(ENUM_ThingMagicCustomTagOpSpecResultType.Success))
         {
             tagOpResponse = ((PARAM_ThingMagicNXPG2IEASAlarmOpSpecResult)opSpecResult[0]).EASAlarmCode;
         }
     }
     else if (opSpecResult[0].GetType() == typeof(PARAM_ThingMagicNXPG2XEASAlarmOpSpecResult))
     {
         ParseCustomTagOpSpecResultType(((PARAM_ThingMagicNXPG2XEASAlarmOpSpecResult)opSpecResult[0]).Result);
         if (((PARAM_ThingMagicNXPG2XEASAlarmOpSpecResult)opSpecResult[0]).Result.Equals(ENUM_ThingMagicCustomTagOpSpecResultType.Success))
         {
             tagOpResponse = ((PARAM_ThingMagicNXPG2XEASAlarmOpSpecResult)opSpecResult[0]).EASAlarmCode;
         }
     }
     else if (opSpecResult[0].GetType() == typeof(PARAM_ThingMagicISO180006BReadOpSpecResult))
     {
         ParseCustomTagOpSpecResultType(((PARAM_ThingMagicISO180006BReadOpSpecResult)opSpecResult[0]).Result);
         if (((PARAM_ThingMagicISO180006BReadOpSpecResult)opSpecResult[0]).Result.Equals(ENUM_ThingMagicCustomTagOpSpecResultType.Success))
         {
             tag._data = ((PARAM_ThingMagicISO180006BReadOpSpecResult)opSpecResult[0]).ReadData.ToArray();
             tagOpResponse = ((PARAM_ThingMagicISO180006BReadOpSpecResult)opSpecResult[0]).ReadData.ToArray();
         }
     }
     else if (opSpecResult[0].GetType() == typeof(PARAM_ThingMagicISO180006BLockOpSpecResult))
     {
         ParseCustomTagOpSpecResultType(((PARAM_ThingMagicISO180006BLockOpSpecResult)opSpecResult[0]).Result);
     }
     else if (opSpecResult[0].GetType() == typeof(PARAM_ThingMagicISO180006BWriteOpSpecResult))
     {
         ParseCustomTagOpSpecResultType(((PARAM_ThingMagicISO180006BWriteOpSpecResult)opSpecResult[0]).Result);
     }
     else if (opSpecResult[0].GetType() == typeof(PARAM_ThingMagicIDSSL900AGetBatteryLevelOpSpecResult))
     {
         ParseCustomTagOpSpecResultType(((PARAM_ThingMagicIDSSL900AGetBatteryLevelOpSpecResult)opSpecResult[0]).Result);
         if (((PARAM_ThingMagicIDSSL900AGetBatteryLevelOpSpecResult)opSpecResult[0]).Result.Equals(ENUM_ThingMagicCustomTagOpSpecResultType.Success))
         {
             tag._data = ByteConv.EncodeU16(((PARAM_ThingMagicIDSSL900AGetBatteryLevelOpSpecResult)opSpecResult[0]).ThingMagicIDSBatteryLevel.reply);
             Gen2.IDS.SL900A.BatteryLevelReading batteryLevel = new Gen2.IDS.SL900A.BatteryLevelReading(((PARAM_ThingMagicIDSSL900AGetBatteryLevelOpSpecResult)opSpecResult[0]).ThingMagicIDSBatteryLevel.reply);
             tagOpResponse = batteryLevel;
         }
     }
     else if (opSpecResult[0].GetType() == typeof(PARAM_ThingMagicIDSSL900ASensorValueOpSpecResult))
     {
         ParseCustomTagOpSpecResultType(((PARAM_ThingMagicIDSSL900ASensorValueOpSpecResult)opSpecResult[0]).Result);
         if (((PARAM_ThingMagicIDSSL900ASensorValueOpSpecResult)opSpecResult[0]).Result.Equals(ENUM_ThingMagicCustomTagOpSpecResultType.Success))
         {
             tag._data = ByteConv.EncodeU16(((PARAM_ThingMagicIDSSL900ASensorValueOpSpecResult)opSpecResult[0]).reply);
             Gen2.IDS.SL900A.SensorReading sensorReading = new Gen2.IDS.SL900A.SensorReading(((PARAM_ThingMagicIDSSL900ASensorValueOpSpecResult)opSpecResult[0]).reply);
             tagOpResponse = sensorReading;
         }
     }
     else if (opSpecResult[0].GetType() == typeof(PARAM_ThingMagicIDSSL900ASetCalibrationDataOpSpecResult))
     {
         ParseCustomTagOpSpecResultType(((PARAM_ThingMagicIDSSL900ASetCalibrationDataOpSpecResult)opSpecResult[0]).Result);
     }
     else if (opSpecResult[0].GetType() == typeof(PARAM_ThingMagicIDSSL900AGetCalibrationDataOpSpecResult))
     {
         ParseCustomTagOpSpecResultType(((PARAM_ThingMagicIDSSL900AGetCalibrationDataOpSpecResult)opSpecResult[0]).Result);
         if (((PARAM_ThingMagicIDSSL900AGetCalibrationDataOpSpecResult)opSpecResult[0]).Result.Equals(ENUM_ThingMagicCustomTagOpSpecResultType.Success))
         {
             PARAM_ThingMagicIDSCalibrationData data = ((PARAM_ThingMagicIDSSL900AGetCalibrationDataOpSpecResult)opSpecResult[0]).ThingMagicIDSCalibrationData;
             LTKD.ByteArray calibrationValue = data.calibrationValueByteStream;
             tag._data = calibrationValue.ToArray();
             tagOpResponse = new Gen2.IDS.SL900A.CalSfe(calibrationValue.ToArray(), 0);
         }
     }
     else if (opSpecResult[0].GetType() == typeof(PARAM_ThingMagicIDSSL900AEndLogOpSpecResult))
     {
         ParseCustomTagOpSpecResultType(((PARAM_ThingMagicIDSSL900AEndLogOpSpecResult)opSpecResult[0]).Result);
     }
     else if (opSpecResult[0].GetType() == typeof(PARAM_ThingMagicIDSSL900AInitializeOpSpecResult))
     {
         ParseCustomTagOpSpecResultType(((PARAM_ThingMagicIDSSL900AInitializeOpSpecResult)opSpecResult[0]).Result);
     }
     else if (opSpecResult[0].GetType() == typeof(PARAM_ThingMagicIDSSL900ALogStateOpSpecResult))
     {
         ParseCustomTagOpSpecResultType(((PARAM_ThingMagicIDSSL900ALogStateOpSpecResult)opSpecResult[0]).Result);
         if (((PARAM_ThingMagicIDSSL900ALogStateOpSpecResult)opSpecResult[0]).Result.Equals(ENUM_ThingMagicCustomTagOpSpecResultType.Success))
         {
             LTKD.ByteArray logStateByteArray = ((PARAM_ThingMagicIDSSL900ALogStateOpSpecResult)opSpecResult[0]).LogStateByteStream;
             tag._data = logStateByteArray.ToArray();
             tagOpResponse = new Gen2.IDS.SL900A.LogState(logStateByteArray.ToArray());
         }
     }
     else if (opSpecResult[0].GetType() == typeof(PARAM_ThingMagicIDSSL900ASetLogModeOpSpecResult))
     {
         ParseCustomTagOpSpecResultType(((PARAM_ThingMagicIDSSL900ASetLogModeOpSpecResult)opSpecResult[0]).Result);
     }
     else if (opSpecResult[0].GetType() == typeof(PARAM_ThingMagicIDSSL900AStartLogOpSpecResult))
     {
         ParseCustomTagOpSpecResultType(((PARAM_ThingMagicIDSSL900AStartLogOpSpecResult)opSpecResult[0]).Result);
     }
     else if (opSpecResult[0].GetType() == typeof(PARAM_ThingMagicIDSSL900ASetSFEParamsOpSpecResult))
     {
         ParseCustomTagOpSpecResultType(((PARAM_ThingMagicIDSSL900ASetSFEParamsOpSpecResult)opSpecResult[0]).Result);
     }
     else if (opSpecResult[0].GetType() == typeof(PARAM_ThingMagicIDSSL900AGetMeasurementSetupOpSpecResult))
     {
         ParseCustomTagOpSpecResultType(((PARAM_ThingMagicIDSSL900AGetMeasurementSetupOpSpecResult)opSpecResult[0]).Result);
         if (((PARAM_ThingMagicIDSSL900AGetMeasurementSetupOpSpecResult)opSpecResult[0]).Result.Equals(ENUM_ThingMagicCustomTagOpSpecResultType.Success))
         {
             LTKD.ByteArray measurementByteArray = ((PARAM_ThingMagicIDSSL900AGetMeasurementSetupOpSpecResult)opSpecResult[0]).measurementByteStream;
             tag._data = measurementByteArray.ToArray();
             tagOpResponse = new Gen2.IDS.SL900A.MeasurementSetupData(measurementByteArray.ToArray(), 0);
         }
     }
     else if (opSpecResult[0].GetType() == typeof(PARAM_ThingMagicIDSSL900AAccessFIFOReadOpSpecResult))
     {
         ParseCustomTagOpSpecResultType(((PARAM_ThingMagicIDSSL900AAccessFIFOReadOpSpecResult)opSpecResult[0]).Result);
         if (((PARAM_ThingMagicIDSSL900AAccessFIFOReadOpSpecResult)opSpecResult[0]).Result.Equals(ENUM_ThingMagicCustomTagOpSpecResultType.Success))
         {
             LTKD.ByteArray readPayLoad = ((PARAM_ThingMagicIDSSL900AAccessFIFOReadOpSpecResult)opSpecResult[0]).readPayLoad;
             tag._data = readPayLoad.ToArray();
             tagOpResponse = readPayLoad.ToArray();
         }
     }
     else if (opSpecResult[0].GetType() == typeof(PARAM_ThingMagicIDSSL900AAccessFIFOWriteOpSpecResult))
     {
         ParseCustomTagOpSpecResultType(((PARAM_ThingMagicIDSSL900AAccessFIFOWriteOpSpecResult)opSpecResult[0]).Result);
     }
     else if (opSpecResult[0].GetType() == typeof(PARAM_ThingMagicIDSSL900AAccessFIFOStatusOpSpecResult))
     {
         ParseCustomTagOpSpecResultType(((PARAM_ThingMagicIDSSL900AAccessFIFOStatusOpSpecResult)opSpecResult[0]).Result);
         if (((PARAM_ThingMagicIDSSL900AAccessFIFOStatusOpSpecResult)opSpecResult[0]).Result.Equals(ENUM_ThingMagicCustomTagOpSpecResultType.Success))
         {
             tag._data = ByteConv.EncodeU16(Convert.ToUInt16(((PARAM_ThingMagicIDSSL900AAccessFIFOStatusOpSpecResult)opSpecResult[0]).FIFOStatusRawByte));
             tagOpResponse = new Gen2.IDS.SL900A.FifoStatus(((PARAM_ThingMagicIDSSL900AAccessFIFOStatusOpSpecResult)opSpecResult[0]).FIFOStatusRawByte);
         }
     }
     else if (opSpecResult[0].GetType() == typeof(PARAM_ThingMagicIDSSL900ASetLogLimitsOpSpecResult))
     {
         ParseCustomTagOpSpecResultType(((PARAM_ThingMagicIDSSL900ASetLogLimitsOpSpecResult)opSpecResult[0]).Result);
     }
     else if (opSpecResult[0].GetType() == typeof(PARAM_ThingMagicIDSSetShelfLifeOpSpecResult))
     {
         ParseCustomTagOpSpecResultType(((PARAM_ThingMagicIDSSetShelfLifeOpSpecResult)opSpecResult[0]).Result);
     }
     else if (opSpecResult[0].GetType() == typeof(PARAM_ThingMagicIDSSL900ASetPasswordOpSpecResult))
     {
        ParseCustomTagOpSpecResultType(((PARAM_ThingMagicIDSSL900ASetPasswordOpSpecResult)opSpecResult[0]).Result);
     }
     else if(opSpecResult[0].GetType() == typeof(PARAM_ThingMagicDenatranIAVActivateSecureModeOpSpecResult))
     {
         ParseCustomTagOpSpecResultType(((PARAM_ThingMagicDenatranIAVActivateSecureModeOpSpecResult)opSpecResult[0]).Result);
         if (((PARAM_ThingMagicDenatranIAVActivateSecureModeOpSpecResult)opSpecResult[0]).Result.Equals(ENUM_ThingMagicCustomTagOpSpecResultType.Success))
         {
             LTKD.ByteArray activateSecureModeValue = ((PARAM_ThingMagicDenatranIAVActivateSecureModeOpSpecResult)opSpecResult[0]).ActivateSecureModeByteStream;
             tag._data = activateSecureModeValue.ToArray();
             tagOpResponse = activateSecureModeValue.ToArray();
         }
     }
     else if(opSpecResult[0].GetType() == typeof(PARAM_ThingMagicDenatranIAVActivateSiniavModeOpSpecResult))
     {
         ParseCustomTagOpSpecResultType(((PARAM_ThingMagicDenatranIAVActivateSiniavModeOpSpecResult)opSpecResult[0]).Result);
         if (((PARAM_ThingMagicDenatranIAVActivateSiniavModeOpSpecResult)opSpecResult[0]).Result.Equals(ENUM_ThingMagicCustomTagOpSpecResultType.Success))
         {
             LTKD.ByteArray activateSiniavModeValue = ((PARAM_ThingMagicDenatranIAVActivateSiniavModeOpSpecResult)opSpecResult[0]).ActivateSiniavModeByteStream;
             tag._data = activateSiniavModeValue.ToArray();
             tagOpResponse = activateSiniavModeValue.ToArray();
         }
     }
     else if(opSpecResult[0].GetType() == typeof(PARAM_ThingMagicDenatranIAVAuthenticateOBUOpSpecResult))
     {
         ParseCustomTagOpSpecResultType(((PARAM_ThingMagicDenatranIAVAuthenticateOBUOpSpecResult)opSpecResult[0]).Result);
         if (((PARAM_ThingMagicDenatranIAVAuthenticateOBUOpSpecResult)opSpecResult[0]).Result.Equals(ENUM_ThingMagicCustomTagOpSpecResultType.Success))
         {
             LTKD.ByteArray authenticateOBUValue = ((PARAM_ThingMagicDenatranIAVAuthenticateOBUOpSpecResult)opSpecResult[0]).AuthenitcateOBUByteStream;
             tag._data = authenticateOBUValue.ToArray();
             tagOpResponse = authenticateOBUValue.ToArray();
         }
     }
     else if(opSpecResult[0].GetType() == typeof(PARAM_ThingMagicDenatranIAVOBUAuthenticateFullPass1OpSpecResult))
     {
         ParseCustomTagOpSpecResultType(((PARAM_ThingMagicDenatranIAVOBUAuthenticateFullPass1OpSpecResult)opSpecResult[0]).Result);
         if (((PARAM_ThingMagicDenatranIAVOBUAuthenticateFullPass1OpSpecResult)opSpecResult[0]).Result.Equals(ENUM_ThingMagicCustomTagOpSpecResultType.Success))
         {
             LTKD.ByteArray authenticateFullPass1Value = ((PARAM_ThingMagicDenatranIAVOBUAuthenticateFullPass1OpSpecResult)opSpecResult[0]).OBUAuthenticateFullPass1ByteStream;
             tag._data = authenticateFullPass1Value.ToArray();
             tagOpResponse = authenticateFullPass1Value.ToArray();
         }
     }
     else if(opSpecResult[0].GetType() == typeof(PARAM_ThingMagicDenatranIAVOBUAuthenticateFullPass2OpSpecResult))
     {
         ParseCustomTagOpSpecResultType(((PARAM_ThingMagicDenatranIAVOBUAuthenticateFullPass2OpSpecResult)opSpecResult[0]).Result);
         if (((PARAM_ThingMagicDenatranIAVOBUAuthenticateFullPass2OpSpecResult)opSpecResult[0]).Result.Equals(ENUM_ThingMagicCustomTagOpSpecResultType.Success))
         {
             LTKD.ByteArray authenticateFullPass2Value = ((PARAM_ThingMagicDenatranIAVOBUAuthenticateFullPass2OpSpecResult)opSpecResult[0]).OBUAuthenticateFullPass2ByteStream;
             tag._data = authenticateFullPass2Value.ToArray();
             tagOpResponse = authenticateFullPass2Value.ToArray();
         }
     }
     else if(opSpecResult[0].GetType() == typeof(PARAM_ThingMagicDenatranIAVOBUAuthenticateIDOpSpecResult))
     {
         ParseCustomTagOpSpecResultType(((PARAM_ThingMagicDenatranIAVOBUAuthenticateIDOpSpecResult)opSpecResult[0]).Result);
         if (((PARAM_ThingMagicDenatranIAVOBUAuthenticateIDOpSpecResult)opSpecResult[0]).Result.Equals(ENUM_ThingMagicCustomTagOpSpecResultType.Success))
         {
             LTKD.ByteArray authenticateIDValue = ((PARAM_ThingMagicDenatranIAVOBUAuthenticateIDOpSpecResult)opSpecResult[0]).OBUAuthenticateIDByteStream;
             tag._data = authenticateIDValue.ToArray();
             tagOpResponse = authenticateIDValue.ToArray();
         }
     }
     else if(opSpecResult[0].GetType() == typeof(PARAM_ThingMagicDenatranIAVOBUReadFromMemMapOpSpecResult))
     {
         ParseCustomTagOpSpecResultType(((PARAM_ThingMagicDenatranIAVOBUReadFromMemMapOpSpecResult)opSpecResult[0]).Result);
         if (((PARAM_ThingMagicDenatranIAVOBUReadFromMemMapOpSpecResult)opSpecResult[0]).Result.Equals(ENUM_ThingMagicCustomTagOpSpecResultType.Success))
         {
             LTKD.ByteArray readMemoryMapValue = ((PARAM_ThingMagicDenatranIAVOBUReadFromMemMapOpSpecResult)opSpecResult[0]).OBUReadMemoryMapByteStream;
             tag._data = readMemoryMapValue.ToArray();
             tagOpResponse = readMemoryMapValue.ToArray();
         }
     }
     else if (opSpecResult[0].GetType() == typeof(PARAM_ThingMagicDenatranIAVOBUWriteToMemMapOpSpecResult))
     {
         ParseCustomTagOpSpecResultType(((PARAM_ThingMagicDenatranIAVOBUWriteToMemMapOpSpecResult)opSpecResult[0]).Result);
         if (((PARAM_ThingMagicDenatranIAVOBUWriteToMemMapOpSpecResult)opSpecResult[0]).Result.Equals(ENUM_ThingMagicCustomTagOpSpecResultType.Success))
         {
             LTKD.ByteArray writeMemoryMapValue = ((PARAM_ThingMagicDenatranIAVOBUWriteToMemMapOpSpecResult)opSpecResult[0]).OBUWriteMemoryMapByteStream;
             tag._data = writeMemoryMapValue.ToArray();
             tagOpResponse = writeMemoryMapValue.ToArray();
         }
     }
 }
Пример #2
0
        static void Main(string[] args)
        {
            // Program setup
            if (1 != args.Length)
            {
                Console.WriteLine(String.Join("\r\n", new string[] {
                    "Please provide reader URL, such as:",
                    "tmr:///com4",
                    "tmr://my-reader.example.com",
                }));
                Environment.Exit(1);
            }

            try
            {
                // Create Reader object, connecting to physical device.
                // Wrap reader in a "using" block to get automatic
                // reader shutdown (using IDisposable interface).
                using (Reader r = Reader.Create(args[0]))
                {
                    // Uncomment this line to add default transport listener.
                    // r.Transport += r.SimpleTransportListener;

                    r.Connect();
                    if (Reader.Region.UNSPEC == (Reader.Region)r.ParamGet("/reader/region/id"))
                    {
                        Reader.Region[] supportedRegions = (Reader.Region[])r.ParamGet("/reader/region/supportedRegions");
                        if (supportedRegions.Length < 1)
                        {
                            throw new FAULT_INVALID_REGION_Exception();
                        }
                        else
                        {
                            r.ParamSet("/reader/region/id", supportedRegions[0]);
                        }
                    }
                    TagReadData[] tagReads;
                    TagFilter filter;
                    byte[] mask = new byte[4];
                    Gen2.Impinj.Monza4.QTPayload payLoad;
                    Gen2.Impinj.Monza4.QTControlByte controlByte;
                    Gen2.Impinj.Monza4.QTReadWrite readWrite;
                    uint accesspassword = 0;

                    r.ParamSet("/reader/tagop/antenna", 1);

                    Gen2.Session session = Gen2.Session.S0;
                    r.ParamSet("/reader/gen2/session", session);

                    SimpleReadPlan readPlan = new SimpleReadPlan(null, TagProtocol.GEN2, null, null, 1000);
                    r.ParamSet("/reader/read/plan", readPlan);

                    // Reading tags with a Monza 4 public EPC in response
                    Console.WriteLine("Reading tags with a Monza 4 public EPC in response");
                    tagReads = r.Read(1000);
                    foreach (TagReadData tagData in tagReads)
                    {
                         Console.WriteLine("Monza4 tag epc: " +tagData.EpcString);
                    }
                    Console.WriteLine();

                    // Initialize the payload and the controlByte of Monza4
                    payLoad = new Gen2.Impinj.Monza4.QTPayload();
                    controlByte = new Gen2.Impinj.Monza4.QTControlByte();

                    Console.WriteLine("Changing to private Mode ");
                    // Executing Monza4 QT Write Set Private tagop
                    payLoad.QTMEM = false;
                    payLoad.QTSR = false;
                    controlByte.QTReadWrite = true;
                    controlByte.Persistence = true;

                    readWrite = new Gen2.Impinj.Monza4.QTReadWrite(accesspassword, payLoad, controlByte);
                    r.ExecuteTagOp(readWrite, null);
                    Console.WriteLine();

                    // Setting the session to S2
                    session = Gen2.Session.S2;
                    r.ParamSet("/reader/gen2/session", session);

                    // Enable filter
                    mask[0] = (byte) 0x20;
                    mask[1] = (byte) 0x01;
                    mask[2] = (byte) 0xB0;
                    mask[3] = (byte) 0x00;
                    filter = new Gen2.Select(true, Gen2.Bank.TID, 0x04, 0x18, mask);

                    Console.WriteLine("Reading tags private Mode with session s2 ");
                    readPlan = new SimpleReadPlan(null, TagProtocol.GEN2, filter, null, 1000);
                    r.ParamSet("/reader/read/plan", readPlan);
                    // Reading tags with a Monza 4 FastID with TID in response
                    Console.WriteLine("Reading tags with a Monza 4 FastID with TID in response");
                    tagReads = r.Read(1000);
                    foreach (TagReadData tagData in tagReads)
                    {
                         Console.WriteLine("Monza4 tag epc: " +tagData.EpcString);
                    }
                    Console.WriteLine();
                    
                    Console.WriteLine("Setting the session to S0");

                    // Setting the session to S0
                    session = Gen2.Session.S0;
                    r.ParamSet("/reader/gen2/session", session);

                    mask[0] = (byte) 0xE2;
                    mask[1] = (byte) 0x80;
                    mask[2] = (byte) 0x11;
                    mask[3] = (byte) 0x05;
                    filter = new Gen2.Select(false, Gen2.Bank.TID, 0x00, 0x20, mask);
                    Console.WriteLine("Reading tags private Mode with session s0 ");
                    readPlan = new SimpleReadPlan(null, TagProtocol.GEN2, filter, null, 1000);
                    r.ParamSet("/reader/read/plan", readPlan);
                    // Reading tags with a Monza 4 FastID with NO TID in response
                    Console.WriteLine("Reading tags with a Monza 4 FastID with NO TID in response");
                    tagReads = r.Read(1000);
                    foreach (TagReadData tagData in tagReads)
                    {
                         Console.WriteLine("Monza4 tag epc: " +tagData.EpcString);
                    }
                    Console.WriteLine();

                    Console.WriteLine("Converting to public mode");
                    // Executing  Monza4 QT Write Set Public tagop
                    payLoad.QTMEM = true;
                    payLoad.QTSR = false;
                    controlByte.QTReadWrite = true;
                    controlByte.Persistence = true;

                    readWrite = new Gen2.Impinj.Monza4.QTReadWrite(accesspassword, payLoad, controlByte);
                    r.ExecuteTagOp(readWrite, null);
                    Console.WriteLine();

                    // Enable filter
                    mask[0] = (byte) 0x20;
                    mask[1] = (byte) 0x01;
                    mask[2] = (byte) 0xB0;
                    mask[3] = (byte) 0x00;
                    filter = new Gen2.Select(true, Gen2.Bank.TID, 0x04, 0x18, mask);
                    Console.WriteLine("Reading tags public Mode with session s0 ");
                    readPlan = new SimpleReadPlan(null, TagProtocol.GEN2, filter, null, 1000);
                    r.ParamSet("/reader/read/plan", readPlan);
                    // Reading tags with a Monza 4 FastID with TID in response
                    tagReads = r.Read(1000);
                    foreach (TagReadData tagData in tagReads)
                    {
                         Console.WriteLine("Monza4 tag epc: " +tagData.EpcString);
                    }
                    Console.WriteLine();
                   
                    Console.WriteLine("Reset the Read protect on ");
                    // Reset the Read protect on
                    payLoad.QTMEM = false;
                    payLoad.QTSR = false;
                    controlByte.QTReadWrite = false;
                    controlByte.Persistence = false;

                    readWrite = new Gen2.Impinj.Monza4.QTReadWrite(accesspassword, payLoad, controlByte);
                    r.ExecuteTagOp(readWrite, null);
                }
            }
            catch (ReaderException re)
            {
                Console.WriteLine("Error: " + re.Message);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: " + ex.Message);
            }
        }