本文整理汇总了C++中UAVObject类的典型用法代码示例。如果您正苦于以下问题:C++ UAVObject类的具体用法?C++ UAVObject怎么用?C++ UAVObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UAVObject类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: getStabBankObject
void ConfigStabilizationWidget::restoreStabBank(int bank)
{
UAVObject *stabBankObject = getStabBankObject(bank);
if (stabBankObject) {
ObjectPersistence *objectPersistenceObject = ObjectPersistence::GetInstance(getObjectManager());
QTimer updateTimer(this);
QEventLoop eventLoop(this);
connect(&updateTimer, SIGNAL(timeout()), &eventLoop, SLOT(quit()));
connect(objectPersistenceObject, SIGNAL(objectUpdated(UAVObject *)), &eventLoop, SLOT(quit()));
ObjectPersistence::DataFields data;
data.Operation = ObjectPersistence::OPERATION_LOAD;
data.Selection = ObjectPersistence::SELECTION_SINGLEOBJECT;
data.ObjectID = stabBankObject->getObjID();
data.InstanceID = stabBankObject->getInstID();
objectPersistenceObject->setData(data);
objectPersistenceObject->updated();
updateTimer.start(500);
eventLoop.exec();
if (updateTimer.isActive()) {
stabBankObject->requestUpdate();
}
updateTimer.stop();
}
}
开发者ID:CaptainFalco,项目名称:OpenPilot,代码行数:26,代码来源:configstabilizationwidget.cpp
示例2: isDirty
void ConfigStabilizationWidget::updateThrottleCurveFromObject()
{
bool dirty = isDirty();
UAVObject *stabBank = getObjectManager()->getObject(QString(m_stabTabBars.at(0)->tabData(m_currentStabSettingsBank).toString()));
Q_ASSERT(stabBank);
UAVObjectField *field = stabBank->getField("ThrustPIDScaleCurve");
Q_ASSERT(field);
QList<double> curve;
for (quint32 i = 0; i < field->getNumElements(); i++) {
curve.append(field->getValue(i).toDouble());
}
ui->thrustPIDScalingCurve->setCurve(&curve);
field = stabBank->getField("EnableThrustPIDScaling");
Q_ASSERT(field);
bool enabled = field->getValue() == "TRUE";
ui->enableThrustPIDScalingCheckBox->setChecked(enabled);
ui->thrustPIDScalingCurve->setEnabled(enabled);
setDirty(dirty);
}
开发者ID:CaptainFalco,项目名称:OpenPilot,代码行数:25,代码来源:configstabilizationwidget.cpp
示例3: switch
/**
Callback once calibration is done on the board.
Currently we don't have a way to tell if calibration is finished, so we
have to use a timer.
calibPhase2 is also connected to the AHRSCalibration object update signal.
*/
void ConfigAHRSWidget::calibPhase2()
{
UAVObject *obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("AHRSCalibration")));
// UAVObjectField *field = obj->getField(QString("measure_var"));
// This is a bit weird, but it is because we are expecting an update from the
// OP board with the correct calibration values, and those only arrive on the object update
// which comes back from the board, and not the first object update signal which is in fast
// the object update we did ourselves... Clear ?
switch (phaseCounter) {
case 0:
phaseCounter++;
m_ahrs->calibInstructions->setText("Getting results...");
connect(obj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(calibPhase2()));
// We need to echo back the results of calibration before changing to set mode
obj->requestUpdate();
break;
case 1: // This is the update with the right values (coming from the board)
disconnect(obj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(calibPhase2()));
// Now update size of all the graphs
drawVariancesGraph();
saveAHRSCalibration();
m_ahrs->calibInstructions->setText(QString("Calibration saved."));
m_ahrs->ahrsCalibStart->setEnabled(true);
break;
}
}
开发者ID:mcu786,项目名称:my_OpenPilot_mods,代码行数:37,代码来源:configahrswidget.cpp
示例4: if
/**
* Initiate object retrieval, initialize queue with objects to be retrieved.
*/
void TelemetryMonitor::startRetrievingObjects()
{
// Clear object queue
queue.clear();
// Get all objects, add metaobjects, settings and data objects with OnChange update mode to the queue
QList< QList<UAVObject *> > objs = objMngr->getObjects();
for (int n = 0; n < objs.length(); ++n) {
UAVObject *obj = objs[n][0];
UAVMetaObject *mobj = dynamic_cast<UAVMetaObject *>(obj);
UAVDataObject *dobj = dynamic_cast<UAVDataObject *>(obj);
UAVObject::Metadata mdata = obj->getMetadata();
if (mobj != NULL) {
queue.enqueue(obj);
} else if (dobj != NULL) {
if (dobj->isSettings()) {
queue.enqueue(obj);
} else {
if (UAVObject::GetFlightTelemetryUpdateMode(mdata) == UAVObject::UPDATEMODE_ONCHANGE) {
queue.enqueue(obj);
}
}
}
}
// Start retrieving
qDebug() << tr("Starting to retrieve meta and settings objects from the autopilot (%1 objects)")
.arg(queue.length());
retrieveNextObject();
}
开发者ID:Alex-Rongzhen-Huang,项目名称:OpenPilot,代码行数:31,代码来源:telemetrymonitor.cpp
示例5: Q_ASSERT
void UAVObjectUtilManager::saveNextObject()
{
if (queue.isEmpty()) {
return;
}
Q_ASSERT(saveState == IDLE);
// Get next object from the queue
UAVObject *obj = queue.head();
qDebug() << "Send save object request to board " << obj->getName();
ObjectPersistence *objper = dynamic_cast<ObjectPersistence *>(getObjectManager()->getObject(ObjectPersistence::NAME));
connect(objper, SIGNAL(transactionCompleted(UAVObject *, bool)), this, SLOT(objectPersistenceTransactionCompleted(UAVObject *, bool)));
connect(objper, SIGNAL(objectUpdated(UAVObject *)), this, SLOT(objectPersistenceUpdated(UAVObject *)));
saveState = AWAITING_ACK;
if (obj != NULL) {
ObjectPersistence::DataFields data;
data.Operation = ObjectPersistence::OPERATION_SAVE;
data.Selection = ObjectPersistence::SELECTION_SINGLEOBJECT;
data.ObjectID = obj->getObjID();
data.InstanceID = obj->getInstID();
objper->setData(data);
objper->updated();
}
// Now: we are going to get two "objectUpdated" messages (one coming from GCS, one coming from Flight, which
// will confirm the object was properly received by both sides) and then one "transactionCompleted" indicating
// that the Flight side did not only receive the object but it did receive it without error. Last we will get
// a last "objectUpdated" message coming from flight side, where we'll get the results of the objectPersistence
// operation we asked for (saved, other).
}
开发者ID:MarcProe,项目名称:LibrePilot,代码行数:31,代码来源:uavobjectutilmanager.cpp
示例6: Q_ASSERT
void UAVObjectBrowserWidget::onTreeItemExpanded(QModelIndex currentProxyIndex)
{
QModelIndex currentIndex = proxyModel->mapToSource(currentProxyIndex);
TreeItem *item = static_cast<TreeItem*>(currentIndex.internalPointer());
TopTreeItem *top = dynamic_cast<TopTreeItem*>(item->parent());
//Check if current tree index is the child of the top tree item
if (top)
{
ObjectTreeItem *objItem = dynamic_cast<ObjectTreeItem*>(item);
//If the cast succeeds, then this is a UAVO
if (objItem)
{
UAVObject *obj = objItem->object();
// Check for multiple instance UAVO
if(!obj){
objItem = dynamic_cast<ObjectTreeItem*>(item->getChild(0));
obj = objItem->object();
}
Q_ASSERT(obj);
UAVObject::Metadata mdata = obj->getMetadata();
// Determine fastest update
quint16 tmpUpdatePeriod = MAXIMUM_UPDATE_PERIOD;
int accessType = UAVObject::GetGcsTelemetryUpdateMode(mdata);
if (accessType != UAVObject::UPDATEMODE_MANUAL){
switch(accessType){
case UAVObject::UPDATEMODE_ONCHANGE:
tmpUpdatePeriod = 0;
break;
case UAVObject::UPDATEMODE_PERIODIC:
case UAVObject::UPDATEMODE_THROTTLED:
tmpUpdatePeriod = std::min(mdata.gcsTelemetryUpdatePeriod, tmpUpdatePeriod);
break;
}
}
accessType = UAVObject::GetFlightTelemetryUpdateMode(mdata);
if (accessType != UAVObject::UPDATEMODE_MANUAL){
switch(accessType){
case UAVObject::UPDATEMODE_ONCHANGE:
tmpUpdatePeriod = 0;
break;
case UAVObject::UPDATEMODE_PERIODIC:
case UAVObject::UPDATEMODE_THROTTLED:
tmpUpdatePeriod = std::min(mdata.flightTelemetryUpdatePeriod, tmpUpdatePeriod);
break;
}
}
expandedUavoItems.insert(obj->getName(), tmpUpdatePeriod);
if (tmpUpdatePeriod < updatePeriod){
updatePeriod = tmpUpdatePeriod;
treeView->updateTimerPeriod(updatePeriod);
}
}
}
}
开发者ID:Trex4Git,项目名称:dRonin,代码行数:59,代码来源:uavobjectbrowserwidget.cpp
示例7: findCurrentObjectTreeItem
void UAVObjectBrowserWidget::requestUpdate()
{
ObjectTreeItem *objItem = findCurrentObjectTreeItem();
Q_ASSERT(objItem);
UAVObject *obj = objItem->object();
Q_ASSERT(obj);
obj->requestUpdate();
}
开发者ID:mcu786,项目名称:my_OpenPilot_mods,代码行数:8,代码来源:uavobjectbrowserwidget.cpp
示例8: calibration
/**
Saves the AHRS sensors calibration (to RAM and SD)
*/
void ConfigAHRSWidget::saveAHRSCalibration()
{
UAVObject *obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("AHRSCalibration")));
UAVObjectField *field = obj->getField(QString("measure_var"));
field->setValue("SET");
obj->updated();
updateObjectPersistance(ObjectPersistence::OPERATION_SAVE, obj);
}
开发者ID:mcu786,项目名称:my_OpenPilot_mods,代码行数:12,代码来源:configahrswidget.cpp
示例9: ConfigTaskWidget
ConfigOutputWidget::ConfigOutputWidget(QWidget *parent) : ConfigTaskWidget(parent),wasItMe(false)
{
m_config = new Ui_OutputWidget();
m_config->setupUi(this);
ExtensionSystem::PluginManager *pm=ExtensionSystem::PluginManager::instance();
Core::Internal::GeneralSettings * settings=pm->getObject<Core::Internal::GeneralSettings>();
if(!settings->useExpertMode())
m_config->saveRCOutputToRAM->setVisible(false);
UAVSettingsImportExportFactory * importexportplugin = pm->getObject<UAVSettingsImportExportFactory>();
connect(importexportplugin,SIGNAL(importAboutToBegin()),this,SLOT(stopTests()));
// NOTE: we have channel indices from 0 to 9, but the convention for OP is Channel 1 to Channel 10.
// Register for ActuatorSettings changes:
for (unsigned int i = 0; i < ActuatorCommand::CHANNEL_NUMELEM; i++)
{
OutputChannelForm *outputForm = new OutputChannelForm(i, this, i==0);
m_config->channelLayout->addWidget(outputForm);
connect(m_config->channelOutTest, SIGNAL(toggled(bool)), outputForm, SLOT(enableChannelTest(bool)));
connect(outputForm, SIGNAL(channelChanged(int,int)), this, SLOT(sendChannelTest(int,int)));
connect(outputForm, SIGNAL(formChanged()), this, SLOT(do_SetDirty()));
}
connect(m_config->channelOutTest, SIGNAL(toggled(bool)), this, SLOT(runChannelTests(bool)));
// Configure the task widget
// Connect the help button
connect(m_config->outputHelp, SIGNAL(clicked()), this, SLOT(openHelp()));
addApplySaveButtons(m_config->saveRCOutputToRAM,m_config->saveRCOutputToSD);
// Track the ActuatorSettings object
addUAVObject("ActuatorSettings");
// Associate the buttons with their UAVO fields
addWidget(m_config->cb_outputRate4);
addWidget(m_config->cb_outputRate3);
addWidget(m_config->cb_outputRate2);
addWidget(m_config->cb_outputRate1);
addWidget(m_config->spinningArmed);
disconnect(this, SLOT(refreshWidgetsValues(UAVObject*)));
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
UAVObject* obj = objManager->getObject(QString("ActuatorCommand"));
if(UAVObject::GetGcsTelemetryUpdateMode(obj->getMetadata()) == UAVObject::UPDATEMODE_ONCHANGE)
this->setEnabled(false);
connect(obj,SIGNAL(objectUpdated(UAVObject*)),this,SLOT(disableIfNotMe(UAVObject*)));
connect(SystemSettings::GetInstance(objManager), SIGNAL(objectUpdated(UAVObject*)),this,SLOT(assignOutputChannels(UAVObject*)));
refreshWidgetsValues();
}
开发者ID:1heinz,项目名称:TauLabs,代码行数:56,代码来源:configoutputwidget.cpp
示例10: getUAVFieldValue
QString UsageTrackerPlugin::getUAVFieldValue(UAVObjectManager *objManager, QString objectName, QString fieldName, int index) const
{
UAVObject *object = objManager->getObject(objectName);
if (object != NULL) {
UAVObjectField *field = object->getField(fieldName);
if (field != NULL) {
return field->getValue(index).toString();
}
}
return tr("Unknown");
}
开发者ID:MAVProxyUser,项目名称:NinjaPilot-15.02.ninja,代码行数:12,代码来源:usagetrackerplugin.cpp
示例11: qDebug
/**
* Retrieve the next object in the queue
*/
void LoggingThread::retrieveNextObject()
{
// If queue is empty return
if (queue.isEmpty()) {
qDebug() << "Logging: Object retrieval completed";
return;
}
// Get next object from the queue
UAVObject *obj = queue.dequeue();
// Connect to object
connect(obj, SIGNAL(transactionCompleted(UAVObject *, bool)), this, SLOT(transactionCompleted(UAVObject *, bool)));
// Request update
obj->requestUpdate();
}
开发者ID:CodeMining,项目名称:OpenPilot,代码行数:17,代码来源:loggingplugin.cpp
示例12:
bool UAVObject::operator ==(const UAVObject &other) {
if((this->UAVObjGetInstance() == other.UAVObjGetID()) && (this->UAVObjGetInstance() == other.UAVObjGetInstance()))
return true;
else
return false;
}
开发者ID:vitaminwater,项目名称:OpenPilot,代码行数:7,代码来源:UAVObject.cpp
示例13: launchAHRSCalibration
/**
Launches the AHRS sensors calibration
*/
void ConfigAHRSWidget::launchAHRSCalibration()
{
m_ahrs->calibInstructions->setText("Estimating sensor variance...");
m_ahrs->ahrsCalibStart->setEnabled(false);
UAVObject *obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("AHRSCalibration")));
UAVObjectField *field = obj->getField(QString("measure_var"));
field->setValue("MEASURE");
obj->updated();
QTimer::singleShot(calibrationDelay*1000, this, SLOT(calibPhase2()));
m_ahrs->calibProgress->setRange(0,calibrationDelay);
phaseCounter = 0;
progressBarIndex = 0;
connect(&progressBarTimer, SIGNAL(timeout()), this, SLOT(incrementProgress()));
progressBarTimer.start(1000);
}
开发者ID:mcu786,项目名称:my_OpenPilot_mods,代码行数:20,代码来源:configahrswidget.cpp
示例14: getObjectManager
//! Query optional objects to determine which tabs can be configured
void ConfigModuleWidget::recheckTabs()
{
UAVObject * obj;
obj = getObjectManager()->getObject(AirspeedSettings::NAME);
connect(obj, SIGNAL(transactionCompleted(UAVObject*,bool)), this, SLOT(objectUpdated(UAVObject*,bool)), Qt::UniqueConnection);
obj->requestUpdate();
obj = getObjectManager()->getObject(FlightBatterySettings::NAME);
connect(obj, SIGNAL(transactionCompleted(UAVObject*,bool)), this, SLOT(objectUpdated(UAVObject*,bool)), Qt::UniqueConnection);
obj->requestUpdate();
obj = getObjectManager()->getObject(VibrationAnalysisSettings::NAME);
connect(obj, SIGNAL(transactionCompleted(UAVObject*,bool)), this, SLOT(objectUpdated(UAVObject*,bool)), Qt::UniqueConnection);
obj->requestUpdate();
obj = getObjectManager()->getObject(HoTTSettings::NAME);
connect(obj, SIGNAL(transactionCompleted(UAVObject*,bool)), this, SLOT(objectUpdated(UAVObject*,bool)), Qt::UniqueConnection);
obj->requestUpdate();
obj = getObjectManager()->getObject(GeoFenceSettings::NAME);
connect(obj, SIGNAL(transactionCompleted(UAVObject*,bool)), this, SLOT(objectUpdated(UAVObject*,bool)), Qt::UniqueConnection);
obj->requestUpdate();
obj = getObjectManager()->getObject(PicoCSettings::NAME);
connect(obj, SIGNAL(transactionCompleted(UAVObject*,bool)), this, SLOT(objectUpdated(UAVObject*,bool)), Qt::UniqueConnection);
obj->requestUpdate();
}
开发者ID:CheBuzz,项目名称:TauLabs,代码行数:29,代码来源:configmodulewidget.cpp
示例15: connected
/**
* Retrieve the next object in the queue
*/
void TelemetryMonitor::retrieveNextObject()
{
// If queue is empty return
if ( queue.isEmpty() )
{
qxtLog->debug("Object retrieval completed");
emit connected();
return;
}
// Get next object from the queue
UAVObject* obj = queue.dequeue();
//qxtLog->trace( tr("Retrieving object: %1").arg(obj->getName()) );
// Connect to object
connect(obj, SIGNAL(transactionCompleted(UAVObject*,bool)), this, SLOT(transactionCompleted(UAVObject*,bool)));
// Request update
obj->requestUpdate();
objPending = obj;
}
开发者ID:1heinz,项目名称:TauLabs,代码行数:21,代码来源:telemetrymonitor.cpp
示例16: getObjectManager
void ConfigStabilizationWidget::updateObjectFromThrottleCurve()
{
UAVObject *stabBank = getObjectManager()->getObject(QString(m_stabTabBars.at(0)->tabData(m_currentStabSettingsBank).toString()));
Q_ASSERT(stabBank);
UAVObjectField *field = stabBank->getField("ThrustPIDScaleCurve");
Q_ASSERT(field);
QList<double> curve = ui->thrustPIDScalingCurve->getCurve();
for (quint32 i = 0; i < field->getNumElements(); i++) {
field->setValue(curve.at(i), i);
}
field = stabBank->getField("EnableThrustPIDScaling");
Q_ASSERT(field);
field->setValue(ui->enableThrustPIDScalingCheckBox->isChecked() ? "TRUE" : "FALSE");
}
开发者ID:CaptainFalco,项目名称:OpenPilot,代码行数:18,代码来源:configstabilizationwidget.cpp
示例17: Q_ASSERT
/**
* @brief UAVObjectUtilManager::saveNextObject
*
* Processes the save queue.
*/
void UAVObjectUtilManager::saveNextObject()
{
if ( queue.isEmpty() ) {
return;
}
Q_ASSERT(saveState == IDLE);
// Get next object from the queue (don't dequeue yet)
UAVObject* obj = queue.head();
Q_ASSERT(obj);
qDebug() << "Send save object request to board " << obj->getName();
ObjectPersistence * objectPersistence = ObjectPersistence::GetInstance(getObjectManager());
Q_ASSERT(objectPersistence);
// "transactionCompleted" is emitted once the objectPersistence object is sent over the telemetry link.
// Since its metadata state that it should be ACK'ed on flight telemetry, the transactionCompleted signal
// will be triggered once the GCS telemetry manager receives an ACK from the flight controller, or times
// out. the success value will reflect success or failure.
connect(objectPersistence, SIGNAL(transactionCompleted(UAVObject*,bool)), this, SLOT(objectPersistenceTransactionCompleted(UAVObject*,bool)));
// After we update the objectPersistence UAVO, we need to listen to its "objectUpdated" event, which will occur
// once the flight controller sends this object back to the GCS, with the "Operation" field set to "Completed"
// or "Error".
connect(objectPersistence, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(objectPersistenceUpdated(UAVObject *)));
saveState = AWAITING_ACK;
qDebug() << "[saveObjectToFlash] Moving on to AWAITING_ACK";
ObjectPersistence::DataFields data;
data.Operation = ObjectPersistence::OPERATION_SAVE;
data.Selection = ObjectPersistence::SELECTION_SINGLEOBJECT;
data.ObjectID = obj->getObjID();
data.InstanceID = obj->getInstID();
objectPersistence->setData(data);
objectPersistence->updated();
// Now: we are going to get the following:
// - two "objectUpdated" messages (one coming from GCS, one coming from Flight, which will confirm the object
// was properly received by both sides). This is because the metadata of objectPersistence has "FlightUpdateOnChange"
// set to true.
// - then one "transactionCompleted" indicating that the Flight side did not only receive the object but it did
// receive it without error (that message will be triggered by reception of the ACK).
// - Last we will get one last "objectUpdated" message coming from flight side, where we'll get the results of
// the objectPersistence operation we asked for (saved, other).
}
开发者ID:MAVProxyUser,项目名称:TeamBlackSheepTauGCS,代码行数:49,代码来源:uavobjectutilmanager.cpp
示例18: onTreeItemCollapsed
void UAVObjectBrowserWidget::onTreeItemCollapsed(QModelIndex currentProxyIndex)
{
QModelIndex currentIndex = proxyModel->mapToSource(currentProxyIndex);
TreeItem *item = static_cast<TreeItem*>(currentIndex.internalPointer());
TopTreeItem *top = dynamic_cast<TopTreeItem*>(item->parent());
//Check if current tree index is the child of the top tree item
if (top)
{
ObjectTreeItem *objItem = dynamic_cast<ObjectTreeItem*>(item);
//If the cast succeeds, then this is a UAVO
if (objItem)
{
UAVObject *obj = objItem->object();
// Check for multiple instance UAVO
if(!obj){
objItem = dynamic_cast<ObjectTreeItem*>(item->getChild(0));
obj = objItem->object();
}
Q_ASSERT(obj);
//Remove the UAVO, getting its stored value first.
quint16 tmpUpdatePeriod = expandedUavoItems.value(obj->getName());
expandedUavoItems.take(obj->getName());
// Check if this was the fastest UAVO
if (tmpUpdatePeriod == updatePeriod){
// If so, search for the new fastest UAVO
updatePeriod = MAXIMUM_UPDATE_PERIOD;
foreach(tmpUpdatePeriod, expandedUavoItems)
{
if (tmpUpdatePeriod < updatePeriod)
updatePeriod = tmpUpdatePeriod;
}
treeView->updateTimerPeriod(updatePeriod);
}
}
}
开发者ID:Trex4Git,项目名称:dRonin,代码行数:41,代码来源:uavobjectbrowserwidget.cpp
示例19: foreach
foreach (QString objStr, strList) {
// Add defaults
UAVObject *obj = objManager->getObject(objStr);
Q_ASSERT(obj);
UAVObject::Metadata mdataDefault = obj->getDefaultMetadata();
QModelIndex index = schedulerModel->index(rowIndex,0, QModelIndex());
schedulerModel->setData(index, QString("%1ms").arg(mdataDefault.flightTelemetryUpdatePeriod));
// Save default metadata for later use
defaultMdata.insert(obj->getName().append("Meta"), mdataDefault);
// Connect live values to the "Current" column
UAVDataObject *dobj = dynamic_cast<UAVDataObject*>(obj);
Q_ASSERT(dobj);
UAVMetaObject *mobj = dobj->getMetaObject();
connect(mobj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(updateCurrentColumn(UAVObject*)));
// Updates the "Current" column with the live value
updateCurrentColumn(mobj);
rowIndex++;
}
开发者ID:Trex4Git,项目名称:dRonin,代码行数:21,代码来源:telemetryschedulergadgetwidget.cpp
示例20: switch
/**
* Process an byte from the telemetry stream.
* \param[in] rxbyte Received byte
* \return Success (true), Failure (false)
*/
bool UAVTalk::processInputByte(quint8 rxbyte)
{
if (!objMngr || !io) // Pip
return false;
// Update stats
stats.rxBytes++;
rxPacketLength++; // update packet byte count
// Receive state machine
switch (rxState)
{
case STATE_SYNC:
if (rxbyte != SYNC_VAL)
break;
// Initialize and update CRC
rxCS = updateCRC(0, rxbyte);
rxPacketLength = 1;
rxState = STATE_TYPE;
break;
case STATE_TYPE:
// Update CRC
rxCS = updateCRC(rxCS, rxbyte);
if ((rxbyte & TYPE_MASK) != TYPE_VER)
{
rxState = STATE_SYNC;
break;
}
rxType = rxbyte;
packetSize = 0;
rxState = STATE_SIZE;
rxCount = 0;
break;
case STATE_SIZE:
// Update CRC
rxCS = updateCRC(rxCS, rxbyte);
if (rxCount == 0)
{
packetSize += rxbyte;
rxCount++;
break;
}
packetSize += (quint32)rxbyte << 8;
if (packetSize < MIN_HEADER_LENGTH || packetSize > MAX_HEADER_LENGTH + MAX_PAYLOAD_LENGTH)
{ // incorrect packet size
rxState = STATE_SYNC;
break;
}
rxCount = 0;
rxState = STATE_OBJID;
break;
case STATE_OBJID:
// Update CRC
rxCS = updateCRC(rxCS, rxbyte);
rxTmpBuffer[rxCount++] = rxbyte;
if (rxCount < 4)
break;
// Search for object, if not found reset state machine
rxObjId = (qint32)qFromLittleEndian<quint32>(rxTmpBuffer);
{
UAVObject *rxObj = objMngr->getObject(rxObjId);
if (rxObj == NULL)
{
stats.rxErrors++;
rxState = STATE_SYNC;
break;
}
// Determine data length
if (rxType == TYPE_OBJ_REQ || rxType == TYPE_ACK)
rxLength = 0;
else
rxLength = rxObj->getNumBytes();
//.........这里部分代码省略.........
开发者ID:mcu786,项目名称:my_OpenPilot_mods,代码行数:101,代码来源:uavtalk.cpp
注:本文中的UAVObject类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论