private void HandleAxisCommand(GameControllerAxisCommand command, GameControllerUpdateNotification notification, bool reverse, bool highspeed)
        {
            if (IsParked || !IsConnected)
            {
                return;
            }
            ASCOM.DeviceInterface.TelescopeAxes axis = ASCOM.DeviceInterface.TelescopeAxes.axisPrimary;
            double rate;

            switch (command)
            {
            case GameControllerAxisCommand.SlewNSLowSpeed:
            case GameControllerAxisCommand.SlewNSHighSpeed:
            case GameControllerAxisCommand.SlewNSDualSpeed:
                if (highspeed)
                {
                    rate = MaxDecSlewRate * Constants.SIDEREAL_RATE_DEGREES;
                }
                else
                {
                    rate = Settings.SlewRatePreset.DecRate * Constants.SIDEREAL_RATE_DEGREES;
                }
                axis = ASCOM.DeviceInterface.TelescopeAxes.axisSecondary;
                break;

            case GameControllerAxisCommand.SlewEWLowSpeed:
            case GameControllerAxisCommand.SlewEWHighSpeed:
            case GameControllerAxisCommand.SlewEWDualSpeed:
                if (highspeed)
                {
                    rate = MaxRASlewRate * Constants.SIDEREAL_RATE_DEGREES;
                }
                else
                {
                    rate = Settings.SlewRatePreset.RARate * Constants.SIDEREAL_RATE_DEGREES;
                }
                axis = ASCOM.DeviceInterface.TelescopeAxes.axisPrimary;
                break;

            default:
                return;
            }
            if (notification == GameControllerUpdateNotification.CommandUp)
            {
                // Stop slew
                Driver.MoveAxis(axis, 0.0);
            }
            else if (notification == GameControllerUpdateNotification.CommandDown)
            {
                if (reverse)
                {
                    rate = -rate;
                }
                Driver.MoveAxis(axis, rate);
            }
        }
 private void HandleStartStopTrackingButton(TrackingMode mode, GameControllerUpdateNotification notification)
 {
     if (notification == GameControllerUpdateNotification.CommandUp)
     {
         if (StartTrackingCommand.CanExecute(mode))
         {
             StartTrackingCommand.Execute(mode);
         }
     }
 }
 private void HandleSlewButton(SlewButton button, GameControllerUpdateNotification notification)
 {
     if (notification == GameControllerUpdateNotification.CommandUp)
     {
         if (StopSlewCommand.CanExecute(button))
         {
             StopSlewCommand.Execute(button);
         }
     }
     else if (notification == GameControllerUpdateNotification.CommandDown)
     {
         if (StartSlewCommand.CanExecute(button))
         {
             StartSlewCommand.Execute(button);
         }
     }
 }
Ejemplo n.º 4
0
 public GameControllerProgressArgs(GameControllerUpdateNotification notification, GameControllerAxisCommand command, bool reverse, bool highspeed) : this(notification, command)
 {
     this.Reverse   = reverse;
     this.Highspeed = highspeed;
 }
Ejemplo n.º 5
0
 public GameControllerProgressArgs(GameControllerUpdateNotification notification, GameControllerAxisCommand command)
 {
     this.Notification = notification;
     this.AxisCommand  = command;
 }
        private void HandleButtonCommand(GameControllerButtonCommand command, GameControllerUpdateNotification notification)
        {
            int index;

            switch (command)
            {
            case GameControllerButtonCommand.UnPark:
                if (notification == GameControllerUpdateNotification.CommandUp)
                {
                    if (ParkCommand.CanExecute(null))
                    {
                        if (IsParked)
                        {
                            ParkCommand.Execute(null);
                        }
                    }
                }
                break;

            case GameControllerButtonCommand.ParkToHome:
                if (notification == GameControllerUpdateNotification.CommandUp)
                {
                    if (ParkCommand.CanExecute(null))
                    {
                        if (!IsParked)
                        {
                            ParkCommand.Execute(null);
                        }
                    }
                }
                break;

            case GameControllerButtonCommand.Sync:
                if (notification == GameControllerUpdateNotification.CommandUp)
                {
                    if (SyncCommand.CanExecute(null))
                    {
                        SyncCommand.Execute(null);
                    }
                }
                break;

            case GameControllerButtonCommand.IncrementPreset:
                index = Settings.SlewRatePresets.IndexOf(Settings.SlewRatePreset);
                if (index < Settings.SlewRatePresets.Count - 1)
                {
                    Settings.SlewRatePreset = Settings.SlewRatePresets[index + 1];
                }
                break;

            case GameControllerButtonCommand.DecrementPreset:
                index = Settings.SlewRatePresets.IndexOf(Settings.SlewRatePreset);
                if (index > 0)
                {
                    Settings.SlewRatePreset = Settings.SlewRatePresets[index - 1];
                }
                break;

            case GameControllerButtonCommand.EmergencyStop:
                if (notification == GameControllerUpdateNotification.CommandUp)
                {
                    if (StopSlewCommand.CanExecute(SlewButton.Stop))
                    {
                        StopSlewCommand.Execute(SlewButton.Stop);
                    }
                }
                break;

            case GameControllerButtonCommand.North:
                HandleSlewButton(SlewButton.North, notification);
                break;

            case GameControllerButtonCommand.South:
                HandleSlewButton(SlewButton.South, notification);
                break;

            case GameControllerButtonCommand.East:
                HandleSlewButton(SlewButton.East, notification);
                break;

            case GameControllerButtonCommand.West:
                HandleSlewButton(SlewButton.West, notification);
                break;

            case GameControllerButtonCommand.ReverseRA:
                if (notification == GameControllerUpdateNotification.CommandUp)
                {
                    Settings.ReverseRA = !Settings.ReverseRA;
                }
                break;

            case GameControllerButtonCommand.ReverseDec:
                if (notification == GameControllerUpdateNotification.CommandUp)
                {
                    Settings.ReverseDec = !Settings.ReverseDec;
                }
                break;

            case GameControllerButtonCommand.SiderealRate:
                HandleStartStopTrackingButton(TrackingMode.Sidereal, notification);
                break;

            case GameControllerButtonCommand.LunarRate:
                HandleStartStopTrackingButton(TrackingMode.Lunar, notification);
                break;

            case GameControllerButtonCommand.SolarRate:
                HandleStartStopTrackingButton(TrackingMode.Solar, notification);
                break;

            case GameControllerButtonCommand.CustomRate:
                HandleStartStopTrackingButton(TrackingMode.Custom, notification);
                break;

            case GameControllerButtonCommand.StopTracking:
                HandleStartStopTrackingButton(TrackingMode.Stop, notification);
                break;
            }
        }