Skip to content

Commit

Permalink
BaseNode: expose setDescription and setDisplayName
Browse files Browse the repository at this point in the history
  • Loading branch information
erossignon committed Jul 23, 2023
1 parent dc706ce commit c789a36
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
3 changes: 2 additions & 1 deletion packages/node-opcua-address-space-base/source/base_node.ts
Expand Up @@ -256,5 +256,6 @@ export declare class BaseNode extends EventEmitter {
*/
getAggregates(): BaseNode[];

setDescription(description: LocalizedTextLike): void;
public setDisplayName(value: LocalizedTextLike[] | LocalizedTextLike): void;
public setDescription(value: LocalizedTextLike| null): void;
}
9 changes: 6 additions & 3 deletions packages/node-opcua-address-space/src/base_node_impl.ts
Expand Up @@ -178,7 +178,11 @@ export class BaseNodeImpl extends EventEmitter implements BaseNode {
return _private._displayName;
}

public setDisplayName(value: LocalizedText[]): void {

public setDisplayName(value: LocalizedTextLike[] | LocalizedTextLike): void {
if (!Array.isArray(value)) {
return this.setDisplayName([value]);
}
this._setDisplayName(value);
/**
* fires when the displayName is changed.
Expand All @@ -193,8 +197,7 @@ export class BaseNodeImpl extends EventEmitter implements BaseNode {
return _private._description!;
}

public setDescription(value: LocalizedTextLike): void {

public setDescription(value: LocalizedTextLike| null): void {
this._setDescription(value);
/**
* fires when the description attribute is changed.
Expand Down
Expand Up @@ -30,12 +30,15 @@ import {
UAVariable,
ContinuationData
} from "node-opcua-address-space-base";
import { make_warningLog } from "node-opcua-debug";
import { ISessionContext } from "node-opcua-address-space-base";

import { UAVariableImpl } from "../ua_variable_impl";
import { AddressSpace } from "../../source/address_space_ts";
import { AddressSpacePrivate } from "../address_space_private";

const warningLog = make_warningLog(__filename);

// tslint:disable:no-var-requires
const Dequeue = require("dequeue");

Expand Down Expand Up @@ -138,12 +141,20 @@ export class VariableHistorian implements IVariableHistorian {
// ensure that values are set with date increasing
if (sourceTime.getTime() <= this.lastDate.getTime()) {
if (!(sourceTime.getTime() === this.lastDate.getTime() && sourcePicoSeconds > this.lastDatePicoSeconds)) {
console.log(
warningLog(
chalk.red("Warning date not increasing "),
chalk.cyan("\n node: ", this.node.browseName.toString(), this.node.nodeId.toString()),
"\n new value = ",
newDataValue.toString(),
" last known date = ",
this.lastDate
"\n last known date = ",
this.lastDate,
"\n last known picoSeconds = ",
this.lastDatePicoSeconds,
"\n lastValue = ",
this._timeline[this._timeline.length - 1]?.toString()
);
// artificially increment date by one 100 picoseconds
newDataValue.sourcePicoseconds++;
}
}

Expand Down

0 comments on commit c789a36

Please sign in to comment.