#include <QDebug>
-const std::vector<OutputFormat> DataFileExporter::SUPPORTED_FORMATS = { OutputFormat("Comma separated values", "csv") };
+const OutputFormat DataFileExporter::SUPPORTED_FORMATS[] = { OutputFormat("Comma separated values", "csv") };
/* Static methods */
QStringList DataFileExporter::supportedFormats()
DataFileExporter::ReturnCode ret;
DataWriterBackend* backend;
- if (formatIdx < 0 || formatIdx >= SUPPORTED_FORMATS.size()) {
+ if (formatIdx < 0 || formatIdx >= sizeof(SUPPORTED_FORMATS)) {
return ReturnCode::E_INVAL_FORMAT;
}
switch (idx) {
case 0:
return OutputFormats::CSV;
+ default:
+ return OutputFormats::INVALID;
}
}
if (suffix.length() == 0)
return;
- for (size_t i = 0; i < SUPPORTED_FORMATS.size(); i++) {
- const OutputFormat& of = SUPPORTED_FORMATS.at(i);
+ for (size_t i = 0; i < sizeof(SUPPORTED_FORMATS); i++) {
+ const OutputFormat& of = SUPPORTED_FORMATS[i];
if (suffix.compare(of.second) == 0) {
emit formatChanged(i);
return;
static QStringList supportedFormats();
private:
enum class OutputFormats {
- CSV
+ CSV,
+ INVALID
};
OutputFormats formatIdxToFormat(const int idx);
QString toCSVLine(double time, double value);
ReturnCode writeToFile(QFile& file, const DataWriterBackend* writer, const std::pair<QVariantList, std::vector<QVariantList>>& data);
- static const std::vector<OutputFormat> SUPPORTED_FORMATS;
+ static const OutputFormat SUPPORTED_FORMATS[];
signals:
void formatChanged(const int idx);
#include "libHPCS/libhpcs.h"
#include <QtCore/QDir>
#include <QtCore/QObject>
+#include <vector>
class DataFilesLoader : public QObject
{
#include <QDebug>
const QString DataManager::ME_SENDER_STR("DataManager");
-const QString DataManager::UNIT_DEGREES_CELSIUS_TEXT = QString::fromLatin1((const char[]){static_cast<char>(0xB0), 0x43, 0x00});
-const QString DataManager::UNIT_KILOVOLTS_TEXT = QString::fromLatin1((const char[]){0x4B, 0x56, 0x00});
-const QString DataManager::UNIT_KILOVOLTS_ALT1_TEXT = QString::fromLatin1((const char[]){0x6B, 0x56, 0x00});
-const QString DataManager::UNIT_MICROAMPERES_TEXT = QString::fromLatin1((const char[]){static_cast<char>(0xB5), 0x41, 0x00});
-const QString DataManager::UNIT_MICROAMPERES_ALT1_TEXT = QString::fromLatin1((const char[]){0x75, 0x41, 0x00});
-const QString DataManager::UNIT_MILLIAU_TEXT = QString::fromLatin1((const char[]){0x6D, 0x41, 0x55, 0x00});
-const QString DataManager::UNIT_MILLIBARS_TEXT = QString::fromLatin1((const char[]){0x6D, 0x62, 0x61, 0x72, 0x00});
-const QString DataManager::UNIT_MILLIVOLTS_TEXT = QString::fromLatin1((const char[]){0x6D, 0x56, 0x00});
-const QString DataManager::UNIT_WATTS_TEXT = QString::fromLatin1((const char[]){0x57, 0x00});
+const char DataManager::UNIT_DEGREES_CELSIUS_TEXT[] = {static_cast<char>(0xB0), 0x43, 0x00};
+const char DataManager::UNIT_KILOVOLTS_TEXT[] = {0x4B, 0x56, 0x00};
+const char DataManager::UNIT_KILOVOLTS_ALT1_TEXT[] = {0x6B, 0x56, 0x00};
+const char DataManager::UNIT_MICROAMPERES_TEXT[] = {static_cast<char>(0xB5), 0x41, 0x00};
+const char DataManager::UNIT_MICROAMPERES_ALT1_TEXT[] = {0x75, 0x41, 0x00};
+const char DataManager::UNIT_MILLIAU_TEXT[] = {0x6D, 0x41, 0x55, 0x00};
+const char DataManager::UNIT_MILLIBARS_TEXT[] = {0x6D, 0x62, 0x61, 0x72, 0x00};
+const char DataManager::UNIT_MILLIVOLTS_TEXT[] = {0x6D, 0x56, 0x00};
+const char DataManager::UNIT_WATTS_TEXT[] = {0x57, 0x00};
const QStringList DataManager::DATA_DIR_SUFFIX = QStringList() << "*.D";
const QString DataManager::S_RES_DATAEXPORT("Error while exporting data to file");
const QString DataManager::S_RES_IMGEXPORT("Error while exporting graph to image");
return std::string(main.toStdString() + "_" + resource.toStdString());
}
-Signal::YUnit DataManager::yunitFromUnitStr(const char* unit_str)
+Signal::YUnit DataManager::yunitFromUnitStr(const char* str)
{
- QString str = m_sigNameCodec->toUnicode(unit_str);
-
- if (QString::compare(str, UNIT_DEGREES_CELSIUS_TEXT) == 0)
+ if (strcmp(str, UNIT_DEGREES_CELSIUS_TEXT) == 0)
return Signal::YUnit::DEGREES_CELSIUS;
- else if (QString::compare(str, UNIT_KILOVOLTS_TEXT) == 0 ||
- QString::compare(str, UNIT_KILOVOLTS_ALT1_TEXT) == 0)
+ else if (strcmp(str, UNIT_KILOVOLTS_TEXT) == 0 ||
+ strcmp(str, UNIT_KILOVOLTS_ALT1_TEXT) == 0)
return Signal::YUnit::KILOVOLTS;
- else if (QString::compare(str, UNIT_MICROAMPERES_TEXT) == 0 ||
- QString::compare(str, UNIT_MICROAMPERES_ALT1_TEXT) == 0)
+ else if (strcmp(str, UNIT_MICROAMPERES_TEXT) == 0 ||
+ strcmp(str, UNIT_MICROAMPERES_ALT1_TEXT) == 0)
return Signal::YUnit::MICROAMPERES;
- else if (QString::compare(str, UNIT_MILLIAU_TEXT) == 0)
+ else if (strcmp(str, UNIT_MILLIAU_TEXT) == 0)
return Signal::YUnit::MILLIAU;
- else if (QString::compare(str, UNIT_MILLIBARS_TEXT) == 0)
+ else if (strcmp(str, UNIT_MILLIBARS_TEXT) == 0)
return Signal::YUnit::MILLIBARS;
- else if (QString::compare(str, UNIT_MILLIVOLTS_TEXT) == 0)
+ else if (strcmp(str, UNIT_MILLIVOLTS_TEXT) == 0)
return Signal::YUnit::MILLIVOLTS;
- else if (QString::compare(str, UNIT_WATTS_TEXT) == 0)
+ else if (strcmp(str, UNIT_WATTS_TEXT) == 0)
return Signal::YUnit::WATTS;
else
- throw std::invalid_argument(str.toStdString());
+ throw std::invalid_argument(std::string(str));
}
std::shared_ptr<SingleRunData> DataManager::loadSingleRun(QDir& dir)
bool saveSingleRunUserData(std::shared_ptr<SingleRunData> sr);
std::string signalControllerKey(const QString& main, const QString& resource);
void showOneSignal(std::shared_ptr<SignalController> ctrl);
- Signal::YUnit yunitFromUnitStr(const char* unit_str);
+ Signal::YUnit yunitFromUnitStr(const char* str);
std::shared_ptr<Sequence> m_activeSequence;
QString m_prevSequenceKey;
ExportGraphToImageDialog m_graphToImageExportDialog;
static const QString ME_SENDER_STR;
- static const QString UNIT_DEGREES_CELSIUS_TEXT;
- static const QString UNIT_KILOVOLTS_TEXT;
- static const QString UNIT_KILOVOLTS_ALT1_TEXT;
- static const QString UNIT_MICROAMPERES_TEXT;
- static const QString UNIT_MICROAMPERES_ALT1_TEXT;
- static const QString UNIT_MILLIAU_TEXT;
- static const QString UNIT_MILLIBARS_TEXT;
- static const QString UNIT_MILLIVOLTS_TEXT;
- static const QString UNIT_WATTS_TEXT;
+ static const char UNIT_DEGREES_CELSIUS_TEXT[];
+ static const char UNIT_KILOVOLTS_TEXT[];
+ static const char UNIT_KILOVOLTS_ALT1_TEXT[];
+ static const char UNIT_MICROAMPERES_TEXT[];
+ static const char UNIT_MICROAMPERES_ALT1_TEXT[];
+ static const char UNIT_MILLIAU_TEXT[];
+ static const char UNIT_MILLIBARS_TEXT[];
+ static const char UNIT_MILLIVOLTS_TEXT[];
+ static const char UNIT_WATTS_TEXT[];
static const QStringList DATA_DIR_SUFFIX;
#include "ui_exportgraphtoimagedialog.h"
#include <QtCore/QLocale>
#include <QtWidgets/QFileDialog>
+#include <tuple>
/* Public functions */
*/
#include "integratedpeak.h"
+#include <QtCore/QVariant>
#include <QtCore/QJsonObject>
const QString IntegratedPeak::KEY_AUC("auc");
return true;
}
+template <typename T> QJsonValue IntegratedPeak::fromQVariant(T value) const
+{
+ return QJsonValue::fromVariant(QVariant(value));
+}
+
double IntegratedPeak::height() const
{
return fabs(m_peakY - (baselineSlope() * (m_peakIdx - m_fromIdx) + m_fromY));
QString type = (m_type == Type::PEAK) ? "PEAK" : "VALLEY";
jso.insert(KEY_AUC, QJsonValue(m_auc));
- jso.insert(KEY_FROMIDX, QJsonValue(static_cast<qint64>(m_fromIdx)));
+ jso.insert(KEY_FROMIDX, QJsonValue(fromQVariant(static_cast<quint64>(m_fromIdx))));
jso.insert(KEY_FROMTIME, QJsonValue(m_fromTime));
jso.insert(KEY_FROMY, QJsonValue(m_fromY));
jso.insert(KEY_ITYPE, QJsonValue( (m_itype == IntegrationType::BASELINE) ? true : false) );
- jso.insert(KEY_PEAKIDX, QJsonValue(static_cast<qint64>(m_peakIdx)));
+ jso.insert(KEY_PEAKIDX, QJsonValue(fromQVariant(static_cast<quint64>(m_peakIdx))));
jso.insert(KEY_PEAKTIME, QJsonValue(m_peakTime));
jso.insert(KEY_PEAKY, QJsonValue(m_peakY));
- jso.insert(KEY_TOIDX, QJsonValue(static_cast<qint64>(m_toIdx)));
+ jso.insert(KEY_TOIDX, QJsonValue(fromQVariant(static_cast<quint64>(m_toIdx))));
jso.insert(KEY_TOTIME, QJsonValue(m_toTime));
jso.insert(KEY_TOY, QJsonValue(m_toY));
jso.insert(KEY_TYPE, QJsonValue(type));
virtual QJsonValue serialize() const;
private:
+ template <typename T> QJsonValue fromQVariant(T val) const;
+
double m_auc;
size_t m_fromIdx;
double m_fromTime;
#include <QtCore/QObject>
#include <QtCore/QDateTime>
+#ifdef WIN32
+#define __func__ __FUNCTION__
+#endif
+
#define __QFUNC__ QString(__func__) + QString("()")
class LocalLogger;
diffRel = to - from;
switch (axis) {
- case Axis::TIME:
- fromAbs = m_signal->timeAt(relToIdx(from));
- toAbs = m_signal->timeAt(relToIdx(to));
- break;
- case Axis::VALUE:
- fromAbs = relToValue(from);
- toAbs = relToValue(to);
- break;
+ case Axis::TIME:
+ fromAbs = m_signal->timeAt(relToIdx(from));
+ toAbs = m_signal->timeAt(relToIdx(to));
+ break;
+ case Axis::VALUE:
+ fromAbs = relToValue(from);
+ toAbs = relToValue(to);
+ break;
+ default:
+ return RulerDrawData();
}
/* Calculate step */