如何在串口通讯的列表框中显示DTR ON TIME和DTR OFF TIME? [英] How to display DTR ON TIME and DTR OFF TIME in listbox in serial port communication?

查看:140
本文介绍了如何在串口通讯的列表框中显示DTR ON TIME和DTR OFF TIME?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在C#中如何取决于用户输入的串行端口通信中如何在列表框中显示DTR ON TIMEDTR OFF TIME?

像例子
1.总时间= 20分钟(i/p)文本框
2. DTR ON = 2000毫秒(i/p)文本框
3. DTR OFF = 5000毫秒(i/p)文本框
4.开始BUTTON
5. LISTBOX(显示启用/禁用消息的时间)


请给我发送C#代码plssssssssssssssssss
嘿,使用线程概念,如两个线程的start sleep start

How to display DTR ON TIME and DTR OFF TIME in listbox in serial port communication that depends on user input, in C#?

like example
1. total time =20 minutes(i/p)Textbox
2. DTR ON=2000 milliseconds(i/p)Textbox
3. DTR OFF =5000 milliseconds (i/p)Textbox
4. start BUTTON
5. LISTBOX(Show the times with message enable/disable)


JUST SEND ME THE C# CODE plsssssssssssssssssss
hey use the thread concept like start sleep start for two threads

推荐答案

由于DTR是PC的输出,因此我将保留一个类级别的Stopwatch实例.提高DTR时启动它(使用 SerialPort.DtrEnable [^ ]属性),然后在计时器中断或用户键入时读取超时.降低DTR时将其停止.

还是我误解了您的问题?
Since DTR is an output from the PC, I would keep a class level Stopwatch instance. Start it when you raise DTR (using the SerialPort.DtrEnable[^] property) and then read the time out in either a timer interrupt or when the user types. Stop it when you lower DTR.

Or have I misread your question?


要添加这些字符串,请在此处添加代码:

To add those strings, herez da codez:

listbox.Items.Add("DTR ON TIME");
listbox.Items.Add("DTR OFF TIME");



认真地说,您是否要求打开/关闭DTR的时间?

如果是这样,那将是这样的:



Seriously though, are you asking for the time at which DTR was turned on/off?

If so, that would go something like this:

listbox.Items.Add(string.Format("{0} - DTR OFF", DateTime.Now.ToString("yyyyMMdd HH:mm:ss")));
listbox.Items.Add(string.Format("{0} - DTR ON", DateTime.Now.ToString("yyyyMMdd HH:mm:ss")));



当然,您可能必须处理一个自定义事件并调用适当的委托才能将适当的文本添加到列表框中,但是您并不需要输入代码,因此我假设您知道自己在做什么.在做.



Of course, you''d probably have to handle a custom event and invoke the proper delegate in order to add the appropriate text to the listbox, but you didn''t ask for code for that, so I assume you know what you''re doing.


这篇关于如何在串口通讯的列表框中显示DTR ON TIME和DTR OFF TIME?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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