node-opcua-json 0.50.0 → 2.182.2
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/LICENSE +22 -0
- package/README.md +168 -4
- package/dist/104/index.d.ts +56 -0
- package/dist/104/index.js +93 -0
- package/dist/104/index.js.map +1 -0
- package/dist/105/index.d.ts +55 -0
- package/dist/105/index.js +95 -0
- package/dist/105/index.js.map +1 -0
- package/dist/decode_opcua_json.d.ts +31 -0
- package/dist/decode_opcua_json.js +61 -0
- package/dist/decode_opcua_json.js.map +1 -0
- package/dist/extension_object_constructor.d.ts +46 -0
- package/dist/extension_object_constructor.js +26 -0
- package/dist/extension_object_constructor.js.map +1 -0
- package/dist/index.d.ts +39 -0
- package/dist/index.js +100 -0
- package/dist/index.js.map +1 -0
- package/dist/json_basic_encoding_body_functor.d.ts +34 -0
- package/dist/json_basic_encoding_body_functor.js +170 -0
- package/dist/json_basic_encoding_body_functor.js.map +1 -0
- package/dist/json_basic_encoding_decoding_byte_string.d.ts +27 -0
- package/dist/json_basic_encoding_decoding_byte_string.js +27 -0
- package/dist/json_basic_encoding_decoding_byte_string.js.map +1 -0
- package/dist/json_basic_encoding_decoding_data_value.d.ts +81 -0
- package/dist/json_basic_encoding_decoding_data_value.js +290 -0
- package/dist/json_basic_encoding_decoding_data_value.js.map +1 -0
- package/dist/json_basic_encoding_decoding_date_time.d.ts +26 -0
- package/dist/json_basic_encoding_decoding_date_time.js +43 -0
- package/dist/json_basic_encoding_decoding_date_time.js.map +1 -0
- package/dist/json_basic_encoding_decoding_extension_object.d.ts +65 -0
- package/dist/json_basic_encoding_decoding_extension_object.js +461 -0
- package/dist/json_basic_encoding_decoding_extension_object.js.map +1 -0
- package/dist/json_basic_encoding_decoding_int64.d.ts +30 -0
- package/dist/json_basic_encoding_decoding_int64.js +56 -0
- package/dist/json_basic_encoding_decoding_int64.js.map +1 -0
- package/dist/json_basic_encoding_decoding_localizedtext.d.ts +33 -0
- package/dist/json_basic_encoding_decoding_localizedtext.js +62 -0
- package/dist/json_basic_encoding_decoding_localizedtext.js.map +1 -0
- package/dist/json_basic_encoding_decoding_nodeid.d.ts +73 -0
- package/dist/json_basic_encoding_decoding_nodeid.js +314 -0
- package/dist/json_basic_encoding_decoding_nodeid.js.map +1 -0
- package/dist/json_basic_encoding_decoding_qualifiedname.d.ts +35 -0
- package/dist/json_basic_encoding_decoding_qualifiedname.js +126 -0
- package/dist/json_basic_encoding_decoding_qualifiedname.js.map +1 -0
- package/dist/json_basic_encoding_decoding_statuscode.d.ts +39 -0
- package/dist/json_basic_encoding_decoding_statuscode.js +139 -0
- package/dist/json_basic_encoding_decoding_statuscode.js.map +1 -0
- package/dist/json_basic_encoding_decoding_variant.d.ts +101 -0
- package/dist/json_basic_encoding_decoding_variant.js +234 -0
- package/dist/json_basic_encoding_decoding_variant.js.map +1 -0
- package/dist/json_encoding_scheme.d.ts +50 -0
- package/dist/json_encoding_scheme.js +117 -0
- package/dist/json_encoding_scheme.js.map +1 -0
- package/package.json +90 -35
- package/source/104/index.ts +117 -0
- package/source/105/index.ts +118 -0
- package/source/decode_opcua_json.ts +67 -0
- package/source/extension_object_constructor.ts +48 -0
- package/source/index.ts +71 -0
- package/source/json_basic_encoding_body_functor.ts +190 -0
- package/source/json_basic_encoding_decoding_byte_string.ts +52 -0
- package/source/json_basic_encoding_decoding_data_value.ts +392 -0
- package/source/json_basic_encoding_decoding_date_time.ts +42 -0
- package/source/json_basic_encoding_decoding_extension_object.ts +531 -0
- package/source/json_basic_encoding_decoding_int64.ts +74 -0
- package/source/json_basic_encoding_decoding_localizedtext.ts +69 -0
- package/source/json_basic_encoding_decoding_nodeid.ts +375 -0
- package/source/json_basic_encoding_decoding_qualifiedname.ts +144 -0
- package/source/json_basic_encoding_decoding_statuscode.ts +151 -0
- package/source/json_basic_encoding_decoding_variant.ts +339 -0
- package/source/json_encoding_scheme.ts +114 -0
- package/LICENSE.md +0 -40
- package/dist2/decode_opcua_json.d.ts +0 -12
- package/dist2/index.d.ts +0 -17
- package/dist2/index.js +0 -1
- package/dist2/json_basic_encoding_body_functor.d.ts +0 -14
- package/dist2/json_basic_encoding_decoding_byte_string.d.ts +0 -8
- package/dist2/json_basic_encoding_decoding_data_value.d.ts +0 -26
- package/dist2/json_basic_encoding_decoding_date_time.d.ts +0 -6
- package/dist2/json_basic_encoding_decoding_extension_object.d.ts +0 -32
- package/dist2/json_basic_encoding_decoding_int64.d.ts +0 -9
- package/dist2/json_basic_encoding_decoding_localizedtext.d.ts +0 -14
- package/dist2/json_basic_encoding_decoding_nodeid.d.ts +0 -33
- package/dist2/json_basic_encoding_decoding_qualifiedname.d.ts +0 -14
- package/dist2/json_basic_encoding_decoding_statuscode.d.ts +0 -16
- package/dist2/json_basic_encoding_decoding_variant.d.ts +0 -0
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* ==========================================================================
|
|
4
|
+
* Copyright (c) 2021-2026 Sterfive - etienne.rossignon@sterfive.com
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in
|
|
14
|
+
* all copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
17
|
+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
19
|
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
21
|
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
22
|
+
* IN THE SOFTWARE.
|
|
23
|
+
* ==========================================================================
|
|
24
|
+
*/
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.opcuaJsonEncodeDataValueMQTT = opcuaJsonEncodeDataValueMQTT;
|
|
27
|
+
exports.opcuaJsonEncodeDataValueMQTT104 = opcuaJsonEncodeDataValueMQTT104;
|
|
28
|
+
exports.opcuaJsonEncodeDataValueMQTT105 = opcuaJsonEncodeDataValueMQTT105;
|
|
29
|
+
exports.opcuaJsonEncodeDataValue104 = opcuaJsonEncodeDataValue104;
|
|
30
|
+
exports.opcuaJsonEncodeDataValue105 = opcuaJsonEncodeDataValue105;
|
|
31
|
+
exports.opcuaJsonEncodeDataValue = opcuaJsonEncodeDataValue;
|
|
32
|
+
exports.opcuaJsonDecodeDataValue104 = opcuaJsonDecodeDataValue104;
|
|
33
|
+
exports.opcuaJsonDecodeDataValue105 = opcuaJsonDecodeDataValue105;
|
|
34
|
+
exports.opcuaJsonDecodeDataValue = opcuaJsonDecodeDataValue;
|
|
35
|
+
const node_opcua_data_value_1 = require("node-opcua-data-value");
|
|
36
|
+
const node_opcua_types_1 = require("node-opcua-types");
|
|
37
|
+
const node_opcua_variant_1 = require("node-opcua-variant");
|
|
38
|
+
const json_basic_encoding_decoding_statuscode_js_1 = require("./json_basic_encoding_decoding_statuscode.js");
|
|
39
|
+
const json_basic_encoding_decoding_variant_js_1 = require("./json_basic_encoding_decoding_variant.js");
|
|
40
|
+
const json_encoding_scheme_js_1 = require("./json_encoding_scheme.js");
|
|
41
|
+
function _setTimestampsAndStatusCode(pojo, dataValue, mask, mode) {
|
|
42
|
+
if (mask & node_opcua_types_1.DataSetFieldContentMask.ServerPicoSeconds && dataValue.serverPicoseconds) {
|
|
43
|
+
pojo.ServerPicoseconds = dataValue.serverPicoseconds;
|
|
44
|
+
}
|
|
45
|
+
if (mask & node_opcua_types_1.DataSetFieldContentMask.SourcePicoSeconds && dataValue.sourcePicoseconds) {
|
|
46
|
+
pojo.SourcePicoseconds = dataValue.sourcePicoseconds;
|
|
47
|
+
}
|
|
48
|
+
if (mask & node_opcua_types_1.DataSetFieldContentMask.ServerTimestamp && dataValue.serverTimestamp) {
|
|
49
|
+
pojo.ServerTimestamp = dataValue.serverTimestamp;
|
|
50
|
+
}
|
|
51
|
+
if (mask & node_opcua_types_1.DataSetFieldContentMask.SourceTimestamp && dataValue.sourceTimestamp) {
|
|
52
|
+
pojo.SourceTimestamp = dataValue.sourceTimestamp;
|
|
53
|
+
}
|
|
54
|
+
if (mask & node_opcua_types_1.DataSetFieldContentMask.StatusCode && dataValue.statusCode.value !== 0) {
|
|
55
|
+
// statusCode is omitted if it is Good (0)
|
|
56
|
+
// https://reference.opcfoundation.org/Core/Part6/v105/docs/5.4
|
|
57
|
+
switch (mode) {
|
|
58
|
+
case json_encoding_scheme_js_1.JsonEncodingScheme.DeprecatedNonReversible:
|
|
59
|
+
pojo.StatusCode = (0, json_basic_encoding_decoding_statuscode_js_1.opcuaJsonEncodeStatusCode104)(dataValue.statusCode, json_encoding_scheme_js_1.JsonEncoderMode104.NonReversible);
|
|
60
|
+
break;
|
|
61
|
+
case json_encoding_scheme_js_1.JsonEncodingScheme.DeprecatedReversible:
|
|
62
|
+
pojo.StatusCode = (0, json_basic_encoding_decoding_statuscode_js_1.opcuaJsonEncodeStatusCode104)(dataValue.statusCode, json_encoding_scheme_js_1.JsonEncoderMode104.Reversible);
|
|
63
|
+
break;
|
|
64
|
+
case json_encoding_scheme_js_1.JsonEncodingScheme.Verbose:
|
|
65
|
+
pojo.StatusCode = (0, json_basic_encoding_decoding_statuscode_js_1.opcuaJsonEncodeStatusCode105)(dataValue.statusCode, json_encoding_scheme_js_1.JsonEncoderMode105.Verbose);
|
|
66
|
+
break;
|
|
67
|
+
case json_encoding_scheme_js_1.JsonEncodingScheme.Compact:
|
|
68
|
+
pojo.StatusCode = (0, json_basic_encoding_decoding_statuscode_js_1.opcuaJsonEncodeStatusCode105)(dataValue.statusCode, json_encoding_scheme_js_1.JsonEncoderMode105.Compact);
|
|
69
|
+
break;
|
|
70
|
+
default:
|
|
71
|
+
throw new Error("Invalid JsonEncodingScheme");
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function _decodeTimestampsAndStatusCodeJson(pojo, dataValueOpt) {
|
|
76
|
+
if (pojo.ServerPicoseconds) {
|
|
77
|
+
dataValueOpt.serverPicoseconds = pojo.ServerPicoseconds;
|
|
78
|
+
}
|
|
79
|
+
if (pojo.SourcePicoseconds) {
|
|
80
|
+
dataValueOpt.sourcePicoseconds = pojo.SourcePicoseconds;
|
|
81
|
+
}
|
|
82
|
+
if (pojo.ServerTimestamp) {
|
|
83
|
+
dataValueOpt.serverTimestamp = new Date(pojo.ServerTimestamp);
|
|
84
|
+
}
|
|
85
|
+
if (pojo.SourceTimestamp) {
|
|
86
|
+
dataValueOpt.sourceTimestamp = new Date(pojo.SourceTimestamp);
|
|
87
|
+
}
|
|
88
|
+
if (pojo.StatusCode) {
|
|
89
|
+
dataValueOpt.statusCode = (0, json_basic_encoding_decoding_statuscode_js_1.opcuaJsonDecodeStatusCode)(pojo.StatusCode);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
*
|
|
94
|
+
* @param dataValue
|
|
95
|
+
* @param mask
|
|
96
|
+
* @returns
|
|
97
|
+
*/
|
|
98
|
+
function opcuaJsonEncodeDataValueMQTT(dataValue, encoding, mask, namespaceArray = []) {
|
|
99
|
+
switch (encoding) {
|
|
100
|
+
case json_encoding_scheme_js_1.JsonEncodingScheme.DeprecatedNonReversible:
|
|
101
|
+
return opcuaJsonEncodeDataValueMQTT104(dataValue, json_encoding_scheme_js_1.JsonEncoderMode104.NonReversible, mask, namespaceArray);
|
|
102
|
+
case json_encoding_scheme_js_1.JsonEncodingScheme.DeprecatedReversible:
|
|
103
|
+
return opcuaJsonEncodeDataValueMQTT104(dataValue, json_encoding_scheme_js_1.JsonEncoderMode104.Reversible, mask, namespaceArray);
|
|
104
|
+
case json_encoding_scheme_js_1.JsonEncodingScheme.Verbose:
|
|
105
|
+
return opcuaJsonEncodeDataValueMQTT105(dataValue, json_encoding_scheme_js_1.JsonEncoderMode105.Verbose, mask, namespaceArray);
|
|
106
|
+
case json_encoding_scheme_js_1.JsonEncodingScheme.Compact: {
|
|
107
|
+
return opcuaJsonEncodeDataValueMQTT105(dataValue, json_encoding_scheme_js_1.JsonEncoderMode105.Compact, mask, namespaceArray);
|
|
108
|
+
}
|
|
109
|
+
default:
|
|
110
|
+
throw new Error("Invalid JsonEncodingScheme");
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
function opcuaJsonEncodeDataValueMQTT104(dataValue, mode, mask, namespaceArray = []) {
|
|
114
|
+
/**
|
|
115
|
+
* All fields with a concrete DataType are encoded using VerboseEncoding if FieldEncoding1 is
|
|
116
|
+
* FALSE and CompactEncoding if FieldEncoding1 is TRUE.
|
|
117
|
+
*
|
|
118
|
+
* See the OPC UA JSON Data encodings defined in OPC 10000-6.
|
|
119
|
+
*
|
|
120
|
+
* The fields in the DataSetMessage are specified by the DataSetFieldContentMask in the
|
|
121
|
+
* DataSetWriter parameters.
|
|
122
|
+
*
|
|
123
|
+
* The format of the field values in the Payload depend on the setting of
|
|
124
|
+
* DataSetFieldContentMask, the FieldEncoding1 and the FieldEncoding2 flag in
|
|
125
|
+
* DataSetMessageContentMask. The resulting JSON encoding is defined in Table 111.
|
|
126
|
+
*
|
|
127
|
+
* FieldEncoding1 FieldEncoding2 Description
|
|
128
|
+
* False True The JSON VerboseEncoding is used for the DataSetMessage field encoding.
|
|
129
|
+
* True True The JSON CompactEncoding is used for the DataSetMessage field encoding.
|
|
130
|
+
* False False The deprecated JSON NonReversibleEncoding is used for the
|
|
131
|
+
* DataSetMessage field encoding.
|
|
132
|
+
* The RawData bit of the DataSetFieldContentMask shall be ignored.
|
|
133
|
+
* True False The deprecated JSON ReversibleFieldEncoding is used for the
|
|
134
|
+
* DataSetMessage field encoding.
|
|
135
|
+
* The RawData bit of the DataSetFieldContentMask shall be ignored.
|
|
136
|
+
*
|
|
137
|
+
* If the DataSetFieldContentMask is 0x0 or 0x20 (only the RawData flag is set), the
|
|
138
|
+
* DataSetMessage fields are encoded as Variant. Otherwise the fields are encoded as
|
|
139
|
+
* DataValue.
|
|
140
|
+
* If the KeyFrameCount is 0, the DataSetFieldContentMask shall be 0x0 or 0x20.
|
|
141
|
+
*
|
|
142
|
+
* If the FieldEncoding1 is FALSE in the DataSetMessageContentMask, the Variant at the top
|
|
143
|
+
* level of a field is encoded as a JSON value containing only the value of the Body field.
|
|
144
|
+
*
|
|
145
|
+
* If this Variant contains an ExtensionObject, the ExtensionObject shall be encoded as a Structure
|
|
146
|
+
* without the UaTypeId field.
|
|
147
|
+
* This also applies to the Variant in a DataValue at the top level of a field.
|
|
148
|
+
*
|
|
149
|
+
* If the RawData flag is set, the UaType fields of Variants and the UaTypeId fields of
|
|
150
|
+
* ExtensionObjects are always omitted.
|
|
151
|
+
*
|
|
152
|
+
* If the RawData flag ist set, it is not possible to reverse the data in a DataSetReader in the
|
|
153
|
+
* following cases.
|
|
154
|
+
*
|
|
155
|
+
* * DataSet fields have an abstract DataType in the DataSetMetaData.
|
|
156
|
+
* * DataSet field values do not match the DataType specified in the DataSetMetaData if
|
|
157
|
+
* they are Structure DataTypes
|
|
158
|
+
**/
|
|
159
|
+
if (mask === node_opcua_types_1.DataSetFieldContentMask.None) {
|
|
160
|
+
return (0, json_basic_encoding_decoding_variant_js_1.opcuaJsonEncodeVariant104)(dataValue.value, mode, namespaceArray);
|
|
161
|
+
}
|
|
162
|
+
const pojoVariant = (0, json_basic_encoding_decoding_variant_js_1.opcuaJsonEncodeVariant104)(dataValue.value, mode, namespaceArray);
|
|
163
|
+
if (mask & node_opcua_types_1.DataSetFieldContentMask.RawData) {
|
|
164
|
+
// RawData: the field value is a Variant encoded using the non-reversible OPC UA JSON Data Encoding defined in OPC 10000-6.
|
|
165
|
+
return pojoVariant;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* DataValue values shall be encoded as a JSON object with the fields below.
|
|
169
|
+
* JSON Object Definition for a DataValue
|
|
170
|
+
* Name DataType Description
|
|
171
|
+
* Value Variant The value.
|
|
172
|
+
* Status StatusCode The status associated with the value.
|
|
173
|
+
* SourceTimestamp DateTime The source timestamp associated with the value.
|
|
174
|
+
* SourcePicoSeconds UInt16 The number of 10 picosecond intervals for the SourceTimestamp.
|
|
175
|
+
* ServerTimestamp DateTime The Server timestamp associated with the value.
|
|
176
|
+
* ServerPicoSeconds UInt16 The number of 10 picosecond intervals for the ServerTimestamp.
|
|
177
|
+
*
|
|
178
|
+
* If a field has a null or default value it is omitted. Each field is encoded using the rules
|
|
179
|
+
* defined for the built-in type specified in the Data Type column.
|
|
180
|
+
*/
|
|
181
|
+
const pojo = {
|
|
182
|
+
Value: pojoVariant
|
|
183
|
+
};
|
|
184
|
+
_setTimestampsAndStatusCode(pojo, dataValue, mask, (0, json_encoding_scheme_js_1.toJsonEncodingScheme)(mode));
|
|
185
|
+
return pojo;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
*
|
|
189
|
+
* @param dataValue
|
|
190
|
+
* @param mask
|
|
191
|
+
* @returns
|
|
192
|
+
*/
|
|
193
|
+
function opcuaJsonEncodeDataValueMQTT105(dataValue, mode, mask, namespaceArray = []) {
|
|
194
|
+
if (mask === node_opcua_types_1.DataSetFieldContentMask.None) {
|
|
195
|
+
if (mode === json_encoding_scheme_js_1.JsonEncoderMode105.Verbose) {
|
|
196
|
+
return (0, json_basic_encoding_decoding_variant_js_1.opcuaJsonEncodeVariant105)(dataValue.value, mode, namespaceArray);
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
return (0, json_basic_encoding_decoding_variant_js_1.opcuaJsonEncodeVariant105)(dataValue.value, mode, namespaceArray);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
const pojoVariant = (0, json_basic_encoding_decoding_variant_js_1.opcuaJsonEncodeVariant105)(dataValue.value, mode, namespaceArray);
|
|
203
|
+
if (mask & node_opcua_types_1.DataSetFieldContentMask.RawData) {
|
|
204
|
+
// RawData: the field value is a Variant encoded using the non-reversible OPC UA JSON Data Encoding defined in OPC 10000-6.
|
|
205
|
+
return pojoVariant;
|
|
206
|
+
}
|
|
207
|
+
const pojo = pojoVariant;
|
|
208
|
+
_setTimestampsAndStatusCode(pojo, dataValue, mask, (0, json_encoding_scheme_js_1.toJsonEncodingScheme)(mode));
|
|
209
|
+
return pojo;
|
|
210
|
+
}
|
|
211
|
+
const DataSetFieldContentMaskAll = node_opcua_types_1.DataSetFieldContentMask.StatusCode |
|
|
212
|
+
node_opcua_types_1.DataSetFieldContentMask.SourceTimestamp |
|
|
213
|
+
node_opcua_types_1.DataSetFieldContentMask.SourcePicoSeconds |
|
|
214
|
+
node_opcua_types_1.DataSetFieldContentMask.ServerTimestamp |
|
|
215
|
+
node_opcua_types_1.DataSetFieldContentMask.ServerPicoSeconds;
|
|
216
|
+
function opcuaJsonEncodeDataValue104(dataValue, mode, namespaceArray) {
|
|
217
|
+
const pojoVariant = (0, json_basic_encoding_decoding_variant_js_1.opcuaJsonEncodeVariant104)(dataValue.value, mode, namespaceArray);
|
|
218
|
+
if (mode === json_encoding_scheme_js_1.JsonEncoderMode104.Reversible) {
|
|
219
|
+
const pojo = {
|
|
220
|
+
Value: pojoVariant
|
|
221
|
+
};
|
|
222
|
+
_setTimestampsAndStatusCode(pojo, dataValue, DataSetFieldContentMaskAll, (0, json_encoding_scheme_js_1.toJsonEncodingScheme)(mode));
|
|
223
|
+
return pojo;
|
|
224
|
+
}
|
|
225
|
+
const pojo = {
|
|
226
|
+
Value: pojoVariant
|
|
227
|
+
};
|
|
228
|
+
_setTimestampsAndStatusCode(pojo, dataValue, DataSetFieldContentMaskAll, (0, json_encoding_scheme_js_1.toJsonEncodingScheme)(mode));
|
|
229
|
+
return pojo;
|
|
230
|
+
}
|
|
231
|
+
function opcuaJsonEncodeDataValue105(dataValue, mode, namespaceArray) {
|
|
232
|
+
if (mode === json_encoding_scheme_js_1.JsonEncoderMode105.Verbose) {
|
|
233
|
+
const pojoVariant = (0, json_basic_encoding_decoding_variant_js_1.opcuaJsonEncodeVariant105)(dataValue.value, mode, namespaceArray);
|
|
234
|
+
const pojo = pojoVariant;
|
|
235
|
+
_setTimestampsAndStatusCode(pojo, dataValue, DataSetFieldContentMaskAll, (0, json_encoding_scheme_js_1.toJsonEncodingScheme)(mode));
|
|
236
|
+
return pojo;
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
const pojoVariant = (0, json_basic_encoding_decoding_variant_js_1.opcuaJsonEncodeVariant105)(dataValue.value, mode, namespaceArray);
|
|
240
|
+
const pojo = pojoVariant;
|
|
241
|
+
_setTimestampsAndStatusCode(pojo, dataValue, DataSetFieldContentMaskAll, (0, json_encoding_scheme_js_1.toJsonEncodingScheme)(mode));
|
|
242
|
+
return pojo;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
function opcuaJsonEncodeDataValue(dataValue, mode, namespaceArray) {
|
|
246
|
+
switch (mode) {
|
|
247
|
+
case json_encoding_scheme_js_1.JsonEncodingScheme.DeprecatedNonReversible:
|
|
248
|
+
return opcuaJsonEncodeDataValue104(dataValue, json_encoding_scheme_js_1.JsonEncoderMode104.NonReversible, namespaceArray);
|
|
249
|
+
case json_encoding_scheme_js_1.JsonEncodingScheme.DeprecatedReversible:
|
|
250
|
+
return opcuaJsonEncodeDataValue104(dataValue, json_encoding_scheme_js_1.JsonEncoderMode104.Reversible, namespaceArray);
|
|
251
|
+
case json_encoding_scheme_js_1.JsonEncodingScheme.Verbose:
|
|
252
|
+
return opcuaJsonEncodeDataValue105(dataValue, json_encoding_scheme_js_1.JsonEncoderMode105.Verbose, namespaceArray);
|
|
253
|
+
case json_encoding_scheme_js_1.JsonEncodingScheme.Compact:
|
|
254
|
+
return opcuaJsonEncodeDataValue105(dataValue, json_encoding_scheme_js_1.JsonEncoderMode105.Compact, namespaceArray);
|
|
255
|
+
default:
|
|
256
|
+
throw new Error("Invalid JsonEncodingScheme");
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
function opcuaJsonDecodeDataValue104(pojo, builder, namespaceArray) {
|
|
260
|
+
if (!pojo) {
|
|
261
|
+
return new node_opcua_data_value_1.DataValue({ value: { dataType: node_opcua_variant_1.DataType.Null } });
|
|
262
|
+
}
|
|
263
|
+
const dataValueOpt = {};
|
|
264
|
+
_decodeTimestampsAndStatusCodeJson(pojo, dataValueOpt);
|
|
265
|
+
if (pojo.Value) {
|
|
266
|
+
dataValueOpt.value = (0, json_basic_encoding_decoding_variant_js_1.opcuaJsonDecodeVariant104)(pojo.Value, builder, namespaceArray);
|
|
267
|
+
}
|
|
268
|
+
return new node_opcua_data_value_1.DataValue(dataValueOpt);
|
|
269
|
+
}
|
|
270
|
+
function opcuaJsonDecodeDataValue105(pojo, builder, namespaceArray) {
|
|
271
|
+
if (!pojo) {
|
|
272
|
+
return new node_opcua_data_value_1.DataValue({ value: { dataType: node_opcua_variant_1.DataType.Null } });
|
|
273
|
+
}
|
|
274
|
+
const dataValueOpt = {};
|
|
275
|
+
_decodeTimestampsAndStatusCodeJson(pojo, dataValueOpt);
|
|
276
|
+
if (pojo.Value) {
|
|
277
|
+
dataValueOpt.value = (0, json_basic_encoding_decoding_variant_js_1.opcuaJsonDecodeVariant105)(pojo, builder, namespaceArray);
|
|
278
|
+
}
|
|
279
|
+
return new node_opcua_data_value_1.DataValue(dataValueOpt);
|
|
280
|
+
}
|
|
281
|
+
function opcuaJsonDecodeDataValue(pojo, builder, namespaceArray) {
|
|
282
|
+
if (!pojo) {
|
|
283
|
+
return new node_opcua_data_value_1.DataValue({ value: { dataType: node_opcua_variant_1.DataType.Null } });
|
|
284
|
+
}
|
|
285
|
+
if ("UaType" in pojo) {
|
|
286
|
+
return opcuaJsonDecodeDataValue105(pojo, builder, namespaceArray);
|
|
287
|
+
}
|
|
288
|
+
return opcuaJsonDecodeDataValue104(pojo, builder, namespaceArray);
|
|
289
|
+
}
|
|
290
|
+
//# sourceMappingURL=json_basic_encoding_decoding_data_value.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json_basic_encoding_decoding_data_value.js","sourceRoot":"","sources":["../source/json_basic_encoding_decoding_data_value.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;AAwHH,oEAmBC;AACD,0EAgFC;AAQD,0EAsBC;AASD,kEAkBC;AACD,kEAgBC;AAYD,4DAiBC;AAED,kEAcC;AAED,kEAcC;AAED,4DAYC;AA9WD,iEAAyE;AACzE,uDAA2D;AAC3D,2DAA8C;AAE9C,6GAKsD;AACtD,uGAQmD;AACnD,uEAA6H;AAmC7H,SAAS,2BAA2B,CAChC,IAAkC,EAClC,SAAoB,EACpB,IAA6B,EAC7B,IAAwB;IAExB,IAAI,IAAI,GAAG,0CAAuB,CAAC,iBAAiB,IAAI,SAAS,CAAC,iBAAiB,EAAE,CAAC;QAClF,IAAI,CAAC,iBAAiB,GAAG,SAAS,CAAC,iBAAiB,CAAC;IACzD,CAAC;IACD,IAAI,IAAI,GAAG,0CAAuB,CAAC,iBAAiB,IAAI,SAAS,CAAC,iBAAiB,EAAE,CAAC;QAClF,IAAI,CAAC,iBAAiB,GAAG,SAAS,CAAC,iBAAiB,CAAC;IACzD,CAAC;IACD,IAAI,IAAI,GAAG,0CAAuB,CAAC,eAAe,IAAI,SAAS,CAAC,eAAe,EAAE,CAAC;QAC9E,IAAI,CAAC,eAAe,GAAG,SAAS,CAAC,eAA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,EAAE,EAAE,CAAC,CAAC;IACjE,CAAC;IACD,IAAI,QAAQ,IAAI,IAAI,EAAE,CAAC;QACnB,OAAO,2BAA2B,CAAC,IAAwB,EAAE,OAAO,EAAE,cAAc,CAAC,CAAC;IAC1F,CAAC;IACD,OAAO,2BAA2B,CAAC,IAAwB,EAAE,OAAO,EAAE,cAAc,CAAC,CAAC;AAC1F,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ==========================================================================
|
|
3
|
+
* Copyright (c) 2021-2026 Sterfive - etienne.rossignon@sterfive.com
|
|
4
|
+
*
|
|
5
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
* in the Software without restriction, including without limitation the rights
|
|
8
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
* furnished to do so, subject to the following conditions:
|
|
11
|
+
*
|
|
12
|
+
* The above copyright notice and this permission notice shall be included in
|
|
13
|
+
* all copies or substantial portions of the Software.
|
|
14
|
+
*
|
|
15
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
16
|
+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
18
|
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
20
|
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
21
|
+
* IN THE SOFTWARE.
|
|
22
|
+
* ==========================================================================
|
|
23
|
+
*/
|
|
24
|
+
import type { JsonEncodingScheme } from "./json_encoding_scheme.js";
|
|
25
|
+
export declare function opcuaJsonEncodeDateTime(date: Date, _scheme: JsonEncodingScheme, _namespaceArray?: string[]): Date;
|
|
26
|
+
export declare function opcuaJsonDecodeDateTime(pojo: Date | string): Date;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* ==========================================================================
|
|
4
|
+
* Copyright (c) 2021-2026 Sterfive - etienne.rossignon@sterfive.com
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in
|
|
14
|
+
* all copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
17
|
+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
19
|
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
21
|
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
22
|
+
* IN THE SOFTWARE.
|
|
23
|
+
* ==========================================================================
|
|
24
|
+
*/
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.opcuaJsonEncodeDateTime = opcuaJsonEncodeDateTime;
|
|
27
|
+
exports.opcuaJsonDecodeDateTime = opcuaJsonDecodeDateTime;
|
|
28
|
+
const node_opcua_date_time_1 = require("node-opcua-date-time");
|
|
29
|
+
const maxDate = new Date("9999-12-31T23:59:59.000Z");
|
|
30
|
+
const reallyMinDate = new Date("0001-01-01T00:00:00.000Z");
|
|
31
|
+
function opcuaJsonEncodeDateTime(date, _scheme, _namespaceArray) {
|
|
32
|
+
if (date.getTime() <= node_opcua_date_time_1.minDate.getTime()) {
|
|
33
|
+
return reallyMinDate;
|
|
34
|
+
}
|
|
35
|
+
if (date.getTime() >= maxDate.getTime()) {
|
|
36
|
+
return maxDate;
|
|
37
|
+
}
|
|
38
|
+
return date;
|
|
39
|
+
}
|
|
40
|
+
function opcuaJsonDecodeDateTime(pojo) {
|
|
41
|
+
return typeof pojo === "string" ? new Date(pojo) : pojo;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=json_basic_encoding_decoding_date_time.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json_basic_encoding_decoding_date_time.js","sourceRoot":"","sources":["../source/json_basic_encoding_decoding_date_time.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;AAOH,0DASC;AACD,0DAEC;AAjBD,+DAA+C;AAG/C,MAAM,OAAO,GAAG,IAAI,IAAI,CAAC,0BAA0B,CAAC,CAAC;AACrD,MAAM,aAAa,GAAG,IAAI,IAAI,CAAC,0BAA0B,CAAC,CAAC;AAC3D,SAAgB,uBAAuB,CAAC,IAAU,EAAE,OAA2B,EAAE,eAA0B;IACvG,IAAI,IAAI,CAAC,OAAO,EAAE,IAAI,8BAAO,CAAC,OAAO,EAAE,EAAE,CAAC;QACtC,OAAO,aAAa,CAAC;IACzB,CAAC;IACD,IAAI,IAAI,CAAC,OAAO,EAAE,IAAI,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;QACtC,OAAO,OAAO,CAAC;IACnB,CAAC;IAED,OAAO,IAAI,CAAC;AAChB,CAAC;AACD,SAAgB,uBAAuB,CAAC,IAAmB;IACvD,OAAO,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAE,IAAa,CAAC;AACtE,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ==========================================================================
|
|
3
|
+
* Copyright (c) 2021-2026 Sterfive - etienne.rossignon@sterfive.com
|
|
4
|
+
*
|
|
5
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
* in the Software without restriction, including without limitation the rights
|
|
8
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
* furnished to do so, subject to the following conditions:
|
|
11
|
+
*
|
|
12
|
+
* The above copyright notice and this permission notice shall be included in
|
|
13
|
+
* all copies or substantial portions of the Software.
|
|
14
|
+
*
|
|
15
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
16
|
+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
18
|
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
20
|
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
21
|
+
* IN THE SOFTWARE.
|
|
22
|
+
* ==========================================================================
|
|
23
|
+
*/
|
|
24
|
+
import { ExtensionObject } from "node-opcua-extension-object";
|
|
25
|
+
import { type IStructuredTypeSchema } from "node-opcua-factory";
|
|
26
|
+
import type { Pojo } from "./decode_opcua_json.js";
|
|
27
|
+
import { type ExtensionObjectBuilder } from "./json_basic_encoding_body_functor.js";
|
|
28
|
+
import { type NodeIdJSON } from "./json_basic_encoding_decoding_nodeid.js";
|
|
29
|
+
import { JsonEncodingScheme } from "./json_encoding_scheme.js";
|
|
30
|
+
export interface ExtensionObjectJSON104 {
|
|
31
|
+
TypeId: NodeIdJSON;
|
|
32
|
+
Body: Pojo;
|
|
33
|
+
UaTypeId?: never;
|
|
34
|
+
UaBody?: never;
|
|
35
|
+
}
|
|
36
|
+
export interface ExtensionObjectJSON105 {
|
|
37
|
+
UaTypeId: NodeIdJSON;
|
|
38
|
+
UaBody: Pojo;
|
|
39
|
+
TypeId?: never;
|
|
40
|
+
Body?: never;
|
|
41
|
+
}
|
|
42
|
+
export type ExtensionObjectJSON = ExtensionObjectJSON104 | ExtensionObjectJSON105;
|
|
43
|
+
export declare function makeBody(extensionObject: ExtensionObject, scheme: JsonEncodingScheme): Pojo | undefined;
|
|
44
|
+
export declare function opcuaJsonDecodeExtensionObjectBody(schema: IStructuredTypeSchema, body: Pojo, builder: ExtensionObjectBuilder, namespaceArray?: string[]): Pojo | Pojo[];
|
|
45
|
+
export declare function opcuaJsonEncodeExtensionObjectBody(extensionObject: ExtensionObject | null, scheme: JsonEncodingScheme, _namespaceArray?: string[]): ExtensionObjectJSON | Pojo | null | undefined;
|
|
46
|
+
/**
|
|
47
|
+
*
|
|
48
|
+
* ExtensionObject values shall be encoded as a JSON object with the fields shown:
|
|
49
|
+
*
|
|
50
|
+
* JSON Object - Definition for a ExtensionObject
|
|
51
|
+
* Name Description
|
|
52
|
+
* TypeId The NodeId of a DataTypeEncoding Node formatted using the rules in 5.4.2.10.
|
|
53
|
+
* Encoding The format of the Body field encoded as a JSON number.
|
|
54
|
+
* This value is 0 if the body is Structure encoded as a JSON object (see 5.4.6).
|
|
55
|
+
* This value is 1 if the body is a ByteString value encoded as a JSON string (see 5.4.2.8).
|
|
56
|
+
* This value is 2 if the body is a XmlElement value encoded as a JSON string (see 5.4.2.9).
|
|
57
|
+
* This field is omitted if the value is 0.
|
|
58
|
+
* Body Body of the ExtensionObject. The type of this field is specified by the Encoding field.
|
|
59
|
+
* If the Body is empty, the ExtensionObject is NULL and is omitted or encoded as a JSON null.
|
|
60
|
+
*
|
|
61
|
+
* For the non-reversible form, ExtensionObject values shall be encoded as a JSON object containing only
|
|
62
|
+
* the value of the Body field. The TypeId and Encoding fields are dropped.
|
|
63
|
+
*/
|
|
64
|
+
export declare function opcuaJsonEncodeExtensionObject(extensionObject: ExtensionObject | ExtensionObject[] | null, scheme: JsonEncodingScheme, namespaceArray?: string[]): ExtensionObjectJSON | Pojo | (ExtensionObjectJSON | Pojo)[] | null | undefined;
|
|
65
|
+
export declare function opcuaJsonDecodeExtensionObject(_pojo: ExtensionObjectJSON104 | ExtensionObjectJSON105, builder: ExtensionObjectBuilder, namespaceArray: string[]): ExtensionObject | ExtensionObject[] | null;
|