Esempio n. 1
0
        public static List <KeyValuePair <int, string> > getModesList(Firmwares firmware)
        {
            log.Info("getModesList Called");

            if (firmware == Firmwares.PX4)
            {
                /*
                 * union px4_custom_mode {
                 * struct {
                 * uint16_t reserved;
                 * uint8_t main_mode;
                 * uint8_t sub_mode;
                 * };
                 * uint32_t data;
                 * float data_float;
                 * };
                 */


                var temp = new List <KeyValuePair <int, string> >()
                {
                    new KeyValuePair <int, string>((int)PX4_CUSTOM_MAIN_MODE.PX4_CUSTOM_MAIN_MODE_MANUAL << 16, "Manual"),
                    new KeyValuePair <int, string>((int)PX4_CUSTOM_MAIN_MODE.PX4_CUSTOM_MAIN_MODE_ACRO << 16, "Acro"),
                    new KeyValuePair <int, string>((int)PX4_CUSTOM_MAIN_MODE.PX4_CUSTOM_MAIN_MODE_STABILIZED << 16,
                                                   "Stabalized"),
                    new KeyValuePair <int, string>((int)PX4_CUSTOM_MAIN_MODE.PX4_CUSTOM_MAIN_MODE_RATTITUDE << 16,
                                                   "Rattitude"),
                    new KeyValuePair <int, string>((int)PX4_CUSTOM_MAIN_MODE.PX4_CUSTOM_MAIN_MODE_ALTCTL << 16,
                                                   "Altitude Control"),
                    new KeyValuePair <int, string>((int)PX4_CUSTOM_MAIN_MODE.PX4_CUSTOM_MAIN_MODE_POSCTL << 16,
                                                   "Position Control"),
                    new KeyValuePair <int, string>((int)PX4_CUSTOM_MAIN_MODE.PX4_CUSTOM_MAIN_MODE_OFFBOARD << 16,
                                                   "Offboard Control"),
                    new KeyValuePair <int, string>(
                        ((int)PX4_CUSTOM_MAIN_MODE.PX4_CUSTOM_MAIN_MODE_AUTO << 16) +
                        (int)PX4_CUSTOM_SUB_MODE_AUTO.PX4_CUSTOM_SUB_MODE_AUTO_READY << 24, "Auto: Ready"),
                    new KeyValuePair <int, string>(
                        ((int)PX4_CUSTOM_MAIN_MODE.PX4_CUSTOM_MAIN_MODE_AUTO << 16) +
                        (int)PX4_CUSTOM_SUB_MODE_AUTO.PX4_CUSTOM_SUB_MODE_AUTO_TAKEOFF << 24, "Auto: Takeoff"),
                    new KeyValuePair <int, string>(
                        ((int)PX4_CUSTOM_MAIN_MODE.PX4_CUSTOM_MAIN_MODE_AUTO << 16) +
                        (int)PX4_CUSTOM_SUB_MODE_AUTO.PX4_CUSTOM_SUB_MODE_AUTO_LOITER << 24, "Loiter"),
                    new KeyValuePair <int, string>(
                        ((int)PX4_CUSTOM_MAIN_MODE.PX4_CUSTOM_MAIN_MODE_AUTO << 16) +
                        (int)PX4_CUSTOM_SUB_MODE_AUTO.PX4_CUSTOM_SUB_MODE_AUTO_MISSION << 24, "Auto"),
                    new KeyValuePair <int, string>(
                        ((int)PX4_CUSTOM_MAIN_MODE.PX4_CUSTOM_MAIN_MODE_AUTO << 16) +
                        (int)PX4_CUSTOM_SUB_MODE_AUTO.PX4_CUSTOM_SUB_MODE_AUTO_RTL << 24, "RTL"),
                    new KeyValuePair <int, string>(
                        ((int)PX4_CUSTOM_MAIN_MODE.PX4_CUSTOM_MAIN_MODE_AUTO << 16) +
                        (int)PX4_CUSTOM_SUB_MODE_AUTO.PX4_CUSTOM_SUB_MODE_AUTO_LAND << 24, "Auto: Landing")
                };

                return(temp);
            }
            else if (firmware == Firmwares.ArduPlane)
            {
                var flightModes = Utilities.ParameterMetaDataRepository.GetParameterOptionsInt("FLTMODE1",
                                                                                               firmware.ToString());
                flightModes.Add(new KeyValuePair <int, string>(16, "INITIALISING"));

                return(flightModes);
            }
            else if (firmware == Firmwares.Ateryx)
            {
                var flightModes = Utilities.ParameterMetaDataRepository.GetParameterOptionsInt("FLTMODE1",
                                                                                               firmware.ToString()); //same as apm
                return(flightModes);
            }
            else if (firmware == Firmwares.ArduCopter2)
            {
                var flightModes = Utilities.ParameterMetaDataRepository.GetParameterOptionsInt("FLTMODE1",
                                                                                               firmware.ToString());
                return(flightModes);
            }
            else if (firmware == Firmwares.ArduRover)
            {
                var flightModes = Utilities.ParameterMetaDataRepository.GetParameterOptionsInt("MODE1",
                                                                                               firmware.ToString());
                return(flightModes);
            }
            else if (firmware == Firmwares.ArduTracker)
            {
                var temp = new List <KeyValuePair <int, string> >();
                temp.Add(new KeyValuePair <int, string>(0, "MANUAL"));
                temp.Add(new KeyValuePair <int, string>(1, "STOP"));
                temp.Add(new KeyValuePair <int, string>(2, "SCAN"));
                temp.Add(new KeyValuePair <int, string>(3, "SERVO_TEST"));
                temp.Add(new KeyValuePair <int, string>(10, "AUTO"));
                temp.Add(new KeyValuePair <int, string>(16, "INITIALISING"));

                return(temp);
            }

            return(null);
        }
