myAXIS.glade + .py work only in stand alone window

  • gfxx
  • gfxx's Avatar Topic Author
  • Visitor
  • Visitor
05 Jun 2014 04:44 - 05 Jun 2014 16:58 #47689 by gfxx
I'm able to work fine myaxis.glade file, myaxis.py and myaxis.hal file in AXIS if put my panel in EMBD_TAB section in .ini file ..... but if put it in GLADEVCP section the panel work only in for myaxis.hal_xxxx pin........ other user button, label and entry not work as expect...... I belive myaxis.py not work.

Where I find specific doc for integrating custom gladevcp panel with .py file?

Tank for any suggestion ..... I read JonT Gladevcp tutorial but I not find this particular explanation.
Last edit: 05 Jun 2014 16:58 by gfxx.

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

  • gfxx
  • gfxx's Avatar Topic Author
  • Visitor
  • Visitor
05 Jun 2014 15:40 - 05 Jun 2014 17:02 #47709 by gfxx
My mistake ..... the program run only in separate window mode ...... I don't now why yesterday night I see these wrong situation ..... Now in TAB mode or in PANEL mode with axis my program not run. Only Hal_pin take effect .... but myaxis.py not run. In separate window mode it is all ok...

file.ini
[EMC]
MACHINE = KBV_K2
DEBUG = 0

[DISPLAY]
DISPLAY = axis
EDITOR = gedit
POSITION_OFFSET = RELATIVE
POSITION_FEEDBACK = ACTUAL
MAX_FEED_OVERRIDE = 1.2
INTRO_GRAPHIC = linuxcnc.gif
INTRO_TIME = 5
PROGRAM_PREFIX = /home/k1/linuxcnc/PROVA1
INCREMENTS = 5mm 1mm .5mm .1mm .05mm .01mm .005mm
GLADEVCP = -u modifica10.py  -H mod.hal -d /home/k1/Scrivania/LAVORO/KBV_K2/POSIZIONI.glade
#GLADEVCP =  -H com.hal  /home/k1/Scrivania/LAVORO/KBV_K2/comandi.glade
#EMBED_TAB_NAME = GESTIONE
#EMBED_TAB_COMMAND = gladevcp -u modifica10.py -H mod.hal -x {XID} /home/k1/Scrivania/LAVORO/KBV_K2/POSIZIONI.glade

[FILTER]
PROGRAM_EXTENSION = .png,.gif,.jpg Greyscale Depth Image
PROGRAM_EXTENSION = .py Python Script
png = image-to-gcode
gif = image-to-gcode
jpg = image-to-gcode
py = python

[TASK]
TASK = milltask
CYCLE_TIME = 0.010

[RS274NGC]
PARAMETER_FILE = linuxcnc.var

[EMCMOT]
EMCMOT = motmod
COMM_TIMEOUT = 1.0
COMM_WAIT = 0.010
BASE_PERIOD = 50000
SERVO_PERIOD = 1000000

[HAL]
HALUI = halui
HALFILE = KBV_K2.hal
HALFILE = custom.hal
POSTGUI_HALFILE = mod.hal
#POSTGUI_HALFILE = com.hal

file.mod.hal
#loadusr -n gladevcp gladevcp -c gladevcp -u modifica10.py POSIZIONI.glade
#loadusr -Wn modifica10 python modifica10.py

net xpos-fb stepgen.0.position-fb => gladevcp.hal_label1
net ypos-fb stepgen.1.position-fb => gladevcp.hal_label2
net zpos-fb stepgen.2.position-fb => gladevcp.hal_label3
net dout-01 => gladevcp.hal_led1
net dout-02 => gladevcp.hal_led2
net estop-out => gladevcp.hal_led5

file modifica10.py
#!/usr/bin/env python3

#from Tkinter import *
	
import sqlite3
from time import sleep
from random import randint
import sys
import linuxcnc
import gtk
import hal_glib
import hal
import os
import time
import glib
import gobject
import gladevcp.makepins
from gladevcp.gladebuilder import GladeBuilder

try:
	import pygtk
	pygtk.require("2.0")
except:
	pass
try:
	import gtk
	import gtk.glade
except:
	sys.exit(1)



comune = 0

#xmlname = "/home/k1/linuxcnc/PROVA1/POSIZIONI.glade"
xmlname = "/home/k1/Scrivania/LAVORO/KBV_K2/POSIZIONI.glade"

class N:
	x0 = str
	y0 = str
	x1 = str
	y1 = str
	x2 = str
	y2 = str
	x3 = str
	y3 = str
	caso = 0

class HandlerClass:

	def __init__(self, halcomp, builder, useropts):
		self.halcomp = halcomp
		self.builder = builder
		self.nhits = 0

def get_handlers(halcomp, builder, useropts):

	return [HandlerClass(halcomp, builder, useropts)]



