public void Update(UasHeartbeat hb)
        {
            Autopilot = (MavAutopilot)hb.Autopilot;
            Type      = (MavType)hb.Type;

            switch (Autopilot)
            {
            case MavAutopilot.Ardupilotmega:
                switch (Type)
                {
                case MavType.FixedWing:
                    Firmware = Firmwares.ArduPlane;
                    break;

                case MavType.Quadrotor:
                case MavType.Coaxial:
                case MavType.Helicopter:
                case MavType.Octorotor:
                case MavType.Tricopter:
                case MavType.Hexarotor:
                    Firmware = Firmwares.ArduCopter2;

                    break;

                case MavType.AntennaTracker:
                    Firmware = Firmwares.ArduTracker;
                    break;

                case MavType.GroundRover:
                case MavType.SurfaceBoat:
                    Firmware = Firmwares.ArduRover;
                    break;

                case MavType.Submarine:
                    Firmware = Firmwares.ArduSub;
                    break;

                default:
                    Firmware = Firmwares.Unknown;
                    break;
                }
                break;

            case MavAutopilot.Px4:
                Firmware = Firmwares.PX4;
                break;

            case MavAutopilot.Generic:
            case MavAutopilot.Reserved:
            case MavAutopilot.Slugs:
            case MavAutopilot.Openpilot:
            case MavAutopilot.GenericWaypointsOnly:
            case MavAutopilot.GenericWaypointsAndSimpleNavigationOnly:
            case MavAutopilot.GenericMissionFull:
            case MavAutopilot.Invalid:
            case MavAutopilot.Ppz:
            case MavAutopilot.Udb:
            case MavAutopilot.Fp:
            case MavAutopilot.Smaccmpilot:
            case MavAutopilot.Autoquad:
            case MavAutopilot.Armazila:
            case MavAutopilot.Aerob:
            case MavAutopilot.Asluav:
            case MavAutopilot.Smartap:
            case MavAutopilot.Airrails:
                Firmware = Firmwares.Unknown;
                break;
            }

            Armed  = (hb.BaseMode & (byte)MavModeFlag.SafetyArmed) == (byte)MavModeFlag.SafetyArmed;
            Guided = (hb.BaseMode & (byte)MavModeFlag.GuidedEnabled) == (byte)MavModeFlag.GuidedEnabled;
            HardwareInLoopSimulation = (hb.BaseMode & (byte)MavModeFlag.HilEnabled) == (byte)MavModeFlag.HilEnabled;
            Autonomous = (hb.BaseMode & (byte)MavModeFlag.AutoEnabled) == (byte)MavModeFlag.AutoEnabled;
            Stabilized = (hb.BaseMode & (byte)MavModeFlag.StabilizeEnabled) == (byte)MavModeFlag.StabilizeEnabled;
            Manual     = (hb.BaseMode & (byte)MavModeFlag.ManualInputEnabled) == (byte)MavModeFlag.ManualInputEnabled;
            var customModeEnabled = (hb.BaseMode & (byte)MavModeFlag.CustomModeEnabled) == (byte)MavModeFlag.CustomModeEnabled;

            if (customModeEnabled)
            {
                if (_customModeType != hb.CustomMode)
                {
                    _customModeType = hb.CustomMode;
                    var modelist = Modes.getModesList(Firmware);
                    if (modelist != null)
                    {
                        var customMode = modelist.Where(mod => mod.Key == hb.CustomMode).FirstOrDefault();
                        if (customMode.Key == hb.CustomMode)
                        {
                            CustomMode = customMode.Value;
                        }
                        else
                        {
                            CustomMode = String.Empty;
                        }
                    }
                }
            }
            else
            {
                CustomMode = String.Empty;
            }

            Standby           = hb.SystemStatus == (byte)MavState.Standby;
            FlightTermination = hb.SystemStatus == (byte)MavState.FlightTermination;
            Unknown           = hb.SystemStatus == (byte)MavState.Uninit;
            Calibrating       = hb.SystemStatus == (byte)MavState.Calibrating;
            Critical          = hb.SystemStatus == (byte)MavState.Critical;
            Emergency         = hb.SystemStatus == (byte)MavState.Emergency;
            Poweroff          = hb.SystemStatus == (byte)MavState.Poweroff;
            Active            = hb.SystemStatus == (byte)MavState.Active;
            Boot = hb.SystemStatus == (byte)MavState.Boot;

            GaugeStatus = Emergency || Critical ? GaugeStatus.Error : GaugeStatus.OK;
            TimeStamp   = DateTime.Now;
        }
예제 #2
0
 public void Update(UasHeartbeat hb)
 {
     MavlinkVersion = hb.MavlinkVersion;
 }