コード例 #1
0
        private void ProcessFromServer(string rcvd)
        {
            ascii_proto_base proto = ascproto_.Resolve(rcvd);

            if (proto != null)
            {
                if (proto.type == "slewto")
                {
                    ascii_proto_slewto proto1 = (ascii_proto_slewto)proto;
                    FillTarget(proto1.ra, proto1.dc, proto1.epoch);
                    remote_cmd_ = true;
                    ProcSlewto();
                }
                else if (proto.type == "guide")
                {
                    ascii_proto_guide proto1 = (ascii_proto_guide)proto;
                    FillTarget(nftele_.ora00 + proto1.ra, nftele_.odc00 + proto1.dc, 2000.0);
                    remote_cmd_ = true;
                    ProcSlewto();
                }
                else if (proto.type == "abort_slew")
                {
                    telescope_.AbortSlew();
                }
                else if (proto.type == "park")
                {
                    nftele_.state = TELESCOPE_STATE.TELESCOPE_PARKING;
                    telescope_.Park();
                }
            }
            else
            {// 错误协议
                OnCloseNetwork("received wrong protocol");
            }
        }
コード例 #2
0
        public ascii_proto_base Resolve(string rcvd)
        {
            string[]         split = rcvd.Split(new char[] { ' ', '=', ',', '\n', '\t' });
            int              n = split.Length, i;
            string           type  = split[0];
            ascii_proto_base proto = null;

            // 解析通信协议
            if (type == "park")
            {
                proto = new ascii_proto_park();
            }
            else if (type == "abort_slew")
            {
                proto = new ascii_proto_abort_slew();
            }
            else if (type == "guide")
            {
                ascii_proto_guide proto1 = new ascii_proto_guide();

                for (i = 1; i < n; ++i)
                {
                    if (split[i] == "ra" && (i + 1) < n)
                    {
                        proto1.ra = Convert.ToDouble(split[i + 1]);
                    }
                    else if (split[i] == "dec" && (i + 1) < n)
                    {
                        proto1.dc = Convert.ToDouble(split[i + 1]);
                    }
                }

                proto = proto1;
            }
            else if (type == "slewto")
            {
                ascii_proto_slewto proto1 = new ascii_proto_slewto();
                for (i = 1; i < n; ++i)
                {
                    if (split[i] == "ra" && (i + 1) < n)
                    {
                        proto1.ra = Convert.ToDouble(split[i + 1]);
                    }
                    else if (split[i] == "dec" && (i + 1) < n)
                    {
                        proto1.dc = Convert.ToDouble(split[i + 1]);
                    }
                }

                proto = proto1;
            }

            return(proto);
        }