Explorar el Código

上传代码,新增数据预览

l2736 hace 1 semana
padre
commit
4a6e6dd026
Se han modificado 31 ficheros con 442 adiciones y 96 borrados
  1. 22 0
      Avalonia/ShakerApp/App.axaml.cs
  2. 17 0
      Avalonia/ShakerApp/Tools/Tools.cs
  3. 199 34
      Avalonia/ShakerApp/ViewModels/DataReview/BaseDataReviewItemViewModel.cs
  4. 1 0
      Avalonia/ShakerApp/ViewModels/DataReview/DataReviewViewModel.cs
  5. 10 1
      Avalonia/ShakerApp/ViewModels/DataReview/SelectTestDataViewModel.cs
  6. 11 0
      Avalonia/ShakerApp/ViewModels/DataReview/TimeDomainReviewViewModel.cs
  7. 3 3
      Avalonia/ShakerApp/ViewModels/DeviceManger/DeviceInfoViewModel.cs
  8. 1 11
      Avalonia/ShakerApp/ViewModels/MainPage/OutSignalMainPageViewModel.cs
  9. 1 1
      Avalonia/ShakerApp/ViewModels/MainPage/RandomMainPageViewModel.cs
  10. 2 1
      Avalonia/ShakerApp/ViewModels/MainPage/SineMainPageViewModel.cs
  11. 2 2
      Avalonia/ShakerApp/ViewModels/MainViewModel.cs
  12. 1 1
      Avalonia/ShakerApp/ViewModels/ShakerConfig/ShakerConfigViewModel.cs
  13. 1 1
      Avalonia/ShakerApp/ViewModels/ShakerControl/ShakerControlViewModel.cs
  14. 13 0
      Avalonia/ShakerApp/Views/DataReview/DataReviewView.axaml
  15. 13 0
      Avalonia/ShakerApp/Views/DataReview/DataReviewView.axaml.cs
  16. 20 7
      Avalonia/ShakerApp/Views/DataReview/SineDataReviewView.axaml
  17. 47 0
      Avalonia/ShakerApp/Views/DataReview/TimeDomainReviewView.axaml
  18. 13 0
      Avalonia/ShakerApp/Views/DataReview/TimeDomainReviewView.axaml.cs
  19. 1 1
      Avalonia/ShakerApp/Views/Device/DeviceMangerView.axaml
  20. 32 14
      Calc/SIMDFxpConvert/SIMDCalc.cs
  21. 3 0
      Language/Zh-CN/Language.axaml
  22. 1 1
      OxyPlot/OxyPlot.Avalonia/OxyPlot.Avalonia.csproj
  23. 1 1
      OxyPlot/OxyPlot.Avalonia/PlotBase.cs
  24. 3 2
      OxyPlot/OxyPlot/PlotModel/PlotModel.Rendering.cs
  25. 4 2
      OxyPlot/OxyPlot/PlotModel/PlotModel.cs
  26. 1 0
      OxyPlot/OxyPlot/Series/DataPointSeries.cs
  27. 8 3
      OxyPlot/OxyPlot/Series/XYAxisSeries.cs
  28. 7 6
      OxyPlot/OxyPlot/Utilities/ListBuilder{T}.cs
  29. 2 2
      Shaker.Model/Models/DeviceInfoModel.cs
  30. 1 1
      Shaker/Service.cs
  31. 1 1
      TDMS/Default/TDMSChannelGroup.cs

+ 22 - 0
Avalonia/ShakerApp/App.axaml.cs

@@ -6,13 +6,18 @@ using FxpConvert.Common;
 
 #if DEBUG
 using HotAvalonia;
+using OxyPlot;
+
 #endif
 using ShakerApp.ViewModels;
 using ShakerApp.Views;
 using System;
+using System.Collections.Generic;
 using System.Globalization;
 using System.Linq;
+using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
+using System.Runtime.Intrinsics;
 
 namespace ShakerApp;
 
