Message Component - Reset?

More
6 years 9 months ago #154074 by phillc54
Replied by phillc54 on topic Message Component - Reset?
You will get that error if you have the HAL Configuration window open while Axis is exiting. The error is because HAL Configuration cannot find the pin because it was removed by Axis when it was exiting.

You could also achieve the same with the following in the .axisrc file in your home directory which allows you to update LinuxCNC without have to edit axis.py again.
Code:
def user_hal_pins(): comp.newpin('notifications', hal.HAL_BIT, hal.HAL_OUT) comp.ready() def user_live_update(): if len(notifications.widgets): comp ["notifications"] = True else: comp ["notifications"] = False
You could have a USER_COMMAND_FILE instead of .axisrc.

See sections 12.3, 12.4, 12.5 & 12.6 here: linuxcnc.org/docs/devel/html/gui/axis.html#_axisrc

Please Log in to join the conversation.

More
6 years 9 months ago #154235 by chimeno
Replied by chimeno on topic Message Component - Reset?
Hi Phill,
  Thank you very much for the answer, modify the code because the .axisrc file does not work for me, it is in the directory where I have the configuration files .ini and .hal, formerly if it worked for me, something else I should do, anyway add your code via USER_COMMAND_FILE and it works very well, I admire your work here in the forum!
thanks
Chimeno

Please Log in to join the conversation.

More
6 years 9 months ago #154266 by phillc54
Replied by phillc54 on topic Message Component - Reset?
If you use .axisrc it needs to be in your home directory (I should have said ~/.axisrc). It is then used by every LinuxCNC config.

A USER_COMMAND_FILE allows you to define a different file for each config and it will take precedence over ~/.axisrc if you have both.

Please Log in to join the conversation.

More
6 years 9 months ago #156046 by chimeno
Replied by chimeno on topic Message Component - Reset?
Hi Phill,
With your guide example I want to perform the PC shutdown by means of a hal-pin, how could a message appear on the screen "turning off PC" wait 5 seconds and turn off, for now this is what I have ...
Code:
def user_hal_pins(): comp.newpin('turn-off-machine', hal.HAL_BIT, hal.HAL_IN) comp.newpin('turn-off-machine.is-on', hal.HAL_BIT, hal.HAL_OUT) comp.ready() def user_live_update(): if bool(comp["turn-off-machine"]): comp ["turn-off-machine.is-on"] = False else: os.system('systemctl poweroff')
tried with these but it just didn't work for me ..
Code:
time.sleep(5) os.system('notify-send -t 10 -u low "turning off..."') tkMessageBox.showinfo("turning off...", "power off")
I get errors together, if you can help me with some guidance, thank you.
Greeting
Chimeno

Please Log in to join the conversation.

More
6 years 8 months ago #156612 by phillc54
Replied by phillc54 on topic Message Component - Reset?
Sorry, I meant to reply earlier but I got a bit sidetracked.

I think the following will do what you want:
Code:
sdShow = False sdCount = 0 sdSecs = '543210' def user_hal_pins(): comp.newpin('turn-off-machine', hal.HAL_BIT, hal.HAL_IN) comp.ready() def user_live_update(): global sdShow, sdCount, sdStart, sdLabel, sdWindow if comp['turn-off-machine'] and s.interp_state == linuxcnc.INTERP_IDLE: if not sdShow: sdStart = time.time() sdWindow = Tkinter.Toplevel(relief='ridge', borderwidth=4) sdWindow.title('SHUTDOWN') sdLabel = Tkinter.Label(sdWindow, fg='red', font='sans 16 bold') sdLabel.pack() sdShow = True else: if sdCount > 5: sdWindow.destroy() os.system('systemctl poweroff') elif time.time() > sdStart + sdCount: msg = 'Turning machine off in {} seconds'.format(sdSecs[sdCount]) sdLabel.config(text=msg) sdCount += 1 elif sdShow: sdWindow.destroy() sdShow = False sdCount = 0

Please Log in to join the conversation.

More
6 years 8 months ago #156893 by chimeno
Replied by chimeno on topic Message Component - Reset?
Hi @phillc54
  Thank you very much for the help, I will study your example!

regards
Chimeno

Please Log in to join the conversation.

Time to create page: 0.079 seconds
Powered by Kunena Forum