mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-03-01 18:29:16 +01:00
OP-1395 - Handles and unpack multiple uavos in single Debug Log Slot, default interval set to 500ms,
This commit is contained in:
parent
55b325966a
commit
80169e998f
@ -7,7 +7,7 @@ import org.openpilot 1.0
|
|||||||
import "functions.js" as Functions
|
import "functions.js" as Functions
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
width: 600
|
width: 700
|
||||||
height: 400
|
height: 400
|
||||||
id: root
|
id: root
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
@ -59,11 +59,11 @@ Rectangle {
|
|||||||
delegate:
|
delegate:
|
||||||
Text {
|
Text {
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
text: Functions.millisToTime(styleData.value)
|
text: Functions.microsToTime(styleData.value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TableViewColumn {
|
TableViewColumn {
|
||||||
role: "Type"; title: "Type"; width: 60;
|
role: "Type"; title: "Type"; width: 50;
|
||||||
delegate:
|
delegate:
|
||||||
Text {
|
Text {
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
@ -72,6 +72,7 @@ Rectangle {
|
|||||||
case 0 : text: qsTr("Empty"); break;
|
case 0 : text: qsTr("Empty"); break;
|
||||||
case 1 : text: qsTr("Text"); break;
|
case 1 : text: qsTr("Text"); break;
|
||||||
case 2 : text: qsTr("UAVO"); break;
|
case 2 : text: qsTr("UAVO"); break;
|
||||||
|
case 3 : text: qsTr("UAVO(P)"); break;
|
||||||
default: text: qsTr("Unknown"); break;
|
default: text: qsTr("Unknown"); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -96,10 +97,14 @@ Rectangle {
|
|||||||
text: "<b>" + qsTr("Flights recorded: ") + "</b>" + (logStatus.Flight + 1)
|
text: "<b>" + qsTr("Flights recorded: ") + "</b>" + (logStatus.Flight + 1)
|
||||||
}
|
}
|
||||||
Text {
|
Text {
|
||||||
id: totalEntries
|
id: totalSlots
|
||||||
text: "<b>" + qsTr("Entries logged (free): ") + "</b>" +
|
text: "<b>" + qsTr("Slot used (free): ") + "</b>" +
|
||||||
logStatus.UsedSlots + " (" + logStatus.FreeSlots + ")"
|
logStatus.UsedSlots + " (" + logStatus.FreeSlots + ")"
|
||||||
}
|
}
|
||||||
|
Text {
|
||||||
|
id: totalEntries
|
||||||
|
text: "<b>" + qsTr("Entries logged: ") + "</b>" + logManager.uavoEntries.count
|
||||||
|
}
|
||||||
Rectangle {
|
Rectangle {
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
}
|
}
|
||||||
|
@ -205,21 +205,47 @@ void FlightLogManager::retrieveLogs(int flightToRetrieve)
|
|||||||
for (int flight = startFlight; flight <= endFlight; flight++) {
|
for (int flight = startFlight; flight <= endFlight; flight++) {
|
||||||
m_flightLogControl->setFlight(flight);
|
m_flightLogControl->setFlight(flight);
|
||||||
bool gotLast = false;
|
bool gotLast = false;
|
||||||
int entry = 0;
|
int slot = 0;
|
||||||
while (!gotLast) {
|
while (!gotLast) {
|
||||||
// Send request for loading flight entry on flight side and wait for ack/nack
|
// Send request for loading flight entry on flight side and wait for ack/nack
|
||||||
m_flightLogControl->setEntry(entry);
|
m_flightLogControl->setEntry(slot);
|
||||||
|
|
||||||
if (updateHelper.doObjectAndWait(m_flightLogControl, UAVTALK_TIMEOUT) == UAVObjectUpdaterHelper::SUCCESS &&
|
if (updateHelper.doObjectAndWait(m_flightLogControl, UAVTALK_TIMEOUT) == UAVObjectUpdaterHelper::SUCCESS &&
|
||||||
requestHelper.doObjectAndWait(m_flightLogEntry, UAVTALK_TIMEOUT) == UAVObjectUpdaterHelper::SUCCESS) {
|
requestHelper.doObjectAndWait(m_flightLogEntry, UAVTALK_TIMEOUT) == UAVObjectUpdaterHelper::SUCCESS) {
|
||||||
if (m_flightLogEntry->getType() != DebugLogEntry::TYPE_EMPTY) {
|
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
|
// Ok, we retrieved the entry, and it was the correct one. clone it and add it to the list
|
||||||
ExtendedDebugLogEntry *logEntry = new ExtendedDebugLogEntry();
|
ExtendedDebugLogEntry *logEntry = new ExtendedDebugLogEntry();
|
||||||
|
|
||||||
logEntry->setData(m_flightLogEntry->getData(), m_objectManager);
|
logEntry->setData(m_flightLogEntry->getData(), m_objectManager);
|
||||||
m_logEntries << logEntry;
|
m_logEntries << logEntry;
|
||||||
|
if (logEntry->getData().Type == DebugLogEntry::TYPE_MULTIPLEUAVOBJECTS) {
|
||||||
|
const quint32 total_len = sizeof(DebugLogEntry::DataFields);
|
||||||
|
const quint32 data_len = sizeof(((DebugLogEntry::DataFields *)0)->Data);
|
||||||
|
const quint32 header_len = total_len - data_len;
|
||||||
|
|
||||||
|
DebugLogEntry::DataFields fields;
|
||||||
|
quint32 start = logEntry->getData().Size;
|
||||||
|
|
||||||
|
// cycle until there is space for another object
|
||||||
|
while (start + header_len + 1 < data_len) {
|
||||||
|
memset(&fields, 0xFF, total_len);
|
||||||
|
memcpy(&fields, &logEntry->getData().Data[start], header_len);
|
||||||
|
// check wether a packed object is found
|
||||||
|
// note that empty data blocks are set as 0xFF in flight side to minimize flash wearing
|
||||||
|
// thus as soon as this read outside of used area, the test will fail as lenght would be 0xFFFF
|
||||||
|
quint32 toread = header_len + fields.Size;
|
||||||
|
if (!(toread + start > data_len)) {
|
||||||
|
memcpy(&fields, &logEntry->getData().Data[start], toread);
|
||||||
|
ExtendedDebugLogEntry *subEntry = new ExtendedDebugLogEntry();
|
||||||
|
subEntry->setData(fields, m_objectManager);
|
||||||
|
m_logEntries << subEntry;
|
||||||
|
}
|
||||||
|
start += toread;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Increment to get next entry from flight side
|
// Increment to get next entry from flight side
|
||||||
entry++;
|
slot++;
|
||||||
} else {
|
} else {
|
||||||
// We are done, not more entries on this flight
|
// We are done, not more entries on this flight
|
||||||
gotLast = true;
|
gotLast = true;
|
||||||
@ -280,7 +306,7 @@ void FlightLogManager::exportToOPL(QString fileName)
|
|||||||
ExtendedDebugLogEntry *entry = m_logEntries[currentEntry];
|
ExtendedDebugLogEntry *entry = m_logEntries[currentEntry];
|
||||||
|
|
||||||
// Only log uavobjects
|
// Only log uavobjects
|
||||||
if (entry->getType() == ExtendedDebugLogEntry::TYPE_UAVOBJECT) {
|
if (entry->getType() == ExtendedDebugLogEntry::TYPE_UAVOBJECT || entry->getType() == ExtendedDebugLogEntry::TYPE_MULTIPLEUAVOBJECTS) {
|
||||||
// Set timestamp that should be logged for this entry
|
// Set timestamp that should be logged for this entry
|
||||||
logFile.setNextTimeStamp(entry->getFlightTime() - adjustedBaseTime);
|
logFile.setNextTimeStamp(entry->getFlightTime() - adjustedBaseTime);
|
||||||
|
|
||||||
@ -615,7 +641,7 @@ QString ExtendedDebugLogEntry::getLogString()
|
|||||||
{
|
{
|
||||||
if (getType() == DebugLogEntry::TYPE_TEXT) {
|
if (getType() == DebugLogEntry::TYPE_TEXT) {
|
||||||
return QString((const char *)getData().Data);
|
return QString((const char *)getData().Data);
|
||||||
} else if (getType() == DebugLogEntry::TYPE_UAVOBJECT) {
|
} else if (getType() == DebugLogEntry::TYPE_UAVOBJECT || getType() == DebugLogEntry::TYPE_MULTIPLEUAVOBJECTS) {
|
||||||
return m_object->toString().replace("\n", " ").replace("\t", " ");
|
return m_object->toString().replace("\n", " ").replace("\t", " ");
|
||||||
} else {
|
} else {
|
||||||
return "";
|
return "";
|
||||||
@ -631,7 +657,7 @@ void ExtendedDebugLogEntry::toXML(QXmlStreamWriter *xmlWriter, quint32 baseTime)
|
|||||||
if (getType() == DebugLogEntry::TYPE_TEXT) {
|
if (getType() == DebugLogEntry::TYPE_TEXT) {
|
||||||
xmlWriter->writeAttribute("type", "text");
|
xmlWriter->writeAttribute("type", "text");
|
||||||
xmlWriter->writeTextElement("message", QString((const char *)getData().Data));
|
xmlWriter->writeTextElement("message", QString((const char *)getData().Data));
|
||||||
} else if (getType() == DebugLogEntry::TYPE_UAVOBJECT) {
|
} else if (getType() == DebugLogEntry::TYPE_UAVOBJECT || getType() == DebugLogEntry::TYPE_MULTIPLEUAVOBJECTS) {
|
||||||
xmlWriter->writeAttribute("type", "uavobject");
|
xmlWriter->writeAttribute("type", "uavobject");
|
||||||
m_object->toXML(xmlWriter);
|
m_object->toXML(xmlWriter);
|
||||||
}
|
}
|
||||||
@ -644,7 +670,7 @@ void ExtendedDebugLogEntry::toCSV(QTextStream *csvStream, quint32 baseTime)
|
|||||||
|
|
||||||
if (getType() == DebugLogEntry::TYPE_TEXT) {
|
if (getType() == DebugLogEntry::TYPE_TEXT) {
|
||||||
data = QString((const char *)getData().Data);
|
data = QString((const char *)getData().Data);
|
||||||
} else if (getType() == DebugLogEntry::TYPE_UAVOBJECT) {
|
} else if (getType() == DebugLogEntry::TYPE_UAVOBJECT || getType() == DebugLogEntry::TYPE_MULTIPLEUAVOBJECTS) {
|
||||||
data = m_object->toString().replace("\n", "").replace("\t", "");
|
data = m_object->toString().replace("\n", "").replace("\t", "");
|
||||||
}
|
}
|
||||||
*csvStream << QString::number(getFlight() + 1) << '\t' << QString::number(getFlightTime() - baseTime) << '\t' << QString::number(getEntry()) << '\t' << data << '\n';
|
*csvStream << QString::number(getFlight() + 1) << '\t' << QString::number(getFlightTime() - baseTime) << '\t' << QString::number(getEntry()) << '\t' << data << '\n';
|
||||||
@ -654,7 +680,7 @@ void ExtendedDebugLogEntry::setData(const DebugLogEntry::DataFields &data, UAVOb
|
|||||||
{
|
{
|
||||||
DebugLogEntry::setData(data);
|
DebugLogEntry::setData(data);
|
||||||
|
|
||||||
if (getType() == DebugLogEntry::TYPE_UAVOBJECT) {
|
if (getType() == DebugLogEntry::TYPE_UAVOBJECT || getType() == DebugLogEntry::TYPE_MULTIPLEUAVOBJECTS) {
|
||||||
UAVDataObject *object = (UAVDataObject *)objectManager->getObject(getObjectID(), getInstanceID());
|
UAVDataObject *object = (UAVDataObject *)objectManager->getObject(getObjectID(), getInstanceID());
|
||||||
Q_ASSERT(object);
|
Q_ASSERT(object);
|
||||||
m_object = object->clone(getInstanceID());
|
m_object = object->clone(getInstanceID());
|
||||||
|
@ -94,6 +94,10 @@ public slots:
|
|||||||
setDirty(true);
|
setDirty(true);
|
||||||
if (m_setting != 1 && m_setting != 3) {
|
if (m_setting != 1 && m_setting != 3) {
|
||||||
setPeriod(0);
|
setPeriod(0);
|
||||||
|
} else {
|
||||||
|
if (!period()) {
|
||||||
|
setPeriod(500);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
emit settingChanged(setting);
|
emit settingChanged(setting);
|
||||||
}
|
}
|
||||||
@ -240,7 +244,6 @@ public:
|
|||||||
{
|
{
|
||||||
return m_loggingEnabled;
|
return m_loggingEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void logEntriesChanged();
|
void logEntriesChanged();
|
||||||
void flightEntriesChanged();
|
void flightEntriesChanged();
|
||||||
|
@ -11,6 +11,12 @@ function millisToTime(ms) {
|
|||||||
return pad(hours, 2) + ":" + pad(minutes, 2) + ":" + pad(seconds, 2) + ":" + pad(msleft, 3);
|
return pad(hours, 2) + ":" + pad(minutes, 2) + ":" + pad(seconds, 2) + ":" + pad(msleft, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function microsToTime(us) {
|
||||||
|
var ms = Math.floor(us / 1000);
|
||||||
|
return millisToTime(ms);
|
||||||
|
}
|
||||||
|
|
||||||
function pad(number, length) {
|
function pad(number, length) {
|
||||||
var str = '' + number;
|
var str = '' + number;
|
||||||
while (str.length < length) {
|
while (str.length < length) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user