@@ -30,6 +35,23 @@ public partial class App : Application
     }
     public override void OnFrameworkInitializationCompleted()
     {
+        Vector512<double> nv = Vector512<double>.One * double.NegativeInfinity;
+        Vector512<double> pv = Vector512<double>.One * double.PositiveInfinity;
+        DataPoint[] maxtempresult = Enumerable.Repeat(new DataPoint(double.MinValue, double.MaxValue), (int)(8 >> 1)).ToArray();
+        ref var maxresunlt = ref Unsafe.As<DataPoint, Vector512<double>>(ref maxtempresult[0]);
+        DataPoint[] mintempresult = Enumerable.Repeat(new DataPoint(double.MaxValue, double.MaxValue), (int)(8 >> 1)).ToArray();
+        ref var minresunlt = ref Unsafe.As<DataPoint, Vector512<double>>(ref maxtempresult[0]);
+        var first = Vector512.Create<double>(new double[] { 1, 2, 3, 6, double.NaN, double.NegativeInfinity, double.PositiveInfinity, 2 });
+        ref var tempv = ref Unsafe.Add(ref first, 0);
+        var errv = Vector512.Equals(tempv, tempv).AsInt64();
+        //errv = Vector512.AndNot(errv, Vector512<double>.One);
+        errv *= (Vector512.Equals(tempv,nv).AsInt64()+Vector512<long>.One);
+        errv *= (Vector512.Equals(tempv, pv).AsInt64() + Vector512<long>.One);
+        var tempmax = Vector512<double>.One * double.MaxValue;
+        var v = Vector512.ConditionalSelect<double>(errv.AsDouble(), tempv, tempmax);
+        var tempmin = Vector512<double>.One * double.MinValue;
+        maxresunlt = Vector512.Max(tempv, maxresunlt);
+        minresunlt = Vector512.Min(tempv, minresunlt);
         BindingPlugins.DataValidators.RemoveAt(0);
         ShakerSettingViewModel.Instance.Init();
 

+ 17 - 0
Avalonia/ShakerApp/Tools/Tools.cs

@@ -30,6 +30,23 @@ namespace ShakerApp.Tools
         {
             return MessagePack.MessagePackSerializer.Serialize(value,options);
         }
+
+        public static byte[] Serialize(Type type,object? value)
+        {
+            return MessagePack.MessagePackSerializer.Serialize(type, value, options);
+        }
+        public static object? Deserialize(Type type, ReadOnlyMemory<byte> bytes)
+        {
+            try
+            {
+                return MessagePack.MessagePackSerializer.Deserialize(type, bytes, options);
+            }
+            catch
+            {
+                return Activator.CreateInstance(type);
+            }
+        }
+
         public static T GetValue<T>(this byte[] data)
         {
             return MessagePackSerializer.Deserialize<T>(data,options);

+ 199 - 34
Avalonia/ShakerApp/ViewModels/DataReview/BaseDataReviewItemViewModel.cs

@@ -1,13 +1,23 @@
-using Shaker.Models;
+using Avalonia.Controls;
+using Shaker.Models;
+using ShakerApp.Tools;
 using System;
 using System.Collections;
+using System.Collections.Generic;
+using System.Data;
+using System.Diagnostics;
 using System.Diagnostics.CodeAnalysis;
 using System.Linq;
+using System.Text;
 
 namespace ShakerApp.ViewModels
 {
-    internal abstract class BaseDataReviewItemViewModel:DisplayViewModelBase<IModel>,IDataReviewItem
+    public abstract class BaseDataReviewItemViewModel:DisplayViewModelBase<IModel>,IDataReviewItem
     {
+        public BaseDataReviewItemViewModel()
+        {
+            TimeDomainReview = new TimeDomainReviewViewModel(this);
+        }
         private protected ShakerConfigModel ShakerConfig = new ShakerConfigModel();
         private protected ShakerControlModel ShakerControl = new ShakerControlModel();
         private protected DeviceInfoModel DeviceInfo = new DeviceInfoModel();
@@ -17,6 +27,8 @@ namespace ShakerApp.ViewModels
         public string File { get; } = string.Empty;
         [AllowNull]
         private protected TDMS.ITDMSFile tdmsfile;
+        [AllowNull]
+        public TimeDomainReviewViewModel TimeDomainReview { get; } 
         public virtual void OpenFile(string path) 
         {
             tdmsfile?.Close();
@@ -38,19 +50,19 @@ namespace ShakerApp.ViewModels
             if (tdmsfile == null) return;
             var group = tdmsfile.Contains(nameof(ShakerConfigModel)) ? tdmsfile[nameof(ShakerConfigModel)] : null;
             if (group == null) return;
-            GetConfig(ref ShakerConfig, group!);
+            GetConfig(ShakerConfig, group!);
             group = tdmsfile.Contains(nameof(ShakerControlModel)) ? tdmsfile[nameof(ShakerControlModel)] : null;
             if (group == null) return;
-            GetConfig(ref ShakerControl, group!);
+            GetConfig(ShakerControl, group!);
             group = tdmsfile.Contains(nameof(DeviceInfoModel)) ? tdmsfile[nameof(DeviceInfoModel)] : null;
             if (group == null) return;
-            GetConfig(ref DeviceInfo, group!);
+            GetConfig(DeviceInfo, group!);
+            TimeDomainReview.InitData();
         }
 
-        private protected void GetConfig<T>(ref T config,TDMS.ITDMSChannelGroup group)
+        private protected void GetConfig<T>(T config,TDMS.ITDMSChannelGroup group)
         {
-            typeof(T).GetType()
-                .GetFields(System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public)
+            typeof(T).GetFields(System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public)
                 .ToList()
                 .ForEach(x =>
                 {
@@ -63,143 +75,154 @@ namespace ShakerApp.ViewModels
                             {
                                 bytes[i] = System.Convert.ToByte(val.Substring(i * 2, 2), 16);
                             }
-                            x.SetValue(MessagePack.MessagePackSerializer.Deserialize(x.FieldType, bytes), ShakerConfig);
+                            x.SetValue(config,ShakerApp.Tools.Tools.Deserialize(x.FieldType, bytes));
                         }
                         else
                         {
-                            x.SetValue(Activator.CreateInstance(x.FieldType), ShakerConfig);
+                            x.SetValue(config,Activator.CreateInstance(x.FieldType));
+                        }
+                    }
+                    else if(x.FieldType == typeof(string))
+                    {
+                        if (group.TryGetProperty<string>(x.Name, out var val) && !string.IsNullOrEmpty(val))
+                        {
+                            x.SetValue(config,val);
+                        }
+                        else
+                        {
+                            x.SetValue(config,string.Empty);
                         }
                     }
                     else if (x.FieldType.IsEnum)
                     {
                         if (group.TryGetProperty<string>(x.Name, out var val) && !string.IsNullOrEmpty(val))
                         {
-                            x.SetValue(Enum.Parse(x.FieldType, val), ShakerConfig);
+                            x.SetValue(config,Enum.Parse(x.FieldType, val));
                         }
                         else
                         {
-                            x.SetValue(Enum.GetValues(x.FieldType), ShakerConfig);
+                            x.SetValue(config,Enum.GetValues(x.FieldType));
                         }
                     }
                     else if (x.FieldType == typeof(byte))
                     {
                         if (group.TryGetProperty<string>(x.Name, out var val) && !string.IsNullOrEmpty(val) && byte.TryParse(val, out var b))
                         {
-                            x.SetValue(b, ShakerConfig);
+                            x.SetValue(config,b);
                         }
                         else
                         {
-                            x.SetValue((byte)0, ShakerConfig);
+                            x.SetValue(config,(byte)0);
                         }
                     }
                     else if (x.FieldType == typeof(sbyte))
                     {
                         if (group.TryGetProperty<string>(x.Name, out var val) && !string.IsNullOrEmpty(val) && sbyte.TryParse(val, out var b))
                         {
-                            x.SetValue(b, ShakerConfig);
+                            x.SetValue(config,b);
                         }
                         else
                         {
-                            x.SetValue((sbyte)0, ShakerConfig);
+                            x.SetValue(config,(sbyte)0);
                         }
                     }
                     else if (x.FieldType == typeof(short))
                     {
                         if (group.TryGetProperty<string>(x.Name, out var val) && !string.IsNullOrEmpty(val) && short.TryParse(val, out var b))
                         {
-                            x.SetValue(b, ShakerConfig);
+                            x.SetValue(config,b);
                         }
                         else
                         {
-                            x.SetValue((short)0, ShakerConfig);
+                            x.SetValue(config,(short)0);
                         }
                     }
                     else if (x.FieldType == typeof(ushort))
                     {
                         if (group.TryGetProperty<string>(x.Name, out var val) && !string.IsNullOrEmpty(val) && ushort.TryParse(val, out var b))
                         {
-                            x.SetValue(b, ShakerConfig);
+                            x.SetValue(config,b);
                         }
                         else
                         {
-                            x.SetValue((ushort)0, ShakerConfig);
+                            x.SetValue(config,(ushort)0);
                         }
                     }
                     else if (x.FieldType == typeof(int))
                     {
                         if (group.TryGetProperty<string>(x.Name, out var val) && !string.IsNullOrEmpty(val) && int.TryParse(val, out var b))
                         {
-                            x.SetValue(b, ShakerConfig);
+                            x.SetValue(config,b);
                         }
                         else
                         {
-                            x.SetValue((int)0, ShakerConfig);
+                            x.SetValue(config,(int)0);
                         }
                     }
                     else if (x.FieldType == typeof(uint))
                     {
                         if (group.TryGetProperty<string>(x.Name, out var val) && !string.IsNullOrEmpty(val) && uint.TryParse(val, out var b))
                         {
-                            x.SetValue(b, ShakerConfig);
+                            x.SetValue(config,b);
                         }
                         else
                         {
-                            x.SetValue((uint)0, ShakerConfig);
+                            x.SetValue(config,(uint)0);
                         }
                     }
                     else if (x.FieldType == typeof(long))
                     {
                         if (group.TryGetProperty<string>(x.Name, out var val) && !string.IsNullOrEmpty(val) && long.TryParse(val, out var b))
                         {
-                            x.SetValue(b, ShakerConfig);
+                            x.SetValue(config,b);
                         }
                         else
                         {
-                            x.SetValue((long)0, ShakerConfig);
+                            x.SetValue(config,(long)0);
                         }
                     }
                     else if (x.FieldType == typeof(ulong))
                     {
                         if (group.TryGetProperty<string>(x.Name, out var val) && !string.IsNullOrEmpty(val) && ulong.TryParse(val, out var b))
                         {
-                            x.SetValue(b, ShakerConfig);
+                            x.SetValue(config,b);
                         }
                         else
                         {
-                            x.SetValue((ulong)0, ShakerConfig);
+                            x.SetValue(config,(ulong)0);
                         }
                     }
                     else if (x.FieldType == typeof(float))
                     {
                         if (group.TryGetProperty<string>(x.Name, out var val) && !string.IsNullOrEmpty(val) && float.TryParse(val, out var b))
                         {
-                            x.SetValue(b, ShakerConfig);
+                            x.SetValue(config,b);
                         }
                         else
                         {
-                            x.SetValue((float)0, ShakerConfig);
+                            x.SetValue(config,(float)0);
                         }
                     }
                     else if (x.FieldType == typeof(double))
                     {
                         if (group.TryGetProperty<string>(x.Name, out var val) && !string.IsNullOrEmpty(val) && double.TryParse(val, out var b))
                         {
-                            x.SetValue(b, ShakerConfig);
+                            x.SetValue(config,b);
                         }
                         else
                         {
-                            x.SetValue((double)0, ShakerConfig);
+                            x.SetValue(config,(double)0);
                         }
                     }
                     else if (x.FieldType == typeof(bool))
                     {
                         if (group.TryGetProperty<string>(x.Name, out var val) && !string.IsNullOrEmpty(val) && bool.TryParse(val, out var b))
                         {
-                            x.SetValue(b, ShakerConfig);
+                            x.SetValue(config,b);
                         }
                         else
                         {
-                            x.SetValue(false, ShakerConfig);
+                            x.SetValue(config,false);
                         }
                     }
                 });
@@ -210,5 +233,147 @@ namespace ShakerApp.ViewModels
             tdmsfile?.Dispose();
             tdmsfile = null;
         }
+
+
+
+        public class TimeDomainReviewViewModel : DisplayViewModelBase<IModel>
+        {
+            private bool isinint = false;
+            List<OxyPlot.Series.LineSeries> _LineSeries = new List<OxyPlot.Series.LineSeries>();
+            public OxyPlot.PlotModel PlotModel { get; } = new OxyPlot.PlotModel();
+            private BaseDataReviewItemViewModel _Parent;
+            public uint SampleRate { get => sampleRate; set =>SetProperty(ref sampleRate , value); }
+            public uint TotalPages
+            {
+                get => Math.Clamp(totalPages, 1, uint.MaxValue);
+                set
+                {
+                    SetProperty(ref totalPages, value);
+                    OnPropertyChanged(nameof(MaxPageIndex));
+                    OnPropertyChanged(nameof(MaxReadPages));
+                    OnPropertyChanged(nameof(PageIndex));
+                    OnPropertyChanged(nameof(ReadPages));
+                }
+            }
+            public uint PageIndex 
+            { 
+                get =>Math.Clamp(pageIndex,MinPageIndex,MaxPageIndex);
+                set
+                {
+                    SetProperty(ref pageIndex, value);
+                    OnPropertyChanged(nameof(MaxReadPages));
+                    OnPropertyChanged(nameof(ReadPages));
+                    LoadData();
+                }
+            }
+            public uint MinPageIndex => 1;
+            public uint MaxPageIndex => TotalPages;
+            public uint ReadPages 
+            {
+                get =>Math.Clamp(readPages,MinReadPages,MaxReadPages);
+                set
+                {
+                    SetProperty(ref readPages, value);
+                    LoadData();
+                }
+            }
+            public uint MinReadPages => 1;
+            public uint MaxReadPages => Math.Clamp(TotalPages - PageIndex + 1, 1, 10000);
+            public TimeDomainReviewViewModel(BaseDataReviewItemViewModel parent)
+            {
+                _Parent = parent;
+                PlotModel.Axes.Add(new OxyPlot.Axes.LinearAxis()
+                {
+                    Position = OxyPlot.Axes.AxisPosition.Bottom,
+                    Key = "X",
+                    Title = App.Current?.FindResource("Time") +"",
+                    Unit = "s",
+                    MinimumPadding = 0,
+                    MaximumPadding = 0,
+                });
+                PlotModel.Axes.Add(new OxyPlot.Axes.LinearAxis()
+                {
+                    Position = OxyPlot.Axes.AxisPosition.Left,
+                    Key = "Y",
+                    Title = App.Current?.FindResource("")+"",
+                    MinimumPadding = 0,
+                    MaximumPadding = 0,
+                });
+                PlotModel.Legends.Add(new OxyPlot.Legends.Legend()
+                {
+                    IsLegendVisible = true,
+                });
+            }
+            private TDMS.ITDMSChannelGroup? _DataGroup;
+            private List<TDMS.ITDMSChannel> _Channels = new List<TDMS.ITDMSChannel>();
+            private uint readPages;
+            private uint pageIndex;
+            private uint totalPages;
+            private uint sampleRate;
+
+            public override void InitData()
+            {
+                isinint = false;
+                base.InitData();
+                _DataGroup = _Parent.tdmsfile.Contains(BaseMainPageViewModel<IModel>.TimeDomainData) ? _Parent.tdmsfile[BaseMainPageViewModel<IModel>.TimeDomainData] : null;
+                if (_DataGroup == null)
+                {
+                    DataReviewViewModel.Instance.ShowError(App.Current?.FindResource("TestFileReadError")+"");
+                    return;
+                }
+                _Channels.Clear();
+                _LineSeries.Clear();
+                PlotModel.Series.Clear();
+                if(_DataGroup.ChildCount ==0)
+                {
+                    DataReviewViewModel.Instance.ShowError(App.Current?.FindResource("TestFileReadError") + "");
+                    return;
+                }
+                PlotModel.InvalidatePlot(false);
+                for(ulong i=0;i<_DataGroup.ChildCount;i++)
+                {
+                    _Channels.Add(_DataGroup[(int)i]!);
+                    _LineSeries.Add(new OxyPlot.Series.LineSeries()
+                    {
+                        XAxisKey = "X",
+                        YAxisKey = "Y",
+                        DataFieldX = nameof(OxyPlot.DataPoint.X),
+                        DataFieldY = nameof(OxyPlot.DataPoint.Y),
+                        Title = App.Current?.FindResource(_Channels[^1].Name)+"",
+                        Tag = _Channels[^1].Unit,
+                    });
+                    PlotModel.Series.Add(_LineSeries[^1]);
+                }
+                PlotModel.InvalidatePlot(true);
+                SampleRate = _Parent.ShakerConfig.SampleRate;
+                TotalPages = (uint)Math.Ceiling(_Channels[0].ChildCount / (double)SampleRate);
+                ReadPages = 1;
+                PageIndex = 1;
+                isinint = true;
+                LoadData();
+            }
+
+            private void LoadData()
+            {
+                if (!isinint) return;
+                uint start = (PageIndex - 1) * SampleRate;
+                uint len = ReadPages * SampleRate;
+                len = (uint)Math.Clamp(len, len, _Channels[^1].ChildCount - start);
+                double pro = 1d / SampleRate;
+                //var datas = Enumerable.Repeat(new OxyPlot.DataPoint(), 1000_000).ToList();
+                PlotModel.InvalidatePlot(false);
+                
+                for(int i=0;i<_Channels.Count;i++)
+                {
+                    uint index = 0;
+                    _LineSeries[i].ItemsSource = _Channels[i].GetDataValues<double>(start, len).Select(x =>
+                    {
+                        return new OxyPlot.DataPoint((index++) * pro, x);
+                    }).ToList();
+                    // _LineSeries[i].ItemsSource = datas;
+                }
+                PlotModel.InvalidatePlot(true);
+            }
+        }
     }
 }

