Skip to content

Commit 77d7732

Browse files
committed
qtdragon family - add code for hal_glib/hal_bridge calls
can cycle start, pause and call macros thru hal_glib and zmq
1 parent 0d0e3d1 commit 77d7732

5 files changed

Lines changed: 148 additions & 7 deletions

File tree

share/qtvcp/screens/qtdragon/qtdragon_handler.py

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,9 @@ def __init__(self, halcomp, widgets, paths):
150150
STATUS.connect('graphics-gcode-properties', lambda w, d: self.update_gcode_properties(d))
151151
STATUS.connect('status-message', lambda w, d, o: self.add_external_status(d,o))
152152
STATUS.connect('runstop-line-changed', lambda w, l :self.lastRunLine(l))
153+
STATUS.connect('cycle-start-request', lambda w, state :self.btn_start_clicked(state))
154+
STATUS.connect('cycle-pause-request', lambda w, state: self.btn_pause_clicked(state))
155+
STATUS.connect('macro-call-request', lambda w, name: self.request_macro_call(name))
153156

154157
self.swoopPath = os.path.join(paths.IMAGEDIR,'lcnc_swoop.png')
155158
self.swoopURL = QtCore.QUrl.fromLocalFile(self.swoopPath)
@@ -871,7 +874,34 @@ def add_external_status(self, message, option):
871874
# Log the last run line (in auto mode) if stopped
872875
def lastRunLine(self, line):
873876
if line >0:
874-
self.add_status('last running line before stoppage: {}'.format(line))
877+
self.add_status(_translate("HandlerClass",'last running line before stoppage: {}'.format(line)))
878+
879+
# called from hal_glib to run macros from external event
880+
def request_macro_call(self, data):
881+
if not STATUS.is_mdi_mode():
882+
self.add_status(_translate("HandlerClass",'Machine must be in MDI mode to run macros'), CRITICAL)
883+
return
884+
flag = True
885+
for b in range(0,10):
886+
button = self.w['macrobutton{}'.format(b)]
887+
# prefer named INI MDI commands
888+
key = button.property('ini_mdi_key')
889+
code = INFO.get_ini_mdi_command(key)
890+
if key == '' or code is None:
891+
# fallback to legacy nth line
892+
key = button.property('ini_mdi_number')
893+
code = INFO.get_ini_mdi_command(key)
894+
try:
895+
if code is None: raise Exception
896+
flag = False
897+
except:
898+
continue
899+
if key == data:
900+
#print('match',button.objectName())
901+
text = button.text().replace('\n',' ')
902+
self.add_status(_translate("HandlerClass",'Running macro: {} {}'.format(key, text)))
903+
button.click()
904+
break
875905

876906
#######################
877907
# CALLBACKS FROM FORM #
@@ -2029,6 +2059,27 @@ def log_version(self):
20292059
self.add_status(mess, CRITICAL,noLog=True)
20302060
STATUS.emit('update-machine-log', mess, None)
20312061

2062+
def request_macro_call(self, data):
2063+
flag = True
2064+
for b in range(0,10):
2065+
button = self.w['macrobutton{}'.format(b)]
2066+
# prefer named INI MDI commands
2067+
key = button.property('ini_mdi_key')
2068+
if key == '' or INFO.get_ini_mdi_command(key) is None:
2069+
# fallback to legacy nth line
2070+
key = button.property('ini_mdi_number')
2071+
try:
2072+
code = INFO.get_ini_mdi_command(key)
2073+
if code is None: raise Exception
2074+
flag = False
2075+
except:
2076+
print('No macro code')
2077+
continue
2078+
if key == data:
2079+
#print('match',button.objectName())
2080+
button.click()
2081+
break
2082+
20322083
#####################
20332084
# KEY BINDING CALLS #
20342085
#####################

