与 WPF 应用程序中的串行设备通信
我正在尝试在实现 MVVM 设计的 WPF 应用程序中与串行设备进行通信的基础知识。现在我有一个硬环回,只期望接收发送的字符。
我过去曾见过 Win Forms 控件执行此操作的提示,也许还有框架类,但现在我对本着 MVVM 策略的精神可以使用什么一无所知。
I'm dabbling with the basics of communicating with a serial device from within a WPF application implementing an MVVM design. Right now I have a hard loopback and only expect to receive characters sent.
I have in the past seen hints of a Win Forms control to do this, and maybe a framework class, but right now I am a bit clueless as to what I can use in the spirit of an MVVM strategy.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我有点困惑,在我看来你可能对 MVVM 想得太多了。 MVVM是一种表示模式;串行通信不是表示,并且表示层是什么并不重要。
如果我这样做并且我正确理解你的问题,我就会有一个封装串行通信的类。如果您只期望将字符发送给您,我会让该类公开一个基本的“已接收”事件。然后,您的视图模型可以使用此类的实例来填充您的视图附加到的一些属性。
希望这有帮助。
I am a bit confused and it seems to me you might be overthinking MVVM. MVVM is a presentation pattern; serial communication is not presentation and it doesn't matter what your presentation layer is.
If I were to do this and I understand your problem correctly, I would have a class that encapsulates the serial communication. If you are only expecting characters to be sent to you, I'd have the class expose a basic "Received" event. Your View Model can then use an instance of this class to populate some properties that your View is attached to.
Hope this helps.