73 lines
2.8 KiB
C++
73 lines
2.8 KiB
C++
#ifndef HELPERS_H
|
|
#define HELPERS_H
|
|
|
|
#include <QString>
|
|
#include <QStringList>
|
|
#include <QSettings>
|
|
#include <QTimer>
|
|
#include <QCoreApplication>
|
|
#include <QThread>
|
|
#include <QList>
|
|
#include <QVector>
|
|
#include <QFile>
|
|
#include <QTextStream>
|
|
#include <cstdint>
|
|
#include <cstring> // for std::memcpy
|
|
#include "datareceiver.h"
|
|
#include <iostream>
|
|
#include <bitset>
|
|
|
|
void BYTE2SD(char* mybuffer, BufferData::SensorData& data);
|
|
void printBufferBits(const char* buffer, size_t size) ;
|
|
uint8_t reverseBits(uint8_t byte);
|
|
void invertBits(char* buffer, size_t size);
|
|
void swapEndian(char* buffer, size_t size);
|
|
|
|
|
|
//byte array <-> unsiged short conversion
|
|
#define SHORT2BYTES(sh,by) {by[0] = (sh>>8) & 0xFF; by[1] = sh & 0xFF;}
|
|
#define LO(x) (x & 0xFF)
|
|
#define HI(x) ((x>>8) & 0xFF)
|
|
#define BYTES2SHORT(by) ( ((unsigned short)(unsigned char)((by)[0]) << 8) | ((unsigned short)(unsigned char)((by)[1])) ) //safe way
|
|
#define BYTES2SIGNSHORT(by) ( *((signed short*)by) ) //faster
|
|
#define BYTES2SIGNEDSHORT(by) \
|
|
( \
|
|
(static_cast<short>(static_cast<unsigned char>((by)[0])) << 8) | \
|
|
(static_cast<short>(static_cast<unsigned char>((by)[1]))) \
|
|
)
|
|
//convert textual representation of IP to array of numbers and/or well-formatted string
|
|
#define BYTES2INT(by) \
|
|
( \
|
|
(static_cast<unsigned char>((by)[0]) << 24) | \
|
|
(static_cast<unsigned char>((by)[1]) << 16) | \
|
|
(static_cast<unsigned char>((by)[2]) << 8) | \
|
|
(static_cast<unsigned char>((by)[3]))\
|
|
)
|
|
#define BYTES2INT64(by) \
|
|
( \
|
|
(static_cast<uint64_t>(static_cast<unsigned char>((by)[0])) << 56) | \
|
|
(static_cast<uint64_t>(static_cast<unsigned char>((by)[1])) << 48) | \
|
|
(static_cast<uint64_t>(static_cast<unsigned char>((by)[2])) << 40) | \
|
|
(static_cast<uint64_t>(static_cast<unsigned char>((by)[3])) << 32) | \
|
|
(static_cast<uint64_t>(static_cast<unsigned char>((by)[4])) << 24) | \
|
|
(static_cast<uint64_t>(static_cast<unsigned char>((by)[5])) << 16) | \
|
|
(static_cast<uint64_t>(static_cast<unsigned char>((by)[6])) << 8) | \
|
|
(static_cast<uint64_t>(static_cast<unsigned char>((by)[7])) ) \
|
|
)
|
|
QString ip2num(QString input, unsigned char* numbers = NULL);
|
|
|
|
//go to the main branch of settings
|
|
void top (QSettings* settings);
|
|
|
|
//copy settings table
|
|
void copyQSettings(QSettings* from, QSettings* to);
|
|
|
|
//sleep with processing queues
|
|
void msleep2(unsigned int ms, unsigned int resolution = 10);
|
|
|
|
//Save data in form of CSV file. The three tables should have the same number of rows. They will be concatenated. Sensormean and sensorstd will be interlaced.
|
|
void saveCsvFile(QString filename, QList<QVector<double>> params, QList<QVector<double>> sensormean, QList<QVector<double>> sensorstd, QString delimiter = QString(","));
|
|
|
|
#endif // HELPERS_H
|
|
|