share/qtvcp/screens/qtdragon_hd/qtdragon_hd_handler.py

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,9 @@ def __init__(self, halcomp, widgets, paths):
149149
STATUS.connect('graphics-gcode-properties', lambda w, d: self.update_gcode_properties(d))
150150
STATUS.connect('status-message', lambda w, d, o: self.add_external_status(d,o))
151151
STATUS.connect('runstop-line-changed', lambda w, l :self.lastRunLine(l))
152+
STATUS.connect('cycle-start-request', lambda w, state :self.btn_start_clicked(state))
153+
STATUS.connect('cycle-pause-request', lambda w, state: self.btn_pause_clicked(state))
154+
STATUS.connect('macro-call-request', lambda w, name: self.request_macro_call(name))
152155

153156
txt1 = _translate("HandlerClass","Setup Tab")
154157
txt2 = _translate("HandlerClass","If you select a file with .html as a file ending, it will be shown here.")
@@ -890,7 +893,34 @@ def add_external_status(self, message, option):
890893
# Log the last run line (in auto mode) if stopped
891894
def lastRunLine(self, line):
892895
if line >0:
893-
self.add_status('last running line before stoppage: {}'.format(line))
896+
self.add_status(_translate("HandlerClass",'last running line before stoppage: {}'.format(line)))
897+
898+
# called from hal_glib to run macros from external event
899+
def request_macro_call(self, data):
900+
if not STATUS.is_mdi_mode():
901+
self.add_status(_translate("HandlerClass",'Machine must be in MDI mode to run macros'), CRITICAL)
902+
return
903+
flag = True
904+
for b in range(0,10):
905+
button = self.w['macrobutton{}'.format(b)]
906+
# prefer named INI MDI commands
907+
key = button.property('ini_mdi_key')
908+
code = INFO.get_ini_mdi_command(key)
909+
if key == '' or code is None:
910+
# fallback to legacy nth line
911+
key = button.property('ini_mdi_number')
912+
code = INFO.get_ini_mdi_command(key)
913+
try:
914+
if code is None: raise Exception
915+
flag = False
916+
except:
917+
continue
918+
if key == data:
919+
#print('match',button.objectName())
920+
text = button.text().replace('\n',' ')
921+
self.add_status(_translate("HandlerClass",'Running macro: {} {}'.format(key, text)))
922+
button.click()
923+
break
894924

895925
#######################
896926
# CALLBACKS FROM FORM #

share/qtvcp/screens/qtdragon_hd_vert/qtdragon_hd_vert_handler.py

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,9 @@ def __init__(self, halcomp, widgets, paths):
149149
STATUS.connect('graphics-gcode-properties', lambda w, d: self.update_gcode_properties(d))
150150
STATUS.connect('status-message', lambda w, d, o: self.add_external_status(d,o))
151151
STATUS.connect('runstop-line-changed', lambda w, l :self.lastRunLine(l))
152+
STATUS.connect('cycle-start-request', lambda w, state :self.btn_start_clicked(state))
153+
STATUS.connect('cycle-pause-request', lambda w, state: self.btn_pause_clicked(state))
154+
STATUS.connect('macro-call-request', lambda w, name: self.request_macro_call(name))
152155

153156
txt1 = _translate("HandlerClass","Setup Tab")
154157
txt2 = _translate("HandlerClass","If you select a file with .html as a file ending, it will be shown here.")
@@ -890,7 +893,34 @@ def add_external_status(self, message, option):
890893
# Log the last run line (in auto mode) if stopped
891894
def lastRunLine(self, line):
892895
if line >0:
893-
self.add_status('last running line before stoppage: {}'.format(line))
896+
self.add_status(_translate("HandlerClass",'last running line before stoppage: {}'.format(line)))
897+
898+
# called from hal_glib to run macros from external event
899+
def request_macro_call(self, data):
900+
if not STATUS.is_mdi_mode():
901+
self.add_status(_translate("HandlerClass",'Machine must be in MDI mode to run macros'), CRITICAL)
902+
return
903+
flag = True
904+
for b in range(0,10):
905+
button = self.w['macrobutton{}'.format(b)]
906+
# prefer named INI MDI commands
907+
key = button.property('ini_mdi_key')
908+
code = INFO.get_ini_mdi_command(key)
909+
if key == '' or code is None:
910+
# fallback to legacy nth line
911+
key = button.property('ini_mdi_number')
912+
code = INFO.get_ini_mdi_command(key)
913+
try:
914+
if code is None: raise Exception
915+
flag = False
916+
except:
917+
continue
918+
if key == data:
919+
#print('match',button.objectName())
920+
text = button.text().replace('\n',' ')
921+
self.add_status(_translate("HandlerClass",'Running macro: {} {}'.format(key, text)))
922+
button.click()
923+
break
894924

