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
主要描述可能的方向,不涉具体过程,详细操作可以查阅网上相关教程 跟随正点原子教程测试以太网端口时,即便按照步骤多次尝试也无法ping通,后补充了些许网络工程基础知识解决了这个问题。 uboot无法ping主机或Ubuntu有多种可能&…...
AUTOSAR-规范文档版本
https://www.autosar.org/standards 2024年11月(R24-11) Foundation(FO) // TODO Classic(CP) // TODO Adaptive(AP) // TODO 2023年11月(R23-11) Foundation&a…...
网络(四)——HTTP协议
文章目录 认识urlurlencode和urldecodeHTTP协议格式HTTP的方法HTTP的状态码HTTP常见Header 虽然应用层的协议是由人为规定的,但是已经有大佬们定义了一些现成的,又非常好用的应用层协议,供我们直接参考使用. HTTP(超文本传输协议)就是其中之一…...
comfyui中报错 Cmd(‘git‘) failed due to: exit code(128) 如何解决
🎈背景 comfyui今天在安装插件的过程中,发现有个插件第一次安装失败后,再次安装就开始报错了,提示: ComfyUI-Inpaint-CropAndStitch install failed: Bad Request 截图如下: 看下后台的报错: …...
测试-Gatling 与性能测试
Gatling 与性能测试详解 一、什么是性能测试? 性能测试是一种软件测试类型,旨在评估系统在负载下的响应时间、吞吐量和资源利用率等性能指标。通过性能测试,开发者和运维团队能够识别出系统的瓶颈、优化系统性能,并确保其在实际…...
ESRGAN——老旧照片、视频帧的修复和增强,提高图像的分辨率
ESRGAN(Enhanced Super-Resolution GAN):用于提高图像的分辨率,将低质量图像升级为高分辨率版本,常用于老旧照片、视频帧的修复和增强。 一、ESRGAN 介绍 1.1 背景 超分辨率问题是计算机视觉中的一个重要研究领域&a…...
跨界融合:EasyDSS+无人机视频直播推流技术助力行业多场景应用
随着科技的飞速发展,无人机技术与流媒体技术的结合正逐步改变着多个行业的运作模式。其中,EasyDSS互联网视频云服务与无人机视频直播推流技术的结合,更是为警务安防、赛事直播、农业监测等多个领域带来了前所未有的变革。本文将深入探讨EasyD…...
Linux实操笔记2 Ubuntu安装Nginx的不同方法
今天来了解Ubuntu或者说Linux系统安装Nginx的几种办法。包括从Ubuntu的库安装到官方源码编译安装。 一、Nginx是什么? 以下是来自Nginx中文文档的内容。 Nginx 是一个高性能的 Web 和反向代理服务器, 它具有有很多非常优越的特性: 作为 Web 服务器:相比…...
QCustomPlot笔记(一)
文章目录 简介将帮助文档添加到Qt Creator中编译共享库cmake工程编译提示ui_mainwindow.h找不到qcustomplot.h文件 环境:windowsQt Creator 10.0.1cmake 简介 QT中用于绘制曲线的第三方工具 下载地址:https://www.qcustomplot.com/index.php/download 第一个压缩…...
【机器学习】多模态AI——融合多种数据源的智能系统
随着人工智能的快速发展,单一模态(如文本、图像或语音)已经不能满足复杂任务的需求。多模态AI(Multimodal AI)通过结合多种数据源(如文本、图像、音频等)来提升模型的智能和表现,适用…...
QT学习与数据库连接
1.基础 1. 安装最后一个非在线版本 5.14, 没有的话联系我 新建一个.cpp文件 #include <QApplication> #include <QLabel> #include <QLineEdit> #include <QPushButton> #include <QHBoxLayout> #include <QVBoxLayout> #include <Q…...
泛读笔记:从Word2Vec到BERT
自然语言处理(NLP)模型的发展历史 1.统计方法时期:使用贝叶斯方法、隐马尔可夫模型、概率模型等传统统计方法 2.机器学习时期:支持向量机(SVM)、决策树模型、随机森林、朴素贝叶斯等传统机器学习方法 3.深度学习革命:各种新的深度学习模型&am…...
redis实现分布式锁详细教程,可续锁(看门狗)、可重入
前言 本文将讨论的做一个高并发场景下避不开的话题,即redis分布式锁。比如在淘宝 的秒杀场景、热点新闻和热搜排行榜等。可见分布式锁是一个程序员面向高级的一门必修课,下面请跟着本篇文章好好学习。 redis分布式锁有哪些面试题 1.Redis做分布式的时…...
代码随想录打卡Day32
今天有点事,先做一题,剩下的明天补。 509. 斐波那契数 这道题目太简单了,递归几行代码就结束了,用动态规划做也可以,主要是学习一下动态规划五部曲。 这是递归的代码 class Solution { public:int fib(int n) {//确…...
数学学习记录
目录 学习资源: 9月14日 1.映射:编辑 2.函数: 9月15日 3.反函数: 4.收敛数列的性质 5.反三角函数: 9月16日 6.函数的极限: 7.无穷小和无穷大 极限运算法则: 学习资源: 3Blue1…...
R语言统计分析——散点图1(常规图)
参考资料:R语言实战【第2版】 R语言中创建散点图的基础函数是plot(x,y),其中,x和y是数值型向量,代表着图形中的(x,y)坐标点。 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.延时函数消抖(缺点:浪费CPU资源ÿ…...
基于STM32的温度、电流、电压检测proteus仿真系统(OLED、DHT11、继电器、电机)
目录 一、主要功能 二、硬件资源 三、程序编程 四、实现现象 一、主要功能 基于STM32F103C8T6 采用DHT11读取温度、滑动变阻器模拟读取电流、电压。 通过OLED屏幕显示,设置电流阈值为80,电流小阈值为50,电压阈值为60,温度阈值…...
Linux - iptables防火墙
目录 一、iptables概述 二、规则表与规则链结构(四表五链) 1.简述 2.四表(规则表) 3.五链(规则链) 三、数据链过滤的匹配流程 四、iptables命令行配置方法 1.命令格式 2.基本匹配条件 3.隐含匹配 …...
智慧工地云平台源码,基于微服务架构+Java+Spring Cloud +UniApp +MySql
智慧工地管理云平台系统,智慧工地全套源码,java版智慧工地源码,支持PC端、大屏端、移动端。 智慧工地聚焦建筑行业的市场需求,提供“平台网络终端”的整体解决方案,提供劳务管理、视频管理、智能监测、绿色施工、安全管…...
遍历 Map 类型集合的方法汇总
1 方法一 先用方法 keySet() 获取集合中的所有键。再通过 gey(key) 方法用对应键获取值 import java.util.HashMap; import java.util.Set;public class Test {public static void main(String[] args) {HashMap hashMap new HashMap();hashMap.put("语文",99);has…...
将对透视变换后的图像使用Otsu进行阈值化,来分离黑色和白色像素。这句话中的Otsu是什么意思?
Otsu 是一种自动阈值化方法,用于将图像分割为前景和背景。它通过最小化图像的类内方差或等价地最大化类间方差来选择最佳阈值。这种方法特别适用于图像的二值化处理,能够自动确定一个阈值,将图像中的像素分为黑色和白色两类。 Otsu 方法的原…...
学习STC51单片机31(芯片为STC89C52RCRC)OLED显示屏1
每日一言 生活的美好,总是藏在那些你咬牙坚持的日子里。 硬件:OLED 以后要用到OLED的时候找到这个文件 OLED的设备地址 SSD1306"SSD" 是品牌缩写,"1306" 是产品编号。 驱动 OLED 屏幕的 IIC 总线数据传输格式 示意图 …...
04-初识css
一、css样式引入 1.1.内部样式 <div style"width: 100px;"></div>1.2.外部样式 1.2.1.外部样式1 <style>.aa {width: 100px;} </style> <div class"aa"></div>1.2.2.外部样式2 <!-- rel内表面引入的是style样…...
WEB3全栈开发——面试专业技能点P2智能合约开发(Solidity)
一、Solidity合约开发 下面是 Solidity 合约开发 的概念、代码示例及讲解,适合用作学习或写简历项目背景说明。 🧠 一、概念简介:Solidity 合约开发 Solidity 是一种专门为 以太坊(Ethereum)平台编写智能合约的高级编…...
OpenPrompt 和直接对提示词的嵌入向量进行训练有什么区别
OpenPrompt 和直接对提示词的嵌入向量进行训练有什么区别 直接训练提示词嵌入向量的核心区别 您提到的代码: prompt_embedding = initial_embedding.clone().requires_grad_(True) optimizer = torch.optim.Adam([prompt_embedding...
智能仓储的未来:自动化、AI与数据分析如何重塑物流中心
当仓库学会“思考”,物流的终极形态正在诞生 想象这样的场景: 凌晨3点,某物流中心灯火通明却空无一人。AGV机器人集群根据实时订单动态规划路径;AI视觉系统在0.1秒内扫描包裹信息;数字孪生平台正模拟次日峰值流量压力…...
AI书签管理工具开发全记录(十九):嵌入资源处理
1.前言 📝 在上一篇文章中,我们完成了书签的导入导出功能。本篇文章我们研究如何处理嵌入资源,方便后续将资源打包到一个可执行文件中。 2.embed介绍 🎯 Go 1.16 引入了革命性的 embed 包,彻底改变了静态资源管理的…...
Python常用模块:time、os、shutil与flask初探
一、Flask初探 & PyCharm终端配置 目的: 快速搭建小型Web服务器以提供数据。 工具: 第三方Web框架 Flask (需 pip install flask 安装)。 安装 Flask: 建议: 使用 PyCharm 内置的 Terminal (模拟命令行) 进行安装,避免频繁切换。 PyCharm Terminal 配置建议: 打开 Py…...
