private static void AddTagSpec(string tagID, string maskBits, MSG_ADD_ACCESSSPEC msg) { //define access command //define air protocol spec msg.AccessSpec.AccessCommand = new PARAM_AccessCommand(); msg.AccessSpec.AccessCommand.AirProtocolTagSpec = new UNION_AirProtocolTagSpec(); PARAM_C1G2TagSpec tagSpec = new PARAM_C1G2TagSpec(); tagSpec.C1G2TargetTag = new PARAM_C1G2TargetTag[1]; tagSpec.C1G2TargetTag[0] = new PARAM_C1G2TargetTag(); tagSpec.C1G2TargetTag[0].Match = true; //change to "true" if you want to the following parameters take effect. tagSpec.C1G2TargetTag[0].MB = new TwoBits(1); tagSpec.C1G2TargetTag[0].Pointer = 0x20; tagSpec.C1G2TargetTag[0].TagData = LLRPBitArray.FromString(tagID); tagSpec.C1G2TargetTag[0].TagMask = LLRPBitArray.FromBinString(maskBits); msg.AccessSpec.AccessCommand.AirProtocolTagSpec.Add(tagSpec); }
private bool ADD_ACCESSSPEC(string tagdata, int type) { MSG_ADD_ACCESSSPEC msg = new MSG_ADD_ACCESSSPEC(); msg.AccessSpec = new PARAM_AccessSpec(); msg.AccessSpec.AccessSpecID = 1001; msg.AccessSpec.AntennaID = 1; msg.AccessSpec.ProtocolID = ENUM_AirProtocols.EPCGlobalClass1Gen2; msg.AccessSpec.CurrentState = ENUM_AccessSpecState.Disabled; msg.AccessSpec.ROSpecID = 123; //define trigger msg.AccessSpec.AccessSpecStopTrigger = new PARAM_AccessSpecStopTrigger(); msg.AccessSpec.AccessSpecStopTrigger.AccessSpecStopTrigger = ENUM_AccessSpecStopTriggerType.Operation_Count; msg.AccessSpec.AccessSpecStopTrigger.OperationCountValue = 100; //define access command //define air protocol spec msg.AccessSpec.AccessCommand = new PARAM_AccessCommand(); msg.AccessSpec.AccessCommand.AirProtocolTagSpec = new UNION_AirProtocolTagSpec(); PARAM_C1G2TagSpec tagSpec = new PARAM_C1G2TagSpec(); tagSpec.C1G2TargetTag = new PARAM_C1G2TargetTag[1]; tagSpec.C1G2TargetTag[0] = new PARAM_C1G2TargetTag(); tagSpec.C1G2TargetTag[0].Match = false; //change to "true" if you want to the following parameters take effect. tagSpec.C1G2TargetTag[0].MB = new TwoBits(1); tagSpec.C1G2TargetTag[0].Pointer = 0x20; tagSpec.C1G2TargetTag[0].TagData = LLRPBitArray.FromString("1111"); tagSpec.C1G2TargetTag[0].TagMask = LLRPBitArray.FromBinString("1111111111111111"); msg.AccessSpec.AccessCommand.AirProtocolTagSpec.Add(tagSpec); //define access spec msg.AccessSpec.AccessCommand.AccessCommandOpSpec = new UNION_AccessCommandOpSpec(); PARAM_C1G2Write wr = new PARAM_C1G2Write(); wr.AccessPassword = 0; wr.MB = new TwoBits(1); wr.OpSpecID = 111; wr.WordPointer = 2; //Data to be written. wr.WriteData = UInt16Array.FromHexString(tagdata); msg.AccessSpec.AccessCommand.AccessCommandOpSpec.Add(wr); msg.AccessSpec.AccessReportSpec = new PARAM_AccessReportSpec(); msg.AccessSpec.AccessReportSpec.AccessReportTrigger = ENUM_AccessReportTriggerType.End_Of_AccessSpec; MSG_ADD_ACCESSSPEC_RESPONSE rsp = reader.ADD_ACCESSSPEC(msg, out msg_err, 12000); if (rsp != null) { //return rsp.ToString(); return(true); } else if (msg_err != null) { //return msg_err.ToString(); return(false); } else { //return "Command time out!"; return(false); } }