zoulei пре 1 година
родитељ
комит
a85c43d669

+ 8 - 5
XdCxRhDW.App/CorTools/DetectToolForm.cs

@@ -236,11 +236,14 @@ namespace XdCxRhDW.App.CorTools
             {
                 layoutControl1.Enabled = true;
             }
-            //if (res!=null&&res.Any())
-            //{
-            //    new CgImageForm().ShowDialog();
-            //}
-            new Test().ShowDialog();
+            if (res != null && res.Any())
+            {
+                new Test(res).ShowDialog();
+            }
+            else
+            {
+                DxHelper.MsgBoxHelper.ShowInfo("无计算结果!");
+            }
         }
 
         private void chkDama_CheckedChanged(object sender, EventArgs e)

+ 37 - 8
XdCxRhDW.App/CorTools/Test.Designer.cs

@@ -34,6 +34,9 @@
             DevExpress.XtraCharts.TextAnnotation textAnnotation1 = new DevExpress.XtraCharts.TextAnnotation();
             DevExpress.XtraCharts.ChartAnchorPoint chartAnchorPoint2 = new DevExpress.XtraCharts.ChartAnchorPoint();
             DevExpress.XtraCharts.FreePosition freePosition2 = new DevExpress.XtraCharts.FreePosition();
+            DevExpress.XtraCharts.TextAnnotation textAnnotation2 = new DevExpress.XtraCharts.TextAnnotation();
+            DevExpress.XtraCharts.ChartAnchorPoint chartAnchorPoint3 = new DevExpress.XtraCharts.ChartAnchorPoint();
+            DevExpress.XtraCharts.FreePosition freePosition3 = new DevExpress.XtraCharts.FreePosition();
             DevExpress.XtraCharts.XYDiagram xyDiagram1 = new DevExpress.XtraCharts.XYDiagram();
             DevExpress.XtraCharts.Series series1 = new DevExpress.XtraCharts.Series();
             DevExpress.XtraCharts.PointSeriesView pointSeriesView1 = new DevExpress.XtraCharts.PointSeriesView();
@@ -42,6 +45,7 @@
             ((System.ComponentModel.ISupportInitialize)(this.chartControl1)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(imageAnnotation1)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(textAnnotation1)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(textAnnotation2)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(xyDiagram1)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(series1)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(pointSeriesView1)).BeginInit();
@@ -64,8 +68,8 @@
             imageAnnotation1.Padding.Right = 0;
             imageAnnotation1.Padding.Top = 0;
             imageAnnotation1.ShapeKind = DevExpress.XtraCharts.ShapeKind.Rectangle;
-            freePosition1.InnerIndents.Left = 349;
-            freePosition1.InnerIndents.Top = 8;
+            freePosition1.InnerIndents.Left = 231;
+            freePosition1.InnerIndents.Top = 7;
             imageAnnotation1.ShapePosition = freePosition1;
             imageAnnotation1.SizeMode = DevExpress.XtraCharts.ChartImageSizeMode.Stretch;
             imageAnnotation1.Width = 400;
@@ -76,21 +80,41 @@
             textAnnotation1.Border.Visibility = DevExpress.Utils.DefaultBoolean.False;
             textAnnotation1.ConnectorStyle = DevExpress.XtraCharts.AnnotationConnectorStyle.None;
             textAnnotation1.Name = "Annotation 2";
+            textAnnotation1.Padding.Right = 0;
             textAnnotation1.ShapeKind = DevExpress.XtraCharts.ShapeKind.Rectangle;
-            freePosition2.InnerIndents.Left = 313;
-            freePosition2.InnerIndents.Top = 13;
+            freePosition2.InnerIndents.Left = 200;
+            freePosition2.InnerIndents.Top = 12;
             textAnnotation1.ShapePosition = freePosition2;
             textAnnotation1.Text = "色系";
