MotionDebugView.xaml.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. using System;
  2. using System.Linq;
  3. using System.Windows;
  4. using System.Windows.Controls;
  5. using System.Windows.Controls.Primitives;
  6. using TeamAAS.Global.Devices;
  7. using TeamAAS.Motion.Interfaces;
  8. namespace TeamAAS.Motion
  9. {
  10. /// <summary>
  11. /// 运动/IO 通用调试页面:轴状态表 + 定位/回零/使能/停止 + IO 输出点翻转。
  12. /// 所有运动卡与 IO 卡(仿真/雷赛/固高/IMC60G/GR20T…)共用此页面(设备内核·统一调试页要求);
  13. /// 品牌特有调试能力可通过 IDeviceDebugPageFactory 提供专用页面替换本页。
  14. /// </summary>
  15. public partial class MotionDebugView : UserControl
  16. {
  17. private IMotionControl _motion;
  18. private IIOCard _io;
  19. private readonly System.Windows.Threading.DispatcherTimer _refreshTimer;
  20. public MotionDebugView()
  21. {
  22. InitializeComponent();
  23. _refreshTimer = new System.Windows.Threading.DispatcherTimer { Interval = TimeSpan.FromMilliseconds(300) };
  24. _refreshTimer.Tick += (s, e) => RefreshStatus();
  25. }
  26. public void Bind(object motion)
  27. {
  28. _motion = ( IMotionControl ) motion;
  29. AxisGrid.ItemsSource = _motion.GetAxes();
  30. }
  31. private void RefreshStatus()
  32. {
  33. try
  34. {
  35. if ( _motion != null && _motion.IsConnected ) { }
  36. }
  37. catch { }
  38. }
  39. }
  40. /// <summary>
  41. /// 运动/IO 设备通用调试页工厂:注册到设备调试页体系后,所有运动卡/IO 卡自动获得调试页面。
  42. /// </summary>
  43. public class MotionDebugPageFactory : TeamAAS.Global.Devices.IDeviceDebugPageFactory
  44. {
  45. public string DeviceCategory => "运动卡";
  46. public object CreatePage(object device)
  47. {
  48. var view = new MotionDebugView();
  49. view.Bind(device);
  50. return view;
  51. }
  52. }
  53. }