This commit is contained in:
curtis
2024-11-25 17:15:44 +08:00
commit 32e5360a91
3749 changed files with 1432905 additions and 0 deletions

View File

@@ -0,0 +1,143 @@
#include "ccommunicateapi.h"
#include "readconfig.h"
#include "ccommunicationinterface.h"
#include "cserialportinterface.h"
#include "cudpinterface.h"
#include "ctcpsocketinterface.h"
#include <QDebug>
CCommunicateAPI *CCommunicateAPI::m_API = NULL;
CCommunicateAPI::CCommunicateAPI(QObject *parent) :
QObject(parent),
m_interface(NULL)
{
init();
}
CCommunicateAPI::~CCommunicateAPI()
{
if(m_interface)
{
delete m_interface;
m_interface = NULL;
}
}
CCommunicateAPI *CCommunicateAPI::getInstance()
{
if(!m_API)
{
m_API = new CCommunicateAPI();
}
return m_API;
}
void CCommunicateAPI::init()
{
commuType = ReadConfig::getInstance()->getCommunicateType();
//根据通信方式生成不同的对象
if(0 == commuType) //串口
{
m_interface = new CSerialportInterface();
}
else if(1 == commuType) //udp
{
m_interface = new CUdpInterface();
}
else if(2 == commuType) //tcp
{
m_interface = new CTcpSocketInterface();
}
else if(3 == commuType) //can
{
//待添加
}
if(m_interface)
{
connect(m_interface,SIGNAL(signalReadyRead(QByteArray)),this,SIGNAL(signalReadyRead(QByteArray)));
connect(m_interface,SIGNAL(signalDisplayError(QString)),this,SIGNAL(signalCommunicateChanged(QString)));
}
}
void CCommunicateAPI::sendData(QByteArray sendArray)
{
char length = sendArray.size();
sendArray.prepend(length);
sendArray.prepend(PACKHEAD);
//添加校验
char sum = 0;
sendArray.append(sum);
sendArray.append(PACKTAIL);
m_interface->sendDataInterface(sendArray);
// qDebug() << "数据:" <<sendArray;
}
//在send_CMD-5个字节序号、发送ID、接收ID、CMD
void CCommunicateAPI::sendData(uint16_t cmdID,QByteArray arrayData)
{
QByteArray fixedArray;
fixedArray.resize(5);
fixedArray[0] = arrayData.length();
memcpy(fixedArray.data()+3,&cmdID,sizeof(uint8_t));
fixedArray.append(arrayData);
sendData(fixedArray);
}
//故障复位
void CCommunicateAPI::resetFault()
{
QByteArray sendArray;
sendArray.resize(4);
sendArray[0] = 0;
sendArray[1] = 0;
sendArray[2] = 1;
sendArray[3] = 0x06;
sendData(sendArray);
}
//发送心跳
void CCommunicateAPI::sendHeartBeat()
{
QByteArray array(4,0);
array[0] = SEND_HEARTBEAT_CMD; //指令
sendData(array);
}
void CCommunicateAPI::sendBicycleParam(const ST_BicycleParam &st_bicycleParam)
{
QByteArray array(13,0);
array[0] = BICYCLE_PARAM_CMD;
memcpy(array.data() + 1,&st_bicycleParam,sizeof(ST_BicycleParam));
sendData(array);
}
void CCommunicateAPI::sendRealTimeParam(E_REALTIMECMD sbuCmd,quint8 value)
{
QByteArray array(4,0);
array[0] = REALTIME_PARAM_CMD;
array[1] = sbuCmd;
array[2] = value;
sendData(array);
}
void CCommunicateAPI::SetquitCmd()
{
// uint16_t cmdId = QUIT_CMD;
// QByteArray array;
// array.resize(0);
// CCommunicateAPI::getInstance()->sendData(cmdId,array);
}
void CCommunicateAPI::setConfigParam()
{
m_interface->setConfigParam();
}

View File

@@ -0,0 +1,59 @@
#ifndef CCOMMUNICATEAPI_H
#define CCOMMUNICATEAPI_H
#include <QObject>
#include "dataformate.h"
class CCommunicationInterface;
class CCommunicateAPI : public QObject
{
Q_OBJECT
public:
static CCommunicateAPI *getInstance();
void sendData(QByteArray);
/************************************
*说明:发送数据函数【重载函数】
*参数:
*@uint8_t seq包的序号,默认为0当发送的数据需要拆包时才会使用
*@uint8_t id 自身设备ID号
*@uint8_t cmdID协议ID号
*@QByteArray arrayData有效数据
*返回值:无
***********************************/
void sendData(uint16_t cmdID,QByteArray arrayData);
//故障复位
void resetFault();
//心跳开关
void sendHeartBeat();
/****测试函数****/
//启动前参数
void sendBicycleParam(const ST_BicycleParam&);
//实时调节参数
void sendRealTimeParam(E_REALTIMECMD,quint8 value);
//退出当前状态
void SetquitCmd();
void setConfigParam();
signals:
//接收到实际数据
void signalReadyRead(QByteArray);
void signalCommunicateChanged(QString);
private:
explicit CCommunicateAPI(QObject *parent = nullptr);
~CCommunicateAPI();
void init();
private:
static CCommunicateAPI *m_API;
int commuType;
CCommunicationInterface *m_interface;
};
#endif // CCOMMUNICATEAPI_H

View File

@@ -0,0 +1,12 @@
#include "ccommunicationinterface.h"
CCommunicationInterface::CCommunicationInterface()
{
}
CCommunicationInterface::~CCommunicationInterface()
{
}
//解析数据
void CCommunicationInterface::analysisProtocal(QByteArray)
{}

View File

@@ -0,0 +1,31 @@
#ifndef CCOMMUNICATIONINTERFACE_H
#define CCOMMUNICATIONINTERFACE_H
#include <QObject>
class CCommunicationInterface : public QObject
{
Q_OBJECT
public:
CCommunicationInterface();
~CCommunicationInterface();
//配置参数
virtual bool setConfigParam() = 0;
//发送数据接口
virtual void sendDataInterface(QByteArray) = 0;
//解析数据
virtual void analysisProtocal(QByteArray);
signals:
//接收到实际数据
void signalReadyRead(QByteArray);
//通信对象发生错误
void signalDisplayError(QString);
//通信状态发生变化
void signalStateChanged(int);
public slots:
//接收数据接口
};
#endif // CCOMMUNICATIONINTERFACE_H

View File

@@ -0,0 +1,276 @@
#include "cserialportinterface.h"
#include <QApplication>
#include "readconfig.h"
#include <QSerialPortInfo>
#include <QMessageBox>
#include <QDebug>
#include <QDateTime>
#include "languagemanager.h"
//#pragma execution_character_set("utf-8")
CSerialportInterface::CSerialportInterface():m_serialPort(NULL)
{
receiveArray.clear();
if(!m_serialPort)
{
m_serialPort = new QSerialPort();
connect(m_serialPort,&QSerialPort::readyRead,this,&CSerialportInterface::receiveDataInterface);
connect(m_serialPort,&QSerialPort::errorOccurred,this,&CSerialportInterface::displayError);
setConfigParam();
}
m_blockTimer = new QTimer();
m_blockTimer->setInterval(1000);
//connect(m_blockTimer,SIGNAL(timeout()),this,SLOT(slotHandleTimeout()));
connect(m_blockTimer,&QTimer::timeout,this,[=]
{
qDebug()<<"Hello"; //串口都没有哪来的jiekou
if(!m_serialPort->isOpen())
{
setConfigParamSerialError();
qDebug()<<"串口重新打开失败";
}
else
{
qDebug()<<"串口重新打开成功";
m_blockTimer->stop();
displayError(QSerialPort::NoError);
}
});
}
CSerialportInterface::~CSerialportInterface()
{
if(m_serialPort)
{
delete m_serialPort;
m_serialPort = NULL;
}
}
//配置参数
bool CSerialportInterface::setConfigParam()
{
m_serialPort->close();
ST_SerialPortConfig st_SerialConfig;
if(!ReadConfig::getInstance()->getSerialPortConfig(st_SerialConfig))
{
QMessageBox::warning(NULL,tr("警告"),tr("获取串口配置失败"),QMessageBox::Retry);
return false;
}
QSerialPortInfo m_SerialPortInfo;
QStringList serialPortNames;
#if 0
foreach(m_SerialPortInfo,QSerialPortInfo::availablePorts())
{
QSerialPort serialport;
serialport.setPort(m_SerialPortInfo);
if(serialport.open(QIODevice::ReadWrite))
{
serialPortNames.append(m_SerialPortInfo.portName());
serialport.close();
}
}
if(serialPortNames.isEmpty())
{
QMessageBox::warning(NULL,tr("警告"),tr("无可用串口"),QMessageBox::Retry);
return false;
}
#endif
if(m_serialPort)
{
m_serialPort->setPortName(st_SerialConfig.portName);
m_serialPort->setReadBufferSize(200);
if(m_serialPort->open(QIODevice::ReadWrite))
{
m_serialPort->setBaudRate(st_SerialConfig.baud);
m_serialPort->setDataBits(QSerialPort::Data8);
m_serialPort->setParity(QSerialPort::NoParity);
m_serialPort->setStopBits(QSerialPort::OneStop);
m_serialPort->setFlowControl(QSerialPort::NoFlowControl);
}
else
{
E_LANGUAGE language = LanguageManager::getInstance()->getCurrentLanguage();
if(language == Chinese_E)
QMessageBox::warning(NULL,tr("警告"),tr("串口打开失败"),QMessageBox::Retry);
else //if(language == English_E)
QMessageBox::warning(NULL,tr("Warning"),tr("Failed to open the serial port"),QMessageBox::Retry);
qDebug() <<"current language index:"<< language;
//QMessageBox::warning(NULL,tr("警告"),tr("串口打开失败"),QMessageBox::Retry);
return false;
}
}
return true;
}
//发送数据接口
void CSerialportInterface::sendDataInterface(QByteArray sendArray)
{
if(m_serialPort)
{
if(m_serialPort->isOpen())
{
m_serialPort->write(sendArray);
// qDebug()<<"send"<<sendArray.toHex();
//qDebug() <<"发送时间:"<< QDateTime::currentDateTime();
}
else
{
// qDebug()<<tr("串口已关闭");
}
}
}
//接收数据接口
void CSerialportInterface::receiveDataInterface()
{
QByteArray buf;
buf = m_serialPort->readAll();
receiveArray.append(buf);
while(!receiveArray.isEmpty())
{
if(receiveArray[0] != (char)SLAVEPACKHEAD)
{
receiveArray.remove(0,1);
}
else
{
//获取有效数据长度
uint8_t datalen = 0;
memcpy(&datalen,receiveArray.constData()+1,sizeof(uint8_t));
if(receiveArray.length() >= datalen + 4)
{
//校验成功
if((uint8_t)receiveArray[datalen+3] == SLAVEPACKTAIL)
{
emit signalReadyRead(receiveArray.mid(0,datalen + 4));
// qDebug()<<receiveArray.toHex();
receiveArray.remove(0,datalen + 4);
}
else //校验失败
{
//方式1 丢弃本包
receiveArray.remove(0,datalen + 4);
}
}
else //数据不够,直接退出继续接收
break;
}
}
}
void CSerialportInterface::displayError(QSerialPort::SerialPortError error)
{
QString lastError("");
switch(error)
{
case QSerialPort::NoError:
lastError = "";
break;
case QSerialPort::DeviceNotFoundError:
lastError = "DeviceNotFoundError";
break;
case QSerialPort::PermissionError:
lastError = "PermissionError";
break;
case QSerialPort::OpenError:
lastError = "OpenError";
break;
case QSerialPort::NotOpenError:
lastError = "NotOpenError";
break;
case QSerialPort::WriteError:
//lastError = "WriteError";
handleSerialError(); //串口被拔了,重新检测串口
break;
case QSerialPort::ReadError:
lastError = "ReadError";
break;
case QSerialPort::UnknownError:
lastError = "UnknownError";
break;
default:
break;
}
emit signalDisplayError(lastError);
}
void CSerialportInterface::handleSerialError()
{
m_blockTimer->start();
qDebug() <<"定时器开始运行";
setConfigParam();
}
//解析数据
void CSerialportInterface::analysisProtocal(QByteArray)
{
}
//配置参数
bool CSerialportInterface::setConfigParamSerialError()
{
m_serialPort->close();
ST_SerialPortConfig st_SerialConfig;
if(!ReadConfig::getInstance()->getSerialPortConfig(st_SerialConfig))
{
QMessageBox::warning(NULL,tr("警告"),tr("获取串口配置失败"),QMessageBox::Retry);
return false;
}
QSerialPortInfo m_SerialPortInfo;
QStringList serialPortNames;
#if 0
foreach(m_SerialPortInfo,QSerialPortInfo::availablePorts())
{
QSerialPort serialport;
serialport.setPort(m_SerialPortInfo);
if(serialport.open(QIODevice::ReadWrite))
{
serialPortNames.append(m_SerialPortInfo.portName());
serialport.close();
}
}
if(serialPortNames.isEmpty())
{
QMessageBox::warning(NULL,tr("警告"),tr("无可用串口"),QMessageBox::Retry);
return false;
}
#endif
if(m_serialPort)
{
m_serialPort->setPortName(st_SerialConfig.portName);
m_serialPort->setReadBufferSize(200);
if(m_serialPort->open(QIODevice::ReadWrite))
{
m_serialPort->setBaudRate(st_SerialConfig.baud);
m_serialPort->setDataBits(QSerialPort::Data8);
m_serialPort->setParity(QSerialPort::NoParity);
m_serialPort->setStopBits(QSerialPort::OneStop);
m_serialPort->setFlowControl(QSerialPort::NoFlowControl);
}
/*else
{
QMessageBox::warning(NULL,tr("警告"),tr("串口打开失败"),QMessageBox::Retry);
return false;
}*/
}
return true;
}

View File

@@ -0,0 +1,36 @@
#ifndef CSERIALPORTINTERFACE_H
#define CSERIALPORTINTERFACE_H
#include "ccommunicationinterface.h"
#include <QObject>
#include <QSerialPort>
#include <QTimer>
class CSerialportInterface : public CCommunicationInterface
{
public:
CSerialportInterface();
~CSerialportInterface();
//配置参数
virtual bool setConfigParam();
//发送数据接口
virtual void sendDataInterface(QByteArray);
//解析数据
virtual void analysisProtocal(QByteArray);
public slots:
//接收数据接口
void receiveDataInterface();
//通信状态变化
void deviceStateChanged(int);
//处理串口断开
void handleSerialError();
//QSerialPort::SerialPortError
//设备错误
void displayError(QSerialPort::SerialPortError error);
bool setConfigParamSerialError();
private:
QSerialPort *m_serialPort;
QByteArray receiveArray;
QTimer *m_blockTimer;
};
#endif // CSERIALPORTINTERFACE_H

View File

@@ -0,0 +1,86 @@
#include "ctcpsocketinterface.h"
#include <QTcpSocket>
#include <QApplication>
#include <QTcpServer>
#include <QAbstractSocket>
CTcpSocketInterface::CTcpSocketInterface(int type):
m_tcpSocket(NULL),
m_tcpServer(NULL)
{
if(0 == type) //客户端
{
m_tcpSocket = new QTcpSocket();
connect(m_tcpSocket,&QTcpSocket::readyRead,this,&CTcpSocketInterface::receiveDataInterface);
}
else if(1 == type) //服务端
{
m_tcpServer = new QTcpServer();
connect(m_tcpServer, &QTcpServer::newConnection, this, &CTcpSocketInterface::newTcpConnection);
connect(m_tcpServer, &QTcpServer::acceptError, this, &CTcpSocketInterface::displayError);
}
}
//新的连接
void CTcpSocketInterface::newTcpConnection()
{
m_tcpSocket = m_tcpServer->nextPendingConnection();
if(m_tcpSocket)
{
connect(m_tcpServer, &QTcpServer::newConnection, this, &CTcpSocketInterface::newTcpConnection);
connect(m_tcpServer, &QTcpServer::acceptError, this, &CTcpSocketInterface::displayError);
}
}
//错误输出
void CTcpSocketInterface::displayError(QAbstractSocket::SocketError socketError)
{
QString lastError("");
switch(socketError)
{
case QAbstractSocket::ConnectionRefusedError:
lastError = "ConnectionRefusedError";
break;
case QAbstractSocket::RemoteHostClosedError:
lastError = "RemoteHostClosedError";
break;
case QAbstractSocket::HostNotFoundError:
lastError = "HostNotFoundError";
break;
case QAbstractSocket::SocketAccessError:
lastError = "SocketAccessError";
break;
case QAbstractSocket::UnknownSocketError:
lastError = "UnknownSocketError";
break;
default:
break;
}
emit signalDisplayError(lastError);
}
//配置参数
bool CTcpSocketInterface::setConfigParam()
{
//读取xml配置文件
QString path = QApplication::applicationDirPath();
//绑定端口
return true;
}
//发送数据接口
void CTcpSocketInterface::sendDataInterface(QByteArray sendArray)
{
if(m_tcpSocket)
{
m_tcpSocket->write(sendArray);
}
}
//解析数据
void CTcpSocketInterface::analysisProtocal(QByteArray dataArray)
{
Q_UNUSED(dataArray)
}
void CTcpSocketInterface::receiveDataInterface()
{
QByteArray sendArray;
emit signalReadyRead(sendArray);
}

View File

@@ -0,0 +1,34 @@
#ifndef CTCPSOCKETINTERFACE_H
#define CTCPSOCKETINTERFACE_H
#include "ccommunicationinterface.h"
#include <QObject>
#include <QAbstractSocket>
class QTcpSocket;
class QTcpServer;
class CTcpSocketInterface : public CCommunicationInterface
{
public:
//0-客户端 1-服务端
CTcpSocketInterface(int type = 0);
//配置参数
virtual bool setConfigParam();
//发送数据接口
virtual void sendDataInterface(QByteArray);
//解析数据
virtual void analysisProtocal(QByteArray);
public slots:
//接收数据接口
void receiveDataInterface();
void newTcpConnection();
void displayError(QAbstractSocket::SocketError socketError);
void deviceStateChanged(QAbstractSocket::SocketState);
private:
QTcpSocket *m_tcpSocket;
QTcpServer *m_tcpServer;
};
#endif // CTCPSOCKETINTERFACE_H

View File

@@ -0,0 +1,129 @@
#include "cudpinterface.h"
#include <QUdpSocket>
#include "dataFormate.h"
#include "readconfig.h"
//LOG4QT_DECLARE_STATIC_LOGGER(logger, CUdpInterface)
CUdpInterface::CUdpInterface():m_udpSocket(NULL)
{
if(!m_udpSocket)
{
m_udpSocket = new QUdpSocket();
connect(m_udpSocket,&QUdpSocket::readyRead,this,&CUdpInterface::receiveDataInterface);
connect(m_udpSocket,&QUdpSocket::stateChanged,this,&CUdpInterface::deviceStateChanged);
setConfigParam();
}
}
CUdpInterface::~CUdpInterface()
{
if(m_udpSocket)
{
delete m_udpSocket;
m_udpSocket = NULL;
}
}
//配置参数
bool CUdpInterface::setConfigParam()
{
//读取配置文件
int16_t port;
QString ip;
if(ReadConfig::getInstance()->getUdpServerAddress(port,ip))
{
if(!m_udpSocket->bind(QHostAddress(ip),port,QUdpSocket::ShareAddress|QUdpSocket::ReuseAddressHint))
{
// logger()->debug(QString("UDP bind port %1 failed").arg(port));
}
else
{
qDebug()<<"bind successed"<<port<<ip;
}
}
//绑定端口
return true;
}
//发送数据接口
void CUdpInterface::sendDataInterface(QByteArray sendArray)
{
int16_t port;
QString ip;
if(ReadConfig::getInstance()->getUdpClientAddress(port,ip))
{
if(m_udpSocket)
{
m_udpSocket->writeDatagram(sendArray,QHostAddress(ip),port);
}
}
}
//接收数据接口
void CUdpInterface::receiveDataInterface()
{
while(m_udpSocket->hasPendingDatagrams())
{
QByteArray buf;
buf.resize(m_udpSocket->pendingDatagramSize());
m_udpSocket->readDatagram(buf.data(),buf.size());
if(buf[0] != (char)PACKHEAD)
{
//如果不是完成包则丢弃
break;
}
else
{
//获取有效数据长度
uint8_t datalen = 0;
memcpy(&datalen,buf.constData()+1,sizeof(uint8_t));
//当缓存中的数据长度大于等于一包数据长度时开始解析
if(buf.length() >= datalen + 8)
{
uint8_t CRC_H = 0;
uint8_t CRC_L = 0;
#if 0
uint8_t *checkData = (uint8_t *)malloc(datalen+7);
memset(checkData,0,datalen+7);
memcpy(checkData,buf.constData(),datalen+7);
Pressure_CheckCRC(checkData,datalen+7,&CRC_H,&CRC_L);
free(checkData);
checkData = NULL;
#else
// Pressure_CheckCRC((uint8_t*)buf.constData(),datalen+6,&CRC_H,&CRC_L);
#endif
//校验成功
if((CRC_L == (uint8_t)buf[6+datalen]) && (CRC_H == (uint8_t)buf[7+datalen]))
{
emit signalReadyRead(buf.mid(0,datalen + 8));
buf.clear();
}
else
{
buf.clear();
break;
}
}
}
}
}
void CUdpInterface::deviceStateChanged(QAbstractSocket::SocketState state)
{
switch(state)
{
case QAbstractSocket::BoundState:
emit signalStateChanged(BoundState_E);
break;
case QAbstractSocket::ClosingState:
emit signalStateChanged(ClosingState_E);
break;
default:
break;
}
}
//解析数据
void CUdpInterface::analysisProtocal(QByteArray)
{
}

View File

@@ -0,0 +1,30 @@
#ifndef CUDPINTERFACE_H
#define CUDPINTERFACE_H
#include "ccommunicationinterface.h"
#include <QObject>
#include <QAbstractSocket>
class QUdpSocket;
class CUdpInterface : public CCommunicationInterface
{
public:
CUdpInterface();
~CUdpInterface();
//配置参数
virtual bool setConfigParam();
//发送数据接口
virtual void sendDataInterface(QByteArray);
//解析数据
virtual void analysisProtocal(QByteArray);
public slots:
//接收数据接口
void receiveDataInterface();
//设备状态发生变化
void deviceStateChanged(QAbstractSocket::SocketState);
//设备错误
void displayError(QAbstractSocket::SocketError socketError);
private:
QUdpSocket *m_udpSocket;
};
#endif // CUDPINTERFACE_H

View File

@@ -0,0 +1,41 @@
#include "globalqueue.h"
#include <QMutexLocker>
QMutex GlobalQueue::m_mutex;
QQueue<QByteArray> GlobalQueue::m_queue;
GlobalQueue* GlobalQueue::m_globalQueue = NULL;
GlobalQueue::GlobalQueue(QObject *parent) : QObject(parent)
{
}
GlobalQueue* GlobalQueue::getInstance()
{
if(!m_globalQueue)
{
m_globalQueue = new GlobalQueue();
}
return m_globalQueue;
}
void GlobalQueue::gEnqueue(const QByteArray& array)
{
QMutexLocker lock(&m_mutex);
m_queue.enqueue(array);
}
QByteArray GlobalQueue::gDequeue()
{
QMutexLocker lock(&m_mutex);
return m_queue.dequeue();
}
int GlobalQueue::getSize()
{
QMutexLocker lock(&m_mutex);
return m_queue.size();
}
void GlobalQueue::clearQueue()
{
QMutexLocker lock(&m_mutex);
m_queue.clear();
}

View File

@@ -0,0 +1,28 @@
#ifndef GLOBALQUEUE_H
#define GLOBALQUEUE_H
#include <QObject>
#include <QMutex>
#include <QQueue>
class GlobalQueue : public QObject
{
Q_OBJECT
public:
static GlobalQueue* getInstance();
void gEnqueue(const QByteArray&);
QByteArray gDequeue();
int getSize();
void clearQueue();
private:
explicit GlobalQueue(QObject *parent = nullptr);
static QMutex m_mutex;
//全局队列,用于数据的传输
static QQueue<QByteArray> m_queue;
static GlobalQueue* m_globalQueue;
};
#endif // GLOBALQUEUE_H

View File

@@ -0,0 +1,378 @@
#include "readconfig.h"
#include <QXmlStreamReader>
#include <QFile>
#include <QApplication>
#include <QDebug>
ReadConfig *ReadConfig::m_pInstance = NULL;
QMutex ReadConfig::mutex;
//#pragma execution_character_set("utf-8")
ReadConfig::ReadConfig()
{
// readConfigFile();
}
bool ReadConfig::readConfigFile()
{
QString fileName = "./DependFile/ConfigFile/config.xml";
QFile configFile(fileName);
if(!configFile.open(QIODevice::ReadOnly | QIODevice::Text))
{
qDebug()<<"配置文件打开失败";
return false;
}
QXmlStreamReader reader(&configFile);
while(!reader.atEnd())
{
QXmlStreamReader::TokenType nType = reader.readNext();
switch(nType)
{
case QXmlStreamReader::StartDocument: //开始元素
{
QString strVersion = reader.documentVersion().toString();
QString strEncoding = reader.documentEncoding().toString();
bool bAlone = reader.isStandaloneDocument();
break;
}
case QXmlStreamReader::Comment://注释
{
QString strComment = reader.text().toString();
break;
}
case QXmlStreamReader::ProcessingInstruction://处理指令
{
QString strProInstr = reader.processingInstructionData().toString();
break;
}
case QXmlStreamReader::DTD://DTD标识
{
QString strDTD = reader.text().toString();
QXmlStreamNotationDeclarations notations = reader.notationDeclarations();
QXmlStreamEntityDeclarations entity = reader.entityDeclarations();
//DTD声明
QString strDTDName = reader.dtdName().toString();
QString strDTDPublicId = reader.dtdPublicId().toString();//DTD公开标识
QString strDTDSystemId = reader.dtdSystemId().toString();//DTD系统标识
break;
}
case QXmlStreamReader::StartElement://开始元素
{
QString strElementName = reader.name().toString();
if(QString::compare(strElementName,"config") == 0)
{
QXmlStreamAttributes attributes = reader.attributes();
}
else if(QString::compare(strElementName,"tcpAddress") == 0)
{
QXmlStreamAttributes attributes = reader.attributes();
if(attributes.hasAttribute("IP"))
{
st_configData.tcpIP = attributes.value("IP").toString();
}
if(attributes.hasAttribute("port"))
{
st_configData.tcpPort = attributes.value("port").toInt();
}
}
else if(QString::compare(strElementName,"udpServerAddress") == 0)
{
QXmlStreamAttributes attributes = reader.attributes();
if(attributes.hasAttribute("IP"))
{
st_configData.udpServerIP = attributes.value("IP").toString();
}
if(attributes.hasAttribute("port"))
{
st_configData.udpServerPort = attributes.value("port").toInt();
}
}
else if(QString::compare(strElementName,"udpClientAddress") == 0)
{
QXmlStreamAttributes attributes = reader.attributes();
if(attributes.hasAttribute("IP"))
{
st_configData.udpClientIP = attributes.value("IP").toString();
}
if(attributes.hasAttribute("port"))
{
st_configData.udpClientPort = attributes.value("port").toInt();
}
}
//与游戏通信的上位机
else if(QString::compare(strElementName,"udpGameServerAddress") == 0)
{
QXmlStreamAttributes attributes = reader.attributes();
if(attributes.hasAttribute("IP"))
{
st_configData.udpGameServerIP = attributes.value("IP").toString();
}
if(attributes.hasAttribute("port"))
{
st_configData.udpGameServerPort = attributes.value("port").toInt();
}
}
//与上位机通信的游戏
else if(QString::compare(strElementName,"udpGameClientAddress") == 0)
{
QXmlStreamAttributes attributes = reader.attributes();
if(attributes.hasAttribute("IP"))
{
st_configData.udpGameClientIP = attributes.value("IP").toString();
}
if(attributes.hasAttribute("port"))
{
st_configData.udpGameClientPort = attributes.value("port").toInt();
}
}
//与下位机通信的串口
else if(QString::compare(strElementName,"serialPort") == 0)
{
QXmlStreamAttributes attributes = reader.attributes();
if(attributes.hasAttribute("portName"))
{
st_configData.serialConfig.portName = attributes.value("portName").toString();
}
if(attributes.hasAttribute("baud"))
{
st_configData.serialConfig.baud = attributes.value("baud").toInt();
}
if(attributes.hasAttribute("dataBits"))
{
st_configData.serialConfig.dataBits = attributes.value("dataBits").toInt();
}
if(attributes.hasAttribute("parity"))
{
st_configData.serialConfig.parity = attributes.value("parity").toInt();
}
if(attributes.hasAttribute("stopBit"))
{
st_configData.serialConfig.stopBit = attributes.value("stopBit").toInt();
}
if(attributes.hasAttribute("flowControl"))
{
st_configData.serialConfig.flowControl = attributes.value("flowControl").toInt();
}
}
//电刺激A串口
else if(QString::compare(strElementName,"serialPortA") == 0)
{
QXmlStreamAttributes attributes = reader.attributes();
if(attributes.hasAttribute("portName"))
{
st_configData.fesASerialConfig.portName = attributes.value("portName").toString();
}
if(attributes.hasAttribute("baud"))
{
st_configData.fesASerialConfig.baud = attributes.value("baud").toInt();
}
if(attributes.hasAttribute("dataBits"))
{
st_configData.fesASerialConfig.dataBits = attributes.value("dataBits").toInt();
}
if(attributes.hasAttribute("parity"))
{
st_configData.fesASerialConfig.parity = attributes.value("parity").toInt();
}
if(attributes.hasAttribute("stopBit"))
{
st_configData.fesASerialConfig.stopBit = attributes.value("stopBit").toInt();
}
if(attributes.hasAttribute("flowControl"))
{
st_configData.fesASerialConfig.flowControl = attributes.value("flowControl").toInt();
}
}
else if(QString::compare(strElementName,"serialPortB") == 0)
{
QXmlStreamAttributes attributes = reader.attributes();
if(attributes.hasAttribute("portName"))
{
st_configData.fesBSerialConfig.portName = attributes.value("portName").toString();
}
if(attributes.hasAttribute("baud"))
{
st_configData.fesBSerialConfig.baud = attributes.value("baud").toInt();
}
if(attributes.hasAttribute("dataBits"))
{
st_configData.fesBSerialConfig.dataBits = attributes.value("dataBits").toInt();
}
if(attributes.hasAttribute("parity"))
{
st_configData.fesBSerialConfig.parity = attributes.value("parity").toInt();
}
if(attributes.hasAttribute("stopBit"))
{
st_configData.fesBSerialConfig.stopBit = attributes.value("stopBit").toInt();
}
if(attributes.hasAttribute("flowControl"))
{
st_configData.fesBSerialConfig.flowControl = attributes.value("flowControl").toInt();
}
}
else if(QString::compare(strElementName,"dataBase") == 0)
{
QXmlStreamAttributes attributes = reader.attributes();
if(attributes.hasAttribute("IP"))
{
st_configData.dataBaseConfig.IP = attributes.value("IP").toString();
}
if(attributes.hasAttribute("port"))
{
st_configData.dataBaseConfig.port = attributes.value("port").toInt();
}
if(attributes.hasAttribute("userName"))
{
st_configData.dataBaseConfig.userName = attributes.value("userName").toString();
}
if(attributes.hasAttribute("password"))
{
st_configData.dataBaseConfig.password = attributes.value("password").toString();
}
}
else if(QString::compare(strElementName,"communicateType") == 0)
{
QXmlStreamAttributes attributes = reader.attributes();
if(attributes.hasAttribute("type"))
st_configData.communicateType = attributes.value("type").toInt();
}
else if(QString::compare(strElementName,"videoTips") == 0)
{
QXmlStreamAttributes attributes = reader.attributes();
if(attributes.hasAttribute("videoPath"))
{
st_configData.videoPath = attributes.value("videoPath").toString();
}
if(attributes.hasAttribute("videoNum"))
{
}
if(strElementName == "videoContent")
{
qDebug()<<"########";
}
}
break;
}
case QXmlStreamReader::EndDocument://结束文档
{
break;
}
default:
break;
}
}
configFile.close();
if(reader.hasError())
{
qDebug()<<QString::fromLocal8Bit("错误信息:%1 行号:%2 列号:%3 字符移位:%4").arg(reader.errorString())
.arg(reader.lineNumber()).arg(reader.columnNumber()).arg(reader.characterOffset());
return false;
}
return true;
}
bool ReadConfig::getFesASerialPortConfig(ST_SerialPortConfig &serialConfig)
{
serialConfig = st_configData.fesASerialConfig;
if(!serialConfig.portName.isEmpty() && serialConfig.baud != 0)
{
return true;
}
else
return false;
}
//获取实例
ReadConfig* ReadConfig::getInstance()
{
QMutexLocker mutexLocker(&mutex);
if(!m_pInstance)
{
m_pInstance = new ReadConfig();
}
return m_pInstance;
}
//获取通信方式
int ReadConfig::getCommunicateType()
{
return st_configData.communicateType;
}
//获取UDP地址信息
bool ReadConfig::getUdpServerAddress(int16_t &port,QString &IP)
{
port = st_configData.udpServerPort;
IP = st_configData.udpServerIP;
if(port != 0 && !IP.isEmpty())
return true;
else
return false;
}
bool ReadConfig::getUdpClientAddress(int16_t &port,QString &IP)
{
port = st_configData.udpClientPort;
IP = st_configData.udpClientIP;
if(port != 0 && !IP.isEmpty())
return true;
else
return false;
}
//获取TCP地址信息
bool ReadConfig::getTcpAddress(int16_t &port,QString &IP)
{
port = st_configData.tcpPort;
IP = st_configData.tcpIP;
if(port != 0 && !IP.isEmpty())
return true;
else
return false;
}
//获取串口信息
bool ReadConfig::getSerialPortConfig(ST_SerialPortConfig &serialConfig)
{
serialConfig = st_configData.serialConfig;
if(!serialConfig.portName.isEmpty() && serialConfig.baud != 0)
{
return true;
}
else
return false;
}
//获取数据库配置
bool ReadConfig::getDataBaseConfig(ST_DataBaseConfig &databaseConfig)
{
databaseConfig = st_configData.dataBaseConfig;
if(!databaseConfig.IP.isEmpty())
return true;
else
return false;
}
bool ReadConfig::getGameServerAddress(int16_t &port,QString& IP)
{
port = st_configData.udpGameServerPort;
IP = st_configData.udpGameServerIP;
return true;
}
bool ReadConfig::getGameClientAddress(int16_t &port,QString& IP)
{
port = st_configData.udpGameClientPort;
IP = st_configData.udpGameClientIP;
return true;
}

View File

@@ -0,0 +1,76 @@
#ifndef READCONFIG_H
#define READCONFIG_H
#include <QObject>
#include "dataformate.h"
#include <QMutex>
#include <QMap>
//饿汉式单例
class ReadConfig
{
private:
ReadConfig();
static QMutex mutex;
static ReadConfig *m_pInstance;
typedef struct ST_AllConfigData
{
QString udpServerIP;
int16_t udpServerPort;
QString udpClientIP;
int16_t udpClientPort;
QString udpGameClientIP;
int16_t udpGameClientPort;
QString udpGameServerIP;
int16_t udpGameServerPort;
QString tcpIP;
int16_t tcpPort;
ST_SerialPortConfig serialConfig;
ST_SerialPortConfig fesASerialConfig;
ST_SerialPortConfig fesBSerialConfig;
ST_DataBaseConfig dataBaseConfig;
int communicateType = -1;
QString videoPath; //视频路径
QMap<int,QString> videoMap; //视频提示管理QMap<视频序号,视频名称>
ST_AllConfigData()
{
udpServerIP.clear();
udpServerPort = 0;
tcpIP.clear();
tcpPort = 0;
}
}ST_AllConfigData;
ST_AllConfigData st_configData;
public:
//获取实例
static ReadConfig* getInstance();
//上下位机通信地址
bool getUdpServerAddress(int16_t &port,QString &IP);
bool getUdpClientAddress(int16_t &port,QString &IP);
//获取TCP地址信息
bool getTcpAddress(int16_t &port,QString &IP);
//获取串口信息
bool getSerialPortConfig(ST_SerialPortConfig &serialConfig);
//获取数据库配置
bool getDataBaseConfig(ST_DataBaseConfig &databaseConfig);
//获取通信方式
int getCommunicateType();
bool readConfigFile();
//获取电刺激设备信息
bool getFesASerialPortConfig(ST_SerialPortConfig &serialConfig);
//与游戏通信地址
bool getGameServerAddress(int16_t &port,QString& IP);
//游戏地址
bool getGameClientAddress(int16_t &port,QString& IP);
};
#endif // READCONFIG_H

View File

