Skip to content

Commit 90f51a6

Browse files
committed
qtdragon family -add a log of the 'last run line', more status levels
When the interpeter stops in automode the last run line will be logged. added machineLog levels to status messages fixed a annoying error message when in auto mode a click the status tab
1 parent f93c962 commit 90f51a6

File tree

4 files changed

+94
-15
lines changed

4 files changed

+94
-15
lines changed

share/qtvcp/screens/qtdragon/qtdragon_handler.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,13 @@
5757
PAGE_TOOL = 3
5858
PAGE_NGCGUI = 4
5959

60+
# message constants
6061
DEFAULT = 0
6162
WARNING = 1
6263
CRITICAL = 2
64+
DEBUG = 3
65+
SUCCESS = 4
66+
ERROR = 5
6367

6468
VERSION ='1.4'
6569

@@ -145,6 +149,7 @@ def __init__(self, halcomp, widgets, paths):
145149
STATUS.connect('override-limits-changed', lambda w, state, data: self._check_override_limits(state, data))
146150
STATUS.connect('graphics-gcode-properties', lambda w, d: self.update_gcode_properties(d))
147151
STATUS.connect('status-message', lambda w, d, o: self.add_external_status(d,o))
152+
STATUS.connect('runstop-line-changed', lambda w, l :self.lastRunLine(l))
148153

149154
self.swoopPath = os.path.join(paths.IMAGEDIR,'lcnc_swoop.png')
150155
self.swoopURL = QtCore.QUrl.fromLocalFile(self.swoopPath)
@@ -863,6 +868,11 @@ def add_external_status(self, message, option):
863868
if log:
864869
STATUS.emit('update-machine-log', "{}\n{}".format(title, logtext), 'TIME')
865870

871+
# Log the last run line (in auto mode) if stopped
872+
def lastRunLine(self, line):
873+
if line >0:
874+
self.add_status('last running line before stoppage: {}'.format(line))
875+
866876
#######################
867877
# CALLBACKS FROM FORM #
868878
#######################
@@ -1528,9 +1538,15 @@ def add_status(self, message, alertLevel = DEFAULT, noLog = False):
15281538
opt = 'TIME'
15291539
if alertLevel==DEFAULT:
15301540
self.set_style_default()
1541+
elif alertLevel==SUCCESS:
1542+
opt += ',SUCCESS'
1543+
self.set_style_default()
15311544
elif alertLevel==WARNING:
15321545
opt += ',WARNING'
15331546
self.set_style_warning()
1547+
elif alertLevel==ERROR:
1548+
opt += ',ERROR'
1549+
self.set_style_warning()
15341550
else:
15351551
opt += ',CRITICAL'
15361552
self.set_style_critical()
@@ -1554,9 +1570,12 @@ def enable_auto(self, state):
15541570

15551571
def enable_onoff(self, state):
15561572
if state:
1557-
self.add_status(_translate("HandlerClass","Machine ON"))
1573+
self.add_status(_translate("HandlerClass","Machine ON"), SUCCESS)
15581574
else:
1559-
self.add_status(_translate("HandlerClass","Machine OFF"))
1575+
if not STATUS.estop_is_clear():
1576+
self.add_status(_translate("HandlerClass","ESTOP!"), CRITICAL)
1577+
else:
1578+
self.add_status(_translate("HandlerClass","MACHINE OFF"), ERROR)
15601579
self.w.btn_spindle_pause.setChecked(False)
15611580
self.h['eoffset-spindle-count'] = 0
15621581
for widget in self.onoff_list:
@@ -1839,7 +1858,8 @@ def adjust_stacked_widgets(self,requestedIndex,mode_change=False):
18391858

18401859
# if indexes don't match then request is disallowed
18411860
# give a warning and reset the button check
1842-
if main_index != requestedIndex and not main_index in(TAB_CAMERA,TAB_GCODES,TAB_SETUP):
1861+
if main_index != requestedIndex and not main_index in(TAB_CAMERA, TAB_GCODES,
1862+
TAB_STATUS, TAB_SETUP):
18431863
self.add_status("Cannot switch pages while in AUTO mode", WARNING)
18441864
self.w.stackedWidget_mainTab.setCurrentIndex(0)
18451865
self.w.btn_main.setChecked(True)

