From 23d0f1b9860e2d90b14dca44e8b6be2b845ca1de Mon Sep 17 00:00:00 2001 From: CMorley Date: Fri, 22 Dec 2023 16:08:22 -0800 Subject: [PATCH] gmoccapy -listen for zmq messages to call functons --- src/emc/usr_intf/gmoccapy/gmoccapy.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/emc/usr_intf/gmoccapy/gmoccapy.py b/src/emc/usr_intf/gmoccapy/gmoccapy.py index 4645da8fb3c..372274f3db8 100644 --- a/src/emc/usr_intf/gmoccapy/gmoccapy.py +++ b/src/emc/usr_intf/gmoccapy/gmoccapy.py @@ -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: @@ -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") @@ -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) @@ -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 # =========================================================