189 lines
5.7 KiB
C++
189 lines
5.7 KiB
C++
#include "machinetypefun.h"
|
|
|
|
//(打开,关闭)
|
|
OutCtrlItem MachineTypeFun::creatOpenCloseItem(int macType, int showPriority, QString name, int def)
|
|
{
|
|
return makeAOutCtrlItem(macType,showPriority,name,def,
|
|
"",false,-1,-1,-1,
|
|
"",false,-1,-1,-1,
|
|
"",false,-1,-1,-1,
|
|
openStr,true,OUTCONTROL_OPEN,-1,-1,
|
|
closeStr,true,OUTCONTROL_CLOSE,-1,-1);
|
|
}
|
|
|
|
//(归零,正转,反转)
|
|
OutCtrlItem MachineTypeFun::creatZeroForwardReverseItem(int macType, int showPriority, QString name, int def)
|
|
{
|
|
return makeAOutCtrlItem(macType,showPriority,name,def,
|
|
"",false,-1,-1,-1,
|
|
"",false,-1,-1,-1,
|
|
zeroStr,true,OUTCONTROL_ZERO,-1,-1,
|
|
jogPStr,true,-1,OUTCONTROL_JOGP,OUTCONTROL_STOP,
|
|
jogNStr,true,-1,OUTCONTROL_JOGN,OUTCONTROL_STOP);
|
|
}
|
|
|
|
//(上升,下降)
|
|
OutCtrlItem MachineTypeFun::creatAscendingDescendingItem(int macType, int showPriority, QString name, int def)
|
|
{
|
|
return makeAOutCtrlItem(macType,showPriority,name,def,
|
|
"",false,-1,-1,-1,
|
|
"",false,-1,-1,-1,
|
|
"",false,-1,-1,-1,
|
|
ascendStr,true,OUTCONTROL_UP,-1,-1,
|
|
descendStr,true,OUTCONTROL_DOWN,-1,-1);
|
|
}
|
|
|
|
OutCtrlItem MachineTypeFun::creatEnableItem(int macType, int showPriority, QString name, int def, QString btnName)
|
|
{
|
|
return makeAOutCtrlItem(macType,showPriority,name,def,
|
|
"",false,-1,-1,-1,
|
|
"",false,-1,-1,-1,
|
|
"",false,-1,-1,-1,
|
|
"",false,-1,-1,-1,
|
|
btnName,true,OUTCONTROL_ENABLE,-1,-1);
|
|
}
|
|
|
|
//归零命令 显示转动
|
|
OutCtrlItem MachineTypeFun::creatZeroItem(int macType, int showPriority, QString name, int def)
|
|
{
|
|
return makeAOutCtrlItem(macType,showPriority,name,def,
|
|
"",false,-1,-1,-1,
|
|
"",false,-1,-1,-1,
|
|
"",false,-1,-1,-1,
|
|
"",false,-1,-1,-1,
|
|
turnStr,true,OUTCONTROL_ZERO,-1,-1);
|
|
}
|
|
|
|
MachineTypeFun::MachineTypeFun(QObject *parent) : QObject(parent)
|
|
{
|
|
m_allParasList.clear();
|
|
m_allOutCtrlList.clear();
|
|
m_allShortCutList.clear();
|
|
m_allAssistList.clear();
|
|
m_allPatternSetList.clear();
|
|
m_allParaSetList.clear();
|
|
m_allSensorList.clear();
|
|
m_allErrorCodeAndStateList.clear();
|
|
enableStr = QObject::tr("Enable"); //使能
|
|
disableStr = QObject::tr("Disable"); //失能
|
|
jogPStr = QObject::tr("JogP"); //正转
|
|
jogNStr = QObject::tr("JogN"); //反转
|
|
turnStr = QObject::tr("Turn"); //转动
|
|
zeroStr = QObject::tr("Zero"); //归零
|
|
openStr = QObject::tr("Open"); //打开
|
|
closeStr = QObject::tr("Close");//关闭
|
|
ascendStr = QObject::tr("Ascending");//上升
|
|
descendStr = QObject::tr("descending");//下降
|
|
trimStr = QObject::tr("Trim"); //剪线
|
|
|
|
initAllSensorList();
|
|
}
|
|
|
|
MachineTypeFun::~MachineTypeFun()
|
|
{
|
|
m_allParasList.clear();
|
|
m_allOutCtrlList.clear();
|
|
m_allShortCutList.clear();
|
|
m_allAssistList.clear();
|
|
m_allPatternSetList.clear();
|
|
m_allParaSetList.clear();
|
|
m_allSensorList.clear();
|
|
m_allErrorCodeAndStateList.clear();
|
|
}
|
|
|
|
//获取传感器列表
|
|
QList<SensorItem> MachineTypeFun::getSensorList()
|
|
{
|
|
return m_allSensorList;
|
|
}
|
|
|
|
//获取错误代码列表
|
|
QList<ErrorCodeStateItem> MachineTypeFun::getErrorCodeAndStateList()
|
|
{
|
|
return m_allErrorCodeAndStateList;
|
|
}
|
|
|
|
const QHash<int, NineItem> &MachineTypeFun::getNinebtn()
|
|
{
|
|
return m_nineBtn;
|
|
}
|
|
|
|
const QList<PATTERNINFO> &MachineTypeFun::getFileInfoMSG()
|
|
{
|
|
return m_fileInfo;
|
|
}
|
|
|
|
void MachineTypeFun::initFileInfoLabel()
|
|
{
|
|
m_fileInfo.append(FileName);
|
|
m_fileInfo.append(Index);
|
|
m_fileInfo.append(BeginPoint);
|
|
m_fileInfo.append(LocalPoint);
|
|
m_fileInfo.append(Range);
|
|
m_fileInfo.append(Position);
|
|
m_fileInfo.append(Production);
|
|
}
|
|
|
|
void MachineTypeFun::initAllSensorList()
|
|
{
|
|
//所有传感器列表,字符为空
|
|
m_allSensorList.clear();
|
|
int addr, byteaddr, bitaddr;
|
|
|
|
SensorItem item;
|
|
|
|
for (addr = 0; addr < MAX_SENSOR_NUM; addr++)
|
|
{
|
|
byteaddr = addr / 8;
|
|
bitaddr = addr % 8; //(0-7)
|
|
item.setItemValue(byteaddr, bitaddr, "");
|
|
m_allSensorList.append(item);
|
|
}
|
|
}
|
|
|
|
QList<ParaSetItem> MachineTypeFun::getParaSetListByFilter()
|
|
{
|
|
return m_allParaSetList;
|
|
}
|
|
|
|
QList<PatternSetItem> MachineTypeFun::getPatternSetListByFilter()
|
|
{
|
|
return m_allPatternSetList;
|
|
}
|
|
|
|
QList<AssistItem> MachineTypeFun::getAssistListByFilter()
|
|
{
|
|
return m_allAssistList;
|
|
}
|
|
|
|
QList<ShortCutItem> MachineTypeFun::getShortCutListByFilter()
|
|
{
|
|
return m_allShortCutList;
|
|
}
|
|
|
|
QList<OutCtrlItem> MachineTypeFun::getOutCtrlListByFilter()
|
|
{
|
|
return m_allOutCtrlList;
|
|
}
|
|
|
|
QList<ParaItem> MachineTypeFun::getParasListByMcSel()
|
|
{
|
|
QList <ParaItem> paralist;
|
|
int size = m_allParasList.size();
|
|
|
|
for (int i = 0; i < size; i++)
|
|
{
|
|
const ParaItem & item = m_allParasList.at(i);
|
|
paralist.append(item);
|
|
#if(0)
|
|
if ((item.mcenSel & mcensel) != 0)
|
|
{
|
|
paralist.append(item);
|
|
}
|
|
#endif
|
|
}
|
|
|
|
qStableSort(paralist.begin(), paralist.end(), comparePriority);
|
|
return paralist;
|
|
}
|