Beispiel #1
0
        /// <summary>
        /// 打开串口
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOpenPort_Click(object sender, EventArgs e)
        {
            sp = new SerialPort();
            int Baudrate;

            if ((!string.IsNullOrEmpty(comboBoxPort.Text)) && (int.TryParse(comboBoxBaudrate.Text, out Baudrate)))
            {
                Controller.Global.OpenPort(sp, comboBoxPort.Text, Baudrate);
                Controller.Global.Order(sp, "SET", 1);//进入设置模式读取设置
                Thread.Sleep(400);
                ThreadStart ThS = new ThreadStart(delegate()
                {
                    IN19 = new Model.INF_B562_0119();
                    Stf  = new Model.SetInf();
                    Controller.Global.ParseDataIN19(sp, IN19);
                    Controller.Global.In19TOSetInf(IN19, Stf);
                    BeginInvoke((EventHandler)(delegate
                    {
                        labProtocol.Text = Stf.Outputtype;
                        labWoringband.Text = Stf.Rtkrate;
                        labPosFormat.Text = "经纬度";
                        labGNSSmode.Text = Stf.Gnsstype;
                        labRTKmode.Text = Stf.Rtkmode;
                        labRTKoutBdRate.Text = Stf.Rtkoutputrate;
                        labTFmode.Text = Stf.enableFlag;
                        labNetID.Text = Stf.NetID;
                        labchanel.Text = Stf.channels;
                        SetTable(IN19.Stationtype);
                    }));
                });
                Thread thd = new Thread(ThS);
                thd.Start();
                sp.DataReceived += new SerialDataReceivedEventHandler(Interpret);
            }
            else
            {
                MessageBox.Show("输入格式有误", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #2
0
        /// <summary>
        /// 设置信息19协议数据转文本信息
        /// </summary>
        /// <param name="In19"></param>
        /// <param name="Stf"></param>
        public static void In19TOSetInf(Model.INF_B562_0119 In19, Model.SetInf Stf)
        {
            switch (In19.Stationtype)
            {
            case 0: Stf.Stationtype = "基准站";
                break;

            case 1: Stf.Stationtype = "流动站";
                break;
            }
            switch (In19.Outputtype)
            {
            case 0: Stf.Outputtype = "NMEA";
                break;

            case 1: Stf.Outputtype = "UBX";
                break;

            case 2: Stf.Outputtype = "SPB";
                break;

            case 3: Stf.Outputtype = "PIX";
                break;

            case 4: Stf.Outputtype = "JIY";
                break;

            case 5: Stf.Outputtype = "ZEROTECH";
                break;

            case 6: Stf.Outputtype = "DJI";
                break;
            }
            switch (In19.Rtkrate)
            {
            case 0: Stf.Rtkrate = "1HZ";
                break;

            case 1:
                Stf.Rtkrate = "2HZ";
                break;

            case 2:
                Stf.Rtkrate = "4HZ";
                break;

            case 3:
                Stf.Rtkrate = "5HZ";
                break;

            case 4:
                Stf.Rtkrate = "10HZ";
                break;
            }
            switch (In19.Gnsstype)
            {
            case 0: Stf.Gnsstype = "GPS";
                break;

            case 1: Stf.Gnsstype = "GPS+北斗";
                break;
            }
            switch (In19.Rtkmode)
            {
            case 0: Stf.Rtkmode = "静态";
                break;

            case 1: Stf.Rtkmode = "动态";
                break;

            case 2: Stf.Rtkmode = "测向";
                break;
            }
            switch (In19.Rtkoutputrate)
            {
            case 0: Stf.Rtkoutputrate = "9600";
                break;

            case 1: Stf.Rtkoutputrate = "19200";
                break;

            case 2:
                Stf.Rtkoutputrate = "38400";
                break;

            case 3:
                Stf.Rtkoutputrate = "57600";
                break;

            case 4:
                Stf.Rtkoutputrate = "115200";
                break;
            }
            switch (In19.enableFlag)
            {
            case 0: Stf.enableFlag = "关闭";
                break;

            case 1:
                Stf.enableFlag = "打开";
                break;
            }
            Stf.NetID    = In19.NetID.ToString();
            Stf.channels = In19.channels.ToString();
        }