get_uart.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #ifndef GET_UART_H
  2. #define GET_UART_H
  3. #include <QObject>
  4. #include <QString>
  5. #include <QThread>
  6. #include <QtSerialPort/QtSerialPort>
  7. #include <iostream>
  8. #include <QVector>
  9. #include <qcustomplot/qcustomplot.h>
  10. const int N_P_GRAPH_DATA_SIZE = 1201, N_M_GRAPH_DATA_SIZE = 280;
  11. struct GraphData
  12. {
  13. QVector <double> ADC1_y_val;
  14. QVector <double> ADC2_y_val;
  15. QVector <double> ADC1_Count;
  16. QVector <double> ADC2_Count;
  17. int32_t f_delta_g = 0;
  18. int16_t m_position_g = 0;
  19. int32_t f_curr = 0;
  20. int32_t g_cur_pos = 0;
  21. int32_t g_offset = 0;
  22. GraphData(unsigned int nADC1Size, unsigned int nADC2Size) : ADC1_y_val(nADC1Size), ADC2_y_val(nADC2Size), ADC1_Count(nADC1Size), ADC2_Count(nADC2Size)
  23. {
  24. }
  25. private:
  26. GraphData() {};
  27. };
  28. class Get_Uart : public QObject
  29. {
  30. Q_OBJECT
  31. public:
  32. Get_Uart(QString name);
  33. ~Get_Uart();
  34. uint32_t i, graph_delay, graph_count;
  35. QString err, data;
  36. int ADC1_y, ADC2_y, ADC1_y_aprx, ADC2_y_aprx, f_delta, m_position, graph_offset, f_delta_g, m_pos_g;
  37. const uint8_t graph_delay_max = 5;
  38. uint8_t cmd_ok = 0;
  39. QFile out_data;
  40. public slots:
  41. void doWork();
  42. void recv_command(QString);
  43. void OpenSerial(QString);
  44. signals:
  45. void send_err(QString);
  46. void send_graph_pointer(GraphData *);
  47. private:
  48. QString name;
  49. QSerialPort *serial;
  50. GraphData theGraphData;
  51. void CloseSerial();
  52. int f_delta_old, m_pos_old;
  53. private slots:
  54. void ReadSerial();
  55. };
  56. #endif // GET_UART_H