Files
spaceballoon/instruments.py

102 lines
1.7 KiB
Python

__author__ = 'asc'
debug = True
from random import random
class Barometer_Debug ():
def __init__(self):
pass
@property
def status (self):
return (0, "Barometer functioning properly")
@property
def temperature (self):
if self.status[0]:
return 'error'
if debug:
temp = random()*100
else:
raise Exception ('Not Debug')
return temp
@property
def pressure (self):
if (self.status[0]):
return 'error'
if debug:
press = random()
else:
raise Exception ('Not Debug')
return press
@property
def altitude (self):
if self.status[0]:
return 'error'
if debug:
alt = random()*100000
else:
raise Exception ('Not Debug')
return alt
class Camera_Debug():
def __init__(self):
pass
@property
def status (self):
return (0, "Camera functioning properly")
def capture (self):
#todo capture image
return ({"file":open("image.jpg", 'rb')})
#barometerdebug2 uses actual barometer
# class Barometer_Debug2 ():
# import Adafruit_BMP.BMP085 as BMP085
# def __init__(self):
# self.bmp = BMP085.BMP085()
# pass
#
# @property
# def status (self):
# return (0, "Barometer functioning properly")
#
# @property
# def temperature (self):
# if self.status[0]:
# return 'error'
#
# temp = self.bmp.read_temperature()
# return temp
#
# @property
# def pressure (self):
# if (self.status[0]):
# return 'error'
#
# # press = 100000*random()
# press = self.bmp.read_pressure()
#
# return press
#
# @property
# def altitude (self):
# if self.status[0]:
# return 'error'
# #TODO Set the altitude of your current location in meter
# alt = self.bmp.read_altitude()
# # alt = 100000*random()
# return alt