bool LzSlaveCalculate::startNewTwoViewCalc(QString cameragroupindex, int tunnelid, QString filename, bool isinterrupt, qint64 interruptedfc) { if (hasinitslavemodel && getNumOfCurrentThreads() < maxnumofthreads) { // 准备计算初始化参数 CheckedTunnelTaskModel task; bool ret = LzProjectAccess::getLzProjectAccessInstance()->getLzCheckedList(LzProjectClass::Calculate).getCheckedTunnelModel(tunnelid, task); if (!ret) { // 得不到有效的CheckedTunnelTaskModel,结束计算 finish(0, 2, tunnelid, filename, 0); return true; } QByteArray camgroupid = cameragroupindex.toLocal8Bit(); QByteArray outputfile = filename.toLocal8Bit(); // 写文件头 DataHead head; head.carriage_direction = task.planTask.traindirection; // 正向 【用】 head.is_normal = task.planTask.isnormal; // 正常拍摄(正序)【用】 head.start_mileage = task.planTask.startdistance; // 隧道起始里程 【用于check与数据库中的信息是否发生改变】 head.end_mileage = task.planTask.enddistance; // 隧道终止里程 【用于check与数据库中的信息是否发生改变】 head.is_double_line = task.planTask.doubleline; // 是否双线 【用于check与数据库中的信息是否发生改变】 head.is_downlink = task.planTask.downstream; head.is_newline = task.planTask.newline; head.interval_pulse_num = task.planTask.pulsepermeter; head.tunnel_id = task.planTask.tunnelnum; // 隧道ID 【用】 strcpy(head.tunnel_name, task.planTask.tunnelname.c_str()); strcpy(head.line_name, task.planTask.linename.c_str()); strcpy(head.camera_index, camgroupid.constData()); QDateTime lastTime = QDateTime::currentDateTime(); strcpy(head.datetime, lastTime.toString().toLocal8Bit().constData()); // 如果是双目计算(双线程) if (calcuthreadtype == LzCalcThreadType::LzCalcThread_GeneralSlave || calcuthreadtype == LzCalcThreadType::LzCalcThread_RTSlave_V2) { // 找起始、终止帧 qint64 start_num_store = 0; qint64 end_num_store = 0; std::list<CheckedItem>::iterator todoit = task.getRealList()->begin(); bool firsttime = true; while (todoit != task.getRealList()->end()) { if (firsttime) { start_num_store = (*todoit).start_frame_master; firsttime = false; } end_num_store = (*todoit).end_frame_master; todoit++; } if (calcuthreadtype == LzCalcThreadType::LzCalcThread_GeneralSlave) { int toinsertid = 1; // 记录线程数量 nummutex.lock(); QList<LzCalculateThread *>::iterator it = currentThreads.begin(); while (it != currentThreads.end()) { if ((*it)->getID() == toinsertid) toinsertid++; it++; } LzCalculateTVThread * athread = new LzCalculateTVThread(0, toinsertid); currentnumofthreads++; currentThreads.push_back(athread); nummutex.unlock(); // 告知上层开始计算 emit myStart(toinsertid, true, tunnelid, filename, start_num_store, end_num_store); // 初始化计算参数 athread->init(projectpath, tunnelid, (*(task.getRealList())), camgroupid.constData(), slavemodel, outputfile.constData(), head, isinterrupt, interruptedfc); // 信号槽,接收到计算结束信号 QObject::connect(athread, SIGNAL(finish(int, int, int, QString, qint64)), this, SLOT(receiveThreadFinish(int, int, int, QString, qint64))); QObject::connect(athread, SIGNAL(statusShow(int, qint64, int, QString)), this, SLOT(receiveStatusShow(int, qint64, int, QString))); // 线程开始运行 athread->start(); }
ConfigServoWidget::ConfigServoWidget(QWidget *parent) : ConfigTaskWidget(parent) { m_config = new Ui_SettingsWidget(); m_config->setupUi(this); ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); UAVObjectManager *objManager = pm->getObject<UAVObjectManager>(); // First of all, put all the channel widgets into lists, so that we can // manipulate those: // NOTE: for historical reasons, we have objects below called ch0 to ch7, but the convention for OP is Channel 1 to Channel 8. outLabels << m_config->ch0OutValue << m_config->ch1OutValue << m_config->ch2OutValue << m_config->ch3OutValue << m_config->ch4OutValue << m_config->ch5OutValue << m_config->ch6OutValue << m_config->ch7OutValue; outSliders << m_config->ch0OutSlider << m_config->ch1OutSlider << m_config->ch2OutSlider << m_config->ch3OutSlider << m_config->ch4OutSlider << m_config->ch5OutSlider << m_config->ch6OutSlider << m_config->ch7OutSlider; outMin << m_config->ch0OutMin << m_config->ch1OutMin << m_config->ch2OutMin << m_config->ch3OutMin << m_config->ch4OutMin << m_config->ch5OutMin << m_config->ch6OutMin << m_config->ch7OutMin; outMax << m_config->ch0OutMax << m_config->ch1OutMax << m_config->ch2OutMax << m_config->ch3OutMax << m_config->ch4OutMax << m_config->ch5OutMax << m_config->ch6OutMax << m_config->ch7OutMax; reversals << m_config->ch0Rev << m_config->ch1Rev << m_config->ch2Rev << m_config->ch3Rev << m_config->ch4Rev << m_config->ch5Rev << m_config->ch6Rev << m_config->ch7Rev; inMaxLabels << m_config->ch0Max << m_config->ch1Max << m_config->ch2Max << m_config->ch3Max << m_config->ch4Max << m_config->ch5Max << m_config->ch6Max << m_config->ch7Max; inMinLabels << m_config->ch0Min << m_config->ch1Min << m_config->ch2Min << m_config->ch3Min << m_config->ch4Min << m_config->ch5Min << m_config->ch6Min << m_config->ch7Min; inNeuLabels << m_config->ch0Cur << m_config->ch1Cur << m_config->ch2Cur << m_config->ch3Cur << m_config->ch4Cur << m_config->ch5Cur << m_config->ch6Cur << m_config->ch7Cur; inSliders << m_config->inSlider0 << m_config->inSlider1 << m_config->inSlider2 << m_config->inSlider3 << m_config->inSlider4 << m_config->inSlider5 << m_config->inSlider6 << m_config->inSlider7; // Now connect the widget to the ManualControlCommand / Channel UAVObject UAVDataObject* obj = dynamic_cast<UAVDataObject*>(objManager->getObject(QString("ManualControlCommand"))); connect(obj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(updateChannels(UAVObject*))); // Get the receiver types supported by OpenPilot and fill the corresponding // dropdown menu: obj = dynamic_cast<UAVDataObject*>(objManager->getObject(QString("ManualControlSettings"))); QString fieldName = QString("InputMode"); UAVObjectField *field = obj->getField(fieldName); m_config->receiverType->addItems(field->getOptions()); m_config->receiverType->setDisabled(true); // This option does not work for now, it is a compile-time option. // Fill in the dropdown menus for the channel RC Input assignement. QStringList channelsList; channelsList << "None"; QList<UAVObjectField*> fieldList = obj->getFields(); foreach (UAVObjectField* field, fieldList) { if (field->getUnits().contains("channel")) { channelsList.append(field->getName()); } } m_config->ch0Assign->addItems(channelsList); m_config->ch1Assign->addItems(channelsList); m_config->ch2Assign->addItems(channelsList); m_config->ch3Assign->addItems(channelsList); m_config->ch4Assign->addItems(channelsList); m_config->ch5Assign->addItems(channelsList); m_config->ch6Assign->addItems(channelsList); m_config->ch7Assign->addItems(channelsList); // And for the channel output assignement options m_config->ch0Output->addItem("None"); m_config->ch1Output->addItem("None"); m_config->ch2Output->addItem("None"); m_config->ch3Output->addItem("None"); m_config->ch4Output->addItem("None"); m_config->ch5Output->addItem("None"); m_config->ch6Output->addItem("None"); m_config->ch7Output->addItem("None"); // And the flight mode settings: field = obj->getField(QString("FlightModePosition")); m_config->fmsModePos1->addItems(field->getOptions()); m_config->fmsModePos2->addItems(field->getOptions()); m_config->fmsModePos3->addItems(field->getOptions()); field = obj->getField(QString("Stabilization1Settings")); channelsList.clear(); channelsList.append(field->getOptions()); m_config->fmsSsPos1Roll->addItems(channelsList); m_config->fmsSsPos1Pitch->addItems(channelsList); m_config->fmsSsPos1Yaw->addItems(channelsList); m_config->fmsSsPos2Roll->addItems(channelsList); m_config->fmsSsPos2Pitch->addItems(channelsList); m_config->fmsSsPos2Yaw->addItems(channelsList); m_config->fmsSsPos3Roll->addItems(channelsList); m_config->fmsSsPos3Pitch->addItems(channelsList); m_config->fmsSsPos3Yaw->addItems(channelsList); // And the Armin configurations: field = obj->getField(QString("Arming")); m_config->armControl->clear(); m_config->armControl->addItems(field->getOptions()); obj = dynamic_cast<UAVDataObject*>(objManager->getObject(QString("ActuatorSettings"))); fieldList = obj->getFields(); foreach (UAVObjectField* field, fieldList) { if (field->getUnits().contains("channel")) { m_config->ch0Output->addItem(field->getName()); m_config->ch1Output->addItem(field->getName()); m_config->ch2Output->addItem(field->getName()); m_config->ch3Output->addItem(field->getName()); m_config->ch4Output->addItem(field->getName()); m_config->ch5Output->addItem(field->getName()); m_config->ch6Output->addItem(field->getName()); m_config->ch7Output->addItem(field->getName()); } } // set the RC input tneutral value textees for (int i = 0; i < 8; i++) inNeuLabels[i]->setText(QString::number(inSliders[i]->value())); for (int i = 0; i < 8; i++) { connect(outMin[i], SIGNAL(editingFinished()), this, SLOT(setChOutRange())); connect(outMax[i], SIGNAL(editingFinished()), this, SLOT(setChOutRange())); connect(reversals[i], SIGNAL(toggled(bool)), this, SLOT(reverseChannel(bool))); // Now connect the channel out sliders to our signal to send updates in test mode connect(outSliders[i], SIGNAL(valueChanged(int)), this, SLOT(sendChannelTest(int))); } connect(m_config->channelOutTest, SIGNAL(toggled(bool)), this, SLOT(runChannelTests(bool))); requestRCInputUpdate(); requestRCOutputUpdate(); connect(m_config->saveRCInputToSD, SIGNAL(clicked()), this, SLOT(saveRCInputObject())); connect(m_config->saveRCInputToRAM, SIGNAL(clicked()), this, SLOT(sendRCInputUpdate())); connect(m_config->getRCInputCurrent, SIGNAL(clicked()), this, SLOT(requestRCInputUpdate())); // Flightmode panel is connected to the same as rcinput because // the underlying object is the same! connect(m_config->saveFmsToSD, SIGNAL(clicked()), this, SLOT(saveRCInputObject())); connect(m_config->saveFmsToRAM, SIGNAL(clicked()), this, SLOT(sendRCInputUpdate())); connect(m_config->getFmsCurrent, SIGNAL(clicked()), this, SLOT(requestRCInputUpdate())); connect(m_config->saveArmToSD, SIGNAL(clicked()), this, SLOT(saveRCInputObject())); connect(m_config->saveArmToRAM, SIGNAL(clicked()), this, SLOT(sendRCInputUpdate())); connect(m_config->getArmCurrent, SIGNAL(clicked()), this, SLOT(requestRCInputUpdate())); connect(m_config->saveRCOutputToSD, SIGNAL(clicked()), this, SLOT(saveRCOutputObject())); connect(m_config->saveRCOutputToRAM, SIGNAL(clicked()), this, SLOT(sendRCOutputUpdate())); connect(m_config->getRCOutputCurrent, SIGNAL(clicked()), this, SLOT(requestRCOutputUpdate())); connect(parent, SIGNAL(autopilotConnected()),this, SLOT(requestRCInputUpdate())); connect(parent, SIGNAL(autopilotConnected()),this, SLOT(requestRCOutputUpdate())); connect(m_config->inSlider0, SIGNAL(valueChanged(int)),this, SLOT(onInSliderValueChanged0(int))); connect(m_config->inSlider1, SIGNAL(valueChanged(int)),this, SLOT(onInSliderValueChanged1(int))); connect(m_config->inSlider2, SIGNAL(valueChanged(int)),this, SLOT(onInSliderValueChanged2(int))); connect(m_config->inSlider3, SIGNAL(valueChanged(int)),this, SLOT(onInSliderValueChanged3(int))); connect(m_config->inSlider4, SIGNAL(valueChanged(int)),this, SLOT(onInSliderValueChanged4(int))); connect(m_config->inSlider5, SIGNAL(valueChanged(int)),this, SLOT(onInSliderValueChanged5(int))); connect(m_config->inSlider6, SIGNAL(valueChanged(int)),this, SLOT(onInSliderValueChanged6(int))); connect(m_config->inSlider7, SIGNAL(valueChanged(int)),this, SLOT(onInSliderValueChanged7(int))); firstUpdate = true; enableControls(false); // Listen to telemetry connection events if (pm) { TelemetryManager *tm = pm->getObject<TelemetryManager>(); if (tm) { connect(tm, SIGNAL(myStart()), this, SLOT(onTelemetryStart())); connect(tm, SIGNAL(myStop()), this, SLOT(onTelemetryStop())); connect(tm, SIGNAL(connected()), this, SLOT(onTelemetryConnect())); connect(tm, SIGNAL(disconnected()), this, SLOT(onTelemetryDisconnect())); } } }
void TelemetryManager::start(QIODevice *dev) { device=dev; emit myStart(); }
ConfigOutputWidget::ConfigOutputWidget(QWidget *parent) : ConfigTaskWidget(parent) { m_config = new Ui_OutputWidget(); m_config->setupUi(this); ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); UAVObjectManager *objManager = pm->getObject<UAVObjectManager>(); // First of all, put all the channel widgets into lists, so that we can // manipulate those: // NOTE: for historical reasons, we have objects below called ch0 to ch7, but the convention for OP is Channel 1 to Channel 8. outLabels << m_config->ch0OutValue << m_config->ch1OutValue << m_config->ch2OutValue << m_config->ch3OutValue << m_config->ch4OutValue << m_config->ch5OutValue << m_config->ch6OutValue << m_config->ch7OutValue; outSliders << m_config->ch0OutSlider << m_config->ch1OutSlider << m_config->ch2OutSlider << m_config->ch3OutSlider << m_config->ch4OutSlider << m_config->ch5OutSlider << m_config->ch6OutSlider << m_config->ch7OutSlider; outMin << m_config->ch0OutMin << m_config->ch1OutMin << m_config->ch2OutMin << m_config->ch3OutMin << m_config->ch4OutMin << m_config->ch5OutMin << m_config->ch6OutMin << m_config->ch7OutMin; outMax << m_config->ch0OutMax << m_config->ch1OutMax << m_config->ch2OutMax << m_config->ch3OutMax << m_config->ch4OutMax << m_config->ch5OutMax << m_config->ch6OutMax << m_config->ch7OutMax; reversals << m_config->ch0Rev << m_config->ch1Rev << m_config->ch2Rev << m_config->ch3Rev << m_config->ch4Rev << m_config->ch5Rev << m_config->ch6Rev << m_config->ch7Rev; links << m_config->ch0Link << m_config->ch1Link << m_config->ch2Link << m_config->ch3Link << m_config->ch4Link << m_config->ch5Link << m_config->ch6Link << m_config->ch7Link; UAVDataObject * obj = dynamic_cast<UAVDataObject*>(objManager->getObject(QString("ActuatorSettings"))); QList<UAVObjectField*> fieldList = obj->getFields(); foreach (UAVObjectField* field, fieldList) { if (field->getUnits().contains("channel")) { m_config->ch0Output->addItem(field->getName()); m_config->ch1Output->addItem(field->getName()); m_config->ch2Output->addItem(field->getName()); m_config->ch3Output->addItem(field->getName()); m_config->ch4Output->addItem(field->getName()); m_config->ch5Output->addItem(field->getName()); m_config->ch6Output->addItem(field->getName()); m_config->ch7Output->addItem(field->getName()); } } for (int i = 0; i < 8; i++) { connect(outMin[i], SIGNAL(editingFinished()), this, SLOT(setChOutRange())); connect(outMax[i], SIGNAL(editingFinished()), this, SLOT(setChOutRange())); connect(reversals[i], SIGNAL(toggled(bool)), this, SLOT(reverseChannel(bool))); // Now connect the channel out sliders to our signal to send updates in test mode connect(outSliders[i], SIGNAL(valueChanged(int)), this, SLOT(sendChannelTest(int))); } connect(m_config->channelOutTest, SIGNAL(toggled(bool)), this, SLOT(runChannelTests(bool))); for (int i = 0; i < links.count(); i++) links[i]->setChecked(false); for (int i = 0; i < links.count(); i++) connect(links[i], SIGNAL(toggled(bool)), this, SLOT(linkToggled(bool))); requestRCOutputUpdate(); connect(m_config->saveRCOutputToSD, SIGNAL(clicked()), this, SLOT(saveRCOutputObject())); connect(m_config->saveRCOutputToRAM, SIGNAL(clicked()), this, SLOT(sendRCOutputUpdate())); connect(m_config->getRCOutputCurrent, SIGNAL(clicked()), this, SLOT(requestRCOutputUpdate())); connect(parent, SIGNAL(autopilotConnected()),this, SLOT(requestRCOutputUpdate())); firstUpdate = true; enableControls(false); // Listen to telemetry connection events if (pm) { TelemetryManager *tm = pm->getObject<TelemetryManager>(); if (tm) { connect(tm, SIGNAL(myStart()), this, SLOT(onTelemetryStart())); connect(tm, SIGNAL(myStop()), this, SLOT(onTelemetryStop())); connect(tm, SIGNAL(connected()), this, SLOT(onTelemetryConnect())); connect(tm, SIGNAL(disconnected()), this, SLOT(onTelemetryDisconnect())); } } }