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 { 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(); } /// /// 通道序号 /// [PropertyAssociation(nameof(Model.Channel))] public AIChannel Channel { get => Model.Channel; set => SetProperty(ref Model.Channel, value); } /// /// 灵敏度 /// [PropertyAssociation(nameof(Sensitivity))] public double Sensitivity { get => Model.Sensitivity; set => SetProperty(ref Model.Sensitivity, value); } /// /// 最大灵敏度 /// [PropertyAssociation(nameof(MaxSensitivity))] public double MaxSensitivity => Model.MaxSensitivity; /// /// 最小灵敏度 /// [PropertyAssociation(nameof(MinSensitivity))] public double MinSensitivity => Model.MinSensitivity; /// /// 偏置 /// ==无效 /// [PropertyAssociation(nameof(Bias))] public double Bias { get => Model.Bias; set => SetProperty(ref Model.Bias, value); } /// /// 最大偏置 /// [PropertyAssociation(nameof(MaxBias))] public double MaxBias => Model.MaxBias; /// /// 最小偏置 /// [PropertyAssociation(nameof(MinBias))] public double MinBias => Model.MinBias; /// /// 模拟通道类型 /// [PropertyAssociation(nameof(ChannelType))] public AIChannelType ChannelType =>Model.ChannelType; /// /// 单位 /// [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}":"")}"; } } }