Signal communication between Threaded Child-Scripts and Non-Threaded Child-Scripts

Typically: "How do I... ", "How can I... " questions
Post Reply
Marimo
Posts: 3
Joined: 18 Mar 2019, 14:37

Signal communication between Threaded Child-Scripts and Non-Threaded Child-Scripts

Post by Marimo »

Hello everyone,

at the moment, I try to make a communication between child scripts.

In my threaded child script, I can get integer Signals from the non-threaded child script:

For example, in non-threaded child script: setting Integer Signal with...

Code: Select all

sim.setIntegerSignal('DropLimit',20)
Then I am able to get the signal in the threaded child script with...

Code: Select all

-- get drop limit from Vision Sensor script   
    shapeDropLimit = sim.getIntegerSignal("DropLimit")
and it works.

But now: I want to set an integer signal in the threaded child script and get it in the non-threaded child script to start an action in it, but it doesn't work...

I need your held. Is there any solution to set a signal in a threaded script and read it in a non-threaded script?

Thanks from Germany...

Regards Marimo

coppelia
Site Admin
Posts: 10336
Joined: 14 Dec 2012, 00:25

Re: Signal communication between Threaded Child-Scripts and Non-Threaded Child-Scripts

Post by coppelia »

Hello,

please post your respective threaded and non-threaded child script. It should work in both directions.

Cheers

Marimo
Posts: 3
Joined: 18 Mar 2019, 14:37

Re: Signal communication between Threaded Child-Scripts and Non-Threaded Child-Scripts

Post by Marimo »

Hi there, thanks for your fast answer.
The scripts code is to large, so I just post the parts that are important:

Threaded child script:

Code: Select all

function sysCall_threadmain() 
    displayInfo('Please wait with starting bp3 client!')
-- deg to rad           
    frad=math.pi/180    
    
sim.setIntegerSignal('apropos',1)
Non-threaded child script:

Code: Select all

if (sim_call_type==sim.syscb_init) then

apropo=sim.getIntegerSignal('apropos')

if apropo==1 then        

    sim.displayDialog("integer","1 apropos",sim.dlgstyle_ok,false,nil,{0.8,0,0,0,0,0},{0.5,0,0,1,1,1})

elseif apropo~=0 then

    sim.displayDialog("integer","0 apropos",sim.dlgstyle_ok,false,nil,{0.8,0,0,0,0,0},{0.5,0,0,1,1,1})

end
I always get a '0' as display info. So the value 'apropos' still is default 'nil' after starting the simu.

Maybe there is a problem in the time of the call?
But actually it should work timewise.

Thanks so much!

Marimo
Posts: 3
Joined: 18 Mar 2019, 14:37

Re: Signal communication between Threaded Child-Scripts and Non-Threaded Child-Scripts

Post by Marimo »

Hi there,

I found the solution. The script is called later than the request of the signal.

I changed the order of calling.

Now it works, thanks!

Post Reply