+ 1 - 0
Avalonia/ShakerApp/ViewModels/DataReview/DataReviewViewModel.cs

@@ -46,6 +46,7 @@ namespace ShakerApp.ViewModels
             DataReviews[MainPageType.SinePage] = SineDataReviewViewModel.Instance;
             DataReviews[MainPageType.OutSignal] = OutSignalDataReviewViewModel.Instance;
             CurrentDataReview = DataReviews[MainPageType.StartPage];
+            Content = typeof(Views.DataReviewView);
         }
         static DataReviewViewModel()
         {

+ 10 - 1
Avalonia/ShakerApp/ViewModels/DataReview/SelectTestDataViewModel.cs

@@ -41,7 +41,16 @@ namespace ShakerApp.ViewModels
             if(!string.IsNullOrEmpty(SelectedFile) && System.IO.File.Exists(SelectedFile))
             {
                 await Task.Delay(1);
-                DataReviewViewModel.Instance.OpenFile(SelectedFile);
+                if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
+                {
+                    DataReviewViewModel.Instance.InitData();
+                    DataReviewViewModel.Instance.Title = "DataReview";
+                    BaseDialogWindow window = new BaseDialogWindow();
+                    window.DataContext = DataReviewViewModel.Instance;
+                    DeviceMangerViewModel.Instance.CloseWindowAction = () => window?.Close();
+                    DataReviewViewModel.Instance.OpenFile(SelectedFile);
+                    await window.ShowDialog(desktop.MainWindow!);
+                }
             }
         }
 

