本文整理汇总了Python中auvsi_suas.models.uas_telemetry.UasTelemetry.by_user方法的典型用法代码示例。如果您正苦于以下问题:Python UasTelemetry.by_user方法的具体用法?Python UasTelemetry.by_user怎么用?Python UasTelemetry.by_user使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类auvsi_suas.models.uas_telemetry.UasTelemetry
的用法示例。
在下文中一共展示了UasTelemetry.by_user方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_kml_simple
# 需要导入模块: from auvsi_suas.models.uas_telemetry import UasTelemetry [as 别名]
# 或者: from auvsi_suas.models.uas_telemetry.UasTelemetry import by_user [as 别名]
def test_kml_simple(self):
coordinates = [
(-76.0, 38.0, 0.0),
(-76.0, 38.0, 10.0),
(-76.0, 38.0, 20.0),
(-76.0, 38.0, 30.0),
(-76.0, 38.0, 100.0),
(-76.0, 38.0, 30.0),
(-76.0, 38.0, 60.0),
]
# Create Coordinates
start = TakeoffOrLandingEvent(user=self.user, uas_in_air=True)
start.save()
for coord in coordinates:
self.create_log_element(*coord)
end = TakeoffOrLandingEvent(user=self.user, uas_in_air=False)
end.save()
kml = Kml()
UasTelemetry.kml(user=self.user,
logs=UasTelemetry.by_user(self.user),
kml=kml,
kml_doc=kml)
for coord in coordinates:
tag = self.coord_format.format(coord[1], coord[0],
units.feet_to_meters(coord[2]))
self.assertTrue(tag in kml.kml())
示例2: test_by_user_time_restrict
# 需要导入模块: from auvsi_suas.models.uas_telemetry import UasTelemetry [as 别名]
# 或者: from auvsi_suas.models.uas_telemetry.UasTelemetry import by_user [as 别名]
def test_by_user_time_restrict(self):
start = timezone.now()
delta = datetime.timedelta(seconds=1)
expect_logs = self.create_logs(self.user1,
num=10,
start=start,
delta=delta)
logs = UasTelemetry.by_user(self.user1,
start_time=start,
end_time=start + delta * 10)
self.assertSequenceEqual(expect_logs, logs)
logs = UasTelemetry.by_user(self.user1, start_time=start + delta * 11)
self.assertSequenceEqual([], logs)
logs = UasTelemetry.by_user(self.user1, end_time=start)
self.assertSequenceEqual([], logs)
示例3: test_basic_access
# 需要导入模块: from auvsi_suas.models.uas_telemetry import UasTelemetry [as 别名]
# 或者: from auvsi_suas.models.uas_telemetry.UasTelemetry import by_user [as 别名]
def test_basic_access(self):
start = timezone.now() - datetime.timedelta(seconds=10)
logs = self.create_logs(self.user1, start=start)
log = UasTelemetry.last_for_user(self.user1)
self.assertEqual(logs[-1], log)
results = UasTelemetry.by_user(self.user1)
self.assertSequenceEqual(logs, results)
示例4: test_multi_user
# 需要导入模块: from auvsi_suas.models.uas_telemetry import UasTelemetry [as 别名]
# 或者: from auvsi_suas.models.uas_telemetry.UasTelemetry import by_user [as 别名]
def test_multi_user(self):
# Intersperse logs from two users
logs = []
for _ in xrange(10):
logs += self.create_logs(self.user1, num=1)
self.create_logs(self.user2, num=1)
log = UasTelemetry.last_for_user(self.user1)
self.assertEqual(logs[-1], log)
results = UasTelemetry.by_user(self.user1)
self.assertSequenceEqual(logs, results)
示例5: test_no_data
# 需要导入模块: from auvsi_suas.models.uas_telemetry import UasTelemetry [as 别名]
# 或者: from auvsi_suas.models.uas_telemetry.UasTelemetry import by_user [as 别名]
def test_no_data(self):
log = UasTelemetry.last_for_user(self.user1)
self.assertEqual(None, log)
logs = UasTelemetry.by_user(self.user1)
self.assertEqual(len(logs), 0)
logs = UasTelemetry.by_time_period(self.user1, [])
self.assertSequenceEqual([], logs)
log_rates = UasTelemetry.rates(self.user1, [])
self.assertTupleEqual(log_rates, (None, None))
示例6: test_kml
# 需要导入模块: from auvsi_suas.models.uas_telemetry import UasTelemetry [as 别名]
# 或者: from auvsi_suas.models.uas_telemetry.UasTelemetry import by_user [as 别名]
def test_kml(self):
"""
Tests the generation of kml data
The correct number of elements are generated
The meta-data tag is present
"""
array_field_tag = '<gx:SimpleArrayField name="proximity" type="float">'
coordinates = [
(-76.0, 38.0, 0.0),
(-76.0, 38.0, 10.0),
(-76.0, 38.0, 20.0),
(-76.0, 38.0, 30.0),
(-76.0, 38.0, 100.0),
(-76.0, 38.0, 30.0),
(-76.0, 38.0, 60.0),
]
user = User.objects.create_user('testuser', '[email protected]',
'testpass')
user.save()
# Create Coordinates
start_time = timezone.now()
next_time = start_time
end_time = start_time
for coord in coordinates:
self.create_log_element(*coord, user=user, log_time=next_time)
end_time = next_time
next_time += datetime.timedelta(seconds=1)
# Calculate expected number of data tags
time_delta = end_time - start_time
ms_elapsed = time_delta.total_seconds() * 1000
kml_output_resolution = 100 # milliseconds
samples_expected = int(ms_elapsed / kml_output_resolution)
for cur_obst in self.obstacles:
kml = Kml()
kml_mission = kml.newfolder(name='SubFolder')
cur_obst.kml(path=UasTelemetry.by_user(user),
kml=kml_mission,
kml_doc=kml.document)
result_kml = kml.kml()
self.assertEqual(samples_expected, result_kml.count('<gx:value>'))
self.assertIn(array_field_tag, result_kml)
示例7: get
# 需要导入模块: from auvsi_suas.models.uas_telemetry import UasTelemetry [as 别名]
# 或者: from auvsi_suas.models.uas_telemetry.UasTelemetry import by_user [as 别名]
def get(self, request):
kml = Kml(name='AUVSI SUAS Flight Data')
kml_teams = kml.newfolder(name='Teams')
kml_mission = kml.newfolder(name='Missions')
users = User.objects.all()
for user in users:
# Ignore admins
if user.is_superuser:
continue
UasTelemetry.kml(user=user,
logs=UasTelemetry.by_user(user),
kml=kml_teams,
kml_doc=kml.document)
MissionConfig.kml_all(kml_mission)
kml_flyzone = kml.newfolder(name='Fly Zones')
FlyZone.kml_all(kml_flyzone)
response = HttpResponse(kml.kml())
response['Content-Type'] = 'application/vnd.google-earth.kml+xml'
response['Content-Disposition'] = 'attachment; filename=mission.kml'
response['Content-Length'] = str(len(response.content))
return response
示例8: test_kml_empty
# 需要导入模块: from auvsi_suas.models.uas_telemetry import UasTelemetry [as 别名]
# 或者: from auvsi_suas.models.uas_telemetry.UasTelemetry import by_user [as 别名]
def test_kml_empty(self):
kml = Kml()
UasTelemetry.kml(user=self.user,
logs=UasTelemetry.by_user(self.user),
kml=kml,
kml_doc=kml)