Author Topic: Mach4 and Coroutines  (Read 1447 times)

0 Members and 1 Guest are viewing this topic.

Offline DazTheGas

  • Active Member
  • Posts: 743
  • DazTheGas
    • View Profile
Mach4 and Coroutines
« on: December 17, 2017, 09:10:34 AM »
Simplified explanation of Mach4 and Coroutines

https://youtu.be/t2xQYvAXT8o


DazTheGas
Theres always time for a choccy biccy

Online joeaverage

  • Active Member
  • Posts: 4,508
    • View Profile
Re: Mach4 and Coroutines
« Reply #1 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
My wife left with my best friend...
     and I miss him!

Offline rhtuttle

  • Active Member
  • Posts: 346
    • View Profile
Re: Mach4 and Coroutines
« Reply #2 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

Offline dbt3000files

  • Active Member
  • Posts: 34
    • View Profile
Re: Mach4 and Coroutines
« Reply #3 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?

Offline DazTheGas

  • Active Member
  • Posts: 743
  • DazTheGas
    • View Profile
Re: Mach4 and Coroutines
« Reply #4 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
Theres always time for a choccy biccy

Online joeaverage

  • Active Member
  • Posts: 4,508
    • View Profile
Re: Mach4 and Coroutines
« Reply #5 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
My wife left with my best friend...
     and I miss him!

Offline DazTheGas

  • Active Member
  • Posts: 743
  • DazTheGas
    • View Profile
Re: Mach4 and Coroutines
« Reply #6 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
Theres always time for a choccy biccy

Offline DazTheGas

  • Active Member
  • Posts: 743
  • DazTheGas
    • View Profile
Re: Mach4 and Coroutines
« Reply #7 on: January 22, 2018, 02:23:49 PM »
Hold that last "simple no" whilst I try something Chaoticone has suggested.

DazTheGas
Theres always time for a choccy biccy

Online joeaverage

  • Active Member
  • Posts: 4,508
    • View Profile
Re: Mach4 and Coroutines
« Reply #8 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
My wife left with my best friend...
     and I miss him!