|
14 | 14 | ********************************************************************************/ |
15 | 15 |
|
16 | 16 | import { Subscription } from "rxjs/Subscription"; |
17 | | -import { promisify } from "util"; |
18 | 17 | import { Readable } from "stream"; |
19 | 18 | import { URL } from "url"; |
20 | 19 | import { |
@@ -49,18 +48,19 @@ import { |
49 | 48 | import { |
50 | 49 | AnonymousIdentity, |
51 | 50 | ArgumentDefinition, |
| 51 | + findBasicDataType, |
52 | 52 | getBuiltInDataType, |
53 | 53 | readNamespaceArray, |
54 | 54 | UserIdentityInfo, |
55 | 55 | } from "node-opcua-pseudo-session"; |
56 | | -import { makeNodeId, NodeId, NodeIdLike, NodeIdType, resolveNodeId } from "node-opcua-nodeid"; |
57 | | -import { AttributeIds, BrowseDirection, makeResultMask } from "node-opcua-data-model"; |
| 56 | +import { NodeId, NodeIdLike, resolveNodeId } from "node-opcua-nodeid"; |
| 57 | +import { AttributeIds } from "node-opcua-data-model"; |
58 | 58 | import { makeBrowsePath } from "node-opcua-service-translate-browse-path"; |
59 | 59 | import { StatusCodes } from "node-opcua-status-code"; |
60 | 60 | import { coercePrivateKeyPem, readPrivateKey } from "node-opcua-crypto"; |
61 | 61 | import { opcuaJsonEncodeVariant } from "node-opcua-json"; |
62 | | -import { Argument, BrowseDescription, BrowseResult, MessageSecurityMode, UserTokenType } from "node-opcua-types"; |
63 | | -import { isGoodish2, ReferenceTypeIds } from "node-opcua"; |
| 62 | +import { Argument, MessageSecurityMode, UserTokenType } from "node-opcua-types"; |
| 63 | +import { isGoodish2 } from "node-opcua"; |
64 | 64 |
|
65 | 65 | import { schemaDataValue } from "./codec"; |
66 | 66 | import { OPCUACAuthenticationScheme, OPCUAChannelSecurityScheme } from "./security-scheme"; |
@@ -101,46 +101,6 @@ interface OPCUAConnectionEx extends OPCUAConnection { |
101 | 101 | pending?: Resolver[]; |
102 | 102 | } |
103 | 103 |
|
104 | | -export function findBasicDataTypeC( |
105 | | - session: IBasicSession, |
106 | | - dataTypeId: NodeId, |
107 | | - callback: (err: Error | null, dataType?: DataType) => void |
108 | | -): void { |
109 | | - const resultMask = makeResultMask("ReferenceType"); |
110 | | - |
111 | | - if (dataTypeId.identifierType === NodeIdType.NUMERIC && Number(dataTypeId.value) <= 25) { |
112 | | - // we have a well-known DataType |
113 | | - callback(null, dataTypeId.value as DataType); |
114 | | - } else { |
115 | | - // let's browse for the SuperType of this object |
116 | | - const nodeToBrowse = new BrowseDescription({ |
117 | | - browseDirection: BrowseDirection.Inverse, |
118 | | - includeSubtypes: false, |
119 | | - nodeId: dataTypeId, |
120 | | - referenceTypeId: makeNodeId(ReferenceTypeIds.HasSubtype), |
121 | | - resultMask, |
122 | | - }); |
123 | | - |
124 | | - session.browse(nodeToBrowse, (err: Error | null, browseResult?: BrowseResult) => { |
125 | | - /* istanbul ignore next */ |
126 | | - if (err) { |
127 | | - return callback(err); |
128 | | - } |
129 | | - |
130 | | - /* istanbul ignore next */ |
131 | | - if (!browseResult) { |
132 | | - return callback(new Error("Internal Error")); |
133 | | - } |
134 | | - |
135 | | - browseResult.references = browseResult.references ?? /* istanbul ignore next */ []; |
136 | | - const baseDataType = browseResult.references[0].nodeId; |
137 | | - return findBasicDataTypeC(session, baseDataType, callback); |
138 | | - }); |
139 | | - } |
140 | | -} |
141 | | -const findBasicDataType: (session: IBasicSession, dataTypeId: NodeId) => Promise<DataType | undefined> = |
142 | | - promisify(findBasicDataTypeC); |
143 | | - |
144 | 104 | function _variantToJSON(variant: Variant, contentType: string) { |
145 | 105 | contentType = contentType.split(";")[0]; |
146 | 106 |
|
|
0 commit comments