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

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>
http://www.cnnetsun.cn/news/6342.html

相关文章:

  • 掌控信息流:Fluent Reader RSS阅读器完全操作手册
  • 高效文件处理与二维码生成:双平台工具包深度解析
  • 三步锁定央国企高薪铁饭碗
  • FutureCoder:重新定义你的Python学习体验
  • 模块化多电平MMC的虚拟同步发电机控制(VSG)并网仿真模型探究
  • 还在用手动改重降重?6款AI神器含PaperFine一键轻松搞定!
  • aubio音频分析库:从零开始掌握音乐检测技术
  • 17.按键-LED灯联动-状态机
  • PermissionX:彻底简化Android运行时权限管理的终极解决方案
  • 【2025版】最新SQL 三种注入方式详解,零基础入门到精通,收藏这一篇就够了
  • Pearcleaner:智能macOS系统清理工具,彻底释放磁盘空间
  • Spark MLlib 基础统计模块相关性、卡方检验与向量汇总
  • 使用质谱进行De Novo测序
  • 5分钟掌握Ant Design Vue Pro Components:打造企业级Vue3应用的终极方案
  • Nilesoft Shell终极配置手册:从入门到精通
  • Qwen3-VL-4B-Instruct-FP8终极指南:重新定义边缘多模态AI
  • NumCpp终极指南:C++科学计算的完整解决方案
  • 从零开始搭建量子模拟环境,全面解析VSCode+Jupyter协同工作流
  • 用 Python 打造一个图形化局域网扫描器:实战网络设备发现工具
  • Android摄像头调试终极指南:V4L2 Camera APK快速上手
  • 36、Red Hat KVM 虚拟化实战指南
  • 861-LangChain框架Use-Cases - Gemini多模态RAG案例分析报告
  • vnpy可视化技术:5步打造专业级K线图表与交易界面
  • 告别机械感,亲测5款AI小说写作工具!让创作更对味
  • 1.3万亿令牌教育数据集登场:FineWeb-Edu如何重塑AI学习能力?
  • 河道水位如何实时掌握?1套监测站的故事,防汛抗旱有了“千里眼”。
  • 从微信群到智能社区:KoalaQA如何重塑企业售后服务新生态
  • 免费获取自动控制原理第3版PDF教材,开启自动化学习之旅
  • 专科女生学云计算前景好吗?怎么样?好就业吗?有前途吗?
  • Responder网络工具配置优化与故障排除实战指南