Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const state = self.getStateByName(toStateNode);
// istanbul ignore next
if (!state) {
throw new Error("Cannot find state with name " + toStateNode);
}
assert(state.browseName.toString() === toStateNode);
toStateNode = state;
}
const fromStateNode = self.currentStateNode;
toStateNode = self._coerceNode(toStateNode);
assert(toStateNode instanceof UAObject);
self.currentState.setValueFromSource({
dataType: DataType.LocalizedText,
value: coerceLocalizedText(toStateNode.browseName.toString())
}, StatusCodes.Good);
self.currentStateNode = toStateNode;
const transitionNode = self.findTransitionNode(fromStateNode, toStateNode);
if (transitionNode) {
//xx console.log("transitionNode ",transitionNode.toString());
// The inherited Property SourceNode shall be filled with the NodeId of the StateMachine instance where the
// Transition occurs. If the Transition occurs in a SubStateMachine, then the NodeId of the SubStateMachine
// has to be used. If the Transition occurs between a StateMachine and a SubStateMachine, then the NodeId of
// the StateMachine has to be used, independent of the direction of the Transition.
// Transition identifies the Transition that triggered the Event.
// FromState identifies the State before the Transition.
// ToState identifies the State after the Transition.
let data: any = {};
if (!obj) {
// cannot find reference node
data = {
isForward,
nodeId: reference.nodeId,
referenceTypeId: (resultMask & ResultMask.ReferenceType) ? referenceTypeId : null,
typeDefinition: null
};
} else {
assert(reference.nodeId, " obj.nodeId");
data = {
browseName: (resultMask & ResultMask.BrowseName) ? coerceQualifiedName(obj.browseName) : null,
displayName: (resultMask & ResultMask.DisplayName) ? coerceLocalizedText(obj.displayName[0]) : null,
isForward: (resultMask & ResultMask.IsForward) ? isForward : false,
nodeClass: (resultMask & ResultMask.NodeClass) ? obj.nodeClass : NodeClass.Unspecified,
nodeId: obj.nodeId,
referenceTypeId: (resultMask & ResultMask.ReferenceType) ? referenceTypeId : null,
typeDefinition: (resultMask & ResultMask.TypeDefinition) ? obj.typeDefinition : null
};
}
if (data.typeDefinition === null) {
data.typeDefinition = NodeId.nullNodeId;
}
const referenceDescription = new ReferenceDescription(data);
return referenceDescription;
}
variable.setValueFromSource(options.value, StatusCodes.Good);
variable.euRange.setValueFromSource(new Variant({
dataType: DataType.ExtensionObject, value: new Range(options.engineeringUnitsRange)
}));
if (options.hasOwnProperty("instrumentRange")) {
variable.instrumentRange.setValueFromSource(new Variant({
dataType: DataType.ExtensionObject, value: new Range(options.instrumentRange)
}));
}
variable.title.setValueFromSource(new Variant({
dataType: DataType.LocalizedText, value: coerceLocalizedText(options.title || "")
}));
// Linear/Log/Ln
variable.axisScaleType.setValueFromSource(new Variant({
dataType: DataType.Int32, value: coerceAxisScale(options.axisScaleType)
}));
variable.xAxisDefinition.setValueFromSource(new Variant({
dataType: DataType.ExtensionObject, value: new AxisInformation(options.xAxisDefinition)
}));
return variable;
};
userAccessLevel: options.userAccessLevel,
value: new Variant({ dataType: DataType.Boolean, value: !!options.value })
}) as UAVariable;
const handler = variable.handle_semantic_changed.bind(variable);
add_dataItem_stuff(variable, options);
const trueStateNode = namespace.addVariable({
browseName: { name: "TrueState", namespaceIndex: 0 },
dataType: "LocalizedText",
minimumSamplingInterval: 0,
propertyOf: variable,
typeDefinition: "PropertyType",
value: new Variant({
dataType: DataType.LocalizedText, value: coerceLocalizedText(options.trueState || "ON")
})
});
trueStateNode.on("value_changed", handler);
const falseStateNode = namespace.addVariable({
browseName: { name: "FalseState", namespaceIndex: 0 },
dataType: "LocalizedText",
minimumSamplingInterval: 0,
propertyOf: variable,
typeDefinition: "PropertyType",
value: new Variant({
dataType: DataType.LocalizedText, value: coerceLocalizedText(options.falseState || "OFF")
})
});
userAccessLevel: options.userAccessLevel,
value: new Variant({dataType: DataType.Boolean, value: !!options.value})
});
const handler = variable.handle_semantic_changed.bind(variable);
add_dataItem_stuff(variable, options);
const trueStateNode = namespace.addVariable({
propertyOf: variable,
typeDefinition: "PropertyType",
browseName: {name: "TrueState", namespaceIndex: 0},
dataType: "LocalizedText",
minimumSamplingInterval: 0,
value: new Variant({
dataType: DataType.LocalizedText, value: coerceLocalizedText(options.trueState || "ON")
})
});
trueStateNode.on("value_changed", handler);
const falseStateNode = namespace.addVariable({
propertyOf: variable,
typeDefinition: "PropertyType",
browseName: {name: "FalseState", namespaceIndex: 0},
dataType: "LocalizedText",
minimumSamplingInterval: 0,
value: new Variant({
dataType: DataType.LocalizedText, value: coerceLocalizedText(options.falseState || "OFF")
})
});
return coerceEnumValues(_.map(enumValues, function (value, key) {
return new EnumValueType({
value: value,
displayName: coerceLocalizedText(key),
description: coerceLocalizedText(key)
});
}));
}
typeDefinition: "PropertyType",
value: new Variant({
dataType: DataType.LocalizedText, value: coerceLocalizedText(options.trueState || "ON")
})
});
trueStateNode.on("value_changed", handler);
const falseStateNode = namespace.addVariable({
browseName: { name: "FalseState", namespaceIndex: 0 },
dataType: "LocalizedText",
minimumSamplingInterval: 0,
propertyOf: variable,
typeDefinition: "PropertyType",
value: new Variant({
dataType: DataType.LocalizedText, value: coerceLocalizedText(options.falseState || "OFF")
})
});
falseStateNode.on("value_changed", handler);
variable.install_extra_properties();
return variable;
}
private _setDescription(description: LocalizedTextLike | null): void {
const __description = coerceLocalizedText(description);
const _private = BaseNode_getPrivate(this);
_private._description = __description!;
}
return _.map(enumValues, function (en) {
assert(en.hasOwnProperty("value"));
assert(en.hasOwnProperty("displayName"));
return new EnumValueType({
value: en.value,
displayName: coerceLocalizedText(en.displayName)
});
})
} else {
const enumStrings = options.enumStrings.map(function(value) {
return coerceLocalizedText(value)
});