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);
});

View File

@@ -0,0 +1,88 @@
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 = "Alplaprodcmd112"; // to consume all the pallets
const lot = "AlplaPRODchg#00000016706"; // to consume to the lot make sure its showing in 2.0 to be able to consume to it
const labels = [
"1000000000000000000000000000000005106656",
"1000000000000000000000000000000005106386",
"1000000000000000000000000000000005106446",
"1000000000000000000000000000000005106326",
"1000000000000000000000000000000005105726",
"1000000000000000000000000000000005106056",
"1000000000000000000000000000000005106256",
"1000000000000000000000000000000005105836",
"1000000000000000000000000000000005105986",
"1000000000000000000000000000000005105506",
"1000000000000000000000000000000005106136",
"1000000000000000000000000000000005105696",
"1000000000000000000000000000000005105426",
"1000000000000000000000000000000005105916",
"1000000000000000000000000000000005105216",
"1000000000000000000000000000000005105416",
"1000000000000000000000000000000005105196",
"1000000000000000000000000000000005105226",
"1000000000000000000000000000000005105816",
"1000000000000000000000000000000005110186",
"1000000000000000000000000000000005110256",
"1000000000000000000000000000000005109926",
"1000000000000000000000000000000005110096",
"1000000000000000000000000000000005110026",
"1000000000000000000000000000000005110036",
"1000000000000000000000000000000005109716",
"1000000000000000000000000000000005110006",
"1000000000000000000000000000000005109446",
"1000000000000000000000000000000005109606",
"1000000000000000000000000000000005109076",
];
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));
// consume 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];
// trigger the lot
let message = Buffer.from(`${STX}${scannerID}${lot}${ETX}`, "ascii");
console.log("Sending:", message.toString("ascii"));
scanner.write(message);
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);
});

View File

@@ -0,0 +1,99 @@
import net from "net";
/**
* This uses a kinda fake scanner to mimic the scanning process to a server and creates the bol.
*/
const prodIP = "10.44.0.26";
const prodPort = 50001;
const scannerID = "98@";
const scannerCommand = "AlplaPRODcmd00000042#000047909"; // top of the picksheet
const scannerCommand2 = ""; // bottom of the pick sheet
const labels = [
"1000000000000000000000000000000006544320",
"1000000000000000000000000000000006544280",
"1000000000000000000000000000000006544410",
"1000000000000000000000000000000006544490",
"1000000000000000000000000000000006544450",
"1000000000000000000000000000000006544520",
"1000000000000000000000000000000006544590",
"1000000000000000000000000000000006544560",
"1000000000000000000000000000000006544860",
"1000000000000000000000000000000006544830",
"1000000000000000000000000000000006544930",
"1000000000000000000000000000000006544890",
"1000000000000000000000000000000006545100",
"1000000000000000000000000000000006545060",
"1000000000000000000000000000000006545270",
"1000000000000000000000000000000006545220",
"1000000000000000000000000000000006544990",
"1000000000000000000000000000000006545040",
"1000000000000000000000000000000006545520",
"1000000000000000000000000000000006545490",
"1000000000000000000000000000000006545450",
"1000000000000000000000000000000006545560",
"1000000000000000000000000000000006545760",
"1000000000000000000000000000000006545640",
"1000000000000000000000000000000006545690",
"1000000000000000000000000000000006545620",
"1000000000000000000000000000000006546450",
"1000000000000000000000000000000006546500",
"1000000000000000000000000000000006545940",
"1000000000000000000000000000000006545900",
"1000000000000000000000000000000006545850",
"1000000000000000000000000000000006545820",
"1000000000000000000000000000000006546530",
"1000000000000000000000000000000006545330",
"1000000000000000000000000000000006546090",
"1000000000000000000000000000000006546220",
"1000000000000000000000000000000006546120",
"1000000000000000000000000000000006546140",
"1000000000000000000000000000000006546260",
"1000000000000000000000000000000006546310",
];
const STX = "\x02";
const ETX = "\x03";
const scanner = new net.Socket();
scanner.connect(prodPort, prodIP, async () => {
console.log("Connected to scanner");
const message = Buffer.from(
`${STX}${scannerID}${scannerCommand}${ETX}`,
"ascii",
);
console.log("Sending:", message.toString("ascii"));
scanner.write(message);
await new Promise((resolve) => setTimeout(resolve, 2000));
for (let i = 0; i < labels.length; i++) {
const l = labels[i];
const message = Buffer.from(`${STX}${scannerID}${l}${ETX}`, "ascii");
console.log("Sending:", message.toString("ascii"));
scanner.write(message);
await new Promise((resolve) => setTimeout(resolve, 1200));
}
// //close the incoming
// await new Promise(resolve => setTimeout(resolve, 1500));
// const message2 = Buffer.from(`${STX}${scannerID}${scannerCommand2}${ETX}`, "ascii");
// console.log("Sending:", message2.toString("ascii"));
// scanner.write(message2);
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);
});