Fleshed out more importers, added some preliminaries for serial port support.

This commit is contained in:
Collin Kidder
2015-04-27 20:47:57 -04:00
parent 6a646cb31b
commit 0268e36d26
7 changed files with 231 additions and 12 deletions
+45
View File
@@ -0,0 +1,45 @@
#ifndef UTILITY_H
#define UTILITY_H
#include <QByteArray>
#include <QDateTime>
class Utility
{
public:
static int ParseStringToNum(QByteArray input)
{
int temp = 0;
input = input.toUpper();
if (input.startsWith("0X")) //hex number
{
temp = input.right(input.size() - 2).toInt(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);
}
}
else //decimal number
{
temp = input.toInt();
}
return temp;
}
static long GetTimeMS()
{
QDateTime stamp = QDateTime::currentDateTime();
return (long)(((stamp.time().hour() * 3600) + (stamp.time().minute() * 60) + (stamp.time().second()) * 1000) + stamp.time().msec());
}
};
#endif // UTILITY_H