UATwoStateVariable Class
Constructor
UATwoStateVariable
()
Item Index
Methods
- addTwoStateVariable
- bindExtensionObject
- bindVariable
- getValue
- getValueAsString
- initialize
- isReadable
- isUserReadable
- isUserWritable
- isValueInRange note: this method is overridden in address-space-data-access
- isWritable
- readAttribute
- readValue
- readValueAsync
- setValue
- setValueFromSource
- touchValue touch the source timestamp of a Variable and cascade up the change to the parent variable if any.
- writeAttribute
- writeEnumValue
- writeValue
Methods
addTwoStateVariable
-
options
Parameters:
-
optionsObject-
browseNameString -
[description]String optional -
[modellingRule]String optional -
[minimumSamplingInterval=0]Number optional -
componentOfNode | NodeId -
propertyOfNode | NodeId -
trueStateString -
falseStateString -
[isTrueSubStateOf]NodeId optional -
[isFalseSubStateOf]NodeId optional -
[modellingRule]optional
-
Returns:
Optionals can be EffectiveDisplayName, TransitionTime, EffectiveTransitionTime
bindExtensionObject
-
[optionalExtensionObject=null]
Parameters:
-
[optionalExtensionObject=null]ExtensionObject optional
Returns:
bindVariable
-
options -
[overwrite = false]
Parameters:
-
optionsObject-
[dataType=null]DataType optionalthe nodeId of the dataType
-
[accessLevel]Number optionalAccessLevelFlagItem
-
[userAccessLevel]Number optionalAccessLevelFlagItem
-
[set]Function optionalthe variable setter function
-
[get]Function optionalthe variable getter function. the function must return a Variant or a status code
-
[timestamped_get]Function optionalthe getter function. this function must return a object with the following
-
[historyRead]Function optionalproperties:
- value: a Variant or a status code
- sourceTimestamp
- sourcePicoseconds
-
[timestamped_set]Function optional -
[refreshFunc]Function optionalthe variable asynchronous getter function.
-
-
[overwrite = false]Boolean optionalset overwrite to true to overwrite existing binding
Returns:
Example:
...
var options = {
get : function() {
return new Variant({...});
},
set : function(variant) {
// store the variant somewhere
return StatusCodes.Good;
}
};
...
engine.bindVariable(nodeId,options):
...
Variation 2:
This variation can be used when the user wants to specify a specific '''sourceTimestamp''' associated with the current value of the UAVariable.
The provided timestamped_get function should return an object with three properties:
- value: containing the variant value or a error StatusCode,
- sourceTimestamp
- sourcePicoseconds
...
var myDataValue = new DataValue({
value: {dataType: DataType.Double , value: 10.0},
sourceTimestamp : new Date(),
sourcePicoseconds: 0
});
...
var options = {
timestamped_get : function() { return myDataValue; }
};
...
engine.bindVariable(nodeId,options):
...
// record a new value
myDataValue.value.value = 5.0;
myDataValue.sourceTimestamp = new Date();
...
Variation 3:
This variation can be used when the value associated with the variables requires a asynchronous function call to be
extracted. In this case, the user should provide an async method refreshFunc.
The refreshFunc shall do whatever is necessary to fetch the most up to date version of the variable value, and
call the callback function when the data is ready.
The callback function follow the standard callback function signature:
- the first argument shall be null or Error, depending of the outcome of the fetch operation,
- the second argument shall be a DataValue with the new UAVariable Value, a StatusCode, and time stamps.
Optionally, it is possible to pass a sourceTimestamp and a sourcePicoseconds value as a third and fourth arguments of the callback. When sourceTimestamp and sourcePicoseconds are missing, the system will set their default value to the current time..
...
var options = {
refreshFunc : function(callback) {
... do_some_async_stuff_to_get_the_new_variable_value
var dataValue = new DataValue({
value: new Variant({...}),
statusCode: StatusCodes.Good,
sourceTimestamp: new Date()
});
callback(null,dataValue);
}
};
...
variable.bindVariable(nodeId,options):
...
Providing write access to the underlying value
Variation1 - provide a simple synchronous set function
Notes
to do : explain return StatusCodes.GoodCompletesAsynchronously;
getValue
()
Boolean
Returns:
getValueAsString
()
String
Returns:
initialize
-
options
Parameters:
-
optionsObject
isReadable
-
context
Parameters:
-
contextSesionContext
Returns:
isUserReadable
-
context
Parameters:
-
contextSesionContext
Returns:
readAttribute
-
context -
attributeId -
indexRange -
dataEncoding
Parameters:
-
contextSessionContext -
attributeIdAttributeIdsthe attributeId to read -
indexRangeNumericRange | null -
dataEncodingString
Returns:
readValue
-
[context] -
[indexRange] -
[dataEncoding]
Parameters:
-
[context]SessionContext optional -
[indexRange]NumericRange | Null optional -
[dataEncoding]String optional
Returns:
readValueAsync
-
context -
callback
Parameters:
-
contextSessionContext -
callbackFunction-
errNull | Error -
dataValueDataValue | Nullthe value read
-
setValue
-
boolValue
Parameters:
-
boolValueBoolean
setValueFromSource
-
variant -
[statusCode = StatusCodes.Good] -
[sourceTimestamp= Now]
Parameters:
-
variantVariant -
[statusCode = StatusCodes.Good]StatusCode optional -
[sourceTimestamp= Now]Object optional
touchValue
touch the source timestamp of a Variable and cascade up the change
to the parent variable if any.
-
[optionalNow=null]
Parameters:
-
[optionalNow=null]Object optional-
timestampDate -
picosecondsNumber
-
writeAttribute
-
context -
writeValue -
callback
Parameters:
-
contextSessionContext -
writeValueWriteValue -
callbackFunction-
errError | Null -
statusCodeStatusCode
-
writeEnumValue
-
value
Parameters:
-
valueString | Number
writeValue
-
context -
dataValue -
[indexRange] -
callback
Parameters:
-
contextSessionContext -
dataValueDataValue -
[indexRange]NumericRange optional -
callbackFunction-
errError | Null -
statusCodeStatusCode
-
The NodeOPCUA API