share/qtvcp/screens/qtdragon_hd/qtdragon_hd_handler.py

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,13 @@
6262
MACRO = True
6363
NO_MACRO = False
6464

65+
# message constants
6566
DEFAULT = 0
6667
WARNING = 1
6768
CRITICAL = 2
69+
DEBUG = 3
70+
SUCCESS = 4
71+
ERROR = 5
6872

6973
VERSION ='1.5'
7074

@@ -144,6 +148,7 @@ def __init__(self, halcomp, widgets, paths):
144148
STATUS.connect('override-limits-changed', lambda w, state, data: self._check_override_limits(state, data))
145149
STATUS.connect('graphics-gcode-properties', lambda w, d: self.update_gcode_properties(d))
146150
STATUS.connect('status-message', lambda w, d, o: self.add_external_status(d,o))
151+
STATUS.connect('runstop-line-changed', lambda w, l :self.lastRunLine(l))
147152

148153
txt1 = _translate("HandlerClass","Setup Tab")
149154
txt2 = _translate("HandlerClass","If you select a file with .html as a file ending, it will be shown here.")
@@ -882,6 +887,11 @@ def add_external_status(self, message, option):
882887
if log:
883888
STATUS.emit('update-machine-log', "{}\n{}".format(title, logtext), 'TIME')
884889

890+
# Log the last run line (in auto mode) if stopped
891+
def lastRunLine(self, line):
892+
if line >0:
893+
self.add_status('last running line before stoppage: {}'.format(line))
894+
885895
#######################
886896
# CALLBACKS FROM FORM #
887897
#######################
@@ -1586,9 +1596,15 @@ def add_status(self, message, alertLevel = DEFAULT, noLog = False):
15861596
opt = 'TIME'
15871597
if alertLevel==DEFAULT:
15881598
self.set_style_default()
1599+
elif alertLevel==SUCCESS:
1600+
opt += ',SUCCESS'
1601+
self.set_style_default()
15891602
elif alertLevel==WARNING:
15901603
opt += ',WARNING'
15911604
self.set_style_warning()
1605+
elif alertLevel==ERROR:
1606+
opt += ',ERROR'
1607+
self.set_style_warning()
15921608
else:
15931609
opt += ',CRITICAL'
15941610
self.set_style_critical()
@@ -1607,10 +1623,13 @@ def enable_auto(self, state):
16071623

16081624
def enable_onoff(self, state):
16091625
if state:
1610-
self.add_status(_translate("HandlerClass","Machine ON"))
1626+
self.add_status(_translate("HandlerClass","Machine ON"), SUCCESS)
16111627
else:
1612-
self.add_status(_translate("HandlerClass","Machine OFF"))
1613-
self.w.btn_spindle_pause.setChecked(False)
1628+
if not STATUS.estop_is_clear():
1629+
self.add_status(_translate("HandlerClass","ESTOP!"), CRITICAL)
1630+
else:
1631+
self.add_status(_translate("HandlerClass","MACHINE OFF"), ERROR)
1632+
self.w.btn_spindle_pause.setChecked(False)
16141633
self.h['eoffset-spindle-count'] = 0
16151634
for widget in self.onoff_list:
16161635
self.w[widget].setEnabled(state)
@@ -1866,7 +1885,8 @@ def adjust_stacked_widgets(self,requestedIndex):
18661885

18671886
# if indexes don't match then request is disallowed
18681887
# give a warning and reset the button check
1869-
if main_index != requestedIndex and not main_index in(TAB_CAMVIEW,TAB_GCODES,TAB_SETUP):
1888+
if main_index != requestedIndex and not main_index in(TAB_CAMVIEW, TAB_GCODES,
1889+
TAB_STATUS, TAB_SETUP):
18701890
self.add_status(_translate("HandlerClass","Cannot switch pages while in AUTO mode"), WARNING)
18711891
self.w.stackedWidget_mainTab.setCurrentIndex(0)
18721892
self.w.btn_main.setChecked(True)

