Exchanging data between tasks
-
Hi,
I’m wondering if there’s a way to exchange data asynchronously between tasks. Specifically, I have two tasks: one running faster and another running significantly slower. The slower task performs a computational process that varies in execution time within known rough limits, which is why I’ve set its period slightly oversized.
My goal is to pass the results from the slower task back to the faster task as soon as the computation is complete, rather than waiting for the next cycle of the slower task.
Is there a recommended approach for achieving this?
Thanks,
Stepan -
Update - second part of the problem : I am also wondering if slower task can be run "on-demand" - asynchrounously, from the faster task. Is there any similar mechanism like for the general blocks inside some tasks that can be halted (marked as red-crossed blocks) and run at specific times using REXLANG with CallExt(".blockname"). Or is it possible to use the entire connection string in CallExt? Such as
CallExt(".Taskname.blockname")? -
@stepan-ozana Regarding "Update - second part of the problem": In the meantime, I conducted a simple test of my idea using CallExt(".Taskname.blockname"), and it seems to work. If anyone is interested, I can share the test results here.
-
@stepan-ozana Hi Stepan,
Thank you for your question. It is possible to set the start of task execution as soon as the previous task ends. More details in TASK documentation: https://www.rexygen.com/doc/ENGLISH/MANUALS/BRef/TASK.html#x26-250002
Information between tasks should be always sent via Inports and Outports if possible (SETPx function blocks can introduce undesired inverse of priorities when sending data between tasks).
Second part - "on demand" execution:
Thanks for sharing your solution! It is also possible to use SRTF function block (Set run-time flags):
Doc: https://www.rexygen.com/doc/ENGLISH/MANUALS/BRef/SRTF.html#x21-200002If you need any assistance just let me know.
Cheers,
Tomas -
@cechurat Hi Tomas,
Thanks for replying. With the SRTF block in a fast taks, I try to call a slower task on demand (setting EXDIS: True and manual pulse to EXOSH). This generally works, but the timing is not what we want.
The slower task should be executed at the end of a tick of the fast task right away and not wait for the next tick of the slow task. In other works, we want to start the slow task independent of its ticks and toggled by a manual pulse.I've shared an example project where one can see that the timing is not what we want. In the project open the TRND bock and run MP. We want the time of the top of the rising edge to match the time in the display; neglecting computation time to calculate the time.
I hope my intention is clear.
Regards
Carvin -
@carvin Hi carvin,
thanks for your feedback. I would suggest to use the SRTF function block with some certain subsystem (e.g. "sybsystem_slow") within your fast task.
Would that solve your issue?
Cheers,
Tomas