Commit | Line | Data |
---|---|---|
4cff3ded AW |
1 | /* |
2 | This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl). | |
3 | Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. | |
4 | Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. | |
5 | You should have received a copy of the GNU General Public License along with Smoothie. If not, see <http://www.gnu.org/licenses/>. | |
6 | */ | |
7 | ||
8 | #ifndef BLOCK_H | |
9 | #define BLOCK_H | |
10 | #include "libs/Module.h" | |
11 | #include "libs/Kernel.h" | |
12 | using namespace std; | |
13 | #include <string> | |
14 | #include <vector> | |
3a4fa0c1 | 15 | |
4cff3ded AW |
16 | #include "../communication/utils/Gcode.h" |
17 | #include "Planner.h" | |
18 | class Planner; | |
3a4fa0c1 | 19 | class Player; |
aab6cbba AW |
20 | |
21 | double max_allowable_speed( double acceleration, double target_velocity, double distance); | |
22 | ||
4cff3ded AW |
23 | class Block { |
24 | public: | |
25 | Block(); | |
26 | double compute_factor_for_safe_speed(); | |
27 | void calculate_trapezoid( double entry_factor, double exit_factor ); | |
28 | double estimate_acceleration_distance( double initial_rate, double target_rate, double acceleration ); | |
29 | double intersection_distance(double initial_rate, double final_rate, double acceleration, double distance); | |
30 | void reverse_pass(Block* previous, Block* next); | |
31 | void forward_pass(Block* previous, Block* next); | |
32 | void debug(Kernel* kernel); | |
33 | void append_gcode(Gcode* gcode); | |
34 | void pop_and_execute_gcode(Kernel* &kernel); | |
35 | double get_duration_left(unsigned int already_taken_steps); | |
3a4fa0c1 AW |
36 | void take(); |
37 | void release(); | |
38 | void ready(); | |
4cff3ded | 39 | |
436a2cd1 AW |
40 | vector<std::string> commands; |
41 | vector<double> travel_distances; | |
13e4a3f9 | 42 | vector<Gcode> gcodes; |
436a2cd1 | 43 | |
b66fb830 AW |
44 | unsigned int steps[3]; // Number of steps for each axis for this block |
45 | unsigned int steps_event_count; // Steps for the longest axis | |
4cff3ded AW |
46 | unsigned int nominal_rate; // Nominal rate in steps per minute |
47 | float nominal_speed; // Nominal speed in mm per minute | |
48 | float millimeters; // Distance for this move | |
b66fb830 | 49 | double entry_speed; |
4464301d | 50 | float rate_delta; // Nomber of steps to add to the speed for each acceleration tick |
4cff3ded AW |
51 | unsigned int initial_rate; // Initial speed in steps per minute |
52 | unsigned int final_rate; // Final speed in steps per minute | |
a1b7e9f0 AW |
53 | unsigned int accelerate_until; // Stop accelerating after this number of steps |
54 | unsigned int decelerate_after; // Start decelerating after this number of steps | |
4cff3ded AW |
55 | unsigned int direction_bits; // Direction for each axis in bit form, relative to the direction port's mask |
56 | ||
aab6cbba AW |
57 | |
58 | uint8_t recalculate_flag; // Planner flag to recalculate trapezoids on entry junction | |
59 | uint8_t nominal_length_flag; // Planner flag for nominal speed always reached | |
60 | ||
61 | double max_entry_speed; | |
4cff3ded | 62 | Planner* planner; |
3a4fa0c1 | 63 | Player* player; |
13e4a3f9 AW |
64 | |
65 | bool is_ready; | |
3a4fa0c1 | 66 | |
2bb8b390 | 67 | short times_taken; // A block can be "taken" by any number of modules, and the next block is not moved to until all the modules have "released" it. This value serves as a tracker. |
a1b7e9f0 | 68 | |
4cff3ded AW |
69 | }; |
70 | ||
71 | ||
72 | ||
73 | ||
74 | ||
75 | ||
76 | ||
77 | ||
78 | ||
79 | ||
80 | ||
81 | #endif |