Przeglądaj źródła

添加验证,更新GDOP动态库

wyq 1 rok temu
rodzic
commit
dbd82b4b31

+ 30 - 0
XdCxRhDW.App/ExtensionsDev/BaseEditExtension.cs

@@ -1,4 +1,5 @@
 using DevExpress.XtraEditors;
+using DevExpress.XtraEditors.DXErrorProvider;
 using System;
 using System.Collections.Generic;
 using System.Drawing;
@@ -20,5 +21,34 @@ namespace ExtensionsDev
             var ctrl= (BaseEdit)sender;
             ctrl.SelectAll();
         }
+        public static (bool,string) CheckLonLat(this TextEdit @this, string msg)
+        {
+            if (string.IsNullOrWhiteSpace(@this.Text.Trim()))
+            {
+               
+                return (false, $"{msg}经纬度不能为空!");
+            }
+            var context = @this.Text.Split(',');
+            if (context.Length != 2)
+            {
+              
+                return (false,$"{msg}经度纬度之间用英文逗号隔开!");
+            }
+            double lon;
+            bool isDoubleLon = Double.TryParse(context[0], out lon);
+            if (!isDoubleLon || lon > 180 || lon < -180)
+            {
+                return (false, $"{msg}经度范围[180,-180]!");
+            }
+            double lat;
+            bool isDoubleLat = Double.TryParse(context[1], out lat);
+            if (!isDoubleLat || lat > 90 || lat < -90)
+            {
+                return (false, $"{msg}纬度范围[90,-90]!");
+            }
+            return (true,"");
+
+        }
+
     }
 }

+ 55 - 13
XdCxRhDW.App/UserControl/X1D1GDOPParam.cs

@@ -7,6 +7,7 @@ using System.Collections.Generic;
 using XdCxRhDW.Repostory.Model;
 using XdCxRhDW.Repostory.EFContext;
 using XdCxRhDW.Core.Api;
+using System.Runtime.ConstrainedExecution;
 namespace XdCxRhDW.App.UserControl
 {
     public partial class X1D1GDOPParam : DevExpress.XtraEditors.XtraUserControl
@@ -24,7 +25,7 @@ namespace XdCxRhDW.App.UserControl
             RefLat = Convert.ToDouble(txtRefLocation1.Text.Replace(",", ",").Split(',')[1].Trim()),
             DtousErr = Convert.ToDouble(txtDtousErr1.Text),
             SatLocErr = Convert.ToDouble(txtSatLocErr1.Text),
-            CXErr= Convert.ToDouble(txtCxErr.Text),
+            CXErr = Convert.ToDouble(txtCxErr.Text),
         };
         public X1D1GDOPParam(PosRes item)
         {
@@ -51,7 +52,7 @@ namespace XdCxRhDW.App.UserControl
                 {
                     this.txtStationLocation1.Text = $"{station.CdbTxLon},{station.CdbTxLat}";
                     this.txtRefLocation1.Text = $"{station.RefLon},{station.RefLat}";
-                    this.txtCXStation.Text= $"{station.CxLon},{station.CxLat}";
+                    this.txtCXStation.Text = $"{station.CxLon},{station.CxLat}";
                 }
                 var xlList = db.XlInfos.OrderBy(p => p.SatName).OrderByDescending(p => p.TimeBJ).ToList();
                 xlall.AddRange(xlList.Select(m => m.TwoLine));
@@ -72,25 +73,66 @@ namespace XdCxRhDW.App.UserControl
 
         }
 
