Hello Keith,
Yes, you have to poll the plugin. You also have to know that there are some special cases. If you call Informplugin then the macro will wait for the job to complete. Also, if you make a plugin which executes something when a button is pressed (Buttonpress_event) then the same happens if you call exec.Callbutton. In these cases you don't have to program anything, the execution comes back when the plugin finished its job. (If you have to call Code, CodeSync or Codelist in the plugin then use the button event, because Informplugin will not do these.)
The other case is if you start a new thread in the plugin to do a longer job. You can start it and then you can check a flag if it is finished. The flag can be checked by an Informplugin call, but it can be a buttons state or an LED too. (Also start it with button event if it contains gcode!) Here is a sample for both from the same macro:
- Code: Select all
exec.Callbutton(848); // Goto probe pos
if (exec.Ismacrostopped()) return;
exec.Callbutton(821); // Start probing
while (!AS3.Getbuttonstate(821) && !exec.Ismacrostopped()) Thread.Sleep(10);
while (AS3.Getbuttonstate(821) && !exec.Ismacrostopped()) Thread.Sleep(10);
exec.Wait(500);
if (exec.Ismacrostopped()) return;
First I send the machine to the probe position: the Callbutton will return only if the movement is finished or stopped. Then I press the start probing button and first I wait for the button to turn on then to turn off. This is because the probing runs in a separate thread which is started by the start probing button and the state of the buttons shows if it is still running.