Esempio n. 2
0
        public static List <KeyValuePair <int, string> > getModesList(Firmwares firmware)
        {
            if (firmware == Firmwares.PX4)
            {
                /*
                 * union px4_custom_mode {
                 * struct {
                 * uint16_t reserved;
                 * uint8_t main_mode;
                 * uint8_t sub_mode;
                 * };
                 * uint32_t data;
                 * float data_float;
                 * };
                 */


                var temp = new List <KeyValuePair <int, string> >()
                {
                    new KeyValuePair <int, string>((int)PX4CustomModes.Manual << 16, CoreResources.PX4Mode_Manual),
                    new KeyValuePair <int, string>((int)PX4CustomModes.Acro << 16, CoreResources.PX4Mode_Acro),
                    new KeyValuePair <int, string>((int)PX4CustomModes.Stablilized << 16, CoreResources.PX4Mode_Stabilized),
                    new KeyValuePair <int, string>((int)PX4CustomModes.Rattitude << 16, CoreResources.PX4Mode_Stabilized),
                    new KeyValuePair <int, string>((int)PX4CustomModes.AltCtl << 16, CoreResources.PX4Mode_AltCtl),
                    new KeyValuePair <int, string>((int)PX4CustomModes.PosCtl << 16, CoreResources.PX4Mode_PoCtl),
                    new KeyValuePair <int, string>((int)PX4CustomModes.OffBoard << 16, CoreResources.PX4Mode_Offboard),
                    new KeyValuePair <int, string>(
                        ((int)PX4CustomModes.Auto << 16) +
                        (int)PX4CustomSubodes.Ready << 24, CoreResources.PX4Mode_AutoReady),
                    new KeyValuePair <int, string>(
                        ((int)PX4CustomModes.Auto << 16) +
                        (int)PX4CustomSubodes.Takeoff << 24, CoreResources.PX4Mode_AutoTakeoff),
                    new KeyValuePair <int, string>(
                        ((int)PX4CustomModes.Auto << 16) +
                        (int)PX4CustomSubodes.Loiter << 24, CoreResources.PX4Mode_Loiter),
                    new KeyValuePair <int, string>(
                        ((int)PX4CustomModes.Auto << 16) +
                        (int)PX4CustomSubodes.Mission << 24, CoreResources.PX4Mode_Mission),
                    new KeyValuePair <int, string>(
                        ((int)PX4CustomModes.Auto << 16) +
                        (int)PX4CustomSubodes.RTL << 24, CoreResources.PX4Mode_RTL),
                    new KeyValuePair <int, string>(
                        ((int)PX4CustomModes.Auto << 16) +
                        (int)PX4CustomSubodes.Land << 24, CoreResources.PX4Mode_Landing)
                };

                return(temp);
            }
            else if (firmware == Firmwares.ArduPlane)
            {
                var flightModes = Parameters.GetParameterOptionsInt("FLTMODE1",
                                                                    firmware.ToString());
                flightModes.Add(new KeyValuePair <int, string>(16, "INITIALISING"));

                flightModes.Add(new KeyValuePair <int, string>(17, "QStabilize"));
                flightModes.Add(new KeyValuePair <int, string>(18, "QHover"));
                flightModes.Add(new KeyValuePair <int, string>(19, "QLoiter"));
                flightModes.Add(new KeyValuePair <int, string>(20, "QLand"));
                flightModes.Add(new KeyValuePair <int, string>(21, "QRTL"));

                return(flightModes);
            }
            else if (firmware == Firmwares.Ateryx)
            {
                var flightModes = Parameters.GetParameterOptionsInt("FLTMODE1", firmware.ToString()); //same as apm
                return(flightModes);
            }
            else if (firmware == Firmwares.ArduCopter2)
            {
                var flightModes = Parameters.GetParameterOptionsInt("FLTMODE1", firmware.ToString());
                return(flightModes);
            }
            else if (firmware == Firmwares.ArduRover)
            {
                var flightModes = Parameters.GetParameterOptionsInt("MODE1", firmware.ToString());
                return(flightModes);
            }
            else if (firmware == Firmwares.ArduTracker)
            {
                var temp = new List <KeyValuePair <int, string> >();
                temp.Add(new KeyValuePair <int, string>(0, CoreResources.TrackerMode_Manual));
                temp.Add(new KeyValuePair <int, string>(1, CoreResources.TrackerMode_Stop));
                temp.Add(new KeyValuePair <int, string>(2, CoreResources.TrackerMode_Scan));
                temp.Add(new KeyValuePair <int, string>(3, CoreResources.TrackerMode_ServoTest));
                temp.Add(new KeyValuePair <int, string>(10, CoreResources.TrackerMode_Auto));
                temp.Add(new KeyValuePair <int, string>(16, CoreResources.TrackerMode_Initializing));

                return(temp);
            }

            return(null);
        }