+ 11 - 0
Avalonia/ShakerApp/ViewModels/DataReview/TimeDomainReviewViewModel.cs

@@ -0,0 +1,11 @@
+using Shaker.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ShakerApp.ViewModels
+{
+    
+}

+ 3 - 3
Avalonia/ShakerApp/ViewModels/DeviceManger/DeviceInfoViewModel.cs

@@ -37,7 +37,7 @@ namespace ShakerApp.ViewModels
                     }
                     if (x.x.FieldType.IsAssignableTo(typeof(IList)) || x.x.FieldType.IsArray)
                     {
-                        group.CreateOrUpdateProperty($"{x.x.Name}", string.Join("", x.Item2.GetBytes().Select(x => $"{x:X2}")));
+                        group.CreateOrUpdateProperty($"{x.x.Name}", string.Join("",Tools.Tools.Serialize(x.x.FieldType, x.Item2).Select(x => $"{x:X2}")));
                     }
                     else
                     {
@@ -45,8 +45,8 @@ namespace ShakerApp.ViewModels
                     }
                 });
         }
-        [PropertyAssociation(nameof(DeviceInfoModel.Name))]
-        public string Name { get => Model.Name; set => SetProperty(ref Model.Name, value); }
+        [PropertyAssociation(nameof(DeviceInfoModel.DeviceName))]
+        public string DeviceName { get => Model.DeviceName; set => SetProperty(ref Model.DeviceName, value); }
         [PropertyAssociation(nameof(DeviceInfoModel.SN))]
         public string SN { get => Model.SN; set => SetProperty(ref Model.SN, value); }
         [PropertyAssociation(nameof(DeviceInfoModel.IP))]