@@ -0,0 +1,86 @@
#include "bleitem.h"
#include "ui_bleitem.h"
#include <QPixmap>
#include <QDebug>
#include <QSettings>
BLEItem::BLEItem(QWidget *parent) :
QWidget(parent),
ui(new Ui::BLEItem)
{
ui->setupUi(this);
}
BLEItem::BLEItem(uint8_t device):ui(new Ui::BLEItem)
{
ui->setupUi(this);
deviceNum = device;
}
BLEItem::~BLEItem()
{
delete ui;
}
void BLEItem::setBLEName(uint8_t name)
{
deviceNum = name;
QString nameStr;
switch(name)
{
case 1:
nameStr = "A";
break;
case 2:
nameStr = "B";
break;
case 3:
nameStr = "C";
break;
case 4:
nameStr = "D";
break;
}
ui->BLEName_Label->setText(tr("电刺激盒%1").arg(nameStr));
}
uint8_t BLEItem::getBLEName()
{
return deviceNum;
}
void BLEItem::setBLEBattery(uint8_t battery)
{
QString batteryImg = QString("qrc:/DependFile/Source/Fes/battery_%1.png").arg(battery);
ui->BLEBattery_Label->setPixmap(QPixmap(batteryImg));
}
void BLEItem::setDeviceState(bool state)
{
if(state)
{
ui->connectBLE_Btn->setText(tr("断开"));
}
else
ui->connectBLE_Btn->setText(tr("连接"));
emit signalBtnStateChanged(deviceNum,state);
qDebug() <<"数量和状态:"<< deviceNum << state ;
}
void BLEItem::on_connectBLE_Btn_clicked()
{
if(ui->connectBLE_Btn->text() == tr("连接"))
{
qDebug()<<"点击连接";
emit signalConnectDevice(true,deviceNum);
// ui->connectBLE_Btn->setText(tr("断开"));
}
else if(ui->connectBLE_Btn->text() == tr("断开"))
{
emit signalConnectDevice(false,deviceNum);
// ui->connectBLE_Btn->setText(tr("连接"));
}
}

View File

@@ -0,0 +1,36 @@
#ifndef BLEITEM_H
#define BLEITEM_H
#include <QWidget>
namespace Ui {
class BLEItem;
}
class BLEItem : public QWidget
{
Q_OBJECT
public:
explicit BLEItem(QWidget *parent = nullptr);
BLEItem(uint8_t device);
~BLEItem();
//设置蓝牙名称
void setBLEName(uint8_t name);
uint8_t getBLEName();
//设置电量
void setBLEBattery(uint8_t battery);
//设置设备状态
void setDeviceState(bool);
private slots:
void on_connectBLE_Btn_clicked();
signals:
void signalConnectDevice(bool connect,uint8_t device);
void signalBtnStateChanged(uint8_t deviceNo,bool state);
private:
Ui::BLEItem *ui;
uint8_t deviceNum;
};
#endif // BLEITEM_H

View File

@@ -0,0 +1,201 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>BLEItem</class>
<widget class="QWidget" name="BLEItem">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>659</width>
<height>78</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox">
<property name="styleSheet">
<string notr="true">#groupBox{background: #E4F4FC;border:none;}</string>
</property>
<property name="title">
<string/>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>10</number>
</property>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label">
<property name="minimumSize">
<size>
<width>40</width>
<height>40</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>40</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">border-image: url(:/DependFile/Source/Fes/box.png);</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="BLEName_Label">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="sizeIncrement">
<size>
<width>130</width>
<height>0</height>
</size>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="connectState_Label">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>70</width>
<height>30</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="BLEBattery_Label">
<property name="minimumSize">
<size>
<width>22</width>
<height>22</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>22</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>157</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="connectBLE_Btn">
<property name="minimumSize">
<size>
<width>80</width>
<height>40</height>
</size>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">QPushButton{background: #FFFFFF;border-radius: 4px;border: 1px solid #0D9DDB;}
QPushButton:pressed{background: #05A6EC;border-radius: 4px;border: 1px solid #0D9DDB;color:#FFFFFF;}</string>
</property>
<property name="text">
<string>连接</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>19</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -0,0 +1,57 @@
#include "fesparambtn.h"
#include "ui_fesparambtn.h"
#include <QMouseEvent>
#include <QDebug>
FesParamBtn::FesParamBtn(QWidget *parent) :
QWidget(parent),
ui(new Ui::FesParamBtn)
{
ui->setupUi(this);
}
FesParamBtn::~FesParamBtn()
{
delete ui;
}
void FesParamBtn::initButton(QString title,QString unit)
{
ui->title_Label->setText(title);
ui->unit_Label->setText(unit);
// qDebug()<<"初始化按钮:"<<title <<unit;
}
void FesParamBtn::setTitle(QString title)
{
ui->title_Label->setText(title);
}
void FesParamBtn::setData(int data)
{
ui->data_Label->setText(QString::number(data));
}
void FesParamBtn::mousePressEvent(QMouseEvent *event)
{
Q_UNUSED(event)
emit fesButtonClicked();
}
int FesParamBtn::getValue()
{
m_value = ui->data_Label->text().toInt();
return m_value;
}
void FesParamBtn::changeEvent(QEvent* event)
{
switch (event->type())
{
case QEvent::LanguageChange:
;//ui->retranslateUi(this);
break;
default:
QWidget::changeEvent(event);
break;
}
}

View File

@@ -0,0 +1,38 @@
#ifndef FESPARAMBTN_H
#define FESPARAMBTN_H
#include <QWidget>
namespace Ui {
class FesParamBtn;
}
class FesParamBtn : public QWidget
{
Q_OBJECT
public:
explicit FesParamBtn(QWidget *parent = nullptr);
~FesParamBtn();
void initButton(QString title,QString unit);
void setTitle(QString title);
void setData(int data);
int getValue();
signals:
void fesButtonClicked();
protected:
virtual void mousePressEvent(QMouseEvent *event);
virtual void changeEvent(QEvent* event);
private:
Ui::FesParamBtn *ui;
int m_value;
};
#endif // FESPARAMBTN_H

View File

@@ -0,0 +1,107 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>FesParamBtn</class>
<widget class="QWidget" name="FesParamBtn">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>250</width>
<height>170</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<widget class="QLabel" name="title_Label">
<property name="geometry">
<rect>
<x>30</x>
<y>23</y>
<width>181</width>
<height>61</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>18</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
<widget class="QLabel" name="data_Label">
<property name="geometry">
<rect>
<x>80</x>
<y>90</y>
<width>81</width>
<height>70</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>30</pointsize>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>5</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="unit_Label">
<property name="geometry">
<rect>
<x>160</x>
<y>120</y>
<width>91</width>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
<bold>true</bold>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QGroupBox" name="groupBox">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>250</width>
<height>170</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">#groupBox{background: #E4F4FC;
border-radius: 6px;}</string>
</property>
<property name="title">
<string/>
</property>
</widget>
<zorder>groupBox</zorder>
<zorder>title_Label</zorder>
<zorder>data_Label</zorder>
<zorder>unit_Label</zorder>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -0,0 +1,155 @@
#include "musclebutton.h"
#include "ui_musclebutton.h"
#include <QDebug>
#include <QMouseEvent>
#include <QPaintEvent>
#include <QGraphicsDropShadowEffect>
#include <QPixmap>
MuscleButton::MuscleButton(QWidget *parent) :
QWidget(parent),
ui(new Ui::MuscleButton),
isConnected(false)
{
ui->setupUi(this);
// QGraphicsDropShadowEffect * shadowEffect = new QGraphicsDropShadowEffect();
// shadowEffect->setYOffset(2);
// shadowEffect->setBlurRadius(12);
// shadowEffect->setColor(QColor(0,0,0,51));
// this->setGraphicsEffect(shadowEffect);
st_muscleParam.muscleId = 0;
}
MuscleButton::~MuscleButton()
{
delete ui;
}
void MuscleButton::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event)
}
void MuscleButton::mousePressEvent(QMouseEvent *event)
{
Q_UNUSED(event)
emit muscleButtonClicked(m_id);
}
void MuscleButton::setMuscleParamButton(const ST_MuscleParam& param)
{
//左右肌肉图标
QString limpFlag;
if(param.muscleId > 30)
{
limpFlag= "";
}
else if(param.muscleId <= 15)
limpFlag = ":/DependFile/Source/channel/left.png";
else
limpFlag = ":/DependFile/Source/channel/right.png";
QPixmap pixmap;
pixmap.load(limpFlag);
ui->Image_Label->setPixmap(pixmap);
ui->muscle_Label->setText(param.muscleName );
ui->current_Label->setText(QString::number(param.minCurrent)+"~"+QString::number(param.maxCurrent) + "mA");
ui->plus_Label->setText(QString::number(param.plus) + "us");
ui->frequency_Label->setText(QString::number(param.frequency) + "Hz");
st_muscleParam = param;
}
void MuscleButton::setBLEBattery(uint8_t battery)
{
QPixmap pixmap;
QString img;
//qDebug() <<"电量:"<<battery;
//battery = 50;
if(battery <= 0)
img = ":/DependFile/Source/Fes/battery_0.png";
else if(0 < battery && battery < 25)
img = ":/DependFile/Source/Fes/battery_25.png";
else if(25 <= battery && battery < 50)
img = ":/DependFile/Source/Fes/battery_50.png";
else if(50 <= battery && battery < 75)
img = ":/DependFile/Source/Fes/battery_75.png";
else if(75<= battery && battery <= 100)
img = ":/DependFile/Source/Fes/battery_100.png";
pixmap.load(img);
ui->BLEBattery_Label->setPixmap(pixmap);
}
void MuscleButton::initWidget(QString title,int id)
{
ui->channel_Label->setText(title);
m_id = id;
}
void MuscleButton::setMuscleEnabled(bool enabled)
{
isConnected = enabled;
QString enabledStyle = "#groupBox{background: #E4F4FC;"
"border-radius: 6px;}";
QString disenabledStyle = "#groupBox{background: #EFEFEF;border-radius: 6px;}";
if(enabled)
ui->groupBox->setStyleSheet(enabledStyle);
else
ui->groupBox->setStyleSheet(disenabledStyle);
}
ST_MuscleParam MuscleButton::getMuscleParam()
{
ST_MuscleParam st_tmpMuscleParam;
st_tmpMuscleParam.frequency = ui->frequency_Label->text().remove("Hz").toInt();
st_tmpMuscleParam.plus = ui->plus_Label->text().remove("us").toInt();
QStringList currentList= ui->current_Label->text().remove("mA").split("~");
st_tmpMuscleParam.connectState = isConnected;
if(currentList.count() >1)
{
st_tmpMuscleParam.minCurrent = currentList.first().toInt();
st_tmpMuscleParam.maxCurrent = currentList.last().toInt();
}
st_tmpMuscleParam.muscleName = ui->muscle_Label->text();
st_tmpMuscleParam.muscleId = st_muscleParam.muscleId;
return st_tmpMuscleParam;
}
void MuscleButton::setConnectState(bool state)
{
QPixmap pixmap;
QString img;
if(state)
img = ":/DependFile/Source/channel/connected.png";
else
img = ":/DependFile/Source/channel/disconnected.png";
pixmap.load(img);
ui->connectState_Label->setPixmap(pixmap);
}
void MuscleButton::setCheckedFesType(E_FES_PAGE E_fesType)
{
if(E_fesType == ONLY_FES_E)
{
ui->muscle_Label->setVisible(false);
ui->Image_Label->setVisible(false);
}
else if(E_fesType == BICYCLE_FES_E)
{
ui->muscle_Label->setVisible(true);
ui->Image_Label->setVisible(true);
}
}
void MuscleButton::changeEvent(QEvent* event)
{
switch (event->type())
{
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
QWidget::changeEvent(event);
break;
}
}

View File

@@ -0,0 +1,47 @@
#ifndef MUSCLEBUTTON_H
#define MUSCLEBUTTON_H
#include <QWidget>
#include "dataformate.h"
namespace Ui {
class MuscleButton;
}
class MuscleButton : public QWidget
{
Q_OBJECT
public:
explicit MuscleButton(QWidget *parent = nullptr);
~MuscleButton();
void setMuscleParamButton(const ST_MuscleParam&);
void setBLEBattery(uint8_t battery); //设置电池
void initWidget(QString title,int id);
void setMuscleEnabled(bool);
ST_MuscleParam getMuscleParam();
void setConnectState(bool);
void setCheckedFesType(E_FES_PAGE E_fesType); //根据Fes类型是否显示肌肉、部位
signals:
void muscleButtonClicked(int id);
protected:
virtual void paintEvent(QPaintEvent *event);
virtual void mousePressEvent(QMouseEvent *event);
virtual void changeEvent(QEvent* event);
private:
Ui::MuscleButton *ui;
int m_id;
ST_MuscleParam st_muscleParam;
bool isConnected;
};
#endif // MUSCLEBUTTON_H

View File

@@ -0,0 +1,314 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MuscleButton</class>
<widget class="QWidget" name="MuscleButton">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>425</width>
<height>225</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<widget class="Line" name="line">
<property name="geometry">
<rect>
<x>130</x>
<y>170</y>
<width>2</width>
<height>30</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">background: #0D9DDB;</string>
</property>
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
</property>
</widget>
<widget class="Line" name="line_2">
<property name="geometry">
<rect>
<x>250</x>
<y>170</y>
<width>2</width>
<height>30</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">background: #0D9DDB;</string>
</property>
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
</property>
</widget>
<widget class="QGroupBox" name="groupBox">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>425</width>
<height>225</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">#groupBox{background: #E4F4FC;
border-radius: 6px;}</string>
</property>
<property name="title">
<string/>
</property>
<widget class="QLabel" name="current_Label">
<property name="geometry">
<rect>
<x>254</x>
<y>130</y>
<width>161</width>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>0~0mA</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>8</x>
<y>160</y>
<width>121</width>
<height>51</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>频率</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
<widget class="QLabel" name="frequency_Label">
<property name="geometry">
<rect>
<x>20</x>
<y>130</y>
<width>91</width>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>10Hz</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="muscle_Label">
<property name="geometry">
<rect>
<x>221</x>
<y>26</y>
<width>131</width>
<height>81</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>15</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
<widget class="QLabel" name="label_4">
<property name="geometry">
<rect>
<x>140</x>
<y>160</y>
<width>101</width>
<height>51</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>脉宽</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
<widget class="QLabel" name="channel_Label">
<property name="geometry">
<rect>
<x>42</x>
<y>29</y>
<width>71</width>
<height>60</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>23</pointsize>
<bold>true</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="label_6">
<property name="geometry">
<rect>
<x>280</x>
<y>160</y>
<width>111</width>
<height>51</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>电流</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
<widget class="QLabel" name="plus_Label">
<property name="geometry">
<rect>
<x>138</x>
<y>130</y>
<width>111</width>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>200us</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="Image_Label">
<property name="geometry">
<rect>
<x>360</x>
<y>50</y>
<width>32</width>
<height>32</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="connectState_Label">
<property name="geometry">
<rect>
<x>122</x>
<y>47</y>
<width>28</width>
<height>25</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="BLEBattery_Label">
<property name="geometry">
<rect>
<x>189</x>
<y>45</y>
<width>16</width>
<height>28</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string/>
</property>
</widget>
</widget>
<zorder>groupBox</zorder>
<zorder>line</zorder>
<zorder>line_2</zorder>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -0,0 +1,146 @@
#include "cdatabaseinterface.h"
#include "mysqldatabase.h"
#include <QMap>
#include <QDebug>
#pragma execution_character_set("utf-8")
CDatabaseInterface* CDatabaseInterface::m_DatabaseInterface = NULL;
CDatabaseInterface::CDatabaseInterface(QObject *parent) : QObject(parent)
{
m_sqlDataBase = new MySqlDataBase();
}
bool CDatabaseInterface::openDB(QString name,const QString &type )
{
if(m_sqlDataBase)
{
return m_sqlDataBase->openDB(name,type);
}
return false;
}
void CDatabaseInterface::closeDB()
{
if(m_sqlDataBase)
{
m_sqlDataBase->closeDB();
}
}
CDatabaseInterface* CDatabaseInterface::getInstance()
{
if(!m_DatabaseInterface)
m_DatabaseInterface = new CDatabaseInterface();
return m_DatabaseInterface;
}
bool CDatabaseInterface::createTable(QString table,QMap<QString,QString> map)
{
if(m_sqlDataBase)
{
return m_sqlDataBase->createTable(table,map);
}
return false;
}
bool CDatabaseInterface::insertRowTable(QString table,QVariantMap map)
{
if(m_sqlDataBase)
{
return m_sqlDataBase->insertRowTable(table,map);
}
return false;
}
bool CDatabaseInterface::deleteRowTable(QString table,QString columName,QString value)
{
if(m_sqlDataBase)
{
return m_sqlDataBase->deleteRowTable(table,columName,value);
}
return false;
}
bool CDatabaseInterface::updateRowTable(QString table,QString name,QVariantMap map)
{
if(m_sqlDataBase)
{
return m_sqlDataBase->updateRowTable(table,name,map);
}
return false;
}
bool CDatabaseInterface::updateRowTable(QString table,QString targetkey,QString targetValue,QString name,QVariantMap map)
{
if(m_sqlDataBase)
{
return m_sqlDataBase->updateRowTable(table,targetkey,targetValue,name,map);
}
return false;
}
bool CDatabaseInterface::sortTable(QString table,QString target)
{
if(m_sqlDataBase)
{
return m_sqlDataBase->sortTable(table,target);
}
return false;
}
QList<QVariantMap> CDatabaseInterface::getValues(int page,int pageNum)
{
QList<QVariantMap> List;
List.clear();
if(m_sqlDataBase)
{
return m_sqlDataBase->getValues(page,pageNum);
}
return List;
}
bool CDatabaseInterface::prepare(const QString& query)
{
if(m_sqlDataBase)
{
return m_sqlDataBase->prepare(query);
}
return false;
}
bool CDatabaseInterface::exec(const QString &query)
{
if(m_sqlDataBase)
{
return m_sqlDataBase->exec(query);
}
return false;
}
bool CDatabaseInterface::exec()
{
if(m_sqlDataBase)
{
return m_sqlDataBase->exec();
}
return false;
}
QString CDatabaseInterface::getLastError()
{
if(m_sqlDataBase)
{
return m_sqlDataBase->lastError();
}
else
return QString("数据库未初始化");
}
int CDatabaseInterface::getValuesSize()
{
if(m_sqlDataBase)
{
return m_sqlDataBase->size();
}
return 0;
}

View File

@@ -0,0 +1,80 @@
#ifndef CDATABASEINTERFACE_H
#define CDATABASEINTERFACE_H
#include <QObject>
#include <QVariant>
#include <QString>
class MySqlDataBase;
class CDatabaseInterface : public QObject
{
Q_OBJECT
public:
static CDatabaseInterface* getInstance();
bool openDB(QString name,const QString &type = "QMYSQL");
//关闭数据库
void closeDB();
/*********创建数据表*****
* 参数 QString table-表名 QMap<QString,QString>-(arg1字段名)(arg2数据类型)
* 返回值 true-插入成功 false-插入失败
* 备注:最好不要使用该函数建表,因为涉及到的语句比较特殊,容易出错
* *********/
bool createTable(QString table,QMap<QString,QString>);
/*********数据库插入操作*****
* 参数 QString table-表名 QVariantMap map-实际带插入数据
* 返回值 true-插入成功 false-插入失败
* *********/
bool insertRowTable(QString table,QVariantMap map);
/*********删除数据库中的某一行*****
* 参数 QString table-表名 QString columName-列字段 QString value-需要删除的具体数据
* 返回值 true-插入成功 false-插入失败
* *********/
bool deleteRowTable(QString table,QString columName,QString value);
/*********更新数据库中的某一行*****
* 参数 QString table-表名 QString name-字段名 QVariantMap map-具体数据
* 返回值 true-插入成功 false-插入失败
* *********/
bool updateRowTable(QString table,QString name,QVariantMap map);
/*********更新数据库中的某一行*****
* 参数 QString table-表名 QString targetkey-字段名 QString targetValue-具体值 QVariantMap map-具体数据
* targetkey,targetValue为查询条件
* name查询条件二
* 返回值 true-插入成功 false-插入失败
* *********/
bool updateRowTable(QString table,QString targetkey,QString targetValue,QString name,QVariantMap map);
/*********升序排列*****
* 参数 QString table-表名 QString target-字段名
* 返回值 true-插入成功 false-插入失败
* *********/
bool sortTable(QString table,QString target);
/********获取数据库的查询结果*****
* 说明:在使用该函数之前需要先执行查询语句,具体为
* 参数 int page-从哪一页获取 int pageNum-一页获取多少数据
* 返回值 QList<QVariantMap>-查询得到的结果
* *********/
QList<QVariantMap>getValues(int page,int pageNum);
bool prepare(const QString& query);
bool exec(const QString &query);
bool exec();
//获取数据库操作最后出现的错误
QString getLastError();
int getValuesSize();
private:
explicit CDatabaseInterface(QObject *parent = nullptr);
static CDatabaseInterface* m_DatabaseInterface;
MySqlDataBase *m_sqlDataBase;
};
#endif // CDATABASEINTERFACE_H

View File

@@ -0,0 +1,332 @@
#include "mysqldatabase.h"
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QDebug>
#include <QSqlError>
#include <QSqlDriver>
#include <QSqlRecord>
#include <QSqlField>
MySqlDataBase::MySqlDataBase(QWidget *parent)
: QWidget(parent)
{
}
MySqlDataBase::~MySqlDataBase()
{
}
/*********打开数据库***************/
bool MySqlDataBase::openDB(QString name,const QString &type)
{
//首先判断是否该数据库
if(QSqlDatabase::contains(name))
{
m_database = QSqlDatabase::database(name);
}
else
{
/***根据type类型添加数据库驱动****/
m_database = QSqlDatabase::addDatabase(type,name);
/****设置数据库连接名****/
m_database.setDatabaseName(name);
}
m_database.setUserName("root");
m_database.setPassword("root");
if(!m_database.open())
{
setLastError(m_database.lastError().text());
return false;
}
m_sqlQuery = QSqlQuery(m_database);
qDebug()<<QSqlDatabase::connectionNames();
return true;
}
void MySqlDataBase::closeDB()
{
if(m_database.isOpen())
m_database.close();
}
/*********创建数据库表格**************/
bool MySqlDataBase::createTable(QString table,QMap<QString,QString> map)
{
if(!isTableExist(table))
{
QString tableList = QString("create table if not exists %1 (").arg(table);
QMapIterator<QString,QString> iter(map);
while(iter.hasNext())
{
iter.next();
tableList.append(QString("%1 %2").arg(iter.key()).arg(iter.value()));
if(iter.hasNext())
tableList.append(",");
}
tableList.append(")");
//执行sql语句
return this->exec(tableList);
}
else
{
setLastError(QString("Exist table<%1>").arg(table));
return false;
}
}
/*********数据库插入操作**************/
bool MySqlDataBase::insertRowTable(QString table,QVariantMap map)
{
QMap<QString,QString> tableContentMap;
if(!isTableExist(table))
{
setLastError(QString("Not find %1 table").arg(table));
return false;
}
else
{
tableContentMap = getTableInfo(table);
if(tableContentMap.isEmpty())
return false;
}
QString insertTableContent = QString("insert into %1(").arg(table);
QString values = QString(" values(");
QMapIterator<QString,QString> iter(tableContentMap);
while(iter.hasNext())
{
iter.next();
insertTableContent.append(QString("%1").arg(iter.key()));
values.append("?");
if(iter.hasNext())
{
insertTableContent.append(", ");
values.append(",");
}
}
insertTableContent.append(")");
values.append(")");
insertTableContent.append(values);
// qDebug()<<insertTableContent;
if(!this->prepare(insertTableContent))
return false;
QMapIterator<QString,QString> iter_(tableContentMap);
while(iter_.hasNext())
{
iter_.next();
m_sqlQuery.addBindValue(map[iter_.key()]);
}
return this->exec();
}
/*********删除数据库中的某一行*********/
bool MySqlDataBase::deleteRowTable(QString table,QString columName,QString value)
{
QString delereContent = QString("delete from %1 where %2 = '%3'").arg(table).arg(columName).arg(value);
return this->exec(delereContent);
}
/*********更新/更改某一个字段的n行数据*********/
bool MySqlDataBase::updateRowTable(QString table,QString name,QVariantMap map)
{
QString content = QString("update %1 set ").arg(table);
QMapIterator<QString,QVariant> iter(map);
while(iter.hasNext())
{
iter.next();
if(iter.hasNext())
content += QString("%1 = '%2',").arg(iter.key()).arg(iter.value().toString());
else
content += QString("%1 = '%2' ").arg(iter.key()).arg(iter.value().toString());
}
content += QString("where %1 = '%2'").arg(name).arg(map[name].toString());
return this->exec(content);
}
/*********更新某个字段为特定值的其他字段的值********/
bool MySqlDataBase::updateRowTable(QString table,QString targetkey,QString targetValue,QString name,QVariantMap map)
{
QString content = QString("update %1 set ").arg(table);
QMapIterator<QString,QVariant> iter(map);
while(iter.hasNext())
{
iter.next();
if(iter.key() == "UUID")
continue;
if(iter.hasNext())
content += QString("%1 = '%2',").arg(iter.key()).arg(iter.value().toString());
else
content += QString("%1 = '%2' ").arg(iter.key()).arg(iter.value().toString());
}
content += QString("where %1 = '%2' and %3 = '%4'").arg(targetkey).arg(targetValue).arg(name).arg(map[name].toString());
return this->exec(content);
}
/*********升序排列*************/
bool MySqlDataBase::sortTable(QString table,QString target)
{
/***select * from table by target*/
QString sortContent = QString("select * from %1 order by '%2'").arg(table).arg(target);
return this->exec(sortContent);
}
/********获取数据库的查询结果*******/
QList<QVariantMap> MySqlDataBase::getValues(int page,int pageNum)
{
QList<QVariantMap>list;
bool ok = m_sqlQuery.isSelect();
if(!ok)
return QList<QVariantMap>();
if( (!m_sqlQuery.seek(page)))
{
setLastError("gevalues error![The number of pages is out of the limit]");
}
do
{
QVariantMap map;
for(int i = 0;i < m_sqlQuery.record().count();i++)
{
map.insert(m_sqlQuery.record().field(i).name(),
m_sqlQuery.record().field(i).value());
}
list.append(map);
}while(m_sqlQuery.next() && --pageNum);
return list;
}
/****获取个数*****/
int MySqlDataBase::size()
{
int size = -1;
while(m_sqlQuery.isSelect() && m_sqlQuery.next())
{
/***驱动支持返回记录***/
if(m_sqlQuery.driver()->hasFeature(QSqlDriver::QuerySize))
{
size = m_sqlQuery.size();
break;
}
else
{
m_sqlQuery.last();
size = m_sqlQuery.at() + 1 ;
}
}
//返回第一个结果
m_sqlQuery.first();
return size;
}
QString MySqlDataBase::lastError()
{
return m_lastError;
}
void MySqlDataBase::setLastError(const QString& error)
{
m_lastError = error;
}
QSqlQuery& MySqlDataBase::getSqlQUery()
{
return m_sqlQuery;
}
bool MySqlDataBase::isTableExist(QString table)
{
QStringList tables = m_database.tables();
if(tables.contains(table))
return true;
else
return false;
}
bool MySqlDataBase::prepare(const QString& query)
{
if(!m_sqlQuery.prepare(QString(query)))
{
setLastError(m_sqlQuery.lastError().text());
return false;
}
return true;
}
bool MySqlDataBase::exec(const QString &query)
{
if(!m_sqlQuery.exec(QString(query)))
{
setLastError(m_sqlQuery.lastError().text());
return false;
}
return true;
}
bool MySqlDataBase::exec()
{
if(!m_sqlQuery.exec())
{
setLastError(m_sqlQuery.lastError().text());
return false;
}
return true;
}
QMap<QString,QString> MySqlDataBase::getTableInfo(QString table)
{
QMap<QString,QString>tableMap;
QString str = QString("PRAGMA table_info(%1)").arg(table);
m_sqlQuery.prepare(str);
if(m_sqlQuery.exec())
{
while(m_sqlQuery.next())
{
tableMap[m_sqlQuery.value(1).toString()] = m_sqlQuery.value(2).toString();
}
return tableMap;
}
else
{
setLastError(m_sqlQuery.lastError().text());
return tableMap;
}
}
#if 0
bool MySqlDataBase::initDataBase()
{
db = QSqlDatabase::addDatabase("QMYSQL");//设置数据库类型
db.setHostName("localhost");//设置数据库主机名
db.setDatabaseName("mysql");//设置数据库的名字
db.setUserName("root");//设置数据库登录用户
db.setPassword("root");//设置数据库登录密码
if(!db.open())
{
qDebug()<<"database open failed";
QSqlError error = db.lastError();
qDebug()<<error.text();
return false;
}
qDebug()<<"database open success";
return true;
}
#endif

View File

@@ -0,0 +1,96 @@
#ifndef MYSQLDATABASE_H
#define MYSQLDATABASE_H
#include <QWidget>
#include <QSqlDatabase>
#include <QSqlQuery>
class MySqlDataBase : public QWidget
{
Q_OBJECT
public:
MySqlDataBase(QWidget *parent = nullptr);
~MySqlDataBase();
//QVariantMap -- QMap<QString,QVariant> --QMap<字段名,值>
//一下所有用到的位置都是该数据内容
/*********打开数据库*****
* 参数 QString name-连接名 const QString &type-数据库类型
* 返回值 true-插入成功 false-插入失败
* *********/
bool openDB(QString name,const QString &type = "QMYSQL");
//关闭数据库
void closeDB();
/*********创建数据表*****
* 参数 QString table-表名 QMap<QString,QString>-(arg1字段名)(arg2数据类型)
* 返回值 true-插入成功 false-插入失败
* 备注:最好不要使用该函数建表,因为涉及到的语句比较特殊,容易出错
* *********/
bool createTable(QString table,QMap<QString,QString>);
/*********数据库插入操作*****
* 参数 QString table-表名 QVariantMap map-实际带插入数据
* 返回值 true-插入成功 false-插入失败
* *********/
bool insertRowTable(QString table,QVariantMap map);
/*********删除数据库中的某一行*****
* 参数 QString table-表名 QString columName-列字段 QString value-需要删除的具体数据
* 返回值 true-插入成功 false-插入失败
* *********/
bool deleteRowTable(QString table,QString columName,QString value);
/*********更新数据库中的某一行*****
* 参数 QString table-表名 QString name-字段名 QVariantMap map-具体数据
* 返回值 true-插入成功 false-插入失败
* *********/
bool updateRowTable(QString table,QString name,QVariantMap map);
/*********更新数据库中的某一行*****
* 参数 QString table-表名 QString targetkey-字段名 QString targetValue-具体值 QVariantMap map-具体数据
* key,value是针对全部要修改的
* 返回值 true-插入成功 false-插入失败
* *********/
bool updateRowTable(QString table,QString targetkey,QString targetValue,QString name,QVariantMap map);
/*********升序排列*****
* 参数 QString table-表名 QString target-字段名
* key,value是针对全部要修改的
* 返回值 true-插入成功 false-插入失败
* *********/
bool sortTable(QString table,QString target);
/********获取数据库的查询结果*****
* 说明:在使用该函数之前需要先执行查询语句,具体为
* 参数 int page-从哪一页获取 int pageNum-一页获取多少数据
* 返回值 QList<QVariantMap>-查询得到的结果
* *********/
QList<QVariantMap>getValues(int page,int pageNum);
/****返回数据库的搜索结果个数*****/
//在使用这个函数之前需要调用查询语句。
int size();
void setLastError(const QString& error);
QString lastError();
//获取当前数据表信息
QMap<QString,QString> getTableInfo(QString table);
QSqlQuery& getSqlQUery();
bool isTableExist(QString table);
bool prepare(const QString& query);
bool exec(const QString &query);
bool exec();
private:
QSqlDatabase m_database;
QSqlQuery m_sqlQuery;
QString m_lastError;
};
#endif // MYSQLDATABASE_H

View File

@@ -0,0 +1,29 @@
#include "dataformate.h"
#include <QTime>
#include <QCoreApplication>
void Pressure_CheckCRC(uint8_t*buf,int len,uint8_t* CRC_H,uint8_t* CRC_L)
{
uint16_t i,j,tmp,CRC16;
CRC16=0xffff;
for (i=0;i<len;i++)
{
CRC16=*buf^CRC16;
for (j=0;j< 8;j++)
{
tmp=CRC16 & 0x0001;
CRC16 =CRC16 >>1;
if (tmp)
CRC16=CRC16 ^ 0xA001;
}
*buf++;
}
CRC_H[0]=CRC16>>8;
CRC_L[0]=CRC16&0xff;
}
void Sleep(int msec)
{
QTime dieTime = QTime::currentTime().addMSecs(msec);
while( QTime::currentTime() < dieTime )
QCoreApplication::processEvents(QEventLoop::AllEvents, 100);
}

View File

