it is described here:

http://linuxcnc.org/docs/2.7/html/config/python-interface.html


31.01.2020 21:01, John Dammeyer пишет:
Thanks Gene,

-----Original Message-----
From: Gene Heskett [mailto:ghesk...@shentel.net]

On Thursday 30 January 2020 23:30:37 John Dammeyer wrote:

I'm trying to figure out how to set up these two buttons in the HAL
file so they behave the way I'd like.
In short, its a problem still in search of a solution at my place too,
that when found should be added to the wiki. Something we can all use.
Others have had similar problems.
https://www.forum.linuxcnc.org/49-basic-configuration/26596-estop-out?start=10
Unfortunately he never posted his final solution.

Last night, for about 2 hours until 2AM, I spent some time looking through the 
AXIS python code.  I've been so spoiled by Delphi and developing Windows based 
programs I'd forgotten how bad Python (and for that matter 1970's BASIC) 
programming is.  But of course if one only has a hammer everything looks like a 
nail.

In a modern development environment one would just highlight the graphical 
object which has been positioned by dragging it to where you want it.  Then you 
double click on it and are taken to the method that deals with the on click 
event.  Here you can fill in what you want to happen for the on click.  If it's 
changing the main state based on the current status of the button then that's 
what you can do.  And you can track through the IDE each of the other methods 
in other objects to walk through the flow of the program.

You don't have to enter in various search terms like STOP or ESTOP to find the 
code fragment in the 4122 line program.

def estop_clicked(event=None):
         s.poll()
         if s.task_state == linuxcnc.STATE_ESTOP:
             c.state(linuxcnc.STATE_ESTOP_RESET)
         else:
             c.state(linuxcnc.STATE_ESTOP)

     def onoff_clicked(event=None):
         s.poll()
         if s.task_state == linuxcnc.STATE_ESTOP_RESET:
             c.state(linuxcnc.STATE_ON)
         else:
             c.state(linuxcnc.STATE_OFF)

So we know now there is an object named 'c' that has a method named 'state' 
that takes a parameter like 'STATE_ESTOP' or 'STATE_ESTOP_RESET' and probably 
assigns that value into another object 's'  that contains 'task_state'.

Now try searching for the declaration of the object 'c' or 's'.  Can you spell 
badly written software.  You'd fail a first year computing science assignment 
writing code like Microsoft basic was written in the 70's.

To quote from 
https://github.com/LinuxCNC/linuxcnc/blob/master/docs/src/code/style-guide.txt
" However, descriptive names for global variables are a must. To call a global 
function 'foo' is a shooting offense."

Odds are it's probably inside the code brought in with
'import linuxcnc *'

Haven't found that source code yet.  It should be python right?

The lack of documentation is truly astounding.
John Dammeyer





_______________________________________________
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users



_______________________________________________
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users

Reply via email to