public void OnCraneDeploymentStarted(CratesGame sender, CraneEventArgs e) { if (sender.State == GameState.Running) { OnCraneMovementStarted(sender, e); } }
public void OnCraneDeploymentFinished(CratesGame sender, CraneEventArgs e) { if (sender.State == GameState.Running || sender.State == GameState.Completed || sender.State == GameState.Aborted) { OnCraneMovementStopped(sender, e); } }
void Monitor_OnCrane(CraneEventArgs args) { if (InvokeRequired) { BeginInvoke(new CraneEventHandler(Monitor_OnCrane), args); } else { Crane crane = args.crane; TextBox txt = GetTextBox("txtColumn", crane.CraneNo); PictureBox pic = GetPictureBox("picCrane", crane.CraneNo.ToString()); if (txt != null && pic != null) { int X = 1476; if (crane.Column == 0) { X = 1484; } int Y = 345; Point P = new Point(); P.X = X - (int)(crane.Column * 35.67F); P.Y = Y - (crane.CraneNo - 1) * 75; pic.Location = P; } } }
public void OnCraneMovementStarted(CratesGame sender, CraneEventArgs e) { if (sender.State == GameState.Running) { craneMoving = true; StartCoroutine(craneMovementStart()); } }
public void OnCraneMovementStopped(CratesGame sender, CraneEventArgs e) { if (sender.State == GameState.Running || sender.State == GameState.Completed || sender.State == GameState.Aborted) { audio.StopSound(21); audio.StopSound(22); audio.PlaySound(23); craneMoving = false; } }
void Monitor_OnCrane(CraneEventArgs args) { if (InvokeRequired) { BeginInvoke(new CraneEventHandler(Monitor_OnCrane), args); } else { Crane crane = args.crane; try { SetTextBoxText("txtMode{0}", crane.CraneNo, dicCraneMode[crane.Mode]); SetTextBoxText("txtState{0}1", crane.CraneNo, dicCraneState[crane.State1]); SetTextBoxText("txtFork{0}1", crane.CraneNo, dicCraneFork[crane.Fork1]); SetTextBoxText("txtTaskNo{0}1", crane.CraneNo, crane.TaskNo1); string strErrMsg = ""; if (crane.AlarmCode > 0) { DataRow[] drs = dtDeviceAlarm.Select(string.Format("Flag=1 and AlarmCode={0}", crane.AlarmCode)); if (drs.Length > 0) strErrMsg = drs[0]["AlarmDesc"].ToString(); else strErrMsg = "设备未知错误!"; SetControlColor("txtAlarmCode{0}", crane.CraneNo, Color.Red); SetControlColor("btnClearAlarm{0}", crane.CraneNo, Color.Red); } else { SetControlColor("txtAlarmCode{0}", crane.CraneNo, SystemColors.Control); SetControlColor("btnClearAlarm{0}", crane.CraneNo, SystemColors.Control); } if (int.Parse(crane.Station[0].ToString()) < 7) { Point P = new Point(); P = P2; P.X = dicLocationX[int.Parse(crane.Station[0].ToString())]; pictureBox2.Location = P; } SetTextBoxText("txtAlarmCode{0}", crane.CraneNo, crane.AlarmCode.ToString()); SetTextBoxText("txtAlarmDesc{0}", crane.CraneNo, strErrMsg); SetTextBoxText("txtColumn{0}", crane.CraneNo, crane.Station[0].ToString()); SetTextBoxText("txtRow{0}", crane.CraneNo, crane.Station[1].ToString()); } catch (Exception ex) { MCP.Logger.Error("监控界面中Monitor_OnCrane出现异常,错误内容:" + ex.Message); } } }
void Monitor_OnCrane(CraneEventArgs args) { if (InvokeRequired) { BeginInvoke(new CraneEventHandler(Monitor_OnCrane), args); } else { Crane crane = args.crane; TextBox txt = GetTextBox("txtTaskNo", crane.CraneNo); if (txt != null) { txt.Text = crane.TaskNo; } txt = GetTextBox("txtState", crane.CraneNo); if (txt != null && dicCraneState.ContainsKey(crane.TaskType)) { txt.Text = dicCraneState[crane.TaskType]; } txt = GetTextBox("txtCraneAction", crane.CraneNo); if (txt != null && dicCraneAction.ContainsKey(crane.Action)) { txt.Text = dicCraneAction[crane.Action]; } txt = GetTextBox("txtRow", crane.CraneNo); if (txt != null) { txt.Text = crane.Row.ToString(); } txt = GetTextBox("txtColumn", crane.CraneNo); if (txt != null) { txt.Text = crane.Column.ToString(); } //堆垛机位置 if (crane.CraneNo == 1) { this.picCrane.Visible = true; Point P1 = InitialP1; if (crane.Column < 46) { P1.X = P1.X + (int)((crane.Column - 1) * colDis); } else { P1.X = picCar.Location.X + 15; } P1.Y = P1.Y + (int)(rowDis * (crane.Row - 1)); this.picCrane.Location = P1; Point P2 = InitialP2; P2.Y = P2.Y + (int)(rowDis * (crane.Row - 1)); this.picCar.Location = P2; } txt = GetTextBox("txtHeight", crane.CraneNo); if (txt != null) { txt.Text = crane.Height.ToString(); } txt = GetTextBox("txtForkStatus", crane.CraneNo); if (txt != null && dicCraneFork.ContainsKey(crane.ForkStatus)) { txt.Text = dicCraneFork[crane.ForkStatus]; } txt = GetTextBox("txtErrorNo", crane.CraneNo); if (txt != null) { txt.Text = crane.ErrCode.ToString(); } string strError = ""; txt = GetTextBox("txtErrorDesc", crane.CraneNo); if (txt != null) { if (crane.ErrCode != 0) { DataRow[] drs = dtCraneErr.Select(string.Format("CraneErrCode={0}", crane.ErrCode)); if (drs.Length > 0) { strError = drs[0]["CraneErrDesc"].ToString(); } else { strError = "堆垛机未知错误!"; } } else { strError = ""; } txt.Text = strError; } //更新错误代码、错误描述 //更新任务状态为执行中 //bll.ExecNonQuery("WCS.UpdateTaskError", new DataParameter[] { new DataParameter("@CraneErrCode", crane.ErrCode.ToString()), new DataParameter("@CraneErrDesc", dicCraneError[crane.ErrCode]), new DataParameter("@TaskNo", crane.TaskNo) }); if (crane.ErrCode > 0) { DataParameter[] param = new DataParameter[] { new DataParameter("@TaskNo", crane.TaskNo), new DataParameter("@CraneErrCode", crane.ErrCode.ToString()), new DataParameter("@CraneErrDesc", strError) }; bll.ExecNonQueryTran("WCS.Sp_UpdateTaskError", param); Logger.Error(crane.CraneNo.ToString() + "堆垛机执行时出现错误,代码:" + crane.ErrCode.ToString() + ",描述:" + strError); } } }
void Monitor_OnCrane(CraneEventArgs args) { if (InvokeRequired) { BeginInvoke(new CraneEventHandler(Monitor_OnCrane), args); } else { Crane crane = args.crane; try { if (crane.Mode != null) { SetTextBoxText("txtMode{0}", crane.CraneNo, dicCraneMode[crane.Mode]); } if (crane.State != null) { SetTextBoxText("txtState{0}", crane.CraneNo, dicCraneState[crane.State]); } if (crane.Fork != null) { SetTextBoxText("txtFork{0}", crane.CraneNo, dicCraneFork[crane.Fork]); } if (crane.TaskNo == null) { crane.TaskNo = ""; } SetTextBoxText("txtTaskNo{0}", crane.CraneNo, crane.TaskNo); string strErrMsg = ""; if (crane.AlarmCode != null) { if (crane.AlarmCode > 0) { DataRow[] drs = dtDeviceAlarm.Select(string.Format("Flag=1 and AlarmCode={0}", crane.AlarmCode)); if (drs.Length > 0) { strErrMsg = drs[0]["AlarmDesc"].ToString(); } else { strErrMsg = "設備未知錯誤!"; } SetControlColor("txtAlarmCode{0}", crane.CraneNo, Color.Red); SetControlColor("btnClearAlarm{0}", crane.CraneNo, Color.Red); } else { SetControlColor("txtAlarmCode{0}", crane.CraneNo, SystemColors.Control); SetControlColor("btnClearAlarm{0}", crane.CraneNo, SystemColors.Control); } } SetTextBoxText("txtAlarmCode{0}", crane.CraneNo, crane.AlarmCode.ToString()); SetTextBoxText("txtAlarmDesc{0}", crane.CraneNo, strErrMsg); SetTextBoxText("txtColumn{0}", crane.CraneNo, crane.Station[0].ToString()); SetTextBoxText("txtRow{0}", crane.CraneNo, crane.Station[1].ToString()); } catch (Exception ex) { MCP.Logger.Error("监控界面中Monitor_OnCrane出现异常UL" + crane.CraneNo + " 錯誤內容:" + ex.Message); } } }
void Monitor_OnCrane(CraneEventArgs args) { if (InvokeRequired) { BeginInvoke(new CraneEventHandler(Monitor_OnCrane), args); } else { Crane crane = args.crane; Button btn = GetButton(crane.CraneNo); TextBox txt = GetTextBox("txtTaskNo", crane.CraneNo); if (txt != null) { txt.Text = crane.TaskNo; } txt = GetTextBox("txtStatus", crane.CraneNo); if (txt != null && dicStatus.ContainsKey(crane.Status)) { txt.Text = dicStatus[crane.Status]; if (txt.Text == "空闲") { txt.BackColor = Color.Lime; } else { txt.BackColor = Color.Yellow; } } txt = GetTextBox("txtWorkMode", crane.CraneNo); if (txt != null && dicWorkMode.ContainsKey(crane.Mode)) { txt.Text = dicWorkMode[crane.Mode]; if (crane.Mode == 1) { txt.BackColor = Color.Lime; } else { txt.BackColor = Color.Yellow; } } if (crane.Mode == 1) { btn.BackColor = Color.Lime; } else { btn.BackColor = Color.Yellow; } txt = GetTextBox("txtRow", crane.CraneNo); if (txt != null) { txt.Text = crane.Row.ToString(); } txt = GetTextBox("txtColumn", crane.CraneNo); if (txt != null) { txt.Text = crane.Column.ToString(); } //堆垛机位置 if (crane.CraneNo == "05") { Point P = InitialP5; if (crane.Row == 6) { P = InitialP6; } else if (crane.Row == 7) { P = InitialP7; } P.X = P.X + (int)((45 - crane.Column) * colDis); this.btnSRM5.Location = P; } if (crane.CraneNo == "06") { Point P = InitialP6; if (crane.Row == 5) { P = InitialP5; } else if (crane.Row == 7) { P = InitialP7; } P.X = P.X + (int)((45 - crane.Column) * colDis); this.btnSRM6.Location = P; } if (crane.CraneNo == "07") { Point P = InitialP7; if (crane.Row == 5) { P = InitialP5; } else if (crane.Row == 6) { P = InitialP6; } P.X = P.X + (int)((45 - crane.Column) * colDis); this.btnSRM7.Location = P; } txt = GetTextBox("txtLayer", crane.CraneNo); if (txt != null) { txt.Text = crane.Layer.ToString(); } txt = GetTextBox("txtForkStatus", crane.CraneNo); if (txt != null && dicFork.ContainsKey(crane.ForkStatus)) { txt.Text = dicFork[crane.ForkStatus]; } txt = GetTextBox("txtAlarmCode", crane.CraneNo); if (txt != null) { txt.Text = crane.AlarmCode.ToString(); if (txt.Text == "0") { txt.BackColor = DefaultBackColor; } else { txt.BackColor = Color.Red; } } string strAlarmDesc = ""; txt = GetTextBox("txtAlarmDesc", crane.CraneNo); if (txt != null) { if (crane.AlarmCode != 0) { DataRow[] drs = dtDeviceAlarm.Select(string.Format("Flag=1 and AlarmCode={0}", crane.AlarmCode)); if (drs.Length > 0) { strAlarmDesc = drs[0]["AlarmDesc"].ToString(); } else { strAlarmDesc = "设备未知错误!"; } } else { strAlarmDesc = ""; } txt.Text = strAlarmDesc; if (txt.Text == "") { txt.BackColor = DefaultBackColor; } else { txt.BackColor = Color.Red; } } txt = GetTextBox("txtSTB", crane.CraneNo); if (txt != null) { txt.Text = crane.STB.ToString(); } txt = GetTextBox("txtACK", crane.CraneNo); if (txt != null) { txt.Text = crane.ACK.ToString(); } //更新错误代码、错误描述 //更新任务状态为执行中 //bll.ExecNonQuery("WCS.UpdateTaskError", new DataParameter[] { new DataParameter("@CraneErrCode", crane.ErrCode.ToString()), new DataParameter("@CraneErrDesc", dicCraneError[crane.ErrCode]), new DataParameter("@TaskNo", crane.TaskNo) }); if (crane.AlarmCode > 0) { btn.BackColor = Color.Red; //DataParameter[] param = new DataParameter[] { new DataParameter("@TaskNo", crane.TaskNo), new DataParameter("@CraneErrCode", crane.AlarmCode.ToString()), new DataParameter("@CraneErrDesc", strAlarmDesc) }; //bll.ExecNonQueryTran("WCS.Sp_UpdateTaskError", param); //Logger.Error(crane.CraneNo.ToString() + "堆垛机执行时出现错误,代码:" + crane.AlarmCode.ToString() + ",描述:" + strAlarmDesc); } } }
void Monitor_OnCrane(CraneEventArgs args) { if (InvokeRequired) { BeginInvoke(new CraneEventHandler(Monitor_OnCrane), args); } else { Crane crane = args.crane; TextBox txt = GetTextBox("txtTaskNo", crane.CraneNo); if (txt != null) { txt.Text = crane.TaskNo; } txt = GetTextBox("txtTaskType", crane.CraneNo); if (txt != null && dicCraneTaskType.ContainsKey(crane.TaskType)) { txt.Text = dicCraneTaskType[crane.TaskType]; } txt = GetTextBox("txtCraneAction", crane.CraneNo); if (txt != null && dicCraneAction.ContainsKey(crane.Action)) { txt.Text = dicCraneAction[crane.Action]; } txt = GetTextBox("txtColumn", crane.CraneNo); if (txt != null) { txt.Text = crane.Column.ToString(); } if (crane.WalkCode > 0) { txt = GetTextBox("txtBpWalkCode", crane.CraneNo); if (txt != null) { txt.Text = crane.WalkCode.ToString(); txt.BackColor = Color.Red; } } else { txt = GetTextBox("txtBpWalkCode", crane.CraneNo); if (txt != null) { txt.Text = ""; txt.BackColor = Control.DefaultBackColor; } } if (crane.UpDownCode > 0) { txt = GetTextBox("txtBpUpDownCode", crane.CraneNo); if (txt != null) { txt.Text = crane.UpDownCode.ToString(); txt.BackColor = Color.Red; } } else { txt = GetTextBox("txtBpUpDownCode", crane.CraneNo); if (txt != null) { txt.Text = ""; txt.BackColor = Control.DefaultBackColor; } } //堆垛机位置 if (crane.CraneNo == 1) { if (crane.Column < 7) { this.picCrane11.Visible = true; this.picCrane12.Visible = false; Point P1 = InitialP1; P1.X = P1.X - (crane.Column - 1) * columnDis1; this.picCrane11.Location = P1; } else { this.picCrane11.Visible = false; this.picCrane12.Visible = true; Point P3 = InitialP3; P3.X = P3.X - (12 - crane.Column) * columnDis2; this.picCrane12.Location = P3; } } else { Point P2 = InitialP2; P2.X = P2.X - (crane.Column - 1) * columnDis3; this.picCrane2.Location = P2; } txt = GetTextBox("txtHeight", crane.CraneNo); if (txt != null) { txt.Text = crane.Height.ToString(); } txt = GetTextBox("txtForkStatus", crane.CraneNo); if (txt != null && dicCraneFork.ContainsKey(crane.ForkStatus)) { txt.Text = dicCraneFork[crane.ForkStatus]; } txt = GetTextBox("txtErrorNo", crane.CraneNo); if (txt != null) { txt.Text = crane.ErrCode.ToString(); } txt = GetTextBox("txtErrorDesc", crane.CraneNo); if (txt != null && dicCraneError.ContainsKey(crane.ErrCode)) { txt.Text = dicCraneError[crane.ErrCode]; } //更新错误代码、错误描述 //更新任务状态为执行中 bll.ExecNonQuery("WCS.UpdateTaskError", new DataParameter[] { new DataParameter("@CraneErrCode", crane.ErrCode.ToString()), new DataParameter("@CraneErrDesc", dicCraneError[crane.ErrCode]), new DataParameter("@TaskNo", crane.TaskNo) }); if (crane.ErrCode > 0) { Logger.Error(crane.CraneNo.ToString() + "堆垛机执行时出现错误,代码:" + crane.ErrCode.ToString() + ",描述:" + dicCraneError[crane.ErrCode]); } } }
void Monitor_OnCrane(CraneEventArgs args) { if (InvokeRequired) { BeginInvoke(new CraneEventHandler(Monitor_OnCrane), args); } else { Crane crane = args.crane; TextBox txt = GetTextBox("txtTaskNo", crane.CraneNo); if (txt != null) txt.Text = crane.TaskNo; txt = GetTextBox("txtState", crane.CraneNo); if (txt != null && dicCraneState.ContainsKey(crane.TaskType)) txt.Text = dicCraneState[crane.TaskType]; txt = GetTextBox("txtCraneAction", crane.CraneNo); if (txt != null && dicCraneAction.ContainsKey(crane.Action)) txt.Text = dicCraneAction[crane.Action]; txt = GetTextBox("txtRow", crane.CraneNo); if (txt != null) txt.Text = crane.Row.ToString(); txt = GetTextBox("txtColumn", crane.CraneNo); if (txt != null) txt.Text = crane.Column.ToString(); //堆垛机位置 if (crane.CraneNo == 1) { this.picCrane.Visible = true; Point P1 = InitialP1; if(crane.Column<46) P1.X = P1.X + (int)((crane.Column-1) * colDis); else P1.X = picCar.Location.X+15; P1.Y = P1.Y + (int)(rowDis * (crane.Row - 1)); this.picCrane.Location = P1; Point P2 = InitialP2; P2.Y = P2.Y + (int)(rowDis * (crane.Row - 1)); this.picCar.Location = P2; } txt = GetTextBox("txtHeight", crane.CraneNo); if (txt != null) txt.Text = crane.Height.ToString(); txt = GetTextBox("txtForkStatus", crane.CraneNo); if (txt != null && dicCraneFork.ContainsKey(crane.ForkStatus)) txt.Text = dicCraneFork[crane.ForkStatus]; txt = GetTextBox("txtErrorDesc", crane.CraneNo); if (txt != null && dicCraneError.ContainsKey(crane.ErrCode)) txt.Text = dicCraneError[crane.ErrCode]; //更新错误代码、错误描述 //更新任务状态为执行中 //bll.ExecNonQuery("WCS.UpdateTaskError", new DataParameter[] { new DataParameter("@CraneErrCode", crane.ErrCode.ToString()), new DataParameter("@CraneErrDesc", dicCraneError[crane.ErrCode]), new DataParameter("@TaskNo", crane.TaskNo) }); txt = GetTextBox("txtErrorNo", crane.CraneNo); if (txt != null) { if (crane.ErrCode > 0) { DataParameter[] param = new DataParameter[] { new DataParameter("@TaskNo", crane.TaskNo), new DataParameter("@CraneErrCode", crane.ErrCode.ToString()), new DataParameter("@CraneErrDesc", dicCraneError[crane.ErrCode]) }; bll.ExecNonQueryTran("WCS.Sp_UpdateTaskError", param); if (txt.Text.Trim() == "") txt.Text = "0"; if (crane.ErrCode != int.Parse(txt.Text)) Logger.Error(crane.CraneNo.ToString() + "堆垛机执行时出现错误,代码:" + crane.ErrCode.ToString() + ",描述:" + dicCraneError[crane.ErrCode]); txt.Text = crane.ErrCode.ToString(); } else { txt.Text = "0"; } } } }
void Monitor_OnCrane(CraneEventArgs args) { if (InvokeRequired) { BeginInvoke(new CraneEventHandler(Monitor_OnCrane), args); } else { Crane crane = args.crane; TextBox txt = GetTextBox("txtTaskNo", crane.CraneNo); if (txt != null) { txt.Text = crane.TaskNo; } txt = GetTextBox("txtState", crane.CraneNo); if (txt != null && dicCraneState.ContainsKey(crane.TaskType)) { txt.Text = dicCraneState[crane.TaskType]; } txt = GetTextBox("txtCraneAction", crane.CraneNo); if (txt != null && dicCraneAction.ContainsKey(crane.Action)) { txt.Text = dicCraneAction[crane.Action]; } txt = GetTextBox("txtRow", crane.CraneNo); if (txt != null) { txt.Text = crane.Row.ToString(); } txt = GetTextBox("txtColumn", crane.CraneNo); if (txt != null) { txt.Text = crane.Column.ToString(); } //堆垛机位置 if (crane.CraneNo == 1) { this.picCrane.Visible = true; Point P1 = InitialP1; if (crane.Column <= 6) { P1.X = P1.X - (int)((crane.Column - 1) * 57); } else { P1.X = P1.X - 320 - (int)((crane.Column - 7) * 33.9F); } this.picCrane.Location = P1; } txt = GetTextBox("txtHeight", crane.CraneNo); if (txt != null) { txt.Text = crane.Height.ToString(); } txt = GetTextBox("txtForkStatus", crane.CraneNo); if (txt != null && dicCraneFork.ContainsKey(crane.ForkStatus)) { txt.Text = dicCraneFork[crane.ForkStatus]; } txt = GetTextBox("txtErrorDesc", crane.CraneNo); if (txt != null && dicCraneError.ContainsKey(crane.ErrCode)) { if (crane.ErrCode > 0 && crane.ErrCode != 202 && crane.ErrCode != 203) { txt.Text = dicCraneError[crane.ErrCode]; } else { txt.Text = ""; } } //更新错误代码、错误描述 //更新任务状态为执行中 //bll.ExecNonQuery("WCS.UpdateTaskError", new DataParameter[] { new DataParameter("@CraneErrCode", crane.ErrCode.ToString()), new DataParameter("@CraneErrDesc", dicCraneError[crane.ErrCode]), new DataParameter("@TaskNo", crane.TaskNo) }); txt = GetTextBox("txtErrorNo", crane.CraneNo); if (txt != null) { if (crane.ErrCode > 0 && crane.ErrCode != 202 && crane.ErrCode != 203) { string strMsg = "未知错误!"; if (dicCraneError.ContainsKey(crane.ErrCode)) { strMsg = dicCraneError[crane.ErrCode]; } DataParameter[] param = new DataParameter[] { new DataParameter("@TaskNo", crane.TaskNo), new DataParameter("@CraneErrCode", crane.ErrCode.ToString()), new DataParameter("@CraneErrDesc", strMsg) }; bll.ExecNonQueryTran("WCS.Sp_UpdateTaskError", param); if (txt.Text.Trim() == "") { txt.Text = "0"; } if (crane.ErrCode != int.Parse(txt.Text)) { Logger.Error("堆垛机执行时出现错误,代码:" + crane.ErrCode.ToString() + ",描述:" + strMsg); } txt.Text = crane.ErrCode.ToString(); } else { txt.Text = "0"; } } } }
void Monitor_OnCrane(CraneEventArgs args) { if (InvokeRequired) { BeginInvoke(new CraneEventHandler(Monitor_OnCrane), args); } else { Crane crane = args.crane; TextBox txt = GetTextBox("txtTaskNo", crane.CraneNo); if (txt != null) txt.Text = crane.TaskNo; txt = GetTextBox("txtTaskType", crane.CraneNo); if (txt != null && dicCraneTaskType.ContainsKey(crane.TaskType)) txt.Text = dicCraneTaskType[crane.TaskType]; txt = GetTextBox("txtCraneAction", crane.CraneNo); if (txt != null && dicCraneAction.ContainsKey(crane.Action)) txt.Text = dicCraneAction[crane.Action]; txt = GetTextBox("txtColumn", crane.CraneNo); if (txt != null) txt.Text = crane.Column.ToString(); if (crane.WalkCode > 0) { txt = GetTextBox("txtBpWalkCode", crane.CraneNo); if (txt != null) { txt.Text = crane.WalkCode.ToString(); txt.BackColor = Color.Red; } } else { txt = GetTextBox("txtBpWalkCode", crane.CraneNo); if (txt != null) { txt.Text = ""; txt.BackColor = Control.DefaultBackColor; } } if (crane.UpDownCode > 0) { txt = GetTextBox("txtBpUpDownCode", crane.CraneNo); if (txt != null) { txt.Text = crane.UpDownCode.ToString(); txt.BackColor = Color.Red; } } else { txt = GetTextBox("txtBpUpDownCode", crane.CraneNo); if (txt != null) { txt.Text = ""; txt.BackColor = Control.DefaultBackColor; } } //堆垛机位置 if (crane.CraneNo == 1) { if (crane.Column < 7) { this.picCrane11.Visible = true; this.picCrane12.Visible = false; Point P1 = InitialP1; P1.X = P1.X - (crane.Column - 1) * columnDis1; this.picCrane11.Location = P1; } else { this.picCrane11.Visible = false; this.picCrane12.Visible = true; Point P3 = InitialP3; P3.X = P3.X - (12 - crane.Column) * columnDis2; this.picCrane12.Location = P3; } } else { Point P2 = InitialP2; P2.X = P2.X - (crane.Column - 1) * columnDis3; this.picCrane2.Location = P2; } txt = GetTextBox("txtHeight", crane.CraneNo); if (txt != null) txt.Text = crane.Height.ToString(); txt = GetTextBox("txtForkStatus", crane.CraneNo); if (txt != null && dicCraneFork.ContainsKey(crane.ForkStatus)) txt.Text = dicCraneFork[crane.ForkStatus]; txt = GetTextBox("txtErrorNo", crane.CraneNo); if (txt != null) txt.Text = crane.ErrCode.ToString(); txt = GetTextBox("txtErrorDesc", crane.CraneNo); if (txt != null && dicCraneError.ContainsKey(crane.ErrCode)) txt.Text = dicCraneError[crane.ErrCode]; //更新错误代码、错误描述 //更新任务状态为执行中 bll.ExecNonQuery("WCS.UpdateTaskError", new DataParameter[] { new DataParameter("@CraneErrCode", crane.ErrCode.ToString()), new DataParameter("@CraneErrDesc", dicCraneError[crane.ErrCode]), new DataParameter("@TaskNo", crane.TaskNo) }); if(crane.ErrCode>0) Logger.Error(crane.CraneNo.ToString() + "堆垛机执行时出现错误,代码:"+ crane.ErrCode.ToString() + ",描述:" + dicCraneError[crane.ErrCode]); } }
void Monitor_OnCrane(CraneEventArgs args) { if (InvokeRequired) { BeginInvoke(new CraneEventHandler(Monitor_OnCrane), args); } else { Crane crane = args.crane; TextBox txt = GetTextBox("txtTaskNo", crane.CraneNo); //任务编号 if (txt != null) { txt.Text = crane.TaskNo; } txt = GetTextBox("txtPalletCode", crane.CraneNo);//托盘编号 if (txt != null) { txt.Text = crane.PalletCode; } txt = GetTextBox("txtTaskType", crane.CraneNo); if (txt != null && dicCraneTaskType.ContainsKey(crane.TaskType)) { txt.Text = dicCraneTaskType[crane.TaskType]; } txt = GetTextBox("txtCraneAction", crane.CraneNo); if (txt != null && dicCraneAction.ContainsKey(crane.Action)) { txt.Text = dicCraneAction[crane.Action]; } txt = GetTextBox("txtColumn", crane.CraneNo); if (txt != null) { txt.Text = crane.Column.ToString(); } txt = GetTextBox("txtColumn", crane.CraneNo); if (txt != null) { txt.Text = crane.Height.ToString(); } txt = GetTextBox("txtErrorNo", crane.CraneNo); if (txt != null) { txt.Text = crane.ErrCode.ToString(); } Control[] ctl = this.Controls.Find("picCrane" + crane.CraneNo.ToString(), true); if (ctl.Length > 0) { if (crane.ErrCode > 0) { ctl[0].BackColor = Color.Red; } else { ctl[0].BackColor = Color.Transparent; } //堆垛机位置 int X = 623; if (crane.Column == 0) { X = 1007; } int Y = 336; Point P = new Point(); P.X = X - (int)(crane.Column * 15.28F); P.Y = Y - (crane.CraneNo - 1) * 73; ctl[0].Location = P; } txt = GetTextBox("txtErrorDesc", crane.CraneNo); string errDesc = ""; if (txt != null) { if (crane.ErrCode > 0) { DataRow[] drs = dtCraneError.Select(string.Format("warncode='{0}'", crane.ErrCode)); if (drs.Length > 0) { txt.Text = drs[0]["description"].ToString(); } else { txt.Text = "未知错误!"; } errDesc = txt.Text; txt.BackColor = Color.Red; string[] d = new string[2]; d[0] = crane.CraneNo.ToString(); d[1] = txt.Text; Context.ProcessDispatcher.WriteToProcess("LEDProcess", "Error", d); } else { txt.Text = ""; txt.BackColor = Control.DefaultBackColor; // Context.ProcessDispatcher.WriteToProcess("LEDProcess" + crane.CraneNo, "Refresh", crane.CraneNo * 2); } } //更新错误代码、错误描述 //bll.ExecNonQuery("WCS.UpdateTaskError", new DataParameter[] { new DataParameter("@CraneErrCode", crane.ErrCode.ToString()), new DataParameter("@CraneErrDesc", errDesc), new DataParameter("@TaskNo", crane.TaskNo) }); } }