Gremlin

More
12 Dec 2012 18:03 - 12 Dec 2012 18:04 #27615 by ArcEye
Replied by ArcEye on topic Gremlin
Thanks Chris

I have some debugging of and potentially re-writing of parts of Gremlin to look at.
I'll might start by substituting the file updating code with that from Axis, to ensure that it is reading the emcStatus struct and not a local variable.

That screen shot looks nice! clean design. I bet the response is snappy being written in C+

Thanks, it is just an Axis clone for now, made it easier to implement like for like features, without spending too long thinking about design.

Once finished, I will use the same underlying code with a different GUI based upon a main docking window and dockable widgets.
Should allow much more flexibilty and ability to just hide the bits you are not using and fill the space with those that you are.

Lots more to do yet though.

regards
Last edit: 12 Dec 2012 18:04 by ArcEye.

Please Log in or Create an account to join the conversation.

More
12 Dec 2012 19:08 - 12 Dec 2012 19:39 #27617 by ArcEye
Replied by ArcEye on topic Gremlin
EDIT - Partial sucess

I hacked the gremlin code thus
def realize(self, widget):
        self.set_current_view()
        #s = self.stat
        s = linuxcnc.stat()
and
def load(self,filename = None):
        #s = self.stat
        s = linuxcnc.stat()
..........
            parameter = self.inifile.find("RS274NGC", "PARAMETER_FILE")
            temp_parameter = os.path.join(td, os.path.basename("linuxcnc.var"))
          #  if parameter:
          #      shutil.copy(parameter, temp_parameter)
            canon.parameter_file = temp_parameter

This forces the use of the global emcStatus structure (or rather its python binding equivalent, linuxcnc.stat) and makes it use emcStatus->task.file from that, not some local variable passed by another mechanism.

The other error caused by shutil being unable to open sim_mm.var referenced in the .INI file (even though it was right there in the config dir)
was bypassed by hard coding linuxcnc.var as an alternative and commenting out the shutil.copy() call

Result, a fully functioning preview.

However it does not update when a new file is loaded, back to the drawing board :sick:



regards
Attachments:
Last edit: 12 Dec 2012 19:39 by ArcEye.

Please Log in or Create an account to join the conversation.

More
12 Dec 2012 20:13 - 12 Dec 2012 21:50 #27619 by ArcEye
Replied by ArcEye on topic Gremlin
Hopefully now cracked it? :unsure:

The substitution
#s = self.stat
    s = linuxcnc.stat()
was not really necessary, they turned out to have the same contents, so were being updated at the same time.

Commenting out use of parameter
parameter = self.inifile.find("RS274NGC", "PARAMETER_FILE")
            temp_parameter = os.path.join(td, os.path.basename("linuxcnc.var"))
          #  if parameter:
          #      shutil.copy(parameter, temp_parameter)
            canon.parameter_file = temp_parameter
was necessary, for this context at least and prevented failure of the call to self.load_preview(filename, canon, unitcode, initcode)

What was needed was a mechanism to force gremlin to check if the displayed file was the current one and if not update, in the absence of any input through gladeVCP.

This was achieved by creating a global oldFile and updating it every time Gremlin loaded a new file
def load(self,filename = None):
        s = self.stat
        #s = linuxcnc.stat()
        s.poll()
        if not filename and s.file:
            filename = s.file
        elif not filename and not s.file:
            return
            
        global oldFile
        oldFile = filename    
.............................

Then the poll() sub was changed to check current filename against the one held in oldFile
def poll(self):
        global oldFile
        s = self.stat
        s.poll()
        fingerprint = (self.logger.npts, self.soft_limits(),
            s.actual_position, s.joint_actual_position,
            s.homed, s.g5x_offset, s.g92_offset, s.limit, s.tool_in_spindle,
            s.motion_mode, s.current_vel)

        if s.file != oldFile:
            self.load()
            
        if fingerprint != self.fingerprint:
            self.fingerprint = fingerprint
            self.queue_draw()

        # return self.visible
        return True

Result, Gremlin now integrates with my GUI and loads a new preview when a new file is opened

NB.
For this to work however you need to implement a status loop in the GUI to compare and update the emcStatus struct.
Mine is only partially complete, so for now I directly write the new file name when ever one is opened with
strcpy(emcStatus->task.file, program);




