Am 23.03.2012 um 10:30 schrieb Erik Christiansen:

> On 23.03.12 08:53, Michael Haberler wrote:
>> As for introspection on state at the gcode level, see
>> http://www.linuxcnc.org/docs/devel/html/gcode/overview.html#_predefined_named_parameters_a_id_sec_predefined_named_parameters_a
> 
> Many thanks for that link, Michael. And I thought that:
> 
> http://www.linuxcnc.org/docview/html/gcode_overview.html#sub:Named-Parameters
> 
> was the definitive reference on the subject. There are more hidden gems
> in the LinuxCNC documentation warren than any single human knows about,
> I suspect. 


yes, here is this 'hidden manual';) - it describes the embedded Python 
environment in boring detail: 
http://www.linuxcnc.org/docs/devel/html/remap/structure.html

I admit the canon and interpreter internals aspects are not as detailed as they 
could. Plowing the testcases and the source helps. The best references for the 
embedded Python exposure are:

Interpreter internals: 
http://git.linuxcnc.org/gitweb?p=emc2.git;a=blob;f=src/emc/rs274ngc/interpmodule.cc;h=3cb2ed7ede7bce140ed284c426c3ca209cf236d9;hb=f1d4b33a6b3a6c10b8220d1e0533075b60fa0e79

Canon: 
http://git.linuxcnc.org/gitweb?p=emc2.git;a=blob;f=src/emc/rs274ngc/canonmodule.cc;h=edba3cb5147684feac0e89143fc3df465e1d247d;hb=f1d4b33a6b3a6c10b8220d1e0533075b60fa0e79

the experimental Task Python plugin: 
http://git.linuxcnc.org/gitweb?p=emc2.git;a=blob;f=src/emc/task/taskmodule.cc;h=d3ae25a16c892c346d48d4e703161d3ec868508b;hb=f1d4b33a6b3a6c10b8220d1e0533075b60fa0e79


>> See tests/remap/introspect/oword.py for state access.
> 
> Seeing there, things like:
> 
> self.params["a_new_local"] = 321.0
> 
> I'm tempted to guess (based on zero prior exposure to python), that
> that's probably a hash.ยน

This is standard Python dictionary syntax, see 
http://www.tutorialspoint.com/python/python_dictionary.htm

> Having that available in bison would have made
> the symbol table much easier to implement. ;-)

it is, use std::map or std::unordered_map, see 
http://www.cplusplus.com/reference/stl/map/, 
http://en.cppreference.com/w/cpp/container/unordered_map

The interpreter uses std::map for all globals and locals, and lots of other 
data. That is, in master - it got rid of all the home-grown symbol table 
routines when I merged the remapping changes last fall.

> 
>> Exporting state from Python is left as an exercise for the reader;)
> 
> Since the translator could be run as a filter or off-line, tests need to
> be executed in gcode, so that they're real-time. I don't know of a
> method to run in-line python in gcode, and have yet to see a need for
> it, anyway. The predefined named parameters you've shared do it for me,
> AFAICT.

The manual shows how to do exactly this here: 
http://www.linuxcnc.org/docs/devel/html/remap/structure.html#remap:Python-O-word-procs

You will find lots of examples for embedded Python usage in the canned demos 
under configs/sim/remap, and regression tests using these features, like under 
tests/remap and tests/interp. 

-m


------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users

Reply via email to