예제 #1
0
        private void SetScopePositionAndObjectText(bool sendPositionToStellarium)
        {
            if (!scopePosAndObjTextChanged_ && !sendPositionToStellarium)
            {
                return;
            }
            scopePosAndObjTextChanged_ = false;

            double d = ClientCommonAPI.CalcTime();

            string s = "";

            if (connectionAltAzm_ == null)
            {
                s += "Encoder Abs Positions Unknown" + Environment.NewLine;
            }
            else
            {
                s += "Encoder Abs Positions: Azm = " + ClientCommonAPI.PrintAngle(AzmAngle * Const.toDeg, false, false) + ", Alt = " + ClientCommonAPI.PrintAngle(AltAngle * Const.toDeg, false, false) + Environment.NewLine;
                s += "ErrCnt = " + errorCnt_ + Environment.NewLine;
            }

            if (connectionEqu_ == null)
            {
                s += "Equ Angle Unknown" + Environment.NewLine;
            }
            else
            {
                s += "Equ Angle = " + ClientCommonAPI.PrintAngle(EquAngle * Const.toDeg) + Environment.NewLine;
            }

            s += Environment.NewLine;
            if (connectionAltAzm_ == null || connectionEqu_ == null)
            {
                s += "Scope Position Unknown";
            }
            else if (alignment_ != null && alignment_.IsAligned)
            {
                PairA horz = alignment_.Scope2Horz(new PairA(AzmAngle, AltAngle), EquAngle);

                s += "Scope Position: Azm = " + ClientCommonAPI.PrintAngle(SkyObjectPosCalc.Rev(horz.Azm * Const.toDeg), false, false);
                s += ", Alt = " + ClientCommonAPI.PrintAngle(SkyObjectPosCalc.Rev(horz.Alt * Const.toDeg), false, false) + Environment.NewLine;

                double dec, ra;
                SkyObjectPosCalc.AzAlt2Equ(d, latitude_, longitude_, SkyObjectPosCalc.Rev(horz.Azm * Const.toDeg), SkyObjectPosCalc.Rev(horz.Alt * Const.toDeg), out dec, out ra);
                s += "R.A.\t= " + ClientCommonAPI.PrintTime(ra) + " (" + ra.ToString("F5") + "\x00B0)" + Environment.NewLine;
                s += "Dec.\t= " + ClientCommonAPI.PrintAngle(dec, true) + " (" + ClientCommonAPI.PrintDec(dec, "F5") + "\x00B0)" + Environment.NewLine;

                if (sendPositionToStellarium && stellariumConnection_ != null && stellariumConnection_.IsConnected)
                {
                    stellariumConnection_.SendPosition(dec, ra);
                }
            }

            s += Environment.NewLine;
            if (object_ == null)
            {
                s += "No Object Selected";
            }
            else
            {
                double azm, alt;
                object_.CalcAzimuthal(d, latitude_, longitude_, out azm, out alt);
                s += object_.Name + ": Azm = " + ClientCommonAPI.PrintAngle(azm, false, false);
                s += ", Alt = " + ClientCommonAPI.PrintAngle(alt, false, false) + Environment.NewLine;

                double dec, ra;
                object_.CalcTopoRaDec(d, latitude_, longitude_, out dec, out ra);
                s += "R.A.\t= " + ClientCommonAPI.PrintTime(ra) + " (" + ra.ToString("F5") + "\x00B0)" + Environment.NewLine;
                s += "Dec.\t= " + ClientCommonAPI.PrintAngle(dec, true) + " (" + ClientCommonAPI.PrintDec(dec, "F5") + "\x00B0)" + Environment.NewLine;

                /*
                 * double azm, alt;
                 * object_.CalcAzimuthal(d, latitude_, longitude_, out azm, out alt);
                 * s += "Azm.\t= " + ScopeDSCClient.PrintAngle(azm) + " (" + azm.ToString("F5") + "\x00B0)" + Environment.NewLine;
                 * s += "Alt.\t= " + ScopeDSCClient.PrintAngle(alt) + " (" + alt.ToString("F5") + "\x00B0)";
                 * */
            }

            textBoxObject.Text = s;
        }
