How to use the node-opcua-debug.make_debugLog function in node-opcua-debug

To help you get started, we’ve selected a few node-opcua-debug examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github node-opcua / node-opcua / packages / node-opcua-server / source / server_publish_engine.ts View on Github external
*/
// tslint:disable:no-console
import * as chalk from "chalk";
import { EventEmitter } from "events";
import * as _ from "underscore";

import { assert } from "node-opcua-assert";
import { checkDebugFlag, make_debugLog } from "node-opcua-debug";
import { ObjectRegistry } from "node-opcua-object-registry";
import { StatusCode, StatusCodes } from "node-opcua-status-code";

import { PublishRequest, PublishResponse, SubscriptionAcknowledgement } from "node-opcua-types";
import { Subscription } from "./server_subscription";
import { SubscriptionState } from "./server_subscription";

const debugLog = make_debugLog(__filename);
const doDebug = checkDebugFlag(__filename);

function traceLog(...args: [any?, ...any[]]) {
    if (!doDebug) {
        return;
    }
    const a: string[] = args.map((x?: any) => x!);
    a.unshift(chalk.yellow(" TRACE "));
    console.log.apply(null, a as [any?, ...any[]]);
}

export interface ServerSidePublishEngineOptions {
    maxPublishRequestInQueue?: number;
}

interface PublishData {
github node-opcua / node-opcua / packages / node-opcua-extension-object / source / extension_object.ts View on Github external
/**
 * @module node-opcua-extension-object
 */
import { decodeNodeId, encodeNodeId } from "node-opcua-basic-types";
import { BinaryStream, OutputBinaryStream } from "node-opcua-binary-stream";
import { checkDebugFlag, hexDump, make_debugLog } from "node-opcua-debug";
import {
    BaseUAObject,
    constructObject,
    is_internal_id,
    registerBuiltInType,
    StructuredTypeSchema
} from "node-opcua-factory";
import { ExpandedNodeId, makeNodeId, NodeId } from "node-opcua-nodeid";

const debugLog = make_debugLog(__filename);

import * as chalk from "chalk";

/* tslint:disable:no-empty */
export class ExtensionObject extends BaseUAObject {

    public static schema: StructuredTypeSchema = new StructuredTypeSchema({
        baseType: "",
        documentation: "",
        fields: [],
        name: "ExtensionObject"
    });

