426 lines
12 KiB
C++
426 lines
12 KiB
C++
#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
|
|
}
|
|
|
|
|
|
|
|
|
|
|