本文整理汇总了TypeScript中node-opcua-nodeid.NodeId类的典型用法代码示例。如果您正苦于以下问题:TypeScript NodeId类的具体用法?TypeScript NodeId怎么用?TypeScript NodeId使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了NodeId类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: n
function n(nodeId: NodeId | null) {
if (!nodeId || nodeId.isEmpty()) {
return "";
}
const node = addressSpace.findNode(nodeId)!;
return "\"" + nodeId.toString() +
"\"" + chalk.yellow(" /* " + (node ? node.browseName.toString() : "???") + " */");
}
示例2: toString
/**
* turn reference into a arrow : ---- ReferenceType --> [NodeId]
* @method toString
* @return {String}
*/
public toString(options?: { addressSpace?: any }): string {
let infoNode = _w(this.nodeId.toString(), 24);
let refType = this.referenceType.toString();
if (options && options.addressSpace) {
const node = options.addressSpace.findNode(this.nodeId);
infoNode = "[" + infoNode + "]" + _w(node.browseName.toString(), 40);
const ref = options.addressSpace.findReferenceType(this.referenceType);
refType += "[" + ref.nodeId.toString() + "]";
}
return _arrow(refType, 40, this.isForward) + infoNode;
}
示例3: return
return (objectId: NodeId, methodId: NodeId) => {
const response = getMethodDeclaration_ArgumentList(the_address_space, objectId, methodId);
/* istanbul ignore next */
if (response.statusCode !== StatusCodes.Good) {
console.log(" StatusCode = " + response.statusCode.toString());
throw new Error("Invalid Method " + response.statusCode.toString() +
" ObjectId= " + objectId.toString() + "Method Id =" + methodId.toString());
}
const methodDeclaration = response.methodDeclaration;
// verify input Parameters
const methodInputArguments = methodDeclaration.getInputArguments();
assert(_.isArray(methodInputArguments));
return methodInputArguments;
};
示例4: findDataTypeNode
function findDataTypeNode(addressSpace: AddressSpace, encodingNodeId: NodeId): UADataType {
const encodingNode = addressSpace.findNode(encodingNodeId)!;
// istanbul ignore next
if (!encodingNode) {
throw new Error("findDataTypeNode: Cannot find " + encodingNodeId.toString());
}
// xx console.log("encodingNode", encodingNode.toString());
const refs = encodingNode.findReferences("HasEncoding", false);
const dataTypes = refs
.map((ref) => addressSpace.findNode(ref.nodeId))
.filter((obj: any) => obj !== null);
// istanbul ignore next
if (dataTypes.length !== 1) {
throw new Error("Internal Error");
}
const dataTypeNode = dataTypes[0] as UADataType;
// istanbul ignore next
if (dataTypeNode.nodeClass !== NodeClass.DataType) {
throw new Error("internal error: expecting a UADataType node here");
}
return dataTypeNode;
}
示例5: nodeIdInfo
function nodeIdInfo(
addressSpace: AddressSpace,
nodeId: NodeId
): string {
const obj = addressSpace.findNode(nodeId);
const name = obj ? obj.browseName.toString() : " <????>";
return nodeId.toString() + " [ " + name + " ]";
}
示例6: nodeID_encodingByte
function nodeID_encodingByte(nodeId: NodeId): number {
if (!nodeId) {
return 0;
}
assert(nodeId.hasOwnProperty("identifierType"));
let encodingByte = 0;
if (nodeId.identifierType === NodeIdType.NUMERIC) {
if (isUInt8(nodeId.value as number) &&
!nodeId.namespace &&
!(nodeId as ExpandedNodeId).namespaceUri &&
!(nodeId as ExpandedNodeId).serverIndex) {
encodingByte = encodingByte | EnumNodeIdEncoding.TwoBytes;
} else if (
isUInt16(nodeId.value as number) &&
isUInt8(nodeId.namespace) &&
!(nodeId as ExpandedNodeId).namespaceUri &&
!(nodeId as ExpandedNodeId).serverIndex
) {
encodingByte = encodingByte | EnumNodeIdEncoding.FourBytes;
} else {
encodingByte = encodingByte | EnumNodeIdEncoding.Numeric;
}
} else if (nodeId.identifierType === NodeIdType.STRING) {
encodingByte = encodingByte | EnumNodeIdEncoding.String;
} else if (nodeId.identifierType === NodeIdType.BYTESTRING) {
encodingByte = encodingByte | EnumNodeIdEncoding.ByteString;
} else if (nodeId.identifierType === NodeIdType.GUID) {
encodingByte = encodingByte | EnumNodeIdEncoding.Guid;
}
if (nodeId.hasOwnProperty("namespaceUri") && (nodeId as ExpandedNodeId).namespaceUri) {
encodingByte = encodingByte | EnumNodeIdEncoding.NamespaceUriFlag;
}
if (nodeId.hasOwnProperty("serverIndex") && (nodeId as ExpandedNodeId).serverIndex) {
encodingByte = encodingByte | EnumNodeIdEncoding.ServerIndexFlag;
}
return encodingByte;
}
示例7: resolveDataTypeName
function resolveDataTypeName(
addressSpace: AddressSpacePrivate,
dataType: string | NodeId
): QualifiedName {
let dataTypeNode = null;
// istanbul ignore next
if (_.isString(dataType)) {
dataTypeNode = addressSpace.findDataType(dataType);
} else {
assert(dataType instanceof NodeId);
const o = addressSpace.findNode(dataType.toString());
dataTypeNode = o ? o : null;
}
if (!dataTypeNode) {
throw new Error("Cannot find dataTypeName " + dataType);
}
return dataTypeNode.browseName;
}
示例8: getMethodDeclaration_ArgumentList
export function getMethodDeclaration_ArgumentList(
addressSpace: AddressSpace,
objectId: NodeId,
methodId: NodeId
): any {
assert(objectId instanceof NodeId);
assert(methodId instanceof NodeId);
// find object in address space
const obj = addressSpace.findNode(objectId) as UAObject;
if (!obj) {
// istanbul ignore next
if (doDebug) {
console.warn("cannot find node ", objectId.toString());
}
return { statusCode: StatusCodes.BadNodeIdUnknown };
}
if (!obj.hasMethods) {
return { statusCode: StatusCodes.BadNodeIdInvalid };
}
let objectMethod = obj.getMethodById(methodId) as UAMethod;
if (!objectMethod) {
// the method doesn't belong to the object, nevertheless
// the method can be called
objectMethod = addressSpace.findNode(methodId) as UAMethod;
if (!objectMethod || objectMethod.nodeClass !== NodeClass.Method) {
return { statusCode: StatusCodes.BadMethodInvalid };
}
}
const methodDeclarationId = (objectMethod as any).methodDeclarationId;
const methodDeclaration = addressSpace.findNode(methodDeclarationId);
if (!methodDeclaration) {
// return {statusCode: StatusCodes.BadMethodInvalid};
return { statusCode: StatusCodes.Good, methodDeclaration: objectMethod };
}
return { statusCode: StatusCodes.Good, methodDeclaration };
}
示例9: toString
public toString(): string {
const str =
"/* OpaqueStructure */ { \n" +
"nodeId " + this.nodeId.toString() + "\n" +
"buffer = \n" + hexDump(this.buffer) + "\n" +
"}";
return str;
}
示例10:
return references.filter((r: UAReference) => r.nodeId.toString() === nodeId.toString());