share/qtvcp/screens/qtdragon_hd_vert/qtdragon_hd_vert_handler.py

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,13 @@
6262
MACRO = True
6363
NO_MACRO = False
6464

65+
# message constants
6566
DEFAULT = 0
6667
WARNING = 1
6768
CRITICAL = 2
69+
DEBUG = 3
70+
SUCCESS = 4
71+
ERROR = 5
6872

6973
VERSION ='1.5'
7074

@@ -144,6 +148,7 @@ def __init__(self, halcomp, widgets, paths):
144148
STATUS.connect('override-limits-changed', lambda w, state, data: self._check_override_limits(state, data))
145149
STATUS.connect('graphics-gcode-properties', lambda w, d: self.update_gcode_properties(d))
146150
STATUS.connect('status-message', lambda w, d, o: self.add_external_status(d,o))
151+
STATUS.connect('runstop-line-changed', lambda w, l :self.lastRunLine(l))
147152

148153
txt1 = _translate("HandlerClass","Setup Tab")
149154
txt2 = _translate("HandlerClass","If you select a file with .html as a file ending, it will be shown here.")
@@ -882,6 +887,11 @@ def add_external_status(self, message, option):
882887
if log:
883888
STATUS.emit('update-machine-log', "{}\n{}".format(title, logtext), 'TIME')
884889

890+
# Log the last run line (in auto mode) if stopped
891+
def lastRunLine(self, line):
892+
if line >0:
893+
self.add_status('last running line before stoppage: {}'.format(line))
894+
885895
#######################
886896
# CALLBACKS FROM FORM #
887897
#######################
@@ -1586,9 +1596,15 @@ def add_status(self, message, alertLevel = DEFAULT, noLog = False):
15861596
opt = 'TIME'
15871597
if alertLevel==DEFAULT:
15881598
self.set_style_default()
1599+
elif alertLevel==SUCCESS:
1600+
opt += ',SUCCESS'
1601+
self.set_style_default()
15891602
elif alertLevel==WARNING:
15901603
opt += ',WARNING'
15911604
self.set_style_warning()
1605+
elif alertLevel==ERROR:
1606+
opt += ',ERROR'
1607+
self.set_style_warning()
15921608
else:
15931609
opt += ',CRITICAL'
15941610
self.set_style_critical()
@@ -1607,10 +1623,13 @@ def enable_auto(self, state):
16071623

16081624
def enable_onoff(self, state):
16091625
if state:
1610-
self.add_status(_translate("HandlerClass","Machine ON"))
1626+
self.add_status(_translate("HandlerClass","Machine ON"), SUCCESS)
16111627
else:
1612-
self.add_status(_translate("HandlerClass","Machine OFF"))
1613-
self.w.btn_spindle_pause.setChecked(False)
1628+
if not STATUS.estop_is_clear():
1629+
self.add_status(_translate("HandlerClass","ESTOP!"), CRITICAL)
1630+
else:
1631+
self.add_status(_translate("HandlerClass","MACHINE OFF"), ERROR)
1632+
self.w.btn_spindle_pause.setChecked(False)
16141633
self.h['eoffset-spindle-count'] = 0
16151634
for widget in self.onoff_list:
16161635
self.w[widget].setEnabled(state)
@@ -1866,7 +1885,8 @@ def adjust_stacked_widgets(self,requestedIndex):
18661885

18671886
# if indexes don't match then request is disallowed
18681887
# give a warning and reset the button check
1869-
if main_index != requestedIndex and not main_index in(TAB_CAMVIEW,TAB_GCODES,TAB_SETUP):
1888+
if main_index != requestedIndex and not main_index in(TAB_CAMVIEW, TAB_GCODES,
1889+
TAB_STATUS, TAB_SETUP):
18701890
self.add_status(_translate("HandlerClass","Cannot switch pages while in AUTO mode"), WARNING)
18711891
self.w.stackedWidget_mainTab.setCurrentIndex(0)
18721892
self.w.btn_main.setChecked(True)

