PufStationCommandControl.xaml.cs 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. using MECF.Framework.Common.DataCenter;
  2. using MECF.Framework.Common.OperationCenter;
  3. using CyberX8_Core;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Runtime.CompilerServices;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows;
  11. using System.Windows.Controls;
  12. using System.Windows.Data;
  13. using System.Windows.Documents;
  14. using System.Windows.Input;
  15. using System.Windows.Media;
  16. using System.Windows.Media.Imaging;
  17. using System.Windows.Navigation;
  18. using System.Windows.Shapes;
  19. namespace CyberX8_Themes.UserControls
  20. {
  21. /// <summary>
  22. /// PufStationCommandControl.xaml 的交互逻辑
  23. /// </summary>
  24. public partial class PufStationCommandControl : UserControl
  25. {
  26. public PufStationCommandControl()
  27. {
  28. InitializeComponent();
  29. }
  30. public static readonly DependencyProperty ModuleNameProperty = DependencyProperty.Register("ModuleName", typeof(string), typeof(PufStationCommandControl));
  31. /// <summary>
  32. /// ModuleName
  33. /// </summary>
  34. public string ModuleName
  35. {
  36. get
  37. {
  38. return (string)this.GetValue(ModuleNameProperty);
  39. }
  40. set
  41. {
  42. this.SetValue(ModuleNameProperty, value);
  43. }
  44. }
  45. public static readonly DependencyProperty VacuumAProperty = DependencyProperty.Register( "VacuumA", typeof(bool), typeof(PufStationCommandControl));
  46. /// <summary>
  47. /// VacuumA
  48. /// </summary>
  49. public bool VacuumA
  50. {
  51. get
  52. {
  53. return (bool)this.GetValue(VacuumAProperty);
  54. }
  55. set
  56. {
  57. this.SetValue(VacuumAProperty, value);
  58. }
  59. }
  60. public static readonly DependencyProperty VacuumBProperty = DependencyProperty.Register("VacuumB", typeof(bool), typeof(PufStationCommandControl));
  61. /// <summary>
  62. /// VacuumB
  63. /// </summary>
  64. public bool VacuumB
  65. {
  66. get
  67. {
  68. return (bool)this.GetValue(VacuumBProperty);
  69. }
  70. set
  71. {
  72. this.SetValue(VacuumBProperty, value);
  73. }
  74. }
  75. public static readonly DependencyProperty VacuumAValueProperty = DependencyProperty.Register("VacuumAValue", typeof(double), typeof(PufStationCommandControl));
  76. /// <summary>
  77. /// VacuumAValue
  78. /// </summary>
  79. public double VacuumAValue
  80. {
  81. get
  82. {
  83. return (double)this.GetValue(VacuumAValueProperty);
  84. }
  85. set
  86. {
  87. this.SetValue(VacuumAValueProperty, value);
  88. }
  89. }
  90. public static readonly DependencyProperty VacuumBValueProperty = DependencyProperty.Register("VacuumBValue", typeof(double), typeof(PufStationCommandControl));
  91. /// <summary>
  92. /// VacuumBValue
  93. /// </summary>
  94. public double VacuumBValue
  95. {
  96. get
  97. {
  98. return (double)this.GetValue(VacuumBValueProperty);
  99. }
  100. set
  101. {
  102. this.SetValue(VacuumBValueProperty, value);
  103. }
  104. }
  105. public static readonly DependencyProperty VacuumAStatusProperty = DependencyProperty.Register("VacuumAStatus", typeof(string), typeof(PufStationCommandControl));
  106. /// <summary>
  107. /// VacuumAStatus
  108. /// </summary>
  109. public string VacuumAStatus
  110. {
  111. get
  112. {
  113. return (string)this.GetValue(VacuumAStatusProperty);
  114. }
  115. set
  116. {
  117. this.SetValue(VacuumAStatusProperty, value);
  118. }
  119. }
  120. public static readonly DependencyProperty VacuumBStatusProperty = DependencyProperty.Register("VacuumBStatus", typeof(string), typeof(PufStationCommandControl));
  121. /// <summary>
  122. /// VacuumBStatus
  123. /// </summary>
  124. public string VacuumBStatus
  125. {
  126. get
  127. {
  128. return (string)this.GetValue(VacuumBStatusProperty);
  129. }
  130. set
  131. {
  132. this.SetValue(VacuumBStatusProperty, value);
  133. }
  134. }
  135. public static readonly DependencyProperty VacuumACheckedProperty = DependencyProperty.Register("VacuumAChecked", typeof(bool), typeof(PufStationCommandControl));
  136. /// <summary>
  137. /// VacuumAChecked
  138. /// </summary>
  139. public bool VacuumAChecked
  140. {
  141. get
  142. {
  143. return (bool)this.GetValue(VacuumACheckedProperty);
  144. }
  145. set
  146. {
  147. this.SetValue(VacuumACheckedProperty, value);
  148. }
  149. }
  150. public static readonly DependencyProperty VacuumBCheckedProperty = DependencyProperty.Register("VacuumBChecked", typeof(bool), typeof(PufStationCommandControl));
  151. /// <summary>
  152. /// VacuumBChecked
  153. /// </summary>
  154. public bool VacuumBChecked
  155. {
  156. get
  157. {
  158. return (bool)this.GetValue(VacuumBCheckedProperty);
  159. }
  160. set
  161. {
  162. this.SetValue(VacuumBCheckedProperty, value);
  163. }
  164. }
  165. public static readonly DependencyProperty PickSelectedItemProperty = DependencyProperty.Register("PickSelectedItem", typeof(string), typeof(PufStationCommandControl));
  166. /// <summary>
  167. /// PickSelectedItem
  168. /// </summary>
  169. public string PickSelectedItem
  170. {
  171. get
  172. {
  173. return (string)this.GetValue(PickSelectedItemProperty);
  174. }
  175. set
  176. {
  177. this.SetValue(PickSelectedItemProperty, value);
  178. }
  179. }
  180. public static readonly DependencyProperty PlaceSelectedItemProperty = DependencyProperty.Register("PlaceSelectedItem", typeof(string), typeof(PufStationCommandControl));
  181. /// <summary>
  182. /// PlaceSelectedItem
  183. /// </summary>
  184. public string PlaceSelectedItem
  185. {
  186. get
  187. {
  188. return (string)this.GetValue(PlaceSelectedItemProperty);
  189. }
  190. set
  191. {
  192. this.SetValue(PlaceSelectedItemProperty, value);
  193. }
  194. }
  195. public static readonly DependencyProperty CombomboxItemSourceProperty = DependencyProperty.Register("CombomboxItemSource", typeof(List<string>), typeof(PufStationCommandControl),
  196. new FrameworkPropertyMetadata(new List<string>() {"SideA","SideB" }, FrameworkPropertyMetadataOptions.AffectsRender));
  197. public List<string> CombomboxItemSource
  198. {
  199. get
  200. {
  201. return (List<string>)this.GetValue(CombomboxItemSourceProperty);
  202. }
  203. set
  204. {
  205. this.SetValue(CombomboxItemSourceProperty, value);
  206. }
  207. }
  208. #region button 事件
  209. private void MoveToPark_Click(object sender, RoutedEventArgs e)
  210. {
  211. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.MoveToPark");
  212. }
  213. private void AllMotorOn_Click(object sender, RoutedEventArgs e)
  214. {
  215. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.{MotionOperation.SwitchOn}");
  216. }
  217. private void AllMotorOff_Click(object sender, RoutedEventArgs e)
  218. {
  219. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.{MotionOperation.SwitchOff}");
  220. }
  221. private void HomePuf_Click(object sender, RoutedEventArgs e)
  222. {
  223. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.{MotionOperation.HomeAll}");
  224. }
  225. private void Abort_Click(object sender, RoutedEventArgs e)
  226. {
  227. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.Abort");
  228. }
  229. private void Pick_Click(object sender, RoutedEventArgs e)
  230. {
  231. if(string.IsNullOrEmpty(PickSelectedItem))
  232. {
  233. MessageBox.Show("please select pick item", "pick", MessageBoxButton.OK, MessageBoxImage.Error);
  234. return;
  235. }
  236. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.Pick", PickSelectedItem);
  237. }
  238. private void Place_Click(object sender, RoutedEventArgs e)
  239. {
  240. if (string.IsNullOrEmpty(PlaceSelectedItem))
  241. {
  242. MessageBox.Show("please select place item", "place", MessageBoxButton.OK, MessageBoxImage.Error);
  243. return;
  244. }
  245. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.Place", PlaceSelectedItem);
  246. }
  247. private void MoveToRobot_Click(object sender, RoutedEventArgs e)
  248. {
  249. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.MoveToRobot");
  250. }
  251. private void VacuumA_Click(object sender, RoutedEventArgs e)
  252. {
  253. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.VacuumAOn", "VacuumAChecked", !VacuumAChecked);
  254. }
  255. private void VacuumB_Click(object sender, RoutedEventArgs e)
  256. {
  257. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.VacuumBOn", "VacuumBChecked", !VacuumBChecked);
  258. }
  259. private void ClearError_Click(object sender, RoutedEventArgs e)
  260. {
  261. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.ClearError");
  262. }
  263. #endregion
  264. }
  265. }