How to connect two BooleanSignal?

I want to know two ploblem about BooleanSignals.

How to connect two BooleanSignals using Python Script?And how to determine if a BooleanSignal has been connected to other signals?

Hi!

See:

https://forum.visualcomponents.com/forums/topic/waiting-for-a-signal-from-another-component-in-a-different-component/#post-13624

 

Thanks for your replay, jouha!

But what I want is not the Connections property.I want to make two boolean signal have a line connection between them,just like robot’s I/O signalMap.

Hi there,

If you find the answer please share, i’m having the same issue.

Thanks

Hi!

In order to see the connection line in the “Signals view”, you have to use interfaces for connecting. That’s actually what is happening in the background when you connect a BooleanSignal in the GUI. A one-to-one interface is created but it’s not shown, even in the Modelling context.

So, something like this:

def createInterface(component, signal):
  ife = component.createBehaviour(VC_ONETOONEINTERFACE, "interface1")
  sect = ife.createSection("section1")
  ife.IsAbstract = True
  field = sect.createField(VC_SIGNALFIELD, "field1")
  field.Signal = signal
  return ife

app = getApplication()
comp1 = getComponent()
sig1 = comp1.findBehaviour("BooleanSignal")

comp2 = app.findComponent("Comp2")
sig2 = comp2.findBehaviour("BooleanSignal")

ife1 = createInterface(comp1, sig1)
ife2 = createInterface(comp2, sig2)
ife1.connect(ife2)

Note: There’s no checking if the interface already exists, is connected etc.

1 Like