终端一体化运控平台
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 

136 líneas
4.5 KiB

  1. using BPA.Helper;
  2. using BPASmartClient.Model;
  3. using BPASmartClient.MorkM.Model;
  4. using BPASmartClient.MorkM.View;
  5. using BPA.Helper;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Collections.ObjectModel;
  9. using System.ComponentModel;
  10. using System.Diagnostics;
  11. using System.Linq;
  12. using System.Runtime.CompilerServices;
  13. using System.Text;
  14. using System.Threading.Tasks;
  15. namespace BPASmartClient.MorkM.ViewModel
  16. {
  17. internal class DebugViewModel : NotifyBase
  18. {
  19. public DebugViewModel()
  20. {
  21. AddSimDataCommand = new BPARelayCommand(() =>
  22. {
  23. SimOrderConfitView simOrderConfitView = new SimOrderConfitView();
  24. simOrderConfitView.Show();
  25. });
  26. SimOrderCommand = new BPARelayCommand(() =>
  27. {
  28. List<ushort> locs = new List<ushort>();
  29. foreach (var item in simOrderConfig)
  30. {
  31. if (item.IsSelected)
  32. locs.Add((ushort)(new Random().Next(item.MinValue, item.MaxValue + 1)));
  33. else
  34. locs.Add(item.Loc);
  35. }
  36. if (locs.Count == 0)
  37. {
  38. locs.Add((ushort)(new Random().Next(1, 5)));
  39. locs.Add(10);
  40. }
  41. ActionManage.GetInstance.Send("SimOrder", locs);
  42. //下发模拟订单
  43. Trace.WriteLine("下发模拟订单。。。");
  44. });
  45. InitCommand = new BPARelayCommand(() =>
  46. {
  47. ActionManage.GetInstance.Send("InitDevice");
  48. //初始化按钮
  49. Trace.WriteLine("已点击初始化按钮。。。");
  50. });
  51. LoopSimOrderCommand = new BPARelayCommand(() =>
  52. {
  53. if (LoopOrderButtonContent == "循环跑单") ActionManage.GetInstance.Send("EnableForOrder");
  54. if (LoopOrderButtonContent == "停止跑单") ActionManage.GetInstance.Send("StopForOrder");
  55. LoopOrderButtonContent = LoopOrderButtonContent == "循环跑单" ? "停止跑单" : "循环跑单";
  56. });
  57. EditCommand = new BPARelayCommand<object>((o) =>
  58. {
  59. if (o != null)
  60. {
  61. var res = Json<KeepDataBase>.Data.simOrderConfig.FirstOrDefault(p => p.Text == o.ToString());
  62. if (res != null)
  63. {
  64. SimOrderConfitView simOrderConfitView = new SimOrderConfitView();
  65. simOrderConfitView.Show();
  66. ActionManage.GetInstance.Send("SendSimData", res);
  67. }
  68. }
  69. });
  70. RemoveCommand = new BPARelayCommand<object>((o) =>
  71. {
  72. if (o != null)
  73. {
  74. var res = Json<KeepDataBase>.Data.simOrderConfig.FirstOrDefault(p => p.Text == o.ToString());
  75. if (res != null) Json<KeepDataBase>.Data.simOrderConfig.Remove(res);
  76. }
  77. });
  78. }
  79. public static bool EnableLocalSimOrder { get { return GeneralConfig.EnableLocalSimOrder; } set { GeneralConfig.EnableLocalSimOrder = value; OnStaticPropertyChanged(); } }
  80. public ObservableCollection<SimOrderVisibleData> simOrderConfig
  81. {
  82. get
  83. {
  84. return Json<KeepDataBase>.Data.simOrderConfig;
  85. }
  86. set
  87. {
  88. Json<KeepDataBase>.Data.simOrderConfig = value;
  89. }
  90. }
  91. public BPARelayCommand AddSimDataCommand { get; set; }
  92. public BPARelayCommand SimOrderCommand { get; set; }
  93. public BPARelayCommand InitCommand { get; set; }
  94. public BPARelayCommand LoopSimOrderCommand { get; set; }
  95. public BPARelayCommand<object> EditCommand { get; set; }
  96. public BPARelayCommand<object> RemoveCommand { get; set; }
  97. public static event EventHandler<PropertyChangedEventArgs> StaticPropertyChanged;
  98. public static void OnStaticPropertyChanged([CallerMemberName] string PropName = "")
  99. {
  100. StaticPropertyChanged?.Invoke(null, new PropertyChangedEventArgs(PropName));
  101. }
  102. public static string LoopOrderButtonContent { get { return _mLoopOrderButtonContent; } set { _mLoopOrderButtonContent = value; OnStaticPropertyChanged(); } }
  103. private static string _mLoopOrderButtonContent = "循环跑单";
  104. }
  105. }