• 大小: 71KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-28
  • 语言: C#
  • 标签: 上位机  c#  数据采集  

资源简介

实现10路串口数据的采集,显示,解析保存,并能够实时图表显示

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace WindowsFormsApplication2
{
    public interface IUpdateTxt
    {
        void Save(string data);

        bool Start(string path string flag string header);

        void Stop();
    }
    class UpdateTxt : IUpdateTxt
    {
        private string path;

        private string text;

        public void SetPath(string path string Index)
        {
            DateTime dt = DateTime.Now;
            string time = string.Format(“{0:yyyyMMddHHmmssffff}“ dt);
            this.path = path + “\\“ + Index + “_“ + time + “.txt“;
            FileStream fs1 = new FileStream(this.path FileMode.Create);//创建写入文件
            fs1.Close();


        }

        public void Save(string data)
        {
            _Save(System.DateTime.Now.ToString() + “;“ + data);
        }
        private void _Save(string data)
        {
            if (!save)
            {
                return;
            }
            if (path == null)
            {
                return;
            }
            StreamWriter sw = new StreamWriter(path true);

            sw.WriteLine(data);
            sw.Close();
        }

        private bool save = false;
        public bool Start(string path string flag string header)
        {
            try
            {
                DateTime dt = DateTime.Now;
                string time = string.Format(“{0:yyyyMMddHHmmssffff}“ dt);
                this.path = path + “\\“ + flag + “_“ + time + “.txt“;
                FileStream fs1 = new FileStream(this.path FileMode.Create);//创建写入文件
                fs1.Close();
                save = true;
                _Save(header);
                return save;
            }
            catch (Exception)
            {
                save = false;
                return save;
            }

        }

        public void Stop()
        {
            save = false;
        }
    }
}

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

    ..A..H.     49664  2018-05-29 17:29  WindowsFormsApplication4\.vs\WindowsFormsApplication2\v14\.suo

     文件      23552  2018-05-29 15:01  WindowsFormsApplication4\WindowsFormsApplication2\bin\Debug\WindowsFormsApplication2.exe

     文件      38400  2018-05-29 15:01  WindowsFormsApplication4\WindowsFormsApplication2\bin\Debug\WindowsFormsApplication2.pdb

     文件      22688  2018-05-29 15:37  WindowsFormsApplication4\WindowsFormsApplication2\bin\Debug\WindowsFormsApplication2.vshost.exe

     文件        490  2015-12-02 08:23  WindowsFormsApplication4\WindowsFormsApplication2\bin\Debug\WindowsFormsApplication2.vshost.exe.manifest

     文件       2085  2018-05-22 16:57  WindowsFormsApplication4\WindowsFormsApplication2\daterecive.cs

     文件      20842  2018-05-29 15:00  WindowsFormsApplication4\WindowsFormsApplication2\Form1.cs

     文件      24107  2018-05-23 12:15  WindowsFormsApplication4\WindowsFormsApplication2\Form1.Designer.cs

     文件       6189  2018-05-23 12:15  WindowsFormsApplication4\WindowsFormsApplication2\Form1.resx

     文件       1452  2018-05-23 12:18  WindowsFormsApplication4\WindowsFormsApplication2\obj\Debug\DesignTimeResolveAssemblyReferences.cache

     文件       6944  2018-05-25 17:36  WindowsFormsApplication4\WindowsFormsApplication2\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件       2814  2018-05-29 15:38  WindowsFormsApplication4\WindowsFormsApplication2\obj\Debug\WindowsFormsApplication2.csproj.FileListAbsolute.txt

     文件       1012  2018-05-25 14:55  WindowsFormsApplication4\WindowsFormsApplication2\obj\Debug\WindowsFormsApplication2.csproj.GenerateResource.Cache

     文件       2210  2018-05-29 15:01  WindowsFormsApplication4\WindowsFormsApplication2\obj\Debug\WindowsFormsApplication2.csprojResolveAssemblyReference.cache

     文件      23552  2018-05-29 15:01  WindowsFormsApplication4\WindowsFormsApplication2\obj\Debug\WindowsFormsApplication2.exe

     文件        180  2018-05-25 14:55  WindowsFormsApplication4\WindowsFormsApplication2\obj\Debug\WindowsFormsApplication2.Form1.resources

     文件      38400  2018-05-29 15:01  WindowsFormsApplication4\WindowsFormsApplication2\obj\Debug\WindowsFormsApplication2.pdb

     文件        180  2018-05-25 14:55  WindowsFormsApplication4\WindowsFormsApplication2\obj\Debug\WindowsFormsApplication2.Properties.Resources.resources

     文件        505  2018-05-21 17:52  WindowsFormsApplication4\WindowsFormsApplication2\Program.cs

     文件       1356  2018-05-21 17:52  WindowsFormsApplication4\WindowsFormsApplication2\Properties\AssemblyInfo.cs

     文件       2861  2018-05-21 17:52  WindowsFormsApplication4\WindowsFormsApplication2\Properties\Resources.Designer.cs

     文件       5612  2018-05-21 17:52  WindowsFormsApplication4\WindowsFormsApplication2\Properties\Resources.resx

     文件       1111  2018-05-21 17:52  WindowsFormsApplication4\WindowsFormsApplication2\Properties\Settings.Designer.cs

     文件        249  2018-05-21 17:52  WindowsFormsApplication4\WindowsFormsApplication2\Properties\Settings.settings

     文件       3803  2018-05-22 16:57  WindowsFormsApplication4\WindowsFormsApplication2\WindowsFormsApplication2.csproj

     文件       1039  2018-05-21 17:52  WindowsFormsApplication4\WindowsFormsApplication2.sln

     目录          0  2018-05-21 17:52  WindowsFormsApplication4\WindowsFormsApplication2\obj\Debug\TempPE

     目录          0  2018-05-25 17:34  WindowsFormsApplication4\.vs\WindowsFormsApplication2\v14

     目录          0  2018-05-25 17:34  WindowsFormsApplication4\WindowsFormsApplication2\bin\Debug

     目录          0  2018-05-22 16:45  WindowsFormsApplication4\WindowsFormsApplication2\bin\Release

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

评论

共有 条评论