summaryrefslogtreecommitdiff
path: root/tools/mmd/MmdSatellite.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/mmd/MmdSatellite.py')
-rw-r--r--tools/mmd/MmdSatellite.py30
1 files changed, 18 insertions, 12 deletions
diff --git a/tools/mmd/MmdSatellite.py b/tools/mmd/MmdSatellite.py
index a148f30..0bf4208 100644
--- a/tools/mmd/MmdSatellite.py
+++ b/tools/mmd/MmdSatellite.py
@@ -3,6 +3,7 @@
import ephem
import time
import os
+import sys
from MmdDb import Db
from MmdLocation import Location
@@ -95,11 +96,13 @@ class Satellite:
self.latitude = dms2degdec (sat.sublat.__str__ ())
self.altitude = round (float (sat.elevation.__str__ ()), 1)
- def computeTrajectory (self):
+ def _computeTrajectory (self):
'''
computes 5 hours of future trajectory data, starting at the
latest timestamp found in data base
'''
+ if not self._loadTLE ():
+ return False
sat = ephem.readtle (self._tle[0], self._tle[1], self._tle[2])
graz = ephem.Observer ()
@@ -134,22 +137,25 @@ class Satellite:
return False
return True
+ def cronJob (self):
+ if self._updateTLEFile ():
+ self._updateTrajectory ()
+ return self._computeTrajectory ()
+
+ def _updateTLEFile (self):
+ return False
+
+ def _updateTrajectory (self):
+ self.db.satelliteDeleteObsoleteSSPs (time.strftime ('%s'))
+
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 ('curves', minutes)
- assert trajectory, 'got not trajectory'
- print trajectory
- t, lon, lat = satellite.getCurrentSSP ()
- assert t, 'loading current SSP failed'
- print lon, lat, time.strftime ('%c', time.gmtime (t))
- print satellite.longitude, satellite.latitude, satellite.altitude
+ assert satellite.cronJob (), 'executing cronjob failed'
except AssertionError as e:
print 'Error: {0}'.format (e)
+ sys.exit (1)
+ sys.exit (0)
# vim: tw=0 ts=2
# EOF