using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Shapes; using HBLConsole.Communication; using System.Threading; using HBLConsole.Model; using HBLConsole.Service; namespace HBLConsole.Debug { /// /// Debug_MORKJC.xaml 的交互逻辑 /// public partial class Debug_MORKJC : UserControl { public Debug_MORKJC() { InitializeComponent(); } private void Wait(int value) { while (!((JaKaHelper.GetInstance.Get_RobotAO1() == value) && JaKaHelper.GetInstance.GetProgramStatus() == 0))//判断文件是否已经执行结束 且 文件末端变量值==文件名 { Thread.Sleep(5); } } private void Btn_Coffee_Click(object sender, RoutedEventArgs e) { JaKaHelper.GetInstance.Set_RobotAO1(0); Wait(0); JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_取杯); Wait(int.Parse(JaKaHelper.SENCE_取杯)); JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_取杯检测); Wait(int.Parse(JaKaHelper.SENCE_取杯检测)); JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_接咖啡); Wait(int.Parse(JaKaHelper.SENCE_接咖啡)); JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放咖啡杯); Wait(int.Parse(JaKaHelper.SENCE_放咖啡杯)); JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放杯检测); Wait(int.Parse(JaKaHelper.SENCE_放杯检测)); JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_初始位); Wait(int.Parse(JaKaHelper.SENCE_初始位)); } int[] devStatusBy=new int[2] { 0,0}; private void Btn_Juicer_Click(object sender, RoutedEventArgs e) { JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_取杯); Wait(int.Parse(JaKaHelper.SENCE_取杯)); JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_取杯检测); Wait(int.Parse(JaKaHelper.SENCE_取杯检测)); byte JuicerNum = byte.Parse(txtJuicerNum.Text.Trim().ToString()); int JuicerNum1 = int.Parse(txtJuicerNum.Text.Trim().ToString()); switch (JuicerNum1) { case 0: JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_接果汁1); Wait(int.Parse(JaKaHelper.SENCE_接果汁1)); break; case 1: JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_接果汁1); Wait(int.Parse(JaKaHelper.SENCE_接果汁1)); break; case 2: JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_接果汁2); Wait(int.Parse(JaKaHelper.SENCE_接果汁2)); break; case 3: JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_接果汁2); Wait(int.Parse(JaKaHelper.SENCE_接果汁2)); break; case 4: JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_接果汁3); Wait(int.Parse(JaKaHelper.SENCE_接果汁3)); break; case 5: JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_接果汁3); Wait(int.Parse(JaKaHelper.SENCE_接果汁3)); break; case 6: JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_接果汁4); Wait(int.Parse(JaKaHelper.SENCE_接果汁4)); break; case 7: JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_接果汁4); Wait(int.Parse(JaKaHelper.SENCE_接果汁4)); break; default: JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_接果汁1); Wait(int.Parse(JaKaHelper.SENCE_接果汁1)); break; } var devStatus = JuicerHelper.GetInstance.GetDeviceStatus(); var devStatus1 = Convert.ToString(devStatus[0], 2); var devStatus2 = devStatus[1]; if (devStatus1.IndexOf("0") == 1&& devStatus2==0) { JuicerHelper.GetInstance.StartCook(JuicerNum); Thread.Sleep(100); devStatusBy = JuicerHelper.GetInstance.GetDeviceStatus(); while (!(devStatusBy[1]==0)) { Thread.Sleep(100); devStatusBy = JuicerHelper.GetInstance.GetDeviceStatus(); while (devStatusBy.Length != 2) { Thread.Sleep(100); devStatusBy = JuicerHelper.GetInstance.GetDeviceStatus(); } } devStatusBy = JuicerHelper.GetInstance.GetDeviceStatus(); Thread.Sleep(1000); switch (JuicerNum1) { case 0: JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放果汁杯1); Wait(int.Parse(JaKaHelper.SENCE_放果汁杯1)); break; case 1: JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放果汁杯1); Wait(int.Parse(JaKaHelper.SENCE_放果汁杯1)); break; case 2: JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放果汁杯2); Wait(int.Parse(JaKaHelper.SENCE_放果汁杯2)); break; case 3: JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放果汁杯2); Wait(int.Parse(JaKaHelper.SENCE_放果汁杯2)); break; case 4: JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放果汁杯3); Wait(int.Parse(JaKaHelper.SENCE_放果汁杯3)); break; case 5: JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放果汁杯3); Wait(int.Parse(JaKaHelper.SENCE_放果汁杯3)); break; case 6: JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放果汁杯4); Wait(int.Parse(JaKaHelper.SENCE_放果汁杯4)); break; case 7: JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放果汁杯4); Wait(int.Parse(JaKaHelper.SENCE_放果汁杯4)); break; default: JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放果汁杯1); Wait(int.Parse(JaKaHelper.SENCE_放果汁杯1)); break; } JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放杯检测); Wait(int.Parse(JaKaHelper.SENCE_放杯检测)); JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_初始位); Wait(int.Parse(JaKaHelper.SENCE_初始位)); } MessageLog.GetInstance.Show("测试流程执行完成"); } private void Btn_Tea_Click(object sender, RoutedEventArgs e) { JaKaHelper.GetInstance.Set_RobotAO1(0); Wait(0); JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_取杯); Wait(int.Parse(JaKaHelper.SENCE_取杯)); MCUSerialHelper.GetInstance.OutputControl(1, true); Thread.Sleep(1000); JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_取杯检测); Wait(int.Parse(JaKaHelper.SENCE_取杯检测)); while (!MCUSerialHelper.GetInstance.GetInputStatus(1)) { JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_取杯); Wait(int.Parse(JaKaHelper.SENCE_取杯)); JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_取杯检测); Wait(int.Parse(JaKaHelper.SENCE_取杯检测)); } JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_接茶); Wait(int.Parse(JaKaHelper.SENCE_接茶)); MCUSerialHelper.GetInstance.ServoControl(1, 105); Thread.Sleep(1000); MCUSerialHelper.GetInstance.ServoControl(1, 130); Thread.Sleep(1000); MCUSerialHelper.GetInstance.ServoControl(1, 105); Thread.Sleep(3000); JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_接茶_接水); Wait(int.Parse(JaKaHelper.SENCE_接茶_接水)); JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_接水); Wait(int.Parse(JaKaHelper.SENCE_接水)); MCUSerialHelper.GetInstance.OutputControl(2,true); Thread.Sleep(1000); MCUSerialHelper.GetInstance.OutputControl(2, false); Thread.Sleep(1000); MCUSerialHelper.GetInstance.OutputControl(3,true); Thread.Sleep(1000); MCUSerialHelper.GetInstance.OutputControl(3, false); Thread.Sleep(3000); JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放水杯); Wait(int.Parse(JaKaHelper.SENCE_放水杯)); MCUSerialHelper.GetInstance.OutputControl(1, false); Thread.Sleep(1000); JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放杯检测); Wait(int.Parse(JaKaHelper.SENCE_放杯检测)); JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_初始位); Wait(int.Parse(JaKaHelper.SENCE_初始位)); } private void Btn_Water_Click(object sender, RoutedEventArgs e) { JaKaHelper.GetInstance.Set_RobotAO1(0); Wait(0); JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_取杯); Wait(int.Parse(JaKaHelper.SENCE_取杯)); MCUSerialHelper.GetInstance.OutputControl(1, true); Thread.Sleep(1000); JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_取杯检测); Wait(int.Parse(JaKaHelper.SENCE_取杯检测)); while (!MCUSerialHelper.GetInstance.GetInputStatus(1)) { JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_取杯); Wait(int.Parse(JaKaHelper.SENCE_取杯)); MCUSerialHelper.GetInstance.OutputControl(1, true); Thread.Sleep(1000); JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_取杯检测); Wait(int.Parse(JaKaHelper.SENCE_取杯检测)); } JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_接水); Wait(int.Parse(JaKaHelper.SENCE_接水)); MCUSerialHelper.GetInstance.OutputControl(2, true); Thread.Sleep(1000); MCUSerialHelper.GetInstance.OutputControl(2, false); Thread.Sleep(1000); MCUSerialHelper.GetInstance.OutputControl(3, true); Thread.Sleep(1000); MCUSerialHelper.GetInstance.OutputControl(3, false); Thread.Sleep(3000); JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放水杯); Wait(int.Parse(JaKaHelper.SENCE_放水杯)); MCUSerialHelper.GetInstance.OutputControl(1, false); Thread.Sleep(1000); JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放杯检测); Wait(int.Parse(JaKaHelper.SENCE_放杯检测)); JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_初始位); Wait(int.Parse(JaKaHelper.SENCE_初始位)); } } }