mirror of
https://github.com/Klipper3d/klipper.git
synced 2025-12-17 05:39:57 +01:00
shaper_calibrate: Fixed sending large objects via Pipe from bg process
Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
This commit is contained in:
committed by
KevinOConnor
parent
c339bb0cdf
commit
baf188bd62
@@ -87,6 +87,12 @@ class ShaperCalibrate:
|
|||||||
child_conn.send((True, traceback.format_exc()))
|
child_conn.send((True, traceback.format_exc()))
|
||||||
child_conn.close()
|
child_conn.close()
|
||||||
return
|
return
|
||||||
|
if isinstance(res, list):
|
||||||
|
child_conn.send((True, None))
|
||||||
|
for el in res:
|
||||||
|
child_conn.send((False, el))
|
||||||
|
child_conn.send((True, None))
|
||||||
|
else:
|
||||||
child_conn.send((False, res))
|
child_conn.send((False, res))
|
||||||
child_conn.close()
|
child_conn.close()
|
||||||
# Start a process to perform the calculation
|
# Start a process to perform the calculation
|
||||||
@@ -97,15 +103,24 @@ class ShaperCalibrate:
|
|||||||
reactor = self.printer.get_reactor()
|
reactor = self.printer.get_reactor()
|
||||||
gcode = self.printer.lookup_object("gcode")
|
gcode = self.printer.lookup_object("gcode")
|
||||||
eventtime = last_report_time = reactor.monotonic()
|
eventtime = last_report_time = reactor.monotonic()
|
||||||
while calc_proc.is_alive():
|
while calc_proc.is_alive() and not parent_conn.poll():
|
||||||
if eventtime > last_report_time + 5.:
|
if eventtime > last_report_time + 5.:
|
||||||
last_report_time = eventtime
|
last_report_time = eventtime
|
||||||
gcode.respond_info("Wait for calculations..", log=False)
|
gcode.respond_info("Wait for calculations..", log=False)
|
||||||
eventtime = reactor.pause(eventtime + .1)
|
eventtime = reactor.pause(eventtime + .1)
|
||||||
# Return results
|
# Return results
|
||||||
is_err, res = parent_conn.recv()
|
status, recv = parent_conn.recv()
|
||||||
if is_err:
|
if recv is None:
|
||||||
raise self.error("Error in remote calculation: %s" % (res,))
|
res = []
|
||||||
|
while True:
|
||||||
|
status, recv = parent_conn.recv()
|
||||||
|
if status:
|
||||||
|
break
|
||||||
|
res.append(recv)
|
||||||
|
else:
|
||||||
|
res = recv
|
||||||
|
if status and recv is not None:
|
||||||
|
raise self.error("Error in remote calculation: %s" % (recv,))
|
||||||
calc_proc.join()
|
calc_proc.join()
|
||||||
parent_conn.close()
|
parent_conn.close()
|
||||||
return res
|
return res
|
||||||
@@ -263,7 +278,7 @@ class ShaperCalibrate:
|
|||||||
shaper = shaper_cfg.init_func(test_freq, damping_ratio)
|
shaper = shaper_cfg.init_func(test_freq, damping_ratio)
|
||||||
shaper_smoothing = self._get_shaper_smoothing(shaper, scv=scv)
|
shaper_smoothing = self._get_shaper_smoothing(shaper, scv=scv)
|
||||||
if max_smoothing and shaper_smoothing > max_smoothing and best_res:
|
if max_smoothing and shaper_smoothing > max_smoothing and best_res:
|
||||||
return best_res, results
|
return [best_res] + results
|
||||||
max_accel = self.find_shaper_max_accel(shaper, scv)
|
max_accel = self.find_shaper_max_accel(shaper, scv)
|
||||||
all_shaper_vals = []
|
all_shaper_vals = []
|
||||||
|
|
||||||
@@ -309,7 +324,7 @@ class ShaperCalibrate:
|
|||||||
if res.vibrs < best_res.vibrs * 1.1 + .0005 \
|
if res.vibrs < best_res.vibrs * 1.1 + .0005 \
|
||||||
and res.score < selected.score:
|
and res.score < selected.score:
|
||||||
selected = res
|
selected = res
|
||||||
return selected, results
|
return [selected] + results
|
||||||
|
|
||||||
def _bisect(self, func):
|
def _bisect(self, func):
|
||||||
left = right = 1.
|
left = right = 1.
|
||||||
@@ -347,9 +362,11 @@ class ShaperCalibrate:
|
|||||||
for shaper_cfg in shaper_defs.INPUT_SHAPERS:
|
for shaper_cfg in shaper_defs.INPUT_SHAPERS:
|
||||||
if shaper_cfg.name not in shapers:
|
if shaper_cfg.name not in shapers:
|
||||||
continue
|
continue
|
||||||
shaper, results = self.background_process_exec(self.fit_shaper, (
|
fit_results = self.background_process_exec(self.fit_shaper, (
|
||||||
shaper_cfg, calibration_data, shaper_freqs, damping_ratio,
|
shaper_cfg, calibration_data, shaper_freqs, damping_ratio,
|
||||||
scv, max_smoothing, test_damping_ratios, max_freq))
|
scv, max_smoothing, test_damping_ratios, max_freq))
|
||||||
|
shaper = fit_results[0]
|
||||||
|
results = fit_results[1:]
|
||||||
if (best_shaper is None or shaper.score * 1.2 < best_shaper.score or
|
if (best_shaper is None or shaper.score * 1.2 < best_shaper.score or
|
||||||
(shaper.score * 1.05 < best_shaper.score and
|
(shaper.score * 1.05 < best_shaper.score and
|
||||||
shaper.smoothing * 1.1 < best_shaper.smoothing)):
|
shaper.smoothing * 1.1 < best_shaper.smoothing)):
|
||||||
|
|||||||
Reference in New Issue
Block a user