GladeVCP text string with HAL pin

More
18 Jun 2016 16:16 #76266 by terkaa
Hi,

I am working this ATC panel for my project. I was wondering if there is a way to pass a text string from HAL component to GladeVCP or as a second option to use passed HAL pin numeric value as a selector for text string within GladeVCP. I would like to use ATC step no as a selector to show a text string telling what ATC is actually waiting for ie. "if(step == 2 ) Text_box_string="Waiting for arm vertical position" What would be best solution for this?



File Attachment:


Tero

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

More
21 Jun 2016 21:21 #76369 by newbynobi
You may want to use gmoccapy user messages to show the infk text and do the selection of the 'show' hal pi with a hal component like mux

Norbert

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

More
22 Jun 2016 04:12 #76391 by terkaa
Hi,

Thank you for suggestion but this is not what I am looking for. Could this be done with Python in handler.py? I was thinking of case structure like:

switch(step_no)

case 1:
message.label.text = "Waiting for user input"
case 2:
message.label.text = "Waiting for shotpin out"

.......
case 31:
message.label.text = "Waiting for enable to go out"

My skills with Python are total 0 so I would need an example that I could modify to suit my needs.

Tero

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

More
22 Jun 2016 06:25 #76397 by newbynobi
Hallo Tero,

yes, that can be done.
Just make a "user_tab" with a label, embed that one on a position of your choice and set the text with python.
But I do not have a sample for that. You could look on the python file sim/gmoccapy/gmoccapy_plasma/plasma.py.
That one creates hal pin and does handle also widgets to show internal values.

Norbert

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

More
23 Jun 2016 20:00 - 23 Jun 2016 21:00 #76513 by terkaa
OK, here it is:

#!/usr/bin/env python
# -*- coding:UTF-8 -*-

import hal
import hal_glib
import gtk

step_strings = {
'0': 'home magazine',
'1': 'waiting at start jog is enabled',
'2': 'Request next tool from magazine',
'3': 'Wait for magazine',
'4': 'Magazine hand unlock',
'5': 'Check hand unlock rotate arm horizontal to grip tool',
'6': 'Check arm horizontal & Magazine hand lock',
'7': 'Check arm locked & arm_advance',
'8': 'Check arm advanced & arm vertical',
'9': 'Check arm is vertical & arm retract',
'10': 'Check arm is retracted & orient spindle',
'11': 'Check spindle is orient & arm to spindle',
'12': 'Check arm is at spindle & arm horizontal',
'13': 'Check arm is horizontal & tool unclamp',
'14': 'Check tool is unclamped & arm advance',
'15': 'Check arm is advance & arm 180 deg pin',
'16': 'Check arm 180 deg pin is in & arm 180 degs',
'17': 'Check arm is vertical & 180 deg pin out',
'18': 'Check 180 deg pin is out & arm vertical',
'19': 'Check arm is retracted & tool clamp',
'20': 'Check tool clamp & spindle hand unlock',
'21': 'Check spindle hand unlock && arm vertical',
'22': 'Check arm vertical',
'23': 'Check arm vertical && spindle hand lock',
'24': 'Check hand is locked & arm to magazine',
'25': 'Check arm is at magazine & Spindle orient off',
'26': 'Check Orient off & magazine shotpin out',
'27': 'Check magazine shotpin out & rotate magazine',
'28': 'Wait for magazine',
'29': 'Check magazine shotpin and advance arm',
'30': 'Check arm advance & arm horizontal',
'31': 'Check arm horizontal & arm retract',
'32': 'Check arm retract & unlock hand',
'33': 'Check unlock & arm vertical',
'34': 'Check arm vertical & reset atc',
'35': 'Wait for enable to go out',
'100': 'Homing',
'101': 'Jog',
'102': 'Jog return'
}

class AtcClass:

def __init__(self, halcomp, builder, useropts):
self.builder = builder
self.halcomp = halcomp
self.lbl_status = self.builder.get_object("status_label")
#self.lbl_atc_step = self.builder.get_object("hal_atc_step_no")
#self.lbl_current_tool = self.builder.get_object("hal_current_tool")

def _on_destroy(self, obj, data = None):
self.ini.save_state(self)

def on_hal_current_tool_hal_pin_changed(self, widget, data = None):
print("eee %s" % (widget.get_label()));
text_file = open("last_tool.sav", "w")
text_file.write("Last Tool: %s" % (widget.get_label()))
text_file.close()

def on_hal_atc_step_no_hal_pin_changed(self, widget, data = None):
step_label = step_strings.get(widget.get_label(), "none")
self.lbl_status.set_label(step_label);

def get_handlers(halcomp, builder, useropts):
return[AtcClass(halcomp, builder, useropts)]

Seems to work also has ability to save number of tool on spindle for recovering after power down.

File Attachment:
Last edit: 23 Jun 2016 21:00 by terkaa.

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

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