43 #define UAVOBJ_ACCESS_SHIFT 0
44 #define UAVOBJ_GCS_ACCESS_SHIFT 1
45 #define UAVOBJ_TELEMETRY_ACKED_SHIFT 2
46 #define UAVOBJ_GCS_TELEMETRY_ACKED_SHIFT 3
47 #define UAVOBJ_TELEMETRY_UPDATE_MODE_SHIFT 4
48 #define UAVOBJ_GCS_TELEMETRY_UPDATE_MODE_SHIFT 6
49 #define UAVOBJ_UPDATE_MODE_MASK 0x3
52 #define SET_BITS(var, shift, value, mask) var = (var & ~(mask << shift)) | (value << shift);
89 for (
int n = 0;
n < fields.length(); ++
n) {
90 fields[
n]->initialize(data, offset,
this);
91 offset += fields[
n]->getNumBytes();
207 QJsonObject obj, fieldMap;
209 obj[
"id"] =
static_cast<qint64
>(
getObjID());
217 for (
unsigned int n = 0;
n < nelem; ++
n) {
221 fieldMap[field->
getName()] = QJsonArray::fromVariantList(vals);
223 fieldMap[field->
getName()] = QJsonValue::fromVariant(field->
getValue(0));
227 obj[
"fields"] = fieldMap;
239 for (
int n = 0;
n <
fields.length(); ++
n) {
240 if (name.compare(
fields[
n]->getName()) == 0) {
245 qWarning() <<
"UAVObject::getField Non existant field " << name
246 <<
" requested. This indicates a bug. Make sure you also have null checking for "
260 field->
pack(&dataOut[offset]);
275 field->
unpack(&dataIn[offset]);
301 sout.append(QString(
"%1 (ID: %2, InstID: %3, NumBytes: %4, SInst: %5)\n")
316 sout.append(
"Data:\n");
319 sout.append(QString(
"\t%1").arg(field->
toString()));
363 |
ACCESS_READWRITE << UAVOBJ_GCS_ACCESS_SHIFT | 1 << UAVOBJ_TELEMETRY_ACKED_SHIFT
364 | 1 << UAVOBJ_GCS_TELEMETRY_ACKED_SHIFT
367 metadata.flightTelemetryUpdatePeriod = 0;
368 metadata.gcsTelemetryUpdatePeriod = 0;
369 metadata.loggingUpdatePeriod = 0;
389 SET_BITS(metadata.flags, UAVOBJ_ACCESS_SHIFT, mode, 1);
409 SET_BITS(metadata.flags, UAVOBJ_GCS_ACCESS_SHIFT, mode, 1);
419 return (metadata.flags >> UAVOBJ_TELEMETRY_ACKED_SHIFT) & 1;
429 SET_BITS(metadata.flags, UAVOBJ_TELEMETRY_ACKED_SHIFT, val, 1);
439 return (metadata.flags >> UAVOBJ_GCS_TELEMETRY_ACKED_SHIFT) & 1;
449 SET_BITS(metadata.flags, UAVOBJ_GCS_TELEMETRY_ACKED_SHIFT, val, 1);
460 & UAVOBJ_UPDATE_MODE_MASK);
471 SET_BITS(metadata.flags, UAVOBJ_TELEMETRY_UPDATE_MODE_SHIFT, val, UAVOBJ_UPDATE_MODE_MASK);
482 & UAVOBJ_UPDATE_MODE_MASK);
492 SET_BITS(metadata.flags, UAVOBJ_GCS_TELEMETRY_UPDATE_MODE_SHIFT, val, UAVOBJ_UPDATE_MODE_MASK);
void initializeFields(QList< UAVObjectField * > &fields, quint8 *data, quint32 numBytes)
void emitTransactionCompleted(bool success)
qint32 unpack(const quint8 *dataIn)
qint32 unpack(const quint8 *dataIn)
size_t getNumBytes() const
qint32 pack(quint8 *dataOut)
static void SetFlightTelemetryAcked(Metadata &meta, quint8 val)
static UpdateMode GetFlightTelemetryUpdateMode(const Metadata &meta)
static void SetFlightAccess(Metadata &meta, AccessMode mode)
QVariant getValue(int index=0) const
QList< UAVObjectField * > fields
static void SetGcsTelemetryAcked(Metadata &meta, quint8 val)
void objectUnpacked(UAVObject *obj)
objectUnpacked: triggered whenever an object is unpacked (i.e. arrives from the telemetry link) ...
static UpdateMode GetGcsTelemetryUpdateMode(const Metadata &meta)
static quint8 GetFlightTelemetryAcked(const Metadata &meta)
int getNumElements() const
void emitInstanceRemoved(UAVObject *)
QJsonObject getJsonRepresentation()
void objectUpdated(UAVObject *obj)
Signal sent whenever any field of the object is updated.
static void SetGcsAccess(Metadata &meta, AccessMode mode)
static void SetFlightTelemetryUpdateMode(Metadata &meta, UpdateMode val)
UAVObject(quint32 objID, bool isSingleInst, const QString &name)
void transactionCompleted(UAVObject *obj, bool success)
transactionCompleted. Triggered by a call to emitTransactionCompleted - done in telemetry.cpp whenever a transaction finishes.
UAVObjectField * getField(const QString &name)
QList< UAVObjectField * > getFields()
void updateRequested(UAVObject *obj)
updateRequested
void newInstance(UAVObject *obj)
newInstance
void updateAllInstancesRequested(UAVObject *obj)
updateAllInstancesRequested
void emitNewInstance(UAVObject *)
void initialize(quint32 instID)
static AccessMode GetFlightAccess(const Metadata &meta)
void fieldUpdated(UAVObjectField *field)
qint32 pack(quint8 *dataOut)
static void SetGcsTelemetryUpdateMode(Metadata &meta, UpdateMode val)
void setDescription(const QString &description)
void objectUpdatedManual(UAVObject *obj)
objectUpdatedManual: triggered only from the "updated" slot in uavobject The telemetry manager listen...
void requestUpdateAllInstances()
static void MetadataInitialize(Metadata &meta)
static quint8 GetGcsTelemetryAcked(const Metadata &meta)
static AccessMode GetGcsAccess(const Metadata &meta)
void instanceRemoved(UAVObject *obj)
instance removed from manager