@@ -0,0 +1,386 @@
#ifndef DATAFORMATE_H
#define DATAFORMATE_H
#include <QWidget>
#define PAGENUM 8 //每页显示数量
#define MAXSHOWNUM 1000 //最大显示数量
#define PERCOUNT 8 //用户每页显示数量
//上位机发送使用
#define PACKHEAD 0xAB //帧头
#define PACKTAIL 0xCD //帧尾
//下位机发送使用
#define SLAVEPACKHEAD 0xBA
#define SLAVEPACKTAIL 0xDC
#define FRAME_HEAD 0xAA
#define FRAME_END 0x55
typedef enum
{
E_NEW_USER = 0,
E_EDIT_USER
}USER_ENUM;
typedef enum
{
ONLY_FES_E = 0,
BICYCLE_FES_E
}E_FES_PAGE;
typedef enum
{
Chinese_E,
English_E
}E_LANGUAGE;
//通信状态
typedef enum
{
UnconnectedState_E = 0,
HostLookupState_E,
ConnectingState_E,
ConnectedState_E,
BoundState_E,
ClosingState_E,
ListeningState_E
}E_DeviceState;
//页面切换
typedef enum
{
MainPage_E = 0, //主界面
TrainingPage_E, //训练界面
UserPage_E, //用户界面
SettingPage_E, //设置界面
BicycleParamSet_E, //踏车参数设置界面
FesParamSet_E, //fes设置界面
FesBicycleParamSet_E, //FesT踏车设置界面
BicycleToFes_E, //从踏车界面到FES界面
TrainingParamSetting_E, //从肢体训练界面,进入参数设置
BrainTraining, //脑电训练
visionTrain //视觉训练
//LoginPage_E //切换到登录页面
}E_PAGENAME;
//上位机发送指令
typedef enum
{
BICYCLE_PARAM_CMD = 0x01, //启动前参数
REALTIME_PARAM_CMD = 0x02, //实时调节参数
SEND_HEARTBEAT_CMD = 0X05, //发送心跳(启用)
GET_VERSION_CMD = 0X08 //获取版本号
}E_SENDCMDID;
//游戏训练状态
typedef enum
{
START = 0x01, //运行
PAUSE = 0x02, //暂停
STOP = 0x03 //停止
}E_TRAINSTATE;
//接收下位机指令
typedef enum
{
BRFORE_START_CMD = 0x00, //启动前
AFTER_START_CMD = 0x01, //启动后
RECE_HEARTBEAT_CMD = 0x02 //接收心跳(启用)
}E_RECECMDID;
//实时调节参数子指令
typedef enum
{
RESISTANCE_CMD = 0x01, //阻力
PASSIVE_SPEED = 0x02, //被动转速
SPASM_LEVEL = 0x03, //痉挛等级
SWITCH_DIRECTION = 0x04,//手动换向
EQUAL_SPEED = 0x08, //等速转速
SYNERGY_SPEED = 0x09, //协同限速
SPASM_CONFIRM = 0x10, //确认痉挛
TUIGAN_UPDOWN = 0x11, //推杆响应 1-up 2-down
YIJIAN_SHANGJI = 0x12 //一键上机
}E_REALTIMECMD;
typedef enum
{
CMD_PARAM_SET_E = 0x71, //单独电刺激参数设置
CMD_CHANNEL_CONTROL =0x72, //电刺激控制0-关闭 1-开启 2-暂停 3-继续
PreCurrentSet_E = 0x73, //预设电流设置
PreCurrentSwitch = 0x76, //预设电流控制开关
CMD_QUERY_STATE_E = 0x78, //查询各个电刺激模块状态
CMD_TURNOFF_E = 0x7A, //关机(断开)
CMD_SEARCH_DEVICE_E = 0x7B, //设备搜索
CMD_DEVICE_REPORT_E = 0x7C, //新设备上报
CMD_DEVICE_CONNECT_E = 0x7D, //连接设备
CMD_DEVICE_DISCONNECT_E = 0X7E, //设备断开,蓝牙断开(下->上)
RealTimeParam_E = 0x80, //实时参数
FESParamSet_E = 0x81, //fes参数
//CMD_BATTERY_LEVAL = 0x82 //接收显示电量
FES_PRE_FREQUENCY = 0x7F, //预设频率
FES_PRE_BINDWIDTH = 0x70 //预设脉宽
}E_FESCMD;
//串口配置
typedef struct ST_SerialPortConfig
{
QString portName; //端口名
int32_t baud; //波特率
int8_t dataBits; //数据位
int8_t parity; //奇偶校验
int8_t stopBit; //停止位
int8_t flowControl; //流控
ST_SerialPortConfig()
{
portName = "";
baud = 0;
dataBits = 0;
parity = 0;
stopBit = 0;
flowControl = 0;
}
}ST_SerialPortConfig;
//数据库配置
typedef struct ST_DataBaseConfig
{
QString IP;
int16_t port;
QString userName; //用户名
QString password; //密码
ST_DataBaseConfig()
{
IP = "";
port = 0;
userName = "";
password = "";
}
}ST_DataBaseConfig;
//FES参数中按钮显示
typedef struct
{
QString muscleName; //肌肉名
int muscleId; //肌肉下标(根据下标可判断左右)
bool connectState; //连接状态
int frequency; //频率
int plus; //脉宽
int minCurrent; //最小电流
int maxCurrent; //最小电流
}ST_MuscleParam;
//高级设置参数
typedef struct
{
//预热阶段
int preheatContinueTime; //预热期持续时间 0~60min step-1
int preheatAContinueTime; //加速持续时间 0~60min step-1
int preheatCompensate; //转速补偿 -30~30 step-1
bool isFesOn; //是否开启电刺激
int preheatMaxPower; //预热期最大电量 0~50% step-1%
int transitionalFesRise; //电刺激上升幅度 1~100% step-1%
//积极阶段
int positiveFChiXuTime; //向前持续时间0~120min step-1
int positiveFControlSpeed; //向前(控制速度) 5~60r/min step-1
int positiveBChiXuTime; //(向后)持续时间 0~120min step-1
int positiveBSpeedCompensate;//(向后)转速补偿 -30~30r/min step-1
int positiveBresistance; //(向后)阻力扭矩补偿 -20~20Nm step-1
int timeLimit; //时间阈值 0~240s step-1s
int speedLimit; //转速阈值 -1~-50r/min step-1
//消极阶段
bool isSkipPassive; //跳过此阶段
int negativeSpeedCompensate; //(向前)转速补偿 -30~30r/min step-1
int tiredContinueTime; //持续时间(疲劳侦测) 0~30min
int tiredSpeedCompensate; //转速补偿(疲劳侦测) -30~0 step-1
}ST_AdvancedParam;
/**********与下位机通信--start**********/
//踏车参数
#pragma pack(push) // 保存原来的字节对齐方式
#pragma pack(1)
//启动前参数
typedef struct
{
int8_t controlState;//状态控制 0-停止 1启动 2-暂停 3-继续
int8_t bodyPart; //训练部位 0-上肢 1-下肢 2-四肢 3-垂直上肢
int8_t trainMode; //训练模式 0-被动 1-主动 2-助力 3-等速 4-上下肢协同被动 7-四肢主被动 9-单独主动 10-被动可切主动(主被动)
int8_t spasmSwitch; //痉挛开关 0-关 1-开
int8_t spasmLevel; //痉挛等级1~3挡
int8_t configPower; //配置功率0~2 低中高
int8_t switchDirectonTime;//换向时间
int8_t phaseValue; //协同相位值
int8_t direction; //方向 0-逆向 1-正向
int8_t speed; //速度 2~60r/min
int8_t resistance; //阻力 Nm 0~20挡
int8_t spasmType; //痉挛后方向 1-正向 0-逆向,默认逆向,没有了
uint8_t trainTime; //训练时间 0~120min
}ST_BicycleParam;
//下位机上传参数
typedef struct
{
int8_t currentMode; //当前模式
int8_t direction; //方向 0-反向 1-正向
uint8_t downLimpSpeed; //下肢速度
uint8_t upLimpSpeed; //上肢速度
uint16_t leftHandPosition; //左手位置
uint16_t leftFootPosition; //左脚位置
uint16_t rightHandPosition; //右手位置
uint16_t rightFootPosition; //右脚位置
int8_t upBalance; //上肢平衡度
int8_t downBalance; //下肢平衡度
uint16_t upLimpCircle; //上肢圈数
uint16_t downLimpCircle; //下肢圈数
int8_t emergencyState; //急停 1-触发 0-未触发
int8_t spasmState; //痉挛 1-触发 0-未触发
int8_t error; //系统故障
int8_t oxygen; //血氧数据
int8_t overSpeedProtect; //过速保护 0-正常 1-触发
uint16_t upPower; //上肢功率
uint16_t downPower; //下肢功率
uint32_t energy; //能量
}ST_DeviceParam;
#pragma pack(pop) // 恢复字节对齐方式
/**********与下位机通信--end**********/
//脉搏血氧
typedef struct
{
int pulse;//脉搏
int oxygen;//血氧
}ST_PulseOxygen;
//游戏界面显示参数
typedef struct
{
int type; //0-上肢 1-下肢
int updown; //方向1-正向 0-逆向
int power; //阻力
int speed; //速度
}ST_SetBicycleParam;
#pragma pack(push) //保存对齐状态
#pragma pack(1)//设定为1字节对齐
//设置参数
typedef struct
{
uint8_t mode; //模式 1-采集 2-刺激 3-触发
uint8_t sampleRate; //采样率 1-4K 2-8K
uint8_t waveStyle; //波形 01-双向对称方波
uint16_t frequency; //频率
uint16_t pulseWidth; //脉宽
uint16_t startAngle; //开始角度(正)
uint16_t stopAgnle; //结束角度(正)
uint16_t startAngleReverse; //开始角度(反)
uint16_t stopAgnleReverse; //结束角度(反)
uint8_t minCurrent; //最小电流
uint16_t maxCurrent; //最大电流
uint8_t upDownLimp; // 1-上 2-下
uint8_t leftRightLimp;//1-左 2-右
}ST_FESSetParam;
typedef struct
{
uint8_t mode;//模式 1-采集 2-刺激 3-触发
uint8_t sampleRate; //采样率 1-4K 2-8K
uint8_t waveStyle; //波形 01-双向对称方波
uint16_t frequency; //频率
uint16_t pulseWidth;//脉宽
uint16_t waveRise; //波升
uint16_t keepTime; //保持
uint16_t waveFall; //波降
uint16_t sleepTime; //休息
}ST_OnlyFESParam;
//实时参数
typedef struct
{
uint8_t upSpeed; //1~60rmp/min
uint8_t downSpeed; //1~60rmp/min
uint16_t currentUpAngle;//实时角度0~360
uint16_t currentDownAngle;
uint8_t direction; //方向 0-逆 1-正
}ST_FESRealTimeParam;
typedef struct
{
int muscleId; //肌肉ID
QString muscleName; //肌肉名称
int startAngle; //起始角度
int stopAngle; //停止角度
}ST_RecipeParam;
//电刺激盒状态
typedef struct
{
uint8_t channle1State; //通道1状态 0-脱落 1-连接
uint8_t channle2State;
uint8_t power;
}ST_FESDeviceState;
#pragma pack(pop)//恢复对齐状态
//游戏相关参数
//更改游戏配置文件的参数(通信文件)
typedef struct ST_GameParam
{
int hardLevel; //难度等级 1-3(此处的难度等级对应范围大小)
int gameTime; //游戏运行时间 单位/s
int speed; //运行速度 1-5
int trainingMode; //训练类型
QString trainTrackFilePath; //路径文件
bool readPosTable; //是否去读轨迹
int angleValue; //分段运动角度
int trainType; //被动训练类型1-圆周 2-分段
int waitTime; //等待时间
int maxCircle; //最大圈数
ST_GameParam()
{
hardLevel = 1;
gameTime = 0;
speed = 3;
trainingMode = 0;
trainTrackFilePath = "";
readPosTable = false;
}
}ST_GameParam;
//该结构体用于读取游戏列表
typedef struct
{
int gameID; //游戏ID
QString gamePath; //游戏路径
QString iconPath; //游戏图标路径
QString gameName; //游戏可执行文件名
QString className; //窗口类名
QString windownName; //窗口名
}ST_GameMsg;
//游戏控制参数
typedef struct
{
int MsgId; //消息ID
int ID; //用户ID
QString userName;//用户名
float speed; //速度
int forceLeft; //左平衡
int forceRight; //右平衡
int angle; //角度
}ST_GameControlParam;
extern void Pressure_CheckCRC(uint8_t*buf,int len,uint8_t* CRC_H,uint8_t* CRC_L);
extern void Sleep(int msec);
#endif // DATAFORMATE_H

View File

@@ -0,0 +1,224 @@
#include "dbforrmate.h"
#include <QUuid>
ST_PatientMsg variantMapToPatientMsg(QVariantMap vMap)
{
ST_PatientMsg st_PatientMsg;
if(vMap.contains("ID"))
st_PatientMsg.ID = vMap.value("ID").toUInt();
if(vMap.contains("name"))
st_PatientMsg.name = vMap.value("name").toString();
if(vMap.contains("phone"))
st_PatientMsg.phone = vMap.value("phone").toString();
if(vMap.contains("sex"))
st_PatientMsg.sex = vMap.value("sex").toUInt();
if(vMap.contains("birthday"))
st_PatientMsg.birthday = vMap.value("birthday").toDate();
if(vMap.contains("bodyIndex"))
st_PatientMsg.bodyIndex = vMap.value("bodyIndex").toInt();
if(vMap.contains("markMsg"))
st_PatientMsg.markMsg = vMap.value("markMsg").toString();
if(vMap.contains("age"))
st_PatientMsg.age = vMap.value("age").toUInt();
return st_PatientMsg;
}
ST_TrainReport variantMapToTrainReport(QVariantMap vMap)
{
ST_TrainReport st_TrainReport;
if(vMap.contains("UUID"))
st_TrainReport.UUID = vMap.value("UUID").toString();
if(vMap.contains("ID"))
st_TrainReport.ID = vMap.value("ID").toInt();
if(vMap.contains("name"))
st_TrainReport.name = vMap.value("name").toString();
if(vMap.contains("sex"))
st_TrainReport.sex = vMap.value("sex").toInt();
if(vMap.contains("phone"))
st_TrainReport.phone = vMap.value("phone").toString();
if(vMap.contains("age"))
st_TrainReport.age = vMap.value("age").toUInt();
if(vMap.contains("trainMode"))
st_TrainReport.trainMode = vMap.value("trainMode").toInt();
if(vMap.contains("bodyIndex"))
st_TrainReport.bodyIndex = vMap.value("bodyIndex").toInt();
if(vMap.contains("markMsg"))
st_TrainReport.markMsg = vMap.value("markMsg").toString();
if(vMap.contains("trainTime"))
st_TrainReport.trainTime = vMap.value("trainTime").toInt();
if(vMap.contains("leftBalance"))
st_TrainReport.leftBalance = vMap.value("leftBalance").toInt();
if(vMap.contains("rightBalance"))
st_TrainReport.rightBalance = vMap.value("rightBalance").toInt();
if(vMap.contains("upLimpLength"))
st_TrainReport.upLimpLength = vMap.value("upLimpLength").toFloat();
if(vMap.contains("downLimpLength"))
st_TrainReport.downLimpLength = vMap.value("downLimpLength").toFloat();
if(vMap.contains("passiveTime"))
st_TrainReport.passiveTime = vMap.value("passiveTime").toInt();
if(vMap.contains("activeTime"))
st_TrainReport.activeTime = vMap.value("activeTime").toInt();
if(vMap.contains("spasmTimes"))
st_TrainReport.spasmTimes = vMap.value("spasmTimes").toInt();
if(vMap.contains("maxResistance"))
st_TrainReport.maxResistance = vMap.value("maxResistance").toFloat();
if(vMap.contains("minResistance"))
st_TrainReport.minResistance = vMap.value("minResistance").toFloat();
if(vMap.contains("averangeResistance"))
st_TrainReport.averangeResistance = vMap.value("averangeResistance").toFloat();
if(vMap.contains("startTimeStr"))
st_TrainReport.startTimeStr = vMap.value("startTimeStr").toString();
if(vMap.contains("averageSpeed"))
st_TrainReport.averageSpeed = vMap.value("averageSpeed").toInt();
if(vMap.contains("maxSpeed"))
st_TrainReport.maxSpeed = vMap.value("maxSpeed").toInt();
return st_TrainReport;
}
ST_TrainRecord variantMapToTrainRecord(QVariantMap vMap)
{
ST_TrainRecord st_trainRecord;
if(vMap.contains("ID"))
st_trainRecord.ID = vMap.value("ID").toUInt();
if(vMap.contains("startTime"))
st_trainRecord.startTime = vMap.value("startTime").toDateTime();
if(vMap.contains("startTimeStr"))
st_trainRecord.startTimeStr = vMap.value("startTimeStr").toString();
if(vMap.contains("trainTime"))
st_trainRecord.trainTime = vMap.value("trainTime").toInt();
if(vMap.contains("score"))
st_trainRecord.score = vMap.value("score").toInt();
if(vMap.contains("bodyPart"))
st_trainRecord.bodyPart = vMap.value("bodyPart").toString();
if(vMap.contains("trainMode"))
st_trainRecord.trainMode = vMap.value("trainMode").toString();
return st_trainRecord;
}
ST_BLEDevice variantMapToBLEDevice(QVariantMap vMap)
{
ST_BLEDevice st_deviceMsg;
if(vMap.contains("deviceNo"))
st_deviceMsg.deviceNo = vMap.value("deviceNo").toInt();
if(vMap.contains("deviceMac"))
st_deviceMsg.deviceMac = vMap.value("deviceMac").toString();
return st_deviceMsg;
}
ST_TrainParam variantMapToTrainParam(QVariantMap vMap)
{
ST_TrainParam st_trainParam;
if(vMap.contains("ID"))
st_trainParam.ID = vMap.value("ID").toInt();
if(vMap.contains("trainLimp"))
st_trainParam.trainLimp = vMap.value("trainLimp").toInt();
if(vMap.contains("trainMode"))
st_trainParam.trainMode = vMap.value("trainMode").toInt();
if(vMap.contains("trainTime"))
st_trainParam.trainTime = vMap.value("trainTime").toInt();
if(vMap.contains("trainResistance"))
st_trainParam.trainResistance = vMap.value("trainResistance").toInt();
if(vMap.contains("trainSpeed"))
st_trainParam.trainSpeed = vMap.value("trainSpeed").toInt();
if(vMap.contains("trainDirection"))
st_trainParam.trainDirection = vMap.value("trainDirection").toInt();
if(vMap.contains("spasmProtect"))
st_trainParam.spasmProtect = vMap.value("spasmProtect").toInt();
if(vMap.contains("spasmLevel"))
st_trainParam.spasmLevel = vMap.value("spasmLevel").toInt();
if(vMap.contains("gameID"))
st_trainParam.gameID = vMap.value("gameID").toInt();
return st_trainParam;
}
QVariantMap patientMsgToVariantMap(const ST_PatientMsg& st_PatientMsg)
{
QVariantMap vMap;
vMap.insert("ID",st_PatientMsg.ID);
vMap.insert("name",st_PatientMsg.name);
vMap.insert("phone",st_PatientMsg.phone);
vMap.insert("birthday",st_PatientMsg.birthday);
vMap.insert("sex",st_PatientMsg.sex);
vMap.insert("bodyIndex",st_PatientMsg.bodyIndex);
vMap.insert("markMsg",st_PatientMsg.markMsg);
vMap.insert("age",st_PatientMsg.age);
return vMap;
}
QVariantMap trainReportToVariantMap(const ST_TrainReport& st_TrainReport)
{
QVariantMap vMap;
//添加UUID
QUuid id = QUuid::createUuid();
QString strId = id.toString(QUuid::Id128);
vMap.insert("UUID",strId);
vMap.insert("ID",st_TrainReport.ID);
vMap.insert("name",st_TrainReport.name);
vMap.insert("sex",st_TrainReport.sex);
vMap.insert("phone",st_TrainReport.phone);
vMap.insert("age",st_TrainReport.age);
vMap.insert("trainMode",st_TrainReport.trainMode);
vMap.insert("bodyIndex",st_TrainReport.bodyIndex);
vMap.insert("markMsg",st_TrainReport.markMsg);
vMap.insert("trainTime",st_TrainReport.trainTime);
vMap.insert("leftBalance",st_TrainReport.leftBalance);
vMap.insert("rightBalance",st_TrainReport.rightBalance);
vMap.insert("upLimpLength",st_TrainReport.upLimpLength);
vMap.insert("downLimpLength",st_TrainReport.downLimpLength);
vMap.insert("activeTime",st_TrainReport.activeTime);
vMap.insert("passiveTime",(int)st_TrainReport.passiveTime);
vMap.insert("spasmTimes",st_TrainReport.spasmTimes);
vMap.insert("maxResistance",st_TrainReport.maxResistance);
vMap.insert("averangeResistance",st_TrainReport.averangeResistance);
vMap.insert("minResistance",st_TrainReport.minResistance);
vMap.insert("startTimeStr",st_TrainReport.startTimeStr);
vMap.insert("averageSpeed",st_TrainReport.averageSpeed);
vMap.insert("maxSpeed",st_TrainReport.maxSpeed);
return vMap;
}
QVariantMap trainRecordToVariantMap(const ST_TrainRecord& st_trainRecord)
{
QVariantMap vMap;
//添加UUID
QUuid id = QUuid::createUuid();
QString strId = id.toString(QUuid::Id128);
vMap.insert("UUID",strId);
vMap.insert("ID",st_trainRecord.ID);
vMap.insert("startTime",st_trainRecord.startTime);
vMap.insert("startTimeStr",st_trainRecord.startTimeStr);
vMap.insert("trainTime",st_trainRecord.trainTime);
vMap.insert("score",st_trainRecord.score);
vMap.insert("bodyPart",st_trainRecord.bodyPart);
vMap.insert("trainMode",st_trainRecord.trainMode);
return vMap;
}
QVariantMap BLEDeviceToVariantMap(const ST_BLEDevice& st_bleDevice)
{
QVariantMap vMap;
vMap.insert("deviceNo",st_bleDevice.deviceNo);
vMap.insert("deviceMac",st_bleDevice.deviceMac);
return vMap;
}
QVariantMap TrainParamToVariantMap(const ST_TrainParam &st_trainParam)
{
QVariantMap vMap;
vMap.insert("ID",st_trainParam.ID);
vMap.insert("trainLimp",st_trainParam.trainLimp);
vMap.insert("trainMode",st_trainParam.trainMode);
vMap.insert("trainTime",st_trainParam.trainTime);
vMap.insert("trainResistance",st_trainParam.trainResistance);
vMap.insert("trainSpeed",st_trainParam.trainSpeed);
vMap.insert("trainDirection",st_trainParam.trainDirection);
vMap.insert("spasmProtect",st_trainParam.spasmProtect);
vMap.insert("spasmLevel",st_trainParam.spasmLevel);
vMap.insert("gameID",st_trainParam.gameID);
return vMap;
}

View File

@@ -0,0 +1,93 @@
#ifndef DBFORRMATE_H
#define DBFORRMATE_H
#include <QDateTime>
#include <QVariantMap>
//用户信息
typedef struct
{
uint32_t ID; //自增性ID由系统分配控制
QString name; //患者姓名 必填
QString phone; //患者电话
int sex; //0-男性 1-女性
QDate birthday; //生日
int bodyIndex; //训练部位选择 0-下肢 1-上肢 2-上下肢
QString markMsg; //备注信息
int age; //患者年龄
}ST_PatientMsg;
//训练记录,
typedef struct
{
QString UUID;
int ID; //用户ID
QDateTime startTime; //开始训练时间-用于排序
QString startTimeStr; //训练时间字符串版-用于显示
int trainTime; //训练时长 min
int score; //游戏得分 距离*3
QString bodyPart; //训练部位
QString trainMode; //训练模式
}ST_TrainRecord;
//训练报告
typedef struct
{
QString UUID;
int ID; //系统ID
QString name; //患者姓名
int sex; //0-male 1-female
QString phone; //手机
int age; //年龄
int trainMode; //训练模式
int bodyIndex; //训练部位
QString markMsg; //备注
int trainTime; //本次训练时长(分钟)
int leftBalance; //左平衡
int rightBalance; //右平衡
float upLimpLength; //上肢距离
float downLimpLength; //下肢距离
int activeTime; //主动时间 /s
int passiveTime; //被动时间 /s
int spasmTimes; //痉挛次数
float maxResistance; //最大阻力
float averangeResistance;//平均阻力
float minResistance; //最小阻力
QString startTimeStr; //训练时间 字符串版-查看检索
int averageSpeed; //平均速度
int maxSpeed; //最大速度
}ST_TrainReport;
typedef struct
{
int ID; //训练用户的ID
int trainLimp; //训练肢体0代表上肢、1代表下肢、2代表四肢
int trainMode; //训练模式
int trainTime; //训练时间
int trainResistance; //训练阻力
int trainSpeed; //训练速度
int trainDirection; //训练方向0正向1逆向
int spasmProtect; //痉挛保护
int spasmLevel; //痉挛等级
int gameID; //游戏的ID
}ST_TrainParam;
//电刺激数据
typedef struct
{
int deviceNo; //设备号
QString deviceMac;//设备Mac地址
}ST_BLEDevice;
extern ST_PatientMsg variantMapToPatientMsg(QVariantMap vMap);
extern ST_TrainReport variantMapToTrainReport(QVariantMap vMap);
extern ST_TrainRecord variantMapToTrainRecord(QVariantMap vMap);
extern ST_BLEDevice variantMapToBLEDevice(QVariantMap vMap);
extern ST_TrainParam variantMapToTrainParam(QVariantMap vMap);
extern QVariantMap patientMsgToVariantMap(const ST_PatientMsg&);
extern QVariantMap trainReportToVariantMap(const ST_TrainReport&);
extern QVariantMap trainRecordToVariantMap(const ST_TrainRecord&);
extern QVariantMap BLEDeviceToVariantMap(const ST_BLEDevice&);
extern QVariantMap TrainParamToVariantMap(const ST_TrainParam&);
#endif // DBFORRMATE_H

View File

@@ -0,0 +1,66 @@
#include "gamecontainer.h"
#include "ui_gamecontainer.h"
#include <QProcess>
#include <QShowEvent>
#include <QDebug>
#include "dataformate.h"
#include <QTimer>
#include <windows.h>
#include <QHBoxLayout>
GameContainer::GameContainer(QWidget *parent) :
QWidget(parent),
ui(new Ui::GameContainer),
process(nullptr)
{
ui->setupUi(this);
initProcess();
}
GameContainer::~GameContainer()
{
if(process)
delete process;
delete ui;
}
void GameContainer::initProcess()
{
process = new QProcess();
connect(process,&QProcess::errorOccurred,[=](QProcess::ProcessError error){qDebug()<<error;});
connect(process,QOverload<int,QProcess::ExitStatus>::of(&QProcess::finished),[this]
(int exitCode,QProcess::ExitStatus exitStatus){
m_exitCode = exitCode;
m_exitStatus = exitStatus;
qDebug()<<"m_exitCode"<<m_exitCode<<"m_exitStatus"<<m_exitStatus;
});
}
void GameContainer::startGame(QString path)
{
}
void GameContainer::showEvent(QShowEvent *event)
{
// qDebug()<<"showEvent";
// QString path = "./GameDemo/game801/game801/MultiplayerBicycleRace.exe";
// process->start(path);
// Sleep(10);
// WId hwnd = 0;
// do{
// QEventLoop loop;
// //1ms之后退出
// QTimer::singleShot(1,&loop,SLOT(quit()));
// hwnd = (WId)FindWindow(L"UnityWndClass",L"DuoRenQiChe2");
// }while(hwnd == 0);
// m_window = QWindow::fromWinId(hwnd);
// QWidget *container = createWindowContainer(m_window,this);
// QHBoxLayout *hLayout = new QHBoxLayout(this);
// hLayout->setMargin(0);
// hLayout->addWidget(container);
// this->setLayout(hLayout);
}

View File

@@ -0,0 +1,33 @@
#ifndef GAMECONTAINER_H
#define GAMECONTAINER_H
#include <QWidget>
#include <QProcess>
#include <QWindow>
namespace Ui {
class GameContainer;
}
class GameContainer : public QWidget
{
Q_OBJECT
public:
explicit GameContainer(QWidget *parent = nullptr);
~GameContainer();
void startGame(QString path);
protected:
void showEvent(QShowEvent *event);
private:
void initProcess();
private:
Ui::GameContainer *ui;
QProcess *process;
int m_exitCode;
QProcess::ExitStatus m_exitStatus;
QWindow *m_window;
};
#endif // GAMECONTAINER_H

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GameContainer</class>
<widget class="QWidget" name="GameContainer">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -0,0 +1,522 @@
#include "gamecontrol.h"
#include <QFile>
#include <QTextStream>
#include "readconfig.h"
#include <QDebug>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonParseError>
#include <QDateTime>
#include "currentuserdata.h"
#include "cdatabaseinterface.h"
#include <QTimer>
//LOG4QT_DECLARE_STATIC_LOGGER(logger, GameControl)
GameControl* GameControl::m_GameParamControl = NULL;
GameControl::GameControl(QWidget *parent)
: QWidget(parent),
m_gameSocket(NULL),
// m_waitingDialog(NULL),
m_trainReport(NULL),
waitTimer(NULL),
m_activeMaxAngle(0),
m_activeMinAngle(0),
currentGameID(0)
{
m_Process = new QProcess();
// initGameSocket();
// m_waitingDialog = new WaitingDialog();
// m_waitingDialog->setWaitingType(INITWAITING);
m_trainReport = new TrainReport();
waitTimer = new QTimer();
waitTimer->setInterval(500);
waitTimer->setSingleShot(true);
connect(waitTimer,SIGNAL(timeout()),this,SLOT(slotWaitTimer()));
player = new QMediaPlayer();
}
GameControl::~GameControl()
{
if(m_trainReport)
{
delete m_trainReport;
}
if(waitTimer)
{
delete waitTimer;
}
if(player)
{
delete player;
}
}
void GameControl::initGameSocket()
{
m_gameSocket = new QUdpSocket();
int16_t port;
QString IP;
ReadConfig::getInstance()->getGameServerAddress(port,IP);
if(m_gameSocket->bind(port))
{
qDebug()<<(QString("游戏服务端口%1").arg(port));
}
connect(m_gameSocket,&QUdpSocket::readyRead,this,&GameControl::slotReceiveGameData);
}
GameControl* GameControl::getInstance()
{
if(!m_GameParamControl)
{
m_GameParamControl = new GameControl();
}
return m_GameParamControl;
}
void GameControl::updateXml(ST_GameParam& st_GameParam)
{
QFile file("./gameExecutable/gameConfig.xml");
if(!file.open(QFile::ReadOnly))
return;
QDomDocument doc;
if(!doc.setContent(&file))
{
file.close();
return;
}
file.close();
QDomElement root = doc.documentElement();
if(1)
{
QDomNodeList timeList = root.elementsByTagName("GameTime");
QDomNode timeNode = timeList.at(0);
QDomNode oldnode=timeNode.firstChild();
timeNode.firstChild().setNodeValue(QString::number(st_GameParam.gameTime));
QDomNode newNode = timeNode.firstChild();
timeNode.replaceChild(newNode,oldnode);
}
if(1)
{
QDomNodeList levelList = root.elementsByTagName("Level");
QDomNode levelNode = levelList.at(0);
QDomNode oldLevelnode=levelNode.firstChild();
levelNode.firstChild().setNodeValue(QString::number(st_GameParam.hardLevel));
QDomNode newLevelNode = levelNode.firstChild();
levelNode.replaceChild(newLevelNode,oldLevelnode);
}
if(1)
{
QDomNodeList List = root.elementsByTagName("Speed");
QDomNode node = List.at(0);
QDomNode oldLevelnode=node.firstChild();
node.firstChild().setNodeValue(QString::number(st_GameParam.speed));
QDomNode newLevelNode = node.firstChild();
node.replaceChild(newLevelNode,oldLevelnode);
}
if(1)
{
QDomNodeList List = root.elementsByTagName("TrainType");
QDomNode node = List.at(0);
QDomNode oldLevelnode=node.firstChild();
node.firstChild().setNodeValue(QString::number(st_GameParam.trainType));
QDomNode newLevelNode = node.firstChild();
node.replaceChild(newLevelNode,oldLevelnode);
}
if(1)
{
QDomNodeList List = root.elementsByTagName("AngleVlue");
QDomNode node = List.at(0);
QDomNode oldLevelnode=node.firstChild();
node.firstChild().setNodeValue(QString::number(st_GameParam.angleValue));
QDomNode newLevelNode = node.firstChild();
node.replaceChild(newLevelNode,oldLevelnode);
}
if(1)
{
QDomNodeList List = root.elementsByTagName("WaitTime");
QDomNode node = List.at(0);
QDomNode oldLevelnode=node.firstChild();
node.firstChild().setNodeValue(QString::number(st_GameParam.waitTime));
QDomNode newLevelNode = node.firstChild();
node.replaceChild(newLevelNode,oldLevelnode);
}
if(1)
{
QDomNodeList List = root.elementsByTagName("MaxCircle");
QDomNode node = List.at(0);
QDomNode oldLevelnode=node.firstChild();
node.firstChild().setNodeValue(QString::number(st_GameParam.maxCircle));
QDomNode newLevelNode = node.firstChild();
node.replaceChild(newLevelNode,oldLevelnode);
}
if(1)
{
QDomNodeList List = root.elementsByTagName("ReadPosTable");
QDomNode node = List.at(0);
QDomNode oldLevelnode=node.firstChild();
QString ok("false");
if(st_GameParam.readPosTable)
ok = "true";
else
ok = "false";
node.firstChild().setNodeValue(ok);
QDomNode newLevelNode = node.firstChild();
node.replaceChild(newLevelNode,oldLevelnode);
}
QDomNode n = root.firstChild();
while(!n.isNull())
{
QDomElement e = n.toElement();
if(!e.isNull())
{
if(e.tagName() == "TrainingTrack")
{
e.setAttribute("path",st_GameParam.trainTrackFilePath);
}
}
n = n.nextSibling();
}
if(!file.open(QFile::WriteOnly|QFile::Truncate))
return;
//输出到文件
QTextStream out_stream(&file);
doc.save(out_stream,4); //缩进4格
file.close();
}
void GameControl::setGamParam(ST_GameParam& st_GameParam)
{
//将本地参数转化成游戏中用到的参数
if(5 == st_GameParam.trainType)
st_GameParam.trainType = 1;
if(6 == st_GameParam.trainType)
st_GameParam.trainType = 2;
updateXml(st_GameParam);
}
void GameControl::readGameConfigMsg()
{
QList<ST_GameMsg> gameMsgList;
QFile file("./DependFile/ConfigFile/gameListConfig.xml");
if(!file.open(QIODevice::ReadOnly))
{
qDebug()<<"read gameListConfig failed";
return ;
}
QDomDocument doc;
QString error;
int row,colum;
if(!doc.setContent(&file,&error,&row,&colum))
{
qDebug()<<"gameList error"<<error<<row<<colum;
file.close();
return ;
}
file.close();
QDomElement root=doc.documentElement(); //返回根节点
QDomNode node=root.firstChild(); //获得第一个子节点
while(!node.isNull())
{
if(node.isElement()) //如果节点是元素
{
ST_GameMsg st_GameMsg;
QDomElement e=node.toElement();
st_GameMsg.gameID = e.attribute("ID").toInt();
st_GameMsg.gameName = e.attribute("gameName");
st_GameMsg.gamePath = e.attribute("path");
st_GameMsg.iconPath = e.attribute("iconPath");
st_GameMsg.className = e.attribute("className");
st_GameMsg.windownName = e.attribute("windownName");
gameMsgList.append(st_GameMsg);
m_mapGameName.insert(st_GameMsg.gameID,st_GameMsg);
}
node = node.nextSibling();
}
m_gameMsgList = gameMsgList;
}
QList<ST_GameMsg> GameControl::getGameMsgs()
{
return m_gameMsgList;
}
ST_GameMsg GameControl::getGameMsgByName(int ID)
{
ST_GameMsg st_gameMsg;
QMapIterator<int, ST_GameMsg> i(m_mapGameName);
while(i.hasNext())
{
i.next();
}
if(m_mapGameName.contains(ID))
{
st_gameMsg = m_mapGameName.value(ID);
}
return st_gameMsg;
}
ST_GameMsg GameControl::getCurrentGameMsg()
{
return getGameMsgByName(currentGameID);
}
void GameControl::startGame(QString path)
{
//1.开启游戏进程
if(path.isEmpty())
return;
QString hardDisk = path.mid(0,2);
hardDisk.append("\n\r");
QString gameName = path.mid(path.lastIndexOf('/')+1);
gameName.prepend("start ");
gameName.append("\n\r");
QString gamePath = path.mid(0,path.lastIndexOf('/'));
gamePath.prepend("cd ");
gamePath.append("\n\r");
m_Process->start("cmd.exe");
//切换盘符
m_Process->write(hardDisk.toLatin1());
//进入文件夹
m_Process->write(gamePath.toLatin1());
//开启进程
m_Process->write(gameName.toLatin1());
m_Process->write("exit\n\r");
m_Process->waitForFinished();
m_Process->close();
//2.关闭设备复位中的界面
}
//游戏数据接收
void GameControl::slotReceiveGameData()
{
while(m_gameSocket->hasPendingDatagrams())
{
QByteArray buf;
buf.resize(m_gameSocket->pendingDatagramSize());
m_gameSocket->readDatagram(buf.data(),buf.size());
// parseGameMsg(buf);
}
}
/***
void GameControl::parseGameMsg(QByteArray jsonArray)
{
QJsonParseError jsonError;
QJsonDocument doucment = QJsonDocument::fromJson(jsonArray, &jsonError); // 转化为 JSON 文档
#if 1
if (!doucment.isNull() && (jsonError.error == QJsonParseError::NoError))
{
if(doucment.isObject())
{
QJsonObject object = doucment.object(); // 转化为对象
if(object.contains("msgID"))
{
int msgID = object.value("msgID").toInt();
switch(msgID)
{
case 1: //游戏开始信号
{
m_spasmTimes = 0;
isTraining = true;
waitTimer->start();
st_TrainReport.startTime = QDateTime::currentDateTime();
emit signalGameState(e_TrainMode,GameStart_E);
}
break;
case 2: //游戏给出的目标位置
{
{
if(object.contains("m_xv"))
{
QJsonObject xObject = object.value("m_xv").toObject();
int current = 0;
int max = 1;
if(xObject.contains("current"))
current = xObject.value("current").toInt();
if(xObject.contains("max"))
max = xObject.value("max").toInt();
}
if(object.contains("m_yv"))
{
QJsonObject yObject = object.value("m_yv").toObject();
int current = 0;
int max = 1;
if(yObject.contains("current"))
current = yObject.value("current").toInt();
if(yObject.contains("max"))
max = yObject.value("max").toInt();
}
if(object.contains("tarAngle"))
{
float angle = 0;
angle = object.value("tarAngle").toDouble();
// emit signalSendDestPosition(angle);
}
}
}
break;
case 3: //结束信息
{
isTraining = false;
if(object.contains("quitType"))
{
//告知下位机训练完成
sendStopCmd();
m_quitType = object.value("quitType").toInt();
//正常退出
if(1 == m_quitType)
{
emit signalGameState(e_TrainMode,GameEnd_E);
st_TrainReport.endTime = QDateTime::currentDateTime();
if(object.contains("totalTime"))
st_TrainReport.duration = object.value("totalTime").toInt();
if(object.contains("totalScore"))
st_TrainReport.score = object.value("totalScore").toInt();
}
else
{
emit signalGameState(e_TrainMode,GameEnd_E);
st_TrainReport.endTime = QDateTime::currentDateTime();
if(object.contains("totalTime"))
st_TrainReport.duration = object.value("totalTime").toInt();
if(object.contains("totalScore"))
st_TrainReport.score = object.value("totalScore").toInt();
}
//生成训练报告
createTrainReport();
}
}
break;
}
}
}
}
else
{
// logger()->debug(jsonError.errorString());
//此处不该在此处停止心跳
}
#endif
}
***/
void GameControl::createTrainReport()
{
/***
ST_PatientMsg st_currentPatient = CurrentUserData::getInstace()->getCurrentPatientMsg();
st_TrainReport.ID = st_currentPatient.ID;
st_TrainReport.name = st_currentPatient.name;
//从数据库中查询总时间
int lastTotalDuration;
QString query("select * from TrainReport order by startTime DESC;");
if(!CDatabaseInterface::getInstance()->exec(query))
qDebug()<<CDatabaseInterface::getInstance()->getLastError()<<"ERROR";
int count = CDatabaseInterface::getInstance()->getValuesSize();
if(count >0)
{
QList<QVariantMap> maplist = CDatabaseInterface::getInstance()->getValues(0,1);
ST_TrainReport st_trainReport = variantMapToTrainReport(maplist.at(0));
lastTotalDuration = st_trainReport.totalDuration;
st_TrainReport.totalDuration = lastTotalDuration + st_TrainReport.duration;
}
st_TrainReport.level = 1;
if(0 == st_TrainReport.trainMode)
m_trainReport->setReportType(tr("被动训练报告"));
else if(1 == st_TrainReport.trainMode)
m_trainReport->setReportType(tr("主动训练报告"));
***/
m_trainReport->setReportData(st_TrainReport,1);
}
void GameControl::sendStopCmd()
{
QJsonObject object;
object.insert("msgID",2);
object.insert("GameState",0);
QJsonDocument document;
document.setObject(object);
QByteArray sendArray = document.toJson();
QString ip("127.0.0.1");
int16_t port = 12000;
for(int i = 0;i < 5;i++)
{
m_gameSocket->writeDatagram(sendArray,QHostAddress(ip),port);
Sleep(100);
}
}
void GameControl::setTrainParam(ST_TrainParam &st_TrainParam)
{
m_st_TrainParam = st_TrainParam;
}
ST_TrainParam GameControl::getTrainParam()
{
return m_st_TrainParam;
}
//游戏界面关闭时间
void GameControl::slotWaitTimer()
{
//关闭等待界面
// m_waitingDialog->setDialogCloseState(true);
}
//关闭游戏
void GameControl::stopGame()
{
sendStopCmd();
}
void GameControl::sendGameControlData(const ST_GameControlParam &st_gameControlParam)
{
QJsonObject object;
object.insert("msgID",st_gameControlParam.MsgId);
object.insert("ID",st_gameControlParam.ID);
object.insert("userName",st_gameControlParam.userName);
object.insert("speed",st_gameControlParam.speed);
object.insert("forceLeft",st_gameControlParam.forceLeft);
object.insert("forceRight",st_gameControlParam.forceRight);
object.insert("angle",st_gameControlParam.angle);
QJsonDocument document;
document.setObject(object);
QByteArray sendArray = document.toJson();
}
void GameControl::setCurrentGame(int ID)
{
currentGameID = ID;
}
void GameControl::playTipMusic(QString path)
{
player->setMedia(QUrl::fromLocalFile(path));
player->setVolume(90);
player->play();
}
int GameControl::getCurrentGameID()
{
return currentGameID;
}

