node-opcua-status-code
Advanced tools
Comparing version 2.9.0 to 2.10.0
@@ -11,3 +11,3 @@ "use strict"; | ||
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); | ||
} | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -14,0 +14,0 @@ __exportStar(require("./opcua_status_code"), exports); |
@@ -8,3 +8,5 @@ /** | ||
*/ | ||
export declare const extraStatusCodeBits: any; | ||
export declare const extraStatusCodeBits: { | ||
[key: string]: number; | ||
}; | ||
/** | ||
@@ -11,0 +13,0 @@ * a particular StatusCode , with it's value , name and description |
@@ -8,3 +8,2 @@ "use strict"; | ||
exports.coerceStatusCode = exports.ModifiableStatusCode = exports.decodeStatusCode = exports.getStatusCodeFromCode = exports.encodeStatusCode = exports.ConstantStatusCode = exports.StatusCode = exports.extraStatusCodeBits = void 0; | ||
const _ = require("underscore"); | ||
const node_opcua_assert_1 = require("node-opcua-assert"); | ||
@@ -32,3 +31,3 @@ function warnLog(...args) { | ||
*/ | ||
StructureChanged: (0x1 << 15), | ||
StructureChanged: 0x1 << 15, | ||
/** | ||
@@ -45,3 +44,3 @@ * **SemanticsChanged** 14:14 Semantics of the associated data value have changed. Clients should not process the data | ||
*/ | ||
SemanticChanged: (0x1 << 14), | ||
SemanticChanged: 0x1 << 14, | ||
// Reserved 12:13 Reserved for future use. Shall always be zero. | ||
@@ -58,3 +57,3 @@ /** | ||
*/ | ||
InfoTypeDataValue: (0x1 << 10), | ||
InfoTypeDataValue: 0x1 << 10, | ||
// InfoBits 0:9 Additional information bits that qualify the StatusCode. | ||
@@ -70,5 +69,5 @@ // The structure of these bits depends on the Info Type field. | ||
// Constant 11 The value is constant and cannot change. | ||
LimitLow: (0x1 << 8), | ||
LimitHigh: (0x2 << 8), | ||
LimitConstant: (0x3 << 8), | ||
LimitLow: 0x1 << 8, | ||
LimitHigh: 0x2 << 8, | ||
LimitConstant: 0x3 << 8, | ||
/** | ||
@@ -81,3 +80,3 @@ * **Overflow** 7:7 | ||
*/ | ||
Overflow: (0x1 << 7), | ||
Overflow: 0x1 << 7, | ||
// Reserved 5:6 Reserved for future use. Shall always be zero. | ||
@@ -105,3 +104,3 @@ // HistorianBits 0:4 These bits are set only when reading historical data. They indicate where the data value | ||
/** Multiple values match the Aggregate criteria (i.e. multiple minimum values at different timestamps within the same interval). */ | ||
HistorianMultiValue: 0x1 << 4 | ||
HistorianMultiValue: 0x1 << 4, | ||
}; | ||
@@ -209,4 +208,4 @@ /** | ||
function getStatusCodeFromCode(code) { | ||
const codeWithoutInfoBits = (code & 0xFFFF0000) >>> 0; | ||
const infoBits = code & 0x0000FFFF; | ||
const codeWithoutInfoBits = (code & 0xffff0000) >>> 0; | ||
const infoBits = code & 0x0000ffff; | ||
let sc = statusCodesReversedMap[codeWithoutInfoBits]; | ||
@@ -216,2 +215,3 @@ /* istanbul ignore if */ | ||
sc = _generated_status_codes_1.StatusCodes.Bad; | ||
// tslint:disable-next-line: no-console | ||
console.log("expecting a known StatusCode but got 0x" + codeWithoutInfoBits.toString(16), " code was 0x" + code.toString(16)); | ||
@@ -291,7 +291,7 @@ warnLog("expecting a known StatusCode but got 0x" + codeWithoutInfoBits.toString(16), " code was 0x" + code.toString(16)); | ||
const str = []; | ||
_.forEach(exports.extraStatusCodeBits, (value, key) => { | ||
for (const [key, value] of Object.entries(exports.extraStatusCodeBits)) { | ||
if ((self._extraBits & value) === value) { | ||
str.push(key); | ||
} | ||
}); | ||
} | ||
/* istanbul ignore next */ | ||
@@ -328,7 +328,7 @@ if (str.length === 0) { | ||
exports.coerceStatusCode = coerceStatusCode; | ||
_.forEach(Object.keys(_generated_status_codes_1.StatusCodes), (name) => { | ||
for (const name of Object.keys(_generated_status_codes_1.StatusCodes)) { | ||
const code = _generated_status_codes_1.StatusCodes[name]; | ||
statusCodesReversedMap[code.value.toString()] = code; | ||
}); | ||
} | ||
_generated_status_codes_1.StatusCodes.makeStatusCode = StatusCode.makeStatusCode; | ||
//# sourceMappingURL=opcua_status_code.js.map |
{ | ||
"name": "node-opcua-status-code", | ||
"version": "2.9.0", | ||
"version": "2.10.0", | ||
"description": "pure nodejs OPCUA SDK - module -status-code", | ||
@@ -13,8 +13,8 @@ "main": "./dist/index.js", | ||
"dependencies": { | ||
"node-opcua-assert": "^2.6.1", | ||
"node-opcua-constants": "^2.9.0", | ||
"node-opcua-assert": "2.10.0", | ||
"node-opcua-constants": "2.9.0", | ||
"underscore": "^1.10.2" | ||
}, | ||
"devDependencies": { | ||
"node-opcua-binary-stream": "^2.8.1", | ||
"node-opcua-binary-stream": "2.10.0", | ||
"should": "^13.2.3" | ||
@@ -37,3 +37,3 @@ }, | ||
"homepage": "http://node-opcua.github.io/", | ||
"gitHead": "66374de9fbf47e8ad7a3e869cad4ec332e256751" | ||
"gitHead": "f1c467c28f8bef1cc04ab54c57a555bd4c95ee45" | ||
} |
@@ -6,4 +6,2 @@ /** | ||
import * as _ from "underscore"; | ||
import { assert } from "node-opcua-assert"; | ||
@@ -21,8 +19,7 @@ import { BinaryStream, OutputBinaryStream } from "node-opcua-binary-stream"; | ||
*/ | ||
export const extraStatusCodeBits: any = { | ||
/** | ||
* **StructureChanged** 15:15 | ||
export const extraStatusCodeBits: { [key: string]: number } = { | ||
/** | ||
* **StructureChanged** 15:15 | ||
* Indicates that the structure of the associated data value has changed since the last | ||
* Notification. | ||
* Notification. | ||
* - Clients should not process the data value unless they re-read the metadata. | ||
@@ -36,3 +33,3 @@ * - Servers shall set this bit if the DataTypeEncoding used for a Variable changes. | ||
*/ | ||
StructureChanged: (0x1 << 15), | ||
StructureChanged: 0x1 << 15, | ||
@@ -46,14 +43,14 @@ /** | ||
* - Part 8 defines the conditions where a Server shall set this bit for a DA Variable. | ||
* - Other specifications may define additional conditions. | ||
* - Other specifications may define additional conditions. | ||
* - A Server may define other conditions that cause this bit to be set. This bit has meaning only for StatusCodes returned as part of a data change Notification | ||
* or the HistoryRead. StatusCodes used in other contexts shall always set this bit to zero. | ||
*/ | ||
SemanticChanged: (0x1 << 14), | ||
SemanticChanged: 0x1 << 14, | ||
// Reserved 12:13 Reserved for future use. Shall always be zero. | ||
/** | ||
* **InfoType** 10:11 | ||
/** | ||
* **InfoType** 10:11 | ||
* The type of information contained in the info bits. These bits have the following meanings: | ||
* | ||
* | ||
* | Meaning |value | description| | ||
@@ -65,3 +62,3 @@ * |-----------------------------------|------|----------------------------------------------------| | ||
*/ | ||
InfoTypeDataValue: (0x1 << 10), // 0x0400, | ||
InfoTypeDataValue: 0x1 << 10, // 0x0400, | ||
@@ -78,16 +75,16 @@ // InfoBits 0:9 Additional information bits that qualify the StatusCode. | ||
// Constant 11 The value is constant and cannot change. | ||
LimitLow: (0x1 << 8), | ||
LimitLow: 0x1 << 8, | ||
LimitHigh: (0x2 << 8), | ||
LimitHigh: 0x2 << 8, | ||
LimitConstant: (0x3 << 8), | ||
LimitConstant: 0x3 << 8, | ||
/** | ||
* **Overflow** 7:7 | ||
* **Overflow** 7:7 | ||
* - This bit shall only be set if the MonitoredItem queue size is greater than 1. | ||
* - If this bit is set, not every detected change has been returned since the Server’s | ||
* queue buffer for the MonitoredItem reached its limit and had to purge out data. | ||
* | ||
* | ||
*/ | ||
Overflow: (0x1 << 7), // 1 << 7 | ||
Overflow: 0x1 << 7, // 1 << 7 | ||
@@ -122,7 +119,5 @@ // Reserved 5:6 Reserved for future use. Shall always be zero. | ||
/** Multiple values match the Aggregate criteria (i.e. multiple minimum values at different timestamps within the same interval). */ | ||
HistorianMultiValue: 0x1 << 4 | ||
HistorianMultiValue: 0x1 << 4, | ||
}; | ||
/** | ||
@@ -133,10 +128,6 @@ * a particular StatusCode , with it's value , name and description | ||
export abstract class StatusCode { | ||
/** | ||
* returns a status code that can be modified | ||
*/ | ||
public static makeStatusCode( | ||
statusCode: StatusCode | string, | ||
optionalBits: string | number): StatusCode { | ||
public static makeStatusCode(statusCode: StatusCode | string, optionalBits: string | number): StatusCode { | ||
const _base = coerceStatusCode(statusCode); | ||
@@ -217,3 +208,2 @@ const tmp = new ModifiableStatusCode({ _base }); | ||
export class ConstantStatusCode extends StatusCode { | ||
private readonly _value: number; | ||
@@ -224,5 +214,5 @@ private readonly _description: string; | ||
/** | ||
* | ||
* @param options | ||
* | ||
* @param options | ||
* @param options | ||
* @param options.value | ||
@@ -233,3 +223,3 @@ * @param options.description | ||
*/ | ||
constructor(options: { value: number, description: string, name: string }) { | ||
constructor(options: { value: number; description: string; name: string }) { | ||
super(); | ||
@@ -252,3 +242,2 @@ this._value = options.value; | ||
} | ||
} | ||
@@ -273,8 +262,7 @@ | ||
* @note: if code is not known , then StatusCodes.Bad will be returned | ||
* @param code | ||
* @param code | ||
*/ | ||
export function getStatusCodeFromCode(code: number) { | ||
const codeWithoutInfoBits = (code & 0xFFFF0000) >>> 0; | ||
const infoBits = code & 0x0000FFFF; | ||
const codeWithoutInfoBits = (code & 0xffff0000) >>> 0; | ||
const infoBits = code & 0x0000ffff; | ||
let sc = statusCodesReversedMap[codeWithoutInfoBits]; | ||
@@ -285,6 +273,11 @@ | ||
sc = StatusCodes.Bad; | ||
console.log("expecting a known StatusCode but got 0x" + codeWithoutInfoBits.toString(16), | ||
" code was 0x" + code.toString(16)); | ||
warnLog("expecting a known StatusCode but got 0x" + codeWithoutInfoBits.toString(16), | ||
" code was 0x" + code.toString(16)); | ||
// tslint:disable-next-line: no-console | ||
console.log( | ||
"expecting a known StatusCode but got 0x" + codeWithoutInfoBits.toString(16), | ||
" code was 0x" + code.toString(16) | ||
); | ||
warnLog( | ||
"expecting a known StatusCode but got 0x" + codeWithoutInfoBits.toString(16), | ||
" code was 0x" + code.toString(16) | ||
); | ||
} | ||
@@ -302,7 +295,5 @@ if (infoBits) { | ||
return getStatusCodeFromCode(code); | ||
} | ||
export class ModifiableStatusCode extends StatusCode { | ||
private readonly _base: StatusCode; | ||
@@ -334,3 +325,2 @@ private _extraBits: number; | ||
public set(bit: string | number): void { | ||
if (typeof bit === "string") { | ||
@@ -356,5 +346,3 @@ const bitsArray = bit.split(" | "); | ||
public unset(bit: string | number): void { | ||
if (typeof bit === "string") { | ||
const bitsArray = bit.split(" | "); | ||
@@ -376,14 +364,12 @@ if (bitsArray.length > 1) { | ||
this._extraBits = this._extraBits & (~bit >>> 0); | ||
} | ||
private _getExtraName() { | ||
const self = this; | ||
const str: string[] = []; | ||
_.forEach(extraStatusCodeBits, (value: number, key: string) => { | ||
for (const [key, value] of Object.entries(extraStatusCodeBits)) { | ||
if ((self._extraBits & value) === value) { | ||
str.push(key); | ||
} | ||
}); | ||
} | ||
@@ -415,3 +401,3 @@ /* istanbul ignore next */ | ||
} | ||
const _StatusCodes = StatusCodes as any | ||
const _StatusCodes = StatusCodes as any; | ||
if (!_StatusCodes[statusCode as string]) { | ||
@@ -423,8 +409,7 @@ throw new Error("Cannot find StatusCode " + statusCode); | ||
_.forEach(Object.keys(StatusCodes), (name) => { | ||
for (const name of Object.keys(StatusCodes)) { | ||
const code = (StatusCodes as any)[name]; | ||
statusCodesReversedMap[code.value.toString()] = code; | ||
}); | ||
} | ||
(StatusCodes as any).makeStatusCode = StatusCode.makeStatusCode; | ||
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2253
252002
+ Addedansi-regex@2.1.1(transitive)
+ Addedbetter-assert@1.0.2(transitive)
+ Addedboolbase@1.0.0(transitive)
+ Addedcallsite@1.0.0(transitive)
+ Addedcss-select@4.3.0(transitive)
+ Addedcss-what@6.1.0(transitive)
+ Addeddom-converter@0.2.0(transitive)
+ Addeddom-serializer@1.4.1(transitive)
+ Addeddomelementtype@2.3.0(transitive)
+ Addeddomhandler@4.3.1(transitive)
+ Addeddomutils@2.8.0(transitive)
+ Addedentities@2.2.0(transitive)
+ Addedhtmlparser2@6.1.0(transitive)
+ Addedlodash@4.17.21(transitive)
+ Addednode-opcua-assert@2.10.0(transitive)
+ Addednode-opcua-constants@2.9.0(transitive)
+ Addednth-check@2.1.1(transitive)
+ Addedpretty-error@2.1.2(transitive)
+ Addedrenderkid@2.0.7(transitive)
+ Addedstrip-ansi@3.0.1(transitive)
+ Addedutila@0.4.0(transitive)
- Removednode-opcua-assert@2.120.0(transitive)
- Removednode-opcua-constants@2.125.0(transitive)
Updatednode-opcua-assert@2.10.0
Updatednode-opcua-constants@2.9.0