From fa0d4f3db94f392a66ce176ccabdc5ef8eb03945 Mon Sep 17 00:00:00 2001 From: dplimin Date: Thu, 7 Dec 2023 16:55:56 +0300 Subject: [PATCH] modified: A142_Desktop.pro new file: customcombobox.cpp new file: customcombobox.h new file: customlabel.cpp new file: customlabel.h modified: enums.h modified: icon.ico new file: ipsettings.cpp new file: ipsettings.h new file: ipsettings.ui modified: main.cpp modified: mainwindow.cpp modified: mainwindow.h modified: mainwindow.ui modified: modbusoverudp.cpp modified: modbusoverudp.h new file: release/moc_predefs.h modified: windowchannel.cpp modified: windowchannel.h modified: windowchannel.ui --- A142_Desktop.pro | 7 + customcombobox.cpp | 50 ++++ customcombobox.h | 31 +++ customlabel.cpp | 33 +++ customlabel.h | 36 +++ enums.h | 9 +- icon.ico | Bin 2955 -> 4303 bytes ipsettings.cpp | 27 ++ ipsettings.h | 29 +++ ipsettings.ui | 144 +++++++++++ main.cpp | 3 + mainwindow.cpp | 66 +++++ mainwindow.h | 7 + mainwindow.ui | 14 +- modbusoverudp.cpp | 335 +++++++++++++++++++++++-- modbusoverudp.h | 20 +- release/moc_predefs.h | 376 ++++++++++++++++++++++++++++ windowchannel.cpp | 567 +++++++++++++++++++++++++++++++++++++----- windowchannel.h | 40 ++- windowchannel.ui | 332 ++++++++----------------- 20 files changed, 1790 insertions(+), 336 deletions(-) create mode 100644 customcombobox.cpp create mode 100644 customcombobox.h create mode 100644 customlabel.cpp create mode 100644 customlabel.h create mode 100644 ipsettings.cpp create mode 100644 ipsettings.h create mode 100644 ipsettings.ui create mode 100644 release/moc_predefs.h diff --git a/A142_Desktop.pro b/A142_Desktop.pro index 93ed2a4..186ddc8 100644 --- a/A142_Desktop.pro +++ b/A142_Desktop.pro @@ -18,18 +18,25 @@ DEFINES += QT_DEPRECATED_WARNINGS #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 SOURCES += \ + customcombobox.cpp \ + customlabel.cpp \ + ipsettings.cpp \ main.cpp \ mainwindow.cpp \ modbusoverudp.cpp \ windowchannel.cpp HEADERS += \ + customcombobox.h \ + customlabel.h \ enums.h \ + ipsettings.h \ mainwindow.h \ modbusoverudp.h \ windowchannel.h FORMS += \ + ipsettings.ui \ mainwindow.ui \ windowchannel.ui win32:RC_FILE = icon.rc diff --git a/customcombobox.cpp b/customcombobox.cpp new file mode 100644 index 0000000..fbac685 --- /dev/null +++ b/customcombobox.cpp @@ -0,0 +1,50 @@ +#include "customcombobox.h" + +CustomComboBox::CustomComboBox(QWidget *parent) : QComboBox(parent) +{ + this->setStyleSheet("QComboBox { background-color : black; color : #d4ae13; " + "}QComboBox:editable {" + " background: black; selection-background-color: black; color : #d4ae13;}" + "QComboBox QAbstractItemView {" + " selection-background-color: black;}" + ); + +} + +void CustomComboBox::wheelEvent(QWheelEvent * event) +{ + if (event->delta() > 0) { + emit wheelUp(); + }else{ + emit wheelDown(); + } +} + +/* +void CustomComboBox::mousePressEvent(QMouseEvent *event) +{ + emit clicked(); +} +*/ + +void CustomComboBox::enterEvent(QEvent * event) +{ + this->setStyleSheet("QComboBox { background-color : black; color : green; " + "}QComboBox:editable {" + " background: black; selection-background-color: black;}" + "QComboBox QAbstractItemView {" + " selection-background-color: black;}" + ); + emit focused(); +} + +void CustomComboBox::leaveEvent(QEvent * event) +{ + this->setStyleSheet("QComboBox { background-color : black; color : #d4ae13; " + "}QComboBox:editable {" + " background: black; selection-background-color: black; color : #d4ae13; selection-color: #d4ae13; }" + "QComboBox QAbstractItemView {" + " selection-background-color: black;}" + ); + emit unfocused(); +} diff --git a/customcombobox.h b/customcombobox.h new file mode 100644 index 0000000..0e0d8ed --- /dev/null +++ b/customcombobox.h @@ -0,0 +1,31 @@ +#ifndef CUSTOMCOMBOBOX_H +#define CUSTOMCOMBOBOX_H + +#include +#include +#include +#include +#include + +class CustomComboBox : public QComboBox +{ + Q_OBJECT +public: + explicit CustomComboBox(QWidget *parent = nullptr); + +protected: + void wheelEvent(QWheelEvent * event) override; + // void mousePressEvent(QMouseEvent *event) override; + void enterEvent(QEvent * event) override; + void leaveEvent(QEvent * event) override; + + +signals: + void wheelUp(); + void wheelDown(); + void clicked(); + void focused(); + void unfocused(); +}; + +#endif // CUSTOMCOMBOBOX_H diff --git a/customlabel.cpp b/customlabel.cpp new file mode 100644 index 0000000..0392f43 --- /dev/null +++ b/customlabel.cpp @@ -0,0 +1,33 @@ +#include "customlabel.h" + +CustomLabel::CustomLabel(QWidget *parent) : QLabel(parent) +{ + +} + +void CustomLabel::wheelEvent(QWheelEvent * event) +{ + if (event->delta() > 0) { + emit wheelUp(); + }else{ + emit wheelDown(); + } +} + + +void CustomLabel::mousePressEvent(QMouseEvent *event) +{ + emit clicked(); +} + +void CustomLabel::enterEvent(QEvent * event) +{ + this->setStyleSheet("QLabel { color : green; }"); + emit focused(); +} + +void CustomLabel::leaveEvent(QEvent * event) +{ + this->setStyleSheet("QLabel { color : #d4ae13; }"); + emit unfocused(); +} diff --git a/customlabel.h b/customlabel.h new file mode 100644 index 0000000..7f912ad --- /dev/null +++ b/customlabel.h @@ -0,0 +1,36 @@ +#ifndef CUSTOMLABEL_H +#define CUSTOMLABEL_H + +#include +#include +#include +#include + + +class CustomLabel : public QLabel +{ + Q_OBJECT +public: + explicit CustomLabel(QWidget *parent = nullptr); + +protected: + void wheelEvent(QWheelEvent * event) override; + void mousePressEvent(QMouseEvent *event) override; + void enterEvent(QEvent * event) override; + void leaveEvent(QEvent * event) override; + + + //void mouseRe(QMouseEvent *event) override; + + + + +signals: + void wheelUp(); + void wheelDown(); + void clicked(); + void focused(); + void unfocused(); +}; + +#endif // CUSTOMLABEL_H diff --git a/enums.h b/enums.h index f9a91b1..d95b1bb 100644 --- a/enums.h +++ b/enums.h @@ -10,7 +10,12 @@ typedef enum { CHARGE = 0, ICP} typeIIN; -typedef enum { Ku0_1 = 0, Ku0_2, Ku0_5, Ku1, Ku2, Ku5, Ku10, Ku20, Ku50, Ku100, Ku200, Ku500, Ku1000 } typeIKU; +typedef enum { Ku0_1 = 0, Ku0_2, Ku0_5, + Ku1, Ku2, Ku5, + Ku10, Ku20, Ku50, + Ku100, Ku200, Ku500, + Ku1000 } typeIKU; // 13 штук + typedef enum { Hp0_2 = 0, Hp0_3, Hp1, Hp2, Hp10 } typeIFV; typedef enum { Lp200 = 0, Lp500, Lp1000, Lp5000, Lp10000, Lp20000, Lp50000, Lp100000 } typeIFN; typedef enum { Ch1 = 0, Ch2, Ch3, Ch4, Ch5, Ch6, Ch7, @@ -45,7 +50,7 @@ typedef enum Out_10000 = 24 } typeOUTPUT; -typedef enum{SENS=0, STATE} typeREQ; +typedef enum{SENS=0, STATE, IIN, IFV, IFN,IKU,VAL} typeREQ; typedef struct { typeCHANNEL channel; diff --git a/icon.ico b/icon.ico index 25ee350751afc11a0d37b9dd45171a7c71968cef..4b749405884e44abfd6b2b805b9839eaededeff0 100644 GIT binary patch literal 4303 zcmcgvXHXN`);$RcC0rm#67HoK1f>b;rArM60#a@$!Zjgu#efuv6sZwJP?{h`DT2}= z6p6-ad2Y>^*z-tU0sJtTPJ$$iey*5Fi1X zkN{u~^4oYzV?Klk;vnTSH8HgQ)%~@(IS&p8|I$mpDqnv~TgaQoL0JGGDW-<{w!t44 zbGg#cAH-v^BltgG{9SOi|F(##h>l2T;^}vn4;4tueED6-?X-w0W`bdL=MIF|0)`e; zh>NqXtU$uMqa+awG( z6|w1>`&LCqKWI(sll)AK6TL^yom1U9v6jWDGWwGa!L8Jsq0Hs;6Cw!$iA`TFkVv|u zL?1C){>$U4lTxAmwtEz;m3;7-E~zD}v2lV|*?E5iG9M;;Z=P%I`kMwqP~b_vme9f^ z%__6m{t44b^)}M1UQKi}d&B{a62X!0bP!-YfkQJdy8^0AI|$J9{=Keft^Fj$(j8Eg zq|=@a(}XGB$d2WN)_6pCt=njT-Z@bX))Bs}Q%)_#w60{22&%gd|F>~VC#UV46MuPE zG-AQI%*8BIkM;MZs2IrI*LEGxgS9fp!#y~J$v(k8dgvGy* zMsHpE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lMV=1h6K6bVv5ewTXf+dSoU zws65q&5+_eH@;x|>52N~BVW{?-pGw~v5JfFaXVK0G27Q@Ry#o{aq%1~!S-E7Ts@#J zO0T$QU2Zhz-2Kv)#M65eQANx-dG1)woO_pj>e#_(9qpkRFcgvl7iZUQIxzF|5QEL` zX=Ag)Ik{}BNlX7jcPi1Z=BlL@rN# zPp6zczPXAh#F``!_G;d7EdG=xkgGkLS~=pKo24#xVDzO#dor?-Hkos5-Q+gb>W4;; zQ)(A$xa{TeHSKtg-fUjZ6XMwSOQBuNl!pm~+k{(;setFixedSize(458,146); + ui->setupUi(this); + ui->lineEditOldIp->setText(ip); + ui->lineEditNewIp->setText(ip); + this->modbus=modbus; +} + +ipSettings::~ipSettings() +{ + delete ui; +} + +void ipSettings::on_pushButton_clicked() +{ + modbus->changeIp(ui->lineEditOldIp->text(), ui->lineEditNewIp->text()); + ui->labelResult->setText("Произведите подключение по новому адресу"); +} diff --git a/ipsettings.h b/ipsettings.h new file mode 100644 index 0000000..ad96daf --- /dev/null +++ b/ipsettings.h @@ -0,0 +1,29 @@ +#ifndef IPSETTINGS_H +#define IPSETTINGS_H + +#include +#include "modbusoverudp.h" + + + +namespace Ui { +class ipSettings; +} + +class ipSettings : public QDialog +{ + Q_OBJECT + +public: + explicit ipSettings(QWidget *parent = nullptr, QString ip="0", ModbusOverUdp *modbus= nullptr); + ~ipSettings(); + +private slots: + void on_pushButton_clicked(); + +private: + Ui::ipSettings *ui; + ModbusOverUdp *modbus; +}; + +#endif // IPSETTINGS_H diff --git a/ipsettings.ui b/ipsettings.ui new file mode 100644 index 0000000..d7a0beb --- /dev/null +++ b/ipsettings.ui @@ -0,0 +1,144 @@ + + + ipSettings + + + + 0 + 0 + 458 + 146 + + + + Dialog + + + + + 140 + 60 + 161 + 21 + + + + + + + 140 + 90 + 161 + 20 + + + + + + + 20 + 60 + 81 + 16 + + + + Текущий адрес + + + + + + 20 + 90 + 81 + 16 + + + + Новый адрес + + + + + + 310 + 60 + 47 + 13 + + + + :7000 + + + + + + 310 + 90 + 47 + 13 + + + + :7000 + + + + + + 350 + 54 + 81 + 61 + + + + Сменить + адрес + + + + + + 20 + 10 + 411 + 21 + + + + Данный режим предназначен для смены адреса A142. + + + + + + 20 + 30 + 411 + 21 + + + + Текущий адрес можно узнать на экране включения A142 + + + + + + 20 + 110 + 411 + 21 + + + + + + + + + + diff --git a/main.cpp b/main.cpp index fd3e533..c209633 100644 --- a/main.cpp +++ b/main.cpp @@ -4,6 +4,9 @@ int main(int argc, char *argv[]) { + + QCoreApplication::setOrganizationName("org"); + QCoreApplication::setApplicationName("app"); QApplication a(argc, argv); MainWindow w; w.show(); diff --git a/mainwindow.cpp b/mainwindow.cpp index 2162de0..93bc5b2 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -10,13 +10,44 @@ MainWindow::MainWindow(QWidget *parent) { ui->setupUi(this); + conf = new QSettings(); modbus=new ModbusOverUdp(); this->setWindowTitle ("Программа для управления A142"); + this->setFixedSize(532,447); + + ui->lineEditPort->setEnabled(0); + ui->widget1->setWindowsChannel(Ch1); ui->widget2->setWindowsChannel(Ch2); ui->widget3->setWindowsChannel(Ch3); ui->widget4->setWindowsChannel(Ch4); + ui->widget1->hideValue(); + ui->widget2->hideValue(); + ui->widget3->hideValue(); + ui->widget4->hideValue(); + + + ui->lineEditAddres->setText(conf->value("section1/keyCurrentIp").toString()); + qDebug()<<"Значение ва памяти"<value("section1/keyCurrentIp").toString(); + if(ui->lineEditAddres->text()==""){ + ui->lineEditAddres->setText("192.168.0.50"); + } + + QRegExp ip_regexp("[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}"); + QRegExpValidator *ip_validator = new QRegExpValidator(ip_regexp,ui->lineEditAddres); + ui->lineEditAddres->setValidator(ip_validator); + + /* + ui->lineEditAddres->setInputMask("000.000.000.000"); + QRegExp rx( "( |[0-9] | [0-9] | [0-9]|[0-9][0-9] | [0-9][0-9]|[0-1][0-9][0-9]|2[0-4][0-9]|25[0-5])." + "( |[0-9] | [0-9] | [0-9]|[0-9][0-9] | [0-9][0-9]|[0-1][0-9][0-9]|2[0-4][0-9]|25[0-5])." + "( |[0-9] | [0-9] | [0-9]|[0-9][0-9] | [0-9][0-9]|[0-1][0-9][0-9]|2[0-4][0-9]|25[0-5])." + "( |[0-9] | [0-9] | [0-9]|[0-9][0-9] | [0-9][0-9]|[0-1][0-9][0-9]|2[0-4][0-9]|25[0-5])"); + QRegExpValidator *validator = new QRegExpValidator(QRegExp(rx), ui->lineEditAddres); + ui->lineEditAddres->setValidator(validator); + */ + connect(this->modbus,SIGNAL(stateRecive (Set)), ui->widget1,SLOT(setState(Set))); connect(modbus,SIGNAL(stateRecive (Set)), @@ -35,11 +66,24 @@ MainWindow::MainWindow(QWidget *parent) connect(modbus,SIGNAL(sensRecive(Set)), ui->widget4,SLOT(setSens(Set))); + connect(ui->widget1,SIGNAL(ReadyToSend(Set, typeREQ)), + modbus,SLOT(set(Set,typeREQ))); + connect(ui->widget2,SIGNAL(ReadyToSend(Set, typeREQ)), + modbus,SLOT(set(Set,typeREQ))); + connect(ui->widget3,SIGNAL(ReadyToSend(Set, typeREQ)), + modbus,SLOT(set(Set,typeREQ))); + connect(ui->widget4,SIGNAL(ReadyToSend(Set, typeREQ)), + modbus,SLOT(set(Set,typeREQ))); + } MainWindow::~MainWindow() { + qDebug()<lineEditAddres->text(); + conf->setValue("section1/keyCurrentIp",ui->lineEditAddres->text()); + qDebug()<<"Значение ва памяти"<value("section1/keyCurrentIp").toString(); + delete ui; } @@ -47,11 +91,33 @@ void MainWindow::on_pushButtonConnect_clicked() { if(isConnected==0){ modbus->connectTo(ui->lineEditAddres->text(),ui->lineEditPort->text().toInt()); + + ui->lineEditAddres->setEnabled(0); + //ui->lineEditPort->setEnabled(0); + + ui->pushButtonConnect->setText("Отключиться"); + ui->pushButtonSettings->setEnabled(0); isConnected=1; + }else{ modbus->disconnectFrom(); + + ui->lineEditAddres->setEnabled(1); + // ui->lineEditPort->setEnabled(1); + ui->widget1->hideValue(); + ui->widget2->hideValue(); + ui->widget3->hideValue(); + ui->widget4->hideValue(); + ui->pushButtonConnect->setText("Подключиться"); + ui->pushButtonSettings->setEnabled(1); isConnected=0; } } + +void MainWindow::on_pushButtonSettings_clicked() +{ + ipSettings *w2 = new ipSettings(this, ui->lineEditAddres->text(),modbus); + w2->exec(); +} diff --git a/mainwindow.h b/mainwindow.h index d86b9a9..32b9022 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -5,6 +5,9 @@ #include "modbusoverudp.h" #include "enums.h" #include "QDebug" +#include "ipsettings.h" +#include "QRegExpValidator" +#include QT_BEGIN_NAMESPACE namespace Ui { class MainWindow; } @@ -18,6 +21,8 @@ public: MainWindow(QWidget *parent = nullptr); bool isConnected=0; ModbusOverUdp* modbus; + QSettings *conf; + ~MainWindow(); @@ -27,6 +32,8 @@ private slots: void on_pushButtonConnect_clicked(); + void on_pushButtonSettings_clicked(); + private: Ui::MainWindow *ui; }; diff --git a/mainwindow.ui b/mainwindow.ui index fe43ae3..6a738d1 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -6,8 +6,8 @@ 0 0 - 539 - 474 + 532 + 447 @@ -30,9 +30,9 @@ - 53 + 43 20 - 81 + 91 20 @@ -56,9 +56,9 @@ - 12 + 7 21 - 41 + 31 16 @@ -156,7 +156,7 @@ 0 0 - 539 + 532 21 diff --git a/modbusoverudp.cpp b/modbusoverudp.cpp index 0d4fa71..e24d9e5 100644 --- a/modbusoverudp.cpp +++ b/modbusoverudp.cpp @@ -21,7 +21,6 @@ void ModbusOverUdp::timeout() } - } @@ -53,7 +52,22 @@ void ModbusOverUdp::readPendingDatagrams() { while (udpSocket->hasPendingDatagrams()) { QNetworkDatagram datagram = udpSocket->receiveDatagram(); - processTheDatagram(datagram); + QByteArray recived = datagram.data(); // копируем датаграмку в аррэй для удобной работы + + int indNachalaCrc = recived[2]+3; + uint16_t crcRecived = Crc16(indNachalaCrc, recived); // в функции используют больше или меньше + + if((recived[indNachalaCrc]&0xFF)==LO(crcRecived)&&(recived[indNachalaCrc+1]&0xFF)==HI(crcRecived)){ //todo внимание костыль + //qDebug()<<"CRC Ок "; + + + }else{ + qDebug()<<"CRC не катит"; + return; + + } + processTheDatagram(datagram); + } } @@ -63,14 +77,20 @@ void ModbusOverUdp::processTheDatagram(QNetworkDatagram & datagram) QByteArray recived = datagram.data(); // копируем датаграмку в аррэй для удобной работы + + Set toSend; //структура для отправки в другой компонент sfloat res; //флоат для сборки из пакета модбас toSend.channel=(typeCHANNEL)(recived[0]-1); //Ch1 = 0 - в енаме - switch (recived.size()){ // сужу о прибывшем по размеру пакета // ЭТО ПЛОХО!!! - case 9: + switch (recived.size()){ // пришла чувствительность + case 9: { + + + //посчитать контрольные суммы + // и добавить кучу проверок на хорошие значения res.ch[3]=recived[3]; // Собираю флоат res.ch[2]=recived[4]; res.ch[1]=recived[5]; @@ -78,29 +98,34 @@ void ModbusOverUdp::processTheDatagram(QNetworkDatagram & datagram) //qDebug() <<"Чувствительность для модбас адреса"<2) return; + if((int)recived[6]>5) return; + if((int)recived[8]>7) return; + if((int)recived[10]>12) return; + if((int)recived[22]>3) return; toSend.IIN=(typeIIN)(recived[4]-0); toSend.IFV=(typeIFV)(recived[6]-0); toSend.IFN=(typeIFN)(recived[8]-0); toSend.IKU=(typeIKU)(recived[10]-0); - //toSend.OUTPUT=(typeOUTPUT)(recived[2]-0); - toSend.VALUE=(typeVALUE)(recived[22]-0); + toSend.VALUE=(typeVALUE)(recived[22]-0); emit stateRecive(toSend); break; - default: - qDebug() <<"ТЫ не понимаешь, это другое"; - qDebug() <<"Это"<bind(QHostAddress::LocalHost,8000,QAbstractSocket::DontShareAddress); + + + + targetIp =QHostAddress(oldIp); + targetPort=7000; + + // QUdpSocket *udpSocketForRecive= new QUdpSocket(this); + + + + connect(udpSocket, SIGNAL(readyRead()), this, SLOT(readPendingDatagrams())); + + QStringList ip= newIp.split("."); + qDebug()<writeDatagram(datagram); + udpSocket->waitForBytesWritten(50); + + +} + void ModbusOverUdp::testReq() { @@ -187,10 +492,4 @@ void ModbusOverUdp::sendPendingDatagrams( QByteArray & data ) } -void ModbusOverUdp::stateSend(Set setWithState) -{ -} -void ModbusOverUdp::sensSend(Set setWithSens) -{ -} diff --git a/modbusoverudp.h b/modbusoverudp.h index 77acc9f..27f4aa5 100644 --- a/modbusoverudp.h +++ b/modbusoverudp.h @@ -6,11 +6,18 @@ #include "QTimer" #include "QDebug" #include -#include +#include "QtNetwork" #define LO(x) ((uint8_t) ((x) & 0xff)) #define HI(x) ((uint8_t) (((x) >> 8) & 0xff)) + + +///////////////// +//привет, я из будущего!! +//Возможно хорошей идеей будет если ты напишешь в обработчике ответов сигналы (в тч и ошибку), +//а потом в зависимости от нужд будешь к ним подключать что нужно +// class ModbusOverUdp : public QObject { Q_OBJECT @@ -56,8 +63,8 @@ public: uint16_t Crc16(uint16_t len, QByteArray iobuf); uint16_t Crc16(uint16_t len, uint16_t iobuf[]); - QHostAddress targetIp; - quint16 targetPort; + QHostAddress targetIp; //работаем с этим адресом + quint16 targetPort; //роаботаем с этим портом signals: @@ -68,11 +75,13 @@ signals: public slots: void connectTo(QString ipAdress, quint16 port); void disconnectFrom(); - void stateSend(Set setWithState); - void sensSend(Set setWithSens); + void set(Set setWithState, typeREQ TYPEREQ); + void readPendingDatagrams(); void timeout(); void req(quint16 adr, typeREQ TYPEREQ); + void changeIp(QString oldIp,QString newIp); + void testReq(); @@ -81,6 +90,7 @@ private: bool isConnected=0; QUdpSocket* udpSocket; + void processTheDatagram(QNetworkDatagram &datagram); }; diff --git a/release/moc_predefs.h b/release/moc_predefs.h new file mode 100644 index 0000000..d4948e6 --- /dev/null +++ b/release/moc_predefs.h @@ -0,0 +1,376 @@ +#define __DBL_MIN_EXP__ (-1021) +#define __FLT32X_MAX_EXP__ 1024 +#define __cpp_attributes 200809 +#define __pentiumpro__ 1 +#define __UINT_LEAST16_MAX__ 0xffff +#define __ATOMIC_ACQUIRE 2 +#define __FLT128_MAX_10_EXP__ 4932 +#define __FLT_MIN__ 1.17549435082228750796873653722224568e-38F +#define __GCC_IEC_559_COMPLEX 2 +#define __UINT_LEAST8_TYPE__ unsigned char +#define __SIZEOF_FLOAT80__ 12 +#define _WIN32 1 +#define __INTMAX_C(c) c ## LL +#define __CHAR_BIT__ 8 +#define __UINT8_MAX__ 0xff +#define __WINT_MAX__ 0xffff +#define __FLT32_MIN_EXP__ (-125) +#define __cpp_static_assert 200410 +#define __ORDER_LITTLE_ENDIAN__ 1234 +#define __SIZE_MAX__ 0xffffffffU +#define __WCHAR_MAX__ 0xffff +#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1 +#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1 +#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1 +#define __DBL_DENORM_MIN__ double(4.94065645841246544176568792868221372e-324L) +#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1 +#define __GCC_ATOMIC_CHAR_LOCK_FREE 2 +#define __GCC_IEC_559 2 +#define __FLT32X_DECIMAL_DIG__ 17 +#define __FLT_EVAL_METHOD__ 2 +#define __cpp_binary_literals 201304 +#define __FLT64_DECIMAL_DIG__ 17 +#define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 2 +#define __cpp_variadic_templates 200704 +#define __UINT_FAST64_MAX__ 0xffffffffffffffffULL +#define __SIG_ATOMIC_TYPE__ int +#define __DBL_MIN_10_EXP__ (-307) +#define __FINITE_MATH_ONLY__ 0 +#define __GNUC_PATCHLEVEL__ 0 +#define __FLT32_HAS_DENORM__ 1 +#define __UINT_FAST8_MAX__ 0xff +#define __has_include(STR) __has_include__(STR) +#define _stdcall __attribute__((__stdcall__)) +#define __DEC64_MAX_EXP__ 385 +#define __INT8_C(c) c +#define __INT_LEAST8_WIDTH__ 8 +#define __UINT_LEAST64_MAX__ 0xffffffffffffffffULL +#define __SHRT_MAX__ 0x7fff +#define __LDBL_MAX__ 1.18973149535723176502126385303097021e+4932L +#define __FLT64X_MAX_10_EXP__ 4932 +#define __UINT_LEAST8_MAX__ 0xff +#define __GCC_ATOMIC_BOOL_LOCK_FREE 2 +#define __FLT128_DENORM_MIN__ 6.47517511943802511092443895822764655e-4966F128 +#define __UINTMAX_TYPE__ long long unsigned int +#define __DEC32_EPSILON__ 1E-6DF +#define __FLT_EVAL_METHOD_TS_18661_3__ 2 +#define __OPTIMIZE__ 1 +#define __UINT32_MAX__ 0xffffffffU +#define __GXX_EXPERIMENTAL_CXX0X__ 1 +#define __LDBL_MAX_EXP__ 16384 +#define __FLT128_MIN_EXP__ (-16381) +#define __WINT_MIN__ 0 +#define __FLT128_MIN_10_EXP__ (-4931) +#define __INT_LEAST16_WIDTH__ 16 +#define __SCHAR_MAX__ 0x7f +#define __FLT128_MANT_DIG__ 113 +#define __WCHAR_MIN__ 0 +#define __INT64_C(c) c ## LL +#define __DBL_DIG__ 15 +#define __GCC_ATOMIC_POINTER_LOCK_FREE 2 +#define __FLT64X_MANT_DIG__ 64 +#define __SIZEOF_INT__ 4 +#define __SIZEOF_POINTER__ 4 +#define __GCC_ATOMIC_CHAR16_T_LOCK_FREE 2 +#define __USER_LABEL_PREFIX__ _ +#define __FLT64X_EPSILON__ 1.08420217248550443400745280086994171e-19F64x +#define __STDC_HOSTED__ 1 +#define __WIN32 1 +#define __LDBL_HAS_INFINITY__ 1 +#define __FLT32_DIG__ 6 +#define __FLT_EPSILON__ 1.19209289550781250000000000000000000e-7F +#define __GXX_WEAK__ 1 +#define __SHRT_WIDTH__ 16 +#define __LDBL_MIN__ 3.36210314311209350626267781732175260e-4932L +#define __DEC32_MAX__ 9.999999E96DF +#define __cpp_threadsafe_static_init 200806 +#define __FLT64X_DENORM_MIN__ 3.64519953188247460252840593361941982e-4951F64x +#define __MINGW32__ 1 +#define __FLT32X_HAS_INFINITY__ 1 +#define __INT32_MAX__ 0x7fffffff +#define __INT_WIDTH__ 32 +#define __SIZEOF_LONG__ 4 +#define __UINT16_C(c) c +#define __PTRDIFF_WIDTH__ 32 +#define __DECIMAL_DIG__ 21 +#define __FLT64_EPSILON__ 2.22044604925031308084726333618164062e-16F64 +#define __INTMAX_WIDTH__ 64 +#define __FLT64_MIN_EXP__ (-1021) +#define __has_include_next(STR) __has_include_next__(STR) +#define __FLT64X_MIN_10_EXP__ (-4931) +#define __LDBL_HAS_QUIET_NAN__ 1 +#define __FLT64_MANT_DIG__ 53 +#define _REENTRANT 1 +#define __GNUC__ 7 +#define _cdecl __attribute__((__cdecl__)) +#define __GXX_RTTI 1 +#define __cpp_delegating_constructors 200604 +#define __FLT_HAS_DENORM__ 1 +#define __SIZEOF_LONG_DOUBLE__ 12 +#define __BIGGEST_ALIGNMENT__ 16 +#define __STDC_UTF_16__ 1 +#define __FLT64_MAX_10_EXP__ 308 +#define __i686 1 +#define __FLT32_HAS_INFINITY__ 1 +#define __DBL_MAX__ double(1.79769313486231570814527423731704357e+308L) +#define _thiscall __attribute__((__thiscall__)) +#define __cpp_raw_strings 200710 +#define __INT_FAST32_MAX__ 0x7fffffff +#define __WINNT 1 +#define __DBL_HAS_INFINITY__ 1 +#define __INT64_MAX__ 0x7fffffffffffffffLL +#define __WINNT__ 1 +#define __DEC32_MIN_EXP__ (-94) +#define __INTPTR_WIDTH__ 32 +#define __FLT32X_HAS_DENORM__ 1 +#define __INT_FAST16_TYPE__ short int +#define _fastcall __attribute__((__fastcall__)) +#define __LDBL_HAS_DENORM__ 1 +#define __cplusplus 201103L +#define __cpp_ref_qualifiers 200710 +#define __DEC128_MAX__ 9.999999999999999999999999999999999E6144DL +#define __INT_LEAST32_MAX__ 0x7fffffff +#define __DEC32_MIN__ 1E-95DF +#define __DEPRECATED 1 +#define __cpp_rvalue_references 200610 +#define __DBL_MAX_EXP__ 1024 +#define __WCHAR_WIDTH__ 16 +#define __FLT32_MAX__ 3.40282346638528859811704183484516925e+38F32 +#define __DEC128_EPSILON__ 1E-33DL +#define __ATOMIC_HLE_RELEASE 131072 +#define __WIN32__ 1 +#define __PTRDIFF_MAX__ 0x7fffffff +#define __ATOMIC_HLE_ACQUIRE 65536 +#define __FLT32_HAS_QUIET_NAN__ 1 +#define __GNUG__ 7 +#define __LONG_LONG_MAX__ 0x7fffffffffffffffLL +#define __SIZEOF_SIZE_T__ 4 +#define __cpp_rvalue_reference 200610 +#define __cpp_nsdmi 200809 +#define __FLT64X_MIN_EXP__ (-16381) +#define __SIZEOF_WINT_T__ 2 +#define __LONG_LONG_WIDTH__ 64 +#define __cpp_initializer_lists 200806 +#define __FLT32_MAX_EXP__ 128 +#define __cpp_hex_float 201603 +#define __GCC_HAVE_DWARF2_CFI_ASM 1 +#define __GXX_ABI_VERSION 1011 +#define __FLT128_HAS_INFINITY__ 1 +#define __FLT_MIN_EXP__ (-125) +#define __i686__ 1 +#define __cpp_lambdas 200907 +#define __FLT64X_HAS_QUIET_NAN__ 1 +#define __INT_FAST64_TYPE__ long long int +#define __FLT64_DENORM_MIN__ 4.94065645841246544176568792868221372e-324F64 +#define __DBL_MIN__ double(2.22507385850720138309023271733240406e-308L) +#define __FLT32X_EPSILON__ 2.22044604925031308084726333618164062e-16F32x +#define __DECIMAL_BID_FORMAT__ 1 +#define __GXX_TYPEINFO_EQUALITY_INLINE 0 +#define __FLT64_MIN_10_EXP__ (-307) +#define __FLT64X_DECIMAL_DIG__ 21 +#define __DEC128_MIN__ 1E-6143DL +#define __REGISTER_PREFIX__ +#define __UINT16_MAX__ 0xffff +#define __DBL_HAS_DENORM__ 1 +#define __cdecl __attribute__((__cdecl__)) +#define __FLT32_MIN__ 1.17549435082228750796873653722224568e-38F32 +#define __UINT8_TYPE__ unsigned char +#define __i386 1 +#define __FLT_MANT_DIG__ 24 +#define __LDBL_DECIMAL_DIG__ 21 +#define __VERSION__ "7.3.0" +#define __UINT64_C(c) c ## ULL +#define __cpp_unicode_characters 200704 +#define __GCC_ATOMIC_INT_LOCK_FREE 2 +#define __FLT128_MAX_EXP__ 16384 +#define __FLT32_MANT_DIG__ 24 +#define _X86_ 1 +#define __FLOAT_WORD_ORDER__ __ORDER_LITTLE_ENDIAN__ +#define __FLT128_HAS_DENORM__ 1 +#define __FLT128_DIG__ 33 +#define __SCHAR_WIDTH__ 8 +#define __INT32_C(c) c +#define __DEC64_EPSILON__ 1E-15DD +#define __ORDER_PDP_ENDIAN__ 3412 +#define __DEC128_MIN_EXP__ (-6142) +#define __code_model_32__ 1 +#define __FLT32_MAX_10_EXP__ 38 +#define __INT_FAST32_TYPE__ int +#define __UINT_LEAST16_TYPE__ short unsigned int +#define __FLT64X_HAS_INFINITY__ 1 +#define __INT16_MAX__ 0x7fff +#define __i386__ 1 +#define __cpp_rtti 199711 +#define __SIZE_TYPE__ unsigned int +#define __UINT64_MAX__ 0xffffffffffffffffULL +#define __FLT64X_DIG__ 18 +#define __INT8_TYPE__ signed char +#define __GCC_ASM_FLAG_OUTPUTS__ 1 +#define __FLT_RADIX__ 2 +#define __INT_LEAST16_TYPE__ short int +#define __LDBL_EPSILON__ 1.08420217248550443400745280086994171e-19L +#define __UINTMAX_C(c) c ## ULL +#define __SIG_ATOMIC_MAX__ 0x7fffffff +#define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 2 +#define __SIZEOF_PTRDIFF_T__ 4 +#define __FLT32X_MANT_DIG__ 53 +#define __FLT32X_MIN_EXP__ (-1021) +#define __DEC32_SUBNORMAL_MIN__ 0.000001E-95DF +#define __pentiumpro 1 +#define __MSVCRT__ 1 +#define __INT_FAST16_MAX__ 0x7fff +#define __FLT64_DIG__ 15 +#define __UINT_FAST32_MAX__ 0xffffffffU +#define __UINT_LEAST64_TYPE__ long long unsigned int +#define __FLT_HAS_QUIET_NAN__ 1 +#define __FLT_MAX_10_EXP__ 38 +#define __LONG_MAX__ 0x7fffffffL +#define __FLT64X_HAS_DENORM__ 1 +#define __DEC128_SUBNORMAL_MIN__ 0.000000000000000000000000000000001E-6143DL +#define __FLT_HAS_INFINITY__ 1 +#define __cpp_unicode_literals 200710 +#define __UINT_FAST16_TYPE__ short unsigned int +#define __DEC64_MAX__ 9.999999999999999E384DD +#define __INT_FAST32_WIDTH__ 32 +#define __CHAR16_TYPE__ short unsigned int +#define __PRAGMA_REDEFINE_EXTNAME 1 +#define __SIZE_WIDTH__ 32 +#define __SEG_FS 1 +#define __INT_LEAST16_MAX__ 0x7fff +#define __DEC64_MANT_DIG__ 16 +#define __UINT_LEAST32_MAX__ 0xffffffffU +#define __SEG_GS 1 +#define __FLT32_DENORM_MIN__ 1.40129846432481707092372958328991613e-45F32 +#define __GCC_ATOMIC_LONG_LOCK_FREE 2 +#define __SIG_ATOMIC_WIDTH__ 32 +#define __INT_LEAST64_TYPE__ long long int +#define __INT16_TYPE__ short int +#define __INT_LEAST8_TYPE__ signed char +#define __DEC32_MAX_EXP__ 97 +#define __INT_FAST8_MAX__ 0x7f +#define __FLT128_MAX__ 1.18973149535723176508575932662800702e+4932F128 +#define __INTPTR_MAX__ 0x7fffffff +#define __GXX_MERGED_TYPEINFO_NAMES 0 +#define __cpp_range_based_for 200907 +#define __FLT64_HAS_QUIET_NAN__ 1 +#define __stdcall __attribute__((__stdcall__)) +#define __FLT32_MIN_10_EXP__ (-37) +#define __EXCEPTIONS 1 +#define __LDBL_MANT_DIG__ 64 +#define __DBL_HAS_QUIET_NAN__ 1 +#define __FLT64_HAS_INFINITY__ 1 +#define __FLT64X_MAX__ 1.18973149535723176502126385303097021e+4932F64x +#define __SIG_ATOMIC_MIN__ (-__SIG_ATOMIC_MAX__ - 1) +#define __INTPTR_TYPE__ int +#define __UINT16_TYPE__ short unsigned int +#define __WCHAR_TYPE__ short unsigned int +#define __SIZEOF_FLOAT__ 4 +#define __UINTPTR_MAX__ 0xffffffffU +#define __INT_FAST64_WIDTH__ 64 +#define __DEC64_MIN_EXP__ (-382) +#define __cpp_decltype 200707 +#define __FLT32_DECIMAL_DIG__ 9 +#define __INT_FAST64_MAX__ 0x7fffffffffffffffLL +#define __GCC_ATOMIC_TEST_AND_SET_TRUEVAL 1 +#define __FLT_DIG__ 6 +#define __FLT64X_MAX_EXP__ 16384 +#define __UINT_FAST64_TYPE__ long long unsigned int +#define __INT_MAX__ 0x7fffffff +#define WIN32 1 +#define __INT64_TYPE__ long long int +#define __FLT_MAX_EXP__ 128 +#define __DBL_MANT_DIG__ 53 +#define __cpp_inheriting_constructors 201511 +#define __SIZEOF_FLOAT128__ 16 +#define __INT_LEAST64_MAX__ 0x7fffffffffffffffLL +#define __DEC64_MIN__ 1E-383DD +#define __WINT_TYPE__ short unsigned int +#define __UINT_LEAST32_TYPE__ unsigned int +#define __SIZEOF_SHORT__ 2 +#define __LDBL_MIN_EXP__ (-16381) +#define __FLT64_MAX__ 1.79769313486231570814527423731704357e+308F64 +#define __WINT_WIDTH__ 16 +#define __INT_LEAST8_MAX__ 0x7f +#define __FLT32X_MAX_10_EXP__ 308 +#define __WCHAR_UNSIGNED__ 1 +#define __LDBL_MAX_10_EXP__ 4932 +#define __ATOMIC_RELAXED 0 +#define __DBL_EPSILON__ double(2.22044604925031308084726333618164062e-16L) +#define __thiscall __attribute__((__thiscall__)) +#define __FLT128_MIN__ 3.36210314311209350626267781732175260e-4932F128 +#define __UINT8_C(c) c +#define __FLT64_MAX_EXP__ 1024 +#define __INT_LEAST32_TYPE__ int +#define __SIZEOF_WCHAR_T__ 2 +#define __FLT128_HAS_QUIET_NAN__ 1 +#define __INT_FAST8_TYPE__ signed char +#define __fastcall __attribute__((__fastcall__)) +#define __FLT64X_MIN__ 3.36210314311209350626267781732175260e-4932F64x +#define __GNUC_STDC_INLINE__ 1 +#define __FLT64_HAS_DENORM__ 1 +#define __FLT32_EPSILON__ 1.19209289550781250000000000000000000e-7F32 +#define __DBL_DECIMAL_DIG__ 17 +#define __STDC_UTF_32__ 1 +#define __INT_FAST8_WIDTH__ 8 +#define __DEC_EVAL_METHOD__ 2 +#define __FLT32X_MAX__ 1.79769313486231570814527423731704357e+308F32x +#define __ORDER_BIG_ENDIAN__ 4321 +#define __cpp_runtime_arrays 198712 +#define __UINT64_TYPE__ long long unsigned int +#define __UINT32_C(c) c ## U +#define __INTMAX_MAX__ 0x7fffffffffffffffLL +#define __cpp_alias_templates 200704 +#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__ +#define WINNT 1 +#define __FLT_DENORM_MIN__ 1.40129846432481707092372958328991613e-45F +#define __INT8_MAX__ 0x7f +#define __LONG_WIDTH__ 32 +#define __UINT_FAST32_TYPE__ unsigned int +#define __CHAR32_TYPE__ unsigned int +#define __FLT_MAX__ 3.40282346638528859811704183484516925e+38F +#define __cpp_constexpr 200704 +#define __INT32_TYPE__ int +#define __SIZEOF_DOUBLE__ 8 +#define __cpp_exceptions 199711 +#define __FLT_MIN_10_EXP__ (-37) +#define __FLT64_MIN__ 2.22507385850720138309023271733240406e-308F64 +#define __INT_LEAST32_WIDTH__ 32 +#define __INTMAX_TYPE__ long long int +#define i386 1 +#define _INTEGRAL_MAX_BITS 64 +#define __DEC128_MAX_EXP__ 6145 +#define __FLT32X_HAS_QUIET_NAN__ 1 +#define __ATOMIC_CONSUME 1 +#define __GNUC_MINOR__ 3 +#define __INT_FAST16_WIDTH__ 16 +#define __UINTMAX_MAX__ 0xffffffffffffffffULL +#define __DEC32_MANT_DIG__ 7 +#define __FLT32X_DENORM_MIN__ 4.94065645841246544176568792868221372e-324F32x +#define __DBL_MAX_10_EXP__ 308 +#define __LDBL_DENORM_MIN__ 3.64519953188247460252840593361941982e-4951L +#define __INT16_C(c) c +#define __STDC__ 1 +#define __FLT32X_DIG__ 15 +#define __PTRDIFF_TYPE__ int +#define __ATOMIC_SEQ_CST 5 +#define __UINT32_TYPE__ unsigned int +#define __FLT32X_MIN_10_EXP__ (-307) +#define __UINTPTR_TYPE__ unsigned int +#define __DEC64_SUBNORMAL_MIN__ 0.000000000000001E-383DD +#define __DEC128_MANT_DIG__ 34 +#define __LDBL_MIN_10_EXP__ (-4931) +#define __FLT128_EPSILON__ 1.92592994438723585305597794258492732e-34F128 +#define __SIZEOF_LONG_LONG__ 8 +#define __cpp_user_defined_literals 200809 +#define __FLT128_DECIMAL_DIG__ 36 +#define __GCC_ATOMIC_LLONG_LOCK_FREE 2 +#define __FLT32X_MIN__ 2.22507385850720138309023271733240406e-308F32x +#define __LDBL_DIG__ 18 +#define __FLT_DECIMAL_DIG__ 9 +#define __UINT_FAST16_MAX__ 0xffff +#define __GCC_ATOMIC_SHORT_LOCK_FREE 2 +#define __INT_LEAST64_WIDTH__ 64 +#define __UINT_FAST8_TYPE__ unsigned char +#define __ATOMIC_ACQ_REL 4 +#define __ATOMIC_RELEASE 3 +#define __declspec(x) __attribute__((x)) diff --git a/windowchannel.cpp b/windowchannel.cpp index b59b530..9d1a98a 100644 --- a/windowchannel.cpp +++ b/windowchannel.cpp @@ -1,6 +1,7 @@ #include "windowchannel.h" #include "ui_windowchannel.h" - +#include "customlabel.h" +//#include "customcombobox.h" windowChannel::windowChannel(QWidget *parent) : @@ -18,13 +19,46 @@ windowChannel::windowChannel(QWidget *parent) : this->setPalette(Pal); this->show(); - thisData.IFN=Lp200; + ui->comboBoxIIN->addItem("Заряд"); //индекс 0 + ui->comboBoxIIN->addItem("IEPE");//индекс 1 + + ui->comboBoxVCH->addItem("0.2Гц"); //индекс 0 + ui->comboBoxVCH->addItem("0.3Гц");//индекс 1 + ui->comboBoxVCH->addItem("1Гц"); //индекс 2 + ui->comboBoxVCH->addItem("2Гц");//индекс 3 + ui->comboBoxVCH->addItem("10Гц"); //индекс 4 + + + ui->comboBoxNCH->addItem("200Гц"); //индекс 0 + ui->comboBoxNCH->addItem("500Гц");//индекс 1 + ui->comboBoxNCH->addItem("1кГц"); //индекс 2 + ui->comboBoxNCH->addItem("5кГц");//индекс 3 + ui->comboBoxNCH->addItem("10кГц"); //индекс 4 + ui->comboBoxNCH->addItem("20кГц");//индекс 5 + ui->comboBoxNCH->addItem("50кГц"); //индекс 6 + ui->comboBoxNCH->addItem("100кГц");//индекс 7 + + + + // QStringList stringList; + // ui->comboBoxOUT->addItems(stringList); + // ui->comboBoxOUT->insertItems(1,stringList); + + thisData.IFN=Lp200; //инициализирую по умолчанию, что бы когда прилетит первый сэнс не было вылета из за расчетов портированных с прибора thisData.IFV=Hp1; thisData.IIN=ICP; thisData.IKU=Ku1; thisData.SENS=1.0; thisData.VALUE=Accel; + connect(ui->labelSENS,SIGNAL(clicked()),this,SLOT(sendSens()));//подключаю сигнал от кастом лэйбла для вызова процедуры смены чувствительности + + + + + + + } windowChannel::~windowChannel() @@ -32,6 +66,25 @@ windowChannel::~windowChannel() delete ui; } +void windowChannel::sendSens() +{ + Set dataToSend=thisData; + bool ok; + dataToSend.SENS = QInputDialog::getDouble(this, tr("Введите значение"), + tr("Введите значение чувствительности датчика"), thisData.SENS, 0.0001, 99999, 4, &ok, + Qt::WindowFlags(), 1); + + + + if (ok){emit ReadyToSend(dataToSend, SENS);} + if(thisData.IKU!=VerifyGainA142(thisData)){ + thisData.IKU=VerifyGainA142(thisData); + emit ReadyToSend(thisData, IKU); + + }; + +} + void windowChannel::setSens(Set data) { @@ -66,37 +119,44 @@ void windowChannel::reDraw() else if(thisData.SENS<100&&thisData.SENS>=10){ui->labelSENS->setText(QString::number(thisData.SENS,'f', 3));} else {ui->labelSENS->setText(QString::number(thisData.SENS,'f', 4));} - +//выставляем значение комбобоксов switch (thisData.IIN) { case ICP:{ - ui->labelIIN->setText("IEPE"); + + ui->comboBoxIIN->setCurrentIndex(1); break; } case CHARGE:{ - ui->labelIIN->setText("Заряд"); + + ui->comboBoxIIN->setCurrentIndex(0); break; } }//end switch switch (thisData.IFV) { case Hp0_2:{ - ui->labelVCH->setText("0.2Гц"); + + ui->comboBoxVCH->setCurrentIndex(0); break; } case Hp0_3:{ - ui->labelVCH->setText("0.3Гц"); + + ui->comboBoxVCH->setCurrentIndex(1); break; } case Hp1:{ - ui->labelVCH->setText("1Гц"); + + ui->comboBoxVCH->setCurrentIndex(2); break; } case Hp2:{ - ui->labelVCH->setText("2Гц"); + + ui->comboBoxVCH->setCurrentIndex(3); break; } case Hp10:{ - ui->labelVCH->setText("10Гц"); + + ui->comboBoxVCH->setCurrentIndex(4); break; } }//end switch @@ -104,66 +164,101 @@ void windowChannel::reDraw() switch (thisData.IFN) { case Lp200:{ - ui->labelNCH->setText("200Гц"); + + ui->comboBoxNCH->setCurrentIndex(0); break; } case Lp500:{ - ui->labelNCH->setText("500Гц"); + + ui->comboBoxNCH->setCurrentIndex(1); break; } case Lp1000:{ - ui->labelNCH->setText("1кГц"); + + ui->comboBoxNCH->setCurrentIndex(2); break; } case Lp5000:{ - ui->labelNCH->setText("5кГц"); + + ui->comboBoxNCH->setCurrentIndex(3); break; } case Lp10000:{ - ui->labelNCH->setText("10кГц"); + + ui->comboBoxNCH->setCurrentIndex(4); break; } case Lp20000:{ - ui->labelNCH->setText("20кГц"); + + ui->comboBoxNCH->setCurrentIndex(5); break; } case Lp50000:{ - ui->labelNCH->setText("50кГц"); + + ui->comboBoxNCH->setCurrentIndex(6); break; } case Lp100000:{ - ui->labelNCH->setText("100кГц"); + + ui->comboBoxNCH->setCurrentIndex(7); break; } }//end switch switch (thisData.VALUE) { case Accel:{ - if(thisData.IIN==ICP)(ui->labelUNIT1->setText("мВ/м/c2")); - else{ui->labelUNIT1->setText("пКл/м/с2");} + ui->comboBoxUNIT->setCurrentIndex(0); + break; } case Nython:{ - if(thisData.IIN==ICP)(ui->labelUNIT1->setText("мВ/Н")); - else{ui->labelUNIT1->setText("пКл/Н");} + ui->comboBoxUNIT->setCurrentIndex(1); + break; } case Pascal:{ - if(thisData.IIN==ICP)(ui->labelUNIT1->setText("мВ/Па")); - else{ui->labelUNIT1->setText("пКл/Па");} + ui->comboBoxUNIT->setCurrentIndex(2); + break; } }//end switch ui->labelOUT->setText(DisplayIKUA142(thisData.SENS, thisData.IKU, thisData.VALUE)); + showValue(); } +void windowChannel::hideValue() +{ + ui->comboBoxIIN->hide(); + ui->comboBoxNCH->hide(); + ui->comboBoxOUT->hide(); + ui->comboBoxVCH->hide(); + ui->comboBoxIIN->hide(); + ui->comboBoxUNIT->hide(); + ui->labelSENS->hide(); + +} + +void windowChannel::showValue() +{ + ui->comboBoxIIN->show(); + ui->comboBoxNCH->show(); + ui->comboBoxOUT->show(); + ui->comboBoxVCH->show(); + ui->comboBoxIIN->show(); + ui->comboBoxUNIT->show(); + ui->labelSENS->show(); + +} + void windowChannel::setWindowsChannel(typeCHANNEL channel) { this->channel = channel; - ui->labelChanel->setNum((int)(channel+1)); + thisData.channel=channel; + ui->labelChanel->setNum((int)(channel+1)); //потому что енам с 0 + } typeCHANNEL windowChannel::getWindowsChannel() @@ -172,128 +267,129 @@ typeCHANNEL windowChannel::getWindowsChannel() } -typeIKU windowChannel::VerifyGainA142(float sens, typeIKU iku) +typeIKU windowChannel::VerifyGainA142(Set thisData) //сверяет гейн на допусимый прибора при установке сенс { - if(sens <= 0.0010f) //0.001 + if(thisData.SENS <= 0.0010f) //0.001 { - if(iku > Ku1000) + if(thisData.IKU > Ku1000) { - iku = Ku1000; + thisData.IKU = Ku1000; } } else - if(/*sens >= 0.0011f && */sens <= 10.000f) //0.002 + if(/*sens >= 0.0011f && */thisData.SENS <= 10.000f) //0.002 { - if(iku > Ku1000) + if(thisData.IKU > Ku1000) { - iku = Ku1000; + thisData.IKU = Ku1000; } } else - if(/*sens >= 10.001f && */sens <= 20.000f) //20 + if(/*sens >= 10.001f && */thisData.SENS <= 20.000f) //20 { - if(iku > Ku500) + if(thisData.IKU > Ku500) { - iku = Ku500; + thisData.IKU = Ku500; } } else - if(/*sens >= 20.001f && */sens <= 50.000f) //50 + if(/*sens >= 20.001f && */thisData.SENS <= 50.000f) //50 { - if(iku > Ku200) + if(thisData.IKU > Ku200) { - iku = Ku200; + thisData.IKU = Ku200; } } else - if(/*sens >= 50.001f && */sens <= 100.00f) //100 + if(/*sens >= 50.001f && */thisData.SENS <= 100.00f) //100 { - if(iku > Ku100) + if(thisData.IKU > Ku100) { - iku = Ku100; + thisData.IKU = Ku100; } } else - if(/*sens >= 100.01f && */sens <= 200.00f) //200 + if(/*sens >= 100.01f && */thisData.SENS <= 200.00f) //200 { - if(iku > Ku50) + if(thisData.IKU > Ku50) { - iku = Ku50; + thisData.IKU = Ku50; } } else - if(/*sens >= 200.01f && */sens <= 500.00f) //500 + if(/*sens >= 200.01f && */thisData.SENS <= 500.00f) //500 { - if(iku > Ku20) + if(thisData.IKU > Ku20) { - iku = Ku20; + thisData.IKU = Ku20; } } else - if(/*sens >= 500.01f && */sens <= 1000.0f) //1000 + if(/*sens >= 500.01f && */thisData.SENS <= 1000.0f) //1000 { - if(iku > Ku10) + if(thisData.IKU > Ku10) { - iku = Ku10; + thisData.IKU = Ku10; } } else - if(/*sens >= 1000.01f && */sens <= 2000.0f) //2000 + if(/*sens >= 1000.01f && */thisData.SENS <= 2000.0f) //2000 { - if(iku > Ku5) + if(thisData.IKU > Ku5) { - iku = Ku5; + thisData.IKU = Ku5; } } else - if(/*sens >= 2000.01f && */sens <= 5000.0f) //5000 + if(/*sens >= 2000.01f && */thisData.SENS <= 5000.0f) //5000 { - if(iku > Ku2) + if(thisData.IKU > Ku2) { - iku = Ku2; + thisData.IKU = Ku2; } } else - if(/*sens >= 5000.01f && */sens <= 10000.0f) //10000 + if(/*sens >= 5000.01f && */thisData.SENS <= 10000.0f) //10000 { - if(iku > Ku1) + if(thisData.IKU > Ku1) { - iku = Ku1; + thisData.IKU = Ku1; } } else - if(/*sens >= 10001.0f && */sens <= 20000.0f) //20000 + if(/*sens >= 10001.0f && */thisData.SENS <= 20000.0f) //20000 { - if(iku > Ku0_5) + if(thisData.IKU > Ku0_5) { - iku = Ku0_5; + thisData.IKU = Ku0_5; } } else - if(/*sens >= 20001.0f && */sens <= 50000.0f) //50000 + if(/*sens >= 20001.0f && */thisData.SENS <= 50000.0f) //50000 { - if(iku > Ku0_2) + if(thisData.IKU > Ku0_2) { - iku = Ku0_2; + thisData.IKU = Ku0_2; } } else - if(sens < 100000.0f) //99999 + if(thisData.SENS < 100000.0f) //99999 { - if(iku > Ku0_1) + if(thisData.IKU > Ku0_1) { - iku = Ku0_1; + thisData.IKU = Ku0_1; } } - return iku; + return thisData.IKU; } QString windowChannel::DisplayIKUA142(float sens, typeIKU iku ,typeVALUE value) {uint out; + uint offset; //вбычку обьявлю тут const char *pOUT[3][25] = @@ -385,129 +481,462 @@ QString windowChannel::DisplayIKUA142(float sens, typeIKU iku ,typeVALUE value) if(sens <= 0.0010f) //0.001 { out = iku; + offset=0; + } else if(/*sens >= 0.0011f && */sens <= 0.0020f) //0.002 { out = (uint16_t)iku + 1; + offset=1; } else if(/*sens >= 0.0021f && */sens <= 0.0050f) //0.005 { out = (uint16_t)iku + 2; + offset=2; } else if(/*sens >= 0.0051f && */sens <= 0.0100f) //0.01 { out = (uint16_t)iku + 3; + offset=3; } else if(/*sens >= 0.0101f && */sens <= 0.0200f) //0.02 { out = (uint16_t)iku + 4; + offset=4; } else if(/*sens >= 0.0201f && */sens <= 0.0500f) //0.05 { out = (uint16_t)iku + 5; + offset=5; } else if(/*sens >= 0.0501f && */sens <= 0.1000f) //0.1 { out = (uint16_t)iku + 6; + offset=6; } else if(/*sens >= 0.1001f && */sens <= 0.2000f) //0.2 { out = (uint16_t)iku + 7; + offset=7; } else if(/*sens >= 0.2001f && */sens <= 0.5000f) //0.5 { out = (uint16_t)iku + 8; + offset=8; } else if(/*sens >= 0.5001f && */sens <= 1.0000f) //1 { out = (uint16_t)iku + 9; + offset=9; } else if(/*sens >= 1.0001f && */sens <= 2.0000f) //2 { out = (uint16_t)iku + 10; + offset=10; } else if(/*sens >= 2.0001f && */sens <= 5.0000f) //5 { out = (uint16_t)iku + 11; + offset=11; } else if(/*sens >= 5.0001f && */sens <= 10.000f) //10 { out = (uint16_t)iku + 12; + offset=12; } else if(/*sens >= 10.001f && */sens <= 20.000f) //20 { out = (uint16_t)iku + 13; + offset=13; } else if(/*sens >= 20.001f && */sens <= 50.000f) //50 { out = (uint16_t)iku + 14; + offset=14; } else if(/*sens >= 50.001f && */sens <= 100.00f) //100 { out = (uint16_t)iku + 15; + offset=15; } else if(/*sens >= 100.01f && */sens <= 200.00f) //200 { out = (uint16_t)iku + 16; + offset=16; } else if(/*sens >= 200.01f && */sens <= 500.00f) //500 { out = (uint16_t)iku + 17; + offset=17; } else if(/*sens >= 500.01f && */sens <= 1000.0f) //1000 { out = (uint16_t)iku + 18; + offset=18; } else if(/*sens >= 1000.1f && */sens <= 2000.0f) //2000 { out = (uint16_t)iku + 19; + offset=19; } else if(/*sens >= 2000.1f && */sens <= 5000.0f) //2000 { out = (uint16_t)iku + 20; + offset=20; } else if(/*sens >= 5000.1f && */sens <= 10000.0f) //10000 { out = (uint16_t)iku + 21; + offset=21; } else if(/*sens >= 10001 && */sens <= 20000.0f) //20000 { out = (uint16_t)iku + 22; + offset=22; } else if(/*sens >= 20001 && */sens <= 50000.0f) //50000 { out = (uint16_t)iku + 23; + offset=23; } else if(/*sens >= 50001 && */sens <= 100000) //100000 { out = (uint16_t)iku + 24; + offset=24; } + // qDebug()<<"текущяя строка Ку по списку"<comboBoxOUT->clear(); + uint16_t maxPlannedOut = offset+13; + for (uint offsetToWork=offset;((offsetToWork<25)&&(offsetToWorkcomboBoxOUT->addItem(pOUT[(uint16_t)value][offsetToWork]); + ui->comboBoxOUT->setCurrentIndex(iku); + //qDebug()<<"добавлено смещние"<comboBoxUNIT->currentIndex(); + ui->comboBoxUNIT->clear(); + + if(index==0) {thisData.IIN=CHARGE; + ui->comboBoxUNIT->addItem("пКл/м/с2"); + ui->comboBoxUNIT->addItem("пКл/Н"); + + ui->comboBoxUNIT->addItem("пКл/Па"); + + //ui->comboBoxUNIT->setCurrentIndex(currentIndex); + + } + else {thisData.IIN=ICP; + ui->comboBoxUNIT->addItem("мВ/м/c2"); + ui->comboBoxUNIT->addItem("мВ/Н"); + ui->comboBoxUNIT->addItem("мВ/Па"); + // ui->comboBoxUNIT->setCurrentIndex(currentIndex); + } + + emit ReadyToSend(thisData, IIN); +} + +void windowChannel::on_comboBoxVCH_activated(int index) +{ + if(index==0) thisData.IFV=Hp0_2; + else if(index==1) thisData.IFV=Hp0_3; + else if(index==2) thisData.IFV=Hp1; + else if(index==3) thisData.IFV=Hp2; + else if(index==4) thisData.IFV=Hp10; + emit ReadyToSend(thisData, IFV); +} + +void windowChannel::on_comboBoxNCH_activated(int index) +{ + if(index==0) thisData.IFN=Lp200; + else if(index==1) thisData.IFN=Lp500; + else if(index==2) thisData.IFN=Lp1000; + else if(index==3) thisData.IFN=Lp5000; + else if(index==4) thisData.IFN=Lp10000; + else if(index==5) thisData.IFN=Lp20000; + else if(index==6) thisData.IFN=Lp50000; + else if(index==7) thisData.IFN=Lp100000; + emit ReadyToSend(thisData, IFN); +} + +void windowChannel::on_comboBoxUNIT_currentIndexChanged(int index) +{ +} + + + +void windowChannel::on_comboBoxUNIT_activated(int index) +{ + if(index==0) thisData.VALUE=Accel; + + + else if(index==1) thisData.VALUE=Nython; + else if(index==2) thisData.VALUE=Pascal; + emit ReadyToSend(thisData, VAL); +} + +void windowChannel::on_comboBoxIIN_activated(int index) +{ + +} + +QStringList windowChannel::avalibleKuList(Set thisData) +{ + QStringList result; + uint startIndex; + + //вбычку обьявлю тут + + const char *pOUT[3][25] = + { + { + "0.0001 мВ/м/c2", + "0.0002 мВ/м/c2", + "0.0005 мВ/м/c2", + "0.001 мВ/м/c2", + "0.002 мВ/м/c2", + "0.005 мВ/м/c2", + "0.01 мВ/м/c2", + "0.02 мВ/м/c2", + "0.05 мВ/м/c2", + "0.1 мВ/м/c2", + "0.2 мВ/м/c2", + "0.5 мВ/м/c2", + "1 мВ/м/c2", + "2 мВ/м/c2", + "5 мВ/м/c2", + "10 мВ/м/c2", + "20 мВ/м/c2", + "50 мВ/м/c2", + "100 мВ/м/c2", + "200 мВ/м/c2", + "500 мВ/м/c2", + "1 В/м/c2", + "2 В/м/c2", + "5 В/м/c2", + "10 В/м/c2" + }, + { + "0.0001 мВ/Па", + "0.0002 мВ/Па", + "0.0005 мВ/Па", + "0.001 мВ/Па", + "0.002 мВ/Па", + "0.005 мВ/Па", + "0.01 мВ/Па", + "0.02 мВ/Па", + "0.05 мВ/Па", + "0.1 мВ/Па", + "0.2 мВ/Па", + "0.5 мВ/Па", + "1 мВ/Па", + "2 мВ/Па", + "5 мВ/Па", + "10 мВ/Па", + "20 мВ/Па", + "50 мВ/Па", + "100 мВ/Па", + "200 мВ/Па", + "500 мВ/Па", + "1 В/Па", + "2 В/Па", + "5 В/Па", + "10 В/Па" + }, + { + "0.0001 мВ/Н", + "0.0002 мВ/Н", + "0.0005 мВ/Н", + "0.001 мВ/Н", + "0.002 мВ/Н", + "0.005 мВ/Н", + "0.01 мВ/Н", + "0.02 мВ/Н", + "0.05 мВ/Н", + "0.1 мВ/Н", + "0.2 мВ/Н", + "0.5 мВ/Н", + "1 мВ/Н", + "2 мВ/Н", + "5 мВ/Н", + "10 мВ/Н", + "20 мВ/Н", + "50 мВ/Н", + "100 мВ/Н", + "200 мВ/Н", + "500 мВ/Н", + "1 В/Н", + "2 В/Н", + "5 В/Н", + "10 В/Н" + } + }; + + if(thisData.SENS <= 0.0010f) //0.001 + { + startIndex = thisData.IKU; + } + else + if(/*thisData.SENS >= 0.0011f && */thisData.SENS <= 0.0020f) //0.002 + { + startIndex = (uint16_t)thisData.IKU + 1; + } + else + if(/*thisData.SENS >= 0.0021f && */thisData.SENS <= 0.0050f) //0.005 + { + startIndex = (uint16_t)thisData.IKU + 2; + } + else + if(/*thisData.SENS >= 0.0051f && */thisData.SENS <= 0.0100f) //0.01 + { + startIndex = (uint16_t)thisData.IKU + 3; + } + else + if(/*thisData.SENS >= 0.0101f && */thisData.SENS <= 0.0200f) //0.02 + { + startIndex = (uint16_t)thisData.IKU + 4; + } + else + if(/*thisData.SENS >= 0.0201f && */thisData.SENS <= 0.0500f) //0.05 + { + startIndex = (uint16_t)thisData.IKU + 5; + } + else + if(/*thisData.SENS >= 0.0501f && */thisData.SENS <= 0.1000f) //0.1 + { + startIndex = (uint16_t)thisData.IKU + 6; + } + else + if(/*thisData.SENS >= 0.1001f && */thisData.SENS <= 0.2000f) //0.2 + { + startIndex = (uint16_t)thisData.IKU + 7; + } + else + if(/*thisData.SENS >= 0.2001f && */thisData.SENS <= 0.5000f) //0.5 + { + startIndex = (uint16_t)thisData.IKU + 8; + } + else + if(/*thisData.SENS >= 0.5001f && */thisData.SENS <= 1.0000f) //1 + { + startIndex = (uint16_t)thisData.IKU + 9; + } + else + if(/*thisData.SENS >= 1.0001f && */thisData.SENS <= 2.0000f) //2 + { + startIndex = (uint16_t)thisData.IKU + 10; + } + else + if(/*thisData.SENS >= 2.0001f && */thisData.SENS <= 5.0000f) //5 + { + startIndex = (uint16_t)thisData.IKU + 11; + } + else + if(/*thisData.SENS >= 5.0001f && */thisData.SENS <= 10.000f) //10 + { + startIndex = (uint16_t)thisData.IKU + 12; + } + else + if(/*thisData.SENS >= 10.001f && */thisData.SENS <= 20.000f) //20 + { + startIndex = (uint16_t)thisData.IKU + 13; + } + else + if(/*thisData.SENS >= 20.001f && */thisData.SENS <= 50.000f) //50 + { + startIndex = (uint16_t)thisData.IKU + 14; + } + else + if(/*thisData.SENS >= 50.001f && */thisData.SENS <= 100.00f) //100 + { + startIndex = (uint16_t)thisData.IKU + 15; + } + else + if(/*thisData.SENS >= 100.01f && */thisData.SENS <= 200.00f) //200 + { + startIndex = (uint16_t)thisData.IKU + 16; + } + else + if(/*thisData.SENS >= 200.01f && */thisData.SENS <= 500.00f) //500 + { + startIndex = (uint16_t)thisData.IKU + 17; + } + else + if(/*thisData.SENS >= 500.01f && */thisData.SENS <= 1000.0f) //1000 + { + startIndex = (uint16_t)thisData.IKU + 18; + } + else + if(/*thisData.SENS >= 1000.1f && */thisData.SENS <= 2000.0f) //2000 + { + startIndex = (uint16_t)thisData.IKU + 19; + } + else + if(/*thisData.SENS >= 2000.1f && */thisData.SENS <= 5000.0f) //2000 + { + startIndex = (uint16_t)thisData.IKU + 20; + } + else + if(/*thisData.SENS >= 5000.1f && */thisData.SENS <= 10000.0f) //10000 + { + startIndex = (uint16_t)thisData.IKU + 21; + } + else + if(/*thisData.SENS >= 10001 && */thisData.SENS <= 20000.0f) //20000 + { + startIndex = (uint16_t)thisData.IKU + 22; + } + else + if(/*thisData.SENS >= 20001 && */thisData.SENS <= 50000.0f) //50000 + { + startIndex = (uint16_t)thisData.IKU + 23; + } + else + if(/*thisData.SENS >= 50001 && */thisData.SENS <= 100000) //100000 + { + startIndex = (uint16_t)thisData.IKU + 24; + } + + qDebug()<<"стартовый индекс для расчета "< #include +#include +#include namespace Ui { class windowChannel; @@ -11,30 +13,58 @@ class windowChannel; class windowChannel : public QWidget { Q_OBJECT - + class MainWindow; + bool isConnected; public: + void hideValue(); + void showValue(); void setWindowsChannel(typeCHANNEL channel); typeCHANNEL getWindowsChannel(); - typeIKU VerifyGainA142(float sens,typeIKU iku); + typeIKU VerifyGainA142(Set thisData); QString DisplayIKUA142(float sens,typeIKU iku, typeVALUE value); - - - explicit windowChannel(QWidget *parent = nullptr); ~windowChannel(); + signals: + void ReadyToSend(Set, typeREQ); + public slots: + + void sendSens(); + void setSens(Set data); void setState(Set data); void reDraw(); +private slots: + //void on_comboBoxIIN_currentIndexChanged(const QString &arg1); + + void on_comboBoxIIN_currentIndexChanged(int index); + + void on_comboBoxVCH_activated(int index); + + void on_comboBoxNCH_activated(int index); + + void on_comboBoxUNIT_currentIndexChanged(int index); + + void on_comboBoxUNIT_activated(int index); + + void on_comboBoxIIN_activated(int index); + + void on_comboBoxOUT_activated(int index); + + //void on_comboBoxUNIT_activated(const QString &arg1); + private: Set thisData; //данные этой структуры typeCHANNEL channel; Ui::windowChannel *ui; + + QStringList avalibleKuList(Set thisData); + }; #endif // WINDOWCHANNEL_H diff --git a/windowchannel.ui b/windowchannel.ui index d0cea8f..86e45f2 100644 --- a/windowchannel.ui +++ b/windowchannel.ui @@ -2887,175 +2887,7 @@ ВЫХОД: - - - - 90 - 36 - 61 - 31 - - - - - - - - - 212 - 174 - 19 - - - - - - - - - 212 - 174 - 19 - - - - - - - - - 0 - 0 - 0 - - - - - - - - - Segoe UI - 14 - - - - Здаряд - - - - - - 90 - 66 - 61 - 31 - - - - - - - - - 212 - 174 - 19 - - - - - - - - - 212 - 174 - 19 - - - - - - - - - 0 - 0 - 0 - - - - - - - - - Segoe UI - 14 - - - - 77Гц - - - - - - 90 - 96 - 71 - 31 - - - - - - - - - 212 - 174 - 19 - - - - - - - - - 212 - 174 - 19 - - - - - - - - - 0 - 0 - 0 - - - - - - - - - Segoe UI - 14 - - - - 77кГц - - - + 99 @@ -3108,66 +2940,13 @@ - ???.?? - - - - - - 159 - 122 - 91 - 31 - - - - - - - - - 212 - 174 - 19 - - - - - - - - - 212 - 174 - 19 - - - - - - - - - 0 - 0 - 0 - - - - - - - - - Segoe UI - 14 - - - - п?/м/с2 + 0.0000 + + false + 100 @@ -3236,21 +3015,114 @@ + + + + 80 + 37 + 81 + 31 + + + + + Segoe UI + 14 + + + + + + + 70 + 68 + 81 + 28 + + + + + Segoe UI + 14 + + + + + + + 70 + 96 + 91 + 31 + + + + + Segoe UI + 14 + + + + + + + 160 + 121 + 101 + 31 + + + + + Segoe UI + 14 + + + + + + + 86 + 150 + 161 + 31 + + + + + Segoe UI + 14 + + + pushButton label_34 labelChanel - labelIIN - labelVCH - labelNCH labelSENS - labelUNIT1 labelOUT label_6 label_3 label_4 label_2 label_5 + comboBoxIIN + comboBoxVCH + comboBoxNCH + comboBoxUNIT + comboBoxOUT + + + CustomLabel + QLabel +
customlabel.h
+
+ + CustomComboBox + QComboBox +
customcombobox.h
+
+