예제 #2
0
        private void CalcAndOutputResults()
        {
            if (!init_)
            {
                return;
            }

            // if true, make four start alignment (i.e. actually the same two alignment starts, but twice for two equatorial angles)
            bool fourStars = textBoxPlatformA2.Enabled = textBoxPlatformDA2.Enabled = checkBox4StarAlignment.Checked;

            string s = "";

            try
            {
                {
                    //rnd_ = new Random(0);

                    PairA stand1 = ToScope(Star1, equAngle_).Offset(RndAngleErr(), RndAngleErr());

                    s += "Eq angle = " + (equAngle_ * toDeg).ToString() + ", Star1 in scope coordinates = " + PrintV(stand1) + Environment.NewLine;
                    if (stand1.Below(minAlt_ + altOff_))
                    {
                        throw new ApplicationException("Star1 is below min altitude");
                    }

                    PairA stand2 = ToScope(Star2, equAngle_ + equAngleD_).Offset(RndAngleErr(), RndAngleErr());

                    s += "Eq angle = " + ((equAngle_ + equAngleD_) * toDeg).ToString() + ", Star2 in scope coordinates = " + PrintV(stand2) + Environment.NewLine;
                    if (stand2.Below(minAlt_ + altOff_))
                    {
                        throw new ApplicationException("Star2 is below min altitude");
                    }

                    s += Environment.NewLine;

                    PairA stand21 = new PairA(), stand22 = new PairA();
                    if (fourStars)
                    {
                        stand21 = ToScope(Star1, equAngle2_).Offset(RndAngleErr(), RndAngleErr());
                        stand22 = ToScope(Star2, equAngle2_ + equAngleD2_).Offset(RndAngleErr(), RndAngleErr());

                        s += "Eq angle = " + (equAngle2_ * toDeg).ToString() + ", Star1 in scope coordinates = " + PrintV(stand21) + Environment.NewLine;
                        s += "Eq angle = " + ((equAngle2_ + equAngleD2_) * toDeg).ToString() + ", Star2 in scope coordinates = " + PrintV(stand22) + Environment.NewLine;
                        s += Environment.NewLine;
                    }

                    Alignment calc;

                    /*
                     * if (fourStars && (equAngleD_ != 0 || equAngleD2_ != 0))
                     * {
                     *  Vect3 star1 = new Vect3(Star1);
                     *  Vect3 star2 = new Vect3(Star2);
                     *  int iterations = MakeDynamic4StarAlignment(star1, "Star1", stand1, equAngle_ * equAngleFactor_,
                     *                                   star2, "Star2", stand2, (equAngle_ + equAngleD_) * equAngleFactor_,
                     *                                   star1, "Star1", stand21, equAngle2_ * equAngleFactor_,
                     *                                   star2, "Star2", stand22, (equAngle2_ + equAngleD2_) * equAngleFactor_,
                     *                                   out calc);
                     *  s += "Iterations: " + iterations.ToString();
                     *  s += Environment.NewLine;
                     * }
                     * else
                     * */
                    {
                        calc = new DSCAlignment(new Vect3(0, latitude_), precesions_);
                        calc.AddStar(new AlignStar("Star1", new Vect3(Star1), stand1, equAngle_ * equAngleFactor_));
                        calc.AddStar(new AlignStar("Star2", new Vect3(Star2), stand2, (equAngle_ + equAngleD_) * equAngleFactor_));
                        if (fourStars)
                        {
                            calc.AddStar(new AlignStar("Star1", new Vect3(Star1), stand21, equAngle2_ * equAngleFactor_));
                            calc.AddStar(new AlignStar("Star2", new Vect3(Star2), stand22, (equAngle2_ + equAngleD2_) * equAngleFactor_));
                        }
                    }

                    s += calc.ToString(true);
                    if (IsEquAxisCorrectionNeeded(latitude_, calc))
                    {
                        s += Environment.NewLine + AddEquAxisCorrectionText(latitude_, calc);
                    }
                    s += Environment.NewLine;
                    s += Environment.NewLine;

                    s += "OBJECT POSITION" + Environment.NewLine;
                    PairA standObj = ToScope(Obj, objEquAngle_);
                    s += "Object in scope coordinates = " + PrintV(standObj);
                    s += Environment.NewLine;
                    if (standObj.Below(minAlt_ + altOff_))
                    {
                        throw new ApplicationException("Object is below min altitude");
                    }

                    PairA  calcObj  = calc.Scope2Horz(standObj, objEquAngle_ * equAngleFactor_);
                    double errorMin = Math.Asin(Vect3.VMul(new Vect3(Obj), new Vect3(calcObj)).Abs) * toDeg * 60;
                    s += "Calculated Horizontal Object: " + PrintV(calcObj) + ", error " + errorMin.ToString("F2") + " arc min";
                    s += Environment.NewLine;
                    s += Environment.NewLine;

                    alignment_ = calc; // (Alignment)calc.Clone();

                    if (IsEquAxisCorrectionNeeded(latitude_, calc))
                    {
                        calc.CorrectEquAxis(new Vect3(0, latitude_));
                        s += calc.ToString(true);
                    }
                }
            }
            catch (Exception e)
            {
                s += e.Message;
                s += Environment.NewLine;
            }

            textBoxResults.Text = s;
        }