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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
using System;
using System.Collections.Generic;
namespace LEDManager
{
public class LEDSendTask:UnitTask
{
private WindowInfo _wi;
public LEDSendTask(string name, WindowInfo wi) : base(name) {
_wi = wi;
}
public static CLEDSender LEDSender = new CLEDSender();
public const int WM_LED_NOTIFY = 1025;
private const int GREEN = 0xFF00;
private const int YELLOW = 0x00FFFF;
private const int RED = 0x0000FF;
private static TSenderParam GetDevParam(string remoteIP,IntPtr handle, ushort imei=0)
{
TSenderParam param = new TSenderParam();
param.devParam.devType = LEDSender.DEVICE_TYPE_UDP;
param.devParam.comPort = 1;
param.devParam.comSpeed = 0;
param.devParam.locPort = 8881;
param.devParam.rmtHost = remoteIP;
param.devParam.rmtPort = 6666;
param.devParam.dstAddr = imei;
param.notifyMode = LEDSender.NOTIFY_BLOCK;
param.wmHandle = (uint)handle;
param.wmMessage = WM_LED_NOTIFY;
return param;
}
private static int GetColor(int color)
{
switch (color)
{
case 1: return RED;
case 2: return YELLOW;
case 3: return GREEN;
default:
return RED;
}
}
private string Parse(Int32 sendResult)
{
if (sendResult == LEDSender.R_DEVICE_READY) return "正在执行命令或者发送数据...";
else if (sendResult == LEDSender.R_DEVICE_INVALID) return "打开通讯设备失败(串口不存在、或者串口已被占用、或者网络端口被占用)";
else if (sendResult == LEDSender.R_DEVICE_BUSY) return "设备忙,正在通讯中...";
else return "无";
}
public override void Execute()
{
WinMessage.Send(_wi.handle, WinMessage.WM_LOG_MESSAGE, $"执行任务:{Name}");
WinMessage.Send(_wi.handle, WinMessage.WM_LOG_MESSAGE, $"发送: {_wi.RemoteIP} 硬件地址: {_wi.IMEI}");
foreach (var item in _wi.ObjList)
{
var K = (ushort)LEDSender.Do_MakeObject(CLEDSender.ROOT_PLAY_OBJECT, CLEDSender.ACTMODE_REPLACE, 0, 0, 0, item.ObjIndex, CLEDSender.COLOR_MODE_DOUBLE);
var d = GetDevParam(_wi.RemoteIP,_wi.handle,0);
if (item.IsScroll)
{
LEDSender.Do_AddText(K,
item.Left, item.Top, item.Width, item.Height, //对象位置
CLEDSender.V_TRUE,//透明
0, //边框
item.Text, //内容
item.FontName, item.FontSize, GetColor(item.FontColor), item.Bold ? CLEDSender.WFS_BOLD : CLEDSender.WFS_NONE, //字体样式
0, //换行
item.Alignment,//对齐
2, 5, // 进入动画 6 连续左滚 2 左滚
2, 5, // 退出动画
0, 5, 0 // 停留动画
);
}
else
{
LEDSender.Do_AddText(K,
item.Left, item.Top, item.Width, item.Height,//对象位置
CLEDSender.V_TRUE, //透明
0,//边框
item.Text, //内容
item.FontName, item.FontSize, GetColor(item.FontColor), item.Bold ? CLEDSender.WFS_BOLD : CLEDSender.WFS_NONE, //字体样式
0, //换行
item.Alignment//对齐
);
}
var sendResult = LEDSender.Do_LED_SendToScreen(ref d, K);
//WinMessage.Send(_wi.handle, WinMessage.WM_LOG_MESSAGE, $"发送led:{sendResult} {Parse(sendResult)}");
}
WinMessage.Send(_wi.handle, WinMessage.WM_LOG_MESSAGE, $"任务完成:{Name}");
}
}
public class WindowInfo
{
public IntPtr handle { get; set; }
public string RemoteIP { get; set; }
public int IMEI { get; set; }
public List<WindowObj2> ObjList { get; set; }
}
public class WindowObj2
{
public int Left { get; set; }
public int Top { get; set; }
public int Width { get; set; }
public int Height { get; set; }
public string Text { get; set; }
public string FontName { get; set; }
public int FontSize { get; set; }
public bool Bold { get; set; }
public int FontColor { get; set; }
public bool IsScroll { get; set; }
public int Alignment { get; set; }
public int ObjIndex { get; set; }
public int ObjType { get; set; }
}
}
|