FrmLedTest.cs
4.5 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Drawing;
using System.Linq;
using TSA_V.Common;
using TSA_V.DeviceLibrary;
using TSA_V.LoadCSVLibrary;
namespace TSA_V
{
public partial class FrmLedTest : FrmBase
{
public FrmLedTest()
{
InitializeComponent();
}
private void Frm1_Load(object sender, EventArgs e)
{
List<TSAVPosition> allList = CSVPositionReader<TSAVPosition>.getPositionList();
List<TSAVPosition> list = (from m in allList where m.PositionType.Equals(2) select m).ToList();
cmbLed.DataSource = list;
cmbLed.DisplayMember = "PositionName";
cmbLed.ValueMember = "PositionName";
if (list.Count > 0)
{
cmbLed.SelectedIndex = 0;
}
}
private void clearLog_btn_Click(object sender, EventArgs e)
{
LogUtil.ClearLogBoxText();
}
private void btnInStore_Click(object sender, EventArgs e)
{
string ip = FormUtil.getValue(txtIp);
int index = FormUtil.GetIntValue(txtLed);
LEDModule led = LedManager.GetLEDModule(ip);
led.AllLightOn(Light.GreenLight(0));
}
private void btnOutStore_Click(object sender, EventArgs e)
{
string ip = FormUtil.getValue(txtIp);
int index = FormUtil.GetIntValue(txtLed);
LEDModule led = LedManager.GetLEDModule(ip);
led.AllLightOff();
}
private void FrmMain_FormClosing(object sender, FormClosingEventArgs e)
{
string ip = FormUtil.getValue(txtIp);
int index = FormUtil.GetIntValue(txtLed);
LEDModule led = LedManager.GetLEDModule(ip);
led.LightOff();
}
private void btnExit_Click(object sender, EventArgs e)
{
this.Close();
}
private void buttonOpenOne_Click(object sender, EventArgs e)
{
string ip = FormUtil.getValue(txtIp);
int index = FormUtil.GetIntValue(txtLed);
LEDModule led = LedManager.GetLEDModule(ip);
try
{
int lightIndex = FormUtil.GetIntValue(txtLed);
led.LightOn(Light.BlueLight(lightIndex));
}
catch (Exception ex)
{
LogUtil.error("打开灯失败:" + ex.ToString());
}
}
private void buttonCloseOne_Click(object sender, EventArgs e)
{
string ip = FormUtil.getValue(txtIp);
int index = FormUtil.GetIntValue(txtLed);
LEDModule led = LedManager.GetLEDModule(ip);
try
{
int lightIndex = FormUtil.GetIntValue(txtLed);
led.LightOff(lightIndex);
}
catch (Exception ex)
{
LogUtil.error("关闭灯失败:" + ex.ToString());
}
}
private void cmbLed_SelectedIndexChanged(object sender, EventArgs e)
{
if (cmbLed.SelectedIndex >= 0)
{
TSAVPosition Select = (TSAVPosition)cmbLed.SelectedItem;
txtIp.Text = Select.DeviceIP.ToString();
txtLeds.Text = Select.Leds;
}
}
private void button_LedOn_Click(object sender, EventArgs e)
{
if (cmbLed.SelectedIndex >= 0)
{
TSAVPosition Select = (TSAVPosition)cmbLed.SelectedItem;
LEDModule led = LedManager.GetLEDModule(Select.DeviceIP);
Light[] lights = new Light[Select.getLedList().Count];
int index = 0;
foreach (int i in Select.getLedList())
{
lights[index] = (Light.GreenLight(i));
index++;
}
led.LightOn(lights);
}
}
private void button_LedOff_Click(object sender, EventArgs e)
{
if (cmbLed.SelectedIndex >= 0)
{
TSAVPosition Select = (TSAVPosition)cmbLed.SelectedItem;
LEDModule led = LedManager.GetLEDModule(Select.DeviceIP);
int[] lights = new int[Select.getLedList().Count];
int index = 0;
foreach (int i in Select.getLedList())
{
lights[index] = i;
index++;
}
led.LightOff(lights);
}
}
}
}