    constructor(options: any) {
        super();
    }
github node-opcua / node-opcua / packages / node-opcua-service-discovery / source / bonjour.ts View on Github external
/**
 * @module node-opcua-service-discovery
 */
// tslint:disable:no-console
import * as bonjour from "bonjour";
import * as   _ from "underscore";
import { callbackify } from "util";
import { promisify } from "util";

import { assert } from "node-opcua-assert";
import { checkDebugFlag, make_debugLog } from "node-opcua-debug";

const debugLog = make_debugLog(__filename);
const doDebug = checkDebugFlag(__filename);

let gBonjour: bonjour.Bonjour | undefined;
let gBonjourRefCount = 0;

export function acquireBonjour(): bonjour.Bonjour {
    if (gBonjourRefCount === 0) {
        // will start the Bonjour service
        gBonjour = bonjour();
    }
    gBonjourRefCount++;
    return gBonjour!;
}

export function releaseBonjour() {
    gBonjourRefCount--;
github node-opcua / node-opcua / packages / node-opcua-generator / source / generator.ts View on Github external
* @module node-opcua-generator
 */
// tslint:disable:max-line-length
// tslint:disable:no-console
import * as fs from "fs";
import * as path from "path";
import * as ts from "typescript";
import { promisify } from "util";

import { assert } from "node-opcua-assert";
import { checkDebugFlag, make_debugLog } from "node-opcua-debug";
import { ConstructorFunc } from "node-opcua-factory";

import { get_class_tscript_filename, produce_tscript_code } from "./factory_code_generator";

const debugLog = make_debugLog(__filename);
const doDebug = checkDebugFlag(__filename);

const fileExists = promisify(fs.exists);
const mkdir = promisify(fs.mkdir);

/**
 * @module opcua.miscellaneous
 * @class Factory
 * @static
 */

function compileTscriptCode(typescriptFilename: string): string {

    const content = fs.readFileSync(typescriptFilename, "ascii");

    const compilerOptions = {
github node-opcua / node-opcua / packages / node-opcua-factory / source / datatype_factory.ts View on Github external
* @module node-opcua-factory
 */
// tslint:disable:no-console
import * as chalk from "chalk";
import * as  _ from "underscore";

import { assert } from "node-opcua-assert";
import { checkDebugFlag, make_debugLog } from "node-opcua-debug";
import { ExpandedNodeId } from "node-opcua-nodeid";

import { BaseUAObject } from "./factories_baseobject";
import { ConstructorFuncWithSchema, ConstructorFunc } from "./constructor_type";
import { StructuredTypeSchema } from "./factories_structuredTypeSchema";


const debugLog = make_debugLog(__filename);
const doDebug = checkDebugFlag(__filename);


export class DataTypeFactory {
    
    public defaultByteOrder: string; 
    public targetNamespace: string;
    public imports: string[] = [];

    private _structureTypeConstructorByNameMap: { [ key: string ]: ConstructorFuncWithSchema } = {};
    private _structureTypeConstructorByEncodingNodeIdMap: any = {};
    private baseDataFactories: DataTypeFactory[];

    public constructor(baseDataFactories: DataTypeFactory[]){
        this.defaultByteOrder = "LittleEndian";
        this.targetNamespace = "";
github node-opcua / node-opcua / packages / node-opcua-address-space / src / alarms_and_conditions / ua_condition_base.ts View on Github external
import { StatusCode, StatusCodes } from "node-opcua-status-code";
import { TimeZoneDataType } from "node-opcua-types";
import { DataType, Variant, VariantLike } from "node-opcua-variant";
import { ConditionType, Namespace, SessionContext, UAEventType, UAMethod, UAVariableT } from "../../source";
import { ConditionInfoOptions } from "../../source/interfaces/alarms_and_conditions/condition_info_i";
import { AddressSpacePrivate } from "../address_space_private";
import { BaseNode } from "../base_node";
import { UAObject } from "../ua_object";
import { UAObjectType } from "../ua_object_type";
import { _install_TwoStateVariable_machinery, UATwoStateVariable } from "../ua_two_state_variable";
import { UAVariable } from "../ua_variable";
import { BaseEventType } from "./base_event_type";
import { ConditionInfo } from "./condition_info";
import { ConditionSnapshot } from "./condition_snapshot";

const debugLog = make_debugLog(__filename);
const errorLog = make_errorLog(__filename);
const doDebug = checkDebugFlag(__filename);

export interface UAConditionBase extends BaseEventType {

    on(
      eventName: string,
      eventHandler: (...args: any[]) => void
    ): this;

    // -- Events
    on(
      eventName: "addComment",
      eventHandler: (
        eventId: Buffer | null,
        comment: LocalizedText,
github node-opcua / node-opcua / packages / node-opcua-server / source / monitored_item.ts View on Github external
isOutsideDeadbandAbsolute, isOutsideDeadbandNone, isOutsideDeadbandPercent,
  PseudoRange
} from "node-opcua-service-subscription";
import { StatusCode, StatusCodes } from "node-opcua-status-code";
import { EventFieldList, MonitoringFilter, ReadValueIdOptions, SimpleAttributeOperand } from "node-opcua-types";
import { sameVariant, Variant } from "node-opcua-variant";

import { appendToTimer, removeFromTimer } from "./node_sampler";
import { validateFilter } from "./validate_filter";

const defaultItemToMonitor: ReadValueIdOptions = new ReadValueId({
  attributeId: AttributeIds.Value,
  indexRange: undefined,
});

const debugLog = make_debugLog(__filename);
const doDebug = checkDebugFlag(__filename);

function _adjust_sampling_interval(samplingInterval: number, node_minimumSamplingInterval: number): number {

  assert(_.isNumber(node_minimumSamplingInterval), "expecting a number");

  if (samplingInterval === 0) {
    return (node_minimumSamplingInterval === 0)
      ? samplingInterval
      : Math.max(MonitoredItem.minimumSamplingInterval, node_minimumSamplingInterval);
  }
  assert(samplingInterval >= 0, " this case should have been prevented outside");
  samplingInterval = samplingInterval || MonitoredItem.defaultSamplingInterval;
  samplingInterval = Math.max(samplingInterval, MonitoredItem.minimumSamplingInterval);
  samplingInterval = Math.min(samplingInterval, MonitoredItem.maximumSamplingInterval);
  samplingInterval = node_minimumSamplingInterval === 0
github node-opcua / node-opcua / packages / node-opcua-client / src / client_session.js View on Github external
const makeResultMask = require("node-opcua-data-model").makeResultMask;
const BrowseDirection = require("node-opcua-data-model").BrowseDirection;
const makeNodeClassMask = require("node-opcua-data-model").makeNodeClassMask;

const subscription_service = require("node-opcua-service-subscription");
const read_service = require("node-opcua-service-read");
const historizing_service = require("node-opcua-service-history");
const browse_service = require("node-opcua-service-browse");
const write_service = require("node-opcua-service-write");
const utils = require("node-opcua-utils");
const call_service = require("node-opcua-service-call");
const translate_service = require("node-opcua-service-translate-browse-path");

const BrowseResult = require("node-opcua-service-browse").BrowseResult;

const debugLog = require("node-opcua-debug").make_debugLog(__filename);
const doDebug = require("node-opcua-debug").checkDebugFlag(__filename);
const helpAPIChange = process.env.DEBUG && process.env.DEBUG.match(/API/);

const getFunctionParameterNames = require("node-opcua-utils").getFunctionParameterNames;

/**
 * @class ClientSession
 * @param client {OPCUAClient}
 * @constructor
 */
function ClientSession(client) {
    this._closeEventHasBeenEmmitted = false;
    this._client = client;
    this._publishEngine = null;
    this._closed = false;
}
github node-opcua / node-opcua / packages / node-opcua-server-configuration / source / server / install_push_certitifate_management.ts View on Github external
} from "node-opcua-hostname";
import {
    ICertificateKeyPairProvider
} from "node-opcua-secure-channel";
import {
    OPCUAServer, OPCUAServerEndPoint
} from "node-opcua-server";
import {
    ApplicationDescriptionOptions
} from "node-opcua-types";
import {
    installPushCertificateManagement
} from "../push_certificate_manager_helpers";
import { ActionQueue } from "./push_certificate_manager_server_impl";

const debugLog = make_debugLog("ServerConfiguration");
const errorLog = make_errorLog("ServerConfiguration");
const doDebug = checkDebugFlag("ServerConfiguration");

export interface OPCUAServerPartial extends ICertificateKeyPairProvider {
    serverInfo?: ApplicationDescriptionOptions;
    serverCertificateManager: OPCUACertificateManager;
    $$privateKeyPEM: PrivateKeyPEM;
    $$certificate?: Certificate;
    $$certificateChain: Certificate;
}

function getCertificate(this: OPCUAServerPartial): Certificate {
    if (!this.$$certificate) {
        const certificateChain = getCertificateChain.call(this);
        this.$$certificate = split_der(certificateChain)[0];
    }
github node-opcua / node-opcua / packages / node-opcua-server / src / opcua_server.js View on Github external
const async = require("async");
const util = require("util");
const fs = require("fs");
const _ = require("underscore");

const ApplicationType = require("node-opcua-service-endpoints").ApplicationType;

const StatusCodes = require("node-opcua-status-code").StatusCodes;
const SessionContext = require("node-opcua-address-space").SessionContext;
const fromURI = require("node-opcua-secure-channel").fromURI;
const SecurityPolicy = require("node-opcua-secure-channel").SecurityPolicy;

const MessageSecurityMode = require("node-opcua-service-secure-channel").MessageSecurityMode;

const utils = require("node-opcua-utils");
const debugLog = require("node-opcua-debug").make_debugLog(__filename);
const forceGarbageCollectionOnSessionClose = false;

const ServerEngine = require("./server_engine").ServerEngine;


const browse_service = require("node-opcua-service-browse");
const read_service = require("node-opcua-service-read");
const write_service = require("node-opcua-service-write");
const historizing_service = require("node-opcua-service-history");
const subscription_service = require("node-opcua-service-subscription");
const translate_service = require("node-opcua-service-translate-browse-path");
const session_service = require("node-opcua-service-session");
const register_node_service = require("node-opcua-service-register-node");
const call_service = require("node-opcua-service-call");
const endpoints_service = require("node-opcua-service-endpoints");
const query_service = require("node-opcua-service-query");