Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion configs/sim/gmoccapy/gmoccapy_right_panel.ini
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@ INTRO_TIME = 5
# list of selectable jog increments
INCREMENTS = 1mm, 0.1mm, 0.01mm, 0.001mm, 1.2345in

MACRO = i_am_lost
MACRO = halo_world
MACRO = jog_around
MACRO = increment xinc yinc
MACRO = go_to_position X-pos Y-pos Z-pos

[MDI_COMMAND_LIST]
# for macro buttons on main oage up to 10 possible
MDI_COMMAND = G0 Z1;X0 Y0;Z0, Goto\nUser\nZero
MDI_COMMAND_MACRO1 = G53 G0 Z0;G53 G0 X0 Y0,Goto\nMachn\nZero

[FILTER]
PROGRAM_EXTENSION = .png,.gif,.jpg Grayscale Depth Image
PROGRAM_EXTENSION = .py Python Script
Expand Down Expand Up @@ -75,7 +86,7 @@ HALFILE = simulated_home.hal
POSTGUI_HALFILE = gmoccapy_postgui.hal

HALUI = halui

HALBRIDGE = hal_bridge -d
# Trajectory planner section --------------------------------------------------
[HALUI]
#No Content
Expand Down
17 changes: 13 additions & 4 deletions lib/python/common/iniinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,9 @@ def update(self):
# here we separate them to two lists (legacy) and one dict
# action_button takes it from there.
self.MDI_COMMAND_DICT={}
self.MDI_COMMAND_LIST = []
self.MDI_COMMAND_LABEL_LIST = []

# suppress error message is there is no section at all
if self.parser.has_section('MDI_COMMAND_LIST'):
try:
Expand All @@ -573,25 +576,31 @@ def update(self):
# in this case order matters in the INI
if key == 'MDI_COMMAND':
LOG.warning("INI file's MDI_COMMAND_LIST is using legacy 'MDI_COMMAND =' entries")
self.MDI_COMMAND_LIST = []
self.MDI_COMMAND_LABEL_LIST = []
temp = (self.INI.findall("MDI_COMMAND_LIST", "MDI_COMMAND")) or None
if temp is None:
self.MDI_COMMAND_LABEL_LIST.append(None)
self.MDI_COMMAND_LIST.append(None)
self.MDI_COMMAND_LABEL_LIST.append(None)
else:
for i in temp:
for count, i in enumerate(temp):
mdidatadict = {}
for num,k in enumerate(i.split(',')):
if num == 0:
self.MDI_COMMAND_LIST.append(k)
mdidatadict['cmd'] = k
if len(i.split(',')) <2:
self.MDI_COMMAND_LABEL_LIST.append(None)
mdidatadict['label'] = None
else:
self.MDI_COMMAND_LABEL_LIST.append(k)
mdidatadict['label'] = k
self.MDI_COMMAND_DICT[str(count)] = mdidatadict
break

# new way: 'MDI_COMMAND_SSS = XXXX' (SSS being any string)
# order of commands doesn't matter in the INI
else:
self.MDI_COMMAND_LIST.append(None)
self.MDI_COMMAND_LABEL_LIST.append(None)
try:
temp = self.INI.find("MDI_COMMAND_LIST",key)
name = (key.replace('MDI_COMMAND_',''))
Expand Down
7 changes: 4 additions & 3 deletions lib/python/gladevcp/gtk_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,11 @@ def CALL_MDI_WAIT(self, code, time=5, mode_return=False):
self.ensure_mode(premode)
return 0

def CALL_INI_MDI(self, number):
def CALL_INI_MDI(self, data):
try:
mdi = INFO.MDI_COMMAND_LIST[number]
mdi = INFO.get_ini_mdi_command(data)
except:
msg = 'MDI_COMMAND= # {} Not found under [MDI_COMMAND_LIST] in INI file'.format(number)
msg = 'MDI_COMMAND= # {} Not found under [MDI_COMMAND_LIST] in INI file'.format(data)
LOG.error(msg)
self.SET_ERROR_MESSAGE(msg)
return
Expand Down Expand Up @@ -479,6 +479,7 @@ def RECORD_CURRENT_MODE(self):
return mode

def RESTORE_RECORDED_MODE(self):
self.cmd.wait_complete()
self.ensure_mode(self.last_mode)

def SET_SELECTED_JOINT(self, data):
Expand Down
2 changes: 1 addition & 1 deletion src/emc/usr_intf/gmoccapy/getiniinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ def get_tool_sensor_data(self):

def get_macros(self):
# lets look in the INI file, if there are any entries
macros = self.inifile.findall("MACROS", "MACRO")
macros = self.inifile.findall("DISPLAY", "MACRO")
# If there are no entries we will return False
if not macros:
return False
Expand Down
61 changes: 56 additions & 5 deletions src/emc/usr_intf/gmoccapy/gmoccapy.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ def __init__(self, argv):
self.error_channel.poll()

