Prechádzať zdrojové kódy

add tool_chassis_check. not complete.

yuchuli 4 mesiacov pred
rodič
commit
2f06de68de

+ 73 - 0
src/tool/tool_chassis_check/.gitignore

@@ -0,0 +1,73 @@
+# This file is used to ignore files which are generated
+# ----------------------------------------------------------------------------
+
+*~
+*.autosave
+*.a
+*.core
+*.moc
+*.o
+*.obj
+*.orig
+*.rej
+*.so
+*.so.*
+*_pch.h.cpp
+*_resource.rc
+*.qm
+.#*
+*.*#
+core
+!core/
+tags
+.DS_Store
+.directory
+*.debug
+Makefile*
+*.prl
+*.app
+moc_*.cpp
+ui_*.h
+qrc_*.cpp
+Thumbs.db
+*.res
+*.rc
+/.qmake.cache
+/.qmake.stash
+
+# qtcreator generated files
+*.pro.user*
+
+# xemacs temporary files
+*.flc
+
+# Vim temporary files
+.*.swp
+
+# Visual Studio generated files
+*.ib_pdb_index
+*.idb
+*.ilk
+*.pdb
+*.sln
+*.suo
+*.vcproj
+*vcproj.*.*.user
+*.ncb
+*.sdf
+*.opensdf
+*.vcxproj
+*vcxproj.*
+
+# MinGW generated files
+*.Debug
+*.Release
+
+# Python byte code
+*.pyc
+
+# Binaries
+# --------
+*.dll
+*.exe
+

+ 11 - 0
src/tool/tool_chassis_check/main.cpp

@@ -0,0 +1,11 @@
+#include "mainwindow.h"
+
+#include <QApplication>
+
+int main(int argc, char *argv[])
+{
+    QApplication a(argc, argv);
+    MainWindow w;
+    w.show();
+    return a.exec();
+}

+ 168 - 0
src/tool/tool_chassis_check/mainwindow.cpp

