node-opcua-address-space 2.74.0 → 2.75.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/source/helpers/argument_list.js +1 -0
- package/dist/source/helpers/argument_list.js.map +1 -1
- package/dist/source/helpers/multiform_func.js +4 -2
- package/dist/source/helpers/multiform_func.js.map +1 -1
- package/dist/source/index.d.ts +0 -2
- package/dist/source/index.js +1 -5
- package/dist/source/index.js.map +1 -1
- package/dist/source/interfaces/alarms_and_conditions/condition_snapshot.d.ts +5 -11
- package/dist/source/interfaces/alarms_and_conditions/condition_snapshot.js +0 -7
- package/dist/source/interfaces/alarms_and_conditions/condition_snapshot.js.map +1 -1
- package/dist/source/interfaces/alarms_and_conditions/deviation_stuff.d.ts +4 -6
- package/dist/source/interfaces/alarms_and_conditions/install_setpoint_options.d.ts +4 -0
- package/dist/source/interfaces/alarms_and_conditions/instantiate_exclusive_deviation_alarm_options.d.ts +4 -0
- package/dist/source/interfaces/alarms_and_conditions/instantiate_exclusive_deviation_alarm_options.js +3 -0
- package/dist/source/interfaces/alarms_and_conditions/instantiate_exclusive_deviation_alarm_options.js.map +1 -0
- package/dist/source/interfaces/alarms_and_conditions/instantiate_limit_alarm_options.d.ts +2 -2
- package/dist/source/interfaces/alarms_and_conditions/instantiate_non_exclusive_deviation_alarm_options.d.ts +4 -0
- package/dist/source/interfaces/alarms_and_conditions/instantiate_non_exclusive_deviation_alarm_options.js +3 -0
- package/dist/source/interfaces/alarms_and_conditions/instantiate_non_exclusive_deviation_alarm_options.js.map +1 -0
- package/dist/source/interfaces/alarms_and_conditions/instantiate_non_exclusive_limit_alarm_options.d.ts +4 -0
- package/dist/source/interfaces/alarms_and_conditions/instantiate_non_exclusive_limit_alarm_options.js +3 -0
- package/dist/source/interfaces/alarms_and_conditions/instantiate_non_exclusive_limit_alarm_options.js.map +1 -0
- package/dist/source/interfaces/alarms_and_conditions/instantiate_off_normal_alarm_options.d.ts +16 -1
- package/dist/source/interfaces/alarms_and_conditions/ua_exclusive_deviation_alarm_ex.d.ts +1 -1
- package/dist/source/interfaces/alarms_and_conditions/ua_non_exclusive_deviation_alarm_ex.d.ts +2 -4
- package/dist/source/namespace_alarm_and_condition.d.ts +19 -11
- package/dist/src/address_space.js +17 -12
- package/dist/src/address_space.js.map +1 -1
- package/dist/src/alarms_and_conditions/condition.js +1 -1
- package/dist/src/alarms_and_conditions/condition_snapshot_impl.d.ts +3 -12
- package/dist/src/alarms_and_conditions/condition_snapshot_impl.js +84 -93
- package/dist/src/alarms_and_conditions/condition_snapshot_impl.js.map +1 -1
- package/dist/src/alarms_and_conditions/deviation_alarm_helper.d.ts +3 -2
- package/dist/src/alarms_and_conditions/deviation_alarm_helper.js +27 -12
- package/dist/src/alarms_and_conditions/deviation_alarm_helper.js.map +1 -1
- package/dist/src/alarms_and_conditions/index.d.ts +0 -2
- package/dist/src/alarms_and_conditions/index.js +0 -2
- package/dist/src/alarms_and_conditions/index.js.map +1 -1
- package/dist/src/alarms_and_conditions/ua_condition_impl.js +5 -5
- package/dist/src/alarms_and_conditions/ua_condition_impl.js.map +1 -1
- package/dist/src/alarms_and_conditions/ua_exclusive_deviation_alarm_impl.d.ts +4 -6
- package/dist/src/alarms_and_conditions/ua_exclusive_deviation_alarm_impl.js.map +1 -1
- package/dist/src/alarms_and_conditions/ua_limit_alarm_impl.d.ts +13 -13
- package/dist/src/alarms_and_conditions/ua_limit_alarm_impl.js +15 -15
- package/dist/src/alarms_and_conditions/ua_limit_alarm_impl.js.map +1 -1
- package/dist/src/alarms_and_conditions/ua_non_exclusive_deviation_alarm_impl.d.ts +3 -3
- package/dist/src/alarms_and_conditions/ua_non_exclusive_deviation_alarm_impl.js.map +1 -1
- package/dist/src/alarms_and_conditions/ua_off_normal_alarm_impl.js +18 -13
- package/dist/src/alarms_and_conditions/ua_off_normal_alarm_impl.js.map +1 -1
- package/dist/src/event_data.d.ts +22 -17
- package/dist/src/event_data.js +33 -64
- package/dist/src/event_data.js.map +1 -1
- package/dist/src/index_current.d.ts +0 -1
- package/dist/src/index_current.js +0 -1
- package/dist/src/index_current.js.map +1 -1
- package/dist/src/namespace_impl.d.ts +14 -11
- package/dist/src/namespace_impl.js.map +1 -1
- package/dist/src/state_machine/ua_two_state_variable.js +1 -1
- package/dist/src/state_machine/ua_two_state_variable.js.map +1 -1
- package/dist/src/ua_object_impl.js +0 -1
- package/dist/src/ua_object_impl.js.map +1 -1
- package/dist/src/ua_reference_type_impl.d.ts +1 -1
- package/distHelpers/alarms_and_conditions_demo.js +2 -1
- package/distHelpers/alarms_and_conditions_demo.js.map +1 -1
- package/package.json +22 -22
- package/source/helpers/argument_list.ts +2 -0
- package/source/helpers/multiform_func.ts +5 -3
- package/source/index.ts +0 -2
- package/source/interfaces/alarms_and_conditions/condition_snapshot.ts +12 -30
- package/source/interfaces/alarms_and_conditions/deviation_stuff.ts +8 -6
- package/source/interfaces/alarms_and_conditions/install_setpoint_options.ts +9 -0
- package/source/interfaces/alarms_and_conditions/instantiate_exclusive_deviation_alarm_options.ts +4 -0
- package/source/interfaces/alarms_and_conditions/instantiate_limit_alarm_options.ts +2 -2
- package/source/interfaces/alarms_and_conditions/instantiate_non_exclusive_deviation_alarm_options.ts +4 -0
- package/source/interfaces/alarms_and_conditions/instantiate_non_exclusive_limit_alarm_options.ts +4 -0
- package/source/interfaces/alarms_and_conditions/instantiate_off_normal_alarm_options.ts +16 -1
- package/source/interfaces/alarms_and_conditions/ua_exclusive_deviation_alarm_ex.ts +1 -0
- package/source/interfaces/alarms_and_conditions/ua_non_exclusive_deviation_alarm_ex.ts +1 -2
- package/source/namespace_alarm_and_condition.ts +48 -23
- package/src/address_space.ts +22 -16
- package/src/alarms_and_conditions/condition.ts +1 -1
- package/src/alarms_and_conditions/condition_snapshot_impl.ts +95 -102
- package/src/alarms_and_conditions/deviation_alarm_helper.ts +33 -18
- package/src/alarms_and_conditions/index.ts +0 -2
- package/src/alarms_and_conditions/ua_condition_impl.ts +5 -5
- package/src/alarms_and_conditions/ua_exclusive_deviation_alarm_impl.ts +5 -6
- package/src/alarms_and_conditions/ua_limit_alarm_impl.ts +6 -8
- package/src/alarms_and_conditions/ua_non_exclusive_deviation_alarm_impl.ts +5 -3
- package/src/alarms_and_conditions/ua_off_normal_alarm_impl.ts +18 -16
- package/src/event_data.ts +47 -77
- package/src/index_current.ts +0 -1
- package/src/namespace_impl.ts +47 -26
- package/src/state_machine/ua_two_state_variable.ts +1 -1
- package/src/ua_object_impl.ts +1 -2
- package/test_helpers/alarms_and_conditions_demo.ts +4 -1
- package/source/helpers/check_event_clause.ts +0 -55
- package/src/alarms_and_conditions/check_where_clause.ts +0 -147
- package/src/alarms_and_conditions/extract_event_fields.ts +0 -103
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ContentFilter,
|
|
3
|
-
FilterOperator,
|
|
4
|
-
LiteralOperand,
|
|
5
|
-
SimpleAttributeOperand,
|
|
6
|
-
FilterOperand,
|
|
7
|
-
ElementOperand
|
|
8
|
-
} from "node-opcua-types";
|
|
9
|
-
import { DataType } from "node-opcua-variant";
|
|
10
|
-
import { NodeClass } from "node-opcua-data-model";
|
|
11
|
-
import { ExtensionObject } from "node-opcua-extension-object";
|
|
12
|
-
import { NodeId, sameNodeId } from "node-opcua-nodeid";
|
|
13
|
-
import {
|
|
14
|
-
IAddressSpace,
|
|
15
|
-
IEventData,
|
|
16
|
-
ISessionContext,
|
|
17
|
-
UAObject,
|
|
18
|
-
UAObjectType,
|
|
19
|
-
UAReferenceType,
|
|
20
|
-
UAVariableType
|
|
21
|
-
} from "node-opcua-address-space-base";
|
|
22
|
-
|
|
23
|
-
import { SessionContext } from "../../source/session_context";
|
|
24
|
-
import { extractEventFields } from "./extract_event_fields";
|
|
25
|
-
|
|
26
|
-
function checkNot(
|
|
27
|
-
addressSpace: IAddressSpace,
|
|
28
|
-
sessionContext: ISessionContext,
|
|
29
|
-
whereClause: ContentFilter,
|
|
30
|
-
eventData: IEventData,
|
|
31
|
-
filteredOperands: FilterOperand[]
|
|
32
|
-
): boolean {
|
|
33
|
-
if (filteredOperands[0] instanceof ElementOperand) {
|
|
34
|
-
const index = (filteredOperands[0] as ElementOperand).index;
|
|
35
|
-
return !__checkWhereClause(addressSpace, sessionContext, whereClause, index, eventData);
|
|
36
|
-
}
|
|
37
|
-
return false;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function checkOfType(addressSpace: IAddressSpace, ofType: LiteralOperand, eventData: IEventData): boolean {
|
|
41
|
-
// istanbul ignore next
|
|
42
|
-
if (!ofType) {
|
|
43
|
-
throw new Error("invalid operand");
|
|
44
|
-
}
|
|
45
|
-
// istanbul ignore next
|
|
46
|
-
if (ofType.value.dataType !== DataType.NodeId) {
|
|
47
|
-
throw new Error("invalid operand type (expecting Nodeid");
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const ofTypeNode = addressSpace.findNode(ofType.value.value) as UAObjectType | UAReferenceType | UAVariableType;
|
|
51
|
-
|
|
52
|
-
// istanbul ignore next
|
|
53
|
-
if (!ofTypeNode) {
|
|
54
|
-
return false; // the ofType node is not known, we don't know what to do
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// istanbul ignore next
|
|
58
|
-
if (ofTypeNode.nodeClass !== NodeClass.ObjectType) {
|
|
59
|
-
throw new Error("operand should be a ObjectType " + ofTypeNode.nodeId.toString());
|
|
60
|
-
}
|
|
61
|
-
const node = eventData.$eventDataSource! as UAObjectType | UAObject | UAReferenceType | UAVariableType;
|
|
62
|
-
if (!node) {
|
|
63
|
-
throw new Error("cannot find node " + eventData.$eventDataSource?.toString());
|
|
64
|
-
}
|
|
65
|
-
if (node.nodeClass === NodeClass.ObjectType) {
|
|
66
|
-
return node.isSupertypeOf(ofTypeNode);
|
|
67
|
-
}
|
|
68
|
-
if (node.nodeClass === NodeClass.Object && node.typeDefinitionObj) {
|
|
69
|
-
return node.typeDefinitionObj.isSupertypeOf(ofTypeNode);
|
|
70
|
-
}
|
|
71
|
-
return true;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function _extractValue(operand: SimpleAttributeOperand, eventData: IEventData): NodeId | null {
|
|
75
|
-
// eventData.readValue;
|
|
76
|
-
const v = extractEventFields(SessionContext.defaultContext, [operand], eventData)[0];
|
|
77
|
-
return v.value as NodeId;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function checkInList(addressSpace: IAddressSpace, filterOperands: ExtensionObject[], eventData: IEventData): boolean {
|
|
81
|
-
const operand0 = filterOperands[0];
|
|
82
|
-
if (!(operand0 instanceof SimpleAttributeOperand)) {
|
|
83
|
-
// unsupported case
|
|
84
|
-
return false;
|
|
85
|
-
}
|
|
86
|
-
const nodeId: NodeId | null = _extractValue(operand0, eventData);
|
|
87
|
-
if (!nodeId) {
|
|
88
|
-
return false;
|
|
89
|
-
}
|
|
90
|
-
function _is(nodeId1: NodeId, operandX: LiteralOperand): boolean {
|
|
91
|
-
const operandNode = addressSpace.findNode(operandX.value.value as NodeId);
|
|
92
|
-
if (!operandNode) {
|
|
93
|
-
return false;
|
|
94
|
-
}
|
|
95
|
-
return sameNodeId(nodeId1, operandNode.nodeId);
|
|
96
|
-
}
|
|
97
|
-
for (let i = 1; i < filterOperands.length; i++) {
|
|
98
|
-
const filterOperand = filterOperands[i];
|
|
99
|
-
if (filterOperand instanceof LiteralOperand && _is(nodeId, filterOperand)) {
|
|
100
|
-
return true;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
return false;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export function __checkWhereClause(
|
|
107
|
-
addressSpace: IAddressSpace,
|
|
108
|
-
sessionContext: ISessionContext,
|
|
109
|
-
whereClause: ContentFilter,
|
|
110
|
-
index: number,
|
|
111
|
-
eventData: IEventData
|
|
112
|
-
): boolean {
|
|
113
|
-
if (!whereClause.elements || whereClause.elements.length === 0) {
|
|
114
|
-
return true;
|
|
115
|
-
}
|
|
116
|
-
const element = whereClause.elements[index];
|
|
117
|
-
if (!element) {
|
|
118
|
-
return true;
|
|
119
|
-
}
|
|
120
|
-
switch (element.filterOperator) {
|
|
121
|
-
case FilterOperator.Not:
|
|
122
|
-
return checkNot(addressSpace, sessionContext, whereClause, eventData, element.filterOperands as FilterOperand[]);
|
|
123
|
-
case FilterOperator.OfType:
|
|
124
|
-
return checkOfType(addressSpace, element.filterOperands![0] as LiteralOperand, eventData);
|
|
125
|
-
case FilterOperator.InList:
|
|
126
|
-
return checkInList(addressSpace, element.filterOperands as ExtensionObject[], eventData);
|
|
127
|
-
default:
|
|
128
|
-
// from Spec OPC Unified Architecture, Part 4 133 Release 1.04
|
|
129
|
-
// Any basic FilterOperator in Table 119 may be used in the whereClause, however, only the
|
|
130
|
-
// OfType_14 FilterOperator from Table 120 is permitted.
|
|
131
|
-
// tslint:disable-next-line: no-console
|
|
132
|
-
console.log("whereClause = ", whereClause.toString());
|
|
133
|
-
throw new Error("Only OfType operator are allowed in checkWhereClause");
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
export function checkWhereClause(
|
|
138
|
-
addressSpace: IAddressSpace,
|
|
139
|
-
sessionContext: ISessionContext,
|
|
140
|
-
whereClause: ContentFilter,
|
|
141
|
-
eventData: IEventData
|
|
142
|
-
): boolean {
|
|
143
|
-
if (!whereClause.elements || whereClause.elements.length === 0) {
|
|
144
|
-
return true;
|
|
145
|
-
}
|
|
146
|
-
return __checkWhereClause(addressSpace, sessionContext, whereClause, 0, eventData);
|
|
147
|
-
}
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { IEventData, ISessionContext, UAObject } from "node-opcua-address-space-base";
|
|
2
|
-
import { assert } from "node-opcua-assert";
|
|
3
|
-
import { AttributeIds } from "node-opcua-data-model";
|
|
4
|
-
import { resolveNodeId } from "node-opcua-nodeid";
|
|
5
|
-
import { SimpleAttributeOperand } from "node-opcua-types";
|
|
6
|
-
import { DataType, Variant } from "node-opcua-variant";
|
|
7
|
-
|
|
8
|
-
function assert_valid_event_data(eventData: IEventData) {
|
|
9
|
-
assert(typeof eventData.resolveSelectClause === "function");
|
|
10
|
-
assert(typeof eventData.readValue === "function");
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
*
|
|
15
|
-
* @method extractEventField
|
|
16
|
-
* extract a eventField from a event node, matching the given selectClause
|
|
17
|
-
* @param eventData
|
|
18
|
-
* @param selectClause
|
|
19
|
-
*/
|
|
20
|
-
function extractEventField(sessionContext: ISessionContext, eventData: IEventData, selectClause: SimpleAttributeOperand): Variant {
|
|
21
|
-
assert_valid_event_data(eventData);
|
|
22
|
-
assert(selectClause instanceof SimpleAttributeOperand);
|
|
23
|
-
|
|
24
|
-
selectClause.browsePath = selectClause.browsePath || [];
|
|
25
|
-
|
|
26
|
-
if (selectClause.browsePath.length === 0 && selectClause.attributeId === AttributeIds.NodeId) {
|
|
27
|
-
const eventSource = eventData.$eventDataSource as UAObject;
|
|
28
|
-
const addressSpace = eventSource.addressSpace;
|
|
29
|
-
const conditionTypeNodeId = resolveNodeId("ConditionType");
|
|
30
|
-
const conditionType = addressSpace.findObjectType(conditionTypeNodeId);
|
|
31
|
-
|
|
32
|
-
/* istanbul ignore next */
|
|
33
|
-
if (!conditionType) {
|
|
34
|
-
throw new Error("Cannot find ConditionType NodeId !");
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// "ns=0;i=2782" => ConditionType
|
|
38
|
-
// "ns=0;i=2041" => BaseEventType
|
|
39
|
-
if (selectClause.typeDefinitionId.toString() !== "ns=0;i=2782") {
|
|
40
|
-
// not a ConditionType
|
|
41
|
-
// but could be on of its derived type. for instance ns=0;i=2881 => AcknowledgeableConditionType
|
|
42
|
-
const typeDefinitionObj = addressSpace.findObjectType(selectClause.typeDefinitionId);
|
|
43
|
-
|
|
44
|
-
/* istanbul ignore next */
|
|
45
|
-
if (!typeDefinitionObj) {
|
|
46
|
-
throw new Error("Cannot find TypeDefinition Type !");
|
|
47
|
-
}
|
|
48
|
-
if (!typeDefinitionObj.isSupertypeOf(conditionType)) {
|
|
49
|
-
// tslint:disable-next-line:no-console
|
|
50
|
-
console.warn(" ", typeDefinitionObj ? typeDefinitionObj.browseName.toString() : "????");
|
|
51
|
-
// tslint:disable-next-line:no-console
|
|
52
|
-
console.warn(
|
|
53
|
-
"this case is not handled yet : selectClause.typeDefinitionId = " + selectClause.typeDefinitionId.toString()
|
|
54
|
-
);
|
|
55
|
-
const eventSource1 = eventData.$eventDataSource!;
|
|
56
|
-
return new Variant({ dataType: DataType.NodeId, value: eventSource1.nodeId });
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const eventSourceTypeDefinition = eventSource.typeDefinitionObj;
|
|
61
|
-
if (!eventSourceTypeDefinition) {
|
|
62
|
-
// eventSource is a EventType class
|
|
63
|
-
return new Variant();
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (!eventSourceTypeDefinition.isSupertypeOf(conditionType)) {
|
|
67
|
-
return new Variant();
|
|
68
|
-
}
|
|
69
|
-
// Yeh : our EventType is a Condition Type !
|
|
70
|
-
return new Variant({ dataType: DataType.NodeId, value: eventSource.nodeId });
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const handle = eventData.resolveSelectClause(selectClause);
|
|
74
|
-
|
|
75
|
-
if (handle !== null) {
|
|
76
|
-
const value = eventData.readValue(sessionContext, handle, selectClause);
|
|
77
|
-
assert(value instanceof Variant);
|
|
78
|
-
return value;
|
|
79
|
-
} else {
|
|
80
|
-
// Part 4 - 7.17.3
|
|
81
|
-
// A null value is returned in the corresponding event field in the Publish response if the selected
|
|
82
|
-
// field is not part of the Event or an error was returned in the selectClauseResults of the EventFilterResult.
|
|
83
|
-
// return new Variant({dataType: DataType.StatusCode, value: browsePathResult.statusCode});
|
|
84
|
-
return new Variant();
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* @method extractEventFields
|
|
90
|
-
* extract a array of eventFields from a event node, matching the selectClauses
|
|
91
|
-
* @param selectClauses
|
|
92
|
-
* @param eventData : a pseudo Node that provides a browse Method and a readValue(nodeId)
|
|
93
|
-
*/
|
|
94
|
-
export function extractEventFields(
|
|
95
|
-
sessionContext: ISessionContext,
|
|
96
|
-
selectClauses: SimpleAttributeOperand[],
|
|
97
|
-
eventData: IEventData
|
|
98
|
-
): Variant[] {
|
|
99
|
-
assert_valid_event_data(eventData);
|
|
100
|
-
assert(Array.isArray(selectClauses));
|
|
101
|
-
assert(selectClauses.length === 0 || selectClauses[0] instanceof SimpleAttributeOperand);
|
|
102
|
-
return selectClauses.map(extractEventField.bind(null, sessionContext, eventData));
|
|
103
|
-
}
|