GS |
The EPC Translator Library is organized around five main classes, depicted as the yellow boxes in the diagram below.
Since version 2.0 of the EPC Translator Library, the underlying data conversions are performed by a native library written in C. An additional class, Gs1EpcLib, has been provided to give access to the underlying data conversion functions.
The five main classes are:
The diagram shows the available conversions between these classes, and the conversions to and from external forms (shown in red) including strings, URIs, binary, hexadecimal, etc.
The primary methods of these classes are organized as follows:
A typical usage pattern is to convert between equivalent forms of a class by first calling a From method of that class, then referencing a property. For example, the following code converts the hexadecimal contents of EPC memory of an RFID tag into an EPC Tag URI:
{
String hex = "303531EDE4424C8000001ABF";
RfidBank01 rfid = RfidBank01.FromEpcHex(hex);
String tagUri = rfid.TagUri;
}
{ String tagUri = "urn:epc:tag:sgtin-96:1.5012345.067890.6847"; RfidBank01 rfid = RfidBank01.FromTagOrRawUri(tagUri); ushort[] words = rfid.EpcWords; }
Another typical usage pattern is to create one class instance using a From method of that class, convert to a different class using a To method of that class (or a chain of such methods), then reference a property to extract the final external form. For example, the following code converts the hexadecimal contents of EPC memory of an RFID tag into the EPC Pure Identity URI:
{
String hex = "303531EDE4424C8000001ABF";
RfidBank01 rfid = RfidBank01.FromEpcHex(hex);
Epc epc = rfid.ToEpc();
String epcUri = epc.EpcUri;
}
{
String hex = "303531EDE4424C8000001ABF";
RfidBank01 rfid = RfidBank01.FromEpcHex(hex);
Epc epc = rfid.ToEpc();
Gs1ElementString es = epc.ToGs1ElementString();
String barCode = es.BarCodeCharacters;
}
{ String barCode = "0105012345678900216847"; Gs1ElementString es = Gs1ElementString.FromBarCodeCharacters(barCode); int companyPrefixLength = 7; Epc epc = es.ToEpc(companyPrefixLength); String epcUri = EpcUri; }
{ String barCode = "0105012345678900216847"; Gs1ElementString es = Gs1ElementString.FromBarCodeCharacters(barCode); int companyPrefixLength = 7; Epc epc = es.ToEpc(companyPrefixLength); int filter = 1; RfidBank01 rfid = epc.ToRfidBank01(EpcTagScheme.SGTIN_96, filter); String hex = rfid.EpcHex; }
{ String barCode = "0105012345678900216847\x001D10ABC123"; Gs1ElementString es = Gs1ElementString.FromBarCodeCharacters(barCode); int companyPrefixLength = 7; Epc epc = es.ToEpc(companyPrefixLength); int filter = 1; RfidBank01 rfidEpc = epc.ToRfidBank01(EpcTagScheme.SGTIN_96, filter); sbyte[] epcBytes = rfidEpc.EpcBytes; RfidUserBank rfidUser = es.ToRfidUserBank(false); sbyte[] userBytes = rfidUser.Bytes; }
{ String digitalLink = "https://example.com/01/80614141123458/10/10MD1234/21/223372036854" int filter = 1; RfidBank01 rfidEpc = RfidBank01.FromDigitalLink(digitalLink, "sgtin+", filter); sbyte[] = epcBytes = rfidEpc.EpcBytes; }
Class | Description | |||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
![]() | Epc | An electronic product code (EPC). Instances of this class represent just the pure EPC identifier, without data carrier-specific control information such as filter bits. | ||||||||||||||||||||||||||||
![]() | EpcClass | An electronic product code (EPC) "class". An EPC Class is an identifier for objects that do not have individual instances identified. An EPC can be constructed from an EPC Class by adding a serial number. | ||||||||||||||||||||||||||||
![]() | EpcClassScheme | An EPC class scheme. This includes a scheme for each EPC pure identity scheme that can be used as an EPC class, along with schemes defined only as EPC class schemes. | ||||||||||||||||||||||||||||
![]() | EpcException | General exception for conditions related to the translation of Electronic Product Codes (EPCs). | ||||||||||||||||||||||||||||
![]() | EpcLibException | Base class for all checked exceptions thrown by the EPC Translator Library. | ||||||||||||||||||||||||||||
![]() | EpcPattern | An electronic product code (EPC) pattern. Instances of this class represent a set of EPCs. | ||||||||||||||||||||||||||||
![]() | EpcScheme | An EPC pure identity scheme. | ||||||||||||||||||||||||||||
![]() | EpcTagScheme | An EPC tag URI scheme. | ||||||||||||||||||||||||||||
![]() | Gs1Ai | A GS1 Application Identifier and value, representing a specific data element that can be encoded into EPC data carriers according to GS1 standards. | ||||||||||||||||||||||||||||
![]() | Gs1ElementString |
A GS1 Element String, which is an ordered list of GS1 Application Identifiers (AIs), each
of which is a specific data element. A GS1 Element string is an abstract representation
of the application data content of a bar code or RFID tag conforming to GS1 standards.
In the bar code representation of GS1 Element String data, the order of AIs must conform to certain rules, namely that certain AIs of pre-defined size (as specified in the GS1 General Specifications) must occur first. The BarCodeCharacters property rearranges the order of AIs as necessary to accomplish this. In the RFID representation of GS1 Element String data, different AIs are written to different RFID memory banks. In particular, the RFID EPC bank may only contain one of the following AI combinations:
In addition, to convert one of the above AI combinations to an EPC the application must specify the number of digits in the GS1 Company Prefix embedded within the AI. The methods take an argument to provide this. | ||||||||||||||||||||||||||||
![]() | Gs1EpcLib | Access to the functions provided by the C EPC Translator library. | ||||||||||||||||||||||||||||
![]() | Gs1Exception | General exception for conditions related to the translation of GS1 element strings. | ||||||||||||||||||||||||||||
![]() | Gs1GcpLengthTable |
A GcpLengthTable populated from data published by GS1, or from any other publisher using
the same XML file format. The format of the XML file is as follows:
<GCPPrefixFormatList date="2016-03-23T16:55:00Z"> <entry prefix="00" gcpLength="7"/> <entry prefix="011" gcpLength="8"/> <entry prefix="018" gcpLength="10"/> <entry prefix="019" gcpLength="7"/> ... </GCPPrefixFormatList>At the time of this writing, the GCP published file is available at the URL http://www.gs1.org/gcp-length. | ||||||||||||||||||||||||||||
![]() | Oid | An ISO Object Identifier (OID). OIDs are used to identify data elements in RFID user memory. | ||||||||||||||||||||||||||||
![]() | PrefixGcpLengthTable |
A implementation of a GcpLengthTable based on mapping a prefix to a length.
Clients can use this class when they want to manage their
own GCP length mappings. To use GS1 published data, see
Gs1GcpLengthTable For example, given the following table: PrefixGcpLengthTable t = new PrefixGcpLengthTable(); t.add("999", 7); t.add("9998", 10); t.add("99712345", 8);Then the following shows various GCP lengths returned by the table. t.gcpLength("9994567890123") ==> 7 t.gcpLength("9998567890123") ==> 10 t.gcpLength("9971234567890") ==> 8 t.gcpLength("9971299999999") ==> UnknownGcpLengthException | ||||||||||||||||||||||||||||
![]() | RfidBank01 | The contents of the EPC/UII Bank (MB01) of an EPCglobal Gen2 / ISO 18000-6C RFID tag. | ||||||||||||||||||||||||||||
![]() | RfidUserBank | Dummy class for RfidUserBank in EPC only library | ||||||||||||||||||||||||||||
![]() | UiiException | General exception for conditions related to the translation of ISO Unique Item Identification (UII). | ||||||||||||||||||||||||||||
![]() | UnknownGcpLengthException | Exception thrown from a GcpLengthTable instance when the GS1 Company Prefix length cannot be determined. | ||||||||||||||||||||||||||||
![]() | UserDataElement | A data element that may be encoded into user memory, from any data system. A data element is a name/value pair, where the name is an and the value is a string. | ||||||||||||||||||||||||||||
![]() | UserMemoryException | General exception for conditions related to the translation of user memory. |
Interface | Description | |
---|---|---|
![]() | GcpLengthTable | Infers the length of the GS1 Company Prefix for a specified GS1 key. Different implementations of this class may reference different data sources and use different methods to make the inference. Clients may implement this interface to create their own strategies for GCP length lookup. For a simple implementation that maps prefixes to GCP length, see PrefixGcpLengthTable To use GS1-provided GCP length data, see Gs1GcpLengthTable |
Enumeration | Description | |
---|---|---|
![]() | Gs1EpcLibEncodings | Encoding options for TDS 2.0 variable length alpha numeric components |
![]() | Gs1EpcLibTagSchemes | EPC Tag Schemes. |