Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add abort button from GUI detected during ocode error check #46

Closed
alkabal opened this issue Dec 28, 2020 · 4 comments
Closed

Add abort button from GUI detected during ocode error check #46

alkabal opened this issue Dec 28, 2020 · 4 comments

Comments

@alkabal
Copy link
Contributor

alkabal commented Dec 28, 2020

Hi

I have thinsk about doing this but does not work (i don't see hal pin goes true) :

axisrc


def my_task_stop(*event):
    probe_user_comp["abort"] = True
    self.original_task_stop(*event)
    probe_user_comp["abort"] = False #also tested with this line comment out


TclCommands.original_task_stop = TclCommands.task_stop
TclCommands.task_stop = my_task_stop


    probe_user_comp.newpin("abort", hal.HAL_BIT, hal.HAL_OUT)
@alkabal
Copy link
Contributor Author

alkabal commented Dec 28, 2020

    def error_poll(self):   	
    	
        if "axis" in self.display:
            # AXIS polls for errors every 0.2 seconds, so we wait slightly longer to make sure it's happened.
            time.sleep(0.25)
            error_pin = Popen(
                "halcmd getp probe.user.error ", shell=True, stdout=PIPE
            ).stdout.read()
            abort_pin = Popen(
                "halcmd getp probe.user.abort ", shell=True, stdout=PIPE
            ).stdout.read()                  #working with axis mod using getp axisui.abort

        elif "gmoccapy" in self.display:
            # gmoccapy polls for errors every 0.25 seconds, OR whatever value is in the [DISPLAY]CYCLE_TIME ini
            # setting, so we wait slightly longer to make sure it's happened.
            ms = int(self.inifile.find("DISPLAY", "CYCLE_TIME") or 250) + 50
            time.sleep(ms / 100)

            error_pin = Popen(
                "halcmd getp gmoccapy.error ", shell=True, stdout=PIPE
            ).stdout.read()

        else:
            print("Unable to poll %s GUI for errors" % self.display)
            return -1
            
        if "TRUE" in abort_pin:
            text = "Program stopped by user"
            self.add_history("Error: %s" % text, "", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
            print("Error", text)
            self.command.mode(linuxcnc.MODE_MANUAL)
            self.command.wait_complete()
            return -1

        if "TRUE" in error_pin:
            text = "See notification popup"
            self.add_history("Error: %s" % text, "", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
            print("error", text)
            self.command.mode(linuxcnc.MODE_MANUAL)
            self.command.wait_complete()
            return -1

        return 0

@alkabal
Copy link
Contributor Author

alkabal commented Dec 28, 2020

test editing directly axis code work fine but it seem to be not possible to use wrapped version like you do for notification

@alkabal
Copy link
Contributor Author

alkabal commented Dec 28, 2020

test using [DISLAY]USER_COMMAND_FILE=filename.py does not work better

@alkabal
Copy link
Contributor Author

alkabal commented Dec 28, 2020

in axis python code this work fine

    def task_stop(*event):
        if s.task_mode == linuxcnc.MODE_AUTO and vars.running_line.get() != 0:
            o.set_highlight_line(vars.running_line.get())
        comp["abort"] = True
        c.abort()
        c.wait_complete()
        time.sleep(0.1)
        comp["abort"] = False

comp.newpin("abort", hal.HAL_BIT, hal.HAL_OUT)

@alkabal alkabal closed this as completed Dec 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant