Exemple #1
0
        private static TLIMIT_STATUS Limits_Detect()
        {
            TLIMIT_STATUS result   = new TLIMIT_STATUS();
            object        oLangDll = null;

            object[] EQ_Beep = null;
            object   HC      = null;

            double Alt           = 0;
            bool   LimitDetected = false;

            result.LimitDetected = false;
            result.Horizon       = false;
            result.RA            = false;

            // Routine to handle RA LIMIT processing
            if ((EQMath.gRA_Limit_East != 0) && (EQMath.gEmulRA < EQMath.gRAEncoder_Zero_pos))
            {
                if (EQMath.gEmulRA < EQMath.gRA_Limit_East)
                {
                    if (gAutoFlipEnabled)
                    {
                        switch (AutoFlipState)
                        {
                        case 0:
                            //we've hit the RA limit so initiate autoflip!
                            Goto.gTargetRA  = EQMath.gRA;
                            Goto.gTargetDec = EQMath.gDec;
                            //UPGRADE_TODO: (1067) Member GetLangString is not defined in type Variant. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1067
                            //UPGRADE_TODO: (1067) Member Add_Message is not defined in type Variant. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1067
                            HC.Add_Message("CoordSlew: " + Convert.ToString(oLangDll.GetLangString(105)) + "[ " + EQMath.FmtSexa(Goto.gTargetRA, false) + " ] " + Convert.ToString(oLangDll.GetLangString(106)) + "[ " + EQMath.FmtSexa(Goto.gTargetDec, true) + " ]");
                            Goto.gSlewCount = Goto.gMaxSlewCount;                                      //NUM_SLEW_RETRIES               'Set initial iterative slew count
                            object tempAuxVar = EQ_Beep[2];
                            Goto.radecAsyncSlew(Goto.gGotoRate);
                            AutoFlipState = 1;
                            break;

                        default:
                            break;
                        }
                    }
                    else
                    {
                        result.RA = true;
                    }
                    goto endsub;
                }
                else
                {
                    AutoFlipState = 0;
                }
            }

            if ((EQMath.gRA_Limit_West != 0) && (EQMath.gEmulRA > EQMath.gRAEncoder_Zero_pos))
            {
                if (EQMath.gEmulRA > EQMath.gRA_Limit_West)
                {
                    if (gAutoFlipEnabled)
                    {
                        switch (AutoFlipState)
                        {
                        case 0:
                            //we've hit the RA limit so initiate autoflip!
                            Goto.gTargetRA  = EQMath.gRA;
                            Goto.gTargetDec = EQMath.gDec;
                            //UPGRADE_TODO: (1067) Member GetLangString is not defined in type Variant. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1067
                            //UPGRADE_TODO: (1067) Member Add_Message is not defined in type Variant. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1067
                            HC.Add_Message("CoordSlew: " + Convert.ToString(oLangDll.GetLangString(105)) + "[ " + EQMath.FmtSexa(Goto.gTargetRA, false) + " ] " + Convert.ToString(oLangDll.GetLangString(106)) + "[ " + EQMath.FmtSexa(Goto.gTargetDec, true) + " ]");
                            Goto.gSlewCount = Goto.gMaxSlewCount;                                      //NUM_SLEW_RETRIES               'Set initial iterative slew count
                            object tempAuxVar2 = EQ_Beep[2];
                            Goto.radecAsyncSlew(Goto.gGotoRate);
                            AutoFlipState = 1;
                            break;

                        default:
                            break;
                        }
                    }
                    else
                    {
                        result.RA = true;
                    }
                    goto endsub;
                }
                else
                {
                    AutoFlipState = 0;
                }
            }

endsub:
            // get altitude limit for current azimuth
            if (!gSupressHorizonLimits)
            {
                if (EQMath.gAlt <= LimitArray2[Convert.ToInt32(EQMath.gAz)].Alt)
                {
                    result.Horizon = true;
                }
            }
            else
            {
                result.Horizon = false;
            }


            result.LimitDetected = result.Horizon || result.RA;
            return(result);
        }
