@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uns-kit/cli",
3
- "version": "0.0.39",
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": "0.0.43"
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({ topic, attribute: "data-number", packet, description: "Number value", tags });
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}`);
@@ -18,7 +18,7 @@
18
18
  }
19
19
  },
20
20
  "scripts": {
21
- "clean": "rimraf dist",
21
+ "clean": "rimraf dist tsconfig.tsbuildinfo",
22
22
  "typecheck": "tsc --noEmit",
23
23
  "build": "pnpm run clean && tsc -p tsconfig.json",
24
24
  "dev": "tsx watch src/index.ts",
@@ -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 = "example/";
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({ topic, attribute: "data-count", packet, description: "Counter", tags });
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: "data-sensor",
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 = "example/factory-a/line-1/";
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({ topic, attribute: "table-sample", packet, description: "Table", tags });
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": "integratedTerminal",
12
+ "console": "internalConsole",
13
13
  "internalConsoleOptions": "openOnSessionStart",
14
+ "outputCapture": "std",
14
15
  "sourceMaps": true,
15
- "stopOnEntry": true,
16
+ "stopOnEntry": false,
16
17
  "outFiles": [
17
18
  "${workspaceFolder}/dist/**/*.js",
18
19
  "!**/node_modules/**"