//响应输入SN后的回车事件 private void tb_scanSN_KeyUp(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { if (inputSN_TB.Text.Length == 0) { return; } StartBtn.PerformClick(); } }
private async void trackBar3_Scroll(object sender, EventArgs e) { DesiredBox.Text = trackBar3.Value.ToString(); if (running == true) { StpBtn.PerformClick(); await Task.Delay(1001); StartBtn.PerformClick(); } }
/// <summary> /// 更新界面 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Update_IN_Status(object sender, System.EventArgs e) { string GroupIN_Status = Group_IN_Signal.Value.ToString(); if (GroupIN_Status != null) { int IO_IN_VALUE = int.Parse(GroupIN_Status); for (int i = 0; i < 16; i++) { if (IO_IN_VALUE % 2 == 1) { checkedListBox_IO_IN.SetItemChecked(i, true);//对应IO置为true } else { checkedListBox_IO_IN.SetItemChecked(i, false); } IO_IN_VALUE = IO_IN_VALUE >> 1; } } if (checkedListBox_IO_IN.GetItemChecked(9) == true) { IO_IN_10 = true; } else { IO_IN_10 = false; } if (checkedListBox_IO_IN.GetItemChecked(10) == true) { IO_IN_11 = true; } else { IO_IN_11 = false; } if (checkedListBox_IO_IN.GetItemChecked(8) == false && IsStart == true) //暂停按键 { StartBtn.PerformClick(); //点击暂停 Thread.Sleep(60); Emergency_Stop_Alarm = true; MessageBox.Show("激光护栏被触发"); } }
private void Form1_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { StartBtn.PerformClick(); } else if (e.KeyCode == Keys.Delete) { deleteBtn.PerformClick(); } else if (e.Modifiers == Keys.Control) { if (e.KeyCode == Keys.E) { editBtn.PerformClick(); } else if (e.KeyCode == Keys.A) { addBtn.PerformClick(); } } e.Handled = false; }
private void engine_Recognized(object sender, SpeechRecognizedEventArgs e) { string speech = e.Result.Text; switch (speech) { case "start reading": CopyScreenBtn.PerformClick(); StartBtn.PerformClick(); break; case "read the result": case "read the resuls": case "whats the result": case "whats the results": GetResult(); break; case "search": SearchBtn.PerformClick(); break; case "pause": PauseBtn.PerformClick(); break; case "resume": PauseBtn.PerformClick(); break; case "back": BackBtn.PerformClick(); break; case "next": ForwardBtn.PerformClick(); break; case "stop": StopBtn.PerformClick(); break; case "close website search": Decca.Speak("Closing Website Reader"); CloseBtn.PerformClick(); break; case "hide website reader": FormBorderStyle = FormBorderStyle.None; WindowState = FormWindowState.Minimized; TopMost = false; break; case "show website reader": case "show website reader again": FormBorderStyle = FormBorderStyle.None; WindowState = FormWindowState.Normal; TopMost = true; break; default: break; } if (speech == "find") { string Speech = e.Result.Text; Qevent = Speech; Speech = string.Empty; Decca.SpeakAsync("what do you want to search"); speech = string.Empty; Process_OutputDataReceived(); } }
/// <summary> /// 开启主线程 /// </summary> private void mainThread() { int Match_timers = 0; //匹配计数 int Start_Glue_Wait_time = 0; //开始喷胶等待的回合 int Stop_Glue_Wait_time = 0; //停止喷胶等待的回合 GLB.Camera_index = 0; //先从垛区拍照 bool isFinishPutDown = false; //是否完成覆合 Pose mypq = new Pose(); Point3 cls = new Point3(); double[] myQQ = cls.ABC2Q(0, Math.PI, 0);//欧拉角转四元数 //#######################################home####################################### abbController.StartRoutine(AbbCtrl, "MainModule", "goHome"); WaitForRoutineFinish();//等待Rapid程序执行结束 while (ProgramStart) { //#######################################喷胶####################################### if (GLB.run_mode == 1 && IsStart == true) { if (IO_IN_11 == false && isFinishPutDown == false)//滚筒上有海绵,未完成覆合 { if (ForwardCylinder == "0") { ForwardCylinder = abbController.SetIOStatus(AbbCtrl, "Local_IO_0_DO12"); //前挡 } if (BackwardCylinder == "0") { BackwardCylinder = abbController.SetIOStatus(AbbCtrl, "Local_IO_0_DO14"); //后挡阻挡 } MotorStatus = abbController.ResetIOStatus(AbbCtrl, "Local_IO_0_DO1"); //停止正转 Thread.Sleep(200); abbController.SetIOStatus(AbbCtrl, "Local_IO_0_DO13"); //侧推 Thread.Sleep(1000); abbController.ResetIOStatus(AbbCtrl, "Local_IO_0_DO13"); //侧推收回 GLB.run_mode = 2; //进入下一工作模式 GLB.Camera_index = 0; Thread.Sleep(300); } else if (IO_IN_11 == false && isFinishPutDown == true) //滚筒上有海绵,完成覆合 { ForwardCylinder = abbController.ResetIOStatus(AbbCtrl, "Local_IO_0_DO12"); //前挡收回 if (BackwardCylinder == "1") { BackwardCylinder = abbController.ResetIOStatus(AbbCtrl, "Local_IO_0_DO14"); //后挡收回 } while (IO_IN_11 != true) //直到海绵离开 { if (IsStart == true && MotorStatus != "1") { MotorStatus = abbController.SetIOStatus(AbbCtrl, "Local_IO_0_DO1"); //正转 } else if (IsStart == false && MotorStatus == "1") { MotorStatus = abbController.ResetIOStatus(AbbCtrl, "Local_IO_0_DO1"); //停止正转 } else { Thread.Sleep(30); } } isFinishPutDown = false; //清除标志 Thread.Sleep(50); //直到棉完全通过 } else { if (ForwardCylinder != "1") { ForwardCylinder = abbController.SetIOStatus(AbbCtrl, "Local_IO_0_DO12"); //前挡 } if (MotorStatus != "1") { MotorStatus = abbController.SetIOStatus(AbbCtrl, "Local_IO_0_DO1"); //正转: } if (Start_Glue_Wait_time == 0 && BackwardCylinder == "1") //后档首次放行 { BackwardCylinder = abbController.ResetIOStatus(AbbCtrl, "Local_IO_0_DO14"); //后挡放行 } if (IO_IN_10 == false) //检测到有棉 { if (Start_Glue_Wait_time < 40) //延时开始喷胶 { Start_Glue_Wait_time++; Thread.Sleep(10); } else { Stop_Glue_Wait_time = 0;//清除停止喷胶延时次数 if (BackwardCylinder == "0") { BackwardCylinder = abbController.SetIOStatus(AbbCtrl, "Local_IO_0_DO14"); //后挡阻挡 } if (Gun1_6 == "0" && GLB.produceSampleList[GLB.produce_index].axisShort > 900) { Gun1_6 = abbController.SetIOStatus(AbbCtrl, "Local_IO_0_DO9");//喷胶1.6 } if (Gun2_3 == "0") { Gun2_3 = abbController.SetIOStatus(AbbCtrl, "Local_IO_0_DO10"); //喷胶2.3 } if (Gun4_5 == "0") { Gun4_5 = abbController.SetIOStatus(AbbCtrl, "Local_IO_0_DO11"); //喷胶4.5 } } } else { if (Stop_Glue_Wait_time < 40) //延时停止喷胶 { Stop_Glue_Wait_time++; Thread.Sleep(10); } else { Start_Glue_Wait_time = 0;//清除开始喷胶延时次数 if (Gun1_6 == "1") { Gun1_6 = abbController.ResetIOStatus(AbbCtrl, "Local_IO_0_DO9"); //停止喷胶 } if (Gun2_3 == "1") { Gun2_3 = abbController.ResetIOStatus(AbbCtrl, "Local_IO_0_DO10"); } if (Gun4_5 == "1") { Gun4_5 = abbController.ResetIOStatus(AbbCtrl, "Local_IO_0_DO11"); } } } } } else if (GLB.run_mode == 1 && IsStart == false)//中途暂停 { Thread.Sleep(5); if (MotorStatus == "1") { MotorStatus = abbController.ResetIOStatus(AbbCtrl, "Local_IO_0_DO1"); //停止正转 } if (Gun1_6 == "1") { Gun1_6 = abbController.ResetIOStatus(AbbCtrl, "Local_IO_0_DO9"); //停止喷胶 } if (Gun2_3 == "1") { Gun2_3 = abbController.ResetIOStatus(AbbCtrl, "Local_IO_0_DO10"); } if (Gun4_5 == "1") { Gun4_5 = abbController.ResetIOStatus(AbbCtrl, "Local_IO_0_DO11"); } } //#######################################图漾相机抓取乳胶棉####################################### if (GLB.run_mode == 2 && GLB.Match_success == true && IsStart == true) //图漾匹配成功 并且没有暂停 { GLB.avgAngle.Clear(); //旋转角清空队列 GLB.avgCameraPoint3.Clear(); //相机坐标队列清空 Match_timers = 0; //计数清零 GLB.Camera_index = -1; //停止拍照 GLB.Match_success = false; //清除标志位 //**************乳胶棉目标点************** myQQ = cls.ABC2Q(-Math.PI / 2 - GLB.device_angl, Math.PI, 0); mypq.FillFromString2("[[" + GLB.robot_device_point.X + "," + GLB.robot_device_point.Y + "," + GLB.robot_device_point.Z + "]," + "[" + myQQ[0] + "," + myQQ[1] + "," + myQQ[2] + "," + myQQ[3] + "]]"); writePosQuat(mypq);//传输坐标 Thread.Sleep(50); abbController.StartRoutine(AbbCtrl, "MainModule", "TakeUpFromZoneToDesk"); WaitForRoutineFinish(); //等待Rapid程序执行结束 GLB.Match_success = false; //清除标志位 GLB.Camera_index = 1; //切换相机 GLB.run_mode = 3; Thread.Sleep(200); } else if (GLB.run_mode == 2 && GLB.Match_success == false && IsStart == true) { Match_timers += 1; if (Match_timers > 20)//二十次匹配不到,暂停 { this.BeginInvoke(new Action(() => { StartBtn.PerformClick();//点击暂停 Emergency_Stop_Alarm = true; Thread.Sleep(60); MessageBox.Show("垛区无法识别到乳胶棉,或者数量过少"); Match_timers = 0; })); } Thread.Sleep(300); } ////#######################################映美金二次抓取乳胶棉####################################### if (GLB.run_mode == 3 && GLB.Match_success == true && IsStart == true) //图漾匹配成功 并且没有暂停 { Match_timers = 0; //计数清零 GLB.Camera_index = -1; //停止拍照 GLB.Match_success = false; //清除标志位 //**************平台乳胶棉目标点************** myQQ = cls.ABC2Q(-GLB.device_angl, Math.PI, 0); mypq.FillFromString2("[[" + GLB.robot_device_point.X + "," + GLB.robot_device_point.Y + "," + GLB.robot_device_point.Z + "]," + "[" + myQQ[0] + "," + myQQ[1] + "," + myQQ[2] + "," + myQQ[3] + "]]"); writePosQuat(mypq);//传输坐标 //产品类型--放置点 abbController.producetypeLocal.FillFromString2(GLB.produce_index.ToString()); using (Mastership m = Mastership.Request(AbbCtrl.Rapid)) { abbController.produceTypeRobot.Value = abbController.producetypeLocal; m.Release(); } Thread.Sleep(50); abbController.StartRoutine(AbbCtrl, "MainModule", "TakeUpFromDeskToTansLine"); WaitForRoutineFinish(); //等待Rapid程序执行结束 isFinishPutDown = true; //完成覆合 GLB.Camera_index = 0; //切换相机 GLB.run_mode = 1; Thread.Sleep(200); } else if (GLB.run_mode == 3 && GLB.Match_success == false && IsStart == true) { Thread.Sleep(500); abbController.SetIOStatus(AbbCtrl, "Local_IO_0_DO3");//触发相机 Thread.Sleep(50); abbController.ResetIOStatus(AbbCtrl, "Local_IO_0_DO3"); Match_timers += 1; if (Match_timers > 10)//十次匹配不到,暂停 { this.BeginInvoke(new Action(() => { StartBtn.PerformClick();//点击暂停 Thread.Sleep(60); Emergency_Stop_Alarm = true; MessageBox.Show("平台上无法识别到乳胶棉"); Match_timers = 0; })); } Thread.Sleep(500); } else { Thread.Sleep(20); } } }