简体   繁体   English

在 WPF 桌面应用程序中实现多个硬件接口

[英]Implement multiple hardware interfaces in WPF Desktop App

I want to make a Desktop application with WPF(.net 5).我想用 WPF(.net 5) 制作一个桌面应用程序。 In this application, I want to connect various hardware devices(sometimes simultaneously) via a USB port, Serial ports/Com port (eg RS232), etc.在这个应用程序中,我想通过 USB 端口、串行端口/Com 端口(例如 RS232)等连接各种硬件设备(有时同时)。

I want the application to talk both ways.我希望应用程序能够双向交谈。 Receiving data from hardware devices with a range of configurations(ie baud rate, frequency, data string), and Sending data to display, modify settings of the device.从具有一系列配置(即波特率,频率,数据字符串)的硬件设备接收数据,以及发送数据以显示,修改设备的设置。

I don't have any idea about where to start in WPF |我不知道从哪里开始 WPF | .NET | .NET | C#. C#。 Are there any inbuilt classes, APIs to achieve this?是否有任何内置类、API 来实现这一点?

There is the Serial port class in.Net, but you might want to read some criticism about the class before using it.串行端口 class in.Net,但您可能想在使用之前阅读一些关于 class 的批评 There are also libraries available to communicate over USB .还有一些库可用于通过 USB 进行通信

But these are fairly low level protocols that does not know what kind of device is on the other end.但这些是相当低级的协议,不知道另一端是什么类型的设备。 So your UI would therefore also need to low level, ie send/receive raw data.因此,您的 UI 也需要低级别,即发送/接收原始数据。 And this would mostly be useful for expert users using very specialized devices.这对于使用非常专业的设备的专家用户来说非常有用。 While you could probably make the part that sends and receive data share an interface for both USB and Serial, connection and setup would probably need to be handled differently, since these are handled differently for serial and USB.虽然您可以让发送和接收数据的部分共享 USB 和串行接口,但连接和设置可能需要以不同方式处理,因为串行和 USB 的处理方式不同。

If you want a easier to use UI you would need to know more about what kind of device it it.如果你想要一个更容易使用的 UI,你需要更多地了解它是什么类型的设备。 There is a number of standardized USB device classes that specify what kind of device it is, and there are often high level APIs to interface with these devices.有许多标准化的USB 设备类指定它是什么类型的设备,并且通常有高级 API 与这些设备接口。 But that would require coding a module for each individual device class.但这需要为每个单独的设备 class 编写一个模块。

So I would recommend to start with figuring out what you really want to do?所以我建议从弄清楚你真正想要做什么开始? Connect to a IO board with some general purpose IO pins?使用一些通用 IO 引脚连接到 IO 板? Connect to some specialized device like a PanTilt unit?连接到诸如 PanTilt 装置之类的专用设备? Read data from a webcam?从网络摄像头读取数据? Read some data from some kind of sensor, do some processing and control some kind of output device?从某种传感器读取一些数据,做一些处理和控制某种 output 设备?

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

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