895925
#######################
896926
# CALLBACKS FROM FORM #

share/qtvcp/screens/qtdragon_lathe/qtdragon_lathe.ui

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12133,7 +12133,7 @@ LIFT</string>
1213312133
<number>2</number>
1213412134
</property>
1213512135
<property name="axis_letter" stdset="0">
12136-
<string>Z</string>
12136+
<string/>
1213712137
</property>
1213812138
<property name="dialog_code_string" stdset="0">
1213912139
<string>CALCULATOR</string>
@@ -14287,7 +14287,7 @@ SCROLL</string>
1428714287
<number>1</number>
1428814288
</property>
1428914289
<property name="axis_letter" stdset="0">
14290-
<string>Y</string>
14290+
<string/>
1429114291
</property>
1429214292
<property name="dialog_code_string" stdset="0">
1429314293
<string>CALCULATOR</string>
@@ -17845,7 +17845,7 @@ SCROLL</string>
1784517845
<number>2</number>
1784617846
</property>
1784717847
<property name="text">
17848-
<string>04:58:12 AM</string>
17848+
<string>03:25:03 PM</string>
1784917849
</property>
1785017850
<property name="alignment">
1785117851
<set>Qt::AlignCenter</set>

share/qtvcp/screens/qtdragon_lathe/qtdragon_lathe_handler.py

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,9 @@ def __init__(self, halcomp, widgets, paths):
153153
STATUS.connect('graphics-gcode-properties', lambda w, d: self.update_gcode_properties(d))
154154
STATUS.connect('status-message', lambda w, d, o: self.add_external_status(d,o))
155155
STATUS.connect('runstop-line-changed', lambda w, l :self.lastRunLine(l))
156+
STATUS.connect('cycle-start-request', lambda w, state :self.btn_start_clicked(state))
157+
STATUS.connect('cycle-pause-request', lambda w, state: self.btn_pause_clicked(state))
158+
STATUS.connect('macro-call-request', lambda w, name: self.request_macro_call(name))
156159

157160
txt1 = _translate("HandlerClass","Setup Tab")
158161
txt2 = _translate("HandlerClass","If you select a file with .html as a file ending, it will be shown here.")
@@ -862,7 +865,34 @@ def add_external_status(self, message, option):
862865
# Log the last run line (in auto mode) if stopped
863866
def lastRunLine(self, line):
864867
if line >0:
865-
self.add_status('last running line before stoppage: {}'.format(line))
868+
self.add_status(_translate("HandlerClass",'last running line before stoppage: {}'.format(line)))
869+
870+
# called from hal_glib to run macros from external event
871+
def request_macro_call(self, data):
872+
if not STATUS.is_mdi_mode():
873+
self.add_status(_translate("HandlerClass",'Machine must be in MDI mode to run macros'), CRITICAL)
874+
return
875+
flag = True
876+
for b in range(0,10):
877+
button = self.w['macrobutton{}'.format(b)]
878+
# prefer named INI MDI commands
879+
key = button.property('ini_mdi_key')
880+
code = INFO.get_ini_mdi_command(key)
881+
if key == '' or code is None:
882+
# fallback to legacy nth line
883+
key = button.property('ini_mdi_number')
884+
code = INFO.get_ini_mdi_command(key)
885+
try:
886+
if code is None: raise Exception
887+
flag = False
888+
except:
889+
continue
890+
if key == data:
891+
#print('match',button.objectName())
892+
text = button.text().replace('\n',' ')
893+
self.add_status(_translate("HandlerClass",'Running macro: {} {}'.format(key, text)))
894+
button.click()
895+
break
866896

867897
#######################
868898
# CALLBACKS FROM FORM #

0 commit comments

Comments
 (0)