AIConfigViewModel.cs 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. using IViewModel;
  2. using IViewModel.ViewModels;
  3. using Shaker.Model;
  4. using Shaker.Models;
  5. using Shaker.Tools;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. namespace Dynamicloadsimulationdevice.ViewModels
  12. {
  13. internal sealed class AIConfigViewModel:ViewModelBase<Shaker.Models.AIConfigModel>
  14. {
  15. private string unit=string.Empty;
  16. public AIConfigViewModel() : base()
  17. {
  18. }
  19. public AIConfigViewModel(Shaker.Models.AIConfigModel model):base(model)
  20. {
  21. }
  22. public override void UpDateModel(AIConfigModel model)
  23. {
  24. base.UpDateModel(model);
  25. Unit = ChannelType.GetUnit();
  26. }
  27. /// <summary>
  28. /// 通道序号
  29. /// </summary>
  30. [PropertyAssociation(nameof(Model.Channel))]
  31. public AIChannel Channel { get => Model.Channel; set => SetProperty(ref Model.Channel, value); }
  32. /// <summary>
  33. /// 灵敏度
  34. /// </summary>
  35. [PropertyAssociation(nameof(Sensitivity))]
  36. public double Sensitivity { get => Model.Sensitivity; set => SetProperty(ref Model.Sensitivity, value); }
  37. /// <summary>
  38. /// 最大灵敏度
  39. /// </summary>
  40. [PropertyAssociation(nameof(MaxSensitivity))]
  41. public double MaxSensitivity => Model.MaxSensitivity;
  42. /// <summary>
  43. /// 最小灵敏度
  44. /// </summary>
  45. [PropertyAssociation(nameof(MinSensitivity))]
  46. public double MinSensitivity => Model.MinSensitivity;
  47. /// <summary>
  48. /// 偏置
  49. ///<para> 当<see cref="ChannelType"/> ==<see cref="AIChannelType.Acceleration"/>和<see cref="AIChannelType.OutSignal"/>无效</para>
  50. /// </summary>
  51. [PropertyAssociation(nameof(Bias))]
  52. public double Bias { get => Model.Bias; set => SetProperty(ref Model.Bias, value); }
  53. /// <summary>
  54. /// 最大偏置
  55. /// </summary>
  56. [PropertyAssociation(nameof(MaxBias))]
  57. public double MaxBias => Model.MaxBias;
  58. /// <summary>
  59. /// 最小偏置
  60. /// </summary>
  61. [PropertyAssociation(nameof(MinBias))]
  62. public double MinBias => Model.MinBias;
  63. /// <summary>
  64. /// 模拟通道类型
  65. /// </summary>
  66. [PropertyAssociation(nameof(ChannelType))]
  67. public AIChannelType ChannelType =>Model.ChannelType;
  68. /// <summary>
  69. /// 单位
  70. /// </summary>
  71. [PropertyAssociation(nameof(Model.ChannelType))]
  72. public string Unit { get => unit; private set =>SetProperty(ref unit , value); }
  73. [PropertyAssociation(nameof(ChannelType))]
  74. public bool BiasVisibily=>ChannelType == AIChannelType.DifferentialPressure || ChannelType == AIChannelType.Pressure || ChannelType == AIChannelType.Displacement ;
  75. [PropertyAssociation(nameof(ChannelType))]
  76. public bool SensitivityVisibily => ChannelType != AIChannelType.OutSignal;
  77. public override string ToString()
  78. {
  79. return $"{ChannelType} {Channel}{(SensitivityVisibily?$" {nameof(Sensitivity)}:{Sensitivity}mV/{Unit}":"")}{(BiasVisibily?$" {nameof(Bias)}:{Bias}{Unit}":"")}";
  80. }
  81. }
  82. }