internal void DeleteAlarm()
 {
     if (currentAlarm != null)
     {
         KACWrapper.KAC.DeleteAlarm(currentAlarm.ID);
         currentAlarm = null;
     }
 }
Ejemplo n.º 2
0
        internal void CreateAlarm()
        {
            if (!KACWrapper.APIReady)
            {
                return;
            }

            if (currentAlarm != null)
            {
                return;
            }

            string newID = KACWrapper.KAC.CreateAlarm(KACWrapper.KACAPI.AlarmTypeEnum.Maneuver,
                                                      KSP.Localization.Localizer.Format("precisemaneuver_KAC_name", FlightGlobals.ActiveVessel.GetName()),
                                                      CurrentNode.UT - 600.0);

            currentAlarm = KACWrapper.KAC.Alarms.First(a => a.ID == newID);

            currentAlarm.VesselID = FlightGlobals.ActiveVessel.id.ToString();
            currentAlarm.Notes    = KSP.Localization.Localizer.Format("precisemaneuver_KAC_note");
        }
        private void NotifyNodeChanged()
        {
            /* update savednode */
            if (currentSavedNode != null)
            {
                currentSavedNode.ResetSavedNode(CurrentNode);
            }
            else
            {
                currentSavedNode = new SavedNode(CurrentNode);
            }
            /* update KAC alarm */
            if (KACWrapper.APIReady)
            {
                currentAlarm = KACWrapper.KAC.Alarms.FirstOrDefault
                                   (a => ((Math.Abs(a.AlarmTime + 600.0 - CurrentNode.UT) < 1E-05) &&
                                          (a.VesselID == FlightGlobals.ActiveVessel.id.ToString()) &&
                                          (a.AlarmType == KACWrapper.KACAPI.AlarmTypeEnum.Maneuver)));
            }

            /* if the node changed, its values changed too */
            NotifyDvUTChanged();
        }