323 lines
13 KiB
C
323 lines
13 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 "sharedviews/debuginfodialog.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 IFDYSENDMODE 0
|
|||
|
|
|||
|
#define DATA_DS8 1
|
|||
|
#define DATA_DS16 0
|
|||
|
#define DATA_FORMATE DATA_DS16
|
|||
|
|
|||
|
#define COLUMN_CODE 0 //信息代码(第一列)
|
|||
|
#define COLUMN_INFO 1 //映射信息(第二列)
|
|||
|
#define COLUMN_SCORE 2 //分值(第三列)
|
|||
|
#define COLUMN_PRESSNUM 3 //是否被点击过(第四列)
|
|||
|
|
|||
|
#define HEADNUM 160 //160个机头为了适用于绗绣机
|
|||
|
#define NEEDLENUM 15
|
|||
|
|
|||
|
#define WIFIINIPATH "/etc/iot_cfg/mcgs_box_conf.ini"
|
|||
|
|
|||
|
//机头断线次数结构体
|
|||
|
struct EmbHeadBreakLine
|
|||
|
{
|
|||
|
s32 headNeedleBreakNum[HEADNUM][NEEDLENUM];//机头针位断线次数
|
|||
|
};
|
|||
|
|
|||
|
struct CoilHeadBreakLine
|
|||
|
{
|
|||
|
s32 headNeedleBreakNum[HEADNUM][NEEDLENUM];//机头针位断线次数
|
|||
|
};
|
|||
|
|
|||
|
struct ChenHeadBreakLine
|
|||
|
{
|
|||
|
s32 headNeedleBreakNum[HEADNUM][NEEDLENUM];//机头针位断线次数
|
|||
|
};
|
|||
|
|
|||
|
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;
|
|||
|
DebugInfoDialog *m_pDebugInfoDlg;
|
|||
|
MCStatus m_mcStatus;
|
|||
|
EmbHeadBreakLine m_embHeadBreakLine;
|
|||
|
CoilHeadBreakLine m_coilHeadBreakLine;
|
|||
|
ChenHeadBreakLine m_chenHeadBreakLine;
|
|||
|
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 *m_pLotTimer; //物联网定时器
|
|||
|
int m_noseHead;
|
|||
|
u32 m_potValue;//电位器值
|
|||
|
u32 m_gearValue;//当前档位值
|
|||
|
u32 m_workNoseHead;//当前工作机头
|
|||
|
int m_adcFlag;//是否进入电位器测试的标志
|
|||
|
int m_getScore;//安装进度调试得分
|
|||
|
int m_totalScore;//总分值
|
|||
|
int m_camColorChange;//凸轮换色
|
|||
|
QStringList m_csvFileStrList;
|
|||
|
|
|||
|
private:
|
|||
|
void initialize();//初始化
|
|||
|
void initializeLotInfo();//初始化物联网所需要的机器信息
|
|||
|
void initializeLotData();//初始化物联网数据
|
|||
|
void systemUpgrade(int type, int paraType = 0, u8 protocol = 0, u8 nodeid = 0, u8 nodeType = 0);
|
|||
|
s16 refreshWifiList(QStringList &wifiStrList,s16 scan = 0);//刷新wifi列表
|
|||
|
QString getIpSegment(bool bl);//获取已连接wifi分配的IP
|
|||
|
void writePonitToFile(QString filePath,u8 type, int x, int y, int st = 0 ,u8 workHead = 1);//将起绣点写回到文件中(以及工作机头)
|
|||
|
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();//添加断线日志信息
|
|||
|
void addJournalInfoDebug();//添加调试信息
|
|||
|
|
|||
|
QString getCompileDateTime();
|
|||
|
QString compositionJson(QString key,QString value);//组成json键值对
|
|||
|
HMILotData getHMILotData();//获取界面物联数据
|
|||
|
void writeBreakageInfoToFile();//将断线信息重新写回文件
|
|||
|
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 funImportParameter(QString tStyle);//参数导入
|
|||
|
void funImportWkParameter(QString tStyle);//工作参数导入
|
|||
|
void funExportParameter(int type = 0);//参数导出
|
|||
|
void funExportFrameParameter();//动框参数导出
|
|||
|
void funMCUpgrade(QString tStyle);//主控升级
|
|||
|
void funHMIUpgrade(QString tStyle);//界面升级
|
|||
|
void funEXBUpgrade(QString tStyle,u8 protocol,u8 nodeid ,u8 nodeType);//外围板升级
|
|||
|
void funWIFI(QString tStyle);//WIFI管理
|
|||
|
void funAllToZero();//全部归零
|
|||
|
void funResetOutput();//产量清零(产线左下角)
|
|||
|
void funAllToReset();//流程复位
|
|||
|
void funFlatEmbHook();//平绣勾线
|
|||
|
void funSpindleJog();//主轴点动
|
|||
|
|
|||
|
void funSpindleRotate();//主轴旋转
|
|||
|
void funBackWorkPoint();//回工作点
|
|||
|
void funBackToOrigin();//回原点
|
|||
|
void funResetStartPoint(QString filePath,DataFilePos pos);//边框检查超限后重新自动设置起绣点
|
|||
|
void funSetOffsetPoint();//设置偏移点
|
|||
|
void funBackOffsetPoint();//回偏移点
|
|||
|
void funSetStartPoint(QString filePath);//设置起始点
|
|||
|
void funBackStartPoint();//回起始点
|
|||
|
void funBorderCheck();//边框检查
|
|||
|
void funWorkState();//切换工作状态
|
|||
|
void funManualTrim();//手动剪线
|
|||
|
void funTowelTrim();//毛巾剪线
|
|||
|
void funCutterOpenAndClose();//剪刀开合
|
|||
|
void funSwitchHead(); //切换机头
|
|||
|
void funMSpindleRotate(); //M轴旋转
|
|||
|
void funChenWorkArea();// 设置可工作区域
|
|||
|
void funEmbWorkArea();// 设置可工作区域
|
|||
|
void funManualChangeColor();//手动换色
|
|||
|
void funTowelChangeColor();//毛巾换色
|
|||
|
void funTraceOffset();//线迹偏移
|
|||
|
void funWorkPause();//工作暂停
|
|||
|
void funSequinChangeColor(s16 sq = 0);//亮片换色,0代表左亮片,1代表右亮片
|
|||
|
void funQuantityMoveFrame();//定量移框
|
|||
|
void funNeedleRodPosition();//针杆定位
|
|||
|
void funSimulateFrame();//空走边框
|
|||
|
void funProcessReset();//流程复位
|
|||
|
void funSetFeedPoint();//定上料点
|
|||
|
void funBackFeedPoint();//回上料点
|
|||
|
void funManualOil();//手动加油
|
|||
|
void funResetRepeatNum();//重置反复次数
|
|||
|
void funShuttleChange();//梭盘计数复位
|
|||
|
void funGotoZeroPos();//框架归零
|
|||
|
void funSetWorkRange();//定工作范围
|
|||
|
void sendPatternHead(QString filePath);//发送花样文件头
|
|||
|
void sendPatternPatchHeadData(QString filePath,int type = FILE_TYPE_DAT);//发送贴布绣或隔头绣数据
|
|||
|
void sendPatternTowelHeightData(QString filePath);//发送毛巾高度数据
|
|||
|
void sendPatternData(QString filePath,int type = FILE_TYPE_DAT);//发送花样数据
|
|||
|
void funBottomDetect(int headType);//底线检测 //headType 用于区分是平绣还是缠绕
|
|||
|
void funFaceDetect(int headType);//面线检测
|
|||
|
void funExitRoot();//退出登录
|
|||
|
void funAgingTest();//老化测试
|
|||
|
void funGetMCVersionInfo();//获取主控主板版本信息
|
|||
|
void funGetEXBVersionInfo(QString tStyle);//获取主控外围板版本信息
|
|||
|
void funProductStatistics(QString tStyle,QString filePath,int patternBreakLineNum);//生产统计
|
|||
|
// void funJournal(QString bStyle,QString tStyle);//文件日志
|
|||
|
|
|||
|
void funJournalError(QString tStyle);//错误日志
|
|||
|
// void funJournalBreakage(QString bStyle,QString tStyle);//断线日志
|
|||
|
void funDebugInfo();
|
|||
|
void funSoftwareAuthor();//软件授权
|
|||
|
void funChangeOneShuttle();//自动换一个梭
|
|||
|
void funShutDown();//win下关闭计算机
|
|||
|
void funHeadEmb(QString filePath);//隔头绣
|
|||
|
void funQuiHeadEmb(QString filePath);//绗缝机隔头绣
|
|||
|
void funSendPatchEmb(QString filePath,u16* patchColorBuf,NeedlePatch* patchNeedleBuf);//发送贴布绣数据
|
|||
|
void funColorOrderChange(QString filePath,u8* buf,s16 combineMode = 0);//色序改变后
|
|||
|
int funErrorPrompt(u32 errcode,QString info);//错误信息提示
|
|||
|
int funDetectBreakLineStatus();//检测断线状态
|
|||
|
int funDetectBreakHeadStatusBit(int type);//平绣剪刀不在回位,检测 机头 按位
|
|||
|
int funDetectBreakHeadStatus(int type);
|
|||
|
int funDetectSignalStatus(int type);//ZP MP信号异常
|
|||
|
|
|||
|
void funSetPromptDlgVisibleFalse();//错误信息提示窗体隐藏
|
|||
|
void funBottomLineCountReset();//底线计数复位
|
|||
|
void funManualOrAutoSwitch(s16 val = 0);//手自动工作状态切换 0:手动 1:自动
|
|||
|
|
|||
|
void getPatternHeadConfig(QString path,DataFileHead & head);
|
|||
|
void setPatternHeadConfig(QString path,DataFileHead head);
|
|||
|
|
|||
|
void getPatternTowelHeightFcg(QString path,QByteArray & datBuf);
|
|||
|
void setPatternTowelHeightFcg(QString path,QByteArray datBuf);//fcg文件写入花样毛巾高度
|
|||
|
|
|||
|
//缠绕
|
|||
|
void funCoilCutterOpenAndClose();//缠绕下剪线
|
|||
|
void funCoilManualTrim();//缠绕剪线
|
|||
|
void funCoilSpindleJog();//缠绕点动
|
|||
|
void funCoilSpindleRotate();//缠绕主轴旋转
|
|||
|
void funCoilMSpindleRotate();//缠绕M主轴旋转
|
|||
|
|
|||
|
void deleteDir(QString path);//删除文件夹
|
|||
|
|
|||
|
public:
|
|||
|
inline int getBeginX(){return m_beginX;}
|
|||
|
inline int getBeginY(){return m_beginY;}
|
|||
|
inline void setLotDatStartPins(int pins){m_HMILotData.startPins = pins; return;}
|
|||
|
inline void setLotDatEndPins(int pins){m_HMILotData.endPins = pins; return;}
|
|||
|
inline int getCurFileID(){return m_curFileID;}
|
|||
|
|
|||
|
private slots:
|
|||
|
void slotMCInfoChange();//机器信息改变
|
|||
|
void slotFileInfoChange();//接收文件信息
|
|||
|
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 slotEmbSpindleAction(int action);//平绣主轴动作
|
|||
|
void slotEmbSpindleRotate(int angle);//主轴旋转
|
|||
|
void slotElasticCtrlPos(int elasticPos);//松紧线控制
|
|||
|
void slotLiftMotorCtrl(int gearValue);//当前档位值
|
|||
|
void onTipsTimer();//4小时定时器
|
|||
|
void slotSetDynamicIP(QString ssid);//设置动态IP
|
|||
|
void slotSetStaticIP(QString ssid,QString psd,QString dnip);//设置静态IP
|
|||
|
void slotSetQuiHeadBuf(u8* buf);
|
|||
|
|
|||
|
signals:
|
|||
|
void siSetButtonUserLogo(int level);
|
|||
|
void siHeadBuf(u8* buf);
|
|||
|
void siClearPatternBreakLineNum();
|
|||
|
void siDebugState();
|
|||
|
void siCloseRootPara();
|
|||
|
void siClearPattern();
|
|||
|
void siClearPatternFcg();
|
|||
|
void siShowPercentage(int val);
|
|||
|
//void siTestADC(int m_adcFlag);//测试电位器的标志
|
|||
|
|
|||
|
void siAfterDeleteFileid();//xcy 0314 删掉影响fileid的数据后需要将m_fileHead置为0
|
|||
|
void siWifiState(bool bl);//wifi连接状态
|
|||
|
void siHeadParaImportFinish(int type);
|
|||
|
|
|||
|
public slots:
|
|||
|
void slotUserLogin(s16 user);//用户登录
|
|||
|
void slotHMIDecrypt(QString id);//界面解密
|
|||
|
void slotHookTest();//平绣勾刀测试
|
|||
|
void slotFootTest();//独立压脚测试
|
|||
|
void slotAutoSetSoftLimit();//自动定软限位
|
|||
|
void slotEMBSpindleTest();//平绣主轴齿轮比测试
|
|||
|
void slotChenSpindleTest();//毛巾主轴齿轮比测试
|
|||
|
void slotEcdWidthTest();
|
|||
|
void slotFrameParaImport();//动框参数导入
|
|||
|
void slotFrameParaExport();//动框参数导出
|
|||
|
void slotHeadBoardBusDetect();//机头板总线检测
|
|||
|
void slotExitApp();//超级用户退出程序
|
|||
|
void slotVerRecovery();//超级用户下版本恢复
|
|||
|
void slotChangePassword();//超级用户下修改一级密码
|
|||
|
void slotDeleteIni();//删除执行目录下的config.ini
|
|||
|
void slotImportCSV();//导入csv文件
|
|||
|
void slotDeleteCSV();//删除csv文件
|
|||
|
void slotResetCSV();//重置安装调试进度
|
|||
|
void slotDebugMode();//界面调试模式
|
|||
|
void slotLiftMotor();//提升电机控制
|
|||
|
void slotLElasticCtrl();//松紧线控制
|
|||
|
void slotChenilleColorDebug();//毛巾换色调试
|
|||
|
void slotPatternClear();//超级用户下花样总清
|
|||
|
void slotPatternFcgClear();//超级用户花样fcg文件删除
|
|||
|
void slotPatternFcgClearFileid();//清除影响fileid的数据
|
|||
|
void slotCalMachineProgress(s16 csvCode,s16 type = 0);//计算安装调试进度
|
|||
|
void slotHeadParaImport(QString tStyle,int type);
|
|||
|
void slotHeadParaExport(int type);
|
|||
|
void slotJournalError();//错误日志
|
|||
|
void slotJournalBreakage();//断线日志
|
|||
|
void slotCsvChangeDebug();//调试信息
|
|||
|
void slotCounterPrompt(s16 flag);
|
|||
|
//以下为测试记录断线次数精准到针位
|
|||
|
//void testBreakLineNeedle();
|
|||
|
public:
|
|||
|
//QTimer *m_testNeedle;
|
|||
|
void moveDlgPos(void); // 移动窗体位置
|
|||
|
|
|||
|
};
|
|||
|
|
|||
|
#endif // MAINWIDGETFUNCTION_H
|