Added bitwise not and modulus division to the list of operations you
can do with modifiers in the custom frame window
This commit is contained in:
@@ -30,6 +30,7 @@ public:
|
||||
int ID;
|
||||
int bus;
|
||||
int databyte;
|
||||
bool notOper; //should a bitwise NOT be applied to this prior to doing the actual calculation?
|
||||
};
|
||||
|
||||
//list of operations that can be done between the two operands
|
||||
@@ -42,7 +43,7 @@ enum ModifierOperationType
|
||||
AND,
|
||||
OR,
|
||||
XOR,
|
||||
NOT
|
||||
MOD
|
||||
};
|
||||
|
||||
//A single modifier operation
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#ifndef CONFIG
|
||||
#define CONFIG
|
||||
|
||||
#define VERSION 138
|
||||
#define VERSION 139
|
||||
|
||||
//try to keep this in sync.
|
||||
//SavvyCAN will complain if you connect a GVRET board with a revision
|
||||
//less than this number.
|
||||
#define CURRENT_GVRET_VER 325
|
||||
#define CURRENT_GVRET_VER 325 //330 is the newest but it is WIP
|
||||
|
||||
#endif // CONFIG
|
||||
|
||||
|
||||
+33
-11
@@ -412,9 +412,8 @@ void FrameSenderWindow::doModifiers(int idx)
|
||||
case XOR:
|
||||
shadowReg = first ^ second;
|
||||
break;
|
||||
case NOT:
|
||||
shadowReg = !shadowReg;
|
||||
break;
|
||||
case MOD:
|
||||
shadowReg = first % second;
|
||||
}
|
||||
}
|
||||
//Finally, drop the result into the proper data byte
|
||||
@@ -427,18 +426,21 @@ int FrameSenderWindow::fetchOperand(int idx, ModifierOperand op)
|
||||
CANFrame *tempFrame = NULL;
|
||||
if (op.ID == 0) //numeric constant
|
||||
{
|
||||
return op.databyte;
|
||||
if (op.notOper) return ~op.databyte;
|
||||
else return op.databyte;
|
||||
}
|
||||
else if (op.ID == -2)
|
||||
{
|
||||
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 //look up external data byte
|
||||
{
|
||||
tempFrame = lookupFrame(op.ID, op.bus);
|
||||
if (tempFrame != NULL)
|
||||
{
|
||||
return tempFrame->data[op.databyte];
|
||||
if (op.notOper) return ~tempFrame->data[op.databyte];
|
||||
else return tempFrame->data[op.databyte];
|
||||
}
|
||||
else return 0;
|
||||
}
|
||||
@@ -497,15 +499,30 @@ void FrameSenderWindow::processModifierText(int line)
|
||||
thisMod.destByte = leftSide.right(1).toInt();
|
||||
thisMod.operations.clear();
|
||||
}
|
||||
else continue;
|
||||
if (!(Utility::grabOperation(mods[i]) == "=")) continue;
|
||||
else
|
||||
{
|
||||
qDebug() << "Something wrong with lefthand val";
|
||||
continue;
|
||||
}
|
||||
if (!(Utility::grabOperation(mods[i]) == "="))
|
||||
{
|
||||
qDebug() << "Err: No = after lefthand val";
|
||||
continue;
|
||||
}
|
||||
abort = false;
|
||||
while (!abort)
|
||||
{
|
||||
QString token = Utility::grabAlphaNumeric(mods[i]);
|
||||
ModifierOp thisOp;
|
||||
|
||||
if (firstOp)
|
||||
{
|
||||
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;
|
||||
}
|
||||
@@ -519,6 +536,7 @@ void FrameSenderWindow::processModifierText(int line)
|
||||
thisOp.operation = ADDITION;
|
||||
thisOp.second.ID = 0;
|
||||
thisOp.second.databyte = 0;
|
||||
thisOp.second.notOper = false;
|
||||
thisMod.operations.append(thisOp);
|
||||
}
|
||||
else //otherwise try to grab them
|
||||
@@ -532,6 +550,12 @@ void FrameSenderWindow::processModifierText(int line)
|
||||
{
|
||||
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);
|
||||
@@ -661,11 +685,9 @@ ModifierOperationType FrameSenderWindow::parseOperation(QString op)
|
||||
if (op == "*") return MULTIPLICATION;
|
||||
if (op == "/") return DIVISION;
|
||||
if (op == "&") return AND;
|
||||
if (op == "AND") return AND;
|
||||
if (op == "|") return OR;
|
||||
if (op == "OR") return OR;
|
||||
if (op == "^") return XOR;
|
||||
if (op == "XOR") return XOR;
|
||||
if (op == "%") return MOD;
|
||||
return ADDITION;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,8 +5,7 @@
|
||||
#include <stdint.h>
|
||||
#include <QByteArray>
|
||||
#include <QDateTime>
|
||||
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
class Utility
|
||||
{
|
||||
@@ -82,13 +81,17 @@ public:
|
||||
for (int i = 0; i < input.length(); i++)
|
||||
{
|
||||
thisChar = input[i];
|
||||
if (thisChar.isLetterOrNumber() || thisChar == ':') builder.append(input[i]);
|
||||
if (thisChar.isLetterOrNumber() || thisChar == ':' || thisChar == '~') builder.append(input[i]);
|
||||
else
|
||||
{
|
||||
input = input.right(input.length() - i);
|
||||
//qDebug() << "i: "<< i << " len: " << input.length();
|
||||
if (i < (input.length() - 1)) input = input.right(input.length() - i);
|
||||
else input = "";
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
//qDebug() << "Reached end of string in grabAlphaNumeric";
|
||||
input = "";
|
||||
return builder;
|
||||
}
|
||||
|
||||
@@ -97,7 +100,7 @@ public:
|
||||
QString builder;
|
||||
QChar thisChar = input[0];
|
||||
|
||||
if (thisChar == '+' || thisChar == '-' || thisChar == '*' || thisChar == '/' || thisChar == '^' || thisChar == '&' || thisChar == '|' || thisChar == '=')
|
||||
if (thisChar == '+' || thisChar == '-' || thisChar == '*' || thisChar == '/' || thisChar == '^' || thisChar == '&' || thisChar == '|' || thisChar == '=' || thisChar == '%')
|
||||
{
|
||||
input = input.right(input.length() - 1);
|
||||
builder = thisChar;
|
||||
|
||||
Reference in New Issue
Block a user