Question:
If I create a Node in atvise, is it possible to make it have simulated data without being connected to any data source.
Answer:
Yes, for this you will need to create a script in the Node itself.
This script will be time trigered.
The script is written as follows:
//se puede usar como trigger un timer
//el script se coloca dentro del tag que queremos simular
// Let value hover around 50 in-between 0 and 100;
var nodeId = base.nodeid;
var valueNode = new UaNode(nodeId);
var currentValue = valueNode.value;
// Generate a new value for the change size (1 - 5)
var changeValue = Math.random() * (5 - 1) + 1;
// The more the value diverges from 50, the more it gets pulled
// back toward 50.
// How: We draw a number from a pool of number between 0 and 100.
// Since we revolve around 50, the smaller our current value is,
// the higher the change we pull a greater number, and thus increase
// the currentValue (and vice verse).
var numberFromPool = Math.random() * 100;
if (numberFromPool <= currentValue) {
valueNode.value = currentValue - changeValue;
} else {
valueNode.value = currentValue + changeValue;
}
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article