• 大小: 0.53M
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2024-04-30
  • 语言: C#
  • 标签: 数据  仰角  方位角  

资源简介

简单写了一个读取GY-25 倾斜度模块数据,应该有bug,需要的可以自行修改

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace AngleSensor
{
    public partial class Form1 : Form
    {
        

        public Form1()
        {
            InitializeComponent();
            InitPort();
            
        }

        private void ConfigUI()
        {

            //初始化天线仰角地图
            BuildElevation();
            //初始化航向地图
            BuildHeading();
            // 启动时钟
            StartClocks();
        }

        private void InitPort()
        {
            //加载串口号
            SerialPortUtil.SetPortNameValues(cmbAngleSensorSerial);
            //加载波特率
            SerialPortUtil.SetBauRateValues(cmbAngleSensorBand);
            //加载数据位
            SerialPortUtil.SetDataBitsValues(cmbAngleSensorDataBits);
            //设置校验位
            SerialPortUtil.SetParityValues(cmbAngleSensorParity);
            //设置停止位
            SerialPortUtil.SetStopBitValues(cmbAngleSensorStop);
        }

        private void btnConnectAngleSensor_Click(object sender EventArgs e)
        {

            if (cmbAngleSensorSerial.Text.Length == 0 && btnConnectAngleSensor.Text != “连接传感器“)
            {
                MessageBox.Show(“请选择端口“);
                return;
            }
            if (AngleSensorSerial == null)
            {
                AngleSensorSerial = new SerialPortUtil(cmbAngleSensorSerial.Text cmbAngleSensorBand.Text cmbAngleSensorParity.Text cmbAngleSensorDataBits.Text cmbAngleSensorStop.Text);
            }
            ConfigUI();
            try
            {
                switch (AngleSensorSerial.IsOpen)
                {
                    case false:

                        AngleSensorSerial.OpenPort();
                        System.Threading.Thread.Sleep(1000);
                        btnConnectAngleSensor.Text = “断开传感器“;
                        break;

                    case true:
                        AngleSensorSerial.ClosePort();
                        System.Threading.Thread.Sleep(1000);
                        btnConnectAngleSensor.Text = “连接传感器“;
                        break;
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(“端口被占用或本地无该端口请检查!“);
            }


            if (AngleSensorSerial.IsOpen)
            {
                MessageBox.Show( “传感器连接成功“);
            }
            else
            {
                MessageBox.Show(“传感器端口已断开“);
            }
        }



        /// 

        ///仰角定位点参数为仰角角度
        /// 

        private void BuildElevationTarget(double Eltemp)
        {
            // Draw target point
            BuildElevation();
            lblAngleSensorEl.Text = Eltemp.ToString() + “°“;
            int ra

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       3847  2020-08-19 16:10  角度传感器\AngleSensor\AngleSensor.csproj

     文件        187  2020-08-19 16:01  角度传感器\AngleSensor\App.config

     文件      31232  2020-08-19 17:17  角度传感器\AngleSensor\bin\Debug\AngleSensor.exe

     文件        187  2020-08-19 16:01  角度传感器\AngleSensor\bin\Debug\AngleSensor.exe.config

     文件      56832  2020-08-19 17:17  角度传感器\AngleSensor\bin\Debug\AngleSensor.pdb

     文件      23168  2020-08-19 17:17  角度传感器\AngleSensor\bin\Debug\AngleSensor.vshost.exe

     文件        187  2020-08-19 16:01  角度传感器\AngleSensor\bin\Debug\AngleSensor.vshost.exe.config

     文件        490  2013-03-18 17:00  角度传感器\AngleSensor\bin\Debug\AngleSensor.vshost.exe.manifest

     文件      17341  2020-08-19 17:17  角度传感器\AngleSensor\Form1.cs

     文件      28539  2020-08-19 17:17  角度传感器\AngleSensor\Form1.Designer.cs

     文件       5817  2020-08-19 16:45  角度传感器\AngleSensor\Form1.resx

     文件       1000  2020-08-19 17:17  角度传感器\AngleSensor\obj\Debug\AngleSensor.csproj.FileListAbsolute.txt

     文件        977  2020-08-19 16:51  角度传感器\AngleSensor\obj\Debug\AngleSensor.csproj.GenerateResource.Cache

     文件      31232  2020-08-19 17:17  角度传感器\AngleSensor\obj\Debug\AngleSensor.exe

     文件        180  2020-08-19 16:51  角度传感器\AngleSensor\obj\Debug\AngleSensor.Form1.resources

     文件      56832  2020-08-19 17:17  角度传感器\AngleSensor\obj\Debug\AngleSensor.pdb

     文件        180  2020-08-19 16:10  角度传感器\AngleSensor\obj\Debug\AngleSensor.Properties.Resources.resources

     文件        865  2020-08-19 16:01  角度传感器\AngleSensor\obj\Debug\DesignTimeResolveAssemblyReferences.cache

     文件       7160  2020-08-19 16:10  角度传感器\AngleSensor\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件          0  2020-08-19 16:01  角度传感器\AngleSensor\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs

     文件          0  2020-08-19 16:01  角度传感器\AngleSensor\obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs

     文件          0  2020-08-19 16:01  角度传感器\AngleSensor\obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs

     文件        523  2020-08-19 16:01  角度传感器\AngleSensor\Program.cs

     文件       1364  2020-08-19 16:01  角度传感器\AngleSensor\Properties\AssemblyInfo.cs

     文件       2874  2020-08-19 16:01  角度传感器\AngleSensor\Properties\Resources.Designer.cs

     文件       5612  2020-08-19 16:01  角度传感器\AngleSensor\Properties\Resources.resx

     文件       1098  2020-08-19 16:01  角度传感器\AngleSensor\Properties\Settings.Designer.cs

     文件        249  2020-08-19 16:01  角度传感器\AngleSensor\Properties\Settings.settings

     文件      16677  2020-08-19 16:10  角度传感器\AngleSensor\SerialPortUtil.cs

     文件       1002  2020-08-19 16:01  角度传感器\角度传感器.sln

............此处省略13个文件信息

评论

共有 条评论