RemoteVariableSynchronizer() constructor

Create a
RemoteVariableSynchronizer
object that can contain a list of project variables to be kept synchronized with the related field variables.
public RemoteVariableSynchronizer()

Example

In the following example, a
variableSynchronizer
object is created to keep the value of a
Speed
project variable synchronized with the value of a field variable that identifies the speed of a motor. The project variable, represented by the
motorSpeed
object, is added to the
variableSynchronizer
object via the
Add()
method.
When the field variable changes its value, the
motorSpeed_VariableChange
method is executed. When the value of
motorSpeed
(of the field variable), is greater than 200, a warning message is generated.
In the
Stop()
method, the termination of the synchronization when the NetLogic parent node is removed is effected by invoking the
Dispose()
method.
IMPORTANT: the
RemoteVariableSynchronizer
object must be declared as a class member within the NetLogic.
private void Start() { motorSpeed = LogicObject.Owner.GetVariable("Speed"); variableSynchronizer = new RemoteVariableSynchronizer(); variableSynchronizer.Add(motorSpeed); motorSpeed.VariableChange += MotorSpeed_VariableChange; } private void MotorSpeed_VariableChange(object sender, VariableChangeEventArgs e) { if (motorSpeed.Value > 200) { Log.Warning("Speed limit reached!"); } } private IUAVariable motorSpeed; private RemoteVariableSynchronizer variableSynchronizer;
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.