public void RefreshControl02(CraneStatusBase theCraneStatusBase) { try { craneStatusBase = theCraneStatusBase; craneinfo.craneOrderInfo02(craneStatusBase.CraneNO.ToString(), txt_ORDER_TYPE, txt_MAT_NO_1, txt_MAT_NO_2, txt_TO_STOCK_NO, txt_FROM_STOCK_NO); } catch { } }
public void RefreshControl01(CraneStatusBase theCraneStatusBase) { try { craneStatusBase = theCraneStatusBase; ///安全门1 // lab1 .Text = craneStatusBase.Safe_door1.ToString(); if (craneStatusBase.Safe_door1.ToString() == "1") { this.lab1.BackColor = System.Drawing.Color.Red; this.lab1.ForeColor = System.Drawing.Color.White; this.lab1.Text = "开"; } else if (craneStatusBase.Safe_door1.ToString() == "0") { this.lab1.BackColor = System.Drawing.Color.Lime; this.lab1.ForeColor = System.Drawing.Color.Black; this.lab1.Text = "关"; } else { this.lab1.BackColor = System.Drawing.Color.Red; this.lab1.ForeColor = System.Drawing.Color.White; this.lab1.Text = "未知"; } ///安全门2 // lab2.Text = craneStatusBase.Safe_door2.ToString(); if (craneStatusBase.Safe_door2.ToString() == "1") { this.lab2.BackColor = System.Drawing.Color.Red; this.lab2.ForeColor = System.Drawing.Color.White; this.lab2.Text = "开"; } else if (craneStatusBase.Safe_door2.ToString() == "0") { this.lab2.BackColor = System.Drawing.Color.Lime; this.lab2.ForeColor = System.Drawing.Color.Black; this.lab2.Text = "关"; } else { this.lab2.BackColor = System.Drawing.Color.Red; this.lab2.ForeColor = System.Drawing.Color.White; this.lab2.Text = "未知"; } ///安全门3 //lab3.Text = craneStatusBase.Safe_door3.ToString(); if (craneStatusBase.Safe_door3.ToString() == "1") { this.lab3.BackColor = System.Drawing.Color.Red; this.lab3.ForeColor = System.Drawing.Color.White; this.lab3.Text = "开"; } else if (craneStatusBase.Safe_door3.ToString() == "0") { this.lab3.BackColor = System.Drawing.Color.Lime; this.lab3.ForeColor = System.Drawing.Color.Black; this.lab3.Text = "关"; } else { this.lab3.BackColor = System.Drawing.Color.Red; this.lab3.ForeColor = System.Drawing.Color.White; this.lab3.Text = "未知"; } ///安全门4 // lab4.Text = craneStatusBase.Safe_door4.ToString(); if (craneStatusBase.Safe_door4.ToString() == "1") { this.lab4.BackColor = System.Drawing.Color.Red; this.lab4.ForeColor = System.Drawing.Color.White; this.lab4.Text = "开"; } else if (craneStatusBase.Safe_door4.ToString() == "0") { this.lab4.BackColor = System.Drawing.Color.Lime; this.lab4.ForeColor = System.Drawing.Color.Black; this.lab4.Text = "关"; } else { this.lab4.BackColor = System.Drawing.Color.Red; this.lab4.ForeColor = System.Drawing.Color.White; this.lab4.Text = "未知"; } } catch { } }
//step3 public void RefreshControl(CraneStatusBase theCraneStatusBase) { try { craneStatusBase = theCraneStatusBase; //行车号 lbl_CraneNo.Text = "行车 " + craneStatusBase.CraneNO.ToString(); //准备好信号灯 refresh_Textbox_Light(light_READY, craneStatusBase.Ready); //自动信号灯 if (craneStatusBase.ControlMode == 4) { refresh_Textbox_Light(light_CONTROL_MODE, 1); } else { refresh_Textbox_Light(light_CONTROL_MODE, 0); } //控制模式 txt_CONTROL_MODE.Text = craneStatusBase.CraneModeDesc(); //请求指令信号灯 refresh_Textbox_Light(light_ASK_PLAN, craneStatusBase.AskPlan); //x txt_XACT.Text = craneStatusBase.XAct.ToString("0,000"); //y txt_YACT.Text = craneStatusBase.YAct.ToString("0,000"); //z txt_ZACT.Text = craneStatusBase.ZAct.ToString("0,000"); //有坯信号灯 refresh_Textbox_Light(light_HAS_COIL, craneStatusBase.HasCoil); //行车状态 txt_CRANE_STATUS.Text = craneStatusBase.CraneStatusDesc(); //与行车通讯状态 if (lbl_HeartBeat.Text == craneStatusBase.ReceiveTime.ToString() && communicate_PLC_OK == true) { heatBeatCounter++; } if (lbl_HeartBeat.Text != craneStatusBase.ReceiveTime.ToString() && communicate_PLC_OK == true) { heatBeatCounter = 0; } else if (lbl_HeartBeat.Text != craneStatusBase.ReceiveTime.ToString() && communicate_PLC_OK == false) { heatBeatCounter = 0; communicate_PLC_OK = true; } if (heatBeatCounter >= 20 && communicate_PLC_OK == true) { communicate_PLC_OK = false; } if (communicate_PLC_OK) { lbl_HeartBeat.BackColor = Color.LightGreen; } else { lbl_HeartBeat.BackColor = Color.Red; } //时间心跳 lbl_HeartBeat.Text = craneStatusBase.ReceiveTime.ToString(); //行车指令 craneinfo.craneOrderInfo(craneStatusBase.CraneNO.ToString(), txt_CraneOrder, txt_CoilNo, txt_CoilNo1, txt_FromStock, txt_ToStock, txt_FromStockX, txt_FromStockY, txt_FromStockZ, txt_ToStockX, txt_ToStockY, txt_ToStockZ, txt_ObjectType, txt_CmdStatus, txt_OrderType); //if (txt_CONTROL_MODE.Text == "等待" && txt_CRANE_STATUS.Text == "999") //{ // btnShow.Visible = true; // if (!flag) // { // btnShow.BackColor = Color.Red; // flag = true; // } // else // { // btnShow.BackColor = System.Drawing.SystemColors.Control; // flag = false; // } // timer1.Enabled = true; //} //else //{ // timer1.Enabled = false; // btnShow.Visible = false; //} } catch (Exception ex) { LogManager.WriteProgramLog(ex.Message); LogManager.WriteProgramLog(ex.StackTrace); } }
public void RefreshControl(CraneStatusBase _cranePLCStatusBase, long baySpaceX, long baySpaceY, int panelWidth, int panelHeight, bool xAxisRight, bool yAxisDown, long craneWith, Panel panel) { try { cranePLCStatusBase = _cranePLCStatusBase; //计算X方向上的比例关系 double xScale = Convert.ToDouble(panelWidth) / Convert.ToDouble(baySpaceX); //计算控件行车中心X,区分为X坐标轴向左或者向右 double X = 0; //定义大车x坐标 double location_Crane_X = 0; //定义小车x坐标 double location_Crab_X = 0; //判断大车移动起始方向 if (xAxisRight == true) { //计算按比例占用宽度 X = Convert.ToDouble(_cranePLCStatusBase.XAct) * xScale; //计算大车按比例所占用移动宽度 location_Crane_X = Convert.ToDouble(_cranePLCStatusBase.XAct - craneWith / 2) * xScale; location_Crab_X = 0;//小车在行车panel内,所以永远为0 } else { //移动方向相反,计算占用宽度 X = (Convert.ToDouble(baySpaceX) - Convert.ToDouble(_cranePLCStatusBase.XAct)) * xScale; //移动方向相反,计算大车按比例所占用移动宽度 location_Crane_X = Convert.ToDouble(baySpaceX - (_cranePLCStatusBase.XAct + craneWith / 2)) * xScale; location_Crab_X = 0;//在行车panel内,所以永远为0 } //计算Y方向的比例关系 double yScale = Convert.ToDouble(panelHeight) / Convert.ToDouble(baySpaceY); //计算行车中心Y 区分Y坐标轴向上或者向下 double Y = 0; double location_Crane_Y = 0; double location_Crab_Y = 0; //判断位移起始方向 if (yAxisDown == true) { //按比例计算位移 Y = Convert.ToDouble(_cranePLCStatusBase.YAct) * yScale; location_Crane_Y = 0;//大车移动距离 //计算小车移动距离 location_Crab_Y = Y - panelCrab.Height / 2; } else { //计算小车反方向移动距离 Y = (Convert.ToDouble(baySpaceY) - Convert.ToDouble(_cranePLCStatusBase.YAct)) * yScale; location_Crane_Y = 0; //实际小车反方向移动距离 location_Crab_Y = Y - panelCrab.Height * 1.3; } //修改行车大车控件的宽度和高度 this.Width = Convert.ToInt32(craneWith * xScale); this.Height = panelHeight;//大车的高度直接等于panel的高度 //定位大车的坐标 this.Location = new Point(Convert.ToInt32(location_Crane_X), Convert.ToInt32(location_Crane_Y)); //修改小车的宽度 panelCrab.Width = this.Width; //定位小车的坐标 panelCrab.Location = new Point(Convert.ToInt32(location_Crab_X), Convert.ToInt32(location_Crab_Y)); panelCrab.BringToFront(); //无坯显示无标记 if (_cranePLCStatusBase.HasCoil == 0) { this.panelCrab.BackgroundImage = global::UACSControls.Resource1.imgCarNoCoil; } //有坯显示有坯标记 else if (_cranePLCStatusBase.HasCoil == 1) { this.panelCrab.BackgroundImage = global::UACSControls.Resource1.imgCarCoil; } this.BringToFront(); Console.WriteLine("Crab,X:{0},Y:{1}", location_Crab_X, location_Crab_Y); //new add 20200508 if (_cranePLCStatusBase.ControlMode == 4) { if (_cranePLCStatusBase.HasCoil == 1 && _cranePLCStatusBase.PlanDownX != 999999 && _cranePLCStatusBase.PlanDownY != 999999) { lblPoint.Visible = true; lblPoint.BringToFront(); lblPointInfo.Visible = true; lblPointInfo.BringToFront(); lblPointInfo.Text = string.Format("X:{0}\nY{1}\nZ{2}", _cranePLCStatusBase.PlanDownX, _cranePLCStatusBase.PlanDownY, _cranePLCStatusBase.PlanDownZ); orderPoint.X = Convert.ToInt32(_cranePLCStatusBase.PlanDownX * xScale - lblPoint.Width / 2); orderPoint.Y = Convert.ToInt32(panel.Height - yScale * _cranePLCStatusBase.PlanDownY - lblPoint.Height / 2); orderPointInfo.X = Convert.ToInt32(_cranePLCStatusBase.PlanDownX * xScale - lblPoint.Width / 2 + lblPoint.Width); orderPointInfo.Y = Convert.ToInt32(panel.Height - yScale * _cranePLCStatusBase.PlanDownY - lblPoint.Height / 2 - lblPointInfo.Height); } else if (_cranePLCStatusBase.HasCoil == 0 && _cranePLCStatusBase.PlanUpX != 999999 && _cranePLCStatusBase.PlanUpY != 999999) { lblPoint.Visible = true; lblPoint.BringToFront(); lblPointInfo.Visible = true; lblPointInfo.BringToFront(); lblPointInfo.Text = string.Format("X:{0}\nY:{1}\nZ:{2}", _cranePLCStatusBase.PlanUpX, _cranePLCStatusBase.PlanUpY, _cranePLCStatusBase.PlanUpZ); orderPoint.X = Convert.ToInt32(_cranePLCStatusBase.PlanUpX * xScale - lblPoint.Width / 2); orderPoint.Y = Convert.ToInt32(panel.Height - yScale * _cranePLCStatusBase.PlanUpY - lblPoint.Height / 2); orderPointInfo.X = Convert.ToInt32(_cranePLCStatusBase.PlanUpX * xScale - lblPoint.Width / 2 + lblPoint.Width); orderPointInfo.Y = Convert.ToInt32(panel.Height - yScale * _cranePLCStatusBase.PlanUpY - lblPoint.Height / 2 - lblPointInfo.Height);; } else { orderPoint.X = 0; orderPoint.Y = 0; orderPointInfo.X = 0; orderPointInfo.Y = 0; lblPoint.Visible = false; lblPointInfo.Visible = false; lblPointInfo.Text = string.Empty; } } else { orderPoint.X = 0; orderPoint.Y = 0; orderPointInfo.X = 0; orderPointInfo.Y = 0; lblPoint.Visible = false; lblPointInfo.Visible = false; lblPointInfo.Text = string.Empty; } lblPoint.Location = orderPoint; lblPointInfo.Location = orderPointInfo; } catch (Exception ex) { LogManager.WriteProgramLog(ex.Message); LogManager.WriteProgramLog(ex.StackTrace); } }
public void RefreshControl(CraneStatusBase _cranePLCStatusBase, long baySpaceX, long baySpaceY, int panelWidth, int panelHeight, bool xAxisRight, bool yAxisDown, long craneWith, Panel panel) { try { cranePLCStatusBase = _cranePLCStatusBase; //计算X方向上的比例关系 double xScale = Convert.ToDouble(panelWidth) / Convert.ToDouble(baySpaceX); //计算控件行车中心X,区分为X坐标轴向左或者向右 double X = 0; double location_Crane_X = 0; double location_Crab_X = 0; if (xAxisRight == true) { X = Convert.ToDouble(_cranePLCStatusBase.XAct) * xScale; location_Crane_X = Convert.ToDouble(_cranePLCStatusBase.XAct - craneWith / 2) * xScale; location_Crab_X = 0;//在行车panel内,所以永远为0 } else { X = (Convert.ToDouble(baySpaceX) - Convert.ToDouble(_cranePLCStatusBase.XAct)) * xScale; location_Crane_X = Convert.ToDouble(baySpaceX - (_cranePLCStatusBase.XAct + craneWith / 2)) * xScale; location_Crab_X = 0;//在行车panel内,所以永远为0 } //计算Y方向的比例关系 double yScale = Convert.ToDouble(panelHeight) / Convert.ToDouble(baySpaceY); //计算行车中心Y 区分Y坐标轴向上或者向下 double Y = 0; double location_Crane_Y = 0; double location_Crab_Y = 0; if (yAxisDown == true) { Y = Convert.ToDouble(_cranePLCStatusBase.YAct) * yScale; location_Crane_Y = 0; location_Crab_Y = Y - panelCrab.Height / 2; } else { Y = (Convert.ToDouble(baySpaceY) - Convert.ToDouble(_cranePLCStatusBase.YAct)) * yScale; location_Crane_Y = 0; location_Crab_Y = Y - panelCrab.Height / 2; } //修改行车大车控件的宽度和高度 this.Width = Convert.ToInt32(craneWith * xScale); this.Height = panelHeight;//大车的高度直接等于panel的高度 //定位大车的坐标 this.Location = new Point(Convert.ToInt32(location_Crane_X), Convert.ToInt32(location_Crane_Y)); //修改小车的宽度 panelCrab.Width = this.Width; //定位小车的坐标 panelCrab.Location = new Point(Convert.ToInt32(location_Crab_X), Convert.ToInt32(location_Crab_Y)); panelCrab.BringToFront(); //无卷显示无卷标记 if (_cranePLCStatusBase.HasCoil == 0) { this.panelCrab.BackgroundImage = global::UACSControls.Resource1.imgCarNoCoil; } //有卷显示有卷标记 else if (_cranePLCStatusBase.HasCoil == 1) { this.panelCrab.BackgroundImage = global::UACSControls.Resource1.imgCarCoil; } this.BringToFront(); } catch (Exception ex) { LogManager.WriteProgramLog(ex.Message); LogManager.WriteProgramLog(ex.StackTrace); } }