View File

@@ -0,0 +1,117 @@
#ifndef GAMECONTROL_H
#define GAMECONTROL_H
#include <QWidget>
#include "dataformate.h"
#include <QDomDocument>
#include <QProcess>
#include <QUdpSocket>
#include "trainreport.h"
#include <QtMultimedia/QMediaPlayer>
class QTimer;
class GameControl : public QWidget
{
Q_OBJECT
public:
//更新游戏参数,通过该文件与游戏进行通信,游戏在启动时读取该文件
void setGamParam(ST_GameParam&);
//通过配置表获取所有游戏的信息
QList<ST_GameMsg> getGameMsgs();
//读取游戏配置文件
void readGameConfigMsg();
//根据游戏名获得游戏信息
ST_GameMsg getGameMsgByName(int ID);
//获取选中游戏信息
ST_GameMsg getCurrentGameMsg();
//获取实例
static GameControl* getInstance();
//启动游戏
void startGame(QString path);
//关闭游戏
void stopGame();
//发送左右平衡以及速度
void sendGameControlData(const ST_GameControlParam& );
//设置当前游戏序号
void setCurrentGame(int ID);
void playTipMusic(QString path);
//返回ID游戏
int getCurrentGameID();
//设置处方训练参数
void setTrainParam(ST_TrainParam &);
//返回处方参数
ST_TrainParam getTrainParam();
signals:
//游戏状态标志
// void signalGameState(E_TRAINMODE,E_GameState);
void signalSendDestPosition(float angle);
public slots:
//游戏数据接收
void slotReceiveGameData();
//游戏界面关闭时间
void slotWaitTimer();
private:
explicit GameControl(QWidget *parent = nullptr);
~GameControl();
void updateXml(ST_GameParam&);
void initGameSocket();
// void parseGameMsg(QByteArray jsonArray);
//生成报告
void createTrainReport();
//停止训练
void sendStopCmd();
private:
static GameControl* m_GameParamControl;
QMap<int,ST_GameMsg> m_mapGameName;
QProcess* m_Process;
QUdpSocket *m_gameSocket;
ST_TrainReport st_TrainReport;
//训练选择界面-配置处方的训练参数
ST_TrainParam m_st_TrainParam;
int m_spasmTimes; //痉挛次数
bool isTraining; //训练状态
int m_quitType; //退出类型
// WaitingDialog *m_waitingDialog;
TrainReport *m_trainReport;
QTimer *waitTimer;
float m_activeMaxAngle; //主动训练中最大的角度
float m_activeMinAngle; //主动训练中最小角度
QList<ST_GameMsg> m_gameMsgList;
int currentGameID;
QMediaPlayer * player;
};
#endif // GAMECONTROL_H

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,292 @@
#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

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,921 @@
#include "fescontroldialog.h"
#include "ui_fescontroldialog.h"
#include <QMessageBox>
#include <QDebug>
#include <QSerialPortInfo>
#include "bleitem.h"
#include <QDir>
#include <QSettings>
#include "dbforrmate.h"
#include "cdatabaseinterface.h"
#include <QMessageBox>
#include "readconfig.h"
#include <QTimer>
#include <QPainter>
#include "languagemanager.h"
FesControlDialog* FesControlDialog::instance = nullptr;
FesControlDialog::FesControlDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::FesControlDialog),
m_serialPort(NULL),
deviceConCount(0),
connectTimer(NULL),
E_fromFesType(ONLY_FES_E)
{
ui->setupUi(this);
//跟随主窗体关闭
ui->queryDevice_Btn->setVisible(false);
//ui->scanDevice_Btn->setVisible(false);
setAttribute(Qt::WA_QuitOnClose,false);
for(int i = 0;i< 4;i++)
{
deviceDtateArray[i] = 0;
//m_batteryValue[i] = 0;
}
for(int i = 0;i< 4;i++)
checkedMuscle_DeviceArray[i] = 0;
connectTimer = new QTimer();
connect(connectTimer,&QTimer::timeout,this,&FesControlDialog::slotConnectFes);
addedDeviceList.clear();
this->setWindowFlags(Qt::FramelessWindowHint); //设置无边框
setAttribute(Qt::WA_TranslucentBackground,true); //设置透明
initSerialPort();
//ui->flushSerial_Btn->setVisible(false);
}
FesControlDialog::~FesControlDialog()
{
qDebug()<<"~FesControlDialog()";
delete ui;
}
FesControlDialog *FesControlDialog::getInstance()
{
if(!instance)
instance = new FesControlDialog();
return instance;
}
bool FesControlDialog::initSerialPort()
{
if(!m_serialPort)
{
m_serialPort = new QSerialPort();
connect(m_serialPort,&QSerialPort::readyRead,this,&FesControlDialog::receiveDataInterface);
connect(m_serialPort,&QSerialPort::errorOccurred,this,&FesControlDialog::displayError);
}
m_serialPort->close();
QSerialPortInfo m_SerialPortInfo;
QStringList serialPortNames;
foreach(m_SerialPortInfo,QSerialPortInfo::availablePorts())
{
QSerialPort serialport;
serialport.setPort(m_SerialPortInfo);
if(serialport.open(QIODevice::ReadWrite))
{
serialPortNames.append(m_SerialPortInfo.portName());
serialport.close();
}
}
if(!serialPortNames.isEmpty())
{
ui->serial_ComboBox->clear();
ui->serial_ComboBox->addItems(serialPortNames);
}
else
{
QMessageBox::warning(NULL,tr("警告"),tr("FES无可用串口"),QMessageBox::Retry);
return false;
}
return true;
}
char FesControlDialog::getSum(QByteArray srcArray, int startIndex, int endIndex)
{
if(srcArray==nullptr||srcArray.length()==0||startIndex>srcArray.length()||endIndex>srcArray.length()||startIndex>endIndex)
{
return static_cast<char>(0);
}
int iSum=0;
for(int i=startIndex;i<=endIndex;i++)
{
iSum+=srcArray[i];
}
return static_cast<char>(iSum%256);
}
QByteArray FesControlDialog::createFrame(QByteArray dataBuffer)
{
//创建数据包
QByteArray buffer;
buffer.append(static_cast<char>(FRAME_HEAD));
buffer.append(static_cast<char>(dataBuffer.length()));
for(int i=0;i<dataBuffer.length();i++)
{
buffer.append(dataBuffer.data()[i]);
}
buffer.append(getSum(buffer,2,buffer.length()-1));
buffer.append(0x55);
return buffer;
}
void FesControlDialog::openSerialPort()
{
if(m_serialPort)
{
m_serialPort->setPortName(ui->serial_ComboBox->currentText());
m_serialPort->setReadBufferSize(200);
if(m_serialPort->open(QIODevice::ReadWrite))
{
m_serialPort->setBaudRate(QSerialPort::Baud115200);
m_serialPort->setDataBits(QSerialPort::Data8);
m_serialPort->setParity(QSerialPort::NoParity);
m_serialPort->setStopBits(QSerialPort::OneStop);
m_serialPort->setFlowControl(QSerialPort::NoFlowControl);
ui->openSerial_Btn->setText("关闭");
}
else
{
QMessageBox::warning(NULL,tr("警告"),tr("串口打开失败"),QMessageBox::Retry);
}
}
}
bool FesControlDialog::openSeriaport(ST_SerialPortConfig st_serialParam)
{
if(m_serialPort)
{
m_serialPort->setPortName(st_serialParam.portName);
m_serialPort->setReadBufferSize(200);
if(m_serialPort->open(QIODevice::ReadWrite))
{
m_serialPort->setBaudRate(QSerialPort::Baud115200);
m_serialPort->setDataBits(QSerialPort::Data8);
m_serialPort->setParity(QSerialPort::NoParity);
m_serialPort->setStopBits(QSerialPort::OneStop);
m_serialPort->setFlowControl(QSerialPort::NoFlowControl);
ui->openSerial_Btn->setText("关闭");
return true;
}
else
{
QMessageBox::warning(NULL,tr("警告"),tr("FES串口打开失败"),QMessageBox::Retry);
}
}
return false;
}
void FesControlDialog::searchDevice()
{
QByteArray array(4,0);
array[0] = CMD_SEARCH_DEVICE_E; //功能码
array[1] = 0; //设备编号0,搜索所有设备
array[2] = 0; //通道号0,默认值
array[3] = 1; //数据1-开始搜索,0-停止搜索)
QByteArray sendArray = createFrame(array);
sendData(sendArray);
}
bool FesControlDialog::connectDevice(QByteArray mac,uint8_t deviceNum)
{
QByteArray array(3,0);
array[0] = CMD_DEVICE_CONNECT_E; //功能码
array[1] = deviceNum; //设备编号0,搜索所有设备
array[2] = 0; //通道号0,默认值
array.append(mac);
QByteArray sendArray = createFrame(array);
sendData(sendArray);
return true;
}
void FesControlDialog::setPreCurrentState(int device, int channel, bool state)
{
QByteArray dataArray(4,0);
dataArray[0] = PreCurrentSwitch; //功能码
dataArray[1] = device; //设备编号0,搜索所有设备
dataArray[2] = channel; //通道号0,默认值
dataArray[3] = state ? 1: 0; //1-开 0-关
QByteArray sendArray = createFrame(dataArray);
sendData(sendArray);
}
//预设电流大小
void FesControlDialog::setPreCurrent(int device,int channel,uint8_t current)
{
QByteArray dataArray(4,0);
dataArray[0] = PreCurrentSet_E; //功能码
dataArray[1] = device; //设备编号0,搜索所有设备
dataArray[2] = channel; //通道号0,默认值
dataArray[3] = current; //1-开 0-关
QByteArray sendArray = createFrame(dataArray);
sendData(sendArray);
}
void FesControlDialog::setPreFrequency(int device, int channel, int16_t current)
{
QByteArray dataArray(3,0);
dataArray[0] = FES_PRE_FREQUENCY; //功能码
dataArray[1] = device; //设备编号0,搜索所有设备
dataArray[2] = channel; //通道号0,默认值
// memcpy(dataArray.data()+3,&current,sizeof(current));
QByteArray tempArray(2,0);
memcpy(tempArray.data(),&current,sizeof(current));
dataArray.append(tempArray.at(1)).append(tempArray.at(0));
QByteArray sendArray = createFrame(dataArray);
sendData(sendArray);
qDebug() <<"发送频率:"<< sendArray.toHex();
/*
switch(E_fromFesType) //FES参数来的页面
{
case ONLY_FES_E:
m_st_OnlyFESParam.frequency = current;
//FesControlDialog::getInstance()->setOnlyFesParam(device,channel,m_st_OnlyFESParam);
Sleep(100);
// FesControlDialog::getInstance()->setPreCurrentState(device,channel,true);
//qDebug()<<"单独电刺激,修改预设频率:"<<current<<m_st_OnlyFESParam.frequency << m_st_OnlyFESParam.keepTime << m_st_OnlyFESParam.mode;
break;
case BICYCLE_FES_E:
m_st_fesParam.frequency = current;
//qDebug()<<"脚踏车电刺激,修改预设频率:"<<current;
//FesControlDialog::getInstance()->setFesParam(device,channel,m_st_fesParam);
Sleep(100);
//FesControlDialog::getInstance()->setPreCurrentState(device,channel,true);
break;
}
*/
}
void FesControlDialog::setPrePulseWidth(int device, int channel, int16_t current)
{
//qDebug() << E_fromFesType;
/*
switch(E_fromFesType) //FES参数来的页面
{
case ONLY_FES_E:
m_st_OnlyFESParam.pulseWidth = current;
FesControlDialog::getInstance()->setOnlyFesParam(device,channel,m_st_OnlyFESParam);
Sleep(100);
// FesControlDialog::getInstance()->setPreCurrentState(device,channel,true);
//qDebug()<<"单独电刺激,修改预设频率:"<<current<<m_st_OnlyFESParam.frequency<<m_st_OnlyFESParam.pulseWidth << m_st_OnlyFESParam.keepTime << m_st_OnlyFESParam.mode;
break;
case BICYCLE_FES_E:
m_st_fesParam.pulseWidth = current;
qDebug()<<"脚踏车电刺激,修改预设频率:"<<current<<m_st_fesParam.frequency << m_st_fesParam.pulseWidth << m_st_fesParam.mode;
FesControlDialog::getInstance()->setFesParam(device,channel,m_st_fesParam);
Sleep(100);
//FesControlDialog::getInstance()->setPreCurrentState(device,channel,true);
break;
}*/
QByteArray dataArray(3,0);
dataArray[0] = FES_PRE_BINDWIDTH; //功能码
dataArray[1] = device; //设备编号0,搜索所有设备
dataArray[2] = channel; //通道号0,默认值
QByteArray tempArray(2,0);
memcpy(tempArray.data(),&current,sizeof(current));
dataArray.append(tempArray.at(1)).append(tempArray.at(0));
QByteArray sendArray = createFrame(dataArray);
sendData(sendArray);
qDebug() <<"发送带宽:"<< sendArray.toHex();
}
void FesControlDialog::setFesParam(int device,int channel,ST_FESSetParam st_fesParam)
{
//来自页面,保存参数
m_st_fesParam = st_fesParam;
E_fromFesType = BICYCLE_FES_E;
QByteArray dataArray(6,0);
dataArray[0] = FESParamSet_E; //功能码
dataArray[1] = device; //设备编号0,搜索所有设备
dataArray[2] = channel; //通道号0,默认值
dataArray[3] = 2; //刺激
dataArray[4] = 1; //采样率4k
dataArray[5] = 1; //双向对称方波
QByteArray tempArray(2,0);
//频率
memcpy(tempArray.data(),&st_fesParam.frequency,sizeof(st_fesParam.frequency));
dataArray.append(tempArray.at(1)).append(tempArray.at(0));
//脉宽
memcpy(tempArray.data(),&st_fesParam.pulseWidth,sizeof(st_fesParam.pulseWidth));
dataArray.append(tempArray.at(1)).append(tempArray.at(0));
//起始角度
memcpy(tempArray.data(),&st_fesParam.startAngle,sizeof(st_fesParam.startAngle));
dataArray.append(tempArray.at(1)).append(tempArray.at(0));
//结束角度
memcpy(tempArray.data(),&st_fesParam.stopAgnle,sizeof(st_fesParam.stopAgnle));
dataArray.append(tempArray.at(1)).append(tempArray.at(0));
//起始角度-逆向
memcpy(tempArray.data(),&st_fesParam.startAngleReverse,sizeof(st_fesParam.startAngle));
dataArray.append(tempArray.at(1)).append(tempArray.at(0));
//结束角度-逆向
memcpy(tempArray.data(),&st_fesParam.stopAgnleReverse,sizeof(st_fesParam.stopAgnle));
dataArray.append(tempArray.at(1)).append(tempArray.at(0));
//最小电流
dataArray.append(st_fesParam.minCurrent);
//最大电流sendRealTimeFesParam
dataArray.append(st_fesParam.maxCurrent);
//上下肢区分
dataArray.append(st_fesParam.upDownLimp);
//左右肢区分
dataArray.append(st_fesParam.leftRightLimp);
QByteArray sendArray = createFrame(dataArray);
sendData(sendArray);
qDebug() <<"发送数据:"<<sendArray.toHex();
}
void FesControlDialog::setRealTimeParam(int device,ST_FESRealTimeParam st_fesRealTimeParam)
{
QByteArray dataArray(5,0);
dataArray[0] = RealTimeParam_E; //功能码
dataArray[1] = device; //设备编号0,搜索所有设备
dataArray[2] = 0; //通道号0,默认值
dataArray[3] = st_fesRealTimeParam.upSpeed;//实时速度
dataArray[4] = st_fesRealTimeParam.downSpeed;//实时速度
QByteArray tempArray(2,0);
//上肢实时角度
memcpy(tempArray.data(),&st_fesRealTimeParam.currentUpAngle,sizeof(st_fesRealTimeParam.currentUpAngle));
dataArray.append(tempArray.at(1)).append(tempArray.at(0));
//下肢实时角度
memcpy(tempArray.data(),&st_fesRealTimeParam.currentDownAngle,sizeof(st_fesRealTimeParam.currentDownAngle));
dataArray.append(tempArray.at(1)).append(tempArray.at(0));
dataArray.append(st_fesRealTimeParam.direction);
QByteArray sendArray = createFrame(dataArray);
sendData(sendArray);
qDebug() <<"电刺激实时数据:"<<sendArray.toHex();
}
void FesControlDialog::switchDeviceChannel(int device, int channel, bool on)
{
QByteArray dataArray(4,0);
dataArray[0] = CMD_CHANNEL_CONTROL; //功能码
dataArray[1] = device; //设备编号0,搜索所有设备
dataArray[2] = channel; //通道号0,默认值
dataArray[3] = on ? 1:0; //1-开 0-关
QByteArray sendArray = createFrame(dataArray);
sendData(sendArray);
qDebug() <<"发送FES输出开关指令"<<sendArray.toHex();
}
void FesControlDialog::setOnlyFesParam(int device,int channel,ST_OnlyFESParam st_fesParm)
{
m_st_OnlyFESParam = st_fesParm;
E_fromFesType = ONLY_FES_E;
st_fesParm.mode = 0x02;//刺激
st_fesParm.sampleRate = 0;//采样率4K
st_fesParm.waveStyle = 1;//波形 双向方波
QByteArray dataArray;
dataArray.append(st_fesParm.mode);
dataArray.append(st_fesParm.sampleRate);
dataArray.append(st_fesParm.waveStyle);
QByteArray tempArray(2,0);
memcpy(tempArray.data(),&st_fesParm.frequency,sizeof(st_fesParm.frequency));
dataArray.append(tempArray.at(1)).append(tempArray.at(0));
memcpy(tempArray.data(),&st_fesParm.pulseWidth,sizeof(st_fesParm.pulseWidth));
dataArray.append(tempArray.at(1)).append(tempArray.at(0));
memcpy(tempArray.data(),&st_fesParm.waveRise,sizeof(st_fesParm.waveRise));
dataArray.append(tempArray.at(1)).append(tempArray.at(0));
memcpy(tempArray.data(),&st_fesParm.keepTime,sizeof(st_fesParm.keepTime));
dataArray.append(tempArray.at(1)).append(tempArray.at(0));
memcpy(tempArray.data(),&st_fesParm.waveFall,sizeof(st_fesParm.waveFall));
dataArray.append(tempArray.at(1)).append(tempArray.at(0));
memcpy(tempArray.data(),&st_fesParm.sleepTime,sizeof(st_fesParm.sleepTime));
dataArray.append(tempArray.at(1)).append(tempArray.at(0));
QByteArray array(3,0);
array[0] = CMD_PARAM_SET_E;
array[1] = device;
array[2] = channel;
array.append(dataArray);
QByteArray sendArray = createFrame(array);
sendData(sendArray);
qDebug() <<"发送实时参数:"<<sendArray.toHex();
}
/*
void FesControlDialog::saveOnlyFesParam(ST_OnlyFESParam st_OnlyFESParam)
{
m_st_OnlyFESParam = st_OnlyFESParam;
E_fromFesType = ONLY_FES_E; //从单电刺激页面来的参数
}
void FesControlDialog::saveBicycleFesParam(ST_FESSetParam st_FESSetParam)
{
m_st_fesParam = st_FESSetParam;
E_fromFesType = BICYCLE_FES_E; //从FES页面来的参数
}
*/
bool FesControlDialog::getDeviceStateByNo(uint8_t deviceNo)
{
if(deviceNo <= 4 )
{
if(deviceDtateArray[deviceNo-1])
return true;
}
return false;
}
bool FesControlDialog::getMuscleDeviceStateByNo(uint8_t deviceNo)
{
if(deviceNo >=1 && deviceNo <= 4 )
{
if(checkedMuscle_DeviceArray[deviceNo-1])
return true;
}
return false;
}
void FesControlDialog::setMuscleDeviceStateByNo(uint8_t deviceNo, bool flag)
{
if(flag)
{
qDebug() <<"打开设备的肌肉:"<<deviceNo; //从0~3
checkedMuscle_DeviceArray[deviceNo-1] = 1;
}
else
{
qDebug() <<"关闭设备的肌肉:"<<deviceNo;
checkedMuscle_DeviceArray[deviceNo-1] = 0;
}
}
//启用电刺激设备
bool FesControlDialog::openFESDevice()
{
//将按钮设置为不可用
//通过配置文件打开串口
ST_SerialPortConfig st_serialPortParam;
if(ReadConfig::getInstance()->getFesASerialPortConfig(st_serialPortParam))
{
//初始化串口
if(initSerialPort())
{
//打开串口
if(openSeriaport(st_serialPortParam))
{
//搜索电刺激设备
searchDevice();
//连接电刺激设备
connectTimer->start(1000);
this->show();
return true;
}
}
}
return false;
}
void FesControlDialog::queryDeviceState(uint8_t deviceNo)
{
QByteArray dataArray(4,0);
dataArray[0] = CMD_QUERY_STATE_E; //功能码
dataArray[1] = deviceNo; //设备编号0,搜索所有设备
dataArray[2] = 0; //通道号0,默认值
dataArray[3] = 0;
QByteArray sendArray = createFrame(dataArray);
sendData(sendArray);
}
void FesControlDialog::turnoffDevice(uint8_t deviceNo, uint8_t type)
{
QByteArray array(4,0);
array[0] = CMD_TURNOFF_E; //功能码
array[1] = deviceNo; //设备编号
array[2] = 0; //通道号0,默认值
array[3] = type; //数据0-关闭单个设备1-所有设备)
QByteArray sendArray = createFrame(array);
sendData(sendArray);
if(1 == deviceNo && 1 == type)
{
qDebug()<<"关闭所有设备";
}
}
void FesControlDialog::on_openSerial_Btn_clicked()
{
if(ui->openSerial_Btn->text() == "打开")
{
openSerialPort();
}
else if(ui->openSerial_Btn->text() == "关闭")
{
m_serialPort->close();
ui->openSerial_Btn->setText("打开");
//刷新串口
initSerialPort();
}
}
void FesControlDialog::on_scanDevice_Btn_clicked()
{
searchDevice();
}
void FesControlDialog::receiveDataInterface()
{
QByteArray buf;
buf = m_serialPort->readAll();
receiveArray.append(buf);
while(!receiveArray.isEmpty())
{
if(receiveArray[0] != (char)(0xAA))
{
receiveArray.remove(0,1);
}
else
{
//获取有效数据长度
uint8_t datalen = 0;
memcpy(&datalen,receiveArray.constData()+1,sizeof(uint8_t));
if(receiveArray.length() >= datalen + 4)
{
//校验成功
if((uint8_t)receiveArray[datalen+3] == 0x55)
{
analysisData(receiveArray);
receiveArray.remove(0,datalen + 4);
}
else //校验失败
{
//方式1 丢弃本包
receiveArray.remove(0,datalen + 4);
}
}
else //数据不够,直接退出继续接收
break;
}
}
}
void FesControlDialog::analysisData(QByteArray array)
{
uint8_t deviceNo = uint8_t(array[3]);
qDebug()<<"FES所有数据"<<array.toHex();
switch(array[2])
{
case CMD_QUERY_STATE_E:
{
//qDebug()<<"轮询:"<<array.toHex();
int temp_batteryValue = array[7];//电量
//temp_batteryValue = 50;
int temp_deviceNo = array[3];
if(temp_deviceNo <= 4)
// m_batteryValue[temp_deviceNo] = temp_batteryValue;
emit signalGetBattery(temp_deviceNo,temp_batteryValue);
//如果轮训,发现设备不在列表中,则删除
}
break;
case CMD_TURNOFF_E:
if(deviceNo <= 4)
deviceDtateArray[deviceNo-1] = 0;
qDebug()<<deviceNo<<"关机断开";
deviceObjectMap.value(deviceNo)->setDeviceState(false);
break;
case CMD_SEARCH_DEVICE_E:
{
qDebug()<<"搜索设备";
//qDebug()<<array.toHex();
}
break;
case CMD_DEVICE_REPORT_E:
{
//qDebug()<<"设备上报:"<<array.toHex();
QByteArray macArray = array.mid(5,6);
//更新连接界面列表
if(connectDevieMap.contains(macArray) && (!deviceList.contains(macArray)))
{
//填充自动连接设备列表
AutoFESDeviceMap.insert(connectDevieMap.value(macArray),macArray);
AutoFESDeviceControlStateMap.insert(connectDevieMap.value(macArray),false);
deviceList.append(macArray);
updateDeviceList();
}
}
break;
case CMD_DEVICE_CONNECT_E:
if(deviceObjectMap.contains(deviceNo))
{
if(deviceNo <= 4)
deviceDtateArray[deviceNo-1] = 1;
//for(int i=0; 1<4; i++)
// qDebug()<<"点击连接状态:"<<i<<deviceDtateArray[i];
AutoFESDeviceControlStateMap[deviceNo] = true;
deviceObjectMap.value(deviceNo)->setDeviceState(true);
}
break;
case CMD_DEVICE_DISCONNECT_E:
qDebug()<<deviceNo<<"断开";
if(deviceObjectMap.contains(deviceNo))
{
if(deviceNo <= 4)
deviceDtateArray[deviceNo-1] = 0;
AutoFESDeviceControlStateMap[deviceNo] = false;
deviceObjectMap.value(deviceNo)->setDeviceState(false);
/*
BLEItem *bleItem = new BLEItem(deviceNo-1);
bleItem->setBLEName(connectDevieMap.value(deviceList.at(deviceNo-1)));
QListWidgetItem *item =ui->listWidget->item(deviceNo-1);
//item->setSizeHint(QSize(100,65));
//ui->listWidget->addItem(item);
ui->listWidget->removeItemWidget(item);
ui->listWidget->takeItem(deviceNo-1);
delete item;
*/
/*
qDebug()<<"ui->listWidget->count()"<<ui->listWidget->count();
BLEItem *bleItem = new BLEItem(deviceNo-1);
bleItem->setBLEName(deviceNo); //BLeItem和命名
qDebug()<<"ui->listWidget->count()2"<<ui->listWidget->count();
for(int i = 0; i < ui->listWidget->count(); ++i) //编号
{
//QListWidgetItem *item =ui->listWidget->item(i);
QListWidgetItem *item =ui->listWidget->item(i);
// 获取与item关联的QWidget
QWidget *widget = ui->listWidget->itemWidget(item);
// 尝试将QWidget转换为BLEItem
BLEItem *tempBleItem = dynamic_cast<BLEItem*>(widget);
if(bleItem->getBLEName() == tempBleItem->getBLEName())
{
qDebug() <<"清除:"<< bleItem->getBLEName();
ui->listWidget->removeItemWidget(item);
delete tempBleItem;
delete item; // 从QListWidget中移除item*
//ui->listWidget->takeItem(i);
--i;
break;
}
}
*/
}
break;
}
}
//更新蓝牙设备列表
void FesControlDialog::updateDeviceList()
{
QStringList labelList;
for(int i = 0;i < deviceList.count();++i)
{
if(addedDeviceList.contains(deviceList.at(i)))
continue;
//在连接界面显示
//qDebug() <<"设备列表:"<<i<< deviceList[i];
BLEItem *bleItem = new BLEItem(i);
bleItem->setBLEName(connectDevieMap.value(deviceList.at(i)));
deviceObjectMap.insert(bleItem->getBLEName(),bleItem);
connect(bleItem,&BLEItem::signalConnectDevice,this,&FesControlDialog::slotConnectDevice);
connect(bleItem,&BLEItem::signalBtnStateChanged,this,&FesControlDialog::deviceStateChanged);
QListWidgetItem *item = new QListWidgetItem(ui->listWidget);
item->setSizeHint(QSize(100,65));
ui->listWidget->addItem(item);
ui->listWidget->setItemWidget(item,bleItem);
addedDeviceList.append(deviceList.at(i));
}
//qDebug() <<"deviceList.count():"<<deviceList.at(0).toInt()<<addedDeviceList.at(0).toInt();
}
QByteArray FesControlDialog::str2QByteArray(QString str)
{
QByteArray currentMac(6,0);
bool ok;
for(int i = 0;i < currentMac.size();++i)
{
currentMac[i] = str.mid(2*i,2).toInt(&ok,16);
}
return currentMac;
}
void FesControlDialog::sendData(QByteArray array)
{
if(m_serialPort && m_serialPort->isOpen())
m_serialPort->write(array);
//qDebug() <<"输出FES数据"<<array.toHex();
}
//查看界面列表
void FesControlDialog::on_listWidgetClicked(QListWidgetItem *item)
{
QString str = item->text();
QByteArray currentMac(6,0);
bool ok;
for(int i = 0;i < currentMac.size();++i)
{
currentMac[i] = str.mid(2*i,2).toInt(&ok,16);
}
currentMacDevice = currentMac;
}
void FesControlDialog::displayError(QSerialPort::SerialPortError error)
{
}
void FesControlDialog::slotConnectDevice(bool connect,uint8_t device)
{
QMapIterator<QByteArray, int> iter(connectDevieMap);
QByteArray devcieMac;
while (iter.hasNext()) {
iter.next();
if(iter.value() == device)
{
devcieMac = iter.key();
break;
}
}
QByteArray sendArray;
if(connect)
{
QByteArray array(3,0);
array[0] = CMD_DEVICE_CONNECT_E; //功能码
array[1] = device; //设备编号0,搜索所有设备
array[2] = 0; //通道号0,默认值
array.append(devcieMac);
sendArray = createFrame(array);
}
else
{
QByteArray array(4,0);
array[0] = CMD_TURNOFF_E; //功能码
array[1] = device; //设备编号
array[2] = 0; //通道号0,默认值
array[3] = 0; //数据0-关闭)
sendArray = createFrame(array);
setMuscleDeviceStateByNo(device,false); //已连接的肌肉设备更新
}
sendData(sendArray);
}
void FesControlDialog::showEvent(QShowEvent *event)
{
Q_UNUSED(event)
//查询数据库
connectDevieMap.clear();
QString query("select * from BLEDeviceMsg");
if(CDatabaseInterface::getInstance()->exec(query))
{
int tempNum = CDatabaseInterface::getInstance()->getValuesSize();
QList<QVariantMap> valueMapList;
valueMapList = CDatabaseInterface::getInstance()->getValues(0,tempNum);
for(int i = 0;i < valueMapList.count();++i)
{
ST_BLEDevice st_BLEDevice = variantMapToBLEDevice(valueMapList.at(i));
//填充设备Map
connectDevieMap.insert(str2QByteArray(st_BLEDevice.deviceMac),st_BLEDevice.deviceNo);
}
}
}
void FesControlDialog::on_queryDevice_Btn_clicked()
{
queryDeviceState(1);
}
void FesControlDialog::on_flushSerial_Btn_clicked()
{
initSerialPort();
}
void FesControlDialog::slotConnectFes()
{
QMapIterator<int,bool> iter(AutoFESDeviceControlStateMap);
int times = 1;
while (iter.hasNext()) {
iter.next();
if(!iter.value())
{
++times;
int deviceNo = iter.key();
QTimer::singleShot(100*times,this,[=](){
connectDevice(AutoFESDeviceMap.value(deviceNo),deviceNo);
});
break;
}
}
}
void FesControlDialog::deviceStateChanged(uint8_t deviceNo, bool state)
{
qDebug()<<"设备状态发生变化"<<deviceNo<<state;
QList<uint8_t> deviceStateList;
for(int i = 0;i < 4;++i)
{
qDebug()<<i<<deviceDtateArray[i];
deviceStateList.append(deviceDtateArray[i]);
//如果不存在item就移除item
}
emit signalDeviceStateChanged(deviceStateList);
}
void FesControlDialog::on_close_Btn_clicked()
{
this->close();
}
void FesControlDialog::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event)
QPainter painter(this);
painter.fillRect(rect(),QColor(0,0,0,100));
}
void FesControlDialog::changeEvent(QEvent *event)
{
switch (event->type())
{
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
QWidget::changeEvent(event);
break;
}
}

View File

@@ -0,0 +1,155 @@
#ifndef FESCONTROLDIALOG_H
#define FESCONTROLDIALOG_H
#include "dataformate.h"
#include <QDialog>
#include <QSerialPort>
#include <QListWidgetItem>
class BLEItem;
namespace Ui {
class FesControlDialog;
}
class FesControlDialog : public QDialog
{
Q_OBJECT
public:
static FesControlDialog *getInstance();
~FesControlDialog();
//预设电流控制开关
void setPreCurrentState(int device,int channel,bool state);
//预设电流控制大小
void setPreCurrent(int device,int channel,uint8_t current);
//预设置频率大小
void setPreFrequency(int device,int channel,int16_t current);
//预设值脉宽大小
void setPrePulseWidth(int device,int channel,int16_t current);
//设置参数FES踏车
void setFesParam(int device,int channel,ST_FESSetParam st_fesParam);
//实时参数
void setRealTimeParam(int device,ST_FESRealTimeParam);
//通道电刺激控制
void switchDeviceChannel(int device,int channel,bool on);
//单独电刺激
void setOnlyFesParam(int device,int channel,ST_OnlyFESParam);
//保存Fes页面设置的参数,便于发送
//void saveOnlyFesParam(ST_OnlyFESParam);
//保存Fes页面设置的参数
//void saveBicycleFesParam(ST_FESSetParam);
bool getDeviceStateByNo(uint8_t deviceNo);
//获取电量
//int getBatteryValue(uint8_t deviceNo);
//获取设备是否选择了肌肉
bool getMuscleDeviceStateByNo(uint8_t deviceNo);
//设置设备的肌肉连接
void setMuscleDeviceStateByNo(uint8_t deviceNo,bool flag);
//启动电刺激
bool openFESDevice();
//查询状态
void queryDeviceState(uint8_t deviceNo);
/******
* 说明:关闭电刺激模块
*@deviceNo 要关闭的设备号1~8
*@type 00-关闭某个设备 01-关闭所有设备
* ********/
void turnoffDevice(uint8_t deviceNo = 1,uint8_t type = 1);
private slots:
void on_openSerial_Btn_clicked();
void on_scanDevice_Btn_clicked();
void receiveDataInterface();
void displayError(QSerialPort::SerialPortError error);
void slotConnectDevice(bool connect,uint8_t device);
//查看界面列表
void on_listWidgetClicked(QListWidgetItem *item);
void on_queryDevice_Btn_clicked();
void on_flushSerial_Btn_clicked();
void slotConnectFes();
//设备状态发生变化
void deviceStateChanged(uint8_t deviceNo,bool state);
void on_close_Btn_clicked();
signals:
void signalDeviceStateChanged(QList<uint8_t>);
void signalGetBattery(int deviceNo,int batteryValue);
protected:
virtual void showEvent(QShowEvent *event);
void paintEvent(QPaintEvent *event);
virtual void changeEvent(QEvent* event);
private:
FesControlDialog(QWidget *parent = nullptr);
char getSum(QByteArray srcArray, int startIndex, int endIndex);
QByteArray createFrame(QByteArray dataBuffer);
bool initSerialPort();
//串口操作
void openSerialPort();
bool openSeriaport(ST_SerialPortConfig);
/***电刺激操作****/
//搜索设备
void searchDevice();
//链接设备
bool connectDevice(QByteArray mac,uint8_t deviceNum);
void analysisData(QByteArray array);
void updateDeviceList();
//数据转换
QByteArray str2QByteArray(QString str);
void sendData(QByteArray array);
private:
Ui::FesControlDialog *ui;
static FesControlDialog* instance;
QSerialPort *m_serialPort;
QByteArray receiveArray;
QList<QByteArray> deviceList;
QList<QByteArray> addedDeviceList;
uint8_t deviceConCount;
QByteArray currentMacDevice;
QMap<QByteArray,int> connectDevieMap; //数据库保存的设备列表
QMap<uint8_t,BLEItem *> deviceObjectMap;
//配置界面
uint8_t deviceDtateArray[4]; //设备状态
//已经选择肌肉的设备
uint8_t checkedMuscle_DeviceArray[4];
//通道改变时单独FES待发送的数据便于滑块发送频率和脉宽
ST_OnlyFESParam m_st_OnlyFESParam;
//通道改变时FES待发送的数据
ST_FESSetParam m_st_fesParam;
//从哪个页面发送来的参数
E_FES_PAGE E_fromFesType;
//uint8_t m_batteryValue[4]; //电池电量
//自动控制 设备号设备Mac连接状态
QMap<int,QByteArray> AutoFESDeviceMap;
QMap<int,bool> AutoFESDeviceControlStateMap;
QTimer *connectTimer;
};
#endif // FESCONTROLDIALOG_H

