Ejemplo n.º 1
0
        public static SteeringManager DeepCopy(SteeringManager oldInstance, SharedObjects shared)
        {
            SteeringManager instance = SteeringManagerProvider.GetInstance(shared);
            instance.ShowAngularVectors = oldInstance.ShowAngularVectors;
            instance.ShowFacingVectors = oldInstance.ShowFacingVectors;
            instance.ShowRCSVectors = oldInstance.ShowRCSVectors;
            instance.ShowThrustVectors = oldInstance.ShowThrustVectors;
            instance.ShowSteeringStats = oldInstance.ShowSteeringStats;
            instance.WriteCSVFiles = oldInstance.WriteCSVFiles;
            instance.MaxStoppingTime = oldInstance.MaxStoppingTime;

            instance.pitchPI.Ts = oldInstance.pitchPI.Ts;
            instance.yawPI.Ts = oldInstance.yawPI.Ts;
            instance.rollPI.Ts = oldInstance.rollPI.Ts;
            instance.pitchPI.Loop = PIDLoop.DeepCopy(oldInstance.pitchPI.Loop);
            instance.yawPI.Loop = PIDLoop.DeepCopy(oldInstance.yawPI.Loop);
            instance.rollPI.Loop = PIDLoop.DeepCopy(oldInstance.rollPI.Loop);

            instance.pitchRatePI = PIDLoop.DeepCopy(oldInstance.pitchRatePI);
            instance.yawRatePI = PIDLoop.DeepCopy(oldInstance.yawRatePI);
            instance.rollRatePI = PIDLoop.DeepCopy(oldInstance.rollRatePI);

            instance.PitchTorqueAdjust = oldInstance.PitchTorqueAdjust;
            instance.PitchTorqueFactor = oldInstance.PitchTorqueFactor;
            instance.RollTorqueAdjust = oldInstance.RollTorqueAdjust;
            instance.RollTorqueFactor = oldInstance.RollTorqueFactor;
            instance.YawTorqueAdjust = oldInstance.YawTorqueAdjust;
            instance.YawTorqueFactor = oldInstance.YawTorqueFactor;
            return instance;
        }
Ejemplo n.º 2
0
        public static SteeringManager SwapInstance(SharedObjects shared, SteeringManager oldInstance)
        {
            if (shared.Vessel == oldInstance.Vessel) return oldInstance;
            if (oldInstance.SubscribedParts.Contains(shared.KSPPart.flightID)) oldInstance.SubscribedParts.Remove(shared.KSPPart.flightID);
            SteeringManager instance = SteeringManager.DeepCopy(oldInstance, shared);

            if (oldInstance.Enabled)
            {
                if (oldInstance.PartId == shared.KSPPart.flightID)
                {
                    oldInstance.DisableControl();
                    instance.EnableControl(shared);
                    instance.Value = oldInstance.Value;
                }
            }
            return instance;
        }
Ejemplo n.º 3
0
        public static SteeringManager GetInstance(SharedObjects shared)
        {
            string key = shared.Vessel.id.ToString();
            if (AllInstances.Keys.Contains(key))
            {
                SteeringManager instance = AllInstances[key];
                if (!instance.SubscribedParts.Contains(shared.KSPPart.flightID))
                {
                    AllInstances[key].SubscribedParts.Add(shared.KSPPart.flightID);
                }
                return AllInstances[key];
            }

            SteeringManager sm = new SteeringManager(shared);

            sm.SubscribedParts.Add(shared.KSPPart.flightID);

            AllInstances.Add(key, sm);
            return sm;
        }
Ejemplo n.º 4
0
 public void UpdateFlightControl(Vessel vessel)
 {
     control = GetControllerByVessel(vessel);
     if (steeringManager != null)
     {
         steeringManager = SteeringManagerProvider.SwapInstance(shared, steeringManager);
         steeringManager.Update(vessel);
     }
 }
Ejemplo n.º 5
0
 public void Dispose()
 {
     Enabled = false;
     if (steeringManager != null)
     {
         SteeringManagerProvider.RemoveInstance(shared.Vessel);
         steeringManager = null;
     }
 }
Ejemplo n.º 6
0
            public FlightCtrlParam(string name, SharedObjects sharedObjects)
            {
                this.name = name;
                shared = sharedObjects;
                control = GetControllerByVessel(sharedObjects.Vessel);
                
                binding = sharedObjects.BindingMgr;
                Enabled = false;
                value = null;

                if (string.Equals(name, "steering", StringComparison.CurrentCultureIgnoreCase))
                {
                    steeringManager = SteeringManagerProvider.GetInstance(sharedObjects);
                }

                HookEvents();
            }