node-opcua-address-space-for-conformance-testing 2.180.0 → 2.181.0
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/address_space_for_conformance_testing.d.ts +12 -2
- package/dist/address_space_for_conformance_testing.js +32 -27
- package/dist/address_space_for_conformance_testing.js.map +1 -1
- package/dist/conformance_testing/alarm_input_nodes.d.ts +2 -0
- package/dist/conformance_testing/alarm_input_nodes.js +102 -0
- package/dist/conformance_testing/alarm_input_nodes.js.map +1 -0
- package/dist/conformance_testing/ctt_folder.d.ts +2 -0
- package/dist/conformance_testing/ctt_folder.js +375 -0
- package/dist/conformance_testing/ctt_folder.js.map +1 -0
- package/dist/conformance_testing/ctt_tree.d.ts +35 -0
- package/dist/conformance_testing/ctt_tree.js +85 -0
- package/dist/conformance_testing/ctt_tree.js.map +1 -0
- package/dist/conformance_testing/custom_extension_object.d.ts +63 -0
- package/dist/conformance_testing/custom_extension_object.js +48 -0
- package/dist/conformance_testing/custom_extension_object.js.map +1 -0
- package/dist/conformance_testing/discrete_variables.js +6 -4
- package/dist/conformance_testing/discrete_variables.js.map +1 -1
- package/dist/conformance_testing/helpers.d.ts +2 -1
- package/dist/conformance_testing/helpers.js +23 -5
- package/dist/conformance_testing/helpers.js.map +1 -1
- package/dist/conformance_testing/mass_variables.d.ts +2 -1
- package/dist/conformance_testing/mass_variables.js +7 -6
- package/dist/conformance_testing/mass_variables.js.map +1 -1
- package/dist/conformance_testing/path_and_large_arrays.d.ts +2 -1
- package/dist/conformance_testing/path_and_large_arrays.js +6 -5
- package/dist/conformance_testing/path_and_large_arrays.js.map +1 -1
- package/dist/conformance_testing/simulation_variables.d.ts +2 -1
- package/dist/conformance_testing/simulation_variables.js +9 -9
- package/dist/conformance_testing/simulation_variables.js.map +1 -1
- package/dist/conformance_testing/static_variables.d.ts +2 -1
- package/dist/conformance_testing/static_variables.js +19 -12
- package/dist/conformance_testing/static_variables.js.map +1 -1
- package/dist/conformance_testing/type_defaults.d.ts +15 -1
- package/dist/conformance_testing/type_defaults.js +30 -1
- package/dist/conformance_testing/type_defaults.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +19 -14
- package/src/address_space_for_conformance_testing.ts +37 -18
- package/src/conformance_testing/alarm_input_nodes.ts +151 -0
- package/src/conformance_testing/ctt_folder.ts +440 -0
- package/src/conformance_testing/ctt_tree.ts +105 -0
- package/src/conformance_testing/custom_extension_object.ts +105 -0
- package/src/conformance_testing/discrete_variables.ts +6 -4
- package/src/conformance_testing/helpers.ts +26 -6
- package/src/conformance_testing/mass_variables.ts +5 -4
- package/src/conformance_testing/path_and_large_arrays.ts +5 -4
- package/src/conformance_testing/simulation_variables.ts +6 -6
- package/src/conformance_testing/static_variables.ts +31 -9
- package/src/conformance_testing/type_defaults.ts +31 -2
- package/src/index.ts +1 -1
|
@@ -25,7 +25,7 @@ export function addTwoStateDiscreteVariables(namespace: Namespace, parentFolder:
|
|
|
25
25
|
const DADiscreteTypeFolder = getDADiscreteTypeFolder(namespace, parentFolder);
|
|
26
26
|
|
|
27
27
|
const twoStateDiscrete001 = namespace.addTwoStateDiscrete({
|
|
28
|
-
|
|
28
|
+
componentOf: DADiscreteTypeFolder,
|
|
29
29
|
nodeId: "s=TwoStateDiscrete001",
|
|
30
30
|
browseName: "TwoStateDiscrete001",
|
|
31
31
|
trueState: "Enabled",
|
|
@@ -33,7 +33,7 @@ export function addTwoStateDiscreteVariables(namespace: Namespace, parentFolder:
|
|
|
33
33
|
});
|
|
34
34
|
|
|
35
35
|
const twoStateDiscrete002 = namespace.addTwoStateDiscrete({
|
|
36
|
-
|
|
36
|
+
componentOf: DADiscreteTypeFolder,
|
|
37
37
|
nodeId: "s=TwoStateDiscrete002",
|
|
38
38
|
browseName: "TwoStateDiscrete002",
|
|
39
39
|
trueState: "On",
|
|
@@ -41,7 +41,9 @@ export function addTwoStateDiscreteVariables(namespace: Namespace, parentFolder:
|
|
|
41
41
|
optionals: ["TransitionTime", "EffectiveDisplayName"]
|
|
42
42
|
});
|
|
43
43
|
|
|
44
|
+
// HasTrueSubState is not hierarchical: the HasComponent reference keeps it browsable
|
|
44
45
|
const twoStateDiscrete003 = namespace.addTwoStateDiscrete({
|
|
46
|
+
componentOf: DADiscreteTypeFolder,
|
|
45
47
|
browseName: "twoStateDiscrete003",
|
|
46
48
|
nodeId: "s=TwoStateDiscrete003",
|
|
47
49
|
optionals: ["TransitionTime"],
|
|
@@ -49,7 +51,7 @@ export function addTwoStateDiscreteVariables(namespace: Namespace, parentFolder:
|
|
|
49
51
|
});
|
|
50
52
|
|
|
51
53
|
const twoStateDiscrete004 = namespace.addTwoStateDiscrete({
|
|
52
|
-
|
|
54
|
+
componentOf: DADiscreteTypeFolder,
|
|
53
55
|
nodeId: "s=TwoStateDiscrete004",
|
|
54
56
|
browseName: "TwoStateDiscrete004",
|
|
55
57
|
trueState: "InProgress",
|
|
@@ -57,7 +59,7 @@ export function addTwoStateDiscreteVariables(namespace: Namespace, parentFolder:
|
|
|
57
59
|
});
|
|
58
60
|
|
|
59
61
|
const twoStateDiscrete005 = namespace.addTwoStateDiscrete({
|
|
60
|
-
|
|
62
|
+
componentOf: DADiscreteTypeFolder,
|
|
61
63
|
nodeId: "s=TwoStateDiscrete005",
|
|
62
64
|
browseName: "TwoStateDiscrete005",
|
|
63
65
|
trueState: "InProgress",
|
|
@@ -5,14 +5,17 @@ import type { Namespace, UAObject, UAVariable } from "node-opcua-address-space";
|
|
|
5
5
|
import { assert } from "node-opcua-assert";
|
|
6
6
|
import * as ec from "node-opcua-basic-types";
|
|
7
7
|
import { randomString } from "node-opcua-basic-types";
|
|
8
|
-
import { AccessLevelFlag, LocalizedText, makeAccessLevelFlag, QualifiedName } from "node-opcua-data-model";
|
|
8
|
+
import { AccessLevelFlag, DiagnosticInfo, LocalizedText, makeAccessLevelFlag, QualifiedName } from "node-opcua-data-model";
|
|
9
|
+
import { DataValue } from "node-opcua-data-value";
|
|
9
10
|
import { checkDebugFlag, make_debugLog, make_warningLog } from "node-opcua-debug";
|
|
10
11
|
import { findBuiltInType } from "node-opcua-factory";
|
|
11
12
|
import { buildVariantArray, DataType, Variant, VariantArrayType } from "node-opcua-variant";
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const
|
|
14
|
+
import type { CustomExtensionObject } from "./custom_extension_object.js";
|
|
15
|
+
|
|
16
|
+
const debugLog = make_debugLog("helpers");
|
|
17
|
+
const doDebug = checkDebugFlag("helpers");
|
|
18
|
+
const warningLog = make_warningLog("helpers");
|
|
16
19
|
|
|
17
20
|
// ─── Validators & Random Generators ─────────────────────────────────────
|
|
18
21
|
|
|
@@ -25,7 +28,7 @@ export function getValidatorFuncForType(dataType: DataType): (value: unknown) =>
|
|
|
25
28
|
return (f as (value: unknown) => boolean) || defaultValidator;
|
|
26
29
|
}
|
|
27
30
|
|
|
28
|
-
export function getRandomFuncForType(dataType: DataType): () => unknown {
|
|
31
|
+
export function getRandomFuncForType(dataType: DataType, custom?: CustomExtensionObject): () => unknown {
|
|
29
32
|
const dataTypeName = DataType[dataType];
|
|
30
33
|
const f = (ec as Record<string, unknown>)[`random${dataTypeName}`];
|
|
31
34
|
|
|
@@ -35,9 +38,26 @@ export function getRandomFuncForType(dataType: DataType): () => unknown {
|
|
|
35
38
|
|
|
36
39
|
switch (dataTypeName) {
|
|
37
40
|
case "Variant":
|
|
41
|
+
// the value of a Variant-typed variable is itself a Variant
|
|
42
|
+
return () => {
|
|
43
|
+
return new Variant({ dataType: DataType.Double, value: Math.random() * 100 });
|
|
44
|
+
};
|
|
45
|
+
case "DataValue":
|
|
46
|
+
return () => {
|
|
47
|
+
return new DataValue({
|
|
48
|
+
value: new Variant({ dataType: DataType.Double, value: Math.random() * 100 }),
|
|
49
|
+
sourceTimestamp: new Date()
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
case "DiagnosticInfo":
|
|
38
53
|
return () => {
|
|
39
|
-
return new
|
|
54
|
+
return new DiagnosticInfo({ additionalInfo: randomString() });
|
|
40
55
|
};
|
|
56
|
+
case "ExtensionObject":
|
|
57
|
+
// the one type with no namespace-zero answer: without a concrete
|
|
58
|
+
// structure from the caller the only valid value is a null
|
|
59
|
+
// ExtensionObject, which never changes - see ./custom_extension_object.ts
|
|
60
|
+
return custom ? () => custom.random() : () => null;
|
|
41
61
|
case "QualifiedName":
|
|
42
62
|
return () => {
|
|
43
63
|
return new QualifiedName({ name: randomString() });
|
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type { Namespace, UAObject } from "node-opcua-address-space";
|
|
5
5
|
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { type CustomExtensionObject, initialValueFor } from "./custom_extension_object.js";
|
|
7
|
+
import { addVariable } from "./helpers.js";
|
|
8
|
+
import { typeAndDefaultValue } from "./type_defaults.js";
|
|
8
9
|
|
|
9
10
|
function addMassVariablesOfType(
|
|
10
11
|
namespace: Namespace,
|
|
@@ -28,7 +29,7 @@ function addMassVariablesOfType(
|
|
|
28
29
|
}
|
|
29
30
|
}
|
|
30
31
|
|
|
31
|
-
export function addMassVariables(namespace: Namespace, scalarFolder: UAObject): void {
|
|
32
|
+
export function addMassVariables(namespace: Namespace, scalarFolder: UAObject, custom?: CustomExtensionObject): void {
|
|
32
33
|
const scalarMass = namespace.addFolder(scalarFolder, {
|
|
33
34
|
browseName: "Scalar_Mass",
|
|
34
35
|
description: "This folder will contain 100 items per supported data-type.",
|
|
@@ -37,6 +38,6 @@ export function addMassVariables(namespace: Namespace, scalarFolder: UAObject):
|
|
|
37
38
|
|
|
38
39
|
for (const e of typeAndDefaultValue) {
|
|
39
40
|
const realType = e.realType || e.type;
|
|
40
|
-
addMassVariablesOfType(namespace, scalarMass, e.type, e
|
|
41
|
+
addMassVariablesOfType(namespace, scalarMass, e.type, initialValueFor(e, custom), realType);
|
|
41
42
|
}
|
|
42
43
|
}
|
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type { Namespace, UAObject } from "node-opcua-address-space";
|
|
5
5
|
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { type CustomExtensionObject, initialValueFor } from "./custom_extension_object.js";
|
|
7
|
+
import { addArrayVariable } from "./helpers.js";
|
|
8
|
+
import { typeAndDefaultValue } from "./type_defaults.js";
|
|
8
9
|
|
|
9
10
|
export function addPath10Deep(namespace: Namespace, simulation_folder: UAObject) {
|
|
10
11
|
let parent = simulation_folder;
|
|
@@ -21,7 +22,7 @@ export function addPath10Deep(namespace: Namespace, simulation_folder: UAObject)
|
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
export function addVeryLargeArrayVariables(namespace: Namespace, objectsFolder: UAObject): void {
|
|
25
|
+
export function addVeryLargeArrayVariables(namespace: Namespace, objectsFolder: UAObject, custom?: CustomExtensionObject): void {
|
|
25
26
|
const scalarStaticLargeArray = namespace.addObject({
|
|
26
27
|
organizedBy: objectsFolder,
|
|
27
28
|
browseName: "Static_Scalar_Large_Array",
|
|
@@ -30,6 +31,6 @@ export function addVeryLargeArrayVariables(namespace: Namespace, objectsFolder:
|
|
|
30
31
|
});
|
|
31
32
|
for (const e of typeAndDefaultValue) {
|
|
32
33
|
const realType = e.realType || e.type;
|
|
33
|
-
addArrayVariable(namespace, scalarStaticLargeArray, e.type, e
|
|
34
|
+
addArrayVariable(namespace, scalarStaticLargeArray, e.type, initialValueFor(e, custom), realType, 50 * 1024, "");
|
|
34
35
|
}
|
|
35
36
|
}
|
|
@@ -6,10 +6,11 @@ import { assert } from "node-opcua-assert";
|
|
|
6
6
|
import { isValidBoolean, isValidUInt16 } from "node-opcua-basic-types";
|
|
7
7
|
import { DataType, Variant, VariantArrayType } from "node-opcua-variant";
|
|
8
8
|
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
9
|
+
import { type CustomExtensionObject, initialValueFor } from "./custom_extension_object.js";
|
|
10
|
+
import { addVariable, findDataType, getRandomFuncForType } from "./helpers.js";
|
|
11
|
+
import { typeAndDefaultValue } from "./type_defaults.js";
|
|
11
12
|
|
|
12
|
-
export function addSimulationVariables(namespace: Namespace, scalarFolder: UAObject): void {
|
|
13
|
+
export function addSimulationVariables(namespace: Namespace, scalarFolder: UAObject, custom?: CustomExtensionObject): void {
|
|
13
14
|
let values_to_change: { dataType: DataType; randomFunc: () => unknown; variable: UAVariable }[] = [];
|
|
14
15
|
|
|
15
16
|
function add_simulation_variable(
|
|
@@ -20,7 +21,7 @@ export function addSimulationVariables(namespace: Namespace, scalarFolder: UAObj
|
|
|
20
21
|
): UAVariable {
|
|
21
22
|
realTypeName = realTypeName || dataTypeName;
|
|
22
23
|
const dataType = findDataType(realTypeName);
|
|
23
|
-
const randomFunc = getRandomFuncForType(dataType);
|
|
24
|
+
const randomFunc = getRandomFuncForType(dataType, custom);
|
|
24
25
|
|
|
25
26
|
// c8 ignore next
|
|
26
27
|
if (typeof randomFunc !== "function") {
|
|
@@ -41,9 +42,8 @@ export function addSimulationVariables(namespace: Namespace, scalarFolder: UAObj
|
|
|
41
42
|
|
|
42
43
|
for (const e of typeAndDefaultValue) {
|
|
43
44
|
const dataType = e.type;
|
|
44
|
-
const defaultValue = typeof e.defaultValue === "function" ? e.defaultValue() : e.defaultValue;
|
|
45
45
|
const realType = e.realType || dataType;
|
|
46
|
-
add_simulation_variable(simulation, dataType,
|
|
46
|
+
add_simulation_variable(simulation, dataType, initialValueFor(e, custom), realType);
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
// Management nodes
|
|
@@ -7,12 +7,22 @@ import type { Namespace, UAObject, UAVariable } from "node-opcua-address-space";
|
|
|
7
7
|
import { make_errorLog } from "node-opcua-debug";
|
|
8
8
|
import { DataType, Variant } from "node-opcua-variant";
|
|
9
9
|
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
10
|
+
import { type CustomExtensionObject, initialValueFor } from "./custom_extension_object.js";
|
|
11
|
+
import { addArrayVariable, addMultiDimensionalArrayVariable, addScalarVariable } from "./helpers.js";
|
|
12
|
+
import { typeAndDefaultValue } from "./type_defaults.js";
|
|
12
13
|
|
|
13
|
-
const errorLog = make_errorLog(
|
|
14
|
+
const errorLog = make_errorLog("static_variables");
|
|
14
15
|
|
|
15
|
-
|
|
16
|
+
// The one place this module learns where it sits on disk. `import.meta.dirname`
|
|
17
|
+
// cannot be used while this package emits CommonJS (TS1470), so the ESM migration
|
|
18
|
+
// has this single line to change rather than several scattered uses.
|
|
19
|
+
const here = __dirname;
|
|
20
|
+
|
|
21
|
+
export async function addStaticVariables(
|
|
22
|
+
namespace: Namespace,
|
|
23
|
+
scalarFolder: UAObject,
|
|
24
|
+
custom?: CustomExtensionObject
|
|
25
|
+
): Promise<void> {
|
|
16
26
|
const staticScalarFolder = namespace.addObject({
|
|
17
27
|
organizedBy: scalarFolder,
|
|
18
28
|
browseName: "Scalars",
|
|
@@ -24,13 +34,16 @@ export async function addStaticVariables(namespace: Namespace, scalarFolder: UAO
|
|
|
24
34
|
for (const e of typeAndDefaultValue) {
|
|
25
35
|
const dataType = e.type;
|
|
26
36
|
const realType = e.realType || dataType;
|
|
27
|
-
|
|
28
|
-
addScalarVariable(namespace, staticScalarFolder, dataType, realType, defaultValue, "");
|
|
37
|
+
addScalarVariable(namespace, staticScalarFolder, dataType, realType, initialValueFor(e, custom), "");
|
|
29
38
|
}
|
|
30
39
|
|
|
40
|
+
// The two Description properties View Minimum Continuation Point 01 012 needs
|
|
41
|
+
// now live on the node that actually serves Static/All Profiles/Scalar/Bool -
|
|
42
|
+
// see addBooleanScalarAndArray() in ctt_folder.ts.
|
|
43
|
+
|
|
31
44
|
// Load images
|
|
32
45
|
async function setImage(imageType: string, filename: string): Promise<void> {
|
|
33
|
-
const fullPath = path.join(
|
|
46
|
+
const fullPath = path.join(here, "../../data", filename);
|
|
34
47
|
const imageNode = namespace.findNode(`s=Static_Scalar_Image${imageType}`) as UAVariable;
|
|
35
48
|
try {
|
|
36
49
|
const data = await fs.promises.readFile(fullPath);
|
|
@@ -55,7 +68,7 @@ export async function addStaticVariables(namespace: Namespace, scalarFolder: UAO
|
|
|
55
68
|
});
|
|
56
69
|
for (const e of typeAndDefaultValue) {
|
|
57
70
|
const realType = e.realType || e.type;
|
|
58
|
-
addArrayVariable(namespace, staticArraysFolders, e.type, e
|
|
71
|
+
addArrayVariable(namespace, staticArraysFolders, e.type, initialValueFor(e, custom), realType, 10, "");
|
|
59
72
|
}
|
|
60
73
|
|
|
61
74
|
// Multi-dimensional array variables
|
|
@@ -68,6 +81,15 @@ export async function addStaticVariables(namespace: Namespace, scalarFolder: UAO
|
|
|
68
81
|
});
|
|
69
82
|
for (const e of typeAndDefaultValue) {
|
|
70
83
|
const realType = e.realType || e.type;
|
|
71
|
-
addMultiDimensionalArrayVariable(
|
|
84
|
+
addMultiDimensionalArrayVariable(
|
|
85
|
+
namespace,
|
|
86
|
+
staticMultiDimensionalArrays,
|
|
87
|
+
e.type,
|
|
88
|
+
initialValueFor(e, custom),
|
|
89
|
+
realType,
|
|
90
|
+
2,
|
|
91
|
+
3,
|
|
92
|
+
""
|
|
93
|
+
);
|
|
72
94
|
}
|
|
73
95
|
}
|
|
@@ -4,8 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
import * as ec from "node-opcua-basic-types";
|
|
6
6
|
import { emptyGuid } from "node-opcua-basic-types";
|
|
7
|
-
import { LocalizedText, QualifiedName } from "node-opcua-data-model";
|
|
7
|
+
import { DiagnosticInfo, LocalizedText, QualifiedName } from "node-opcua-data-model";
|
|
8
|
+
import { DataValue } from "node-opcua-data-value";
|
|
8
9
|
import { coerceNodeId } from "node-opcua-nodeid";
|
|
10
|
+
import { DataType, Variant } from "node-opcua-variant";
|
|
9
11
|
|
|
10
12
|
export const typeAndDefaultValue = [
|
|
11
13
|
{ type: "Boolean", defaultValue: false },
|
|
@@ -57,5 +59,32 @@ export const typeAndDefaultValue = [
|
|
|
57
59
|
{ type: "ImageBMP", realType: "ByteString", defaultValue: null },
|
|
58
60
|
{ type: "ImageGIF", realType: "ByteString", defaultValue: null },
|
|
59
61
|
{ type: "ImageJPG", realType: "ByteString", defaultValue: null },
|
|
60
|
-
{ type: "ImagePNG", realType: "ByteString", defaultValue: null }
|
|
62
|
+
{ type: "ImagePNG", realType: "ByteString", defaultValue: null },
|
|
63
|
+
// The last four built-in types. `type` is the browse name *and* the DataType
|
|
64
|
+
// attribute, so it has to be a DataType the address space can resolve, while
|
|
65
|
+
// `realType` names the built-in encoding of the value. Two of them differ:
|
|
66
|
+
// the Variant DataType node is BaseDataType (i=24) and the ExtensionObject
|
|
67
|
+
// one is Structure (i=22) - "Variant" and "ExtensionObject" are encodings,
|
|
68
|
+
// not browse names, and addVariable() rejects them as DataTypes.
|
|
69
|
+
{
|
|
70
|
+
type: "BaseDataType",
|
|
71
|
+
realType: "Variant",
|
|
72
|
+
defaultValue() {
|
|
73
|
+
return new Variant({ dataType: DataType.Double, value: 0.0 });
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
// a null ExtensionObject: TypeId 0, no body - what an unassigned Structure is
|
|
77
|
+
{ type: "Structure", realType: "ExtensionObject", defaultValue: null },
|
|
78
|
+
{
|
|
79
|
+
type: "DataValue",
|
|
80
|
+
defaultValue() {
|
|
81
|
+
return new DataValue({ value: new Variant({ dataType: DataType.Double, value: 0.0 }) });
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
type: "DiagnosticInfo",
|
|
86
|
+
defaultValue() {
|
|
87
|
+
return new DiagnosticInfo({});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
61
90
|
];
|
package/src/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./address_space_for_conformance_testing";
|
|
1
|
+
export * from "./address_space_for_conformance_testing.js";
|