From f8e72986f00ebaa38fe422755b0cac1417ad2f65 Mon Sep 17 00:00:00 2001 From: Collin Kidder Date: Thu, 25 Feb 2016 21:09:48 -0500 Subject: [PATCH] Fixed parsing and processing of modifiers in custom frame sender window. Added serialbus to project (Qt5.6 dependency) --- SavvyCAN.pro | 2 +- framesenderwindow.cpp | 85 ++++++++++++++++++++----------------------- 2 files changed, 41 insertions(+), 46 deletions(-) diff --git a/SavvyCAN.pro b/SavvyCAN.pro index 8d64e4d..344c9e0 100644 --- a/SavvyCAN.pro +++ b/SavvyCAN.pro @@ -6,7 +6,7 @@ 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 diff --git a/framesenderwindow.cpp b/framesenderwindow.cpp index 61cc598..91dd13c 100644 --- a/framesenderwindow.cpp +++ b/framesenderwindow.cpp @@ -430,7 +430,7 @@ int FrameSenderWindow::fetchOperand(int idx, ModifierOperand op) if (op.notOper) 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]; else return sendingData.at(idx).data[op.databyte]; @@ -473,6 +473,8 @@ void FrameSenderWindow::processModifierText(int line) QString modString; bool firstOp = true; bool abort = false; + QString token; + ModifierOp thisOp; //Example line: //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; thisMod.destByte = 0; + firstOp = true; QString leftSide = Utility::grabAlphaNumeric(mods[i]); if (leftSide.startsWith("D") && leftSide.length() == 2) @@ -511,58 +514,50 @@ void FrameSenderWindow::processModifierText(int line) continue; } 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) { - QString token = Utility::grabAlphaNumeric(mods[i]); - ModifierOp thisOp; - - if (firstOp) + QString operation = Utility::grabOperation(mods[i]); + if (operation == "") { - 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); - firstOp = false; + abort = true; } else { - thisOp.first.ID = -1; //shadow register - } - if (mods[i].length() == 0) //if this thing had no actual operation or second operand then fake it - { - abort = true; - thisOp.operation = ADDITION; - thisOp.second.ID = 0; - thisOp.second.databyte = 0; - thisOp.second.notOper = false; + 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); } - else //otherwise try to grab them - { - QString operation = Utility::grabOperation(mods[i]); - 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); - } - } + + thisOp.first.ID = -1; //shadow register + if (mods[i].length() < 2) abort = true; } sendingData[line].modifiers.append(thisMod);