-
+        private (bool, string) ParamValidate()
+        {
+            if (string.IsNullOrWhiteSpace(txtTleMain.Text.Trim()))
+            {
+                return (false, "主星星历不能为空!");
+            }
+            if (txtCapTime.DateTime==DateTime.MinValue)
+            {
+                return (false, "采集时刻不能为空!");
+            }
+            var txtstat = txtStationLocation1.CheckLonLat("超短波");
+            if (!txtstat.Item1)
+            {
+                return txtstat;
+            }
+            var cxsta = txtCXStation.CheckLonLat("测向站");
+            if (!cxsta.Item1)
+            {
+                return cxsta;
+            }
+            var refsta = txtRefLocation1.CheckLonLat("参考站");
+            if (!refsta.Item1)
+            {
+                return refsta;
+            }
+            return (true, "");
+        }
 
         private void btnOK_Click(object sender, EventArgs e)
         {
-            mapControl1.ClearMap();
-            var cdb = new double[] { Model.StationLon, Model.StationLat, 0 };
-            var cx = new double[] { Model.StationLon, Model.StationLat, 0 };
-            var refstation = new double[] { Model.RefLon, Model.RefLat, 0 };
-            var (listSat, data) = GdopHelper.Gdop1Sat1D(Model.TleMain, Model.CapTime, cdb, cx,
-                             Model.DtousErr,Model.CXErr, Model.SatLocErr, refstation);
-            if (data == null)
+            var pv = ParamValidate();
+            if (!pv.Item1)
             {
+                DxHelper.MsgBoxHelper.ShowWarning($"{pv.Item2}");
                 return;
             }
-            foreach (var errLins in data)//画GDOP
+            try
+            {
+                mapControl1.ClearMap();
+                var cdb = new double[] { Model.StationLon, Model.StationLat, 0 };
+                var cx = new double[] { Model.StationLon, Model.StationLat, 0 };
+                var refstation = new double[] { Model.RefLon, Model.RefLat, 0 };
+                var (listSat, data) = GdopHelper.Gdop1Sat1D(Model.TleMain, Model.CapTime, cdb, cx,
+                                 Model.DtousErr, Model.CXErr, Model.SatLocErr, refstation);
+                if (data == null)
+                {
+                    return;
+                }
+                foreach (var errLins in data)//画GDOP
+                {
+                    var mapDots = errLins.MapDots.Select(p => p).Select(p => (p.Lon, p.Lat));
+                    mapControl1.DrawGdopLineTwo(errLins.ErrDistanceKm, mapDots, 1);
+                }
+
+            }
+            catch (Exception ex)
             {
-                var mapDots = errLins.MapDots.Select(p => p).Select(p => (p.Lon, p.Lat));
-                mapControl1.DrawGdopLineTwo(errLins.ErrDistanceKm, mapDots, 1);
+                DxHelper.MsgBoxHelper.ShowError($"绘制GDOP失败,{ex.Message}");
             }
+
         }
         private void btnClose_Click(object sender, EventArgs e)
         {

+ 53 - 8
XdCxRhDW.App/UserControl/X2D1GDOPParam.cs

@@ -7,6 +7,7 @@ using System.Collections.Generic;
 using XdCxRhDW.Repostory.Model;
 using XdCxRhDW.Repostory.EFContext;
 using XdCxRhDW.Core.Api;
+using DxHelper;
 namespace XdCxRhDW.App.UserControl
 {
     public partial class X2D1GDOPParam : DevExpress.XtraEditors.XtraUserControl
@@ -88,20 +89,64 @@ namespace XdCxRhDW.App.UserControl
         }
 
 
+        private (bool, string) ParamValidate()
+        {
+            if (string.IsNullOrWhiteSpace(txtTleMain.Text.Trim()))
+            {
+                return (false, "主星星历不能为空!");
+            }
+            if (string.IsNullOrWhiteSpace(txtTleAdja.Text.Trim()))
+            {
+                return (false, "主星星历不能为空!");
+            }
+            if (txtTleMain.Text.Trim() == txtTleAdja.Text.Trim())
+            {
+                return (false, "主邻星历不能相同!");
+            }
+            if (txtCapTime.DateTime == DateTime.MinValue)
+            {
+                return (false, "采集时刻不能为空!");
+            }
+            var txtstat = txtStationLocation1.CheckLonLat("超短波");
+            if (!txtstat.Item1)
+            {
+                return txtstat;
+            }
 
+            var refsta = txtRefLocation1.CheckLonLat("参考站");
+            if (PosResType == EnumPosResType.X2D1 && !refsta.Item1)
+            {
+                return refsta;
+            }
+            return (true, "");
+        }
         private void btnOK_Click(object sender, EventArgs e)
         {
-            mapControl1.ClearMap();
+            var pv = ParamValidate();
+            if (!pv.Item1)
+            {
+                DxHelper.MsgBoxHelper.ShowWarning($"{pv.Item2}");
+                return;
+            }
+            try
+            {
+
+                mapControl1.ClearMap();
 
-            var cdb = new double[] { Model.StationLon, Model.StationLat, 0 };
-            var refstation = new double[] { Model.RefLon, Model.RefLat, 0 };
+                var cdb = new double[] { Model.StationLon, Model.StationLat, 0 };
+                var refstation = new double[] { Model.RefLon, Model.RefLat, 0 };
 
-            var (listSat, data) = GdopHelper.Gdop2Sat1D(Model.TleMain, Model.TleAdja, Model.CapTime, cdb
-                     , Model.DtousErr, Model.SatLocErr, PosResType == EnumPosResType.X2D1NoRef ? null : refstation);
-            foreach (var errLins in data)//画GDOP
+                var (listSat, data) = GdopHelper.Gdop2Sat1D(Model.TleMain, Model.TleAdja, Model.CapTime, cdb
+                         , Model.DtousErr, Model.SatLocErr, PosResType == EnumPosResType.X2D1NoRef ? null : refstation);
+                foreach (var errLins in data)//画GDOP
+                {
+                    var mapDots = errLins.MapDots.Select(p => p).Select(p => (p.Lon, p.Lat));
+                    mapControl1.DrawGdopLineTwo(errLins.ErrDistanceKm, mapDots, 1);
+                }
+            }
+            catch (Exception ex)
             {
-                var mapDots = errLins.MapDots.Select(p => p).Select(p => (p.Lon, p.Lat));
-                mapControl1.DrawGdopLineTwo(errLins.ErrDistanceKm, mapDots, 1);
+                DxHelper.MsgBoxHelper.ShowError($"绘制{PosResType.GetEnumDisplayName()}GDOP失败,{ex.Message}");
             }
         }
         private void btnClose_Click(object sender, EventArgs e)

+ 49 - 10
XdCxRhDW.App/UserControl/X2DFGDOPParam.cs

@@ -82,23 +82,62 @@ namespace XdCxRhDW.App.UserControl
             txtTleLeo2.UseDefault().SetStringData(xlall).Text = adjaTle1;
         }
 
