MATLAB-GUI和OPC服务器 [英] MATLAB - GUI and OPC server

查看:84
本文介绍了MATLAB-GUI和OPC服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在MATLAB中设计一个图形用户界面,该界面可以使用MATLAB的对象链接和嵌入过程控制(OPC)工具箱连续读取数据.我该如何实施?

I want to design a graphical user interface in MATLAB that can read data continuously using the MATLAB's object linking and embedding for process control (OPC) toolbox. How can I implement this?

我已经设计了图形用户界面,但是无法将数据读取到图形用户界面中.

I have designed the graphical user interface, but I'm not able to read the data into the graphical user interface.

推荐答案

做到这一点

键入 opctool

  • 点击创建新主机

  • click create new host

选择本地主机

  • 点击添加客户端

  • 点击添加组并添加项目

  • 现在您可以看到要调用的变量的实际名称像 SimControl.Run,​​SimControl.Stop ,..etc

现在你必须在 MATLAB 中像这样编码

Now you have to code it like this in MATLAB

         %====================================VARIABLE VALUE===============================
         volume_val=app.VolumeVEditField.Value;
         area_val=app.AreaAEditField.Value;



         %====================================CONNECTION====================================
         global hostInfo ;
         hostInfo = opcserverinfo('localhost');
         global da;
         da = opcda('localhost','Dymosim.OPCServer.1');
         connect(da);
         pause(2);


         %====================================INITIAL VARIABLE=============================
         grp=addgroup(da,'Demo');
         grp2=addgroup(da,'Demo2');
         Initialize=additem(grp2,{'SimControl.Initialize'});
         Run=additem(grp2,{'SimControl.Run'});
         Status=additem(grp2,{'SimControl.Status'});
         Stop=additem(grp2,{'SimControl.Stop'});
         Pause=additem(grp2,{'SimControl.Pause'});
         %=================================================================================
         write(Initialize,1);

         %you can use write(area,area_val) 

  • 然后您可以使用 deploytool 创建应用

    这篇关于MATLAB-GUI和OPC服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