news 2025/12/25 11:46:08

Linux上位机松下PLC NewTocol通信实例,源码。国产系统麒麟上位机与PLC通信实战实例,快速上手国产化系统的统信UOS上位机 硬核国产化 自主可控上位机 Deepin+Qt

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
Linux上位机松下PLC NewTocol通信实例,源码。国产系统麒麟上位机与PLC通信实战实例,快速上手国产化系统的统信UOS上位机 硬核国产化 自主可控上位机 Deepin+Qt

在国产化浪潮下,Deepin系统作为国产操作系统标杆,为工业控制领域提供了稳定可靠的部署平台。本文以Qt C++框架开发松下PLC上位机通信为例,阐述国产化适配实践。

核心实现:通过Qt网络模块建立TCP连接,严格遵循NewTocol协议规范构建报文帧。关键步骤包括握手认证(发送NewTocol命令码0x00000000)、内存地址解析及数据封装。需特别注意字节序转换(Big-Endian)和超时重传机制,确保工业级通信稳定性。

国产化亮点:Deepin对Qt5/6的完美兼容,使跨平台编译零成本;其内核级实时性优化,显著降低通信抖动。实测在鲲鹏CPU架构下,数据刷新周期稳定在10ms以内,满足严苛的产线节拍要求。

开发建议:封装NewTocol协议库为独立模块,利用Qt信号槽机制实现异步通信,避免界面卡顿。通过qmake条件编译适配不同国产平台,一套代码即可覆盖龙芯、飞腾等架构,助力工业软件自主可控。

完整代码下载https://8ma.co/res/ANJT6EAP

