BottingClass.cs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace CCDCount.DLL
  7. {
  8. public class BottingClass
  9. {
  10. // 计数,总粒数
  11. private int KeLiNum = 0;
  12. // 当前第几瓶
  13. private int BottNum = 1;
  14. // 传送带瓶颗粒数量
  15. private int FirstBottCount = 0;
  16. // 旋转阀门颗粒数量
  17. private int SecondBottCount = 0;
  18. // 通道内颗粒数量
  19. private int ThirdBottCount = 0;
  20. // 汽缸阀门上颗粒数量
  21. private int FourthBottCount = 0;
  22. // 一瓶应该多少粒
  23. private int OneBottNum = 30;
  24. /// <summary>
  25. /// 有一粒进入瓶子
  26. /// </summary>
  27. /// <returns></returns>
  28. public bool SetOneActiveToFirstBoot()
  29. {
  30. bool result = false;
  31. KeLiNum++;
  32. FirstBottCount++;
  33. if (FirstBottCount >= OneBottNum)
  34. {
  35. result = true;
  36. }
  37. return result;
  38. }
  39. /// <summary>
  40. /// 有一粒进入旋转阀门
  41. /// </summary>
  42. /// <returns></returns>
  43. public bool SetOneActiveToSecondBoot()
  44. {
  45. bool result = false;
  46. KeLiNum++;
  47. SecondBottCount++;
  48. if (SecondBottCount >= OneBottNum)
  49. {
  50. result = true;
  51. }
  52. return result;
  53. }
  54. /// <summary>
  55. /// 有一粒进入通道
  56. /// </summary>
  57. /// <returns></returns>
  58. public bool SetOneActiveToThirdBoot()
  59. {
  60. bool result = false;
  61. KeLiNum++;
  62. ThirdBottCount++;
  63. if (ThirdBottCount >= OneBottNum)
  64. {
  65. result = true;
  66. }
  67. return result;
  68. }
  69. /// <summary>
  70. /// 有一粒进入汽缸阀门
  71. /// </summary>
  72. /// <returns></returns>
  73. public bool SetOneActiveToFourthBoot()
  74. {
  75. bool result = false;
  76. KeLiNum++;
  77. FourthBottCount++;
  78. if (FourthBottCount >= OneBottNum*0.9)
  79. {
  80. result = true;
  81. }
  82. return result;
  83. }
  84. /// <summary>
  85. /// 计数清零
  86. /// </summary>
  87. public void ClearCount()
  88. {
  89. KeLiNum = 0;
  90. BottNum = 1;
  91. FirstBottCount = 0;
  92. SecondBottCount = 0;
  93. ThirdBottCount = 0;
  94. FourthBottCount = 0;
  95. }
  96. /// <summary>
  97. /// 瓶子计数清零
  98. /// </summary>
  99. public void ClearFirstBottCount()
  100. {
  101. FirstBottCount = 0;
  102. }
  103. /// <summary>
  104. /// 旋转阀门计数清零
  105. /// </summary>
  106. public void ClearSecondBottCount()
  107. {
  108. SecondBottCount = 0;
  109. }
  110. /// <summary>
  111. /// 通道计数清零
  112. /// </summary>
  113. public void ClearThirdBottCount()
  114. {
  115. ThirdBottCount = 0;
  116. }
  117. // <summary>
  118. /// 汽缸阀门计数清零
  119. /// </summary>
  120. public void ClearFourthBottCount()
  121. {
  122. FourthBottCount = 0;
  123. }
  124. /// <summary>
  125. /// 获取瓶子状态
  126. /// </summary>
  127. /// <returns></returns>
  128. public bool GetFirstBottState()
  129. {
  130. return FirstBottCount >= OneBottNum;
  131. }
  132. /// <summary>
  133. /// 获取旋转阀门状态
  134. /// </summary>
  135. /// <returns></returns>
  136. public bool GetSecondBottState()
  137. {
  138. return SecondBottCount >= OneBottNum;
  139. }
  140. /// <summary>
  141. /// 获取通道状态
  142. /// </summary>
  143. public bool GetThirdBottState()
  144. {
  145. return ThirdBottCount >= OneBottNum;
  146. }
  147. /// <summary>
  148. /// 获取汽缸阀门状态
  149. /// </summary>
  150. public bool GetFourthBottState()
  151. {
  152. return FourthBottCount >= (OneBottNum*0.9);
  153. }
  154. /// <summary>
  155. /// bottle完成一瓶
  156. /// </summary>
  157. public void FinishOnBott()
  158. {
  159. BottNum++;
  160. }
  161. /// <summary>
  162. /// 修改每瓶粒数
  163. /// </summary>
  164. /// <param name="num"></param>
  165. public void ChangeOneBottNum(int num)
  166. {
  167. OneBottNum = num;
  168. }
  169. public void MoveFourthToThirdCount()
  170. {
  171. ThirdBottCount += FourthBottCount;
  172. FourthBottCount = 0;
  173. }
  174. }
  175. }