node-opcua-service-filter
Advanced tools
Comparing version 2.0.0-alpha.8 to 2.0.0-alpha.9
@@ -0,1 +1,4 @@ | ||
/** | ||
* @module node-opcua-service-filter | ||
*/ | ||
export { FilterOperator, AttributeOperand, ElementOperand, FilterOperand, LiteralOperand, SimpleAttributeOperand, MonitoringFilter, ContentFilterElement, ContentFilter, EventFilter, AttributeOperandOptions, ElementOperandOptions, FilterOperandOptions, LiteralOperandOptions, SimpleAttributeOperandOptions, MonitoringFilterOptions, ContentFilterElementOptions, ContentFilterOptions, EventFilterOptions } from "node-opcua-types"; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/** | ||
* @module node-opcua-service-filter | ||
*/ | ||
var node_opcua_types_1 = require("node-opcua-types"); | ||
@@ -4,0 +7,0 @@ exports.FilterOperator = node_opcua_types_1.FilterOperator; |
@@ -0,2 +1,5 @@ | ||
/** | ||
* @module node-opcua-service-filter | ||
*/ | ||
export * from "./imports"; | ||
export * from "./tools_event_filter"; |
@@ -6,2 +6,5 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/** | ||
* @module node-opcua-service-filter | ||
*/ | ||
__export(require("./imports")); | ||
@@ -8,0 +11,0 @@ __export(require("./tools_event_filter")); |
@@ -0,3 +1,3 @@ | ||
import { NodeId } from "node-opcua-nodeid"; | ||
import { SimpleAttributeOperand } from "./imports"; | ||
import { NodeId } from "node-opcua-nodeid"; | ||
/** | ||
@@ -4,0 +4,0 @@ * helper to construct event filters: |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/** | ||
* @module node-opcua-service-filter | ||
*/ | ||
// tslint:disable:object-literal-shorthand | ||
// tslint:disable:only-arrow-functions | ||
// tslint:disable:max-line-length | ||
const node_opcua_assert_1 = require("node-opcua-assert"); | ||
const node_opcua_nodeid_1 = require("node-opcua-nodeid"); | ||
const node_opcua_variant_1 = require("node-opcua-variant"); | ||
const _ = require("underscore"); | ||
const imports_1 = require("./imports"); | ||
const node_opcua_variant_1 = require("node-opcua-variant"); | ||
const node_opcua_nodeid_1 = require("node-opcua-nodeid"); | ||
const node_opcua_constants_1 = require("node-opcua-constants"); | ||
const node_opcua_data_model_1 = require("node-opcua-data-model"); | ||
const debugLog = require("node-opcua-debug").make_debugLog(__filename); | ||
const doDebug = require("node-opcua-debug").checkDebugFlag(__filename); | ||
const node_opcua_debug_1 = require("node-opcua-debug"); | ||
const debugLog = node_opcua_debug_1.make_debugLog(__filename); | ||
const doDebug = node_opcua_debug_1.checkDebugFlag(__filename); | ||
/** | ||
@@ -41,6 +46,7 @@ * helper to construct event filters: | ||
} | ||
if (!(arrayOfNames instanceof Array)) | ||
if (!(arrayOfNames instanceof Array)) { | ||
throw new Error("internal error"); | ||
} | ||
// replace "string" element in the form A.B.C into [ "A","B","C"] | ||
const arrayOfNames2 = arrayOfNames.map(function (path) { | ||
const arrayOfNames2 = arrayOfNames.map((path) => { | ||
if (typeof path !== "string") { | ||
@@ -51,3 +57,3 @@ return path; | ||
}); | ||
const arrayOfNames3 = arrayOfNames2.map(function (path) { | ||
const arrayOfNames3 = arrayOfNames2.map((path) => { | ||
if (_.isArray(path)) { | ||
@@ -59,7 +65,7 @@ return path.map(node_opcua_data_model_1.stringToQualifiedName); | ||
// replace "string" elements in arrayOfName with QualifiedName in namespace 0 | ||
const arrayOfNames4 = arrayOfNames3.map(function (s) { | ||
const arrayOfNames4 = arrayOfNames3.map((s) => { | ||
return (typeof s === "string") ? node_opcua_data_model_1.stringToQualifiedName(s) : s; | ||
}); | ||
// construct browse paths array | ||
const browsePaths = arrayOfNames4.map(function (s) { | ||
const browsePaths = arrayOfNames4.map((s) => { | ||
return _.isArray(s) ? s : [s]; | ||
@@ -74,17 +80,17 @@ }); | ||
// That said, profiles defined in Part 7 may make support for additional Attributes mandatory. | ||
let selectClauses = browsePaths.map(function (browsePath) { | ||
let selectClauses = browsePaths.map((browsePath) => { | ||
return new imports_1.SimpleAttributeOperand({ | ||
typeDefinitionId: node_opcua_nodeid_1.makeNodeId(node_opcua_constants_1.ObjectTypeIds.BaseEventType), | ||
browsePath: browsePath, | ||
attributeId: node_opcua_data_model_1.AttributeIds.Value, | ||
indexRange: undefined // NumericRange | ||
browsePath, | ||
indexRange: undefined, | ||
typeDefinitionId: node_opcua_nodeid_1.makeNodeId(node_opcua_constants_1.ObjectTypeIds.BaseEventType) // i=2041 | ||
}); | ||
}); | ||
if (conditionTypes) { | ||
const extraSelectClauses = conditionTypes.map(function (nodeId) { | ||
if (conditionTypes && conditionTypes instanceof Array) { | ||
const extraSelectClauses = conditionTypes.map((nodeId) => { | ||
return new imports_1.SimpleAttributeOperand({ | ||
typeDefinitionId: nodeId, | ||
attributeId: node_opcua_data_model_1.AttributeIds.NodeId, | ||
browsePath: undefined, | ||
attributeId: node_opcua_data_model_1.AttributeIds.NodeId, | ||
indexRange: undefined // NumericRange | ||
indexRange: undefined, | ||
typeDefinitionId: nodeId // conditionType for instance | ||
}); | ||
@@ -130,5 +136,6 @@ }); | ||
function simpleAttributeOperandToPath(self) { | ||
if (!self.browsePath) | ||
if (!self.browsePath) { | ||
return ""; | ||
return self.browsePath.map(function (a) { | ||
} | ||
return self.browsePath.map((a) => { | ||
return a.name; | ||
@@ -176,5 +183,6 @@ }).join("/"); | ||
// not ConditionType | ||
// tslint:disable-next-line:no-console | ||
console.warn("this case is not handled yet : selectClause.typeDefinitionId = " + selectClause.typeDefinitionId.toString()); | ||
const eventSource = eventData.$eventDataSource; | ||
return new node_opcua_variant_1.Variant({ dataType: node_opcua_variant_1.DataType.NodeId, value: eventSource.nodeId }); | ||
const eventSource1 = eventData.$eventDataSource; | ||
return new node_opcua_variant_1.Variant({ dataType: node_opcua_variant_1.DataType.NodeId, value: eventSource1.nodeId }); | ||
} | ||
@@ -181,0 +189,0 @@ const conditionTypeNodeId = node_opcua_nodeid_1.resolveNodeId("ConditionType"); |
{ | ||
"name": "node-opcua-service-filter", | ||
"version": "2.0.0-alpha.8", | ||
"version": "2.0.0-alpha.9", | ||
"description": "pure nodejs OPCUA SDK - module -service-filter", | ||
@@ -13,20 +13,20 @@ "main": "./dist/index.js", | ||
"dependencies": { | ||
"node-opcua-assert": "^2.0.0-alpha.8", | ||
"node-opcua-basic-types": "^2.0.0-alpha.8", | ||
"node-opcua-binary-stream": "^2.0.0-alpha.8", | ||
"node-opcua-constants": "^2.0.0-alpha.8", | ||
"node-opcua-data-model": "^2.0.0-alpha.8", | ||
"node-opcua-debug": "^2.0.0-alpha.8", | ||
"node-opcua-factory": "^2.0.0-alpha.8", | ||
"node-opcua-nodeid": "^2.0.0-alpha.8", | ||
"node-opcua-numeric-range": "^2.0.0-alpha.8", | ||
"node-opcua-service-translate-browse-path": "^2.0.0-alpha.8", | ||
"node-opcua-status-code": "^2.0.0-alpha.8", | ||
"node-opcua-types": "^2.0.0-alpha.8", | ||
"node-opcua-variant": "^2.0.0-alpha.8", | ||
"node-opcua-assert": "^2.0.0-alpha.9", | ||
"node-opcua-basic-types": "^2.0.0-alpha.9", | ||
"node-opcua-binary-stream": "^2.0.0-alpha.9", | ||
"node-opcua-constants": "^2.0.0-alpha.9", | ||
"node-opcua-data-model": "^2.0.0-alpha.9", | ||
"node-opcua-debug": "^2.0.0-alpha.9", | ||
"node-opcua-factory": "^2.0.0-alpha.9", | ||
"node-opcua-nodeid": "^2.0.0-alpha.9", | ||
"node-opcua-numeric-range": "^2.0.0-alpha.9", | ||
"node-opcua-service-translate-browse-path": "^2.0.0-alpha.9", | ||
"node-opcua-status-code": "^2.0.0-alpha.9", | ||
"node-opcua-types": "^2.0.0-alpha.9", | ||
"node-opcua-variant": "^2.0.0-alpha.9", | ||
"underscore": "^1.9.1" | ||
}, | ||
"devDependencies": { | ||
"node-opcua-generator": "^2.0.0-alpha.8", | ||
"node-opcua-service-secure-channel": "^2.0.0-alpha.8", | ||
"node-opcua-generator": "^2.0.0-alpha.9", | ||
"node-opcua-service-secure-channel": "^2.0.0-alpha.9", | ||
"should": "13.2.3" | ||
@@ -49,3 +49,3 @@ }, | ||
"homepage": "http://node-opcua.github.io/", | ||
"gitHead": "7bbf38d5a3cd29cb6aed6ca38078f4d89d3f956a" | ||
"gitHead": "cd7120d1840593757f0f3c9e53be4e85883dc0e6" | ||
} |
@@ -0,1 +1,4 @@ | ||
/** | ||
* @module node-opcua-service-filter | ||
*/ | ||
export { | ||
@@ -2,0 +5,0 @@ |
@@ -0,1 +1,4 @@ | ||
/** | ||
* @module node-opcua-service-filter | ||
*/ | ||
export * from "./imports"; | ||
@@ -2,0 +5,0 @@ export * from "./tools_event_filter"; |
@@ -0,15 +1,20 @@ | ||
/** | ||
* @module node-opcua-service-filter | ||
*/ | ||
// tslint:disable:object-literal-shorthand | ||
// tslint:disable:only-arrow-functions | ||
// tslint:disable:max-line-length | ||
import { assert } from "node-opcua-assert"; | ||
import * as _ from "underscore"; | ||
import { SimpleAttributeOperand, EventFilter, } from "./imports"; | ||
import { makeNodeId, NodeId, resolveNodeId, sameNodeId } from "node-opcua-nodeid"; | ||
import { StatusCodes } from "node-opcua-status-code"; | ||
import { DataType, Variant } from "node-opcua-variant"; | ||
import { makeNodeId, NodeId, resolveNodeId, sameNodeId } from "node-opcua-nodeid"; | ||
import * as _ from "underscore"; | ||
import { EventFilter, SimpleAttributeOperand } from "./imports"; | ||
import { ObjectTypeIds } from "node-opcua-constants"; | ||
import { AttributeIds, stringToQualifiedName } from "node-opcua-data-model"; | ||
import { checkDebugFlag, make_debugLog } from "node-opcua-debug"; | ||
const debugLog = require("node-opcua-debug").make_debugLog(__filename); | ||
const doDebug = require("node-opcua-debug").checkDebugFlag(__filename); | ||
const debugLog = make_debugLog(__filename); | ||
const doDebug = checkDebugFlag(__filename); | ||
@@ -44,6 +49,7 @@ /** | ||
} | ||
if (!(arrayOfNames instanceof Array)) throw new Error("internal error"); | ||
if (!(arrayOfNames instanceof Array)) { | ||
throw new Error("internal error"); | ||
} | ||
// replace "string" element in the form A.B.C into [ "A","B","C"] | ||
const arrayOfNames2 = arrayOfNames.map(function (path) { | ||
const arrayOfNames2 = arrayOfNames.map((path) => { | ||
if (typeof path !== "string") { | ||
@@ -55,3 +61,3 @@ return path; | ||
const arrayOfNames3 = arrayOfNames2.map(function (path) { | ||
const arrayOfNames3 = arrayOfNames2.map((path) => { | ||
if (_.isArray(path)) { | ||
@@ -63,9 +69,8 @@ return path.map(stringToQualifiedName); | ||
// replace "string" elements in arrayOfName with QualifiedName in namespace 0 | ||
const arrayOfNames4 = arrayOfNames3.map(function (s) { | ||
const arrayOfNames4 = arrayOfNames3.map((s) => { | ||
return (typeof s === "string") ? stringToQualifiedName(s) : s; | ||
}); | ||
// construct browse paths array | ||
const browsePaths = arrayOfNames4.map(function (s) { | ||
const browsePaths = arrayOfNames4.map((s) => { | ||
return _.isArray(s) ? s : [s]; | ||
@@ -82,18 +87,20 @@ }); | ||
// That said, profiles defined in Part 7 may make support for additional Attributes mandatory. | ||
let selectClauses = browsePaths.map(function (browsePath) { | ||
let selectClauses = browsePaths.map((browsePath) => { | ||
return new SimpleAttributeOperand({ | ||
typeDefinitionId: makeNodeId(ObjectTypeIds.BaseEventType), // i=2041 | ||
browsePath: browsePath, | ||
attributeId: AttributeIds.Value, | ||
indexRange: undefined // NumericRange | ||
browsePath, | ||
indexRange: undefined, // NumericRange | ||
typeDefinitionId: makeNodeId(ObjectTypeIds.BaseEventType) // i=2041 | ||
}); | ||
}); | ||
if (conditionTypes) { | ||
const extraSelectClauses = conditionTypes.map(function (nodeId) { | ||
if (conditionTypes && conditionTypes instanceof Array) { | ||
const extraSelectClauses = conditionTypes.map((nodeId) => { | ||
return new SimpleAttributeOperand({ | ||
typeDefinitionId: nodeId, // conditionType for instance | ||
attributeId: AttributeIds.NodeId, | ||
browsePath: undefined, | ||
attributeId: AttributeIds.NodeId, | ||
indexRange: undefined // NumericRange | ||
indexRange: undefined, // NumericRange | ||
typeDefinitionId: nodeId // conditionType for instance | ||
}); | ||
@@ -104,3 +111,2 @@ }); | ||
const filter = new EventFilter({ | ||
@@ -135,3 +141,2 @@ | ||
/** | ||
@@ -147,4 +152,6 @@ * @class SimpleAttributeOperand | ||
function simpleAttributeOperandToPath(self: SimpleAttributeOperand): string { | ||
if (!self.browsePath) return ""; | ||
return self.browsePath.map(function (a) { | ||
if (!self.browsePath) { | ||
return ""; | ||
} | ||
return self.browsePath.map((a) => { | ||
return a.name; | ||
@@ -173,2 +180,3 @@ }).join("/"); | ||
} | ||
function assert_valid_event_data(eventData: any) { | ||
@@ -179,3 +187,2 @@ assert(_.isFunction(eventData.resolveSelectClause)); | ||
/** | ||
@@ -201,5 +208,6 @@ * | ||
// not ConditionType | ||
// tslint:disable-next-line:no-console | ||
console.warn("this case is not handled yet : selectClause.typeDefinitionId = " + selectClause.typeDefinitionId.toString()); | ||
const eventSource = eventData.$eventDataSource; | ||
return new Variant({dataType: DataType.NodeId, value: eventSource.nodeId}); | ||
const eventSource1 = eventData.$eventDataSource; | ||
return new Variant({ dataType: DataType.NodeId, value: eventSource1.nodeId }); | ||
} | ||
@@ -222,6 +230,5 @@ const conditionTypeNodeId = resolveNodeId("ConditionType"); | ||
// Yeh : our EventType is a Condition Type ! | ||
return new Variant({dataType: DataType.NodeId, value: eventSource.nodeId}); | ||
return new Variant({ dataType: DataType.NodeId, value: eventSource.nodeId }); | ||
} | ||
const handle = eventData.resolveSelectClause(selectClause); | ||
@@ -236,3 +243,3 @@ | ||
// Part 4 - 7.17.3 | ||
// Part 4 - 7.17.3 | ||
// A null value is returned in the corresponding event field in the Publish response if the selected | ||
@@ -260,3 +267,1 @@ // field is not part of the Event or an error was returned in the selectClauseResults of the EventFilterResult. | ||
exports.extractEventFields = extractEventFields; | ||
Sorry, the diff of this file is not supported yet
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
35541
15
623