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; using WCS_Client.From.From_Montior; namespace WCS_Client.From { public partial class Form_Monitior : Form { #region System.Timers.Timer _timer; private delegate void ShowTextDelegate(List ds);// 创建委托和委托对象 #endregion; public Form_Monitior() { InitializeComponent(); InitOne(); InitTwo(); } private static Form_Monitior childFromInstanc; public static Form_Monitior ChildFromInstanc { get { if (childFromInstanc == null || childFromInstanc.IsDisposed) { childFromInstanc = new Form_Monitior(); } return childFromInstanc; } } private void InitOne() { conveyor_1021.button1.Text = "1021"; conveyor_1022.button1.Text = "1022"; conveyor_1038.button1.Text = "1038"; conveyor_1040.button1.Text = "1040"; conveyor_1039.button1.Text = "1039"; conveyor_1037.button1.Text = "1037"; conveyor_1036.button1.Text = "1036"; conveyor3_1027.button1.Text = "1027"; conveyor_1029.button1.Text = "1029"; conveyor_1019.button1.Text = "1019"; conveyor_1046.button1.Text = "1046"; conveyor_1018.button1.Text = "1018"; conveyor_1048.button1.Text = "1048"; conveyor_1017.button1.Text = "1017"; conveyor_1030.button1.Text = "1030"; conveyor_1031.button1.Text = "1031"; conveyor_1015.button1.Text = "1015"; conveyor_1033.button1.Text = "1033"; conveyor_1013.button1.Text = "1013"; conveyor_1012.button1.Text = "1012"; conveyor_1011.button1.Text = "1011"; conveyor_1032.button1.Text = "1032"; conveyor_1035.button1.Text = "1035"; rgv01.btn02.Text = "1024"; rgv01.btn01.Text = "1023"; rgv02.btn02.Text = "1008"; rgv02.btn01.Text = "1007"; rgv03.btn02.Text = "1057"; rgv03.btn01.Text = "1056"; conveyor_1041.button1.Text = "1041"; conveyor_1044.button1.Text = "1044"; conveyor_1118.button1.Text = "1118"; conveyor_1116.button1.Text = "1116"; conveyor_1115.button1.Text = "1115"; conveyor_1112.button1.Text = "1112"; conveyor_1111.button1.Text = "1111"; conveyor_1110.button1.Text = "1110"; conveyor_1138.button1.Text = "1138"; conveyor_1139.button1.Text = "1139"; conveyor_1001.button1.Text = "1001"; conveyor_1002.button1.Text = "1002"; conveyor_1003.button1.Text = "1003"; conveyor_1004.button1.Text = "1004"; conveyor_1005.button1.Text = "1005"; conveyor_1006.button1.Text = "1006"; conveyor_1050.button1.Text = "1050"; conveyor_1051.button1.Text = "1051"; conveyor_1052.button1.Text = "1052"; conveyor_1053.button1.Text = "1053"; conveyor_1054.button1.Text = "1054"; conveyor_1055.button1.Text = "1055"; conveyor_1061.button1.Text = "1061"; conveyor_1062.button1.Text = "1062"; conveyor_1063.button1.Text = "1063"; conveyor_1064.button1.Text = "1064"; conveyor_1065.button1.Text = "1065"; conveyor_1066.button1.Text = "1066"; conveyor_1067.button1.Text = "1067"; conveyor_1068.button1.Text = "1068"; conveyor_1069.button1.Text = "1069"; conveyor_1070.button1.Text = "1070"; conveyor_1071.button1.Text = "1071"; conveyor_1072.button1.Text = "1072"; } private void InitTwo() { conveyor_1080.button1.Text = "1080"; conveyor_1081.button1.Text = "1081"; conveyor_1082.button1.Text = "1082"; conveyor_1083.button1.Text = "1083"; conveyor_1084.button1.Text = "1084"; conveyor_1085.button1.Text = "1085"; rgv04.btn02.Text = "1087"; rgv04.btn01.Text = "1086"; conveyor_1090.button1.Text = "1090"; conveyor_1091.button1.Text = "1091"; conveyor_1092.button1.Text = "1092"; conveyor_1093.button1.Text = "1093"; conveyor_1094.button1.Text = "1094"; conveyor_1095.button1.Text = "1095"; conveyor_1096.button1.Text = "1096"; conveyor_1097.button1.Text = "1097"; conveyor_1098.button1.Text = "1098"; conveyor_1099.button1.Text = "1099"; conveyor_1100.button1.Text = "1100"; conveyor_1101.button1.Text = "1101"; conveyor_1102.button1.Text = "1102"; conveyor_1103.button1.Text = "1103"; conveyor_1116.button1.Text = "1116"; conveyor_1120.button1.Text = "1120"; conveyor_1121.button1.Text = "1121"; conveyor_1123.button1.Text = "1123"; conveyor_1124.button1.Text = "1124"; conveyor_1126.button1.Text = "1126"; conveyor_1127.button1.Text = "1127"; conveyor_1128.button1.Text = "1128"; conveyor_1130.button1.Text = "1130"; conveyor_1129.button1.Text = "1129"; conveyor_1132.button1.Text = "1132"; conveyor_1133.button1.Text = "1133"; conveyor_1134.button1.Text = "1134"; conveyor_1136.button1.Text = "1136"; conveyor_1137.button1.Text = "1137"; conveyor_1112.button1.Text = "1114"; conveyor2_1114.button1.Text = "1114"; conveyor2_1116.button1.Text = "1116"; } private void myTableLayoutPanel1_CellPaint(object sender, TableLayoutCellPaintEventArgs e) { #region RGV01轨道边框 if (e.Row == 2 && e.Column == 9) { float x = e.CellBounds.Location.X; float x2 = e.CellBounds.Right; float y = e.CellBounds.Location.Y; float y2 = e.CellBounds.Bottom; e.Graphics.DrawLine(new Pen(Color.Blue), x, y, x, y2);//竖线 e.Graphics.DrawLine(new Pen(Color.Blue), x, y, x2, y);//横线 } if (e.Row == 3 && e.Column >= 9 && e.Column <= 19) { float x = e.CellBounds.Location.X; float x2 = e.CellBounds.Right; float y = e.CellBounds.Location.Y; float y2 = e.CellBounds.Bottom; e.Graphics.DrawLine(new Pen(Color.Blue), x, y, x2, y);//横线 } if (e.Row == 2 && e.Column >= 9 && e.Column <= 19) { float x = e.CellBounds.Location.X; float x2 = e.CellBounds.Right; float y = e.CellBounds.Location.Y; float y2 = e.CellBounds.Bottom; e.Graphics.DrawLine(new Pen(Color.Blue), x, y, x2, y);//横线 } //if (e.Row == 2 && e.Column == 17) //{ // float x = e.CellBounds.Location.X; // float x2 = e.CellBounds.Right; // float y = e.CellBounds.Location.Y; // float y2 = e.CellBounds.Bottom; // e.Graphics.DrawLine(new Pen(Color.Blue), x, y, x, y2);//竖线 //} //e.Graphics.DrawRectangle(new Pen(Color.Blue), e.CellBounds); #endregion; #region RGV02轨道边框 if (e.Row == 3 && e.Column == 24) { float x = e.CellBounds.Location.X; float x2 = e.CellBounds.Right; float y = e.CellBounds.Location.Y; float y2 = e.CellBounds.Bottom; e.Graphics.DrawLine(new Pen(Color.Blue), x, y, x2, y);//横线 } if (e.Row >= 3 && e.Row <= 18 && e.Column == 24) { float x = e.CellBounds.Location.X; float x2 = e.CellBounds.Right; float y = e.CellBounds.Location.Y; float y2 = e.CellBounds.Bottom; e.Graphics.DrawLine(new Pen(Color.Blue), x, y, x, y2);//竖线 } if (e.Row >= 3 && e.Row <= 18 && e.Column == 25) { float x = e.CellBounds.Location.X; float x2 = e.CellBounds.Right; float y = e.CellBounds.Location.Y; float y2 = e.CellBounds.Bottom; e.Graphics.DrawLine(new Pen(Color.Blue), x, y, x, y2);//竖线 } if (e.Row == 19 && e.Column == 24) { float x = e.CellBounds.Location.X; float x2 = e.CellBounds.Right; float y = e.CellBounds.Location.Y; float y2 = e.CellBounds.Bottom; e.Graphics.DrawLine(new Pen(Color.Blue), x, y, x2, y);//横线 } #endregion; #region RGV03轨道边框 if (e.Row == 5 && e.Column == 2) { float x = e.CellBounds.Location.X; float x2 = e.CellBounds.Right; float y = e.CellBounds.Location.Y; float y2 = e.CellBounds.Bottom; e.Graphics.DrawLine(new Pen(Color.Blue), x, y, x2, y);//横线 } if (e.Row >= 5 && e.Row <= 19 && e.Column == 2) { float x = e.CellBounds.Location.X; float x2 = e.CellBounds.Right; float y = e.CellBounds.Location.Y; float y2 = e.CellBounds.Bottom; e.Graphics.DrawLine(new Pen(Color.Blue), x, y, x, y2);//竖线 } if (e.Row >= 5 && e.Row <= 19 && e.Column == 3) { float x = e.CellBounds.Location.X; float x2 = e.CellBounds.Right; float y = e.CellBounds.Location.Y; float y2 = e.CellBounds.Bottom; e.Graphics.DrawLine(new Pen(Color.Blue), x, y, x, y2);//竖线 } if (e.Row == 20 && e.Column == 2) { float x = e.CellBounds.Location.X; float x2 = e.CellBounds.Right; float y = e.CellBounds.Location.Y; float y2 = e.CellBounds.Bottom; e.Graphics.DrawLine(new Pen(Color.Blue), x, y, x2, y);//横线 } #endregion; } private void tableLayoutPanel1_CellPaint(object sender, TableLayoutCellPaintEventArgs e) { #region RGV03轨道边框 if (e.Row == 4 && e.Column == 2) { float x = e.CellBounds.Location.X; float x2 = e.CellBounds.Right; float y = e.CellBounds.Location.Y; float y2 = e.CellBounds.Bottom; e.Graphics.DrawLine(new Pen(Color.Blue), x, y, x2, y);//横线 } if (e.Row >= 4 && e.Row <= 18 && e.Column == 2) { float x = e.CellBounds.Location.X; float x2 = e.CellBounds.Right; float y = e.CellBounds.Location.Y; float y2 = e.CellBounds.Bottom; e.Graphics.DrawLine(new Pen(Color.Blue), x, y, x, y2);//竖线 } if (e.Row >= 4 && e.Row <= 18 && e.Column == 3) { float x = e.CellBounds.Location.X; float x2 = e.CellBounds.Right; float y = e.CellBounds.Location.Y; float y2 = e.CellBounds.Bottom; e.Graphics.DrawLine(new Pen(Color.Blue), x, y, x, y2);//竖线 } if (e.Row == 19 && e.Column == 2) { float x = e.CellBounds.Location.X; float x2 = e.CellBounds.Right; float y = e.CellBounds.Location.Y; float y2 = e.CellBounds.Bottom; e.Graphics.DrawLine(new Pen(Color.Blue), x, y, x2, y);//横线 } #endregion; } private void tabControl1_DrawItem(object sender, DrawItemEventArgs e) { //设置笔刷 //SolidBrush a = new SolidBrush(Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(144)))), ((int)(((byte)(154)))))); //SolidBrush blue = new SolidBrush(Color.Blue); //StringFormat sf = new StringFormat(); //sf.Alignment = StringAlignment.Center; //sf.LineAlignment = StringAlignment.Center; //for (int i = 0; i < tabControl1.TabPages.Count; i++) //{ // //绘制背景 // Rectangle rec1 = tabControl1.GetTabRect(i); // e.Graphics.FillRectangle(a, rec1); // Rectangle rec = tabControl1.GetTabRect(i); // e.Graphics.DrawString(tabControl1.TabPages[i].Text, new Font("宋体", 10), blue, rec, sf); //} } private void Form_Monitior_Load(object sender, EventArgs e) { _timer = new System.Timers.Timer(5000); _timer.Elapsed += new System.Timers.ElapsedEventHandler(theout);//到达时间的时候执行事件; _timer.AutoReset = true;//设置是执行一次(false)还是一直执行(true); _timer.Enabled = true;//是否执行System.Timers.Timer.Elapsed事件; } private void theout(object sender, EventArgs e) { var plcnameSet = new List(); plcnameSet.Add("conveyor01"); plcnameSet.Add("conveyor02"); plcnameSet.Add("srm01"); plcnameSet.Add("srm02"); plcnameSet.Add("srm03"); plcnameSet.Add("rgv01"); plcnameSet.Add("rgv02"); plcnameSet.Add("rgv03"); plcnameSet.Add("rgv04"); // var list = BaseWorkflow.QueryStackerdData(plcnameSet); //ShowData(list); } private void ShowData(object Dat) { try { if (InvokeRequired) { //List data = (List)Dat;//传过来的数据 object[] obj = { Dat }; //异步调用委托(后面添加方法需要将方法委托其中) this.BeginInvoke(new ShowTextDelegate(pan11), obj); //this.BeginInvoke(new ShowTextDelegate(pan10), obj); } else { } } catch (Exception ex) { LogHelper.Sys_Log.WriteLog(ex.ToString()); } } public void pan11(List dt) { try { var conveyorSet = dt.Where(v => v.STA_TYPE == "conveyor").ToList(); var conveyor1 = conveyorSet.FirstOrDefault(v => v.STA_EQUIPMENTNO == "1032"); SetConveyor_R(conveyor_1032, conveyor1); var conveyor2 = conveyorSet.FirstOrDefault(v => v.STA_EQUIPMENTNO == "1035"); SetConveyor_R(conveyor_1035, conveyor2); Control.ControlCollection sonControls = this.Controls; var conveyors = sonControls[0].Controls[0].Controls[0]; //遍历窗体所有控件, foreach (Control control in conveyors.Controls) { var equipmentno = control.Name.Substring(control.Name.Length - 4); var conveyor = conveyorSet.FirstOrDefault(v => v.STA_EQUIPMENTNO == equipmentno); if (conveyor != null) { if (control is Conveyor3_B) { SetConveyor3_B(control, conveyor); } else if (control is Conveyor3) { SetConveyor3(control, conveyor); } else if (control is Conveyor_L) { SetConveyor_L(control, conveyor); } else if (control is Conveyor_R) { SetConveyor_R(control, conveyor); } else if (control is Conveyor) { SetConveyor(control, conveyor); } else if (control is Conveyor4_left) { SetConveyor4_left(control, conveyor); } else if (control is Conveyor4_right) { SetConveyor4_right(control, conveyor); } else if (control is Conveyor4_L_R) { SetConveyor4_L_R(control, conveyor); } else if (control is Conveyor5) { SetConveyor5(control, conveyor); } else if (control is Conveyor6) { SetConveyor6(control, conveyor); } } } var rgvSet = dt.Where(v => v.STA_TYPE == "rgv").ToList(); foreach (Control control in conveyors.Controls) { if (control.Name.Contains("rgv")) { var rgv = rgvSet.FirstOrDefault(v => v.STA_EQUIPMENTNO == control.Name); if (rgv != null) { if (control is Rgv02) { SetRgv02(control, rgv); } else if (control is Rgv) { SetRgv(control, rgv); } } } } var srmSet = dt.Where(v => v.STA_TYPE == "srm").ToList(); foreach (Control control in conveyors.Controls) { if (control.Name.Contains("srm")) { var srm = srmSet.FirstOrDefault(v => v.STA_EQUIPMENTNO == control.Name); if (srm != null) { if (control is Srm3) { SetSrmInfo(srm, control); } } } } var conveyors2 = sonControls[0].Controls[1].Controls[0]; foreach (Control control in conveyors2.Controls) { var equipmentno = control.Name.Substring(control.Name.Length - 4); var conveyor = conveyorSet.FirstOrDefault(v => v.STA_EQUIPMENTNO == equipmentno); if (conveyor != null) { if (control is Conveyor) { SetConveyor(control, conveyor); } else if (control is Conveyor4_L_R) { SetConveyor4_L_R(control, conveyor); } else if (control is Conveyor4_left) { SetConveyor4_left(control, conveyor); } else if (control is Conveyor4_right) { SetConveyor4_right(control, conveyor); } else if (control is Conveyor5) { SetConveyor5(control, conveyor); } else if (control is Conveyor3) { SetConveyor3(control, conveyor); } else if (control is Conveyor6) { SetConveyor6(control, conveyor); } } } foreach (Control control in conveyors2.Controls) { if (control.Name.Contains("rgv")) { var rgv = rgvSet.FirstOrDefault(v => v.STA_EQUIPMENTNO == control.Name); if (rgv != null) { if (control is Rgv) { SetRgv(control, rgv); } } } } } catch (Exception ex) { LogHelper.Sys_Log.WriteLog(ex.ToString()); } } private void SetConveyor_R(Conveyor_R conveyor_R, WCS_STACKERDATA conveyor) { if (conveyor.ConveyorSignalItem.DB521_Tasknum > 0) { if (conveyor_R.button1.Tag.ToString() != "pall") { conveyor_R.button1.BackgroundImage = Image.FromFile("Resources/Conveyor_R.png"); conveyor_R.button1.Tag = "pall"; } } else { if (conveyor_R.button1.Tag.ToString() != "empty") { conveyor_R.button1.BackgroundImage = Image.FromFile("Resources/1009L1.png"); conveyor_R.button1.Tag = "empty"; } } if (conveyor.ConveyorSignalItem.DB523_Fault && conveyor_R.button1.BackColor != Color.Red) { conveyor_R.button1.BackColor = Color.Red; } if (conveyor.ConveyorSignalItem.DB523_Fault == false && conveyor_R.button1.BackColor != Color.FromArgb(0, 144, 154)) { conveyor_R.button1.BackColor = Color.FromArgb(0, 144, 154); } } private void SetConveyor3_B(Control control, WCS_STACKERDATA conveyor) { var con = (Conveyor3_B)control; if (conveyor.ConveyorSignalItem.DB521_Tasknum > 0) { if (con.button1.Tag.ToString() != "pall") { con.button1.BackgroundImage = Image.FromFile("Resources/1009R1_B.png");//1009R1_A.png con.button1.Tag = "pall"; } } else { if (con.button1.Tag.ToString() != "empty") { con.button1.BackgroundImage = Image.FromFile("Resources/1009R1.png");//1009R1.png con.button1.Tag = "empty"; } } if (conveyor.ConveyorSignalItem.DB523_Fault && con.button1.BackColor != Color.Red) { con.button1.BackColor = Color.Red; } if (conveyor.ConveyorSignalItem.DB523_Fault == false && con.button1.BackColor != Color.FromArgb(0, 144, 154)) { con.button1.BackColor = Color.FromArgb(0, 144, 154); } } private void SetConveyor3(Control control, WCS_STACKERDATA conveyor) { var con = (Conveyor3)control; if (conveyor.ConveyorSignalItem.DB521_Tasknum > 0) { if (con.button1.Tag.ToString() != "pall") { con.button1.BackgroundImage = Image.FromFile("Resources/Conveyor3.png");//1009R1_A.png con.button1.Tag = "pall"; } } else { if (con.button1.Tag.ToString() != "empty") { con.button1.BackgroundImage = Image.FromFile("Resources/1004LR.png");//1009R1.png con.button1.Tag = "empty"; } } if (conveyor.ConveyorSignalItem.DB523_Fault && con.button1.BackColor != Color.Red) { con.button1.BackColor = Color.Red; } if (conveyor.ConveyorSignalItem.DB523_Fault == false && con.button1.BackColor != Color.FromArgb(0, 144, 154)) { con.button1.BackColor = Color.FromArgb(0, 144, 154); } } private void SetConveyor_L(Control control, WCS_STACKERDATA conveyor) { var con = (Conveyor_L)control; if (conveyor.ConveyorSignalItem.DB521_Tasknum > 0) { if (con.button1.Tag.ToString() != "pall") { con.button1.BackgroundImage = Image.FromFile("Resources/Conveyor_L.png");//1009L11.png con.button1.Tag = "pall"; } } else { if (con.button1.Tag.ToString() != "empty") { con.button1.BackgroundImage = Image.FromFile("Resources/1009L11.png");//1009L11.png con.button1.Tag = "empty"; } } if (conveyor.ConveyorSignalItem.DB523_Fault && con.button1.BackColor != Color.Red) { con.button1.BackColor = Color.Red; } if (conveyor.ConveyorSignalItem.DB523_Fault == false && con.button1.BackColor != Color.FromArgb(0, 144, 154)) { con.button1.BackColor = Color.FromArgb(0, 144, 154); } } private void SetConveyor_R(Control control, WCS_STACKERDATA conveyor) { var con = (Conveyor_R)control; if (conveyor.ConveyorSignalItem.DB521_Tasknum > 0) { if (con.button1.Tag.ToString() != "pall") { con.button1.BackgroundImage = Image.FromFile("Resources/Conveyor_R.png");//1009L1.png con.button1.Tag = "pall"; } } else { if (con.button1.Tag.ToString() != "empty") { con.button1.BackgroundImage = Image.FromFile("Resources/1009L1.png");//1009L1.png con.button1.Tag = "empty"; } } if (conveyor.ConveyorSignalItem.DB523_Fault && con.button1.BackColor != Color.Red) { con.button1.BackColor = Color.Red; } if (conveyor.ConveyorSignalItem.DB523_Fault == false && con.button1.BackColor != Color.FromArgb(0, 144, 154)) { con.button1.BackColor = Color.FromArgb(0, 144, 154); } } private void SetConveyor(Control control, WCS_STACKERDATA conveyor) { var con = (Conveyor)control; if (conveyor.ConveyorSignalItem.DB521_Tasknum > 0) { if (con.button1.Tag.ToString() != "pall") { con.button1.BackgroundImage = Image.FromFile("Resources/Conveyor.png"); con.button1.Tag = "pall"; } } else { if (con.button1.Tag.ToString() != "empty") { con.button1.BackgroundImage = Image.FromFile("Resources/1009LR.png"); con.button1.Tag = "empty"; } } if (conveyor.ConveyorSignalItem.DB523_Fault && con.button1.BackColor != Color.Red) { con.button1.BackColor = Color.Red; } if (conveyor.ConveyorSignalItem.DB523_Fault == false && con.button1.BackColor != Color.FromArgb(0, 144, 154)) { con.button1.BackColor = Color.FromArgb(0, 144, 154); } } private void SetConveyor4_left(Control control, WCS_STACKERDATA conveyor) { var con = (Conveyor4_left)control; if (conveyor.ConveyorSignalItem.DB521_Tasknum > 0) { if (con.button1.Tag.ToString() != "pall") { con.button1.BackgroundImage = Image.FromFile("Resources/Conveyor4_left.png"); con.button1.Tag = "pall"; } } else { if (con.button1.Tag.ToString() != "empty") { con.button1.BackgroundImage = Image.FromFile("Resources/1001L.gif"); con.button1.Tag = "empty"; } } if (conveyor.ConveyorSignalItem.DB523_Fault && con.button1.BackColor != Color.Red) { con.button1.BackColor = Color.Red; } if (conveyor.ConveyorSignalItem.DB523_Fault == false && con.button1.BackColor != Color.FromArgb(0, 144, 154)) { con.button1.BackColor = Color.FromArgb(0, 144, 154); } } private void SetConveyor4_right(Control control, WCS_STACKERDATA conveyor) { var con = (Conveyor4_right)control; if (conveyor.ConveyorSignalItem.DB521_Tasknum > 0) { if (con.button1.Tag.ToString() != "pall") { con.button1.BackgroundImage = Image.FromFile("Resources/Conveyor4_right.png"); con.button1.Tag = "pall"; } } else { if (con.button1.Tag.ToString() != "empty") { con.button1.BackgroundImage = Image.FromFile("Resources/1001LR.gif"); con.button1.Tag = "empty"; } } if (conveyor.ConveyorSignalItem.DB523_Fault && con.button1.BackColor != Color.Red) { con.button1.BackColor = Color.Red; } if (conveyor.ConveyorSignalItem.DB523_Fault == false && con.button1.BackColor != Color.FromArgb(0, 144, 154)) { con.button1.BackColor = Color.FromArgb(0, 144, 154); } } private void SetConveyor4_L_R(Control control, WCS_STACKERDATA conveyor) { var con = (Conveyor4_L_R)control; if (conveyor.ConveyorSignalItem.DB521_Tasknum > 0) { if (con.button1.Tag.ToString() != "pall") { con.button1.BackgroundImage = Image.FromFile("Resources/Conveyor4_L_R.png"); con.button1.Tag = "pall"; } } else { if (con.button1.Tag.ToString() != "empty") { con.button1.BackgroundImage = Image.FromFile("Resources/1001LR.gif"); con.button1.Tag = "empty"; } } if (conveyor.ConveyorSignalItem.DB523_Fault && con.button1.BackColor != Color.Red) { con.button1.BackColor = Color.Red; } if (conveyor.ConveyorSignalItem.DB523_Fault == false && con.button1.BackColor != Color.FromArgb(0, 144, 154)) { con.button1.BackColor = Color.FromArgb(0, 144, 154); } } private void SetConveyor5(Control control, WCS_STACKERDATA conveyor) { var con = (Conveyor5)control; if (conveyor.ConveyorSignalItem.DB521_Tasknum > 0) { if (con.button1.Tag.ToString() != "pall") { con.button1.BackgroundImage = Image.FromFile("Resources/rgv03.png"); con.button1.Tag = "pall"; } } else { if (con.button1.Tag.ToString() != "empty") { con.button1.BackgroundImage = Image.FromFile("Resources/shelf16UD1.png"); con.button1.Tag = "empty"; } } if (conveyor.ConveyorSignalItem.DB523_Fault && con.button1.BackColor != Color.Red) { con.button1.BackColor = Color.Red; } if (conveyor.ConveyorSignalItem.DB523_Fault == false && con.button1.BackColor != Color.FromArgb(0, 144, 154)) { con.button1.BackColor = Color.FromArgb(0, 144, 154); } } private void SetConveyor6(Control control, WCS_STACKERDATA conveyor) { var con = (Conveyor6)control; if (conveyor.ConveyorSignalItem.DB521_Tasknum > 0) { if (con.button1.Tag.ToString() != "pall") { con.button1.BackgroundImage = Image.FromFile("Resources/Rgv02.png"); con.button1.Tag = "pall"; } } else { if (con.button1.Tag.ToString() != "empty") { con.button1.BackgroundImage = Image.FromFile("Resources/shelf16UD.png"); con.button1.Tag = "empty"; } } if (conveyor.ConveyorSignalItem.DB523_Fault && con.button1.BackColor != Color.Red) { con.button1.BackColor = Color.Red; } if (conveyor.ConveyorSignalItem.DB523_Fault == false && con.button1.BackColor != Color.FromArgb(0, 144, 154)) { con.button1.BackColor = Color.FromArgb(0, 144, 154); } } private void SetRgv02(Control control, WCS_STACKERDATA rgv) { var con = (Rgv02)control; if (con.Name == "rgv01") { //var tablecelllabel1 = new TableCellLabel2(); //tablecelllabel1.Dock = DockStyle.Fill; //tablecelllabel1.Name = "tableCellLabel23"; //var tablecelllabel2 = new TableCellLabel2(); //tablecelllabel2.Dock = DockStyle.Fill; //tablecelllabel2.Name = "tableCellLabel27"; //int column = myTableLayoutPanel1.GetColumn(con); //int rgvposCout = 18; ////int rgvrunpos = 18; //int rgvrunpos = GetRgv01Pos(rgv.RGVSignalItem.DB522_Position_1, 8, 220000, 11, true); //if (column != rgvrunpos) //{ // myTableLayoutPanel1.Controls.Remove(con); // var tablecelllabelSet = myTableLayoutPanel1.Controls.Find("tableCellLabel23", false).ToList(); // if (tablecelllabelSet.Count > 0) // { // myTableLayoutPanel1.Controls.Remove(tablecelllabelSet[0]); // } // tablecelllabelSet = myTableLayoutPanel1.Controls.Find("tableCellLabel27", false).ToList(); // if (tablecelllabelSet.Count > 0) // { // myTableLayoutPanel1.Controls.Remove(tablecelllabelSet[0]); // } // myTableLayoutPanel1.Controls.Add(con, rgvrunpos, 2); // if (rgvrunpos == 9) // { // myTableLayoutPanel1.Controls.Add(tablecelllabel2, rgvrunpos + 2, 2); // myTableLayoutPanel1.SetColumnSpan(tablecelllabel2, rgvposCout - rgvrunpos); // } // else if (rgvrunpos == 18) // { // myTableLayoutPanel1.Controls.Add(tablecelllabel1, 9, 2); // myTableLayoutPanel1.SetColumnSpan(tablecelllabel1, rgvrunpos - 9); // } // else // { // myTableLayoutPanel1.Controls.Add(tablecelllabel2, rgvrunpos + 2, 2); // myTableLayoutPanel1.SetColumnSpan(tablecelllabel2, rgvposCout - rgvrunpos); // myTableLayoutPanel1.Controls.Add(tablecelllabel1, 9, 2); // myTableLayoutPanel1.SetColumnSpan(tablecelllabel1, rgvrunpos - 9); // } //} if (rgv.RGVSignalItem.DB522_PH_Status_1) { if (con.btn01.Tag.ToString() != "pall") { con.btn01.BackgroundImage = Image.FromFile("Resources/Rgv02.png"); con.btn01.Tag = "pall"; } } else { if (con.btn01.Tag.ToString() != "empty") { con.btn01.BackgroundImage = Image.FromFile("Resources/shelf16UD.png"); con.btn01.Tag = "empty"; } } if (rgv.RGVSignalItem.DB522_PH_Status_2) { if (con.btn02.Tag.ToString() != "pall") { con.btn02.BackgroundImage = Image.FromFile("Resources/Rgv02.png"); con.btn02.Tag = "pall"; } } else { if (con.btn02.Tag.ToString() != "empty") { con.btn02.BackgroundImage = Image.FromFile("Resources/shelf16UD.png"); con.btn02.Tag = "empty"; } } if (rgv.RGVSignalItem.DB522_Fault_1 && con.btn01.BackColor != Color.Red) { con.btn01.BackColor = Color.Red; } if (rgv.RGVSignalItem.DB522_Fault_2 == false && con.btn02.BackColor != Color.FromArgb(0, 144, 154)) { con.btn02.BackColor = Color.FromArgb(0, 144, 154); } } } private void SetRgv(Control control, WCS_STACKERDATA rgv) { var con = (Rgv)control; if (con.Name == "rgv02") { //var tablecelllabel1 = new TableCellLabel(); //tablecelllabel1.Dock = DockStyle.Fill; //tablecelllabel1.Name = "tableCellLabel1"; //var tablecelllabel2 = new TableCellLabel(); //tablecelllabel2.Dock = DockStyle.Fill; //tablecelllabel2.Name = "tableCellLabel12"; //int column = myTableLayoutPanel1.GetRow(con); //int rgvposCout = 19; //////int rgvrunpos = 16; //int rgvpositon_1 = rgv.RGVSignalItem.DB522_Position_1; //int rgvrunpos = GetRgv01Pos(rgvpositon_1, 3, 490000, 16, false); ////rgvrunpos = 3;//起点 ////rgvrunpos = 17;//终点 //if (column != rgvrunpos) //{ // myTableLayoutPanel1.Controls.Remove(con); // var tablecelllabelSet = myTableLayoutPanel1.Controls.Find("tableCellLabel1", false).ToList(); // if (tablecelllabelSet.Count > 0) // { // myTableLayoutPanel1.Controls.Remove(tablecelllabelSet[0]); // } // tablecelllabelSet = myTableLayoutPanel1.Controls.Find("tableCellLabel12", false).ToList(); // if (tablecelllabelSet.Count > 0) // { // myTableLayoutPanel1.Controls.Remove(tablecelllabelSet[0]); // } // myTableLayoutPanel1.Controls.Add(con, 24, rgvrunpos); // if (rgvrunpos == 3) // { // myTableLayoutPanel1.Controls.Add(tablecelllabel2, 24, rgvrunpos + 2); // myTableLayoutPanel1.SetRowSpan(tablecelllabel2, rgvposCout - rgvrunpos - 2); // } // else if (rgvrunpos == 17) // { // myTableLayoutPanel1.Controls.Add(tablecelllabel1, 24, 3); // myTableLayoutPanel1.SetRowSpan(tablecelllabel1, rgvrunpos - 3); // } // else // { // myTableLayoutPanel1.Controls.Add(tablecelllabel1, 24, 3); // myTableLayoutPanel1.SetRowSpan(tablecelllabel1, rgvrunpos - 3); // myTableLayoutPanel1.Controls.Add(tablecelllabel2, 24, rgvrunpos + 2); // myTableLayoutPanel1.SetRowSpan(tablecelllabel2, rgvposCout - rgvrunpos - 2); // } //} SetRgvInfo(rgv, con); } else if (con.Name == "rgv03") { //var tablecelllabel1 = new TableCellLabel(); //tablecelllabel1.Dock = DockStyle.Fill; //tablecelllabel1.Name = "tableCellLabel15"; //var tablecelllabel2 = new TableCellLabel(); //tablecelllabel2.Dock = DockStyle.Fill; //tablecelllabel2.Name = "tableCellLabel18"; //int column = myTableLayoutPanel1.GetRow(con); //int rgvposCout = 20; //////int rgvrunpos = 18; //int rgvpositon_1 = rgv.RGVSignalItem.DB522_Position_1 + 300; //int rgvrunpos = GetRgv01Pos(rgvpositon_1, 4, 240300, 15, true); //if (column != rgvrunpos) //{ // myTableLayoutPanel1.Controls.Remove(con); // var tablecelllabelSet = myTableLayoutPanel1.Controls.Find("tableCellLabel15", false).ToList(); // if (tablecelllabelSet.Count > 0) // { // myTableLayoutPanel1.Controls.Remove(tablecelllabelSet[0]); // } // tablecelllabelSet = myTableLayoutPanel1.Controls.Find("tableCellLabel18", false).ToList(); // if (tablecelllabelSet.Count > 0) // { // myTableLayoutPanel1.Controls.Remove(tablecelllabelSet[0]); // } // myTableLayoutPanel1.Controls.Add(con, 2, rgvrunpos); // if (rgvrunpos == 5) // { // myTableLayoutPanel1.Controls.Add(tablecelllabel2, 2, rgvrunpos + 2); // myTableLayoutPanel1.SetRowSpan(tablecelllabel2, rgvposCout - rgvrunpos - 2); // } // else if (rgvrunpos == 18) // { // myTableLayoutPanel1.Controls.Add(tablecelllabel1, 2, 5); // myTableLayoutPanel1.SetRowSpan(tablecelllabel1, rgvrunpos - 5); // } // else // { // myTableLayoutPanel1.Controls.Add(tablecelllabel1, 2, 5); // myTableLayoutPanel1.SetRowSpan(tablecelllabel1, rgvrunpos - 5); // myTableLayoutPanel1.Controls.Add(tablecelllabel2, 2, rgvrunpos + 2); // myTableLayoutPanel1.SetRowSpan(tablecelllabel2, rgvposCout - rgvrunpos - 2); // } //} SetRgvInfo(rgv, con); } else if (con.Name == "rgv04") { //var tablecelllabel1 = new TableCellLabel(); //tablecelllabel1.Dock = DockStyle.Fill; //tablecelllabel1.Name = "tableCellLabel16"; //var tablecelllabel2 = new TableCellLabel(); //tablecelllabel2.Dock = DockStyle.Fill; //tablecelllabel2.Name = "tableCellLabel41"; //int column = tableLayoutPanel1.GetRow(con); //int rgvposCout = 19; //////int rgvrunpos = 18; //int rgvpositon_1 = rgv.RGVSignalItem.DB522_Position_1 + 8000; //int rgvrunpos = GetRgv01Pos(rgvpositon_1, 3, 238000, 15, false); ////rgvrunpos = 4;//起点 ////rgvrunpos = 17;//终点 //if (column != rgvrunpos) //{ // tableLayoutPanel1.Controls.Remove(con); // var tablecelllabelSet = tableLayoutPanel1.Controls.Find("tableCellLabel16", false).ToList(); // if (tablecelllabelSet.Count > 0) // { // tableLayoutPanel1.Controls.Remove(tablecelllabelSet[0]); // } // tablecelllabelSet = tableLayoutPanel1.Controls.Find("tableCellLabel41", false).ToList(); // if (tablecelllabelSet.Count > 0) // { // tableLayoutPanel1.Controls.Remove(tablecelllabelSet[0]); // } // tableLayoutPanel1.Controls.Add(con, 2, rgvrunpos); // if (rgvrunpos == 4) // { // tableLayoutPanel1.Controls.Add(tablecelllabel2, 2, rgvrunpos + 2); // tableLayoutPanel1.SetRowSpan(tablecelllabel2, rgvposCout - rgvrunpos - 2); // } // else if (rgvrunpos == 17) // { // tableLayoutPanel1.Controls.Add(tablecelllabel1, 2, 4); // tableLayoutPanel1.SetRowSpan(tablecelllabel1, rgvrunpos - 4); // } // else // { // tableLayoutPanel1.Controls.Add(tablecelllabel1, 2, 4); // tableLayoutPanel1.SetRowSpan(tablecelllabel1, rgvrunpos - 4); // tableLayoutPanel1.Controls.Add(tablecelllabel2, 2, rgvrunpos + 2); // tableLayoutPanel1.SetRowSpan(tablecelllabel2, rgvposCout - rgvrunpos - 2); // } //} SetRgvInfo(rgv, con); } } private static void SetRgvInfo(WCS_STACKERDATA rgv, Rgv con) { if (rgv.RGVSignalItem.DB522_PH_Status_1) { if (con.btn01.Tag.ToString() != "pall") { con.btn01.BackgroundImage = Image.FromFile("Resources/rgv03.png"); con.btn01.Tag = "pall"; } } else { if (con.btn01.Tag.ToString() != "empty") { con.btn01.BackgroundImage = Image.FromFile("Resources/shelf16UD1.png"); con.btn01.Tag = "empty"; } } if (rgv.RGVSignalItem.DB522_PH_Status_2) { if (con.btn02.Tag.ToString() != "pall") { con.btn02.BackgroundImage = Image.FromFile("Resources/rgv03.png"); con.btn02.Tag = "pall"; } } else { if (con.btn02.Tag.ToString() != "empty") { con.btn02.BackgroundImage = Image.FromFile("Resources/shelf16UD1.png"); con.btn02.Tag = "empty"; } } if (rgv.RGVSignalItem.DB522_Fault_1 && con.btn01.BackColor != Color.Red) { con.btn01.BackColor = Color.Red; } if (rgv.RGVSignalItem.DB522_Fault_2 == false && con.btn02.BackColor != Color.FromArgb(0, 144, 154)) { con.btn02.BackColor = Color.FromArgb(0, 144, 154); } } private static void SetSrmInfo(WCS_STACKERDATA srm, Control con) { var srmitem = (Srm3)con; if (srm.SrmSignalItem.SrmDB541_Alarm && srmitem.BackColor != Color.Red) { srmitem.button1.BackColor = Color.Red; } if (srm.SrmSignalItem.SrmDB541_Alarm && srmitem.BackColor != Color.FromArgb(0, 144, 154)) { srmitem.button1.BackColor = Color.FromArgb(0, 144, 154); } } protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); if (_timer != null) { _timer.Stop(); _timer.Dispose(); } System.GC.Collect(); } /// /// 计算RGV要移动的位置 /// /// rgv当前位置长度 /// 偏移量 /// rgv轨道长度 /// rgv轨道位置总数 /// 是否取AGV反位置 /// private int GetRgv01Pos(int rgvCurPosLength, int offsets,int rgvTracklength,int rgvTrackPosCount,bool isGetRgvPosBack) { //取rgv当前位置 int rgvpos = rgvCurPosLength; if (isGetRgvPosBack) { rgvpos = rgvTracklength - rgvCurPosLength; } //单个位置长度 int OnePosLength = rgvTracklength / rgvTrackPosCount; int OnePosNum = rgvpos / OnePosLength; if ((rgvpos % OnePosLength) > 0) { if (isGetRgvPosBack==false) { OnePosNum = OnePosNum + 1; } } if (OnePosNum == 0) OnePosNum++; return OnePosNum + offsets; } } }