node-opcua-modeler 2.51.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/.mocharc.js +13 -0
- package/LICENSE +20 -0
- package/MyModelIds.csv +151 -0
- package/dist/addExtensionObjectDataType.d.ts +24 -0
- package/dist/addExtensionObjectDataType.js +198 -0
- package/dist/addExtensionObjectDataType.js.map +1 -0
- package/dist/build_model_inner.d.ts +17 -0
- package/dist/build_model_inner.js +41 -0
- package/dist/build_model_inner.js.map +1 -0
- package/dist/displayNodeElement.d.ts +5 -0
- package/dist/displayNodeElement.js +157 -0
- package/dist/displayNodeElement.js.map +1 -0
- package/dist/generate_markdown_doc.d.ts +6 -0
- package/dist/generate_markdown_doc.js +148 -0
- package/dist/generate_markdown_doc.js.map +1 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +48 -0
- package/dist/index.js.map +1 -0
- package/dist/promoteToMandatory.d.ts +8 -0
- package/dist/promoteToMandatory.js +98 -0
- package/dist/promoteToMandatory.js.map +1 -0
- package/dist/setNamespaceMetaData.d.ts +1 -0
- package/dist/setNamespaceMetaData.js +6 -0
- package/dist/setNamespaceMetaData.js.map +1 -0
- package/dist/symbol.d.ts +1 -0
- package/dist/symbol.js +3 -0
- package/dist/symbol.js.map +1 -0
- package/dist/tableHelper.d.ts +9 -0
- package/dist/tableHelper.js +61 -0
- package/dist/tableHelper.js.map +1 -0
- package/dist/to_cvs.d.ts +2 -0
- package/dist/to_cvs.js +12 -0
- package/dist/to_cvs.js.map +1 -0
- package/dist/types.d.ts +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/distNodeJS/build_documentation_to_file.d.ts +2 -0
- package/distNodeJS/build_documentation_to_file.js +27 -0
- package/distNodeJS/build_documentation_to_file.js.map +1 -0
- package/distNodeJS/build_model.d.ts +7 -0
- package/distNodeJS/build_model.js +22 -0
- package/distNodeJS/build_model.js.map +1 -0
- package/distNodeJS/index.d.ts +5 -0
- package/distNodeJS/index.js +20 -0
- package/distNodeJS/index.js.map +1 -0
- package/distNodeJS/symbol_cvs.d.ts +3 -0
- package/distNodeJS/symbol_cvs.js +64 -0
- package/distNodeJS/symbol_cvs.js.map +1 -0
- package/examples/make_model.ts +152 -0
- package/nodeJS.d.ts +1 -0
- package/nodeJS.js +1 -0
- package/package.json +53 -0
- package/readme.md +43 -0
- package/source/addExtensionObjectDataType.ts +241 -0
- package/source/build_model_inner.ts +45 -0
- package/source/displayNodeElement.ts +178 -0
- package/source/generate_markdown_doc.ts +156 -0
- package/source/index.ts +31 -0
- package/source/promoteToMandatory.ts +137 -0
- package/source/setNamespaceMetaData.ts +1 -0
- package/source/symbol.ts +1 -0
- package/source/tableHelper.ts +64 -0
- package/source/to_cvs.ts +9 -0
- package/source/types.ts +1 -0
- package/source_nodejs/build_documentation_to_file.ts +13 -0
- package/source_nodejs/build_model.ts +12 -0
- package/source_nodejs/index.ts +5 -0
- package/source_nodejs/symbol_cvs.ts +52 -0
- package/tsconfig_common.json +55 -0
- package/tsconfig_nodejs.json +25 -0
package/.mocharc.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
recursive: true,
|
|
3
|
+
diff: true,
|
|
4
|
+
extension: [".ts", ".js"],
|
|
5
|
+
spec: ["test/*.ts"],
|
|
6
|
+
bail: true,
|
|
7
|
+
timeout: 20000,
|
|
8
|
+
require: [
|
|
9
|
+
"../../node_modules/should",
|
|
10
|
+
"../../node_modules/ts-node/register",
|
|
11
|
+
"../../node_modules/source-map-support/register"
|
|
12
|
+
]
|
|
13
|
+
};
|
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2014-2021 Etienne Rossignon
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
7
|
+
the Software without restriction, including without limitation the rights to
|
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
10
|
+
subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/MyModelIds.csv
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
BoilerType,1008,ObjectType
|
|
2
|
+
BoilerType_DeviceHealth,1009,Variable
|
|
3
|
+
BoilerType_ParameterSet,1010,Object
|
|
4
|
+
BoilerType_ParameterSet_ParameterIdentifier>,1011,Variable
|
|
5
|
+
BoilerType_ParameterSet_HumiditySetpoint,1012,Variable
|
|
6
|
+
BoilerType_ParameterSet_TemperatureSetpoint,1013,Variable
|
|
7
|
+
BoilerType_ParameterSet_ParameterIdentifier,1014,Variable
|
|
8
|
+
NewBoilerType,1015,ObjectType
|
|
9
|
+
NewBoilerType_DeviceHealth,1016,Variable
|
|
10
|
+
NewBoilerType_ParameterSet,1017,Object
|
|
11
|
+
NewBoilerType_ParameterSet_ParameterIdentifier,1018,Variable
|
|
12
|
+
NewBoilerType_ParameterSet_HumiditySetpoint,1019,Variable
|
|
13
|
+
NewBoilerType_ParameterSet_TemperatureSetpoint,1020,Variable
|
|
14
|
+
FlowTo,1021,ReferenceType
|
|
15
|
+
HotFlowTo,1022,ReferenceType
|
|
16
|
+
SignalTo,1023,ReferenceType
|
|
17
|
+
BoilerHaltedEventType,1024,ObjectType
|
|
18
|
+
CustomControllerType,1025,ObjectType
|
|
19
|
+
CustomControllerType_Input1,1026,Variable
|
|
20
|
+
CustomControllerType_Input2,1027,Variable
|
|
21
|
+
CustomControllerType_Input3,1028,Variable
|
|
22
|
+
CustomControllerType_ControlOut,1029,Variable
|
|
23
|
+
CustomControllerType_Description,1030,Variable
|
|
24
|
+
GenericSensorType,1031,ObjectType
|
|
25
|
+
GenericSensorType_Output,1032,Variable
|
|
26
|
+
GenericSensorType_Output_EURange,1033,Variable
|
|
27
|
+
GenericControllerType,1034,ObjectType
|
|
28
|
+
GenericControllerType_ControlOut,1035,Variable
|
|
29
|
+
GenericControllerType_Measurement,1036,Variable
|
|
30
|
+
GenericControllerType_SetPoint,1037,Variable
|
|
31
|
+
FlowControllerType,1038,ObjectType
|
|
32
|
+
LevelControllerType,1039,ObjectType
|
|
33
|
+
FlowTransmitterType,1040,ObjectType
|
|
34
|
+
LevelIndicatorType,1041,ObjectType
|
|
35
|
+
GenericActuatorType,1042,ObjectType
|
|
36
|
+
GenericActuatorType_Input,1043,Variable
|
|
37
|
+
GenericActuatorType_Input_EURange,1044,Variable
|
|
38
|
+
ValveType,1045,ObjectType
|
|
39
|
+
BoilerInputPipeType,1046,ObjectType
|
|
40
|
+
BoilerInputPipeType_FTX001,1047,Object
|
|
41
|
+
BoilerInputPipeType_FTX001_Output,1048,Variable
|
|
42
|
+
BoilerInputPipeType_FTX001_Output_EURange,1049,Variable
|
|
43
|
+
BoilerInputPipeType_ValveX001,1050,Object
|
|
44
|
+
BoilerInputPipeType_ValveX001_Input,1051,Variable
|
|
45
|
+
BoilerInputPipeType_ValveX001_Input_EURange,1052,Variable
|
|
46
|
+
BoilerOutputPipeType,1053,ObjectType
|
|
47
|
+
BoilerOutputPipeType_FTX002,1054,Object
|
|
48
|
+
BoilerOutputPipeType_FTX002_Output,1055,Variable
|
|
49
|
+
BoilerOutputPipeType_FTX002_Output_EURange,1056,Variable
|
|
50
|
+
BoilerDrumType,1057,ObjectType
|
|
51
|
+
BoilerDrumType_LIX001,1058,Object
|
|
52
|
+
BoilerDrumType_LIX001_Output,1059,Variable
|
|
53
|
+
BoilerDrumType_LIX001_Output_EURange,1060,Variable
|
|
54
|
+
BoilerStateMachineType,1061,ObjectType
|
|
55
|
+
BoilerStateMachineType_Halt,1062,Method
|
|
56
|
+
BoilerStateMachineType_Reset,1063,Method
|
|
57
|
+
BoilerStateMachineType_Start,1064,Method
|
|
58
|
+
BoilerStateMachineType_Suspend,1065,Method
|
|
59
|
+
BoilerStateMachineType_Resume,1066,Method
|
|
60
|
+
BoilerType_CCX001,1067,Object
|
|
61
|
+
BoilerType_CCX001_Input1,1068,Variable
|
|
62
|
+
BoilerType_CCX001_Input2,1069,Variable
|
|
63
|
+
BoilerType_CCX001_Input3,1070,Variable
|
|
64
|
+
BoilerType_CCX001_ControlOut,1071,Variable
|
|
65
|
+
BoilerType_CCX001_Description,1072,Variable
|
|
66
|
+
BoilerType_FCX001,1073,Object
|
|
67
|
+
BoilerType_FCX001_ControlOut,1074,Variable
|
|
68
|
+
BoilerType_FCX001_Measurement,1075,Variable
|
|
69
|
+
BoilerType_FCX001_SetPoint,1076,Variable
|
|
70
|
+
BoilerType_LCX001,1077,Object
|
|
71
|
+
BoilerType_LCX001_ControlOut,1078,Variable
|
|
72
|
+
BoilerType_LCX001_Measurement,1079,Variable
|
|
73
|
+
BoilerType_LCX001_SetPoint,1080,Variable
|
|
74
|
+
BoilerType_PipeX001,1081,Object
|
|
75
|
+
BoilerType_PipeX001_FTX001,1082,Object
|
|
76
|
+
BoilerType_PipeX001_FTX001_Output,1083,Variable
|
|
77
|
+
BoilerType_PipeX001_FTX001_Output_EURange,1084,Variable
|
|
78
|
+
BoilerType_PipeX001_ValveX001,1085,Object
|
|
79
|
+
BoilerType_PipeX001_ValveX001_Input,1086,Variable
|
|
80
|
+
BoilerType_PipeX001_ValveX001_Input_EURange,1087,Variable
|
|
81
|
+
BoilerType_DrumX001,1088,Object
|
|
82
|
+
BoilerType_DrumX001_LIX001,1089,Object
|
|
83
|
+
BoilerType_DrumX001_LIX001_Output,1090,Variable
|
|
84
|
+
BoilerType_DrumX001_LIX001_Output_EURange,1091,Variable
|
|
85
|
+
BoilerType_PipeX002,1092,Object
|
|
86
|
+
BoilerType_PipeX002_FTX002,1093,Object
|
|
87
|
+
BoilerType_PipeX002_FTX002_Output,1094,Variable
|
|
88
|
+
BoilerType_PipeX002_FTX002_Output_EURange,1095,Variable
|
|
89
|
+
BoilerType_Simulation,1096,Object
|
|
90
|
+
BoilerType_Simulation_Halt,1097,Method
|
|
91
|
+
BoilerType_Simulation_Reset,1098,Method
|
|
92
|
+
BoilerType_Simulation_Start,1099,Method
|
|
93
|
+
BoilerType_Simulation_Suspend,1100,Method
|
|
94
|
+
BoilerType_Simulation_Resume,1101,Method
|
|
95
|
+
BoilerType_Simulation_CurrentState,1102,Variable
|
|
96
|
+
BoilerType_Simulation_CurrentState_Id,1103,Variable
|
|
97
|
+
BoilerType_Simulation_CurrentState_Number,1104,Variable
|
|
98
|
+
BoilerType_Simulation_LastTransition,1105,Variable
|
|
99
|
+
BoilerType_Simulation_LastTransition_Id,1106,Variable
|
|
100
|
+
BoilerType_Simulation_LastTransition_Number,1107,Variable
|
|
101
|
+
BoilerType_Simulation_LastTransition_TransitionTime,1108,Variable
|
|
102
|
+
BoilerType_Simulation_Deletable,1109,Variable
|
|
103
|
+
BoilerType_Simulation_AutoDelete,1110,Variable
|
|
104
|
+
BoilerType_Simulation_RecycleCount,1111,Variable
|
|
105
|
+
BoilerDeviceType,1112,ObjectType
|
|
106
|
+
BoilerDeviceType_DeviceHealth,1113,Variable
|
|
107
|
+
BoilerDeviceType_ParameterSet,1114,Object
|
|
108
|
+
BoilerDeviceType_ParameterSet_ParameterIdentifier,1115,Variable
|
|
109
|
+
BoilerDeviceType_ParameterSet_HumiditySetpoint,1116,Variable
|
|
110
|
+
BoilerDeviceType_ParameterSet_TemperatureSetpoint,1117,Variable
|
|
111
|
+
BoilerInputPipeType_FlowTransmitter,1118,Object
|
|
112
|
+
BoilerInputPipeType_FlowTransmitter_Output,1119,Variable
|
|
113
|
+
BoilerInputPipeType_FlowTransmitter_Output_EURange,1120,Variable
|
|
114
|
+
BoilerInputPipeType_Valve,1121,Object
|
|
115
|
+
BoilerInputPipeType_Valve_Input,1122,Variable
|
|
116
|
+
BoilerInputPipeType_Valve_Input_EURange,1123,Variable
|
|
117
|
+
BoilerOutputPipeType_FlowTransmitter,1124,Object
|
|
118
|
+
BoilerOutputPipeType_FlowTransmitter_Output,1125,Variable
|
|
119
|
+
BoilerOutputPipeType_FlowTransmitter_Output_EURange,1126,Variable
|
|
120
|
+
BoilerDrumType_LevelIndicator,1127,Object
|
|
121
|
+
BoilerDrumType_LevelIndicator_Output,1128,Variable
|
|
122
|
+
BoilerDrumType_LevelIndicator_Output_EURange,1129,Variable
|
|
123
|
+
BoilerType_CustomController,1130,Object
|
|
124
|
+
BoilerType_CustomController_Input1,1131,Variable
|
|
125
|
+
BoilerType_CustomController_Input2,1132,Variable
|
|
126
|
+
BoilerType_CustomController_Input3,1133,Variable
|
|
127
|
+
BoilerType_CustomController_ControlOut,1134,Variable
|
|
128
|
+
BoilerType_CustomController_Description,1135,Variable
|
|
129
|
+
BoilerType_FlowController,1136,Object
|
|
130
|
+
BoilerType_FlowController_ControlOut,1137,Variable
|
|
131
|
+
BoilerType_FlowController_Measurement,1138,Variable
|
|
132
|
+
BoilerType_FlowController_SetPoint,1139,Variable
|
|
133
|
+
BoilerType_LevelController,1140,Object
|
|
134
|
+
BoilerType_LevelController_ControlOut,1141,Variable
|
|
135
|
+
BoilerType_LevelController_Measurement,1142,Variable
|
|
136
|
+
BoilerType_LevelController_SetPoint,1143,Variable
|
|
137
|
+
BoilerType_InputPipe,1144,Object
|
|
138
|
+
BoilerType_InputPipe_FlowTransmitter,1145,Object
|
|
139
|
+
BoilerType_InputPipe_FlowTransmitter_Output,1146,Variable
|
|
140
|
+
BoilerType_InputPipe_FlowTransmitter_Output_EURange,1147,Variable
|
|
141
|
+
BoilerType_InputPipe_Valve,1148,Object
|
|
142
|
+
BoilerType_InputPipe_Valve_Input,1149,Variable
|
|
143
|
+
BoilerType_InputPipe_Valve_Input_EURange,1150,Variable
|
|
144
|
+
BoilerType_BoilerDrum,1151,Object
|
|
145
|
+
BoilerType_BoilerDrum_LevelIndicator,1152,Object
|
|
146
|
+
BoilerType_BoilerDrum_LevelIndicator_Output,1153,Variable
|
|
147
|
+
BoilerType_BoilerDrum_LevelIndicator_Output_EURange,1154,Variable
|
|
148
|
+
BoilerType_OutputPipe,1155,Object
|
|
149
|
+
BoilerType_OutputPipe_FlowTransmitter,1156,Object
|
|
150
|
+
BoilerType_OutputPipe_FlowTransmitter_Output,1157,Variable
|
|
151
|
+
BoilerType_OutputPipe_FlowTransmitter_Output_EURange,1158,Variable
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Namespace, UADataType, UAObject, UAVariable, UAVariableType, UADataTypeDictionary } from "node-opcua-address-space";
|
|
3
|
+
import { LocalizedTextLike, QualifiedNameLike } from "node-opcua-data-model";
|
|
4
|
+
import { NodeId } from "node-opcua-nodeid";
|
|
5
|
+
import { StructureDefinitionOptions } from "node-opcua-types";
|
|
6
|
+
/**
|
|
7
|
+
* create the deprecated DataTypeDictionary node that was
|
|
8
|
+
* used up to version 1.03
|
|
9
|
+
*/
|
|
10
|
+
export declare function getOrCreateDataTypeSystem(namespace: Namespace): UAObject;
|
|
11
|
+
export declare function getDataTypeDictionary(namespace: Namespace): UADataTypeDictionary<Buffer>;
|
|
12
|
+
export declare function addDataTypeDescription(namespace: Namespace, dataType: UADataType): UAVariable;
|
|
13
|
+
export interface ExtensionObjectDefinition {
|
|
14
|
+
browseName: QualifiedNameLike;
|
|
15
|
+
description: LocalizedTextLike;
|
|
16
|
+
isAbstract: boolean;
|
|
17
|
+
structureDefinition: StructureDefinitionOptions;
|
|
18
|
+
binaryEncoding?: NodeId;
|
|
19
|
+
xmlEncoding?: NodeId;
|
|
20
|
+
jsonEncoding?: NodeId;
|
|
21
|
+
subtypeOf?: UADataType;
|
|
22
|
+
}
|
|
23
|
+
export declare function addExtensionObjectDataType(namespace: Namespace, options: ExtensionObjectDefinition): Promise<UADataType>;
|
|
24
|
+
export declare function addVariableTypeForDataType(namespace: Namespace, dataType: UADataType): UAVariableType;
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.addVariableTypeForDataType = exports.addExtensionObjectDataType = exports.addDataTypeDescription = exports.getDataTypeDictionary = exports.getOrCreateDataTypeSystem = void 0;
|
|
13
|
+
const node_opcua_address_space_1 = require("node-opcua-address-space");
|
|
14
|
+
const node_opcua_assert_1 = require("node-opcua-assert");
|
|
15
|
+
const node_opcua_client_dynamic_extension_object_1 = require("node-opcua-client-dynamic-extension-object");
|
|
16
|
+
const node_opcua_data_model_1 = require("node-opcua-data-model");
|
|
17
|
+
const node_opcua_nodeid_1 = require("node-opcua-nodeid");
|
|
18
|
+
const node_opcua_schemas_1 = require("node-opcua-schemas");
|
|
19
|
+
const node_opcua_types_1 = require("node-opcua-types");
|
|
20
|
+
const node_opcua_variant_1 = require("node-opcua-variant");
|
|
21
|
+
/**
|
|
22
|
+
* create the deprecated DataTypeDictionary node that was
|
|
23
|
+
* used up to version 1.03
|
|
24
|
+
*/
|
|
25
|
+
function getOrCreateDataTypeSystem(namespace) {
|
|
26
|
+
const addressSpace = namespace.addressSpace;
|
|
27
|
+
const opcBinaryTypeSystem = addressSpace.findNode("OPCBinarySchema_TypeSystem");
|
|
28
|
+
/* istanbul ignore next */
|
|
29
|
+
if (!opcBinaryTypeSystem) {
|
|
30
|
+
throw new Error("Cannot find OPCBinarySchema_TypeSystem");
|
|
31
|
+
}
|
|
32
|
+
(0, node_opcua_assert_1.default)(opcBinaryTypeSystem.nodeId.toString() === "ns=0;i=93");
|
|
33
|
+
(0, node_opcua_assert_1.default)(opcBinaryTypeSystem.browseName.toString() === "OPC Binary");
|
|
34
|
+
return opcBinaryTypeSystem;
|
|
35
|
+
}
|
|
36
|
+
exports.getOrCreateDataTypeSystem = getOrCreateDataTypeSystem;
|
|
37
|
+
function getDataTypeDictionary(namespace) {
|
|
38
|
+
const addressSpace = namespace.addressSpace;
|
|
39
|
+
const opcBinaryTypeSystem = getOrCreateDataTypeSystem(namespace);
|
|
40
|
+
(0, node_opcua_assert_1.default)(opcBinaryTypeSystem.nodeId.toString() === "ns=0;i=93");
|
|
41
|
+
const name = namespace.namespaceUri.replace(/.*:/, "");
|
|
42
|
+
const node = opcBinaryTypeSystem.getComponentByName(name);
|
|
43
|
+
if (node) {
|
|
44
|
+
(0, node_opcua_assert_1.default)(node.nodeClass === node_opcua_data_model_1.NodeClass.Variable);
|
|
45
|
+
// already exits ....
|
|
46
|
+
return node;
|
|
47
|
+
}
|
|
48
|
+
const dataTypeDictionaryType = addressSpace.findVariableType("DataTypeDictionaryType");
|
|
49
|
+
/* istanbul ignore next */
|
|
50
|
+
if (!dataTypeDictionaryType) {
|
|
51
|
+
throw new Error("Cannot find DataTypeDictionaryType");
|
|
52
|
+
}
|
|
53
|
+
const dataTypeDictionary = dataTypeDictionaryType.instantiate({
|
|
54
|
+
browseName: name,
|
|
55
|
+
description: `Collects the data type descriptions of ${namespace.namespaceUri}`,
|
|
56
|
+
componentOf: opcBinaryTypeSystem,
|
|
57
|
+
optionals: ["Deprecated", "DataTypeVersion", "NamespaceUri"]
|
|
58
|
+
});
|
|
59
|
+
dataTypeDictionary.bindVariable({
|
|
60
|
+
get: () => {
|
|
61
|
+
const bsd = (0, node_opcua_address_space_1.dumpToBSD)(namespace);
|
|
62
|
+
return new node_opcua_variant_1.Variant({
|
|
63
|
+
dataType: node_opcua_variant_1.DataType.ByteString,
|
|
64
|
+
value: Buffer.from(bsd, "utf-8")
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
const namespaceUriProp = dataTypeDictionary.getPropertyByName("NamespaceUri");
|
|
69
|
+
if (namespaceUriProp) {
|
|
70
|
+
namespaceUriProp.setValueFromSource({ dataType: node_opcua_variant_1.DataType.String, value: namespace.namespaceUri });
|
|
71
|
+
}
|
|
72
|
+
const deprecatedProp = dataTypeDictionary.getPropertyByName("Deprecated");
|
|
73
|
+
if (deprecatedProp) {
|
|
74
|
+
deprecatedProp.setValueFromSource({ dataType: node_opcua_variant_1.DataType.Boolean, value: true });
|
|
75
|
+
}
|
|
76
|
+
return dataTypeDictionary;
|
|
77
|
+
}
|
|
78
|
+
exports.getDataTypeDictionary = getDataTypeDictionary;
|
|
79
|
+
function addDataTypeDescription(namespace, dataType) {
|
|
80
|
+
const addressSpace = namespace.addressSpace;
|
|
81
|
+
const dataTypeDictionary = getDataTypeDictionary(namespace);
|
|
82
|
+
const dataTypeDescriptionType = addressSpace.findVariableType("DataTypeDescriptionType");
|
|
83
|
+
if (!dataTypeDescriptionType) {
|
|
84
|
+
throw new Error("Cannot find DataTypeDescriptionType");
|
|
85
|
+
}
|
|
86
|
+
const dataTypeDescription = dataTypeDescriptionType.instantiate({
|
|
87
|
+
browseName: dataType.browseName.name,
|
|
88
|
+
componentOf: dataTypeDictionary
|
|
89
|
+
});
|
|
90
|
+
dataTypeDescription.setValueFromSource({
|
|
91
|
+
dataType: node_opcua_variant_1.DataType.String,
|
|
92
|
+
value: dataType.browseName.name
|
|
93
|
+
});
|
|
94
|
+
return dataTypeDescription;
|
|
95
|
+
}
|
|
96
|
+
exports.addDataTypeDescription = addDataTypeDescription;
|
|
97
|
+
function addExtensionObjectDataType(namespace, options) {
|
|
98
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
99
|
+
const addressSpace = namespace.addressSpace;
|
|
100
|
+
// encodings
|
|
101
|
+
const dataTypeEncodingType = addressSpace.findObjectType("DataTypeEncodingType");
|
|
102
|
+
/* istanbul ignore next */
|
|
103
|
+
if (!dataTypeEncodingType) {
|
|
104
|
+
throw new Error("Cannot find DataTypeEncodingType");
|
|
105
|
+
}
|
|
106
|
+
/* istanbul ignore next */
|
|
107
|
+
if (!options.browseName.toString().match(/DataType$/)) {
|
|
108
|
+
throw new Error("DataType name must end up with DataType ! " + options.browseName.toString());
|
|
109
|
+
}
|
|
110
|
+
const baseSuperType = "Structure";
|
|
111
|
+
const subtypeOf = addressSpace.findDataType(options.subtypeOf ? options.subtypeOf : baseSuperType);
|
|
112
|
+
const structureDefinition = options.structureDefinition;
|
|
113
|
+
structureDefinition.baseDataType = structureDefinition.baseDataType
|
|
114
|
+
? (0, node_opcua_nodeid_1.resolveNodeId)(structureDefinition.baseDataType)
|
|
115
|
+
: (0, node_opcua_nodeid_1.resolveNodeId)("Structure");
|
|
116
|
+
const dataType = namespace.createDataType({
|
|
117
|
+
browseName: options.browseName,
|
|
118
|
+
description: options.description,
|
|
119
|
+
isAbstract: options.isAbstract,
|
|
120
|
+
subtypeOf
|
|
121
|
+
});
|
|
122
|
+
const defaultBinary = dataTypeEncodingType.instantiate({
|
|
123
|
+
browseName: (0, node_opcua_data_model_1.coerceQualifiedName)("0:Default Binary"),
|
|
124
|
+
encodingOf: dataType
|
|
125
|
+
// nodeId: defaultBinaryEncodingNode,
|
|
126
|
+
});
|
|
127
|
+
(0, node_opcua_assert_1.default)(defaultBinary.browseName.toString() === "Default Binary");
|
|
128
|
+
dataType.$definition = new node_opcua_types_1.StructureDefinition(structureDefinition);
|
|
129
|
+
(0, node_opcua_assert_1.default)(!node_opcua_nodeid_1.NodeId.sameNodeId(dataType.$definition.baseDataType, node_opcua_nodeid_1.NodeId.nullNodeId));
|
|
130
|
+
const dataTypeDescription = addDataTypeDescription(namespace, dataType);
|
|
131
|
+
defaultBinary.addReference({
|
|
132
|
+
isForward: true,
|
|
133
|
+
nodeId: dataTypeDescription,
|
|
134
|
+
referenceType: "HasDescription"
|
|
135
|
+
});
|
|
136
|
+
const v = dataType.getEncodingNode("Default Binary");
|
|
137
|
+
(0, node_opcua_assert_1.default)((v === null || v === void 0 ? void 0 : v.browseName.toString()) === "Default Binary");
|
|
138
|
+
/// --------------- Create constructor
|
|
139
|
+
const dataTypeManager = addressSpace.$$extraDataTypeManager;
|
|
140
|
+
const dataTypeFactory = dataTypeManager.getDataTypeFactory(namespace.index);
|
|
141
|
+
const session = new node_opcua_address_space_1.PseudoSession(addressSpace);
|
|
142
|
+
const className = dataType.browseName.name;
|
|
143
|
+
const cache = {};
|
|
144
|
+
const schema = yield (0, node_opcua_client_dynamic_extension_object_1.convertDataTypeDefinitionToStructureTypeSchema)(session, dataType.nodeId, className, dataType.$definition, dataTypeFactory, cache);
|
|
145
|
+
const Constructor = (0, node_opcua_schemas_1.createDynamicObjectConstructor)(schema, dataTypeFactory);
|
|
146
|
+
return dataType;
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
exports.addExtensionObjectDataType = addExtensionObjectDataType;
|
|
150
|
+
function addVariableTypeForDataType(namespace, dataType) {
|
|
151
|
+
var _a;
|
|
152
|
+
const addressSpace = namespace.addressSpace;
|
|
153
|
+
// get Definition
|
|
154
|
+
const definition = dataType.$definition;
|
|
155
|
+
if (!definition || !(definition instanceof node_opcua_types_1.StructureDefinition)) {
|
|
156
|
+
throw new Error("dataType is not a structure");
|
|
157
|
+
}
|
|
158
|
+
const variableTypeName = (_a = dataType.browseName.name) === null || _a === void 0 ? void 0 : _a.replace("DataType", "Type");
|
|
159
|
+
const variableType = namespace.addVariableType({
|
|
160
|
+
browseName: variableTypeName,
|
|
161
|
+
dataType: dataType.nodeId
|
|
162
|
+
});
|
|
163
|
+
const structure = addressSpace.findDataType("Structure");
|
|
164
|
+
for (const field of definition.fields || []) {
|
|
165
|
+
let typeDefinition = "BaseVariableType";
|
|
166
|
+
const fType = addressSpace.findDataType(field.dataType);
|
|
167
|
+
/* istanbul ignore next */
|
|
168
|
+
if (!fType) {
|
|
169
|
+
throw new Error("Cannot find dataType" + field.dataType.toString());
|
|
170
|
+
}
|
|
171
|
+
if (fType.isSupertypeOf(structure)) {
|
|
172
|
+
const name = fType.browseName.name.replace("DataType", "Type");
|
|
173
|
+
typeDefinition = addressSpace.findVariableType(name, field.dataType.namespace);
|
|
174
|
+
const comp = typeDefinition.instantiate({
|
|
175
|
+
browseName: field.name,
|
|
176
|
+
componentOf: variableType,
|
|
177
|
+
dataType: field.dataType,
|
|
178
|
+
description: field.description,
|
|
179
|
+
modellingRule: "Mandatory",
|
|
180
|
+
valueRank: field.valueRank === undefined ? -1 : field.valueRank
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
const comp = namespace.addVariable({
|
|
185
|
+
browseName: field.name,
|
|
186
|
+
componentOf: variableType,
|
|
187
|
+
dataType: field.dataType,
|
|
188
|
+
description: field.description,
|
|
189
|
+
modellingRule: "Mandatory",
|
|
190
|
+
typeDefinition,
|
|
191
|
+
valueRank: field.valueRank === undefined ? -1 : field.valueRank
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return variableType;
|
|
196
|
+
}
|
|
197
|
+
exports.addVariableTypeForDataType = addVariableTypeForDataType;
|
|
198
|
+
//# sourceMappingURL=addExtensionObjectDataType.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addExtensionObjectDataType.js","sourceRoot":"","sources":["../source/addExtensionObjectDataType.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uEAYkC;AAClC,yDAAuC;AACvC,2GAAkI;AAClI,iEAA6G;AAE7G,yDAA0D;AAC1D,2DAAoE;AACpE,uDAAmF;AACnF,2DAAuD;AAEvD;;;GAGG;AACH,SAAgB,yBAAyB,CAAC,SAAoB;IAC1D,MAAM,YAAY,GAAG,SAAS,CAAC,YAAY,CAAC;IAE5C,MAAM,mBAAmB,GAAG,YAAY,CAAC,QAAQ,CAAC,4BAA4B,CAAa,CAAC;IAC5F,0BAA0B;IAC1B,IAAI,CAAC,mBAAmB,EAAE;QACtB,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;KAC7D;IACD,IAAA,2BAAM,EAAC,mBAAmB,CAAC,MAAM,CAAC,QAAQ,EAAE,KAAK,WAAW,CAAC,CAAC;IAC9D,IAAA,2BAAM,EAAC,mBAAmB,CAAC,UAAU,CAAC,QAAQ,EAAE,KAAK,YAAY,CAAC,CAAC;IAEnE,OAAO,mBAAmB,CAAC;AAC/B,CAAC;AAZD,8DAYC;AAED,SAAgB,qBAAqB,CAAC,SAAoB;IACtD,MAAM,YAAY,GAAG,SAAS,CAAC,YAAY,CAAC;IAE5C,MAAM,mBAAmB,GAAG,yBAAyB,CAAC,SAAS,CAAC,CAAC;IACjE,IAAA,2BAAM,EAAC,mBAAmB,CAAC,MAAM,CAAC,QAAQ,EAAE,KAAK,WAAW,CAAC,CAAC;IAE9D,MAAM,IAAI,GAAG,SAAS,CAAC,YAAY,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAEvD,MAAM,IAAI,GAAe,mBAAmB,CAAC,kBAA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H,MAAM,IAAI,GAAG,SAAS,CAAC,WAAW,CAAC;gBAC/B,UAAU,EAAE,KAAK,CAAC,IAAK;gBACvB,WAAW,EAAE,YAAY;gBACzB,QAAQ,EAAE,KAAK,CAAC,QAAQ;gBACxB,WAAW,EAAE,KAAK,CAAC,WAAW;gBAC9B,aAAa,EAAE,WAAW;gBAC1B,cAAc;gBACd,SAAS,EAAE,KAAK,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS;aAClE,CAAC,CAAC;SACN;KACJ;IACD,OAAO,YAAY,CAAC;AACxB,CAAC;AA/CD,gEA+CC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AddressSpace, XmlLoaderFunc } from "node-opcua-address-space";
|
|
2
|
+
import { Symbols } from "./symbol";
|
|
3
|
+
export interface BuildModelOptionsBase {
|
|
4
|
+
version: string;
|
|
5
|
+
namespaceUri: string;
|
|
6
|
+
xmlFiles: string[];
|
|
7
|
+
createModel: (addressSpace: AddressSpace) => Promise<void>;
|
|
8
|
+
presetSymbols?: Symbols;
|
|
9
|
+
}
|
|
10
|
+
export interface BuildModelOptions extends BuildModelOptionsBase {
|
|
11
|
+
xmlLoader: XmlLoaderFunc;
|
|
12
|
+
}
|
|
13
|
+
export declare function buildModelInner(data: BuildModelOptions): Promise<{
|
|
14
|
+
markdown: string;
|
|
15
|
+
xmlModel: string;
|
|
16
|
+
symbols: Symbols;
|
|
17
|
+
}>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.buildModelInner = void 0;
|
|
13
|
+
const node_opcua_address_space_1 = require("node-opcua-address-space");
|
|
14
|
+
const generate_markdown_doc_1 = require("./generate_markdown_doc");
|
|
15
|
+
function buildModelInner(data) {
|
|
16
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
try {
|
|
18
|
+
const addressSpace = node_opcua_address_space_1.AddressSpace.create();
|
|
19
|
+
// create own namespace (before loading other xml files)
|
|
20
|
+
const ns = addressSpace.registerNamespace(data.namespaceUri);
|
|
21
|
+
const nodeIdManager = ns._nodeIdManager;
|
|
22
|
+
if (data.presetSymbols) {
|
|
23
|
+
nodeIdManager.setSymbols(data.presetSymbols);
|
|
24
|
+
}
|
|
25
|
+
yield (0, node_opcua_address_space_1.generateAddressSpaceRaw)(addressSpace, data.xmlFiles, data.xmlLoader);
|
|
26
|
+
yield data.createModel(addressSpace);
|
|
27
|
+
const xmlModel = ns.toNodeset2XML();
|
|
28
|
+
const symbols = nodeIdManager.getSymbols();
|
|
29
|
+
const doc = yield (0, generate_markdown_doc_1.buildDocumentationToString)(ns);
|
|
30
|
+
addressSpace.dispose();
|
|
31
|
+
return { xmlModel, symbols, markdown: doc };
|
|
32
|
+
}
|
|
33
|
+
catch (err) {
|
|
34
|
+
// tslint:disable-next-line: no-console
|
|
35
|
+
console.log("Error", err);
|
|
36
|
+
throw err;
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
exports.buildModelInner = buildModelInner;
|
|
41
|
+
//# sourceMappingURL=build_model_inner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build_model_inner.js","sourceRoot":"","sources":["../source/build_model_inner.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uEAEuG;AACvG,mEAAqE;AAcrE,SAAsB,eAAe,CAAC,IAAuB;;QACzD,IAAI;YACA,MAAM,YAAY,GAAG,uCAAY,CAAC,MAAM,EAAE,CAAC;YAE3C,wDAAwD;YACxD,MAAM,EAAE,GAAG,YAAY,CAAC,iBAAiB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;YAE7D,MAAM,aAAa,GAAI,EAAU,CAAC,cAA+B,CAAC;YAClE,IAAI,IAAI,CAAC,aAAa,EAAE;gBACpB,aAAa,CAAC,UAAU,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;aAChD;YAED,MAAM,IAAA,kDAAuB,EAAC,YAAY,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;YAE3E,MAAM,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;YAErC,MAAM,QAAQ,GAAG,EAAE,CAAC,aAAa,EAAE,CAAC;YACpC,MAAM,OAAO,GAAG,aAAa,CAAC,UAAU,EAAE,CAAC;YAC3C,MAAM,GAAG,GAAG,MAAM,IAAA,kDAA0B,EAAC,EAAE,CAAC,CAAC;YACjD,YAAY,CAAC,OAAO,EAAE,CAAC;YAEvB,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC;SAC/C;QAAC,OAAO,GAAG,EAAE;YACV,uCAAuC;YACvC,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;YAC1B,MAAM,GAAG,CAAC;SACb;IACL,CAAC;CAAA;AA3BD,0CA2BC"}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.displayNodeElement = void 0;
|
|
4
|
+
const node_opcua_address_space_1 = require("node-opcua-address-space");
|
|
5
|
+
const node_opcua_data_model_1 = require("node-opcua-data-model");
|
|
6
|
+
const node_opcua_nodeid_1 = require("node-opcua-nodeid");
|
|
7
|
+
const node_opcua_variant_1 = require("node-opcua-variant");
|
|
8
|
+
const tableHelper_1 = require("./tableHelper");
|
|
9
|
+
const a = "ⓂⓄⓋⓥⓇ❗⟵ ⟶⟷";
|
|
10
|
+
function symbol(nodeClass) {
|
|
11
|
+
switch (nodeClass) {
|
|
12
|
+
case node_opcua_data_model_1.NodeClass.DataType:
|
|
13
|
+
return "Ⓓ";
|
|
14
|
+
case node_opcua_data_model_1.NodeClass.ObjectType:
|
|
15
|
+
return "ⓄT";
|
|
16
|
+
case node_opcua_data_model_1.NodeClass.VariableType:
|
|
17
|
+
return "ⓋT";
|
|
18
|
+
case node_opcua_data_model_1.NodeClass.Method:
|
|
19
|
+
return "Ⓜ";
|
|
20
|
+
case node_opcua_data_model_1.NodeClass.Object:
|
|
21
|
+
return "Ⓞ";
|
|
22
|
+
case node_opcua_data_model_1.NodeClass.Variable:
|
|
23
|
+
return "Ⓥ";
|
|
24
|
+
case node_opcua_data_model_1.NodeClass.View:
|
|
25
|
+
return "⦖";
|
|
26
|
+
default:
|
|
27
|
+
return "?";
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const hasSubtypeNodeId = (0, node_opcua_nodeid_1.resolveNodeId)("HasSubtype");
|
|
31
|
+
function displayNodeElement(node, options) {
|
|
32
|
+
const head = ["ReferenceType", "NodeId", "BrowseName", "ModellingRule", "TypeDefinition", "DataType", "Value"];
|
|
33
|
+
const table = new tableHelper_1.TableHelper(head);
|
|
34
|
+
table.push(["BrowseName: ", { colSpan: 6, content: node.browseName.toString() }]);
|
|
35
|
+
const superType = node.subtypeOfObj;
|
|
36
|
+
if (superType) {
|
|
37
|
+
table.push(["Base", superType.browseName.toString(), { colSpan: 6, content: node.browseName.toString() }]);
|
|
38
|
+
}
|
|
39
|
+
if (node.description) {
|
|
40
|
+
table.push(["Description", node.description.toString(), { colSpan: 6, content: node.browseName.toString() }]);
|
|
41
|
+
}
|
|
42
|
+
const alreadyDumped = {};
|
|
43
|
+
const descriptions = [];
|
|
44
|
+
function dumpReference(ref, filter) {
|
|
45
|
+
(0, node_opcua_address_space_1.resolveReferenceNode)(node.addressSpace, ref);
|
|
46
|
+
if (!ref.isForward) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (node_opcua_nodeid_1.NodeId.sameNodeId(ref.referenceType, hasSubtypeNodeId)) {
|
|
50
|
+
return; // ignore forward HasSubtype
|
|
51
|
+
}
|
|
52
|
+
// ignore subtype references
|
|
53
|
+
/* istanbul ignore next */
|
|
54
|
+
if (!ref.node) {
|
|
55
|
+
// tslint:disable-next-line: no-console
|
|
56
|
+
console.log(" Halt ", ref.toString({ addressSpace: node.addressSpace }));
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const dir = ref.isForward ? " " : " ";
|
|
60
|
+
const refNode = ref.node;
|
|
61
|
+
const refType = (0, node_opcua_address_space_1.resolveReferenceType)(node.addressSpace, ref);
|
|
62
|
+
if (filter) {
|
|
63
|
+
if (refType.browseName.toString() !== filter) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (alreadyDumped[refNode.nodeId.toString()]) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
// xx const r = refNode.findReferencesAsObject("HasModellingRule", true);
|
|
71
|
+
const modelingRule = refNode.modellingRule || ""; // r[0] ? r[0].browseName.toString() : "/";
|
|
72
|
+
let value = "";
|
|
73
|
+
let dataType = "";
|
|
74
|
+
if (refNode.nodeClass === node_opcua_data_model_1.NodeClass.Variable) {
|
|
75
|
+
const v = refNode;
|
|
76
|
+
const val = v.readValue().value.value;
|
|
77
|
+
if (v.isExtensionObject()) {
|
|
78
|
+
// don't do anything
|
|
79
|
+
}
|
|
80
|
+
else if (v.isEnumeration() && val !== null) {
|
|
81
|
+
const enumValue = v.readEnumValue();
|
|
82
|
+
value = enumValue.value + " (" + enumValue.name + ")";
|
|
83
|
+
}
|
|
84
|
+
else if (val instanceof Date) {
|
|
85
|
+
value = val ? val.toUTCString() : "";
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
value = val ? val.toString() : "null";
|
|
89
|
+
}
|
|
90
|
+
const actualDataType = node_opcua_variant_1.DataType[v.readValue().value.dataType];
|
|
91
|
+
const basicDataType = node_opcua_variant_1.DataType[v.dataTypeObj.basicDataType];
|
|
92
|
+
dataType = v.dataTypeObj.browseName.toString();
|
|
93
|
+
if (basicDataType !== dataType) {
|
|
94
|
+
dataType = dataType + "(" + basicDataType + ")";
|
|
95
|
+
}
|
|
96
|
+
// findBasicDataType(v.dataTypeObj);
|
|
97
|
+
}
|
|
98
|
+
const row = [
|
|
99
|
+
refType.browseName.toString() + dir + symbol(refNode.nodeClass),
|
|
100
|
+
refNode.nodeId.toString(),
|
|
101
|
+
refNode.browseName.toString(),
|
|
102
|
+
modelingRule,
|
|
103
|
+
refNode.typeDefinitionObj ? refNode.typeDefinitionObj.browseName.toString() : "",
|
|
104
|
+
dataType,
|
|
105
|
+
value
|
|
106
|
+
];
|
|
107
|
+
table.push(row);
|
|
108
|
+
descriptions.push({
|
|
109
|
+
description: refNode.description ? refNode.description.toString() : "",
|
|
110
|
+
name: refNode.browseName.name,
|
|
111
|
+
type: dataType
|
|
112
|
+
});
|
|
113
|
+
alreadyDumped[refNode.nodeId.toString()] = 1;
|
|
114
|
+
}
|
|
115
|
+
const references = node.allReferences();
|
|
116
|
+
const m = {};
|
|
117
|
+
function dumpReferences(_references) {
|
|
118
|
+
// xx for (const ref of references) {
|
|
119
|
+
// xx dumpReference(ref, "HasSubtype");
|
|
120
|
+
// xx }
|
|
121
|
+
for (const ref of _references) {
|
|
122
|
+
dumpReference(ref, "HasTypeDefinition");
|
|
123
|
+
}
|
|
124
|
+
for (const ref of _references) {
|
|
125
|
+
dumpReference(ref, "HasEncoding");
|
|
126
|
+
}
|
|
127
|
+
for (const ref of _references) {
|
|
128
|
+
dumpReference(ref, "HasComponent");
|
|
129
|
+
}
|
|
130
|
+
for (const ref of _references) {
|
|
131
|
+
dumpReference(ref, "HasProperty");
|
|
132
|
+
}
|
|
133
|
+
for (const ref of _references) {
|
|
134
|
+
dumpReference(ref, "Organizes");
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
dumpReferences(references);
|
|
138
|
+
// add property from base object/variable type
|
|
139
|
+
if (node.nodeClass === node_opcua_data_model_1.NodeClass.ObjectType || node.nodeClass === node_opcua_data_model_1.NodeClass.VariableType) {
|
|
140
|
+
const curNode = node;
|
|
141
|
+
let subtypeOf = curNode.subtypeOfObj;
|
|
142
|
+
while (subtypeOf) {
|
|
143
|
+
table.push([subtypeOf.browseName.toString() + ":", "--", "--", "--"]);
|
|
144
|
+
const references2 = subtypeOf.allReferences();
|
|
145
|
+
dumpReferences(references2);
|
|
146
|
+
subtypeOf = subtypeOf.subtypeOfObj;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
if (options && options.format === "markdown") {
|
|
150
|
+
return table.toMarkdownTable();
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
return table.toString();
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
exports.displayNodeElement = displayNodeElement;
|
|
157
|
+
//# sourceMappingURL=displayNodeElement.js.map
|