Fixed parsing and processing of modifiers in custom frame sender

window. Added serialbus to project (Qt5.6 dependency)
This commit is contained in:
Collin Kidder
2016-02-25 21:09:48 -05:00
parent 6e64ab7134
commit f8e72986f0
2 changed files with 41 additions and 46 deletions
+1 -1
View File
@@ -6,7 +6,7 @@
QT += core gui QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets serialport printsupport qml greaterThan(QT_MAJOR_VERSION, 4): QT += widgets serialport printsupport qml serialbus
CONFIG(release, debug|release):DEFINES += QT_NO_DEBUG_OUTPUT CONFIG(release, debug|release):DEFINES += QT_NO_DEBUG_OUTPUT
+40 -45
View File
@@ -430,7 +430,7 @@ int FrameSenderWindow::fetchOperand(int idx, ModifierOperand op)
if (op.notOper) return ~op.databyte; if (op.notOper) return ~op.databyte;
else return op.databyte; else return op.databyte;
} }
else if (op.ID == -2) else if (op.ID == -2) //fetch data from a data byte within the output frame
{ {
if (op.notOper) return ~sendingData.at(idx).data[op.databyte]; if (op.notOper) return ~sendingData.at(idx).data[op.databyte];
else return sendingData.at(idx).data[op.databyte]; else return sendingData.at(idx).data[op.databyte];
@@ -473,6 +473,8 @@ void FrameSenderWindow::processModifierText(int line)
QString modString; QString modString;
bool firstOp = true; bool firstOp = true;
bool abort = false; bool abort = false;
QString token;
ModifierOp thisOp;
//Example line: //Example line:
//d0 = D0 + 1,d1 = id:0x200:d3 + id:0x200:d4 AND 0xF0 - Original version //d0 = D0 + 1,d1 = id:0x200:d3 + id:0x200:d4 AND 0xF0 - Original version
@@ -493,6 +495,7 @@ void FrameSenderWindow::processModifierText(int line)
{ {
Modifier thisMod; Modifier thisMod;
thisMod.destByte = 0; thisMod.destByte = 0;
firstOp = true;
QString leftSide = Utility::grabAlphaNumeric(mods[i]); QString leftSide = Utility::grabAlphaNumeric(mods[i]);
if (leftSide.startsWith("D") && leftSide.length() == 2) if (leftSide.startsWith("D") && leftSide.length() == 2)
@@ -511,58 +514,50 @@ void FrameSenderWindow::processModifierText(int line)
continue; continue;
} }
abort = false; abort = false;
token = Utility::grabAlphaNumeric(mods[i]);
if (token[0] == '~')
{
thisOp.first.notOper = true;
token = token.remove(0, 1); //remove the ~ character
}
else thisOp.first.notOper = false;
parseOperandString(token.split(":"), thisOp.first);
if (mods[i].length() < 2) {
abort = true;
thisOp.operation = ADDITION;
thisOp.second.ID = 0;
thisOp.second.databyte = 0;
thisOp.second.notOper = false;
thisMod.operations.append(thisOp);
}
while (!abort) while (!abort)
{ {
QString token = Utility::grabAlphaNumeric(mods[i]); QString operation = Utility::grabOperation(mods[i]);
ModifierOp thisOp; if (operation == "")
if (firstOp)
{ {
if (token[0] == '~') abort = true;
{
thisOp.first.notOper = true;
token = token.remove(0, 1); //remove the ~ character
}
else thisOp.first.notOper = false;
parseOperandString(token.split(":"), thisOp.first);
firstOp = false;
} }
else else
{ {
thisOp.first.ID = -1; //shadow register thisOp.operation = parseOperation(operation);
} QString secondOp = Utility::grabAlphaNumeric(mods[i]);
if (mods[i].length() == 0) //if this thing had no actual operation or second operand then fake it if (mods[i][0] == '~')
{ {
abort = true; thisOp.second.notOper = true;
thisOp.operation = ADDITION; mods[i] = mods[i].remove(0, 1); //remove the ~ character
thisOp.second.ID = 0; }
thisOp.second.databyte = 0; else thisOp.second.notOper = false;
thisOp.second.notOper = false; thisOp.second.bus = sendingData[line].bus;
thisOp.second.ID = sendingData[line].ID;
parseOperandString(secondOp.split(":"), thisOp.second);
thisMod.operations.append(thisOp); thisMod.operations.append(thisOp);
} }
else //otherwise try to grab them
{ thisOp.first.ID = -1; //shadow register
QString operation = Utility::grabOperation(mods[i]); if (mods[i].length() < 2) abort = true;
if (operation == "")
{
abort = true;
}
else
{
thisOp.operation = parseOperation(operation);
QString secondOp = Utility::grabAlphaNumeric(mods[i]);
if (mods[i][0] == '~')
{
thisOp.second.notOper = true;
mods[i] = mods[i].remove(0, 1); //remove the ~ character
}
else thisOp.second.notOper = false;
thisOp.second.bus = sendingData[line].bus;
thisOp.second.ID = sendingData[line].ID;
parseOperandString(secondOp.split(":"), thisOp.second);
thisMod.operations.append(thisOp);
}
}
} }
sendingData[line].modifiers.append(thisMod); sendingData[line].modifiers.append(thisMod);