nope/modules/wamo/cli/generateConfig.ts

160 lines
3.8 KiB
TypeScript
Raw Normal View History

/**
* @author Martin Karkowski
* @email m.karkowski@zema.de
* @create date 2021-02-09 10:12:37
2021-02-26 09:22:32 +00:00
* @modify date 2021-02-26 08:53:56
* @desc [description]
*/
import { hostname } from "os";
import { join, resolve } from "path";
import { createFile } from "../../../lib/helpers/fileMethods";
const name = hostname();
const num: number = +name.split("-")[1];
2021-02-26 09:22:32 +00:00
const config = {
functions: [],
packages: [
// Mirrpr
{
nameOfPackage: "mirrorPackage",
defaultInstances: [
{
options: {
identifier: ("wamo-" + name + "-mirror").toLowerCase(),
params: [
"http://nope-master.demonstrator04.local:7001",
"info", // Logger-Level
false, // considerConnection
false // waitForConnection
],
type: "MirrorLinkModule"
},
selector: "MirrorLinkModule"
}
],
autostart: {},
path: "dist\\modules\\mirror\\src\\mirror-link.package.js"
},
// Beckhoff
{
nameOfPackage: "beckhoffPackage",
defaultInstances: [
{
options: {
identifier: name,
params: [
{
port: 48898,
amsPortSource: 32905,
amsPortTarget: 851,
timeout: 5000,
2021-02-26 09:22:32 +00:00
amsNetIdTarget: "1.1.1.1.1." + num.toString(),
amsNetIdSource: "2.2.2.2.2.2",
host: "localhost",
twinCatVersion: 3
}
],
type: "BeckhoffPlc"
},
selector: "BeckhoffPlc"
}
],
autostart: {},
path:
"dist\\modules\\mod-Beckhoff-PLC-Interface\\src\\beckhoff.package.js"
},
// MQTT-Broker
{
nameOfPackage: "mqttBrokerPackage",
defaultInstances: [
{
options: {
identifier: ("wamo-" + name + "-mqtt-broker").toLowerCase(),
params: [],
type: "MQTTBrokerModule"
},
selector: "MQTTBrokerModule"
}
],
autostart: {},
path: "dist\\modules\\mqtt-broker\\src\\mqtt.broker.package.js"
},
// Updater
{
nameOfPackage: "updaterPackage",
defaultInstances: [
{
options: {
2021-02-26 09:22:32 +00:00
identifier: ("wamo-" + name + "-updater").toLowerCase(),
params: [],
type: "UpdaterModule"
},
selector: "UpdaterModule"
}
],
autostart: {},
path: "dist\\modules\\updater\\src\\updater.package.js"
},
// Evil
{
nameOfPackage: "evilPackage",
defaultInstances: [
{
options: {
identifier: ("wamo-" + name + "-evil-module").toLowerCase(),
params: [],
type: "EvilModule"
}
}
],
autostart: {},
path: "dist\\modules\\evil\\src\\slave.package.js"
},
// HostManager:
{
nameOfPackage: "hostManagerPackage",
defaultInstances: [
{
options: {
identifier: ("wamo-" + name + "-host-manager").toLowerCase(),
params: [],
type: "HostManagerModule"
},
selector: "HostManagerModule"
}
],
autostart: {},
path: "dist\\modules\\host-manager\\src\\hostManager.package.js"
}
]
};
const pubSubConfig = {
nameOfPackage: "pubsubPackage",
defaultInstances: [
{
options: {
identifier: "pub-sub-system",
params: [],
type: "PubSubModule"
}
}
],
autostart: {},
path: "dist\\modules\\pub-sub\\src\\pub-sub.package.js"
};
// Define the Filename for the Configuration
const filename: string = join(
resolve(process.cwd()),
"config",
"settings.json"
);
createFile(filename, JSON.stringify(config, undefined, 4)).then(() =>
console.log("Created Configuartion in", filename)
);