Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-opcua-status-code

Package Overview
Dependencies
Maintainers
1
Versions
121
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-opcua-status-code - npm Package Compare versions

Comparing version 2.0.0-alpha.7 to 2.0.0-alpha.8

source/opcua_status_code.d.ts

17

dist/opcua_status_code.d.ts
import { BinaryStream } from "node-opcua-binary-stream";
export declare const StatusCodes: any;
export declare const extraStatusCodeBits: any;

@@ -16,2 +15,6 @@ /**

export declare abstract class StatusCode {
/**
* return a status code that can be modified
*/
static makeStatusCode(statusCode: StatusCode, optionalBits: string): StatusCode;
abstract readonly value: number;

@@ -28,9 +31,8 @@ abstract readonly name: string;

equals(other: StatusCode): boolean;
static makeStatusCode(statusCode: StatusCode, optionalBits: string): StatusCode;
toJSON(): any;
}
export declare class ConstantStatusCode extends StatusCode {
private _value;
private _description;
private _name;
private readonly _value;
private readonly _description;
private readonly _name;
constructor(options: {

@@ -50,3 +52,3 @@ value: number;

export declare class ModifiableStatusCode extends StatusCode {
private _base;
private readonly _base;
private _extraBits;

@@ -56,3 +58,2 @@ constructor(options: {

});
_getExtraName(): string;
readonly value: number;

@@ -63,3 +64,5 @@ readonly name: string;

unset(bit: string): void;
private _getExtraName;
}
export declare function coerceStatusCode(statusCode: any): any;
export { StatusCodes } from "node-opcua-constants";
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
// tslint:disable:no-bitwise
/**

@@ -8,3 +9,7 @@ * @module opcua.status-code

const node_opcua_assert_1 = require("node-opcua-assert");
exports.StatusCodes = require("node-opcua-constants").StatusCodes;
const node_opcua_constants_1 = require("node-opcua-constants");
function warnLog(...args) {
// tslint:disable-next-line:no-console
console.warn.apply(console, args);
}
exports.extraStatusCodeBits = {

@@ -78,6 +83,6 @@ // StatusCode Special bits

HistorianExtraData: 0x1 << 3,
HistorianMultiValue: 0x1 << 4,
HistorianMultiValue: 0x1 << 4
};
// Release 1.03 144 OPC Unified Architecture, Part 4
exports.StatusCodes.Bad = {
node_opcua_constants_1.StatusCodes.Bad = {
name: "Bad",

@@ -87,3 +92,3 @@ value: 0x80000000,

};
exports.StatusCodes.Uncertain = {
node_opcua_constants_1.StatusCodes.Uncertain = {
name: "Uncertain",

@@ -105,2 +110,14 @@ value: 0x40000000,

class StatusCode {
/**
* return a status code that can be modified
*/
static makeStatusCode(statusCode, optionalBits) {
const tmp = new ModifiableStatusCode({
_base: statusCode
});
if (optionalBits) {
tmp.set(optionalBits);
}
return tmp;
}
get valueOf() {

@@ -132,12 +149,2 @@ return this.value;

}
// return a status code that can be modified
static makeStatusCode(statusCode, optionalBits) {
const tmp = new ModifiableStatusCode({
_base: statusCode
});
if (optionalBits) {
tmp.set(optionalBits);
}
return tmp;
}
toJSON() {

@@ -151,2 +158,3 @@ return { value: this.value, name: this.name, description: this.description };

Object.defineProperty(StatusCode.prototype, "name", { enumerable: true });
// tslint:disable:max-classes-per-file
class ConstantStatusCode extends StatusCode {

@@ -189,8 +197,8 @@ constructor(options) {

const statusCodesReversedMap = {};
_.forEach(exports.StatusCodes, (code) => {
_.forEach(node_opcua_constants_1.StatusCodes, (code) => {
code = new ConstantStatusCode(code);
statusCodesReversedMap[code.value.toString()] = code;
exports.StatusCodes[code.name] = code;
node_opcua_constants_1.StatusCodes[code.name] = code;
});
exports.StatusCodes.makeStatusCode = StatusCode.makeStatusCode;
node_opcua_constants_1.StatusCodes.makeStatusCode = StatusCode.makeStatusCode;
function getStatusCodeFromCode(code) {

@@ -201,4 +209,4 @@ const codeWithoutInfoBits = (code & 0xFFFF0000) >>> 0;

if (!sc) {
sc = exports.StatusCodes.Bad;
console.warn("expecting a known StatusCode but got 0x" + codeWithoutInfoBits.toString(16));
sc = node_opcua_constants_1.StatusCodes.Bad;
warnLog("expecting a known StatusCode but got 0x" + codeWithoutInfoBits.toString(16));
}

@@ -228,15 +236,2 @@ if (infoBits) {

}
_getExtraName() {
const self = this;
const str = [];
_.forEach(exports.extraStatusCodeBits, (value, key) => {
if ((self._extraBits & value) === value) {
str.push(key);
}
});
if (str.length === 0) {
return "";
}
return "#" + str.join("|");
}
get value() {

@@ -273,5 +268,3 @@ return this._base.value + this._extraBits;

for (const bitArray of bitsArray) {
console.log(" Unset", this._extraBits.toString(16));
this.unset(bitArray);
console.log(" Unset", this._extraBits.toString(16));
}

@@ -288,2 +281,15 @@ return;

}
_getExtraName() {
const self = this;
const str = [];
_.forEach(exports.extraStatusCodeBits, (value, key) => {
if ((self._extraBits & value) === value) {
str.push(key);
}
});
if (str.length === 0) {
return "";
}
return "#" + str.join("|");
}
}

@@ -293,3 +299,3 @@ exports.ModifiableStatusCode = ModifiableStatusCode;

Object.defineProperty(ModifiableStatusCode.prototype, "_extraBits", { enumerable: false, writable: true });
exports.StatusCodes.GoodWithOverflowBit = exports.StatusCodes.makeStatusCode(exports.StatusCodes.Good, "Overflow | InfoTypeDataValue");
node_opcua_constants_1.StatusCodes.GoodWithOverflowBit = node_opcua_constants_1.StatusCodes.makeStatusCode(node_opcua_constants_1.StatusCodes.Good, "Overflow | InfoTypeDataValue");
function coerceStatusCode(statusCode) {

@@ -308,5 +314,7 @@ if (statusCode instanceof StatusCode) {

}
return exports.StatusCodes[statusCode.name];
return node_opcua_constants_1.StatusCodes[statusCode.name];
}
exports.coerceStatusCode = coerceStatusCode;
var node_opcua_constants_2 = require("node-opcua-constants");
exports.StatusCodes = node_opcua_constants_2.StatusCodes;
//# sourceMappingURL=opcua_status_code.js.map
{
"name": "node-opcua-status-code",
"version": "2.0.0-alpha.7",
"version": "2.0.0-alpha.8",
"description": "pure nodejs OPCUA SDK - module -status-code",

@@ -12,8 +12,8 @@ "main": "./dist/opcua_status_code.js",

"dependencies": {
"node-opcua-assert": "^2.0.0-alpha.7",
"node-opcua-constants": "^2.0.0-alpha.7",
"node-opcua-assert": "^2.0.0-alpha.8",
"node-opcua-constants": "^2.0.0-alpha.8",
"underscore": "^1.9.1"
},
"devDependencies": {
"node-opcua-binary-stream": "^2.0.0-alpha.7",
"node-opcua-binary-stream": "^2.0.0-alpha.8",
"should": "13.2.3"

@@ -36,3 +36,3 @@ },

"homepage": "http://node-opcua.github.io/",
"gitHead": "af4f00cca7a45563e759c88afa21bba73152dd03"
"gitHead": "7bbf38d5a3cd29cb6aed6ca38078f4d89d3f956a"
}

@@ -1,2 +0,2 @@

"use strict";
// tslint:disable:no-bitwise
/**

@@ -6,7 +6,11 @@ * @module opcua.status-code

import * as _ from "underscore";
import assert from "node-opcua-assert";
import { BinaryStream } from "node-opcua-binary-stream";
import { StatusCodes } from "node-opcua-constants";
export const StatusCodes = require("node-opcua-constants").StatusCodes;
function warnLog(...args: [any?, ...any[]]) {
// tslint:disable-next-line:no-console
console.warn.apply(console, args);
}
export const extraStatusCodeBits: any = {

@@ -62,3 +66,5 @@

LimitLow: (0x1 << 8),
LimitHigh: (0x2 << 8),
LimitConstant: (0x3 << 8),

@@ -71,3 +77,2 @@

// Reserved 5:6 Reserved for future use. Shall always be zero.

@@ -88,17 +93,19 @@

HistorianCalculated: 0x1 << 0,
HistorianInterpolated: 0x2 << 0,
HistorianPartial: 0x1 << 2,
HistorianExtraData: 0x1 << 3,
HistorianMultiValue: 0x1 << 4,
HistorianMultiValue: 0x1 << 4
};
// Release 1.03 144 OPC Unified Architecture, Part 4
StatusCodes.Bad = {
name: "Bad",
value: 0x80000000,
description: "The value is bad but no specific reason is known."

@@ -110,6 +117,6 @@ };

value: 0x40000000,
description: "The value is uncertain but no specific reason is known."
};
/**

@@ -129,29 +136,46 @@ * a particular StatusCode , with it's value , name and description

abstract get value(): number;
abstract get name(): string;
abstract get description(): string;
/**
* return a status code that can be modified
*/
public static makeStatusCode(statusCode: StatusCode, optionalBits: string): StatusCode {
const tmp = new ModifiableStatusCode({
_base: statusCode
});
if (optionalBits) {
tmp.set(optionalBits);
}
return tmp;
}
get valueOf(): number {
public abstract get value(): number;
public abstract get name(): string;
public abstract get description(): string;
public get valueOf(): number {
return this.value;
}
toString(): string {
public toString(): string {
return this.name + " (0x" + ("0000" + this.value.toString(16)).substr(-8) + ")";
}
checkBit(mask: number): boolean {
public checkBit(mask: number): boolean {
return (this.value & mask) === mask;
}
get hasOverflowBit(): boolean {
public get hasOverflowBit(): boolean {
return this.checkBit(extraStatusCodeBits.Overflow);
}
get hasSemanticChangedBit(): boolean {
public get hasSemanticChangedBit(): boolean {
return this.checkBit(extraStatusCodeBits.SemanticChanged);
}
get hasStructureChangedBit(): boolean {
public get hasStructureChangedBit(): boolean {
return this.checkBit(extraStatusCodeBits.StructureChanged);
}
isNot(other: StatusCode): boolean {
public isNot(other: StatusCode): boolean {
assert(other instanceof StatusCode);

@@ -161,3 +185,3 @@ return this.value !== other.value;

equals(other: StatusCode): boolean {
public equals(other: StatusCode): boolean {
assert(other instanceof StatusCode);

@@ -167,29 +191,19 @@ return this.value === other.value;

// return a status code that can be modified
static makeStatusCode(statusCode: StatusCode, optionalBits: string): StatusCode {
const tmp = new ModifiableStatusCode({
_base: statusCode
});
if (optionalBits) {
tmp.set(optionalBits);
}
return tmp;
public toJSON(): any {
return { value: this.value, name: this.name, description: this.description };
}
toJSON(): any {
return { value: this.value, name: this.name, description: this.description };
}
}
Object.defineProperty(StatusCode.prototype, "value",{enumerable: true });
Object.defineProperty(StatusCode.prototype, "description",{enumerable: true });
Object.defineProperty(StatusCode.prototype, "name",{enumerable: true });
Object.defineProperty(StatusCode.prototype, "value", { enumerable: true });
Object.defineProperty(StatusCode.prototype, "description", { enumerable: true });
Object.defineProperty(StatusCode.prototype, "name", { enumerable: true });
// tslint:disable:max-classes-per-file
export class ConstantStatusCode extends StatusCode {
private _value: number;
private _description: string;
private _name: string;
private readonly _value: number;
private readonly _description: string;
private readonly _name: string;
constructor(options: {value: number, description: string, name: string}) {
constructor(options: { value: number, description: string, name: string }) {
super();

@@ -201,18 +215,19 @@ this._value = options.value;

get value(): number {
public get value(): number {
return this._value;
}
get name(): string {
public get name(): string {
return this._name;
}
get description(): string {
public get description(): string {
return this._description;
}
toJSON(): any {
return {value: this.value };
public toJSON(): any {
return { value: this.value };
}
}
Object.defineProperty(ConstantStatusCode.prototype, "_value", { enumerable: false, writable: true });

@@ -222,13 +237,9 @@ Object.defineProperty(ConstantStatusCode.prototype, "_description", { enumerable: false, writable: true });

Object.defineProperty(ConstantStatusCode.prototype, "value", { enumerable: true });
Object.defineProperty(ConstantStatusCode.prototype, "description", { enumerable: true});
Object.defineProperty(ConstantStatusCode.prototype, "description", { enumerable: true });
Object.defineProperty(ConstantStatusCode.prototype, "name", { enumerable: true });
export function encodeStatusCode(statusCode: StatusCode|ConstantStatusCode, stream: BinaryStream) {
export function encodeStatusCode(statusCode: StatusCode | ConstantStatusCode, stream: BinaryStream) {
stream.writeUInt32(statusCode.value);
}
function b(c: number) {

@@ -241,3 +252,3 @@ const tmp = "0000000000000000000000" + (c >>> 0).toString(2);

const statusCodesReversedMap: any = {};
_.forEach(StatusCodes, (code: {value: number, description: string, name: string}) => {
_.forEach(StatusCodes, (code: { value: number, description: string, name: string }) => {
code = new ConstantStatusCode(code);

@@ -256,6 +267,6 @@ statusCodesReversedMap[code.value.toString()] = code;

sc = StatusCodes.Bad;
console.warn("expecting a known StatusCode but got 0x" + codeWithoutInfoBits.toString(16));
warnLog("expecting a known StatusCode but got 0x" + codeWithoutInfoBits.toString(16));
}
if (infoBits) {
const tmp = new ModifiableStatusCode({_base: sc});
const tmp = new ModifiableStatusCode({ _base: sc });
tmp.set(infoBits);

@@ -273,9 +284,6 @@ sc = tmp;

export class ModifiableStatusCode extends StatusCode {
private _base: StatusCode;
private _extraBits: number;
private readonly _base: StatusCode;
private _extraBits: number;

@@ -292,30 +300,15 @@ constructor(options: { _base: StatusCode }) {

_getExtraName() {
const self = this;
const str: string[] = [];
_.forEach(extraStatusCodeBits, (value: number, key: string) => {
if ((self._extraBits & value) === value) {
str.push(key);
}
});
if (str.length === 0) {
return "";
}
return "#" + str.join("|");
}
get value() {
public get value() {
return this._base.value + this._extraBits;
}
get name() {
public get name() {
return this._base.name + this._getExtraName();
}
get description() {
public get description() {
return this._base.description;
}
set(bit: string | number) {
public set(bit: string | number) {

@@ -339,3 +332,3 @@ if (typeof bit === "string") {

unset(bit: string) {
public unset(bit: string) {

@@ -347,6 +340,3 @@ if (typeof bit === "string") {

for (const bitArray of bitsArray) {
console.log(" Unset", this._extraBits.toString(16));
this.unset(bitArray);
console.log(" Unset", this._extraBits.toString(16));
}

@@ -365,11 +355,21 @@ return;

private _getExtraName() {
const self = this;
const str: string[] = [];
_.forEach(extraStatusCodeBits, (value: number, key: string) => {
if ((self._extraBits & value) === value) {
str.push(key);
}
});
if (str.length === 0) {
return "";
}
return "#" + str.join("|");
}
}
Object.defineProperty(ModifiableStatusCode.prototype, "_base", { enumerable: false, writable: true});
Object.defineProperty(ModifiableStatusCode.prototype, "_extraBits", { enumerable: false, writable: true});
Object.defineProperty(ModifiableStatusCode.prototype, "_base", { enumerable: false, writable: true });
Object.defineProperty(ModifiableStatusCode.prototype, "_extraBits", { enumerable: false, writable: true });
StatusCodes.GoodWithOverflowBit = StatusCodes.makeStatusCode(StatusCodes.Good, "Overflow | InfoTypeDataValue");

@@ -393,2 +393,2 @@

export { StatusCodes } from "node-opcua-constants";

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc