| 1 | #pragma once |
| 2 | |
| 3 | #include <simgear/compiler.h> |
| 4 | |
| 5 | #include <iostream> |
| 6 | #include <string> |
| 7 | #include <queue> |
| 8 | |
| 9 | #include <simgear/misc/stdint.hxx> |
| 10 | #include <simgear/io/iochannel.hxx> |
| 11 | #include <simgear/serial/serial.hxx> |
| 12 | |
| 13 | |
| 14 | // Manage UGear Command Channel |
| 15 | class UGCommand { |
| 16 | |
| 17 | private: |
| 18 | |
| 19 | int cmd_send_index; |
| 20 | int cmd_recv_index; |
| 21 | bool prime_state; |
| 22 | std::queue <std::string> cmd_queue; |
| 23 | |
| 24 | public: |
| 25 | |
| 26 | UGCommand(); |
| 27 | ~UGCommand(); |
| 28 | |
| 29 | // send current command until acknowledged |
| 30 | int update( SGSerialPort *serial ); |
| 31 | |
| 32 | void add( const std::string command ); |
| 33 | inline int cmd_queue_size() { |
| 34 | return cmd_queue.size(); |
| 35 | } |
| 36 | inline void update_cmd_sequence( int sequence ) { |
| 37 | cmd_recv_index = sequence; |
| 38 | } |
| 39 | }; |
| 40 | |
| 41 | |
| 42 | extern UGCommand command_mgr; |