# Path: MAVProxy/modules/lib/multiproc.py
# class PipeQueue(object):
#     def __init__(self):
#     def close(self):
#     def put(self, *args):
#     def fill(self):
#     def get(self):
#     def qsize(self):
#     def empty(self):
# 
# Path: MAVProxy/modules/mavproxy_paramedit/checklisteditor.py
# class GridCheckListEditor(gridlib.PyGridCellEditor):
# class GridDropListEditor(gridlib.PyGridCellEditor):
# class GridScrollEditor(gridlib.PyGridCellEditor):
#     def __init__(self, choice, pvalcol, start):
#     def set_checked(self, selected):
#     def get_checked(self):
#     def Create(self, parent, id, evtHandler):
#     def SetSize(self, rect):
#     def Show(self, show, attr):
#     def BeginEdit(self, row, col, grid):
#     def EndEdit(self, row, col, grid, oldVal):
#     def get_pvalue(self):
#     def ApplyEdit(self, row, col, grid):
#     def Reset(self):
#     def StartingKey(self, evt):
#     def Destroy(self):
#     def Clone(self):
#     def __init__(self, choice, pvalcol, start=0):
#     def set_checked(self, selected):
#     def get_checked(self):
#     def Create(self, parent, id, evtHandler):
#     def Show(self, show, attr):
#     def SetSize(self, rect):
#     def BeginEdit(self, row, col, grid):
#     def EndEdit(self, row, col, grid, oldVal):
#     def ApplyEdit(self, row, col, grid):
#     def Reset(self):
#     def StartingKey(self, evt):
#     def Destroy(self):
#     def Clone(self):
#     def __init__(self, Range, pvalcol, start):
#     def set_checked(self, selected):
#     def SetSize(self, rect):
#     def get_checked(self):
#     def Create(self, parent, id, evtHandler):
#     def Show(self, show, attr):
#     def BeginEdit(self, row, col, grid):
#     def EndEdit(self, row, col, grid, oldVal):
#     def ApplyEdit(self, row, col, grid):
#     def Reset(self):
#     def StartingKey(self, evt):
#     def Destroy(self):
#     def Clone(self):
# 
# Path: MAVProxy/modules/lib/mp_util.py
# def wrap_360(angle):
# def wrap_180(angle):
# def gps_distance(lat1, lon1, lat2, lon2):
# def gps_bearing(lat1, lon1, lat2, lon2):
# def wrap_valid_longitude(lon):
# def constrain(v, minv, maxv):
# def constrain_latlon(latlon):
# def gps_newpos(lat, lon, bearing, distance):
# def gps_offset(lat, lon, east, north):
# def mkdir_p(dir):
# def polygon_load(filename):
# def polygon_bounds(points):
# def bounds_overlap(bound1, bound2):
#     def __init__(self, object, debug=False):
# def degrees_to_dms(degrees):
#     def __init__(self, zone, easting, northing, hemisphere='S'):
#     def __str__(self):
#     def latlon(self):
# def latlon_to_grid(latlon):
# def latlon_round(latlon, spacing=1000):
# def wxToPIL(wimg):
# def PILTowx(pimg):
# def dot_mavproxy(name=None):
# def download_url(url):
# def download_files(files):
# def child_close_fds():
# def child_fd_list_add(fd):
# def child_fd_list_remove(fd):
# def quaternion_to_axis_angle(q):
# def null_term(str):
# def decode_devid(devid, pname):
# def decode_flight_sw_version(flight_sw_version):
# class object_container:
# class UTMGrid:
# 
# Path: MAVProxy/modules/mavproxy_paramedit/ph_event.py
# PEE_READ_KEY = 0
# PEE_LOAD_FILE = 1
# PEE_SAVE_FILE = 2
# PEE_READ_PARAM = 3
# PEE_WRITE_PARAM = 4
# PEE_TIME_TO_QUIT = 5
# PEE_RESET = 6
# PEE_FETCH = 7
# PEGE_READ_PARAM = 0
# PEGE_REFRESH_PARAM = 1
# PEGE_WRITE_SUCC = 2
# PEGE_RCIN = 3
# class ParamEditorEvent:
#     def __init__(self, type, **kwargs):
#     def get_type(self):
#     def get_arg(self, key):


