Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public _assert_valid() {
assert(this.receiveTime.readValue().value.dataType === DataType.DateTime);
assert(this.receiveTime.readValue().value.value instanceof Date);
assert(this.message.readValue().value.dataType === DataType.LocalizedText);
assert(this.severity.readValue().value.dataType === DataType.UInt16);
assert(this.time.readValue().value.dataType === DataType.DateTime);
assert(this.time.readValue().value.value instanceof Date);
assert(this.quality.readValue().value.dataType === DataType.StatusCode);
assert(this.enabledState.readValue().value.dataType === DataType.LocalizedText);
assert(this.branchId.readValue().value.dataType === DataType.NodeId);
// note localTime has been made optional in 1.04
assert(!this.localTime || this.localTime.readValue().value.dataType === DataType.ExtensionObject);
}
function _unShelveTimeFunc(
shelvingState: ShelvingStateMachine
) {
if (shelvingState.getCurrentState() === "Unshelved") {
return new Variant({
dataType: DataType.StatusCode,
value: StatusCodes.BadConditionNotShelved
});
}
if (!shelvingState._sheveldTime) {
return new Variant({
dataType: DataType.StatusCode,
value: StatusCodes.BadConditionNotShelved
});
}
if (shelvingState.getCurrentState() === "OneShotShelved" &&
shelvingState._duration === UAAlarmConditionBase.MaxDuration) {
return new Variant({
dataType: DataType.Double,
value: UAAlarmConditionBase.MaxDuration
});
}
const now = new Date();
let timeToAutomaticUnshelvedState =
shelvingState._duration - (now.getTime() - shelvingState._sheveldTime.getTime());
// timeToAutomaticUnshelvedState should always be greater than (or equal) zero
function prepare(dataValue: DataValue): Variant {
if (dataValue.statusCode === StatusCodes.Good) {
return dataValue.value;
}
return new Variant({dataType: DataType.StatusCode, value: dataValue.statusCode});
}
ConditionSnapshot.prototype.getQuality = function() {
const self = this;
return self._get_var("quality", DataType.StatusCode);
};
function prepare(dataValue) {
assert(dataValue instanceof DataValue);
if(dataValue.statusCode === StatusCodes.Good) {
return dataValue.value;
}
return new Variant({dataType: DataType.StatusCode, value: dataValue.statusCode});
}
UAConditionBase.prototype._assert_valid = function() {
const self = this;
assert(self.receiveTime.readValue().value.dataType === DataType.DateTime);
assert(self.receiveTime.readValue().value.value instanceof Date);
assert(self.localTime.readValue().value.dataType === DataType.ExtensionObject);
assert(self.message.readValue().value.dataType === DataType.LocalizedText);
assert(self.severity.readValue().value.dataType === DataType.UInt16);
assert(self.time.readValue().value.dataType === DataType.DateTime);
assert(self.time.readValue().value.value instanceof Date);
assert(self.quality.readValue().value.dataType === DataType.StatusCode);
assert(self.enabledState.readValue().value.dataType === DataType.LocalizedText);
assert(self.branchId.readValue().value.dataType === DataType.NodeId);
};
public setQuality(quality: StatusCode): void {
this._set_var("quality", DataType.StatusCode, quality);
}
ConditionSnapshot.prototype.setQuality = function(quality) {
const self = this;
assert(quality instanceof StatusCode);
assert(quality.hasOwnProperty("value") || "quality must be a StatusCode");
self._set_var("quality", DataType.StatusCode, quality);
/*
* OPCUA Spec 1.0.3 - Part 9:
* Comment, severity and quality are important elements of Conditions and any change
* to them will cause Event Notifications.
*
*/
self._need_event_raise = true;
};
},
clientUserId: {
dataType: DataType.Null
},
comment: { dataType: DataType.LocalizedText, value: branch.getComment() },
inputArguments: {
dataType: DataType.Null
},
methodId: {
dataType: DataType.Null
},
serverId: {
dataType: DataType.Null
},
status: {
dataType: DataType.StatusCode,
value: StatusCodes.Good
}
};
this.raiseEvent("AuditConditionConfirmEventType", eventData);
}
function _unShelveTimeFunc(shelvingState) {
if (shelvingState.getCurrentState() === "Unshelved") {
return new Variant({
dataType: DataType.StatusCode,
value: StatusCodes.BadConditionNotShelved
});
}
if (!shelvingState._sheveldTime) {
return new Variant({
dataType: DataType.StatusCode,
value: StatusCodes.BadConditionNotShelved
});
}
if (shelvingState.getCurrentState() === "OneShotShelved" && shelvingState._duration === UAAlarmConditionBase.MaxDuration) {
return new Variant({
dataType: DataType.Double,
value: UAAlarmConditionBase.MaxDuration
});
}