예제 #1
0
파일: ToolHead.cs 프로젝트: Benkei/klipper
        public ToolHead(ConfigWrapper config)
        {
            this.printer       = config.get_printer();
            this.reactor       = this.printer.get_reactor();
            this.all_mcus      = (from mcus in this.printer.lookup_objects <Mcu>(module: "mcu") select mcus.modul).ToList();
            this.mcu           = this.all_mcus[0];
            this.move_queue    = new MoveQueue();
            this.commanded_pos = Vector4d.Zero;
            this.printer.register_event_handler("klippy:shutdown", _handle_shutdown);
            // Velocity and acceleration control
            this.max_velocity                  = config.getfloat("max_velocity", above: 0.0);
            this.max_accel                     = config.getfloat("max_accel", above: 0.0);
            this.requested_accel_to_decel      = config.getfloat("max_accel_to_decel", this.max_accel * 0.5, above: 0.0);
            this.max_accel_to_decel            = this.requested_accel_to_decel;
            this.square_corner_velocity        = config.getfloat("square_corner_velocity", 5.0, minval: 0.0);
            this.config_max_velocity           = this.max_velocity;
            this.config_max_accel              = this.max_accel;
            this.config_square_corner_velocity = this.square_corner_velocity;
            this.junction_deviation            = 0.0;
            this._calc_junction_deviation();
            // Print time tracking
            this.buffer_time_low       = config.getfloat("buffer_time_low", 1.0, above: 0.0);
            this.buffer_time_high      = config.getfloat("buffer_time_high", 2.0, above: this.buffer_time_low);
            this.buffer_time_start     = config.getfloat("buffer_time_start", 0.25, above: 0.0);
            this.move_flush_time       = config.getfloat("move_flush_time", 0.05, above: 0.0);
            this.print_time            = 0.0;
            this.last_print_start_time = 0.0;
            this.need_check_stall      = -1.0;
            this.print_stall           = 0;
            this.sync_print_time       = true;
            this.idle_flush_print_time = 0.0;
            this.flush_timer           = this.reactor.register_timer(this._flush_handler);
            this.move_queue.set_flush_time(this.buffer_time_high);
            this.printer.try_load_module(config, "idle_timeout");
            this.printer.try_load_module(config, "statistics");
            // Setup iterative solver
            this.cmove = new move();
            // Create kinematics class
            this.extruder = new ExtruderDummy();
            this.move_queue.set_extruder(this.extruder);
            var kin_name = config.getEnum <KinematicType>("kinematics");

            try
            {
                this.kin = KinematicFactory.load_kinematics(kin_name, this, config);
            }
            catch (ConfigException)
            {
                throw;
            }
            catch (PinsException)
            {
                throw;
            }
            catch (Exception ex)
            {
                var msg = $"Error loading kinematics '{kin_name}'";
                logging.Error(msg);
                throw new Exception(msg, ex);
            }
            var gcode = this.printer.lookup_object <GCodeParser>("gcode");

            gcode.register_command("SET_VELOCITY_LIMIT", this.cmd_SET_VELOCITY_LIMIT, desc: cmd_SET_VELOCITY_LIMIT_help);
            gcode.register_command("M204", this.cmd_M204);
        }