import wx
import wx.grid
import os
import sys
import time
import math
from MAVProxy.modules.lib import multiproc
from MAVProxy.modules.mavproxy_paramedit import checklisteditor as cle
from MAVProxy.modules.lib import mp_util
from MAVProxy.modules.mavproxy_paramedit import ph_event
            from lxml import objectify
        row_changed = event.GetRow()
        if event.Col == PE_OPTION:
            newval = float(self.display_list.GetCellValue(row_changed, PE_VALUE))
            self.display_list.SetCellValue(row_changed, PE_VALUE, str(round(newval, 4)))
        elif event.Col == PE_VALUE:
            newval = float(self.display_list.GetCellValue(row_changed, PE_VALUE))
            celleditor = self.display_list.GetCellEditor(row_changed, PE_OPTION)
            try:
                celleditor.set_checked(newval)
            except Exception:
                pass
        if float(self.oldval) != newval:
            self.display_list.SetCellBackgroundColour(row_changed, PE_VALUE,
                                                      wx.Colour(152, 251, 152))
            self.modified_param[self.display_list.GetCellValue(
                row_changed, PE_PARAM)] = newval
            self.param_received[self.display_list.GetCellValue(
                row_changed, PE_PARAM)] = newval
        event.Skip()

    def param_help_download(self):
        '''download XML files for parameters'''
        files = []
        for vehicle in ['APMrover2', 'ArduCopter', 'ArduPlane', 'ArduSub', 'AntennaTracker']:
            url = 'http://autotest.ardupilot.org/Parameters/%s/apm.pdef.xml' % vehicle
            path = mp_util.dot_mavproxy("%s.xml" % vehicle)
            files.append((url, path))
            url = 'http://autotest.ardupilot.org/%s-defaults.parm' % vehicle
            if vehicle != 'AntennaTracker':
                # defaults not generated for AntennaTracker ATM

# Path: MAVProxy/modules/lib/multiproc.py
# class PipeQueue(object):
#     def __init__(self):
#     def close(self):
#     def put(self, *args):
#     def fill(self):
#     def get(self):
#     def qsize(self):
#     def empty(self):
# 
# Path: MAVProxy/modules/mavproxy_paramedit/checklisteditor.py
# class GridCheckListEditor(gridlib.PyGridCellEditor):
# class GridDropListEditor(gridlib.PyGridCellEditor):
# class GridScrollEditor(gridlib.PyGridCellEditor):
#     def __init__(self, choice, pvalcol, start):
#     def set_checked(self, selected):
#     def get_checked(self):
#     def Create(self, parent, id, evtHandler):
#     def SetSize(self, rect):
#     def Show(self, show, attr):
#     def BeginEdit(self, row, col, grid):
#     def EndEdit(self, row, col, grid, oldVal):
#     def get_pvalue(self):
#     def ApplyEdit(self, row, col, grid):
#     def Reset(self):
#     def StartingKey(self, evt):
#     def Destroy(self):
#     def Clone(self):
#     def __init__(self, choice, pvalcol, start=0):
#     def set_checked(self, selected):
#     def get_checked(self):
#     def Create(self, parent, id, evtHandler):
#     def Show(self, show, attr):
#     def SetSize(self, rect):
#     def BeginEdit(self, row, col, grid):
#     def EndEdit(self, row, col, grid, oldVal):
#     def ApplyEdit(self, row, col, grid):
#     def Reset(self):
#     def StartingKey(self, evt):
#     def Destroy(self):
#     def Clone(self):
#     def __init__(self, Range, pvalcol, start):
#     def set_checked(self, selected):
#     def SetSize(self, rect):
#     def get_checked(self):
#     def Create(self, parent, id, evtHandler):
#     def Show(self, show, attr):
#     def BeginEdit(self, row, col, grid):
#     def EndEdit(self, row, col, grid, oldVal):
#     def ApplyEdit(self, row, col, grid):
#     def Reset(self):
#     def StartingKey(self, evt):
#     def Destroy(self):
#     def Clone(self):
# 
# Path: MAVProxy/modules/lib/mp_util.py
# def wrap_360(angle):
# def wrap_180(angle):
# def gps_distance(lat1, lon1, lat2, lon2):
# def gps_bearing(lat1, lon1, lat2, lon2):
# def wrap_valid_longitude(lon):
# def constrain(v, minv, maxv):
# def constrain_latlon(latlon):
# def gps_newpos(lat, lon, bearing, distance):
# def gps_offset(lat, lon, east, north):
# def mkdir_p(dir):
# def polygon_load(filename):
# def polygon_bounds(points):
# def bounds_overlap(bound1, bound2):
#     def __init__(self, object, debug=False):
# def degrees_to_dms(degrees):
#     def __init__(self, zone, easting, northing, hemisphere='S'):
#     def __str__(self):
#     def latlon(self):
# def latlon_to_grid(latlon):
# def latlon_round(latlon, spacing=1000):
# def wxToPIL(wimg):
# def PILTowx(pimg):
# def dot_mavproxy(name=None):
# def download_url(url):
# def download_files(files):
# def child_close_fds():
# def child_fd_list_add(fd):
# def child_fd_list_remove(fd):
# def quaternion_to_axis_angle(q):
# def null_term(str):
# def decode_devid(devid, pname):
# def decode_flight_sw_version(flight_sw_version):
# class object_container:
# class UTMGrid:
# 
# Path: MAVProxy/modules/mavproxy_paramedit/ph_event.py
# PEE_READ_KEY = 0
# PEE_LOAD_FILE = 1
# PEE_SAVE_FILE = 2
# PEE_READ_PARAM = 3
# PEE_WRITE_PARAM = 4
# PEE_TIME_TO_QUIT = 5
# PEE_RESET = 6
# PEE_FETCH = 7
# PEGE_READ_PARAM = 0
# PEGE_REFRESH_PARAM = 1
# PEGE_WRITE_SUCC = 2
# PEGE_RCIN = 3
# class ParamEditorEvent:
#     def __init__(self, type, **kwargs):
#     def get_type(self):
#     def get_arg(self, key):


