From 1300ca645745394839a2532f05863165e6193bb2 Mon Sep 17 00:00:00 2001 From: Collin Kidder Date: Sun, 22 Nov 2015 10:27:17 -0500 Subject: [PATCH] Fix up some faulty variable definitions and clarify others. --- graphingwindow.cpp | 36 ++++++++++++++++++------------------ graphingwindow.h | 4 ++-- utility.h | 12 ++++++------ 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/graphingwindow.cpp b/graphingwindow.cpp index f1a9fc6..5712824 100644 --- a/graphingwindow.cpp +++ b/graphingwindow.cpp @@ -798,7 +798,7 @@ void GraphingWindow::addNewGraph() void GraphingWindow::appendToGraph(GraphParams ¶ms, 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 ¶ms, 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 ¶ms, 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 ¶ms, 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 ¶ms, 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 ¶ms, CANFrame &frame) void GraphingWindow::createGraph(GraphParams ¶ms, 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 = ¶ms; @@ -958,15 +958,15 @@ void GraphingWindow::createGraph(GraphParams ¶ms, 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 ¶ms, 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 ¶ms, 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 ¶ms, 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))) diff --git a/graphingwindow.h b/graphingwindow.h index fb96302..7c29e70 100644 --- a/graphingwindow.h +++ b/graphingwindow.h @@ -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; diff --git a/utility.h b/utility.h index 8d68ce8..9e86fa7 100644 --- a/utility.h +++ b/utility.h @@ -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()); }