SimulatorPlcFloatIOView.xaml.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. using Aitex.Common.Util;
  2. using Aitex.Core.UI.MVVM;
  3. using MECF.Framework.Common.IOCore;
  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.Controls.Primitives;
  13. using System.Windows.Data;
  14. using System.Windows.Documents;
  15. using System.Windows.Input;
  16. using System.Windows.Media;
  17. using System.Windows.Media.Imaging;
  18. using System.Windows.Navigation;
  19. using System.Windows.Shapes;
  20. namespace FurnaceSimulator.Views
  21. {
  22. /// <summary>
  23. /// SimulatorPMAIOView.xaml 的交互逻辑
  24. /// </summary>
  25. public partial class SimulatorPlcFloatIOView : UserControl
  26. {
  27. public static readonly DependencyProperty PortProperty = DependencyProperty.Register(
  28. "Port", typeof(int), typeof(SimulatorPlcFloatIOView),
  29. new FrameworkPropertyMetadata(0, FrameworkPropertyMetadataOptions.AffectsRender));
  30. public static readonly DependencyProperty SourceProperty = DependencyProperty.Register(
  31. "Source", typeof(string), typeof(SimulatorPlcFloatIOView),
  32. new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));
  33. public static readonly DependencyProperty ModuleProperty = DependencyProperty.Register(
  34. "Module", typeof(string), typeof(SimulatorPlcFloatIOView),
  35. new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));
  36. public static readonly DependencyProperty IoMapFileProperty = DependencyProperty.Register(
  37. "IoMapFile", typeof(string), typeof(SimulatorPlcFloatIOView),
  38. new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));
  39. public int Port
  40. {
  41. get
  42. {
  43. return (int)this.GetValue(PortProperty);
  44. }
  45. set
  46. {
  47. this.SetValue(PortProperty, value);
  48. }
  49. }
  50. public string Source
  51. {
  52. get
  53. {
  54. return (string)this.GetValue(SourceProperty);
  55. }
  56. set
  57. {
  58. this.SetValue(SourceProperty, value);
  59. }
  60. }
  61. public string Module
  62. {
  63. get
  64. {
  65. return (string)this.GetValue(ModuleProperty);
  66. }
  67. set
  68. {
  69. this.SetValue(ModuleProperty, value);
  70. }
  71. }
  72. public string IoMapFile
  73. {
  74. get
  75. {
  76. return (string)this.GetValue(IoMapFileProperty);
  77. }
  78. set
  79. {
  80. this.SetValue(IoMapFileProperty, value);
  81. }
  82. }
  83. private void OnViewLoaded(object sender, RoutedEventArgs e)
  84. {
  85. if (DataContext == null)
  86. {
  87. DataContext = new IoViewModel(Port, Source, $"{PathManager.GetCfgDir()}{IoMapFile}", Module);
  88. (DataContext as TimerViewModelBase).Start();
  89. }
  90. }
  91. public SimulatorPlcFloatIOView()
  92. {
  93. InitializeComponent();
  94. this.Loaded += OnViewLoaded;
  95. }
  96. }
  97. }