|
@@ -19,7 +19,7 @@ namespace ShakerApp.ViewModels
|
|
|
{
|
|
|
internal class RandomConfigViewModel : ViewModelBase<Shaker.Models.RandomConfigModel>
|
|
|
{
|
|
|
- public List<SweepData> RefSpectrum => datas;
|
|
|
+ public List<RandomData> RefSpectrum => datas;
|
|
|
private RandomConfigViewModel()
|
|
|
{
|
|
|
Content = typeof(Views.RandomConfigView);
|
|
@@ -160,12 +160,20 @@ namespace ShakerApp.ViewModels
|
|
|
displacement.Title = App.Current?.FindResource(ShakerConstant.DisplacementKey) + "";
|
|
|
DisplacementModel.InvalidatePlot(true);
|
|
|
});
|
|
|
- CommunicationViewModel.Intance.LocalCommunication?.GetEvent<RandomConfigModel>()?.Subscrip((sender, args) =>
|
|
|
+ GetEvent<AllConfig>().Subscrip((sender, args) =>
|
|
|
{
|
|
|
- UpDateModel(args.Data);
|
|
|
- Refresh();
|
|
|
-
|
|
|
- CommunicationViewModel.Intance.ServiceCommunication?.GetEvent<RandomConfigModel>()?.Publish(this, args.Data);
|
|
|
+ UpDateModel(args.Data.RandomConfig);
|
|
|
+ if (CommunicationViewModel.Intance.ServiceIsStart)
|
|
|
+ {
|
|
|
+ CommunicationViewModel.Intance.ServiceCommunication.GetEvent<RandomConfigModel>().Publish(this, args.Data.RandomConfig);
|
|
|
+ }
|
|
|
+ CommunicationViewModel.Intance.LocalCommunication?.GetEvent<RandomConfigModel>()?.Subscrip((sender, args) =>
|
|
|
+ {
|
|
|
+ UpDateModel(args.Data);
|
|
|
+ Refresh();
|
|
|
+ RandomMainPageViewModel.Instance.SetRefSpectrum(datas);
|
|
|
+ CommunicationViewModel.Intance.ServiceCommunication?.GetEvent<RandomConfigModel>()?.Publish(this, Model);
|
|
|
+ });
|
|
|
});
|
|
|
}
|
|
|
static RandomConfigViewModel()
|
|
@@ -195,8 +203,8 @@ namespace ShakerApp.ViewModels
|
|
|
List<DataPoint> displacementdata = new List<DataPoint>();
|
|
|
List<OxyColor> oxyColors = new List<OxyColor>() { OxyColors.Green, OxyColors.Red, OxyColors.Red, OxyColors.Yellow, OxyColors.Yellow };
|
|
|
List<LineStyle> lineStyles = new List<LineStyle>() { LineStyle.Solid, LineStyle.Solid, LineStyle.Solid, LineStyle.LongDashDotDot, LineStyle.LongDashDotDot };
|
|
|
- List<string> properties = new List<string>() { nameof(SweepData.TargetAcceleration), nameof(SweepData.UpStopAcceleration), nameof(SweepData.DownStopAcceleration), nameof(SweepData.UpWarnAcceleration), nameof(SweepData.DownWarnAcceleration) };
|
|
|
- List<SweepData> datas = new List<SweepData>();
|
|
|
+ List<string> properties = new List<string>() { nameof(RandomData.TargetAcceleration), nameof(RandomData.UpStopAcceleration), nameof(RandomData.DownStopAcceleration), nameof(RandomData.UpWarnAcceleration), nameof(RandomData.DownWarnAcceleration) };
|
|
|
+ List<RandomData> datas = new List<RandomData>();
|
|
|
private double rmsAcceleration = 0;
|
|
|
private double maxDisplacement;
|
|
|
private double maxVelocity;
|
|
@@ -266,15 +274,36 @@ namespace ShakerApp.ViewModels
|
|
|
public double RMSAcceleration { get => rmsAcceleration; set =>SetProperty(ref rmsAcceleration , value); }
|
|
|
|
|
|
public ICommand AddCommand => new RelayCommand(Add);
|
|
|
+ public override void UpDateModel(RandomConfigModel model)
|
|
|
+ {
|
|
|
+ SpectrumItems.Clear();
|
|
|
+ PlanItems.Clear();
|
|
|
+ for(int i=0;i<model.SpectrumItems.Count;i++)
|
|
|
+ {
|
|
|
+ SpectrumItems.Add(new IndexValueItemViewModel<RandomSpectrumItemViewModel>(i + 1, new RandomSpectrumItemViewModel(model.SpectrumItems[i])));
|
|
|
+ }
|
|
|
+ for(int i=0;i<model.PlanItems.Count;i++)
|
|
|
+ {
|
|
|
+ PlanItems.Add(new IndexValueItemViewModel<RandomPlanItemViewModel>(i + 1, new RandomPlanItemViewModel(model.PlanItems[i])));
|
|
|
+ }
|
|
|
+ base.UpDateModel(model);
|
|
|
+
|
|
|
+ }
|
|
|
private void Add()
|
|
|
{
|
|
|
if (SpectrumItems.Count >= SpectrumItemsCount) return;
|
|
|
- SpectrumItems.Add(new IndexValueItemViewModel<RandomSpectrumItemViewModel>(SpectrumItems.Count + 1, new RandomSpectrumItemViewModel()));
|
|
|
+ if (Model.SpectrumItems.Count == 0) Model.SpectrumItems.Add(new RandomSpectrumItemModel());
|
|
|
+ else Model.SpectrumItems.Add(Model.SpectrumItems[^1].CloneBase());
|
|
|
+ SpectrumItems.Add(new IndexValueItemViewModel<RandomSpectrumItemViewModel>(SpectrumItems.Count + 1, new RandomSpectrumItemViewModel(Model.SpectrumItems[^1])));
|
|
|
}
|
|
|
public ICommand DeleteCommand => new RelayCommand(Delete);
|
|
|
private void Delete()
|
|
|
{
|
|
|
if (SpectrumItems.Count == 0) return;
|
|
|
+ if(Model.SpectrumItems.Count>0)
|
|
|
+ {
|
|
|
+ Model.SpectrumItems.RemoveAt(Model.SpectrumItems.Count - 1);
|
|
|
+ }
|
|
|
SpectrumItems.RemoveAt(SpectrumItems.Count - 1);
|
|
|
}
|
|
|
public ICommand ResetRMSCommand=>new RelayCommand(ResetRMSExecute);
|
|
@@ -285,6 +314,7 @@ namespace ShakerApp.ViewModels
|
|
|
for(int i=0;i<SpectrumItems.Count;i++)
|
|
|
{
|
|
|
SpectrumItems[i].Value.Value *= (ResetRMS*ResetRMS)/(RMSAcceleration * RMSAcceleration);
|
|
|
+ Model.SpectrumItems[0].Value = SpectrumItems[i].Value.Value;
|
|
|
}
|
|
|
CanResetRMS = false;
|
|
|
}
|
|
@@ -293,13 +323,19 @@ namespace ShakerApp.ViewModels
|
|
|
public ICommand AddPlanCommand => new RelayCommand(AddPlan);
|
|
|
private void AddPlan()
|
|
|
{
|
|
|
- if (PlanItems.Count >= 10) return;
|
|
|
- PlanItems.Add(new IndexValueItemViewModel<RandomPlanItemViewModel>(PlanItems.Count + 1, new RandomPlanItemViewModel()));
|
|
|
+ if (PlanItems.Count >= 10 || Model.PlanItems.Count>=10) return;
|
|
|
+ if (Model.PlanItems.Count == 0) Model.PlanItems.Add(new RandomPlanItemModel());
|
|
|
+ else Model.PlanItems.Add(Model.PlanItems[^1].CloneBase());
|
|
|
+ PlanItems.Add(new IndexValueItemViewModel<RandomPlanItemViewModel>(PlanItems.Count + 1, new RandomPlanItemViewModel(Model.PlanItems[^1])));
|
|
|
}
|
|
|
public ICommand DeletePlanCommand => new RelayCommand(DeletePlan);
|
|
|
private void DeletePlan()
|
|
|
{
|
|
|
if (PlanItems.Count == 0) return;
|
|
|
+ if(Model.PlanItems.Count==0)
|
|
|
+ {
|
|
|
+ Model.PlanItems.RemoveAt(Model.PlanItems.Count - 1);
|
|
|
+ }
|
|
|
PlanItems.RemoveAt(PlanItems.Count - 1);
|
|
|
}
|
|
|
public ICommand RefreshPlanCommand => new RelayCommand(RefreshPlan);
|
|
@@ -349,15 +385,7 @@ namespace ShakerApp.ViewModels
|
|
|
displacementdata.Clear();
|
|
|
for (int i=0;i<f.Length;i++)
|
|
|
{
|
|
|
- datas.Add(new SweepData()
|
|
|
- {
|
|
|
- Frequency = f[i],
|
|
|
- TargetAcceleration = spectrumdata[0, i],
|
|
|
- UpStopAcceleration = spectrumdata[1, i],
|
|
|
- UpWarnAcceleration = spectrumdata[2, i],
|
|
|
- DownStopAcceleration = spectrumdata[3, i],
|
|
|
- DownWarnAcceleration = spectrumdata[4, i]
|
|
|
- });
|
|
|
+ datas.Add(new RandomData(f[i],double.NaN, double.NaN, spectrumdata[0, i], spectrumdata[1, i], spectrumdata[3, i], spectrumdata[2, i], spectrumdata[4,i]));
|
|
|
velocitydata.Add(new DataPoint(f[i], Shaker.Models.Tools.Tools.AccelerationToVelocity(spectrumdata[0, i], f[i])));
|
|
|
displacementdata.Add(new DataPoint(f[i], Shaker.Models.Tools.Tools.AccelerationToDisplacement(spectrumdata[0, i], f[i])));
|
|
|
}
|