Hello Guest it is April 25, 2024, 03:38:07 PM

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Muemonic

Pages: 1
1
Mach4 General Discussion / Calling an "Action" from a lua script
« on: January 28, 2016, 10:21:46 PM »
Greetings.

I have built an external pendant that removes a lot of the need for clicking on screen buttons. Using the lua scripts and the resources, almost everything is currently working, including multiple handwheels, start/stop/feedhold, M01, jogging, overrides, etc.

However, I do have an issue that I haven't been able to find the solution for. I've done a ton of searches, but haven't come up with the answer yet.

In the standard screens, the jogging page has a button the increments the jogging step through the steps defined in the configuration. This is triggered via the "Left Up Action" event on the button, and calls the internal action "Cycle Jog Increment". Within these actions, there are other useful actions, (sticking with the jog motif), "Jog Inc. 1" ... Etc. This allows you to directly set the increment to the one selected in the configuration file. (Or as another example, the enable button using the "Left Down Action" and "Left Up Action" to triggering the "Enable On/Enable Off".)

Looking over the documentation, there doesn't seem to be a mc function that allows you to trigger these actions from lua, and there is not an equivalent function to directly trigger these events.

On some older code, they mentioned deprecated ways of using the scr. functions to trigger button presses and such. Not only are they not the "correct" way now, but they have been mostly removed. Trying the existing GetProperty/SetProperty doesn't work, as they don't trigger actions or scripts, only allow you you to set the properties of the items on the screen. (The stuff on the first tab on the item properties in the editor.)

I may have missed them, but is there a way of triggering these "internal" actions from lua? And by extension, is there a way of trigging any of the other "events" that are registered on the second tab of a screen button/item. (Yes, you could directly call script actions from within lua. Actions seem to be the main missing piece, with perhaps "goto screen", but I haven't researched that one.)

I know there are other ways of doing this. As an example, I have code written that uses "mcJogSetInc()" to set the individual axis increments. (Which in some ways is more powerful, as you can have different increments for each axis.) However, there may be cases that you need to trigger the internal action from lua. And in this case, the direct call does not give the use a way of using the configured jog increments from the configuration file.

Is there a way of triggering this action, perhaps a "mcTriggerAction(inst, "Cycle Jog Increment")", or are there plans to directly map all the actions to mc lua calls (IE. "mcActionCycleJogIncrement())?

Thanks all.

Jim

Pages: 1