2023-11-17 09:24:13 +03:00
|
|
|
|
#include "mainwindow.h"
|
|
|
|
|
#include "ui_mainwindow.h"
|
2023-11-24 14:08:11 +03:00
|
|
|
|
//подключаем последующие окна
|
|
|
|
|
#include "setpribor.h"
|
|
|
|
|
#include "enums.h"
|
|
|
|
|
#include "QDebug"
|
|
|
|
|
#include "comWorks.h"
|
|
|
|
|
#include "qvalidator.h"
|
|
|
|
|
#include "cstring"
|
|
|
|
|
#include "QThread"
|
|
|
|
|
#include "QInputDialog"
|
|
|
|
|
#include <vector>
|
|
|
|
|
#include <QSettings>
|
|
|
|
|
#include "secondwindows.h"
|
2023-11-17 09:24:13 +03:00
|
|
|
|
|
2023-11-24 14:08:11 +03:00
|
|
|
|
const char *STRINGS_OUTUNITS[] = {"0.0001мВ/",
|
|
|
|
|
"0.0002мВ/",
|
|
|
|
|
"0.0005мВ/",
|
|
|
|
|
"0.001мВ/", //3
|
|
|
|
|
"0.002мВ/",
|
|
|
|
|
"0.005мВ/",
|
|
|
|
|
"0.01мВ/",//6
|
|
|
|
|
"0.02мВ/",
|
|
|
|
|
"0.05мВ/",
|
|
|
|
|
"0.1мВ/",//9
|
|
|
|
|
"0.2мВ/",
|
|
|
|
|
"0.5мВ/",
|
|
|
|
|
"1мВ/",//12
|
|
|
|
|
"2мВ/",
|
|
|
|
|
"5мВ/",
|
|
|
|
|
"10мВ/",//15
|
|
|
|
|
"20мВ/",
|
|
|
|
|
"50мВ/",
|
|
|
|
|
"100мВ/",//18
|
|
|
|
|
"200мВ/",
|
|
|
|
|
"500мВ/",
|
|
|
|
|
"1В/",//21
|
|
|
|
|
"2В/",
|
|
|
|
|
"5В/",
|
|
|
|
|
"10В/",//24
|
|
|
|
|
"20В/",
|
|
|
|
|
"50В/",
|
|
|
|
|
"100В/",//27
|
|
|
|
|
"200В/",
|
|
|
|
|
"500В/",
|
|
|
|
|
"1000В/", //30
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const char *STRINGS_UNITS[]={"мс2","Па","Н"}; // массив с единицами измерений
|
|
|
|
|
|
2023-12-07 16:57:51 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-11-24 14:08:11 +03:00
|
|
|
|
MainWindow::MainWindow(QWidget *parent): QMainWindow(parent), ui(new Ui::MainWindow)
|
2023-11-17 09:24:13 +03:00
|
|
|
|
{
|
2023-11-24 14:08:11 +03:00
|
|
|
|
conf = new QSettings();
|
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Перенос хэндлера в друглй поток- перечтают работать сигналы
|
|
|
|
|
|
|
|
|
|
// modeBusThread = new QThread(this);
|
|
|
|
|
modebus = new ModBusHandler();
|
|
|
|
|
// modebus ->moveToThread(modeBusThread);
|
|
|
|
|
// modeBusThread->start();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
connect(modebus, SIGNAL(dataRecivedNotify(DataStruct)),this, SLOT(dataSetter(DataStruct)));
|
|
|
|
|
//по получению данных проверяем адрес раскидываем их по переменным
|
|
|
|
|
//и обновляем экран
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QWidget::setWindowTitle("А1210");
|
|
|
|
|
QWidget::setFixedSize( 314, 372 );
|
|
|
|
|
OffsetKuDisplay=0;
|
|
|
|
|
isConnected = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-12-07 16:57:51 +03:00
|
|
|
|
|
2023-11-24 14:08:11 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//формирую комбобокс для установки скорости
|
|
|
|
|
extern const uint32_t BAUDRATE[];
|
|
|
|
|
for(uint i = 0; i<10; i++){ui->comboBoxSpeed->addItem(QString::number(BAUDRATE[i]));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//формирую данные для комбобокса бита четности
|
|
|
|
|
ui->comboBoxBit->addItem("Нет"); // Добавляем в список доступных
|
|
|
|
|
ui->comboBoxBit->addItem("Четности"); // Добавляем в список доступных
|
|
|
|
|
ui->comboBoxBit->addItem("Нечетности"); // Добавляем в список доступных
|
|
|
|
|
|
2023-12-07 16:57:51 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Перечислим порты в консоль
|
|
|
|
|
foreach(const QSerialPortInfo &info, QSerialPortInfo::availablePorts()){ //для каждого доступного порта
|
|
|
|
|
QSerialPort port; //
|
|
|
|
|
port.setPort(info); //
|
|
|
|
|
if(port.open(QIODevice::ReadWrite)){// если порт доступен
|
|
|
|
|
ui->comboBoxPort->addItem(info.portName()); // Добавляем в список доступных
|
|
|
|
|
comList.push_back(info.portName());
|
|
|
|
|
}
|
|
|
|
|
}//конец foreach
|
|
|
|
|
|
2023-11-24 14:08:11 +03:00
|
|
|
|
// значения для полей из сохраненных значений
|
|
|
|
|
ui->comboBoxPort->setCurrentIndex(conf->value("section1/keyCurrentPort").toInt());
|
|
|
|
|
ui->comboBoxSpeed->setCurrentIndex(conf->value("section1/keyCurrentSpeed").toInt());
|
|
|
|
|
ui->comboBoxBit->setCurrentIndex(conf->value("section1/keyCurrentBit").toInt());
|
|
|
|
|
ui->lineEditAddr->setText(conf->value("section1/keyAdress").toString());
|
|
|
|
|
|
|
|
|
|
//передаем текущие значения полей в глобальные переменные
|
|
|
|
|
adrValue=ui->lineEditAddr->text();
|
|
|
|
|
bitComboboxIndex=ui->comboBoxBit->currentIndex();
|
|
|
|
|
portComboboxIndex=ui->comboBoxPort->currentIndex();
|
|
|
|
|
speedComboboxIndex=ui->comboBoxSpeed->currentIndex();
|
|
|
|
|
|
|
|
|
|
|
2023-12-07 16:57:51 +03:00
|
|
|
|
//заполняю статические комбобоксы
|
|
|
|
|
|
|
|
|
|
ui->comboBoxPlavGround->addItem("ОЗ");
|
|
|
|
|
ui->comboBoxPlavGround->addItem("ПЗ");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ui->comboBoxNch->addItem("0.1");
|
|
|
|
|
ui->comboBoxNch->addItem("0.3");
|
|
|
|
|
ui->comboBoxNch->addItem("1");
|
|
|
|
|
ui->comboBoxNch->addItem("3");
|
|
|
|
|
ui->comboBoxNch->addItem("10");
|
|
|
|
|
ui->comboBoxNch->addItem("30");
|
|
|
|
|
ui->comboBoxNch->addItem("100");
|
|
|
|
|
|
|
|
|
|
ui->comboBoxVch->addItem("0.2");
|
|
|
|
|
ui->comboBoxVch->addItem("1");
|
|
|
|
|
ui->comboBoxVch->addItem("2");
|
|
|
|
|
ui->comboBoxVch->addItem("10");
|
|
|
|
|
|
2023-11-24 14:08:11 +03:00
|
|
|
|
|
2023-12-07 16:57:51 +03:00
|
|
|
|
ui->comboBoxUnitSens->addItem("пКл/Н");
|
|
|
|
|
ui->comboBoxUnitSens->addItem("пКл/Па");
|
|
|
|
|
ui->comboBoxUnitSens->addItem("пКл/мс2");
|
2023-11-24 14:08:11 +03:00
|
|
|
|
|
2023-12-12 16:51:50 +03:00
|
|
|
|
hideInteface();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-11-24 14:08:11 +03:00
|
|
|
|
}//конец конструктора главного окна
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-11-17 09:24:13 +03:00
|
|
|
|
|
|
|
|
|
MainWindow::~MainWindow()
|
|
|
|
|
{
|
2023-12-07 16:57:51 +03:00
|
|
|
|
qDebug()<<ui->comboBoxPort->currentIndex();
|
2023-11-24 14:08:11 +03:00
|
|
|
|
//сохранение значения полей
|
2023-12-07 16:57:51 +03:00
|
|
|
|
|
2023-11-24 14:08:11 +03:00
|
|
|
|
conf->setValue("section1/keyCurrentPort", ui->comboBoxPort->currentIndex());
|
|
|
|
|
conf->setValue("section1/keyCurrentSpeed", ui->comboBoxSpeed->currentIndex());
|
|
|
|
|
conf->setValue("section1/keyCurrentBit", ui->comboBoxBit->currentIndex());
|
|
|
|
|
conf->setValue("section1/keyAdress", ui->lineEditAddr->text());
|
|
|
|
|
// modeBusThread->quit();
|
|
|
|
|
// modeBusThread->wait(1000);
|
2023-11-17 09:24:13 +03:00
|
|
|
|
delete ui;
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-24 14:08:11 +03:00
|
|
|
|
|
|
|
|
|
void MainWindow::dataSetter(DataStruct data)
|
|
|
|
|
{
|
|
|
|
|
if(adrPri==data.adress){
|
|
|
|
|
state=data;
|
|
|
|
|
refreshDisplay();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-12 16:51:50 +03:00
|
|
|
|
void MainWindow::hideInteface()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ui->label_4->hide();
|
|
|
|
|
|
|
|
|
|
ui->label_8->hide();
|
|
|
|
|
ui->label_11->hide();
|
|
|
|
|
ui->label_13->hide();
|
|
|
|
|
ui->label_14->hide();
|
|
|
|
|
ui->label_16->hide();
|
|
|
|
|
ui->labelSens->hide();
|
|
|
|
|
ui->labelOverload->hide();
|
|
|
|
|
ui->comboBoxKu->hide();
|
|
|
|
|
ui->comboBoxNch->hide();
|
|
|
|
|
ui->comboBoxVch->hide();
|
|
|
|
|
ui->comboBoxUnitSens->hide();
|
|
|
|
|
ui->comboBoxPlavGround->hide();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::showInteface()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ui->label_4->show();
|
|
|
|
|
|
|
|
|
|
ui->label_8->show();
|
|
|
|
|
ui->label_11->show();
|
|
|
|
|
ui->label_13->show();
|
|
|
|
|
ui->label_14->show();
|
|
|
|
|
ui->label_16->show();
|
|
|
|
|
ui->labelSens->show();
|
|
|
|
|
ui->labelOverload->show();
|
|
|
|
|
ui->comboBoxKu->show();
|
|
|
|
|
ui->comboBoxVch->show();
|
|
|
|
|
ui->comboBoxNch->show();
|
|
|
|
|
ui->comboBoxUnitSens->show();
|
|
|
|
|
ui->comboBoxPlavGround->show();
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-24 14:08:11 +03:00
|
|
|
|
|
|
|
|
|
//todo: заблокировать элементы управления без подключения
|
|
|
|
|
void MainWindow::on_pushButtonConnect_clicked()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
adrPri=ui->lineEditAddr->text().toInt(); //todo:добавить валидатор для адреса
|
2023-12-12 16:51:50 +03:00
|
|
|
|
|
|
|
|
|
|
2023-11-24 14:08:11 +03:00
|
|
|
|
if(isConnected==false){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PrborConnectonAtr thisPribor;
|
|
|
|
|
thisPribor.port=ui->comboBoxPort->currentText();
|
|
|
|
|
thisPribor.adress=ui->lineEditAddr->text().toInt();
|
|
|
|
|
thisPribor.speed=(ui->comboBoxSpeed->currentText().toInt());
|
|
|
|
|
thisPribor.parity=(Parity)ui->comboBoxBit->currentIndex();
|
|
|
|
|
|
|
|
|
|
modebus->addToReqList(thisPribor); //добавляем прибор в список опрашиваемых
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ui->pushButtonConnect->setText("Отключение");
|
|
|
|
|
//блокируем элементы
|
|
|
|
|
ui->lineEditAddr->setDisabled(true);
|
|
|
|
|
ui->pushButtonSetPri->setDisabled(true);
|
|
|
|
|
ui->comboBoxPort->setDisabled(true);
|
|
|
|
|
ui->comboBoxBit->setDisabled(true);
|
|
|
|
|
ui->comboBoxSpeed->setDisabled(true);
|
2023-12-12 16:51:50 +03:00
|
|
|
|
|
|
|
|
|
showInteface();
|
|
|
|
|
|
2023-11-24 14:08:11 +03:00
|
|
|
|
isConnected=true;
|
|
|
|
|
}
|
|
|
|
|
else if(isConnected==true){
|
|
|
|
|
modebus->removeFromReqList(adrPri);
|
|
|
|
|
|
|
|
|
|
//удаляем прибор с данным адресом из списка
|
|
|
|
|
|
2023-12-07 16:57:51 +03:00
|
|
|
|
|
2023-11-24 14:08:11 +03:00
|
|
|
|
|
|
|
|
|
//разблокируем элементы
|
|
|
|
|
ui->lineEditAddr->setDisabled(false);
|
|
|
|
|
ui->comboBoxPort->setDisabled(false);
|
|
|
|
|
ui->pushButtonSetPri->setDisabled(false);
|
|
|
|
|
ui->comboBoxBit->setDisabled(false);
|
|
|
|
|
ui->comboBoxSpeed->setDisabled(false);
|
|
|
|
|
ui->pushButtonConnect->setText("Подключение");
|
|
|
|
|
|
2023-12-12 16:51:50 +03:00
|
|
|
|
hideInteface();
|
|
|
|
|
|
2023-11-24 14:08:11 +03:00
|
|
|
|
isConnected=false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_pushButtonAddPri_clicked()
|
|
|
|
|
{
|
|
|
|
|
SecondWindows *w2 = new SecondWindows(this);
|
|
|
|
|
w2->show();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_pushButtonSetPri_clicked()
|
|
|
|
|
{
|
|
|
|
|
SetPribor *w2 = new SetPribor(this); //передаем в новый обьект указатель на существующий для доступа к нему
|
|
|
|
|
w2->exec();
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
SetPribor setpribor;
|
|
|
|
|
setpribor.setModal(true);
|
|
|
|
|
setpribor.exec();
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::getSens(){
|
|
|
|
|
// sens=readSens(serial, adrPri);
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::getState(){
|
|
|
|
|
// state = readSet(serial, adrPri);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void MainWindow::setState(){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::refreshDisplay(){
|
|
|
|
|
|
|
|
|
|
//делаем дополнение до 6 знаков
|
|
|
|
|
if(state.sens==1000) { ui->labelSens->setText(QString::number(state.sens,'f', 1));}
|
|
|
|
|
else if(state.sens<1000&&state.sens>=100) {ui->labelSens->setText(QString::number(state.sens,'f', 2));}
|
|
|
|
|
else if(state.sens<100&&state.sens>=10){ui->labelSens->setText(QString::number(state.sens,'f', 3));}
|
|
|
|
|
else {ui->labelSens->setText(QString::number(state.sens,'f', 4));}
|
|
|
|
|
|
2023-12-07 16:57:51 +03:00
|
|
|
|
//с автоподгонкой всё начинает прыгать. Я думаю всё прокатит если её применять тоьлко по изменеию содержимого
|
2023-11-24 14:08:11 +03:00
|
|
|
|
//ui->labelSens->adjustSize(); //подгоняем размер по содержимому
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (state.fn) {
|
|
|
|
|
case Lp100:
|
2023-12-07 16:57:51 +03:00
|
|
|
|
|
|
|
|
|
ui->comboBoxNch->setCurrentIndex(0);
|
2023-11-24 14:08:11 +03:00
|
|
|
|
break;
|
|
|
|
|
case Lp300:
|
2023-12-07 16:57:51 +03:00
|
|
|
|
|
|
|
|
|
ui->comboBoxNch->setCurrentIndex(1);
|
2023-11-24 14:08:11 +03:00
|
|
|
|
break;
|
|
|
|
|
case Lp1000:
|
2023-12-07 16:57:51 +03:00
|
|
|
|
|
|
|
|
|
ui->comboBoxNch->setCurrentIndex(2);
|
2023-11-24 14:08:11 +03:00
|
|
|
|
break;
|
|
|
|
|
case Lp3000:
|
2023-12-07 16:57:51 +03:00
|
|
|
|
|
|
|
|
|
ui->comboBoxNch->setCurrentIndex(3);
|
2023-11-24 14:08:11 +03:00
|
|
|
|
break;
|
|
|
|
|
case Lp10000:
|
2023-12-07 16:57:51 +03:00
|
|
|
|
|
|
|
|
|
ui->comboBoxNch->setCurrentIndex(4);
|
2023-11-24 14:08:11 +03:00
|
|
|
|
break;
|
|
|
|
|
case Lp30000:
|
2023-12-07 16:57:51 +03:00
|
|
|
|
|
|
|
|
|
ui->comboBoxNch->setCurrentIndex(5);
|
2023-11-24 14:08:11 +03:00
|
|
|
|
break;
|
|
|
|
|
case Lp100000:
|
2023-12-07 16:57:51 +03:00
|
|
|
|
|
|
|
|
|
ui->comboBoxNch->setCurrentIndex(6);
|
2023-11-24 14:08:11 +03:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2023-12-07 16:57:51 +03:00
|
|
|
|
// ui->labelNch->setText("#####");
|
2023-11-24 14:08:11 +03:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (state.fv) {
|
|
|
|
|
case Hp0_2 :
|
2023-12-07 16:57:51 +03:00
|
|
|
|
|
|
|
|
|
ui->comboBoxVch->setCurrentIndex(0);
|
2023-11-24 14:08:11 +03:00
|
|
|
|
break;
|
|
|
|
|
case Hp1:
|
2023-12-07 16:57:51 +03:00
|
|
|
|
|
|
|
|
|
ui->comboBoxVch->setCurrentIndex(1);
|
2023-11-24 14:08:11 +03:00
|
|
|
|
break;
|
|
|
|
|
case Hp2:
|
2023-12-07 16:57:51 +03:00
|
|
|
|
|
|
|
|
|
ui->comboBoxVch->setCurrentIndex(2);
|
2023-11-24 14:08:11 +03:00
|
|
|
|
break;
|
|
|
|
|
case Hp10:
|
2023-12-07 16:57:51 +03:00
|
|
|
|
|
|
|
|
|
ui->comboBoxVch->setCurrentIndex(3);
|
2023-11-24 14:08:11 +03:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2023-12-07 16:57:51 +03:00
|
|
|
|
|
2023-11-24 14:08:11 +03:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////
|
|
|
|
|
///// вывод юнитов и нормирование///
|
|
|
|
|
////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
////Аналогично прибору считаем смещение по массиву значений
|
|
|
|
|
///
|
|
|
|
|
if (state.sens>=0.0001&&state.sens<0.001) {OffsetKuDisplay=0;} // такие значения не допустимы
|
|
|
|
|
else if (state.sens>=0.001&&state.sens<0.01){OffsetKuDisplay=0;}
|
|
|
|
|
else if (state.sens>=0.01&&state.sens<0.1){OffsetKuDisplay=3; }
|
|
|
|
|
else if (state.sens>=0.1&&state.sens<1){OffsetKuDisplay=6;}
|
|
|
|
|
else if (state.sens>=1&&state.sens<10){OffsetKuDisplay=9;}
|
|
|
|
|
else if (state.sens>=10&&state.sens<100){OffsetKuDisplay=12;}
|
|
|
|
|
else if (state.sens>=100&&state.sens<1000){OffsetKuDisplay=15;}
|
|
|
|
|
else if (state.sens<=1000){OffsetKuDisplay=18;}
|
|
|
|
|
|
|
|
|
|
char * result = (char *)malloc(strlen(STRINGS_OUTUNITS[state.ku+OffsetKuDisplay]) + strlen(STRINGS_UNITS[state.unit]) + 1); // +1 for the null-terminator
|
|
|
|
|
strcpy(result, STRINGS_OUTUNITS[state.ku+OffsetKuDisplay]);
|
|
|
|
|
strcat(result, STRINGS_UNITS[state.unit]);
|
|
|
|
|
|
2023-12-07 16:57:51 +03:00
|
|
|
|
|
2023-11-24 14:08:11 +03:00
|
|
|
|
free(result); /// освободил память
|
|
|
|
|
|
2023-12-07 16:57:51 +03:00
|
|
|
|
//шляпа для комбобокса
|
|
|
|
|
ui->comboBoxKu->clear();
|
|
|
|
|
for(int i=0; i<=12; i++){
|
|
|
|
|
QString StringForComboBox;
|
|
|
|
|
StringForComboBox.append(STRINGS_OUTUNITS[i+OffsetKuDisplay]);
|
|
|
|
|
StringForComboBox.append(STRINGS_UNITS[state.unit]);
|
2023-11-24 14:08:11 +03:00
|
|
|
|
|
2023-12-07 16:57:51 +03:00
|
|
|
|
ui->comboBoxKu->addItem(StringForComboBox);
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
ui->comboBoxKu->setCurrentIndex(state.ku);
|
2023-11-24 14:08:11 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (state.pz) { //todo тут нужно нормирование
|
|
|
|
|
case 0 :
|
2023-12-12 16:51:50 +03:00
|
|
|
|
|
2023-12-07 16:57:51 +03:00
|
|
|
|
|
|
|
|
|
ui->comboBoxPlavGround->setCurrentIndex(0);
|
2023-11-24 14:08:11 +03:00
|
|
|
|
break;
|
|
|
|
|
case 1:
|
2023-12-07 16:57:51 +03:00
|
|
|
|
|
|
|
|
|
ui->comboBoxPlavGround->setCurrentIndex(1);
|
2023-11-24 14:08:11 +03:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2023-12-07 16:57:51 +03:00
|
|
|
|
|
|
|
|
|
ui->comboBoxPlavGround->hide();
|
2023-11-24 14:08:11 +03:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (state.unit) { //todo тут нужно нормирование
|
|
|
|
|
case H :
|
2023-12-07 16:57:51 +03:00
|
|
|
|
|
|
|
|
|
ui->comboBoxUnitSens->setCurrentIndex(0);
|
2023-11-24 14:08:11 +03:00
|
|
|
|
// ui->labelUnitKu->setText("xВ/Н"); // Заменил на нормирование с прибора
|
|
|
|
|
break;
|
|
|
|
|
case PA:
|
2023-12-07 16:57:51 +03:00
|
|
|
|
|
|
|
|
|
ui->comboBoxUnitSens->setCurrentIndex(1);
|
2023-11-24 14:08:11 +03:00
|
|
|
|
// ui->labelUnitKu->setText("xВ/Па");
|
|
|
|
|
break;
|
|
|
|
|
case MS2:
|
2023-12-07 16:57:51 +03:00
|
|
|
|
|
|
|
|
|
ui->comboBoxUnitSens->setCurrentIndex(2);
|
2023-11-24 14:08:11 +03:00
|
|
|
|
// ui->labelUnitKu->setText("xВ/мс2");
|
|
|
|
|
break;
|
|
|
|
|
default:
|
2023-12-07 16:57:51 +03:00
|
|
|
|
|
2023-11-24 14:08:11 +03:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
//ui->labelUnitSens->adjustSize();
|
|
|
|
|
|
|
|
|
|
|
2023-12-07 16:57:51 +03:00
|
|
|
|
switch (state.overload) {
|
2023-11-24 14:08:11 +03:00
|
|
|
|
case Norm :
|
|
|
|
|
ui->labelOverload->setText("");
|
|
|
|
|
break;
|
|
|
|
|
case Overload:
|
|
|
|
|
ui->labelOverload->setText("ПЕРЕГРУЗКА");
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
ui->labelOverload->setText("#####");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-12-07 16:57:51 +03:00
|
|
|
|
void MainWindow::on_labelSens_clicked()
|
2023-11-24 14:08:11 +03:00
|
|
|
|
{
|
2023-12-07 16:57:51 +03:00
|
|
|
|
bool ok;
|
|
|
|
|
state.sens = QInputDialog::getDouble(this, tr("Введите значение"),
|
|
|
|
|
tr("Введите значение чувствительности датчика"), state.sens, 0.001, 1000, 4, &ok,
|
|
|
|
|
Qt::WindowFlags(), 1);
|
2023-11-24 14:08:11 +03:00
|
|
|
|
|
2023-12-07 16:57:51 +03:00
|
|
|
|
if (ok){modebus->writeDataToPribor(state, SENS_REQ_TYPE);}
|
2023-11-24 14:08:11 +03:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-07 16:57:51 +03:00
|
|
|
|
void MainWindow::on_comboBoxPort_currentIndexChanged(int )
|
2023-11-24 14:08:11 +03:00
|
|
|
|
{
|
2023-12-07 16:57:51 +03:00
|
|
|
|
portComboboxIndex=ui->comboBoxPort->currentIndex();
|
2023-11-24 14:08:11 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2023-12-07 16:57:51 +03:00
|
|
|
|
void MainWindow::on_comboBoxSpeed_currentIndexChanged(int )
|
2023-11-24 14:08:11 +03:00
|
|
|
|
{
|
2023-12-07 16:57:51 +03:00
|
|
|
|
speedComboboxIndex=ui->comboBoxSpeed->currentIndex();
|
2023-11-24 14:08:11 +03:00
|
|
|
|
}
|
|
|
|
|
|
2023-12-07 16:57:51 +03:00
|
|
|
|
void MainWindow::on_comboBoxBit_currentIndexChanged(int )
|
2023-11-24 14:08:11 +03:00
|
|
|
|
{
|
2023-12-07 16:57:51 +03:00
|
|
|
|
bitComboboxIndex=ui->comboBoxBit->currentIndex();
|
2023-11-24 14:08:11 +03:00
|
|
|
|
}
|
|
|
|
|
|
2023-12-07 16:57:51 +03:00
|
|
|
|
void MainWindow::on_lineEditAddr_textEdited(const QString &)
|
2023-11-24 14:08:11 +03:00
|
|
|
|
{
|
2023-12-07 16:57:51 +03:00
|
|
|
|
adrValue=ui->lineEditAddr->text();
|
2023-11-24 14:08:11 +03:00
|
|
|
|
}
|
|
|
|
|
|
2023-12-07 16:57:51 +03:00
|
|
|
|
void MainWindow::on_comboBoxUnitSens_activated(int index)
|
2023-11-24 14:08:11 +03:00
|
|
|
|
{
|
2023-12-07 16:57:51 +03:00
|
|
|
|
if(index==0)state.unit=H;
|
|
|
|
|
if(index==1)state.unit=PA; //тут были непонятки, скорее всего сработает без этого
|
|
|
|
|
if(index==2)state.unit=MS2;
|
2023-11-24 14:08:11 +03:00
|
|
|
|
|
2023-12-07 16:57:51 +03:00
|
|
|
|
modebus->writeDataToPribor(state, STATE_REQ_TYPE);
|
2023-11-24 14:08:11 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-12-07 16:57:51 +03:00
|
|
|
|
void MainWindow::on_comboBoxKu_activated(int index)
|
2023-11-24 14:08:11 +03:00
|
|
|
|
{
|
2023-12-07 16:57:51 +03:00
|
|
|
|
state.ku=typeIKU(index);
|
|
|
|
|
modebus->writeDataToPribor(state, STATE_REQ_TYPE);
|
|
|
|
|
}
|
2023-11-24 14:08:11 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-12-07 16:57:51 +03:00
|
|
|
|
void MainWindow::on_comboBoxVch_activated(int index)
|
2023-11-24 14:08:11 +03:00
|
|
|
|
{
|
2023-12-07 16:57:51 +03:00
|
|
|
|
state.fv=typeIFV(index);
|
|
|
|
|
modebus->writeDataToPribor(state, STATE_REQ_TYPE);
|
2023-11-24 14:08:11 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-12-07 16:57:51 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_comboBoxNch_activated(int index)
|
2023-11-24 14:08:11 +03:00
|
|
|
|
{
|
2023-12-07 16:57:51 +03:00
|
|
|
|
state.fn=typeIFN(index);
|
|
|
|
|
modebus->writeDataToPribor(state, STATE_REQ_TYPE);
|
2023-11-24 14:08:11 +03:00
|
|
|
|
}
|
|
|
|
|
|
2023-12-07 16:57:51 +03:00
|
|
|
|
void MainWindow::on_comboBoxPlavGround_activated(int index)
|
2023-11-24 14:08:11 +03:00
|
|
|
|
{
|
2023-12-07 16:57:51 +03:00
|
|
|
|
state.pz=typePlavGround(index);
|
|
|
|
|
modebus->writeDataToPribor(state, STATE_REQ_TYPE);
|
2023-11-24 14:08:11 +03:00
|
|
|
|
}
|