106 lines
7.1 KiB
C++
106 lines
7.1 KiB
C++
|
|
|||
|
#include "error.h"
|
|||
|
#include "comm/protocol.h"
|
|||
|
#include <QObject>
|
|||
|
|
|||
|
#define CASE_OP(cd, str) \
|
|||
|
{\
|
|||
|
case cd:\
|
|||
|
errinfo = str;\
|
|||
|
break;\
|
|||
|
}
|
|||
|
|
|||
|
QString getErrStr(u32 code)
|
|||
|
{
|
|||
|
QString errinfo;
|
|||
|
errinfo.clear();
|
|||
|
QString errorCode;
|
|||
|
errorCode.clear();
|
|||
|
|
|||
|
switch (code)
|
|||
|
{
|
|||
|
//通用的错误代码
|
|||
|
CASE_OP(ERR_NONE, QObject::tr("")); // 没有错误
|
|||
|
CASE_OP(ERR_NO_AIR, QObject::tr("(0x0002)Insufficient air pressure")); // 气压不足
|
|||
|
CASE_OP(ERR_NOT_SAFE, QObject::tr("(0x0003)safe area error")); // 安全区域介入
|
|||
|
CASE_OP(ERR_EXPIRATION, QObject::tr("(0x0004)Expiration of use")); // 使用时限已到
|
|||
|
CASE_OP(ERR_DRIVER, QObject::tr("(0x0005)Driver alarm")); // 驱动器报警
|
|||
|
CASE_OP(ERR_FILL_DATA, QObject::tr("(0x0006)Fill data error")); // 填充数据错误
|
|||
|
CASE_OP(ERR_NOT_ALLOWED, QObject::tr("(0x0007)Not allowed to work")); // 不允许工作状态
|
|||
|
CASE_OP(ERR_CTRL_ERR, QObject::tr("(0x0008)Control error")); // 控制错误
|
|||
|
CASE_OP(ERR_FPGA_ERR, QObject::tr("(0x0009)Motion control chip version error")); // 运动控制芯片版本错误
|
|||
|
CASE_OP(ERR_BUTTON_NOUP, QObject::tr("(0x000A)Waiting for button to lift timeout")); // 等待按钮抬起超时
|
|||
|
CASE_OP(ERR_FPGA_RESET, QObject::tr("(0x000B)FPGA Reset")); // FPGA复位
|
|||
|
CASE_OP(ERR_NO_READY, QObject::tr("(0x000C)Peripheral Device not ready")); // 外设未就绪
|
|||
|
CASE_OP(ERR_NO_SEND_ERR, QObject::tr("(0x000D)Transmission data error")); // 传输数据错误
|
|||
|
CASE_OP(ERR_EDTION_ERR, QObject::tr("(0x000E)Program version error")); // 程序版本错误
|
|||
|
CASE_OP(ERR_WORK_DONE, QObject::tr("(0x000F)Complete output")); // 完成产量
|
|||
|
CASE_OP(ERR_LMT_POSITIVE, QObject::tr("(0x0010)Positive limit")); // 正向限位
|
|||
|
CASE_OP(ERR_LMT_NEGATIVE, QObject::tr("(0x0011)Negative limit")); // 反向限位
|
|||
|
CASE_OP(ERR_RUN_ALM, QObject::tr("(0x0012)Motion alarm")); // 运动报警
|
|||
|
CASE_OP(ERR_RUN_LIMIT, QObject::tr("(0x0013)Motion limit")); // 运动限位
|
|||
|
CASE_OP(ERR_RUN_EMS, QObject::tr("(0x0014)Emergency stop")); // 运动急停
|
|||
|
CASE_OP(ERR_MV_PARA, QObject::tr("(0x0015)Motion parameters error")); // 运动参数错误
|
|||
|
CASE_OP(ERR_MC_PARA, QObject::tr("(0x0016)Machine parameters error")); // 机器参数错误
|
|||
|
CASE_OP(ERR_IN_PARA, QObject::tr("(0x0017)Input parameters error")); // 输入参数错误
|
|||
|
CASE_OP(ERR_NOT_WORKSTA, QObject::tr("(0x001A)Not in work status error")); // 不能工作状态
|
|||
|
CASE_OP(ERR_NOT_MOVESTA, QObject::tr("(0x001B)Prohibited frame moving state")); // 禁止移框状态
|
|||
|
CASE_OP(ERR_MTZ_RIGHT, QObject::tr("(0x001F)Zero success")); // 归零成功
|
|||
|
CASE_OP(ERR_MTZ_ERROR, QObject::tr("(0x0020)Return to zero error")); // 归零错误
|
|||
|
CASE_OP(ERR_COOR_SYSTM, QObject::tr("(0x0021)Coordinate system error")); // 坐标系统错误
|
|||
|
CASE_OP(ERR_OUT_RANGE, QObject::tr("(0x0022)Target position out of bounds")); // 目标位置越界
|
|||
|
CASE_OP(ERR_X_LIT_POSI, QObject::tr("(0x0023)X Positive limit")); // X正向限位
|
|||
|
CASE_OP(ERR_X_LIT_NEGA, QObject::tr("(0x0024)X Negative limit")); // X反向限位
|
|||
|
CASE_OP(ERR_Y_LIT_POSI, QObject::tr("(0x0025)Y Positive limit")); // Y正向限位
|
|||
|
CASE_OP(ERR_Y_LIT_NEGA, QObject::tr("(0x0026)Y Negative limit")); // Y反向限位
|
|||
|
CASE_OP(ERR_ALM_COVEROPEN, QObject::tr("(0x002B)Safety door error")); // 开盖报警,安全门错误
|
|||
|
CASE_OP(ERR_LIGHTCURTAINS1, QObject::tr("(0x002C)Entering the light curtain 1")); // 光幕1介入
|
|||
|
CASE_OP(ERR_LIGHTCURTAINS2, QObject::tr("(0x002D)Entering the light curtain 2")); // 光幕2介入
|
|||
|
CASE_OP(ERR_NO_DATA, QObject::tr("(0x0040)None data")); // 无数据
|
|||
|
CASE_OP(ERR_DATA_ERROR, QObject::tr("(0x0041)Data error")); // 数据错误
|
|||
|
CASE_OP(ERR_GRAPH_OUT_RANGE, QObject::tr("(0x0042)Graphics out of range")); // 图形超出范围
|
|||
|
CASE_OP(ERR_MS_NOT_ZERO, QObject::tr("(0x0050)Spindle is not in zero position")); // 主轴不在零位
|
|||
|
CASE_OP(ERR_HK_NOT_ZERO, QObject::tr("(0x0051)Rotary hook is not in zero position")); // 旋梭不在零位
|
|||
|
CASE_OP(ERR_CUTTER_NOT_POS, QObject::tr("(0x0054)Scissors are not in position")); // 剪刀不在回位
|
|||
|
CASE_OP(ERR_HEAD_NOT_LOW, QObject::tr("(0x0056)Nose not in low position")); // 机头不在低位
|
|||
|
CASE_OP(ERR_UPER_TBREAK, QObject::tr("(0x0058)Thread is broken"));// 断线
|
|||
|
CASE_OP(ERR_BOBBIN_TBREAK, QObject::tr("(0x0059)Bottom thread disconnected")); // 底线断线
|
|||
|
CASE_OP(ERR_TRANS_TIMEOUT, QObject::tr("(0x005D)Execution command timed out")); // 执行命令超时
|
|||
|
CASE_OP(ERR_LIFT_TIMEOUT, QObject::tr("(0x005F)Head lifting timeout")); // 机头升降超时
|
|||
|
CASE_OP(ERR_CHANGE_BOBBIN, QObject::tr("(0x00F0)Change the bobbin")); // 更换梭芯
|
|||
|
CASE_OP(ERR_CHANGE_BOBBIN_A, QObject::tr("(0x00F1)Replace bobbin A")); // 更换梭芯A
|
|||
|
CASE_OP(ERR_CHANGE_BOBBIN_B, QObject::tr("(0x00F2)Replace bobbin B")); // 更换梭芯B
|
|||
|
CASE_OP(ERR_CHANGE_BOBBIN_STA, QObject::tr("(0x00F3)The machine is in the state of replacing the bobbin")); // 机器处于更换梭芯状态
|
|||
|
CASE_OP(ERR_AIR_POWER, QObject::tr("(0x002E)Insufficient air pressure")); // 气压不足
|
|||
|
|
|||
|
//通用的状态信息
|
|||
|
CASE_OP(STA_NORMAL_STOP, QObject::tr("Normal stop")); // 正常停止
|
|||
|
CASE_OP(STA_MTZ_SUCCESS, QObject::tr("Find zero success")); // 归零成功
|
|||
|
CASE_OP(STA_WORK_PAUSE, QObject::tr("work pause")); // 工作暂停
|
|||
|
CASE_OP(STA_WORK_OVER, QObject::tr("End of work")); // 工作结束
|
|||
|
CASE_OP(STA_WORK_FINISH, QObject::tr("Work done")); // 工作完成
|
|||
|
CASE_OP(STA_WORK_DONE, QObject::tr("Complete production")); // 完成产量
|
|||
|
CASE_OP(STA_EXEC_SUCCESS, QObject::tr("(0x0106)Execute success")); // 执行成功
|
|||
|
CASE_OP(STA_EXEC_FAILED, QObject::tr("(0x0107)Execute false")); // 执行失败
|
|||
|
CASE_OP(STA_WAIT_FILE, QObject::tr("(0x0108)wait file")); // 等待文件
|
|||
|
CASE_OP(STA_CHANGE_BOBBIN, QObject::tr("(0x0109)change the bobbin")); // 更换梭芯
|
|||
|
CASE_OP(STA_PROCESS_FINISH, QObject::tr("(0x010A)Execute finish")); // 执行完成
|
|||
|
CASE_OP(STA_PROCESS_RUNNING, QObject::tr("(0x010B)Execute runnibng")); // 执行过程中
|
|||
|
|
|||
|
default:
|
|||
|
//errorCode.sprintf("CODE 0x%x", code);
|
|||
|
//errinfo.append(QObject::tr("Undefined error,") + errorCode);
|
|||
|
break;
|
|||
|
}
|
|||
|
return errinfo;
|
|||
|
}
|
|||
|
|
|||
|
QString getPromptStr(u32 code)
|
|||
|
{
|
|||
|
QString errinfo;
|
|||
|
switch (code)
|
|||
|
{
|
|||
|
}
|
|||
|
return errinfo;
|
|||
|
}
|