dRonin
adbada4
dRonin GCS
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Groups
Pages
uavobject.py
Go to the documentation of this file.
1
__all__ = (
"UAVObject"
)
2
3
##
4
##############################################################################
5
#
6
# @file uavobject.py
7
# @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
8
# @brief Base classes for python UAVObject
9
#
10
# @see The GNU Public License (GPL) Version 3
11
#
12
#############################################################################/
13
#
14
# This program is free software; you can redistribute it and/or modify
15
# it under the terms of the GNU General Public License as published by
16
# the Free Software Foundation; either version 3 of the License, or
17
# (at your option) any later version.
18
#
19
# This program is distributed in the hope that it will be useful, but
20
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
21
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22
# for more details.
23
#
24
# You should have received a copy of the GNU General Public License along
25
# with this program; if not, see <http://www.gnu.org/licenses/>
26
#
27
28
import
struct
29
from
collections
import
namedtuple
30
31
class
UAVMetaData
(object):
32
def
__init__
(self):
33
self.
telemetryAcked
= false
34
self.
telemetryUpdateMode
= 0
35
self.
telemetryUpdatePeriod
= 0
36
self.
gcsTelemetryAcked
= false
37
self.
gcsTelemetryUpdateMode
= 0
38
self.
gcsTelemetryUpdatePeriod
= 0
39
self.
loggingUpdateMode
= 0
40
self.
loggingUpdatePeriod
= 0
41
42
class
UAVObject
(object):
43
def
__init__
(self, objid, name, metaname, instanceid, issingle):
44
self.
objid
= objid
45
self.
name
= name
46
self.
metaname
= metaname
47
self.
instanceid
= instanceid
48
self.
issingle
= issingle
49
50
self.
fields
= []
51
52
uavobjects[objid] = self
53
54
def
add_field
(self, field):
55
self.fields.append(field)
56
57
def
get_struct
(self):
58
fmt =
"<"
59
for
f
in
self.
fields
:
60
fmt += f.get_struct()
61
return
struct.Struct(fmt)
62
63
def
get_tuple
(self):
64
fieldnames =
' '
.join([f.name
for
f
in
self.
fields
])
65
return
namedtuple (self.
name
, fieldnames)
66
67
def
get_size
(self):
68
return
self.
get_struct
().size
69
70
class
UAVObjectField
(object):
71
def
__init__
(self, fieldname, type, nelements, elemnames, values):
72
self.
name
= fieldname
73
self.
type
= type
74
self.
nelements
= nelements
75
self.
elemnames
= elemnames
76
self.
values
= values
77
78
def
get_struct
(self):
79
fmt =
""
80
if
self.
nelements
> 1:
81
fmt +=
"%u"
% self.
nelements
82
fmt +=
"%s"
% (self.
type
)
83
return
fmt
84
85
# List of registered uavobject instances
86
uavobjects = {}
87
88
def
main
():
89
pass
90
91
if
__name__ ==
"__main__"
:
92
#import pdb ; pdb.run('main()')
93
main
()
uavobject.UAVObject.issingle
issingle
Definition:
uavobject.py:48
uavobject.UAVObject.__init__
def __init__
Definition:
uavobject.py:43
uavobject.UAVMetaData.telemetryUpdateMode
telemetryUpdateMode
Definition:
uavobject.py:34
uavobject.UAVMetaData.gcsTelemetryUpdateMode
gcsTelemetryUpdateMode
Definition:
uavobject.py:37
uavobject.UAVObjectField.type
type
Definition:
uavobject.py:73
uavobject.UAVMetaData.loggingUpdatePeriod
loggingUpdatePeriod
Definition:
uavobject.py:40
uavobject.UAVObject
Definition:
uavobject.py:42
uavobject.UAVMetaData.gcsTelemetryAcked
gcsTelemetryAcked
Definition:
uavobject.py:36
uavobject.UAVMetaData.telemetryAcked
telemetryAcked
Definition:
uavobject.py:33
uavobject.UAVObject.objid
objid
Definition:
uavobject.py:44
uavobject.UAVMetaData.telemetryUpdatePeriod
telemetryUpdatePeriod
Definition:
uavobject.py:35
uavobject.UAVObjectField.elemnames
elemnames
Definition:
uavobject.py:75
uavobject.UAVObjectField
Definition:
uavobject.py:70
uavobject.UAVObject.name
name
Definition:
uavobject.py:45
uavobject.UAVObjectField.get_struct
def get_struct
Definition:
uavobject.py:78
uavobject.UAVObject.get_tuple
def get_tuple
Definition:
uavobject.py:63
uavobject.UAVObject.instanceid
instanceid
Definition:
uavobject.py:47
uavobject.main
def main
Definition:
uavobject.py:88
uavobject.UAVMetaData.gcsTelemetryUpdatePeriod
gcsTelemetryUpdatePeriod
Definition:
uavobject.py:38
uavobject.UAVObject.add_field
def add_field
Definition:
uavobject.py:54
uavobject.UAVObjectField.values
values
Definition:
uavobject.py:76
uavobject.UAVMetaData.loggingUpdateMode
loggingUpdateMode
Definition:
uavobject.py:39
uavobject.UAVMetaData.__init__
def __init__
Definition:
uavobject.py:32
uavobject.UAVObjectField.__init__
def __init__
Definition:
uavobject.py:71
uavobject.UAVObject.fields
fields
Definition:
uavobject.py:50
uavobject.UAVObject.get_struct
def get_struct
Definition:
uavobject.py:57
uavobject.UAVObject.get_size
def get_size
Definition:
uavobject.py:67
uavobject.UAVMetaData
Definition:
uavobject.py:31
uavobject.UAVObjectField.name
name
Definition:
uavobject.py:72
uavobject.UAVObject.metaname
metaname
Definition:
uavobject.py:46
uavobject.UAVObjectField.nelements
nelements
Definition:
uavobject.py:74
ground
gcs
src
plugins
uavobjects
uavobject.py
Generated by
1.8.6