@@ -0,0 +1,168 @@
+#include "mainwindow.h"
+#include "ui_mainwindow.h"
+
+#include <QMessageBox>
+
+MainWindow::MainWindow(QWidget *parent)
+    : QMainWindow(parent)
+    , ui(new Ui::MainWindow)
+{
+    ui->setupUi(this);
+
+    mpLabelTip = new QLabel(this);
+    mpLabelTip->setText(tr("回车确认输入"));
+    mpLabelTip->setMidLineWidth(50);
+
+    mpLabelInfo = new QLabel(this);
+    mpLabelInfo->setText(tr(""));
+    mpLabelInfo->setMidLineWidth(150);
+
+    ui->statusbar->addWidget(mpLabelTip);
+    ui->statusbar->addWidget(mpLabelInfo);
+
+    ui->checkBox_left->setChecked(mbleft);
+    ui->checkBox_right->setChecked(mbright);
+
+    ui->lineEdit_wheel->setText(QString::number(mfwheel,'g'));
+    ui->lineEdit_drive->setText(QString::number(mftorque,'g'));
+    ui->lineEdit_brake->setText(QString::number(mfbrake,'g'));
+
+    QString styleLabel =  "QLabel {"
+                                 "    background-color: rgb(10, 90, 160);"  // 背景颜色
+                                 "    color: white;"               // 字体颜色
+                                 "}";
+    QString styleEdit =  "QLineEdit {"
+                                 "    background-color: rgb(0, 160, 50);"  // 背景颜色
+                                 "    color: white;"               // 字体颜色
+                                 "}";
+    QString styleCheck =  "QCheckBox {"
+                                 "    background-color: rgb(0, 160, 50);"  // 背景颜色
+                                 "    color: white;"               // 字体颜色
+                                 "}";
+    ui->label_1->setStyleSheet(styleLabel);
+    ui->label_2->setStyleSheet(styleLabel);
+    ui->label_3->setStyleSheet(styleLabel);
+    ui->label_4->setStyleSheet(styleLabel);
+
+    ui->checkBox_left->setStyleSheet(styleCheck);
+    ui->checkBox_right->setStyleSheet(styleCheck);
+
+    ui->lineEdit_wheel->setStyleSheet(styleEdit);
+    ui->lineEdit_drive->setStyleSheet(styleEdit);
+    ui->lineEdit_brake->setStyleSheet(styleEdit);
+
+    updatevalue();
+
+    setWindowTitle(tr("线控底盘检测项目"));
+
+}
+
+MainWindow::~MainWindow()
+{
+    delete ui;
+}
+
+
+void MainWindow::on_checkBox_left_stateChanged(int arg1)
+{
+    (void)arg1;
+}
+
+void MainWindow::on_checkBox_right_stateChanged(int arg1)
+{
+    (void)arg1;
+}
+
+void MainWindow::on_checkBox_left_clicked()
+{
+    if(ui->checkBox_left->isChecked())
+    {
+        if(ui->checkBox_right->isChecked())ui->checkBox_right->setChecked(false);
+    }
+    updatevalue();
+}
+
+void MainWindow::on_checkBox_right_clicked()
+{
+    if(ui->checkBox_right->isChecked()){
+        if(ui->checkBox_left->isChecked())ui->checkBox_left->setChecked(false);
+    }
+    updatevalue();
+}
+
+void MainWindow::keyPressEvent(QKeyEvent *event){
+    (void)event;
+    if (event->modifiers() == Qt::ControlModifier && event->key() == Qt::Key_E) {
+        updatevalue();
+    }
+}
+
+void MainWindow::on_lineEdit_wheel_returnPressed()
+{
+    updatevalue();
+}
+
+void MainWindow::on_lineEdit_drive_returnPressed()
+{
+    updatevalue();
+}
+
+void MainWindow::on_lineEdit_brake_returnPressed()
+{
+    updatevalue();
+}
+
+void MainWindow::updatevalue()
+{
+    const double MAXWHEEL = 430.0;
+    const double MINWHEEL = -430.0;
+    const double MAXTORQUE = 100;
+    const double MAXBRAKE = -3.0;
+
+    if(ui->checkBox_left->isChecked())mbleft = true;
+    else mbleft = false;
+    if(ui->checkBox_right->isChecked())mbright = true;
+    else mbright = false;
+    double fwheel = ui->lineEdit_wheel->text().toDouble();
+    if(fwheel>MAXWHEEL){
+        char strtip[256];
+        snprintf(strtip,256,"Wheel exceed maximum wheel. Wheel Range is %6.1f  ---  %6.1f",MINWHEEL,MAXWHEEL);
+        QMessageBox::warning(this,tr("Warning"),strtip,QMessageBox::YesAll);
+        return;
+    }
+    if(fwheel<MINWHEEL){
+        char strtip[256];
+        snprintf(strtip,256,"Wheel exceed maximum wheel. Wheel Range is %6.1f  ---  %6.1f",MINWHEEL,MAXWHEEL);
+        QMessageBox::warning(this,tr("Warning"),strtip,QMessageBox::YesAll);
+        return;
+    }
+    mfwheel = fwheel;
+    double ftorque = ui->lineEdit_drive->text().toDouble();
+    if(ftorque > MAXTORQUE){
+        char strtip[256];
+        snprintf(strtip,256,"Torque exceed maximum torque. Torque Range is %6.1f  ---  %6.1f",0.0,MAXTORQUE);
+        QMessageBox::warning(this,tr("Warning"),strtip,QMessageBox::YesAll);
+        return;
+    }
+    if(ftorque<-0.0000001)
+    {
+        char strtip[256];
+        snprintf(strtip,256,"Torque must bigger than 0. Torque Range is %6.1f  ---  %6.1f",0.0,MAXTORQUE);
+        QMessageBox::warning(this,tr("Warning"),strtip,QMessageBox::YesAll);
+        return;
+    }
+    mftorque = ftorque;
+    double fbrake = ui->lineEdit_brake->text().toDouble();
+    if(fbrake < MAXBRAKE)
+    {
+        char strtip[256];
+        snprintf(strtip,256,"Brake exceed maximum brake. Brake Range is %6.1f  ---  %6.1f",MAXBRAKE,0.0);
+        QMessageBox::warning(this,tr("Warning"),strtip,QMessageBox::YesAll);
+        return;
+    }
+    mfbrake = fbrake;
+    char strout[1000];
+    snprintf(strout,1000,"Left:%d Right:%d  Wheel:%6.1f Torque:%6.1f Brake:%6.1f",
+             mbleft,mbright,mfwheel,mftorque,mfbrake);
+    mpLabelInfo->setText(strout);
+}

+ 54 - 0
src/tool/tool_chassis_check/mainwindow.h

@@ -0,0 +1,54 @@
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+#include <QLabel>
+#include <QKeyEvent>
+
+QT_BEGIN_NAMESPACE
+namespace Ui { class MainWindow; }
+QT_END_NAMESPACE
+
+class MainWindow : public QMainWindow
+{
+    Q_OBJECT
+
+public:
+    MainWindow(QWidget *parent = nullptr);
+    ~MainWindow();
+
+private slots:
+    void on_checkBox_left_stateChanged(int arg1);
+
+    void on_checkBox_right_stateChanged(int arg1);
+
+    void on_checkBox_left_clicked();
+
+    void on_checkBox_right_clicked();
+
+    void on_lineEdit_wheel_returnPressed();
+
+    void on_lineEdit_drive_returnPressed();
+
+    void on_lineEdit_brake_returnPressed();
+
+public:
+    void keyPressEvent(QKeyEvent *event) override;
+
+private:
+    Ui::MainWindow *ui;
+
+    QLabel * mpLabelInfo;
+    QLabel * mpLabelTip;
+
+private:
+    void updatevalue();
+
+private:
+    bool mbleft  = false;
+    bool mbright = false;
+    double mfwheel = 0.0;
+    double mftorque = 0.0;
+    double mfbrake = 0.0;
+};
+#endif // MAINWINDOW_H

