Change Server Variable Through Component Signals (TwinCAT, OPC-UA)

Hey there!
I’m running Visual Components 4.3 connected to TwinCAT via OPC-UA & can’t seem to change signals or make them change server variables.

I’m basically sending a request from TwinCAT to Visual Components and would like to receive a confirmation from Visual Components.

My request signal is (Server to Simulation, reading from TwinCAT):
ACKNOWLEDGE_REQUEST = comp.findBehaviour("ACKNOWLEDGE_REQUEST")

My confirmation signal is (Simulation to Server, sent from Visual Components):
ACKNOWLEDGE_CONFIRM = comp.findBehaviour("ACKNOWLEDGE_CONFIRM")

My issue is that, if I simply write:

def OnRun():
    app = getApplication():
    while app.Simulation.IsRunning:
    if ACKNOWLEDGE_REQUEST.Value == True
        ACKNOWLEDGE_CONFIRM.Value = True
        if ACKNOWLEDGE_CONFIRM.Value == True
            print "ACKN!"

OR:

def acknowledge():
  print '-'*99 # print a line 
  print '- ACKNOWLEDGE_REQUEST value:',ACKNOWLEDGE_REQUEST.Value 
  triggerCondition(lambda : ACKNOWLEDGE_REQUEST.Value == True) 
  if ACKNOWLEDGE_REQUEST.Value == True: 
    print '- ACKNOWLEDGE_REQUEST value:',ACKNOWLEDGE_REQUEST.Value
    delay(1)
    ACKNOWLEDGE_CONFIRM.Value = True 
    print '- ACKNOWLEDGE_CONFIRM value:',ACKNOWLEDGE_CONFIRM.Value
    delay(1)
    return True

in a python script, I can see prints as well as changed signal values just fine.

In “CONNECTIVITY” I also see the variables in “Server to Simulation” change values.
But “Simulation to server” stays on false, and won’t change in TwinCAT either.

Any idea what I’m missing is much appreciated :slight_smile:
Thanks and have a nice day!
BR Klaus

If you want to send signal, setting the vcSignal.Value is not enough. You should use the vcSignal.signal() method.

For more details, see the help file, or the Academy tutorial on how signals can be used: Conditions and Signals | Visual Components Academy

2 Likes

Hy,

quite similar to:

Regards
Feature

1 Like

Thanks this worked!
I still don’t quite get why though, like what’s the idea?
Read this doc & Python API but found that rather lacking for my understanding.

Thanks!

This confused me even more though, since Python API documentation mentions reading joint position using joint.CurrentValue with servo.getJoint(0) instead of servo.getJointValue(0)

I feel like different sources (official YouTube, Academy PDFs & inbuilt API doc & forum) aren’t really concise?