Moodle PHP Documentation 4.4
Moodle 4.4.1 (Build: 20240610) (db07c09afc5)
Datamatrix Class Reference

Class to create DataMatrix ECC 200 barcode arrays for TCPDF class. More...

Public Member Functions

 __construct ($code)
 This is the class constructor.
 
 getBarcodeArray ()
 Returns a barcode array which is readable by TCPDF.
 

Protected Member Functions

 get253StateCodeword ($cwpad, $cwpos)
 Return the 253-state codeword.
 
 get255StateCodeword ($cwpad, $cwpos)
 Return the 255-state codeword.
 
 getErrorCorrection ($wd, $nb, $nd, $nc, $gf=256, $pp=301)
 Add error correction codewords to data codewords array (ANNEX E).
 
 getGFProduct ($a, $b, $log, $alog, $gf)
 Product of two numbers in a Power-of-Two Galois Field.
 
 getHighLevelEncoding ($data)
 Get high level encoding using the minimum symbol data characters for ECC 200.
 
 getMaxDataCodewords ($numcw)
 Choose the minimum matrix size and return the max number of data codewords.
 
 getPlacementMap ($nrow, $ncol)
 Build a placement map.
 
 getSwitchEncodingCodeword ($mode)
 Get the switching codeword to a new encoding mode (latch codeword)
 
 isCharMode ($chr, $mode)
 Returns true if the char belongs to the selected mode.
 
 lookAheadTest ($data, $pos, $mode)
 The look-ahead test scans the data to be encoded to find the best mode (Annex P - steps from J to S).
 
 placeCornerA ($marr, $nrow, $ncol, $chr)
 Places the 8 bits of the first special corner case.
 
 placeCornerB ($marr, $nrow, $ncol, $chr)
 Places the 8 bits of the second special corner case.
 
 placeCornerC ($marr, $nrow, $ncol, $chr)
 Places the 8 bits of the third special corner case.
 
 placeCornerD ($marr, $nrow, $ncol, $chr)
 Places the 8 bits of the fourth special corner case.
 
 placeModule ($marr, $nrow, $ncol, $row, $col, $chr, $bit)
 Places "chr+bit" with appropriate wrapping within array[].
 
 placeUtah ($marr, $nrow, $ncol, $row, $col, $chr)
 Places the 8 bits of a utah-shaped symbol character.
 

Protected Attributes

 $barcode_array = array()
 Barcode array to be returned which is readable by TCPDF.
 
 $chset
 Basic set of characters for each encodation mode.
 
 $chset_id = array(ENC_C40 => 'C40', ENC_TXT => 'TXT', ENC_X12 =>'X12')
 Map encodation modes whit character sets.
 
 $last_enc = ENC_ASCII
 Store last used encoding for data codewords.
 
 $symbattr
 Table of Data Matrix ECC 200 Symbol Attributes:
 

Detailed Description

Class to create DataMatrix ECC 200 barcode arrays for TCPDF class.

DataMatrix (ISO/IEC 16022:2006) is a 2-dimensional bar code.

..

Author
Nicola Asuni
Version
1.0.004

Constructor & Destructor Documentation

◆ __construct()

Datamatrix::__construct ( $code)

This is the class constructor.

Creates a datamatrix object

Parameters
string$codeCode to represent using Datamatrix.

Member Function Documentation

◆ get253StateCodeword()

Datamatrix::get253StateCodeword ( $cwpad,
$cwpos )
protected

Return the 253-state codeword.

Parameters
int$cwpadPad codeword.
int$cwposNumber of data codewords from the beginning of encoded data.
Return values
intpad codeword

◆ get255StateCodeword()

Datamatrix::get255StateCodeword ( $cwpad,
$cwpos )
protected

Return the 255-state codeword.

Parameters
int$cwpadPad codeword.
int$cwposNumber of data codewords from the beginning of encoded data.
Return values
intpad codeword

◆ getBarcodeArray()

Datamatrix::getBarcodeArray ( )

Returns a barcode array which is readable by TCPDF.

Return values
arraybarcode array readable by TCPDF;

◆ getErrorCorrection()

Datamatrix::getErrorCorrection ( $wd,
$nb,
$nd,
$nc,
$gf = 256,
$pp = 301 )
protected

Add error correction codewords to data codewords array (ANNEX E).

Parameters
array$wdArray of datacodewords.
int$nbNumber of blocks.
int$ndNumber of data codewords per block.
int$ncNumber of correction codewords per block.
int$gfnumner of fields on log/antilog table (power of 2).
int$ppThe value of its prime modulus polynomial (301 for ECC200).
Return values
arraydata codewords + error codewords

◆ getGFProduct()

Datamatrix::getGFProduct ( $a,
$b,
$log,
$alog,
$gf )
protected

Product of two numbers in a Power-of-Two Galois Field.

