This commit is contained in:
curtis 2024-12-03 13:41:51 +08:00
parent f4e520d795
commit 02c2b7d8ea
10 changed files with 204 additions and 154 deletions

View File

@ -6,7 +6,7 @@ Item {
property int hitIndex: -1 property int hitIndex: -1
property bool bStimulate: false property bool bStimulate: false
property int responseTime: 10 property int responseTime: 10
property bool bTest: true property bool bTest: false
property bool bConnect: false; property bool bConnect: false;
property var brainTrainForm: null property var brainTrainForm: null
property string red: "#EE6352" property string red: "#EE6352"
@ -78,7 +78,7 @@ Item {
"qrc:/DependFile/Source/brainTrain/upTest3/upper_stretch_R14.png", "qrc:/DependFile/Source/brainTrain/upTest3/upper_stretch_R14.png",
"qrc:/DependFile/Source/brainTrain/upTest3/upper_stretch_R15.png", "qrc:/DependFile/Source/brainTrain/upTest3/upper_stretch_R15.png",
"qrc:/DependFile/Source/brainTrain/upTest3/upper_stretch_R16.png", "qrc:/DependFile/Source/brainTrain/upTest3/upper_stretch_R16.png",
] ];
function startStimulate() function startStimulate()
@ -89,11 +89,8 @@ Item {
if(!bConnect) if(!bConnect)
{ {
clientSocket.connectToHost(); clientSocket.connectToHost();
bConnect = true;
}else
{
clientSocket.writeBytes(getIntArr("1"));
} }
clientSocket.writeBytes(getIntArr("1"));
} }
@ -149,6 +146,15 @@ Item {
} }
} }
Timer {
id: connectTimer
interval: 3*1000;
onTriggered: {
clientSocket.connected();
}
}
function ssvepHit(index) function ssvepHit(index)
{ {
if(!bStimulate) if(!bStimulate)
@ -211,8 +217,10 @@ Item {
Component.onCompleted: Component.onCompleted:
{ {
bci.initTrain(); bci.initTrain();
clientSocket.connectToHost();
} }
TcpSocket{ TcpSocket{
id: clientSocket id: clientSocket
peer: "127.0.0.1" peer: "127.0.0.1"
@ -232,12 +240,18 @@ Item {
onConnected: onConnected:
{ {
console.info("Client socket connected"); console.info("Client socket connected");
writeBytes(getIntArr("1")); bConnect = true;
bci.deviceStatus(true);
if(connectTimer.running)
{
connectTimer.stop();
}
} }
onDisconnected: onDisconnected:
{ {
console.info("Client socket disconnected"); console.info("Client socket disconnected");
bConnect = false; bConnect = false;
bci.deviceStatus(false);
} }
onPeerChanged: onPeerChanged:
{ {
@ -249,7 +263,11 @@ Item {
} }
onError: onError:
{ {
console.info("Client socket disconnected") console.info("Client socket error",socketError);
if(socketError === 0 || socketError === 1)
{
connectTimer.start();
}
} }
} }
BCIManager BCIManager
@ -881,10 +899,8 @@ Item {
anchors.fill: parent anchors.fill: parent
onClicked: { onClicked: {
popimpedance.show() popimpedance.show()
popimpedance.colorChange(5,green) popimpedance.colorChange(2,green)
popimpedance.colorChange(3,green)
} }
} }
@ -892,12 +908,5 @@ Item {
PopImpedance{ PopImpedance{
id:popimpedance id:popimpedance
} }
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -10,6 +10,7 @@
#include "ccommunicateapi.h" #include "ccommunicateapi.h"
#include "currentuserdata.h" #include "currentuserdata.h"
#include "loginwidget.h" #include "loginwidget.h"
#include "BCIManager.h"
TitleWidget::TitleWidget(QWidget *parent) : TitleWidget::TitleWidget(QWidget *parent) :
QWidget(parent), QWidget(parent),
@ -17,27 +18,27 @@ TitleWidget::TitleWidget(QWidget *parent) :
checkTimer(nullptr) checkTimer(nullptr)
{ {
ui->setupUi(this); ui->setupUi(this);
connect(ui->back1_Btn,SIGNAL(clicked()),this,SLOT(slotBackClicked())); connect(ui->back1_Btn, SIGNAL(clicked()), this, SLOT(slotBackClicked()));
connect(ui->back2_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->setIcon(QIcon(":/DependFile/Source/User/user1.png"));
ui->user_Btn->setIconSize(QSize(40,40)); ui->user_Btn->setIconSize(QSize(40, 40));
setBackBtnVisible(false); setBackBtnVisible(false);
checkTimer = new QTimer(); checkTimer = new QTimer();
checkTimer->setInterval(3000); checkTimer->setInterval(3000);
connect(checkTimer,SIGNAL(timeout()),this,SLOT(slotCheckTimer())); connect(checkTimer, SIGNAL(timeout()), this, SLOT(slotCheckTimer()));
checkTimer->start(); checkTimer->start();
connect(CCommunicateAPI::getInstance(),SIGNAL(signalCommunicateChanged(QString)),this,SLOT(slotStateChanged(QString))); connect(CCommunicateAPI::getInstance(), SIGNAL(signalCommunicateChanged(QString)), this, SLOT(slotStateChanged(QString)));
ui->signal_Label->setVisible(false); ui->signal_Label->setVisible(false);
ui->wifiSignal2_Label->setVisible(true); ui->wifiSignal2_Label->setVisible(true);
ui->brainSignal_Labe->move(1550,30); ui->brainSignal_Labe->move(1550, 30);
ui->sound_Button->move(1480,30); ui->sound_Button->move(1480, 30);
ui->wifiSignal_Label->move(1620,30); ui->wifiSignal_Label->move(1620, 30);
ui->title_Label->setText(tr("功能选择")); //默认汉字 ui->title_Label->setText(tr("功能选择")); //默认汉字
@ -47,6 +48,9 @@ TitleWidget::TitleWidget(QWidget *parent) :
ui->back2_Btn->setVisible(true); ui->back2_Btn->setVisible(true);
m_soundDialog = new SoundDialog(); m_soundDialog = new SoundDialog();
connect(&BCIManager::getInstance(), &BCIManager::signalDeviceStatus, this, &TitleWidget::slotBciDeviceStatus);
} }
TitleWidget::~TitleWidget() TitleWidget::~TitleWidget()
@ -64,9 +68,11 @@ void TitleWidget::slotBackClicked()
{ {
int currentPage = MainWindowPageControl::getInstance()->getCurrentPageIndex(); int currentPage = MainWindowPageControl::getInstance()->getCurrentPageIndex();
if(!(currentPage>=MainPage_E && currentPage <=visionTrain)) if(!(currentPage >= MainPage_E && currentPage <= visionTrain))
currentPage = MainPage_E;//初始化异常值276795792,设置当前页索引为0 {
qDebug()<<"当前页"<<currentPage; currentPage = MainPage_E; //初始化异常值276795792,设置当前页索引为0
}
qDebug() << "当前页" << currentPage;
switch(currentPage) switch(currentPage)
{ {
case MainPage_E: case MainPage_E:
@ -106,9 +112,13 @@ void TitleWidget::slotBackClicked()
case TrainingParamSetting_E: case TrainingParamSetting_E:
{ {
if(m_trainType == 0) if(m_trainType == 0)
{
MainWindowPageControl::getInstance()->setCurrentPage(BicycleParamSet_E); MainWindowPageControl::getInstance()->setCurrentPage(BicycleParamSet_E);
}
else if(m_trainType == 1) else if(m_trainType == 1)
{
MainWindowPageControl::getInstance()->setCurrentPage(FesBicycleParamSet_E); MainWindowPageControl::getInstance()->setCurrentPage(FesBicycleParamSet_E);
}
//qDebug() <<"Hello"; //qDebug() <<"Hello";
} }
@ -120,7 +130,7 @@ void TitleWidget::slotBackClicked()
} }
} }
//设置当前用户 //设置当前用户
void TitleWidget::setUser(const ST_PatientMsg& st_patientMsg) void TitleWidget::setUser(const ST_PatientMsg &st_patientMsg)
{ {
ui->user_Btn->setText(st_patientMsg.name); ui->user_Btn->setText(st_patientMsg.name);
} }
@ -210,15 +220,15 @@ void TitleWidget::showWIFI()
dwError = WlanOpenHandle(1, NULL, &dwNegotiatedVersion, &hClientHandle); dwError = WlanOpenHandle(1, NULL, &dwNegotiatedVersion, &hClientHandle);
if (dwError != ERROR_SUCCESS) if (dwError != ERROR_SUCCESS)
{ {
WlanCloseHandle(hClientHandle,NULL); WlanCloseHandle(hClientHandle, NULL);
return; return;
} }
PWLAN_INTERFACE_INFO_LIST pInterfaceList = NULL; PWLAN_INTERFACE_INFO_LIST pInterfaceList = NULL;
dwError = WlanEnumInterfaces(hClientHandle, NULL,&pInterfaceList); dwError = WlanEnumInterfaces(hClientHandle, NULL, &pInterfaceList);
if ( dwError != ERROR_SUCCESS ) if ( dwError != ERROR_SUCCESS )
{ {
WlanFreeMemory(pInterfaceList); WlanFreeMemory(pInterfaceList);
WlanCloseHandle(hClientHandle,NULL); WlanCloseHandle(hClientHandle, NULL);
return; return;
} }
@ -226,44 +236,44 @@ void TitleWidget::showWIFI()
PWLAN_AVAILABLE_NETWORK_LIST pWLAN_AVAILABLE_NETWORK_LIST = NULL; PWLAN_AVAILABLE_NETWORK_LIST pWLAN_AVAILABLE_NETWORK_LIST = NULL;
dwError = WlanGetAvailableNetworkList(hClientHandle, &guid, dwError = WlanGetAvailableNetworkList(hClientHandle, &guid,
2,NULL, &pWLAN_AVAILABLE_NETWORK_LIST); 2, NULL, &pWLAN_AVAILABLE_NETWORK_LIST);
if (dwError != ERROR_SUCCESS) if (dwError != ERROR_SUCCESS)
{ {
WlanFreeMemory(pInterfaceList); WlanFreeMemory(pInterfaceList);
WlanFreeMemory(pWLAN_AVAILABLE_NETWORK_LIST); WlanFreeMemory(pWLAN_AVAILABLE_NETWORK_LIST);
WlanCloseHandle(hClientHandle,NULL); WlanCloseHandle(hClientHandle, NULL);
return; return;
} }
WLAN_AVAILABLE_NETWORK wlanAN; WLAN_AVAILABLE_NETWORK wlanAN;
bool isConnected=false; bool isConnected = false;
int numberOfItems = pWLAN_AVAILABLE_NETWORK_LIST->dwNumberOfItems; int numberOfItems = pWLAN_AVAILABLE_NETWORK_LIST->dwNumberOfItems;
if (numberOfItems > 0) if (numberOfItems > 0)
{ {
for(int i = 0; i <numberOfItems; i++) for(int i = 0; i < numberOfItems; i++)
{ {
wlanAN = pWLAN_AVAILABLE_NETWORK_LIST->Network[i]; wlanAN = pWLAN_AVAILABLE_NETWORK_LIST->Network[i];
if(wlanAN.dwFlags & 1) if(wlanAN.dwFlags & 1)
{ {
isConnected=true; isConnected = true;
int wifiQuality=(int)wlanAN.wlanSignalQuality; int wifiQuality = (int)wlanAN.wlanSignalQuality;
if(wifiQuality>75) if(wifiQuality > 75)
{ {
QPixmap pixmapWireless(":/DependFile/Source/signal/wifi3.png"); QPixmap pixmapWireless(":/DependFile/Source/signal/wifi3.png");
ui->wifiSignal_Label->setPixmap(pixmapWireless); ui->wifiSignal_Label->setPixmap(pixmapWireless);
} }
else if(wifiQuality>50&&wifiQuality<=75) else if(wifiQuality > 50 && wifiQuality <= 75)
{ {
QPixmap pixmapWireless(":/DependFile/Source/signal/wifi2.png"); QPixmap pixmapWireless(":/DependFile/Source/signal/wifi2.png");
ui->wifiSignal_Label->setPixmap(pixmapWireless); ui->wifiSignal_Label->setPixmap(pixmapWireless);
} }
else if(wifiQuality>25&&wifiQuality<=50) else if(wifiQuality > 25 && wifiQuality <= 50)
{ {
QPixmap pixmapWireless(":/DependFile/Source/signal/wifi1.png"); QPixmap pixmapWireless(":/DependFile/Source/signal/wifi1.png");
ui->wifiSignal_Label->setPixmap(pixmapWireless); ui->wifiSignal_Label->setPixmap(pixmapWireless);
} }
else if(wifiQuality>0&&wifiQuality<=25) else if(wifiQuality > 0 && wifiQuality <= 25)
{ {
QPixmap pixmapWireless(":/icons/WirelessIcon3.png"); QPixmap pixmapWireless(":/icons/WirelessIcon3.png");
ui->wifiSignal_Label->setPixmap(pixmapWireless); ui->wifiSignal_Label->setPixmap(pixmapWireless);
@ -279,7 +289,7 @@ void TitleWidget::showWIFI()
} }
WlanFreeMemory(pInterfaceList); WlanFreeMemory(pInterfaceList);
WlanFreeMemory(pWLAN_AVAILABLE_NETWORK_LIST); WlanFreeMemory(pWLAN_AVAILABLE_NETWORK_LIST);
WlanCloseHandle(hClientHandle,NULL); WlanCloseHandle(hClientHandle, NULL);
#else #else
QPixmap pixmap; QPixmap pixmap;
@ -289,7 +299,9 @@ void TitleWidget::showWIFI()
pixmap.load(":/DependFile/Source/signal/deviceConnected.png"); pixmap.load(":/DependFile/Source/signal/deviceConnected.png");
} }
else else
{
pixmap.load(":/DependFile/Source/signal/deviceDisconnected.png"); pixmap.load(":/DependFile/Source/signal/deviceDisconnected.png");
}
ui->wifiSignal_Label->setPixmap(pixmap); ui->wifiSignal_Label->setPixmap(pixmap);
#endif #endif
@ -325,12 +337,16 @@ void TitleWidget::slotSaveUpPicture()
QString dirPath = QApplication::applicationDirPath() + "/DependFile/Source/trainDisplayPage"; QString dirPath = QApplication::applicationDirPath() + "/DependFile/Source/trainDisplayPage";
QDir resultDir(dirPath); QDir resultDir(dirPath);
if(!resultDir.exists()) if(!resultDir.exists())
qDebug()<<"保存图片失败"; {
qDebug() << "保存图片失败";
}
if(upPicture.save(dirPath + "/upPicture.png")) if(upPicture.save(dirPath + "/upPicture.png"))
qDebug() <<dirPath + "/upPicture.png"; {
qDebug() << dirPath + "/upPicture.png";
}
} }
void TitleWidget::changeEvent(QEvent* event) void TitleWidget::changeEvent(QEvent *event)
{ {
switch (event->type()) switch (event->type())
{ {
@ -353,6 +369,18 @@ void TitleWidget::on_sound_Button_clicked()
m_soundDialog->show(); m_soundDialog->show();
} }
void TitleWidget::slotBciDeviceStatus(bool bConnected)
{
if(bConnected)
{
ui->brainSignal_Labe->setStyleSheet("QLabel#brainSignal_Labe{border-image:url(:/DependFile/Source/signal/icon_brain_on.png);}");
}
else
{
ui->brainSignal_Labe->setStyleSheet("QLabel#brainSignal_Labe{border-image:url(:/DependFile/Source/signal/icon_brain_off.png);}");
}
}

View File

@ -8,8 +8,9 @@
#include <QTimer> #include <QTimer>
#include "sounddialog.h" #include "sounddialog.h"
namespace Ui { namespace Ui
class TitleWidget; {
class TitleWidget;
} }
class TitleWidget : public QWidget class TitleWidget : public QWidget
@ -21,7 +22,7 @@ public:
~TitleWidget(); ~TitleWidget();
//设置当前用户 //设置当前用户
void setUser(const ST_PatientMsg&); void setUser(const ST_PatientMsg &);
//设置wifi信号强度 //设置wifi信号强度
void setSignalStrength(int value); void setSignalStrength(int value);
//设置标题 //设置标题
@ -36,7 +37,7 @@ public:
void setBackBtnVisible(bool); void setBackBtnVisible(bool);
void slotSaveUpPicture();//保存上截图 void slotSaveUpPicture();//保存上截图
protected: protected:
virtual void changeEvent(QEvent* event); virtual void changeEvent(QEvent *event);
signals: signals:
void signalCloseWindow(); void signalCloseWindow();
private slots: private slots:
@ -62,6 +63,8 @@ private slots:
//void on_back1_Btn_clicked(); //void on_back1_Btn_clicked();
void slotBciDeviceStatus(bool bConnected);
private: private:
void showWIFI(); void showWIFI();
private: private:

View File

@ -29,7 +29,6 @@
<font> <font>
<family>黑体</family> <family>黑体</family>
<pointsize>28</pointsize> <pointsize>28</pointsize>
<weight>75</weight>
<bold>true</bold> <bold>true</bold>
</font> </font>
</property> </property>
@ -224,7 +223,7 @@ border:2px;</string>
</rect> </rect>
</property> </property>
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">border-image: url(:/DependFile/Source/signal/icon_brain_on.png);</string> <string notr="true">border-image: url(:/DependFile/Source/signal/icon_brain_off.png);</string>
</property> </property>
<property name="text"> <property name="text">
<string/> <string/>

View File

@ -76,6 +76,8 @@ void BCIManager::initTrain()
m_st_bicycleParam.resistance = 0; //阻力 Nm 0~20挡 m_st_bicycleParam.resistance = 0; //阻力 Nm 0~20挡
m_st_bicycleParam.spasmType = 0; //默认逆向 m_st_bicycleParam.spasmType = 0; //默认逆向
} }
connect(this, &BCIManager::signalDeviceStatus, &getInstance(), &BCIManager::signalDeviceStatus);
} }
void BCIManager::slotLinkerProgrameReadyReadStandardOutput() void BCIManager::slotLinkerProgrameReadyReadStandardOutput()
@ -138,7 +140,7 @@ void BCIManager::startTrain(int Part, int Time)
//状态控制 0-停止 1启动 2-暂停 3-继续 //状态控制 0-停止 1启动 2-暂停 3-继续
m_st_bicycleParam.controlState = 1; m_st_bicycleParam.controlState = 1;
m_st_bicycleParam.bodyPart = Part; //训练部位 0-上肢 1-下肢 2-四肢 3-垂直上肢 m_st_bicycleParam.bodyPart = Part; //训练部位 0-上肢 1-下肢 2-四肢 3-垂直上肢
if(Part==2) if(Part == 2)
{ {
m_st_bicycleParam.trainMode = 4; m_st_bicycleParam.trainMode = 4;
} }
@ -181,3 +183,8 @@ void BCIManager::continueTrain()
CCommunicateAPI::getInstance()->sendBicycleParam(m_st_bicycleParam); CCommunicateAPI::getInstance()->sendBicycleParam(m_st_bicycleParam);
} }
} }
void BCIManager::deviceStatus(bool bConnected)
{
emit signalDeviceStatus(bConnected);
}

View File

@ -33,6 +33,7 @@ public:
Q_INVOKABLE void stopTrain(); Q_INVOKABLE void stopTrain();
Q_INVOKABLE void pauseTrain(); Q_INVOKABLE void pauseTrain();
Q_INVOKABLE void continueTrain(); Q_INVOKABLE void continueTrain();
Q_INVOKABLE void deviceStatus(bool bConnected);
private slots: private slots:
//Linker程序的标准输出 //Linker程序的标准输出
@ -48,6 +49,8 @@ private slots:
signals: signals:
void signalQmlStopLinkerPrograme(); void signalQmlStopLinkerPrograme();
void signalDeviceStatus(bool bConnected);
private: private:
QProcess *m_pCmd = nullptr; QProcess *m_pCmd = nullptr;

View File

@ -290,5 +290,6 @@
<file>DependFile/Source/brainTrain/popup_Z_bg.png</file> <file>DependFile/Source/brainTrain/popup_Z_bg.png</file>
<file>DependFile/Source/brainTrain/btn_Z.png</file> <file>DependFile/Source/brainTrain/btn_Z.png</file>
<file>DependFile/QML/PopImpedance.qml</file> <file>DependFile/QML/PopImpedance.qml</file>
<file>DependFile/Source/signal/icon_brain_off.png</file>
</qresource> </qresource>
</RCC> </RCC>