// emit parseState(QString("<font color=\"green\">End of inclusion from file: %1</font>").arg(incFileName));
// }
// else
// {
// // Include file could not be opened
// emit parseState(QString("<font color=\"red\">ERROR: Failed including file: %1, file is not readable. Wrong/misspelled filename?\nAbort.</font>").arg(fileName));
// return false;
// }
// }
// // Handle all enum tags
// else if (e.tagName() == "version")
// {
// //QString fieldType = e.attribute("type", "");
// //QString fieldName = e.attribute("name", "");
// QString fieldText = e.text();
// // Check if version has been previously set
// if (mavlinkVersion != 0)
// {
// emit parseState(QString("<font color=\"red\">ERROR: Protocol version tag set twice, please use it only once. First version was %1, second version is %2.\nAbort.</font>").arg(mavlinkVersion).arg(fieldText));
// return false;
// }
// bool ok;
// int version = fieldText.toInt(&ok);
// if (ok && (version > 0) && (version < 256))
// {
// // Set MAVLink version
// mavlinkVersion = version;
// }
// else
// {
// emit parseState(QString("<font color=\"red\">ERROR: Reading version string failed: %1, string is not an integer number between 1 and 255.\nAbort.</font>").arg(fieldText));
// emit parseState(tr("<font color=\"red\">ERROR: Missing required name=\"\" attribute for tag %2 near line %1\nAbort.</font>").arg(QString::number(e.lineNumber()), e.tagName()));
// return false;
// }
// else
// {
// // Sanity check: Accept only enum names not used previously
// if (usedEnumNames->contains(enumName))
// {
// emit parseState(tr("<font color=\"red\">ERROR: Enum name %1 used twice, second occurence near line %2 of file %3\nAbort.</font>").arg(enumName, QString::number(e.lineNumber()), fileName));
// // If value was given, use it, if not, use the enum iterator
// // value. The iterator value gets reset by manual values
// QString fieldName = e2.attribute("name", "");
// if (fieldValue.length() == 0)
// {
// fieldValue = QString::number(nextEnumValue);
// nextEnumValue++;
// }
// else
// {
// bool ok;
// nextEnumValue = fieldValue.toInt(&ok) + 1;
// if (!ok)
// {
// emit parseState(tr("<font color=\"red\">ERROR: Enum entry %1 has not a valid number (%2) in the value field.\nAbort.</font>").arg(fieldName, fieldValue));
// return false;
// }
// }
// // Add comment of field if there is one
// QString fieldComment;
// if (e2.text().length() > 0)
// {
// QString sep(" | ");
// QDomNode pp = e2.firstChild();
// while (!pp.isNull())
// {
// QDomElement pp2 = pp.toElement();
// if (pp2.isText() || pp2.isCDATASection())
// {
// // If this is the only field, don't add the separator
// if (pp.nextSibling().isNull())
// {
// fieldComment += pp2.nodeValue();
// }
// else
// {
// fieldComment += pp2.nodeValue() + sep;
// }
// }
// else if (pp2.isElement())
// {
// // If this is the only field, don't add the separator
// emit parseState(tr("<font color=\"red\">ERROR: Missing required name=\"\" attribute for tag %2 near line %1\nAbort.</font>").arg(QString::number(e.lineNumber()), e.tagName()));
// return false;
// }
// else
// {
// // Get message id
// bool ok;
// int messageId = e.attribute("id", "-1").toInt(&ok, 10);
// // Sanity check: Accept only message IDs not used previously
// if (usedMessageIDs->contains(messageId))
// {
// emit parseState(tr("<font color=\"red\">ERROR: Message ID %1 used twice, second occurence near line %2 of file %3\nAbort.</font>").arg(QString::number(messageId), QString::number(e.lineNumber()), fileName));
// return false;
// }
// else
// {
// usedMessageIDs->append(messageId);
// }
// // Sanity check: Accept only message names not used previously
// if (usedMessageNames->contains(messageName))
// {
// emit parseState(tr("<font color=\"red\">ERROR: Message name %1 used twice, second occurence near line %2 of file %3\nAbort.</font>").arg(messageName, QString::number(e.lineNumber()), fileName));
// QString commentContainer("/**\n * @brief Pack a %1 message\n * @param system_id ID of this system\n * @param component_id ID of this component (e.g. 200 for IMU)\n * @param msg The MAVLink message to compress the data into\n *\n%2 * @return length of the message in bytes (excluding serial stream start sign)\n */\n");
// QString commentPackChanContainer("/**\n * @brief Pack a %1 message\n * @param system_id ID of this system\n * @param component_id ID of this component (e.g. 200 for IMU)\n * @param chan The MAVLink channel this message was sent over\n * @param msg The MAVLink message to compress the data into\n%2 * @return length of the message in bytes (excluding serial stream start sign)\n */\n");
// QString commentSendContainer("/**\n * @brief Send a %1 message\n * @param chan MAVLink channel to send the message\n *\n%2 */\n");
// QString commentEncodeContainer("/**\n * @brief Encode a %1 struct into a message\n *\n * @param system_id ID of this system\n * @param component_id ID of this component (e.g. 200 for IMU)\n * @param msg The MAVLink message to compress the data into\n * @param %1 C-struct to read the message contents from\n */\n");
// QString commentDecodeContainer("/**\n * @brief Decode a %1 message into a struct\n *\n * @param msg The message to decode\n * @param %1 C-struct to decode the message contents into\n */\n");
// // ARRAYS are not longer supported - leave error message in here to inform users!
// else if (fieldType.startsWith("array"))
// {
// emit parseState(tr("<font color=\"red\">ERROR: In message %1 deprecated type <array> used near line %2 of file %3. Please change from array[size] to uint8_t[size] to get the same behaviour.\nAbort.</font>").arg(messageName, QString::number(e.lineNumber()), fileName));
// return false;
// }
// else if (fieldType.startsWith("string"))
// {
// int arrayLength = QString(fieldType.split("[").at(1).split("]").first()).toInt();
// // String array is always unsigned char, so bytes
// emit parseState(tr("<font color=\"red\">ERROR: In message %1 invalid array type %4 used near line %2 of file %3\nAbort.</font>").arg(messageName, QString::number(e.lineNumber()), fileName, arrayType));
// emit parseState(tr("<font color=\"red\">ERROR: In message %1 inavlid type %4 used near line %2 of file %3\nAbort.</font>").arg(messageName, QString::number(e.lineNumber()), fileName, fieldType));
// emit parseState(tr("<font color=\"red\">ERROR: Unable to calculate length for %2 near line %1\nAbort.</font>").arg(QString::number(e.lineNumber()), fieldType));
// ok = mavlinkHeader.open(QIODevice::WriteOnly | QIODevice::Text);
// success = success && ok;
// QString mHeader = QString("/** @file\n *\t@brief MAVLink comm protocol.\n *\t@see http://pixhawk.ethz.ch/software/mavlink\n *\t Generated on %1\n */\n#ifndef MAVLINK_H\n#define MAVLINK_H\n\n").arg(date); // The main header includes all messages
QMessageBox::critical(this,tr("Please select an XML input file first"),tr("You have to select an input XML file before generating C files."),QMessageBox::Ok);
QMessageBox::critical(this,tr("Please select output directory first"),tr("You have to select an output directory before generating C files."),QMessageBox::Ok);