AxisControl.cs
4.6 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
using DeviceLibrary;
using OnlineStore;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace TheMachine
{
public partial class AxisControl : UserControl
{
StoreMachine Machine;
public AxisControl(StoreMachine machine)
{
Machine = machine;
InitializeComponent();
RobotManage.LoadFinishEvent += RobotManage_LoadFinishEvent;
crc.LanguageChangeEvent += Crc_LanguageChangeEvent;
configControl1.Machine = machine;
crc.LanguageProcess(this);
}
private void Crc_LanguageChangeEvent(object sender, EventArgs e)
{
RobotManage_LoadFinishEvent(true, "");
crc.LanguageProcess(this);
}
private void RobotManage_LoadFinishEvent(bool state, string msg)
{
if (this.InvokeRequired)
{
this.Invoke((EventHandler)delegate
{
RobotManage_LoadFinishEvent(state, msg);
});
return;
}
if (!state)
return;
axisMoveControl1.LoadData(AxisBean.List[Machine.MachineSide]);
configControl1.Config = Machine.Config;
LogUtil.info("伺服面板加载完成.");
}
private void AxisControl_Load(object sender, EventArgs e)
{
var sizelist = Machine.StorePosition.Values.Distinct(new ACStorePositionComparer());
var ll = sizelist.Select(a => { return new Position(a.BagWidth, a.BagHigh); }).ToList();
ll.AddRange(FixtureConfig.FixtureConfigList.Select(a => { return new Position(a.Width, a.Height); }).ToArray());
var aa=ll.Distinct(new PositionComparer());
cb_sizelist.Items.AddRange(aa.ToArray());
if (cb_sizelist.Items.Count > 0)
cb_sizelist.SelectedIndex = 0;
}
private void btn_comptest_Click(object sender, EventArgs e)
{
Position p = cb_sizelist.SelectedItem as Position;
var BagHigh = p.Height;
if (FixtureConfig.GetFixtureHeight(p.Width, p.Height, out int actualheight))
BagHigh = actualheight;
var Comp_PL = Machine.Config.Comp_P2 - Machine.Config.Comp_PoToMM * (BagHigh - 70);
Comp_PL = Comp_PL < 0 ? 0 : Comp_PL;
Machine.Comp_Axis.AbsMove(null, Comp_PL, Machine.Config.Comp_P1_speed);
}
public class Position {
public int Width;
public int Height;
public Position(int width, int height)
{
Width = width;
Height = height;
}
public override string ToString()
{
return $"{Width}x{Height}";
}
}
public class ACStorePositionComparer : IEqualityComparer<ACStorePosition>
{
public bool Equals(ACStorePosition x, ACStorePosition y)
{
if (x == null && y == null)
return true;
else if (x == null || y == null)
return false;
return $"{x.BagHigh}x{x.BagWidth}" == $"{y.BagHigh}x{y.BagWidth}";
}
public int GetHashCode(ACStorePosition obj)
{
return base.GetHashCode();
}
}
public class PositionComparer : IEqualityComparer<Position>
{
public bool Equals(Position x, Position y)
{
if (x == null && y == null)
return true;
else if (x == null || y == null)
return false;
return $"{x.Height}x{x.Width}" == $"{y.Height}x{y.Width}";
}
public int GetHashCode(Position obj)
{
return base.GetHashCode();
}
}
private void cb_sizelist_SelectedIndexChanged(object sender, EventArgs e)
{
Position p = cb_sizelist.SelectedItem as Position;
var BagHigh = p.Height;
if (FixtureConfig.GetFixtureHeight(p.Width, p.Height, out int actualheight))
BagHigh = actualheight;
lbl_acheight.Text = crc.GetString("AxisControl_panel1_groupBox1_lbl_acheight_Text","设置高度") + ":" + BagHigh + "mm";
}
}
}