+ 160 - 0
src/tool/tool_chassis_check/mainwindow.ui

@@ -0,0 +1,160 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MainWindow</class>
+ <widget class="QMainWindow" name="MainWindow">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>445</width>
+    <height>338</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>MainWindow</string>
+  </property>
+  <widget class="QWidget" name="centralwidget">
+   <widget class="QLabel" name="label_1">
+    <property name="geometry">
+     <rect>
+      <x>100</x>
+      <y>80</y>
+      <width>80</width>
+      <height>41</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>灯光控制</string>
+    </property>
+   </widget>
+   <widget class="QLabel" name="label_2">
+    <property name="geometry">
+     <rect>
+      <x>100</x>
+      <y>130</y>
+      <width>80</width>
+      <height>41</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>转向控制</string>
+    </property>
+   </widget>
+   <widget class="QLabel" name="label_3">
+    <property name="geometry">
+     <rect>
+      <x>100</x>
+      <y>180</y>
+      <width>80</width>
+      <height>41</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>驱动控制</string>
+    </property>
+   </widget>
+   <widget class="QLabel" name="label_4">
+    <property name="geometry">
+     <rect>
+      <x>100</x>
+      <y>230</y>
+      <width>80</width>
+      <height>41</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>制动控制</string>
+    </property>
+   </widget>
+   <widget class="QLabel" name="label_5">
+    <property name="geometry">
+     <rect>
+      <x>133</x>
+      <y>20</y>
+      <width>210</width>
+      <height>61</height>
+     </rect>
+    </property>
+    <property name="font">
+     <font>
+      <pointsize>16</pointsize>
+      <weight>75</weight>
+      <bold>true</bold>
+     </font>
+    </property>
+    <property name="text">
+     <string>线控底盘检测项目</string>
+    </property>
+   </widget>
+   <widget class="QCheckBox" name="checkBox_left">
+    <property name="geometry">
+     <rect>
+      <x>210</x>
+      <y>80</y>
+      <width>51</width>
+      <height>41</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>左</string>
+    </property>
+   </widget>
+   <widget class="QCheckBox" name="checkBox_right">
+    <property name="geometry">
+     <rect>
+      <x>280</x>
+      <y>80</y>
+      <width>51</width>
+      <height>41</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>右</string>
+    </property>
+   </widget>
+   <widget class="QLineEdit" name="lineEdit_wheel">
+    <property name="geometry">
+     <rect>
+      <x>210</x>
+      <y>130</y>
+      <width>121</width>
+      <height>41</height>
+     </rect>
+    </property>
+   </widget>
+   <widget class="QLineEdit" name="lineEdit_drive">
+    <property name="geometry">
+     <rect>
+      <x>210</x>
+      <y>180</y>
+      <width>121</width>
+      <height>41</height>
+     </rect>
+    </property>
+   </widget>
+   <widget class="QLineEdit" name="lineEdit_brake">
+    <property name="geometry">
+     <rect>
+      <x>210</x>
+      <y>230</y>
+      <width>121</width>
+      <height>41</height>
+     </rect>
+    </property>
+   </widget>
+  </widget>
+  <widget class="QMenuBar" name="menubar">
+   <property name="geometry">
+    <rect>
+     <x>0</x>
+     <y>0</y>
+     <width>445</width>
+     <height>28</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QStatusBar" name="statusbar"/>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>

+ 31 - 0
src/tool/tool_chassis_check/tool_chassis_check.pro

@@ -0,0 +1,31 @@
+QT       += core gui
+
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
+
+CONFIG += c++11
+
+# The following define makes your compiler emit warnings if you use
+# any Qt feature that has been marked deprecated (the exact warnings
+# depend on your compiler). Please consult the documentation of the
+# deprecated API in order to know how to port your code away from it.
+DEFINES += QT_DEPRECATED_WARNINGS
+
+# You can also make your code fail to compile if it uses deprecated APIs.
+# In order to do so, uncomment the following line.
+# You can also select to disable deprecated APIs only up to a certain version of Qt.
+#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
+
+SOURCES += \
+    main.cpp \
+    mainwindow.cpp
+
+HEADERS += \
+    mainwindow.h
+
+FORMS += \
+    mainwindow.ui
+
+# Default rules for deployment.
+qnx: target.path = /tmp/$${TARGET}/bin
+else: unix:!android: target.path = /opt/$${TARGET}/bin
+!isEmpty(target.path): INSTALLS += target