Commit f81bc9a5 authored by sumpfralle's avatar sumpfralle

store server connection details (ports, hostname, password) in config file

improved performance of "update_progress_bar" slightly


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@948 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 1cb83c3f
...@@ -22,7 +22,7 @@ along with PyCAM. If not, see <http://www.gnu.org/licenses/>. ...@@ -22,7 +22,7 @@ along with PyCAM. If not, see <http://www.gnu.org/licenses/>.
""" """
import pycam.Exporters.GCodeExporter from pycam.Exporters.GCodeExporter import PATH_MODES, GCodeGenerator
import pycam.Exporters.EMCToolExporter import pycam.Exporters.EMCToolExporter
import pycam.Gui.Settings import pycam.Gui.Settings
import pycam.Cutters import pycam.Cutters
...@@ -137,6 +137,10 @@ PREFERENCES_DEFAULTS = { ...@@ -137,6 +137,10 @@ PREFERENCES_DEFAULTS = {
"gcode_filename_extension": "", "gcode_filename_extension": "",
"external_program_inkscape": "", "external_program_inkscape": "",
"external_program_pstoedit": "", "external_program_pstoedit": "",
"server_auth_key": "",
"server_port_local": pycam.Utils.threading.DEFAULT_PORT,
"server_port_remote": pycam.Utils.threading.DEFAULT_PORT,
"server_hostname": "",
} }
""" the listed items will be loaded/saved via the preferences file in the """ the listed items will be loaded/saved via the preferences file in the
user's home directory on startup/shutdown""" user's home directory on startup/shutdown"""
...@@ -954,10 +958,14 @@ class ProjectGui: ...@@ -954,10 +958,14 @@ class ProjectGui:
"NumberOfProcesses") "NumberOfProcesses")
self.number_of_processes.set_value( self.number_of_processes.set_value(
pycam.Utils.threading.get_number_of_processes()) pycam.Utils.threading.get_number_of_processes())
self.gui.get_object("ServerPortLocal").set_value( server_port_local_obj = self.gui.get_object("ServerPortLocal")
pycam.Utils.threading.DEFAULT_PORT) self.settings.add_item("server_port_local",
self.gui.get_object("RemoteServerPort").set_value( server_port_local_obj.get_value,
pycam.Utils.threading.DEFAULT_PORT) server_port_local_obj.set_value)
server_port_remote_obj = self.gui.get_object("RemoteServerPort")
self.settings.add_item("server_port_remote",
server_port_remote_obj.get_value,
server_port_remote_obj.set_value)
self.number_of_processes.connect("value-changed", self.number_of_processes.connect("value-changed",
self.handle_parallel_processes_settings) self.handle_parallel_processes_settings)
self.gui.get_object("EnableServerMode").connect("toggled", self.gui.get_object("EnableServerMode").connect("toggled",
...@@ -966,6 +974,13 @@ class ProjectGui: ...@@ -966,6 +974,13 @@ class ProjectGui:
self.generate_random_server_password) self.generate_random_server_password)
self.gui.get_object("ServerPasswordShow").connect("toggled", self.gui.get_object("ServerPasswordShow").connect("toggled",
self.update_parallel_processes_settings) self.update_parallel_processes_settings)
auth_key_obj = self.gui.get_object("ServerPassword")
self.settings.add_item("server_auth_key", auth_key_obj.get_text,
auth_key_obj.set_text)
server_hostname = self.gui.get_object("RemoteServerHostname")
self.settings.add_item("server_hostname",
server_hostname.get_text,
server_hostname.set_text)
cpu_cores = pycam.Utils.threading.get_number_of_cores() cpu_cores = pycam.Utils.threading.get_number_of_cores()
if cpu_cores is None: if cpu_cores is None:
cpu_cores = "unknown" cpu_cores = "unknown"
...@@ -2046,6 +2061,10 @@ class ProjectGui: ...@@ -2046,6 +2061,10 @@ class ProjectGui:
model.append(item) model.append(item)
self.gui.get_object("ProcessPoolConnectedWorkersValue").set_text( self.gui.get_object("ProcessPoolConnectedWorkersValue").set_text(
str(len(stats))) str(len(stats)))
details = pycam.Utils.threading.get_task_statistics()
detail_text = os.linesep.join(["%s: %s" % (key, value)
for (key, value) in details.iteritems()])
self.gui.get_object("ProcessPoolDetails").set_text(detail_text)
current_interval = int(max(1, self.gui.get_object( current_interval = int(max(1, self.gui.get_object(
"ProcessPoolRefreshInterval").get_value())) "ProcessPoolRefreshInterval").get_value()))
if original_interval != current_interval: if original_interval != current_interval:
...@@ -3273,6 +3292,15 @@ class ProjectGui: ...@@ -3273,6 +3292,15 @@ class ProjectGui:
if (percent is None) and (self.progress_bar.get_fraction() == 0): if (percent is None) and (self.progress_bar.get_fraction() == 0):
# use "pulse" mode until we reach 1% of the work to be done # use "pulse" mode until we reach 1% of the work to be done
self.progress_bar.pulse() self.progress_bar.pulse()
# update the GUI
current_time = time.time()
# Don't update the GUI more often than once per second.
# Exception: text-only updates
# This restriction improves performance and reduces the
# "snappiness" of the GUI.
if (self._last_gtk_events_time is None) \
or text \
or (self._last_gtk_events_time + 1 <= current_time):
# "estimated time of arrival" text # "estimated time of arrival" text
time_estimation_suffix = " remaining ..." time_estimation_suffix = " remaining ..."
if self.progress_bar.get_fraction() > 0: if self.progress_bar.get_fraction() > 0:
...@@ -3304,18 +3332,9 @@ class ProjectGui: ...@@ -3304,18 +3332,9 @@ class ProjectGui:
if eta_text: if eta_text:
lines.append(eta_text) lines.append(eta_text)
self.progress_bar.set_text(os.linesep.join(lines)) self.progress_bar.set_text(os.linesep.join(lines))
# update the GUI
current_time = time.time()
# show the "show_tool_button" ("hide" is called in the progress decorator) # show the "show_tool_button" ("hide" is called in the progress decorator)
if self.settings.get("toolpath_in_progress"): if self.settings.get("toolpath_in_progress"):
self.show_progress_button.show() self.show_progress_button.show()
# Don't update the GUI more often than once per second.
# Exception: text-only updates
# This restriction improves performance and reduces the
# "snappiness" of the GUI.
if (self._last_gtk_events_time is None) \
or text \
or (self._last_gtk_events_time + 1 < current_time):
while gtk.events_pending(): while gtk.events_pending():
gtk.main_iteration() gtk.main_iteration()
if not text or (self._progress_start_time + 5 < current_time): if not text or (self._progress_start_time + 5 < current_time):
...@@ -3473,21 +3492,19 @@ class ProjectGui: ...@@ -3473,21 +3492,19 @@ class ProjectGui:
self.func = func self.func = func
def update(self, text=None, percent=None, tool_position=None, def update(self, text=None, percent=None, tool_position=None,
toolpath=None): toolpath=None):
if parent.settings.get("show_drill_progress"):
if not tool_position is None: if not tool_position is None:
parent.cutter.moveto(tool_position) parent.cutter.moveto(tool_position)
if not toolpath is None: if not toolpath is None:
parent.settings.set("toolpath_in_progress", toolpath) parent.settings.set("toolpath_in_progress", toolpath)
if (time.time() - self.last_update) > 1.0/self.max_fps: current_time = time.time()
self.last_update = time.time() if (current_time - self.last_update) > 1.0/self.max_fps:
self.last_update = current_time
if self.func: if self.func:
self.func() self.func()
# break the loop if someone clicked the "cancel" button # break the loop if someone clicked the "cancel" button
return parent.update_progress_bar(text, percent) return parent.update_progress_bar(text, percent)
# allow the "show_drill_progress" setting to be changed instantly draw_callback = UpdateView(self.update_view,
def conditional_progress_update():
if self.settings.get("show_drill_progress"):
self.update_view()
draw_callback = UpdateView(conditional_progress_update,
max_fps=self.settings.get("drill_progress_max_fps")).update max_fps=self.settings.get("drill_progress_max_fps")).update
self.update_progress_bar("Generating collision model") self.update_progress_bar("Generating collision model")
...@@ -3778,8 +3795,7 @@ class ProjectGui: ...@@ -3778,8 +3795,7 @@ class ProjectGui:
machine_time += tp.get_machine_time(safety_height) machine_time += tp.get_machine_time(safety_height)
all_info = meta_data + os.linesep \ all_info = meta_data + os.linesep \
+ "Estimated machine time: %g minutes" % machine_time + "Estimated machine time: %g minutes" % machine_time
generator = pycam.Exporters.GCodeExporter.GCodeGenerator( generator = GCodeGenerator(destination,
destination,
metric_units=(self.settings.get("unit") == "mm"), metric_units=(self.settings.get("unit") == "mm"),
safety_height=safety_height, safety_height=safety_height,
toggle_spindle_status=self.settings.get("gcode_start_stop_spindle"), toggle_spindle_status=self.settings.get("gcode_start_stop_spindle"),
...@@ -3788,7 +3804,6 @@ class ProjectGui: ...@@ -3788,7 +3804,6 @@ class ProjectGui:
minimum_step_y=self.settings.get("gcode_minimum_step_y"), minimum_step_y=self.settings.get("gcode_minimum_step_y"),
minimum_step_z=self.settings.get("gcode_minimum_step_z")) minimum_step_z=self.settings.get("gcode_minimum_step_z"))
path_mode = self.settings.get("gcode_path_mode") path_mode = self.settings.get("gcode_path_mode")
PATH_MODES = pycam.Exporters.GCodeExporter.PATH_MODES
if path_mode == 0: if path_mode == 0:
generator.set_path_mode(PATH_MODES["exact_path"]) generator.set_path_mode(PATH_MODES["exact_path"])
elif path_mode == 1: elif path_mode == 1:
......
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