- in CNCJob UI Autolevelling - GRBL Control and Sender tabs are disabled when the serial port is disconnected

This commit is contained in:
Marius Stanciu 2020-08-19 04:44:50 +03:00
parent 7285ee0b82
commit d62793c9bd
3 changed files with 23 additions and 5 deletions

View File

@ -11,6 +11,7 @@ CHANGELOG for FlatCAM beta
- in CNCJob UI Autolevelling - sending GCode/GRBL commands is now threaded
- in CNCJob UI Autolevelling - Grbl Connect tab colors will change with the connection status
- in CNCJob UI Autolevelling - GRBL Control and Sender tabs are disabled when the serial port is disconnected
18.08.2020

View File

@ -2084,10 +2084,6 @@ class CNCObjectUI(ObjectUI):
# self.gr_conn_tab_layout.addWidget(self.gr_conn_scroll_area)
self.al_toolbar.addTab(self.gr_conn_tab, _("Connect"))
for idx in range(self.al_toolbar.count()):
if self.al_toolbar.tabText(idx) == _("Connect"):
self.al_toolbar.tabBar.setTabTextColor(idx, QtGui.QColor('red'))
# GRBL Control TAB
self.gr_ctrl_tab = QtWidgets.QWidget()
self.gr_ctrl_tab.setObjectName("connect_tab")
@ -2107,6 +2103,14 @@ class CNCObjectUI(ObjectUI):
# self.gr_send_scroll_area = VerticalScrollArea()
# self.gr_send_tab_layout.addWidget(self.gr_send_scroll_area)
self.al_toolbar.addTab(self.gr_send_tab, _("Sender"))
for idx in range(self.al_toolbar.count()):
if self.al_toolbar.tabText(idx) == _("Connect"):
self.al_toolbar.tabBar.setTabTextColor(idx, QtGui.QColor('red'))
if self.al_toolbar.tabText(idx) == _("Control"):
self.al_toolbar.tabBar.setTabEnabled(idx, False)
if self.al_toolbar.tabText(idx) == _("Sender"):
self.al_toolbar.tabBar.setTabEnabled(idx, False)
# #############################################################################################################
# GRBL CONNECT
@ -2176,7 +2180,8 @@ class CNCObjectUI(ObjectUI):
)
ctrl_hlay.addWidget(self.controller_reset_button)
self.com_connect_button = FCButton(_("(Dis)Connect"))
self.com_connect_button = FCButton()
self.com_connect_button.setText(_("Disconnected"))
self.com_connect_button.setToolTip(
_("Connect to the selected port with the selected baud rate.")
)

View File

@ -954,9 +954,15 @@ class CNCJobObject(FlatCAMObj, CNCjob):
self.app.inform.emit("%s: %s" % (_("Port connected"), port_name))
self.ui.com_connect_button.setStyleSheet("QPushButton {background-color: seagreen;}")
self.ui.com_connect_button.setText(_("Connected"))
for idx in range(self.ui.al_toolbar.count()):
if self.ui.al_toolbar.tabText(idx) == _("Connect"):
self.ui.al_toolbar.tabBar.setTabTextColor(idx, QtGui.QColor('seagreen'))
if self.ui.al_toolbar.tabText(idx) == _("Control"):
self.ui.al_toolbar.tabBar.setTabEnabled(idx, True)
if self.ui.al_toolbar.tabText(idx) == _("Sender"):
self.ui.al_toolbar.tabBar.setTabEnabled(idx, True)
# Toggle DTR to reset the controller loaded with GRBL (Arduino, ESP32, etc)
try:
self.grbl_ser_port.dtr = False
@ -974,9 +980,15 @@ class CNCJobObject(FlatCAMObj, CNCjob):
self.grbl_ser_port.port = port_name
self.grbl_ser_port.close()
self.ui.com_connect_button.setStyleSheet("QPushButton {background-color: red;}")
self.ui.com_connect_button.setText(_("Disconnected"))
for idx in range(self.ui.al_toolbar.count()):
if self.ui.al_toolbar.tabText(idx) == _("Connect"):
self.ui.al_toolbar.tabBar.setTabTextColor(idx, QtGui.QColor('red'))
if self.ui.al_toolbar.tabText(idx) == _("Control"):
self.ui.al_toolbar.tabBar.setTabEnabled(idx, False)
if self.ui.al_toolbar.tabText(idx) == _("Sender"):
self.ui.al_toolbar.tabBar.setTabEnabled(idx, False)
self.app.inform.emit("%s: %s" % (_("Port is connected. Disconnecting"), port_name))
except Exception:
self.app.inform.emit("[ERROR_NOTCL] %s: %s" % (_("Could not connect to port"), port_name))