Possibility to abort self-written macro
-
@HeidiH please post your complete macro, using the </> code tags button to preserve the indentation.
-
@dc42
Please, find below the above macros with indentations:In config.g
global abortX=false
In the macro file, named X, I should be able to abort when needed:
set global.abortX=false M42 P6 S255 ; output is generated G4 S10 if global.abortX abort"0:macros/X"
In the Abort X-macro activation macro I have:
set global.abortX=true
-
@HeidiH I've edited your macros with how they should look, with the forum code tags. Please check it is correct.
Ian
-
@droftarts Thank you for your edit. I tested my files and the macro file, which I am running and am willing to abort, does still not respond to another macro (called Abort X), in which I activate the global variable of the configuration file with global.abortX=true. I don't get any warnings, still. As a result, the macro is still running.
Have I understood correctly that it is possible to abort the running macro (called X), just by including inside of it the commands
if global.abortXabort"0:macros/X"
BR; Heidi
-
@droftarts Hi, I have been testing the above ideas further using a macro, in which I have a repeatable beep-sound, which I should be possible to end if the stop macro is activated.
The code, consisting of 5 beep sounds, is as written below:
if !exists(global.abortMacro) global abortMacro = false ; var Toisto = 0 ;loop while var.Toisto < 5 echo global.abortMacro if global.abortMacro = false echo global.abortMacro M300 G4 S2 set var.Toisto = var.Toisto +1 ;iterations echo var.Toisto echo global.abortMacro if global.abortMacro = true abort "Aborted"
Then, I have Abort_activation macro, in which I change the global variable abortMacro to true:
set global.abortMacro = true
However, it seems that my Abort_activation macro does not have an effect on the ongoing beep-sound macro, when it is running. Like the beep-sound macro would check the state of the abortMacro global variable? However, my Abort_Activation macro works when used without the running beep-sound macro, as I have seen from the console.
Would I need to have some kind of break in my while loop to be able to see the changes in the global variable state during the repeatable process of beep sounds?
BR; Heidi
-
@HeidiH Please can you edit your post and use code tags, so I can see your actual code. Use the
</>
in the post formatting tools to put in three ticks on the line before and after your code.Ian
-
@droftarts Hi, thanks, I modified my code now. I don't know if those > and >> were necessary to see the indentations, but I added them anyway.
-
@HeidiH Ideally, when you paste code, to help the person helping you, they should be able to copy and paste the exact code you are using, so it can be tested. So please can you post code that is EXACTLY what you are using, ie no >> or >.
Code in loops and conditionals is indented with spaces or tabs. The amount of indentation is not critical, but code will be easier to read if you are consistent. Don't mix spaces and tabs, or it can look correct, but I think a tab is that same as one space, so it can cause problems if you have nested loops. We usually use four spaces for each indent.
Ian
-
@droftarts Hi Ian, yes, I understand completely and definitely want to do as it is easier for you. And thank you, now I got the idea that I just copy-paste inside those marks, simple :). Now the code is as it is as I have used it with Duet.
-
@droftarts Hi Ian, I modified my codes so that they would be easy to test now. So it would be great, if you could find out the cause why I can't abort on-going macro with those. I haven't figured it out yet.
BR, Heidi
-
@HeidiH I think this may be a problem of how you are calling the macros. If you start the beep macro from DWC, it will run, but if you start another macro from DWC, it will be queued behind the first macro, and only be run when the first macro is finished. This is similar to how when you set a heater temperature and wait for it to heat up from DWC, you can't do anything else from DWC, but you can from the PanelDue. If you call the beep macro from within a print job, then run that print job, then run the abort macro, I would think that would work. RRF maintains a number of separate input channels, and commands are executed sequentially within them.
Ian