SGLN

class epc.schemes.SGLN(*args, **kwargs)

The SGLN EPC scheme is used to assign a unique identity to a physical location, such as a specific building or a specific unit of shelving within a warehouse.

General syntax: urn:epc:id:sgln:CompanyPrefix.LocationReference.Extension

Example: urn:epc:id:sgln:0614141.12345.400

filter(tag_filter)

The filter value is additional control information that may be included in the EPC memory bank of a Gen 2 tag. The intended use of the filter value is to allow an RFID reader to select or deselect the tags corresponding to certain physical objects, to make it easier to read the desired tags in an environment where there may be other tags present in the environment. For example, if the goal is to read the single tag on a pallet, and it is expected that there may be hundreds or thousands of item-level tags present, the performance of the capturing application may be improved by using the Gen 2 air interface to select the pallet tag and deselect the item-level tags.

Allowed values for SGLN tags:

Value

Constant

Description

0

FILTER_ALL

All Others

1-7

FILTER_RESERVED_*

Reserved

Parameters

tag_filter (int) – The filter value, defaults to FILTER_ALL.

Raises

AttributeError – Filter must be between 0 and 7.

Returns

The SGLN tag object.

Return type

epc.schemes.SGLN

company_prefix(company_prefix, company_prefix_length=None)

The GS1 Company Prefix, assigned by GS1 to a managing entity. The Company Prefix is the same as the GS1 Company Prefix digits within a GS1 GIAI key.

Length corresponds to the number of digits in the company prefix.

Parameters
  • company_prefix (str, int) – GS1 company prefix.

  • company_prefix_length (int, optional) – Number of digits in the company prefix. Required when company_prefix is an int.

Returns

The SGLN tag object.

Return type

epc.schemes.SGLN

location_reference(location_reference)

The Location Reference, assigned uniquely by the managing entity to a specific physical location.

Parameters

location_reference (int, str) – The location reference

Raises

ValueError – Unable to convert input to an integer.

Returns

The SGLN tag object.

Return type

epc.schemes.SGLN

extension(extension)

The GLN Extension, assigned by the managing entity to an individual unique location. If the entire GLN Extension is just a single zero digit, it indicates that the SGLN stands for a GLN, without an extension.

Parameters

extension (str, int) – The GLN extension

Raises

AttributeError – Extension length incorrect.

Returns

The SGLN tag object.

Return type

epc.schemes.SGLN

tag_size()

Set the size for the tag. Options are SIZE_96 or SIZE_195.

Parameters

tag_size (int) – Tag size in bits. Defaults to SIZE_96.

Raises

AttributeError – Invalid tag size specified.

Returns

The SGLN tag object.

Return type

epc.schemes.SGLN

property tag_uri
Returns

The tag’s URI.

Return type

str

property pure_identity_uri
Returns

The tag’s pure identity URI.

Return type

str

property barcode
Returns

The barcode representation of the tag.

Return type

str

property barcode_humanized
Returns

A human readable barcode representation of the tag.

Return type

str

property values
Returns

Dictionary containing:

  • size (int): the tag’s size in bits

  • filter (int)

  • company_prefix (str)

  • location_reference (int)

  • extension (int or str)

decode_epc(hex_string)

Decode an encoded tag and populate this object’s values from it.

Parameters

hex_string (str) – Tag data encoded as a hexadecimal string.

Raises
  • ValueError – EPC scheme header does not match input.

  • ValueError – Filter does not match allowed values.

  • ValueError – Supplied hex_string bit length invalid.

decode_barcode(barcode, company_prefix_length)

Decode a barcode and populate this object’s values from it.

Parameters
  • hex_string (str) – Barcode

  • company_prefix_length (int) – Number of digits of the company prefix length

Raises
  • ValueError – Expected barcode header does not match input.

  • AttributeError – Invalid barcode length, or wrong company prefix.

check_fields()

Checks to make sure all components of the tag are present, including size, filter, company_prefix, location_reference and extension.

Raises

AttributeError – If any components of the tag are missing.

Hint

To get the encoded tag data, use python’s built in conversion methods:

>>> tag = SGLN()
>>> tag.company_prefix(1234, company_prefix_length=6).location_reference(15).extension(1000)

# Hexadecimal
>>> hex(tag)
'0x3218013480001e00000003e8'

# Binary
>>> bin(tag)
'0b1100100001100000000001001101001000000000000000000111100000000000000000000000000000001111101000'

Constants

Filters

SGLN.FILTER_ALL
SGLN.FILTER_RESERVED_*

Replace asterisk with 1-7.

Sizes

SGLN.SIZE_96

96 bit tag size.

SGLN.SIZE_195

195 bit tag size.

Headers

SGLN.HEADER_BARCODE

GS1 specified barcode header: 414.

SGLN.HEADER_96

GS1 specified hexadecimal header for 96 bit SGLN tags: 0x32.

SGLN.HEADER_195

GS1 specified hexadecimal header for 202 bit SGLN tags: 0x39.

SGLN.SGLN_96

Human readable GS1 specified header for 96 bit SGLN tags: sgln-96.

SGLN.SGLN_195

Human readable GS1 specified header for 202 bit SGLN tags: sgln-195.