示例#1
0
        // 处理指向
        private void ProcSlewto()
        {
            // 检查输入坐标正确性
            string strEpoch = cmbInEpoch.Text;
            double ra       = 0.0;
            double dec      = 0.0;
            double tmsid    = 0.0; // 恒星时

            if (false == ats_.StringHour2Double(txtInRA.Text, ref ra))
            {
                txtLog.AppendLine("Invalid R.A. style");
                //...设置错误字
                return;
            }
            if (false == ats_.StringDegree2Double(txtInDEC.Text, ref dec))
            {
                txtLog.AppendLine("Invalid DEC. style");
                //...设置错误字
                return;
            }
            // DDMAgent=>Autoslew:当前历元
            DateTime now  = DateTime.UtcNow;
            double   ra_a = 0.0;
            double   de_a = 0.0;

            char[] epLead = { 'B', 'J' }; // 常见历元的引导字符, 例: B1950, J2000
            double jc1    = Convert.ToDouble(strEpoch.Trim(epLead));
            double jc2    = ats_.GetEpoch(now.Year, now.Month, now.Day,
                                          now.Hour + (now.Minute + (now.Second + now.Millisecond * 0.001) / 60.0) / 60.0);

            jc1 = ats_.Epoch2JC(jc1);    // 转换为儒略世纪
            jc2 = ats_.Epoch2JC(jc2);
            if (strEpoch != "" && string.Compare(strEpoch, "Real", StringComparison.CurrentCultureIgnoreCase) != 0)
            {// J2000=>Real
                nftele_.ora00 = ra * 15.0;
                nftele_.odc00 = dec;
                ats_.Epoch2Actual(jc1, ra * 15 * AstroArith.GtoR, dec * AstroArith.GtoR,
                                  jc2, ref ra_a, ref de_a);
                ra          = ra_a * AstroArith.RtoG / 15;
                dec         = de_a * AstroArith.RtoG;
                nftele_.ora = ra * 15.0;
                nftele_.odc = dec;
            }
            else
            {// Real=>J2000
                nftele_.ora = ra * 15.0;
                nftele_.odc = dec;
                ats_.Epoch2Actual(jc2, ra * 15 * AstroArith.GtoR, dec * AstroArith.GtoR,
                                  jc1, ref ra_a, ref de_a);
                nftele_.ora00 = ra_a * AstroArith.RtoG;
                nftele_.odc00 = de_a * AstroArith.RtoG;
            }

            tmsid = telescope_.SiderealTime; // 恒星时, 量纲: 小时
            if (SafePosition((tmsid - ra) * 15.0, dec) == false)
            {                                // 超出安全限位, 界面显示及通知远程用户
                txtLog.AppendLine("Out of Limit");
                //...设置错误字
            }
            else
            {// 在安全范围内
                if (telescope_.AtPark == true)
                {
                    telescope_.Unpark();
                }
                if (telescope_.Tracking == false)
                {
                    telescope_.Tracking = true;
                }

                obj_range_ = ats_.SphereAngle(nftele_.ora00, nftele_.odc00, telescope_.RightAscension * 15.0, telescope_.Declination);

                if (obj_range_ < 1E-6) // 1E-6弧度≈0.2角秒
                {
                    nftele_.state = TELESCOPE_STATE.TELESCOPE_TRACKING;
                }
                else
                {
                    // 指向前同步时钟
                    if (ntp_ != null && ntp_.validCorrect == true && ntp_.clockCorrect.TotalMilliseconds > 50)
                    {
                        DateTime now1 = DateTime.Now + ntp_.clockCorrect;
                        ntp_.SetTime(ref now1);
                    }
                    // 执行指向操作
                    nftele_.state = TELESCOPE_STATE.TELESCOPE_SLEWING;
                    telescope_.TargetRightAscension = ra;
                    telescope_.TargetDeclination    = dec;
                    telescope_.SlewToTargetAsync();

                    procSlew.Value = procSlew.Minimum;
                }
                lblState.Text = TELESCOPE_STATE_STR[(int)nftele_.state];
            }
        }