293 lines
7.4 KiB
C++
293 lines
7.4 KiB
C++
#ifndef GAMEDISPLAYPAGE_H
|
||
#define GAMEDISPLAYPAGE_H
|
||
|
||
#include <QWidget>
|
||
#include <QLabel>
|
||
#include <QTimer>
|
||
#include "dataformate.h"
|
||
#include "dbforrmate.h"
|
||
#include "spasmtipsdialog.h"
|
||
#include <QUdpSocket>
|
||
#include "trainreport.h"
|
||
#include "quitgamedialog.h"
|
||
#include "emergencystopdialog.h"
|
||
#include "trainreporttwotwo.h"
|
||
#include "trainreportthreetwo.h"
|
||
#include "trainreporttwothree.h"
|
||
#include "sounddialog.h"
|
||
#include "quitbyspeeddialog.h"
|
||
|
||
class QPropertyAnimation;
|
||
namespace Ui {
|
||
class GameDisplayPage;
|
||
}
|
||
|
||
class GameDisplayPage : public QWidget
|
||
{
|
||
Q_OBJECT
|
||
|
||
public:
|
||
explicit GameDisplayPage(QWidget *parent = nullptr);
|
||
~GameDisplayPage();
|
||
|
||
//设置当前用户
|
||
void setUser(const ST_PatientMsg&);
|
||
//表头显示
|
||
void setTitle();
|
||
|
||
/****设置训练部位****
|
||
* 参数@int type 0-上肢 1-下肢 2-上下肢
|
||
* ***/
|
||
void setTrainPart(int type);
|
||
|
||
//根据参数填充实时数据
|
||
void setSlaveParam(ST_DeviceParam& st_deviceParam);
|
||
|
||
//根据界面的参数设置模式
|
||
void setTrainMode(int8_t mode);
|
||
|
||
//设置主被动切换的模式(实时填充)
|
||
void setActivePassiveSwitchMode(int8_t mode);
|
||
|
||
//在未开始游戏,处理急停状态
|
||
void getEmergecyState(ST_DeviceParam& st_deviceParam);
|
||
|
||
|
||
/****填充设置参数***
|
||
*参数@int direction 0-正向 1-反向
|
||
****/
|
||
void fillSetParam(int updown,int speed,int resistance,int direction);
|
||
//设置脉搏血氧
|
||
void setPulseOxygen(const ST_PulseOxygen&);
|
||
//设置中部参数
|
||
void setCenterParam(int left,int right,int length);
|
||
|
||
/***********通信相关************/
|
||
/*****设置速度***
|
||
* 参数@int speed 速度大小
|
||
* @qint8 type 上下肢类型 0-被动转速 1-等速转速
|
||
* ******/
|
||
void setTrainSpeed(int speed = 1,qint8 type = 0);
|
||
|
||
/******设置阻力****
|
||
* 参数@int force 阻力大小
|
||
* @qint8 type 上下肢类型 0-上肢 1-下肢
|
||
* ********/
|
||
void setTrainFore(int force,qint8 type = 0);
|
||
|
||
/******设置方向****
|
||
* 参数@qint8 direction 方向 1-顺时针 0-逆时针
|
||
* @qint8 type 上下肢类型 0-上肢 1-下肢
|
||
* ********/
|
||
void setTrainDirection(qint8 direction = 1,qint8 type = 1);
|
||
|
||
/******设置Fes开关****
|
||
* 参数@qint8 channel 方向 0-电刺激A 1-电刺激B
|
||
* @bool ok 上下肢类型 false-关 true-开
|
||
* ********/
|
||
void switchFes(qint8 channel,bool ok);
|
||
|
||
void initGameSocket();
|
||
|
||
//设置速度使能状态
|
||
void setSpeedState(bool);
|
||
|
||
//设置阻力使能状态
|
||
void setForceState(bool);
|
||
//连续按住改变速度
|
||
void pressedAdjustSpeed();
|
||
//连续按住阻力
|
||
void pressAdjustForce();
|
||
//设置方向是能
|
||
void setDirectionState(bool);
|
||
|
||
protected:
|
||
void paintEvent(QPaintEvent *event);
|
||
|
||
void showEvent(QShowEvent *event);
|
||
|
||
virtual void changeEvent(QEvent* event);
|
||
private slots:
|
||
void on_start_Btn_clicked();
|
||
|
||
void open_Btn_clicked();
|
||
|
||
void close_Btn_clicked();
|
||
|
||
void on_upSpeedMinus_Btn_clicked();
|
||
|
||
void on_upSpeedPlus_Btn_clicked();
|
||
|
||
void on_upForceMinus_Btn_clicked();
|
||
|
||
void on_upForcePlus_Btn_clicked();
|
||
|
||
void on_forward_Btn_clicked();
|
||
|
||
void on_backward_Btn_clicked();
|
||
|
||
void on_stop_Btn_clicked();
|
||
|
||
void on_pause_Btn_clicked();
|
||
|
||
void on_switchAFes_Btn_clicked();
|
||
|
||
//填充电刺激参数
|
||
void slotSetChannelAData(int *data,int size);
|
||
|
||
void slotSetChannelBData(int *data,int size);
|
||
|
||
//踏车设置参数
|
||
void slotSetBicycleParam(ST_BicycleParam st_setBicycleParam);
|
||
|
||
//接收下位机数据
|
||
void slotReceiveData(QByteArray);
|
||
|
||
void slotHeartTimer();
|
||
|
||
void slotCountDownTimer();
|
||
|
||
void slotStopTraining();
|
||
|
||
//游戏数据接收
|
||
void slotReceiveGameData();
|
||
|
||
void slotBackClicked();
|
||
|
||
void on_switchFes_Btn_clicked();
|
||
|
||
void on_sound_Button_clicked();
|
||
|
||
void on_upSpeedPlus_Btn_pressed();
|
||
|
||
void on_upSpeedMinus_Btn_pressed();
|
||
|
||
void on_upSpeedPlus_Btn_released();
|
||
|
||
void on_upSpeedMinus_Btn_released();
|
||
|
||
void on_upForcePlus_Btn_pressed();
|
||
|
||
void on_upForceMinus_Btn_pressed();
|
||
|
||
void on_upForcePlus_Btn_released();
|
||
|
||
void on_upForceMinus_Btn_released();
|
||
|
||
void slotSpeedDialogClosed();
|
||
|
||
//模拟数据
|
||
void slotSimulateData();
|
||
|
||
|
||
|
||
signals:
|
||
/******游戏状态*****
|
||
*@int8_t state 1-开始 0-关闭
|
||
***/
|
||
void signalGameStateChanged(int8_t state);
|
||
|
||
private:
|
||
//解析游戏数据
|
||
void parseGameMsg(QByteArray jsonArray);
|
||
|
||
//给游戏发送实时数据
|
||
void sendGameControlParam(ST_GameControlParam);
|
||
//停止游戏指令
|
||
void sendStopCmd();
|
||
//开始游戏
|
||
void startGameCmd();
|
||
//暂停游戏
|
||
void pauseGameCmd();
|
||
|
||
void sendStopCmdThreeTimes();
|
||
//计算结果数据
|
||
void calculateResultData();
|
||
|
||
void initButton();
|
||
|
||
//退出训练
|
||
void quitTrain();
|
||
|
||
//模式提示
|
||
void changeModeTips(QString str);
|
||
|
||
//根据模式切换按钮状态
|
||
void switchButtonState(int8_t);
|
||
|
||
void setbackBtVisible(bool isShow);
|
||
|
||
//给电刺激发送实时参数
|
||
void sendRealTimeFesParam(ST_FESRealTimeParam);
|
||
void testTipsDialog();
|
||
protected:
|
||
virtual void mouseDoubleClickEvent(QMouseEvent *event);
|
||
private:
|
||
Ui::GameDisplayPage *ui;
|
||
QPropertyAnimation *m_leftAnimation,*m_rightAnimation;
|
||
bool m_openState;
|
||
QList<QLabel*> m_channelAList,m_channelBList;
|
||
int upDirection; //上肢旋转方向 1-正 0-逆
|
||
int downDirection; //下肢旋转方向 1-正 0-逆
|
||
int8_t m_bodyPart; //训练部位 0-上肢 1-下肢 2-上下肢
|
||
SpasmTipsDialog *m_spasmTipsDialog;
|
||
|
||
QTimer *heartTimer;
|
||
QTimer *countDownTimer; //倒计时
|
||
QTimer *paramPressTimer; //持续按主速度参数,改变值
|
||
QTimer *paramPressForceTimer; //持续按主阻力参数,改变值
|
||
ST_BicycleParam m_st_bicycleParam; //启动参数
|
||
int m_startNum; //倒计时初始值
|
||
int m_spasmTimes; //痉挛次数
|
||
QUdpSocket *m_gameSocket;
|
||
ST_TrainReport st_trainReport; //训练报告数据
|
||
|
||
ST_PatientMsg st_patientMsg; //患者信息
|
||
|
||
int8_t m_currentMode; //当前模式
|
||
int8_t m_AP_mode; //切换主被动的模式
|
||
|
||
QList<QPair<int,int>> balanceList;//左右平衡
|
||
|
||
QList<uint8_t> resistentList; //阻力集合
|
||
|
||
QList<uint8_t> speedList; //速度集合
|
||
|
||
TrainReport *m_reportDialog; //正常报告,3行3图的报告
|
||
|
||
TrainReportTwoTwo *m_trainReportTwoTwo; //2行2图的报告
|
||
|
||
TrainReportTwoThree *m_trainReportTwoThree; //2行3图的报告
|
||
|
||
TrainReportThreeTwo *m_trainReportThreeTwo; //3行2图的报告
|
||
|
||
QuitGameDialog *m_quitDialog;
|
||
|
||
EmergencyStopDialog *m_emergencyDialog;
|
||
|
||
int8_t gameState; // 游戏训练状态 0-未开始 1-其他(1开始,2暂停)
|
||
|
||
int heartCount; //心跳次数,用于检测通信
|
||
|
||
E_TRAINSTATE E_gameState;
|
||
|
||
int8_t m_currentDirection; //当前方向
|
||
|
||
int8_t m_gameRebackState; //游戏反馈的状态
|
||
|
||
QString m_tipStr;
|
||
|
||
long m_switchTimes;
|
||
|
||
int m_currentSpeed; //当前速度
|
||
bool m_decreasingSpeed,m_increasingSpeed; //判断连续按住速度是增还是减少
|
||
bool m_decreasingForce,m_increasingForce; //判断连续按住阻力是增还是减少
|
||
|
||
SoundDialog *m_soundDialog;
|
||
QuitBySpeedDialog *m_quitBySpeedDialog; // 速度退出提醒
|
||
|
||
|
||
};
|
||
|
||
#endif // GAMEDISPLAYPAGE_H
|