dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
uavdataobject.cpp
Go to the documentation of this file.
1 
17 /*
18  * This program is free software; you can redistribute it and/or modify
19  * it under the terms of the GNU General Public License as published by
20  * the Free Software Foundation; either version 3 of the License, or
21  * (at your option) any later version.
22  *
23  * This program is distributed in the hope that it will be useful, but
24  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
25  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
26  * for more details.
27  *
28  * You should have received a copy of the GNU General Public License along
29  * with this program; if not, see <http://www.gnu.org/licenses/>
30  *
31  * Additional note on redistribution: The copyright and license notices above
32  * must be maintained in each individual source file that is a derivative work
33  * of this source file; otherwise redistribution is prohibited.
34  */
35 
36 #include "uavdataobject.h"
37 
41 UAVDataObject::UAVDataObject(quint32 objID, bool isSingleInst, bool isSet, const QString &name)
42  : UAVObject(objID, isSingleInst, name)
43 {
44  mobj = NULL;
45  this->isSet = isSet;
46  this->isPresentOnHardware = unknownPresent;
47 
48  connect(this, &UAVObject::objectUnpacked,
50 }
51 
55 void UAVDataObject::initialize(quint32 instID, UAVMetaObject *mobj)
56 {
57  this->mobj = mobj;
58  UAVObject::initialize(instID);
59 }
60 
65 {
66  this->mobj = mobj;
67 }
68 
73 {
74  return isSet;
75 }
76 
80 void UAVDataObject::setMetadata(const Metadata &mdata)
81 {
82  if (mobj != NULL) {
83  mobj->setData(mdata);
84  }
85 }
86 
90 UAVObject::Metadata UAVDataObject::getMetadata(void)
91 {
92  if (mobj != NULL) {
93  return mobj->getData();
94  } else {
95  return getDefaultMetadata();
96  }
97 }
98 
103 {
104  return mobj;
105 }
106 
108 {
109  return (isPresentOnHardware != unknownPresent);
110 }
111 
113 {
114  return (isPresentOnHardware == isPresent) ||
115  (isPresentOnHardware == isPresentAndReceived);
116 }
117 
119 {
120  bool temp = getIsPresentOnHardware();
121 
122  isPresentOnHardware = isPresentAndReceived;
123 
124  if (temp != getIsPresentOnHardware()) {
125  emit presentOnHardwareChanged(this);
126  emit presentOnHardwareChanged(true);
127  }
128 }
129 
131 {
132  return (isPresentOnHardware == isPresentAndReceived);
133 }
134 
136 {
137  bool temp = getIsPresentOnHardware();
138 
139  if (value) {
140  isPresentOnHardware = isPresent;
141  } else {
142  isPresentOnHardware = notPresent;
143  }
144 
145  if (temp != getIsPresentOnHardware()) {
146  emit presentOnHardwareChanged(this);
147  emit presentOnHardwareChanged(value);
148  }
149 }
150 
152 {
153  enum presence old = isPresentOnHardware;
154 
155  isPresentOnHardware = unknownPresent;
156 
157  if (old == isPresent) {
158  emit presentOnHardwareChanged(this);
159  emit presentOnHardwareChanged(false);
160  }
161 }
virtual Metadata getDefaultMetadata()=0
void initialize(quint32 instID, UAVMetaObject *mobj)
void setMetadata(const Metadata &mdata)
void setData(const Metadata &mdata)
void objectUnpacked(UAVObject *obj)
objectUnpacked: triggered whenever an object is unpacked (i.e. arrives from the telemetry link) ...
bool isPresentOnHardware
Definition: uavdataobject.h:40
UAVMetaObject * getMetaObject()
bool getIsPresentOnHardware() const
UAVDataObject(quint32 objID, bool isSingleInst, bool isSet, const QString &name)
void resetIsPresentOnHardware()
Metadata getMetadata()
void initialize(quint32 instID)
Definition: uavobject.cpp:71
bool getPresenceKnown() const
void setIsPresentOnHardware(bool value=true)
Metadata getData()
void presentOnHardwareChanged(UAVDataObject *)