2020-08-30 07:45:44 +00:00
|
|
|
/**
|
|
|
|
* @author Martin Karkowski
|
|
|
|
* @email m.karkowski@zema.de
|
|
|
|
* @create date 2018-12-19 15:26:04
|
2020-09-10 16:21:19 +00:00
|
|
|
* @modify date 2020-09-09 16:06:45
|
2020-08-30 07:45:44 +00:00
|
|
|
* @desc [Tool to convert the the provided Inputs to a config file]
|
|
|
|
*/
|
|
|
|
|
|
|
|
import { writeFileSync } from "fs";
|
2020-09-10 16:21:19 +00:00
|
|
|
import { padString } from "../../../lib/helpers/stringMethods";
|
2020-08-30 07:45:44 +00:00
|
|
|
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(
|
2020-09-08 14:59:06 +00:00
|
|
|
"./modules/mod-Generic-PLC-Interface/helpers/SPS-Belegung-Raw.txt",
|
2020-08-30 07:45:44 +00:00
|
|
|
ret,
|
|
|
|
{ encoding: "utf-8" }
|
|
|
|
);
|
|
|
|
}
|