news 2026/5/24 23:24:25

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进行投诉反馈,一经查实,立即删除!
网站建设 2026/5/22 9:59:36

Wan2.2-T2V-5B模型支持灰度发布与AB测试

Wan2.2-T2V-5B&#xff1a;轻量视频生成的实战利器&#xff0c;如何用灰度发布玩转A/B测试&#xff1f;&#x1f680; 你有没有遇到过这种情况——团队急着上线一个“惊艳”的AI视频生成功能&#xff0c;结果一上线&#xff0c;用户反馈炸了锅&#xff1a;“画面抽搐”、“猫变…

作者头像 李华
网站建设 2026/5/21 11:38:32

Slate:跨平台像素画编辑器,让创意像素化绽放 ✨

Slate&#xff1a;跨平台像素画编辑器&#xff0c;让创意像素化绽放 ✨ 【免费下载链接】slate Pixel Art Editor 项目地址: https://gitcode.com/gh_mirrors/slate3/slate 还在为寻找合适的像素画编辑器而烦恼吗&#xff1f;想要一款能在Linux、Windows和Mac上都能流畅…

作者头像 李华
网站建设 2026/5/24 16:25:53

PictureSelector:Android图片选择器的终极解决方案

PictureSelector&#xff1a;Android图片选择器的终极解决方案 【免费下载链接】PictureSelector Picture Selector Library for Android or 图片选择器 项目地址: https://gitcode.com/gh_mirrors/pict/PictureSelector 在移动应用开发中&#xff0c;媒体文件的选择和管…

作者头像 李华
网站建设 2026/5/21 18:30:12

洛雪音乐音源完整配置教程:新手3分钟快速上手指南

洛雪音乐音源完整配置教程&#xff1a;新手3分钟快速上手指南 【免费下载链接】lxmusic- lxmusic(洛雪音乐)全网最新最全音源 项目地址: https://gitcode.com/gh_mirrors/lx/lxmusic- 洛雪音乐音源作为洛雪音乐播放器的核心扩展组件&#xff0c;专为聚合全网最新最全的音…

作者头像 李华
网站建设 2026/5/22 19:52:26

Hoverboard固件终极指南:FOC磁场定向控制完全解析

Hoverboard固件终极指南&#xff1a;FOC磁场定向控制完全解析 【免费下载链接】hoverboard-firmware-hack-FOC 项目地址: https://gitcode.com/gh_mirrors/hov/hoverboard-firmware-hack-FOC 想要让你的平衡车性能更上一层楼吗&#xff1f;Hoverboard Firmware Hack FO…

作者头像 李华
网站建设 2026/5/21 18:48:38

4步解锁电脑操控Android手机:escrcpy无线投屏终极指南

4步解锁电脑操控Android手机&#xff1a;escrcpy无线投屏终极指南 【免费下载链接】escrcpy 优雅而强大的跨平台 Android 设备控制工具&#xff0c;基于 Scrcpy 的 Electron 应用,支持无线连接和多设备管理,让您的电脑成为 Android 的完美伴侣。 项目地址: https://gitcode.c…

作者头像 李华