274 lines
11 KiB
C
274 lines
11 KiB
C
|
#ifndef MAINWIDGETFUNCTION_H
|
|||
|
#define MAINWIDGETFUNCTION_H
|
|||
|
|
|||
|
#include <QObject>
|
|||
|
#include <QWidget>
|
|||
|
#include <QApplication>
|
|||
|
#include <stdio.h>
|
|||
|
#include <QDateTime>
|
|||
|
#include <QProcess>
|
|||
|
#include "main.h"
|
|||
|
#include "machine/error.h"
|
|||
|
#include "sharedviews/promptdialog.h"
|
|||
|
#include "sharedviews/passworddialog.h"
|
|||
|
#include "sharedviews/systemmanagedialog.h"
|
|||
|
#include "sharedviews/brokenlinedialog.h"
|
|||
|
#include "datafile/datafiledst.h"
|
|||
|
#include "datafile/datafiledsr.h"
|
|||
|
#include "settings/lotsettings.h"
|
|||
|
#include "items/errorcodestateitem.h"
|
|||
|
#include "Lot/csvcode.h"
|
|||
|
#include "items/paraitem.h"
|
|||
|
|
|||
|
#ifdef Q_OS_WIN
|
|||
|
#include <windows.h>
|
|||
|
#endif
|
|||
|
|
|||
|
//是否打开物联功能
|
|||
|
#define IFOPENGATEWAY 1
|
|||
|
|
|||
|
#define DATA_DS8 1
|
|||
|
#define DATA_DS16 2
|
|||
|
#define DATA_FORMATE DATA_DS16
|
|||
|
|
|||
|
#define COLUMN_CODE 0 //信息代码(第一列)
|
|||
|
#define COLUMN_INFO 1 //映射信息(第二列)
|
|||
|
#define COLUMN_SCORE 2 //分值(第三列)
|
|||
|
#define COLUMN_PRESSNUM 3 //是否被点击过(第四列)
|
|||
|
|
|||
|
#define WIFIINIPATH "/etc/iot_cfg/mcgs_box_conf.ini"
|
|||
|
|
|||
|
//机头断线次数结构体
|
|||
|
struct HeadBreakLine
|
|||
|
{
|
|||
|
//32个机头,每个机头的断线次数
|
|||
|
s32 headBreakLineNum[32];
|
|||
|
|
|||
|
//xcy 0314 机头针位断线
|
|||
|
s32 headNeedleBreakLine[32][15];
|
|||
|
};
|
|||
|
|
|||
|
struct HMIFileHead
|
|||
|
{
|
|||
|
int fileNum;
|
|||
|
};
|
|||
|
|
|||
|
struct HMIItemFileHead
|
|||
|
{
|
|||
|
char filePath[64];
|
|||
|
char fileName[64];
|
|||
|
int dataCheck;
|
|||
|
int fileSize;
|
|||
|
};
|
|||
|
|
|||
|
class MainWidgetFunction : public QObject
|
|||
|
{
|
|||
|
Q_OBJECT
|
|||
|
public:
|
|||
|
explicit MainWidgetFunction(QObject *parent = 0);
|
|||
|
~MainWidgetFunction();
|
|||
|
|
|||
|
private:
|
|||
|
PromptDialog *m_pPromptDlg;
|
|||
|
SystemManageDialog *m_pSystemManageDlg;
|
|||
|
BrokenLineDialog *m_pBrokenLineDialog;
|
|||
|
MCStatus m_mcStatus;
|
|||
|
HeadBreakLine m_headBreakLine;
|
|||
|
int m_curFileID;
|
|||
|
int m_beginX;
|
|||
|
int m_beginY;
|
|||
|
QString m_filePath;
|
|||
|
QString m_fileName;
|
|||
|
McLotData m_mcLotData;//下位机物联数据
|
|||
|
HMILotData m_HMILotData;//上位机物联数据
|
|||
|
int m_sensorBitmapNum;//传感器位图个数
|
|||
|
QList<ErrorCodeStateItem> m_errorCodeAndStateItemList;//错误代码和状态列表
|
|||
|
QTimer * m_pTipsTimer; //4小时定时器提示用户使用时长不足5天
|
|||
|
//QTimer timer; //测试物联网用
|
|||
|
QTimer *m_pLotTimer; //物联网定时器
|
|||
|
int m_getScore;//安装进度调试得分
|
|||
|
int m_totalScore;//总分值
|
|||
|
|
|||
|
QStringList m_csvFileStrList;
|
|||
|
|
|||
|
private:
|
|||
|
void initialize();//初始化
|
|||
|
void initializeLotInfo();//初始化物联网所需要的机器信息
|
|||
|
void initializeLotData();//初始化物联网数据
|
|||
|
void systemUpgrade(int type, u8 protocol = 0, u8 nodeid = 0, u8 nodeType = 0);
|
|||
|
s16 refreshWifiList(QStringList &wifiStrList,s16 scan = 0);//刷新wifi列表
|
|||
|
QString getIpSegment(bool bl);//获取已连接wifi分配的IP
|
|||
|
void sendDs16PatternData(int type = FILE_TYPE_DAT);//发送ds16花样数据
|
|||
|
void convertDs16ToDs8AndSend(QString filePath,int type = FILE_TYPE_DAT);//将ds16数据转换为ds8数据并发送
|
|||
|
void addProductStatisInfo(int patternBreakLineNum);//添加生产统计信息
|
|||
|
|
|||
|
void addJournalInfoError();//添加错误日志信息
|
|||
|
void addJournalInfoBreakage();//添加断线日志信息
|
|||
|
|
|||
|
QString getCompileDateTime();
|
|||
|
QString compositionJson(QString key,QString value);//组成json键值对
|
|||
|
HMILotData getHMILotData();//获取界面物联数据
|
|||
|
void sendDataToGateway(s16 code,s16 type = 0);//发送数据到物联网
|
|||
|
|
|||
|
public:
|
|||
|
void setErrorCodeAndStateList(QList<ErrorCodeStateItem> list);//设置错误代码和状态的列表
|
|||
|
void setShutDownTime();//上电计算关机时间并发送给主控
|
|||
|
void setMcStates(MCStatus mcStatus);//设置机器状态
|
|||
|
QString getVersionStr();
|
|||
|
QString detectUsb();//优盘检测
|
|||
|
s16 detectWifiConnect();
|
|||
|
void writePonitToFile(QString filePath,int x,int y,int flag = 0);//将起始点或定位点写回到文件中
|
|||
|
void funImportParameter(QString tStyle);//参数导入
|
|||
|
void funImportWkParameter(QString tStyle);//工作参数导入
|
|||
|
void funExportParameter();//参数导出
|
|||
|
void funExportFrameParameter();//动框参数导出
|
|||
|
void funMCUpgrade(QString tStyle);//主控升级
|
|||
|
void funHMIUpgrade(QString tStyle);//界面升级
|
|||
|
void funWIFI(QString tStyle);//WIFI管理
|
|||
|
void funAllToZero();//全部归零
|
|||
|
void funSpindleJog();//主轴点动
|
|||
|
void funPunchMsSeverOn();//冲孔主轴使能
|
|||
|
void funPunchMsSeverOff();//冲孔主轴失能
|
|||
|
void funPunchMsRun();//冲孔主轴研车
|
|||
|
void funSewMsRun();//缝纫主轴研车
|
|||
|
void funEmbMsRun();//平绣主轴研车
|
|||
|
void funPunchSpindleJog();//冲孔主轴点动
|
|||
|
void funSewSpindleJog();//缝纫主轴点动
|
|||
|
void funEmbSpindleJog();//平绣主轴点动
|
|||
|
void funToHookPosition();//缝纫主轴去勾线位
|
|||
|
void funEmbToHookPosition();//平绣主轴去勾线位
|
|||
|
void funRotateProofread();//缝纫旋转校对
|
|||
|
void funSewheadUpDown();//缝纫机头升降
|
|||
|
void switchMachineHead(int nNum);//切换机头
|
|||
|
void funNeedleContrast(int step);//针梭校对
|
|||
|
void funBackShuttlePos();//回换梭位
|
|||
|
void funSewRotate(int flag); //缝纫旋转+-
|
|||
|
void funBackWorkPoint();//回工作点
|
|||
|
void funBackAnchorPoint();//回定位点
|
|||
|
void funBackThreadPoint();//回穿线点
|
|||
|
void funBackToOrigin();//回原点
|
|||
|
void funBackCenterPoint();//回中心点
|
|||
|
void funFirstHeadSetStartPoint(QString filePath);//主机头设置起始点(冲缝机时主机头为缝纫机头)
|
|||
|
void funFirstHeadSetAnchorPoint(QString filePath);//主机头设置定位点(冲缝机时主机头为缝纫机头)
|
|||
|
void funSecHeadSetStartPoint(QString filePath);//次机头设置起始点(冲缝机时次机头为冲孔机头)
|
|||
|
void funSecHeadSetAnchorPoint(QString filePath);//次机头设置定位点(冲缝机时次机头为冲孔机头)
|
|||
|
void funThrHeadSetStartPoint(QString filePath);//三机头设置起始点(冲绣缝时三机头为平绣机头)
|
|||
|
void funThrHeadSetAnchorPoint(QString filePath);//三机头设置定位点(冲绣缝时三机头为平绣机头)
|
|||
|
void funResetStartPoint(QString filePath,DataFilePos pos);//边框检查超限后重新自动设置起始点
|
|||
|
void funSetStartPoint(QString filePath, s32 x, s32 y);//参数设置起始点
|
|||
|
void funSetAnchorPoint(QString filePath, s32 x, s32 y);//参数设置定位点
|
|||
|
void funBackStartPoint();//回起始点
|
|||
|
void funBorderCheck();//边框检查
|
|||
|
void funSewHeadCutLine(int nNum);//缝纫机头剪线
|
|||
|
void funEmbHeadCutLine();//平绣机头剪线
|
|||
|
void funManualTrimUp();//手动剪线-剪上线
|
|||
|
void funManualTrimDn();//手动剪线-剪下线
|
|||
|
void funCutterOpenAndClose();//剪刀开合
|
|||
|
void funPunchRodZero();//冲孔换杆归零
|
|||
|
void funPunchManualChangeColor();//手动换色
|
|||
|
void funEmbManualChangeColor();//绣花手动换色
|
|||
|
void funSinglePunch();//单次冲孔
|
|||
|
void funWorkPause();//工作暂停
|
|||
|
void funSimulateFrame();//空走边框
|
|||
|
void funProcessReset();//流程复位
|
|||
|
void funSetOffsetPoint();//设置偏移点
|
|||
|
void funBackOffsetPoint();//回偏移点
|
|||
|
void funPunchRotToZero();//冲孔旋转去零位
|
|||
|
void funGotoZeroPos();//框架归零
|
|||
|
void funGotoGorner(int nNum);//回角点 1、右上,2、右下,3、左上,4、左下
|
|||
|
void funSetWorkRange();//定工作范围
|
|||
|
void funTestADC();//测试电位器值
|
|||
|
void funPunchMsDown();//冲头停下位
|
|||
|
void funDrawOutline();//画轮廓线
|
|||
|
void funAutoSetStartPoint(QString filePath);//自动设置起始点-只有垫板冲孔机(自动定位冲孔机)有这个功能
|
|||
|
void funContinuousOilSupply();//连续供油
|
|||
|
void funManualOil(int nNum);//手动加油
|
|||
|
void sendPatternHead(QString filePath);//发送花样文件头
|
|||
|
void sendPatternData(QString filePath,int type = FILE_TYPE_DAT);//发送花样数据
|
|||
|
void funFaceDetect();//面线检测
|
|||
|
void funExitRoot();//退出登录
|
|||
|
void funGetMCVersionInfo();//获取主控主板版本信息
|
|||
|
void funProductStatistics(QString tStyle,QString filePath,int patternBreakLineNum);//生产统计
|
|||
|
void funJournalError(QString tStyle);//错误日志
|
|||
|
void funSoftwareAuthor();//软件授权
|
|||
|
void funShutDown();//win下关闭计算机
|
|||
|
int funErrorPrompt(u32 errcode,QString info);//错误信息提示
|
|||
|
void funSetPromptDlgVisibleFalse();//错误信息提示窗体隐藏
|
|||
|
void funBottomLineCountReset();//底线计数复位
|
|||
|
void funBottomCountClear();//计数清零(罗莱)
|
|||
|
void funResetAll();//整机全部复位
|
|||
|
void funMotorZeroing();//电机归零
|
|||
|
void funStationGluing(int idx);//工位涂胶
|
|||
|
void funHeadUpDown(); //机头升降
|
|||
|
void funToStationApos(int idx);//回工位起始点
|
|||
|
void funToWaittingPos();//回等料点
|
|||
|
void funToRemoveGluePos();//回排胶点
|
|||
|
void funRemoveGlueOnce();//排一次胶
|
|||
|
void funAdjustGlueHeight();//校准胶管高度
|
|||
|
|
|||
|
void funManualOrAutoSwitch(s16 val = 0);//手自动工作状态切换 0:手动 1:自动
|
|||
|
void getPatternHeadConfig(QString path,DataFileHead & head);
|
|||
|
void setPatternHeadConfig(QString path,DataFileHead head);
|
|||
|
void deleteDir(QString path);//删除文件夹
|
|||
|
|
|||
|
public:
|
|||
|
inline int getBeginX(){return m_beginX;}
|
|||
|
inline int getBeginY(){return m_beginY;}
|
|||
|
|
|||
|
private slots:
|
|||
|
void slotMCInfoChange();//机器信息改变
|
|||
|
void slotSendLotData();//发送物联数据
|
|||
|
void slotRunLotDataAction(QString str);//执行网关数据动作
|
|||
|
//void slotSendJsonToMqtt();//当界面与网关建立连接时需要向网关发送固定的键值对
|
|||
|
void slotTransProgress(u8 fileType, int send, int total); // 发送文件进度条
|
|||
|
void slotClearProductStatis();//清空产量统计
|
|||
|
void slotCsvExport(int logType);//导出csv文件
|
|||
|
void slotClearJournal();//清空文件日志
|
|||
|
void slotRefreshWifiList();//刷新wifi列表
|
|||
|
void onTipsTimer();//4小时定时器
|
|||
|
void slotSetDynamicIP(QString ssid);//设置动态IP
|
|||
|
void slotSetStaticIP(QString ssid,QString psd,QString dnip);//设置静态IP
|
|||
|
void slotDebugMode();//界面调试模式
|
|||
|
void slotParaReadPrompt(s16 type,s16 value);
|
|||
|
|
|||
|
signals:
|
|||
|
void siSetButtonUserLogo(int level);
|
|||
|
void siClearPatternBreakLineNum();
|
|||
|
void siDebugState();
|
|||
|
void siCloseRootPara();
|
|||
|
void siClearPattern();
|
|||
|
void siClearPatternFcg();
|
|||
|
//void siReceiveLotDat(); //测试物联网用
|
|||
|
|
|||
|
void siAfterDeleteFileid();//xcy 0314 删掉影响fileid的数据后
|
|||
|
void siWifiState(bool bl);//wifi连接状态
|
|||
|
|
|||
|
public slots:
|
|||
|
void slotUserLogin(s16 user);//用户登录
|
|||
|
void slotHMIDecrypt(QString id);//界面解密
|
|||
|
void slotStrokeCorrection();//行程矫正
|
|||
|
void slotAutoSetSoftLimit();//自动定软限位
|
|||
|
void slotFrameParaImport();//动框参数导入
|
|||
|
void slotFrameParaExport();//动框参数导出
|
|||
|
void slotExitApp();//超级用户退出程序
|
|||
|
void slotVerRecovery();//超级用户下版本恢复
|
|||
|
void slotDeleteIni();//删除执行目录下的config.ini
|
|||
|
void slotImportCSV();//导入csv文件
|
|||
|
void slotDeleteCSV();//删除csv文件
|
|||
|
void slotResetCSV();//重置安装调试进度
|
|||
|
void slotPatternClear();//超级用户下花样总清
|
|||
|
void slotPatternFcgClear();//超级用户花样fcg文件删除
|
|||
|
void slotPatternFcgClearFileid();//清除影响fileid的数据
|
|||
|
void slotCalMachineProgress(s16 csvCode,s16 type = 0);//计算安装调试进度
|
|||
|
void slotJournalError();//错误日志
|
|||
|
void slotJournalBreakage();//断线日志
|
|||
|
void slotSpindleTest();
|
|||
|
//以下为测试记录断线次数精准到针位
|
|||
|
//void testBreakLineNeedle();
|
|||
|
public:
|
|||
|
//QTimer *m_testNeedle;
|
|||
|
|
|||
|
};
|
|||
|
|
|||
|
#endif // MAINWIDGETFUNCTION_H
|