View File

@@ -0,0 +1,246 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>FesControlDialog</class>
<widget class="QDialog" name="FesControlDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1920</width>
<height>1080</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QGroupBox" name="groupBox_2">
<property name="geometry">
<rect>
<x>555</x>
<y>240</y>
<width>804</width>
<height>600</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">#groupBox_2{border:none;background-color:white;border-radius: 8px;}</string>
</property>
<property name="title">
<string/>
</property>
<widget class="QListWidget" name="listWidget">
<property name="geometry">
<rect>
<x>38</x>
<y>117</y>
<width>571</width>
<height>391</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">#listWidget{background:#E4F4FC;border:none;}</string>
</property>
</widget>
<widget class="QGroupBox" name="groupBox">
<property name="geometry">
<rect>
<x>628</x>
<y>120</y>
<width>151</width>
<height>391</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">border:none;</string>
</property>
<property name="title">
<string/>
</property>
<widget class="QComboBox" name="serial_ComboBox">
<property name="geometry">
<rect>
<x>10</x>
<y>0</y>
<width>131</width>
<height>40</height>
</rect>
</property>
<property name="font">
<font>
<family>微软雅黑</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">background: #05A6EC;
border-radius: 4px;
color:white;</string>
</property>
</widget>
<widget class="QPushButton" name="scanDevice_Btn">
<property name="geometry">
<rect>
<x>10</x>
<y>190</y>
<width>131</width>
<height>40</height>
</rect>
</property>
<property name="font">
<font>
<family>微软雅黑</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">background: #05A6EC;
border-radius: 4px;
color:white;</string>
</property>
<property name="text">
<string>扫描</string>
</property>
</widget>
<widget class="QPushButton" name="queryDevice_Btn">
<property name="geometry">
<rect>
<x>10</x>
<y>250</y>
<width>131</width>
<height>40</height>
</rect>
</property>
<property name="font">
<font>
<family>微软雅黑</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">background: #05A6EC;
border-radius: 4px;
color:white;</string>
</property>
<property name="text">
<string>查询</string>
</property>
</widget>
<widget class="QPushButton" name="flushSerial_Btn">
<property name="geometry">
<rect>
<x>10</x>
<y>60</y>
<width>131</width>
<height>40</height>
</rect>
</property>
<property name="font">
<font>
<family>微软雅黑</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">background: #05A6EC;
border-radius: 4px;
color:white;</string>
</property>
<property name="text">
<string>刷新</string>
</property>
</widget>
<widget class="QPushButton" name="openSerial_Btn">
<property name="geometry">
<rect>
<x>10</x>
<y>130</y>
<width>131</width>
<height>40</height>
</rect>
</property>
<property name="font">
<font>
<family>微软雅黑</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">background: #05A6EC;
border-radius: 4px;
color:white;</string>
</property>
<property name="text">
<string>打开</string>
</property>
</widget>
</widget>
<widget class="QPushButton" name="close_Btn">
<property name="geometry">
<rect>
<x>0</x>
<y>549</y>
<width>804</width>
<height>51</height>
</rect>
</property>
<property name="font">
<font>
<family>微软雅黑</family>
<pointsize>13</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">background: #05A6EC;
border-radius: 4px;
color:white;</string>
</property>
<property name="text">
<string>关闭</string>
</property>
</widget>
<widget class="QGroupBox" name="groupBox_3">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>804</width>
<height>60</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">background: #DDECFC;
border:none;
border-top-left-radius: 8px;border-top-right-radius:8px;
</string>
</property>
<property name="title">
<string/>
</property>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>200</x>
<y>10</y>
<width>371</width>
<height>41</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>电刺激控制</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</widget>
</widget>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -0,0 +1,99 @@
#include "icemodule.h"
#include <qDebug>
IceModule *IceModule::m_IceModule = NULL;
IceModule::IceModule(QObject *parent)
: QObject{parent},
isBicycleConnected(true),
isEmergency(false),
m_power(0)
{
for(int i=0; i<8; i++)
maxCurrentData[i] = 0;
}
IceModule *IceModule::getInstance()
{
if(!m_IceModule)
m_IceModule = new IceModule();
return m_IceModule;
}
void IceModule::setFesAParam(int *data,int size)
{
emit signalSetFesAParam(data,size);
}
void IceModule::setFesBParam(int *data,int size)
{
emit signalSetFesBParam(data,size);
}
void IceModule::setBicycleParam(ST_BicycleParam st_setBicycleParam)
{
emit signalSetBicycleParam(st_setBicycleParam);
}
void IceModule::setBicycleDeviceState(bool isConnected)
{
isBicycleConnected = isConnected;
}
bool IceModule::getBicycleDeviceState()
{
return isBicycleConnected;
}
//设置痉挛状态
void IceModule::setEmergencyState(bool isEnabled)
{
isEmergency = isEnabled;
}
//获取痉挛状态
bool IceModule::getEmergencyState()
{
return isEmergency;
}
void IceModule::setPower(int8_t power)
{
m_power = power;
}
int8_t IceModule::getPower()
{
return m_power;
}
void IceModule::setVersion(QString version)
{
m_version = version;
}
QString IceModule::getVersion()
{
return m_version;
}
void IceModule::setGameType(int8_t type)
{
m_gameType = type;
qDebug()<<"游戏类型:"<<type;
}
int8_t IceModule::getGameType()
{
return m_gameType;
}
void IceModule::setMaxCurrentValue(int index,int value)
{
maxCurrentData[index] = value;
}
void IceModule::setMaxFESAParam()
{
for(int i=0; i<8; i++)
qDebug() <<"电流"<< maxCurrentData[i];
setFesBParam(maxCurrentData,8);
}

View File

@@ -0,0 +1,58 @@
#ifndef ICEMODULE_H
#define ICEMODULE_H
#include <QObject>
#include "dataformate.h"
class IceModule : public QObject
{
Q_OBJECT
public:
static IceModule *getInstance();
/****设置游戏界面(GameDisplayPage)显示参数****/
void setFesAParam(int *data,int size);
void setFesBParam(int *data,int size);
void setBicycleParam(ST_BicycleParam);
//设置下位机连状态
void setBicycleDeviceState(bool isConnected);
//获取下位机连接状态
bool getBicycleDeviceState();
//设置痉挛状态
void setEmergencyState(bool);
//获取痉挛状态
bool getEmergencyState();
//配置功率
void setPower(int8_t power);
int8_t getPower();
//软件版本号
void setVersion(QString version);
QString getVersion();
void setGameType(int8_t type);
int8_t getGameType();
//设置最大电量
void setMaxCurrentValue(int index,int value);
//发送FES最大电流数据
void setMaxFESAParam();
signals:
void signalSetFesAParam(int *data,int size);
void signalSetFesBParam(int *data,int size);
void signalSetBicycleParam(ST_BicycleParam);
private:
explicit IceModule(QObject *parent = nullptr);
static IceModule *m_IceModule;
bool isBicycleConnected;
bool isEmergency;
int8_t m_power;
QString m_version;
int8_t m_gameType; //1-单独踏车 2-FES踏车
int maxCurrentData[8]; //最大电流
};
#endif // ICEMODULE_H

View File

@@ -0,0 +1,63 @@
#include "languagemanager.h"
#include <QSettings>
#include <QDir>
#include <QApplication>
LanguageManager *LanguageManager::m_languageManager = NULL;
LanguageManager::LanguageManager(QObject *parent)
: QObject{parent}
{
m_translator = new QTranslator(this);
getConfigLanguage();
}
LanguageManager *LanguageManager::getInstance()
{
if(!m_languageManager)
m_languageManager = new LanguageManager();
return m_languageManager;
}
void LanguageManager::setCurrentLanguage(E_LANGUAGE language)
{
switch(language)
{
case English_E:
if(m_translator->load("./UpLowLimp_EN.qm"))
qApp->installTranslator(m_translator);
break;
case Chinese_E:
if(m_translator->load("./UpLowLimp_CN.qm"))
qApp->installTranslator(m_translator);
break;
}
m_language = language;
// emit signalLanguageChanged(m_language);
QString dirPath = QApplication::applicationDirPath() + "/conf/";
QDir confdir(dirPath);
if(!confdir.exists())
confdir.mkdir(dirPath);
QString confFile(dirPath + "IDconf.ini");
QSettings iniSetting(confFile, QSettings::IniFormat);
iniSetting.setValue("language",language);
}
E_LANGUAGE LanguageManager::getCurrentLanguage()
{
return m_language;
}
E_LANGUAGE LanguageManager::getConfigLanguage()
{
QString dirPath = QApplication::applicationDirPath() + "/conf/";
QDir confdir(dirPath);
if(!confdir.exists())
confdir.mkdir(dirPath);
QString confFile(dirPath + "IDconf.ini");
QSettings iniSetting(confFile, QSettings::IniFormat);
int value = iniSetting.value("language").toUInt();
m_language = E_LANGUAGE(value);
return m_language;
}

View File

@@ -0,0 +1,27 @@
#ifndef LANGUAGEMANAGER_H
#define LANGUAGEMANAGER_H
#include "dataformate.h"
#include <QObject>
#include <QTranslator>
class LanguageManager : public QObject
{
Q_OBJECT
public:
static LanguageManager *getInstance();
void setCurrentLanguage(E_LANGUAGE);
E_LANGUAGE getCurrentLanguage();
E_LANGUAGE getConfigLanguage();
signals:
void signalLanguageChanged(E_LANGUAGE);
private:
explicit LanguageManager(QObject *parent = nullptr);
static LanguageManager *m_languageManager;
E_LANGUAGE m_language;
QTranslator *m_translator;
};
#endif // LANGUAGEMANAGER_H

View File

@@ -0,0 +1,301 @@
#include "cmainwindow.h"
#include "ui_cmainwindow.h"
#include "mainwindowpagecontrol.h"
#include "currentuserdata.h"
#include <QDebug>
#include <QTimer>
#include <windows.h>
#include <QHBoxLayout>
#include <QProcess>
#include "gamecontrol.h"
#include "fescontroldialog.h"
CMainWindow::CMainWindow(QWidget *parent) :
QWidget(parent),
ui(new Ui::CMainWindow),
m_gameDisplayPage(NULL),
gamedialog(NULL),
grabWindowTimer(NULL)
{
ui->setupUi(this);
ui->title_Widget->hide();
ui->stackedWidget->setGeometry(0,0,1920,1080);
this->setWindowFlags(Qt::FramelessWindowHint); //设置无边框
qRegisterMetaType<E_PAGENAME>("E_PAGENAME");
connect(MainWindowPageControl::getInstance(),SIGNAL(signalSwitchPage(E_PAGENAME)),this,SLOT(slotSwitchPage(E_PAGENAME)));
connect(CurrentUserData::getInstace(),SIGNAL(signalUserChanged()),this,SLOT(slotCurrentUserChanged()));
//默认为主界面
// setAttribute(Qt::WA_DeleteOnClose,false);
ui->stackedWidget->setCurrentIndex(0);
m_gameDisplayPage = new GameDisplayPage();
connect(m_gameDisplayPage,SIGNAL(signalGameStateChanged(int8_t)),this,SLOT(slotGameStateChanged(int8_t)));
m_Process = new QProcess();
connect(ui->title_Widget,SIGNAL(signalCloseWindow()),this,SLOT(closeWindow()));
gamedialog = new QDialog;
m_loginWidget = new LoginWidget();
gamedialog->stackUnder(m_gameDisplayPage);
grabWindowTimer = new QTimer();
connect(grabWindowTimer,SIGNAL(timeout()),this,SLOT(slotGrabWindow()));
connect(ui->FES_Page,SIGNAL(signalStartGame()),ui->FESCar_Page,SLOT(slotStartGame()));
//从参数界面传递到训练界面
connect(ui->trainParam_Page,&TrainingParamSetting::signalTrainParamChanged,ui->FESCar_Page,&ArmOrLeg::slotRecvTrainParamChanged);
//训练页面发消息让tittle页面保存截图
connect(ui->FESCar_Page,&ArmOrLeg::saveUpPictureSignal,ui->title_Widget,&TitleWidget::slotSaveUpPicture);
//从训练界面传递到参数界面
connect(ui->FESCar_Page,&ArmOrLeg::signalBicycleParamChanged,ui->trainParam_Page,&TrainingParamSetting::slotBicycleParamChanged);
//训练界面打开,跟新游戏配置默认参数
connect(ui->Main_Page,&TrainManager::signalOpenTrainManagerPage,ui->trainParam_Page,&TrainingParamSetting::slotResetParam);
// connect(m_loginWidget,SIGNAL(signalCloseApp),this,SLOT(closeWindow()));
}
CMainWindow::~CMainWindow()
{
if(gamedialog)
delete gamedialog;
if(m_gameDisplayPage)
delete m_gameDisplayPage;
if(grabWindowTimer)
delete grabWindowTimer;
delete ui;
}
void CMainWindow::switchPage(E_PAGENAME E_Page)
{
switch(E_Page)
{
case MainPage_E:
gamedialog->close();
ui->stackedWidget->setGeometry(0,0,1920,1080);
ui->stackedWidget->setCurrentWidget(ui->Main_Page);
ui->title_Widget->hide();
qDebug() <<"来到了主页";
emit ui->Main_Page->signalOpenTrainManagerPage();
break;
case TrainingPage_E://游戏训练界面
// ui->stackedWidget->setCurrentWidget(ui->game_Page);
startGame_Btn_clicked();
// QTimer::singleShot(1000,this,SLOT(slot_Timerout()));//同上,就是参数不同
break;
case UserPage_E:
ui->stackedWidget->setGeometry(0,100,1920,980);
ui->stackedWidget->setCurrentWidget(ui->userMsg_Page);
ui->title_Widget->show();
break;
case SettingPage_E:
ui->stackedWidget->setGeometry(0,100,1920,980);
ui->stackedWidget->setCurrentWidget(ui->setting_Page);
ui->title_Widget->show();
break;
case BicycleParamSet_E:
ui->stackedWidget->setGeometry(0,100,1920,980);
//qDebug() <<"普通单车";
ui->FESCar_Page->setTrainType(0);
ui->title_Widget->setTrainType(0);
ui->trainParam_Page->setTrainType(0);
ui->stackedWidget->setCurrentWidget(ui->FESCar_Page);
ui->title_Widget->show();
break;
case FesBicycleParamSet_E:
ui->stackedWidget->setGeometry(0,100,1920,980);
//qDebug() <<"FES单车";
ui->FESCar_Page->setTrainType(1);
ui->title_Widget->setTrainType(1);
ui->trainParam_Page->setTrainType(1);
ui->stackedWidget->setCurrentWidget(ui->FESCar_Page);
ui->title_Widget->show();
break;
case FesParamSet_E:
ui->stackedWidget->setGeometry(0,100,1920,980);
ui->title_Widget->setTrainType(0);
ui->FES_Page->switchPage(ONLY_FES_E);
ui->stackedWidget->setCurrentWidget(ui->FES_Page);
ui->title_Widget->show();
break;
case BicycleToFes_E:
ui->stackedWidget->setGeometry(0,100,1920,980);
ui->FES_Page->switchPage(BICYCLE_FES_E);
ui->stackedWidget->setCurrentWidget(ui->FES_Page);
ui->title_Widget->show();
break;
case TrainingParamSetting_E: //训练参数设置页
ui->stackedWidget->setGeometry(0,100,1920,980);
ui->stackedWidget->setCurrentWidget(ui->trainParam_Page);
ui->title_Widget->show();
break;
case BrainTraining: //训练参数设置页
ui->stackedWidget->setGeometry(0,100,1920,980);
ui->stackedWidget->setCurrentWidget(ui->Brain_Page);
ui->title_Widget->show();
break;
case visionTrain: //训练参数设置页
ui->stackedWidget->setGeometry(0,100,1920,980);
ui->stackedWidget->setCurrentWidget(ui->Vision_Page);
ui->title_Widget->show();
break;
default:
break;
}
}
void CMainWindow::slotSwitchPage(E_PAGENAME page)
{
switchPage(page);
ui->title_Widget->setTitleByPage(page);
}
void CMainWindow::slotCurrentUserChanged()
{
ui->title_Widget->setUser(CurrentUserData::getInstace()->getCurrentPatientMsg());
}
void CMainWindow::startGame_Btn_clicked()
{
connect(m_Process,&QProcess::errorOccurred,[=](QProcess::ProcessError error){qDebug()<<error;});
// connect(m_Process,QOverload<int,QProcess::ExitStatus>::of(&QProcess::finished),[this]
// (int exitCode,QProcess::ExitStatus exitStatus){
// m_exitCode = exitCode;
// m_exitStatus = exitStatus;
// qDebug()<<"m_exitCode"<<m_exitCode<<"m_exitStatus"<<m_exitStatus;
// });
QString destPath = GameControl::getInstance()->getCurrentGameMsg().gamePath + GameControl::getInstance()->getCurrentGameMsg().gameName;
startGame(destPath);
grabWindowTimer->start(300);
}
void CMainWindow::slotGrabWindow()
{
WId hwnd = 0;
if(1 == GameControl::getInstance()->getCurrentGameMsg().gameID)
hwnd = (WId)FindWindow(L"UnityWndClass",L"TJ_SXZ001_SingleplayerBicycleRace");
else if(2 == GameControl::getInstance()->getCurrentGameMsg().gameID)
hwnd = (WId)FindWindow(L"UnityWndClass",L"TJ_SXZ002_MultiplayerBicycleRace_LBY");
else if(3 == GameControl::getInstance()->getCurrentGameMsg().gameID)
hwnd = (WId)FindWindow(L"UnityWndClass",L"TJ_SXZ003_MultiplayerRaceSciFi");
else if(4 == GameControl::getInstance()->getCurrentGameMsg().gameID)
hwnd = (WId)FindWindow(L"UnityWndClass",L"TJ_SXZ004_CatchFish");
if(IsHungAppWindow(HWND(hwnd)))
{
qDebug()<<"正在运行";
}
if(hwnd > 0)
{
grabWindowTimer->stop();
m_window = QWindow::fromWinId(hwnd);
container = createWindowContainer(m_window,this);
gamedialog->setWindowFlags(Qt::FramelessWindowHint);
QGridLayout *hLayout = new QGridLayout(this);
hLayout->setMargin(0);
hLayout->addWidget(container);
if(gamedialog->layout() != NULL)
delete gamedialog->layout();
gamedialog->setLayout(hLayout);
gamedialog->show();
gamedialog->resize(1920,980);
gamedialog->move(0,100);
// m_gameDisplayPage->show();
}
}
void CMainWindow::slotGameStateChanged(int8_t state)
{
switch(state)
{
case 0: //停止游戏
{
m_gameDisplayPage->close();
gamedialog->close();
slotSwitchPage(MainPage_E);
}
break;
case 1: //开始游戏
m_gameDisplayPage->show();
break;
}
}
void CMainWindow::closeWindow()
{
//关闭所有设备
qDebug()<<"运行了";
FesControlDialog::getInstance()->turnoffDevice(1,1);
this->close();
}
void CMainWindow::startGame(QString path)
{
//1.开启游戏进程
if(path.isEmpty())
return;
QString hardDisk = path.mid(0,2);
hardDisk.append("\n\r");
QString gameName = path.mid(path.lastIndexOf('/')+1);
gameName.prepend("start ");
gameName.append("\n\r");
QString gamePath = path.mid(0,path.lastIndexOf('/'));
gamePath.prepend("cd ");
gamePath.append("\n\r");
m_Process->start("cmd.exe");
//切换盘符
m_Process->write(hardDisk.toLatin1());
//进入文件夹
m_Process->write(gamePath.toLatin1());
//开启进程
m_Process->write(gameName.toLatin1());
m_Process->write("exit\n\r");
m_Process->waitForFinished();
m_Process->close();
//2.关闭设备复位中的界面
}
void CMainWindow::slot_Timerout()
{
// m_gameDisplayPage->show();
}
void CMainWindow::showEvent(QShowEvent *event)
{
Q_UNUSED(event)
signalShowCompleted();
}
void CMainWindow::changeEvent(QEvent* event)
{
switch (event->type())
{
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
QWidget::changeEvent(event);
break;
}
}

View File

@@ -0,0 +1,66 @@
#ifndef CMAINWINDOW_H
#define CMAINWINDOW_H
#include <QWidget>
#include "dataformate.h"
#include "loginwidget.h"
//#include "fessetting.h"
#include "gamedisplaypage.h"
#include <QProcess>
#include <QWindow>
#include "loginwidget.h"
class QProcess;
namespace Ui {
class CMainWindow;
}
class CMainWindow : public QWidget
{
Q_OBJECT
public:
explicit CMainWindow(QWidget *parent = nullptr);
~CMainWindow();
public slots:
void slotSwitchPage(E_PAGENAME);
void slot_Timerout();
protected:
void showEvent(QShowEvent *event);
virtual void changeEvent(QEvent* event);
signals:
void signalShowCompleted();
private slots:
void slotCurrentUserChanged();
void startGame_Btn_clicked();
void slotGameStateChanged(int8_t state);
void closeWindow();
void slotGrabWindow();
private:
void switchPage(E_PAGENAME);
void startGame(QString path);
private:
Ui::CMainWindow *ui;
LoginWidget *loginDialog;
// QProcess *process;
int m_exitCode;
QProcess::ExitStatus m_exitStatus;
QWindow *m_window;
GameDisplayPage *m_gameDisplayPage;
QProcess* m_Process;
QWidget *container;
QDialog *gamedialog;
QTimer *grabWindowTimer;
LoginWidget *m_loginWidget;
};
#endif // CMAINWINDOW_H

View File

@@ -0,0 +1,136 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CMainWindow</class>
<widget class="QWidget" name="CMainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1920</width>
<height>1080</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<widget class="TitleWidget" name="title_Widget" native="true">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1920</width>
<height>100</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
</widget>
<widget class="QStackedWidget" name="stackedWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>100</y>
<width>1920</width>
<height>980</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="currentIndex">
<number>1</number>
</property>
<widget class="TrainManager" name="Main_Page">
<property name="styleSheet">
<string notr="true">background-color:transparent;</string>
</property>
</widget>
<widget class="eyeTrainWidget" name="Vision_Page"/>
<widget class="brainTrain" name="Brain_Page"/>
<widget class="ArmOrLeg" name="FESCar_Page"/>
<widget class="FesSetting" name="FES_Page"/>
<widget class="SettingWidget" name="setting_Page"/>
<widget class="UserManager" name="userMsg_Page"/>
<widget class="QWidget" name="login_Page"/>
<widget class="QWidget" name="game_Page">
<widget class="QWidget" name="game_widget" native="true">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1921</width>
<height>980</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">border-image: url(:/DependFile/Image/background1.png);
</string>
</property>
</widget>
</widget>
<widget class="TrainingParamSetting" name="trainParam_Page"/>
</widget>
</widget>
<customwidgets>
<customwidget>
<class>TitleWidget</class>
<extends>QWidget</extends>
<header>titlewidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>UserManager</class>
<extends>QWidget</extends>
<header>usermanager.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>SettingWidget</class>
<extends>QWidget</extends>
<header>settingwidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>TrainManager</class>
<extends>QWidget</extends>
<header>trainmanager.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>FesSetting</class>
<extends>QWidget</extends>
<header>fessetting.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ArmOrLeg</class>
<extends>QWidget</extends>
<header>armorleg.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>TrainingParamSetting</class>
<extends>QWidget</extends>
<header>trainingparamsetting.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>brainTrain</class>
<extends>QWidget</extends>
<header>braintrain.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>eyeTrainWidget</class>
<extends>QWidget</extends>
<header>eyetrainwidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@@ -0,0 +1,254 @@
#include "loginwidget.h"
#include "ui_loginwidget.h"
#include <QSettings>
#include <QDir>
#include "passworddialog.h"
#include "dataformate.h"
#include <QDebug>
#include <QProcess>
#include "fescontroldialog.h"
#include "cmainwindow.h"
#include "languagemanager.h"
LoginWidget::LoginWidget(QDialog *parent) :
QDialog(parent),
ui(new Ui::LoginWidget),
passworldDialog(nullptr)
{
//PC版默认密码111111TV版默认密码666666
ui->setupUi(this);
setWindowFlags(Qt::FramelessWindowHint);
//设置为模态对话框
// setModal(true);
connect(this,&LoginWidget::signalResult,this,&LoginWidget::done);
// setAttribute(Qt::WA_DeleteOnClose,true);
ui->userNameTips_Label->setVisible(false);
ui->passwordTips_Label->setVisible(false);
passworldDialog = new PasswordDialog();
m_shutdownDialog = new ShutdeonDialog();
ui->password_LineEdit->setEchoMode(QLineEdit::Password);
// ui->password_LineEdit->setEchoMode(QLineEdit::PasswordEchoOnEdit);
ui->remember_RadioButton->setChecked(true);
QString dirPath = "./DependFile/conf/";
QDir confdir(dirPath);
if(!confdir.exists())
confdir.mkdir(dirPath);
QString confFile(dirPath + "remberIDconf.ini");
QSettings iniSetting(confFile, QSettings::IniFormat);
QString password = iniSetting.value("password").toString();
QString userName = iniSetting.value("userName").toString();
ui->userName_LineEdit->setText(userName);
ui->password_LineEdit->setText(password);
ui->forgetPasswordTips_Label->setVisible(false);
m_timer = new QTimer(this);
m_bleItem = new BLEItem();
connect(m_timer,SIGNAL(timeout()),this,SLOT(slotCleanTimes()));
// qDebug()<<"password"<< ui->userName_LineEdit->text()<<ui->password_LineEdit->text();
// connect(this,SIGNAL(signalCloseApp(),FesControlDialog::getInstance(),FesControlDialog::getInstance()->);
/*
#ifdef NORMALEXE
ui->label_2->setStyleSheet("border-image: url(:/DependFile/Source/login/upDown_limp.jpg);");
#endif
*/
#ifdef ONLYUPLIMP
ui->label_2->setStyleSheet("border-image: url(:/DependFile/Source/login/upLimp.png);");
#endif
#ifdef ONLYDOWNLIMP
ui->label_2->setStyleSheet("border-image: url(:/DependFile/Source/login/downLimp.png);");
#endif
}
LoginWidget::~LoginWidget()
{
if(passworldDialog)
delete passworldDialog;
if(m_shutdownDialog)
delete m_shutdownDialog;
if(m_bleItem)
delete m_bleItem;
delete ui;
}
void LoginWidget::slotShowCompleted()
{
this->close();
}
void LoginWidget::slotCleanTimes()
{
m_clockTime = 0;
}
void LoginWidget::on_forgetPassword_Btn_clicked()
{
//弹出提示框,告知获取密码的方式
ui->forgetPasswordTips_Label->setText(tr("请联系管理员获取初始密码"));
ui->forgetPasswordTips_Label->setVisible(true);
}
void LoginWidget::on_confirm_Btn_clicked()
{
QString dirPath = "./DependFile/conf/";
QDir confdir(dirPath);
if(!confdir.exists())
confdir.mkdir(dirPath);
QString confFile(dirPath + "IDconf.ini");
QSettings iniSetting(confFile, QSettings::IniFormat);
QString password = iniSetting.value("password").toString();
QString userName = iniSetting.value("userName").toString();
qDebug()<<userName<<password;
QString rememberConfFile(dirPath + "remberIDconf.ini");
QSettings remIniSetting(confFile, QSettings::IniFormat);
QString remPassword = iniSetting.value("password").toString();
QString remUserName = iniSetting.value("userName").toString();
if(ui->userName_LineEdit->text() != userName)
{
ui->userNameTips_Label->setVisible(true);
ui->userNameTips_Label->setText(tr("用户名输入错误"));
return;
}
if(ui->password_LineEdit->text() != password)
{
ui->passwordTips_Label->setVisible(true);
ui->passwordTips_Label->setText(tr("密码输入错误"));
return;
}
//设置返回值结果
emit signalResult(1);
if(ui->remember_RadioButton->isChecked())
{
QString confFile(dirPath + "remberIDconf.ini");
QSettings iniSetting(confFile, QSettings::IniFormat);
iniSetting.setValue("password",ui->password_LineEdit->text());
iniSetting.setValue("userName",ui->userName_LineEdit->text());
}
}
void LoginWidget::on_userName_LineEdit_textChanged(const QString &arg1)
{
Q_UNUSED(arg1)
ui->userNameTips_Label->setVisible(false);
ui->forgetPasswordTips_Label->setVisible(false);
}
void LoginWidget::on_password_LineEdit_textChanged(const QString &arg1)
{
Q_UNUSED(arg1)
ui->passwordTips_Label->setVisible(false);
ui->forgetPasswordTips_Label->setVisible(false);
}
void LoginWidget::changeEvent(QEvent* event)
{
switch (event->type())
{
case QEvent::LanguageChange:
{
ui->retranslateUi(this);
}
break;
default:
QWidget::changeEvent(event);
break;
}
m_clockTime = 0;
}
void LoginWidget::showEvent(QShowEvent *event)
{
Q_UNUSED(event)
E_LANGUAGE language = LanguageManager::getInstance()->getCurrentLanguage();
if(language == Chinese_E)
{
ui->company_Label->setStyleSheet("border-image: url(:/DependFile/Source/login/company.png);");
QFont font;
font.setFamily("黑体");
font.setPointSize(18);
ui->productionName_Label->setFont(font);
}
//
else if(language == English_E)
{
ui->company_Label->setStyleSheet("border-image: url(:/DependFile/Source/login/company_En.png);");
//
QFont font;
font.setFamily("Arial");
font.setPointSize(18);
ui->productionName_Label->setFont(font);
}
}
void LoginWidget::on_pushButton_clicked()
{
m_shutdownDialog->exec(); //关闭窗口
qDebug()<<"关机值:"<< m_shutdownDialog->getResult();
if(m_shutdownDialog->getResult() == 0)
return;
else
{
FesControlDialog::getInstance()->turnoffDevice(1,1);
Sleep(100);
// FesControlDialog::getInstance()->turnoffDevice(1,1);
QCoreApplication::quit(); //关闭程序
Sleep(3500); //睡眠
}
// emit signalCloseWindow();
/*
QString program = "C:/WINDOWS/system32/shutdown.exe";
QStringList arguments;
arguments << "-s";
QProcess *myProcess = new QProcess();
myProcess->start(program,arguments);
*/
system("shutdown -s -t 00");
}
void LoginWidget::on_company_Label_clicked()
{
m_clockTime++;
if(m_clockTime == 1)
m_timer->start(5000);
qDebug()<<m_clockTime;
if(m_clockTime == 10)
{
//m_bleItem->setDeviceState(false);
FesControlDialog::getInstance()->turnoffDevice(1,1);
Sleep(100);
// emit signalCloseApp();
//FesControlDialog::getInstance()->turnoffDevice(1,1);
QApplication *app;
app->exit(0);
this->close();
//关闭所有设备
//FesControlDialog::getInstance()->turnoffDevice(1,1);
//emit signalCloseApp();
}
}

View File

@@ -0,0 +1,57 @@
#ifndef LOGINWIDGET_H
#define LOGINWIDGET_H
#include <QDialog>
#include <QTimer>
#include "shutdeondialog.h"
#include "BLEItem.h"
class PasswordDialog;
namespace Ui {
class LoginWidget;
}
class LoginWidget : public QDialog
{
Q_OBJECT
public:
explicit LoginWidget(QDialog *parent = nullptr);
~LoginWidget();
signals:
void signalResult(int);
signals:
void signalCloseApp();
void signalCloseWindow();
protected:
virtual void changeEvent(QEvent* event);
virtual void showEvent(QShowEvent *event);
public slots:
void slotShowCompleted();
void slotCleanTimes();
private slots:
void on_forgetPassword_Btn_clicked();
void on_confirm_Btn_clicked();
void on_userName_LineEdit_textChanged(const QString &arg1);
void on_password_LineEdit_textChanged(const QString &arg1);
void on_pushButton_clicked();
void on_company_Label_clicked();
private:
Ui::LoginWidget *ui;
PasswordDialog *passworldDialog;
ShutdeonDialog *m_shutdownDialog;
QTimer *m_timer;
int m_clockTime;
BLEItem *m_bleItem;
};
#endif // LOGINWIDGET_H

View File

