mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-03-09 13:59:45 -04:00
SID: Fix crash when loading data from .csv.
This commit is contained in:
parent
aa65bd5b39
commit
86ac92e63e
@ -167,9 +167,9 @@ SIDGUI::SIDGUI(PluginAPI* pluginAPI, FeatureUISet *featureUISet, Feature *featur
|
|||||||
setAttribute(Qt::WA_DeleteOnClose, true);
|
setAttribute(Qt::WA_DeleteOnClose, true);
|
||||||
m_helpURL = "plugins/feature/sid/readme.md";
|
m_helpURL = "plugins/feature/sid/readme.md";
|
||||||
RollupContents *rollupContents = getRollupContents();
|
RollupContents *rollupContents = getRollupContents();
|
||||||
ui->setupUi(rollupContents);
|
ui->setupUi(rollupContents);
|
||||||
rollupContents->arrangeRollups();
|
rollupContents->arrangeRollups();
|
||||||
connect(rollupContents, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool)));
|
connect(rollupContents, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool)));
|
||||||
|
|
||||||
m_sid = reinterpret_cast<SIDMain*>(feature);
|
m_sid = reinterpret_cast<SIDMain*>(feature);
|
||||||
m_sid->setMessageQueueToGUI(&m_inputMessageQueue);
|
m_sid->setMessageQueueToGUI(&m_inputMessageQueue);
|
||||||
@ -257,8 +257,8 @@ SIDGUI::SIDGUI(PluginAPI* pluginAPI, FeatureUISet *featureUISet, Feature *featur
|
|||||||
m_stix = STIX::create();
|
m_stix = STIX::create();
|
||||||
if (m_stix)
|
if (m_stix)
|
||||||
{
|
{
|
||||||
connect(m_stix, &STIX::dataUpdated, this, &SIDGUI::stixDataUpdated);
|
connect(m_stix, &STIX::dataUpdated, this, &SIDGUI::stixDataUpdated);
|
||||||
m_stix->getDataPeriodically();
|
m_stix->getDataPeriodically();
|
||||||
}
|
}
|
||||||
|
|
||||||
plotChart();
|
plotChart();
|
||||||
@ -448,7 +448,7 @@ void SIDGUI::onMenuDialogCalled(const QPoint &p)
|
|||||||
"reverseAPIPort",
|
"reverseAPIPort",
|
||||||
"reverseAPIDeviceIndex",
|
"reverseAPIDeviceIndex",
|
||||||
"reverseAPIChannelIndex"
|
"reverseAPIChannelIndex"
|
||||||
});
|
});
|
||||||
|
|
||||||
applySettings(m_settingsKeys);
|
applySettings(m_settingsKeys);
|
||||||
}
|
}
|
||||||
@ -689,7 +689,7 @@ void SIDGUI::createProtonSeries(QChart *chart, QDateTimeAxis *xAxis, QLogValueAx
|
|||||||
yAxis->setVisible(!secondaryAxis || m_settings.m_displaySecondaryAxis);
|
yAxis->setVisible(!secondaryAxis || m_settings.m_displaySecondaryAxis);
|
||||||
|
|
||||||
for (int i = 0; i < 4; i += 2) // Only plot 10 and 100 MeV so graph isn't too cluttered
|
for (int i = 0; i < 4; i += 2) // Only plot 10 and 100 MeV so graph isn't too cluttered
|
||||||
//for (int i = 0; i < 4; i++)
|
//for (int i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
m_protonMeasurements[i].m_series = new QLineSeries();
|
m_protonMeasurements[i].m_series = new QLineSeries();
|
||||||
m_protonMeasurements[i].m_series->setName(QString("%1 Proton").arg(SIDGUI::m_protonEnergies[i]));
|
m_protonMeasurements[i].m_series->setName(QString("%1 Proton").arg(SIDGUI::m_protonEnergies[i]));
|
||||||
@ -1041,21 +1041,21 @@ void SIDGUI::showGRBContextMenu(QContextMenuEvent *contextEvent, QChartView *cha
|
|||||||
QAction* fermiDataAction = new QAction("View Fermi data directory...", contextMenu);
|
QAction* fermiDataAction = new QAction("View Fermi data directory...", contextMenu);
|
||||||
connect(fermiDataAction, &QAction::triggered, this, [url]()->void {
|
connect(fermiDataAction, &QAction::triggered, this, [url]()->void {
|
||||||
QDesktopServices::openUrl(QUrl(url));
|
QDesktopServices::openUrl(QUrl(url));
|
||||||
});
|
});
|
||||||
contextMenu->addAction(fermiDataAction);
|
contextMenu->addAction(fermiDataAction);
|
||||||
|
|
||||||
QString plotURL = m_grbData[closestPoint].getFermiPlotURL();
|
QString plotURL = m_grbData[closestPoint].getFermiPlotURL();
|
||||||
QAction* fermiPlotAction = new QAction("View Fermi data plot...", contextMenu);
|
QAction* fermiPlotAction = new QAction("View Fermi data plot...", contextMenu);
|
||||||
connect(fermiPlotAction, &QAction::triggered, this, [plotURL]()->void {
|
connect(fermiPlotAction, &QAction::triggered, this, [plotURL]()->void {
|
||||||
QDesktopServices::openUrl(QUrl(plotURL));
|
QDesktopServices::openUrl(QUrl(plotURL));
|
||||||
});
|
});
|
||||||
contextMenu->addAction(fermiPlotAction);
|
contextMenu->addAction(fermiPlotAction);
|
||||||
|
|
||||||
QString mapURL = m_grbData[closestPoint].getFermiSkyMapURL();
|
QString mapURL = m_grbData[closestPoint].getFermiSkyMapURL();
|
||||||
QAction* fermiMapDataAction = new QAction("View Fermi sky map...", contextMenu);
|
QAction* fermiMapDataAction = new QAction("View Fermi sky map...", contextMenu);
|
||||||
connect(fermiMapDataAction, &QAction::triggered, this, [mapURL]()->void {
|
connect(fermiMapDataAction, &QAction::triggered, this, [mapURL]()->void {
|
||||||
QDesktopServices::openUrl(QUrl(mapURL));
|
QDesktopServices::openUrl(QUrl(mapURL));
|
||||||
});
|
});
|
||||||
contextMenu->addAction(fermiMapDataAction);
|
contextMenu->addAction(fermiMapDataAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1066,7 +1066,7 @@ void SIDGUI::showGRBContextMenu(QContextMenuEvent *contextEvent, QChartView *cha
|
|||||||
QString switftURL = m_grbData[closestPoint].getSwiftURL();
|
QString switftURL = m_grbData[closestPoint].getSwiftURL();
|
||||||
connect(swiftDataAction, &QAction::triggered, this, [switftURL]()->void {
|
connect(swiftDataAction, &QAction::triggered, this, [switftURL]()->void {
|
||||||
QDesktopServices::openUrl(QUrl(switftURL));
|
QDesktopServices::openUrl(QUrl(switftURL));
|
||||||
});
|
});
|
||||||
contextMenu->addAction(swiftDataAction);
|
contextMenu->addAction(swiftDataAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1083,7 +1083,7 @@ void SIDGUI::showGRBContextMenu(QContextMenuEvent *contextEvent, QChartView *cha
|
|||||||
float dec = m_grbData[closestPoint].m_dec;
|
float dec = m_grbData[closestPoint].m_dec;
|
||||||
connect(skyMapAction, &QAction::triggered, this, [this, skymap, ra, dec]()->void {
|
connect(skyMapAction, &QAction::triggered, this, [this, skymap, ra, dec]()->void {
|
||||||
sendToSkyMap(skymap, ra, dec);
|
sendToSkyMap(skymap, ra, dec);
|
||||||
});
|
});
|
||||||
contextMenu->addAction(skyMapAction);
|
contextMenu->addAction(skyMapAction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1095,7 +1095,7 @@ void SIDGUI::showGRBContextMenu(QContextMenuEvent *contextEvent, QChartView *cha
|
|||||||
QString target = QString("%1 %2").arg(ra).arg(dec);
|
QString target = QString("%1 %2").arg(ra).arg(dec);
|
||||||
connect(skyMapAction, &QAction::triggered, this, [target]()->void {
|
connect(skyMapAction, &QAction::triggered, this, [target]()->void {
|
||||||
FeatureWebAPIUtils::openSkyMapAndFind(target);
|
FeatureWebAPIUtils::openSkyMapAndFind(target);
|
||||||
});
|
});
|
||||||
contextMenu->addAction(skyMapAction);
|
contextMenu->addAction(skyMapAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1114,14 +1114,14 @@ void SIDGUI::showStixContextMenu(QContextMenuEvent *contextEvent, QChartView *ch
|
|||||||
QAction* lcAction = new QAction("View light curves...", contextMenu);
|
QAction* lcAction = new QAction("View light curves...", contextMenu);
|
||||||
connect(lcAction, &QAction::triggered, this, [lcURL]()->void {
|
connect(lcAction, &QAction::triggered, this, [lcURL]()->void {
|
||||||
QDesktopServices::openUrl(QUrl(lcURL));
|
QDesktopServices::openUrl(QUrl(lcURL));
|
||||||
});
|
});
|
||||||
contextMenu->addAction(lcAction);
|
contextMenu->addAction(lcAction);
|
||||||
|
|
||||||
QString dataURL = m_stixData[closestPoint].getDataURL();
|
QString dataURL = m_stixData[closestPoint].getDataURL();
|
||||||
QAction* stixDataAction = new QAction("View STIX data...", contextMenu);
|
QAction* stixDataAction = new QAction("View STIX data...", contextMenu);
|
||||||
connect(stixDataAction, &QAction::triggered, this, [dataURL]()->void {
|
connect(stixDataAction, &QAction::triggered, this, [dataURL]()->void {
|
||||||
QDesktopServices::openUrl(QUrl(dataURL));
|
QDesktopServices::openUrl(QUrl(dataURL));
|
||||||
});
|
});
|
||||||
contextMenu->addAction(stixDataAction);
|
contextMenu->addAction(stixDataAction);
|
||||||
|
|
||||||
contextMenu->popup(chartView->viewport()->mapToGlobal(contextEvent->pos()));
|
contextMenu->popup(chartView->viewport()->mapToGlobal(contextEvent->pos()));
|
||||||
@ -1525,27 +1525,27 @@ void SIDGUI::updateStatus()
|
|||||||
bool oldState;
|
bool oldState;
|
||||||
switch (state)
|
switch (state)
|
||||||
{
|
{
|
||||||
case Feature::StNotStarted:
|
case Feature::StNotStarted:
|
||||||
ui->startStop->setStyleSheet("QToolButton { background:rgb(79,79,79); }");
|
ui->startStop->setStyleSheet("QToolButton { background:rgb(79,79,79); }");
|
||||||
break;
|
break;
|
||||||
case Feature::StIdle:
|
case Feature::StIdle:
|
||||||
oldState = ui->startStop->blockSignals(true);
|
oldState = ui->startStop->blockSignals(true);
|
||||||
ui->startStop->setChecked(false);
|
ui->startStop->setChecked(false);
|
||||||
ui->startStop->blockSignals(oldState);
|
ui->startStop->blockSignals(oldState);
|
||||||
ui->startStop->setStyleSheet("QToolButton { background-color : blue; }");
|
ui->startStop->setStyleSheet("QToolButton { background-color : blue; }");
|
||||||
break;
|
break;
|
||||||
case Feature::StRunning:
|
case Feature::StRunning:
|
||||||
oldState = ui->startStop->blockSignals(true);
|
oldState = ui->startStop->blockSignals(true);
|
||||||
ui->startStop->setChecked(true);
|
ui->startStop->setChecked(true);
|
||||||
ui->startStop->blockSignals(oldState);
|
ui->startStop->blockSignals(oldState);
|
||||||
ui->startStop->setStyleSheet("QToolButton { background-color : green; }");
|
ui->startStop->setStyleSheet("QToolButton { background-color : green; }");
|
||||||
break;
|
break;
|
||||||
case Feature::StError:
|
case Feature::StError:
|
||||||
ui->startStop->setStyleSheet("QToolButton { background-color : red; }");
|
ui->startStop->setStyleSheet("QToolButton { background-color : red; }");
|
||||||
QMessageBox::critical(this, m_settings.m_title, m_sid->getErrorMessage());
|
QMessageBox::critical(this, m_settings.m_title, m_sid->getErrorMessage());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_lastFeatureState = state;
|
m_lastFeatureState = state;
|
||||||
@ -2396,8 +2396,11 @@ void SIDGUI::readCSV(const QString& filename, bool autoload)
|
|||||||
if (CSV::readRow(in, &colNames))
|
if (CSV::readRow(in, &colNames))
|
||||||
{
|
{
|
||||||
QList<ChannelMeasurement *> measurements;
|
QList<ChannelMeasurement *> measurements;
|
||||||
for (int i = 0; i < colNames.size() - 1; i++) {
|
QList<int> measurementIdx;
|
||||||
|
for (int i = 0; i < colNames.size() - 1; i++)
|
||||||
|
{
|
||||||
measurements.append(nullptr);
|
measurements.append(nullptr);
|
||||||
|
measurementIdx.append(-1);
|
||||||
}
|
}
|
||||||
for (int i = 1; i < colNames.size(); i++)
|
for (int i = 1; i < colNames.size(); i++)
|
||||||
{
|
{
|
||||||
@ -2439,7 +2442,8 @@ void SIDGUI::readCSV(const QString& filename, bool autoload)
|
|||||||
} else {
|
} else {
|
||||||
id = name;
|
id = name;
|
||||||
}
|
}
|
||||||
measurements[i-1] = &addMeasurements(id);
|
addMeasurements(id);
|
||||||
|
measurementIdx[i-1] = m_channelMeasurements.size() - 1;
|
||||||
|
|
||||||
// Create settings, if we don't have them
|
// Create settings, if we don't have them
|
||||||
SIDSettings::ChannelSettings *channelSettings = m_settings.getChannelSettings(id);
|
SIDSettings::ChannelSettings *channelSettings = m_settings.getChannelSettings(id);
|
||||||
@ -2482,7 +2486,11 @@ void SIDGUI::readCSV(const QString& filename, bool autoload)
|
|||||||
if (!valueStr.isEmpty())
|
if (!valueStr.isEmpty())
|
||||||
{
|
{
|
||||||
double value = valueStr.toDouble();
|
double value = valueStr.toDouble();
|
||||||
measurements[i]->append(dateTime, value, false);
|
if (measurements[i]) {
|
||||||
|
measurements[i]->append(dateTime, value, false);
|
||||||
|
} else {
|
||||||
|
m_channelMeasurements[measurementIdx[i]].append(dateTime, value, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user