Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 30 additions & 12 deletions demo/advanced.html
Original file line number Diff line number Diff line change
Expand Up @@ -446,18 +446,21 @@ <h4>${titleHtml}</h4>
<span class="visually-hidden">Settings</span>
</button>
<ul class="dropdown-menu">
<li><a id="printtest_${idx}" data-printer-idx="${idx}" class="dropdown-item" href="#">
Print test page
</a></li>
<li><a id="feedlabel_${idx}" data-printer-idx="${idx}" class="dropdown-item" href="#">
Feed blank label
</a></li>
<li><a id="configprinter_${idx}" data-printer-idx="${idx}" class="dropdown-item" href="#">
Set label config
</a></li>
<li><a id="printconfig_${idx}" data-printer-idx="${idx}" class="dropdown-item" href="#">
Print config on labels
</a></li>
<li><a id="printerStatus_${idx}" data-printer-idx="${idx}" class="dropdown-item" href="#">
Query printer status
</a></li>
<li><a id="printtest_${idx}" data-printer-idx="${idx}" class="dropdown-item" href="#">
Print test page
</a></li>
<li><a id="feedlabel_${idx}" data-printer-idx="${idx}" class="dropdown-item" href="#">
Feed blank label
</a></li>
<li><a id="configprinter_${idx}" data-printer-idx="${idx}" class="dropdown-item" href="#">
Set label config
</a></li>
<li><a id="printconfig_${idx}" data-printer-idx="${idx}" class="dropdown-item" href="#">
Print config on labels
</a></li>
</ul>
</div>
</div>
Expand Down Expand Up @@ -487,6 +490,14 @@ <h4>${titleHtml}</h4>
this.redrawPrinterButtonHighlights();
this.redrawTextCanvas();
});
document.getElementById(`printerStatus_${idx}`)!
.addEventListener('click', async (e) => {
e.preventDefault();
const printerIdx = (e.currentTarget as HTMLAnchorElement).dataset.printerIdx as unknown as number;
const printer = this.printers[printerIdx];
const doc = printer.getConfigDocument().queryStatus().finalize();
await printer.sendDocument(doc);
});
document.getElementById(`printtest_${idx}`)!
.addEventListener('click', async (e) => {
e.preventDefault();
Expand Down Expand Up @@ -709,12 +720,19 @@ <h4>${titleHtml}</h4>
// And send the whole shebang to the printer!
await printer.sendDocument(doc);

// Then get the updated printer info..
await printer.sendDocument(WebLabel.ReadyToPrintDocuments.configDocument);

// Hide the config modal
form.modalWithAutosense.checked = false;
form.modalZplWithSensorGraph.checked = false;
form.modalSubmit.removeAttribute("disabled");
form.modalCancel.removeAttribute("disabled");
this.activePrinterIndex = printerIdx;
this.configModalHandle.hide();

// Redraw the buttons with the updated config
this.redrawPrinterButtons();
}
}

Expand Down
42 changes: 30 additions & 12 deletions demo/editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -412,18 +412,21 @@ <h4>${titleHtml}</h4>
<span class="visually-hidden">Settings</span>
</button>
<ul class="dropdown-menu">
<li><a id="printtest_${idx}" data-printer-idx="${idx}" class="dropdown-item" href="#">
Print test page
</a></li>
<li><a id="feedlabel_${idx}" data-printer-idx="${idx}" class="dropdown-item" href="#">
Feed blank label
</a></li>
<li><a id="configprinter_${idx}" data-printer-idx="${idx}" class="dropdown-item" href="#">
Set label config
</a></li>
<li><a id="printconfig_${idx}" data-printer-idx="${idx}" class="dropdown-item" href="#">
Print config on labels
</a></li>
<li><a id="printerStatus_${idx}" data-printer-idx="${idx}" class="dropdown-item" href="#">
Query printer status
</a></li>
<li><a id="printtest_${idx}" data-printer-idx="${idx}" class="dropdown-item" href="#">
Print test page
</a></li>
<li><a id="feedlabel_${idx}" data-printer-idx="${idx}" class="dropdown-item" href="#">
Feed blank label
</a></li>
<li><a id="configprinter_${idx}" data-printer-idx="${idx}" class="dropdown-item" href="#">
Set label config
</a></li>
<li><a id="printconfig_${idx}" data-printer-idx="${idx}" class="dropdown-item" href="#">
Print config on labels
</a></li>
</ul>
</div>
</div>
Expand Down Expand Up @@ -453,6 +456,14 @@ <h4>${titleHtml}</h4>
this.redrawPrinterButtonHighlights();
this.redrawLabelCanvas();
});
document.getElementById(`printerStatus_${idx}`)!
.addEventListener('click', async (e) => {
e.preventDefault();
const printerIdx = (e.currentTarget as HTMLAnchorElement).dataset.printerIdx as unknown as number;
const printer = this.printers[printerIdx];
const doc = printer.getConfigDocument().queryStatus().finalize();
await printer.sendDocument(doc);
});
document.getElementById(`printtest_${idx}`)!
.addEventListener('click', async (e) => {
e.preventDefault();
Expand Down Expand Up @@ -639,12 +650,19 @@ <h4>${titleHtml}</h4>
// And send the whole shebang to the printer!
await printer.sendDocument(doc);

// Then get the updated printer info..
await printer.sendDocument(WebLabel.ReadyToPrintDocuments.configDocument);

// Hide the config modal
form.modalWithAutosense.checked = false;
form.modalZplWithSensorGraph.checked = false;
form.modalSubmit.removeAttribute("disabled");
form.modalCancel.removeAttribute("disabled");
this.activePrinterIndex = printerIdx;
this.configModalHandle.hide();

// Redraw the buttons with the updated config
this.redrawPrinterButtons();
}
}

