ETA

Description:

This application estimates the time of arrival for sailors:

 

#########################################################
# Estimated Time of Arrival calculator for sailors #
# 2006 October 10th - Jan Elling #
# Assigment for mobile phone programming course at AAU #
#########################################################
import appuifw
from graphics import *
import e32
# Initialize screen
appuifw.app.screen = 'normal'
appuifw.app.title = u'ETA Calculator'
print u''
print u''
print u''
print u''
print u''
print u''
print u''
print u''
print u''
print u''
print u''
print u''
#Input data
dist_name = appuifw.query(u'Where to go=?', 'text')
image=screenshot()
path = (u'c:\\Nokia\\images\\wheretogo1.jpg')
image.save(path)
time_dep = appuifw.query(u'Departure time=?', 'time')
image=screenshot()
path = (u'c:\\Nokia\\images\\departuretime1.jpg')
image.save(path)
dist_sail = appuifw.query(u'Distance[10s sm]=?', 'number')
image=screenshot()
path = (u'c:\\Nokia\\images\\distance1.jpg')
image.save(path)
speed_ship = appuifw.query(u'Speed[10s kn]=?', 'number')
image=screenshot()
path = (u'c:\\Nokia\\images\\speed1.jpg')
image.save(path)
#Time calculation
time_dep_h = int(time_dep / 3600)
time_dep_m = time_dep - time_dep_h*3600
time_dep_m = int(time_dep_m/60)
if (time_dep_m < 10 ):
if (time_dep_h < 10):
time_dep_text = '0'+str(time_dep_h)+':0'+str(time_dep_m)
else:
time_dep_text = str(time_dep_h)+':0'+str(time_dep_m)
else:
if (time_dep_h < 10):
time_dep_text = '0'+str(time_dep_h)+':'+str(time_dep_m)
else:
time_dep_text = str(time_dep_h)+':'+str(time_dep_m)

Sail_time = dist_sail * 3600 / speed_ship
ETA = time_dep + Sail_time
ETA_h = int(ETA/3600)
ETA_m = ETA - ETA_h*3600
ETA_m = int(ETA_m/60)
ETA_days=0
if (ETA_h > 24) :
ETA_days = int(ETA_h/24)
ETA_h = ETA_h - ETA_days*24
ETA_days_txt = str(ETA_days)
if (ETA_m <10 ) and (ETA_h < 10):
ETA_text = '0'+str(ETA_h)+':0'+str(ETA_m)
elif (ETA_m >9) and (ETA_h < 10):
ETA_text = '0'+str(ETA_h)+':'+str(ETA_m)
elif (ETA_m <10) and (ETA_h>9):
ETA_text = str(ETA_h)+':0'+str(ETA_m)
elif (ETA_m >9) and (ETA_h>9):
ETA_text = str(ETA_h)+':'+str(ETA_m)
#Print result
appuifw.app.screen = 'normal'
appuifw.app.title = u'ETA Calculator'
if (ETA_days >0):
appuifw.note(u'ETA: '+ETA_text+u', '+ETA_days_txt+u' day(s)','info')
else :
appuifw.note(u'ETA: '+ETA_text,'info')
image=screenshot()
path=(u'c:\\Nokia\\images\\ETA-calc1.jpg')
image.save(path)
print u''
print u''
print u'Destination '
print u' '+dist_name
print u'Departure Time'
print u' '+time_dep_text
print u''
print u'Estimated Time of Arrival'
print u' '+ETA_text
if (ETA_days>0):
print u'after'
print u' '+ETA_days_txt+u' day(s)'
print u''
print u''
# Wait for the user to exit
e32.Ao_lock().wait()
 

Download:

ETA_calc.py

Output:

The following screenshots are the outcome. Just click on the icons to enlarge them for a better view.

Output

Department of Electronic Systems | Aalborg University | Niels Jernes Vej 12 | DK-9220 Aalborg | Denmark
Phone: (+45) 9635 8695 | Fax (+45) 9815 1583 | E-mail ies(at)ies.aau.dk
Copyright © 2006 Department of Electronic Systems

Last update:20-10-2006