Exemplo n.º 1
0
        internal static void StartSlew(double targetRAEncoder, double targetDECEncoder, double currentRAEncoder, double currentDECEncoder)
        {
            int DeltaRAStep  = 0;
            int DeltaDECStep = 0;

            try
            {
                // calculate relative amount to move
                DeltaRAStep  = Convert.ToInt32(Math.Abs(targetRAEncoder - currentRAEncoder));
                DeltaDECStep = Convert.ToInt32(Math.Abs(targetDECEncoder - currentDECEncoder));

                if (DeltaRAStep != 0)
                {
                    // Compensate for the smallest discrepancy after the final slew
                    if (EQMath.gTrackingStatus > 0)
                    {
                        if (targetRAEncoder > currentRAEncoder)
                        {
                            if (EQMath.gHemisphere == 0)
                            {
                                DeltaRAStep += gRA_Compensate;
                            }
                            else
                            {
                                DeltaRAStep -= gRA_Compensate;
                            }
                        }
                        else
                        {
                            if (EQMath.gHemisphere == 0)
                            {
                                DeltaRAStep -= gRA_Compensate;
                            }
                            else
                            {
                                DeltaRAStep += gRA_Compensate;
                            }
                        }
                        if (DeltaRAStep < 0)
                        {
                            DeltaRAStep = 0;
                        }
                    }

                    if (targetRAEncoder > currentRAEncoder)
                    {
                        gGotoParams.RA_Direction = 0;
                        switch (gGotoParams.rate)
                        {
                        case 0:
                            // let mount decide on slew rate
                            gGotoParams.RA_SlewActive = 0;
                            EQMath.eqres = Common.EQStartMoveMotor(0, 0, 0, DeltaRAStep, Convert.ToInt32(EQMath.GetSlowdown(DeltaRAStep)));
                            break;

                        default:
                            gGotoParams.RA_SlewActive = 1;
                            EQMath.eqres = UpgradeSolution1Support.PInvoke.SafeNative.eqcontrl.EQ_Slew(0, 0, 0, Convert.ToInt32(gGotoParams.rate));
                            break;
                        }
                    }
                    else
                    {
                        gGotoParams.RA_Direction = 1;
                        switch (gGotoParams.rate)
                        {
                        case 0:
                            gGotoParams.RA_SlewActive = 0;
                            EQMath.eqres = Common.EQStartMoveMotor(0, 0, 1, DeltaRAStep, Convert.ToInt32(EQMath.GetSlowdown(DeltaRAStep)));
                            break;

                        default:
                            gGotoParams.RA_SlewActive = 1;
                            EQMath.eqres = UpgradeSolution1Support.PInvoke.SafeNative.eqcontrl.EQ_Slew(0, 0, 1, Convert.ToInt32(gGotoParams.rate));
                            break;
                        }
                    }
                }

                if (DeltaDECStep != 0)
                {
                    if (targetDECEncoder > currentDECEncoder)
                    {
                        gGotoParams.DEC_Direction = 0;
                        switch (gGotoParams.rate)
                        {
                        case 0:
                            // let mount decide on slew rate
                            gGotoParams.DEC_SlewActive = 0;
                            EQMath.eqres = Common.EQStartMoveMotor(1, 0, 0, DeltaDECStep, Convert.ToInt32(EQMath.GetSlowdown(DeltaDECStep)));
                            break;

                        default:
                            gGotoParams.DEC_SlewActive = 1;
                            EQMath.eqres = UpgradeSolution1Support.PInvoke.SafeNative.eqcontrl.EQ_Slew(1, 0, 0, Convert.ToInt32(gGotoParams.rate));
                            break;
                        }
                    }
                    else
                    {
                        gGotoParams.DEC_Direction = 1;
                        switch (gGotoParams.rate)
                        {
                        case 0:
                            // let mount decide on slew rate
                            gGotoParams.DEC_SlewActive = 0;
                            EQMath.eqres = Common.EQStartMoveMotor(1, 0, 1, DeltaDECStep, Convert.ToInt32(EQMath.GetSlowdown(DeltaDECStep)));
                            break;

                        default:
                            gGotoParams.DEC_SlewActive = 1;
                            EQMath.eqres = UpgradeSolution1Support.PInvoke.SafeNative.eqcontrl.EQ_Slew(1, 0, 1, Convert.ToInt32(gGotoParams.rate));
                            break;
                        }
                    }
                }

                // Activate Asynchronous Slew Monitoring Routine
                EQMath.gRAStatus      = Common.EQ_MOTORBUSY;
                EQMath.gDECStatus     = Common.EQ_MOTORBUSY;
                EQMath.gRAStatus_slew = false;
            }
            catch
            {
            }


            EQMath.gSlewStatus = true;
        }