share/qtvcp/screens/qtdragon_lathe/qtdragon_lathe_handler.py

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,13 @@
5757
PAGE_TOOL = 3
5858
PAGE_NGCGUI = 4
5959

60+
# message constants
6061
DEFAULT = 0
6162
WARNING = 1
6263
CRITICAL = 2
63-
64+
DEBUG = 3
65+
SUCCESS = 4
66+
ERROR = 5
6467
VERSION ='1.4'
6568

6669
class HandlerClass:
@@ -149,6 +152,7 @@ def __init__(self, halcomp, widgets, paths):
149152
STATUS.connect('override-limits-changed', lambda w, state, data: self._check_override_limits(state, data))
150153
STATUS.connect('graphics-gcode-properties', lambda w, d: self.update_gcode_properties(d))
151154
STATUS.connect('status-message', lambda w, d, o: self.add_external_status(d,o))
155+
STATUS.connect('runstop-line-changed', lambda w, l :self.lastRunLine(l))
152156

153157
txt1 = _translate("HandlerClass","Setup Tab")
154158
txt2 = _translate("HandlerClass","If you select a file with .html as a file ending, it will be shown here.")
@@ -855,6 +859,11 @@ def add_external_status(self, message, option):
855859
if log:
856860
STATUS.emit('update-machine-log', "{}\n{}".format(title, logtext), 'TIME')
857861

862+
# Log the last run line (in auto mode) if stopped
863+
def lastRunLine(self, line):
864+
if line >0:
865+
self.add_status('last running line before stoppage: {}'.format(line))
866+
858867
#######################
859868
# CALLBACKS FROM FORM #
860869
#######################
@@ -1532,9 +1541,15 @@ def add_status(self, message, alertLevel = DEFAULT, noLog = False):
15321541
opt = 'TIME'
15331542
if alertLevel==DEFAULT:
15341543
self.set_style_default()
1544+
elif alertLevel==SUCCESS:
1545+
opt += ',SUCCESS'
1546+
self.set_style_default()
15351547
elif alertLevel==WARNING:
15361548
opt += ',WARNING'
15371549
self.set_style_warning()
1550+
elif alertLevel==ERROR:
1551+
opt += ',ERROR'
1552+
self.set_style_warning()
15381553
else:
15391554
opt += ',CRITICAL'
15401555
self.set_style_critical()
@@ -1558,9 +1573,12 @@ def enable_auto(self, state):
15581573

15591574
def enable_onoff(self, state):
15601575
if state:
1561-
self.add_status(_translate("HandlerClass","Machine ON"))
1576+
self.add_status(_translate("HandlerClass","Machine ON"), SUCCESS)
15621577
else:
1563-
self.add_status(_translate("HandlerClass","Machine OFF"))
1578+
if not STATUS.estop_is_clear():
1579+
self.add_status(_translate("HandlerClass","ESTOP!"), CRITICAL)
1580+
else:
1581+
self.add_status(_translate("HandlerClass","MACHINE OFF"), ERROR)
15641582
self.w.btn_spindle_pause.setChecked(False)
15651583
self.h['eoffset-spindle-count'] = 0
15661584
for widget in self.onoff_list:
@@ -1843,7 +1861,8 @@ def adjust_stacked_widgets(self,requestedIndex,mode_change=False):
18431861

18441862
# if indexes don't match then request is disallowed
18451863
# give a warning and reset the button check
1846-
if main_index != requestedIndex and not main_index in(TAB_CAMERA,TAB_GCODES,TAB_SETUP):
1864+
if main_index != requestedIndex and not main_index in(TAB_CAMERA, TAB_GCODES,
1865+
TAB_STATUS, TAB_SETUP):
18471866
self.add_status("Cannot switch pages while in AUTO mode", WARNING)
18481867
self.w.stackedWidget_mainTab.setCurrentIndex(0)
18491868
self.w.btn_main.setChecked(True)

0 commit comments

Comments
 (0)