void VehicleTemplateExportDialog::importTemplate() { QJsonObject *tmpl = ui->selectionWidget->selectedTemplate(); if (tmpl != NULL) { QList<UAVObject *> updatedObjects; m_uavoManager->fromJson(*tmpl, &updatedObjects); UAVObjectUpdaterHelper helper; foreach(UAVObject * object, updatedObjects) { UAVDataObject *dataObj = dynamic_cast<UAVDataObject *>(object); if (dataObj != NULL && dataObj->isKnown()) { helper.doObjectAndWait(dataObj); ObjectPersistence *objper = ObjectPersistence::GetInstance(m_uavoManager); ObjectPersistence::DataFields data; data.Operation = ObjectPersistence::OPERATION_SAVE; data.Selection = ObjectPersistence::SELECTION_SINGLEOBJECT; data.ObjectID = dataObj->getObjID(); data.InstanceID = dataObj->getInstID(); objper->setData(data); helper.doObjectAndWait(objper); } }
void FlightLogManager::clearAllLogs() { setDisableControls(true); QApplication::setOverrideCursor(Qt::WaitCursor); // Clear on flight side UAVObjectUpdaterHelper updateHelper; m_flightLogControl->setFlight(0); m_flightLogControl->setEntry(0); m_flightLogControl->setOperation(DebugLogControl::OPERATION_FORMATFLASH); if (updateHelper.doObjectAndWait(m_flightLogControl, UAVTALK_TIMEOUT) == UAVObjectUpdaterHelper::SUCCESS) { // Then empty locally clearLogList(); } QApplication::restoreOverrideCursor(); setDisableControls(false); }
void FlightLogManager::retrieveLogs(int flightToRetrieve) { setDisableControls(true); QApplication::setOverrideCursor(Qt::WaitCursor); m_cancelDownload = false; UAVObjectUpdaterHelper updateHelper; UAVObjectRequestHelper requestHelper; clearLogList(); // Set up what to retrieve int startFlight = (flightToRetrieve == -1) ? 0 : flightToRetrieve; int endFlight = (flightToRetrieve == -1) ? m_flightLogStatus->getFlight() : flightToRetrieve; // Prepare to send request for event retrieval m_flightLogControl->setOperation(DebugLogControl::OPERATION_RETRIEVE); for (int flight = startFlight; flight <= endFlight; flight++) { m_flightLogControl->setFlight(flight); bool gotLast = false; int entry = 0; while (!gotLast) { // Send request for loading flight entry on flight side and wait for ack/nack m_flightLogControl->setEntry(entry); if (updateHelper.doObjectAndWait(m_flightLogControl, UAVTALK_TIMEOUT) == UAVObjectUpdaterHelper::SUCCESS && requestHelper.doObjectAndWait(m_flightLogEntry, UAVTALK_TIMEOUT) == UAVObjectUpdaterHelper::SUCCESS) { if (m_flightLogEntry->getType() != DebugLogEntry::TYPE_EMPTY) { // Ok, we retrieved the entry, and it was the correct one. clone it and add it to the list ExtendedDebugLogEntry *logEntry = new ExtendedDebugLogEntry(); logEntry->setData(m_flightLogEntry->getData(), m_objectManager); m_logEntries << logEntry; // Increment to get next entry from flight side entry++; } else { // We are done, not more entries on this flight gotLast = true; } } else { // We failed for some reason break; } if (m_cancelDownload) { break; } } if (m_cancelDownload) { break; } } if (m_cancelDownload) { clearLogList(); m_cancelDownload = false; } emit logEntriesChanged(); setDisableExport(m_logEntries.count() == 0); QApplication::restoreOverrideCursor(); setDisableControls(false); }