-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathShowText.cpp
134 lines (93 loc) · 2.6 KB
/
ShowText.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#include "ShowText.h"
#include <QDebug>
#include <QString>
#define CMD_STA 1
#define CMD_END 2
#define CMD_MOV 3
#define CMD_DEY 4
#define CMD_CMG 5
#define CMD_JMP 6
QMap<QString,int> map_StrcmdToCode =
{
{"STA",1},
{"END",2},
{"MOV",3},
{"DEY",4},
{"CMG",5},
{"JMP",6}
};
QList<int> StringToList(QString pos)
{
QList<int> carrierPos;
carrierPos.clear();
QString param ;
QStringList Pos =pos.split(" ");
for(int index=0;index<Pos.size();index++)
{
param=Pos.at(index);
carrierPos<<param.toInt();
}
return carrierPos;
}
QString ListToString (QList<QString> list)
{
QString str;
for(int i=0; i<list.count();i++)
{
str.append(list.at(i)+"\r\n");
}
return str;
}
ShowText::ShowText()
{
}
void ShowText::transListContents(QStringList list,QString OriPos,QString Rfid)
{
if (list.isEmpty() || OriPos.isEmpty() || Rfid.isEmpty()) return;
//把string型OriPos 转换为 int型list的CarrierPos
QList<int>CarrierPos ;
QStringList OriPosList = OriPos.split(" ");
for(int i = 0; i<OriPosList.size();i++)
{
QString pos = OriPosList.at(i);
CarrierPos.append(pos.toInt());
}
//把string型的Rfid转为int型的rfidNum
int rfidNum = Rfid.toInt();
qDebug()<<"CarrierPos"<<CarrierPos;
qDebug()<<"rfid"<<rfidNum;
if (!debugMsg.isEmpty()) debugMsg.clear();
QString text,str;
int instruct;
QString willShowText;
QList<QString> strlist;
for(int i =0 ;i < list.count();i++)
{
text = list.at(i); //一条指令
QStringList splitText ;
splitText = text.split("-"); //一条指令列表
//qDebug()<<splitText<<"指令"<<endl;
str = splitText.at(0);
instruct = str.toInt();
//判断每条命令的种类
if (IS_BASE_INSTRUCT(instruct))
{
splitText.replace(0,QString::number(instruct));
str = BaseInstructTranslate(splitText,CarrierPos,rfidNum);
willShowText.append(str+"\r\n");
}
if (IS_ADVANCE_INSTRUCT(instruct))
{
splitText.replace(0,QString::number(instruct));
qDebug()<<splitText<<"指令"<<endl;
strlist = AdvanceInstructTranslate(splitText,CarrierPos,rfidNum);
str = ListToString(strlist);
willShowText.append(str);
}
}
qDebug()<<"last"<<willShowText<<endl;
//输出显示翻译命令时的调试信息
QString msg = ListToString(debugMsg);
MainWindow::GetInstance()->showDebugMsg(msg);
emit sendData(willShowText);
}