+ 1 - 11
Avalonia/ShakerApp/ViewModels/MainPage/OutSignalMainPageViewModel.cs

@@ -1,16 +1,6 @@
-using Avalonia.Collections;
-using Avalonia.Controls;
-using Shaker.Models;
-using ShakerApp.Models;
+using Shaker.Models;
 using ShakerApp.Tools;
-using ShakerApp.Views;
-using System;
 using System.Collections.Generic;
-using System.ComponentModel.DataAnnotations;
-using System.Diagnostics.CodeAnalysis;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
 
 namespace ShakerApp.ViewModels
 {

+ 1 - 1
Avalonia/ShakerApp/ViewModels/MainPage/RandomMainPageViewModel.cs

@@ -154,7 +154,7 @@ namespace ShakerApp.ViewModels
                     }
                     if (x.x.FieldType.IsAssignableTo(typeof(IList)) || x.x.FieldType.IsArray)
                     {
-                        group.CreateOrUpdateProperty($"{x.x.Name}", string.Join("", x.Item2.GetBytes().Select(x => $"{x:X2}")));
+                        group.CreateOrUpdateProperty($"{x.x.Name}", string.Join("", Tools.Tools.Serialize(x.x.FieldType, x.Item2).Select(x => $"{x:X2}")));
                     }
                     else
                     {

+ 2 - 1
Avalonia/ShakerApp/ViewModels/MainPage/SineMainPageViewModel.cs

@@ -121,7 +121,7 @@ namespace ShakerApp.ViewModels
                     }
                     if (x.x.FieldType.IsAssignableTo(typeof(IList)) || x.x.FieldType.IsArray)
                     {
-                        group.CreateOrUpdateProperty($"{x.x.Name}", string.Join("", x.Item2.GetBytes().Select(x => $"{x:X2}")));
+                        group.CreateOrUpdateProperty($"{x.x.Name}", string.Join("", Tools.Tools.Serialize(x.x.FieldType, x.Item2).Select(x => $"{x:X2}")));
                     }
                     else
                     {
@@ -269,6 +269,7 @@ namespace ShakerApp.ViewModels
                 {
                     ch.AppendData(savemodels.Select(x => (int)x.SweepIndex).ToArray());
                 }
+                file.Save();
             }
             catch(Exception ex)
             {

+ 2 - 2
Avalonia/ShakerApp/ViewModels/MainViewModel.cs

@@ -110,11 +110,11 @@ public class MainViewModel : DisplayViewModelBase<IModel>
         {
             if(MainPageViewModel.Instance.MainPageType == MainPageType.StartPage)
             {
-                s = $"{App.Current?.FindResource("Title")}-{ViewModels.DeviceMangerViewModel.Instance.CurrentDevice!.Name}[{CommunicationViewModel.Instance.LocalCommunication.IP}:{CommunicationViewModel.Instance.LocalCommunication.Port}]";
+                s = $"{App.Current?.FindResource("Title")}-{ViewModels.DeviceMangerViewModel.Instance.CurrentDevice!.DeviceName}[{CommunicationViewModel.Instance.LocalCommunication.IP}:{CommunicationViewModel.Instance.LocalCommunication.Port}]";
             }
             else
             {
-                s = $"{App.Current?.FindResource("Title")}-{ViewModels.DeviceMangerViewModel.Instance.CurrentDevice!.Name}-[{App.Current?.FindResource(MainPageViewModel.Instance.MainPageType.Description())}]";
+                s = $"{App.Current?.FindResource("Title")}-{ViewModels.DeviceMangerViewModel.Instance.CurrentDevice!.DeviceName}-[{App.Current?.FindResource(MainPageViewModel.Instance.MainPageType.Description())}]";
             }
         }
         else

+ 1 - 1
Avalonia/ShakerApp/ViewModels/ShakerConfig/ShakerConfigViewModel.cs

@@ -143,7 +143,7 @@ namespace ShakerApp.ViewModels
                     }
                     if(x.x.FieldType.IsAssignableTo(typeof(IList)) || x.x.FieldType.IsArray)
                     {
-                        group.CreateOrUpdateProperty($"{x.x.Name}", string.Join("", x.Item2.GetBytes().Select(x => $"{x:X2}"))); 
+                        group.CreateOrUpdateProperty($"{x.x.Name}", string.Join("", Tools.Tools.Serialize(x.x.FieldType, x.Item2).Select(x => $"{x:X2}"))); 
                     }
                     else
                     {

+ 1 - 1
Avalonia/ShakerApp/ViewModels/ShakerControl/ShakerControlViewModel.cs

@@ -37,7 +37,7 @@ namespace ShakerApp.ViewModels
                     }
                     if (x.x.FieldType.IsAssignableTo(typeof(IList)) || x.x.FieldType.IsArray)
                     {
-                        group.CreateOrUpdateProperty($"{x.x.Name}",string.Join("", x.Item2.GetBytes().Select(x => $"{x:X2}")));
+                        group.CreateOrUpdateProperty($"{x.x.Name}",string.Join("", Tools.Tools.Serialize(x.x.FieldType, x.Item2).Select(x => $"{x:X2}")));
                     }
                     else
                     {

+ 13 - 0
Avalonia/ShakerApp/Views/DataReview/DataReviewView.axaml

@@ -0,0 +1,13 @@
+<UserControl
+    x:Class="ShakerApp.Views.DataReviewView"
+    xmlns="https://github.com/avaloniaui"
+    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+    xmlns:vm="using:ShakerApp.ViewModels"
+    d:DesignHeight="450"
+    d:DesignWidth="800"
+    x:DataType="vm:DataReviewViewModel"
+    mc:Ignorable="d">
+    <ContentPresenter Content="{Binding CurrentDataReview.Content, Converter={StaticResource Type2ViewConverter}}" />
+</UserControl>

+ 13 - 0
Avalonia/ShakerApp/Views/DataReview/DataReviewView.axaml.cs

@@ -0,0 +1,13 @@
+using Avalonia;
+using Avalonia.Controls;
+using Avalonia.Markup.Xaml;
+
+namespace ShakerApp.Views;
+
+public partial class DataReviewView : UserControl
+{
+    public DataReviewView()
+    {
+        InitializeComponent();
+    }
+}

+ 20 - 7
Avalonia/ShakerApp/Views/DataReview/SineDataReviewView.axaml

@@ -1,8 +1,21 @@
-<UserControl xmlns="https://github.com/avaloniaui"
-             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
-             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
-             mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
-             x:Class="ShakerApp.Views.SineDataReviewView">
-  Welcome to Avalonia!
+<UserControl
+    x:Class="ShakerApp.Views.SineDataReviewView"
+    xmlns="https://github.com/avaloniaui"
+    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+    xmlns:oxy="http://oxyplot.org/avalonia"
+    xmlns:view="using:ShakerApp.Views"
+    xmlns:vm="using:ShakerApp.ViewModels"
+    d:DesignHeight="450"
+    d:DesignWidth="800"
+    x:DataType="vm:SineDataReviewViewModel"
+    DataContext="{Binding CurrentDataReview}"
+    mc:Ignorable="d">
+    <TabControl>
+        <TabItem Header="{DynamicResource TimeDomainData}">
+            <view:TimeDomainReviewView />
+        </TabItem>
+        <TabItem Header="{DynamicResource SweepData}" />
+    </TabControl>
 </UserControl>

+ 47 - 0
Avalonia/ShakerApp/Views/DataReview/TimeDomainReviewView.axaml

@@ -0,0 +1,47 @@
+<UserControl
+    x:Class="ShakerApp.Views.TimeDomainReviewView"
+    xmlns="https://github.com/avaloniaui"
+    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+    xmlns:oxy="http://oxyplot.org/avalonia"
+    xmlns:vm="using:ShakerApp.ViewModels"
+    d:DesignHeight="450"
+    d:DesignWidth="800"
+    x:DataType="vm:DataReviewViewModel"
+    DataContext="{Binding Source={x:Static vm:DataReviewViewModel.Instance}, Path=CurrentDataReview.TimeDomainReview}"
+    mc:Ignorable="d">
+    <Grid RowDefinitions="42,*">
+        <UniformGrid Grid.Row="0" Rows="1">
+            <StackPanel Orientation="Horizontal">
+                <TextBlock VerticalAlignment="Center" Text="采样率:" />
+                <TextBlock VerticalAlignment="Center" Text="{Binding SampleRate}" />
+            </StackPanel>
+            <StackPanel Orientation="Horizontal">
+                <TextBlock VerticalAlignment="Center" Text="总帧数:" />
+                <TextBlock VerticalAlignment="Center" Text="{Binding TotalPages}" />
+            </StackPanel>
+            <StackPanel Orientation="Horizontal">
+                <TextBlock VerticalAlignment="Center" Text="起始帧数:" />
+                <NumericUpDown
+                    MinWidth="80"
+                    Margin="4,0,0,0"
+                    Increment="1"
+                    Maximum="{Binding MaxPageIndex}"
+                    Minimum="{Binding MinPageIndex}"
+                    Value="{Binding PageIndex}" />
+            </StackPanel>
+            <StackPanel Orientation="Horizontal">
+                <TextBlock VerticalAlignment="Center" Text="读取帧数:" />
+                <NumericUpDown
+                    MinWidth="80"
+                    Margin="4,0,0,0"
+                    Increment="1"
+                    Maximum="{Binding MaxReadPages}"
+                    Minimum="{Binding MinReadPages}"
+                    Value="{Binding ReadPages}" />
+            </StackPanel>
+        </UniformGrid>
+        <oxy:PlotView Grid.Row="1" Model="{Binding PlotModel}" />
+    </Grid>
+</UserControl>

+ 13 - 0
Avalonia/ShakerApp/Views/DataReview/TimeDomainReviewView.axaml.cs

@@ -0,0 +1,13 @@
+using Avalonia;
+using Avalonia.Controls;
+using Avalonia.Markup.Xaml;
+
+namespace ShakerApp.Views;
+
+public partial class TimeDomainReviewView : UserControl
+{
+    public TimeDomainReviewView()
+    {
+        InitializeComponent();
+    }
+}

+ 1 - 1
Avalonia/ShakerApp/Views/Device/DeviceMangerView.axaml

@@ -108,7 +108,7 @@
                                 Grid.Column="1"
                                 HorizontalAlignment="Center"
                                 VerticalAlignment="Center"
-                                Text="{Binding Value.Name}" />
+                                Text="{Binding Value.DeviceName}" />
                             <TextBlock
                                 Grid.Column="2"
                                 HorizontalAlignment="Center"

+ 32 - 14
Calc/SIMDFxpConvert/SIMDCalc.cs

@@ -321,10 +321,7 @@ namespace SIMDFxpConvert
             {
                 ref var tempref = ref Unsafe.Add(ref refvalue, i);
                 var t = tempref * tempref;
-                for (int j = 0; j < onecount; j++)
-                {
-                    temp += t[j];
-                }
+                temp += Vector512.Sum(tempref);
             }
             if (c1 > 0)
             {
@@ -351,10 +348,7 @@ namespace SIMDFxpConvert
             {
                 ref var tempref = ref Unsafe.Add(ref refvalue, i);
                 tempref *= tempref;
-                for (int j = 0; j < onecount; j++)
-                {
-                    temp += tempref[j];
-                }
+                temp += Vector512.Sum(tempref);
             }
             if (c1 > 0)
             {
@@ -370,11 +364,23 @@ namespace SIMDFxpConvert
         {
             if (count == 0) return 0;
             if (count == 1) return value;
+            float temp = 0;
             float* ptr = (float*)Unsafe.AsPointer(ref value);
-            float temp = value;
-            for (int i = 1; i < count; i++)
+            uint onecount = (uint)(512 / (Unsafe.SizeOf<float>() * 8));
+            uint c = count / onecount;
+            uint c1 = count % onecount;
+            uint start = c * onecount;
+            ref var refvalue = ref Unsafe.As<float, System.Runtime.Intrinsics.Vector512<float>>(ref value);
+            for (int i = 0; i < c; i++)
+            {
+                temp += Vector512.Sum(Unsafe.Add(ref refvalue, i));
+            }
+            if (c1 > 0)
             {
-                temp += ptr[i];
+                for (int i = 0; i < c1; i++)
+                {
+                    temp += (ptr[start + i] * ptr[start + i]);
+                }
             }
             return temp;
         }
@@ -383,11 +389,23 @@ namespace SIMDFxpConvert
         {
             if (count == 0) return 0;
             if (count == 1) return value;
+            double temp = 0;
             double* ptr = (double*)Unsafe.AsPointer(ref value);
-            double temp = value;
-            for (int i = 1; i < count; i++)
+            uint onecount = (uint)(512 / (Unsafe.SizeOf<double>() * 8));
+            uint c = count / onecount;
+            uint c1 = count % onecount;
+            uint start = c * onecount;
+            ref var refvalue = ref Unsafe.As<double, System.Runtime.Intrinsics.Vector512<double>>(ref value);
+            for (int i = 0; i < c; i++)
+            {
+                temp += Vector512.Sum(Unsafe.Add(ref refvalue, i));
+            }
+            if (c1 > 0)
             {
-                temp += ptr[i];
+                for (int i = 0; i < c1; i++)
+                {
+                    temp += (ptr[start + i] * ptr[start + i]);
+                }
             }
             return temp;
         }

+ 3 - 0
Language/Zh-CN/Language.axaml

@@ -261,7 +261,10 @@
     <s:String x:Key="BitstreamMD5">固件MD5</s:String>
     <s:String x:Key="UpBitfile">更新固件</s:String>
     <s:String x:Key="Weight">权重</s:String>
+    <s:String x:Key="TimeDomainData">时域数据</s:String>
+    <s:String x:Key="SweepData">扫频数据</s:String>
 
+    <s:String x:Key="TestFileReadError">实验数据读取错误</s:String>
 
 
     <s:String x:Key="Network">网络设置</s:String>

+ 1 - 1
OxyPlot/OxyPlot.Avalonia/OxyPlot.Avalonia.csproj

@@ -1,6 +1,6 @@
 <Project Sdk="Microsoft.NET.Sdk">
   <PropertyGroup>
-    <TargetFramework>netstandard2.0</TargetFramework>
+    <TargetFramework>net8.0</TargetFramework>
     <PackageId>Oxyplot.Avalonia</PackageId>
     <GeneratePackageOnBuild>False</GeneratePackageOnBuild>
     <Description>OxyPlot is a plotting library for .NET. This is a support library for OxyPlot to work with AvaloniaUI.</Description>

+ 1 - 1
OxyPlot/OxyPlot.Avalonia/PlotBase.cs

@@ -20,6 +20,7 @@ namespace OxyPlot.Avalonia
     using global::Avalonia.VisualTree;
     using System;
     using System.Collections.ObjectModel;
+    using System.Diagnostics;
     using System.Linq;
     using System.Threading;
 
@@ -401,7 +402,6 @@ namespace OxyPlot.Avalonia
                 isUpdateRequired = 0;
                 return;
             }
-
             lock (this.ActualModel.SyncRoot)
             {
                 var updateState = (Interlocked.Exchange(ref isUpdateRequired, 0));

+ 3 - 2
OxyPlot/OxyPlot/PlotModel/PlotModel.Rendering.cs

@@ -17,6 +17,7 @@ namespace OxyPlot
     using OxyPlot.Axes;
     using OxyPlot.Series;
     using OxyPlot.Legends;
+    using System.Diagnostics;
 
     /// <summary>
     /// Represents a plot.
@@ -99,10 +100,10 @@ namespace OxyPlot
                     }
 
                     this.RenderBackgrounds(rc);
-                    this.RenderAnnotations(rc, AnnotationLayer.BelowAxes);
+                    this.RenderAnnotations(rc, AnnotationLayer.BelowAxes);//14ms
                     this.RenderAxes(rc, AxisLayer.BelowSeries);
                     this.RenderAnnotations(rc, AnnotationLayer.BelowSeries);
-                    this.RenderSeries(rc);
+                    this.RenderSeries(rc);//1170;
                     this.RenderAnnotations(rc, AnnotationLayer.AboveSeries);
                     this.RenderTitle(rc);
                     this.RenderBox(rc);

+ 4 - 2
OxyPlot/OxyPlot/PlotModel/PlotModel.cs

@@ -11,6 +11,7 @@ namespace OxyPlot
 {
     using System;
     using System.Collections.Generic;
+    using System.Diagnostics;
     using System.Globalization;
     using System.Linq;
 
@@ -778,7 +779,7 @@ namespace OxyPlot
                 {
                     this.lastPlotException = null;
                     this.OnUpdating();
-
+                    Stopwatch sw = Stopwatch.StartNew();
                     // Updates the default axes
                     this.EnsureDefaultAxes();
 
@@ -795,13 +796,13 @@ namespace OxyPlot
                         this.isDataUpdated = true;
                     }
 
-
                     // Updates bar series managers and associated category axes
                     this.UpdateBarSeriesManagers();
 
                     // Update the max and min of the axes
                     this.UpdateMaxMin(updateData);
 
+                    sw.Stop();
                     // Update category axes that are not managed by bar series managers
                     this.UpdateUnmanagedCategoryAxes();
 
@@ -817,6 +818,7 @@ namespace OxyPlot
                     }
 
                     this.OnUpdated();
+                    //Debug.WriteLine(sw.ElapsedMilliseconds);
                 }
                 catch (Exception e)
                 {

+ 1 - 0
OxyPlot/OxyPlot/Series/DataPointSeries.cs

@@ -11,6 +11,7 @@ namespace OxyPlot.Series
 {
     using System;
     using System.Collections.Generic;
+    using System.Diagnostics;
 
     /// <summary>
     /// Provides an abstract base class for series that contain a collection of <see cref="DataPoint" />s.

+ 8 - 3
OxyPlot/OxyPlot/Series/XYAxisSeries.cs

@@ -11,8 +11,11 @@ namespace OxyPlot.Series
 {
     using System;
     using System.Collections.Generic;
+    using System.ComponentModel.DataAnnotations;
+    using System.Diagnostics;
     using System.Linq;
-
+    using System.Runtime.CompilerServices;
+    using System.Runtime.Intrinsics;
     using OxyPlot.Axes;
 
     /// <summary>
@@ -377,7 +380,10 @@ namespace OxyPlot.Series
                 this.XAxis != null && this.XAxis.IsValidValue(x) &&
                 this.YAxis != null && this.YAxis.IsValidValue(y);
         }
-
+        Vector512<double> nv = Vector512<double>.One * double.NegativeInfinity;
+        Vector512<double> pv = Vector512<double>.One * double.PositiveInfinity;
+        Vector512<double> maxv = Vector512<double>.One * double.MaxValue;
+        Vector512<double> minv = Vector512<double>.One * double.MinValue;
         /// <summary>
         /// Updates the Max/Min limits from the specified <see cref="DataPoint" /> list.
         /// </summary>
@@ -460,7 +466,6 @@ namespace OxyPlot.Series
 
                 lastX = x;
             }
-
             if (minx < double.MaxValue)
             {
                 if (minx < this.XAxis.FilterMinValue)

+ 7 - 6
OxyPlot/OxyPlot/Utilities/ListBuilder{T}.cs

@@ -73,16 +73,17 @@ namespace OxyPlot
         /// <param name="instanceCreator">The instance creator.</param>
         public void Fill(IList target, IEnumerable source, Func<IList<object?>, object?> instanceCreator)
         {
+
             ReflectionPath?[]? pi = null;
             Type? t = null;
+            Type? itemtype = source.GetType().GetMethods().FirstOrDefault(x => x.Name == "get_Item")?.ReturnType;
+            if (pi == null || itemtype != t)
+            {
+                t = itemtype;
+                pi = this.properties.Select(p => p != null ? new ReflectionPath(p) : null).ToArray();
+            }
             foreach (var sourceItem in source)
             {
-                if (pi == null || sourceItem.GetType() != t)
-                {
-                    t = sourceItem.GetType();
-                    pi = this.properties.Select(p => p != null ? new ReflectionPath(p) : null).ToArray();
-                }
-
                 var args = new List<object?>(pi.Length);
                 for (int j = 0; j < pi.Length; j++)
                 {

+ 2 - 2
Shaker.Model/Models/DeviceInfoModel.cs

@@ -8,13 +8,13 @@ namespace Shaker.Models
 {
     public class DeviceInfoModel : BaseModel
     {
-        public string Name = string.Empty;
+        public string DeviceName = string.Empty;
         public string SN = string.Empty;
         public string IP = "127.0.0.1";
         public int Port = 5555;
         public override string ToString()
         {
-            return $"{Name}[{IP}:{Port}]-{SN}";
+            return $"{DeviceName}[{IP}:{Port}]-{SN}";
         }
         public override object Clone()
         {

+ 1 - 1
Shaker/Service.cs

@@ -90,7 +90,7 @@ namespace ShakerService
                         resultDevice.Success = true;
                         resultDevice.DeviceInfoModel.Port = ServiceConfigViewModel.Instance.Port;
                         resultDevice.DeviceInfoModel.SN = ServiceConfigViewModel.Instance.SN;
-                        resultDevice.DeviceInfoModel.Name = ServiceConfigViewModel.Instance.Name;
+                        resultDevice.DeviceInfoModel.DeviceName = ServiceConfigViewModel.Instance.Name;
                         if(index ==-1)
                         {
                             resultDevice.DeviceInfoModel.IP = "127.0.0.1";

+ 1 - 1
TDMS/Default/TDMSChannelGroup.cs

@@ -130,7 +130,7 @@ namespace TDMS.Default
                     return true;
             }
 
-            return success == 0;
+            return false;
         }
 
         /// <inheritdoc />