-
+        private (bool, string) ParamValidate()
+        {
+            if (string.IsNullOrWhiteSpace(txtTleLeo1.Text.Trim()))
+            {
+                return (false, "主星星历不能为空!");
+            }
+            if (string.IsNullOrWhiteSpace(txtTleLeo2.Text.Trim()))
+            {
+                return (false, "邻星星历不能为空!");
+            }
+            if (txtTleLeo1.Text.Trim() == txtTleLeo2.Text.Trim())
+            {
+                return (false, "主邻星历不能相同!");
+            }
+            if (txtCapTime.DateTime == DateTime.MinValue)
+            {
+                return (false, "采集时刻不能为空!");
+            }
+            var refsta = txtRefLocation1.CheckLonLat("参考站");
+            if ( !refsta.Item1)
+            {
+                return refsta;
+            }
+            return (true, "");
+        }
         private void btnOK_Click(object sender, EventArgs e)
         {
-            mapControl1.ClearMap();
-            var refs = new double[] { Model.RefLon, Model.RefLat, 0 };
-            var (listSat, data) = GdopHelper.Gdop2SatDRef(Model.TleLeo1, Model.TleLeo2,
-                Model.CapTime, Model.fu1, Model.fu2, Model.DtousErr, Model.DfoErr, Model.SatLocErr, Model.EphVelErr, refs);
-
-            if (data == null)
+            var pv = ParamValidate();
+            if (!pv.Item1)
             {
+                DxHelper.MsgBoxHelper.ShowWarning($"{pv.Item2}");
                 return;
             }
+            try
+            {
 
-            foreach (var errLins in data)//画GDOP
+
+                mapControl1.ClearMap();
+                var refs = new double[] { Model.RefLon, Model.RefLat, 0 };
+                var (listSat, data) = GdopHelper.Gdop2SatDRef(Model.TleLeo1, Model.TleLeo2,
+                    Model.CapTime, Model.fu1, Model.fu2, Model.DtousErr, Model.DfoErr, Model.SatLocErr, Model.EphVelErr, refs);
+
+                if (data == null)
+                {
+                    return;
+                }
+
+                foreach (var errLins in data)//画GDOP
+                {
+                    var mapDots = errLins.MapDots.Select(p => p).Select(p => (p.Lon, p.Lat));
+                    mapControl1.DrawGdopLineTwo(errLins.ErrDistanceKm, mapDots, mapDots.Count() / 2);
+                }
+            }
+            catch (Exception ex)
             {
-                var mapDots = errLins.MapDots.Select(p => p).Select(p => (p.Lon, p.Lat));
-                mapControl1.DrawGdopLineTwo(errLins.ErrDistanceKm, mapDots, mapDots.Count() / 2);
+                DxHelper.MsgBoxHelper.ShowError($"绘制GDOP失败,{ex.Message}");
             }
         }
 

