appmodel.h 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. #ifndef APPMODEL_H
  2. #define APPMODEL_H
  3. #include "EgoInterface.h"
  4. #include "ImageProvider.h"
  5. #include <QObject>
  6. #include <QtCore/QObject>
  7. #include <QtCore/QString>
  8. #include <QtGui>
  9. #include <QtQml/qqml.h>
  10. class CarData : public QObject {
  11. Q_OBJECT
  12. Q_PROPERTY(int32_t uid READ uid WRITE setUid NOTIFY dataChanged)
  13. Q_PROPERTY(QString name READ name WRITE setName NOTIFY dataChanged)
  14. Q_PROPERTY(QString type READ type WRITE setType NOTIFY dataChanged)
  15. Q_PROPERTY(QString state READ state WRITE setState NOTIFY dataChanged)
  16. public:
  17. explicit CarData(QObject *parent = 0);
  18. CarData(const CarData &other);
  19. int32_t uid() const;
  20. QString name() const;
  21. QString type() const;
  22. QString state() const;
  23. int32_t carType() const;
  24. void setUid(const int32_t &value);
  25. void setName(const QString &value);
  26. void setType(const QString &value);
  27. void setState(const QString &value);
  28. void setCarType(const int32_t& value);
  29. signals:
  30. void dataChanged();
  31. private:
  32. int32_t m_uid;
  33. int32_t m_carType;
  34. QString m_name;
  35. QString m_type;
  36. QString m_state;
  37. };
  38. Q_DECLARE_METATYPE(CarData)
  39. class AppModelPrivate;
  40. class CFishEyeWindow;
  41. class AppModel : public QObject {
  42. Q_OBJECT
  43. Q_PROPERTY(bool ready READ ready WRITE setReady NOTIFY readyChanged)
  44. Q_PROPERTY(QQmlListProperty<CarData> car READ car NOTIFY carChanged)
  45. Q_PROPERTY(int32_t radar1 READ radar1 WRITE setRadar1 NOTIFY radar1Changed)
  46. Q_PROPERTY(int32_t radar2 READ radar2 WRITE setRadar2 NOTIFY radar2Changed)
  47. Q_PROPERTY(int32_t radar3 READ radar3 WRITE setRadar3 NOTIFY radar3Changed)
  48. Q_PROPERTY(int32_t radar4 READ radar4 WRITE setRadar4 NOTIFY radar4Changed)
  49. Q_PROPERTY(int32_t radar5 READ radar5 WRITE setRadar5 NOTIFY radar5Changed)
  50. // Q_PROPERTY(int32_t radar6 READ radar6 WRITE setRadar6 NOTIFY radar6Changed)
  51. // Q_PROPERTY(int32_t radar7 READ radar7 WRITE setRadar7 NOTIFY radar7Changed)
  52. Q_PROPERTY(float Steer READ Steer WRITE setSteerAngle NOTIFY steerAngleChanged)
  53. //Q_PROPERTY(int32_t radar6 READ radar6 WRITE setRadar6 NOTIFY radar6Changed)
  54. Q_PROPERTY(int32_t ping READ ping WRITE setPing NOTIFY pingChanged)
  55. Q_PROPERTY(int32_t temp READ temp WRITE setTemp NOTIFY tempChanged)
  56. Q_PROPERTY(int32_t alertSound READ alertSound NOTIFY playAlertSound)
  57. Q_PROPERTY(int32_t Speed READ Speed WRITE SetSpeed NOTIFY speedChanged)
  58. Q_PROPERTY(int32_t Visible READ Visible WRITE SetVisible NOTIFY visibleChanged)
  59. // Q_PROPERTY(int32_t Gear READ Gear WRITE SetGear NOTIFY gearChanged)
  60. Q_PROPERTY(QString Account READ Account WRITE setAccount NOTIFY accountChanged)
  61. Q_PROPERTY(QString Password READ Password WRITE setPassword NOTIFY passwordChanged)
  62. Q_PROPERTY(QString CarName READ CarName WRITE setCarName NOTIFY carNameChanged)
  63. Q_PROPERTY(QString DriveName READ DriveName WRITE setDriveName NOTIFY driveNameChanged)
  64. Q_PROPERTY(int32_t BrakePressure READ BrakePressure WRITE SetBrakePressure NOTIFY brakePressureChanged)
  65. Q_PROPERTY(int32_t GearboxOilPressure READ GearboxOilPressure WRITE SetGearBoxOilPressure NOTIFY gearboxOilPressureChanged)
  66. Q_PROPERTY(int32_t GearboxOilTemp READ GearboxOilTemp WRITE SetGearBoxOilTemp NOTIFY gearboxOilTempChanged)
  67. Q_PROPERTY(int32_t EnginRpm READ EnginRpm WRITE SetEngingRpm NOTIFY engineRpmChanged)
  68. Q_PROPERTY(int32_t EngineOilPressure READ EngineOilPressure WRITE SetEngineOilPressure NOTIFY engineoilPressureChanged)
  69. Q_PROPERTY(int32_t OilPos READ OilPos WRITE SetOilPos NOTIFY oilPosChanged)
  70. Q_PROPERTY(int32_t WorkPressure READ WorkPressure WRITE setWorkPressure NOTIFY workPressureChanged)
  71. Q_PROPERTY(int32_t Cold READ Cold WRITE SetCold NOTIFY coldChanged)
  72. Q_PROPERTY(int32_t leftAngle READ leftAngle WRITE setLeftAngle NOTIFY leftAngleChanged)
  73. Q_PROPERTY(int32_t rightAngle READ rightAngle WRITE setRightAngle NOTIFY rightAngleChanged)
  74. // Q_PROPERTY(int32_t ModelX READ ModelX WRITE setModelX NOTIFY modelXChanged)
  75. // Q_PROPERTY(int32_t ModelY READ ModelY WRITE setModelY NOTIFY modelYChanged)
  76. // Q_PROPERTY(int32_t ModelZ READ ModelZ WRITE setModelZ NOTIFY modelZChanged)
  77. public:
  78. explicit AppModel(IEgoNotify *n , IEgoControl *c , QObject* qmlObj, QObject *parent = 0);
  79. ~AppModel();
  80. Q_INVOKABLE void userLogin(QString useName, QString password);
  81. Q_INVOKABLE void connectCar(int id);
  82. Q_INVOKABLE void leaveCar();
  83. Q_INVOKABLE void logout();
  84. Q_INVOKABLE void moveBegin(int32_t area,int32_t no);
  85. // Q_INVOKABLE void switchDriver();
  86. //Q_INVOKABLE void areaChanged(int32_t area);
  87. Q_INVOKABLE void controlCar(int id);
  88. Q_INVOKABLE void cancelControl();
  89. Q_INVOKABLE void showBackDlg(QString content, WorkArea area, int32_t no, int32_t uid);
  90. Q_INVOKABLE void showMoveDlg(MoveDesc desc);
  91. Q_INVOKABLE bool idle(int32_t uid);
  92. //Q_INVOKABLE void showTrackDlg();
  93. // Q_INVOKABLE void track();
  94. //Q_INVOKABLE void unTrack();
  95. //Q_INVOKABLE bool autoClose();
  96. //Q_INVOKABLE QString ReadyText();
  97. bool ready() const;
  98. int radar1() const;
  99. int radar2() const;
  100. int radar3() const;
  101. int radar4() const;
  102. int radar5() const;
  103. //int radar6() const;
  104. //int radar7() const;
  105. QString Account() const;
  106. QString Password() const;
  107. QString CarName() const;
  108. QString DriveName() const;
  109. /*int radar6() const;*/
  110. int ping() const;
  111. double temp() const;
  112. int alertSound() const;
  113. int32_t BrakePressure() const;
  114. int32_t OilPos() const;
  115. int32_t GearboxOilPressure()const;
  116. int32_t GearboxOilTemp()const;
  117. int32_t EnginRpm()const;
  118. int32_t EngineOilPressure()const;
  119. int32_t Speed()const;
  120. bool Visible() const;
  121. //int32_t Gear() const;
  122. int32_t Cold() const;
  123. //int32_t ModelX() const;
  124. // int32_t ModelY() const;
  125. // int32_t ModelZ() const;
  126. int32_t leftAngle() const;
  127. int32_t rightAngle() const;
  128. float Steer() const;
  129. int32_t WorkPressure() const;
  130. void SetBrakePressure(const int32_t value);
  131. void SetOilPos(const int32_t value);
  132. void SetGearBoxOilPressure(const int32_t value);
  133. void SetGearBoxOilTemp(const int32_t value);
  134. void SetEngingRpm(const int32_t value);
  135. void SetEngineOilPressure(const int32_t value);
  136. void SetSpeed(const int32_t value);
  137. void SetVisible(const bool value);
  138. //void SetGear(const int32_t value);
  139. void SetCold(const int32_t value);
  140. void setReady(const bool value);
  141. void setRadar1(const int32_t &value);
  142. void setRadar2(const int32_t &value);
  143. void setRadar3(const int32_t &value);
  144. void setRadar4(const int32_t &value);
  145. void setRadar5(const int32_t &value);
  146. //void setRadar6(const int32_t& value);
  147. //void setRadar7(const int32_t& value);
  148. void setAccount(const QString& value);
  149. void setPassword(const QString& password);
  150. void setCarName(const QString& carname);
  151. void setDriveName(const QString& drivename);
  152. void setWorkPressure(const int32_t value);
  153. //void setModelX(const int32_t value);
  154. //void setModelY(const int32_t value);
  155. //void setModelZ(const int32_t value);
  156. void setLeftAngle(const int32_t value);
  157. void setRightAngle(const int32_t value);
  158. //void setRadar6(const int32_t &value);
  159. void setPing(const int32_t &value);
  160. void setTemp(const double& value);
  161. void setSteerAngle(const float& value);
  162. QQmlListProperty<CarData> car() const;
  163. public slots:
  164. void onLoginRst(bool rst);
  165. void onCarAppend(const UserCamera &info);
  166. void onRadarUpadte(int32_t r0, int32_t r1, int32_t r2, int32_t r3, int32_t r4,
  167. int32_t r5, int32_t r6);
  168. void onEncodeUpdate(int32_t left, int32_t right);
  169. void onFeedData(const FeedData& data);
  170. void onNotifyState(int32_t uid, UserState state);
  171. void onPing(int32_t value,double temp);
  172. void onMoveEnd(int32_t rid, WorkArea area, int32_t no);
  173. void onNotifyDel(int32_t peer);
  174. void onKickoff();
  175. void onNotifyLeave(int32_t peer);
  176. void onNotifyFail(int32_t peer);
  177. void onMoveRet(MoveDesc desc);
  178. void OnClose();
  179. //void OnPosition(float x, float y, float z);
  180. signals:
  181. void readyChanged();
  182. void carChanged();
  183. void radar1Changed();
  184. void radar2Changed();
  185. void radar3Changed();
  186. void radar4Changed();
  187. void radar5Changed();
  188. //void radar6Changed();
  189. //void radar7Changed();
  190. void accountChanged();
  191. void passwordChanged();
  192. void carNameChanged();
  193. void driveNameChanged();
  194. void sectionTextChanged();
  195. void steerAngleChanged();
  196. // void radar6Changed();
  197. void pingChanged();
  198. void tempChanged();
  199. void speedChanged();
  200. void visibleChanged();
  201. void gearChanged();
  202. void coldChanged();
  203. void gearboxOilPressureChanged();
  204. void gearboxOilTempChanged();
  205. void engineRpmChanged();
  206. void engineoilPressureChanged();
  207. void brakePressureChanged();
  208. void playAlertSound();
  209. void carConnected();
  210. void closeWin();
  211. void oilPosChanged();
  212. void workPressureChanged();
  213. void leftAngleChanged();
  214. void rightAngleChanged();
  215. private:
  216. IEgoNotify *_notify;
  217. IEgoControl *_control;
  218. // std::unique_ptr<CFishEyeWindow> _window;
  219. AppModelPrivate *d;
  220. std::vector<UserCamera> _users;
  221. QString m_account;
  222. QString m_password;
  223. QString m_carName;
  224. QString m_driveName;
  225. int32_t m_radar1 = 0;
  226. int32_t m_radar2 = 0;
  227. int32_t m_radar3 = 0;
  228. int32_t m_radar4 = 0;
  229. int32_t m_radar5 = 0;
  230. //int32_t m_radar6 = 0;
  231. //int32_t m_radar7 = 0;
  232. int32_t m_ping =0;
  233. double m_temp = 0.f;
  234. int32_t m_alert;
  235. int32_t m_peer;
  236. int32_t m_work_pressure =0; //工作系统压力
  237. int32_t m_brake_pressure =0;//制动系统压力
  238. int32_t m_gearbox_oil_temp =0;//变速箱油温
  239. int32_t m_gearbox_oil_pressure=0;//变速箱油压
  240. int32_t m_oil_pos = 0;
  241. int32_t m_cold_water = 0;
  242. int32_t m_engine_rpm =0;//发动机转速
  243. int32_t m_engine_oil_pressure =0;// 发动机油压
  244. int32_t m_speed =0;
  245. bool m_visible = true;
  246. //int32_t m_gear =0;
  247. //WorkArea m_area= WorkArea::Area_A;
  248. // int32_t m_no;
  249. bool m_ready;
  250. QObject* m_qmlObj = nullptr;
  251. //int32_t m_modelx = 0;
  252. //int32_t m_modely = 0;
  253. int32_t m_steerAngle = 0;
  254. // int32_t m_modelz = 0;
  255. int32_t m_leftAngle = 0;
  256. int32_t m_rightAngle = 0;
  257. Lock_Status m_leftlock;
  258. Lock_Status m_rightlock;
  259. };
  260. #endif // APPMODEL_H