Hopefully save someone else the same head scratching in the future

regards
Attachments:
Last edit: 12 Dec 2012 21:50 by ArcEye.

Please Log in or Create an account to join the conversation.

More
12 Dec 2012 20:49 #27620 by BigJohnT
Replied by BigJohnT on topic Gremlin
Dang, and I was hoping someone had cracked the gremlin error when loaded with GladeVCP...

John

Please Log in or Create an account to join the conversation.

More
12 Dec 2012 22:07 #27625 by ArcEye
Replied by ArcEye on topic Gremlin

Dang, and I was hoping someone had cracked the gremlin error when loaded with GladeVCP...
John


Sorry I have hi-jacked your thread, hopefully the program flow I used will help you get yours working

I start linuxcnc from a test config (modified axis_mm.ini ) that specifies my GUI, qtCNC in the DISPLAY = qtCNC
This ensures that real time is loaded, linuxcnc, then the GUI
Once the GUI has loaded, I launch Gremlin (with the same ini file as an argument) and then embed it in my GUI

Because Gremlin is native to your system, I assume that you can start it within a widget in your GUI, rather than a main window as gremlin-run does.
I didn't have that choice so had to let it start in a window, then get its winID and then grab it and embed it in my container widget.

good luck

Please Log in or Create an account to join the conversation.

More
12 Dec 2012 23:58 #27635 by BigJohnT
Replied by BigJohnT on topic Gremlin
No problem it just draws more attention to the thread...

John

Please Log in or Create an account to join the conversation.

More
13 Dec 2012 09:24 #27655 by cmorley
Replied by cmorley on topic Gremlin
John is there an actual problem or are you just trying to rid your self of the error message?

Chris M

Please Log in or Create an account to join the conversation.

More
13 Dec 2012 19:47 #27662 by BigJohnT
Replied by BigJohnT on topic Gremlin
Error messages bother me LOL because I know something is wrong when you see them. Also it clutters up the terminal when your testing.

John

Please Log in or Create an account to join the conversation.

More
14 Dec 2012 20:50 #27726 by BigJohnT
Replied by BigJohnT on topic Gremlin
Something has to be different, when I run gscreen I get:

GtkWarning: _gdk_drawable_get_source_drawable: assertion `GDK_IS_DRAWABLE (drawable)' failed

But when I run my GUI I get:

(gui7:19209): GtkGLExt-CRITICAL **: gtk_widget_get_gl_context: assertion `GTK_WIDGET_REALIZED (widget)' failed

(gui7:19209): GtkGLExt-CRITICAL **: gtk_widget_get_gl_window: assertion `GTK_WIDGET_REALIZED (widget)' failed

(gui7:19209): GtkGLExt-CRITICAL **: gtk_widget_get_gl_window: assertion `GTK_WIDGET_REALIZED (widget)' failed
Traceback (most recent call last):
File "/usr/lib/pymodules/python2.6/gladevcp/hal_gremlin.py", line 66, in <lambda>
self.gstat.connect('file-loaded', lambda w, f: self._load(f))
File "/usr/lib/pymodules/python2.6/rs274/glcanon.py", line 268, in inner
self.deactivate()
File "/usr/lib/pymodules/python2.6/gremlin.py", line 153, in deactivate
gldrawable.gl_end()
AttributeError: 'NoneType' object has no attribute 'gl_end'

John

Please Log in or Create an account to join the conversation.

More
15 Dec 2012 20:15 #27763 by ArcEye
Replied by ArcEye on topic Gremlin
A query re Gremlin and python for you or Chris, John

It has a method self.clear_live_plotter() which I want to bind to a keyboard combination to make it work in the same way as Axis

I have wasted a lot of time trying to get XXX.bind("Ctrl k", self.clear_live_plotter()) to work, but have been unable to determine what should replace XXX

Reading docs it just needs to be the frame window or widget, but everything I have tried errors with
File "/usr/local/bin/gremlin", line 27, in __init__
XXX.bind("<Control-k>", self.clear_live_plotter())
AttributeError: 'XXX' object has no attribute 'bind'

or similar

Any ideas?

regards

Please Log in or Create an account to join the conversation.

Time to create page: 0.429 seconds
Powered by Kunena Forum