本文整理汇总了C++中UAVDataObject::getIsPresentOnHardware方法的典型用法代码示例。如果您正苦于以下问题:C++ UAVDataObject::getIsPresentOnHardware方法的具体用法?C++ UAVDataObject::getIsPresentOnHardware怎么用?C++ UAVDataObject::getIsPresentOnHardware使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UAVDataObject
的用法示例。
在下文中一共展示了UAVDataObject::getIsPresentOnHardware方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: importUAVSettings
// Slot called by the menu manager on user action
void UAVSettingsImportExportFactory::importUAVSettings()
{
// ask for file name
QString fileName;
QString filters = tr("UAVObjects XML files (*.uav);; XML files (*.xml)");
fileName = QFileDialog::getOpenFileName(0, tr("Import UAV Settings"), "", filters);
if (fileName.isEmpty()) {
return;
}
// Now open the file
QFile file(fileName);
QDomDocument doc("UAVObjects");
file.open(QFile::ReadOnly|QFile::Text);
if (!doc.setContent(file.readAll())) {
QMessageBox msgBox;
msgBox.setText(tr("File Parsing Failed."));
msgBox.setInformativeText(tr("This file is not a correct XML file"));
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.exec();
return;
}
file.close();
// find the root of settings subtree
emit importAboutToBegin();
qDebug()<<"Import about to begin";
QDomElement root = doc.documentElement();
if (root.tagName() == "uavobjects") {
root = root.firstChildElement("settings");
}
if (root.isNull() || (root.tagName() != "settings")) {
QMessageBox msgBox;
msgBox.setText(tr("Wrong file contents"));
msgBox.setInformativeText(tr("This file does not contain correct UAVSettings"));
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.exec();
return;
}
// We are now ok: setup the import summary dialog & update it as we
// go along.
ImportSummaryDialog swui((QWidget*)Core::ICore::instance()->mainWindow());
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
swui.show();
QDomNode node = root.firstChild();
while (!node.isNull()) {
QDomElement e = node.toElement();
if (e.tagName() == "object") {
// - Read each object
QString uavObjectName = e.attribute("name");
uint uavObjectID = e.attribute("id").toUInt(NULL,16);
// Sanity Check:
UAVObject *obj = objManager->getObject(uavObjectName);
UAVDataObject *dobj = dynamic_cast<UAVDataObject*>(obj);
if (obj == NULL) {
// This object is unknown!
qDebug() << "Object unknown:" << uavObjectName << uavObjectID;
swui.addLine(uavObjectName, "Error (Object unknown)", false);
} else if(dobj && !dobj->getIsPresentOnHardware()) {
swui.addLine(uavObjectName, "Error (Object not present on hw)", false);
} else {
// - Update each field
// - Issue and "updated" command
bool error = false;
bool setError = false;
QDomNode field = node.firstChild();
while(!field.isNull()) {
QDomElement f = field.toElement();
if (f.tagName() == "field") {
UAVObjectField *uavfield = obj->getField(f.attribute("name"));
if (uavfield) {
QStringList list = f.attribute("values").split(",");
if (list.length() == 1) {
if (false == uavfield->checkValue(f.attribute("values"))) {
qDebug() << "checkValue returned false on: " << uavObjectName << f.attribute("values");
setError = true;
} else {
uavfield->setValue(f.attribute("values"));
}
} else {
// This is an enum:
int i = 0;
QStringList list = f.attribute("values").split(",");
foreach (QString element, list) {
if (false == uavfield->checkValue(element, i)) {
qDebug() << "checkValue(list) returned false on: " << uavObjectName << list;
setError = true;
} else {
uavfield->setValue(element,i);
}
i++;
}
//.........这里部分代码省略.........