LEDHelper.cs
2.73 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LEDhelper
{
public class LEDHelper
{
//led对应的IP地址
private byte[] led_ip;
//led对应的端口号
private uint led_port;
//句柄
private uint hand;
//超时时间
private int timeout = 1;
private int mode = 0;
public LEDHelper(string ledIp, uint port, int timesec)
{
led_ip = Encoding.ASCII.GetBytes(ledIp);
led_port = port;
timeout = timesec;
}
public int SendLedInfo(string sendText)
{
int result = 0;
if (hand <= 0)
{
CreateClient();
}
LedInfo ledinfo = new LedInfo(sendText);
result = Led5kSDK.SCREEN_SendDynamicArea(hand, ledinfo.bx_5k, (ushort)ledinfo.AreaText.Length, ledinfo.AreaText);
return result;
}
public uint CreateClient()
{
hand= Led5kSDK.CreateClient(led_ip, led_port, Led5kSDK.bx_5k_card_type.BX_5MK2,timeout, mode, null);
return hand;
}
public void CloseClient()
{
Led5kSDK.Destroy(hand);
}
public int CheckPing()
{
return Led5kSDK.CON_PING(hand);
}
/// <summary>
/// 获取控制器类型的对应16进制编码
/// 任意
///BX_5K1
///BX_5K2
///BX_5MK1
///BX_5MK2
///BX_5K1Q_YY
///BX_6K1
///BX_6K2
///BX_6K3
///BX_6K1_YY
///BX_6K2_YY
///BX_6K3_YY
/// </summary>
/// <param name="controllerType"></param>
/// <returns></returns>
private static byte getControllerTypeByName(string controllerType)
{
byte result = 0;
switch (controllerType)
{
case "任意": { result = 0xFE; break; };
case "BX_5K1": { result = 0x51; break; };
case "BX_5K2": { result = 0x58; break; };
case "BX_5MK1": { result = 0x54; break; };
case "BX_5MK2": { result = 0x53; break; };
case "BX_5K1Q_YY": { result = 0x5c; break; };
case "BX_6K1": { result = 0x61; break; };
case "BX_6K2": { result = 0x62; break; };
case "BX_6K3": { result = 0x63; break; };
case "BX_6K1_YY": { result = 0x64; break; };
case "BX_6K2_YY": { result = 0x65; break; };
case "BX_6K3_YY": { result = 0x66; break; };
default:result = 0; break;
}
return result;
}
}
}