Commit 0bf820b0 authored by sumpfralle's avatar sumpfralle

calculate the estimated machine time for each toolpath


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@337 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 68221da6
Version 0.2.5 - NOT RELEASED
* calculate the estimated machine time for each toolpath
* changing the unit (mm/inch) now opens a dialog for scaling the model,
processing dimensions or tool dimensions accordingly
* remove unnecessary moves to safety height
......
......@@ -1381,6 +1381,13 @@ class ProjectGui:
self.update_view()
def update_toolpath_table(self, new_index=None, skip_model_update=False):
def get_time_string(minutes):
if minutes > 180:
return "%d hours" % int(round(minutes / 60))
elif minutes > 3:
return "%d minutes" % int(round(minutes))
else:
return "%d seconds" % int(round(minutes * 60))
# show or hide the "toolpath" tab
toolpath_tab = self.gui.get_object("ToolPathTab")
if not self.toolpath:
......@@ -1403,7 +1410,8 @@ class ProjectGui:
for index in range(len(self.toolpath)):
tp = self.toolpath[index]
items = (index, tp.name, tp.visible, tp.tool_settings["radius"],
tp.tool_id, tp.material_allowance, tp.speed, tp.feedrate)
tp.tool_id, tp.material_allowance, tp.speed,
tp.feedrate, get_time_string(tp.get_machine_time()))
model.append(items)
if not new_index is None:
self._treeview_set_active_index(self.toolpath_table, new_index)
......
......@@ -2,48 +2,6 @@
<interface>
<!-- interface-requires gtk+ 2.12 -->
<!-- interface-naming-policy project-wide -->
<object class="GtkListStore" id="ToolPathListModel">
<columns>
<!-- column-name index -->
<column type="guint"/>
<!-- column-name name -->
<column type="gchararray"/>
<!-- column-name visible -->
<column type="gboolean"/>
<!-- column-name drill_size -->
<column type="gfloat"/>
<!-- column-name drill_id -->
<column type="guint"/>
<!-- column-name allowance -->
<column type="gfloat"/>
<!-- column-name speed -->
<column type="gfloat"/>
<!-- column-name feedrate -->
<column type="gfloat"/>
</columns>
<data>
<row>
<col id="0">0</col>
<col id="1" translatable="yes">Rough</col>
<col id="2">True</col>
<col id="3">12</col>
<col id="4">0</col>
<col id="5">0</col>
<col id="6">0</col>
<col id="7">0</col>
</row>
<row>
<col id="0">0</col>
<col id="1" translatable="yes">test</col>
<col id="2">False</col>
<col id="3">0</col>
<col id="4">0</col>
<col id="5">0</col>
<col id="6">0</col>
<col id="7">0</col>
</row>
</data>
</object>
<object class="GtkListStore" id="unit_model">
<columns>
<!-- column-name name -->
......@@ -164,6 +122,52 @@
</row>
</data>
</object>
<object class="GtkListStore" id="ToolPathListModel">
<columns>
<!-- column-name index -->
<column type="guint"/>
<!-- column-name name -->
<column type="gchararray"/>
<!-- column-name visible -->
<column type="gboolean"/>
<!-- column-name drill_size -->
<column type="gfloat"/>
<!-- column-name drill_id -->
<column type="guint"/>
<!-- column-name allowance -->
<column type="gfloat"/>
<!-- column-name speed -->
<column type="gfloat"/>
<!-- column-name feedrate -->
<column type="gfloat"/>
<!-- column-name machine_time -->
<column type="gchararray"/>
</columns>
<data>
<row>
<col id="0">0</col>
<col id="1" translatable="yes">Rough</col>
<col id="2">True</col>
<col id="3">12</col>
<col id="4">0</col>
<col id="5">0</col>
<col id="6">0</col>
<col id="7">0</col>
<col id="8">0</col>
</row>
<row>
<col id="0">0</col>
<col id="1" translatable="yes">test</col>
<col id="2">False</col>
<col id="3">0</col>
<col id="4">0</col>
<col id="5">0</col>
<col id="6">0</col>
<col id="7">0</col>
<col id="8">0</col>
</row>
</data>
</object>
<object class="GtkWindow" id="ProjectWindow">
<property name="title" translatable="yes">PyCAM</property>
<property name="destroy_with_parent">True</property>
......@@ -1581,6 +1585,17 @@ This combination is added to the above task list.</property>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="Machine Time">
<property name="title">Machine Time</property>
<child>
<object class="GtkCellRendererText" id="machine_time"/>
<attributes>
<attribute name="text">8</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="Drill">
<property name="title">Drill</property>
......
......@@ -22,6 +22,7 @@ along with PyCAM. If not, see <http://www.gnu.org/licenses/>.
__all__ = ["ToolPathList", "ToolPath", "Generator"]
from pycam.Geometry.Point import Point
import random
class ToolPathList(list):
......@@ -61,4 +62,34 @@ class ToolPath:
else:
self.color = color
def get_machine_time(self, start_position=None):
""" calculate an estimation of the time required for processing the
toolpath with the machine
@value start_position: (optional) the position of the tool before the
start
@type start_position: pycam.Geometry.Point.Point
@rtype: float
@returns: the machine time used for processing the toolpath in minutes
"""
if start_position is None:
start_position = Point(0, 0, 0)
def move(new_pos):
move.result_time += new_pos.sub(move.current_position).norm() / self.feedrate
move.current_position = new_pos
move.current_position = start_position
move.result_time = 0
# move to safey height at the starting position
move(Point(start_position.x, start_position.y, self.safety_height))
for path in self.get_path():
# go to safety height (horizontally from the previous x/y location)
if len(path.points) > 0:
move(Point(path.points[0].x, path.points[0].y, self.safety_height))
# go through all points of the path
for point in path.points:
move(point)
# go to safety height (vertically up from the current x/y location)
if len(path.points) > 0:
move(Point(path.points[-1].x, path.points[-1].y, self.safety_height))
return move.result_time
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment