Skip to content

Commit 100a9fd

Browse files
committed
chore(binding-opcua): remove redundant findBasicDataType
1 parent 8dc6ed8 commit 100a9fd

File tree

1 file changed

+5
-45
lines changed

1 file changed

+5
-45
lines changed

packages/binding-opcua/src/opcua-protocol-client.ts

Lines changed: 5 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
********************************************************************************/
1515

1616
import { Subscription } from "rxjs/Subscription";
17-
import { promisify } from "util";
1817
import { Readable } from "stream";
1918
import { URL } from "url";
2019
import {
@@ -49,18 +48,19 @@ import {
4948
import {
5049
AnonymousIdentity,
5150
ArgumentDefinition,
51+
findBasicDataType,
5252
getBuiltInDataType,
5353
readNamespaceArray,
5454
UserIdentityInfo,
5555
} 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";
5858
import { makeBrowsePath } from "node-opcua-service-translate-browse-path";
5959
import { StatusCodes } from "node-opcua-status-code";
6060
import { coercePrivateKeyPem, readPrivateKey } from "node-opcua-crypto";
6161
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";
6464

6565
import { schemaDataValue } from "./codec";
6666
import { OPCUACAuthenticationScheme, OPCUAChannelSecurityScheme } from "./security-scheme";
@@ -101,46 +101,6 @@ interface OPCUAConnectionEx extends OPCUAConnection {
101101
pending?: Resolver[];
102102
}
103103

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-
144104
function _variantToJSON(variant: Variant, contentType: string) {
145105
contentType = contentType.split(";")[0];
146106

0 commit comments

Comments
 (0)