123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172 |
- using Avalonia.Collections;
- using IViewModel;
- using IViewModel.ViewModels;
- using MessagePack.Formatters;
- using Mono.Cecil;
- using Shaker.Models;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Dynamicloadsimulationdevice.ViewModels
- {
- public sealed class ServoConfigViewModel : DisplayViewModelBase<ServoConfigModel>
- {
- private ServoConfigViewModel() : base()
- {
- Title = nameof(LanguageValueViewModel.MenuDeviceConfig);
- Content = typeof(Views.ServoConfigView);
- #if NO_DEVICE
- UpDateModel(new ServoConfigModel()
- {
- PI = [.. Enumerable.Range(0,ShakerConfigViewModel.Instance.VerticalCount).Select(x=>new PIModel()),..Enumerable.Range(0,ShakerConfigViewModel.Instance.VerticalCount).Select(x=>new PIModel())]
- });
- #endif
- }
- static ServoConfigViewModel()
- {
- }
- public override double Width => 780;
- public override double Height => 620;
- public override bool CanResize => false;
- public override string MenuKey => nameof(LanguageValueViewModel.MenuDeviceConfig);
- public override string MenuParentKey => nameof(LanguageValueViewModel.MenuDevice);
- public override string IconKey => nameof(IconResourceValueViewModel.DeviceConfigGeometry);
- public override bool ShowTop => true;
- public override void UpDateModel(ServoConfigModel model)
- {
- foreach (var item in PI)
- {
- item.Value.PropertyChanged -= (sender, args) => SetSaveClose(true);
- }
- PI.Clear();
- if(model.PI.Count>0)
- {
- for (int i = 0; i < model.PI.Count; i++)
- {
- PI.Add(new IndexValueItemViewModel<PIViewModel>(i + 1, new PIViewModel(model.PI[i])));
- PI[^1].Value.PropertyChanged += (sender, args) => SetSaveClose(true);
- }
- }
- base.UpDateModel(model);
- }
- protected override void Save()
- {
- base.Save();
- savecanclose = false;
- }
- public override string OKContent => nameof(LanguageValueViewModel.Apply);
- public static ServoConfigViewModel Instance { get; } = new ServoConfigViewModel();
- public AvaloniaList<IndexValueItemViewModel<PIViewModel>> PI { get; } = new AvaloniaList<IndexValueItemViewModel<PIViewModel>>();
- /// <summary>
- /// 水平阀死区电压(V)
- /// </summary>
- [PropertyAssociation(nameof(ServoConfigModel.HorizontalBarrierPotential))]
- public double HorizontalBarrierPotential { get => Model.HorizontalBarrierPotential; set => SetProperty(ref Model.HorizontalBarrierPotential, value); }
- /// <summary>
- /// 最大水平阀死区电压(V)
- /// </summary>
- [PropertyAssociation(nameof(ServoConfigModel.MaxHorizontalBarrierPotential))]
- public double MaxHorizontalBarrierPotential { get => Model.MaxHorizontalBarrierPotential; }
- /// <summary>
- /// 最小水平阀死区电压(V)
- /// </summary>
- [PropertyAssociation(nameof(ServoConfigModel.MinHorizontalBarrierPotential))]
- public double MinHorizontalBarrierPotential { get => Model.MinHorizontalBarrierPotential; }
- /// <summary>
- /// 竖直阀死区电压(V)
- /// </summary>
- [PropertyAssociation(nameof(ServoConfigModel.VerticalBarrierPotential))]
- public double VerticalBarrierPotential { get => Model.VerticalBarrierPotential; set => SetProperty(ref Model.VerticalBarrierPotential, value); }
- /// <summary>
- /// 最大竖直阀死区电压(V)
- /// </summary>
- [PropertyAssociation(nameof(ServoConfigModel.MaxVerticalBarrierPotential))]
- public double MaxVerticalBarrierPotential { get => Model.MaxVerticalBarrierPotential; }
- /// <summary>
- /// 最小竖直阀死区电压(V)
- /// </summary>
- [PropertyAssociation(nameof(ServoConfigModel.MinVerticalBarrierPotential))]
- public double MinVerticalBarrierPotential { get => Model.MinVerticalBarrierPotential; }
- /// <summary>
- /// 最大积分电压(V)
- /// </summary>
- [PropertyAssociation(nameof(ServoConfigModel.MaxIntegratedVoltage))]
- public double MaxIntegratedVoltage { get => Model.MaxIntegratedVoltage; set => SetProperty(ref Model.MaxIntegratedVoltage, value); }
- /// <summary>
- /// 最大最大积分电压(V)
- /// </summary>
- [PropertyAssociation(nameof(ServoConfigModel.MaxMaxIntegratedVoltage))]
- public double MaxMaxIntegratedVoltage { get => Model.MaxMaxIntegratedVoltage; }
- /// <summary>
- /// 最小最大积分电压(V)
- /// </summary>
- [PropertyAssociation(nameof(ServoConfigModel.MinMaxIntegratedVoltage))]
- public double MinMaxIntegratedVoltage { get => Model.MinMaxIntegratedVoltage; }
- /// <summary>
- /// 位移前馈增益
- /// </summary>
- [PropertyAssociation(nameof(ServoConfigModel.DisplacementFeedforwardGain))]
- public double DisplacementFeedforwardGain { get => Model.DisplacementFeedforwardGain; set => SetProperty(ref Model.DisplacementFeedforwardGain, value); }
- /// <summary>
- /// 最大位移前馈增益
- /// </summary>
- [PropertyAssociation(nameof(ServoConfigModel.MaxDisplacementFeedforwardGain))]
- public double MaxDisplacementFeedforwardGain { get => Model.MaxDisplacementFeedforwardGain; }
- /// <summary>
- /// 最小位移前馈增益
- /// </summary>
- [PropertyAssociation(nameof(ServoConfigModel.MinDisplacementFeedforwardGain))]
- public double MinDisplacementFeedforwardGain { get => Model.MinDisplacementFeedforwardGain; }
- /// <summary>
- /// 最大驱动电压(V)
- /// </summary>
- [PropertyAssociation(nameof(ServoConfigModel.MaxDriverVoltage))]
- public double MaxDriverVoltage { get => Model.MaxDriverVoltage; set => SetProperty(ref Model.MaxDriverVoltage, value); }
- /// <summary>
- /// 最大最大驱动电压(V)
- /// </summary>
- [PropertyAssociation(nameof(ServoConfigModel.MaxMaxDriverVoltage))]
- public double MaxMaxDriverVoltage { get => Model.MaxMaxDriverVoltage; }
- /// <summary>
- /// 最小最大驱动电压(V)
- /// </summary>
- [PropertyAssociation(nameof(ServoConfigModel.MinMaxDriverVoltage))]
- public double MinMaxDriverVoltage { get => Model.MinMaxDriverVoltage; }
- /// <summary>
- /// 驱动超限电压(V)
- /// </summary>
- [PropertyAssociation(nameof(ServoConfigModel.DriverOverLimitVoltage))]
- public double DriverOverLimitVoltage { get => Model.DriverOverLimitVoltage; set => SetProperty(ref Model.DriverOverLimitVoltage, value); }
- /// <summary>
- /// 最大驱动超限电压(V)
- /// </summary>
- [PropertyAssociation(nameof(ServoConfigModel.MaxDriverOverLimitVoltage))]
- public double MaxDriverOverLimitVoltage { get => Model.MaxDriverOverLimitVoltage; }
- /// <summary>
- /// 最小驱动超限电压(V)
- /// </summary>
- [PropertyAssociation(nameof(ServoConfigModel.MinDriverOverLimitVoltage))]
- public double MinDriverOverLimitVoltage { get => Model.MinDriverOverLimitVoltage; }
- /// <summary>
- /// 急停后驱动限幅值(V)
- /// </summary>
- [PropertyAssociation(nameof(ServoConfigModel.EmerhencyDriverLimitVoltage))]
- public double EmerhencyDriverLimitVoltage { get => Model.EmerhencyDriverLimitVoltage; set => SetProperty(ref Model.EmerhencyDriverLimitVoltage, value); }
- /// <summary>
- /// 最大急停后驱动限幅值(V)
- /// </summary>
- [PropertyAssociation(nameof(ServoConfigModel.MaxEmerhencyDriverLimitVoltage))]
- public double MaxEmerhencyDriverLimitVoltage { get => Model.MaxEmerhencyDriverLimitVoltage; }
- /// <summary>
- /// 最小急停后驱动限幅值(V)
- /// </summary>
- [PropertyAssociation(nameof(ServoConfigModel.MinEmerhencyDriverLimitVoltage))]
- public double MinEmerhencyDriverLimitVoltage { get => Model.MinEmerhencyDriverLimitVoltage; }
- }
- }
|