+            textAnnotation2.AnchorPoint = chartAnchorPoint3;
+            textAnnotation2.AnnotationID = 3;
+            textAnnotation2.AutoHeight = true;
+            textAnnotation2.AutoWidth = true;
+            textAnnotation2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
+            textAnnotation2.Border.Visibility = DevExpress.Utils.DefaultBoolean.False;
+            textAnnotation2.ConnectorStyle = DevExpress.XtraCharts.AnnotationConnectorStyle.None;
+            textAnnotation2.Name = "Annotation 3";
+            textAnnotation2.Padding.Left = 0;
+            textAnnotation2.ShapeKind = DevExpress.XtraCharts.ShapeKind.Rectangle;
+            freePosition3.InnerIndents.Left = 632;
+            freePosition3.InnerIndents.Top = 13;
+            textAnnotation2.ShapePosition = freePosition3;
+            textAnnotation2.Text = "共0个点";
             this.chartControl1.AnnotationRepository.AddRange(new DevExpress.XtraCharts.Annotation[] {
             imageAnnotation1,
-            textAnnotation1});
+            textAnnotation1,
+            textAnnotation2});
+            this.chartControl1.BorderOptions.Visibility = DevExpress.Utils.DefaultBoolean.False;
+            this.chartControl1.CrosshairEnabled = DevExpress.Utils.DefaultBoolean.Default;
+            xyDiagram1.AxisX.Label.TextColor = System.Drawing.Color.FromArgb(((int)(((byte)(242)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
             xyDiagram1.AxisX.Tickmarks.MinorVisible = false;
             xyDiagram1.AxisX.Tickmarks.Visible = false;
-            xyDiagram1.AxisX.Visibility = DevExpress.Utils.DefaultBoolean.True;
             xyDiagram1.AxisX.VisibleInPanesSerializable = "-1";
             xyDiagram1.AxisY.GridLines.Visible = false;
+            xyDiagram1.AxisY.Label.TextColor = System.Drawing.Color.FromArgb(((int)(((byte)(242)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
             xyDiagram1.AxisY.Tickmarks.MinorVisible = false;
             xyDiagram1.AxisY.Tickmarks.Visible = false;
+            xyDiagram1.AxisY.Visibility = DevExpress.Utils.DefaultBoolean.True;
             xyDiagram1.AxisY.VisibleInPanesSerializable = "-1";
             xyDiagram1.DefaultPane.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
             xyDiagram1.DefaultPane.BorderVisible = false;
@@ -103,13 +127,16 @@
             this.chartControl1.Diagram = xyDiagram1;
             this.chartControl1.Dock = System.Windows.Forms.DockStyle.Fill;
             this.chartControl1.Legend.LegendID = -1;
-            this.chartControl1.Legend.Visibility = DevExpress.Utils.DefaultBoolean.True;
+            this.chartControl1.Legend.MarkerMode = DevExpress.XtraCharts.LegendMarkerMode.None;
+            this.chartControl1.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False;
             this.chartControl1.Location = new System.Drawing.Point(0, 0);
             this.chartControl1.Name = "chartControl1";
+            this.chartControl1.PaletteName = "Blue Green";
+            series1.CrosshairEnabled = DevExpress.Utils.DefaultBoolean.False;
             series1.Name = "Series 1";
             series1.SeriesID = 0;
+            series1.ToolTipEnabled = DevExpress.Utils.DefaultBoolean.True;
             pointSeriesView1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
-            pointSeriesView1.ColorEach = true;
             pointSeriesView1.PointMarkerOptions.Size = 6;
             series1.View = pointSeriesView1;
             this.chartControl1.SeriesSerializable = new DevExpress.XtraCharts.Series[] {
@@ -117,6 +144,7 @@
             this.chartControl1.Size = new System.Drawing.Size(898, 599);
             this.chartControl1.TabIndex = 1;
             chartTitle1.Indent = 10;
+            chartTitle1.Text = " ";
             chartTitle1.TitleID = 1;
             chartTitle1.Visibility = DevExpress.Utils.DefaultBoolean.True;
             this.chartControl1.Titles.AddRange(new DevExpress.XtraCharts.ChartTitle[] {
@@ -138,6 +166,7 @@
             this.Load += new System.EventHandler(this.Test_Load);
             ((System.ComponentModel.ISupportInitialize)(imageAnnotation1)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(textAnnotation1)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(textAnnotation2)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(xyDiagram1)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(pointSeriesView1)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(series1)).EndInit();

+ 44 - 15
XdCxRhDW.App/CorTools/Test.cs

@@ -1,4 +1,6 @@
 using DevExpress.Charts.Native;
+using DevExpress.Map.Dashboard;
+using DevExpress.Map.Native;
 using DevExpress.XtraBars;
 using DevExpress.XtraCharts;
 using DevExpress.XtraEditors.Repository;
@@ -11,26 +13,31 @@ using System.Drawing;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using System.Windows;
 using System.Windows.Forms;
+using System.Xml.Linq;
 using XdCxRhDW.Core;
+using XdCxRhDW.Core.Api;
+using static DevExpress.XtraEditors.Mask.Design.MaskSettingsForm.DesignInfo.MaskManagerInfo;
+using static System.Windows.Forms.VisualStyles.VisualStyleElement.TaskbarClock;
+using static System.Windows.Forms.VisualStyles.VisualStyleElement.ToolTip;
 
 namespace XdCxRhDW.App.CorTools
 {
     public partial class Test : DevExpress.XtraEditors.XtraForm
     {
+        List<ImageResult> list;
         public Test()
         {
             InitializeComponent();
-        }
-
-        private void Test_Load(object sender, EventArgs e)
-        {
-            Bitmap bmp = new Bitmap(1024, 768);
-            for (int x = 0; x < 1024; x++)
+            int w = (this.chartControl1.AnnotationRepository[0] as ImageAnnotation).Width;
+            int h = (this.chartControl1.AnnotationRepository[0] as ImageAnnotation).Height;
+            Bitmap bmp = new Bitmap(w, h);
+            for (int x = 0; x < w; x++)
             {
-                for (int y = 0; y < 768; y++)
+                for (int y = 0; y < h; y++)
                 {
-                    var rgbb = ColorRGB.GetSpecColor(x / 1023d);
+                    var rgbb = ColorRGB.GetSpecColor(x / 1d / w);
                     int r = rgbb.R;
                     int g = rgbb.G;
                     int b = rgbb.B;
@@ -38,18 +45,40 @@ namespace XdCxRhDW.App.CorTools
                     bmp.SetPixel(x, y, c);
                 }
             }
-            var bgColor= ColorRGB.GetSpecColor(0); 
-            chartControl1.BackColor= bgColor;
+            var bgColor = ColorRGB.GetSpecColor(0.3);
+            chartControl1.BackColor = bgColor;
             (this.chartControl1.Diagram as XYDiagram).DefaultPane.BackColor = bgColor;
-           (this.chartControl1.AnnotationRepository[0] as ImageAnnotation).Image.DXImage = bmp;
-            (this.chartControl1.AnnotationRepository[1] as TextAnnotation).BackColor=bgColor;
+            (this.chartControl1.AnnotationRepository[0] as ImageAnnotation).Image.DXImage = bmp;
+            (this.chartControl1.AnnotationRepository[1] as TextAnnotation).BackColor = bgColor;
             (this.chartControl1.AnnotationRepository[1] as TextAnnotation).TextColor = Color.White;
+            (this.chartControl1.AnnotationRepository[2] as TextAnnotation).BackColor = bgColor;
+            (this.chartControl1.AnnotationRepository[2] as TextAnnotation).TextColor = Color.White;
             (this.chartControl1.Diagram as XYDiagram).AxisX.Color = Color.White;
+            (this.chartControl1.Diagram as XYDiagram).AxisX.Label.TextColor = Color.White;
             (this.chartControl1.Diagram as XYDiagram).AxisY.Color = Color.White;
+            (this.chartControl1.Diagram as XYDiagram).AxisY.Label.TextColor = Color.White;
+            this.chartControl1.Series[0].ToolTipEnabled = DevExpress.Utils.DefaultBoolean.True;
 
-
-
-
+            //ToolTipPointPattern可以参考以下网站说明
+            //https://docs.devexpress.com/CoreLibraries/DevExpress.XtraCharts.SeriesBase.ToolTipPointPattern?utm_source=visualstudio&utm_medium=DXHelpAssistant&utm_campaign=onlinehelp
+            this.chartControl1.Series[0].ToolTipPointPattern = "{A:f3}us\r\n{V:f3}Hz";
+        }
+        public Test(List<ImageResult> list)
+            : this()
+        { 
+            this.list = list;
+            var maxY = list.First().YMax / 2;
+            (this.chartControl1.AnnotationRepository[2] as TextAnnotation).Text = $"共{list.Count}个点";
+            (this.chartControl1.Diagram as XYDiagram).AxisY.WholeRange.SetMinMaxValues(-maxY, maxY);
+            (this.chartControl1.Diagram as XYDiagram).AxisY.VisualRange.SetMinMaxValues(-maxY, maxY);
+        }
+        private void Test_Load(object sender, EventArgs e)
+        {
+            foreach (var item in list)
+            {
+                double xValue = (item.XValue + item.XFlag)/1d/
+                this.chartControl1.Series[0].Points.AddPoint(item.XValue, item.YValue);
+            }
         }
     }
 }

+ 33 - 3
XdCxRhDW.Repostory/XlCache.cs

@@ -12,7 +12,12 @@ namespace XdCxRhDW.Repostory
 {
     public static class XlCache
     {
-        public static async Task<List<XlInfo>> GetAllAsync()
+        /// <summary>
+        /// 获取数据库所有双行根数
+        /// </summary>
+        /// <param name="maxCount">最大条数.超过此条数时不再继续查询,为0则不限制条数</param>
+        /// <returns></returns>
+        public static async Task<List<XlInfo>> GetAllAsync(int maxCount = 2000)
         {
             try
             {
@@ -22,13 +27,13 @@ namespace XdCxRhDW.Repostory
                 foreach (var yearDir in yearDirs)
                 {
                     //每一天的db文件,倒序排列
-                    var dayFiles = Directory.EnumerateFiles(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, yearDir),"*.db").OrderByDescending(p => Convert.ToInt32(new DirectoryInfo(p).Name.Substring(0, 4)));
+                    var dayFiles = Directory.EnumerateFiles(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, yearDir), "*.db").OrderByDescending(p => Convert.ToInt32(new DirectoryInfo(p).Name.Substring(0, 4)));
                     foreach (var dayFile in dayFiles)
                     {
                         using (RHDWPartContext db = RHDWPartContext.GetContext(dayFile))
                         {
                             list.AddRange(await db.XlInfos.ToListAsync());
-                            if (list.Count > 2000)
+                            if (maxCount > 0 && list.Count >= maxCount)
                                 return list;
                         }
                     }
@@ -41,5 +46,30 @@ namespace XdCxRhDW.Repostory
                 return null;
             }
         }
+
+
+        /// <summary>
+        /// 获取某个星某个时刻最近的双行根(可能返回null)
+        /// </summary>
+        /// <param name="satCode">卫星编号</param>
+        /// <param name="timeBj">时刻</param>
+        /// <returns></returns>
+        public static async Task<XlInfo> GetLatestAsync(int satCode, DateTime timeBj)
+        {
+            try
+            {
+
+                var list = await GetAllAsync(0);
+                if (!list.Any()) return null;
+                var minSec = list.Min(p => Math.Abs((p.TimeBJ - timeBj).TotalSeconds));
+                var find = list.Find(p => Math.Abs((p.TimeBJ - timeBj).TotalSeconds) == minSec);
+                return find;
+            }
+            catch (Exception ex)
+            {
+                Serilog.Log.Error(ex, $"获取卫星[{satCode}]--{timeBj:yyyyMMddHHmmss}时刻附近的双行根数出错!");
+                return null;
+            }
+        }
     }
 }