Fix up some faulty variable definitions and clarify others.

This commit is contained in:
Collin Kidder
2015-11-23 09:19:47 -05:00
parent a6198bc20f
commit 1d89fe576e
3 changed files with 26 additions and 26 deletions
+18 -18
View File
@@ -798,7 +798,7 @@ void GraphingWindow::addNewGraph()
void GraphingWindow::appendToGraph(GraphParams &params, CANFrame &frame)
{
long long tempVal; //64 bit temp value.
int64_t tempVal; //64 bit temp value.
if (params.endByte == -1 || params.startByte == params.endByte)
{
tempVal = (frame.data[params.startByte] & params.mask);
@@ -819,13 +819,13 @@ void GraphingWindow::appendToGraph(GraphParams &params, CANFrame &frame)
else if (params.endByte > params.startByte) //big endian
{
float tempValue;
long long tempValInt;
int64_t tempValInt;
int numBytes = (params.endByte - params.startByte) + 1;
long long shiftRef = 1 << (numBytes * 8);
int64_t shiftRef = 1 << (numBytes * 8);
uint64_t maskShifter;
uint8_t tempByte;
tempValInt = 0;
long long expon = 1;
int64_t expon = 1;
maskShifter = params.mask;
for (int c = 0; c < numBytes; c++)
{
@@ -838,7 +838,7 @@ void GraphingWindow::appendToGraph(GraphParams &params, CANFrame &frame)
tempValInt &= params.mask;
long long twocompPoint = params.mask;
int64_t twocompPoint = params.mask;
if (shiftRef < twocompPoint || twocompPoint == -1) twocompPoint = shiftRef;
//qDebug() << "two comp point: " << twocompPoint;
if (params.isSigned && tempValInt > ((twocompPoint / 2)))
@@ -862,13 +862,13 @@ void GraphingWindow::appendToGraph(GraphParams &params, CANFrame &frame)
else //little endian
{
float tempValue;
long long tempValInt;
int64_t tempValInt;
int numBytes = (params.startByte - params.endByte) + 1;
long long shiftRef = 1 << (numBytes * 8);
int64_t shiftRef = 1 << (numBytes * 8);
uint64_t maskShifter;
uint8_t tempByte;
tempValInt = 0;
long long expon = 1;
int64_t expon = 1;
maskShifter = params.mask;
for (int c = 0; c < numBytes; c++)
{
@@ -880,7 +880,7 @@ void GraphingWindow::appendToGraph(GraphParams &params, CANFrame &frame)
}
tempValInt &= params.mask;
long long twocompPoint = params.mask;
int64_t twocompPoint = params.mask;
if (shiftRef < twocompPoint || twocompPoint == -1) twocompPoint = shiftRef;
//qDebug() << "two comp point: " << twocompPoint;
if (params.isSigned && tempValInt > ((twocompPoint / 2)))
@@ -907,7 +907,7 @@ void GraphingWindow::appendToGraph(GraphParams &params, CANFrame &frame)
void GraphingWindow::createGraph(GraphParams &params, bool createGraphParam)
{
long long tempVal; //64 bit temp value.
int64_t tempVal; //64 bit temp value.
float yminval=10000000.0, ymaxval = -1000000.0;
float xminval=10000000000.0, xmaxval = -10000000000.0;
GraphParams *refParam = &params;
@@ -958,15 +958,15 @@ void GraphingWindow::createGraph(GraphParams &params, bool createGraphParam)
else if (params.endByte > params.startByte) //big endian
{
float tempValue;
long long tempValInt;
int64_t tempValInt;
int numBytes = (params.endByte - params.startByte) + 1;
long long shiftRef = 1 << (numBytes * 8);
int64_t shiftRef = 1 << (numBytes * 8);
uint64_t maskShifter;
uint8_t tempByte;
for (int j = 0; j < numEntries; j++)
{
tempValInt = 0;
long long expon = 1;
int64_t expon = 1;
maskShifter = params.mask;
for (int c = 0; c < numBytes; c++)
{
@@ -979,7 +979,7 @@ void GraphingWindow::createGraph(GraphParams &params, bool createGraphParam)
tempValInt &= params.mask;
long long twocompPoint = params.mask;
int64_t twocompPoint = params.mask;
if (shiftRef < twocompPoint || twocompPoint == -1) twocompPoint = shiftRef;
//qDebug() << "two comp point: " << twocompPoint;
if (params.isSigned && tempValInt > ((twocompPoint / 2)))
@@ -1008,15 +1008,15 @@ void GraphingWindow::createGraph(GraphParams &params, bool createGraphParam)
else //little endian
{
float tempValue;
long long tempValInt;
int64_t tempValInt;
int numBytes = (params.startByte - params.endByte) + 1;
long long shiftRef = 1 << (numBytes * 8);
int64_t shiftRef = 1 << (numBytes * 8);
uint64_t maskShifter;
uint8_t tempByte;
for (int j = 0; j < numEntries; j++)
{
tempValInt = 0;
long long expon = 1;
int64_t expon = 1;
maskShifter = params.mask;
for (int c = 0; c < numBytes; c++)
{
@@ -1028,7 +1028,7 @@ void GraphingWindow::createGraph(GraphParams &params, bool createGraphParam)
}
tempValInt &= params.mask;
long long twocompPoint = params.mask;
int64_t twocompPoint = params.mask;
if (shiftRef < twocompPoint || twocompPoint == -1) twocompPoint = shiftRef;
//qDebug() << "two comp point: " << twocompPoint;
if (params.isSigned && tempValInt > ((twocompPoint / 2)))
+2 -2
View File
@@ -14,10 +14,10 @@ class GraphingWindow;
class GraphParams
{
public:
int32_t ID;
uint32_t ID;
int startByte, endByte;
bool isSigned;
int32_t mask;
uint64_t mask;
float bias;
float scale;
int stride;
+6 -6
View File
@@ -13,33 +13,33 @@ public:
static bool decimalMode;
static int ParseStringToNum(QByteArray input)
static uint64_t ParseStringToNum(QByteArray input)
{
int temp = 0;
uint64_t temp = 0;
input = input.toUpper();
if (input.startsWith("0X") || input.startsWith("X")) //hex number
{
if (input.length() < 3) temp = 0;
else temp = input.right(input.size() - 2).toInt(NULL, 16);
else temp = input.right(input.size() - 2).toLongLong(NULL, 16);
}
else if (input.startsWith("B")) //binary number
{
input = input.right(input.size() - 1); //remove the B
for (int i = 0; i < input.length(); i++)
{
if (input[i] == '1') temp += 1 << (input.length() - i - 1);
if (input[i] == '1') temp += (uint64_t)1 << (input.length() - i - 1);
}
}
else //decimal number
{
temp = input.toInt();
temp = input.toLongLong();
}
return temp;
}
static int ParseStringToNum(QString input)
static uint64_t ParseStringToNum(QString input)
{
return ParseStringToNum(input.toUtf8());
}