Expand Down
42 changes: 30 additions & 12 deletions demo/test_advanced.ts
Original file line number Diff line number Diff line change
Expand Up @@ -377,18 +377,21 @@ class BasicLabelDesignerApp {
<span class="visually-hidden">Settings</span>
</button>
<ul class="dropdown-menu">
<li><a id="printtest_${idx}" data-printer-idx="${idx}" class="dropdown-item" href="#">
Print test page
</a></li>
<li><a id="feedlabel_${idx}" data-printer-idx="${idx}" class="dropdown-item" href="#">
Feed blank label
</a></li>
<li><a id="configprinter_${idx}" data-printer-idx="${idx}" class="dropdown-item" href="#">
Set label config
</a></li>
<li><a id="printconfig_${idx}" data-printer-idx="${idx}" class="dropdown-item" href="#">
Print config on labels
</a></li>
<li><a id="printerStatus_${idx}" data-printer-idx="${idx}" class="dropdown-item" href="#">
Query printer status
</a></li>
<li><a id="printtest_${idx}" data-printer-idx="${idx}" class="dropdown-item" href="#">
Print test page
</a></li>
<li><a id="feedlabel_${idx}" data-printer-idx="${idx}" class="dropdown-item" href="#">
Feed blank label
</a></li>
<li><a id="configprinter_${idx}" data-printer-idx="${idx}" class="dropdown-item" href="#">
Set label config
</a></li>
<li><a id="printconfig_${idx}" data-printer-idx="${idx}" class="dropdown-item" href="#">
Print config on labels
</a></li>
</ul>
</div>
</div>
Expand Down Expand Up @@ -418,6 +421,14 @@ class BasicLabelDesignerApp {
this.redrawPrinterButtonHighlights();
this.redrawTextCanvas();
});
document.getElementById(`printerStatus_${idx}`)!
.addEventListener('click', async (e) => {
e.preventDefault();
const printerIdx = (e.currentTarget as HTMLAnchorElement).dataset.printerIdx as unknown as number;
const printer = this.printers[printerIdx];
const doc = printer.getConfigDocument().queryStatus().finalize();
await printer.sendDocument(doc);
});
document.getElementById(`printtest_${idx}`)!
.addEventListener('click', async (e) => {
e.preventDefault();
Expand Down Expand Up @@ -640,12 +651,19 @@ class BasicLabelDesignerApp {
// And send the whole shebang to the printer!
await printer.sendDocument(doc);

// Then get the updated printer info..
await printer.sendDocument(WebLabel.ReadyToPrintDocuments.configDocument);

// Hide the config modal
form.modalWithAutosense.checked = false;
form.modalZplWithSensorGraph.checked = false;
form.modalSubmit.removeAttribute("disabled");
form.modalCancel.removeAttribute("disabled");
this.activePrinterIndex = printerIdx;
this.configModalHandle.hide();

// Redraw the buttons with the updated config
this.redrawPrinterButtons();
}
}

Expand Down
42 changes: 30 additions & 12 deletions demo/test_editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,18 +348,21 @@ class BasicLabelDesignerApp {
<span class="visually-hidden">Settings</span>
</button>
<ul class="dropdown-menu">
<li><a id="printtest_${idx}" data-printer-idx="${idx}" class="dropdown-item" href="#">
Print test page
</a></li>
<li><a id="feedlabel_${idx}" data-printer-idx="${idx}" class="dropdown-item" href="#">
Feed blank label
</a></li>
<li><a id="configprinter_${idx}" data-printer-idx="${idx}" class="dropdown-item" href="#">
Set label config
</a></li>
<li><a id="printconfig_${idx}" data-printer-idx="${idx}" class="dropdown-item" href="#">
Print config on labels
</a></li>
<li><a id="printerStatus_${idx}" data-printer-idx="${idx}" class="dropdown-item" href="#">
Query printer status
</a></li>
<li><a id="printtest_${idx}" data-printer-idx="${idx}" class="dropdown-item" href="#">
Print test page
</a></li>
<li><a id="feedlabel_${idx}" data-printer-idx="${idx}" class="dropdown-item" href="#">
Feed blank label
</a></li>
<li><a id="configprinter_${idx}" data-printer-idx="${idx}" class="dropdown-item" href="#">
Set label config
</a></li>
<li><a id="printconfig_${idx}" data-printer-idx="${idx}" class="dropdown-item" href="#">
Print config on labels
</a></li>
</ul>
</div>
</div>
Expand Down Expand Up @@ -389,6 +392,14 @@ class BasicLabelDesignerApp {
this.redrawPrinterButtonHighlights();
this.redrawLabelCanvas();
});
document.getElementById(`printerStatus_${idx}`)!
.addEventListener('click', async (e) => {
e.preventDefault();
const printerIdx = (e.currentTarget as HTMLAnchorElement).dataset.printerIdx as unknown as number;
const printer = this.printers[printerIdx];
const doc = printer.getConfigDocument().queryStatus().finalize();
await printer.sendDocument(doc);
});
document.getElementById(`printtest_${idx}`)!
.addEventListener('click', async (e) => {
e.preventDefault();
Expand Down Expand Up @@ -575,12 +586,19 @@ class BasicLabelDesignerApp {
// And send the whole shebang to the printer!
await printer.sendDocument(doc);

// Then get the updated printer info..
await printer.sendDocument(WebLabel.ReadyToPrintDocuments.configDocument);

// Hide the config modal
form.modalWithAutosense.checked = false;
form.modalZplWithSensorGraph.checked = false;
form.modalSubmit.removeAttribute("disabled");
form.modalCancel.removeAttribute("disabled");
this.activePrinterIndex = printerIdx;
this.configModalHandle.hide();

// Redraw the buttons with the updated config
this.redrawPrinterButtons();
}
}

Expand Down
6 changes: 4 additions & 2 deletions src/Documents/ConfigDocument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ export class ConfigDocumentBuilder
// to commit the changes to stored memory. EPL does this automatically, ZPL does not
// so to bring them closer to parity this is automatically implied.
private _doSave = false;
// TODO: Consider whether this should move to a ZPL extended command.
override finalize() {
if (this._doSave) {
this.andThen(new Cmds.SaveCurrentConfigurationCommand());
this.andThen(new Cmds.SaveCurrentConfigurationCommand())
.andThen(new Cmds.EndLabel())
.andThen(new Cmds.StartLabel())
.andThen(new Cmds.QueryConfigurationCommand());
}
return super.finalize();
}
Expand Down
24 changes: 21 additions & 3 deletions src/Languages/Zpl/CmdHostConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ export function parseCmdHostConfig(
// Store these for disambiguation later on..
let markLed, ribbonLed: number | undefined;
let sawGain = false;
let sawNonCont = false;
let sawSensorType: string | undefined;

response
.split('\n')
Expand Down Expand Up @@ -125,19 +127,25 @@ export function parseCmdHostConfig(
update.printerMedia!.mediaGapDetectMode = Conf.MediaMediaGapDetectionMode.continuous;
break;
case "GAP/NOTCH":
case "NON-CONTINUOUS":
update.printerMedia!.mediaGapDetectMode = Conf.MediaMediaGapDetectionMode.webSensing;
break;
case "NON-CONTINUOUS":
// Older printers use this for both mark and web, then use SENSOR TYPE
// to determine what type of non-continuous.
sawNonCont = true;
break;
}
break;
}
case "SENSOR SELECT": // TRANSMISSIVE, REFLECTIVE, MANUAL
// Seems to be present on newer firmware revisions
// This should be set automatically with MEDIA TYPE.
// TODO: Don't ignore this if it disagrees with MEDIA TYPE?
break;
case "SENSOR TYPE": // MARK, WEB
// This should be set automatically with MEDIA TYPE. LP2844-Z units.
// TODO: Don't ignore this if it disagrees with MEDIA TYPE?
// Seems to be present on older firmware revisions. Will still be set
// when in continuous mode, so disambiguate later on.
sawSensorType = l.value
break;

// Cases handled by XML.
Expand Down Expand Up @@ -360,6 +368,16 @@ export function parseCmdHostConfig(
update.printerZplSettings!.ribbonGain = ribbonLed;
}

// On older printers 'NON-CONTINOUS' media type is used for web and mark
// then the SENSOR TYPE is used to determine the gap mode.
if (sawNonCont && sawSensorType !== undefined) {
if (sawSensorType === "MARK") {
update.printerMedia!.mediaGapDetectMode = Conf.MediaMediaGapDetectionMode.markSensing;
} else if (sawSensorType === "WEB") {
update.printerMedia!.mediaGapDetectMode = Conf.MediaMediaGapDetectionMode.webSensing;
}
}

result.messages = [update];
return result
}
Expand Down
2 changes: 1 addition & 1 deletion src/Languages/Zpl/test_files/LP2844_Z_CONF.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"messageType": "SettingUpdateMessage",
"printerHardware": {},
"printerMedia": {
"mediaGapDetectMode": 1,
"mediaGapDetectMode": 2,
"mediaLengthDots": 235,
},
"printerSettings": {},
Expand Down
Loading