@uns-kit/cli 0.0.31 → 0.0.32
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/dist/index.js
CHANGED
|
@@ -298,6 +298,22 @@ async function configureDevops(targetPath) {
|
|
|
298
298
|
scripts["pull-request"] = "node ./node_modules/@uns-kit/core/dist/tools/pull-request.js";
|
|
299
299
|
pkgChanged = true;
|
|
300
300
|
}
|
|
301
|
+
const azurePipelineTemplatePath = path.resolve(__dirname, "../templates/azure-pipelines.yml");
|
|
302
|
+
try {
|
|
303
|
+
await access(azurePipelineTemplatePath);
|
|
304
|
+
}
|
|
305
|
+
catch (error) {
|
|
306
|
+
throw new Error("Azure Pipelines template is missing. Please ensure templates/azure-pipelines.yml exists.");
|
|
307
|
+
}
|
|
308
|
+
const pipelineTargetPath = path.join(targetDir, "azure-pipelines.yml");
|
|
309
|
+
let pipelineMessage = "";
|
|
310
|
+
if (await fileExists(pipelineTargetPath)) {
|
|
311
|
+
pipelineMessage = " azure-pipelines.yml already exists (skipped).";
|
|
312
|
+
}
|
|
313
|
+
else {
|
|
314
|
+
await copyFile(azurePipelineTemplatePath, pipelineTargetPath);
|
|
315
|
+
pipelineMessage = " Added azure-pipelines.yml pipeline definition.";
|
|
316
|
+
}
|
|
301
317
|
await writeFile(configPath, JSON.stringify(config, null, 2) + "\n", "utf8");
|
|
302
318
|
if (pkgChanged) {
|
|
303
319
|
await writeFile(packagePath, JSON.stringify(pkg, null, 2) + "\n", "utf8");
|
|
@@ -312,6 +328,9 @@ async function configureDevops(targetPath) {
|
|
|
312
328
|
if (gitRemoteMessage) {
|
|
313
329
|
console.log(gitRemoteMessage);
|
|
314
330
|
}
|
|
331
|
+
if (pipelineMessage) {
|
|
332
|
+
console.log(pipelineMessage);
|
|
333
|
+
}
|
|
315
334
|
if (pkgChanged) {
|
|
316
335
|
console.log(" Updated package.json scripts/devDependencies. Run pnpm install to fetch new packages.");
|
|
317
336
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uns-kit/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.32",
|
|
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.
|
|
29
|
+
"@uns-kit/core": "0.0.33"
|
|
30
30
|
},
|
|
31
31
|
"scripts": {
|
|
32
32
|
"build": "tsc -p tsconfig.build.json",
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
variables:
|
|
2
|
+
privatePool: 'Azure private pool'
|
|
3
|
+
|
|
4
|
+
trigger:
|
|
5
|
+
- master
|
|
6
|
+
|
|
7
|
+
stages:
|
|
8
|
+
- stage: version_tag
|
|
9
|
+
displayName: Add Version Tag
|
|
10
|
+
pool: $(privatePool)
|
|
11
|
+
jobs:
|
|
12
|
+
- job: add_tags
|
|
13
|
+
steps:
|
|
14
|
+
- checkout: self
|
|
15
|
+
persistCredentials: true
|
|
16
|
+
clean: true
|
|
17
|
+
- script: |
|
|
18
|
+
tag=$(node -pe "require('./package.json').version")
|
|
19
|
+
git tag $tag
|
|
20
|
+
git push origin $tag
|
|
21
|
+
displayName: "Add version tag from package.json"
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Change this file according to your specifications and rename it to index.ts
|
|
3
3
|
*/
|
|
4
4
|
import { UnsProxyProcess, ConfigFile, logger, type IUnsMessage } from "@uns-kit/core";
|
|
5
|
-
import { PhysicalMeasurements } from "@uns-kit/core/uns/uns-measurements.js";
|
|
5
|
+
import { DataSizeMeasurements, PhysicalMeasurements } from "@uns-kit/core/uns/uns-measurements.js";
|
|
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";
|
|
@@ -31,14 +31,34 @@ const mqttOutput = await unsProxyProcess.createUnsMqttProxy((config.output?.host
|
|
|
31
31
|
mqttInput.event.on("input", async (event) => {
|
|
32
32
|
try {
|
|
33
33
|
if (event.topic === "raw/data") {
|
|
34
|
-
const time = UnsPacket.formatToISO8601(new Date());
|
|
35
34
|
const values = event.message.split(",");
|
|
36
|
-
const
|
|
37
|
-
const
|
|
35
|
+
const [countRaw, timestampRaw, sensorRaw] = values;
|
|
36
|
+
const numberValue = Number.parseFloat(countRaw);
|
|
37
|
+
const eventDate = new Date(Number.parseInt(timestampRaw, 10));
|
|
38
|
+
const sensorValue = Number.parseFloat(sensorRaw);
|
|
39
|
+
const time = UnsPacket.formatToISO8601(eventDate);
|
|
40
|
+
|
|
41
|
+
const dataGroup = "sensor";
|
|
42
|
+
|
|
43
|
+
const message: IUnsMessage = {
|
|
44
|
+
data: { dataGroup, time, value: numberValue, uom: PhysicalMeasurements.None },
|
|
45
|
+
};
|
|
38
46
|
const topic: UnsTopics = "example/";
|
|
39
47
|
const tags: UnsTags[] = [];
|
|
40
48
|
const packet = await UnsPacket.unsPacketFromUnsMessage(message);
|
|
41
|
-
mqttOutput.publishMqttMessage({ topic, attribute: "data-
|
|
49
|
+
mqttOutput.publishMqttMessage({ topic, attribute: "data-count", packet, description: "Counter", tags });
|
|
50
|
+
|
|
51
|
+
const sensorMessage: IUnsMessage = {
|
|
52
|
+
data: { dataGroup, time, value: sensorValue, uom: PhysicalMeasurements.Celsius },
|
|
53
|
+
};
|
|
54
|
+
const sensorPacket = await UnsPacket.unsPacketFromUnsMessage(sensorMessage);
|
|
55
|
+
mqttOutput.publishMqttMessage({
|
|
56
|
+
topic,
|
|
57
|
+
attribute: "data-sensor",
|
|
58
|
+
packet: sensorPacket,
|
|
59
|
+
description: "Simulated sensor value",
|
|
60
|
+
tags,
|
|
61
|
+
});
|
|
42
62
|
}
|
|
43
63
|
} catch (error) {
|
|
44
64
|
const reason = error instanceof Error ? error : new Error(String(error));
|
|
@@ -7,6 +7,20 @@ import readline from "readline";
|
|
|
7
7
|
import { ConfigFile, logger } from "@uns-kit/core";
|
|
8
8
|
import UnsMqttProxy from "@uns-kit/core/uns-mqtt/uns-mqtt-proxy.js";
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Produces a smooth oscillating value to mimic a real-world sensor signal.
|
|
12
|
+
* Combines fast and slow sine waves plus tiny ripple so that subsequent values
|
|
13
|
+
* rise and fall without appearing purely random.
|
|
14
|
+
*/
|
|
15
|
+
function simulateSensorValue(step: number): number {
|
|
16
|
+
const baseValue = 42; // arbitrary midpoint for the simulated signal
|
|
17
|
+
const fastCycle = Math.sin(step / 5) * 3;
|
|
18
|
+
const slowCycle = Math.sin(step / 25) * 6;
|
|
19
|
+
const ripple = Math.sin(step / 2 + Math.PI / 4) * 0.5;
|
|
20
|
+
const value = baseValue + fastCycle + slowCycle + ripple;
|
|
21
|
+
|
|
22
|
+
return Number(value.toFixed(2));
|
|
23
|
+
}
|
|
10
24
|
|
|
11
25
|
/**
|
|
12
26
|
* This script initializes an MQTT output proxy for load testing purposes.
|
|
@@ -50,7 +64,8 @@ async function main() {
|
|
|
50
64
|
while (count < maxIntervals) {
|
|
51
65
|
try {
|
|
52
66
|
const currentDate = new Date();
|
|
53
|
-
const
|
|
67
|
+
const sensorValue = simulateSensorValue(count);
|
|
68
|
+
const rawData = `${count},${currentDate.getTime()},${sensorValue}`;
|
|
54
69
|
await mqttOutput.publishMessage("raw/data", rawData);
|
|
55
70
|
} catch (error) {
|
|
56
71
|
const reason = error instanceof Error ? error : new Error(String(error));
|
|
@@ -1,6 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": "0.2.0",
|
|
3
3
|
"configurations": [
|
|
4
|
+
{
|
|
5
|
+
"type": "node",
|
|
6
|
+
"request": "launch",
|
|
7
|
+
"name": "index",
|
|
8
|
+
"runtimeArgs": [
|
|
9
|
+
"--enable-source-maps",
|
|
10
|
+
"--import",
|
|
11
|
+
"tsx",
|
|
12
|
+
],
|
|
13
|
+
"program": "${workspaceFolder}/src/index.ts",
|
|
14
|
+
"console": "internalConsole",
|
|
15
|
+
"internalConsoleOptions": "openOnSessionStart",
|
|
16
|
+
"outputCapture": "std",
|
|
17
|
+
"cwd": "${workspaceFolder}",
|
|
18
|
+
"sourceMaps": true,
|
|
19
|
+
"skipFiles": ["<node_internals>/**"],
|
|
20
|
+
"resolveSourceMapLocations": [
|
|
21
|
+
"${workspaceFolder}/**"
|
|
22
|
+
]
|
|
23
|
+
},
|
|
4
24
|
{
|
|
5
25
|
"type": "node",
|
|
6
26
|
"request": "launch",
|