+ 52 - 11
XdCxRhDW.App/UserControl/X3DFGDOPParam .cs

@@ -93,23 +93,64 @@ namespace XdCxRhDW.App.UserControl
             txtTleLeo3.UseDefault().SetStringData(xlall).Text = adjaTle2;
         }
 
-
+        private (bool, string) ParamValidate()
+        {
+            if (string.IsNullOrWhiteSpace(txtTleLeo1.Text.Trim()))
+            {
+                return (false, "主星星历不能为空!");
+            }
+            if (string.IsNullOrWhiteSpace(txtTleLeo2.Text.Trim()))
+            {
+                return (false, "邻星1星历不能为空!");
+            }
+            if (string.IsNullOrWhiteSpace(txtTleLeo3.Text.Trim()))
+            {
+                return (false, "邻星2星历不能为空!");
+            }
+            if (txtTleLeo1.Text.Trim() == txtTleLeo2.Text.Trim() || txtTleLeo1.Text.Trim() == txtTleLeo3.Text.Trim() || txtTleLeo2.Text.Trim() == txtTleLeo3.Text.Trim())
+            {
+                return (false, "主邻星历不能相同!");
+            }
+            if (txtCapTime.DateTime == DateTime.MinValue)
+            {
+                return (false, "采集时刻不能为空!");
+            }
+            var refsta = txtRefLocation1.CheckLonLat("参考站");
+            if (!refsta.Item1)
+            {
+                return refsta;
+            }
+            return (true, "");
+        }
         private void btnOK_Click(object sender, EventArgs e)
         {
-            mapControl1.ClearMap();
-            var refs = new double[] { Model.RefLon, Model.RefLat, 0 };
-            var (listSat, data) = GdopHelper.Gdop3SatDF(Model.TleLeo1, Model.TleLeo2, Model.TleLeo3,
-                Model.CapTime, Model.fu1, Model.fu2, Model.DfoErr, Model.SatLocErr, Model.EphVelErr, refs);
-
-            if (data == null)
+            var pv = ParamValidate();
+            if (!pv.Item1)
             {
+                DxHelper.MsgBoxHelper.ShowWarning($"{pv.Item2}");
                 return;
             }
-           
-            foreach (var errLins in data)//画GDOP
+            try
+            {
+                mapControl1.ClearMap();
+                var refs = new double[] { Model.RefLon, Model.RefLat, 0 };
+                var (listSat, data) = GdopHelper.Gdop3SatDF(Model.TleLeo1, Model.TleLeo2, Model.TleLeo3,
+                    Model.CapTime, Model.fu1, Model.fu2, Model.DfoErr, Model.SatLocErr, Model.EphVelErr, refs);
+
+                if (data == null)
+                {
+                    return;
+                }
+
+                foreach (var errLins in data)//画GDOP
+                {
+                    var mapDots = errLins.MapDots.Select(p => p).Select(p => (p.Lon, p.Lat));
+                    mapControl1.DrawGdopLineTwo(errLins.ErrDistanceKm, mapDots, mapDots.Count() / 2);
+                }
+            }
+            catch (Exception ex)
             {
-                var mapDots = errLins.MapDots.Select(p => p).Select(p => (p.Lon, p.Lat));
-                mapControl1.DrawGdopLineTwo(errLins.ErrDistanceKm, mapDots, mapDots.Count() / 2);
+                DxHelper.MsgBoxHelper.ShowError($"绘制GDOP失败,{ex.Message}");
             }
         }
 

