E84SimilatorUnitView.xaml.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. using System.Windows;
  2. using System.Windows.Controls;
  3. using System.Windows.Input;
  4. using Aitex.Core.UI.MVVM;
  5. namespace MECF.Framework.Simulator.Core.IoProviders
  6. {
  7. public partial class E84SimulatorUnitView : UserControl
  8. {
  9. public static readonly DependencyProperty LoadPortNameProperty = DependencyProperty.Register(
  10. "LoadPortName", typeof(string), typeof(E84SimulatorUnitView),
  11. null);
  12. public string LoadPortName
  13. {
  14. get => (string) GetValue(LoadPortNameProperty);
  15. set => SetValue(LoadPortNameProperty, value);
  16. }
  17. public static readonly DependencyProperty IsFloorVehicleProperty = DependencyProperty.Register(
  18. "IsFloorVehicle", typeof(bool), typeof(E84SimulatorUnitView),
  19. new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));
  20. public bool IsFloorVehicle
  21. {
  22. get => (bool) GetValue(IsFloorVehicleProperty);
  23. set => SetValue(IsFloorVehicleProperty, value);
  24. }
  25. private E84SimulatorUnitViewModel _viewModel;
  26. public ICommand E84Command { get; set; }
  27. public E84SimulatorUnitView()
  28. {
  29. InitializeComponent();
  30. E84Command = new DelegateCommand<string>(E84Operation);
  31. this.Loaded += OnViewLoaded;
  32. }
  33. private void E84Operation(string obj)
  34. {
  35. var x = obj.ToString();
  36. // var command = CommandHelper.GetCommandItem(obj);
  37. // var lstParameter = new List<object>
  38. // {
  39. // Station
  40. // };
  41. //lstParameter.AddRange(obj.Parameters);
  42. //InvokeClient.Instance.Service.DoOperation(command.CommandName, lstParameter.ToArray());
  43. }
  44. private void OnViewLoaded(object sender, RoutedEventArgs e)
  45. {
  46. if (DataContext == null)
  47. {
  48. _viewModel = new E84SimulatorUnitViewModel(LoadPortName, IsFloorVehicle);
  49. DataContext = _viewModel;
  50. (DataContext as TimerViewModelBase)?.Start();
  51. }
  52. }
  53. private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
  54. {
  55. if (sender is Button button)
  56. {
  57. if ((string) button.Content == "Pick From Lp")
  58. {
  59. _viewModel._simulatorE84.Stage = E84Stage.TD0;
  60. //_viewModel._simulatorE84.LReq;
  61. }
  62. else
  63. {
  64. _viewModel._simulatorE84.Stage = E84Stage.TD0;
  65. }
  66. }
  67. }
  68. }
  69. class E84SimulatorUnitViewModel: TimerViewModelBase
  70. {
  71. public readonly SimulatorE84 _simulatorE84;
  72. public bool IsFloorMode => _simulatorE84.IsFloor;
  73. public bool IsLoading => _simulatorE84.IsLoading;
  74. public bool IsUnloading => _simulatorE84.IsUnLoading;
  75. public bool LReq => _simulatorE84.LReq;
  76. public bool UReq => _simulatorE84.UReq;
  77. public bool Ready => _simulatorE84.Ready;
  78. public bool HoAvbl => _simulatorE84.HoAvbl;
  79. public bool ES => _simulatorE84.ES;
  80. public bool VA => _simulatorE84.VA;
  81. public bool VS0 => _simulatorE84.VS0;
  82. public bool VS1 => _simulatorE84.VS1;
  83. public bool ON => _simulatorE84.ON;
  84. public bool VALID => _simulatorE84.VALID;
  85. public bool CS_0 => _simulatorE84.CS_0;
  86. public bool TR_REQ => _simulatorE84.TR_REQ;
  87. public bool BUSY => _simulatorE84.BUSY;
  88. public bool COMPT => _simulatorE84.COMPT;
  89. public bool CONT => _simulatorE84.CONT;
  90. public bool AM_AVBL => _simulatorE84.AM_AVBL;
  91. public E84SimulatorUnitViewModel(string loadPortName, bool isFloorVehicle) : base("E84SimulatorUnitViewModel")
  92. {
  93. _simulatorE84 = new SimulatorE84(loadPortName, isFloorVehicle);
  94. }
  95. protected override void Poll()
  96. {
  97. InvokePropertyChanged();
  98. }
  99. }
  100. }