EndPointViewModel.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. using Aitex.Core.UI.MVVM;
  2. using MECF.Framework.Common.DataCenter;
  3. using MECF.Framework.Common.OperationCenter;
  4. using OpenSEMI.ClientBase;
  5. using System.Collections.Generic;
  6. using System.Windows.Input;
  7. using MECF.Framework.Common.CommonData;
  8. using VirgoUI.Client.Models.Sys;
  9. namespace VirgoUI.Client.Models.Utility.EndPoint
  10. {
  11. class EndPointViewModel : ModuleUiViewModelBase, ISupportMultipleSystem
  12. {
  13. private int MenuPermission;
  14. public class AlogarithmTypeItem
  15. {
  16. public string AlogarithmName { get; set; }
  17. }
  18. public List<AlogarithmTypeItem> AlgorithmTypes { get; set; }
  19. public ICommand SaveCommand
  20. {
  21. get;
  22. private set;
  23. }
  24. public EndPointConfigItem ConfigItem
  25. {
  26. get;
  27. set;
  28. }
  29. public EndPointViewModel()
  30. {
  31. MenuPermission = ClientApp.Instance.GetPermission("epd");
  32. SaveCommand = new DelegateCommand<object>(SaveConfig);
  33. ConfigItem = new EndPointConfigItem();
  34. AlgorithmTypes = new List<AlogarithmTypeItem>()
  35. {
  36. new AlogarithmTypeItem() { AlogarithmName = "Unknown"},
  37. new AlogarithmTypeItem() { AlogarithmName = "Above_ABS_Value"},
  38. new AlogarithmTypeItem() { AlogarithmName = "Below_ABS_Value"},
  39. new AlogarithmTypeItem() { AlogarithmName = "Drop_Percent"},
  40. new AlogarithmTypeItem() { AlogarithmName = "Up_Percent"},
  41. new AlogarithmTypeItem() { AlogarithmName = "Range_In"},
  42. new AlogarithmTypeItem() { AlogarithmName = "Gradient"},
  43. new AlogarithmTypeItem() { AlogarithmName = "Peek"},
  44. new AlogarithmTypeItem() { AlogarithmName = "Valley"},
  45. new AlogarithmTypeItem() { AlogarithmName = "Min_Drop_Percent"},
  46. new AlogarithmTypeItem() { AlogarithmName = "Min_Up_Percent"},
  47. new AlogarithmTypeItem() { AlogarithmName = "Max_Drop_Percent"},
  48. new AlogarithmTypeItem() { AlogarithmName = "Max_Up_Percent"},
  49. new AlogarithmTypeItem() { AlogarithmName = "Rise_Fall"},
  50. new AlogarithmTypeItem() { AlogarithmName = "Fall_Rise"},
  51. };
  52. }
  53. protected override void OnActivate()
  54. {
  55. base.OnActivate();
  56. LoadConfig();
  57. }
  58. protected override void OnDeactivate(bool close)
  59. {
  60. base.OnDeactivate(close);
  61. }
  62. public void LoadConfig()
  63. {
  64. string config = (string)QueryDataClient.Instance.Service.GetConfig("System.EndPoint.EndPointDefaultValue");
  65. ConfigItem.SetValue(config);
  66. NotifyOfPropertyChange(nameof(ConfigItem));
  67. }
  68. void SaveConfig(object param)
  69. {
  70. if (MenuPermission != 3) return;
  71. InvokeClient.Instance.Service.DoOperation("System.SetConfig", "System.EndPoint.EndPointDefaultValue", ConfigItem.ToValue());
  72. }
  73. protected override void InvokeBeforeUpdateProperty(Dictionary<string, object> data)
  74. {
  75. base.InvokeBeforeUpdateProperty(data);
  76. }
  77. }
  78. }