• 大小: 157KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-20
  • 语言: C#
  • 标签: C#  动态曲线  

资源简介

C#通过串口连接硬件设备,并获取硬件数据,然后将数据点绘制成动态曲线,显示出来

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
using System.IO.Ports;    //对应串口操作命名空间
using System.Threading;
using System.Collections;   //线程命名空间

namespace DynamicCurce
{
    public partial class FrmMain : Form
    {
        public SerialPort mycomm;//定义一串口对象
        MyControl my = new MyControl();
        //构造函数
        public FrmMain()
        {
            InitializeComponent();
            this.Resize += new EventHandler(FrmMain_Resize);
        }

       void FrmMain_Resize(object sender EventArgs e)
        {
            this.plMain.Width = this.panel1.Width;
            this.plMain.Height = this.panel1.Height - this.panel2.Height-this.plTop.Height-30;
        }

        #region 菜单操作
        //显示网一温度
        private void 温度ToolStripMenuItem_Click(object sender EventArgs e)
        {
            
        }
        //显示网一湿度
        private void 湿度ToolStripMenuItem_Click(object sender EventArgs e)
        {
            
        }
        #endregion

        //窗体加载
        private void FrmMain_Load(object sender EventArgs e)
        {
            //this.statusStrip1.
        }
        
        //关闭窗体
        private void button1_Click_1(object sender EventArgs e)
        {
            this.Close();
        }

        //模拟动态绘制曲线
        private void timer1_Tick(object sender EventArgs e)
        {
            float value = 25F;
            my.ReadData(“Temperature“ value);
        }
        //开始绘制曲线
        private void button2_Click(object sender EventArgs e)
        {
            this.timer1.Interval = 1000;
            this.timer1.Enabled = !this.timer1.Enabled;
            if (this.timer1.Enabled)
            {
                this.button2.Text = “暂停绘图“;
            }
            else
            {
                this.button2.Text = “开始绘图“;
            }
        }        
        //初始化曲线
        private void button3_Click(object sender EventArgs e)
        {
            this.plMain.Controls.Clear();
            my.Anchor = Anchorstyles.None;
            my.Dock = Dockstyle.Fill;

            #region 曲线初始化变量
            string myCurKey = ““;
            string myCurtitle = ““;
            Color myCurNormalColor = new Color();
            Color myCurErrorColor = new Color();
            int myXRange = 90;
            int myXSeqment = 6;
            string myXunit = ““;
            int myYErrorMaxValue=70;
            string myYErrorMaxtitle = ““;
            int myYErrorMinValue=30;
            string myYErrorMintitle = ““;
            int myYNormalMaxValue=60;
            string myYNormalMaxtitle = ““;
            int myYNormalMinValue=40;
            string myYNormalMintitle = ““;
            int myYTerminalMaxValue=100;
            string myYTerminalMaxtitle = ““;
            int my

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

    ..A..H.       162  2009-05-11 09:58  Curve\~$曲线开发文档.doc

     文件       5612  2009-04-16 09:30  Curve\DynamicCurce\DynamicCurce\Properties\Resources.resx

     文件        249  2009-04-16 09:30  Curve\DynamicCurce\DynamicCurce\Properties\Settings.settings

     文件       1196  2009-04-16 09:30  Curve\DynamicCurce\DynamicCurce\Properties\AssemblyInfo.cs

     文件       2878  2009-04-16 09:30  Curve\DynamicCurce\DynamicCurce\Properties\Resources.Designer.cs

     文件       1095  2009-04-16 09:30  Curve\DynamicCurce\DynamicCurce\Properties\Settings.Designer.cs

     文件      10676  2009-05-09 12:31  Curve\DynamicCurce\DynamicCurce\FrmMain.Designer.cs

     文件       6207  2009-05-09 12:31  Curve\DynamicCurce\DynamicCurce\FrmMain.resx

     文件       3693  2009-05-12 15:01  Curve\DynamicCurce\DynamicCurce\DynamicCurce.csproj

     文件       5632  2005-12-08 14:51  Curve\DynamicCurce\DynamicCurce\bin\Debug\DynamicCurce.vshost.exe

     文件      45056  2009-05-12 15:01  Curve\DynamicCurce\DynamicCurce\bin\Debug\DynamicCurce.dll

     文件      65024  2009-05-12 15:01  Curve\DynamicCurce\DynamicCurce\bin\Debug\DynamicCurce.pdb

     文件    1253376  2009-05-12 14:57  Curve\DynamicCurce\DynamicCurce\bin\Debug\CurceData.mdb

     文件        180  2009-05-09 16:22  Curve\DynamicCurce\DynamicCurce\obj\Debug\DynamicCurce.FrmMain.resources

     文件        180  2009-05-12 14:59  Curve\DynamicCurce\DynamicCurce\obj\Debug\DynamicCurce.MyControl.resources

     文件        180  2009-05-09 16:22  Curve\DynamicCurce\DynamicCurce\obj\Debug\DynamicCurce.Properties.Resources.resources

     文件        906  2009-05-12 14:59  Curve\DynamicCurce\DynamicCurce\obj\Debug\DynamicCurce.csproj.GenerateResource.Cache

     文件      65024  2009-05-12 15:01  Curve\DynamicCurce\DynamicCurce\obj\Debug\DynamicCurce.pdb

     文件      45056  2009-05-12 15:01  Curve\DynamicCurce\DynamicCurce\obj\Debug\DynamicCurce.dll

     文件        349  2009-05-12 15:01  Curve\DynamicCurce\DynamicCurce\obj\DynamicCurce.csproj.FileList.txt

     文件        473  2009-04-27 14:57  Curve\DynamicCurce\DynamicCurce\Program.cs

     文件      54593  2009-05-12 15:16  Curve\DynamicCurce\DynamicCurce\MyControl.cs

     文件        535  2009-05-09 12:45  Curve\DynamicCurce\DynamicCurce\DynamicCurce.csproj.user

     文件       9056  2009-05-12 14:59  Curve\DynamicCurce\DynamicCurce\MyControl.Designer.cs

     文件       6019  2009-05-12 14:59  Curve\DynamicCurce\DynamicCurce\MyControl.resx

     文件       6692  2009-05-11 15:48  Curve\DynamicCurce\DynamicCurce\FrmMain.cs

     文件       2362  2009-05-09 12:13  Curve\DynamicCurce\DynamicCurce\HistoryData.cs

     文件        925  2009-04-16 09:30  Curve\DynamicCurce\DynamicCurce.sln

    ..A..H.     24064  2009-05-12 15:21  Curve\DynamicCurce\DynamicCurce.suo

     文件      48128  2009-05-12 10:39  Curve\曲线开发文档.doc

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

评论

共有 条评论