LEDModel.cs
1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using LEDhelp;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HHECS.LED
{
public class LEDModel
{
public LEDHelper LED { get; set; }
public Queue<string> InfoQueue { get; set; }
public LEDModel(string ledIp, uint port, int timesec)
{
LED = new LEDHelper(ledIp, port, timesec);
InfoQueue = new Queue<string>();
}
public void BeginSendInfo()
{
Task.Run(async () =>
{
if (LED != null && InfoQueue != null)
{
while (true)
{
await Task.Delay(2000);
if (InfoQueue.Count > 0)
{
int i = LED.SendLedInfo(InfoQueue.Dequeue());
Console.WriteLine("LED发送返回值:" + i);
if (i != 0)
{
LED = new LEDHelper(null,0,0);
}
}
}
}
});
}
}
}