<?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> <class>MitsubishiPlc</class> <widget class="QWidget" name="MitsubishiPlc"> <property name="geometry"> <rect> <x>0</x> <y>0</y> <width>1030</width> <height>646</height> </rect> </property> <property name="windowTitle"> <string>QT(C++)与松下NewTocol协议通信</string> </property> <layout class="QGridLayout" name="gridLayout"> <item row="0" column="0"> <layout class="QVBoxLayout" name="verticalLayout" stretch="6,4"> <item> <layout class="QVBoxLayout" name="verticalLayout_2"> <item> <widget class="QWidget" name="widget" native="true"> <property name="sizePolicy"> <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> <property name="minimumSize"> <size> <width>0</width> <height>340</height> </size> </property> <widget class="QLineEdit" name="lineEdit_2"> <property name="geometry"> <rect> <x>580</x> <y>70</y> <width>81</width> <height>31</height> </rect> </property> <property name="text"> <string>2000</string> </property> </widget> <widget class="QLabel" name="label_4"> <property name="geometry"> <rect> <x>60</x> <y>150</y> <width>61</width> <height>16</height> </rect> </property> <property name="text"> <string>读地址:</string> </property> </widget> <widget class="QPushButton" name="bt_open"> <property name="geometry"> <rect> <x>680</x> <y>60</y> <width>91</width> <height>41</height> </rect> </property> <property name="text"> <string>连接</string> </property> <property name="type" stdset="0"> <string>primary</string> </property> </widget> <widget class="QLineEdit" name="lineEdit"> <property name="geometry"> <rect> <x>290</x> <y>70</y> <width>211</width> <height>31</height> </rect> </property> <property name="text"> <string>127.0.0.1</string> </property> </widget> <widget class="QLineEdit" name="lineEdit_4"> <property name="geometry"> <rect> <x>350</x> <y>140</y> <width>81</width> <height>31</height> </rect> </property> <property name="text"> <string>1</string> </property> </widget> <widget class="QLabel" name="label_2"> <property name="geometry"> <rect> <x>520</x> <y>80</y> <width>51</width> <height>16</height> </rect> </property> <property name="text"> <string>端口:</string> </property> </widget> <widget class="QLabel" name="label_5"> <property name="geometry"> <rect> <x>280</x> <y>150</y> <width>61</width> <height>16</height> </rect> </property> <property name="text"> <string>读数量:</string> </property> </widget> <widget class="QPushButton" name="bt_close"> <property name="geometry"> <rect> <x>800</x> <y>60</y> <width>91</width> <height>41</height> </rect> </property> <property name="text"> <string>断开</string> </property> <property name="type" stdset="0"> <string>danger</string> </property> </widget> <widget class="QLabel" name="label_3"> <property name="geometry"> <rect> <x>150</x> <y>10</y> <width>401</width> <height>31</height> </rect> </property> <property name="text"> <string>QT(C++)与松下NewTocol协议通信</string> </property> <property name="type" stdset="0"> <string>h3</string> </property> </widget> <widget class="QLabel" name="label"> <property name="geometry"> <rect> <x>220</x> <y>80</y> <width>61</width> <height>16</height> </rect> </property> <property name="text"> <string>IP地址:</string> </property> </widget> <widget class="QPushButton" name="bt_write"> <property name="geometry"> <rect> <x>620</x> <y>240</y> <width>130</width> <height>40</height> </rect> </property> <property name="text"> <string>写入short</string> </property> <property name="type" stdset="0"> <string>warning</string> </property> </widget> <widget class="QPushButton" name="bt_read"> <property name="geometry"> <rect> <x>120</x> <y>240</y> <width>130</width> <height>40</height> </rect> </property> <property name="text"> <string>short读取</string> </property> </widget> <widget class="QLineEdit" name="lineEdit_3"> <property name="geometry"> <rect> <x>130</x> <y>140</y> <width>121</width> <height>31</height> </rect> </property> <property name="text"> <string>D100</string> </property> </widget> <widget class="QLabel" name="label_6"> <property name="geometry"> <rect> <x>130</x> <y>110</y> <width>751</width> <height>21</height> </rect> </property> <property name="text"> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;位地址支持&lt;span style=&quot; color:#008000;&quot;&gt;Y、R、L&lt;/span&gt;,字地址支持&lt;span style=&quot; color:#008000;&quot;&gt;D、R、L&lt;/span&gt;,位的读取如R10,字的读写如D100&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> </property> </widget> <widget class="QPushButton" name="bt_readBool"> <property name="geometry"> <rect> <x>120</x> <y>190</y> <width>130</width> <height>40</height> </rect> </property> <property name="text"> <string>bool读取</string> </property> </widget> <widget class="QPushButton" name="bt_readInt"> <property name="geometry"> <rect> <x>120</x> <y>290</y> <width>130</width> <height>40</height> </rect> </property> <property name="text"> <string>int读取</string> </property> </widget> <widget class="QLabel" name="label_10"> <property name="geometry"> <rect> <x>550</x> <y>150</y> <width>61</width> <height>16</height> </rect> </property> <property name="text"> <string>写地址:</string> </property> </widget> <widget class="QLabel" name="label_11"> <property name="geometry"> <rect> <x>750</x> <y>150</y> <width>41</width> <height>16</height> </rect> </property> <property name="text"> <string>写值:</string> </property> </widget> <widget class="QLineEdit" name="lineEdit_5"> <property name="geometry"> <rect> <x>810</x> <y>140</y> <width>81</width> <height>31</height> </rect> </property> <property name="text"> <string>1</string> </property> </widget> <widget class="QLineEdit" name="lineEdit_6"> <property name="geometry"> <rect> <x>610</x> <y>140</y> <width>121</width> <height>31</height> </rect> </property> <property name="text"> <string>D100</string> </property> </widget> <widget class="QPushButton" name="bt_write_2"> <property name="geometry"> <rect> <x>620</x> <y>190</y> <width>130</width> <height>40</height> </rect> </property> <property name="text"> <string>写入bool</string> </property> <property name="type" stdset="0"> <string>warning</string> </property> </widget> <widget class="QPushButton" name="bt_write_3"> <property name="geometry"> <rect> <x>620</x> <y>290</y> <width>130</width> <height>40</height> </rect> </property> <property name="text"> <string>写入Int</string> </property> <property name="type" stdset="0"> <string>warning</string> </property> </widget> <widget class="QPushButton" name="pushButton_35"> <property name="geometry"> <rect> <x>870</x> <y>10</y> <width>121</width> <height>41</height> </rect> </property> <property name="text"> <string>源码下载</string> </property> <property name="type" stdset="0"> <string>primary</string> </property> </widget> <widget class="QLineEdit" name="worker"> <property name="geometry"> <rect> <x>130</x> <y>70</y> <width>81</width> <height>31</height> </rect> </property> <property name="text"> <string>1</string> </property> </widget> <widget class="QLabel" name="label_7"> <property name="geometry"> <rect> <x>70</x> <y>80</y> <width>51</width> <height>16</height> </rect> </property> <property name="text"> <string>站号:</string> </property> </widget> </widget> </item> </layout> </item> <item> <widget class="QListWidget" name="listWidget"/> </item> </layout> </item> </layout> </widget> <layoutdefault spacing="6" margin="11"/> <resources/> <connections/> </ui>
版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2025/12/13 16:16:35

