Skip to content

Commit

Permalink
Merge branch 'release/1.2.8'
Browse files Browse the repository at this point in the history
  • Loading branch information
proclaim committed Mar 8, 2017
2 parents 4282b10 + a42709c commit 081269a
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 28 deletions.
29 changes: 16 additions & 13 deletions fluxclient/printer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ def float_or_percent(key, value, percent_start=float('-inf'), percent_end=float(
infill_sparse_thickness = 0.1
gradual_infill_steps = 0
gradual_infill_step_height = 5
infill_before_walls = true
infill_before_walls = false
min_infill_area = 0
material_flow_dependent_temperature = false
default_material_print_temperature = 210
Expand All @@ -292,25 +292,25 @@ def float_or_percent(key, value, percent_start=float('-inf'), percent_end=float(
material_extrusion_cool_down_speed = 0.7
material_bed_temperature = 60
material_bed_temperature_layer_0 = 60
material_diameter = 2.85
material_diameter = 1.75
material_flow = 100
retraction_enable = true
retract_at_layer_change = false
retraction_amount = 6.5
retraction_retract_speed = 25
retraction_prime_speed = 25
retraction_amount = 8
retraction_retract_speed = 80
retraction_prime_speed = 80
retraction_extra_prime_amount = 0
retraction_min_travel = 1.5
retraction_min_travel = 0.8
retraction_count_max = 90
retraction_extrusion_window = 4.5
retraction_extrusion_window = 8
material_standby_temperature = 150
switch_extruder_retraction_amount = 20
switch_extruder_retraction_speed = 20
switch_extruder_prime_speed = 20
speed_infill = 60
speed_wall_0 = 30
speed_wall_x = 60
speed_topbottom = 30
speed_wall_0 = 28
speed_wall_x = 40
speed_topbottom = 20
speed_support_infill = 60
speed_support_interface = 40
speed_prime_tower = 60
Expand Down Expand Up @@ -405,7 +405,7 @@ def float_or_percent(key, value, percent_start=float('-inf'), percent_end=float(
raft_airgap = 0.3
layer_0_z_overlap = 0.22
raft = 0
raft_surface_layers = 2
raft_surface_layers = 4
raft_surface_thickness = 0.1
raft_surface_line_width = 0.4
raft_surface_line_spacing = 0.4
Expand Down Expand Up @@ -494,12 +494,15 @@ def float_or_percent(key, value, percent_start=float('-inf'), percent_end=float(
wireframe_roof_outer_delay = 0.2
wireframe_nozzle_clearance = 1
temperature = 200
z_offset = 0
cut_bottom = 0
geometric_error_correction_on = 1
detect_filament_runout = 1
detect_head_shake = 1
detect_head_tilt = 1
flux_calibration = 1
pause_at_layers ="""
pause_at_layers =
before_layer_gcode ="""

ini_constraint = {
'avoid_crossing_perimeters': [binary],
Expand Down Expand Up @@ -648,4 +651,4 @@ def float_or_percent(key, value, percent_start=float('-inf'), percent_end=float(
'geometric_error_correction_on': [binary]
}

ini_flux_params = ['cut_bottom' ,'flux_', 'detect_', 'pause_at_layers', 'geometric_error_correction_on', 'cura2']
ini_flux_params = ['cut_bottom' ,'flux_', 'detect_', 'pause_at_layers', 'geometric_error_correction_on', 'cura2', 'z_offset', 'detect_filament_runout', 'detect_head_shake', 'flux_calibration']
52 changes: 37 additions & 15 deletions fluxclient/printer/stl_slicer.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
logger = logging.getLogger(__name__)


def rreplace(s, old, new, occurrence):
li = s.rsplit(old, occurrence)
return new.join(li)

def read_until(f):
"""
eat all the empty line
Expand Down Expand Up @@ -281,7 +285,7 @@ def begin_slicing(self, names, ws, output_type):
m_mesh_merge = m_mesh
else:
m_mesh_merge.add_on(m_mesh)

if float(self.config['cut_bottom']) > 0:
m_mesh_merge = m_mesh_merge.cut(float(self.config['cut_bottom']))

Expand All @@ -296,7 +300,7 @@ def begin_slicing(self, names, ws, output_type):
command += ['--print-center', '%f,%f' % (cx, cy)]
command += ['--load', tmp_slic3r_setting_file]

logger.debug('command: ' + ' '.join(command))
logger.info('command: ' + ' '.join(command))
self.end_slicing('slic3r begin next slicing')

status_list = []
Expand Down Expand Up @@ -547,6 +551,9 @@ def my_ini_writer(cls, file_path, content, delete=None):
if int(content.get('raft','1')) == 0:
logger.info("Raft off, remove raft_layers")
content['raft_layers'] = '0';

if content.get('start_gcode','') != "":
content['start_gcode'] = "M109 S[first_layer_temperature]\\n" + content.get('start_gcode','')

with open(file_path, 'w') as f:
for i in content:
Expand Down Expand Up @@ -731,12 +738,13 @@ def begin_slicing(self, names, ws, output_type):
for n in names:
if not (n in self.models and n in self.parameter):
return False, 'id:%s is not setted yet' % (n)

status_list = []
mergedConfig = self.configCura2 if self.version == 2 else self.config

self.end_slicing()
from threading import Thread # Do not expose thrading in module level
p = Thread(target=self.slicing_worker, args=(dict(self.config), self.image, dict(self.ext_metadata), output_type, status_list, names, ws, len(self.working_p)))
p = Thread(target=self.slicing_worker, args=(dict(mergedConfig), self.image, dict(self.ext_metadata), output_type, status_list, names, ws, len(self.working_p)))
# thread, files, status_list
self.working_p.append([p, [], status_list, False, len(self.working_p)])
p.start()
Expand Down Expand Up @@ -771,9 +779,10 @@ def slicing_worker(self, config, image, ext_metadata, output_type, status_list,
f.close();

params = {}

for n in names:
params[n] = self.parameter[n]
current_transform = json.dumps({'p': params, 'sink': float(self.config['cut_bottom'])})
current_transform = json.dumps({'p': params, 'sink': float(config['cut_bottom'])})

status_list.append('{"slice_status": "computing", "message": "Comparing Transformation", "percentage": 0.025}');

Expand Down Expand Up @@ -802,9 +811,10 @@ def slicing_worker(self, config, image, ext_metadata, output_type, status_list,
if self.is_aborted(p_index):
return logger.info('Worker #%d aborted' % p_index)

if float(self.config['cut_bottom']) > 0:

if float(config['cut_bottom']) > 0:
status_list.append('{"slice_status": "computing", "message": "Performing cut_bottom", "percentage": 0.04}');
m_mesh_merge = m_mesh_merge.cut(float(self.config['cut_bottom']))
m_mesh_merge = m_mesh_merge.cut(float(config['cut_bottom']))

logger.info('Writing new stl');
status_list.append('{"slice_status": "computing", "message": "Writing new stl", "percentage": 0.05}');
Expand Down Expand Up @@ -840,11 +850,18 @@ def slicing_worker(self, config, image, ext_metadata, output_type, status_list,
command = []

if cura2:
self.cura2_ini_writer(tmp_slicer_setting_file, self.configCura2, delete=ini_flux_params)
self.cura2_ini_writer(tmp_slicer_setting_file, config, delete=ini_flux_params)
# Call CuraEngine in command line
command = [self.slicer.replace("CuraEngine.exe", "v2/CuraEngine.exe").replace("CuraEngine", "CuraEngine2"), 'slice', '-v', '-j', tmp_slicer_setting_file, '-o', tmp_gcode_file, '-l', tmp_stl_file]
binary_path = self.slicer
if platform().startswith("Windows"):
binary_path = binary_path.replace("CuraEngine.exe", "v2/CuraEngine2.exe")
else:
binary_path = binary_path.replace("lib/CuraEngine", "lib/CuraEngine2")

command = [binary_path, 'slice', '-v', '-j',
tmp_slicer_setting_file, '-o', tmp_gcode_file, '-l', tmp_stl_file]
else:
self.cura_ini_writer(tmp_slicer_setting_file, self.config, delete=ini_flux_params)
self.cura_ini_writer(tmp_slicer_setting_file, config, delete=ini_flux_params)
# Call CuraEngine in command line
command = [self.slicer, '-o', tmp_gcode_file, '-c', tmp_slicer_setting_file]
command.append(tmp_stl_file)
Expand All @@ -856,19 +873,21 @@ def slicing_worker(self, config, image, ext_metadata, output_type, status_list,
fail_flag = True
logger.info('Worker #%d aborted' % p_index)

status_list.append('{"slice_status": "computing", "message": "Submitting model to slicing engine", "percentage": 0.10}');
logger.info('Starting CuraEngine');
status_list.append('{"slice_status": "computing", "message": "Submitting model to slicing engine", "percentage": 0.10}')
logger.info('Starting CuraEngine')

# tmp_gcode_file = command[2]
# tmp_slicer_setting_file = command[4]
fail_flag = False
try:
my_env = os.environ.copy()
my_env["CURA_ENGINE_SEARCH_PATH"] = os.path.dirname(self.slicer) + "/resources"
subp = subprocess.Popen(command, stderr=subprocess.STDOUT, stdout=subprocess.PIPE, universal_newlines=True, bufsize=0, env=my_env)
my_env["LD_LIBRARY_PATH"] = os.path.dirname(self.slicer) + "/resources"
subp = subprocess.Popen(command, stderr=subprocess.STDOUT, stdout=subprocess.PIPE,
universal_newlines=True, bufsize=0, env=my_env)
self.working_p[p_index].append(subp)
logger.info("#%d Real slicing started" % (p_index));
logger.info("#%d Real slicing started" % (p_index))

progress = 0.2
slicer_error = False
slicer_out = [None, None]
Expand Down Expand Up @@ -1105,6 +1124,9 @@ def cura2_ini_writer(cls, file_path, content, delete=None):
pass
definition['overrides'][key] = { 'default_value': content[key] }

definition['overrides']['machine_start_gcode']['default_value'] = add_multi_line('M109 S{}\n'.format(content['material_print_temperature_layer_0']) + content['machine_start_gcode'])
definition['overrides']['machine_end_gcode']['default_value'] = add_multi_line(content['machine_end_gcode'])

# TODO FIX Raft layers
if int(content.get('raft','1')) == 1:
definition['overrides']['adhesion_type']['default_value'] = 'raft'
Expand Down

0 comments on commit 081269a

Please sign in to comment.