本文整理汇总了TypeScript中node-opcua-binary-stream.BinaryStream.readUInt32方法的典型用法代码示例。如果您正苦于以下问题:TypeScript BinaryStream.readUInt32方法的具体用法?TypeScript BinaryStream.readUInt32怎么用?TypeScript BinaryStream.readUInt32使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类node-opcua-binary-stream.BinaryStream
的用法示例。
在下文中一共展示了BinaryStream.readUInt32方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: decodeExtensionObject
export function decodeExtensionObject(stream: BinaryStream): ExtensionObject | null {
const nodeId = decodeNodeId(stream);
const encodingType = stream.readUInt8();
if (encodingType === 0) {
return null;
}
const length = stream.readUInt32();
/* istanbul ignore next */
if (nodeId.value === 0 || encodingType === 0) {
return {} as ExtensionObject;
}
// let verify that decode will use the expected number of bytes
const streamLengthBefore = stream.length;
let object: any;
if (nodeId.namespace !== 0) {
// this is a extension object define in a other namespace
// we can only threat it as an opaque object for the time being
// the caller that may now more about the namespace Array and type
// definition will be able to turn the opaque object into a meaningful
// structure
// lets rewind before the length
stream.length -= 4;
object = new OpaqueStructure(nodeId, stream.readByteStream()!);
} else {
object = constructEmptyExtensionObject(nodeId);
/* istanbul ignore next */
if (object === null) {
// this object is unknown to us ..
stream.length += length;
object = {} as ExtensionObject;
} else {
try {
object.decode(stream);
} catch (err) {
debugLog("Cannot decode object ", err.message);
}
}
}
if (streamLengthBefore + length !== stream.length) {
// this may happen if the server or client do have a different OPCUA version
// for instance SubscriptionDiagnostics structure has been changed between OPCUA version 1.01 and 1.04
// causing 2 extra member to be added.
debugLog(chalk.bgWhiteBright.red("========================================="));
// tslint:disable-next-line:no-console
console.warn("WARNING => Extension object decoding error on ",
object.constructor.name, " expected size was", length,
"but only this amount of bytes have been read :", stream.length - streamLengthBefore);
stream.length = streamLengthBefore + length;
}
return object;
}
示例2: messageHeaderToString
export function messageHeaderToString(messageChunk: Buffer): string {
const stream = new BinaryStream(messageChunk);
const messageHeader = readMessageHeader(stream);
if (messageHeader.msgType === "ERR" || messageHeader.msgType === "HEL") {
return messageHeader.msgType + " " + messageHeader.isFinal + " length = " + messageHeader.length;
}
const securityHeader = chooseSecurityHeader(messageHeader.msgType);
const sequenceHeader = new SequenceHeader();
assert(stream.length === 8);
const channelId = stream.readUInt32();
securityHeader.decode(stream);
sequenceHeader.decode(stream);
const slice = messageChunk.slice(0, stream.length);
return messageHeader.msgType + " " +
messageHeader.isFinal +
" length = " + messageHeader.length +
" channel = " + channelId +
" seqNum = " + sequenceHeader.sequenceNumber +
" req ID = " + sequenceHeader.requestId +
" security = " + securityHeader.toString() +
"\n\n" + hexDump(slice);
}
示例3: readMessageHeader
export function readMessageHeader(stream: BinaryStream): MessageHeader {
const msgType = String.fromCharCode(stream.readUInt8()) +
String.fromCharCode(stream.readUInt8()) +
String.fromCharCode(stream.readUInt8());
const isFinal = String.fromCharCode(stream.readUInt8());
const length = stream.readUInt32();
return {msgType, isFinal, length};
}
示例4: decodeArray
export function decodeArray(stream: BinaryStream, decodeElementFunc: (stream: BinaryStream) => any): any[] | null {
const length = stream.readUInt32();
if (length === 0xffffffff) {
return null;
}
const arr = [];
for (let i = 0; i < length; i++) {
arr.push(decodeElementFunc(stream));
}
return arr;
}
示例5: _read_headers
protected _read_headers(binaryStream: BinaryStream): boolean {
this.messageHeader = readMessageHeader(binaryStream);
assert(binaryStream.length === 8, "expecting message header to be 8 bytes");
this.channelId = binaryStream.readUInt32();
assert(binaryStream.length === 12);
// verifying secure ChannelId
if (this._expectedChannelId && this.channelId !== this._expectedChannelId) {
return this._report_error("Invalid secure channel Id");
}
return true;
}
示例6: _decodeNodeId
function _decodeNodeId(encodingByte: number, stream: BinaryStream): NodeId {
let value;
let namespace;
let nodeIdType;
/*jslint bitwise: true */
encodingByte &= 0x3f; // 1 to 5
switch (encodingByte) {
case EnumNodeIdEncoding.TwoBytes:
value = stream.readUInt8();
nodeIdType = NodeIdType.NUMERIC;
break;
case EnumNodeIdEncoding.FourBytes:
namespace = stream.readUInt8();
value = stream.readUInt16();
nodeIdType = NodeIdType.NUMERIC;
break;
case EnumNodeIdEncoding.Numeric:
namespace = stream.readUInt16();
value = stream.readUInt32();
nodeIdType = NodeIdType.NUMERIC;
break;
case EnumNodeIdEncoding.String:
namespace = stream.readUInt16();
value = decodeString(stream);
nodeIdType = NodeIdType.STRING;
break;
case EnumNodeIdEncoding.ByteString:
namespace = stream.readUInt16();
value = decodeByteString(stream);
nodeIdType = NodeIdType.BYTESTRING;
break;
default:
if (encodingByte !== EnumNodeIdEncoding.Guid) {
/*jslint bitwise: true */
// console.log(" encoding_byte = 0x" + encodingByte.toString(16),
// " bin=", ("0000000000000000" + encodingByte.toString(2)).substr(-16),
// encodingByte, encodingByte & 0x3f);
throw new Error(" encoding_byte = " + encodingByte.toString(16));
}
namespace = stream.readUInt16();
value = decodeGuid(stream);
nodeIdType = NodeIdType.GUID;
assert(isValidGuid(value));
break;
}
return new NodeId(nodeIdType, value, namespace);
}
示例7: decode_array
function decode_array(
fun_decode_element: (stream: BinaryStream) => any,
arr: any[],
stream: BinaryStream
): any[] | null {
const n = stream.readUInt32();
if (n === 0xFFFFFFFF) {
return null;
}
const result = [];
for (let i = 0; i < n; i++) {
result.push(fun_decode_element(stream));
}
return result;
}
示例8: decodeDebug
/**
* @method decodeDebug
*
*/
public decodeDebug(stream: BinaryStream, options: DecodeDebugOptions): void {
const tracer = options.tracer;
const schema = this.schema;
tracer.trace("start", options.name + "(" + schema.name + ")", stream.length, stream.length);
const self: any = this as any;
for (const field of schema.fields) {
const value = self[field.name];
if (field.isArray) {
const cursorBefore = stream.length;
let nb = stream.readUInt32();
if (nb === 0xFFFFFFFF) {
nb = 0;
}
options.name = field.name + [];
tracer.trace("start_array", field.name, nb, cursorBefore, stream.length);
for (let i = 0; i < nb; i++) {
tracer.trace("start_element", field.name, i);
options.name = "element #" + i;
_decode_member_(value, field, stream, options);
tracer.trace("end_element", field.name, i);
}
tracer.trace("end_array", field.name, stream.length - 4);
} else {
options.name = field.name;
_decode_member_(value, field, stream, options);
}
}
tracer.trace("end", schema.name, stream.length, stream.length);
}
示例9: read_UInt32
function read_UInt32() {
return toHex(stream.readUInt32(), 8);
}
示例10: decodeTimestampsToReturn
export function decodeTimestampsToReturn(stream: BinaryStream): TimestampsToReturn {
return clamp(TimestampsToReturn.Source, stream.readUInt32(), TimestampsToReturn.Invalid) as TimestampsToReturn;
}