Commit | Line | Data |
---|---|---|
663d7943 L |
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 | ||
9 | #ifndef PLAYER_H | |
10 | #define PLAYER_H | |
11 | ||
9ef9c12a | 12 | #include "Module.h" |
663d7943 | 13 | |
9ef9c12a JM |
14 | #include <stdio.h> |
15 | #include <string> | |
02e4b295 JM |
16 | #include <map> |
17 | #include <vector> | |
9ef9c12a JM |
18 | using std::string; |
19 | ||
20 | class StreamOutput; | |
663d7943 | 21 | |
21294981 AW |
22 | struct stacked_file { |
23 | string filename; | |
24 | uint32_t position; | |
25 | }; | |
26 | ||
663d7943 L |
27 | class Player : public Module { |
28 | public: | |
02e4b295 | 29 | Player(); |
663d7943 L |
30 | |
31 | void on_module_loaded(); | |
32 | void on_console_line_received( void* argument ); | |
33 | void on_main_loop( void* argument ); | |
63888663 | 34 | void on_second_tick(void* argument); |
35089dc7 JM |
35 | void on_get_public_data(void* argument); |
36 | void on_set_public_data(void* argument); | |
c4e56997 | 37 | void on_gcode_received(void *argument); |
75f4581c JM |
38 | |
39 | private: | |
21294981 AW |
40 | bool prepare_playing( string filename_argument ); |
41 | void pop_file_from_stack(); | |
42 | void get_current_file_size(); | |
663d7943 | 43 | void play_command( string parameters, StreamOutput* stream ); |
addfb453 L |
44 | void progress_command( string parameters, StreamOutput* stream ); |
45 | void abort_command( string parameters, StreamOutput* stream ); | |
02e4b295 JM |
46 | void suspend_command( string parameters, StreamOutput* stream ); |
47 | void resume_command( string parameters, StreamOutput* stream ); | |
428d1181 | 48 | string extract_options(string& args); |
0f11f650 | 49 | void suspend_part2(); |
663d7943 | 50 | |
e2cd3423 | 51 | string filename; |
d467fcad JM |
52 | string after_suspend_gcode; |
53 | string before_resume_gcode; | |
7a42f8a2 | 54 | string on_boot_gcode; |
663d7943 | 55 | StreamOutput* current_stream; |
c4e56997 | 56 | StreamOutput* reply_stream; |
0f11f650 | 57 | |
21294981 AW |
58 | std::vector<stacked_file> file_stack; |
59 | ||
663d7943 | 60 | FILE* current_file_handler; |
be6a1e19 DM |
61 | long file_size; |
62 | unsigned long played_cnt; | |
63 | unsigned long elapsed_secs; | |
02e4b295 | 64 | float saved_position[3]; |
02e4b295 | 65 | std::map<uint16_t, float> saved_temperatures; |
4c09283b JM |
66 | struct { |
67 | bool on_boot_gcode_enable:1; | |
68 | bool booted:1; | |
69 | bool playing_file:1; | |
02e4b295 | 70 | bool suspended:1; |
02e4b295 | 71 | bool was_playing_file:1; |
f6fc8c0d | 72 | bool leave_heaters_on:1; |
16d1a7b7 | 73 | bool override_leave_heaters_on:1; |
0f11f650 | 74 | uint8_t suspend_loops:4; |
21294981 | 75 | uint8_t recursion_limit:4; |
4c09283b | 76 | }; |
663d7943 L |
77 | }; |
78 | ||
79 | #endif // PLAYER_H |