三菱PLC通讯RS485模块数据采集与C#开发监控软件到Excel

使用MX Component软件和C#,通过DLL引用连接三菱PLC CPU进行数据采集,并实现监控数据实时导出到Excel。
摘要由CSDN通过智能技术生成
using ActUtlTypeLib;
using NPOI.HSSF.UserModel;
using NPOI.SS.UserModel;
using NPOI.XSSF.Streaming;
using NPOI.XSSF.UserModel;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Forms;

namespace 台博数据采集
{

    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        void jieShouID(string str)//方法=接收子窗体的委托
        {
            sid = str;
            //textBox1.Text = str;
            sid2 = sid;
        }

        public string[] plcDword ={"D500","D501","D502","D503","D504","D505","D506","D507","D508","D509","D510",
            "D511","D512","D513","D514","D515","D516","D517"
        };

        //淋膜模头2#温度的寄存器地址
        public string[] plcDword2 = { "D600","D601","D602","D603","D604","D605","D606","D607","D608","D609","D610",
            "D611","D612","D613","D614","D615","D616","D617"
        };

        //淋膜环境的寄存器地址
        public string[] plcDword3 = { "D700","D701","D702","D703","D704","D705","D706","D707","D708","D709","D710","D711",
            "D716","D718","D719"

            };

        //涂布烘箱温度的寄存器地址
        public string[] plcDword4 = { "D110","D120","D130","D140","D150","D160","D170",
                "D210","D220","D230","D240","D250","D260","D270",
                "D310","D320","D330","D340","D350","D360","D370",
            };

        //涂布环境温度的寄存器地址
        public string[] plcDword5 = { "D180", "D410", "D420", "D430", "D440", "D450", "D460", "D470", "D480",
            "D103","D102","D700","D701","D702","D703",

            };

        public int XunHuan = 0;//开始通讯按钮,循环读取开始标志
        public int Open1 = 0;//1站在线标志
        public int Open2 = 0;//2站在线标志
        public int RunStop = 0;//开始通讯按钮=1,关闭通讯按钮=0。
        public int add1 = 0;//写入Excel文件的当前行号
        public int add2 = 0;//写入文件执行标志
        public string sid;//创建文件夹的位置
        public static string sid2;//保存创建文件夹的位置

        public string[] fanHui = new string[18] { "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0" };//淋膜1#当前温度
        public string[] fanHui2 = new string[18] { "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0" };//淋膜2#当前温度
        public string[] fanHui3 = new string[15] { "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0" };//淋膜环境温度
        public string[] fanHui4 = new string[21] { "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0" };//涂布烘箱温度
        public string[] fanHui5 = new string[15] { "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0" };//涂布环境温度

        #region//创建文件的按钮处理
        /// <summary>
        /// 创建文件的按钮处理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void 创建文件夹ToolStripMenuItem_Click(object sender, EventArgs e)//创建文件夹按钮
        {
            Form2 form2 = new Form2(
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值