@uns-kit/cli 0.0.60 → 0.0.62

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.60",
3
+ "version": "0.0.62",
4
4
  "description": "Command line scaffolding tool for UNS applications",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -26,10 +26,10 @@
26
26
  ],
27
27
  "dependencies": {
28
28
  "azure-devops-node-api": "^15.1.1",
29
- "@uns-kit/core": "1.0.24"
29
+ "@uns-kit/core": "1.0.29"
30
30
  },
31
31
  "unsKitPackages": {
32
- "@uns-kit/core": "1.0.24",
32
+ "@uns-kit/core": "1.0.29",
33
33
  "@uns-kit/api": "0.0.19",
34
34
  "@uns-kit/cron": "0.0.18",
35
35
  "@uns-kit/temporal": "0.0.18"
@@ -1,16 +1,20 @@
1
1
  /**
2
2
  * Change this file according to your specifications and rename it to index.ts
3
3
  */
4
- import { UnsProxyProcess, ConfigFile, logger } from "@uns-kit/core";
5
- import type { IUnsMessage, UnsEvents } from "@uns-kit/core";
4
+ import { UnsProxyProcess, ConfigFile, logger, UnsEvents } from "@uns-kit/core";
5
+ import { registerAttributeDescriptions, registerObjectTypeDescriptions } from "@uns-kit/core/uns/uns-dictionary-registry.js";
6
6
  import "@uns-kit/cron";
7
- import { type UnsProxyProcessWithCron } from "@uns-kit/cron.js";
8
- import { UnsTags } from "../uns/uns-tags.js";
9
- import { UnsTopics } from "../uns/uns-topics.js";
10
- import { PhysicalMeasurements } from "@uns-kit/core/uns/uns-measurements.js";
7
+ import { type UnsProxyProcessWithCron } from "@uns-kit/cron";
8
+ import { UnsTopics } from "@uns-kit/core/uns/uns-topics.js";
11
9
  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";
10
+ import {
11
+ GeneratedObjectTypes,
12
+ GeneratedAttributes,
13
+ GeneratedAttributesByType,
14
+ GeneratedAttributeDescriptions,
15
+ GeneratedObjectTypeDescriptions,
16
+ } from "./uns/uns-dictionary.generated.js";
17
+ import { GeneratedPhysicalMeasurements } from "./uns/uns-measurements.generated.js";
14
18
 
15
19
 
16
20
  /**
@@ -19,12 +23,14 @@ import { EquipmentAttributes } from "@uns-kit/core/uns/uns-attributes.js";
19
23
  * In the development environment, you are responsible for creating and maintaining this file and its contents.
20
24
  */
21
25
  const config = await ConfigFile.loadConfig();
26
+ registerObjectTypeDescriptions(GeneratedObjectTypeDescriptions);
27
+ registerAttributeDescriptions(GeneratedAttributeDescriptions);
22
28
 
23
29
  /**
24
30
  * Connect to the output broker and create a crontab proxy
25
31
  */
26
32
  const unsProxyProcess = new UnsProxyProcess(config.infra.host!, {processName:config.uns.processName}) as UnsProxyProcessWithCron;;
27
- const mqttOutput = await unsProxyProcess.createUnsMqttProxy((config.output?.host)!, "templateUnsRttOutput", config.uns.instanceMode, config.uns.handover, { publishThrottlingDelay: 1000});
33
+ const mqttOutput = await unsProxyProcess.createUnsMqttProxy((config.output?.host)!, "templateUnsRttOutput", config.uns.instanceMode!, config.uns.handover!, { publishThrottlingDelay: 1000});
28
34
  const cronInput = await unsProxyProcess.createCrontabProxy("* * * * * *");
29
35
 
30
36
  /**
@@ -35,20 +41,24 @@ cronInput.event.on("cronEvent", async (event: UnsEvents["cronEvent"]) => {
35
41
  try {
36
42
  const time = UnsPacket.formatToISO8601(new Date());
37
43
  const numberValue: number = 42;
38
- const message: IUnsMessage = { data: { time, value: numberValue, uom: PhysicalMeasurements.MiliVolt } };
39
44
  const topic: UnsTopics = "example/";
40
- const objectType = ObjectTypes.Equipment;
41
- const objectId = "main";
42
- const tags: UnsTags[] = [];
43
- const packet = await UnsPacket.unsPacketFromUnsMessage(message);
45
+ const asset = "asset";
46
+ const assetDescription = "Sample asset";
47
+
48
+ const dataGroup = "sensor";
49
+
44
50
  mqttOutput.publishMqttMessage({
45
51
  topic,
46
- attribute: EquipmentAttributes.MeasuredTemperature,
47
- packet,
48
- description: "Number value",
49
- objectType,
50
- objectId,
51
- tags
52
+ asset,
53
+ assetDescription,
54
+ objectType: GeneratedObjectTypes.equipment,
55
+ objectId: "main",
56
+ attributes: [
57
+ {
58
+ attribute: GeneratedAttributesByType["energy-resource"]["current"],
59
+ data: { dataGroup, time, value: numberValue, uom: GeneratedPhysicalMeasurements.Ampere }
60
+ }
61
+ ],
52
62
  });
53
63
  } catch (error) {
54
64
  const reason = error instanceof Error ? error : new Error(String(error));
@@ -11,13 +11,13 @@
11
11
  "password": "123"
12
12
  },
13
13
  "infra": {
14
- "host": "localhost:1883"
14
+ "host": "localhost"
15
15
  },
16
16
  "output": {
17
- "host": "localhost:1883"
17
+ "host": "localhost"
18
18
  },
19
19
  "input": {
20
- "host": "localhost:1883"
20
+ "host": "localhost"
21
21
  },
22
22
  "devops": {
23
23
  "provider": "azure-devops",