Message Component - Reset?
- phillc54
-
- Offline
- Platinum Member
-
Less
More
- Posts: 5723
- Thank you received: 2095
05 Jan 2020 03:44 #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.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
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.
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
See sections 12.3, 12.4, 12.5 & 12.6 here: linuxcnc.org/docs/devel/html/gui/axis.html#_axisrc
The following user(s) said Thank You: chimeno
Please Log in or Create an account to join the conversation.
- chimeno
- Offline
- Elite Member
-
Less
More
- Posts: 303
- Thank you received: 125
07 Jan 2020 19:04 #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
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 or Create an account to join the conversation.
- phillc54
-
- Offline
- Platinum Member
-
Less
More
- Posts: 5723
- Thank you received: 2095
07 Jan 2020 22:18 #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.
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.
The following user(s) said Thank You: chimeno
Please Log in or Create an account to join the conversation.
- chimeno
- Offline
- Elite Member
-
Less
More
- Posts: 303
- Thank you received: 125
28 Jan 2020 20:37 - 28 Jan 2020 20:38 #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 ...
tried with these but it just didn't work for me ..I get errors together, if you can help me with some guidance, thank you.
Greeting
Chimeno
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 ...
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')
time.sleep(5)
os.system('notify-send -t 10 -u low "turning off..."')
tkMessageBox.showinfo("turning off...", "power off")
Greeting
Chimeno
Last edit: 28 Jan 2020 20:38 by chimeno.
Please Log in or Create an account to join the conversation.
- phillc54
-
- Offline
- Platinum Member
-
Less
More
- Posts: 5723
- Thank you received: 2095
06 Feb 2020 03:28 #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:
I think the following will do what you want:
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
The following user(s) said Thank You: chimeno
Please Log in or Create an account to join the conversation.
- chimeno
- Offline
- Elite Member
-
Less
More
- Posts: 303
- Thank you received: 125
09 Feb 2020 17:26 #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
Thank you very much for the help, I will study your example!
regards
Chimeno
Please Log in or Create an account to join the conversation.
Time to create page: 0.082 seconds