155 lines
4.5 KiB
C
155 lines
4.5 KiB
C
|
|
#ifndef MainWindow_H
|
|||
|
|
#define MainWindow_H
|
|||
|
|
|
|||
|
|
#include <QWidget>
|
|||
|
|
#include <QtSerialPort/QSerialPortInfo>
|
|||
|
|
#include <QtSerialPort/QSerialPort>
|
|||
|
|
#include <QDebug>
|
|||
|
|
#include <QString>
|
|||
|
|
#include <stdio.h>
|
|||
|
|
#include <string.h>
|
|||
|
|
#include <WinSock2.h>
|
|||
|
|
#include <windows.h>
|
|||
|
|
#include <stdlib.h>
|
|||
|
|
#include <string>
|
|||
|
|
#include <vector>
|
|||
|
|
#include <chrono>
|
|||
|
|
#include <iostream>
|
|||
|
|
#include <iomanip>
|
|||
|
|
#include <cstring>
|
|||
|
|
#include <QWaitCondition>
|
|||
|
|
#include <ctime>
|
|||
|
|
#include <codecvt>
|
|||
|
|
#include <Iphlpapi.h>
|
|||
|
|
#include <cstdlib>
|
|||
|
|
#include <QObject>
|
|||
|
|
#include <QTcpsocket>
|
|||
|
|
#include <direct.h>
|
|||
|
|
#include <algorithm>
|
|||
|
|
#include <QDateTime>
|
|||
|
|
#include "httplib.h"
|
|||
|
|
#include "json.h"
|
|||
|
|
#include <QInputDialog>
|
|||
|
|
#include <QSystemTrayIcon>
|
|||
|
|
#include <QCloseEvent>
|
|||
|
|
#include <QAction>
|
|||
|
|
#include <QCloseEvent>
|
|||
|
|
#include <qmenu.h>
|
|||
|
|
#include <QFile>
|
|||
|
|
#include <QDir>
|
|||
|
|
#include <thread>
|
|||
|
|
#include <QMessageBox>
|
|||
|
|
#include <QTimer>
|
|||
|
|
#include <queue>
|
|||
|
|
#include <mutex>
|
|||
|
|
#include <thread>
|
|||
|
|
#include <chrono>
|
|||
|
|
#include "common.h"
|
|||
|
|
|
|||
|
|
QT_BEGIN_NAMESPACE
|
|||
|
|
namespace Ui { class MainWindow; }
|
|||
|
|
QT_END_NAMESPACE
|
|||
|
|
|
|||
|
|
class MainWindow : public QWidget
|
|||
|
|
{
|
|||
|
|
Q_OBJECT
|
|||
|
|
|
|||
|
|
public:
|
|||
|
|
MainWindow(QWidget *parent = nullptr);
|
|||
|
|
~MainWindow();
|
|||
|
|
|
|||
|
|
void set_uart_parameter();
|
|||
|
|
int debug_log_printf(std::string daystime);
|
|||
|
|
void get_system_time();
|
|||
|
|
void print_log(std::string logstr);
|
|||
|
|
bool deal_uart_data(std::string &szcarModel,std::string &szcarNumber);
|
|||
|
|
bool label_compare(std::string &label);
|
|||
|
|
int http_send(std::string &carriageType, std::string &carriageNumber, std::string &carriageOrder, std::string &time);
|
|||
|
|
void obtain_accredit();
|
|||
|
|
void read_configure_file();
|
|||
|
|
void write_configure_file();
|
|||
|
|
void creat_menu();
|
|||
|
|
void creat_action();
|
|||
|
|
int compare_string(const std::string &recv_str);
|
|||
|
|
bool Judge_direction();
|
|||
|
|
// bool Data_time(int icon);
|
|||
|
|
void add_order(int count);
|
|||
|
|
void serial_timerstart();
|
|||
|
|
typedef struct _CONFIGURE_INFO_{
|
|||
|
|
std::string uartName; //串口名
|
|||
|
|
std::string uartBaud; //波特率
|
|||
|
|
std::string ip; //web IP
|
|||
|
|
std::string port; //web 端口号
|
|||
|
|
std::string urlPath; //web URL
|
|||
|
|
std::string stationTrack; //股道号
|
|||
|
|
std::string configDirection; //配置的磁钢方向
|
|||
|
|
|
|||
|
|
}CONFIGURE_INFO_;
|
|||
|
|
|
|||
|
|
private:
|
|||
|
|
CONFIGURE_INFO_ configureInfo_T;
|
|||
|
|
std::string szcurrentTime; //当前时间
|
|||
|
|
std::string szlastTime; //上一次时间
|
|||
|
|
std::string zhcarNumber = "";
|
|||
|
|
|
|||
|
|
bool btrainLeave; //火车离开标志 当前火车已经离开:true 没有离开:false
|
|||
|
|
std::vector <std::string> m_veclabel; //倒车防重扫
|
|||
|
|
bool baccredit; //是否获取授权
|
|||
|
|
std::string accreditInformation; //授权信息
|
|||
|
|
// std::string m_recvData; //接收到的数据
|
|||
|
|
//std::string f_time; //第一个磁钢时间
|
|||
|
|
// std::string t_tine; //第二个磁钢时间
|
|||
|
|
std::string m_direction; //磁钢号存储
|
|||
|
|
bool m_sendHttpSign; //发送给http标志
|
|||
|
|
int m_icarriageOrder; //车节号
|
|||
|
|
int m_icot;
|
|||
|
|
bool m_flag = false; //是否丢车节
|
|||
|
|
int m_icot2=0; //丢车节计数防止丢两节
|
|||
|
|
int itime = 0;
|
|||
|
|
bool bdir = true; //和配置方向是否相同
|
|||
|
|
int m_lastCarriagrOrder = 0;
|
|||
|
|
int lc_carnum; //漏车的车节号
|
|||
|
|
|
|||
|
|
QByteArray buffer; //串口接收数据缓存区
|
|||
|
|
QTimer* timer;
|
|||
|
|
bool judget = false;
|
|||
|
|
std::string c_carnum;
|
|||
|
|
std::string szHavdcarTime;
|
|||
|
|
std::vector<std::string> vec_configureDir;
|
|||
|
|
private:
|
|||
|
|
void changeEvent(QEvent *event);
|
|||
|
|
void on_ShowMainAction();
|
|||
|
|
void on_ExitAppAction();
|
|||
|
|
void closeEvent(QCloseEvent *event);
|
|||
|
|
void get_queue_data();
|
|||
|
|
void deal_str_data(const std::string &szStr);
|
|||
|
|
|
|||
|
|
QMenu* m_pTrayMennu; //系统托盘右键菜单项
|
|||
|
|
QSystemTrayIcon* m_pSystemTray; //系统托盘图标
|
|||
|
|
QFile logOut;
|
|||
|
|
QFile logrecv;
|
|||
|
|
QFile logtest;
|
|||
|
|
std::ofstream ofswrite;
|
|||
|
|
|
|||
|
|
//右键菜单栏选项
|
|||
|
|
QAction* m_pActionShow;
|
|||
|
|
QAction* m_pActionQuit;
|
|||
|
|
|
|||
|
|
QSerialPort *serial; //串口
|
|||
|
|
/****************************xl*****************************/
|
|||
|
|
std::queue<std::string> queData;
|
|||
|
|
std::thread tid;
|
|||
|
|
std::mutex mtx_sync_;
|
|||
|
|
private slots:
|
|||
|
|
void rece_data_slots();
|
|||
|
|
void on_activatedSysTrayIcon(QSystemTrayIcon::ActivationReason reason);
|
|||
|
|
|
|||
|
|
private:
|
|||
|
|
Ui::MainWindow *ui;
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
#endif // MainWindow_H
|