Machsupport Forum

Mach Discussion => Mach4 General Discussion => Mach4 Videos => Topic started by: DazTheGas on December 17, 2017, 09:10:34 AM

Title: Mach4 and Coroutines
Post by: DazTheGas on December 17, 2017, 09:10:34 AM
Simplified explanation of Mach4 and Coroutines

https://youtu.be/t2xQYvAXT8o


DazTheGas
Title: Re: Mach4 and Coroutines
Post by: joeaverage on December 17, 2017, 12:19:24 PM
Hi Daz,
superb work, I've really struggled with coroutines, not so much the concept but the implementation, this will help BIGTIME. Thanks.

Craig
Title: Re: Mach4 and Coroutines
Post by: rhtuttle on December 18, 2017, 11:29:25 AM
What Craig said, exactly!!!

Thanks!!!

Any difference running one from a module or macro script?

RT



RT
Title: Re: Mach4 and Coroutines
Post by: dbt3000files on January 11, 2018, 06:18:17 PM
Can't seem to get coroutine working with a macro.  Anything special that needs to be done, or is that not even a thing?
Title: Re: Mach4 and Coroutines
Post by: DazTheGas on January 11, 2018, 06:34:27 PM
There are 2 instances/states of wxLua, one is for the Gui and this is where the PLC/Timer Event is that makes coroutines possible. Macros run in a different wxLua state with no PLC/Timer Event available. neither of these 2 states can comunicate with eachother directly.

DazTheGas
Title: Re: Mach4 and Coroutines
Post by: joeaverage on January 21, 2018, 10:25:05 PM
Hi Daz,
still struggling with coroutines.

Is it possible to switch back and forth between the Gcode interpreter and the GUI?

The reason I ask is because there is a thread on the forum where the OP wishes when an M6 is encountered in
a Gcode job, ie Gcode interpreter is in control, he wishes to manually jog and/or MDI ,ie GUI in control then
revert back to the interpreter to continue the job.

Naturally would require some coding so that on resumption of the job that the machine coordinates remain in sync.

Can a coroutine work across the two instances of Lua?

Craig
Title: Re: Mach4 and Coroutines
Post by: DazTheGas on January 22, 2018, 03:30:59 AM
Simple answer is no, the only way you can share data across 2 instances of lua is to use registers.

DazTheGas
Title: Re: Mach4 and Coroutines
Post by: DazTheGas on January 22, 2018, 02:23:49 PM
Hold that last "simple no" whilst I try something Chaoticone has suggested.

DazTheGas
Title: Re: Mach4 and Coroutines
Post by: joeaverage on January 22, 2018, 02:55:04 PM
Hi Daz,
yes I could easily use registers to communicate data between the two.

More importantly can say the Gcode interpreter be suspended while control is assumed by the GUI?
The interpreter would need to be 'massaged' before it was resumed.

Craig