/** * @author Martin Karkowski * @email m.karkowski@zema.de * @create date 2018-12-19 15:26:04 * @modify date 2020-03-12 21:41:12 * @desc [Tool to convert the the provided Inputs to a config file] */ import { writeFileSync } from "fs"; import { padString } from "../../ZISS-TypeScript-Library/src/String-Methods"; 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/ZISS-Generic-PLC-Interface/helpers/SPS-Belegung-Raw.txt", ret, { encoding: "utf-8" } ); }