Skip to content

Commit

Permalink
gmoccapy -listen for zmq messages to call functons
Browse files Browse the repository at this point in the history
  • Loading branch information
c-morley committed Dec 23, 2023
1 parent 0f8f1cc commit 23d0f1b
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/emc/usr_intf/gmoccapy/gmoccapy.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
from time import strftime # needed for the clock in the GUI
#from Gtk._Gtk import main_quit

from gladevcp.zmqnetwork import ZMQSendReceive

# Throws up a dialog with debug info when an error is encountered
def excepthook(exc_type, exc_obj, exc_tb):
try:
Expand Down Expand Up @@ -167,6 +169,9 @@ def __init__(self, argv):
self.stat.poll()
self.error_channel.poll()

self.zmqmessage = ZMQSendReceive(self.external_call)
self.zmqmessage.init_zmq_subscribe()

self.builder = Gtk.Builder()
# translation of the glade file will be done with
self.builder.set_translation_domain("gmoccapy")
Expand Down Expand Up @@ -3968,6 +3973,21 @@ def _update_vc(self):
text = "Vc= {0:.2f}".format(vc)
self.widgets.lbl_vc.set_text(text)

def external_reload(self, path):
print('gmoccapy external reload:',path)
if path is None:
self.widgets.hal_action_reload.emit("activate")
else:
# use a little hack to load a specific file
self.widgets.hal_action_reload._load_file(path)

# qualify a ZMQ message and if good, call the function
def external_call(self, topic, function, args):
print('gmoccapy ext call:',topic, function, args)
# allow reloading of files
if function == 'external_reload':
self.external_reload(args[0])

def on_rbt_forward_clicked(self, widget, data=None):
if widget.get_active():
widget.set_image(self.widgets.img_spindle_forward_on)
Expand Down Expand Up @@ -5712,6 +5732,12 @@ def _make_hal_pins(self):
pin = self.halcomp.newpin("blockdelete", hal.HAL_BIT, hal.HAL_IN)
hal_glib.GPin(pin).connect("value_changed", self._blockdelete)

def __getitem__(self, item):
return getattr(self, item)

def __setitem__(self, item, value):
return setattr(self, item, value)


# Hal Pin Handling End
# =========================================================
Expand Down

0 comments on commit 23d0f1b

Please sign in to comment.