+ 51 - 8
XdCxRhDW.App/UserControl/X3GDOPParam.cs

@@ -7,6 +7,7 @@ using System.Collections.Generic;
 using XdCxRhDW.Repostory.Model;
 using XdCxRhDW.Repostory.EFContext;
 using XdCxRhDW.Core.Api;
+using DxHelper;
 namespace XdCxRhDW.App.UserControl
 {
     public partial class X3GDOPParam : DevExpress.XtraEditors.XtraUserControl
@@ -92,20 +93,62 @@ namespace XdCxRhDW.App.UserControl
         {
             DxHelper.PopupHelper.HidePopup(this);
         }
+        private (bool, string) ParamValidate()
+        {
+            if (string.IsNullOrWhiteSpace(txtTleMain.Text.Trim()))
+            {
+                return (false, "主星星历不能为空!");
+            }
+            if (string.IsNullOrWhiteSpace(txtTleAdja1.Text.Trim()))
+            {
+                return (false, "邻星1星历不能为空!");
+            }
+            if (string.IsNullOrWhiteSpace(txtTleAdja2.Text.Trim()))
+            {
+                return (false, "邻星2星历不能为空!");
+            }
+            if (txtTleMain.Text.Trim() == txtTleAdja1.Text.Trim() || txtTleMain.Text.Trim() == txtTleAdja2.Text.Trim() || txtTleAdja1.Text.Trim() == txtTleAdja2.Text.Trim())
+            {
+                return (false, "主邻星历不能相同!");
+            }
+            if (txtCapTime.DateTime == DateTime.MinValue)
+            {
+                return (false, "采集时刻不能为空!");
+            }
+            var refsta = txtRefLocation1.CheckLonLat("参考站");
+            if (PosResType == EnumPosResType.X3 && !refsta.Item1)
+            {
+                return refsta;
+            }
+            return (true, "");
+        }
         private void btnX1D2_Click(object sender, EventArgs e)
         {
-            mapControl1.ClearMap();
-            var refs = new double[] { Model.RefLon, Model.RefLat, 0 };
-            var (listSat, data) = GdopHelper.Gdop3Sat(Model.TleMain, Model.TleAdja1, Model.TleAdja2, Model.CapTime
-                              , Model.DtousErr, Model.SatLocErr, PosResType == EnumPosResType.X3NoRef ? null : refs);
-            if (data == null)
+            var pv = ParamValidate();
+            if (!pv.Item1)
             {
+                DxHelper.MsgBoxHelper.ShowWarning($"{pv.Item2}");
                 return;
             }
-            foreach (var errLins in data)//画GDOP
+            try
+            {
+                mapControl1.ClearMap();
+                var refs = new double[] { Model.RefLon, Model.RefLat, 0 };
+                var (listSat, data) = GdopHelper.Gdop3Sat(Model.TleMain, Model.TleAdja1, Model.TleAdja2, Model.CapTime
+                                  , Model.DtousErr, Model.SatLocErr, PosResType == EnumPosResType.X3NoRef ? null : refs);
+                if (data == null)
+                {
+                    return;
+                }
+                foreach (var errLins in data)//画GDOP
+                {
+                    var mapDots = errLins.MapDots.Select(p => p).Select(p => (p.Lon, p.Lat));
+                    mapControl1.DrawGdopLineTwo(errLins.ErrDistanceKm, mapDots, 1);
+                }
+            }
+            catch (Exception ex)
             {
-                var mapDots = errLins.MapDots.Select(p => p).Select(p => (p.Lon, p.Lat));
-                mapControl1.DrawGdopLineTwo(errLins.ErrDistanceKm, mapDots, 1);
+                DxHelper.MsgBoxHelper.ShowError($"绘制{PosResType.GetEnumDisplayName()}GDOP失败,{ex.Message}");
             }
         }
     }

BIN
XdCxRhDW.Core/Api/GDOP误差椭圆/GDOP/GDOP_Draw_11.dll