# Path: MAVProxy/modules/mavproxy_paramedit/param_editor_frame.py
import wx
import wx.grid
import os
import sys
import time
import math
from MAVProxy.modules.lib import multiproc
from MAVProxy.modules.mavproxy_paramedit import checklisteditor as cle
from MAVProxy.modules.lib import mp_util
from MAVProxy.modules.mavproxy_paramedit import ph_event
            from lxml import objectify

        row_changed = event.GetRow()
        if event.Col == PE_OPTION:
            newval = float(self.display_list.GetCellValue(row_changed, PE_VALUE))
            self.display_list.SetCellValue(row_changed, PE_VALUE, str(round(newval, 4)))
        elif event.Col == PE_VALUE:
            newval = float(self.display_list.GetCellValue(row_changed, PE_VALUE))
            celleditor = self.display_list.GetCellEditor(row_changed, PE_OPTION)
            try:
                celleditor.set_checked(newval)
            except Exception:
                pass
        if float(self.oldval) != newval:
            self.display_list.SetCellBackgroundColour(row_changed, PE_VALUE,
                                                      wx.Colour(152, 251, 152))
            self.modified_param[self.display_list.GetCellValue(
                row_changed, PE_PARAM)] = newval
            self.param_received[self.display_list.GetCellValue(
                row_changed, PE_PARAM)] = newval
        event.Skip()

    def param_help_download(self):
        '''download XML files for parameters'''
        files = []
        for vehicle in ['APMrover2', 'ArduCopter', 'ArduPlane', 'ArduSub', 'AntennaTracker']:
            url = 'http://autotest.ardupilot.org/Parameters/%s/apm.pdef.xml' % vehicle
            path = mp_util.dot_mavproxy("%s.xml" % vehicle)
            files.append((url, path))
            url = 'http://autotest.ardupilot.org/%s-defaults.parm' % vehicle
            if vehicle != 'AntennaTracker':
                # defaults not generated for AntennaTracker ATM

                path = mp_util.dot_mavproxy("%s-defaults.parm" % vehicle)