5个关键步骤彻底解决Super Productivity在Ubuntu 24.10启动失败问题

5个关键步骤彻底解决Super Productivity在Ubuntu 24.10启动失败问题 【免费下载链接】super-productivity Super Productivity is an advanced todo list app with integrated Timeboxing and time tracking capabilities. It also comes with integrations for Jira, Gitlab, …

作者头像 李华
网站建设 2025/12/23 14:56:20

15分钟搭建VMware许可证验证API服务

快速体验 打开 InsCode(快马)平台 https://www.inscode.net输入框内输入如下内容&#xff1a; 开发一个RESTful API服务用于验证VMware16密钥有效性&#xff0c;要求&#xff1a;1. 接收密钥参数 2. 返回验证结果和类型 3. 缓存机制 4. 限流防护 5. Swagger文档。使用FastAPI框…

作者头像 李华
网站建设 2025/12/21 23:16:44

ComfyUI实战:3步构建电商后台管理系统

快速体验 打开 InsCode(快马)平台 https://www.inscode.net输入框内输入如下内容&#xff1a; 开发一个电商后台管理系统原型&#xff0c;包含以下功能模块&#xff1a;1. 用户管理&#xff08;列表、添加、编辑、删除&#xff09;&#xff1b;2. 商品管理&#xff08;分类、上…

作者头像 李华
网站建设 2025/12/22 15:53:19

Wan2.2-T2V-5B在影视前期分镜测试中的高效应用

Wan2.2-T2V-5B在影视前期分镜测试中的高效应用 &#x1f3ac; 想象一下&#xff1a;导演坐在剪辑室里&#xff0c;刚说完一句“雨夜的霓虹小巷&#xff0c;机器人缓缓走来”&#xff0c;3秒后屏幕上就跳出一段动态画面——镜头低角度推进&#xff0c;水洼倒映着蓝紫色灯光&…

作者头像 李华
网站建设 2025/12/11 17:59:31

约束优化求解器技术深度解析与实践指南

约束优化求解器技术深度解析与实践指南 【免费下载链接】awesome-java A curated list of awesome frameworks, libraries and software for the Java programming language. 项目地址: https://gitcode.com/GitHub_Trending/aw/awesome-java 引言 在现代企业运营中&am…

作者头像 李华
网站建设 2025/12/21 10:54:20

AI工程实战指南:三步解决传统ML系统迁移的避坑策略

AI工程实战指南&#xff1a;三步解决传统ML系统迁移的避坑策略 【免费下载链接】aie-book [WIP] Resources for AI engineers. Also contains supporting materials for the book AI Engineering (Chip Huyen, 2025) 项目地址: https://gitcode.com/GitHub_Trending/ai/aie-b…

作者头像 李华