@@ -0,0 +1,433 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>LoginWidget</class>
<widget class="QWidget" name="LoginWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1920</width>
<height>1080</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<widget class="QGroupBox" name="groupBox">
<property name="geometry">
<rect>
<x>110</x>
<y>110</y>
<width>1700</width>
<height>860</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">#groupBox{background: #F7F7F7;
border-radius: 20px;
}</string>
</property>
<property name="title">
<string/>
</property>
<widget class="QGroupBox" name="groupBox_2">
<property name="geometry">
<rect>
<x>810</x>
<y>0</y>
<width>850</width>
<height>1020</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">#groupBox_2{background:#F7F7F7;
border-radius: 20px;}</string>
</property>
<property name="title">
<string/>
</property>
<widget class="QPushButton" name="confirm_Btn">
<property name="geometry">
<rect>
<x>95</x>
<y>650</y>
<width>670</width>
<height>100</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>25</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">background: #07A8E7;
border-radius: 45px;
color:white;</string>
</property>
<property name="text">
<string>确认</string>
</property>
</widget>
<widget class="QLabel" name="passwordTips_Label">
<property name="geometry">
<rect>
<x>140</x>
<y>470</y>
<width>171</width>
<height>40</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">color:#F47E4B;</string>
</property>
<property name="text">
<string>密码输入错误</string>
</property>
</widget>
<widget class="QRadioButton" name="remember_RadioButton">
<property name="geometry">
<rect>
<x>480</x>
<y>530</y>
<width>391</width>
<height>71</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>20</pointsize>
</font>
</property>
<property name="text">
<string>记住密码</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
<widget class="QPushButton" name="forgetPassword_Btn">
<property name="geometry">
<rect>
<x>100</x>
<y>528</y>
<width>301</width>
<height>71</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>20</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">border:none;</string>
</property>
<property name="text">
<string>忘记密码</string>
</property>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>335</x>
<y>110</y>
<width>231</width>
<height>71</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>35</pointsize>
</font>
</property>
<property name="text">
<string>登录</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="userNameTips_Label">
<property name="geometry">
<rect>
<x>140</x>
<y>320</y>
<width>171</width>
<height>40</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">color:#F47E4B;</string>
</property>
<property name="text">
<string>用户名输入错误</string>
</property>
</widget>
<widget class="QGroupBox" name="groupBox_3">
<property name="geometry">
<rect>
<x>95</x>
<y>230</y>
<width>670</width>
<height>90</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">#groupBox_3{border-radius: 45px;
background:white;}</string>
</property>
<property name="title">
<string/>
</property>
<widget class="QLineEdit" name="userName_LineEdit">
<property name="geometry">
<rect>
<x>90</x>
<y>12</y>
<width>501</width>
<height>61</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>35</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">border:none;</string>
</property>
<property name="text">
<string>xyyl</string>
</property>
<property name="placeholderText">
<string>请输入用户名</string>
</property>
</widget>
</widget>
<widget class="QGroupBox" name="groupBox_4">
<property name="geometry">
<rect>
<x>95</x>
<y>380</y>
<width>670</width>
<height>90</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">#groupBox_4{border-radius: 45px;
background:white;}</string>
</property>
<property name="title">
<string/>
</property>
<widget class="QLineEdit" name="password_LineEdit">
<property name="geometry">
<rect>
<x>70</x>
<y>6</y>
<width>561</width>
<height>80</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>28</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">border:none;
color:#999999 ;</string>
</property>
<property name="text">
<string>666666</string>
</property>
<property name="placeholderText">
<string>请输入密码</string>
</property>
</widget>
</widget>
<widget class="QLabel" name="forgetPasswordTips_Label">
<property name="geometry">
<rect>
<x>120</x>
<y>600</y>
<width>711</width>
<height>40</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">color:#F47E4B;</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</widget>
<widget class="QGroupBox" name="groupBox_5">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>810</width>
<height>860</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">#groupBox_5{
background: #FFFFFF;
border-radius: 20px;}</string>
</property>
<property name="title">
<string/>
</property>
<widget class="QLabel" name="productionName_Label">
<property name="geometry">
<rect>
<x>89</x>
<y>730</y>
<width>621</width>
<height>100</height>
</rect>
</property>
<property name="font">
<font>
<family>Arial</family>
<pointsize>18</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>上下肢主被动康复训练仪</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>230</x>
<y>140</y>
<width>401</width>
<height>507</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">border-image: url(:/DependFile/Source/login/upDownLimp.png);</string>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="company_Label_2_invalid">
<property name="geometry">
<rect>
<x>30</x>
<y>30</y>
<width>230</width>
<height>57</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">border-image: url(:/DependFile/Source/login/company.png);</string>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QPushButton" name="company_Label">
<property name="geometry">
<rect>
<x>30</x>
<y>30</y>
<width>230</width>
<height>57</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(255, 255, 255);
border:none;
border-image: url(:/DependFile/Source/login/company.png);</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</widget>
<zorder>groupBox_5</zorder>
<zorder>groupBox_2</zorder>
</widget>
<widget class="QGroupBox" name="groupBox_6">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1920</width>
<height>1080</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">#groupBox_6{background: #07A8E7;
border: 1px solid #979797;}</string>
</property>
<property name="title">
<string/>
</property>
<widget class="QPushButton" name="pushButton">
<property name="geometry">
<rect>
<x>20</x>
<y>20</y>
<width>90</width>
<height>90</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">background: #05A6EC;
border-radius: 4px;
color:white;
border-image: url(:/DependFile/Source/MainPage/shutdown.png);</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</widget>
<zorder>groupBox_6</zorder>
<zorder>groupBox</zorder>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -0,0 +1,146 @@
#include <QApplication>
#include "cdatabaseinterface.h"
#include <QFile>
#include <QDebug>
#include <QMessageBox>
//#include "loginwidget.h"
#include "cmainwindow.h"
#include "readconfig.h"
#include "loginwidget.h"
#include "gamecontrol.h"
#include <QSharedMemory>
#include <QMutex>
#include <QFile>
#include <QObject>
#include "fescontroldialog.h"
#include <QSettings>
void outputMessage(QtMsgType type, const QMessageLogContext &context, const QString &msg)
{
static QMutex mutex;
mutex.lock();
QString text;
switch(type)
{
case QtDebugMsg:
text = QString("Debug:");
break;
case QtWarningMsg:
text = QString("Warning:");
break;
case QtCriticalMsg:
text = QString("Critical:");
break;
case QtFatalMsg:
text = QString("Fatal:");
}
QString context_info = QString("File:(%1) Line:(%2)").arg(QString(context.file)).arg(context.line);
QString current_date_time = QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss ddd");
QString current_date = QString("(%1)").arg(current_date_time);
QString message = QString("%1 %2 %3 %4").arg(text).arg(context_info).arg(msg).arg(current_date);
QFile file("log.txt");
file.open(QIODevice::WriteOnly | QIODevice::Append);
QTextStream text_stream(&file);
text_stream << message << "\r\n";
file.flush();
file.close();
mutex.unlock();
}
#include <QDir>
#include <QSettings>
//设置程序自启动 appPath程序路径
void SetProcessAutoRunSelf(const QString &appPath)
{
//注册表路径需要使用双反斜杠如果是32位系统要使用QSettings::Registry32Format
QSettings settings("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run",
QSettings::Registry64Format);
//以程序名称作为注册表中的键
//根据键获取对应的值(程序路径)
QFileInfo fInfo(appPath);
QString name = fInfo.baseName();
QString path = settings.value(name).toString();
//如果注册表中的路径和当前程序路径不一样,
//则表示没有设置自启动或自启动程序已经更换了路径
//toNativeSeparators的意思是将"/"替换为"\"
QString newPath = QDir::toNativeSeparators(appPath);
if (path != newPath)
{
settings.setValue(name, newPath);
qDebug() <<"添加快捷启动注册表HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run,";
}
}
int main(int argc, char *argv[])
{
qputenv("QT_IM_MODULE", QByteArray("tgtsml"));
//qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));
QApplication a(argc, argv);
//Qt开机自启动
//SetProcessAutoRunSelf(qApp->applicationFilePath());
#ifdef DEBUGON
qInstallMessageHandler(outputMessage);
#endif
//数据库读取
if(!CDatabaseInterface::getInstance()->openDB("./DependFile/DBFile/UpLow.db","QSQLITE"))
qDebug()<<"UpLow.db open failed!";
//配置文件读取
if(!ReadConfig::getInstance()->readConfigFile())
{
qDebug()<<"配置文件读取失败";
return -1;
}
//读取游戏配置文件
GameControl::getInstance()->readGameConfigMsg();
//设置全局样式表
QFile file("./DependFile/QSS/app.txt");
if(file.open(QFile::ReadOnly))
{
QString styleSheet = QLatin1String(file.readAll());
qApp->setStyleSheet(styleSheet);
file.close();
}
else
{
QMessageBox::warning(NULL, "warning", "totalqss Open failed", QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
}
QSharedMemory sharedMemory;
sharedMemory.setKey("main_Window");
if(sharedMemory.attach())
{
QMessageBox::warning(NULL, "Warning", ("不可重复开启进程"));
return 0;
}
LoginWidget login;//
CMainWindow w;
if(sharedMemory.create(1))
{
QObject::connect(&w,SIGNAL(signalShowCompleted()),&login,SLOT(slotShowCompleted()));
login.setWindowModality(Qt::WindowModal);//
login.exec(); //
w.show();
}
QObject::connect(&a,&QApplication::aboutToQuit,[](){
FesControlDialog::getInstance()->turnoffDevice(1,1);
});
return a.exec();
}

View File

@@ -0,0 +1,19 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QListView>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
// , ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->comboBox->setView(new QListView());
//设置无边框
// ui->comboBox_2->setView(new QListView());
}
MainWindow::~MainWindow()
{
delete ui;
}

View File

@@ -0,0 +1,21 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H

View File

@@ -0,0 +1,499 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
<widget class="QLineEdit" name="lineEdit">
<property name="geometry">
<rect>
<x>190</x>
<y>140</y>
<width>113</width>
<height>25</height>
</rect>
</property>
</widget>
<widget class="QGroupBox" name="groupBox">
<property name="geometry">
<rect>
<x>80</x>
<y>350</y>
<width>471</width>
<height>131</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">#groupBox{background:white;}</string>
</property>
<property name="title">
<string>GroupBox</string>
</property>
<widget class="QSlider" name="horizontalSlider">
<property name="geometry">
<rect>
<x>50</x>
<y>60</y>
<width>351</width>
<height>43</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">/**********首先指定是水平还是竖直*不添加此代码,下方不起作用******/
QSlider::groove:horizontal {
border: 0px solid #bbb;
}
/*1.滑动过的槽设计参数*/
QSlider::sub-page:horizontal {
/*槽颜色*/
background: #05F6CC;
/*外环区域倒圆角度*/
border-radius: 4px;
/*上遮住区域高度*/
margin-top:14px;
/*下遮住区域高度*/
margin-bottom:14px;
/*width在这里无效不写即可*/
/*****/
margin-left:8px;
}
/*2.未滑动过的槽设计参数*/
QSlider::add-page:horizontal {
/*槽颜色*/
background: #ECEBEB;
/*外环大小0px就是不显示默认也是0*/
border: 0px solid #777;
/*外环区域倒圆角度*/
border-radius: 4px;
/*上遮住区域高度*/
margin-top:14px;
/*下遮住区域高度*/
margin-bottom:14px;
margin-right:8px;
}
QSlider::handle:horizontal {
width: 43px;
background:transparent;
background-image: url(:/DependFile/Source/channel/slder.png);
margin: -0px -0px -0px -0px;
}
</string>
</property>
<property name="value">
<number>20</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</widget>
<widget class="QComboBox" name="comboBox">
<property name="geometry">
<rect>
<x>420</x>
<y>150</y>
<width>131</width>
<height>41</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">/* 未下拉时QComboBox的样式 */
QComboBox {
border: 1px solid gray; /* 边框 */
border-radius: 3px; /* 圆角 */
padding: 1px 18px 1px 3px; /* 字体填衬 */
color: #000;
background: transparent;
}
/* 下拉后,整个下拉窗体样式 */
QComboBox QAbstractItemView {
outline: 2px solid gray; /* 选定项的虚框 */
border: 1px solid yellow; /* 整个下拉窗体的边框 */
color: black;
background-color: white; /* 整个下拉窗体的背景色 */
selection-background-color: lightgreen; /* 整个下拉窗体被选中项的背景色 */
}
/* 下拉后,整个下拉窗体每项的样式-此项起作用后,整个下拉窗体的样式则被顶替了 */
QComboBox QAbstractItemView::item {
height: 50px; /* 项的高度设置pComboBox-&gt;setView(new QListView());后,该项才起作用) */
font: normal normal 25px &quot;黑体&quot;;/********字体未起作用***********/
}
/* 下拉后,整个下拉窗体越过每项的样式 */
QComboBox QAbstractItemView::item:hover {
color: #FFFFFF;
background-color: lightgreen; /* 整个下拉窗体越过每项的背景色 */
}
/* 下拉后,整个下拉窗体被选择的每项的样式 */
QComboBox QAbstractItemView::item:selected {
color: #FFFFFF;
background-color: lightgreen;
}
/* QComboBox中的垂直滚动条 */
QComboBox QAbstractScrollArea QScrollBar:vertical {
width: 10px;
background-color: #d0d2d4; /* 空白区域的背景色 灰色green */
}
QComboBox QAbstractScrollArea QScrollBar::handle:vertical {
border-radius: 5px; /* 圆角 */
background: rgb(160,160,160); /* 小方块的背景色深灰lightblue */
}
QComboBox QAbstractScrollArea QScrollBar::handle:vertical:hover {
background: rgb(90, 91, 93); /* 越过小方块的背景色yellow */
}
/* 下拉框样式 */
QComboBox::drop-down {
subcontrol-origin: padding; /* 子控件在父元素中的原点矩形。如果未指定此属性则默认为padding。 */
subcontrol-position: top right; /* 下拉框的位置(右上) */
width: 25px; /* 下拉框的宽度 */
border-left-width: 1px; /* 下拉框的左边界线宽度 */
border-left-color: darkgray; /* 下拉框的左边界线颜色 */
border-left-style: solid; /* 下拉框的左边界线为实线 */
border-top-right-radius: 3px; /* 下拉框的右上边界线的圆角半径应和整个QComboBox右上边界线的圆角半径一致 */
border-bottom-right-radius: 3px; /* 同上 */
}
</string>
</property>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
</widget>
<widget class="QRadioButton" name="radioButton">
<property name="geometry">
<rect>
<x>190</x>
<y>250</y>
<width>131</width>
<height>41</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">QRadioButton::indicator:unchecked{
image: url(:/DependFile/Source/radioButton/normal.png);
width:20;
height:20
}
QRadioButton::indicator:checked{
image: url(:/DependFile/Source/radioButton/checked.png);
width:20;
height:20
}
</string>
</property>
<property name="text">
<string>RadioButton</string>
</property>
</widget>
<widget class="QComboBox" name="comboBox_2">
<property name="geometry">
<rect>
<x>590</x>
<y>150</y>
<width>161</width>
<height>41</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>-1</pointsize>
<italic>false</italic>
<bold>false</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">/* 未下拉时QComboBox的样式 */
QComboBox {
border: 1px solid gray; /* 边框 */
border-radius: 3px; /* 圆角 */
padding: 1px 18px 1px 3px; /* 字体填衬 */
color: #000;
font: 20px &quot;黑体&quot;;
background: transparent;
}
/* 下拉后,整个下拉窗体样式 */
QComboBox QAbstractItemView {
outline: 0px solid gray; /* 选定项的虚框 */
border: 0px solid gray; /* 整个下拉窗体的边框 */
color: black;
background-color: #C3E4F3; /* 整个下拉窗体的背景色 */
selection-background-color: lightgreen; /* 整个下拉窗体被选中项的背景色 */
font: 20px &quot;黑体&quot;;
}
/* 下拉后,整个下拉窗体每项的样式 */
QComboBox QAbstractItemView::item {
height: 50px; /* 项的高度设置pComboBox-&gt;setView(new QListView());后,该项才起作用) */
}</string>
</property>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
<item>
<property name="text">
<string>新建项目</string>
</property>
</item>
</widget>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>21</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -0,0 +1,42 @@
#include "mainwindowpagecontrol.h"
#include <QDebug>
MainWindowPageControl* MainWindowPageControl::m_pageControlInterface = NULL;
MainWindowPageControl::MainWindowPageControl(QObject *parent) : QObject(parent)
{
ST_runningFlag.evaluateFlag = false;
ST_runningFlag.gameFlag = false;
ST_runningFlag.moveRangeFlag = false;
ST_runningFlag.trainModeFlag = false;
ST_runningFlag.trainRecordFlag = false;
}
MainWindowPageControl* MainWindowPageControl::getInstance()
{
if(m_pageControlInterface == NULL)
{
m_pageControlInterface = new MainWindowPageControl();
}
return m_pageControlInterface;
}
void MainWindowPageControl::setCurrentPage(int pageIndex)
{
m_currentPageIndex = pageIndex;
emit signalSwitchPage((E_PAGENAME)pageIndex);
}
void MainWindowPageControl::setMainWindowBtnsLock(bool isLock)
{
emit signalSetBtnsLock(isLock);
}
int MainWindowPageControl::getCurrentPageIndex()
{
return m_currentPageIndex;
}
void MainWindowPageControl::setPageIndex(int pageIndex)
{
m_currentPageIndex = pageIndex;
}

View File

@@ -0,0 +1,50 @@
#ifndef MAINWINDOWPAGECONTROL_H
#define MAINWINDOWPAGECONTROL_H
/*************该类主要用于管理页面间的切换***************/
#include "dataformate.h"
#include <QObject>
class MainWindowPageControl : public QObject
{
Q_OBJECT
public:
static MainWindowPageControl* getInstance();
/****设置当前页面****
* @int pageIndex 目标页面
* *************/
void setCurrentPage(int pageIndex);
//各个模块是否解锁
void setMainWindowBtnsLock(bool);
//获取当前页面下标
int getCurrentPageIndex();
//只修改页面所以,不发送槽函数
void setPageIndex(int pageIndex);
signals:
void signalSwitchPage(E_PAGENAME pageIndex);
void signalSetBtnsLock(bool);
//关闭当前运行的练习
void signalTurnOffRunning(int pageIndex);
private:
explicit MainWindowPageControl(QObject *parent = nullptr);
static MainWindowPageControl* m_pageControlInterface;
int m_currentPageIndex; //当前页面下标
//各界面状态
struct
{
bool moveRangeFlag;
bool trainModeFlag;
bool gameFlag;
bool evaluateFlag;
bool trainRecordFlag;
}ST_runningFlag;
};
#endif // MAINWINDOWPAGECONTROL_H

View File

@@ -0,0 +1,357 @@
#include "titlewidget.h"
#include "ui_titlewidget.h"
#include <QPixmap>
#include <windows.h>
#include <wlanapi.h>
#include "mainwindowpagecontrol.h"
#include <QDebug>
#include <QDir>
#include "icemodule.h"
#include "ccommunicateapi.h"
#include "currentuserdata.h"
#include "loginwidget.h"
TitleWidget::TitleWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::TitleWidget),
checkTimer(nullptr)
{
ui->setupUi(this);
connect(ui->back1_Btn,SIGNAL(clicked()),this,SLOT(slotBackClicked()));
connect(ui->back2_Btn,SIGNAL(clicked()),this,SLOT(slotBackClicked()));
ui->user_Btn->setIcon(QIcon(":/DependFile/Source/User/user1.png"));
ui->user_Btn->setIconSize(QSize(40,40));
setBackBtnVisible(false);
checkTimer = new QTimer();
checkTimer->setInterval(3000);
connect(checkTimer,SIGNAL(timeout()),this,SLOT(slotCheckTimer()));
checkTimer->start();
connect(CCommunicateAPI::getInstance(),SIGNAL(signalCommunicateChanged(QString)),this,SLOT(slotStateChanged(QString)));
ui->signal_Label->setVisible(false);
ui->wifiSignal2_Label->setVisible(true);
ui->wifiSignal_Label->move(1620,30);
ui->title_Label->setText(tr("功能选择")); //默认汉字
ui->quit_Btn->setVisible(false);
ui->back1_Btn->setVisible(true);
ui->back2_Btn->setVisible(true);
m_soundDialog = new SoundDialog();
}
TitleWidget::~TitleWidget()
{
if(m_soundDialog)
{
delete m_soundDialog;
}
delete ui;
}
void TitleWidget::slotBackClicked()
{
int currentPage = MainWindowPageControl::getInstance()->getCurrentPageIndex();
if(!(currentPage>=MainPage_E && currentPage <=visionTrain))
currentPage = MainPage_E;//初始化异常值276795792,设置当前页索引为0
qDebug()<<"当前页"<<currentPage;
switch(currentPage)
{
case MainPage_E:
{
LoginWidget login;//
login.setWindowModality(Qt::WindowModal);//
login.exec(); //
// MainWindowPageControl::getInstance()->setCurrentPage(LoginPage_E);
// qDebug()<<"开始跳转";
}
break;
case BrainTraining:
case UserPage_E:
case SettingPage_E:
case BicycleParamSet_E:
case FesBicycleParamSet_E:
MainWindowPageControl::getInstance()->setCurrentPage(MainPage_E);
break;
case FesParamSet_E:
{
//分两种情况
switch(m_trainType)
{
case 0://1、直接选择的FES训练跳到主界面
MainWindowPageControl::getInstance()->setCurrentPage(MainPage_E);
break;
case 1://2、从踏车界面跳转到FES界面,跳到踏车界面
MainWindowPageControl::getInstance()->setCurrentPage(BicycleParamSet_E);
break;
}
}
break;
case BicycleToFes_E:
MainWindowPageControl::getInstance()->setCurrentPage(FesBicycleParamSet_E);
break;
case TrainingParamSetting_E:
{
if(m_trainType == 0)
MainWindowPageControl::getInstance()->setCurrentPage(BicycleParamSet_E);
else if(m_trainType == 1)
MainWindowPageControl::getInstance()->setCurrentPage(FesBicycleParamSet_E);
//qDebug() <<"Hello";
}
break;
case visionTrain:
MainWindowPageControl::getInstance()->setCurrentPage(BrainTraining);
break;
}
}
//设置当前用户
void TitleWidget::setUser(const ST_PatientMsg& st_patientMsg)
{
ui->user_Btn->setText(st_patientMsg.name);
}
//设置wifi信号强度
void TitleWidget::setSignalStrength(int value)
{
Q_UNUSED(value)
}
//设置标题
void TitleWidget::setTitleByPage(E_PAGENAME pageType)
{
QString title;
switch(pageType)
{
case MainPage_E:
title = tr("功能选择");
setBackBtnVisible(true);
ui->quit_Btn->setVisible(false);
//只修改pageIndex不发送槽函数
MainWindowPageControl::getInstance()->setPageIndex(MainPage_E);
break;
case TrainingPage_E:
title = tr("");//上肢、下肢、四肢训练
setBackBtnVisible(false);
ui->quit_Btn->setVisible(false);
break;
case UserPage_E:
title = tr("用户管理");
setBackBtnVisible(true);
break;
case SettingPage_E:
title = tr("软件设置");
setBackBtnVisible(true);
break;
case BicycleParamSet_E:
title = tr("参数设置");
setBackBtnVisible(true);
break;
case FesParamSet_E:
setBackBtnVisible(true);
title = tr("FES参数");
break;
case FesBicycleParamSet_E:
setBackBtnVisible(true);
title = tr("踏车参数");
break;
case TrainingParamSetting_E:
setBackBtnVisible(true);
title = tr("参数设置");
break;
case BrainTraining:
setBackBtnVisible(true);
title = tr("脑控康复");
break;
case visionTrain:
setBackBtnVisible(true);
title = tr("视觉脑机康复训练");
break;
default:
break;
}
ui->title_Label->setText(title);
}
void TitleWidget::setTrainType(int8_t type)
{
m_trainType = type;
}
void TitleWidget::on_user_Btn_clicked()
{
MainWindowPageControl::getInstance()->setCurrentPage(UserPage_E);
}
void TitleWidget::slotCheckTimer()
{
showWIFI();
}
void TitleWidget::showWIFI()
{
#if 0
DWORD dwError = ERROR_SUCCESS;
DWORD dwNegotiatedVersion;
HANDLE hClientHandle = NULL;
dwError = WlanOpenHandle(1, NULL, &dwNegotiatedVersion, &hClientHandle);
if (dwError != ERROR_SUCCESS)
{
WlanCloseHandle(hClientHandle,NULL);
return;
}
PWLAN_INTERFACE_INFO_LIST pInterfaceList = NULL;
dwError = WlanEnumInterfaces(hClientHandle, NULL,&pInterfaceList);
if ( dwError != ERROR_SUCCESS )
{
WlanFreeMemory(pInterfaceList);
WlanCloseHandle(hClientHandle,NULL);
return;
}
GUID &guid = pInterfaceList->InterfaceInfo[0].InterfaceGuid;
PWLAN_AVAILABLE_NETWORK_LIST pWLAN_AVAILABLE_NETWORK_LIST = NULL;
dwError = WlanGetAvailableNetworkList(hClientHandle, &guid,
2,NULL, &pWLAN_AVAILABLE_NETWORK_LIST);
if (dwError != ERROR_SUCCESS)
{
WlanFreeMemory(pInterfaceList);
WlanFreeMemory(pWLAN_AVAILABLE_NETWORK_LIST);
WlanCloseHandle(hClientHandle,NULL);
return;
}
WLAN_AVAILABLE_NETWORK wlanAN;
bool isConnected=false;
int numberOfItems = pWLAN_AVAILABLE_NETWORK_LIST->dwNumberOfItems;
if (numberOfItems > 0)
{
for(int i = 0; i <numberOfItems; i++)
{
wlanAN = pWLAN_AVAILABLE_NETWORK_LIST->Network[i];
if(wlanAN.dwFlags & 1)
{
isConnected=true;
int wifiQuality=(int)wlanAN.wlanSignalQuality;
if(wifiQuality>75)
{
QPixmap pixmapWireless(":/DependFile/Source/signal/wifi3.png");
ui->wifiSignal_Label->setPixmap(pixmapWireless);
}
else if(wifiQuality>50&&wifiQuality<=75)
{
QPixmap pixmapWireless(":/DependFile/Source/signal/wifi2.png");
ui->wifiSignal_Label->setPixmap(pixmapWireless);
}
else if(wifiQuality>25&&wifiQuality<=50)
{
QPixmap pixmapWireless(":/DependFile/Source/signal/wifi1.png");
ui->wifiSignal_Label->setPixmap(pixmapWireless);
}
else if(wifiQuality>0&&wifiQuality<=25)
{
QPixmap pixmapWireless(":/icons/WirelessIcon3.png");
ui->wifiSignal_Label->setPixmap(pixmapWireless);
}
}
}
}
if (!isConnected)
{
QPixmap pixmapWireless(":/icons/WirelessIcon4.png");
ui->wifiSignal_Label->setPixmap(pixmapWireless);
}
WlanFreeMemory(pInterfaceList);
WlanFreeMemory(pWLAN_AVAILABLE_NETWORK_LIST);
WlanCloseHandle(hClientHandle,NULL);
#else
QPixmap pixmap;
if(IceModule::getInstance()->getBicycleDeviceState())
{
pixmap.load(":/DependFile/Source/signal/deviceConnected.png");
}
else
pixmap.load(":/DependFile/Source/signal/deviceDisconnected.png");
ui->wifiSignal_Label->setPixmap(pixmap);
#endif
}
void TitleWidget::setBackBtnVisible(bool visible)
{
ui->back1_Btn->setVisible(visible);
ui->back2_Btn->setVisible(visible);
ui->quit_Btn->setVisible(!visible);
}
void TitleWidget::on_quit_Btn_clicked()
{
emit signalCloseWindow();
//MainWindowPageControl::getInstance()->setCurrentPage(LoginPage_E);
/*
*
*/
}
void TitleWidget::slotStateChanged(QString str)
{
ui->state_label->setText(str);
}
void TitleWidget::slotSaveUpPicture()
{
QPixmap upPicture = this->grab();
QString dirPath = QApplication::applicationDirPath() + "/DependFile/Source/trainDisplayPage";
QDir resultDir(dirPath);
if(!resultDir.exists())
qDebug()<<"保存图片失败";
if(upPicture.save(dirPath + "/upPicture.png"))
qDebug() <<dirPath + "/upPicture.png";
}
void TitleWidget::changeEvent(QEvent* event)
{
switch (event->type())
{
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
QWidget::changeEvent(event);
break;
}
setUser(CurrentUserData::getInstace()->getCurrentPatientMsg());
}
void TitleWidget::on_sound_Button_clicked()
{
m_soundDialog->show();
}

View File

@@ -0,0 +1,75 @@
#ifndef TITLEWIDGET_H
#define TITLEWIDGET_H
#include <QWidget>
#include <QLabel>
#include "dbforrmate.h"
#include "dataformate.h"
#include <QTimer>
#include "sounddialog.h"
namespace Ui {
class TitleWidget;
}
class TitleWidget : public QWidget
{
Q_OBJECT
public:
explicit TitleWidget(QWidget *parent = nullptr);
~TitleWidget();
//设置当前用户
void setUser(const ST_PatientMsg&);
//设置wifi信号强度
void setSignalStrength(int value);
//设置标题
void setTitleByPage(E_PAGENAME);
//设置界面从属状态
/*****设置训练类型****
* 参数@int8_t type 0-单踏车 1-FES踏车
* *****/
void setTrainType(int8_t type);
void setBackBtnVisible(bool);
void slotSaveUpPicture();//保存上截图
protected:
virtual void changeEvent(QEvent* event);
signals:
void signalCloseWindow();
private slots:
void slotBackClicked();
void on_user_Btn_clicked();
void slotCheckTimer();
void on_quit_Btn_clicked();
void slotStateChanged(QString);
//void on_back1_Btn_clicked();
// void on_pushButton_clicked();
void on_sound_Button_clicked();
//void on_back2_Btn_clicked();
//void on_back1_Btn_clicked();
private:
void showWIFI();
private:
Ui::TitleWidget *ui;
int8_t m_trainType;
QTimer *checkTimer;
SoundDialog *m_soundDialog;
//
};
#endif // TITLEWIDGET_H

View File

@@ -0,0 +1,226 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>TitleWidget</class>
<widget class="QWidget" name="TitleWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1920</width>
<height>100</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<widget class="QLabel" name="title_Label">
<property name="geometry">
<rect>
<x>570</x>
<y>0</y>
<width>621</width>
<height>101</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>28</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">color:white;</string>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="signal_Label">
<property name="geometry">
<rect>
<x>1620</x>
<y>30</y>
<width>40</width>
<height>40</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">border-image: url(:/DependFile/Source/signal/titleSignal.png);</string>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QPushButton" name="user_Btn">
<property name="geometry">
<rect>
<x>1700</x>
<y>20</y>
<width>170</width>
<height>60</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>15</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">#user_Btn{background: #FFFFFF;
border-radius: 30px;
color:#05A6EC;}</string>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="wifiSignal_Label">
<property name="geometry">
<rect>
<x>1500</x>
<y>30</y>
<width>40</width>
<height>40</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QGroupBox" name="groupBox">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1920</width>
<height>100</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">#groupBox{background: #05A6EC;border:none;}</string>
</property>
<property name="title">
<string/>
</property>
<widget class="QPushButton" name="back2_Btn">
<property name="geometry">
<rect>
<x>85</x>
<y>14</y>
<width>131</width>
<height>70</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>28</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">color:white;
border:2px;</string>
</property>
<property name="text">
<string>返回</string>
</property>
</widget>
<widget class="QPushButton" name="back1_Btn">
<property name="geometry">
<rect>
<x>37</x>
<y>24</y>
<width>50</width>
<height>50</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">border-image: url(:/DependFile/Source/signal/back.png);</string>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QPushButton" name="quit_Btn">
<property name="geometry">
<rect>
<x>60</x>
<y>20</y>
<width>60</width>
<height>60</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">border-image: url(:/DependFile/Source/channel/quit.png);</string>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="state_label">
<property name="geometry">
<rect>
<x>1400</x>
<y>70</y>
<width>301</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="wifiSignal2_Label">
<property name="geometry">
<rect>
<x>1430</x>
<y>30</y>
<width>40</width>
<height>40</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QPushButton" name="sound_Button">
<property name="geometry">
<rect>
<x>1550</x>
<y>30</y>
<width>40</width>
<height>40</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">border-image: url(:/DependFile/Source/channel/sound.png);</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</widget>
<zorder>groupBox</zorder>
<zorder>title_Label</zorder>
<zorder>signal_Label</zorder>
<zorder>user_Btn</zorder>
<zorder>wifiSignal_Label</zorder>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -0,0 +1,43 @@
#include "Prescriptiondialog.h"
#include "ui_Prescriptiondialog.h"
#include <QPainter>
PrescriptionDialog::PrescriptionDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::PrescriptionDialog)
{
ui->setupUi(this);
this->setWindowFlags(Qt::FramelessWindowHint); //设置无边框
setAttribute(Qt::WA_TranslucentBackground,true);
}
PrescriptionDialog::~PrescriptionDialog()
{
delete ui;
}
void PrescriptionDialog::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event)
QPainter painter(this);
painter.fillRect(rect(),QColor(0,0,0,100));
}
void PrescriptionDialog::changeEvent(QEvent *event)
{
switch (event->type())
{
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
QWidget::changeEvent(event);
break;
}
}
void PrescriptionDialog::on_confirm_Btn_clicked()
{
this->close();
}

View File

@@ -0,0 +1,31 @@
#ifndef PRESCRIPTIONDIALOG_H
#define PRESCRIPTIONDIALOG_H
#include <QDialog>
namespace Ui {
class PrescriptionDialog;
}
class PrescriptionDialog : public QDialog
{
Q_OBJECT
public:
explicit PrescriptionDialog(QWidget *parent = nullptr);
~PrescriptionDialog();
protected:
void paintEvent(QPaintEvent *event);
virtual void changeEvent(QEvent* event);
private slots:
void on_confirm_Btn_clicked();
private:
Ui::PrescriptionDialog *ui;
};
#endif // PRESCRIPTIONDIALOG_H

View File

@@ -0,0 +1,108 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PrescriptionDialog</class>
<widget class="QDialog" name="PrescriptionDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1920</width>
<height>1080</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QGroupBox" name="groupBox">
<property name="geometry">
<rect>
<x>558</x>
<y>240</y>
<width>804</width>
<height>598</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">#groupBox{background: #FFFFFF;
border-radius: 32px;}</string>
</property>
<property name="title">
<string/>
</property>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>804</width>
<height>64</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>15</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">border-image: url(:/DependFile/Source/gamePage/dialog.png);</string>
</property>
<property name="text">
<string>提示</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>-10</x>
<y>190</y>
<width>811</width>
<height>71</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>25</pointsize>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>未查询到您上一次训练处方!</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QPushButton" name="confirm_Btn">
<property name="geometry">
<rect>
<x>340</x>
<y>380</y>
<width>120</width>
<height>45</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">border-radius: 4px;
border: 1px solid #0D9DDB;
color:#0D9DDB;</string>
</property>
<property name="text">
<string>确认</string>
</property>
</widget>
</widget>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -0,0 +1,166 @@
#include "advanceddialog.h"
#include "ui_advanceddialog.h"
#include <QPaintEvent>
#include <QPainter>
#include <QListView>
AdvancedDialog::AdvancedDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::AdvancedDialog),
fesSwitchFlag(true),
isSkipPassive(true)
{
ui->setupUi(this);
this->setWindowFlags(Qt::FramelessWindowHint); //设置无边框
setAttribute(Qt::WA_TranslucentBackground,true); //设置透明
st_advanceParam.isFesOn = fesSwitchFlag;
st_advanceParam.isSkipPassive = isSkipPassive;
initWidgetData();
}
AdvancedDialog::~AdvancedDialog()
{
delete ui;
}
void AdvancedDialog::on_confirm_Btn_clicked()
{
st_advanceParam.isFesOn = fesSwitchFlag;
st_advanceParam.isSkipPassive = isSkipPassive;
//预热阶段
st_advanceParam.preheatContinueTime = ui->preheatContinueTime_ComboBox->currentText().toInt();
st_advanceParam.preheatAContinueTime = ui->preheatAContinueTime_ComboBox->currentText().toInt();
st_advanceParam.preheatCompensate = ui->preheatCompensate_ComboBox->currentText().toInt();
st_advanceParam.preheatMaxPower = ui->preheatMaxPower_ComboBox->currentText().toInt();
st_advanceParam.transitionalFesRise = ui->transitionalFesRise_ComboBox->currentText().toInt();
//积极治疗阶段
st_advanceParam.positiveFChiXuTime = ui->positiveFChiXuTime_ComboBox->currentText().toInt();
st_advanceParam.positiveFControlSpeed = ui->positiveFControlSpeed_ComboBox->currentText().toInt();
st_advanceParam.positiveBChiXuTime = ui->positiveBChiXuTime_ComboBox->currentText().toInt();
st_advanceParam.positiveBSpeedCompensate = ui->positiveBSpeedCompensate_ComboBox->currentText().toInt();
st_advanceParam.positiveBresistance = ui->positiveBresistance_ComboBox->currentText().toInt();
st_advanceParam.timeLimit = ui->timeLimit_ComboBox->currentText().toInt();
st_advanceParam.speedLimit = ui->speedLimit_ComboBox->currentText().toInt();
//消极阶段
st_advanceParam.negativeSpeedCompensate = ui->negativeSpeedCompensate_ComboBox->currentText().toInt();
st_advanceParam.tiredContinueTime = ui->tiredContinueTime_ComboBox->currentText().toInt();
st_advanceParam.tiredSpeedCompensate = ui->tiredSpeedCompensate_ComboBox->currentText().toInt();
this->close();
}
void AdvancedDialog::on_cancel_Btn_clicked()
{
this->close();
}
void AdvancedDialog::on_skipPassive_Btn_clicked()
{
if(ui->skipPassive_Btn->styleSheet() == "border-image: url(:/DependFile/Source/gamePage/switchOn.png);")
{
isSkipPassive = false;
ui->skipPassive_Btn->setStyleSheet("border-image: url(:/DependFile/Source/gamePage/switchOff.png);");
}
else if(ui->skipPassive_Btn->styleSheet() == "border-image: url(:/DependFile/Source/gamePage/switchOff.png);")
{
isSkipPassive = true;
ui->skipPassive_Btn->setStyleSheet("border-image: url(:/DependFile/Source/gamePage/switchOn.png);");
}
}
void AdvancedDialog::on_preheatFesSwitch_Btn_clicked()
{
if(ui->preheatFesSwitch_Btn->styleSheet() == "border-image: url(:/DependFile/Source/gamePage/switchOn.png);")
{
fesSwitchFlag = false;
ui->preheatFesSwitch_Btn->setStyleSheet("border-image: url(:/DependFile/Source/gamePage/switchOff.png);");
}
else if(ui->preheatFesSwitch_Btn->styleSheet() == "border-image: url(:/DependFile/Source/gamePage/switchOff.png);")
{
fesSwitchFlag = true;
ui->preheatFesSwitch_Btn->setStyleSheet("border-image: url(:/DependFile/Source/gamePage/switchOn.png);");
}
}
void AdvancedDialog::initWidgetData()
{
//预热阶段
//加速时间/加速持续时间
for(int i = 0;i <= 60;i++)
{
ui->preheatContinueTime_ComboBox->addItem(QString::number(i));
ui->preheatAContinueTime_ComboBox->addItem(QString::number(i));
}
//转速补偿
for(int i = -30;i <= 30;i++ )
ui->preheatCompensate_ComboBox->addItem(QString::number(i));
//最大电量
for(int i =0;i <=50 ;i++)
ui->preheatMaxPower_ComboBox->addItem(QString::number(i));
//电刺激上升幅度
for(int i = 0;i <= 100; i++)
ui->transitionalFesRise_ComboBox->addItem(QString::number(i));
//积极阶段
for(int i = 0; i <= 120; i++)
ui->positiveFChiXuTime_ComboBox->addItem(QString::number(i));
for(int i = 5;i <= 60;i++)
ui->positiveFControlSpeed_ComboBox->addItem(QString::number(i));
for(int i = 0; i <= 120; i++)
ui->positiveBChiXuTime_ComboBox->addItem(QString::number(i));
for(int i = -30;i <= 30; i++)
ui->positiveBSpeedCompensate_ComboBox->addItem(QString::number(i));
for(int i = -20;i <= 20;i++)
ui->positiveBresistance_ComboBox->addItem(QString::number(i));
for(int i = 0;i <= 240;i++)
ui->timeLimit_ComboBox->addItem(QString::number(i));
for(int i = 1;i <= 50;i++ )
ui->speedLimit_ComboBox->addItem(QString::number(i*(-1)));
//消极阶段
for(int i = -30;i <= 30;i++)
ui->negativeSpeedCompensate_ComboBox->addItem(QString::number(i));
for(int i = 0;i <= 30;i ++)
ui->tiredContinueTime_ComboBox->addItem(QString::number(i));
for(int i = 0;i <= 30;i++)
ui->tiredSpeedCompensate_ComboBox->addItem(QString::number(i*(-1)));
foreach (QObject* obj, ui->groupBox->children()) {
if(obj->objectName().contains("ComboBox"))
{
QComboBox *combox = static_cast<QComboBox*>(obj);
combox->setView(new QListView);
}
}
foreach (QObject* obj, ui->groupBox_2->children()) {
if(obj->objectName().contains("ComboBox"))
{
QComboBox *combox = static_cast<QComboBox*>(obj);
combox->setView(new QListView);
}
}
foreach (QObject* obj, ui->groupBox_3->children()) {
if(obj->objectName().contains("ComboBox"))
{
QComboBox *combox = static_cast<QComboBox*>(obj);
combox->setView(new QListView);
}
}
}
ST_AdvancedParam AdvancedDialog::getValue()
{
return st_advanceParam;
}
void AdvancedDialog::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event)
QPainter painter(this);
painter.fillRect(rect(),QColor(0,0,0,100));
}

