ModuleAPI C# Version Developer's Guide
MODULETECH.GEN2
   
There are some classes and enumeration about Gen2 protocol to be used when inventory, reading, writing, locking and destroying a tag. They are mainly defined in this namespace.

Session Enumeration

Define four Session of the GEN2 protocol.
  
Member Description
Session0 Gen2 Session0
Session1 Gen2 Session1
Session2 Gen2 Session2
Session3 Gen2 Session3

MemBank Enumeration

Define four banks of GEN2 tag.
  
Member Description
RESERVED Reserve bank
EPC EPC bank
TID TID bank
USER User bank

Gen2LockAct Enumeration

Define the memory area and type of tag locking operation.
  
Member Description
ACCESS_LOCK Temporarily lock access password
ACCESS_PERMALOCK Permanently lock access password
ACCESS_UNLOCK Unlock access password
EPC_LOCK Temporarily lock EPC bank
EPC_PERMALOCK Permanently lock EPC bank
EPC_UNLOCK Unlock EPC bank
KILL_LOCK Temporarily lock kill password
KILL_PERMALOCK Permanently lock kill password
KILL_UNLOCK Unlock kill password
TID_LOCK Temporarily lock TID bank
TID_PERMALOCK Permanently lock TID bank
TID_UNLOCK Unlock TID bank
USER_LOCK Temporarily lock USER bank
USER_PERMALOCK Permanently lock USER bank
USER_UNLOCK Unlock USER bank

Gen2LockAction Class

The action of locking tag.
  
Constructor

  
public Gen2LockAction(ModuleTech.Gen2.Gen2LockAct[] acts)
Parameters
Parameter Description
acts Store the locking actions.
    
Example
If you want to temporarily lock EPC, unlock USER and permanently lock access password the code would be as following.
  
Gen2LockAct [] acts = new Gen2LockAct[3];
acts[0] = Gen2LockAct.EPC_LOCK;
acts[1] = Gen2LockAct.TID_UNLOCK;
acts[2] = Gen2LockAct.ACCESS_PERMALOCK;
Gen2LockAction lockact = new Gen2LockAction(acts);

Gen2TagFilter Class

Users can add filter option when executing inventory, reading, writing, locking and kill tag operations so that only the tag which match the filter criteria would be operated.
  
Constructor

  
public Gen2TagFilter(int filterlen, byte[] filterdata, MemBank filterbank, int filteraddr, bool isInvert)
  
Parameters
Parameters Description
Filterlen The length of data to be compared,in bits.
Filterdata Data to compare, when filterlen is not the integral multiple of 8, the length of filterdata is (filterlen-1) /8 + 1.
Filterbank The bank to filter.
Filteraddr The starting address of filtering,in bits, There are several tags in the field of an antenna. Among them there is only one tag whose EPC ID start with 1101. Now we need to read the TID of this tag then we can use the parameter Gen2TagFilter to ensure that the reading.
isInvert Rule of filter,false means matching the filter criteria,true means not matching the filter criteria.
    
Example
There are several tags in the field of an antenna. Among them there is only one tag whose EPC ID start with 1101. Now we need to read the TID of this tag then we can use the parameter Gen2TagFilter to ensure that the reading operation is on the right tag. The code is as following.
  
int bitcnt = 0;
string binarystr = “1101”;
byte[] filterbytes = new byte[(binarystr.Length-1)/8+1];
for (int c = 0; c < filterbytes.Length; ++c)
	filterbytes[c] = 0;
foreach (Char ch in binarystr)
{
	if (ch == '1')
		filterbytes[bitcnt / 8] |= (byte)(0x01 << (7 - bitcnt % 8));
	bitcnt++;
}
Gen2TagFilter filter = new Gen2TagFilter(binarystr.Length, filterbytes, ModuleTech.Gen2.MemBank.EPC, 32, false);
   

Target Enumeration

Define the target of the GEN2 protocol.
  
Member Description
A Search for tags in State A.
B Search for tags in State B.
AB Search for tags in State A, then switch to B.
BA Search for tags in State B, then switch to A.

WriteMode Enumeration

Define the write mode of tag wrtie operation.
  
Member Description
WORD_ONLY Use the Write command of Gen2 air interface for tag write operation.
BLOCK_ONLY Use the BlockWrite command of Gen2 air interface for tag write operation.
BLOCK_FALLBACK Temporarily not supported.