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 25ee350..4b74940 100644 Binary files a/icon.ico and b/icon.ico differ diff --git a/ipsettings.cpp b/ipsettings.cpp new file mode 100644 index 0000000..c0fa9a9 --- /dev/null +++ b/ipsettings.cpp @@ -0,0 +1,27 @@ +#include "ipsettings.h" +#include "ui_ipsettings.h" +#include "mainwindow.h" +#include "modbusoverudp.h" + + +ipSettings::ipSettings(QWidget *parent, QString ip, ModbusOverUdp* modbus) : + QDialog(parent), + ui(new Ui::ipSettings) +{ + this->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
+
+