Просмотр исходного кода

- added estimated time of routing for the CNCJob and added travelled distance parameter for geometry, too

Marius Stanciu 6 лет назад
Родитель
Сommit
bc6b2666cd
4 измененных файлов с 65 добавлено и 11 удалено
  1. 14 1
      FlatCAMObj.py
  2. 4 0
      README.md
  3. 26 2
      camlib.py
  4. 21 8
      flatcamGUI/ObjectUI.py

+ 14 - 1
FlatCAMObj.py

@@ -5506,7 +5506,7 @@ class FlatCAMCNCjob(FlatCAMObj, CNCjob):
         # Fill form fields only on object create
         self.to_form()
 
-        # this means that the object that created this CNCJob was an Excellon
+        # this means that the object that created this CNCJob was an Excellon or Geometry
         try:
             if self.travel_distance:
                 self.ui.t_distance_label.show()
@@ -5515,6 +5515,19 @@ class FlatCAMCNCjob(FlatCAMObj, CNCjob):
                 self.ui.t_distance_entry.set_value('%.4f' % float(self.travel_distance))
                 self.ui.units_label.setText(str(self.units).lower())
                 self.ui.units_label.setDisabled(True)
+
+                self.ui.t_time_label.show()
+                self.ui.t_time_entry.setVisible(True)
+                self.ui.t_time_entry.setDisabled(True)
+                # if time is more than 1 then we have minutes, else we have seconds
+                if self.routing_time > 1:
+                    self.ui.t_time_entry.set_value('%.4f' % float(self.routing_time))
+                    self.ui.units_time_label.setText('min')
+                else:
+                    time_r = self.routing_time * 60
+                    self.ui.t_time_entry.set_value('%.4f' % float(time_r))
+                    self.ui.units_time_label.setText('sec')
+                self.ui.units_time_label.setDisabled(True)
         except AttributeError:
             pass
 

+ 4 - 0
README.md

@@ -11,6 +11,10 @@ CAD program, and create G-Code for Isolation routing.
 
 17.08.2019
 
+- added estimated time of routing for the CNCJob and added travelled distance parameter for geometry, too
+
+17.08.2019
+
 - updated the translations for the new strings
 - RELEASE 8.94
 

+ 26 - 2
camlib.py

@@ -5024,6 +5024,11 @@ class CNCjob(Geometry):
 
         self.tool = 0.0
 
+        # here store the travelled distance
+        self.travel_distance = 0.0
+        # here store the routing time
+        self.routing_time = 0.0
+
         # used for creating drill CCode geometry; will be updated in the generate_from_excellon_by_tool()
         self.exc_drills = None
         self.exc_tools = None
@@ -5557,6 +5562,7 @@ class CNCjob(Geometry):
         log.debug("The total travel distance including travel to end position is: %s" %
                   str(measured_distance) + '\n')
         self.travel_distance = measured_distance
+        # self.routing_time = measured_distance / self.z_feedrate
 
         self.gcode = gcode
         return 'OK'
@@ -5736,6 +5742,9 @@ class CNCjob(Geometry):
             if self.dwell is True:
                 self.gcode += self.doformat(p.dwell_code)   # Dwell time
 
+        total_travel = 0.0
+        total_cut = 0.0
+
         # ## Iterate over geometry paths getting the nearest each time.
         log.debug("Starting G-Code...")
         path_count = 0
@@ -5764,14 +5773,20 @@ class CNCjob(Geometry):
                     self.gcode += self.create_gcode_multi_pass(geo, extracut, tolerance,
                                                                postproc=p, current_point=current_pt)
 
+                # calculate the total distance
+                total_travel = total_travel + abs(distance(pt1=current_pt, pt2=pt))
+                total_cut = total_cut + geo.length
                 current_pt = geo.coords[-1]
-                pt, geo = storage.nearest(current_pt) # Next
 
+                pt, geo = storage.nearest(current_pt) # Next
         except StopIteration:  # Nothing found in storage.
             pass
 
         log.debug("Finishing G-Code... %s paths traced." % path_count)
 