class AppGlade(object):
	def __init__(self):
		self.emc = linuxcnc
		self.error_channel = self.emc.error_channel()
		self.s = self.emc.stat()
		self.c = self.emc.command()
		self.builder = gtk.Builder()
		self.builder.add_from_file(xmlname)
		self.halcomp = hal.component("modifica10")
		dic={
			#"on_leggi_clicked" :self.cicla,
			#"on_ok_clicked" :self.xx0,
			"on_button1_clicked" :self.quit,
			}
		self.builder.connect_signals( dic )
		self.builder.connect_signals(self)
		self.window = self.builder.get_object("window1")
		self.window.set_default_size(300, 500)
		self.window.show()
		self.panel = gladevcp.makepins.GladePanel(self.halcomp, xmlname, self.builder, None)
		self.halcomp.ready()
		gobject.timeout_add(500, self.periodic)
		self.machine_status = 0


		

	def periodic(self):
		lettura()
		self.error_status = self.error_channel.poll()
		if self.error_status:
			self.error_kind, self.error_text = self.error_status
			if self.error_kind in (linuxcnc.NML_ERROR, linuxcnc.OPERATOR_ERROR):
				self.error_type = "Error "
			else:
				self.error_type = "Info "
			#self.message_id = self.statusbar.push(0, self.error_type + self.error_text)
		self.s.poll()
		data0 = self.s.actual_position[0]
		data1 = self.s.actual_position[1]
		data2 = self.s.actual_position[2]
		#text = "% 9.4f"% (data)
		self.halcomp.hal_label1 = round(data0,4)
		self.halcomp.hal_label2 = round(data1,4)
		self.halcomp.hal_label3 = round(data2,4)
		self.builder.get_object("ex0").set_text(str(N.x0))
		self.builder.get_object("ey0").set_text(str(N.y0))
		self.builder.get_object("ex1").set_text(str(N.x1))
		self.builder.get_object("ey1").set_text(str(N.y1))
		self.builder.get_object("ex2").set_text(str(N.x2))
		self.builder.get_object("ey2").set_text(str(N.y2))
		self.builder.get_object("ex3").set_text(str(N.x3))
		self.builder.get_object("ey3").set_text(str(N.y3))
		return True

#	def postgui(self)
#		inifile = linucnc.ini(self.ini_file)
#		postgui_halfile = inifile.find("HAL", "POSTGUI_HALFILE")
#		return postgui_halfile,sys.argv[2]

	def quit(self, object):
		sys.exit(0)
		#self.window.hide()

	def cicla(self, object):
		lettura()




def lettura():
    conn = sqlite3.connect('/home/k1/linuxcnc/PROVA1/interfaccia_posizioni')
    conn.row_factory = sqlite3.Row
    c = conn.cursor()
    c.execute("SELECT x, y FROM posizioni WHERE ROWID = (SELECT MIN(ROWID) FROM posizioni)")
    rows = c.fetchall()
    if len(rows) != 0:
       for row in rows:
           N.x0 = row[0]
           N.y0 = row[1]
    else:
                N.x0 = "2"
                N.y0 = "2"


    c.execute("SELECT x, y FROM posizioni WHERE ROWID = (SELECT MIN(ROWID) FROM posizioni) + 1")
    rows = c.fetchall()
    if len(rows) != 0:
       for row in rows:
           N.x1 = row[0]
           N.y1 = row[1]
    else:
                N.x1 = "2"
                N.y1 = "2"


    c.execute("SELECT x, y FROM posizioni WHERE ROWID = (SELECT MIN(ROWID) FROM posizioni) + 2")
    rows = c.fetchall()
    if len(rows) != 0:
       for row in rows:
           N.x2 = row[0]
           N.y2 = row[1]
    else:
                N.x2 = "2"
                N.y2 = "2"


    c.execute("SELECT x, y FROM posizioni WHERE ROWID = (SELECT MIN(ROWID) FROM posizioni) + 3")  
    rows = c.fetchall()
    if len(rows) != 0:
       for row in rows:
           N.x3 = row[0]
           N.y3 = row[1]
    else:
                N.x3 = "2"
                N.y3 = "2"

    conn.close()






if __name__ == "__main__":
	cal = AppGlade()
	gtk.main()

file POSIZIONI.glade

see file ....

File Attachment:

File Name: POSIZIONI.glade
File Size:26 KB



Where is my error??
Attachments:
Last edit: 05 Jun 2014 17:02 by gfxx.

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

  • gfxx
  • gfxx's Avatar Topic Author
  • Visitor
  • Visitor
05 Jun 2014 17:01 #47711 by gfxx
I change the title of post ..... because I see this is the real problem: my.glade and my.py work perfect with axis only in separate window ..... if try to insert them in axis in panel or tab mode the my.py program not start

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

Moderators: HansU
Time to create page: 0.131 seconds
Powered by Kunena Forum