# set INI path for INI info class before widgets are loaded
INFO = Info(ini=argv[2])
self.INFO = Info(ini=argv[2])
self.ACTION = Action()

self.builder = Gtk.Builder()
# translation of the glade file will be done with
Expand Down Expand Up @@ -406,9 +407,10 @@ def __init__(self, argv):
self.widgets["rbt_view_{0}".format(view)].set_active(True)
self.widgets.gremlin.set_property("view", view)

GSTAT = hal_glib.GStat()
GSTAT.connect("graphics-gcode-properties", self.on_gcode_properties)
GSTAT.connect("file-loaded", self.on_hal_status_file_loaded)
self.GSTAT = hal_glib.GStat()
self.GSTAT.connect("graphics-gcode-properties", self.on_gcode_properties)
self.GSTAT.connect("file-loaded", self.on_hal_status_file_loaded)
self.GSTAT.connect('macro-call-request', lambda w, name: self.request_macro_call(name))

# get if run from line should be used
self.run_from_line = self.prefs.getpref("run_from_line", "no_run", str)
Expand Down Expand Up @@ -1321,6 +1323,43 @@ def _make_joints_button(self):

self.joints_button_dic[name] = btn

# call INI macro (from hal_glib message)
def request_macro_call(self, data):
# if MDI command change to MDI and run
cmd = self.INFO.get_ini_mdi_command(data)
print('MDI command:',data,cmd)
if not cmd is None:
self.ACTION.RECORD_CURRENT_MODE()
LOG.debug("INI MDI COMMAND #: {} = {}".format(data, cmd))
self.ACTION.CALL_INI_MDI(data)
self.ACTION.RESTORE_RECORDED_MODE()
return

# run Macros
# some error checking
if not self.GSTAT.is_mdi_mode():
message = _("You must be in MDI mode to run macros")
self.dialogs.warning_dialog(self, _("Important Warning!"), message)
return

# look thru the INI macros
macros = self.get_ini_info.get_macros()
num_macros = len(macros)
if num_macros > 14:
num_macros = 14
for pos in range(0, num_macros):
# extract just the macro name
name = macros[pos].split()[0]
if data == name:
# get the button instance and click it
button = self["button_macro_{0}".format(pos)]
button.emit("clicked")
break
else:
# didn't match a name - give a hint
message = _("Macro {} not found ".format(data))
self.dialogs.warning_dialog(self, _("Important Warning!"), message)

# check if macros are in the INI file and add them to MDI Button List
def _make_macro_button(self):
LOG.debug("Entering make macro button")
Expand Down Expand Up @@ -1362,6 +1401,8 @@ def _make_macro_button(self):
btn.set_halign(Gtk.Align.CENTER)
btn.set_valign(Gtk.Align.CENTER)
btn.set_property("name","macro_{0}".format(pos))
# keep a reference of the button
self["button_macro_{0}".format(pos)] = btn
btn.set_property("tooltip-text", _("Press to run macro {0}".format(name)))
btn.connect("clicked", self._on_btn_macro_pressed, name)
btn.position = pos
Expand Down Expand Up @@ -6076,6 +6117,16 @@ def _make_hal_pins(self):
hal_glib.GPin(pin).connect("value_changed", self._blockdelete)


##############################
# required class boiler code #
# for subscriptable objects #
##############################
def __getitem__(self, item):
return getattr(self, item)

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

# Hal Pin Handling End
# =========================================================

Expand Down Expand Up @@ -6114,7 +6165,7 @@ def _make_hal_pins(self):

# Some of these libraries log when imported so logging level must already be set.
import gladevcp.makepins
from gladevcp.core import Info
from gladevcp.core import Info, Action
from gladevcp.combi_dro import Combi_DRO # we will need it to make the DRO
from gmoccapy import widgets # a class to handle the widgets

Expand Down
7 changes: 7 additions & 0 deletions src/hal/user_comps/hal_bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ def init_hal(self):
self[i] = QHAL.newpin('macro-cmd-{}'.format(i),QHAL.HAL_BIT, QHAL.HAL_IN)
self[i].pinValueChanged.connect(self.runMacroChanged)

for i in self.INFO.INI_MACROS:
name = i.split()[0]
LOG.debug('{} {}'.format(name,i))

self[name] = QHAL.newpin('macro-cmd-{}'.format(name),QHAL.HAL_BIT, QHAL.HAL_IN)
self[name].pinValueChanged.connect(self.runMacroChanged)

QHAL.setUpdateRate(100)
h.ready()

Expand Down
Loading