選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

262 行
12 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Data;
  9. using System.Windows.Documents;
  10. using System.Windows.Input;
  11. using System.Windows.Media;
  12. using System.Windows.Media.Imaging;
  13. using System.Windows.Shapes;
  14. using HBLConsole.Communication;
  15. using System.Threading;
  16. using HBLConsole.Model;
  17. using HBLConsole.Service;
  18. namespace HBLConsole.Debug
  19. {
  20. /// <summary>
  21. /// Debug_MORKJC.xaml 的交互逻辑
  22. /// </summary>
  23. public partial class Debug_MORKJC : UserControl
  24. {
  25. public Debug_MORKJC()
  26. {
  27. InitializeComponent();
  28. }
  29. private void Wait(int value)
  30. {
  31. while (!((JaKaHelper.GetInstance.Get_RobotAO1() == value) && JaKaHelper.GetInstance.GetProgramStatus() == 0))//判断文件是否已经执行结束 且 文件末端变量值==文件名
  32. {
  33. Thread.Sleep(5);
  34. }
  35. }
  36. private void Btn_Coffee_Click(object sender, RoutedEventArgs e)
  37. {
  38. JaKaHelper.GetInstance.Set_RobotAO1(0);
  39. Wait(0);
  40. JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_取杯);
  41. Wait(int.Parse(JaKaHelper.SENCE_取杯));
  42. JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_取杯检测);
  43. Wait(int.Parse(JaKaHelper.SENCE_取杯检测));
  44. JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_接咖啡);
  45. Wait(int.Parse(JaKaHelper.SENCE_接咖啡));
  46. JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放咖啡杯);
  47. Wait(int.Parse(JaKaHelper.SENCE_放咖啡杯));
  48. JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放杯检测);
  49. Wait(int.Parse(JaKaHelper.SENCE_放杯检测));
  50. JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_初始位);
  51. Wait(int.Parse(JaKaHelper.SENCE_初始位));
  52. }
  53. int[] devStatusBy=new int[2] { 0,0};
  54. private void Btn_Juicer_Click(object sender, RoutedEventArgs e)
  55. {
  56. JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_取杯);
  57. Wait(int.Parse(JaKaHelper.SENCE_取杯));
  58. JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_取杯检测);
  59. Wait(int.Parse(JaKaHelper.SENCE_取杯检测));
  60. byte JuicerNum = byte.Parse(txtJuicerNum.Text.Trim().ToString());
  61. int JuicerNum1 = int.Parse(txtJuicerNum.Text.Trim().ToString());
  62. switch (JuicerNum1)
  63. {
  64. case 0:
  65. JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_接果汁1);
  66. Wait(int.Parse(JaKaHelper.SENCE_接果汁1));
  67. break;
  68. case 1:
  69. JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_接果汁1);
  70. Wait(int.Parse(JaKaHelper.SENCE_接果汁1));
  71. break;
  72. case 2:
  73. JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_接果汁2);
  74. Wait(int.Parse(JaKaHelper.SENCE_接果汁2));
  75. break;
  76. case 3:
  77. JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_接果汁2);
  78. Wait(int.Parse(JaKaHelper.SENCE_接果汁2));
  79. break;
  80. case 4:
  81. JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_接果汁3);
  82. Wait(int.Parse(JaKaHelper.SENCE_接果汁3));
  83. break;
  84. case 5:
  85. JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_接果汁3);
  86. Wait(int.Parse(JaKaHelper.SENCE_接果汁3));
  87. break;
  88. case 6:
  89. JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_接果汁4);
  90. Wait(int.Parse(JaKaHelper.SENCE_接果汁4));
  91. break;
  92. case 7:
  93. JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_接果汁4);
  94. Wait(int.Parse(JaKaHelper.SENCE_接果汁4));
  95. break;
  96. default:
  97. JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_接果汁1);
  98. Wait(int.Parse(JaKaHelper.SENCE_接果汁1));
  99. break;
  100. }
  101. var devStatus = JuicerHelper.GetInstance.GetDeviceStatus();
  102. var devStatus1 = Convert.ToString(devStatus[0], 2);
  103. var devStatus2 = devStatus[1];
  104. if (devStatus1.IndexOf("0") == 1&& devStatus2==0)
  105. {
  106. JuicerHelper.GetInstance.StartCook(JuicerNum);
  107. Thread.Sleep(100);
  108. devStatusBy = JuicerHelper.GetInstance.GetDeviceStatus();
  109. while (!(devStatusBy[1]==0))
  110. {
  111. Thread.Sleep(100);
  112. devStatusBy = JuicerHelper.GetInstance.GetDeviceStatus();
  113. while (devStatusBy.Length != 2)
  114. {
  115. Thread.Sleep(100);
  116. devStatusBy = JuicerHelper.GetInstance.GetDeviceStatus();
  117. }
  118. }
  119. devStatusBy = JuicerHelper.GetInstance.GetDeviceStatus();
  120. Thread.Sleep(1000);
  121. switch (JuicerNum1)
  122. {
  123. case 0:
  124. JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放果汁杯1);
  125. Wait(int.Parse(JaKaHelper.SENCE_放果汁杯1));
  126. break;
  127. case 1:
  128. JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放果汁杯1);
  129. Wait(int.Parse(JaKaHelper.SENCE_放果汁杯1));
  130. break;
  131. case 2:
  132. JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放果汁杯2);
  133. Wait(int.Parse(JaKaHelper.SENCE_放果汁杯2));
  134. break;
  135. case 3:
  136. JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放果汁杯2);
  137. Wait(int.Parse(JaKaHelper.SENCE_放果汁杯2));
  138. break;
  139. case 4:
  140. JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放果汁杯3);
  141. Wait(int.Parse(JaKaHelper.SENCE_放果汁杯3));
  142. break;
  143. case 5:
  144. JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放果汁杯3);
  145. Wait(int.Parse(JaKaHelper.SENCE_放果汁杯3));
  146. break;
  147. case 6:
  148. JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放果汁杯4);
  149. Wait(int.Parse(JaKaHelper.SENCE_放果汁杯4));
  150. break;
  151. case 7:
  152. JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放果汁杯4);
  153. Wait(int.Parse(JaKaHelper.SENCE_放果汁杯4));
  154. break;
  155. default:
  156. JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放果汁杯1);
  157. Wait(int.Parse(JaKaHelper.SENCE_放果汁杯1));
  158. break;
  159. }
  160. JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放杯检测);
  161. Wait(int.Parse(JaKaHelper.SENCE_放杯检测));
  162. JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_初始位);
  163. Wait(int.Parse(JaKaHelper.SENCE_初始位));
  164. }
  165. MessageLog.GetInstance.Show("测试流程执行完成");
  166. }
  167. private void Btn_Tea_Click(object sender, RoutedEventArgs e)
  168. {
  169. JaKaHelper.GetInstance.Set_RobotAO1(0);
  170. Wait(0);
  171. JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_取杯);
  172. Wait(int.Parse(JaKaHelper.SENCE_取杯));
  173. MCUSerialHelper.GetInstance.OutputControl(1, true);
  174. Thread.Sleep(1000);
  175. JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_取杯检测);
  176. Wait(int.Parse(JaKaHelper.SENCE_取杯检测));
  177. while (!MCUSerialHelper.GetInstance.GetInputStatus(1))
  178. {
  179. JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_取杯);
  180. Wait(int.Parse(JaKaHelper.SENCE_取杯));
  181. JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_取杯检测);
  182. Wait(int.Parse(JaKaHelper.SENCE_取杯检测));
  183. }
  184. JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_接茶);
  185. Wait(int.Parse(JaKaHelper.SENCE_接茶));
  186. MCUSerialHelper.GetInstance.ServoControl(1, 105);
  187. Thread.Sleep(1000);
  188. MCUSerialHelper.GetInstance.ServoControl(1, 130);
  189. Thread.Sleep(1000);
  190. MCUSerialHelper.GetInstance.ServoControl(1, 105);
  191. Thread.Sleep(3000);
  192. JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_接茶_接水);
  193. Wait(int.Parse(JaKaHelper.SENCE_接茶_接水));
  194. JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_接水);
  195. Wait(int.Parse(JaKaHelper.SENCE_接水));
  196. MCUSerialHelper.GetInstance.OutputControl(2,true);
  197. Thread.Sleep(1000);
  198. MCUSerialHelper.GetInstance.OutputControl(2, false);
  199. Thread.Sleep(1000);
  200. MCUSerialHelper.GetInstance.OutputControl(3,true);
  201. Thread.Sleep(1000);
  202. MCUSerialHelper.GetInstance.OutputControl(3, false);
  203. Thread.Sleep(3000);
  204. JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放水杯);
  205. Wait(int.Parse(JaKaHelper.SENCE_放水杯));
  206. MCUSerialHelper.GetInstance.OutputControl(1, false);
  207. Thread.Sleep(1000);
  208. JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放杯检测);
  209. Wait(int.Parse(JaKaHelper.SENCE_放杯检测));
  210. JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_初始位);
  211. Wait(int.Parse(JaKaHelper.SENCE_初始位));
  212. }
  213. private void Btn_Water_Click(object sender, RoutedEventArgs e)
  214. {
  215. JaKaHelper.GetInstance.Set_RobotAO1(0);
  216. Wait(0);
  217. JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_取杯);
  218. Wait(int.Parse(JaKaHelper.SENCE_取杯));
  219. MCUSerialHelper.GetInstance.OutputControl(1, true);
  220. Thread.Sleep(1000);
  221. JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_取杯检测);
  222. Wait(int.Parse(JaKaHelper.SENCE_取杯检测));
  223. while (!MCUSerialHelper.GetInstance.GetInputStatus(1))
  224. {
  225. JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_取杯);
  226. Wait(int.Parse(JaKaHelper.SENCE_取杯));
  227. MCUSerialHelper.GetInstance.OutputControl(1, true);
  228. Thread.Sleep(1000);
  229. JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_取杯检测);
  230. Wait(int.Parse(JaKaHelper.SENCE_取杯检测));
  231. }
  232. JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_接水);
  233. Wait(int.Parse(JaKaHelper.SENCE_接水));
  234. MCUSerialHelper.GetInstance.OutputControl(2, true);
  235. Thread.Sleep(1000);
  236. MCUSerialHelper.GetInstance.OutputControl(2, false);
  237. Thread.Sleep(1000);
  238. MCUSerialHelper.GetInstance.OutputControl(3, true);
  239. Thread.Sleep(1000);
  240. MCUSerialHelper.GetInstance.OutputControl(3, false);
  241. Thread.Sleep(3000);
  242. JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放水杯);
  243. Wait(int.Parse(JaKaHelper.SENCE_放水杯));
  244. MCUSerialHelper.GetInstance.OutputControl(1, false);
  245. Thread.Sleep(1000);
  246. JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放杯检测);
  247. Wait(int.Parse(JaKaHelper.SENCE_放杯检测));
  248. JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_初始位);
  249. Wait(int.Parse(JaKaHelper.SENCE_初始位));
  250. }
  251. }
  252. }