Parameters
int$afirst number to multiply.
int$bsecond number to multiply.
array$logLog table.
array$alogAnti-Log table.
int$gfNumber of Factors of the Reed-Solomon polynomial.
Return values
intproduct

◆ getHighLevelEncoding()

Datamatrix::getHighLevelEncoding ( $data)
protected

Get high level encoding using the minimum symbol data characters for ECC 200.

Parameters
string$datadata to encode
Return values
arrayof codewords

◆ getMaxDataCodewords()

Datamatrix::getMaxDataCodewords ( $numcw)
protected

Choose the minimum matrix size and return the max number of data codewords.

Parameters
int$numcwNumber of current codewords.
Return values
intnumber of data codewords in matrix

◆ getPlacementMap()

Datamatrix::getPlacementMap ( $nrow,
$ncol )
protected

Build a placement map.

(Annex F - ECC 200 symbol character placement)

Parameters
int$nrowNumber of rows.
int$ncolNumber of columns.
Return values
array

◆ getSwitchEncodingCodeword()

Datamatrix::getSwitchEncodingCodeword ( $mode)
protected

Get the switching codeword to a new encoding mode (latch codeword)

Parameters
int$modeNew encoding mode.
Return values
intSwitch codeword.

◆ isCharMode()

Datamatrix::isCharMode ( $chr,
$mode )
protected

Returns true if the char belongs to the selected mode.

Parameters
int$chrCharacter (byte) to check.
int$modeCurrent encoding mode.
Return values
booleantrue if the char is of the selected mode.

◆ lookAheadTest()

Datamatrix::lookAheadTest ( $data,
$pos,
$mode )
protected

The look-ahead test scans the data to be encoded to find the best mode (Annex P - steps from J to S).

Parameters
string$datadata to encode
int$poscurrent position
int$modecurrent encoding mode
Return values
intencoding mode

◆ placeCornerA()

Datamatrix::placeCornerA ( $marr,
$nrow,
$ncol,
$chr )
protected

Places the 8 bits of the first special corner case.

(Annex F - ECC 200 symbol character placement)

Parameters
array$marrArray of symbols.
int$nrowNumber of rows.
int$ncolNumber of columns.
int$chrChar byte.
Return values
array

◆ placeCornerB()

Datamatrix::placeCornerB ( $marr,
$nrow,
$ncol,
$chr )
protected

Places the 8 bits of the second special corner case.

(Annex F - ECC 200 symbol character placement)

Parameters
array$marrArray of symbols.
int$nrowNumber of rows.
int$ncolNumber of columns.
int$chrChar byte.
Return values
array

◆ placeCornerC()

Datamatrix::placeCornerC ( $marr,
$nrow,
$ncol,
$chr )
protected

Places the 8 bits of the third special corner case.

(Annex F - ECC 200 symbol character placement)

Parameters
array$marrArray of symbols.
int$nrowNumber of rows.
int$ncolNumber of columns.
int$chrChar byte.
Return values
array

◆ placeCornerD()

Datamatrix::placeCornerD ( $marr,
$nrow,
$ncol,
$chr )
protected

Places the 8 bits of the fourth special corner case.

(Annex F - ECC 200 symbol character placement)

Parameters
array$marrArray of symbols.
int$nrowNumber of rows.
int$ncolNumber of columns.
int$chrChar byte.
Return values
array

◆ placeModule()

Datamatrix::placeModule ( $marr,
$nrow,
$ncol,
$row,
$col,
$chr,
$bit )
protected

Places "chr+bit" with appropriate wrapping within array[].

(Annex F - ECC 200 symbol character placement)

Parameters
array$marrArray of symbols.
int$nrowNumber of rows.
int$ncolNumber of columns.
int$rowRow number.
int$colColumn number.
int$chrChar byte.
int$bitBit.
Return values
array

◆ placeUtah()

Datamatrix::placeUtah ( $marr,
$nrow,
$ncol,
$row,
$col,
$chr )
protected

Places the 8 bits of a utah-shaped symbol character.

(Annex F - ECC 200 symbol character placement)

Parameters
array$marrArray of symbols.
int$nrowNumber of rows.
int$ncolNumber of columns.
int$rowRow number.
int$colColumn number.
int$chrChar byte.
Return values
array

Member Data Documentation

◆ $symbattr

Datamatrix::$symbattr
protected

Table of Data Matrix ECC 200 Symbol Attributes:

  • total matrix rows (including finder pattern)
  • total matrix cols (including finder pattern)
  • total matrix rows (without finder pattern)
  • total matrix cols (without finder pattern)
  • region data rows (with finder pattern)
  • region data col (with finder pattern)
  • region data rows (without finder pattern)
  • region data col (without finder pattern)
  • horizontal regions
  • vertical regions
  • regions
  • data codewords
  • error codewords
  • blocks
  • data codewords per block
  • error codewords per block

The documentation for this class was generated from the following file: