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