View File

@@ -0,0 +1,42 @@
#ifndef ADVANCEDDIALOG_H
#define ADVANCEDDIALOG_H
#include "dataformate.h"
#include <QDialog>
namespace Ui {
class AdvancedDialog;
}
class AdvancedDialog : public QDialog
{
Q_OBJECT
public:
explicit AdvancedDialog(QWidget *parent = nullptr);
~AdvancedDialog();
ST_AdvancedParam getValue();
protected:
void paintEvent(QPaintEvent *event);
private slots:
void on_confirm_Btn_clicked();
void on_cancel_Btn_clicked();
void on_skipPassive_Btn_clicked();
void on_preheatFesSwitch_Btn_clicked();
private:
//给控件添加数据
void initWidgetData();
private:
Ui::AdvancedDialog *ui;
bool fesSwitchFlag; //是否启动电刺激
bool isSkipPassive; //是否跳过此阶段
ST_AdvancedParam st_advanceParam;
};
#endif // ADVANCEDDIALOG_H

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,510 @@
#include "channeldialog.h"
#include "ui_channeldialog.h"
#include <QDebug>
#include <QPainter>
#include <QTimer>
#include <QMessageBox>
#include "fescontroldialog.h"
#include "icemodule.h"
#include <QDateTime>
ChannelDialog::ChannelDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::ChannelDialog),
m_buttonGroup(nullptr)
{
ui->setupUi(this);
this->setWindowFlags(Qt::FramelessWindowHint); //设置无边框
setAttribute(Qt::WA_TranslucentBackground,true); //设置透明
initWidget();
st_MuscleParam.connectState = true;
for(int i=0; i<8; i++)
maxCurrentData[i] = 0;
st_AnalogSetting.breakTime = 0;
st_AnalogSetting.fallingTime = 10;
st_AnalogSetting.holdingTime = 100;
st_AnalogSetting.risingTime = 10;
st_AnalogSetting.frequency = 50; //0~100Hz
st_AnalogSetting.pulseWidth = 100; //0~500us
st_AnalogSetting.samplerate = SamplingRate4K;
st_AnalogSetting.workmode = WorkModeStimulate;
//限制最大和最小电流滑块
QObject::connect(ui->minCurrent_Slider, &QSlider::valueChanged, [this](int value) {
if (value > ui->maxCurrent_Slider->value()) {
ui->minCurrent_Slider->setValue(ui->maxCurrent_Slider->value());
}
});
}
ChannelDialog::~ChannelDialog()
{
delete ui;
}
void ChannelDialog::initWidget()
{
//设置按钮互斥,配合样式表
m_buttonGroup = new QButtonGroup;
// m_buttonGroup->setExclusive(true);
m_buttonGroup->addButton(ui->gongErL_Btn,1);
m_buttonGroup->addButton(ui->gongSanL_Btn,2);
m_buttonGroup->addButton(ui->qianSanJiaoL_Btn,3);
m_buttonGroup->addButton(ui->houSanJiaoL_Btn,4);
m_buttonGroup->addButton(ui->quWanL_Btn,5);
m_buttonGroup->addButton(ui->shenWanL_Btn,6);
m_buttonGroup->addButton(ui->jianJiaL_Btn,7);
m_buttonGroup->addButton(ui->gangShangL_Btn,8);
m_buttonGroup->addButton(ui->guoShengL_Btn,9);
m_buttonGroup->addButton(ui->tunDaL_Btn,10);
m_buttonGroup->addButton(ui->jingQianL_Btn,11);
m_buttonGroup->addButton(ui->feiChangL_Btn,12);
m_buttonGroup->addButton(ui->fuJiL_Btn,13);
m_buttonGroup->addButton(ui->shuJiL_Btn,14);
m_buttonGroup->addButton(ui->guSiTouL_Btn,15);
m_buttonGroup->addButton(ui->gongErR_Btn,16);
m_buttonGroup->addButton(ui->gongSanR_Btn,17);
m_buttonGroup->addButton(ui->qianSanJiaoR_Btn,18);
m_buttonGroup->addButton(ui->houSanJiaoR_Btn,19);
m_buttonGroup->addButton(ui->quWanR_Btn,20);
m_buttonGroup->addButton(ui->shenWanR_Btn,21);
m_buttonGroup->addButton(ui->jianJiaR_Btn,22);
m_buttonGroup->addButton(ui->gangShangR_Btn,23);
m_buttonGroup->addButton(ui->guoShengR_Btn,24);
m_buttonGroup->addButton(ui->tunDaR_Btn,25);
m_buttonGroup->addButton(ui->jingQianR_Btn,26);
m_buttonGroup->addButton(ui->feiChangR_Btn,27);
m_buttonGroup->addButton(ui->fuJiR_Btn,28);
m_buttonGroup->addButton(ui->shuJiR_Btn,29);
m_buttonGroup->addButton(ui->guSiTouR_Btn,30);
foreach(QAbstractButton *button,m_buttonGroup->buttons())
button->setCheckable(true);
connect(m_buttonGroup,SIGNAL(buttonClicked(int)),this,SLOT(slotButtonClicked(int)));
connect(m_buttonGroup,SIGNAL(buttonClicked(QAbstractButton *)),this,SLOT(slotButtonClicked(QAbstractButton*)));
ui->maxCurrent_Slider->setRange(0,100);
}
void ChannelDialog::setTitle(int title)
{
QString strTitle;
switch(title)
{
case 1:
case 2:
strTitle = QString(tr("通道A%1").arg(title%2 ? 1:2));
break;
case 3:
case 4:
strTitle = QString(tr("通道B%1").arg(title%2 ? 1:2));
break;
case 5:
case 6:
strTitle = QString(tr("通道C%1").arg(title%2 ? 1:2));
break;
case 7:
case 8:
strTitle = QString(tr("通道D%1").arg(title%2 ? 1:2));
break;
}
ui->channelName_Label->setText(strTitle);
m_currentChannel = title;
m_deviceNo = m_currentChannel/2 + (m_currentChannel%2?1:0);
m_deviceChannel = m_currentChannel%2 ? 1:2;
/********电刺激操作流程*********/
}
ST_MuscleParam ChannelDialog::getValue()
{
return st_MuscleParam;
}
void ChannelDialog::on_confirm_Btn_clicked()
{
st_MuscleParam.plus = ui->plus_Label->text().toInt();
st_MuscleParam.minCurrent = ui->minCurrent_Label->text().toInt();
st_MuscleParam.frequency = ui->frequent_Label->text().toInt();
st_MuscleParam.maxCurrent = ui->maxCurrent_Label->text().toInt();
if(st_MuscleParam.muscleName == "")
{
QMessageBox::warning(NULL,"Warning",tr("未选择肌肉!"));
return;
}
//关闭预设电流开关
if(st_MuscleParam.connectState)
{
FesControlDialog::getInstance()->setPreCurrentState(m_deviceNo,m_deviceChannel,false);
int index = (m_deviceNo-1)*2 + m_deviceChannel-1;
maxCurrentData[index] = st_MuscleParam.maxCurrent;
qDebug() << "index:"<<index;
IceModule::getInstance()->setMaxCurrentValue(index,st_MuscleParam.maxCurrent);
}
FesControlDialog::getInstance()->setMuscleDeviceStateByNo(m_deviceNo,true);; //添加已经更改肌肉的设备
this->hide();
}
void ChannelDialog::slotButtonClicked(int id)
{
st_MuscleParam.muscleId = id;
}
void ChannelDialog::slotButtonClicked(QAbstractButton *button)
{
st_MuscleParam.muscleName = button->text();
ui->muscle_Label->setText(st_MuscleParam.muscleName);
QString muscleName = button->objectName();
int index = muscleName.indexOf("_");
QPixmap pixmap;
QString fileName("./DependFile/Image/leftMuscle/");
fileName.append(muscleName.leftRef(index-1));
fileName.append(".png");
pixmap.load(fileName );
ui->muscleImage_Label->setPixmap(pixmap);
}
void ChannelDialog::on_frequentMinus_Btn_clicked()
{
int value = ui->frequent_Slider->value();
--value;
ui->frequent_Slider->setValue(value);
//FesControlDialog::getInstance()->setPreFrequency(m_deviceNo,m_deviceChannel, value);
//FesControlDialog::getInstance()->setPreCurrentState(m_deviceNo,m_deviceChannel,true);
}
void ChannelDialog::on_frequentPlus_Btn_clicked()
{
int value = ui->frequent_Slider->value();
++value;
ui->frequent_Slider->setValue(value);
//FesControlDialog::getInstance()->setPreCurrentState(m_deviceNo,m_deviceChannel,true);
//FesControlDialog::getInstance()->setPreFrequency(m_deviceNo,m_deviceChannel, value);
}
//频率
void ChannelDialog::on_frequent_Slider_valueChanged(int value)
{
ui->frequent_Label->setText(QString::number(value));
st_AnalogSetting.frequency = value;
//qDebug() <<m_deviceNo << m_deviceChannel;
}
//脉宽
void ChannelDialog::on_plus_Slider_valueChanged(int value)
{
ui->plus_Label->setText(QString::number(value));
st_AnalogSetting.pulseWidth = value;
}
//最小电流
void ChannelDialog::on_minCurrent_Slider_valueChanged(int value)
{
ui->minCurrent_Label->setText(QString::number(value));
static int times = 0;
if(st_MuscleParam.connectState)
{
times++;
if(times > 20) //100ms
{
FesControlDialog::getInstance()->setPreCurrent(m_deviceNo,m_deviceChannel,value);
times = 0;
}
}
}
//最大电流
void ChannelDialog::on_maxCurrent_Slider_valueChanged(int value)
{
ui->maxCurrent_Label->setText(QString::number(value));
ui->minCurrent_Slider->setRange(0,99);
ui->minCurrent_Slider->setPageStep(value);
//ui->minCurrent_Slider->setMaximum(value);
static int times = 0;
if(st_MuscleParam.connectState)
{
times++;
if(times > 20) //100ms
{
FesControlDialog::getInstance()->setPreCurrent(m_deviceNo,m_deviceChannel,value);
times = 0;
}
}
}
void ChannelDialog::on_PWMMinus_Btn_clicked()
{
int value = ui->plus_Slider->value();
value -= 10;
ui->plus_Slider->setValue(value);
//FesControlDialog::getInstance()->setPrePulseWidth(m_deviceNo,m_deviceChannel,value);
}
void ChannelDialog::on_PWMPlus_Btn_clicked()
{
int value = ui->plus_Slider->value();
value += 10;
ui->plus_Slider->setValue(value);
//FesControlDialog::getInstance()->setPrePulseWidth(m_deviceNo,m_deviceChannel,value);
}
void ChannelDialog::on_minCurrentMinus_Btn_clicked()
{
int value = ui->minCurrent_Slider->value();
--value;
ui->minCurrent_Slider->setValue(value);
//测试使用2024.9.30
if(st_MuscleParam.connectState)
FesControlDialog::getInstance()->setPreCurrent(m_deviceNo,m_deviceChannel,value);
}
void ChannelDialog::on_minCurrentPlus_Btn_clicked()
{
int value = ui->minCurrent_Slider->value();
++value;
ui->minCurrent_Slider->setValue(value);
//测试使用2024.9.30
if(st_MuscleParam.connectState)
FesControlDialog::getInstance()->setPreCurrent(m_deviceNo,m_deviceChannel,value);
}
void ChannelDialog::on_maxCurrentMinus_Btn_clicked()
{
int value = ui->maxCurrent_Slider->value();
--value;
ui->maxCurrent_Slider->setValue(value);
//测试使用2024.9.30
if(st_MuscleParam.connectState)
FesControlDialog::getInstance()->setPreCurrent(m_deviceNo,m_deviceChannel,value);
}
void ChannelDialog::on_maxCurrentPlus_Btn_clicked()
{
int value = ui->maxCurrent_Slider->value();
++value;
ui->maxCurrent_Slider->setValue(value);
//测试使用2024.9.30
if(st_MuscleParam.connectState)
FesControlDialog::getInstance()->setPreCurrent(m_deviceNo,m_deviceChannel,value);
}
//通道开关
void ChannelDialog::on_switch_Btn_clicked()
{
if(ui->switch_Btn->styleSheet() == "border-image: url(:/DependFile/Source/gamePage/switchOn.png);")
{
ui->switch_Btn->setStyleSheet("border-image: url(:/DependFile/Source/gamePage/switchOff.png);");
st_MuscleParam.connectState = false;
//FesControlDialog::getInstance()->setPreCurrentState(,,false);
}
else if(ui->switch_Btn->styleSheet() == "border-image: url(:/DependFile/Source/gamePage/switchOff.png);")
{
st_MuscleParam.connectState = true;
ui->switch_Btn->setStyleSheet("border-image: url(:/DependFile/Source/gamePage/switchOn.png);");
}
}
void ChannelDialog::setMuscleState(QList<bool> muscleStateList)
{
//为了防止肌肉重复选择
// for(int i = 0;i < muscleStateList.size();i++)
// {
// if(muscleStateList.at(i))
// {
// m_buttonGroup->button(i+1)->setChecked(true);
// slotButtonClicked(i+1);
// slotButtonClicked(m_buttonGroup->button(i+1));
// break;
// }
// }
//已选择的肌肉设置为不可用
// foreach(QAbstractButton *button,m_buttonGroup->buttons())
// {
// QPushButton* pushButton = dynamic_cast<QPushButton*>(button);
// int id = m_buttonGroup->id(button);
// pushButton->setEnabled(muscleStateList.at(id-1));
// }
// for(int i = 0;i < m_buttonGroup->buttons().count();++i)
// {
// m_buttonGroup->buttons().at(i)->setEnabled(muscleStateList.at(i));
// }
}
void ChannelDialog::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event)
QPainter painter(this);
painter.fillRect(rect(),QColor(0,0,0,100));
}
void ChannelDialog::showEvent(QShowEvent *event)
{
Q_UNUSED(event)
ui->minCurrent_Slider->setRange(0,ui->maxCurrent_Slider->value());
ui->maxCurrent_Label->setText(QString::number(0));
//打开预设电流开关
if(st_MuscleParam.connectState)
FesControlDialog::getInstance()->setPreCurrentState(m_deviceNo,m_deviceChannel,true);
}
void ChannelDialog::changeEvent(QEvent* event)
{
Q_UNUSED(event)
#if 0
switch (event->type())
{
case QEvent::LanguageChange:
ui->retranslateUi(this);
QTimer::singleShot(300,this,[this](){
initWidget();
});
break;
default:
QWidget::changeEvent(event);
break;
}
#endif
}
void ChannelDialog::setFrequentRange(int min,int max)
{
ui->frequent_Slider->setRange(min,max);
}
void ChannelDialog::setPlusRange(int min,int max)
{
ui->plus_Slider->setRange(min,max);
}
void ChannelDialog::setMinCurrentRange(int min,int max)
{
ui->minCurrent_Slider->setRange(min,max);
ui->minCurrent_Label->setText("0");
}
void ChannelDialog::setMaxCurrentRange(int min,int max)
{
ui->maxCurrent_Slider->setRange(min,max);
ui->maxCurrent_Label->setText("0");
}
void ChannelDialog::setFrequentValue(int value)
{
ui->frequent_Slider->setValue(value);
}
void ChannelDialog::setPlusValue(int value)
{
ui->plus_Slider->setValue(value);
}
void ChannelDialog::setMinCurrentValue(int value)
{
ui->minCurrent_Slider->setValue(value);
ui->minCurrent_Label->setText(QString::number(value));
}
void ChannelDialog::setMaxCurrentValue(int value)
{
ui->maxCurrent_Slider->setValue(value);
}
void ChannelDialog::setMuscleId(int id)
{
if(id > 0 && id < 31)
{
m_buttonGroup->button(id)->setChecked(true);
m_buttonGroup->button(id)->click();
}
}
void ChannelDialog::setChannleDialogState(bool isRunning)
{
ui->groupBox->setEnabled(!isRunning);
ui->groupBox_3->setEnabled(!isRunning);
ui->groupBox_4->setEnabled(!isRunning);
ui->groupBox_5->setEnabled(!isRunning);
}
int *ChannelDialog::getMaxCurrentData()
{
return maxCurrentData;
}
void ChannelDialog::setMuscleConnectState(bool flag)
{
if(!flag)
{
ui->switch_Btn->setStyleSheet("border-image: url(:/DependFile/Source/gamePage/switchOff.png);");
st_MuscleParam.connectState = false;
//FesControlDialog::getInstance()->setPreCurrentState(,,false);
}
else if(flag)
{
st_MuscleParam.connectState = true;
ui->switch_Btn->setStyleSheet("border-image: url(:/DependFile/Source/gamePage/switchOn.png);");
}
}
void ChannelDialog::on_frequent_Slider_sliderReleased()
{
int value = ui->frequent_Label->text().toInt();
if(st_MuscleParam.connectState)
FesControlDialog::getInstance()->setPreFrequency(m_deviceNo,m_deviceChannel, value);
}
void ChannelDialog::on_plus_Slider_sliderReleased()
{
int value = ui->plus_Label->text().toInt();
if(st_MuscleParam.connectState)
FesControlDialog::getInstance()->setPrePulseWidth(m_deviceNo,m_deviceChannel,value);
}
void ChannelDialog::on_minCurrent_Slider_sliderReleased()
{
int value = ui->minCurrent_Label->text().toInt();
FesControlDialog::getInstance()->setPreCurrent(m_deviceNo,m_deviceChannel,value);
qDebug()<<"最小电流"<<value;
}
void ChannelDialog::on_maxCurrent_Slider_sliderReleased()
{
int value = ui->maxCurrent_Label->text().toInt();
FesControlDialog::getInstance()->setPreCurrent(m_deviceNo,m_deviceChannel,value);
qDebug()<<"最大电流"<<value;
}

View File

@@ -0,0 +1,107 @@
#ifndef CHANNELDIALOG_H
#define CHANNELDIALOG_H
/*********
* Fes参数界面下方刺激盒中按钮弹出的对话框
* ****/
#include <QDialog>
#include <QButtonGroup>
#include "dataformate.h"
#include "commonStruct.h"
namespace Ui {
class ChannelDialog;
}
class ChannelDialog : public QDialog
{
Q_OBJECT
public:
explicit ChannelDialog(QWidget *parent = nullptr);
~ChannelDialog();
void initWidget();
void setTitle(int title);
ST_MuscleParam getValue();
void setMuscleState(QList<bool>);
void setFrequentRange(int min,int max);
void setPlusRange(int min,int max);
void setMinCurrentRange(int min,int max);
void setMaxCurrentRange(int min,int max);
void setFrequentValue(int value);
void setPlusValue(int value);
void setMinCurrentValue(int value);
void setMaxCurrentValue(int value);
void setMuscleId(int id);
//是否运行
void setChannleDialogState(bool isRunning);
int* getMaxCurrentData(); //获取八个通道最大电流值
void setMuscleConnectState(bool flag); // 判断是否打开开关
protected:
void paintEvent(QPaintEvent *event);
void showEvent(QShowEvent *event);
virtual void changeEvent(QEvent* event);
private slots:
void on_confirm_Btn_clicked();
void on_frequentMinus_Btn_clicked();
void on_frequentPlus_Btn_clicked();
void on_frequent_Slider_valueChanged(int value);
void on_PWMMinus_Btn_clicked();
void on_PWMPlus_Btn_clicked();
void on_plus_Slider_valueChanged(int value);
void on_minCurrentMinus_Btn_clicked();
void on_minCurrentPlus_Btn_clicked();
void on_minCurrent_Slider_valueChanged(int value);
void on_maxCurrentMinus_Btn_clicked();
void on_maxCurrentPlus_Btn_clicked();
void on_maxCurrent_Slider_valueChanged(int value);
void on_switch_Btn_clicked();
void slotButtonClicked(int);
void slotButtonClicked(QAbstractButton*);
void on_frequent_Slider_sliderReleased();
void on_plus_Slider_sliderReleased();
void on_minCurrent_Slider_sliderReleased();
void on_maxCurrent_Slider_sliderReleased();
private:
Ui::ChannelDialog *ui;
QButtonGroup *m_buttonGroup;
ST_MuscleParam st_MuscleParam;
int m_currentChannel; //当前通道
AnalogSetting st_AnalogSetting;
int m_deviceNo; //当前设备号 1,2,3,4
int m_deviceChannel;//当前设备通道 1,2
int maxCurrentData[8]; //最大电流
};
#endif // CHANNELDIALOG_H

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,425 @@
#include "channelonlydialog.h"
#include "ui_channelonlydialog.h"
#include <QDebug>
#include <QPainter>
#include <QTimer>
#include <QMessageBox>
#include "fescontroldialog.h"
#include "icemodule.h"
#include <QDateTime>
ChannelOnlyDialog::ChannelOnlyDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::ChannelOnlyDialog)
{
ui->setupUi(this);
this->setWindowFlags(Qt::FramelessWindowHint); //设置无边框
setAttribute(Qt::WA_TranslucentBackground,true); //设置透明
initWidget();
st_MuscleParam.connectState = true;
for(int i=0; i<8; i++)
maxCurrentData[i] = 0;
st_AnalogSetting.breakTime = 0;
st_AnalogSetting.fallingTime = 10;
st_AnalogSetting.holdingTime = 100;
st_AnalogSetting.risingTime = 10;
st_AnalogSetting.frequency = 50; //0~100Hz
st_AnalogSetting.pulseWidth = 100; //0~500us
st_AnalogSetting.samplerate = SamplingRate4K;
st_AnalogSetting.workmode = WorkModeStimulate;
//限制最大和最小电流滑块
QObject::connect(ui->minCurrent_Slider, &QSlider::valueChanged, [this](int value) {
if (value > ui->maxCurrent_Slider->value()) {
ui->minCurrent_Slider->setValue(ui->maxCurrent_Slider->value());
}
});
}
ChannelOnlyDialog::~ChannelOnlyDialog()
{
delete ui;
}
void ChannelOnlyDialog::initWidget()
{
ui->maxCurrent_Slider->setRange(0,100);
}
void ChannelOnlyDialog::setTitle(int title)
{
QString strTitle;
switch(title)
{
case 1:
case 2:
strTitle = QString(tr("通道A%1").arg(title%2 ? 1:2));
break;
case 3:
case 4:
strTitle = QString(tr("通道B%1").arg(title%2 ? 1:2));
break;
case 5:
case 6:
strTitle = QString(tr("通道C%1").arg(title%2 ? 1:2));
break;
case 7:
case 8:
strTitle = QString(tr("通道D%1").arg(title%2 ? 1:2));
break;
}
ui->channelName_Label->setText(strTitle);
m_currentChannel = title;
m_deviceNo = m_currentChannel/2 + (m_currentChannel%2?1:0);
m_deviceChannel = m_currentChannel%2 ? 1:2;
/********电刺激操作流程*********/
}
void ChannelOnlyDialog::setMuscleConnectState(bool flag)
{
if(!flag)
{
ui->switch_Btn->setStyleSheet("border-image: url(:/DependFile/Source/gamePage/switchOff.png);");
st_MuscleParam.connectState = false;
//FesControlDialog::getInstance()->setPreCurrentState(,,false);
}
else if(flag)
{
st_MuscleParam.connectState = true;
ui->switch_Btn->setStyleSheet("border-image: url(:/DependFile/Source/gamePage/switchOn.png);");
}
}
ST_MuscleParam ChannelOnlyDialog::getValue()
{
return st_MuscleParam;
}
void ChannelOnlyDialog::setFrequentRange(int min, int max)
{
ui->frequent_Slider->setRange(min,max);
}
void ChannelOnlyDialog::setPlusRange(int min, int max)
{
ui->plus_Slider->setRange(min,max);
}
void ChannelOnlyDialog::setMinCurrentRange(int min, int max)
{
ui->minCurrent_Slider->setRange(min,max);
ui->minCurrent_Label->setText("0");
}
void ChannelOnlyDialog::setMaxCurrentRange(int min, int max)
{
ui->maxCurrent_Slider->setRange(min,max);
ui->maxCurrent_Label->setText("0");
}
void ChannelOnlyDialog::setFrequentValue(int value)
{
ui->frequent_Slider->setValue(value);
}
void ChannelOnlyDialog::setPlusValue(int value)
{
ui->plus_Slider->setValue(value);
}
void ChannelOnlyDialog::setMinCurrentValue(int value)
{
ui->minCurrent_Slider->setValue(value);
ui->minCurrent_Label->setText(QString::number(value));
}
void ChannelOnlyDialog::setMaxCurrentValue(int value)
{
ui->maxCurrent_Slider->setValue(value);
}
int *ChannelOnlyDialog::getMaxCurrentData()
{
return maxCurrentData;
}
void ChannelOnlyDialog::setMuscleState(QList<bool>)
{
//为了防止肌肉重复选择
// for(int i = 0;i < muscleStateList.size();i++)
// {
// if(muscleStateList.at(i))
// {
// m_buttonGroup->button(i+1)->setChecked(true);
// slotButtonClicked(i+1);
// slotButtonClicked(m_buttonGroup->button(i+1));
// break;
// }
// }
//已选择的肌肉设置为不可用
// foreach(QAbstractButton *button,m_buttonGroup->buttons())
// {
// QPushButton* pushButton = dynamic_cast<QPushButton*>(button);
// int id = m_buttonGroup->id(button);
// pushButton->setEnabled(muscleStateList.at(id-1));
// }
// for(int i = 0;i < m_buttonGroup->buttons().count();++i)
// {
// m_buttonGroup->buttons().at(i)->setEnabled(muscleStateList.at(i));
// }
}
void ChannelOnlyDialog::on_confirm_Btn_clicked()
{
st_MuscleParam.plus = ui->plus_Label->text().toInt();
st_MuscleParam.minCurrent = ui->minCurrent_Label->text().toInt();
st_MuscleParam.frequency = ui->frequent_Label->text().toInt();
st_MuscleParam.maxCurrent = ui->maxCurrent_Label->text().toInt();
//st_MuscleParam.muscleName == "";//设置肌肉名称
//关闭预设电流开关
if(st_MuscleParam.connectState)
{
FesControlDialog::getInstance()->setPreCurrentState(m_deviceNo,m_deviceChannel,false);
int index = (m_deviceNo-1)*2 + m_deviceChannel-1;
maxCurrentData[index] = st_MuscleParam.maxCurrent;
qDebug() << "index:"<<index;
IceModule::getInstance()->setMaxCurrentValue(index,st_MuscleParam.maxCurrent);
}
// FesControlDialog::getInstance()->setMuscleDeviceStateByNo(m_deviceNo,true);; //添加已经更改肌肉的设备
FesControlDialog::getInstance()->setMuscleDeviceStateByNo(m_deviceNo,true);; //添加已经更改肌肉的设备
this->hide();
//qDebug() <<"Hello";
}
void ChannelOnlyDialog::on_frequentMinus_Btn_clicked()
{
int value = ui->frequent_Slider->value();
--value;
ui->frequent_Slider->setValue(value);
//FesControlDialog::getInstance()->setPreFrequency(m_deviceNo,m_deviceChannel, value);
//FesControlDialog::getInstance()->setPreCurrentState(m_deviceNo,m_deviceChannel,true);
}
void ChannelOnlyDialog::on_frequentPlus_Btn_clicked()
{
int value = ui->frequent_Slider->value();
++value;
ui->frequent_Slider->setValue(value);
//FesControlDialog::getInstance()->setPreCurrentState(m_deviceNo,m_deviceChannel,true);
//FesControlDialog::getInstance()->setPreFrequency(m_deviceNo,m_deviceChannel, value);
}
void ChannelOnlyDialog::on_frequent_Slider_valueChanged(int value)
{
ui->frequent_Label->setText(QString::number(value));
st_AnalogSetting.frequency = value;
//qDebug() <<m_deviceNo << m_deviceChannel;
}
void ChannelOnlyDialog::on_plus_Slider_valueChanged(int value)
{
ui->plus_Label->setText(QString::number(value));
st_AnalogSetting.pulseWidth = value;
}
void ChannelOnlyDialog::on_minCurrent_Slider_valueChanged(int value)
{
ui->minCurrent_Label->setText(QString::number(value));
static int times = 0;
if(st_MuscleParam.connectState)
{
times++;
if(times > 20) //100ms
{
FesControlDialog::getInstance()->setPreCurrent(m_deviceNo,m_deviceChannel,value);
times = 0;
}
}
}
void ChannelOnlyDialog::on_maxCurrent_Slider_valueChanged(int value)
{
ui->maxCurrent_Label->setText(QString::number(value));
ui->minCurrent_Slider->setRange(0,99);
ui->minCurrent_Slider->setPageStep(value);
//ui->minCurrent_Slider->setMaximum(value);
static int times = 0;
if(st_MuscleParam.connectState)
{
times++;
if(times > 20) //100ms
{
FesControlDialog::getInstance()->setPreCurrent(m_deviceNo,m_deviceChannel,value);
times = 0;
}
}
}
void ChannelOnlyDialog::on_PWMMinus_Btn_clicked()
{
int value = ui->plus_Slider->value();
value -= 10;
ui->plus_Slider->setValue(value);
//FesControlDialog::getInstance()->setPrePulseWidth(m_deviceNo,m_deviceChannel,value);
}
void ChannelOnlyDialog::on_PWMPlus_Btn_clicked()
{
int value = ui->plus_Slider->value();
value += 10;
ui->plus_Slider->setValue(value);
//FesControlDialog::getInstance()->setPrePulseWidth(m_deviceNo,m_deviceChannel,value);
}
void ChannelOnlyDialog::on_minCurrentMinus_Btn_clicked()
{
int value = ui->minCurrent_Slider->value();
--value;
ui->minCurrent_Slider->setValue(value);
//测试使用2024.9.30
if(st_MuscleParam.connectState)
FesControlDialog::getInstance()->setPreCurrent(m_deviceNo,m_deviceChannel,value);
}
void ChannelOnlyDialog::on_minCurrentPlus_Btn_clicked()
{
int value = ui->minCurrent_Slider->value();
++value;
ui->minCurrent_Slider->setValue(value);
//测试使用2024.9.30
if(st_MuscleParam.connectState)
FesControlDialog::getInstance()->setPreCurrent(m_deviceNo,m_deviceChannel,value);
}
void ChannelOnlyDialog::on_maxCurrentMinus_Btn_clicked()
{
int value = ui->maxCurrent_Slider->value();
--value;
ui->maxCurrent_Slider->setValue(value);
//测试使用2024.9.30
if(st_MuscleParam.connectState)
FesControlDialog::getInstance()->setPreCurrent(m_deviceNo,m_deviceChannel,value);
}
void ChannelOnlyDialog::on_maxCurrentPlus_Btn_clicked()
{
int value = ui->maxCurrent_Slider->value();
++value;
ui->maxCurrent_Slider->setValue(value);
//测试使用2024.9.30
if(st_MuscleParam.connectState)
FesControlDialog::getInstance()->setPreCurrent(m_deviceNo,m_deviceChannel,value);
}
void ChannelOnlyDialog::on_switch_Btn_clicked()
{
if(ui->switch_Btn->styleSheet() == "border-image: url(:/DependFile/Source/gamePage/switchOn.png);")
{
ui->switch_Btn->setStyleSheet("border-image: url(:/DependFile/Source/gamePage/switchOff.png);");
st_MuscleParam.connectState = false;
//FesControlDialog::getInstance()->setPreCurrentState(,,false);
}
else if(ui->switch_Btn->styleSheet() == "border-image: url(:/DependFile/Source/gamePage/switchOff.png);")
{
st_MuscleParam.connectState = true;
ui->switch_Btn->setStyleSheet("border-image: url(:/DependFile/Source/gamePage/switchOn.png);");
}
}
void ChannelOnlyDialog::on_frequent_Slider_sliderReleased()
{
int value = ui->frequent_Label->text().toInt();
if(st_MuscleParam.connectState)
FesControlDialog::getInstance()->setPreFrequency(m_deviceNo,m_deviceChannel, value);
}
void ChannelOnlyDialog::on_plus_Slider_sliderReleased()
{
int value = ui->plus_Label->text().toInt();
if(st_MuscleParam.connectState)
FesControlDialog::getInstance()->setPrePulseWidth(m_deviceNo,m_deviceChannel,value);
}
void ChannelOnlyDialog::on_minCurrent_Slider_sliderReleased()
{
int value = ui->minCurrent_Label->text().toInt();
FesControlDialog::getInstance()->setPreCurrent(m_deviceNo,m_deviceChannel,value);
qDebug()<<"最小电流"<<value;
}
void ChannelOnlyDialog::on_maxCurrent_Slider_sliderReleased()
{
int value = ui->maxCurrent_Label->text().toInt();
FesControlDialog::getInstance()->setPreCurrent(m_deviceNo,m_deviceChannel,value);
qDebug()<<"最大电流"<<value;
}
void ChannelOnlyDialog::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event)
QPainter painter(this);
painter.fillRect(rect(),QColor(0,0,0,100));
}
void ChannelOnlyDialog::showEvent(QShowEvent *event)
{
Q_UNUSED(event)
ui->minCurrent_Slider->setRange(0,ui->maxCurrent_Slider->value());
ui->maxCurrent_Label->setText(QString::number(0));
//打开预设电流开关
if(st_MuscleParam.connectState)
FesControlDialog::getInstance()->setPreCurrentState(m_deviceNo,m_deviceChannel,true);
}
void ChannelOnlyDialog::chcangeEvent(QEvent *event)
{
Q_UNUSED(event)
#if 0
switch (event->type())
{
case QEvent::LanguageChange:
ui->retranslateUi(this);
QTimer::singleShot(300,this,[this](){
initWidget();
});
break;
default:
QWidget::changeEvent(event);
break;
}
#endif
}

View File

@@ -0,0 +1,97 @@
#ifndef CHANNELONLYDIALOG_H
#define CHANNELONLYDIALOG_H
#include <QDialog>
#include <QButtonGroup>
#include "dataformate.h"
#include "commonStruct.h"
namespace Ui {
class ChannelOnlyDialog;
}
class ChannelOnlyDialog : public QDialog
{
Q_OBJECT
public:
explicit ChannelOnlyDialog(QWidget *parent = nullptr);
~ChannelOnlyDialog();
void initWidget();
void setTitle(int title);
void setMuscleConnectState(bool flag); // 判断是否打开开关
ST_MuscleParam getValue();
void setFrequentRange(int min,int max);
void setPlusRange(int min,int max);
void setMinCurrentRange(int min,int max);
void setMaxCurrentRange(int min,int max);
void setFrequentValue(int value);
void setPlusValue(int value);
void setMinCurrentValue(int value);
void setMaxCurrentValue(int value);
int* getMaxCurrentData(); //获取八个通道最大电流值
void setMuscleState(QList<bool>);
private slots:
void on_confirm_Btn_clicked();
void on_frequentMinus_Btn_clicked();
void on_frequentPlus_Btn_clicked();
void on_frequent_Slider_valueChanged(int value);
void on_plus_Slider_valueChanged(int value);
void on_minCurrent_Slider_valueChanged(int value);
void on_maxCurrent_Slider_valueChanged(int value);
void on_PWMMinus_Btn_clicked();
void on_PWMPlus_Btn_clicked();
void on_minCurrentMinus_Btn_clicked();
void on_minCurrentPlus_Btn_clicked();
void on_maxCurrentMinus_Btn_clicked();
void on_maxCurrentPlus_Btn_clicked();
void on_switch_Btn_clicked();
void on_frequent_Slider_sliderReleased();
void on_plus_Slider_sliderReleased();
void on_minCurrent_Slider_sliderReleased();
void on_maxCurrent_Slider_sliderReleased();
protected:
void paintEvent(QPaintEvent *event);
void showEvent(QShowEvent *event);
virtual void chcangeEvent(QEvent* event);
private:
Ui::ChannelOnlyDialog *ui;
ST_MuscleParam st_MuscleParam;
int m_currentChannel; //当前通道
AnalogSetting st_AnalogSetting;
int m_deviceNo; //当前设备号 1,2,3,4
int m_deviceChannel;//当前设备通道 1,2
int maxCurrentData[8]; //最大电流
};
#endif // CHANNELONLYDIALOG_H

