summaryrefslogtreecommitdiff
path: root/tools/mmd
diff options
context:
space:
mode:
authorJogi Hofmüller <jogi@mur.at>2011-08-11 08:45:41 +0000
committerJogi Hofmüller <jogi@mur.at>2011-08-11 08:45:41 +0000
commitd07617fd3fb065a304ecdd53096e45954d07ee1e (patch)
tree4acc5c3af1d65abc6b8ea30739b98e6372be6988 /tools/mmd
parent- added TODO file to repo (diff)
- more Satellite code
git-svn-id: https://svn.spreadspace.org/mur.sat@120 7de4ea59-55d0-425e-a1af-a3118ea81d4c
Diffstat (limited to 'tools/mmd')
-rw-r--r--tools/mmd/MmdDb.py11
-rw-r--r--tools/mmd/MmdSatellite.py20
-rw-r--r--tools/mmd/TODO11
3 files changed, 34 insertions, 8 deletions
diff --git a/tools/mmd/MmdDb.py b/tools/mmd/MmdDb.py
index 74b11bd..aa6ff03 100644
--- a/tools/mmd/MmdDb.py
+++ b/tools/mmd/MmdDb.py
@@ -122,6 +122,17 @@ class Db:
self.cursor.execute ('INSERT INTO ssps (timestamp, longitude, latitude) VALUES (?,?,?)', (timestamp, longitude, latitude,))
self.conn.commit ()
+ def satelliteLoadTrajectory (self, timestamp, count):
+ '''
+ get count rows from table ssps, starting at >= timestamp
+ '''
+ self.cursor.execute ('SELECT * FROM ssps WHERE timestamp >=? ORDER BY timestamp ASC LIMIT ?', (timestamp, count,))
+ return self.cursor.fetchall ()
+
+ def satelliteLoadCurrentSSP (self, timestamp):
+ self.cursor.execute ('SELECT * FROM ssps WHERE timestamp >=? LIMIT 1', (timestamp,))
+ return self.cursor.fetchone ()
+
def close (self):
self.cursor.close ()
self.conn.close ()
diff --git a/tools/mmd/MmdSatellite.py b/tools/mmd/MmdSatellite.py
index 1575648..8085773 100644
--- a/tools/mmd/MmdSatellite.py
+++ b/tools/mmd/MmdSatellite.py
@@ -47,16 +47,18 @@ class Satellite:
self.db = Db ()
def getCurrentSSP (self):
- pass
+ ssp = self._loadCurrentSSP ()
+ return ssp['timestamp'], ssp['longitude'], ssp['latitude']
def getTrajectoryAsJavaArray (self, minutes = 180):
- pass
+ # FIXME include java array code here
+ return self._loadTrajectory (minutes)
def _loadTrajectory (self, minutes):
- pass
+ return self.db.satelliteLoadTrajectory (time.strftime ('%s'), minutes)
def _loadCurrentSSP (self):
- pass
+ return self.db.satelliteLoadCurrentSSP (time.strftime ('%s'))
def computeTrajectory (self):
sat = ephem.readtle (self._tle[0], self._tle[1], self._tle[2])
@@ -96,10 +98,20 @@ class Satellite:
if __name__ == "__main__":
satellite = Satellite ()
+ minutes = 30
try:
assert satellite._loadTLE (), 'loading TLE failed'
print satellite._tle
assert satellite.computeTrajectory (), 'computing trajectory failed'
+ trajectory = satellite.getTrajectoryAsJavaArray (minutes)
+ assert trajectory, 'got not trajectory'
+ assert len (trajectory) == minutes, 'count={0}, minutes={1}'.format (len (trajectory), minutes)
+ print time.strftime ('%c', time.gmtime (float (time.strftime ('%s')))), time.strftime ('%s')
+ for t in trajectory:
+ print t['timestamp'], time.strftime ('%c', time.gmtime (t['timestamp']))
+ t, lon, lat = satellite.getCurrentSSP ()
+ assert t, 'loading current SSP failed'
+ print lon, lat, time.strftime ('%c', time.gmtime (t))
except AssertionError as e:
print 'Error: {0}'.format (e)
diff --git a/tools/mmd/TODO b/tools/mmd/TODO
index cc5341d..c0ef046 100644
--- a/tools/mmd/TODO
+++ b/tools/mmd/TODO
@@ -1,10 +1,13 @@
Things to do for completing this app
+- satellite
+ - add retreival of current SSP
+ - add trajectory to class
+
- registration
- - add user's location data
- - change the registration form
- - complete class Location
- - make class LocationList
+ - add location.altitude
+ - complete class Location
+ - make class LocationList
- user
- change profile data (password)