本文整理汇总了TypeScript中node-opcua-nodeid.resolveNodeId函数的典型用法代码示例。如果您正苦于以下问题:TypeScript resolveNodeId函数的具体用法?TypeScript resolveNodeId怎么用?TypeScript resolveNodeId使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了resolveNodeId函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: it
it(" AddressSpace#findCorrespondingBasicDataType i=13 => DataType.String", () => {
const dataType = addressSpace.findDataType(resolveNodeId("i=12"))!;
dataType.browseName.toString().should.eql("String");
addressSpace.findCorrespondingBasicDataType(dataType).should.eql(DataType.String);
});
开发者ID:node-opcua,项目名称:node-opcua,代码行数:7,代码来源:test_address_space.ts
示例2: browse
public browse(nodesToBrowse: BrowseDescriptionLike | BrowseDescriptionLike[], callback?: ResponseCallback<any>): any {
const isArray = _.isArray(nodesToBrowse);
if (!isArray) {
nodesToBrowse = [nodesToBrowse as BrowseDescriptionLike];
}
const results: BrowseResult[] = [];
for (let browseDescription of nodesToBrowse as any[]) {
browseDescription.referenceTypeId = resolveNodeId(browseDescription.referenceTypeId);
browseDescription = new BrowseDescription(browseDescription);
const nodeId = resolveNodeId(browseDescription.nodeId);
const r = this.addressSpace.browseSingleNode(nodeId, browseDescription);
results.push(r);
}
callback!(null, isArray ? results : results[0]);
}
开发者ID:node-opcua,项目名称:node-opcua,代码行数:16,代码来源:pseudo_session.ts
示例3: constructHookArgument
///
function constructHookArgument(options?: { dataType: any, valueRank?: number, arrayDimensions?: any }): any {
options = options || {dataType: DataType.Null};
let dataType = options.dataType;
if (dataType) {
if (typeof dataType === "string") {
dataType = resolveNodeId(dataType);
} else if (dataType instanceof NodeId) {
// nothing
} else if (dataType.value) {
assert(dataType.hasOwnProperty("namespace"));
dataType = coerceNodeId(dataType.value, dataType.namespace);
} else {
assert(typeof dataType === "number");
}
options.dataType = dataType;
}
if (options.valueRank === undefined) {
options.valueRank = -1;
}
// fix missing ArrayDimension (The value is an array with one dimension.)
if (options.valueRank !== 1 || !options.arrayDimensions) {
options.arrayDimensions = [0];
}
return options;
}
开发者ID:node-opcua,项目名称:node-opcua,代码行数:30,代码来源:imports.ts
示例4: it
it("AddressSpace#addObject should create a 'hasTypeDefinition' reference on node", () => {
const nbReferencesBefore = baseObjectType.findReferencesEx(
"HasTypeDefinition", BrowseDirection.Inverse).length;
const node1 = namespace.addObject({
browseName: "Node1",
typeDefinition: "BaseObjectType"
});
// xx node1.findReferencesEx("References", BrowseDirection.Forward).forEach(dump);
const forwardReferences = node1.findReferencesEx("References", BrowseDirection.Forward);
forwardReferences.length.should.eql(1);
forwardReferences[0].referenceType.should.eql(resolveNodeId("HasTypeDefinition"));
forwardReferences[0].isForward.should.eql(true);
forwardReferences[0].nodeId.should.eql(baseObjectType.nodeId);
const inverseReferences = node1.findReferencesEx("References", BrowseDirection.Inverse);
inverseReferences.length.should.eql(0);
const nbReferencesAfter = baseObjectType.findReferencesEx("HasTypeDefinition", BrowseDirection.Inverse).length;
// xx console.log("",nbReferencesBefore,nbReferencesAfter);
nbReferencesAfter.should.eql(nbReferencesBefore,
"we should have no more inverse references on the BaseObjectType because we " +
"do not add backward reference when reference is HasTypeDefinition");
should(node1.parent).eql(null, "node1 should have no parent");
});
开发者ID:node-opcua,项目名称:node-opcua,代码行数:31,代码来源:test_base_node.ts
示例5: it
it("should add a YArrayItem", () => {
const yArrayItem = namespace.addYArrayItem({
organizedBy: objectsFolder,
browseName: "MyYArrayItem",
title: "My Little YArray Item",
engineeringUnits: standardUnits.degree_celsius,
engineeringUnitsRange: { low: 100, high: 200 },
axisScaleType: "Log",
xAxisDefinition: {
axisScaleType: AxisScaleEnumeration.Linear,
axisSteps: [0, 25, 50, 75, 100],
engineeringUnits: standardUnits.second,
euRange: { low: -10, high: 100 },
title: coerceLocalizedText("the X axis legend"),
},
value: new Variant({
arrayType: VariantArrayType.Array,
dataType: DataType.Float,
value: [1, 2, 3, 2]
})
});
yArrayItem.browseName.toString().should.eql("1:MyYArrayItem");
yArrayItem.dataType.should.eql(resolveNodeId("Float"));
yArrayItem.readValue().value.value.length.should.eql(4);
yArrayItem.readValue().value.value[0].should.eql(1);
yArrayItem.readValue().value.value[1].should.eql(2);
yArrayItem.readValue().value.value[2].should.eql(3);
yArrayItem.readValue().value.value[3].should.eql(2);
yArrayItem.hasOwnProperty("instrumentRange").should.eql(false, "optional instrument Range not expected");
yArrayItem.euRange.readValue().value.value.low.should.eql(100);
yArrayItem.euRange.readValue().value.value.high.should.eql(200);
yArrayItem.title.readValue().value.value.text.should.eql("My Little YArray Item");
// access xAxisDefinition from extension object
const x = yArrayItem.xAxisDefinition.readValue().value.value as AxisInformation;
x.engineeringUnits.should.eql(standardUnits.second);
x.title!.text!.should.eql("the X axis legend");
x.euRange.low.should.eql(-10);
x.euRange.high.should.eql(100);
// xx console.log("xxxx ",yArrayItem.xAxisDefinition.toString())
// xx yArrayItem.xAxisDefinition.euRange.readValue().value.value.should.eql(standardUnits.second);
// xx yArrayItem.xAxisDefinition.engineeringUnits.readValue().value.value.should.eql(standardUnits.second);
});
开发者ID:node-opcua,项目名称:node-opcua,代码行数:60,代码来源:subtest_Y_array_item_type.ts
示例6: extractNamespaceDataType
export async function extractNamespaceDataType(
session: IBasicSession,
dataTypeManager: ExtraDataTypeManager
) {
// read namespace array
const dataValueNamespaceArray = await session.read({
attributeId: AttributeIds.Value,
nodeId: resolveNodeId("Server_NamespaceArray")
});
if (dataValueNamespaceArray.statusCode === StatusCodes.Good) {
dataTypeManager.setNamespaceArray(dataValueNamespaceArray.value.value as string[]);
}
// DatType/OPCBinary => i=93 [OPCBinarySchema_TypeSystem]
const opcBinaryNodeId = resolveNodeId("OPCBinarySchema_TypeSystem");
const nodeToBrowse = {
browseDirection: BrowseDirection.Forward,
includeSubtypes: false,
nodeClassMask: makeNodeClassMask("Variable"),
nodeId: opcBinaryNodeId,
referenceTypeId: resolveNodeId("HasComponent"),
resultMask: makeResultMask("ReferenceType | IsForward | BrowseName | NodeClass | TypeDefinition")
};
const result = await session.browse(nodeToBrowse);
// filter nodes that have the expected namespace Index
const references = result.references!.filter(
(e: ReferenceDescription) => e.nodeId.namespace !== 0);
/* istanbul ignore next */
if (references.length === 0) {
return;
}
for (const ref of references) {
const typeDictionary = await extractSchema(session, ref.nodeId);
await exploreDataTypeDefinition(session, ref.nodeId, typeDictionary, dataTypeManager.namespaceArray);
dataTypeManager.registerTypeDictionary(ref.nodeId, typeDictionary);
}
}
开发者ID:node-opcua,项目名称:node-opcua,代码行数:43,代码来源:client_dynamic_extension_object.ts
示例7: makeNodeClassMask
const nodesToBrowse2 = references.map((ref: ReferenceDescription) => {
return {
browseDirection: BrowseDirection.Inverse,
includeSubtypes: false,
nodeClassMask: makeNodeClassMask("Object | Variable"),
nodeId: ref.nodeId,
referenceTypeId: resolveNodeId("HasDescription"),
resultMask: makeResultMask("NodeId | ReferenceType | BrowseName | NodeClass | TypeDefinition")
};
});
开发者ID:node-opcua,项目名称:node-opcua,代码行数:10,代码来源:client_dynamic_extension_object.ts
示例8: _translateNodeId
function _translateNodeId(nodeId: string): NodeId {
if (alias_map[nodeId]) {
return alias_map[nodeId];
}
const m = nodeId.match(reg);
if (m) {
const namespaceIndex = _translateNamespaceIndex(parseInt(m[1], 10));
nodeId = "ns=" + namespaceIndex + ";" + m[2];
}
return resolveNodeId(nodeId);
}
开发者ID:node-opcua,项目名称:node-opcua,代码行数:11,代码来源:load_nodeset2.ts
示例9: extractEventField
/**
*
* @method extractEventField
* extract a eventField from a event node, matching the given selectClause
* @param eventData
* @param selectClause
*/
function extractEventField(eventData: any, selectClause: SimpleAttributeOperand): Variant {
assert_valid_event_data(eventData);
assert(selectClause instanceof SimpleAttributeOperand);
selectClause.browsePath = selectClause.browsePath || [];
if (selectClause.browsePath.length === 0 && selectClause.attributeId === AttributeIds.NodeId) {
// "ns=0;i=2782" => ConditionType
// "ns=0;i=2041" => BaseEventType
if (selectClause.typeDefinitionId.toString() !== "ns=0;i=2782") {
// not ConditionType
// tslint:disable-next-line:no-console
console.warn("this case is not handled yet : selectClause.typeDefinitionId = " + selectClause.typeDefinitionId.toString());
const eventSource1 = eventData.$eventDataSource;
return new Variant({ dataType: DataType.NodeId, value: eventSource1.nodeId });
}
const conditionTypeNodeId = resolveNodeId("ConditionType");
assert(sameNodeId(selectClause.typeDefinitionId, conditionTypeNodeId));
const eventSource = eventData.$eventDataSource;
const eventSourceTypeDefinition = eventSource.typeDefinitionObj;
if (!eventSourceTypeDefinition) {
// eventSource is a EventType class
return new Variant();
}
const addressSpace = eventSource.addressSpace;
const conditionType = addressSpace.findObjectType(conditionTypeNodeId);
if (!eventSourceTypeDefinition.isSupertypeOf(conditionType)) {
return new Variant();
}
// Yeh : our EventType is a Condition Type !
return new Variant({ dataType: DataType.NodeId, value: eventSource.nodeId });
}
const handle = eventData.resolveSelectClause(selectClause);
if (handle !== null) {
const value = eventData.readValue(handle, selectClause);
assert(value instanceof Variant);
return value;
} else {
// Part 4 - 7.17.3
// A null value is returned in the corresponding event field in the Publish response if the selected
// field is not part of the Event or an error was returned in the selectClauseResults of the EventFilterResult.
// return new Variant({dataType: DataType.StatusCode, value: browsePathResult.statusCode});
return new Variant();
}
}
开发者ID:node-opcua,项目名称:node-opcua,代码行数:60,代码来源:tools_event_filter.ts
示例10: it
it("should dump a browseDescription", (done: any) => {
const browseDescription: BrowseDescriptionOptions = {
browseDirection: BrowseDirection.Both,
includeSubtypes: true,
nodeClassMask: 0, // 0 = all nodes
referenceTypeId: resolveNodeId("HierarchicalReferences"),
resultMask: 0x3F
};
const hr = addressSpace.findReferenceType("HierarchicalReferences")!;
redirectToFile("dumpBrowseDescription.log", () => {
dumpBrowseDescription(hr, browseDescription);
}, done);
});
开发者ID:node-opcua,项目名称:node-opcua,代码行数:17,代码来源:test_browse_node.ts
注:本文中的node-opcua-nodeid.resolveNodeId函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论