FrmPackLine.cs
2.9 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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace DoubleLine
{
public partial class FrmPackLine : Form
{
public FrmPackLine()
{
InitializeComponent();
}
private void FrmPackage_Load(object sender, EventArgs e)
{
Common.IO_Info[3].Box.DI_Changed_Event += DI4_Changed;
Common.IO_Info[3].Box.DO_Changed_Event += DO4_Changed;
}
private void FrmPackLine_FormClosing(object sender, FormClosingEventArgs e)
{
Common.IO_Info[3].Box.DI_Changed_Event -= DI4_Changed;
Common.IO_Info[3].Box.DO_Changed_Event -= DO4_Changed;
}
internal void DI4_Changed(Asa.IOModule.AIOBOX box, Asa.IOModule.Box_Sta[] sta)
{
for (int i = 0; i < sta.Length; i++)
{
if (Common.IO_Info[3].DI[i].Sta == sta[i]) continue;
if (sta[i] == Asa.IOModule.Box_Sta.On)
tabPage1.Controls["DI4_" + i].BackColor = Color.Lime;
else
tabPage1.Controls["DI4_" + i].BackColor = Color.LightGray;
Common.IO_Info[3].DI[i].Sta = sta[i];
}
}
internal void DO4_Changed(Asa.IOModule.AIOBOX box, Asa.IOModule.Box_Sta[] sta)
{
for (int i = 0; i < sta.Length; i++)
{
if (Common.IO_Info[3].DO[i].Sta == sta[i]) continue;
if (sta[i] == Asa.IOModule.Box_Sta.On)
tabPage1.Controls["DO4_" + i].BackColor = Color.Lime;
else
tabPage1.Controls["DO4_" + i].BackColor = Color.Transparent;
Common.IO_Info[3].DO[i].Sta = sta[i];
}
}
private void DO4_Click(object sender, EventArgs e)
{
if (!Common.IO_Info[3].Box.IsConn) return;
int add = Convert.ToInt32((sender as Control).Name.Substring(4));
if (add == 7)
Common.IO_Info[3].Box.WriteDO(8, Asa.IOModule.Box_Sta.Off);
else if (add == 8)
Common.IO_Info[3].Box.WriteDO(7, Asa.IOModule.Box_Sta.Off);
if (add == 10)
Common.IO_Info[3].Box.WriteDO(11, Asa.IOModule.Box_Sta.Off);
else if (add == 11)
Common.IO_Info[3].Box.WriteDO(10, Asa.IOModule.Box_Sta.Off);
if (add == 12)
Common.IO_Info[3].Box.WriteDO(13, Asa.IOModule.Box_Sta.Off);
else if (add == 13)
Common.IO_Info[3].Box.WriteDO(12, Asa.IOModule.Box_Sta.Off);
Asa.IOModule.Box_Sta sta = Common.IO_Info[3].Box.ReadDO(add);
sta = Common.IO_Info[3].Box.ReverseStatus(sta);
Common.IO_Info[3].Box.WriteDO(add, sta);
}
}
}