helper scripts

This commit is contained in:
2026-02-03 15:40:51 -06:00
parent 84a28f2d01
commit d63138d746
3 changed files with 292 additions and 0 deletions

View File

@@ -0,0 +1,105 @@
import net from "net";
/**
* This uses a kinda fake scanner to mimic the scanning process to a server and creates the bol.
*/
const scannerID = "98@";
const scannerCommand = "Alplaprodcmd10"; // to consume all the pallets
const lot = "AlplaPRODchg#00000016700"; // to consume to the lot make sure its showing in 2.0 to be able to consume to it
const labels = [
"1000000000000000000000000000000005512460",
"1000000000000000000000000000000005512470",
"1000000000000000000000000000000005512480",
"1000000000000000000000000000000005512490",
"1000000000000000000000000000000005512500",
"1000000000000000000000000000000005512510",
"1000000000000000000000000000000005512520",
"1000000000000000000000000000000005512530",
"1000000000000000000000000000000005512540",
"1000000000000000000000000000000005512550",
"1000000000000000000000000000000005512560",
"1000000000000000000000000000000005512570",
"1000000000000000000000000000000005512580",
"1000000000000000000000000000000005512590",
"1000000000000000000000000000000005512600",
"1000000000000000000000000000000005512610",
"1000000000000000000000000000000005512620",
"1000000000000000000000000000000005512630",
"1000000000000000000000000000000005512640",
"1000000000000000000000000000000005512650",
"1000000000000000000000000000000005512660",
"1000000000000000000000000000000005512670",
"1000000000000000000000000000000005512680",
"1000000000000000000000000000000005512690",
"1000000000000000000000000000000005512700",
"1000000000000000000000000000000005512710",
"1000000000000000000000000000000005512720",
"1000000000000000000000000000000005512730",
"1000000000000000000000000000000005512740",
"1000000000000000000000000000000005512750",
"1000000000000000000000000000000005512760",
"1000000000000000000000000000000005512770",
"1000000000000000000000000000000005512780",
"1000000000000000000000000000000005512790",
"1000000000000000000000000000000005512800",
"1000000000000000000000000000000005512810",
"1000000000000000000000000000000005512820",
"1000000000000000000000000000000005512830",
"1000000000000000000000000000000005512840",
"1000000000000000000000000000000005512850",
"1000000000000000000000000000000005512860",
"1000000000000000000000000000000005512870",
"1000000000000000000000000000000005512880",
"1000000000000000000000000000000005512890",
"1000000000000000000000000000000005512900",
"1000000000000000000000000000000005512910",
"1000000000000000000000000000000005512920",
"1000000000000000000000000000000005512930",
"1000000000000000000000000000000005512940",
"1000000000000000000000000000000005512950",
"1000000000000000000000000000000005512960",
];
const STX = "\x02";
const ETX = "\x03";
const scanner = new net.Socket();
scanner.connect(50000, "10.204.0.26", async () => {
console.log("Connected to scanner");
// change the scanner to the to 112
let message = Buffer.from(
`${STX}${scannerID}${scannerCommand}${ETX}`,
"ascii",
);
console.log("Sending:", message.toString("ascii"));
scanner.write(message);
await new Promise((resolve) => setTimeout(resolve, 2000));
// bookin all the pallets in the array
await new Promise((resolve) => setTimeout(resolve, 2000));
for (let i = 0; i < labels.length; i++) {
const l = labels[i];
message = Buffer.from(`${STX}${scannerID}${l}${ETX}`, "ascii");
console.log("Sending:", message.toString("ascii"));
scanner.write(message);
await new Promise((resolve) => setTimeout(resolve, 1200));
}
await new Promise((resolve) => setTimeout(resolve, 1500));
scanner.destroy();
});
scanner.on("data", async (data) => {
console.log("Response:", data.toString("ascii"));
});
scanner.on("close", () => {
console.log("Connection closed");
});
scanner.on("error", (err) => {
console.error("Scanner error:", err);
});