def build(config_node): global standby_route standby_route = [] # clear standby route for child_name in config_node.getChildren(): if child_name == 'name': # ignore this for now pass elif child_name[:3] == 'wpt': child = config_node.getChild(child_name) wp = waypoint.Waypoint() wp.build(child) standby_route.append(wp) elif child_name == 'enable': # we do nothing on this tag right now, fixme: remove # this tag from all routes? pass else: print('Unknown top level section:', child_name) return False print('loaded %d waypoints' % len(standby_route)) return True
def build_str(request): global standby_route tokens = request.split(',') if len(tokens) < 4: return False standby_route = [] # clear standby i = 0 while i + 4 <= len(tokens): mode = int(tokens[i]) wp = waypoint.Waypoint() if mode == 0: wp.mode = 'relative' wp.dist_m = float(tokens[i + 1]) wp.hdg_deg = float(tokens[i + 2]) else: wp.mode = 'absolute' wp.lon_deg = float(tokens[i + 1]) wp.lat_deg = float(tokens[i + 2]) standby_route.append(wp) i += 4 print('Loaded %d waypoints' % len(standby_route)) return True