12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- using IViewModel;
- using IViewModel.ViewModels;
- using Shaker.Model;
- using Shaker.Models;
- using Shaker.Tools;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Dynamicloadsimulationdevice.ViewModels
- {
- internal sealed class AIConfigViewModel:ViewModelBase<Shaker.Models.AIConfigModel>
- {
- private string unit=string.Empty;
- public AIConfigViewModel() : base()
- {
- }
- public AIConfigViewModel(Shaker.Models.AIConfigModel model):base(model)
- {
- }
- public override void UpDateModel(AIConfigModel model)
- {
- base.UpDateModel(model);
- Unit = ChannelType.GetUnit();
- }
- /// <summary>
- /// 通道序号
- /// </summary>
- [PropertyAssociation(nameof(Model.Channel))]
- public AIChannel Channel { get => Model.Channel; set => SetProperty(ref Model.Channel, value); }
- /// <summary>
- /// 灵敏度
- /// </summary>
- [PropertyAssociation(nameof(Sensitivity))]
- public double Sensitivity { get => Model.Sensitivity; set => SetProperty(ref Model.Sensitivity, value); }
- /// <summary>
- /// 最大灵敏度
- /// </summary>
- [PropertyAssociation(nameof(MaxSensitivity))]
- public double MaxSensitivity => Model.MaxSensitivity;
- /// <summary>
- /// 最小灵敏度
- /// </summary>
- [PropertyAssociation(nameof(MinSensitivity))]
- public double MinSensitivity => Model.MinSensitivity;
- /// <summary>
- /// 偏置
- ///<para> 当<see cref="ChannelType"/> ==<see cref="AIChannelType.Acceleration"/>和<see cref="AIChannelType.OutSignal"/>无效</para>
- /// </summary>
- [PropertyAssociation(nameof(Bias))]
- public double Bias { get => Model.Bias; set => SetProperty(ref Model.Bias, value); }
- /// <summary>
- /// 最大偏置
- /// </summary>
- [PropertyAssociation(nameof(MaxBias))]
- public double MaxBias => Model.MaxBias;
- /// <summary>
- /// 最小偏置
- /// </summary>
- [PropertyAssociation(nameof(MinBias))]
- public double MinBias => Model.MinBias;
- /// <summary>
- /// 模拟通道类型
- /// </summary>
- [PropertyAssociation(nameof(ChannelType))]
- public AIChannelType ChannelType =>Model.ChannelType;
- /// <summary>
- /// 单位
- /// </summary>
- [PropertyAssociation(nameof(Model.ChannelType))]
- public string Unit { get => unit; private set =>SetProperty(ref unit , value); }
- [PropertyAssociation(nameof(ChannelType))]
- public bool BiasVisibily=>ChannelType == AIChannelType.DifferentialPressure || ChannelType == AIChannelType.Pressure || ChannelType == AIChannelType.Displacement ;
- [PropertyAssociation(nameof(ChannelType))]
- public bool SensitivityVisibily => ChannelType != AIChannelType.OutSignal;
- public override string ToString()
- {
- return $"{ChannelType} {Channel}{(SensitivityVisibily?$" {nameof(Sensitivity)}:{Sensitivity}mV/{Unit}":"")}{(BiasVisibily?$" {nameof(Bias)}:{Bias}{Unit}":"")}";
- }
- }
- }
|