LEDExcute.cs
3.38 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
using HHECS.Model.Entities;
using LEDhelp;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Threading.Tasks;
namespace HHECS.Bll
{
public class LEDExcute
{
LEDHelper Led;
//LEDHelper BatteriesLED;
//LEDHelper PartsStation1LED;
//LEDHelper PartsStation2LED;
public Queue<string> LedQueue { get; set; } = new Queue<string>();
//public Queue<string> BatteriesQueue { get; set; } = new Queue<string>();
//public Queue<string> PartsStation1Queue { get; set; } = new Queue<string>();
//public Queue<string> PartsStation2Queue { get; set; } = new Queue<string>();
public LEDExcute()
{
string LedIP = ConfigurationManager.AppSettings["LedIP"];
//string batteriesLedIP = ConfigurationManager.AppSettings["BatteriesLedIP"];
//string partsStation1LedIP = ConfigurationManager.AppSettings["PartsStation1LedIP"];
//string partsStation2LedIP = ConfigurationManager.AppSettings["PartsStation2LedIP"];
int ledPort = Convert.ToInt32(ConfigurationManager.AppSettings["ledPort"]);
Led = new LEDhelp.LEDHelper(LedIP, (uint)ledPort, 1);
//BatteriesLED = new LEDhelp.LEDHelper(batteriesLedIP, (uint)ledPort, 1);
//PartsStation1LED = new LEDhelp.LEDHelper(partsStation1LedIP, (uint)ledPort, 1);
//PartsStation2LED = new LEDhelp.LEDHelper(partsStation2LedIP, (uint)ledPort, 1);
}
public void BeginSendInfo()
{
Task.Run(async () =>
{
while (true)
{
await Task.Delay(2000);
if (Led != null && LedQueue != null && LedQueue.Count > 0)
{
SCREEN_ForceOnOff(LEDHelper.Produce, LEDHelper.OPEN);
SCREEN_DelDynamicArea(LEDHelper.Produce, 0);
sendLedInfo(LEDHelper.Produce, LEDHelper.GREEN, LedQueue.Dequeue());
setBrightness(LEDHelper.Produce, 5);
}
}
});
}
private void sendLedInfo(int direction, int color, String sendText)
{
if (color == LEDhelp.LEDHelper.GREEN)
{
sendText = "\\C2" + sendText;
}
else if (color == LEDhelp.LEDHelper.YELLOW)
{
sendText = "\\C3" + sendText;
}
else
{
sendText = "\\C1" + sendText;
}
if (direction == LEDhelp.LEDHelper.Produce)
{
Led.SendLedInfo(sendText);
}
}
private void SCREEN_ForceOnOff(int direction, byte status)
{
if (direction == LEDhelp.LEDHelper.Produce)
{
Led.SCREEN_ForceOnOff(status);
}
}
// value 0-15 值越大亮度越大
public void setBrightness(int direction, byte value)
{
if (direction == LEDhelp.LEDHelper.Produce)
{
Led.setBrightness(1, value, null);
}
}
public void SCREEN_DelDynamicArea(int direction, byte DeleteAreaId)
{
if (direction == LEDhelp.LEDHelper.Produce)
{
Led.SCREEN_DelDynamicArea(DeleteAreaId);
}
}
}
}