switched to multiprocessing instead of threading

This commit is contained in:
Félix Boisselier
2024-06-03 17:49:28 +02:00
parent 9ce82e3dc0
commit d22b3fcbef
6 changed files with 59 additions and 52 deletions

View File

@@ -3,12 +3,12 @@
from ..helpers.common_func import AXIS_CONFIG
from ..helpers.console_output import ConsoleOutput
from ..shaketune_thread import ShakeTuneThread
from ..shaketune_process import ShakeTuneProcess
from .accelerometer import Accelerometer
from .resonance_test import vibrate_axis
def axes_shaper_calibration(gcmd, config, st_thread: ShakeTuneThread) -> None:
def axes_shaper_calibration(gcmd, config, st_process: ShakeTuneProcess) -> None:
min_freq = gcmd.get_float('FREQ_START', default=5, minval=1)
max_freq = gcmd.get_float('FREQ_END', default=133.33, minval=1)
hz_per_sec = gcmd.get_float('HZ_PER_SEC', default=1, minval=1)
@@ -60,7 +60,7 @@ def axes_shaper_calibration(gcmd, config, st_thread: ShakeTuneThread) -> None:
toolhead.dwell(0.5)
# Configure the graph creator
creator = st_thread.get_graph_creator()
creator = st_process.get_graph_creator()
creator.configure(scv, max_sm, accel_per_hz)
# set the needed acceleration values for the test
@@ -95,8 +95,8 @@ def axes_shaper_calibration(gcmd, config, st_thread: ShakeTuneThread) -> None:
# And finally generate the graph for each measured axis
ConsoleOutput.print(f'{config["axis"].upper()} axis frequency profile generation...')
ConsoleOutput.print('This may take some time (1-3min)')
st_thread.run()
st_thread.wait_for_completion()
st_process.run()
st_process.wait_for_completion()
# Re-enable the input shaper if it was active
if input_shaper is not None:

View File

@@ -2,11 +2,11 @@
from ..helpers.console_output import ConsoleOutput
from ..shaketune_thread import ShakeTuneThread
from ..shaketune_process import ShakeTuneProcess
from .accelerometer import Accelerometer
def axes_map_calibration(gcmd, config, st_thread: ShakeTuneThread) -> None:
def axes_map_calibration(gcmd, config, st_process: ShakeTuneProcess) -> None:
z_height = gcmd.get_float('Z_HEIGHT', default=20.0)
speed = gcmd.get_float('SPEED', default=80.0, minval=20.0)
accel = gcmd.get_int('ACCEL', default=1500, minval=100)
@@ -70,6 +70,6 @@ def axes_map_calibration(gcmd, config, st_thread: ShakeTuneThread) -> None:
# Run post-processing
ConsoleOutput.print('Analysis of the movements...')
creator = st_thread.get_graph_creator()
creator = st_process.get_graph_creator()
creator.configure(accel)
st_thread.run()
st_process.run()

View File

@@ -3,13 +3,13 @@
from ..helpers.common_func import AXIS_CONFIG
from ..helpers.console_output import ConsoleOutput
from ..shaketune_thread import ShakeTuneThread
from ..shaketune_process import ShakeTuneProcess
from .accelerometer import Accelerometer
from .motorsconfigparser import MotorsConfigParser
from .resonance_test import vibrate_axis
def compare_belts_responses(gcmd, config, st_thread: ShakeTuneThread) -> None:
def compare_belts_responses(gcmd, config, st_process: ShakeTuneProcess) -> None:
min_freq = gcmd.get_float('FREQ_START', default=5.0, minval=1)
max_freq = gcmd.get_float('FREQ_END', default=133.33, minval=1)
hz_per_sec = gcmd.get_float('HZ_PER_SEC', default=1.0, minval=1)
@@ -29,7 +29,7 @@ def compare_belts_responses(gcmd, config, st_thread: ShakeTuneThread) -> None:
# Configure the graph creator
motors_config_parser = MotorsConfigParser(config, motors=None)
creator = st_thread.get_graph_creator()
creator = st_process.get_graph_creator()
creator.configure(motors_config_parser.kinematics, accel_per_hz)
if motors_config_parser.kinematics == 'corexy':
@@ -102,4 +102,4 @@ def compare_belts_responses(gcmd, config, st_thread: ShakeTuneThread) -> None:
# Run post-processing
ConsoleOutput.print('Belts comparative frequency profile generation...')
ConsoleOutput.print('This may take some time (3-5min)')
st_thread.run()
st_process.run()

View File

@@ -4,14 +4,14 @@
import math
from ..helpers.console_output import ConsoleOutput
from ..shaketune_thread import ShakeTuneThread
from ..shaketune_process import ShakeTuneProcess
from .accelerometer import Accelerometer
from .motorsconfigparser import MotorsConfigParser
MIN_SPEED = 2 # mm/s
def create_vibrations_profile(gcmd, config, st_thread: ShakeTuneThread) -> None:
def create_vibrations_profile(gcmd, config, st_process: ShakeTuneProcess) -> None:
size = gcmd.get_float('SIZE', default=100.0, minval=50.0)
z_height = gcmd.get_float('Z_HEIGHT', default=20.0)
max_speed = gcmd.get_float('MAX_SPEED', default=200.0, minval=10.0)
@@ -127,6 +127,6 @@ def create_vibrations_profile(gcmd, config, st_thread: ShakeTuneThread) -> None:
# Run post-processing
ConsoleOutput.print('Machine vibrations profile generation...')
ConsoleOutput.print('This may take some time (5-8min)')
creator = st_thread.get_graph_creator()
creator = st_process.get_graph_creator()
creator.configure(motors_config_parser.kinematics, accel, motors_config_parser)
st_thread.run()
st_process.run()