本文整理汇总了TypeScript中node-opcua-assert.assert函数的典型用法代码示例。如果您正苦于以下问题:TypeScript assert函数的具体用法?TypeScript assert怎么用?TypeScript assert使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了assert函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: 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;
}
开发者ID:node-opcua,项目名称:node-opcua,代码行数:19,代码来源:nodeset_to_xml.ts
示例2: dumpReferencedNodesOld
function dumpReferencedNodesOld(
xw: XmlWriter,
node: BaseNode,
forward: boolean
) {
assert(_.isBoolean(forward));
xw.visitedNode[_hash(node)] = 1;
const nodesToVisit: any = {};
visitUANode(node, nodesToVisit, forward);
for (const el of nodesToVisit.elements) {
if (!xw.visitedNode[_hash(el)]) {
el.dumpXML(xw);
}
}
}
开发者ID:node-opcua,项目名称:node-opcua,代码行数:19,代码来源:nodeset_to_xml.ts
示例3: _post_process_current_chunk
private _post_process_current_chunk() {
let extraEncryptionBytes = 0;
// add padding bytes if needed
if (this.plainBlockSize > 0) {
// write padding ( if encryption )
// let's calculate curLength = the length of the block to encrypt without padding yet
// +---------------+---------------+-------------+---------+--------------+------------+
// |SequenceHeader | data | paddingByte | padding | extraPadding | signature |
// +---------------+---------------+-------------+---------+--------------+------------+
let curLength = this.sequenceHeaderSize + this.cursor + this.signatureLength;
if (this.plainBlockSize > 256) {
curLength += 2; // account for extraPadding Byte Number;
} else {
curLength += 1;
}
// let's calculate the required number of padding bytes
const n = (curLength % this.plainBlockSize);
const nbPaddingByteTotal = (this.plainBlockSize - n) % this.plainBlockSize;
this._write_padding_bytes(nbPaddingByteTotal);
const adjustedLength = this.sequenceHeaderSize + this.cursor + this.signatureLength;
assert(adjustedLength % this.plainBlockSize === 0);
const nbBlock = adjustedLength / this.plainBlockSize;
extraEncryptionBytes = nbBlock * (this.cipherBlockSize - this.plainBlockSize);
}
this.dataEnd = this.dataOffset + this.cursor;
// calculate the expected length of the chunk, once encrypted if encryption apply
const expectedLength = this.dataEnd + this.signatureLength + extraEncryptionBytes;
this.pendingChunk = this.chunk!.slice(0, expectedLength);
// note :
// - this.pending_chunk has the correct size but is not signed nor encrypted yet
// as we don't know what to write in the header yet
// - as a result,
this.chunk = null;
this.cursor = 0;
}
开发者ID:node-opcua,项目名称:node-opcua,代码行数:43,代码来源:chunk_manager.ts
示例4: assert
this.withSession(endpointUrl, (session: ClientSession, done: (err?: Error) => void) => {
assert(_.isFunction(done));
const subscription = new ClientSubscriptionImpl(session as ClientSessionImpl, subscriptionParameters);
try {
innerFunc(session, subscription, (err?: Error) => {
subscription.terminate((err1?: Error) => {
done(err1);
});
});
} catch (err) {
debugLog(err);
done(err);
}
}, callback);
开发者ID:node-opcua,项目名称:node-opcua,代码行数:19,代码来源:opcua_client_impl.ts
示例5: _historyReadRawAsync
function _historyReadRawAsync(
this: UAVariable,
historyReadRawModifiedDetails: ReadRawModifiedDetails,
maxNumberToExtract: number,
isReversed: boolean,
reverseDataValue: boolean,
callback: Callback<DataValue[]>
) {
assert(callback instanceof Function);
const node = this;
node.varHistorian!.extractDataValues(
historyReadRawModifiedDetails,
maxNumberToExtract,
isReversed,
reverseDataValue,
callback);
}
开发者ID:node-opcua,项目名称:node-opcua,代码行数:19,代码来源:address_space_historical_data_node.ts
示例6: getMiniAddressSpace
export function getMiniAddressSpace(...args: any[]): any {
const callback = args[0] as (err: Error | null, addressSpace?: AddressSpace) => void;
const addressSpace = AddressSpace.create();
// register namespace 1 (our namespace);
const serverNamespace = addressSpace.registerNamespace("http://MYNAMESPACE");
assert(serverNamespace.index === 1);
generateAddressSpace(addressSpace, get_mini_nodeset_filename(), (err?: Error) => {
// istanbul ignore next
if (err) {
// tslint:disable:no-console
console.log("err =", err);
}
callback(err || null, addressSpace);
});
}
开发者ID:node-opcua,项目名称:node-opcua,代码行数:19,代码来源:get_mini_address_space.ts
示例7: debugLog
this._mockTransport.server.on("data", (data: Buffer) => {
let reply = this._replies[this._counter];
this._counter++;
if (reply) {
if (_.isFunction(reply)) {
reply = reply.call(this);
// console.log(" interpreting reply as a function" + reply);
if (!reply) {
return;
}
}
debugLog("\nFAKE SERVER RECEIVED");
debugLog(hexDump(data));
let replies = [];
if (reply instanceof Buffer) {
replies.push(reply);
} else {
replies = reply;
}
assert(replies.length >= 1, " expecting at least one reply " + JSON.stringify(reply));
replies.forEach((reply1: any) => {
debugLog("\nFAKE SERVER SEND");
debugLog(chalk.red(hexDump(reply1)));
this._mockTransport.server.write(reply1);
});
} else {
const msg = " MockServerTransport has no more packets to send to client to" +
" emulate server responses.... ";
console.log(chalk.red.bold(msg));
console.log(chalk.blue.bold(hexDump(data)));
display_trace_from_this_projet_only();
analyseExtensionObject(data, 0, 0, {});
this.emit("done");
}
});
开发者ID:node-opcua,项目名称:node-opcua,代码行数:42,代码来源:mock_transport.ts
示例8: _acknowledge_branch
public _acknowledge_branch(
eventId: Buffer,
comment: string | LocalizedTextLike | LocalizedText,
branch: ConditionSnapshot,
message: string
) {
assert(typeof (message) === "string");
const conditionNode = this;
if (conditionNode.confirmedState) {
// alarm has a confirmed state !
// we should be waiting for confirmation now
branch.setConfirmedState(false);
branch.setRetain(true);
} else {
branch.setRetain(false);
}
const statusCode = _setAckedState(branch, true, eventId, comment);
if (statusCode !== StatusCodes.Good) {
return statusCode;
}
branch.setComment(comment);
conditionNode.raiseNewBranchState(branch);
// xx conditionNode._raiseAuditConditionCommentEvent("Method/Acknowledge",eventId,comment);
conditionNode._raiseAuditConditionAcknowledgeEvent(branch);
/**
* @event acknowledged
* @param eventId {Buffer|null}
* @param comment {LocalizedText}
* @param branch {ConditionSnapshot}
* raised when the alarm branch has been acknowledged
*/
conditionNode.emit("acknowledged", eventId, comment, branch);
}
开发者ID:node-opcua,项目名称:node-opcua,代码行数:42,代码来源:ua_acknowledgeable_condition_base.ts
示例9: setDeprecated
export function setDeprecated(constructor: Function, methodName: string, helpString: string): void {
const oldMethod = constructor.prototype[methodName];
assert(oldMethod instanceof Function,
"expecting a valid " + methodName + "method on class " + constructor.constructor.name);
let counter = 0;
constructor.prototype[methodName] = function() {
if (counter % 1000 === 0) {
// tslint:disable:no-console
console.log(chalk.green("Warning !"),
chalk.green(chalk.bold(constructor.name + "#" + methodName), " is now deprecated"));
console.log(" ", helpString);
}
counter++;
return oldMethod.apply(this, arguments);
};
}
开发者ID:node-opcua,项目名称:node-opcua,代码行数:20,代码来源:set_deprecated.ts
示例10: _start_one_time_message_receiver
private _start_one_time_message_receiver() {
assert(!this._timerId, "timer already started");
// Setup timeout detection timer ....
this._timerId = setTimeout(() => {
this._timerId = null;
this._fulfill_pending_promises(
new Error(`Timeout in waiting for data on socket ( timeout was = ${this.timeout} ms)`));
}, this.timeout);
// also monitored
if (this._socket) {
// to do = intercept socket error as well
this._on_error_during_one_time_message_receiver = (err?: Error) => {
this._fulfill_pending_promises(
new Error(`ERROR in waiting for data on socket ( timeout was = ${this.timeout} ms)`));
};
this._socket.on("close", this._on_error_during_one_time_message_receiver);
}
}
开发者ID:node-opcua,项目名称:node-opcua,代码行数:20,代码来源:tcp_transport.ts
注:本文中的node-opcua-assert.assert函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论