Prechádzať zdrojové kódy

- in CNCJob UI Autolevelling - sending GCode/GRBL commands is now threaded

Marius Stanciu 5 rokov pred
rodič
commit
33c633f0c4
3 zmenil súbory, kde vykonal 20 pridanie a 7 odobranie
  1. 4 0
      CHANGELOG.md
  2. 11 3
      appObjects/FlatCAMCNCJob.py
  3. 5 4
      app_Main.py

+ 4 - 0
CHANGELOG.md

@@ -7,6 +7,10 @@ CHANGELOG for FlatCAM beta
 
 =================================================
 
+19.08.2020
+
+- in CNCJob UI Autolevelling - sending GCode/GRBL commands is now threaded
+
 18.08.2020
 
 - in Doublesided Tool added some UI for Excellon hole snapping

+ 11 - 3
appObjects/FlatCAMCNCJob.py

@@ -995,14 +995,22 @@ class CNCJobObject(FlatCAMObj, CNCjob):
     def on_send_grbl_command(self):
         cmd = self.ui.grbl_command_entry.get_value()
         self.wake_grbl()
-        self.send_grbl_command(command=cmd)
+
+        # show the Shell Dock
+        self.app.ui.shell_dock.show()
+
+        def worker_task():
+            with self.app.proc_container.new(_("Sending GCode...")):
+                self.send_grbl_command(command=cmd)
+
+        self.app.worker_task.emit({'fcn': worker_task, 'params': []})
 
     def send_grbl_command(self, command, echo=True):
         stripped_cmd = command.strip()  # Strip all EOL characters for consistency
 
         for l in stripped_cmd.split('\n'):
             if echo:
-                self.app.shell_message(l, show=True, new_line=False)
+                self.app.inform_shell[str, bool].emit(l, False)
 
             snd = l + '\n'
             self.grbl_ser_port.write(snd.encode('utf-8'))  # Send g-code block to grbl
@@ -1011,7 +1019,7 @@ class CNCJobObject(FlatCAMObj, CNCjob):
             for line in grbl_out:
                 if echo:
                     try:
-                        self.app.shell_message(' : ' + line.decode('utf-8').strip().upper(), show=True)
+                        self.app.inform_shell.emit(' : ' + line.decode('utf-8').strip().upper())
                     except Exception as e:
                         log.debug("CNCJobObject.send_grbl_command() --> %s" % str(e))
 

+ 5 - 4
app_Main.py

@@ -208,7 +208,7 @@ class App(QtCore.QObject):
     # Handled by: App.info() --> Print on the status bar
     inform = QtCore.pyqtSignal([str], [str, bool])
     # Handled by: App.info_shell() --> Print on the shell
-    inform_shell = QtCore.pyqtSignal(str)
+    inform_shell = QtCore.pyqtSignal([str], [str, bool])
 
     app_quit = QtCore.pyqtSignal()
 
@@ -791,7 +791,8 @@ class App(QtCore.QObject):
         self.inform[str, bool].connect(self.info)
 
         # signal for displaying messages in the shell
-        self.inform_shell.connect(self.info_shell)
+        self.inform_shell[str].connect(self.info_shell)
+        self.inform_shell[str, bool].connect(self.info_shell)
 
         # signal to be called when the app is quiting
         self.app_quit.connect(self.quit_application, type=Qt.QueuedConnection)
@@ -2546,8 +2547,8 @@ class App(QtCore.QObject):
             if msg != '' and shell_echo is True:
                 self.shell_message(msg)
 
-    def info_shell(self, msg):
-        self.shell_message(msg=msg)
+    def info_shell(self, msg, new_line=True):
+        self.shell_message(msg=msg, new_line=new_line)
 
     def on_import_preferences(self):
         """