371
Mach4 General Discussion / Re: How to trigger "action" with an input?
« on: January 09, 2023, 02:58:33 PM »
Hi,
Some Mach elements have an 'Action' and others have a 'Script'.
In general an Action is a bunch of code within Mach4 that performs a specific action. It is not viewable or editable. For example open the screen editor,
select the Events tab, and inspect the actions available as a drop down menu when you select say the GCodeLoad button, per the attached screenshot.
Other items items, for instance the CycleStart button has a script rather than an action.......although note from the Events tab it could have either or both. If you wish to see
the script the control to the right of the script will cause the script editor to open so you can view and in many cases edit the script.
Thosj has posted some code that he has put into the SigLib table, and it looks like it would work fine.
Note the the signal script triggers and runs whenever one of Machs many hundreds, both internal and external, of signal change state, which could happen many hundreds of times a second.
For this reason it is recommended that you keep the SigLib table very lean and clean, and in this regard I would write the SigLib table entries more like this:
The two functions (MyBloodyCoolantPumpON() and MyBloodyCoolantPumpOFF()) are actually functions in the screen load script. This means that there is minimal code burden
whenever the SigLIb table is called.
Please be assured I never call a spade, just a 'spade' but always a 'Bloody Spade', its a matter of technical pride you understand!
Craig
Quote
Is there a general way to execute the "actions" via siglib? Some of the gui buttons have obvious scripts i can call, others have only these actions.
Some Mach elements have an 'Action' and others have a 'Script'.
In general an Action is a bunch of code within Mach4 that performs a specific action. It is not viewable or editable. For example open the screen editor,
select the Events tab, and inspect the actions available as a drop down menu when you select say the GCodeLoad button, per the attached screenshot.
Other items items, for instance the CycleStart button has a script rather than an action.......although note from the Events tab it could have either or both. If you wish to see
the script the control to the right of the script will cause the script editor to open so you can view and in many cases edit the script.
Thosj has posted some code that he has put into the SigLib table, and it looks like it would work fine.
Note the the signal script triggers and runs whenever one of Machs many hundreds, both internal and external, of signal change state, which could happen many hundreds of times a second.
For this reason it is recommended that you keep the SigLib table very lean and clean, and in this regard I would write the SigLib table entries more like this:
Code: [Select]
[mc.ISIG_INPUT17]=function(state)
if(state==1) then
MyBloodyCoolantPumpON()
else
MyBloodyCoolantPumpOFF()
end
end,
The two functions (MyBloodyCoolantPumpON() and MyBloodyCoolantPumpOFF()) are actually functions in the screen load script. This means that there is minimal code burden
whenever the SigLIb table is called.
Please be assured I never call a spade, just a 'spade' but always a 'Bloody Spade', its a matter of technical pride you understand!
Craig