nope/modules/generic-plc/helpers/gen-setup-belegung.ts
Martin Karkowski 838d910c2f adding gojs
2020-12-01 13:05:35 +01:00

70 lines
1.4 KiB
TypeScript

/**
* @author Martin Karkowski
* @email m.karkowski@zema.de
* @create date 2018-12-19 15:26:04
* @modify date 2020-09-09 16:06:45
* @desc [Tool to convert the the provided Inputs to a config file]
*/
import { writeFileSync } from "fs";
import { padString } from "../../../lib/helpers/stringMethods";
export const DEFAULT_GUI_CONFIG = "./config/gui-configuration.json";
function _genOutputBool(
start: number,
numberOfByts: number,
modName: string,
preLabel = "out_"
) {
let counter = 0;
let ret = "";
do {
const str =
preLabel +
padString(start + Math.floor(counter / 8), 3) +
"_" +
(counter % 8).toString() +
"\t" +
modName +
"\tBool\t%Q" +
(start + Math.floor(counter / 8)).toString() +
"." +
(counter % 8).toString();
if (counter === 0) {
ret = str;
} else {
ret += "\n" + str;
}
counter++;
} while (counter < numberOfByts * 8);
return ret;
}
if (require.main == module) {
const mods = [
[0, 4, "SPS"],
[12, 4, "ET200"]
];
let ret = "";
for (const [counter, m] of mods.entries()) {
const str = _genOutputBool(...m);
if (counter === 0) {
ret = str;
} else {
ret += "\n" + str;
}
}
writeFileSync(
"./modules/mod-Generic-PLC-Interface/helpers/SPS-Belegung-Raw.txt",
ret,
{ encoding: "utf-8" }
);
}