FIx suspend/pause and saving/restoring Extruder state, this is complex due to possibl...
[clinton/Smoothieware.git] / src / modules / utils / player / Player.h
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
12 #include "Module.h"
13
14 #include <stdio.h>
15 #include <string>
16 #include <map>
17 #include <vector>
18 using std::string;
19
20 class StreamOutput;
21
22 class Player : public Module {
23 public:
24 Player();
25
26 void on_module_loaded();
27 void on_console_line_received( void* argument );
28 void on_main_loop( void* argument );
29 void on_second_tick(void* argument);
30 void on_get_public_data(void* argument);
31 void on_set_public_data(void* argument);
32 void on_gcode_received(void *argument);
33
34 private:
35 void play_command( string parameters, StreamOutput* stream );
36 void progress_command( string parameters, StreamOutput* stream );
37 void abort_command( string parameters, StreamOutput* stream );
38 void suspend_command( string parameters, StreamOutput* stream );
39 void resume_command( string parameters, StreamOutput* stream );
40 string extract_options(string& args);
41 void suspend_part2();
42
43 string filename;
44 string after_suspend_gcode;
45 string before_resume_gcode;
46 string on_boot_gcode;
47 StreamOutput* current_stream;
48 StreamOutput* reply_stream;
49
50 FILE* current_file_handler;
51 long file_size;
52 unsigned long played_cnt;
53 unsigned long elapsed_secs;
54 float saved_position[3]; // only saves XYZ
55 std::map<uint16_t, float> saved_temperatures;
56 struct {
57 bool on_boot_gcode_enable:1;
58 bool booted:1;
59 bool playing_file:1;
60 bool suspended:1;
61 bool was_playing_file:1;
62 bool leave_heaters_on:1;
63 bool override_leave_heaters_on:1;
64 uint8_t suspend_loops:4;
65 };
66 };
67
68 #endif // PLAYER_H