Exemple #2
0
        //UPGRADE_NOTE: (2041) The following line was commented. More Information: https://www.mobilize.net/vbtonet/ewis/ewi2041
        //[DllImport("kernel32.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
        //extern public static int GetTickCount();

        private void EncoderTimer_Timer()
        {
            eqmodvector.Coordt tmpcoord = new eqmodvector.Coordt();
            double             tRa      = 0;
            double             tAlt     = 0;
            double             tAz      = 0;
            object             tmpRa    = null;
            int tmpDec = 0;

            //Avoid overruns
            if (EncoderTimerFlag)
            {
                EncoderTimerFlag = false;
                //UPGRADE_TODO: (1067) Member CheckRASync is not defined in type HC. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1067
                //Read true motor positions
                tmpRa  = Common.EQGetMotorValues(0);
                tmpDec = Common.EQGetMotorValues(1);

                EQMath.gEmulRA      = Convert.ToDouble(tmpRa);
                EQMath.gEmulDEC     = tmpDec;
                EQMath.gEmulRA_Init = EQMath.gEmulRA;
                EQMath.gLast_time   = EQMath.EQnow_lst_norange();
                EQMath.gEmulOneShot = false;

                if (!Alignment.gThreeStarEnable)
                {
                    Alignment.gSelectStar = 0;
                    EQMath.gRA_Encoder    = EQMath.Delta_RA_Map(EQMath.gEmulRA);
                    EQMath.gDec_Encoder   = EQMath.Delta_DEC_Map(EQMath.gEmulDEC);
                }
                else
                {
                    switch (Common.gAlignmentMode)
                    {
                    case 2:
                        tmpcoord            = EQMath.DeltaSync_Matrix_Map(EQMath.gEmulRA, EQMath.gEmulDEC);
                        EQMath.gRA_Encoder  = tmpcoord.x;
                        EQMath.gDec_Encoder = tmpcoord.Y;

                        break;

                    case 1:
                        tmpcoord            = EQMath.Delta_Matrix_Reverse_Map(EQMath.gEmulRA, EQMath.gEmulDEC);
                        EQMath.gRA_Encoder  = tmpcoord.x;
                        EQMath.gDec_Encoder = tmpcoord.Y;

                        break;

                    default:
                        tmpcoord            = EQMath.Delta_Matrix_Reverse_Map(EQMath.gEmulRA, EQMath.gEmulDEC);
                        EQMath.gRA_Encoder  = tmpcoord.x;
                        EQMath.gDec_Encoder = tmpcoord.Y;
                        if (tmpcoord.f == 0)
                        {
                            tmpcoord            = EQMath.DeltaSync_Matrix_Map(EQMath.gEmulRA, EQMath.gEmulDEC);
                            EQMath.gRA_Encoder  = tmpcoord.x;
                            EQMath.gDec_Encoder = tmpcoord.Y;
                        }

                        break;
                    }
                }

                //Convert RA_Encoder to Hours
                if ((EQMath.gRA_Encoder < 0x1000000))
                {
                    EQMath.gRA_Hours = EQMath.Get_EncoderHours(EQMath.gRAEncoder_Zero_pos, EQMath.gRA_Encoder, EQMath.gTot_RA, EQMath.gHemisphere);
                }

                //Convert DEC_Encoder to DEC Degrees
                EQMath.gDec_DegNoAdjust = EQMath.Get_EncoderDegrees(EQMath.gDECEncoder_Zero_pos, EQMath.gDec_Encoder, EQMath.gTot_DEC, EQMath.gHemisphere);
                if (EQMath.gDec_Encoder < 0x1000000)
                {
                    EQMath.gDec_Degrees = EQMath.Range_DEC(EQMath.gDec_DegNoAdjust);
                }

                tRa = EQMath.EQnow_lst(EQMath.gLongitude * EQMath.DEG_RAD) + EQMath.gRA_Hours;
                if (EQMath.gHemisphere == 0)
                {
                    if ((EQMath.gDec_DegNoAdjust > 90) && (EQMath.gDec_DegNoAdjust <= 270))
                    {
                        tRa -= 12;
                    }
                }
                else
                {
                    if ((EQMath.gDec_DegNoAdjust <= 90) || (EQMath.gDec_DegNoAdjust > 270))
                    {
                        tRa += 12;
                    }
                }
                tRa = EQMath.Range24(tRa);

                //assign global RA / Dec
                EQMath.gRA  = tRa;
                EQMath.gDec = EQMath.gDec_Degrees;
                EQMath.gha  = tRa - EQMath.EQnow_lst(EQMath.gLongitude * EQMath.DEG_RAD);

                //calc alt/ az poition
                ((Array)hadec_aa).GetValue(Convert.ToInt32(EQMath.gLatitude * EQMath.DEG_RAD), Convert.ToInt32(EQMath.gha * EQMath.HRS_RAD), Convert.ToInt32(EQMath.gDec_Degrees * EQMath.DEG_RAD), Convert.ToInt32(tAlt), Convert.ToInt32(tAz));
                //asign global Alt / Az
                EQMath.gAlt = tAlt * EQMath.RAD_DEG;         // convert to degrees from Radians
                EQMath.gAz  = 360d - (tAz * EQMath.RAD_DEG); //  convert to degrees from Radians

                //Poll the Motor Status while slew is active
                if (EQMath.gSlewStatus)
                {
                    EQMath.gRAStatus  = UpgradeSolution1Support.PInvoke.SafeNative.eqcontrl.EQ_GetMotorStatus(0);
                    EQMath.gDECStatus = UpgradeSolution1Support.PInvoke.SafeNative.eqcontrl.EQ_GetMotorStatus(1);
                    if (EQMath.gEQparkstatus == 0)
                    {
                        Goto.ManageGoto();
                    }
                }

                //UPGRADE_TODO: (1067) Member Caption is not defined in type Variant. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1067
                AlignmentCountLbl.Caption = Alignment.gAlignmentStars_count.ToString();

                do
                {
                    limit management


                    Limits.Limits_Execute();
                }

                EncoderTimerFlag = true;
            }
        }