简体   繁体   English

如何编辑和接收来自cRIO的数据?

[英]How to edit and receive data from cRIO?

At my lab I have a testbed that uses cRIO. 在我的实验室,我有一个使用cRIO的测试平台。 There are 3 cRIOs connected to multiple sensors. 有3个cRIO连接到多个传感器。 My aim is to manipulate sensor data and see how it affects other processes. 我的目标是操纵传感器数据并查看它如何影响其他过程。 The company that installed the testbed wrote a very complex LabView program. 安装测试平台的公司编写了一个非常复杂的LabView程序。

I am new to LabView. 我是LabView的新手。 I have seen a few answers about making web-services. 我已经看到了一些关于制作网络服务的答案。 Will this be useful to edit the data? 这对编辑数据有用吗? The engineer says that the data is continuously injected in a loop, so my program would also have to run in a similar manner or to disable the other loop completely. 工程师说数据是在循环中连续注入的,所以我的程序也必须以类似的方式运行或完全禁用另一个循环。 If yes how do I go about creating web services for such a massive project? 如果是,我该如何为这样一个庞大的项目创建Web服务?

Is there an easier way to achieve my goal. 有没有更简单的方法来实现我的目标。 A man in the middle between the controller and remote(?) IO? 控制器和远程(?)IO之间的中间人? What protocol runs there? 那里有什么协议? Do you recommend any Python libraries for this? 你推荐任何Python库吗?

Since your existing application has a 'simulation mode' in which the data you want to change can be set manually using controls on the LabVIEW front panel, you can manipulate these controls programatically from another LabVIEW VI using control references. 由于您现有的应用程序具有“模拟模式”,您可以使用LabVIEW前面板上的控件手动设置要更改的数据,您可以使用控件参考从另一个LabVIEW VI以编程方式操作这些控件。 The following LabVIEW snippet sets the value of the control with index 0 in the target VI to the specified value: 以下LabVIEW代码段将目标VI中索引为0的控件的值设置为指定值:

控制参考演示 -  LabVIEW 2014 VI片段

We open a reference to the target VI then use property nodes (from the Application Control palette) to return references to that VI's front panel, to all the controls on that panel (as an array), and finally to write to the Value (Signaling) property of the selected control. 我们打开对目标VI的引用,然后使用属性节点(来自Application Control面板)将对VI前面板的引用返回到该面板上的所有控件(作为数组),最后写入Value (Signaling)所选控件的属性。 To make repeated changes you only need to repeat that last property write. 要进行重复更改,您只需要重复最后一次属性写入。 Just close the reference when you're finished. 完成后只需关闭参考。

To find out which control has which index, read the Label.Text property for each control reference in the array, giving you the text of its block diagram label - not necessarily the same as its caption on the front panel. 要找出哪个控件具有哪个索引,请读取数组中每个控件引用的Label.Text属性,为其提供其程序框图标签的文本 - 不一定与前面板上的标题相同。

If you prefer to do the automation in Python you should be able to use the method described in this post , using the pywin32 module: 如果你喜欢做在Python自动化,你应该能够使用所描述的方法这个帖子 ,使用pywin32模块:

import win32com.client
labview = win32com.client.Dispatch("Labview.Application")
VI = labview.getvireference(r'C:\path\to\target.vi')
VI.setcontrolvalue('Numeric','5')

This sets the value of the control with label Numeric to 5. However the above code will not work if the target VI uses LabVIEW events to respond to control value changes, rather than polling the control values, because it sets the control's Value but not its Value (Signaling) property. 这将控件的值设置为标签Numeric为5. 但是 ,如果目标VI使用LabVIEW事件响应控制值更改而不是轮询控件值,则上述代码将不起作用,因为它设置控件的Value但不设置Value (Signaling)财产。 Unfortunately the answer from rolfk to my question on the NI forum suggests there isn't a way of doing the latter - you would need to write an intermediate LabVIEW layer and send the data from Python to that somehow. 不幸的是,rolfk对我在NI论坛上提出的问题的回答表明,没有办法做后者 - 你需要编写一个中间的LabVIEW层,并以某种方式从Python发送数据。 That could use the COM interface to drive the LabVIEW code in the first example above, if you poll value to set (etc) in a loop. 如果您在循环中轮询value to set (等),那么可以使用COM接口来驱动上面第一个示例中的LabVIEW代码。

If you want to go beyond this it should be possible to either modify the existing LabVIEW application so you can inject the data you want, or, if you prefer, to replace it completely and handle the sending and receiving of data to/from the cRIOs yourself; 如果你想超越这个,应该可以修改现有的LabVIEW应用程序,这样你就可以注入你想要的数据,或者,如果你愿意,可以完全替换它并处理向/从cRIO发送和接收数据自己; but that would be too broad a question to answer without more detail of how the system has been implemented. 但如果没有关于系统如何实施的更多细节,这将是一个过于宽泛的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM