Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// setup data
const sourceTimestamp = makeDate(time);
if (value === undefined || value === null) {
return new DataValue({
sourceTimestamp,
statusCode,
value: undefined,
});
} else if (typeof value === "boolean") {
return new DataValue({
sourceTimestamp,
statusCode,
value: {dataType: DataType.Boolean, value},
});
} else {
return new DataValue({
sourceTimestamp,
statusCode,
value: {dataType: DataType.Float, value},
});
}
}
const twoStateDiscreteType = addressSpace.findVariableType("TwoStateDiscreteType");
assert(twoStateDiscreteType, "expecting TwoStateDiscreteType to be defined , check nodeset xml file");
// todo : if options.typeDefinition is specified,
const variable = namespace.addVariable({
componentOf: options.componentOf,
browseName: options.browseName,
nodeId: options.nodeId,
typeDefinition: twoStateDiscreteType.nodeId,
dataType: "Boolean",
accessLevel: options.accessLevel,
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")
})
});
public readAttribute(context: SessionContext | null, attributeId: AttributeIds): DataValue {
assert(!context || context instanceof SessionContext);
const options: DataValueLike = {};
switch (attributeId) {
case AttributeIds.IsAbstract:
options.value = { dataType: DataType.Boolean, value: !!this.isAbstract };
options.statusCode = StatusCodes.Good;
break;
case AttributeIds.Symmetric:
options.value = { dataType: DataType.Boolean, value: !!this.symmetric };
options.statusCode = StatusCodes.Good;
break;
case AttributeIds.InverseName: // LocalizedText
options.value = { dataType: DataType.LocalizedText, value: this.inverseName };
options.statusCode = StatusCodes.Good;
break;
default:
return super.readAttribute(context, attributeId);
}
return new DataValue(options);
}
const variant = dataValue.value;
assert(variant instanceof Variant);
assert(ec.isValidUInt16(variant.value) && " value must be valid for dataType");
interval = variant.value;
install_Timer();
});
const enabledVariable = namespace.addVariable({
componentOf: simulation,
browseName: "Enabled",
description: { locale: "en", text: "Enabled" },
nodeId: "s=Scalar_Simulation_Enabled",
dataType: "Boolean",
value: new Variant({
dataType: DataType.Boolean,
arrayType: VariantArrayType.Scalar,
value: enabled
})
});
enabledVariable.on("value_changed", function(dataValue/*,indexRange*/) {
const variant = dataValue.value;
assert(variant instanceof Variant);
assert(ec.isValidBoolean(variant.value) && " value must be valid for dataType");
enabled = variant.value;
install_Timer();
});
install_Timer();
const addressSpace = namespace.addressSpace;
addressSpace.registerShutdownTask(tearDown_Timer);
private _readHistorizing(): DataValue {
assert(typeof (this.historizing) === "boolean");
const options = {
statusCode: StatusCodes.Good,
value: { dataType: DataType.Boolean, value: !!this.historizing }
};
return new DataValue(options);
}
}
});
bindStandardScalar(VariableIds.HistoryServerCapabilities_AccessHistoryDataCapability,
DataType.Boolean, () => {
return engine.historyServerCapabilities.accessHistoryDataCapability;
});
bindStandardScalar(VariableIds.HistoryServerCapabilities_AccessHistoryEventsCapability,
DataType.Boolean, () => {
return engine.historyServerCapabilities.accessHistoryEventsCapability;
});
bindStandardScalar(VariableIds.HistoryServerCapabilities_InsertDataCapability,
DataType.Boolean, () => {
return engine.historyServerCapabilities.insertDataCapability;
});
bindStandardScalar(VariableIds.HistoryServerCapabilities_ReplaceDataCapability,
DataType.Boolean, () => {
return engine.historyServerCapabilities.replaceDataCapability;
});
bindStandardScalar(VariableIds.HistoryServerCapabilities_UpdateDataCapability,
DataType.Boolean, () => {
return engine.historyServerCapabilities.updateDataCapability;
});
bindStandardScalar(VariableIds.HistoryServerCapabilities_InsertEventCapability,
DataType.Boolean, () => {
return engine.historyServerCapabilities.insertEventCapability;
});
bindStandardScalar(VariableIds.HistoryServerCapabilities_ReplaceEventCapability,
DataType.Boolean, () => {
return engine.historyServerCapabilities.replaceEventCapability;
});
UAMethod.prototype.readAttribute = function (context, attributeId) {
assert(context instanceof SessionContext);
const self = this;
const options = {};
switch (attributeId) {
case AttributeIds.Executable:
options.value = {dataType: DataType.Boolean, value: self.getExecutableFlag(context)};
options.statusCode = StatusCodes.Good;
break;
case AttributeIds.UserExecutable:
options.value = {dataType: DataType.Boolean, value: self.getExecutableFlag(context)};
options.statusCode = StatusCodes.Good;
break;
default:
return BaseNode.prototype.readAttribute.call(this, context, attributeId);
}
return new DataValue(options);
};
const certificateGroupIdVariant = inputArguments[0];
const certificateTypeIdVariant = inputArguments[1];
const subjectNameVariant = inputArguments[2];
const regeneratePrivateKeyVariant = inputArguments[3];
const nonceVariant = inputArguments[4];
if (!expected(certificateGroupIdVariant, DataType.NodeId, VariantArrayType.Scalar)) {
return { statusCode: StatusCodes.BadInvalidArgument };
}
if (!expected(certificateTypeIdVariant, DataType.NodeId, VariantArrayType.Scalar)) {
return { statusCode: StatusCodes.BadInvalidArgument };
}
if (!expected(subjectNameVariant, DataType.String, VariantArrayType.Scalar)) {
return { statusCode: StatusCodes.BadInvalidArgument };
}
if (!expected(regeneratePrivateKeyVariant, DataType.Boolean, VariantArrayType.Scalar)) {
return { statusCode: StatusCodes.BadInvalidArgument };
}
if (!expected(regeneratePrivateKeyVariant, DataType.Boolean, VariantArrayType.Scalar)) {
return { statusCode: StatusCodes.BadInvalidArgument };
}
if (!hasEncryptedChannel(context)) {
return { statusCode: StatusCodes.BadSecurityModeInsufficient };
}
if (!hasExpectedUserAccess(context)) {
return { statusCode: StatusCodes.BadUserAccessDenied };
}
const certificateGroupId = certificateGroupIdVariant.value as NodeId;
const certificateTypeId = certificateTypeIdVariant.value as NodeId;
function _update_suppressedOrShelved(alarmNode) {
alarmNode.suppressedOrShelved.setValueFromSource({
dataType: DataType.Boolean,
value: alarmNode.isSuppressedOrShelved()
});
}
DataType.Boolean, function () {
return engine.historyServerCapabilities.updateDataCapability;
});
bindStandardScalar(VariableIds.HistoryServerCapabilities_InsertEventCapability,
DataType.Boolean, function () {
return engine.historyServerCapabilities.insertEventCapability;
});
bindStandardScalar(VariableIds.HistoryServerCapabilities_ReplaceEventCapability,
DataType.Boolean, function () {
return engine.historyServerCapabilities.replaceEventCapability;
});
bindStandardScalar(VariableIds.HistoryServerCapabilities_UpdateEventCapability,
DataType.Boolean, function () {
return engine.historyServerCapabilities.updateEventCapability;
});
bindStandardScalar(VariableIds.HistoryServerCapabilities_DeleteEventCapability,
DataType.Boolean, function () {
return engine.historyServerCapabilities.deleteEventCapability;
});
bindStandardScalar(VariableIds.HistoryServerCapabilities_DeleteRawCapability,
DataType.Boolean, function () {
return engine.historyServerCapabilities.deleteRawCapability;
});
bindStandardScalar(VariableIds.HistoryServerCapabilities_DeleteAtTimeCapability,
DataType.Boolean, function () {