@uns-kit/cli 0.0.39 → 0.0.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/templates/cron/src/examples/cron-example.ts +13 -1
- package/templates/default/package.json +1 -1
- package/templates/default/src/examples/data-example.ts +21 -3
- package/templates/default/src/examples/table-example.ts +14 -2
- package/templates/vscode/.vscode/launch.json +3 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uns-kit/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.41",
|
|
4
4
|
"description": "Command line scaffolding tool for UNS applications",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"azure-devops-node-api": "^15.1.1",
|
|
29
|
-
"@uns-kit/core": "
|
|
29
|
+
"@uns-kit/core": "1.0.4"
|
|
30
30
|
},
|
|
31
31
|
"unsKitPackages": {
|
|
32
32
|
"@uns-kit/core": "0.0.36",
|
|
@@ -9,6 +9,8 @@ import { UnsTags } from "../uns/uns-tags.js";
|
|
|
9
9
|
import { UnsTopics } from "../uns/uns-topics.js";
|
|
10
10
|
import { PhysicalMeasurements } from "@uns-kit/core/uns/uns-measurements.js";
|
|
11
11
|
import { UnsPacket } from "@uns-kit/core/uns/uns-packet.js";
|
|
12
|
+
import { ObjectTypes } from "@uns-kit/core/uns/uns-object.js";
|
|
13
|
+
import { EquipmentAttributes } from "@uns-kit/core/uns/uns-attributes.js";
|
|
12
14
|
|
|
13
15
|
|
|
14
16
|
/**
|
|
@@ -35,9 +37,19 @@ cronInput.event.on("cronEvent", async (event: UnsEvents["cronEvent"]) => {
|
|
|
35
37
|
const numberValue: number = 42;
|
|
36
38
|
const message: IUnsMessage = { data: { time, value: numberValue, uom: PhysicalMeasurements.MiliVolt } };
|
|
37
39
|
const topic: UnsTopics = "example/";
|
|
40
|
+
const objectType = ObjectTypes.Equipment;
|
|
41
|
+
const objectId = "main";
|
|
38
42
|
const tags: UnsTags[] = [];
|
|
39
43
|
const packet = await UnsPacket.unsPacketFromUnsMessage(message);
|
|
40
|
-
mqttOutput.publishMqttMessage({
|
|
44
|
+
mqttOutput.publishMqttMessage({
|
|
45
|
+
topic,
|
|
46
|
+
attribute: EquipmentAttributes.MeasuredTemperature,
|
|
47
|
+
packet,
|
|
48
|
+
description: "Number value",
|
|
49
|
+
objectType,
|
|
50
|
+
objectId,
|
|
51
|
+
tags
|
|
52
|
+
});
|
|
41
53
|
} catch (error) {
|
|
42
54
|
const reason = error instanceof Error ? error : new Error(String(error));
|
|
43
55
|
logger.error(`Error publishing message to MQTT: ${reason.message}`);
|
|
@@ -6,6 +6,8 @@ import { DataSizeMeasurements, PhysicalMeasurements } from "@uns-kit/core/uns/un
|
|
|
6
6
|
import { UnsPacket } from "@uns-kit/core/uns/uns-packet.js";
|
|
7
7
|
import { UnsTags } from "@uns-kit/core/uns/uns-tags.js";
|
|
8
8
|
import { UnsTopics } from "@uns-kit/core/uns/uns-topics.js";
|
|
9
|
+
import { ObjectTypes } from "@uns-kit/core/uns/uns-object.js";
|
|
10
|
+
import { EnergyResourceAttributes } from "@uns-kit/core/uns/uns-attributes.js";
|
|
9
11
|
|
|
10
12
|
/**
|
|
11
13
|
* Load the configuration from a file.
|
|
@@ -33,6 +35,10 @@ mqttInput.event.on("input", async (event) => {
|
|
|
33
35
|
if (event.topic === "raw/data") {
|
|
34
36
|
const values = event.message.split(",");
|
|
35
37
|
const [countRaw, timestampRaw, sensorRaw] = values;
|
|
38
|
+
if (!countRaw || !timestampRaw || !sensorRaw) {
|
|
39
|
+
logger.warn(`Skipping malformed raw/data payload: ${event.message}`);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
36
42
|
const numberValue = Number.parseFloat(countRaw);
|
|
37
43
|
const eventDate = new Date(Number.parseInt(timestampRaw, 10));
|
|
38
44
|
const sensorValue = Number.parseFloat(sensorRaw);
|
|
@@ -43,10 +49,20 @@ mqttInput.event.on("input", async (event) => {
|
|
|
43
49
|
const message: IUnsMessage = {
|
|
44
50
|
data: { dataGroup, time, value: numberValue, uom: PhysicalMeasurements.None },
|
|
45
51
|
};
|
|
46
|
-
const topic: UnsTopics = "
|
|
52
|
+
const topic: UnsTopics = "acme/plant-a/hot-end/line-1/furnace-1/";
|
|
53
|
+
const objectType = ObjectTypes.EnergyResource;
|
|
54
|
+
const objectId = "main";
|
|
47
55
|
const tags: UnsTags[] = [];
|
|
48
56
|
const packet = await UnsPacket.unsPacketFromUnsMessage(message);
|
|
49
|
-
mqttOutput.publishMqttMessage({
|
|
57
|
+
mqttOutput.publishMqttMessage({
|
|
58
|
+
topic,
|
|
59
|
+
attribute: EnergyResourceAttributes.Current,
|
|
60
|
+
packet,
|
|
61
|
+
description: "Counter",
|
|
62
|
+
objectType,
|
|
63
|
+
objectId,
|
|
64
|
+
tags
|
|
65
|
+
});
|
|
50
66
|
|
|
51
67
|
const sensorMessage: IUnsMessage = {
|
|
52
68
|
data: { dataGroup, time, value: sensorValue, uom: PhysicalMeasurements.Celsius },
|
|
@@ -54,9 +70,11 @@ mqttInput.event.on("input", async (event) => {
|
|
|
54
70
|
const sensorPacket = await UnsPacket.unsPacketFromUnsMessage(sensorMessage);
|
|
55
71
|
mqttOutput.publishMqttMessage({
|
|
56
72
|
topic,
|
|
57
|
-
attribute:
|
|
73
|
+
attribute: EnergyResourceAttributes.Voltage,
|
|
58
74
|
packet: sensorPacket,
|
|
59
75
|
description: "Simulated sensor value",
|
|
76
|
+
objectType,
|
|
77
|
+
objectId,
|
|
60
78
|
tags,
|
|
61
79
|
});
|
|
62
80
|
}
|
|
@@ -6,6 +6,8 @@ import { UnsProxyProcess, ConfigFile, logger, type IUnsMessage } from "@uns-kit/
|
|
|
6
6
|
import { UnsPacket } from "@uns-kit/core/uns/uns-packet.js";
|
|
7
7
|
import { UnsTags } from "@uns-kit/core/uns/uns-tags.js";
|
|
8
8
|
import { UnsTopics } from "@uns-kit/core/uns/uns-topics.js";
|
|
9
|
+
import { ObjectTypes } from "@uns-kit/core/uns/uns-object.js";
|
|
10
|
+
import { LineAttributes } from "@uns-kit/core/uns/uns-attributes.js";
|
|
9
11
|
|
|
10
12
|
/**
|
|
11
13
|
* Load the configuration from a file.
|
|
@@ -53,10 +55,20 @@ mqttInput.event.on("input", async (event) => {
|
|
|
53
55
|
const time = UnsPacket.formatToISO8601(new Date(timestamp));
|
|
54
56
|
// const message: IUnsMessage = { table: {dataGroup:"demo_table", values:jsonObject, columnTypes, time}};
|
|
55
57
|
const message: IUnsMessage = { table: {dataGroup:"demo_table", values:jsonObject, time}};
|
|
56
|
-
const topic: UnsTopics = "
|
|
58
|
+
const topic: UnsTopics = "acme/plant-a/hot-end/line-1/";
|
|
59
|
+
const objectType = ObjectTypes.Line;
|
|
60
|
+
const objectId = "line-1";
|
|
57
61
|
const tags: UnsTags[] = [];
|
|
58
62
|
const packet = await UnsPacket.unsPacketFromUnsMessage(message);
|
|
59
|
-
mqttOutput.publishMqttMessage({
|
|
63
|
+
mqttOutput.publishMqttMessage({
|
|
64
|
+
topic,
|
|
65
|
+
attribute: LineAttributes.Status,
|
|
66
|
+
packet,
|
|
67
|
+
description: "Table",
|
|
68
|
+
objectType,
|
|
69
|
+
objectId,
|
|
70
|
+
tags
|
|
71
|
+
});
|
|
60
72
|
}
|
|
61
73
|
} catch (error) {
|
|
62
74
|
const reason = error instanceof Error ? error : new Error(String(error));
|
|
@@ -9,10 +9,11 @@
|
|
|
9
9
|
"--enable-source-maps"
|
|
10
10
|
],
|
|
11
11
|
"program": "${workspaceFolder}/dist/index.js",
|
|
12
|
-
"console": "
|
|
12
|
+
"console": "internalConsole",
|
|
13
13
|
"internalConsoleOptions": "openOnSessionStart",
|
|
14
|
+
"outputCapture": "std",
|
|
14
15
|
"sourceMaps": true,
|
|
15
|
-
"stopOnEntry":
|
|
16
|
+
"stopOnEntry": false,
|
|
16
17
|
"outFiles": [
|
|
17
18
|
"${workspaceFolder}/dist/**/*.js",
|
|
18
19
|
"!**/node_modules/**"
|