如何使用.net从labview生成的文件中读取簇数据

发布于 2024-10-01 11:49:46 字数 128 浏览 0 评论 0原文

我正在尝试读取存储在使用 LabVIEW 生成的自定义二进制文件中的数据。数据文件是通过写入簇数组来创建的。我想使用 .net 编写的程序从此数据文件中读取集群信息。有没有一种简单的方法可以在不修改labview生成的文件的情况下做到这一点?

I am trying to read in data stored in a custom binary file generated using LabVIEW. The data file is created by writing an array of clusters. I want to read in the cluster information from this data file using a program written in .net. Is there an easy way to do this without modifying the labview generated file?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

生寂 2024-10-08 11:49:46

这有点取决于你对“简单”的定义。

如果您使用标准 LV 函数,则直接写入的二进制文件将以与 LV 存储相同的方式存储 内存中的数据。因此,前 4 个字节存储数组中元素的数量。剩下的就是实际数据:簇。每个簇都由其成员组成,每个成员都有上面链接中指定的字节大小。如果你有数组簇的数组,这可能会有点迟钝……无论如何,一旦你弄清楚了写入的数据的类型和大小,你就已经成功了一半。

接下来,您几乎可以使用 .NET BinaryReader。然而,LV 是 Mac 的后代,因此,它是大端 。 BinaryReader 不这样做。

幸运的是,乔恩·斯基特做到了。检查他的 MiscUtil 库中是否有可以正确读取数据的 EndianBinaryReader。

This depends a bit on your definition of "easy".

If you're using the standard LV functions, a directly written binary file is stored in the same fashion as LV stores data in memory. So, the first 4 bytes store the number of elements in the array. The remainder is the actual data: clusters. Each cluster is composed of its members, each of which has a byte size as specified in the link above. This can get a little obtuse if you have clusters of arrays of clusters of arrays of... anyway, once you figure out the types and sizes of the data that was written, you're halfway there.

Next, you can almost read the file in using a .NET BinaryReader. However, LV was descended from the Mac, and, as such, it's big endian. BinaryReader doesn't do that.

Fortunately, Jon Skeet does. Check his MiscUtil library for an EndianBinaryReader that can read the data in correctly.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文