Skip to content

Commit

Permalink
chore(proxy-client) handle enumeration dataType better
Browse files Browse the repository at this point in the history
  • Loading branch information
erossignon committed Apr 14, 2022
1 parent 75e600d commit 052ac6d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/node-opcua-client-proxy/source/object_explorer.ts
Expand Up @@ -20,6 +20,7 @@ import { makeRefId } from "./proxy";
import { UAProxyManager } from "./proxy_manager";
import { ProxyVariable } from "./proxy_variable";
import { MethodDescription, ArgumentEx } from "./proxy_base_node";
import { DataTypeIds } from "node-opcua-constants";

const doDebug = false;
const errorLog = make_errorLog("Proxy");
Expand Down Expand Up @@ -56,13 +57,14 @@ const resultMask = makeResultMask("ReferenceType | IsForward | BrowseName | Node
* });
*
* see also AddressSpace#findCorrespondingBasicDataType
*
* for an enumeration dataType will be DataType.Int32
*/
function convertNodeIdToDataTypeAsync(session: IBasicSession, dataTypeId: NodeId, callback: Callback<DataType>) {
const nodeToRead = {
attributeId: AttributeIds.BrowseName,
nodeId: dataTypeId
};

session.read(nodeToRead, (err: Error | null, dataValue?: DataValue) => {
// istanbul ignore next
if (err) {
Expand All @@ -86,6 +88,14 @@ function convertNodeIdToDataTypeAsync(session: IBasicSession, dataTypeId: NodeId

const dataTypeName = dataValue.value.value;

if (dataTypeId.namespace === 0 && dataTypeId.value === DataTypeIds.Enumeration) {
dataType = DataType.Int32;
setImmediate(() => {
callback(null, dataType);
});
return;
}

if (dataTypeId.namespace === 0 && DataType[dataTypeId.value as number]) {
dataType = (DataType as any)[dataTypeId.value as number] as DataType;
setImmediate(() => {
Expand Down

0 comments on commit 052ac6d

Please sign in to comment.