summaryrefslogtreecommitdiff
path: root/source/codes/DataMatrix.mc
diff options
context:
space:
mode:
Diffstat (limited to 'source/codes/DataMatrix.mc')
-rw-r--r--source/codes/DataMatrix.mc24
1 files changed, 23 insertions, 1 deletions
diff --git a/source/codes/DataMatrix.mc b/source/codes/DataMatrix.mc
index 76a29e8..4fcc179 100644
--- a/source/codes/DataMatrix.mc
+++ b/source/codes/DataMatrix.mc
@@ -39,6 +39,8 @@ module DataMatrix {
// with a 1,500-byte payload (144 x 144 modules).
const BYTES_PER_STEP = 250; // codeword encodation
const ECC_WORK_PER_STEP = 400; // data symbols x EC symbols
+ // Cumulative percent at the end of each phase 0-4 (see DataMatrixJob.percent).
+ const PHASE_ENDS = [2, 44, 45, 69, 100];
const BUILD_MODULES_PER_STEP = 300; // symbol modules
var field as ReedSolomon.Field? = null;
@@ -184,8 +186,28 @@ module DataMatrix {
_data = Bytes.fromUtf8(text);
}
+ // Progress 0-100: the share of each phase (simulator timings; the
+ // Reed-Solomon blocks, the placement and the symbol take the most).
function percent() as Number {
- return _phase * 20;
+ var done = 0;
+ var total = 0;
+ if (_phase == 1 && _size.size() > 0) { // blocks done, and the current one
+ var e = _encoder;
+ done = _block * 100 + (e != null ? e.percent() : 0);
+ total = _size[5] * 100;
+ } else if (_phase == 3 && _size.size() > 0) { // codewords placed
+ done = _chr - 1;
+ total = _size[3] + _size[4];
+ } else if (_phase == 4 && _size.size() > 0) { // rows built
+ done = _buildRow;
+ total = _size[0];
+ }
+ return Codes.phased(PHASE_ENDS, _phase, done, total);
+ }
+
+ // Packing and runs: about 84 / 3 / 13 % of a whole display job.
+ function stageEnds() as Array<Number> {
+ return [84, 87];
}
function matrix() as Codes.Matrix? {