RgbLedController.cs
1.8 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
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TSA_V.Common;
using TSA_V.LoadCSVLibrary;
namespace TSA_V.DeviceLibrary
{
public class RgbLedController
{
public static Flyelectronic_485_RGB_Controller rGB_Controller = null;
public static bool Init()
{
if (Setting_NInit.RGBLed_PortName == "")
{
LogUtil.error("未配置RGBLED端口号");
return false;
}
rGB_Controller = new Flyelectronic_485_RGB_Controller("LED");
rGB_Controller.OpenPort(Setting_NInit.RGBLed_PortName, out string errmsg);
if (errmsg != null)
{
LogUtil.error("初始化RgbLed灯失败:" + errmsg);
return false;
}
return true;
}
private static Color defColor = Color.Green;
public static void OpenPosLed(TSAVPosition position)
{
if (position.IsRgbLed())
{
List<int> leds = position.getLedList();
OpenPosLed(leds);
}
}
public static void OpenPosLed(List<int> leds)
{
if (rGB_Controller == null)
{
return;
}
rGB_Controller.ShowLedColor(defColor, leds);
}
public static void CloseAll()
{
if (rGB_Controller == null)
{
return;
}
rGB_Controller.ShowColor(Color.Black);
}
public static void OpenAll()
{
if (rGB_Controller == null)
{
return;
}
rGB_Controller.ShowColor(defColor);
}
}
}