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:
-
options
Object-
browseName
String -
[description]
String optional -
[modellingRule]
String optional -
[minimumSamplingInterval=0]
Number optional -
componentOf
Node | NodeId -
propertyOf
Node | NodeId -
trueState
String -
falseState
String -
[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:
-
options
Object-
[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:
-
options
Object
isReadable
-
context
Parameters:
-
context
SesionContext
Returns:
isUserReadable
-
context
Parameters:
-
context
SesionContext
Returns:
readAttribute
-
context
-
attributeId
-
indexRange
-
dataEncoding
Parameters:
-
context
SessionContext -
attributeId
AttributeIdsthe attributeId to read -
indexRange
NumericRange | null -
dataEncoding
String
Returns:
readValue
-
[context]
-
[indexRange]
-
[dataEncoding]
Parameters:
-
[context]
SessionContext optional -
[indexRange]
NumericRange | Null optional -
[dataEncoding]
String optional
Returns:
readValueAsync
-
context
-
callback
Parameters:
-
context
SessionContext -
callback
Function-
err
Null | Error -
dataValue
DataValue | Nullthe value read
-
setValue
-
boolValue
Parameters:
-
boolValue
Boolean
setValueFromSource
-
variant
-
[statusCode = StatusCodes.Good]
-
[sourceTimestamp= Now]
Parameters:
-
variant
Variant -
[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-
timestamp
Date -
picoseconds
Number
-
writeAttribute
-
context
-
writeValue
-
callback
Parameters:
-
context
SessionContext -
writeValue
WriteValue -
callback
Function-
err
Error | Null -
statusCode
StatusCode
-
writeEnumValue
-
value
Parameters:
-
value
String | Number
writeValue
-
context
-
dataValue
-
[indexRange]
-
callback
Parameters:
-
context
SessionContext -
dataValue
DataValue -
[indexRange]
NumericRange optional -
callback
Function-
err
Error | Null -
statusCode
StatusCode
-