示例#1
0
 public void unregister_timer(ReactorTimer handler)
 {
     lock (_timers)
     {
         _timers.Remove(handler);
     }
 }
示例#2
0
 public void update_timer(ReactorTimer t, double nexttime)
 {
     lock (_timers)
     {
         t.waketime = nexttime;
         _note_time(t);
     }
 }
示例#3
0
        public ReactorTimer register_timer(ReactorAction callback, double waketime = NEVER)
        {
            var handler = new ReactorTimer(callback, waketime);

            lock (_timers)
            {
                _timers.Add(handler);
                _note_time(handler);
            }
            return(handler);
        }
示例#4
0
 // Timers
 void _note_time(ReactorTimer t)
 {
     lock (_timers)
     {
         var nexttime = t.waketime;
         if (nexttime < this._next_timer)
         {
             _next_timer = nexttime;
         }
     }
 }
示例#5
0
        void ParallelTimer(object arg)
        {
            ReactorTimer t = (ReactorTimer)arg;

            try
            {
                t.waketime = t.callback(t.calltime);
                _note_time(t);
            }
            finally
            {
                lock (t.syncLock)
                {
                    Monitor.PulseAll(t.syncLock);
                }
            }
        }
示例#6
0
 public ReactorCallback(SelectReactor reactor, ReactorAction callback, double waketime)
 {
     this.reactor  = reactor;
     this.timer    = reactor.register_timer(this.invoke, waketime);
     this.callback = callback;
 }
示例#7
0
        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);
        }