+        self.travel_distance = total_travel + total_cut
+        self.routing_time = total_cut / self.feedrate
+
         # Finish
         self.gcode += self.doformat(p.spindle_stop_code)
         self.gcode += self.doformat(p.lift_code, x=current_pt[0], y=current_pt[1])
@@ -6002,6 +6017,9 @@ class CNCjob(Geometry):
             if self.dwell is True:
                 self.gcode += self.doformat(p.dwell_code)   # Dwell time
 
+        total_travel = 0.0
+        total_cut = 0.0
+
         # Iterate over geometry paths getting the nearest each time.
         log.debug("Starting G-Code...")
         path_count = 0
@@ -6028,14 +6046,20 @@ class CNCjob(Geometry):
                     self.gcode += self.create_gcode_multi_pass(geo, extracut, tolerance,
                                                                postproc=p, current_point=current_pt)
 
+                # calculate the total distance
+                total_travel = total_travel + abs(distance(pt1=current_pt, pt2=pt))
+                total_cut = total_cut + geo.length
                 current_pt = geo.coords[-1]
-                pt, geo = storage.nearest(current_pt) # Next
 
+                pt, geo = storage.nearest(current_pt) # Next
         except StopIteration:  # Nothing found in storage.
             pass
 
         log.debug("Finishing G-Code... %s paths traced." % path_count)
 
+        self.travel_distance = total_travel + total_cut
+        self.routing_time = total_cut / self.feedrate
+
         # Finish
         self.gcode += self.doformat(p.spindle_stop_code)
         self.gcode += self.doformat(p.lift_code, x=current_pt[0], y=current_pt[1])

+ 21 - 8
flatcamGUI/ObjectUI.py

@@ -1393,20 +1393,28 @@ class CNCObjectUI(ObjectUI):
 
         self.t_distance_label = QtWidgets.QLabel(_("<b>Travelled dist.:</b>"))
         self.t_distance_label.setToolTip(
-            _(
-                "This is the total travelled distance on X-Y plane.\n"
-                "In current units."
-            )
+            _("This is the total travelled distance on X-Y plane.\n"
+              "In current units.")
         )
         self.t_distance_entry = FCEntry()
         self.t_distance_entry.setToolTip(
-            _(
-                "This is the total travelled distance on X-Y plane.\n"
-                "In current units."
-            )
+            _("This is the total travelled distance on X-Y plane.\n"
+              "In current units.")
         )
         self.units_label = QtWidgets.QLabel()
 
+        self.t_time_label = QtWidgets.QLabel(_("<b>Estimated time.:</b>"))
+        self.t_distance_label.setToolTip(
+            _("This is the estimated time to do the routing.\n"
+              "In current units.")
+        )
+        self.t_time_entry = FCEntry()
+        self.t_time_entry.setToolTip(
+            _("This is the estimated time to do the routing.\n"
+              "In current units.")
+        )
+        self.units_time_label = QtWidgets.QLabel()
+
         f_lay = QtWidgets.QGridLayout()
         f_lay.setColumnStretch(1, 1)
         f_lay.setColumnStretch(2, 1)
@@ -1421,9 +1429,14 @@ class CNCObjectUI(ObjectUI):
         f_lay.addWidget(self.t_distance_label, 2, 0)
         f_lay.addWidget(self.t_distance_entry, 2, 1)
         f_lay.addWidget(self.units_label, 2, 2)
+        f_lay.addWidget(self.t_time_label, 3, 0)
+        f_lay.addWidget(self.t_time_entry, 3, 1)
+        f_lay.addWidget(self.units_time_label, 3, 2)
 
         self.t_distance_label.hide()
         self.t_distance_entry.setVisible(False)
+        self.t_time_label.hide()
+        self.t_time_entry.setVisible(False)
 
         e1_lbl = QtWidgets.QLabel('')
         self.custom_box.addWidget(e1_lbl)