2,新增“Apps”; 3,新增“Common”; 4,新增“FileList”; 5,新增“MediaX”; 6,新增“OpenSource”; 7,新增“Samples”; 8,新增“SoftwareBusinessLines”.
162 lines
4.2 KiB
C++
162 lines
4.2 KiB
C++
#ifndef MAINWINDOW_H
|
|
#define MAINWINDOW_H
|
|
|
|
#include <QMainWindow>
|
|
#include <QComboBox>
|
|
#include <QTimer>
|
|
#include <QFile>
|
|
|
|
#include <QStandardItemModel>
|
|
|
|
#include <mutex>
|
|
#include <thread>
|
|
using namespace std;
|
|
|
|
#include "./../../../Common/CommDef.h"
|
|
#include "./../../../Common/GCycleQueue.h"
|
|
|
|
#include "./GuiInvoker.h"
|
|
|
|
#include "UpgradeCode/CanUpgrade_CM1K10A.h"
|
|
#include "UpgradeCode/CanUpgrade_CM1K12G.h"
|
|
#include "UpgradeCode/CanUpgrade_CM1K12G_Private.h"
|
|
|
|
namespace Ui
|
|
{
|
|
class MainWindow;
|
|
}
|
|
|
|
enum eMainWindow_DispatchMsg
|
|
{
|
|
eMainWindow_DispatchMsg_RefreshUpgradeProgress = 1,
|
|
eMainWindow_DispatchMsg_UploadFinished = 2
|
|
};
|
|
|
|
enum eUpgradeStatus
|
|
{
|
|
eUpgradeStatus_Ready = 1,
|
|
eUpgradeStatus_Uploading = 2,
|
|
eUpgradeStatus_UploadFinished = 3,
|
|
eUpgradeStatus_Preparing = 4,
|
|
eUpgradeStatus_Writing = 5,
|
|
eUpgradeStatus_Writen_Succeed = 6,
|
|
eUpgradeStatus_Writen_Failed = 7
|
|
};
|
|
|
|
enum eDeviceType
|
|
{
|
|
eDeviceType_CM1K10A = 1,
|
|
eDeviceType_CM1K12G = 2,
|
|
eDeviceType_CM1K12G_Private = 3,
|
|
|
|
eDeviceType_NULL = 0,
|
|
};
|
|
|
|
class MainWindow : public QMainWindow
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit MainWindow(QWidget* parent = 0);
|
|
~MainWindow();
|
|
|
|
bool SendData_CAN(const QString& strFrameID_HexStr, const QString& strFrameData_HexStr, bool bAddMsg = false);
|
|
bool SendData_CAN(int nFrameID_Hex, const byte* pFrameData, int nFrameDataLen, bool bAddMsg);
|
|
|
|
bool GetUpgradeData(byte** pUpgradeData, int& nUpgradeDataSize);
|
|
|
|
static void OnCallBack_DispatchMsg(eMainWindow_DispatchMsg eDispatchMsg, void* pParams, void* pOwner);
|
|
|
|
private:
|
|
void Connect();
|
|
void Disconnect();
|
|
|
|
bool ConnectCAN(int nDeviceIndex);
|
|
bool SendData_CAN();
|
|
|
|
void AddMsg(const QString& strMsg, bool bAddMsg);
|
|
bool BrowseFile();
|
|
bool UpgradeFile();
|
|
void WriteIn();
|
|
|
|
bool RecordRecvData(CAN_OBJ varFrameInfo);
|
|
|
|
void DispatchMsg(eMainWindow_DispatchMsg eDispatchMsg, void* pParams);
|
|
|
|
int strtodata(unsigned char* str, unsigned char* data, int len, int flag);
|
|
int chartoint(unsigned char chr, unsigned char* cint);
|
|
|
|
protected:
|
|
bool eventFilter(QObject* obj, QEvent* event);
|
|
|
|
private slots:
|
|
void OnButtonClicked();
|
|
void OnChecked(bool bChecked);
|
|
void OnComboxIndexChanged(int nIndex);
|
|
void OnTimer();
|
|
|
|
private:
|
|
void InitStyle();
|
|
|
|
private:
|
|
typedef void (MainWindow::*ThreadRunFunPtr)();
|
|
static void ThreadEntry(ThreadRunFunPtr pRunFun, void* pOwner);
|
|
|
|
void ThreadFun_ReceiveData_CAN();
|
|
|
|
bool StartThread_ReceiveData_CAN();
|
|
void StopThread_ReceiveData_CAN();
|
|
|
|
private:
|
|
Ui::MainWindow* ui;
|
|
|
|
QPoint m_ptMouse;
|
|
bool m_bMousePressed;
|
|
|
|
QTimer m_varTimer_RefreshUI;
|
|
QTimer m_varTimer_RefreshMsgList;
|
|
QTimer m_varTimer_RefreshUpgradeStatus;
|
|
GCycleQueue m_varCaptureData; // 设备采集数据
|
|
|
|
//
|
|
bool m_bThreadRunning_ReceiveData_CAN;
|
|
std::thread* m_ptrThread_ReceiveData_CAN;
|
|
|
|
// CAN
|
|
bool m_bConnectCAN;
|
|
int m_nCAN_DevType;
|
|
int m_nCAN_DeviceIndex;
|
|
|
|
eDeviceType m_eDeviceType;
|
|
|
|
QStringList m_strMsgList;
|
|
std::mutex m_mutexMsgList;
|
|
|
|
std::shared_ptr<QStandardItemModel> m_ptrDataModel_Msg;
|
|
std::shared_ptr<CanUpgrade_CM1K10A> m_ptrCanUpgrade_CM1K10A;
|
|
std::shared_ptr<CanUpgrade_CM1K12G> m_ptrCanUpgrade_CM1K12G;
|
|
std::shared_ptr<CanUpgrade_CM1K12G_Private> m_ptrCanUpgrade_CM1K12G_Private;
|
|
|
|
std::shared_ptr<byte> m_ptrUpgradeData;
|
|
int m_nUpgradeDataSize;
|
|
bool m_bReady_Upgrade;
|
|
|
|
bool m_bUploading;
|
|
bool m_bWritingIn;
|
|
bool m_bUpgradeProgress;
|
|
double m_dUpgradeProgress;
|
|
|
|
bool m_bRefreshUpgradeStatus;
|
|
eUpgradeStatus m_eUpgradeStatus;
|
|
int m_nUpgradeStatus_Counter;
|
|
|
|
bool m_bUploadFinished;
|
|
|
|
QFile m_varFileRecorder;
|
|
bool m_bRecord;
|
|
UINT m_nLastRecvTimeStamp;
|
|
UINT m_nRecordCount;
|
|
};
|
|
|
|
#endif // MAINWINDOW_H
|