refactor(printers): allowed for more logging to come over
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
import net from "net";
|
||||
import { pausePrinter } from "../../utils/pausePrinter.js";
|
||||
import { addHours, differenceInSeconds } from "date-fns";
|
||||
import { printerUpdate } from "./printerStatUpdate.js";
|
||||
import net from "net";
|
||||
import { timeZoneFix } from "../../../../globalUtils/timeZoneFix.js";
|
||||
import { createLog } from "../../../logger/logger.js";
|
||||
import { pausePrinter } from "../../utils/pausePrinter.js";
|
||||
import { unPausePrinter } from "../../utils/unpausePrinter.js";
|
||||
|
||||
import { labelingProcess } from "../labeling/labelProcess.js";
|
||||
import { timeZoneFix } from "../../../../globalUtils/timeZoneFix.js";
|
||||
import { autoLabelCreated } from "../labeling/labelRatio.js";
|
||||
import { printerUpdate } from "./printerStatUpdate.js";
|
||||
|
||||
let logLevel: string = process.env.LOG_LEVEL || "info";
|
||||
let errorCheck = false;
|
||||
@@ -70,20 +70,20 @@ export const printerStatus = async (p: any) => {
|
||||
"ocp",
|
||||
"ocp",
|
||||
`${p.name}: timeBetween: ${timeBetween}, delay ${parseInt(
|
||||
p.printDelay
|
||||
)}, ${currentTime}... ${lastTime}`
|
||||
p.printDelay,
|
||||
)}, ${currentTime}... ${lastTime}`,
|
||||
);
|
||||
|
||||
if (tmp[2] === "0" && tmp[4] !== "000") {
|
||||
// unpaused and printing labels - reset timer
|
||||
createLog(
|
||||
"debug",
|
||||
"info",
|
||||
"ocp",
|
||||
"ocp",
|
||||
`Unpaused and printing labels, time remaing ${differenceInSeconds(
|
||||
parseInt(p.printDelay),
|
||||
timeBetween
|
||||
)}`
|
||||
timeBetween,
|
||||
)}`,
|
||||
);
|
||||
|
||||
// update last time printed in the array
|
||||
@@ -98,8 +98,8 @@ export const printerStatus = async (p: any) => {
|
||||
p.name
|
||||
} paused to soon, unpausing, remaining time: ${differenceInSeconds(
|
||||
parseInt(p.printDelay),
|
||||
timeBetween
|
||||
)}`
|
||||
timeBetween,
|
||||
)}`,
|
||||
);
|
||||
|
||||
// reset the timer for this printer as well other labels shouldnt be sent but if we send them ok
|
||||
@@ -109,12 +109,12 @@ export const printerStatus = async (p: any) => {
|
||||
} else if (tmp[2] === "0" && timeBetween < parseInt(p.printDelay)) {
|
||||
// was unpaused to soon so repause it
|
||||
createLog(
|
||||
"debug",
|
||||
"info",
|
||||
"ocp",
|
||||
"ocp",
|
||||
`${p.name} Unpaused before the time allowed, time left ${
|
||||
differenceInSeconds(parseInt(p.printDelay), timeBetween) //seconds
|
||||
}`
|
||||
}`,
|
||||
);
|
||||
|
||||
printerUpdate(p, 3);
|
||||
@@ -122,10 +122,10 @@ export const printerStatus = async (p: any) => {
|
||||
} else if (tmp[2] === "0" && timeBetween > parseInt(p.printDelay)) {
|
||||
// its been long enough we can print a label
|
||||
createLog(
|
||||
"debug",
|
||||
"info",
|
||||
"ocp",
|
||||
"ocp",
|
||||
`${p.name} Allowed time passed and printing new label`
|
||||
`${p.name} Allowed time passed and printing new label`,
|
||||
);
|
||||
|
||||
// update last time printed in the array
|
||||
@@ -136,12 +136,7 @@ export const printerStatus = async (p: any) => {
|
||||
autoLabelCreated();
|
||||
} else if (tmp[2] === "0") {
|
||||
// printer was unpaused for the first time or made it here
|
||||
createLog(
|
||||
"debug",
|
||||
"ocp",
|
||||
"ocp",
|
||||
`${p.name} Frist time printing`
|
||||
);
|
||||
createLog("info", "ocp", "ocp", `${p.name} Frist time printing`);
|
||||
|
||||
// add the time and printer
|
||||
printerUpdate(p, 4);
|
||||
@@ -151,12 +146,7 @@ export const printerStatus = async (p: any) => {
|
||||
autoLabelCreated();
|
||||
} else if (tmp[2] === "1") {
|
||||
// printer is paused and waiting
|
||||
createLog(
|
||||
"debug",
|
||||
"ocp",
|
||||
"ocp",
|
||||
`${p.name} paused and waiting`
|
||||
);
|
||||
createLog("debug", "ocp", "ocp", `${p.name} paused and waiting`);
|
||||
|
||||
printerUpdate(p, 6);
|
||||
}
|
||||
@@ -174,7 +164,7 @@ export const printerStatus = async (p: any) => {
|
||||
"info",
|
||||
"printerState",
|
||||
"ocp",
|
||||
`${p.name}: was force closed, during normal cycle counting`
|
||||
`${p.name}: was force closed, during normal cycle counting`,
|
||||
);
|
||||
printer.destroy();
|
||||
}
|
||||
@@ -201,7 +191,7 @@ export const printerStatus = async (p: any) => {
|
||||
"error",
|
||||
"ocp",
|
||||
"ocp",
|
||||
`${p.name} encountered an error: ${error}`
|
||||
`${p.name} encountered an error: ${error}`,
|
||||
);
|
||||
|
||||
await printerUpdate(p, 7);
|
||||
@@ -266,7 +256,7 @@ export const autoLabelingStats = async (p: any) => {
|
||||
"error",
|
||||
"ocp",
|
||||
"ocp",
|
||||
`${p.name}, encountered an error: ${error}`
|
||||
`${p.name}, encountered an error: ${error}`,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user