View File

@@ -0,0 +1,662 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ChannelOnlyDialog</class>
<widget class="QDialog" name="ChannelOnlyDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1920</width>
<height>1080</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QGroupBox" name="groupBox_8">
<property name="geometry">
<rect>
<x>176</x>
<y>50</y>
<width>1568</width>
<height>962</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">#groupBox_8{background: #FFFFFF;border-radius: 8px;}</string>
</property>
<property name="title">
<string/>
</property>
<widget class="QPushButton" name="confirm_Btn">
<property name="geometry">
<rect>
<x>0</x>
<y>908</y>
<width>1568</width>
<height>54</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>15</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">background: #05A6EC;
border-radius: 8px;
color:white;</string>
</property>
<property name="text">
<string>确认</string>
</property>
</widget>
<widget class="QGroupBox" name="groupBox_6">
<property name="geometry">
<rect>
<x>900</x>
<y>493</y>
<width>360</width>
<height>313</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">#groupBox_6{background: #E4F4FC;
border-radius: 4px;}</string>
</property>
<property name="title">
<string/>
</property>
<widget class="QLabel" name="maxCurrent_Label1">
<property name="geometry">
<rect>
<x>79</x>
<y>19</y>
<width>151</width>
<height>61</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>最大电流</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
<widget class="QLabel" name="label_13">
<property name="geometry">
<rect>
<x>240</x>
<y>40</y>
<width>51</width>
<height>21</height>
</rect>
</property>
<property name="font">
<font>
<family>微软雅黑</family>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>mA</string>
</property>
</widget>
<widget class="QLabel" name="maxCurrent_Label">
<property name="geometry">
<rect>
<x>60</x>
<y>84</y>
<width>240</width>
<height>60</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>25</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">background: #FFFFFF;
border-radius: 30px;
border: 1px solid #05A6EC;</string>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QPushButton" name="maxCurrentMinus_Btn">
<property name="geometry">
<rect>
<x>70</x>
<y>160</y>
<width>60</width>
<height>60</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">border-image: url(:/DependFile/Source/channel/minus.png);</string>
</property>
<property name="text">
<string/>
</property>
<property name="autoRepeat">
<bool>true</bool>
</property>
</widget>
<widget class="QPushButton" name="maxCurrentPlus_Btn">
<property name="geometry">
<rect>
<x>220</x>
<y>160</y>
<width>60</width>
<height>60</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">border-image: url(:/DependFile/Source/channel/plus.png);</string>
</property>
<property name="text">
<string/>
</property>
<property name="autoRepeat">
<bool>true</bool>
</property>
</widget>
<widget class="QSlider" name="maxCurrent_Slider">
<property name="geometry">
<rect>
<x>30</x>
<y>240</y>
<width>300</width>
<height>43</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</widget>
<widget class="QGroupBox" name="groupBox_4">
<property name="geometry">
<rect>
<x>900</x>
<y>140</y>
<width>360</width>
<height>313</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">#groupBox_4{background: #E4F4FC;
border-radius: 4px;}</string>
</property>
<property name="title">
<string/>
</property>
<widget class="QLabel" name="plus_Label1">
<property name="geometry">
<rect>
<x>125</x>
<y>19</y>
<width>91</width>
<height>61</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>脉宽</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
<widget class="QLabel" name="label_7">
<property name="geometry">
<rect>
<x>220</x>
<y>40</y>
<width>61</width>
<height>21</height>
</rect>
</property>
<property name="font">
<font>
<family>微软雅黑</family>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>us</string>
</property>
</widget>
<widget class="QLabel" name="plus_Label">
<property name="geometry">
<rect>
<x>60</x>
<y>84</y>
<width>240</width>
<height>60</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>25</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">background: #FFFFFF;
border-radius: 30px;
border: 1px solid #05A6EC;</string>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QPushButton" name="PWMMinus_Btn">
<property name="geometry">
<rect>
<x>70</x>
<y>160</y>
<width>60</width>
<height>60</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">border-image: url(:/DependFile/Source/channel/minus.png);</string>
</property>
<property name="text">
<string/>
</property>
<property name="autoRepeat">
<bool>true</bool>
</property>
</widget>
<widget class="QPushButton" name="PWMPlus_Btn">
<property name="geometry">
<rect>
<x>220</x>
<y>160</y>
<width>60</width>
<height>60</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">border-image: url(:/DependFile/Source/channel/plus.png);</string>
</property>
<property name="text">
<string/>
</property>
<property name="autoRepeat">
<bool>true</bool>
</property>
</widget>
<widget class="QSlider" name="plus_Slider">
<property name="geometry">
<rect>
<x>30</x>
<y>240</y>
<width>300</width>
<height>43</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</widget>
<widget class="QGroupBox" name="groupBox_5">
<property name="geometry">
<rect>
<x>320</x>
<y>495</y>
<width>360</width>
<height>313</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">#groupBox_5{background: #E4F4FC;
border-radius: 4px;}</string>
</property>
<property name="title">
<string/>
</property>
<widget class="QLabel" name="minCurrent_Label1">
<property name="geometry">
<rect>
<x>89</x>
<y>19</y>
<width>141</width>
<height>61</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>最小电流</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
<widget class="QLabel" name="label_10">
<property name="geometry">
<rect>
<x>240</x>
<y>40</y>
<width>51</width>
<height>21</height>
</rect>
</property>
<property name="font">
<font>
<family>微软雅黑</family>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>mA</string>
</property>
</widget>
<widget class="QLabel" name="minCurrent_Label">
<property name="geometry">
<rect>
<x>60</x>
<y>84</y>
<width>240</width>
<height>60</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>25</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">background: #FFFFFF;
border-radius: 30px;
border: 1px solid #05A6EC;</string>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QPushButton" name="minCurrentMinus_Btn">
<property name="geometry">
<rect>
<x>60</x>
<y>160</y>
<width>60</width>
<height>60</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">border-image: url(:/DependFile/Source/channel/minus.png);</string>
</property>
<property name="text">
<string/>
</property>
<property name="autoRepeat">
<bool>true</bool>
</property>
</widget>
<widget class="QPushButton" name="minCurrentPlus_Btn">
<property name="geometry">
<rect>
<x>230</x>
<y>160</y>
<width>60</width>
<height>60</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">border-image: url(:/DependFile/Source/channel/plus.png);</string>
</property>
<property name="text">
<string/>
</property>
<property name="autoRepeat">
<bool>true</bool>
</property>
</widget>
<widget class="QSlider" name="minCurrent_Slider">
<property name="geometry">
<rect>
<x>30</x>
<y>240</y>
<width>300</width>
<height>43</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</widget>
<widget class="QGroupBox" name="groupBox_3">
<property name="geometry">
<rect>
<x>320</x>
<y>140</y>
<width>360</width>
<height>313</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">#groupBox_3{background: #E4F4FC;
border-radius: 4px;}</string>
</property>
<property name="title">
<string/>
</property>
<widget class="QLabel" name="label_3">
<property name="geometry">
<rect>
<x>125</x>
<y>19</y>
<width>91</width>
<height>61</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>频率</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
<widget class="QLabel" name="label_4">
<property name="geometry">
<rect>
<x>220</x>
<y>40</y>
<width>51</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>Hz</string>
</property>
</widget>
<widget class="QLabel" name="frequent_Label">
<property name="geometry">
<rect>
<x>60</x>
<y>84</y>
<width>240</width>
<height>60</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>25</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">background: #FFFFFF;
border-radius: 30px;
border: 1px solid #05A6EC;</string>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QPushButton" name="frequentMinus_Btn">
<property name="geometry">
<rect>
<x>60</x>
<y>160</y>
<width>60</width>
<height>60</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">border-image: url(:/DependFile/Source/channel/minus.png);</string>
</property>
<property name="text">
<string/>
</property>
<property name="autoRepeat">
<bool>true</bool>
</property>
</widget>
<widget class="QPushButton" name="frequentPlus_Btn">
<property name="geometry">
<rect>
<x>230</x>
<y>160</y>
<width>60</width>
<height>60</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">border-image: url(:/DependFile/Source/channel/plus.png);</string>
</property>
<property name="text">
<string/>
</property>
<property name="autoRepeat">
<bool>true</bool>
</property>
</widget>
<widget class="QSlider" name="frequent_Slider">
<property name="geometry">
<rect>
<x>30</x>
<y>240</y>
<width>300</width>
<height>43</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</widget>
<widget class="QLabel" name="channelName_Label">
<property name="geometry">
<rect>
<x>660</x>
<y>14</y>
<width>241</width>
<height>51</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>15</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QPushButton" name="switch_Btn">
<property name="geometry">
<rect>
<x>1440</x>
<y>20</y>
<width>67</width>
<height>40</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">border-image: url(:/DependFile/Source/gamePage/switchOn.png);</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</widget>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -0,0 +1,14 @@
#include "clickmachine.h"
#include "ui_clickmachine.h"
ClickMachine::ClickMachine(QWidget *parent) :
QWidget(parent),
ui(new Ui::ClickMachine)
{
ui->setupUi(this);
}
ClickMachine::~ClickMachine()
{
delete ui;
}

View File

@@ -0,0 +1,22 @@
#ifndef CLICKMACHINE_H
#define CLICKMACHINE_H
#include <QWidget>
namespace Ui {
class ClickMachine;
}
class ClickMachine : public QWidget
{
Q_OBJECT
public:
explicit ClickMachine(QWidget *parent = nullptr);
~ClickMachine();
private:
Ui::ClickMachine *ui;
};
#endif // CLICKMACHINE_H

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ClickMachine</class>
<widget class="QWidget" name="ClickMachine">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<property name="styleSheet">
<string notr="true">#groupBox{background: #FFFFFF;
border-radius: 32px;}</string>
</property>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -0,0 +1,14 @@
#include "clickmachinedialog.h"
#include "ui_clickmachinedialog.h"
ClickMachineDialog::ClickMachineDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::ClickMachineDialog)
{
ui->setupUi(this);
}
ClickMachineDialog::~ClickMachineDialog()
{
delete ui;
}

View File

@@ -0,0 +1,22 @@
#ifndef CLICKMACHINEDIALOG_H
#define CLICKMACHINEDIALOG_H
#include <QDialog>
namespace Ui {
class ClickMachineDialog;
}
class ClickMachineDialog : public QDialog
{
Q_OBJECT
public:
explicit ClickMachineDialog(QWidget *parent = nullptr);
~ClickMachineDialog();
private:
Ui::ClickMachineDialog *ui;
};
#endif // CLICKMACHINEDIALOG_H

View File

@@ -0,0 +1,155 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ClickMachineDialog</class>
<widget class="QDialog" name="ClickMachineDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>500</width>
<height>400</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<property name="styleSheet">
<string notr="true">#groupBox{background: #FFFFFF;
border-radius: 32px;}</string>
</property>
<widget class="QGroupBox" name="groupBox">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>500</width>
<height>400</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">#groupBox{background: #FFFFFF;
border-radius: 32px;}</string>
</property>
<property name="title">
<string/>
</property>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>500</width>
<height>70</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>15</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">border-image: url(:/DependFile/Source/gamePage/dialog.png);</string>
</property>
<property name="text">
<string>提示</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="tips_Label">
<property name="geometry">
<rect>
<x>100</x>
<y>180</y>
<width>301</width>
<height>71</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>18</pointsize>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>一键上机,设备将运行,请注意安全</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
<widget class="QPushButton" name="confirm_Btn">
<property name="geometry">
<rect>
<x>0</x>
<y>320</y>
<width>251</width>
<height>81</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">border-radius: 4px;
border: 1px solid #0D9DDB;
color:#0D9DDB;</string>
</property>
<property name="text">
<string>结束</string>
</property>
</widget>
<widget class="QLabel" name="image_Label">
<property name="geometry">
<rect>
<x>220</x>
<y>110</y>
<width>71</width>
<height>71</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">border-image: url(:/DependFile/Source/dialog/spasm.png);</string>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QPushButton" name="confirm_Btn_2">
<property name="geometry">
<rect>
<x>250</x>
<y>320</y>
<width>251</width>
<height>81</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">border-radius: 4px;
border: 1px solid #0D9DDB;
color:#0D9DDB;</string>
</property>
<property name="text">
<string>下一步</string>
</property>
</widget>
</widget>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -0,0 +1,59 @@
#include "deletereportdialog.h"
#include "ui_deletereportdialog.h"
#include <QPainter>
DeleteReportDialog::DeleteReportDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::DeleteReportDialog)
{
ui->setupUi(this);
this->setWindowFlags(Qt::FramelessWindowHint); //设置无边框
setAttribute(Qt::WA_TranslucentBackground,true); //设置透明
}
DeleteReportDialog::~DeleteReportDialog()
{
delete ui;
}
bool DeleteReportDialog::isDeletedUser()
{
return m_isdeleted;
}
void DeleteReportDialog::on_cancel_Btn_clicked()
{
m_isdeleted = false;
this->close();
}
void DeleteReportDialog::on_confirm_Btn_clicked()
{
m_isdeleted = true;
this->close();
}
void DeleteReportDialog::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event)
QPainter painter(this);
painter.fillRect(rect(),QColor(0,0,0,100));
}
void DeleteReportDialog::changeEvent(QEvent* event)
{
switch (event->type())
{
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
QWidget::changeEvent(event);
break;
}
}

View File

@@ -0,0 +1,34 @@
#ifndef DELETEREPORTDIALOG_H
#define DELETEREPORTDIALOG_H
#include <QDialog>
namespace Ui {
class DeleteReportDialog;
}
class DeleteReportDialog : public QDialog
{
Q_OBJECT
public:
explicit DeleteReportDialog(QWidget *parent = nullptr);
~DeleteReportDialog();
bool isDeletedUser();
protected:
void paintEvent(QPaintEvent *event);
virtual void changeEvent(QEvent* event);
private slots:
void on_cancel_Btn_clicked();
void on_confirm_Btn_clicked();
private:
bool m_isdeleted;
private:
Ui::DeleteReportDialog *ui;
};
#endif // DELETEREPORTDIALOG_H

View File

@@ -0,0 +1,157 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DeleteReportDialog</class>
<widget class="QDialog" name="DeleteReportDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1920</width>
<height>1080</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QGroupBox" name="groupBox">
<property name="geometry">
<rect>
<x>558</x>
<y>241</y>
<width>804</width>
<height>598</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">#groupBox{background: #FFFFFF;
border-radius: 32px;}</string>
</property>
<property name="title">
<string/>
</property>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>804</width>
<height>64</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>15</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">border-image: url(:/DependFile/Source/gamePage/dialog.png);</string>
</property>
<property name="text">
<string>提示</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>90</x>
<y>190</y>
<width>641</width>
<height>71</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>25</pointsize>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>确认是否删除报告</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="label_3">
<property name="geometry">
<rect>
<x>140</x>
<y>290</y>
<width>541</width>
<height>51</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>18</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">color:#000000 ;</string>
</property>
<property name="text">
<string>删除后无法恢复</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QPushButton" name="cancel_Btn">
<property name="geometry">
<rect>
<x>232</x>
<y>493</y>
<width>120</width>
<height>45</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">border-radius: 4px;
border: 1px solid #0D9DDB;
color:#0D9DDB;</string>
</property>
<property name="text">
<string>取消</string>
</property>
</widget>
<widget class="QPushButton" name="confirm_Btn">
<property name="geometry">
<rect>
<x>452</x>
<y>493</y>
<width>120</width>
<height>45</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">border-radius: 4px;
border: 1px solid #0D9DDB;
color:#0D9DDB;</string>
</property>
<property name="text">
<string>确认</string>
</property>
</widget>
</widget>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -0,0 +1,56 @@
#include "deleteuserdialog.h"
#include "ui_deleteuserdialog.h"
#include <QPainter>
#include <QPaintEvent>
DeleteUserDialog::DeleteUserDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::DeleteUserDialog),
m_isdeleted(false)
{
ui->setupUi(this);
this->setWindowFlags(Qt::FramelessWindowHint); //设置无边框
setAttribute(Qt::WA_TranslucentBackground,true); //设置透明
}
DeleteUserDialog::~DeleteUserDialog()
{
delete ui;
}
bool DeleteUserDialog::isDeletedUser()
{
return m_isdeleted;
}
void DeleteUserDialog::on_cancel_Btn_clicked()
{
m_isdeleted = false;
this->close();
}
void DeleteUserDialog::on_confirm_Btn_clicked()
{
m_isdeleted = true;
this->close();
}
void DeleteUserDialog::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event)
QPainter painter(this);
painter.fillRect(rect(),QColor(0,0,0,100));
}
void DeleteUserDialog::changeEvent(QEvent* event)
{
switch (event->type())
{
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
QWidget::changeEvent(event);
break;
}
}

View File

@@ -0,0 +1,34 @@
#ifndef DELETEUSERDIALOG_H
#define DELETEUSERDIALOG_H
#include <QDialog>
namespace Ui {
class DeleteUserDialog;
}
class DeleteUserDialog : public QDialog
{
Q_OBJECT
public:
explicit DeleteUserDialog(QWidget *parent = nullptr);
~DeleteUserDialog();
bool isDeletedUser();
protected:
void paintEvent(QPaintEvent *event);
virtual void changeEvent(QEvent* event);
private slots:
void on_cancel_Btn_clicked();
void on_confirm_Btn_clicked();
private:
Ui::DeleteUserDialog *ui;
bool m_isdeleted;
};
#endif // DELETEUSERDIALOG_H

View File

@@ -0,0 +1,157 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DeleteUserDialog</class>
<widget class="QDialog" name="DeleteUserDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1920</width>
<height>1080</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QGroupBox" name="groupBox">
<property name="geometry">
<rect>
<x>558</x>
<y>241</y>
<width>804</width>
<height>598</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">#groupBox{background: #FFFFFF;
border-radius: 32px;}</string>
</property>
<property name="title">
<string/>
</property>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>804</width>
<height>64</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>15</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">border-image: url(:/DependFile/Source/gamePage/dialog.png);</string>
</property>
<property name="text">
<string>提示</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>100</x>
<y>190</y>
<width>601</width>
<height>71</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>25</pointsize>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>确认是否删除用户</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="label_3">
<property name="geometry">
<rect>
<x>130</x>
<y>290</y>
<width>551</width>
<height>51</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>18</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">color:#000000 ;</string>
</property>
<property name="text">
<string>删除后无法恢复</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QPushButton" name="cancel_Btn">
<property name="geometry">
<rect>
<x>232</x>
<y>493</y>
<width>120</width>
<height>45</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">border-radius: 4px;
border: 1px solid #0D9DDB;
color:#0D9DDB;</string>
</property>
<property name="text">
<string>取消</string>
</property>
</widget>
<widget class="QPushButton" name="confirm_Btn">
<property name="geometry">
<rect>
<x>452</x>
<y>493</y>
<width>120</width>
<height>45</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">border-radius: 4px;
border: 1px solid #0D9DDB;
color:#0D9DDB;</string>
</property>
<property name="text">
<string>确认</string>
</property>
</widget>
</widget>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -0,0 +1,77 @@
#include "emergencystopdialog.h"
#include "ui_emergencystopdialog.h"
#include <QPainter>
#include <QDebug>
EmergencyStopDialog::EmergencyStopDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::EmergencyStopDialog),
bells("./DependFile/Music/emergency.wav")
{
ui->setupUi(this);
this->setWindowFlags(Qt::FramelessWindowHint); //设置无边框
setAttribute(Qt::WA_TranslucentBackground,true); //设置透明
//设置报警音无线循环
bells.setLoops(-1);
}
EmergencyStopDialog::~EmergencyStopDialog()
{
delete ui;
}
void EmergencyStopDialog::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event)
QPainter painter(this);
painter.fillRect(rect(),QColor(0,0,0,100));
}
void EmergencyStopDialog::showEvent(QShowEvent *event)
{
Q_UNUSED(event)
playBell();
}
void EmergencyStopDialog::closeEvent(QCloseEvent *event)
{
Q_UNUSED(event)
stopPlayBell();
}
void EmergencyStopDialog::on_emergency_Btn_clicked()
{
static int closeTime;
closeTime++;
if(closeTime > 30)
{
closeTime = 0;
this->close();
}
}
//痉挛报警音控制
void EmergencyStopDialog::playBell()
{
bells.play();
}
//停止报警音
void EmergencyStopDialog::stopPlayBell()
{
if(bells.loopsRemaining())
bells.stop();
}
void EmergencyStopDialog::changeEvent(QEvent* event)
{
switch (event->type())
{
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
QWidget::changeEvent(event);
break;
}
}

View File

@@ -0,0 +1,38 @@
#ifndef EMERGENCYSTOPDIALOG_H
#define EMERGENCYSTOPDIALOG_H
#include <QDialog>
#include <QSound>
namespace Ui {
class EmergencyStopDialog;
}
class EmergencyStopDialog : public QDialog
{
Q_OBJECT
public:
explicit EmergencyStopDialog(QWidget *parent = nullptr);
~EmergencyStopDialog();
//痉挛报警音控制
void playBell();
//停止报警音
void stopPlayBell();
protected:
void paintEvent(QPaintEvent *event);
void showEvent(QShowEvent *event);
void closeEvent(QCloseEvent *event);
virtual void changeEvent(QEvent* event);
private slots:
void on_emergency_Btn_clicked();
private:
Ui::EmergencyStopDialog *ui;
QSound bells; //铃声对象
};
#endif // EMERGENCYSTOPDIALOG_H

View File

@@ -0,0 +1,109 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>EmergencyStopDialog</class>
<widget class="QDialog" name="EmergencyStopDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1920</width>
<height>1080</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<widget class="QGroupBox" name="groupBox">
<property name="geometry">
<rect>
<x>710</x>
<y>340</y>
<width>500</width>
<height>400</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">#groupBox{background: #FFFFFF;
border-radius: 32px;}</string>
</property>
<property name="title">
<string/>
</property>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>500</width>
<height>70</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>15</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">border-image: url(:/DependFile/Source/gamePage/dialog.png);</string>
</property>
<property name="text">
<string>提示</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>180</x>
<y>260</y>
<width>151</width>
<height>71</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>18</pointsize>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>急停</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QPushButton" name="emergency_Btn">
<property name="geometry">
<rect>
<x>218</x>
<y>170</y>
<width>70</width>
<height>70</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">border-image: url(:/DependFile/Source/dialog/emergency.png);</string>
</property>
<property name="text">
<string/>
</property>
<property name="autoRepeat">
<bool>true</bool>
</property>
<property name="autoRepeatDelay">
<number>100</number>
</property>
</widget>
</widget>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -0,0 +1,30 @@
#include "fesboxtipsdialog.h"
#include "ui_fesboxtipsdialog.h"
#include <QPainter>
FesBoxTipsDialog::FesBoxTipsDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::FesBoxTipsDialog)
{
ui->setupUi(this);
this->setWindowFlags(Qt::FramelessWindowHint); //设置无边框
setAttribute(Qt::WA_TranslucentBackground,true);
}
FesBoxTipsDialog::~FesBoxTipsDialog()
{
delete ui;
}
void FesBoxTipsDialog::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event)
QPainter painter(this);
painter.fillRect(rect(),QColor(0,0,0,100));
}
void FesBoxTipsDialog::on_pushButton_clicked()
{
this->close();
}

View File

@@ -0,0 +1,28 @@
#ifndef FESBOXTIPSDIALOG_H
#define FESBOXTIPSDIALOG_H
#include <QDialog>
namespace Ui {
class FesBoxTipsDialog;
}
class FesBoxTipsDialog : public QDialog
{
Q_OBJECT
public:
explicit FesBoxTipsDialog(QWidget *parent = nullptr);
~FesBoxTipsDialog();
protected:
void paintEvent(QPaintEvent *event);
private slots:
void on_pushButton_clicked();
private:
Ui::FesBoxTipsDialog *ui;
};
#endif // FESBOXTIPSDIALOG_H

View File

@@ -0,0 +1,135 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>FesBoxTipsDialog</class>
<widget class="QDialog" name="FesBoxTipsDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1920</width>
<height>1080</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QGroupBox" name="groupBox">
<property name="geometry">
<rect>
<x>558</x>
<y>240</y>
<width>804</width>
<height>598</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">#groupBox{background: #FFFFFF;
border-radius: 8px;}</string>
</property>
<property name="title">
<string/>
</property>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>804</width>
<height>64</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>14</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">border-image: url(:/DependFile/Source/dialog/header3.png);
</string>
</property>
<property name="text">
<string>提示</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QPushButton" name="pushButton">
<property name="geometry">
<rect>
<x>0</x>
<y>534</y>
<width>804</width>
<height>64</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>15</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">border-image: url(:/DependFile/Source/dialog/bottomButton.png);
color:white;</string>
</property>
<property name="text">
<string>确认</string>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>200</x>
<y>200</y>
<width>421</width>
<height>71</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>20</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">color:#333333;</string>
</property>
<property name="text">
<string>电刺激盒未启用</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="label_3">
<property name="geometry">
<rect>
<x>160</x>
<y>280</y>
<width>511</width>
<height>61</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>14</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: rgba(0,0,0,0.45);</string>
</property>
<property name="text">
<string>在“设置-系统设置”中启用电刺激盒</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</widget>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -0,0 +1,28 @@
#include "festipsdialog.h"
#include "ui_festipsdialog.h"
#include <QPainter>
FesTipsDialog::FesTipsDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::FesTipsDialog)
{
ui->setupUi(this);
this->setWindowFlags(Qt::FramelessWindowHint); //设置无边框
setAttribute(Qt::WA_TranslucentBackground,true);
}
FesTipsDialog::~FesTipsDialog()
{
delete ui;
}
void FesTipsDialog::on_confirm_Btn_clicked()
{
this->close();
}
void FesTipsDialog::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event)
QPainter painter(this);
painter.fillRect(rect(),QColor(0,0,0,100));
}

View File

@@ -0,0 +1,26 @@
#ifndef FESTIPSDIALOG_H
#define FESTIPSDIALOG_H
#include <QDialog>
namespace Ui {
class FesTipsDialog;
}
class FesTipsDialog : public QDialog
{
Q_OBJECT
public:
explicit FesTipsDialog(QWidget *parent = nullptr);
~FesTipsDialog();
protected:
void paintEvent(QPaintEvent *event);
private slots:
void on_confirm_Btn_clicked();
private:
Ui::FesTipsDialog *ui;
};
#endif // FESTIPSDIALOG_H

View File

@@ -0,0 +1,130 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>FesTipsDialog</class>
<widget class="QDialog" name="FesTipsDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1920</width>
<height>1080</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QGroupBox" name="groupBox">
<property name="geometry">
<rect>
<x>710</x>
<y>340</y>
<width>500</width>
<height>400</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">#groupBox{background: #FFFFFF;
border-radius: 32px;}</string>
</property>
<property name="title">
<string/>
</property>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>501</width>
<height>71</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>15</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">border-image: url(:/DependFile/Source/gamePage/dialog.png);</string>
</property>
<property name="text">
<string>提示</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>100</x>
<y>130</y>
<width>301</width>
<height>71</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>18</pointsize>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>请检查极片脱落</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="userMessage_Label">
<property name="geometry">
<rect>
<x>60</x>
<y>210</y>
<width>371</width>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>请贴好继续</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QPushButton" name="confirm_Btn">
<property name="geometry">
<rect>
<x>186</x>
<y>300</y>
<width>120</width>
<height>45</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">border-radius: 4px;
border: 1px solid #0D9DDB;
color:#0D9DDB;</string>
</property>
<property name="text">
<string>确认</string>
</property>
</widget>
</widget>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -0,0 +1,91 @@
#include "festotalparamdialog.h"
#include "ui_festotalparamdialog.h"
#include <QPainter>
FesTotalParamDialog::FesTotalParamDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::FesTotalParamDialog),
m_value(0)
{
ui->setupUi(this);
this->setWindowFlags(Qt::FramelessWindowHint); //设置无边框
setAttribute(Qt::WA_TranslucentBackground,true); //设置透明
}
FesTotalParamDialog::~FesTotalParamDialog()
{
delete ui;
}
void FesTotalParamDialog::setTitleAndUnit(QString title, QString unit)
{
ui->title_Label->setText(title);
ui->unit_Label->setText(unit);
}
int FesTotalParamDialog::getValue()
{
return m_value;
}
void FesTotalParamDialog::setValue(int value)
{
ui->slider->setValue(value);
m_value = value;
}
void FesTotalParamDialog::setRange(int min, int max)
{
ui->slider->setRange(min,max);
}
void FesTotalParamDialog::on_cancel_Btn_clicked()
{
this->close();
}
void FesTotalParamDialog::on_confirm_Btn_clicked()
{
m_value = ui->value_Label->text().toInt();
this->close();
}
void FesTotalParamDialog::on_minus_Btn_clicked()
{
int value = ui->slider->value();
--value;
ui->slider->setValue(value);
}
void FesTotalParamDialog::on_plus_Btn_clicked()
{
int value = ui->slider->value();
++value;
ui->slider->setValue(value);
}
void FesTotalParamDialog::on_slider_valueChanged(int value)
{
ui->value_Label->setText(QString::number(value));
}
void FesTotalParamDialog::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event)
QPainter painter(this);
painter.fillRect(rect(),QColor(0,0,0,100));
}
void FesTotalParamDialog::changeEvent(QEvent* event)
{
switch (event->type())
{
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
QWidget::changeEvent(event);
break;
}
}

View File

@@ -0,0 +1,46 @@
#ifndef FESTOTALPARAMDIALOG_H
#define FESTOTALPARAMDIALOG_H
#include <QDialog>
namespace Ui {
class FesTotalParamDialog;
}
class FesTotalParamDialog : public QDialog
{
Q_OBJECT
public:
explicit FesTotalParamDialog(QWidget *parent = nullptr);
~FesTotalParamDialog();
void setTitleAndUnit(QString title,QString unit);
int getValue();
void setValue(int value);
void setRange(int min,int max);
protected:
void paintEvent(QPaintEvent *event);
virtual void changeEvent(QEvent* event);
private slots:
void on_cancel_Btn_clicked();
void on_confirm_Btn_clicked();
void on_minus_Btn_clicked();
void on_plus_Btn_clicked();
void on_slider_valueChanged(int value);
private:
Ui::FesTotalParamDialog *ui;
int m_value;
};
#endif // FESTOTALPARAMDIALOG_H

View File

@@ -0,0 +1,230 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>FesTotalParamDialog</class>
<widget class="QDialog" name="FesTotalParamDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1920</width>
<height>1080</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QGroupBox" name="groupBox">
<property name="geometry">
<rect>
<x>558</x>
<y>240</y>
<width>804</width>
<height>598</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">#groupBox{background: #FFFFFF;
border-radius: 32px;}</string>
</property>
<property name="title">
<string/>
</property>
<widget class="QSlider" name="slider">
<property name="geometry">
<rect>
<x>220</x>
<y>340</y>
<width>400</width>
<height>43</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<widget class="QLabel" name="title_Label">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>804</width>
<height>64</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>15</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">border-image: url(:/DependFile/Source/gamePage/dialog.png);</string>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QPushButton" name="confirm_Btn">
<property name="geometry">
<rect>
<x>455</x>
<y>513</y>
<width>120</width>
<height>45</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">border-radius: 4px;
border: 1px solid #0D9DDB;
color:#0D9DDB;</string>
</property>
<property name="text">
<string>确认</string>
</property>
</widget>
<widget class="QPushButton" name="cancel_Btn">
<property name="geometry">
<rect>
<x>235</x>
<y>513</y>
<width>120</width>
<height>45</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">border-radius: 4px;
border: 1px solid #0D9DDB;
color:#0D9DDB;</string>
</property>
<property name="text">
<string>取消</string>
</property>
</widget>
<widget class="QGroupBox" name="groupBox_2">
<property name="geometry">
<rect>
<x>240</x>
<y>205</y>
<width>360</width>
<height>60</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">#groupBox_2{background: #FFFFFF;
border: 1px solid #05A6EC;}</string>
</property>
<property name="title">
<string/>
</property>
<widget class="QPushButton" name="plus_Btn">
<property name="geometry">
<rect>
<x>299</x>
<y>1</y>
<width>60</width>
<height>58</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">border-image: url(:/DependFile/Source/gamePage/plus.png);</string>
</property>
<property name="text">
<string/>
</property>
<property name="autoRepeat">
<bool>true</bool>
</property>
<property name="autoRepeatInterval">
<number>50</number>
</property>
</widget>
<widget class="QPushButton" name="minus_Btn">
<property name="geometry">
<rect>
<x>1</x>
<y>1</y>
<width>60</width>
<height>58</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">border-image: url(:/DependFile/Source/gamePage/minus.png);</string>
</property>
<property name="text">
<string/>
</property>
<property name="autoRepeat">
<bool>true</bool>
</property>
<property name="autoRepeatInterval">
<number>50</number>
</property>
</widget>
<widget class="QLabel" name="value_Label">
<property name="geometry">
<rect>
<x>60</x>
<y>3</y>
<width>131</width>
<height>51</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>20</pointsize>
</font>
</property>
<property name="text">
<string>100</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
<widget class="QLabel" name="unit_Label">
<property name="geometry">
<rect>
<x>200</x>
<y>4</y>
<width>91</width>
<height>51</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>18</pointsize>
</font>
</property>
<property name="text">
<string>mA</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</widget>
</widget>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -0,0 +1,97 @@
#include "horizontaltoverticaldialog.h"
#include "ui_horizontaltoverticaldialog.h"
#include <QPainter>
#include "dataformate.h"
#include "languagemanager.h"
HorizontalToVerticalDialog::HorizontalToVerticalDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::HorizontalToVerticalDialog)
{
ui->setupUi(this);
this->setWindowFlags(Qt::FramelessWindowHint); //设置无边框
setAttribute(Qt::WA_TranslucentBackground,true);
}
HorizontalToVerticalDialog::~HorizontalToVerticalDialog()
{
delete ui;
}
bool HorizontalToVerticalDialog::getConfirmState()
{
return isConfirmed;
}
void HorizontalToVerticalDialog::on_cancel_Btn_clicked()
{
isConfirmed = false;
this->close();
}
void HorizontalToVerticalDialog::on_confirm_Btn_clicked()
{
isConfirmed = true;
this->close();
}
void HorizontalToVerticalDialog::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event)
QPainter painter(this);
painter.fillRect(rect(),QColor(0,0,0,100));
}
void HorizontalToVerticalDialog::changeEvent(QEvent* event)
{
switch (event->type())
{
case QEvent::LanguageChange:
{
E_LANGUAGE language = LanguageManager::getInstance()->getCurrentLanguage();
switch(language)
{
case Chinese_E:
ui->leftText_label->setVisible(true);
ui->middleText_label->setVisible(true);
ui->rightText_label->setVisible(true);
ui->English1_label->setVisible(false);
ui->english2_label->setVisible(false);
ui->tip_label->setText("提示");
ui->confirm_Btn->setText("确认");
ui->cancel_Btn->setText("取消");
break;
case English_E:
ui->leftText_label->setVisible(false);
ui->middleText_label->setVisible(false);
ui->rightText_label->setVisible(false);
ui->English1_label->setVisible(true);
ui->English1_label->move(80,420);
ui->english2_label->setVisible(true);
ui->english2_label->move(120,460);
ui->tip_label->setText("Tips");
ui->confirm_Btn->setText("Confirm");
ui->cancel_Btn->setText("Cancel");
break;
}
ui->retranslateUi(this);
}
break;
default:
QWidget::changeEvent(event);
break;
}
//避免刚开始中文时,有英文
E_LANGUAGE language = LanguageManager::getInstance()->getCurrentLanguage();
if(language == Chinese_E)
{
ui->English1_label->setVisible(false);
ui->english2_label->setVisible(false);
}
}

View File

@@ -0,0 +1,34 @@
#ifndef HORIZONTALTOVERTICALDIALOG_H
#define HORIZONTALTOVERTICALDIALOG_H
#include <QDialog>
namespace Ui {
class HorizontalToVerticalDialog;
}
class HorizontalToVerticalDialog : public QDialog
{
Q_OBJECT
public:
explicit HorizontalToVerticalDialog(QWidget *parent = nullptr);
~HorizontalToVerticalDialog();
bool getConfirmState();
virtual void changeEvent(QEvent* event);
private slots:
void on_cancel_Btn_clicked();
void on_confirm_Btn_clicked();
protected:
void paintEvent(QPaintEvent *event);
bool isConfirmed;
private:
Ui::HorizontalToVerticalDialog *ui;
};
#endif // HORIZONTALTOVERTICALDIALOG_H

Some files were not shown because too many files have changed in this diff Show More