modified: comWorks.cpp

modified:   mainwindow.cpp
	modified:   mainwindow.h
	modified:   modbushandler.cpp
	modified:   secondwindows.cpp
	modified:   secondwindows.h
	modified:   setpribor.cpp
	modified:   setpribor.ui
main
dplimin 2023-12-12 16:51:50 +03:00
parent a5046356a1
commit 0a2c1a3ea8
8 changed files with 120 additions and 30 deletions

View File

@ -10,7 +10,7 @@
#define PACKET_STATE_SIZE 26 #define PACKET_STATE_SIZE 26
#define PACKET_SENS_SIZE 10 #define PACKET_SENS_SIZE 10
#define READY_FOR_READ_INT 200 #define READY_FOR_READ_INT 400
extern QSerialPort *serial; extern QSerialPort *serial;

View File

@ -142,6 +142,10 @@ MainWindow::MainWindow(QWidget *parent): QMainWindow(parent), ui(new Ui::MainWin
ui->comboBoxUnitSens->addItem("пКл/Па"); ui->comboBoxUnitSens->addItem("пКл/Па");
ui->comboBoxUnitSens->addItem("пКл/мс2"); ui->comboBoxUnitSens->addItem("пКл/мс2");
hideInteface();
}//конец конструктора главного окна }//конец конструктора главного окна
@ -170,12 +174,55 @@ void MainWindow::dataSetter(DataStruct data)
} }
} }
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();
}
//todo: заблокировать элементы управления без подключения //todo: заблокировать элементы управления без подключения
void MainWindow::on_pushButtonConnect_clicked() void MainWindow::on_pushButtonConnect_clicked()
{ {
adrPri=ui->lineEditAddr->text().toInt(); //todo:добавить валидатор для адреса adrPri=ui->lineEditAddr->text().toInt(); //todo:добавить валидатор для адреса
if(isConnected==false){ if(isConnected==false){
@ -195,6 +242,9 @@ void MainWindow::on_pushButtonConnect_clicked()
ui->comboBoxPort->setDisabled(true); ui->comboBoxPort->setDisabled(true);
ui->comboBoxBit->setDisabled(true); ui->comboBoxBit->setDisabled(true);
ui->comboBoxSpeed->setDisabled(true); ui->comboBoxSpeed->setDisabled(true);
showInteface();
isConnected=true; isConnected=true;
} }
else if(isConnected==true){ else if(isConnected==true){
@ -212,6 +262,8 @@ void MainWindow::on_pushButtonConnect_clicked()
ui->comboBoxSpeed->setDisabled(false); ui->comboBoxSpeed->setDisabled(false);
ui->pushButtonConnect->setText("Подключение"); ui->pushButtonConnect->setText("Подключение");
hideInteface();
isConnected=false; isConnected=false;
} }
@ -361,12 +413,11 @@ void MainWindow::refreshDisplay(){
switch (state.pz) { //todo тут нужно нормирование switch (state.pz) { //todo тут нужно нормирование
case 0 : case 0 :
ui->comboBoxPlavGround->show();
ui->comboBoxPlavGround->setCurrentIndex(0); ui->comboBoxPlavGround->setCurrentIndex(0);
break; break;
case 1: case 1:
ui->comboBoxPlavGround->show();
ui->comboBoxPlavGround->setCurrentIndex(1); ui->comboBoxPlavGround->setCurrentIndex(1);
break; break;

View File

@ -19,7 +19,6 @@ QT_END_NAMESPACE
#define REFRESH_TIME_MS 5
class MainWindow : public QMainWindow class MainWindow : public QMainWindow
{ {
@ -52,6 +51,10 @@ public slots:
private slots: private slots:
void hideInteface();
void showInteface();
void on_pushButtonConnect_clicked(); void on_pushButtonConnect_clicked();
void on_pushButtonAddPri_clicked(); void on_pushButtonAddPri_clicked();

View File

@ -4,8 +4,9 @@
#define REQ_PERIOD 500 //прериод опроса #define REQ_PERIOD 1000 //прериод опроса
#define TIMEOUT 120
@ -45,7 +46,7 @@ void ModBusHandler::requestPriborFromList() //слот для истекшег
{ {
//пробегаемся по листу и опрашиваем выкидываая сигналы //пробегаемся по листу и опрашиваем выкидываая сигналы
static uint numForReqest; //static uint numForReqest;
//QMap<uint,PrborConnectonAtr>::iterator iteratorPriborMap; //QMap<uint,PrborConnectonAtr>::iterator iteratorPriborMap;
// qDebug()<<"Приборов в списке "<<PriborMap.size(); // qDebug()<<"Приборов в списке "<<PriborMap.size();
@ -74,12 +75,12 @@ void ModBusHandler::removeFromReqList(uint adress)
void ModBusHandler::getDataFromPribor(PrborConnectonAtr atr) //слот для истекшего таймера void ModBusHandler::getDataFromPribor(PrborConnectonAtr atr) //слот для истекшего таймера
{ {
{ {
modbusDevice->disconnectDevice(); // modbusDevice->disconnectDevice();
modbusDevice->setConnectionParameter(QModbusDevice::SerialPortNameParameter, QVariant(atr.port)); modbusDevice->setConnectionParameter(QModbusDevice::SerialPortNameParameter, QVariant(atr.port));
modbusDevice->setConnectionParameter(QModbusDevice::SerialStopBitsParameter, QSerialPort::OneStop); modbusDevice->setConnectionParameter(QModbusDevice::SerialStopBitsParameter, QSerialPort::OneStop);
modbusDevice->setConnectionParameter(QModbusDevice::SerialDataBitsParameter, QSerialPort::Data8); modbusDevice->setConnectionParameter(QModbusDevice::SerialDataBitsParameter, QSerialPort::Data8);
modbusDevice->setTimeout(100); //1 таймаута modbusDevice->setTimeout(TIMEOUT); //1 таймаута
modbusDevice->setNumberOfRetries(0);// попытки достучатся modbusDevice->setNumberOfRetries(0);// попытки достучатся
modbusDevice->setConnectionParameter(QModbusDevice::SerialBaudRateParameter, atr.speed); modbusDevice->setConnectionParameter(QModbusDevice::SerialBaudRateParameter, atr.speed);
switch (atr.parity) {//выставляем парити switch (atr.parity) {//выставляем парити
@ -101,7 +102,8 @@ void ModBusHandler::getDataFromPribor(PrborConnectonAtr atr) //слот для
readCoils(atr.adress, 5001, 11); readCoils(atr.adress, 5001, 11);
readCoils(atr.adress, 7004, 2);
readCoils(atr.adress, 7004, 2);
} }
@ -331,7 +333,7 @@ void ModBusHandler::scanPort() //принимает сигнал о заверш
switch (BAUDRATE[s]) {//выставляем парити switch (BAUDRATE[s]) {//выставляем парити
case 4800: case 4800:
modbusDevice->setTimeout(140); //1 таймаута modbusDevice->setTimeout(120); //1 таймаута
break; break;
case 7200: case 7200:

View File

@ -78,6 +78,7 @@ SecondWindows::SecondWindows(MainWindow *parent) ://конструктор
ui->comboBoxUnitSens->addItem("пКл/Па"); ui->comboBoxUnitSens->addItem("пКл/Па");
ui->comboBoxUnitSens->addItem("пКл/мс2"); ui->comboBoxUnitSens->addItem("пКл/мс2");
hideInteface();
} }
@ -93,6 +94,48 @@ SecondWindows::~SecondWindows()
} }
void SecondWindows::hideInteface()
{
ui->label_4->hide();
ui->comboBoxPlavGround->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 SecondWindows::showInteface()
{
ui->label_4->show();
ui->comboBoxPlavGround->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();
}
void SecondWindows::dataSetter(DataStruct data) void SecondWindows::dataSetter(DataStruct data)
{ {
@ -127,6 +170,9 @@ void SecondWindows::on_pushButtonConnect_clicked()
ui->comboBoxPort->setDisabled(true); ui->comboBoxPort->setDisabled(true);
ui->comboBoxBit->setDisabled(true); ui->comboBoxBit->setDisabled(true);
ui->comboBoxSpeed->setDisabled(true); ui->comboBoxSpeed->setDisabled(true);
showInteface();
isConnected=true; isConnected=true;
} }
else if(isConnected==true){ else if(isConnected==true){
@ -146,6 +192,9 @@ void SecondWindows::on_pushButtonConnect_clicked()
ui->comboBoxSpeed->setDisabled(false); ui->comboBoxSpeed->setDisabled(false);
ui->pushButtonConnect->setText("Подключение"); ui->pushButtonConnect->setText("Подключение");
hideInteface();
ui->comboBoxPlavGround->hide();
isConnected=false; isConnected=false;
} }
} }
@ -255,50 +304,33 @@ void SecondWindows::refreshDisplay(){
}; };
ui->comboBoxKu->setCurrentIndex(state.ku); ui->comboBoxKu->setCurrentIndex(state.ku);
switch (state.pz) { //todo тут нужно нормирование switch (state.pz) { //todo тут нужно нормирование
case 0 : case 0 :
ui->comboBoxPlavGround->show();
ui->comboBoxPlavGround->setCurrentIndex(0); ui->comboBoxPlavGround->setCurrentIndex(0);
break; break;
case 1: case 1:
ui->comboBoxPlavGround->show();
ui->comboBoxPlavGround->setCurrentIndex(1); ui->comboBoxPlavGround->setCurrentIndex(1);
break; break;
default: default:
ui->comboBoxPlavGround->hide();
break; break;
} }
switch (state.unit) { //todo тут нужно нормирование switch (state.unit) { //todo тут нужно нормирование
case H : case H :
ui->comboBoxUnitSens->setCurrentIndex(0); ui->comboBoxUnitSens->setCurrentIndex(0);
// ui->labelUnitKu->setText("xВ/Н"); // Заменил на нормирование с прибора
break; break;
case PA: case PA:
ui->comboBoxUnitSens->setCurrentIndex(1); ui->comboBoxUnitSens->setCurrentIndex(1);
// ui->labelUnitKu->setText("xВ/Па");
break; break;
case MS2: case MS2:
ui->comboBoxUnitSens->setCurrentIndex(2); ui->comboBoxUnitSens->setCurrentIndex(2);
// ui->labelUnitKu->setText("xВс2");
break; break;
default: default:
break; break;
} }
//ui->labelUnitSens->adjustSize();
switch (state.overload) { switch (state.overload) {
case Norm : case Norm :

View File

@ -28,6 +28,8 @@ public:
void on_pushButtonConnect_clicked(); void on_pushButtonConnect_clicked();
void dataSetter(DataStruct data); void dataSetter(DataStruct data);
void showInteface();
void hideInteface();
private slots: private slots:
void on_labelSens_clicked(); void on_labelSens_clicked();

View File

@ -120,7 +120,7 @@ void SetPribor::priborIsSetConnAtr(QModbusDevice::Error modbusMessage)
} else if (modbusMessage != QModbusDevice::NoError) { } else if (modbusMessage != QModbusDevice::NoError) {
ui->labelResult->setText("Ошибочка"); // ui->labelResult->setText("Ошибочка"); //
} else if(modbusMessage == QModbusDevice::NoError) { } else if(modbusMessage == QModbusDevice::NoError) {
ui->labelResult->setText("Успшно настроен"); // ui->labelResult->setText("Успшно настроен /n Подключитесь к прибору с новыми атрибутами"); //
} }
QApplication::beep(); QApplication::beep();

View File

@ -209,7 +209,7 @@
<x>10</x> <x>10</x>
<y>170</y> <y>170</y>
<width>91</width> <width>91</width>
<height>31</height> <height>51</height>
</rect> </rect>
</property> </property>
<property name="text"> <property name="text">