news 2026/1/10 5:25:19

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/1/9 0:23:46

5个技巧让你的网页播放器实现专业级录像回放功能

5个技巧让你的网页播放器实现专业级录像回放功能 【免费下载链接】jessibuca Jessibuca是一款开源的纯H5直播流播放器 项目地址: https://gitcode.com/GitHub_Trending/je/jessibuca 你是否曾经在使用网页播放器时遇到过这些问题&#xff1a;时间轴拖动不精确、倍速播放…

作者头像 李华
网站建设 2025/12/28 6:08:40

终极HTML5音效生成器指南:用jsfxr让游戏开发音效制作零门槛

还在为游戏音效制作发愁吗&#xff1f;jsfxr这款基于HTML5的开源音效生成器将彻底改变你的创作体验。无需专业音频知识&#xff0c;无需昂贵软件&#xff0c;在浏览器中就能轻松制作出专业级的游戏音效&#xff0c;让独立游戏开发者的音效制作变得前所未有的简单高效。 【免费下…

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

IDM激活脚本深度解析:技术原理与实战指南

IDM激活脚本深度解析&#xff1a;技术原理与实战指南 【免费下载链接】IDM-Activation-Script IDM Activation & Trail Reset Script 项目地址: https://gitcode.com/gh_mirrors/id/IDM-Activation-Script Internet Download Manager&#xff08;IDM&#xff09;作为…

作者头像 李华
网站建设 2025/12/19 7:05:08

UI自动化巡检终极指南:5分钟快速上手指南

UI自动化巡检终极指南&#xff1a;5分钟快速上手指南 【免费下载链接】online-inspection-tracker 线上UI自动化巡检系统 项目地址: https://gitcode.com/gh_mirrors/on/online-inspection-tracker 还在为线上Web应用频繁出现的UI异常而烦恼吗&#xff1f;&#x1f629;…

作者头像 李华
网站建设 2026/1/8 10:10:53

Python MySQL从零上手:30分钟搞定pymysql基本CRUD操作

Python MySQL从零上手&#xff1a;30分钟搞定pymysql基本CRUD操作 文章目录Python MySQL从零上手&#xff1a;30分钟搞定pymysql基本CRUD操作一、环境准备&#xff1a;搭建你的第一个PythonMySQL开发环境1.1 为什么需要pymysql&#xff1f;1.2 一步步搭建环境二、核心概念&…

作者头像 李华
网站建设 2025/12/11 18:01:11

Intel RealSense深度相机性能优化7大策略

Intel RealSense深度相机性能优化7大策略 【免费下载链接】librealsense Intel RealSense™ SDK 项目地址: https://gitcode.com/GitHub_Trending/li/librealsense Intel RealSense™深度相机技术在现代计算机视觉应用中扮演着关键角色。本文针对开发者在实际部署中遇到…

作者头像 李华