FestoControl.xaml.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. using FestoDebugger.Beckoff;
  2. using FestoDebugger.Models;
  3. using FestoDebugger.Service;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Collections.ObjectModel;
  7. using System.Linq;
  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 FestoDebugger.UserControls
  20. {
  21. /// <summary>
  22. /// FestoControl.xaml 的交互逻辑
  23. /// </summary>
  24. public partial class FestoControl : UserControl
  25. {
  26. public FestoControl()
  27. {
  28. InitializeComponent();
  29. }
  30. public static readonly DependencyProperty ModuleNameProperty = DependencyProperty.Register(
  31. "ModuleName", typeof(string), typeof(FestoControl),
  32. new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));
  33. /// <summary>
  34. /// 信号名称
  35. /// </summary>
  36. public string ModuleName
  37. {
  38. get
  39. {
  40. return (string)this.GetValue(ModuleNameProperty);
  41. }
  42. set
  43. {
  44. this.SetValue(ModuleNameProperty, value);
  45. }
  46. }
  47. public static readonly DependencyProperty SignalOnProperty = DependencyProperty.Register(
  48. "SignalOn", typeof(bool), typeof(FestoControl), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));
  49. /// <summary>
  50. /// WaferPresent
  51. /// </summary>
  52. public bool SignalOn
  53. {
  54. get
  55. {
  56. return (bool)this.GetValue(SignalOnProperty);
  57. }
  58. set
  59. {
  60. this.SetValue(SignalOnProperty, value);
  61. }
  62. }
  63. public static readonly DependencyProperty ModuleDataProperty = DependencyProperty.Register(
  64. "ModuleData", typeof(SignalModuleData), typeof(FestoControl), new FrameworkPropertyMetadata(null, new PropertyChangedCallback(OnItemsSourceChanged)));
  65. /// <summary>
  66. /// WaferPresent
  67. /// </summary>
  68. public SignalModuleData ModuleData
  69. {
  70. get
  71. {
  72. return (SignalModuleData)this.GetValue(ModuleDataProperty);
  73. }
  74. set
  75. {
  76. this.SetValue(ModuleDataProperty, value);
  77. }
  78. }
  79. private void On_Click(object sender, RoutedEventArgs e)
  80. {
  81. object[] paramater = new object[] { $"{ModuleData.ModuleName}",true };
  82. BeckhoffIOManager.Instance.WriteDoOperation(" ", paramater);
  83. }
  84. private void Off_Click(object sender, RoutedEventArgs e)
  85. {
  86. object[] paramater = new object[] { $"{ModuleData.ModuleName}", false };
  87. BeckhoffIOManager.Instance.WriteDoOperation(" ", paramater);
  88. }
  89. private static void OnItemsSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
  90. {
  91. if (e.NewValue != null)
  92. {
  93. SignalModuleData newValue = (SignalModuleData)e.NewValue;
  94. d.SetValue(SignalOnProperty, newValue.SignalOn);
  95. }
  96. }
  97. }
  98. }