<s> import logging <EOL> import math <EOL> import os <EOL> from PIL import Image <EOL> import Tkinter <EOL> class MainViewController : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , kernel , view_model ) : <EOL> self . _kernel = kernel <EOL> self . model = view_model <EOL> def update ( self ) : <EOL> """<STR_LIT>""" <EOL> self . model . GPS_latitude . set ( self . _kernel . data . lat ) <EOL> self . model . GPS_longitude . set ( self . _kernel . data . lon ) <EOL> self . model . GPS_heading . set ( self . _kernel . data . gps_heading ) <EOL> self . model . GPS_speed . set ( self . _kernel . data . speed ) <EOL> self . model . GPS_altitude . set ( self . _kernel . data . altitude ) <EOL> self . model . GPS_fix . set ( self . _kernel . data . fix ) <EOL> self . model . GPS_satellite_count . set ( self . _kernel . data . num_sat ) <EOL> self . model . compass_heading . set ( self . _kernel . data . compass_heading ) <EOL> self . model . time . set ( self . _kernel . data . timestamp . isoformat ( ) ) <EOL> self . model . date . set ( self . _kernel . data . datestamp . isoformat ( ) ) <EOL> self . model . temperature . set ( self . _kernel . data . temperature ) <EOL> @ property <EOL> def last_img ( self ) : <EOL> return self . _kernel . last_img <EOL> def set_manual_mode ( self ) : <EOL> """<STR_LIT>""" <EOL> self . _kernel . set_manual_mode ( ) <EOL> def set_auto_pilot_mode ( self ) : <EOL> """<STR_LIT>""" <EOL> self . _kernel . set_auto_pilot_mode ( ) <EOL> def halt ( self ) : <EOL> """<STR_LIT>""" <EOL> self . _kernel . halt ( ) <EOL> @ property <EOL> def auto_mode_enabled ( self ) : <EOL> return self . _kernel . auto_mode_enabled <EOL> def set_throttle ( self , throttle_level ) : <EOL> throttle_act = float ( throttle_level ) / <NUM_LIT> <EOL> if throttle_act > <NUM_LIT> and throttle_act < <NUM_LIT> : <EOL> throttle_act = <NUM_LIT> <EOL> elif throttle_act < - <NUM_LIT> and throttle_act > - <NUM_LIT> : <EOL> throttle_act = - <NUM_LIT> <EOL> self . _kernel . set_throttle ( throttle_act ) <EOL> def set_steering ( self , angle ) : <EOL> angle_in_rad = ( float ( angle ) / <NUM_LIT> ) * math . pi <EOL> angle_in_rad = angle_in_rad * - <NUM_LIT:1.0> <EOL> self . _kernel . set_steering ( angle_in_rad ) <EOL> def set_speed ( self , speed ) : <EOL> """<STR_LIT>""" <EOL> self . _kernel . set_speed ( float ( speed ) ) <EOL> def set_heading ( self , heading ) : <EOL> """<STR_LIT>""" <EOL> self . _kernel . set_heading ( float ( heading ) ) <EOL> def navigate_to ( self ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> def get_current_map ( self ) : <EOL> return Image . open ( os . path . join ( self . _kernel . config . resources_folder ( ) , '<STR_LIT>' ) ) <EOL> def load_gpx ( self ) : <EOL> import tkFileDialog <EOL> default_path = os . path . join ( self . _kernel . config . resources_folder ( ) , '<STR_LIT>' ) <EOL> filename = tkFileDialog . askopenfilename ( initialdir = default_path , title = "<STR_LIT>" , filetypes = [ ( "<STR_LIT>" , "<STR_LIT>" ) ] ) <EOL> if os . path . exists ( filename ) : <EOL> logging . info ( "<STR_LIT>" % filename ) <EOL> gpx = self . _kernel . load_gpx ( filename ) <EOL> self . model . clear_waypoints ( ) <EOL> for route in gpx . routes : <EOL> for point in route . points : <EOL> wp_str = '<STR_LIT>' . format ( point . name , point . latitude , point . longitude ) <EOL> logging . info ( wp_str ) <EOL> wp_str2 = '<STR_LIT>' . format ( point . name , point . latitude , point . longitude ) <EOL> self . model . waypoints . append ( wp_str2 ) <EOL> def save_gpx ( self ) : <EOL> pass <EOL> class MainViewModel : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , root ) : <EOL> self . GPS_latitude = Tkinter . StringVar ( master = root , value = "<STR_LIT>" ) <EOL> self . GPS_longitude = Tkinter . StringVar ( master = root , value = "<STR_LIT>" ) <EOL> self . GPS_heading = Tkinter . DoubleVar ( master = root , value = <NUM_LIT:0.0> ) <EOL> self . GPS_speed = Tkinter . DoubleVar ( master = root , value = <NUM_LIT:0.0> ) <EOL> self . GPS_altitude = Tkinter . DoubleVar ( master = root , value = <NUM_LIT:0.0> ) <EOL> self . GPS_fix = Tkinter . IntVar ( master = root , value = <NUM_LIT:0> ) <EOL> self . GPS_satellite_count = Tkinter . IntVar ( master = root , value = <NUM_LIT:0> ) <EOL> self . compass_heading = Tkinter . DoubleVar ( master = root , value = <NUM_LIT:0.0> ) <EOL> self . time = Tkinter . StringVar ( master = root , value = "<STR_LIT>" ) <EOL> self . date = Tkinter . StringVar ( master = root , value = "<STR_LIT>" ) <EOL> self . temperature = Tkinter . DoubleVar ( master = root , value = <NUM_LIT:0.0> ) <EOL> self . capture_img_enabled = Tkinter . IntVar ( master = root , value = <NUM_LIT:0> ) <EOL> self . waypoints = [ ] <EOL> def clear_waypoints ( self ) : <EOL> del self . waypoints [ <NUM_LIT:0> : len ( self . waypoints ) ] </s>
