81 connect(
ui.BTNEdit, SIGNAL(clicked()),
this, SLOT(
configDialog()));
82 connect(
ui.BTNPlotterStatus,
83 SIGNAL(toggled(
bool)),
85 SLOT(plottingPaused(
bool)));
87 connect(
ui.BTNAutoScale, SIGNAL(toggled(
bool)), plotterController, SLOT(autoScale(
bool)));
89 connect(
ui.btnLogToFile, SIGNAL(toggled(
bool)),
this, SLOT(
toggleLogging(
bool)));
91 connect(
ui.CBgraphStyle,
92 SIGNAL(currentTextChanged(QString)),
96 connect(
ui.btnClearHistory, SIGNAL(clicked()), plotterController, SLOT(clearHistory()));
98 if (!QMetaObject::invokeMethod(plotterController,
"setupCurves"))
157 std::unique_lock lock(dataMutex);
158 plotterController->setUpdateInterval(
dialog->ui.spinBoxUpdateInterval->value());
159 plotterController->setShownInterval(
dialog->ui.spinBoxShownInterval->value());
160 plotterController->setPollingInterval(
dialog->ui.spinBoxPollingInterval->value());
163 syncDataLogging =
dialog->ui.syncDataLogging->isChecked();
164 ui.btnLogToFile->setChecked(
false);
165 ui.BTNPlotterStatus->setChecked(
false);
166 plotterController->setSelectedDatafields(
dialog->getSelectedDatafields());
175 std::lock_guard<std::mutex> lock(mutex);
179 std::filesystem::path outputPath;
180 if (filename.empty())
182 outputPath =
loggingDir.toStdString() +
"/datalog.csv";
184 std::string time = IceUtil::Time::now().toDateTime();
185 time = simox::alg::replace_all(time,
"/",
"-");
186 time = simox::alg::replace_all(time,
" ",
"_");
187 time = simox::alg::replace_all(time,
":",
"-");
188 outputPath = outputPath.parent_path() / (outputPath.stem().
string() +
"-" + time +
189 outputPath.extension().string());
193 std::filesystem::path path = filename;
194 outputPath =
loggingDir.toStdString() +
"/" + path.stem().string() +
".csv";
197 ARMARX_INFO <<
"Logging to " << outputPath.string();
198 logstream.open(outputPath.string());
199 logStartTime = IceUtil::Time::now();
201 if (!logstream.is_open())
203 ARMARX_ERROR <<
"Could not open file for logging: " << outputPath.string();
204 ui.btnLogToFile->setChecked(
false);
208 std::lock_guard<std::mutex> lock(fileMutex);
210 csvHeader = plotterController->getSelectedDatafieldsKeys();
212 logstream <<
"Timestamp";
213 for (
const auto& s : csvHeader)
215 logstream <<
"," << s;
217 logstream << std::endl;
219 connect(plotterController,
220 SIGNAL(newDataAvailable(
long, std::map<std::string, VariantPtr>)),
222 SLOT(
logToFile(
long, std::map<std::string, VariantPtr>)));
228 QObject::disconnect(plotterController,
229 SIGNAL(newDataAvailable(
long, std::map<std::string, VariantPtr>)),
231 SLOT(
logToFile(
long, std::map<std::string, VariantPtr>)));
233 std::lock_guard<std::mutex> lock(fileMutex);
264 std::unique_lock lock(dataMutex);
265 settings->setValue(
"updateInterval", plotterController->getUpdateInterval());
266 settings->setValue(
"shownInterval", plotterController->getShownInterval());
267 settings->setValue(
"pollingInterval", plotterController->getPollingInterval());
268 settings->setValue(
"selectedChannels", plotterController->getSelectedDatafields());
269 settings->setValue(
"autoScaleActive",
ui.BTNAutoScale->isChecked());
270 settings->setValue(
"syncDataLogging", syncDataLogging);
276 std::unique_lock lock(dataMutex);
277 plotterController->setUpdateInterval(
settings->value(
"updateInterval", 100).toInt());
278 plotterController->setShownInterval(
settings->value(
"shownInterval", 60).toInt());
279 plotterController->setPollingInterval(
settings->value(
"pollingInterval", 33).toInt());
280 plotterController->setSelectedDatafields(
281 settings->value(
"selectedChannels", QStringList()).toStringList());
282 ui.BTNAutoScale->setChecked(
settings->value(
"autoScaleActive",
true).toBool());
283 syncDataLogging =
settings->value(
"syncDataLogging",
false).toBool();
290 const std::map<std::string, VariantPtr>& dataMaptoAppend)
292 std::lock_guard<std::mutex> lock(fileMutex);
294 if (!logstream.is_open() || !dataMaptoAppend.size())
299 logstream << (IceUtil::Time::microSeconds(
timestamp) - logStartTime).toMilliSecondsDouble();
301 for (
const auto& f : csvHeader)
304 if (dataMaptoAppend.count(f))
306 logstream << dataMaptoAppend.at(f)->Variant::getOutputValueOnly();
309 logstream << std::endl;