Quilting-lw/items/itemsmanage.cpp
2026-01-23 16:37:18 +08:00

594 lines
26 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "itemsmanage.h"
extern QString createStrList(QStringList list);
ParaItem makeAParaItem(
int64_t mcenSel,
int paraType,
int paraTypeSort,
int indexInPara,
int bitInWord,
int readonly,
int valueType,
QString paraName,
int64_t value,
int64_t minval,
int64_t maxval,
int64_t defvalue,
int afterpoint,
QString unitstr,
QString valuestr,
QString selList,
int selIdx,
int defIdx,
int showPriority,
int authority)
{
ParaItem item;
item.clean();
item.mcenSel = mcenSel; /* 机型选择 */
item.paraType = paraType; /* 参数类型(机器参数、工作参数、花样设置参数...) */
item.paraTypeSort = paraTypeSort; /* 参数类型分类(机器参数的速度参数、机器参数的动作参数...) */
item.indexInPara = indexInPara; /* 参数索引,-1提示型显示; >= 0该条目在参数中的位置*/
item.bitInWord = bitInWord; /* 参数位索引 */
item.readonly = readonly; /* 只读标志 */
item.valueType = valueType; /* 参数值类型 = 0, 无值; = 1, 数字输入型; = 2, 开关选择型; = 3, 列表选择型 */
item.paraName = paraName; /* 参数名称 */
item.value = value; /* int输入型或选择型参数值 */
item.minVal = minval; /* int输入型参数值范围下限 */
item.maxVal = maxval; /* int输入型参数值范围上限 */
item.defValue = defvalue; /* int输入型或选择型默认参数值 */
item.afterPoint = afterpoint; /* int输入型保留小数位数 */
item.unitStr = unitstr; /* int输入型单位字符串 */
item.valueStr = valuestr; /* 字符输入型参数字符串 */
item.selList = selList; /* 列表选择型的参数列表, 通过"\n"来分割 */
item.selIdx = selIdx; /* 当前选择项索引 */
item.defIdx = defIdx; /* 默认选择项索引 */
item.showPriority = showPriority; /* 显示优先级 */
item.authority = authority; /* 显示优先级 */
return item;
}
bool comparePriority(const ParaItem &item1, const ParaItem &item2)
{
int pr1, pr2;
pr1 = item1.showPriority;
pr2 = item2.showPriority;
if (pr1 < 0)
{
pr1 = 0;
}
if (pr2 < 0)
{
pr2 = 0;
}
return (pr1 < pr2);
}
//各个机型通用参数-软件设置参数
void initSoftwareParasList(QList <ParaItem> & parasList)
{
//软件设置参数---------------------------
//软件设置参数-主题;单位:无 范围1-3默认1
/*
parasList.append(makeAParaItem(0,
PARA_TYPE_SOFTWARESET,
0 ,
SET_THEME, 0, 1, PARA_VALUE_TYPE_LIST,
QCoreApplication::translate("GLOBAL", "Theme"),//主题
1, 1, 3, 1, 0, "", "",
QCoreApplication::translate("GLOBAL", "Theme1:1;Theme2:2;Theme3:3"),//主题1:1;主题2:2;主题3:3
0, 0, 0x0001, operate));
*/
//不加油:0;按工作时间间断加油:1;按工作针数间歇加油:2;持续加油:3
QString strLanguage = createStrList
({QCoreApplication::translate("GLOBAL", "Chinese"), //0, 中文
QCoreApplication::translate("GLOBAL", "English"), //1, 英文
QCoreApplication::translate("GLOBAL", "Ukrainian"), //2, 乌克兰文
QCoreApplication::translate("GLOBAL", "French"),//3, 法文
QCoreApplication::translate("GLOBAL", "Russian"),//4, 俄语
QCoreApplication::translate("GLOBAL", "German")//5, 德文
});
//软件设置参数-语言;单位:无 范围0-1默认0
parasList.append(makeAParaItem(0,
PARA_TYPE_SOFTWARESET,
0 ,
SET_LANGUAGE, 0, 0, PARA_VALUE_TYPE_LIST,
QCoreApplication::translate("GLOBAL", "Language"),//语言
0, chinese, german, 0, 0, "", "",
strLanguage,0, 0, 0x0002, operate));
// #ifdef Q_OS_WIN
//软件设置参数-字体大小
parasList.append(makeAParaItem(0,
PARA_TYPE_SOFTWARESET,
0 ,
SET_FONTSIZE, 0, 0, PARA_VALUE_TYPE_INT,
QCoreApplication::translate("GLOBAL", "Fontsize"),//字体大小
0, 8, 16, 0, 0, "", "",
(""),
0, 0, 0x0002, operate));
// #endif
//软件设置参数---------------------------
}
//各个机型通用参数-时间设置参数
void initTimeParasList(QList <ParaItem> & parasList)
{
//时间设置参数---------------------------
//时间设置参数-年;单位:无 范围1000-9999默认1000
parasList.append(makeAParaItem(0,
PARA_TYPE_TIMESET,
0 ,
1, 0, 0, PARA_VALUE_TYPE_INT,
QCoreApplication::translate("GLOBAL", "Year"),//年
1000, 1000, 9999, 1000, 0, "", "",
"", 0, 0, 0x0000, operate));
//时间设置参数-月;单位:无 范围1-12默认1
parasList.append(makeAParaItem(0,
PARA_TYPE_TIMESET,
0 ,
2, 0, 0, PARA_VALUE_TYPE_INT,
QCoreApplication::translate("GLOBAL", "Month"),//月
1, 1, 12, 1, 0, "", "",
"", 0, 0, 0x0001, operate));
//时间设置参数-日;单位:无 范围1-31默认1
parasList.append(makeAParaItem(0,
PARA_TYPE_TIMESET,
0 ,
3, 0, 0, PARA_VALUE_TYPE_INT,
QCoreApplication::translate("GLOBAL", "Day"),//日
1, 1, 31, 1, 0, "", "",
"", 0, 0, 0x0002, operate));
//时间设置参数-时;单位:无 范围0-23默认0
parasList.append(makeAParaItem(0,
PARA_TYPE_TIMESET,
0 ,
4, 0, 0, PARA_VALUE_TYPE_INT,
QCoreApplication::translate("GLOBAL", "Hour"),//时
0, 0, 23, 0, 0, "", "",
"", 0, 0, 0x0003, operate));
//时间设置参数-分;单位:无 范围0-59默认0
parasList.append(makeAParaItem(0,
PARA_TYPE_TIMESET,
0 ,
5, 0, 0, PARA_VALUE_TYPE_INT,
QCoreApplication::translate("GLOBAL", "Minute"),//分
0, 0, 59, 0, 0, "", "",
"", 0, 0, 0x0004, operate));
//时间设置参数-秒;单位:无 范围0-59默认0
parasList.append(makeAParaItem(0,
PARA_TYPE_TIMESET,
0 ,
6, 0, 0, PARA_VALUE_TYPE_INT,
QCoreApplication::translate("GLOBAL", "Second"),//秒
0, 0, 59, 0, 0, "", "",
"", 0, 0, 0x0005, operate));
//时间设置参数---------------------------
}
//各个机型通用参数-网络管理参数
void initNetworkParasList(QList <ParaItem> & parasList)
{
//网络管理参数-服务器IP设置单位范围无默认192.168.16.253
parasList.append(makeAParaItem(0,
PARA_TYPE_NETWORKSET,
0 ,
SET_MACHINE_SERVERIP, 0, 0, PARA_VALUE_TYPE_STRINPUT,
QCoreApplication::translate("GLOBAL", "Server IP settings"),//服务器IP设置
0, 0, 0, 0, 0, "", "192.168.16.253",
"",
0, 0, 0x0007, operate));
//网络管理参数-服务器端口设置;单位:无 范围0-65535默认5000
parasList.append(makeAParaItem(0,
PARA_TYPE_NETWORKSET,
0 ,
SET_MACHINE_SERVERPORT, 0, 0, PARA_VALUE_TYPE_INT,
QCoreApplication::translate("GLOBAL", "Server port settings"),//服务器端口设置
5000, 0, U16_MAX, 5000, 0, "", "",
"", 0, 0,0x0008, operate));
//网络管理参数-本地IP设置单位范围无默认192.168.16.41
parasList.append(makeAParaItem(0,
PARA_TYPE_NETWORKSET,
0 ,
SET_LOCALIP, 0, 0, PARA_VALUE_TYPE_STRINPUT,
QCoreApplication::translate("GLOBAL", "Local IP settings"),//本地IP设置
0, 0, 0, 0, 0, "", "192.168.16.41",
"",
0, 0, 0x0009, operate));
//网络管理参数-本地端口设置;单位:无 范围0-65535默认5001
parasList.append(makeAParaItem(0,
PARA_TYPE_NETWORKSET,
0 ,
SET_LOCALPORT, 0, 0, PARA_VALUE_TYPE_INT,
QCoreApplication::translate("GLOBAL", "Local port settings"),//本地端口设置
5001, 0, U16_MAX, 5001, 0, "", "",
"", 0, 0,0x000A, operate));
//网络管理参数---------------------------
}
OutCtrlItem makeAOutCtrlItem(int macType, int showPriority, QString name, int def,
QString btn1Str, bool btn1Visible, int btn1ClickFun, int btn1PreFun, int btn1RelFun,
QString btn2Str, bool btn2Visible, int btn2ClickFun, int btn2PreFun, int btn2RelFun,
QString btn3Str, bool btn3Visible, int btn3ClickFun, int btn3PreFun, int btn3RelFun,
QString btn4Str, bool btn4Visible, int btn4ClickFun, int btn4PreFun, int btn4RelFun,
QString btn5Str, bool btn5Visible, int btn5ClickFun, int btn5PreFun, int btn5RelFun)
{
OutCtrlItem item;
item.clean();
item.m_macType = macType;
item.m_showPriority = showPriority;
item.m_name = name;
item.m_def = def;
item.m_btn1Str = btn1Str;
item.m_btn1Visible = btn1Visible;
item.m_btn1ClickFun = btn1ClickFun;
item.m_btn1PreFun = btn1PreFun;
item.m_btn1RelFun = btn1RelFun;
item.m_btn2Str = btn2Str;
item.m_btn2Visible = btn2Visible;
item.m_btn2ClickFun = btn2ClickFun;
item.m_btn2PreFun = btn2PreFun;
item.m_btn2RelFun = btn2RelFun;
item.m_btn3Str = btn3Str;
item.m_btn3Visible = btn3Visible;
item.m_btn3ClickFun = btn3ClickFun;
item.m_btn3PreFun = btn3PreFun;
item.m_btn3RelFun = btn3RelFun;
item.m_btn4Str = btn4Str;
item.m_btn4Visible = btn4Visible;
item.m_btn4ClickFun = btn4ClickFun;
item.m_btn4PreFun = btn4PreFun;
item.m_btn4RelFun = btn4RelFun;
item.m_btn5Str = btn5Str;
item.m_btn5Visible = btn5Visible;
item.m_btn5ClickFun = btn5ClickFun;
item.m_btn5PreFun = btn5PreFun;
item.m_btn5RelFun = btn5RelFun;
return item;
}
ShortCutItem makeAShortCutItem(int macType, int showPriority, QString name, QString topImageName, int enumFunction)
{
ShortCutItem item;
item.clean();
item.m_macType = macType;
item.m_showPriority = showPriority;
item.m_name = name;
item.m_topImageName = topImageName;
item.m_enumFunction = enumFunction;
return item;
}
//添加辅助功能item
AssistItem makeAAssistItem(int macType, int showPriority, QString name, QString topImageName, int enumFunction)
{
AssistItem item;
item.clean();
item.m_macType = macType;
item.m_showPriority = showPriority;
item.m_name = name;
item.m_topImageName = topImageName;
item.m_enumFunction = enumFunction;
return item;
}
PatternSetItem makeAPatternSetItem(int macType, int showPriority, QString name, QString topImageName, int enumFunction)
{
PatternSetItem item;
item.clean();
item.m_macType = macType;
item.m_showPriority = showPriority;
item.m_name = name;
item.m_topImageName = topImageName;
item.m_enumFunction = enumFunction;
return item;
}
void initRootHMIConfigurationList(QList<ParaItem> &parasList)
{
//超级用户界面配置参数-分辨率;单位:无
parasList.append(makeAParaItem(0,
PARA_TYPE_HMICONFIGURATION,
0 ,
ROOT_RESOLUTION, 0, 0, PARA_VALUE_TYPE_LIST,
QCoreApplication::translate("GLOBAL", "Resolution"),//分辨率
0, 0, 2, 0, 0, "", "",
"1920x1080:0;1024x600:1;800x480:2;",
0, 0, 0x0001, root));
//软件设置参数-通讯方式;单位:无 范围0-2默认0
parasList.append(makeAParaItem(0,
PARA_TYPE_HMICONFIGURATION,
0 ,
SET_CONNECTMODE, 0, 0, PARA_VALUE_TYPE_LIST,
QCoreApplication::translate("GLOBAL", "Communication method"),//通讯方式
0, 0, 1, 0, 0, "", "",
QCoreApplication::translate("GLOBAL", "Network:0;SerialPort:1"),//网口:0;串口:1
0, 0, 0x0011, operate));
QString strYesNo = createStrList
({QCoreApplication::translate("GLOBAL", "No"), //0, 否
QCoreApplication::translate("GLOBAL", "Yes"), //1, 是
});
QList<mcSelect> mcTypeList;
mcSelect mc;
mc.mcName = QCoreApplication::translate("GLOBAL", "McHighSingleQui"); //高速单针机
mc.mcIdx = MACHINE_HIGHSPEEDSINGLEQUI;
mcTypeList.append(mc);
mc.mcName = QCoreApplication::translate("GLOBAL", "FiveHeadPrecisionSewing"); //五头精密缝
mc.mcIdx = MACHINE_FIVEHEADPRECISIONSEWING;
mcTypeList.append(mc);
mc.mcName = QCoreApplication::translate("GLOBAL", "ClothingMac"); //服装机
mc.mcIdx = MACHINE_CLOTHINGMAC;
mcTypeList.append(mc);
// mc.mcName = QCoreApplication::translate("GLOBAL", "Multineedlerotary"); //多针旋梭
// mc.mcIdx = MACHINE_MULTINEEDLEROTARY;
// mcTypeList.append(mc);
mc.mcName = QCoreApplication::translate("GLOBAL", "ThickWiringMac"); //粗布布线机
mc.mcIdx = MACHINE_THICK_WIRING;
mcTypeList.append(mc);
mc.mcName = QCoreApplication::translate("GLOBAL", "FlyShuttle"); //飞梭机
mc.mcIdx = MACHINE_FLYSHUTTLE;
mcTypeList.append(mc);
mc.mcName = QCoreApplication::translate("GLOBAL", "GlassFibre"); //玻璃纤维
mc.mcIdx = MACHINE_GLASSFIBRE;
mcTypeList.append(mc);
mc.mcName = QCoreApplication::translate("GLOBAL", "DoubleLayered"); //双层绗缝机
mc.mcIdx = MACHINE_DOUBLE_LAYERED;
mcTypeList.append(mc);
mc.mcName = QCoreApplication::translate("GLOBAL", "DLQScheBoard"); //双层绗缝调度主板
mc.mcIdx = MACHINE_DLQSCHE_BOARD;
mcTypeList.append(mc);
// mc.mcName = QCoreApplication::translate("GLOBAL", "SingleMutilNeedle"); //单排多针旋梭
// mc.mcIdx = MACHINE_SINGLE_MUTIL_NEEDLE;
// mcTypeList.append(mc);
mc.mcName = QCoreApplication::translate("GLOBAL", "DoubleSizedBedSheets"); //床单机双边缝
mc.mcIdx = MACHINE_DOUBLE_BEDSHEETS;
mcTypeList.append(mc);
mc.mcName = QCoreApplication::translate("GLOBAL", "Multi-headRotaryShuttleMc"); //L2000多针机 改为 多头旋梭机
mc.mcIdx = MACHINE_L2000_MULTI;
mcTypeList.append(mc);
mc.mcName = QCoreApplication::translate("GLOBAL", "Fully automatic quilting machine"); //全自动绗缝机
mc.mcIdx = MACHINE_FULLYAUTOMATIC;
mcTypeList.append(mc);
mc.mcName = QCoreApplication::translate("GLOBAL", "PackageFourSidedTestBoard"); //包四边机测试板
mc.mcIdx = MACHINE_PkgFourTestBoard;
mcTypeList.append(mc);
mc.mcName = QCoreApplication::translate("GLOBAL", "AutoDoubleDoor"); //全自动双龙门单机头
mc.mcIdx = MACHINE_AutoDoubleDoor;
mcTypeList.append(mc);
mc.mcName = QCoreApplication::translate("GLOBAL", "DoubleHeadCombQuiMc"); //双头组合绗缝机
mc.mcIdx = MACHINE_DOUBLEHEADQUI;
mcTypeList.append(mc);
mc.mcName = QCoreApplication::translate("GLOBAL", "CuttingWalk"); //边走边裁
mc.mcIdx = MACHINE_CUTTINGWALK;
mcTypeList.append(mc);
mc.mcName = QCoreApplication::translate("GLOBAL", "FourHeadCombQuiMc"); //四头组合绗缝机
mc.mcIdx = MACHINE_FOURHEADQUI;
mcTypeList.append(mc);
QString strValue;
for(int i = 0; i < mcTypeList.size(); i++)
{
//01/** McHighSingleQui:0;
QString index = QString("%1/%2").arg(i + 1, 2, 10, QChar('0')).arg(mcTypeList.size());
strValue += index + " " + mcTypeList.at(i).mcName + ":" + QString::number(mcTypeList.at(i).mcIdx) + ";";
}
//机器类型
parasList.append(makeAParaItem(0,
PARA_TYPE_HMICONFIGURATION,
0 ,
ROOT_MACTYPE, 0, 0, PARA_VALUE_TYPE_LIST,
QCoreApplication::translate("GLOBAL", "Machine type"),//机器类型
//值,最小值,最大值,默认值
MACHINE_HIGHSPEEDSINGLEQUI, MACHINE_HIGHSPEEDSINGLEQUI, MACHINE_FOURHEADQUI, MACHINE_HIGHSPEEDSINGLEQUI, 0, "", "",
strValue,
0, 0, 0x0012, operate));
//超级用户界面配置参数-产品类型;单位:无
parasList.append(makeAParaItem(0,
PARA_TYPE_HMICONFIGURATION,
0 ,
ROOT_PRODUCTTYPE, 0, 0, PARA_VALUE_TYPE_LIST,
QCoreApplication::translate("GLOBAL", "Product type"),//产品类型
PRODUCT_NULL, PRODUCT_NULL, PRODUCT_NULL, PRODUCT_NULL, 0, "", "",
QCoreApplication::translate("GLOBAL","ProductNull:")+QString::number(PRODUCT_NULL),//无
0, 0, 0x0013, root));
if(g_emMacType != MACHINE_L2000_MULTI)
{
//超级用户界面配置参数-是否有自动换梭功能;单位:无
parasList.append(makeAParaItem(0,
PARA_TYPE_HMICONFIGURATION,
0 ,
ROOT_SHUTTLECHANGE, 0, 0, PARA_VALUE_TYPE_LIST,
QCoreApplication::translate("GLOBAL", "Whether there is a Automatic shuttle change function"),//是否有自动换梭功能
1, 0, 1, 1, 0, "", "",
strYesNo,
1, 1, 0x0016, root));
}
//超级用户界面配置参数-主背景是否带水印;单位:无
parasList.append(makeAParaItem(0,
PARA_TYPE_HMICONFIGURATION,
0 ,
ROOT_WATERMARKSET, 0, 0, PARA_VALUE_TYPE_LIST,
QCoreApplication::translate("GLOBAL", "Is there a GetonAgain logo"),//是否有再登高标志
1, 0, 1, 1, 0, "", "",
strYesNo,
1, 1, 0x0017, root));
//超级用户界面配置参数-参数是否分类显示;单位:无
parasList.append(makeAParaItem(0,
PARA_TYPE_HMICONFIGURATION,
0 ,
ROOT_PARASORTSET, 0, 0, PARA_VALUE_TYPE_LIST,
QCoreApplication::translate("GLOBAL", "Parameter is classified"),//参数是否分类显示
0, 0, 1, 0, 0, "", "",
strYesNo,
0, 0, 0x0018, root));
//是否WIFI
parasList.append(makeAParaItem(0,
PARA_TYPE_HMICONFIGURATION,
0 ,
ROOT_WIFI, 0, 0, PARA_VALUE_TYPE_SW,
QCoreApplication::translate("GLOBAL", "WIFI"),//WIFI
0, 0, 1, 0, 0, "", "",
"",
0, 0, 0x0018, root));
//主轴缝纫工作最高转速
parasList.append(makeAParaItem(0,
PARA_TYPE_HMICONFIGURATION,
0 ,
ROOT_MAXSPEED_MAINSEWWORK, 0, 0, PARA_VALUE_TYPE_INT,
QCoreApplication::translate("GLOBAL", "Max Speed Of Main Sew Work"),
0, 0, 4000, 0, 0, "", "",
"",
0, 0, 0x0018, root));
}
//物联网配置参数
void initRootIOTConfigurationList(QList<ParaItem> &parasList)
{
//超级用户物联网配置-网关连接方式;单位:无
// parasList.append(makeAParaItem(0,
// PARA_TYPE_IOTCONFIGURATION,
// 0 ,
// ROOT_GATEWAYCONNECTIONMETHOD, 0, 0, PARA_VALUE_TYPE_LIST,
// QCoreApplication::translate("GLOBAL", "Gateway connection method"),//网关连接方式
// 0, 0, 2, 0, 0, "", "",
// QCoreApplication::translate("GLOBAL","Serial port:0; Network port:1"),
// 0, 0, 0x0011, root));
//超级用户物联网配置-机架号输入; 单位:无
parasList.append(makeAParaItem(0,
PARA_TYPE_IOTCONFIGURATION,
0 ,
ROOT_RACKNUMBERINPUT, 0, 0, PARA_VALUE_TYPE_INT,
QCoreApplication::translate("GLOBAL", "Input rack number"),//机架号输入
0, 0, INT_MAX, 0, 0, "", "",
"",
0, 0, 0x0012, root));
//超级用户物联网配置-网络设置; 单位:无
parasList.append(makeAParaItem(0,
PARA_TYPE_IOTCONFIGURATION,
0 ,
ROOT_NETWORKSETTINGS, 0, 0, PARA_VALUE_TYPE_CLICK,
QCoreApplication::translate("GLOBAL", "Network settings"),//网络设置
0, 0, 0, 0, 0, "", "",
"",
0, 0, 0x0013, root));
//超级用户物联网配置-工厂预计交货时间; 单位:无
parasList.append(makeAParaItem(0,
PARA_TYPE_IOTCONFIGURATION,
0 ,
ROOT_DELIVERYTIME, 0, 0, PARA_VALUE_TYPE_STRINPUT,
QCoreApplication::translate("GLOBAL", "Factory expects delivery time"),//工厂预计交货时间
0, 0, 0, 0, 0, "", "",
"",
0, 0, 0x0014, root));
//超级用户物联网配置-调试进度; 单位:无
parasList.append(makeAParaItem(0,
PARA_TYPE_IOTCONFIGURATION,
0 ,
ROOT_DEBUGPROGRESS, 0, 0, PARA_VALUE_TYPE_INT,
QCoreApplication::translate("GLOBAL", "Debugging progress"),//调试进度
0, 1, 100, 0, 0, "", "",
"",
0, 0, 0x0015, root));
}
ParaSetItem makeAParaSetItem(int macType, int showPriority, QString name, QString topImageName, int paraType)
{
ParaSetItem item;
item.clean();
item.m_macType = macType;
item.m_showPriority = showPriority;
item.m_name = name;
item.m_topImageName = topImageName;
item.m_paraType = paraType;
return item;
}
SensorItem makeASensorItem(int byte, int bit, QString name, int type)
{
SensorItem item;
item.clean();
item.m_byte_offset = byte;
item.m_bit_offset = bit;
item.m_name = name;
item.m_type = type;
return item;
}
ErrorCodeStateItem makeAErrorStateItem(int code, QString name)
{
ErrorCodeStateItem item;
item.clean();
item.m_code = code;
item.m_name = name;
return item;
}