当前位置: 首页 > news >正文

C#使用TCP-S7协议读写西门子PLC(五)-测试程序

上面四篇我们进行封装连接PLC以及读写PLC内存地址表 

C#使用TCP-S7协议读写西门子PLC(一)-CSDN博客

 C#使用TCP-S7协议读写西门子PLC(二)-CSDN博客

 C#使用TCP-S7协议读写西门子PLC(三)-CSDN博客

 C#使用TCP-S7协议读写西门子PLC(四)-CSDN博客

这里我们进行测试操作

西门子PLC-S7协议测试读写基础数据类型、字符串、Unicode字符串、连续数组等

窗体应用程序PlcSiemesS7Demo应用程序文件清单如下图所示

窗体FormS7Protocol设计器如下:

窗体设计器代码如下:

文件FormS7Protocol.Designer.cs


namespace PlcSiemesS7Demo
{partial class FormS7Protocol{/// <summary>/// 必需的设计器变量。/// </summary>private System.ComponentModel.IContainer components = null;/// <summary>/// 清理所有正在使用的资源。/// </summary>/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>protected override void Dispose(bool disposing){if (disposing && (components != null)){components.Dispose();}base.Dispose(disposing);}#region Windows 窗体设计器生成的代码/// <summary>/// 设计器支持所需的方法 - 不要修改/// 使用代码编辑器修改此方法的内容。/// </summary>private void InitializeComponent(){this.panel1 = new System.Windows.Forms.Panel();this.cboSiemensPLCCategory = new System.Windows.Forms.ComboBox();this.label2 = new System.Windows.Forms.Label();this.btnDisconnect = new System.Windows.Forms.Button();this.btnConnect = new System.Windows.Forms.Button();this.txbPort = new System.Windows.Forms.TextBox();this.label3 = new System.Windows.Forms.Label();this.txbIP = new System.Windows.Forms.TextBox();this.label1 = new System.Windows.Forms.Label();this.rtxbDisplay = new System.Windows.Forms.RichTextBox();this.groupBox1 = new System.Windows.Forms.GroupBox();this.btnReadWString = new System.Windows.Forms.Button();this.label12 = new System.Windows.Forms.Label();this.txtReadValWString = new System.Windows.Forms.TextBox();this.label13 = new System.Windows.Forms.Label();this.txtReadWStringLength = new System.Windows.Forms.TextBox();this.rtxtReadValArray = new System.Windows.Forms.RichTextBox();this.btnReadArray = new System.Windows.Forms.Button();this.label9 = new System.Windows.Forms.Label();this.label8 = new System.Windows.Forms.Label();this.txtReadArrayLength = new System.Windows.Forms.TextBox();this.btnReadString = new System.Windows.Forms.Button();this.label7 = new System.Windows.Forms.Label();this.txtReadValString = new System.Windows.Forms.TextBox();this.label4 = new System.Windows.Forms.Label();this.txtReadStringLength = new System.Windows.Forms.TextBox();this.btnReadBasic = new System.Windows.Forms.Button();this.label5 = new System.Windows.Forms.Label();this.txtReadValBasic = new System.Windows.Forms.TextBox();this.cboReadDataType = new System.Windows.Forms.ComboBox();this.label6 = new System.Windows.Forms.Label();this.label10 = new System.Windows.Forms.Label();this.label11 = new System.Windows.Forms.Label();this.txtOffsetAddress = new System.Windows.Forms.TextBox();this.cboRegisterCategory = new System.Windows.Forms.ComboBox();this.groupBox2 = new System.Windows.Forms.GroupBox();this.btnWriteWString = new System.Windows.Forms.Button();this.label14 = new System.Windows.Forms.Label();this.txtWriteValWString = new System.Windows.Forms.TextBox();this.label15 = new System.Windows.Forms.Label();this.txtWriteWStringLength = new System.Windows.Forms.TextBox();this.rtxtWriteValArray = new System.Windows.Forms.RichTextBox();this.btnWriteArray = new System.Windows.Forms.Button();this.label16 = new System.Windows.Forms.Label();this.btnWriteString = new System.Windows.Forms.Button();this.label18 = new System.Windows.Forms.Label();this.txtWriteValString = new System.Windows.Forms.TextBox();this.label19 = new System.Windows.Forms.Label();this.txtWriteStringLength = new System.Windows.Forms.TextBox();this.btnWriteBasic = new System.Windows.Forms.Button();this.label20 = new System.Windows.Forms.Label();this.txtWriteValBasic = new System.Windows.Forms.TextBox();this.cboWriteDataType = new System.Windows.Forms.ComboBox();this.label21 = new System.Windows.Forms.Label();this.label22 = new System.Windows.Forms.Label();this.txtDbNumber = new System.Windows.Forms.TextBox();this.panel1.SuspendLayout();this.groupBox1.SuspendLayout();this.groupBox2.SuspendLayout();this.SuspendLayout();// // panel1// this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right)));this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.panel1.Controls.Add(this.cboSiemensPLCCategory);this.panel1.Controls.Add(this.label2);this.panel1.Controls.Add(this.btnDisconnect);this.panel1.Controls.Add(this.btnConnect);this.panel1.Controls.Add(this.txbPort);this.panel1.Controls.Add(this.label3);this.panel1.Controls.Add(this.txbIP);this.panel1.Controls.Add(this.label1);this.panel1.Location = new System.Drawing.Point(4, 4);this.panel1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);this.panel1.Name = "panel1";this.panel1.Size = new System.Drawing.Size(611, 87);this.panel1.TabIndex = 2;// // cboSiemensPLCCategory// this.cboSiemensPLCCategory.FormattingEnabled = true;this.cboSiemensPLCCategory.Location = new System.Drawing.Point(122, 52);this.cboSiemensPLCCategory.Name = "cboSiemensPLCCategory";this.cboSiemensPLCCategory.Size = new System.Drawing.Size(206, 20);this.cboSiemensPLCCategory.TabIndex = 14;// // label2// this.label2.AutoSize = true;this.label2.Location = new System.Drawing.Point(8, 52);this.label2.Name = "label2";this.label2.Size = new System.Drawing.Size(95, 12);this.label2.TabIndex = 13;this.label2.Text = "西门子PLC型号:";// // btnDisconnect// this.btnDisconnect.Enabled = false;this.btnDisconnect.Location = new System.Drawing.Point(494, 14);this.btnDisconnect.Name = "btnDisconnect";this.btnDisconnect.Size = new System.Drawing.Size(91, 28);this.btnDisconnect.TabIndex = 5;this.btnDisconnect.Text = "断开连接";this.btnDisconnect.UseVisualStyleBackColor = true;this.btnDisconnect.Click += new System.EventHandler(this.btnDisconnect_Click);// // btnConnect// this.btnConnect.Location = new System.Drawing.Point(371, 14);this.btnConnect.Name = "btnConnect";this.btnConnect.Size = new System.Drawing.Size(91, 28);this.btnConnect.TabIndex = 4;this.btnConnect.Text = "连接";this.btnConnect.UseVisualStyleBackColor = true;this.btnConnect.Click += new System.EventHandler(this.btnConnect_Click);// // txbPort// this.txbPort.Location = new System.Drawing.Point(238, 14);this.txbPort.Name = "txbPort";this.txbPort.Size = new System.Drawing.Size(90, 21);this.txbPort.TabIndex = 3;this.txbPort.Text = "102";// // label3// this.label3.AutoSize = true;this.label3.Location = new System.Drawing.Point(184, 17);this.label3.Name = "label3";this.label3.Size = new System.Drawing.Size(53, 12);this.label3.TabIndex = 2;this.label3.Text = "端口号:";// // txbIP// this.txbIP.Location = new System.Drawing.Point(62, 14);this.txbIP.Name = "txbIP";this.txbIP.Size = new System.Drawing.Size(106, 21);this.txbIP.TabIndex = 1;this.txbIP.Text = "192.168.1.10";// // label1// this.label1.AutoSize = true;this.label1.Location = new System.Drawing.Point(8, 17);this.label1.Name = "label1";this.label1.Size = new System.Drawing.Size(53, 12);this.label1.TabIndex = 0;this.label1.Text = "IP地址:";// // rtxbDisplay// this.rtxbDisplay.Location = new System.Drawing.Point(4, 622);this.rtxbDisplay.Name = "rtxbDisplay";this.rtxbDisplay.ReadOnly = true;this.rtxbDisplay.Size = new System.Drawing.Size(943, 232);this.rtxbDisplay.TabIndex = 3;this.rtxbDisplay.Text = "";// // groupBox1// this.groupBox1.Controls.Add(this.btnReadWString);this.groupBox1.Controls.Add(this.label12);this.groupBox1.Controls.Add(this.txtReadValWString);this.groupBox1.Controls.Add(this.label13);this.groupBox1.Controls.Add(this.txtReadWStringLength);this.groupBox1.Controls.Add(this.rtxtReadValArray);this.groupBox1.Controls.Add(this.btnReadArray);this.groupBox1.Controls.Add(this.label9);this.groupBox1.Controls.Add(this.label8);this.groupBox1.Controls.Add(this.txtReadArrayLength);this.groupBox1

相关文章:

C#使用TCP-S7协议读写西门子PLC(五)-测试程序

上面四篇我们进行封装连接PLC以及读写PLC内存地址表 C#使用TCP-S7协议读写西门子PLC(一)-CSDN博客 C#使用TCP-S7协议读写西门子PLC(二)-CSDN博客 C#使用TCP-S7协议读写西门子PLC(三)-CSDN博客 C#使用TCP-S7协议读写西门子PLC(四)-CSDN博客 这里我们进行测试操作 西门子PLC-…...

经验——IMX6UL的uboot无法ping主机或Ubuntu

主要描述可能的方向&#xff0c;不涉具体过程&#xff0c;详细操作可以查阅网上相关教程 跟随正点原子教程测试以太网端口时&#xff0c;即便按照步骤多次尝试也无法ping通&#xff0c;后补充了些许网络工程基础知识解决了这个问题。 uboot无法ping主机或Ubuntu有多种可能&…...

AUTOSAR-规范文档版本

https://www.autosar.org/standards 2024年11月&#xff08;R24-11&#xff09; Foundation&#xff08;FO) // TODO Classic&#xff08;CP&#xff09; // TODO Adaptive&#xff08;AP&#xff09; // TODO 2023年11月&#xff08;R23-11&#xff09; Foundation&a…...

网络(四)——HTTP协议

文章目录 认识urlurlencode和urldecodeHTTP协议格式HTTP的方法HTTP的状态码HTTP常见Header 虽然应用层的协议是由人为规定的&#xff0c;但是已经有大佬们定义了一些现成的&#xff0c;又非常好用的应用层协议&#xff0c;供我们直接参考使用. HTTP(超文本传输协议)就是其中之一…...

comfyui中报错 Cmd(‘git‘) failed due to: exit code(128) 如何解决

&#x1f388;背景 comfyui今天在安装插件的过程中&#xff0c;发现有个插件第一次安装失败后&#xff0c;再次安装就开始报错了&#xff0c;提示&#xff1a; ComfyUI-Inpaint-CropAndStitch install failed: Bad Request 截图如下&#xff1a; 看下后台的报错&#xff1a; …...

测试-Gatling 与性能测试

Gatling 与性能测试详解 一、什么是性能测试&#xff1f; 性能测试是一种软件测试类型&#xff0c;旨在评估系统在负载下的响应时间、吞吐量和资源利用率等性能指标。通过性能测试&#xff0c;开发者和运维团队能够识别出系统的瓶颈、优化系统性能&#xff0c;并确保其在实际…...

ESRGAN——老旧照片、视频帧的修复和增强,提高图像的分辨率

ESRGAN&#xff08;Enhanced Super-Resolution GAN&#xff09;&#xff1a;用于提高图像的分辨率&#xff0c;将低质量图像升级为高分辨率版本&#xff0c;常用于老旧照片、视频帧的修复和增强。 一、ESRGAN 介绍 1.1 背景 超分辨率问题是计算机视觉中的一个重要研究领域&a…...

跨界融合:EasyDSS+无人机视频直播推流技术助力行业多场景应用

随着科技的飞速发展&#xff0c;无人机技术与流媒体技术的结合正逐步改变着多个行业的运作模式。其中&#xff0c;EasyDSS互联网视频云服务与无人机视频直播推流技术的结合&#xff0c;更是为警务安防、赛事直播、农业监测等多个领域带来了前所未有的变革。本文将深入探讨EasyD…...

Linux实操笔记2 Ubuntu安装Nginx的不同方法

今天来了解Ubuntu或者说Linux系统安装Nginx的几种办法。包括从Ubuntu的库安装到官方源码编译安装。 一、Nginx是什么&#xff1f; 以下是来自Nginx中文文档的内容。 Nginx 是一个高性能的 Web 和反向代理服务器, 它具有有很多非常优越的特性: 作为 Web 服务器&#xff1a;相比…...

QCustomPlot笔记(一)

文章目录 简介将帮助文档添加到Qt Creator中编译共享库cmake工程编译提示ui_mainwindow.h找不到qcustomplot.h文件 环境:windowsQt Creator 10.0.1cmake 简介 QT中用于绘制曲线的第三方工具 下载地址&#xff1a;https://www.qcustomplot.com/index.php/download 第一个压缩…...

【机器学习】多模态AI——融合多种数据源的智能系统

随着人工智能的快速发展&#xff0c;单一模态&#xff08;如文本、图像或语音&#xff09;已经不能满足复杂任务的需求。多模态AI&#xff08;Multimodal AI&#xff09;通过结合多种数据源&#xff08;如文本、图像、音频等&#xff09;来提升模型的智能和表现&#xff0c;适用…...

QT学习与数据库连接

1.基础 1. 安装最后一个非在线版本 5.14, 没有的话联系我 新建一个.cpp文件 #include <QApplication> #include <QLabel> #include <QLineEdit> #include <QPushButton> #include <QHBoxLayout> #include <QVBoxLayout> #include <Q…...

泛读笔记:从Word2Vec到BERT

自然语言处理(NLP)模型的发展历史 1.统计方法时期&#xff1a;使用贝叶斯方法、隐马尔可夫模型、概率模型等传统统计方法 2.机器学习时期&#xff1a;支持向量机(SVM)、决策树模型、随机森林、朴素贝叶斯等传统机器学习方法 3.深度学习革命&#xff1a;各种新的深度学习模型&am…...

redis实现分布式锁详细教程,可续锁(看门狗)、可重入

前言 本文将讨论的做一个高并发场景下避不开的话题&#xff0c;即redis分布式锁。比如在淘宝 的秒杀场景、热点新闻和热搜排行榜等。可见分布式锁是一个程序员面向高级的一门必修课&#xff0c;下面请跟着本篇文章好好学习。 redis分布式锁有哪些面试题 1.Redis做分布式的时…...

代码随想录打卡Day32

今天有点事&#xff0c;先做一题&#xff0c;剩下的明天补。 509. 斐波那契数 这道题目太简单了&#xff0c;递归几行代码就结束了&#xff0c;用动态规划做也可以&#xff0c;主要是学习一下动态规划五部曲。 这是递归的代码 class Solution { public:int fib(int n) {//确…...

数学学习记录

目录 学习资源&#xff1a; 9月14日 1.映射&#xff1a;​编辑 2.函数: 9月15日 3.反函数&#xff1a; 4.收敛数列的性质 5.反三角函数&#xff1a; 9月16日 6.函数的极限&#xff1a; 7.无穷小和无穷大 极限运算法则&#xff1a; 学习资源&#xff1a; 3Blue1…...

R语言统计分析——散点图1(常规图)

参考资料&#xff1a;R语言实战【第2版】 R语言中创建散点图的基础函数是plot(x,y)&#xff0c;其中&#xff0c;x和y是数值型向量&#xff0c;代表着图形中的&#xff08;x,y&#xff09;坐标点。 attach(mtcars) plot(wt,mpg,main"Basic Scatter plot of MPG vs. Weigh…...

蓝桥杯—STM32G431RBT6按键的多方式使用(包含软件消抖方法精讲)从原理层面到实际应用(一)

新建工程教程见http://t.csdnimg.cn/JySLg 点亮LED教程见http://t.csdnimg.cn/Urlj5 末尾含所有代码 目录 按键原理图 一、按键使用需要解决的问题 1.抖动 1.什么是抖动 2.抖动类型 3.如何去消除抖动 FIRST.延时函数消抖&#xff08;缺点&#xff1a;浪费CPU资源&#xff…...

基于STM32的温度、电流、电压检测proteus仿真系统(OLED、DHT11、继电器、电机)

目录 一、主要功能 二、硬件资源 三、程序编程 四、实现现象 一、主要功能 基于STM32F103C8T6 采用DHT11读取温度、滑动变阻器模拟读取电流、电压。 通过OLED屏幕显示&#xff0c;设置电流阈值为80&#xff0c;电流小阈值为50&#xff0c;电压阈值为60&#xff0c;温度阈值…...

Linux - iptables防火墙

目录 一、iptables概述 二、规则表与规则链结构&#xff08;四表五链&#xff09; 1.简述 2.四表&#xff08;规则表&#xff09; 3.五链&#xff08;规则链&#xff09; 三、数据链过滤的匹配流程 四、iptables命令行配置方法 1.命令格式 2.基本匹配条件 3.隐含匹配 …...

使用VSCode开发Django指南

使用VSCode开发Django指南 一、概述 Django 是一个高级 Python 框架&#xff0c;专为快速、安全和可扩展的 Web 开发而设计。Django 包含对 URL 路由、页面模板和数据处理的丰富支持。 本文将创建一个简单的 Django 应用&#xff0c;其中包含三个使用通用基本模板的页面。在此…...

从WWDC看苹果产品发展的规律

WWDC 是苹果公司一年一度面向全球开发者的盛会&#xff0c;其主题演讲展现了苹果在产品设计、技术路线、用户体验和生态系统构建上的核心理念与演进脉络。我们借助 ChatGPT Deep Research 工具&#xff0c;对过去十年 WWDC 主题演讲内容进行了系统化分析&#xff0c;形成了这份…...

现代密码学 | 椭圆曲线密码学—附py代码

Elliptic Curve Cryptography 椭圆曲线密码学&#xff08;ECC&#xff09;是一种基于有限域上椭圆曲线数学特性的公钥加密技术。其核心原理涉及椭圆曲线的代数性质、离散对数问题以及有限域上的运算。 椭圆曲线密码学是多种数字签名算法的基础&#xff0c;例如椭圆曲线数字签…...

Python如何给视频添加音频和字幕

在Python中&#xff0c;给视频添加音频和字幕可以使用电影文件处理库MoviePy和字幕处理库Subtitles。下面将详细介绍如何使用这些库来实现视频的音频和字幕添加&#xff0c;包括必要的代码示例和详细解释。 环境准备 在开始之前&#xff0c;需要安装以下Python库&#xff1a;…...

3403. 从盒子中找出字典序最大的字符串 I

3403. 从盒子中找出字典序最大的字符串 I 题目链接&#xff1a;3403. 从盒子中找出字典序最大的字符串 I 代码如下&#xff1a; class Solution { public:string answerString(string word, int numFriends) {if (numFriends 1) {return word;}string res;for (int i 0;i &…...

学校时钟系统,标准考场时钟系统,AI亮相2025高考,赛思时钟系统为教育公平筑起“精准防线”

2025年#高考 将在近日拉开帷幕&#xff0c;#AI 监考一度冲上热搜。当AI深度融入高考&#xff0c;#时间同步 不再是辅助功能&#xff0c;而是决定AI监考系统成败的“生命线”。 AI亮相2025高考&#xff0c;40种异常行为0.5秒精准识别 2025年高考即将拉开帷幕&#xff0c;江西、…...

HashMap中的put方法执行流程(流程图)

1 put操作整体流程 HashMap 的 put 操作是其最核心的功能之一。在 JDK 1.8 及以后版本中&#xff0c;其主要逻辑封装在 putVal 这个内部方法中。整个过程大致如下&#xff1a; 初始判断与哈希计算&#xff1a; 首先&#xff0c;putVal 方法会检查当前的 table&#xff08;也就…...

C++.OpenGL (20/64)混合(Blending)

混合(Blending) 透明效果核心原理 #mermaid-svg-SWG0UzVfJms7Sm3e {font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}#mermaid-svg-SWG0UzVfJms7Sm3e .error-icon{fill:#552222;}#mermaid-svg-SWG0UzVfJms7Sm3e .error-text{fill…...

三分算法与DeepSeek辅助证明是单峰函数

前置 单峰函数有唯一的最大值&#xff0c;最大值左侧的数值严格单调递增&#xff0c;最大值右侧的数值严格单调递减。 单谷函数有唯一的最小值&#xff0c;最小值左侧的数值严格单调递减&#xff0c;最小值右侧的数值严格单调递增。 三分的本质 三分和二分一样都是通过不断缩…...

Linux安全加固:从攻防视角构建系统免疫

Linux安全加固:从攻防视角构建系统免疫 构建坚不可摧的数字堡垒 引言:攻防对抗的新纪元 在日益复杂的网络威胁环境中,Linux系统安全已从被动防御转向主动免疫。2023年全球网络安全报告显示,高级持续性威胁(APT)攻击同比增长65%,平均入侵停留时间缩短至48小时。本章将从…...