终端一体化运控平台
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 

136 satır
4.5 KiB

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