private void panelCrane_Paint(object sender, PaintEventArgs e) { //行车标识 Graphics gr = e.Graphics; gr.DrawString(cranePLCStatusBase.CraneNO.ToString(), new Font("微软雅黑", 10, FontStyle.Bold), Brushes.White, new Point(5, this.Height - 20)); //显示行车所属状态 Graphics gt = e.Graphics; gt.DrawString(cranePLCStatusBase.CraneModeDesc().ToString(), new Font("微软雅黑", 10, FontStyle.Bold), Brushes.Yellow, new Point(30, this.Height - 20)); }
//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); } }