TransporterOperationControl.xaml.cs 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. using MECF.Framework.Common.OperationCenter;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows;
  8. using System.Windows.Controls;
  9. using System.Windows.Data;
  10. using System.Windows.Documents;
  11. using System.Windows.Input;
  12. using System.Windows.Media;
  13. using System.Windows.Media.Imaging;
  14. using System.Windows.Navigation;
  15. using System.Windows.Shapes;
  16. namespace CyberX8_Themes.UserControls
  17. {
  18. /// <summary>
  19. /// TransporterOperationControl.xaml 的交互逻辑
  20. /// </summary>
  21. public partial class TransporterOperationControl : UserControl
  22. {
  23. #region 属性
  24. public static readonly DependencyProperty ModuleNameProperty = DependencyProperty.Register("ModuleName", typeof(string), typeof(TransporterOperationControl),
  25. new FrameworkPropertyMetadata("Transporter",new PropertyChangedCallback(ModuleNamePropertyChanged)));
  26. /// <summary>
  27. /// 模块名称
  28. /// </summary>
  29. public string ModuleName
  30. {
  31. get
  32. {
  33. return (string)this.GetValue(ModuleNameProperty);
  34. }
  35. set
  36. {
  37. this.SetValue(ModuleNameProperty, value);
  38. }
  39. }
  40. private static void ModuleNamePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
  41. {
  42. }
  43. public static readonly DependencyProperty ClampedProperty = DependencyProperty.Register(
  44. "Clamped", typeof(bool), typeof(TransporterOperationControl), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));
  45. /// <summary>
  46. /// Clamped
  47. /// </summary>
  48. public bool Clamped
  49. {
  50. get
  51. {
  52. return (bool)this.GetValue(ClampedProperty);
  53. }
  54. set
  55. {
  56. this.SetValue(ClampedProperty, value);
  57. }
  58. }
  59. public static readonly DependencyProperty UnclampedProperty = DependencyProperty.Register(
  60. "Unclamped", typeof(bool), typeof(TransporterOperationControl), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));
  61. /// <summary>
  62. /// Unclamped
  63. /// </summary>
  64. public bool Unclamped
  65. {
  66. get
  67. {
  68. return (bool)this.GetValue(UnclampedProperty);
  69. }
  70. set
  71. {
  72. this.SetValue(UnclampedProperty, value);
  73. }
  74. }
  75. public static readonly DependencyProperty LockedProperty = DependencyProperty.Register(
  76. "Locked", typeof(bool), typeof(TransporterOperationControl), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));
  77. /// <summary>
  78. /// Locked
  79. /// </summary>
  80. public bool Locked
  81. {
  82. get
  83. {
  84. return (bool)this.GetValue(LockedProperty);
  85. }
  86. set
  87. {
  88. this.SetValue(LockedProperty, value);
  89. }
  90. }
  91. public static readonly DependencyProperty UnlockedProperty = DependencyProperty.Register(
  92. "Unlocked", typeof(bool), typeof(TransporterOperationControl), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));
  93. /// <summary>
  94. /// Unlocked
  95. /// </summary>
  96. public bool Unlocked
  97. {
  98. get
  99. {
  100. return (bool)this.GetValue(UnlockedProperty);
  101. }
  102. set
  103. {
  104. this.SetValue(UnlockedProperty, value);
  105. }
  106. }
  107. public static readonly DependencyProperty DripOpenedProperty = DependencyProperty.Register(
  108. "DripOpened", typeof(bool), typeof(TransporterOperationControl), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));
  109. /// <summary>
  110. /// DripOpened
  111. /// </summary>
  112. public bool DripOpened
  113. {
  114. get
  115. {
  116. return (bool)this.GetValue(DripOpenedProperty);
  117. }
  118. set
  119. {
  120. this.SetValue(DripOpenedProperty, value);
  121. }
  122. }
  123. public static readonly DependencyProperty DripClosedProperty = DependencyProperty.Register(
  124. "DripClosed", typeof(bool), typeof(TransporterOperationControl), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));
  125. /// <summary>
  126. /// DripClosed
  127. /// </summary>
  128. public bool DripClosed
  129. {
  130. get
  131. {
  132. return (bool)this.GetValue(DripClosedProperty);
  133. }
  134. set
  135. {
  136. this.SetValue(DripClosedProperty, value);
  137. }
  138. }
  139. public static readonly DependencyProperty DripHorizontalProperty = DependencyProperty.Register(
  140. "DripHorizontal", typeof(bool), typeof(TransporterOperationControl), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));
  141. /// <summary>
  142. /// DripHorizontal
  143. /// </summary>
  144. public bool DripHorizontal
  145. {
  146. get
  147. {
  148. return (bool)this.GetValue(DripHorizontalProperty);
  149. }
  150. set
  151. {
  152. this.SetValue(DripHorizontalProperty, value);
  153. }
  154. }
  155. public static readonly DependencyProperty DripVerticalProperty = DependencyProperty.Register(
  156. "DripVertical", typeof(bool), typeof(TransporterOperationControl), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));
  157. /// <summary>
  158. /// DripVertical
  159. /// </summary>
  160. public bool DripVertical
  161. {
  162. get
  163. {
  164. return (bool)this.GetValue(DripVerticalProperty);
  165. }
  166. set
  167. {
  168. this.SetValue(DripVerticalProperty, value);
  169. }
  170. }
  171. public static readonly DependencyProperty ManualModeProperty = DependencyProperty.Register(
  172. "ManualMode", typeof(bool), typeof(TransporterOperationControl), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));
  173. /// <summary>
  174. /// ManualMode
  175. /// </summary>
  176. public bool ManualMode
  177. {
  178. get
  179. {
  180. return (bool)this.GetValue(ManualModeProperty);
  181. }
  182. set
  183. {
  184. this.SetValue(ManualModeProperty, value);
  185. }
  186. }
  187. public static readonly DependencyProperty TargetStationProperty = DependencyProperty.Register(
  188. "TargetStation", typeof(string), typeof(TransporterOperationControl), new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));
  189. /// <summary>
  190. /// TargetStation
  191. /// </summary>
  192. public string TargetStation
  193. {
  194. get
  195. {
  196. return (string)this.GetValue(TargetStationProperty);
  197. }
  198. set
  199. {
  200. this.SetValue(TargetStationProperty, value);
  201. }
  202. }
  203. public static readonly DependencyProperty IsElevatorInUpPlaceProperty = DependencyProperty.Register(
  204. "IsElevatorInUpPlace", typeof(bool), typeof(TransporterOperationControl), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));
  205. /// <summary>
  206. /// IsElevatorInUpPlace
  207. /// </summary>
  208. public bool IsElevatorInUpPlace
  209. {
  210. get
  211. {
  212. return (bool)this.GetValue(IsElevatorInUpPlaceProperty);
  213. }
  214. set
  215. {
  216. this.SetValue(IsElevatorInUpPlaceProperty, value);
  217. }
  218. }
  219. #endregion
  220. public TransporterOperationControl()
  221. {
  222. InitializeComponent();
  223. }
  224. private void Clamp_Click(object sender, RoutedEventArgs e)
  225. {
  226. if (!IsElevatorInUpPlace)
  227. {
  228. MessageBox.Show("Elevator is not in 'UP' place", "Clamp", MessageBoxButton.OK, MessageBoxImage.Error);
  229. return;
  230. }
  231. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.Extend");
  232. }
  233. private void Unclamp_Click(object sender, RoutedEventArgs e)
  234. {
  235. if (!IsElevatorInUpPlace)
  236. {
  237. MessageBox.Show("Elevator is not in 'UP' place", "Clamp", MessageBoxButton.OK, MessageBoxImage.Error);
  238. return;
  239. }
  240. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.Retract");
  241. }
  242. private void Lock_Click(object sender, RoutedEventArgs e)
  243. {
  244. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.Lock");
  245. }
  246. private void Unlock_Click(object sender, RoutedEventArgs e)
  247. {
  248. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.Unlock");
  249. }
  250. private void Pick_Click(object sender, RoutedEventArgs e)
  251. {
  252. if (string.IsNullOrEmpty(TargetStation))
  253. {
  254. MessageBox.Show("Gantry is not in station", "pick", MessageBoxButton.OK, MessageBoxImage.Error);
  255. return;
  256. }
  257. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.PickUpFrom", TargetStation);
  258. }
  259. private void Place_Click(object sender, RoutedEventArgs e)
  260. {
  261. if (string.IsNullOrEmpty(TargetStation))
  262. {
  263. MessageBox.Show("Gantry is not in station", "place", MessageBoxButton.OK, MessageBoxImage.Error);
  264. return;
  265. }
  266. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.PutDownTo", TargetStation);
  267. }
  268. }
  269. }