From 29a6de30e328c46cbbcae15066f449b0660c2db1 Mon Sep 17 00:00:00 2001 From: tangxu <tangxu76880903> Date: 星期六, 27 一月 2024 11:26:56 +0800 Subject: [PATCH] 添加坐标辅助类 --- Yw.Application.Curve.Core/1-pump-curve/2-chat/dto/CoordinateParasLxp.cs | 122 ++ Yw.Coordinate/QhCoordinateParas.cs | 224 ++++ Yw.Coordinate/Properties/PublishProfiles/FolderProfile.pubxml | 12 Yw.Coordinate/IGetQhCoordinate.cs | 17 Yw.Application.Curve.Core/1-pump-curve/2-chat/PumpChart_Controller.cs | 77 + Yw.Coordinate/CoordinateHelper.cs | 1287 +++++++++++++++++++++++++++ Yw.Coordinate/Axis/AxisNonuniform.cs | 30 Yw.Coordinate/Yw.Coordinate.csproj | 34 Yw.Coordinate/Axis/AxisUniform.cs | 44 Yw.Coordinate/Properties/PublishProfiles/FolderProfile.pubxml.user | 9 Yw.Coordinate/Axis/IAxisCalcer.cs | 55 + Yw.Coordinate/GlobalUsings.cs | 7 Yw.Coordinate/Axis/AxisBase.cs | 19 Yw.Coordinate/IGetLxpCoordinate.cs | 17 Yw.Coordinate/AxisXyCalcer.cs | 36 Yw.Coordinate/ZlpCoordinateParas.cs | 214 ++++ Yw.Coordinate/LxpCoordinateParas.cs | 383 ++++++++ Yw.Coordinate/LxpCoordinateParasConver.cs | 21 Yw.Application.Curve.Core/1-pump-curve/2-chat/dto/PumpChart.cs | 151 +++ 19 files changed, 2,759 insertions(+), 0 deletions(-) diff --git a/Yw.Application.Curve.Core/1-pump-curve/2-chat/PumpChart_Controller.cs b/Yw.Application.Curve.Core/1-pump-curve/2-chat/PumpChart_Controller.cs new file mode 100644 index 0000000..af66544 --- /dev/null +++ b/Yw.Application.Curve.Core/1-pump-curve/2-chat/PumpChart_Controller.cs @@ -0,0 +1,77 @@ +namespace Yw.Application +{ + /// <summary> + /// PumpCurve + /// </summary> + [Route("Curve/PumpChart")] + [ApiDescriptionSettings("Chart", Name = "泵曲线", Order = 10000)] + public class PumpChart_Controller : IDynamicApiController + { + + private readonly Service.PumpCurve _service = new(); + + #region Query + + + + /// <summary> + /// 通过 ID 获取 + /// </summary> + [Route("GetByID@V1.0")] + [HttpGet] + public PumpChartDto GetByID([FromQuery][Required] IDInput input) + { + var model = _service.GetByID(input.ID); + return model == null ? null : new PumpChartDto(model); + } + + + + #endregion + + + + #region Update + + + + /// <summary> + /// 更新坐标信息 + /// </summary> + [Route("UpdateCoordParas@V1.0")] + [HttpPut] + public bool UpdateCoordParas(UpdatePumpCoordParasInput input) + { + var bol = _service.UpdateCoordParas(input.ID, input.CoordParas, UserManager.UserID, DateTime.Now); + return bol; + } + + + + #endregion + + #region Delete + + /// <summary> + /// 删除曲线 + /// </summary> + [Route("DeleteByID@V1.0")] + [HttpDelete] + public bool DeleteByID([FromQuery][Required] IDInput input) + { + var bol = _service.DeleteByID(input.ID, out string Msg); + if (!bol) + { + throw YOops.Oh(eResultCode.Alert, ErrorCodes.D999, Msg); + } + return bol; + } + + #endregion + + + + + + } +} diff --git a/Yw.Application.Curve.Core/1-pump-curve/2-chat/dto/CoordinateParasLxp.cs b/Yw.Application.Curve.Core/1-pump-curve/2-chat/dto/CoordinateParasLxp.cs new file mode 100644 index 0000000..70fb461 --- /dev/null +++ b/Yw.Application.Curve.Core/1-pump-curve/2-chat/dto/CoordinateParasLxp.cs @@ -0,0 +1,122 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace Yw.Dto +{ + /// <summary> + /// + /// </summary> + public class CoordinateParasLxp + { + /// <summary> + /// + /// </summary> + public CoordinateParasLxp() { } + /// <summary> + /// + /// </summary> + /// <param name="dsChartCoord"></param> + public CoordinateParasLxp(Yw.Coordinate.LxpCoordinateParas dsChartCoord) + { + if (dsChartCoord == null) + { + return; + } + + //鍧愭爣闂撮殧鏁�,鍧愭爣绾夸細姣斿潗鏍囬棿闅旀暟澶氫竴 + this.GridNumberX = dsChartCoord.GridNumberX; + this.GridNumberY = dsChartCoord.GridNumberY; + + + // + this.MinQ = dsChartCoord.CoordMinQ; + this.SpaceQ = dsChartCoord.CoordSpaceQ; + this.DispMinQ = dsChartCoord.CoordMinQ; + this.DispMaxQ = dsChartCoord.DispMaxQ(); + + this.MinH = dsChartCoord.CoordMinH; + this.SpaceH = dsChartCoord.CoordSpaceH; + this.DispMinH = dsChartCoord.DispMinH(); + this.DispMaxH = dsChartCoord.DispMaxH(); + this.StartLineNoH = dsChartCoord.StartLineNoH; + this.EndLineNoH = dsChartCoord.EndLineNoH; + + + this.MinE = dsChartCoord.CoordMinE; + this.SpaceE = dsChartCoord.CoordSpaceE; + this.DispMinE = dsChartCoord.DispMinE(); + this.DispMaxE = dsChartCoord.DispMaxE(); + this.StartLineNoE = dsChartCoord.StartLineNoE; + this.EndLineNoE = dsChartCoord.EndLineNoE; + + + this.MinP = dsChartCoord.CoordMinP; + this.SpaceP = dsChartCoord.CoordSpaceP; + this.DispMinP = dsChartCoord.DispMinP(); + this.DispMaxP = dsChartCoord.DispMaxP(); + this.StartLineNoP = dsChartCoord.StartLineNoP; + this.EndLineNoP = dsChartCoord.EndLineNoP; + + + + + this.DislocationNumUp = dsChartCoord.DislocationNumUp; + + + } + + /// <summary> + /// 鍧愭爣闂撮殧鏁�,鍧愭爣绾夸細姣斿潗鏍囬棿闅旀暟澶氫竴 + /// </summary> + public int GridNumberX = 30;//X鍧愭爣 + /// <summary> + /// + /// </summary> + public int GridNumberY = 16;//Y鍧愭爣 + + /// <summary> + /// 鏄剧ず鐨勫潗鏍囩嚎鍙� + /// </summary> + public int StartLineNoH, EndLineNoH; + + /// <summary> + /// + /// </summary> + public int StartLineNoE, EndLineNoE; + + + /// <summary> + /// + /// </summary> + public int StartLineNoP, EndLineNoP; + + + + + + /// <summary> + /// 鍧愭爣鏈�灏忓�煎拰闂撮殧 + /// </summary> + public double MinQ, DispMinQ, DispMaxQ, SpaceQ; + /// <summary> + /// + /// </summary> + public double MinH, DispMinH, DispMaxH, SpaceH; + /// <summary> + /// + /// </summary> + public double MinE, DispMinE, DispMaxE, SpaceE; + /// <summary> + /// + /// </summary> + public double MinP, DispMinP, DispMaxP, SpaceP; + + /// <summary> + /// + /// </summary> + public int DislocationNumUp = 2;//鎵▼鏁堢巼鍒诲害 閿欎綅鏁� (QH鍜孮E鍧愭爣鐨勯敊浣�) 灏辨槸QH涓嬮潰鐨勭┖鏍兼暟 + + } +} \ No newline at end of file diff --git a/Yw.Application.Curve.Core/1-pump-curve/2-chat/dto/PumpChart.cs b/Yw.Application.Curve.Core/1-pump-curve/2-chat/dto/PumpChart.cs new file mode 100644 index 0000000..cd31e4d --- /dev/null +++ b/Yw.Application.Curve.Core/1-pump-curve/2-chat/dto/PumpChart.cs @@ -0,0 +1,151 @@ +锘縩amespace Yw.Application +{ + /// <summary> + /// 娉垫洸绾� + /// </summary> + public class PumpChartDto + { + + /// <summary> + /// + /// </summary> + public PumpChartDto() { } + + /// <summary> + /// + /// </summary> + public PumpChartDto(Model.PumpCurve rhs) + { + this.Name = rhs.Name; + this.SourceWay = rhs.SourceWay; + this.CreateMethod = rhs.CreateMethod; + //this.CoordParas = rhs.CoordParas; + //this.CurveInfo = rhs.CurveInfo; + this.ReliabilityStatus = rhs.ReliabilityStatus; + this.InputTime = rhs.InputTime; + this.CreateTime = rhs.CreateTime; + this.CreateUserID = rhs.CreateUserID; + this.CreateUserName = rhs.CreateUserName; + this.UpdateTime = rhs.UpdateTime; + this.UpdateUserID = rhs.UpdateUserID; + this.UpdateUserName = rhs.UpdateUserName; + this.Description = rhs.Description; + + _dictChartObject = new Dictionary<string, object>(); + if(rhs.CurveInfo != null && rhs.CurveInfo.CurveQH != null) + { + //鏈�澶у彾杞洸绾� + List<Yw.Curve.CurvePoint> qhPointMax = Yw.Curve.FitHelper.GetFitPoints(rhs.CurveInfo.CurveQH, 20); + List<Yw.Curve.CurvePoint> qePointMax = Yw.Curve.FitHelper.GetFitPoints(rhs.CurveInfo.CurveQE, 14); + List<Yw.Curve.CurvePoint> qpPointMax = Yw.Curve.FitHelper.GetFitPoints(rhs.CurveInfo.CurveQP, 14); + //List<Yw.Curve.CurvePoint> npshPointMax = Yw.Curve.FitHelper.GetFitPoints(_maxCurveGrp.CurveExpressNPSH, 8); + + if (!string.IsNullOrEmpty(rhs.CoordParas)) + { + var lxp = new Yw.Coordinate.LxpCoordinateParas(rhs.CoordParas); + _dictChartObject["Coordinate"] = new Yw.Dto.CoordinateParasLxp(lxp); + } + else + { + var lxp = Yw.Coordinate.CoordinateHelper.CalcCoordinate(qhPointMax, qePointMax, qpPointMax); + _dictChartObject["Coordinate"] = new Yw.Dto.CoordinateParasLxp(lxp); + } + + _dictChartObject["MaxCurveQH"] = BuildDispElement4UI(qhPointMax); + _dictChartObject["MaxCurveQE"] = BuildDispElement4UI(qePointMax); + _dictChartObject["MaxCurveQP"] = BuildDispElement4UI(qpPointMax); + //_dictChartObject["MaxWaterCurveNPSH"] = BuildDispElement4UI(npshPointMax); + } + + } + //浼犲叆鍒板墠绔�,娌″繀瑕佹湁杩囧灏忔暟鐐� + private List<Yw.Curve.CurvePoint> BuildDispElement4UI(List<Yw.Curve.CurvePoint> points) + { + if (points != null && points.Count > 0) + { + foreach (var pt in points) + { + if (pt != null) + { + pt.X = Math.Round(pt.X, 3); + pt.Y = Math.Round(pt.Y, 3); + } + } + } + return points; + } + + /// <summary> + /// + /// </summary> + public virtual long ID { get; set; } + /// <summary> + /// 鍚嶇О + /// </summary> + public string Name { get; set; } + + /// <summary> + /// 鏉ユ簮鏂瑰紡 + /// </summary> + public eSourceWay SourceWay { get; set; } + + /// <summary> + /// 鍒涘缓鏂规硶 + /// </summary> + public string CreateMethod { get; set; } + + + private Dictionary<string, object> _dictChartObject = null; + /// <summary> + /// + /// </summary> + public Dictionary<string, object> DictChartObject { get { return _dictChartObject; }set { _dictChartObject = value; } } + /// <summary> + /// 鍙俊搴� + /// </summary> + public eReliabilityStatus ReliabilityStatus { get; set; } + + /// <summary> + /// 褰曞叆鏃堕棿 + /// </summary> + public DateTime InputTime { get; set; } + + /// <summary> + /// 鍒涘缓鏃堕棿 + /// </summary> + public DateTime CreateTime { get; set; } + + /// <summary> + /// 鍒涘缓浜篿d + /// </summary> + public long CreateUserID { get; set; } + + /// <summary> + /// 鍒涘缓浜哄悕绉� + /// </summary> + public string CreateUserName { get; set; } + + /// <summary> + /// 鏇存柊鏃堕棿 + /// </summary> + public DateTime? UpdateTime { get; set; } + + /// <summary> + /// 鏇存柊浜篿d + /// </summary> + public long? UpdateUserID { get; set; } + + /// <summary> + /// 鏇存柊浜哄悕绉� + /// </summary> + public string UpdateUserName { get; set; } + + /// <summary> + /// 璇存槑 + /// </summary> + public string Description { get; set; } + + + } + +} diff --git a/Yw.Coordinate/Axis/AxisBase.cs b/Yw.Coordinate/Axis/AxisBase.cs new file mode 100644 index 0000000..c464d28 --- /dev/null +++ b/Yw.Coordinate/Axis/AxisBase.cs @@ -0,0 +1,19 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Yw.Coordinate +{ + [DataContract] + [Serializable] + public class AxisBase + { + [DataMember] + public double Max { set; get; }//鍙兘涓嶆槸鍏ㄩ儴鏃�, + [DataMember] + public double Min { set; get; }//鍙兘涓嶆槸鍏ㄩ儴鏃�, 鍜孡abel涓嶄竴鑷� + [DataMember] + public int Unit { set; get; } + } +} diff --git a/Yw.Coordinate/Axis/AxisNonuniform.cs b/Yw.Coordinate/Axis/AxisNonuniform.cs new file mode 100644 index 0000000..807c2e8 --- /dev/null +++ b/Yw.Coordinate/Axis/AxisNonuniform.cs @@ -0,0 +1,30 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; + +namespace Yw.Coordinate +{ + /// <summary> + /// 闈炲潎鍖�鍧愭爣 + /// </summary> + [DataContract] + [Serializable] + public class AxisNonuniform : AxisBase + { + [DataMember] + public List<double> GridValues { get; set; } + + public int GridNumber + { + get + { + if (GridValues == null) + return 0; + + return GridValues.Count(); + } + } + } +} diff --git a/Yw.Coordinate/Axis/AxisUniform.cs b/Yw.Coordinate/Axis/AxisUniform.cs new file mode 100644 index 0000000..ac1400d --- /dev/null +++ b/Yw.Coordinate/Axis/AxisUniform.cs @@ -0,0 +1,44 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; + +namespace Yw.Coordinate +{ + /// <summary> + /// 鍧囧寑鍧愭爣 + /// </summary> + [DataContract] + [Serializable] + public class AxisUniform : AxisBase + { + public AxisUniform() { } + public AxisUniform(double minAcoord, double maxAcoord, double refSpace) { + this.GridMin = minAcoord; + this.Min = minAcoord; + this.GridMax = maxAcoord; + this.Max = maxAcoord; + + this.GridSpace = refSpace; + } + [DataMember] + public double GridMax { set; get; }//鍒诲害鏈�澶у�� + [DataMember] + public double GridMin { set; get; }//鍒诲害鏈�灏忓�� + [DataMember] + public double GridSpace { set; get; }//鍒诲害闂撮殧 + + public int GridNumber + { + get + { + if (GridSpace <= 0) + return 0; + + return 1 + (int)((GridMax - GridMin) / GridSpace); + } + } + + } +} diff --git a/Yw.Coordinate/Axis/IAxisCalcer.cs b/Yw.Coordinate/Axis/IAxisCalcer.cs new file mode 100644 index 0000000..65da64e --- /dev/null +++ b/Yw.Coordinate/Axis/IAxisCalcer.cs @@ -0,0 +1,55 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Yw.Coordinate +{ + public interface IAxisCalcer + { + double Calc(double v); + double RevCalc(double v); + } + + public class ConstantAxis : IAxisCalcer + { + public double Calc(double v) + { + return v; + } + public double RevCalc(double v) + { + return v; + } + } + + public class Log10Axis : IAxisCalcer + { + public double Calc(double v) + { + return Math.Log10(v); + } + public double RevCalc(double v) + { + return Math.Pow(10, v); + } + } + + public class CoefficientAxis : IAxisCalcer + { + private double Coeff = 1; + public CoefficientAxis(double coeff) + { + Coeff = coeff; + } + public double Calc(double v) + { + return v * Coeff; + } + public double RevCalc(double v) + { + return v / Coeff; + } + } +} + diff --git a/Yw.Coordinate/AxisXyCalcer.cs b/Yw.Coordinate/AxisXyCalcer.cs new file mode 100644 index 0000000..9d67753 --- /dev/null +++ b/Yw.Coordinate/AxisXyCalcer.cs @@ -0,0 +1,36 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Yw.Model +{ + public class AxisXyCalcer + { + IAxisCalcer xCalc = null; + IAxisCalcer yCalc = null; + public AxisXyCalcer() + { + } + public AxisXyCalcer(IAxisCalcer AxisCalcerX, IAxisCalcer AxisCalcerY) + { + SetCalcer( AxisCalcerX,AxisCalcerY); + } + public void SetCalcer(IAxisCalcer AxisCalcerX, IAxisCalcer AxisCalcerY) + { + xCalc = AxisCalcerX; + yCalc = AxisCalcerY; + } + public double ToChartX(double v) + { + return xCalc.Calc(v); + } + + public double ToChartY(double v) + { + return yCalc.Calc(v); + } + + + } +} diff --git a/Yw.Coordinate/CoordinateHelper.cs b/Yw.Coordinate/CoordinateHelper.cs new file mode 100644 index 0000000..70982d6 --- /dev/null +++ b/Yw.Coordinate/CoordinateHelper.cs @@ -0,0 +1,1287 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Yw.Coordinate; + +namespace Yw.Coordinate +{ + public class CoordinateHelper + { + #region 寰楀埌鏈�浼樺潗鏍囬棿闅� + //鎵�鏈� + public static double GetOptimalSpace(double refSpace) + { + if (refSpace < 0.000001) + { + return 1; + } + if (refSpace < 0.01) + { + var refSpace2 = refSpace * 100; + return GetOptimalSpace(refSpace2) / 100; + } + else if (refSpace < 0.1) + { + var refSpace2 = refSpace * 10; + return GetOptimalSpace(refSpace2) / 10; + } + else if (refSpace < 1) + { + if (refSpace < 0.15) + return 0.1; + else if (refSpace < 0.22) + return 0.2; + //else if (refSpace < 0.32) + // return 0.25; + else if (refSpace < 0.6) + return 0.5; + //else if (refSpace < 0.85) + // return 0.75; + else + return 1; + } + + else if (refSpace < 3) + { + if (refSpace < 1.2) + return 1; + //else if (refSpace < 1.7) + // return 1.5; + else if (refSpace < 2.3) + return 2; + //else if (refSpace < 2.7) + // return 2.5; + else + return 3; + } + else if (refSpace < 11) + { + if (refSpace < 5.5) + return 5; + //else if (refSpace < 6.5) + // return 6; + //else if (refSpace < 7.8) + // return 7.5; + else if (refSpace < 8.5) + return 8; + else + return 10; + } + else if (refSpace < 16) + return 15; + else if (refSpace < 22) + return 20; + else if (refSpace < 35) + return 25; + else if (refSpace < 41) + return 40; + else if (refSpace < 51) + return 50; + else if (refSpace < 61) + return 60; + else if (refSpace < 71) + return 70; + else if (refSpace < 78) + return 75; + else if (refSpace < 150) + return 100; + else if (refSpace < 230) + return 200; + else if (refSpace < 270) + { + return 250; + } + else + { + if (refSpace < 1500) + { + int a = (int)(refSpace / 100); + return a * 100; + } + else + { + int a = (int)(refSpace / 1000); + return a * 1000; + } + } + } + + //鍙栦笅涓�妗� + public static double GetNextSpace(double refSpace) + { + if (refSpace < 0.01) + { + var refSpace2 = refSpace * 100; + return GetNextSpace(refSpace2) / 100; + } + else if (refSpace < 0.1) + { + var refSpace2 = refSpace * 10; + return GetNextSpace(refSpace2) / 10; + } + + if (refSpace < 0.11) + return 0.2; + else if (refSpace < 0.201) + return 0.25; + else if (refSpace < 0.251) + return 0.5; + else if (refSpace < 0.51) + return 0.75; + else if (refSpace < 0.751) + return 1; + else if (refSpace < 1.01) + return 1.5; + else if (refSpace < 1.51) + return 2; + else if (refSpace < 2.01) + return 2.5; + else if (refSpace < 2.51) + return 3; + else if (refSpace < 3.01) + return 5; + else if (refSpace < 5.01) + return 6; + else if (refSpace < 6.01) + return 7.5; + else if (refSpace < 7.51) + return 8; + else if (refSpace < 8.01) + return 10; + + else if (refSpace < 10.1) + return 15; + else if (refSpace < 15.1) + return 20; + else if (refSpace < 20.1) + return 25; + else if (refSpace < 40.1) + return 40; + else if (refSpace < 40.1) + return 50; + else if (refSpace < 50.1) + return 60; + else if (refSpace < 70.1) + return 70; + else if (refSpace < 70.1) + return 75; + else if (refSpace < 75.1) + return 100; + else if (refSpace < 100.1) + return 200; + else if (refSpace < 200.1) + return 250; + else if (refSpace < 250.1) + return 500; + else if (refSpace < 1500) + { + int a = (int)(refSpace / 100); + return a * 100 + 100; + } + else + { + int a = (int)(refSpace / 1000); + return a * 1000 + 1000; + } + + } + + //涓嶅甫灏忔暟鐐� + public static double GetOptimalSpace2(double refSpace) + { + if (refSpace < 1.2) + { + return 1; + } + else if (refSpace < 11) + { + if (refSpace < 1.35) + return 1; + else if (refSpace < 2.2) + return 2; + else if (refSpace < 5.5) + return 5; + else if (refSpace < 8.5) + return 8; + else + return 10; + } + else + { + return GetOptimalSpace(refSpace); + } + } + #endregion + + //鎵�鏈� + public static Yw.Coordinate.AxisUniform GetCoordAxis(double minRecord, double maxRecord, double spaceNumber) + { + if (spaceNumber < 2) + return null; + if (minRecord > maxRecord - 0.001) + return null; + if (maxRecord < 0.1) + { + var coord = GetCoordAxis(minRecord * 100, maxRecord * 100, spaceNumber); + coord.GridMin = coord.GridMin / 100; + coord.GridMax = coord.GridMax / 100; + coord.GridSpace = coord.GridSpace / 100; + coord.Min = coord.Min / 100; + coord.Max = coord.Max / 100; + return coord; + } + else if (maxRecord < 1) + { + var coord = GetCoordAxis(minRecord * 10, maxRecord * 10, spaceNumber); + coord.GridMin = coord.GridMin / 10; + coord.GridMax = coord.GridMax / 10; + coord.GridSpace = coord.GridSpace / 10; + coord.Min = coord.Min / 10; + coord.Max = coord.Max / 10; + + return coord; + } + else if (maxRecord < 100) + { + double refSpace = (maxRecord - minRecord) / spaceNumber; + refSpace = GetOptimalSpace(refSpace); + + double minAcoord = Math.Round(((int)minRecord / refSpace) * refSpace, 0); + double maxAcoord = minAcoord + spaceNumber * refSpace; + if (maxAcoord < maxRecord) + { + refSpace = GetNextSpace(refSpace);//鍙栦竴涓嬫。 + minAcoord = Math.Round(((int)minRecord / refSpace) * refSpace, 0); + maxAcoord = minAcoord + spaceNumber * refSpace; + return new Yw.Coordinate.AxisUniform(minAcoord, maxAcoord, refSpace); + } + else + { + return new Yw.Coordinate.AxisUniform(minAcoord, maxAcoord, refSpace); + } + } + else if (maxRecord < 10000) + { + double refSpace = (maxRecord - minRecord) / spaceNumber; + refSpace = GetOptimalSpace(refSpace); + + double minAcoord = (int)((minRecord / refSpace) * refSpace / 100) * 100;//鍙�100鐨勬暣鏁� + double maxAcoord = minAcoord + spaceNumber * refSpace; + if (maxAcoord < maxRecord) + { + refSpace = GetNextSpace(refSpace);//鍙栦竴涓嬫。 + minAcoord = (int)((minRecord / refSpace) * refSpace / 100) * 100;//鍙�100鐨勬暣鏁� + maxAcoord = minAcoord + spaceNumber * refSpace; + return new Yw.Coordinate.AxisUniform(minAcoord, maxAcoord, refSpace); + } + else + { + return new Yw.Coordinate.AxisUniform(minAcoord, maxAcoord, refSpace); + } + } + else + {//澶т簬10000 + + double refSpace = (maxRecord - minRecord) / spaceNumber; + double minAcoord, maxAcoord; + if (refSpace > 500 && refSpace < 1000) + { + for (refSpace = 500; refSpace <= 2000; refSpace = refSpace + 100) + { + minAcoord = (int)((minRecord / refSpace) * refSpace / 1000) * 1000;//鍙�100鐨勬暣鏁� + maxAcoord = minAcoord + spaceNumber * refSpace; + if (maxAcoord < maxRecord) + continue; + return new Yw.Coordinate.AxisUniform(minAcoord, maxAcoord, refSpace); + } + } + else if (refSpace > 1000) + { + for (refSpace = 1000; refSpace <= 20000; refSpace = refSpace + 500) + { + minAcoord = (int)((minRecord / refSpace) * refSpace / 1000) * 1000;//鍙�100鐨勬暣鏁� + maxAcoord = minAcoord + spaceNumber * refSpace; + if (maxAcoord < maxRecord) + continue; + + return new Yw.Coordinate.AxisUniform(minAcoord, maxAcoord, refSpace); + } + } + + refSpace = GetOptimalSpace(refSpace); + + minAcoord = (int)((minRecord / refSpace) * refSpace / 1000) * 1000;//鍙�1000鐨勬暣鏁� + maxAcoord = minAcoord + spaceNumber * refSpace; + if (maxAcoord < maxRecord) + { + refSpace = GetNextSpace(refSpace);//鍙栦竴涓嬫。 + minAcoord = (int)((minRecord / refSpace) * refSpace / 1000) * 1000;//鍙�1000鐨勬暣鏁� + maxAcoord = minAcoord + spaceNumber * refSpace; + + if (maxAcoord < maxRecord) + { + refSpace = GetNextSpace(refSpace);//鍙栦竴涓嬫。 + minAcoord = (int)((minRecord / refSpace) * refSpace / 1000) * 1000;//鍙�1000鐨勬暣鏁� + maxAcoord = minAcoord + spaceNumber * refSpace; + + if (maxAcoord < maxRecord) + { + refSpace = GetNextSpace(refSpace);//鍙栦竴涓嬫。 + minAcoord = (int)((minRecord / refSpace) * refSpace / 1000) * 1000;//鍙�1000鐨勬暣鏁� + maxAcoord = minAcoord + spaceNumber * refSpace; + + return new Yw.Coordinate.AxisUniform(minAcoord, maxAcoord, refSpace); + } + else + { + return new Yw.Coordinate.AxisUniform( minAcoord, maxAcoord, refSpace ); + } + } + else + { + return new Yw.Coordinate.AxisUniform(minAcoord, maxAcoord, refSpace); + } + } + else + { + return new Yw.Coordinate.AxisUniform(minAcoord, maxAcoord, refSpace); + } + } + + } + + + + #region 鏍规嵁鏈�灏忓�糓in璁$畻 + //寰楀埌鏈�浼樺潗鏍囬棿闅�,杩樹細杩斿洖鏄剧ず鐨勬渶澶ф渶灏忓��,淇濊瘉minDisplay鏄瘮minValue灏忕殑鏈�澶ч棿闅欐暣鏁板�� + public static double GetOptimalSpaceMin(double minValue, double maxValue, int spaceNum, out double minDisplay, out double maxDisplay) + { + minDisplay = minValue; + maxDisplay = maxValue; + double dis = maxValue - minValue; + if (dis < 0 || spaceNum < 1) + return (maxValue - minValue) / 10; + + double space = GetOptimalSpace((maxValue - minValue) / spaceNum); + if (space < 2) + { + minDisplay = Math.Floor(minValue / space) * space; + maxDisplay = minDisplay + spaceNum * space; + } + else + { + minDisplay = Math.Floor(minValue / space) * space; + maxDisplay = minDisplay + spaceNum * space; + } + + + return space; + } + + public static double GetOptimalSpaceMin(double minValue, double maxValue, double coeff, int spaceNum, out double minDisplay, out double maxDisplay) + { + minDisplay = minValue; + maxDisplay = maxValue; + double dis = maxValue - minValue; + if (dis < 0 || spaceNum < 1) + { + return (maxValue - minValue) / 10; + } + + double space = GetOptimalSpace((maxValue / coeff - minValue / coeff) / spaceNum) * coeff; + if (space < 2) + { + minDisplay = Math.Floor(minValue / coeff / space) * space * coeff; + maxDisplay = minDisplay + spaceNum * space; + } + else + { + minDisplay = Math.Floor(minValue / coeff / space) * space * coeff; + maxDisplay = minDisplay + spaceNum * space; + } + + + return space; + } + + + //寰楀埌鏈�浼樺潗鏍囬棿闅�,杩樹細杩斿洖鏄剧ず鐨勬渶澶ф渶灏忓��,淇濊瘉minDisplay鏄瘮minValue灏忕殑鏈�澶ч棿闅欐暣鏁板�� + public static double GetOptimalSpaceMin(double minValue, double space) + { + double minDisplay = minValue; + + return Math.Floor(minValue / space) * space; + } + #endregion + + #region 鏍规嵁鏈�澶у�糓ax璁$畻 + //寰楀埌鏈�浼樺潗鏍囬棿闅�,杩樹細杩斿洖鏄剧ず鐨勬渶澶ф渶灏忓��,淇濊瘉maxDisplay鏄瘮maxValue澶х殑鏈�灏忛棿闅欐暣鏁板�� + public static double GetOptimalSpaceMax(double minValue, double maxValue, int spaceNum, out double minDisplay, out double maxDisplay) + { + minDisplay = minValue; + maxDisplay = maxValue; + double dis = maxValue - minValue; + if (dis < 0 || spaceNum < 1) + return (maxValue - minValue) / 10; + + double space = GetOptimalSpace((maxValue - minValue) / spaceNum); + + maxDisplay = Math.Ceiling(maxValue / space) * space; + minDisplay = maxDisplay - spaceNum * space; + + return space; + } + //涓嶉渶瑕佸皬鏁扮偣 + public static double GetOptimalSpaceMax2(double minValue, double maxValue, int spaceNum, out double minDisplay, out double maxDisplay) + { + minDisplay = minValue; + maxDisplay = maxValue; + double dis = maxValue - minValue; + if (dis < 0 || spaceNum < 1) + return (maxValue - minValue) / 5; + + double space = GetOptimalSpace2((maxValue - minValue) / spaceNum); + + maxDisplay = Math.Ceiling(maxValue / space) * space; + minDisplay = maxDisplay - spaceNum * space; + + return space; + } + + #endregion + + #region Optimal + //寰楀埌鏈�浼樺潗鏍囬棿闅�,杩樹細杩斿洖鏄剧ず鐨勬渶澶ф渶灏忓��,涓嶄繚璇佸埢搴︽暟spaceNum,淇濊瘉鐪熷疄鍊煎湪鏄剧ず鍊煎唴閮� + public static double GetOptimalSpaceNum(double minValue, double maxValue, ref int spaceNum, out double minDisplay, out double maxDisplay) + { + minDisplay = minValue; + maxDisplay = maxValue; + double dis = maxValue - minValue; + if (dis < 0 || spaceNum < 1) + return (maxValue - minValue) / 10; + + double space = GetOptimalSpace((maxValue - minValue) / spaceNum); + + minDisplay = Math.Floor(minValue / space) * space; + maxDisplay = minDisplay + spaceNum * space; + + while (maxDisplay < maxValue) + { + spaceNum++; + maxDisplay = minDisplay + spaceNum * space; + } + + return space; + } + + //娉ㄦ剰 杩斿洖鐨凩ist澶у皬涓簊paceNum+1 + public static List<double> GetOptimal(double min, double max, int spaceNum) + { + double dis = max - min; + if (dis < 0 || spaceNum < 1) + return null; + + double space = GetOptimalSpace((max - min) / spaceNum); + + List<double> valueList = new List<double>(); + + int startK = (int)Math.Floor(min / space);//Ceiling + double start = startK * space; + + double total = start; + //while (total < max + firstSplitSpace) + for (int i = 0; i < spaceNum + 1; i++) + { + valueList.Add(total); + total = total + space; + } + + return valueList; + } + + + #endregion + + #region 璁剧疆鍧愭爣鍊�(鍙湁H鍊�) + //璁剧疆鍧愭爣鍊� 鍙樉绀烘祦閲忔壃绋� + public static void CalcCoordinate2(ref Yw.Coordinate.QhCoordinateParas coordinateParas, double minQ, double maxQ, double minH, double maxH, + int GridNumberX = 10, int GridNumberY = 12) + { + if (minQ < 0) + minQ = 0; + if(coordinateParas==null) + coordinateParas = new Yw.Coordinate.QhCoordinateParas(); + + //娴侀噺 + double dispMinQ = 0; + double dispMaxQ = 0; + double CoordSpaceQ = GetOptimalSpaceMin(minQ , maxQ , GridNumberX, out dispMinQ, out dispMaxQ); + //璁$畻鏈夋晥鍒诲害 + double dispQ = dispMinQ - CoordSpaceQ; + coordinateParas.GridValueQ = new List<double>(); + while (dispQ < maxQ) + { + dispQ = dispQ + CoordSpaceQ; + if (dispQ >= 0) + coordinateParas.GridValueQ.Add(dispQ); + } + + //鎵▼ + double dispMinH = 0; + double dispMaxH = 0; + double CoordSpaceH = GetOptimalSpaceMin(minH , maxH , GridNumberY, out dispMinH, out dispMaxH); + CoordSpaceH = Math.Max(1, CoordSpaceH); + + //璁$畻鏈夋晥鍒诲害 + double disH = dispMinH - CoordSpaceH; + coordinateParas.GridValueH = new List<double>(); + while (disH < maxH) + { + disH = disH + CoordSpaceH; + if (disH >= 0) + coordinateParas.GridValueH.Add(disH); + } + } + + //璁$畻鍧囧寑鍧愭爣 + public static void CalcCoordinate( + ref Yw.Coordinate.QhCoordinateParas coordinateParas, + double minQ, double maxQ, double minH, double maxH, + int gridNumX = 10, int gridNumY = 10) + { + if (minQ < 0) + minQ = 0; + if (coordinateParas == null) + coordinateParas = new Yw.Coordinate.QhCoordinateParas(); + + double spaceQ = (maxQ - minQ) / gridNumX; + spaceQ = Yw.Coordinate.CoordinateHelper.GetOptimalSpace(spaceQ); + + double q = 0; + int index = (int)(minQ / spaceQ); + q = index * spaceQ; + coordinateParas.GridValueQ = new List<double>(); + while (q < maxQ) + { + if (q >= 0) + { + coordinateParas.GridValueQ.Add(q); + } + + q = q + spaceQ; + } + coordinateParas.GridValueQ.Add(q); + + if (maxH == minH) + { + coordinateParas.GridValueH.Add(maxH/2); + coordinateParas.GridValueH.Add(maxH); + coordinateParas.GridValueH.Add(maxH + maxH / 2); + coordinateParas.GridValueH.Add(maxH + maxH ); + } + else + { + double spaceH = (maxH - minH) / gridNumY; + spaceH = Yw.Coordinate.CoordinateHelper.GetOptimalSpace(spaceH); + double h = 0; + index = (int)(minH / spaceH); + h = index * spaceH; + coordinateParas.GridValueH = new List<double>(); + while (h < maxH) + { + if (h >= 0) + coordinateParas.GridValueH.Add(h); + + h = h + spaceH; + } + coordinateParas.GridValueH.Add(h); + } + } + + + + #endregion + + + #region 璁剧疆鍧愭爣鍊�(澶歒鍊�) + //璁$畻鏈�澶ф渶灏忓�� + public static bool CalcMinMaxValue( + List<Yw.Curve.CurvePoint> PointInfoQH, + List<Yw.Curve.CurvePoint> PointInfoQE, + List<Yw.Curve.CurvePoint> PointInfoQP, + ref double maxQ, ref double minQ, + ref double maxH, ref double minH, + ref double maxE, ref double minE, + ref double maxP, ref double minP ) + { + maxQ = 0; minQ = 1000; + maxH = 0; minH = 1000; + maxE = 0; minE = 1000; + maxP = 0; minP = 1000; + + if (PointInfoQH == null ) + return false; + + minQ = (from x in PointInfoQH select x.X).Min(); + maxQ = (from x in PointInfoQH select x.X).Max(); + if (minQ > maxQ) + return false; + + minH = (from x in PointInfoQH select x.Y).Min(); + maxH = (from x in PointInfoQH select x.Y).Max(); + + if (PointInfoQE != null && PointInfoQE.Count>0) + { + minE = (from x in PointInfoQE select x.Y).Min(); + maxE = (from x in PointInfoQE select x.Y).Max(); + } + if (PointInfoQP != null && PointInfoQP.Count > 0) + { + minP = (from x in PointInfoQP select x.Y).Min(); + maxP = (from x in PointInfoQP select x.Y).Max(); + } + + return true; + } + + //璁剧疆鍧愭爣鍊� + public static Yw.Coordinate.LxpCoordinateParas CalcCoordinate( + List<Yw.Curve.CurvePoint> PointInfoQH, + List<Yw.Curve.CurvePoint> PointInfoQE, + List<Yw.Curve.CurvePoint> PointInfoQP ) + { + if (PointInfoQH == null) + return null; + if (PointInfoQE == null) + return null; + if (PointInfoQP == null) + return null; + + //璁$畻鏈�澶ф渶灏忓�� + double maxQ = 0, minQ = 1000; + double maxH = 0, minH = 1000; + double maxE = 0, minE = 1000; + double maxP = 0, minP = 1000; + + CalcMinMaxValue(PointInfoQH, PointInfoQE, PointInfoQP, + ref maxQ, ref minQ, + ref maxH, ref minH, + ref maxE, ref minE, + ref maxP, ref minP ); + + + return CalcCoordinate(minQ, maxQ, minH, maxH, minE, maxE, minP, maxP ); + } + + + + + + + + + + // + public static Yw.Coordinate.LxpCoordinateParas CalcCoordinate( + double minQ,double maxQ, + double minH,double maxH, + double minE,double maxE, + double minP,double maxP ) + { + if (minQ >= maxQ) + { + minQ = maxQ / 2; + maxQ = maxQ * 2; + } + if (minH >= maxH) + { + minH = maxH / 2; + maxH = maxH * 2; + } + + + //鎵▼閮借缃粠0寮�濮� + Yw.Coordinate.LxpCoordinateParas coordinateParas = new Yw.Coordinate.LxpCoordinateParas(); + coordinateParas.GridNumberX = 10; + coordinateParas.GridNumberY = 18; + + //璁$畻X鍧愭爣 + CalcCoordinateQ1(minQ, maxQ, ref coordinateParas, coordinateParas.GridNumberX); + + + + if (maxP > minP + 0.01) + { + CalcCoordinateY_Left(minH, maxH, minP, maxP, 0, ref coordinateParas); + } + else + { + double dispMinH, dispMaxH; + CalcCoordinateH(minH, maxH, coordinateParas.GridNumberY, ref coordinateParas, + out dispMinH, out dispMaxH); + } + + + + + //鍐嶈绠楀彸杈�: + if (maxE > minE + 0.01) + CalcCoordinateEta(minE, maxE , ref coordinateParas); + + + return coordinateParas; + } + + + + + + #endregion + + + #region 绂诲績娉靛潗鏍嘫 + //鏍规嵁validGridNumH璁$畻H鍊� + private static void CalcCoordinateH( + double minH, double maxH, + int validGridNumH, + ref Yw.Coordinate.LxpCoordinateParas coordinateParas, + out double disMinH, + out double disMaxH) + { + if (minH > 100 && maxH > 100) + { + CalcCoordinateH浣庝簬100(minH/100, maxH/100, validGridNumH, ref coordinateParas, out disMinH, out disMaxH); + if (coordinateParas != null) + { + coordinateParas.CoordMinH = coordinateParas.CoordMinH * 100; + coordinateParas.CoordSpaceH = coordinateParas.CoordSpaceH * 100; + + disMinH = disMinH * 100; + disMaxH = disMaxH * 100; + } + } + else + { + CalcCoordinateH浣庝簬100(minH, maxH, validGridNumH,ref coordinateParas, out disMinH, out disMaxH); + } + } + private static void CalcCoordinateH浣庝簬100( + double minH, double maxH, + int validGridNumH, + ref Yw.Coordinate.LxpCoordinateParas coordinateParas, + out double disMinH, + out double disMaxH) + { + if (minH == maxH) + { + minH = minH / 2; + maxH = maxH * 2; + } + disMinH = 0; + disMaxH = 0; + + if (maxH > 20) + coordinateParas.CoordSpaceH = GetOptimalSpaceMax2(minH, maxH, validGridNumH, out disMinH, out disMaxH); + else + coordinateParas.CoordSpaceH = GetOptimalSpaceMax(minH, maxH , validGridNumH, out disMinH, out disMaxH); + + double disH = disMaxH; + coordinateParas.EndLineNoH = coordinateParas.GridNumberY; + coordinateParas.StartLineNoH = coordinateParas.EndLineNoH; + while (disH > minH * 0.98) + { + disH = disH - coordinateParas.CoordSpaceH; + if (disH < 0) + break; + coordinateParas.StartLineNoH--; + } + coordinateParas.CoordMinH = disMaxH - coordinateParas.EndLineNoH * coordinateParas.CoordSpaceH; + } + + + + + //鏍规嵁validGridNumH璁$畻H鍊�,浣嗕細姣旇緝maxH鍊� + private static void CalcCoordinateH2( + double minH, double maxH, + int validGridNumH, + ref Yw.Coordinate.LxpCoordinateParas coordinateParas, + out double disMinH, + out double disMaxH) + { + if (minH == maxH) + { + minH = minH / 2; + maxH = maxH * 2; + } + if (maxH < 1) + { + coordinateParas.CoordSpaceH = 0.1; + disMinH = 0; + disMaxH = 1; + coordinateParas.EndLineNoH = coordinateParas.GridNumberY; + coordinateParas.StartLineNoH = coordinateParas.EndLineNoH - (int)((disMaxH - disMinH )/ coordinateParas.CoordSpaceH); + coordinateParas.CoordMinH = disMaxH - coordinateParas.EndLineNoH * coordinateParas.CoordSpaceH; + } + else if (maxH < 2) + { + coordinateParas.CoordSpaceH = 0.2; + disMinH = 0; + disMaxH = 2; + coordinateParas.EndLineNoH = coordinateParas.GridNumberY; + coordinateParas.StartLineNoH = coordinateParas.EndLineNoH - (int)((disMaxH - disMinH) / coordinateParas.CoordSpaceH); + coordinateParas.CoordMinH = disMaxH - coordinateParas.EndLineNoH * coordinateParas.CoordSpaceH; + } + else if (maxH < 5) + { + coordinateParas.CoordSpaceH = 0.5; + disMinH = 0; + disMaxH = 5; + coordinateParas.EndLineNoH = coordinateParas.GridNumberY; + coordinateParas.StartLineNoH = coordinateParas.EndLineNoH - (int)((disMaxH - disMinH) / coordinateParas.CoordSpaceH); + coordinateParas.CoordMinH = disMaxH - coordinateParas.EndLineNoH * coordinateParas.CoordSpaceH; + } + else if (maxH < 10) + { + coordinateParas.CoordSpaceH = 1; + disMinH = 0; + disMaxH = 10; + coordinateParas.EndLineNoH = coordinateParas.GridNumberY; + coordinateParas.StartLineNoH = coordinateParas.EndLineNoH - (int)((disMaxH - disMinH) / coordinateParas.CoordSpaceH); + coordinateParas.CoordMinH = disMaxH - coordinateParas.EndLineNoH * coordinateParas.CoordSpaceH; + } + else if (maxH < 12) + { + coordinateParas.CoordSpaceH = 1; + disMinH = 0; + disMaxH = 12; + coordinateParas.EndLineNoH = coordinateParas.GridNumberY; + coordinateParas.StartLineNoH = coordinateParas.EndLineNoH - (int)((disMaxH - disMinH) / coordinateParas.CoordSpaceH); + coordinateParas.CoordMinH = disMaxH - coordinateParas.EndLineNoH * coordinateParas.CoordSpaceH; + } + else if (maxH < 15) + { + coordinateParas.CoordSpaceH = 2; + disMinH = 0; + disMaxH = 16; + coordinateParas.EndLineNoH = coordinateParas.GridNumberY; + coordinateParas.StartLineNoH = coordinateParas.EndLineNoH - (int)((disMaxH - disMinH) / coordinateParas.CoordSpaceH); + coordinateParas.CoordMinH = disMaxH - coordinateParas.EndLineNoH * coordinateParas.CoordSpaceH; + } + else if (maxH < 20) + { + coordinateParas.CoordSpaceH = 2; + disMinH = 0; + disMaxH = 20; + coordinateParas.EndLineNoH = coordinateParas.GridNumberY; + coordinateParas.StartLineNoH = coordinateParas.EndLineNoH - (int)((disMaxH - disMinH) / coordinateParas.CoordSpaceH); + coordinateParas.CoordMinH = disMaxH - coordinateParas.EndLineNoH * coordinateParas.CoordSpaceH; + } + else + { + CalcCoordinateH(minH, maxH, validGridNumH, ref coordinateParas, out disMinH, out disMaxH); + } + } + + + + //downGridNum 涓嬮儴淇濈暀鍒诲害绾跨殑鏁伴噺 + private static void CalcCoordinateY_Left( + double minH, double maxH, + double minP, double maxP, + int downGridNum, + ref Yw.Coordinate.LxpCoordinateParas coordinateParas) + { + //鎵▼ + int validGridNumH = 6; + double disMinH = 0; + double disMaxH = 0; + CalcCoordinateH2(minH, maxH, validGridNumH, ref coordinateParas, out disMinH, out disMaxH); + //鎵▼鍜屽姛鐜囦箣闂寸殑鏍煎瓙鏁� + int HP_grid_dis = 5; + + #region 鍔熺巼 + int validGridNumP = coordinateParas.StartLineNoH - HP_grid_dis - downGridNum; + if (validGridNumP < 3) + validGridNumP = 3; + double disMinP = 0; + double disMaxP = 0; + coordinateParas.CoordSpaceP = GetOptimalSpaceMax(minP, maxP, validGridNumP, out disMinP, out disMaxP); + // + double disP = disMaxP; + coordinateParas.EndLineNoP = coordinateParas.StartLineNoH - HP_grid_dis; + coordinateParas.StartLineNoP = coordinateParas.EndLineNoP; + while (disP > minP * 0.98) + { + disP = disP - coordinateParas.CoordSpaceP; + if (disP < 0) + break; + coordinateParas.StartLineNoP--; + } + #endregion + + if (coordinateParas.StartLineNoP < downGridNum) + { + int addGridNum = downGridNum - coordinateParas.StartLineNoP; + coordinateParas.GridNumberY = coordinateParas.GridNumberY + addGridNum;//Y鍒诲害鏁颁篃瑕佹坊鍔� + coordinateParas.EndLineNoH = coordinateParas.EndLineNoH + addGridNum; + coordinateParas.StartLineNoH = coordinateParas.StartLineNoH + addGridNum; + coordinateParas.EndLineNoP = coordinateParas.EndLineNoP + addGridNum; + coordinateParas.StartLineNoP = coordinateParas.StartLineNoP + addGridNum; + } + + //璁$畻鏈�灏忓�� + coordinateParas.CoordMinH = disMaxH - coordinateParas.EndLineNoH * coordinateParas.CoordSpaceH ; + coordinateParas.CoordMinP = disMaxP - coordinateParas.EndLineNoP * coordinateParas.CoordSpaceP ; + } + + + //鏁堢巼 + public static void CalcCoordinateEta(double minE, double maxE, + ref Yw.Coordinate.LxpCoordinateParas coordinateParas) + { + if (maxE <= 50) + { + coordinateParas.StartLineNoE = coordinateParas.EndLineNoNPSH + 3; + coordinateParas.EndLineNoE = coordinateParas.StartLineNoE + 5; + coordinateParas.CoordSpaceE = 10; + } + else if (maxE <= 60) + { + coordinateParas.StartLineNoE = coordinateParas.EndLineNoNPSH + 3; + coordinateParas.EndLineNoE = coordinateParas.StartLineNoE + 6; + coordinateParas.CoordSpaceE = 10; + } + else + { + coordinateParas.StartLineNoE = coordinateParas.EndLineNoNPSH + 3; + coordinateParas.EndLineNoE = coordinateParas.StartLineNoE + 5; + coordinateParas.CoordSpaceE = 20; + } + + coordinateParas.CoordMinE = -coordinateParas.StartLineNoE * coordinateParas.CoordSpaceE; + } + + public static void CalcCoordinateEta( double maxE, ref Yw.Coordinate.LxpCoordinateParas coordinateParas) + { + //鏁堢巼 + if (maxE <= 50) + { + coordinateParas.StartLineNoE = coordinateParas.EndLineNoNPSH + 3; + coordinateParas.EndLineNoE = coordinateParas.StartLineNoE + 5; + coordinateParas.CoordSpaceE = 5; + } + else if (maxE <= 75) + { + coordinateParas.StartLineNoE = coordinateParas.EndLineNoNPSH + 3; + coordinateParas.EndLineNoE = coordinateParas.StartLineNoE + 6; + coordinateParas.CoordSpaceE = 10; + } + else + { + coordinateParas.StartLineNoE = coordinateParas.EndLineNoNPSH + 3; + coordinateParas.EndLineNoE = coordinateParas.StartLineNoE + 5; + coordinateParas.CoordSpaceE = 20; + } + + coordinateParas.CoordMinE = -coordinateParas.StartLineNoE * coordinateParas.CoordSpaceE; + } + + + + + + + + #endregion + + + #region 璁$畻娴侀噺鍧愭爣 + // + public static void CalcCoordinateQ1(double minQ, double maxQ, ref Yw.Coordinate.LxpCoordinateParas coordinateParas, int validGridNum = 10) + { + double dispMinQ = 0; + double dispMaxQ = 0; + coordinateParas.CoordSpaceQ = GetOptimalSpaceMin(minQ, maxQ, validGridNum, out dispMinQ, out dispMaxQ); + coordinateParas.CoordSpaceQ = Math.Max(0.5, coordinateParas.CoordSpaceQ);//鏈�灏忎篃鏄�0.5 + if (coordinateParas.CoordSpaceQ == 8) + coordinateParas.CoordSpaceQ = 10; + + //璁$畻鏈夋晥鍒诲害 + double disQ = dispMinQ; + coordinateParas.CoordMinQ = dispMinQ; + coordinateParas.GridNumberX = 0; + while (disQ < maxQ) + { + coordinateParas.GridNumberX++; + disQ = dispMinQ + coordinateParas.GridNumberX * coordinateParas.CoordSpaceQ; + } + if (coordinateParas.GridNumberX <= 5) + { + coordinateParas.CoordSpaceQ = coordinateParas.CoordSpaceQ * 0.5; + coordinateParas.GridNumberX = coordinateParas.GridNumberX*2; + } + //if (coordinateParas.GridNumberX < 5) + //{ + // coordinateParas.GridNumberX = 5; + //} + } + + + + //鍙湁5:6:10 涓夌闂撮殧(浠g爜淇濈暀) + public static void CalcCoordinateQ2(double minQ, double maxQ, ref Yw.Coordinate.LxpCoordinateParas coordinateParas) + { + //娴侀噺(姣旇緝鍝鏂规硶鍒嗘濂�) + if (minQ < maxQ) + { + double dispMinQ = 0; + double dispMaxQ = 0; + int spaceNum = -1; + double cz = -1; + + double space5 = GetOptimalSpace((maxQ - minQ) / 5); + double dispMinQ5 = Math.Floor(minQ / space5) * space5; + double dispMaxQ5 = dispMinQ5 + space5 * 5; + double cz5 = dispMaxQ5 - maxQ; + bool isCZ5 = cz5 > 0; + if (isCZ5) + { + spaceNum = 5; + cz = cz5; + } + + double space6 = GetOptimalSpace((maxQ - minQ) / 6); + double dispMinQ6 = Math.Floor(minQ / space6) * space6;//灏忎簬minQ鐨勬渶澶у�� + double dispMaxQ6 = dispMinQ6 + space6 * 6; + double cz6 = dispMaxQ6 - maxQ; + bool isCZ6 = cz6 > 0; + if (isCZ6) + { + if (spaceNum > 0) + { + if (cz6 < cz) + { + spaceNum = 6; + cz = cz6; + } + } + else + { + spaceNum = 6; + cz = cz6; + } + } + + double space10 = GetOptimalSpace((maxQ - minQ) / 10); + double dispMinQ10 = Math.Floor(minQ / space10) * space10; + double dispMaxQ10 = dispMinQ10 + space10 * 10; + double cz10 = dispMaxQ10 - maxQ; + bool isCZ10 = cz10 > 0; + if (isCZ10) + { + if (spaceNum > 0) + { + if (cz10 < cz) + { + spaceNum = 10; + cz = cz10; + } + } + else + { + spaceNum = 10; + cz = cz10; + } + } + + // + switch (spaceNum) + { + case 5: + coordinateParas.GridNumberX = 5; + coordinateParas.CoordSpaceQ = space5; + dispMinQ = dispMinQ5; + dispMaxQ = dispMinQ5 + 5 * space5; + break; + case 6: + coordinateParas.GridNumberX = 6; + coordinateParas.CoordSpaceQ = space6; + dispMinQ = dispMinQ6; + dispMaxQ = dispMinQ6 + 6 * space6; + break; + case 10: + coordinateParas.GridNumberX = 10; + coordinateParas.CoordSpaceQ = space10; + dispMinQ = dispMinQ10; + dispMaxQ = dispMinQ10 + 10 * space10; + break; + default: + //閮戒笉绗﹀悎,鍙兘鐢�5鐨勭劧鍚庡鍙栦竴涓� + coordinateParas.GridNumberX = 6; + coordinateParas.CoordSpaceQ = space5; + dispMinQ = dispMinQ5; + dispMaxQ = dispMinQ5 + 6 * space5; + break; + } + + coordinateParas.CoordMinQ = dispMinQ; + } + } + //鍙湁5:6:10 涓夌闂撮殧(浠g爜淇濈暀) + private static void CalcCoordinateQ3(double minQ, double maxQ, ref Yw.Coordinate.LxpCoordinateParas CoordinateParas) + { + //娴侀噺(姣旇緝鍝鏂规硶鍒嗘濂�) + if (minQ < maxQ) + { + double dispMinQ = 0; + double dispMaxQ = 0; + int spaceNum = -1; + double cz = -1; + + double space5 = CoordinateHelper.GetOptimalSpace((maxQ - minQ) / 5); + double dispMinQ5 = Math.Floor(minQ / space5) * space5; + double dispMaxQ5 = dispMinQ5 + space5 * 5; + double cz5 = dispMaxQ5 - maxQ; + bool isCZ5 = cz5 > 0; + if (isCZ5) + { + spaceNum = 5; + cz = cz5; + } + + double space6 = CoordinateHelper.GetOptimalSpace((maxQ - minQ) / 6); + double dispMinQ6 = Math.Floor(minQ / space6) * space6;//灏忎簬minQ鐨勬渶澶у�� + double dispMaxQ6 = dispMinQ6 + space6 * 6; + double cz6 = dispMaxQ6 - maxQ; + bool isCZ6 = cz6 > 0; + if (isCZ6) + { + if (spaceNum > 0) + { + if (cz6 < cz) + { + spaceNum = 6; + cz = cz6; + } + } + else + { + spaceNum = 6; + cz = cz6; + } + } + + double space10 = CoordinateHelper.GetOptimalSpace((maxQ - minQ) / 10); + double dispMinQ10 = Math.Floor(minQ / space10) * space10; + double dispMaxQ10 = dispMinQ10 + space10 * 10; + double cz10 = dispMaxQ10 - maxQ; + bool isCZ10 = cz10 > 0; + if (isCZ10) + { + if (spaceNum > 0) + { + if (cz10 < cz) + { + spaceNum = 10; + cz = cz10; + } + } + else + { + spaceNum = 10; + cz = cz10; + } + } + + // + switch (spaceNum) + { + case 5: + CoordinateParas.GridNumberX = 5; + CoordinateParas.CoordSpaceQ = space5; + dispMinQ = dispMinQ5; + dispMaxQ = dispMinQ5 + 5 * space5; + break; + case 6: + CoordinateParas.GridNumberX = 6; + CoordinateParas.CoordSpaceQ = space6; + dispMinQ = dispMinQ6; + dispMaxQ = dispMinQ6 + 6 * space6; + break; + case 10: + CoordinateParas.GridNumberX = 10; + CoordinateParas.CoordSpaceQ = space10; + dispMinQ = dispMinQ10; + dispMaxQ = dispMinQ10 + 10 * space10; + break; + default: + //閮戒笉绗﹀悎,鍙兘鐢�5鐨勭劧鍚庡鍙栦竴涓� + CoordinateParas.GridNumberX = 5; + CoordinateParas.CoordSpaceQ = space5; + dispMinQ = dispMinQ5; + dispMaxQ = dispMinQ5 + 6 * space5; + break; + } + + CoordinateParas.CoordMinQ = dispMinQ; + } + } + + #endregion + + + + #region 瀛愬埢搴︽暟閲� + //鑾峰彇瀛愬埢搴︽暟閲� + public static int GetMiniCount(double space) + { + if (space > 10000) + return GetMiniCount2(space / 10000); + else if (space > 1000) + return GetMiniCount2(space / 1000); + else if (space > 100) + return GetMiniCount2(space / 100); + else if (space > 10) + return GetMiniCount2(space / 10); + else if (space > 1) + return GetMiniCount2(space); + else if (space > 0.1) + return GetMiniCount2(space * 10); + else if (space > 0.01) + return GetMiniCount2(space * 100); + else if (space > 0.001) + return GetMiniCount2(space * 1000); + return 2; + } + //1-10涔嬮棿 + private static int GetMiniCount2(double space) + { + if (Math.Abs(space - 9) < 0.1) + return 2; + else if (Math.Abs(space - 8) < 0.1) + return 3; + else if (Math.Abs(space - 7.5) < 0.1) + return 2; + else if (Math.Abs(space - 7) < 0.1) + return 1; + else if (Math.Abs(space - 6) < 0.1) + return 2; + else if (Math.Abs(space - 5) < 0.1) + return 4; + else if (Math.Abs(space - 4) < 0.1) + return 3; + else if (Math.Abs(space - 3) < 0.1) + return 2; + else if (Math.Abs(space - 2) < 0.1) + return 1; + else if (Math.Abs(space - 1) < 0.1) + return 4; + + return 2; + } + + #endregion + } +} diff --git a/Yw.Coordinate/GlobalUsings.cs b/Yw.Coordinate/GlobalUsings.cs new file mode 100644 index 0000000..3e83e42 --- /dev/null +++ b/Yw.Coordinate/GlobalUsings.cs @@ -0,0 +1,7 @@ +锘� +global using MathNet.Numerics; +global using System.Runtime.Serialization; +global using System.ComponentModel.DataAnnotations; +global using System.ComponentModel; +global using System.Text; +global using Yw.Coordinate; \ No newline at end of file diff --git a/Yw.Coordinate/IGetLxpCoordinate.cs b/Yw.Coordinate/IGetLxpCoordinate.cs new file mode 100644 index 0000000..9ea5eee --- /dev/null +++ b/Yw.Coordinate/IGetLxpCoordinate.cs @@ -0,0 +1,17 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Yw.Coordinate +{ + public interface IGetLxpCoordinate + { + Yw.Coordinate.LxpCoordinateParas GetCoordinateParas(); + } + + public interface ISetLxpCoordinate + { + void SetCoordinateParas(Yw.Coordinate.LxpCoordinateParas coord); + } +} diff --git a/Yw.Coordinate/IGetQhCoordinate.cs b/Yw.Coordinate/IGetQhCoordinate.cs new file mode 100644 index 0000000..20e7743 --- /dev/null +++ b/Yw.Coordinate/IGetQhCoordinate.cs @@ -0,0 +1,17 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Yw.Coordinate +{ + public interface IGetQhCoordinate + { + Yw.Coordinate.QhCoordinateParas GetCoordinateParas(); + } + + public interface ISetQhCoordinate + { + void SetCoordinateParas(Yw.Coordinate.QhCoordinateParas coord); + } +} diff --git a/Yw.Coordinate/LxpCoordinateParas.cs b/Yw.Coordinate/LxpCoordinateParas.cs new file mode 100644 index 0000000..f4c2531 --- /dev/null +++ b/Yw.Coordinate/LxpCoordinateParas.cs @@ -0,0 +1,383 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Data; +using System.Text; + +namespace Yw.Coordinate +{ + public class LxpCoordinateParas + { + public LxpCoordinateParas() { } + + public LxpCoordinateParas(string strChartCoord) + { + try + { + if (string.IsNullOrEmpty(strChartCoord)) + { + isNull = true; + return; + } + + string[] coords = strChartCoord.Split('|'); + if (coords.Count() < 6) + { + isNull = true; + return; + } + + // + string sbQ = coords[0]; + string[] coordParasQ = sbQ.Split(','); + //coordParasQ[0] =1 琛ㄧず鍧囧寑 榛樿灏辨槸鍧囧寑鐨� + //this.UnitQ = Convert.ToInt32(coordParasQ[1]); + this.GridNumberX = Convert.ToInt32(coordParasQ[2]); + this.CoordMinQ = Convert.ToDouble(coordParasQ[3]); + this.CoordSpaceQ = Convert.ToDouble(coordParasQ[4]); + + + // + string sbY = coords[1]; + string[] coordParasY = sbY.Split(','); + //coordParasQ[0] =1 琛ㄧず鍧囧寑:榛樿灏辨槸鍧囧寑鐨� + this.GridNumberY = Convert.ToInt32(coordParasY[1]); + + //H + string sbH = coords[2]; + string[] coordParasH = sbH.Split(','); + //this.UnitH = (UnitH)Convert.ToInt32(coordParasH[0]); + this.CoordMinH = Convert.ToDouble(coordParasH[1]) ; + this.CoordSpaceH = Convert.ToDouble(coordParasH[2]); + this.StartLineNoH = Convert.ToInt32(coordParasH[3]); + this.EndLineNoH = Convert.ToInt32(coordParasH[4]); + + //Eff + string sbE = coords[3]; + string[] coordParasE = sbE.Split(','); + // this.UnitE = (UnitE)Convert.ToInt32(coordParasE[0]); + this.CoordMinE = Convert.ToDouble(coordParasE[1]) ; + this.CoordSpaceE = Convert.ToDouble(coordParasE[2]); + this.StartLineNoE = Convert.ToInt32(coordParasE[3]); + this.EndLineNoE = Convert.ToInt32(coordParasE[4]); + if (this.CoordSpaceE < 0.01) + this.CoordSpaceE = 10; + if (this.EndLineNoE == 0) + this.EndLineNoE = 10; + + //Power + string sbP = coords[4]; + string[] coordParasP = sbP.Split(','); + // paras.UnitP = (UnitE)Convert.ToInt32(coordParasP[0]); + this.CoordMinP = Convert.ToDouble(coordParasP[1]) ; + this.CoordSpaceP = Convert.ToDouble(coordParasP[2]); + this.StartLineNoP = Convert.ToInt32(coordParasP[3]); + this.EndLineNoP = Convert.ToInt32(coordParasP[4]); + if (this.CoordSpaceP < 0.001) + this.CoordSpaceP = 10; + if (this.EndLineNoP == 0) + this.EndLineNoP = 5; + + //QNPSH + string sbNPSH = coords[5]; + string[] coordParasNPSH = sbNPSH.Split(','); + // this.UnitNPSH = (UnitH)Convert.ToInt32(coordParasNPSH[0]); + this.CoordMinNPSH = Convert.ToDouble(coordParasNPSH[1]); + this.CoordSpaceNPSH = Convert.ToDouble(coordParasNPSH[2]); + this.StartLineNoNPSH = Convert.ToInt32(coordParasNPSH[3]); + this.EndLineNoNPSH = Convert.ToInt32(coordParasNPSH[4]); + if (this.CoordSpaceNPSH < 0.1) + this.CoordSpaceNPSH = 1; + if (this.EndLineNoNPSH == 0) + this.EndLineNoNPSH = 5; + + if (coords.Count() > 6) + {//澶т簬6 + string sbPanel = coords[6]; + string[] coordParasPanel = sbPanel.Split(','); + this.DispStyle = Convert.ToInt32(coordParasPanel[0]); + var num1 = Convert.ToInt32(coordParasPanel[1]); + if (num1 > 0)//涓嶈兘鏄�0 涓轰簡鍏煎鑰佹暟鎹�, 鑰佺殑鏁版嵁閲岄潰鏄�0 + this.DislocationNumUp = num1; + + var num2 = Convert.ToInt32(coordParasPanel[2]); + if (num2 > 0) + this.DislocationNumDown = num2; + } + } + catch (Exception) + { + isNull = true; + return; + } + } + + public LxpCoordinateParas(LxpCoordinateParas rhs) + { + if (rhs == null) + { + return; + } + + + this.UnitQ = rhs.UnitQ; + this.GridNumberX = rhs.GridNumberX; + this.CoordMinQ = rhs.CoordMinQ; + this.CoordSpaceQ = rhs.CoordSpaceQ; + + // + this.GridNumberY = rhs.GridNumberY; + + //H + this.UnitH = rhs.UnitH; + this.CoordMinH = rhs.CoordMinH; + this.CoordSpaceH = rhs.CoordSpaceH; + this.StartLineNoH = rhs.StartLineNoH; + this.EndLineNoH = rhs.EndLineNoH; + + //Eff + this.CoordMinE = rhs.CoordMinE; + this.CoordSpaceE = rhs.CoordSpaceE; + this.StartLineNoE = rhs.StartLineNoE; + this.EndLineNoE = rhs.EndLineNoE; + + + //Power + this.CoordMinP = rhs.CoordMinP; + this.CoordSpaceP = rhs.CoordSpaceP; + this.StartLineNoP = rhs.StartLineNoP; + this.EndLineNoP = rhs.EndLineNoP; + + + //QNPSH + this.CoordMinNPSH = rhs.CoordMinNPSH; + this.CoordSpaceNPSH = rhs.CoordSpaceNPSH; + this.StartLineNoNPSH = rhs.StartLineNoNPSH; + this.EndLineNoNPSH = rhs.EndLineNoNPSH; + + this.DispStyle = rhs.DispStyle; + this.DislocationNumUp = rhs.DislocationNumUp; + this.DislocationNumDown = rhs.DislocationNumDown; + } + + + //寰楀埌绌虹櫧鐨勫潗鏍囧�� + public static LxpCoordinateParas GetBlankCoordinate() + { + LxpCoordinateParas para = new LxpCoordinateParas(); + para.GridNumberX = 30; + para.GridNumberY = 16; + + //鏄剧ず鐨勫潗鏍囩嚎鍙� + para.StartLineNoH = 10; + para.EndLineNoH = 15; + + para.StartLineNoE = 0; + para.EndLineNoE = 10; + + para.StartLineNoP = 2; + para.EndLineNoP = 9; + + //鍧愭爣鏈�灏忓�煎拰闂撮殧 + para.CoordMinQ = 0; para.CoordSpaceQ = 1000; + para.CoordMinH = 10; para.CoordSpaceH = 100; + para.CoordMinE = 0; para.CoordSpaceE = 100; + para.CoordMinP = 10; para.CoordSpaceP = 100; + + return para; + } + + + //鍧愭爣闂撮殧鏁�,鍧愭爣绾夸細姣斿潗鏍囬棿闅旀暟澶氫竴 + public int GridNumberX = 30;//X鍧愭爣 + public int GridNumberY = 16;//Y鍧愭爣 + + //鏄剧ず鐨勫潗鏍囩嚎鍙� + public int StartLineNoH; + public int EndLineNoH; + + public int StartLineNoE; + public int EndLineNoE; + + public int StartLineNoP; + public int EndLineNoP; + + public int StartLineNoNPSH; + public int EndLineNoNPSH; + + //闈㈡澘鏄剧ず璁剧疆 + public int DispStyle = 0;//鏄剧ず椋庢牸 0 璺熼殢绯荤粺: 浠ュ悗鎷撳睍 + public int DislocationNumUp = 2;//鎵▼鏁堢巼鍒诲害 閿欎綅鏁� (QH鍜孮E鍧愭爣鐨勯敊浣�) 灏辨槸QH涓嬮潰鐨勭┖鏍兼暟 + public int DislocationNumDown = 1;//姘旇殌鍔熺巼鍒诲害 閿欎綅鏁� + + + //鍧愭爣鏈�灏忓�煎拰闂撮殧 + public double CoordMinQ, CoordSpaceQ; + public double CoordMinH, CoordSpaceH; + public double CoordMinE, CoordSpaceE; + public double CoordMinP, CoordSpaceP; + public double CoordMinNPSH, CoordSpaceNPSH; + + // + public double DispMaxQ() + { + return this.CoordMinQ + this.GridNumberX * this.CoordSpaceQ; + } + + public double DispMinH() + { + return this.CoordMinH + this.StartLineNoH * this.CoordSpaceH; + } + public double DispMaxH() + { + return this.CoordMinH + this.EndLineNoH * this.CoordSpaceH; + } + public double DispMinE() + { + return this.CoordMinE + this.StartLineNoE * this.CoordSpaceE; + } + public double DispMaxE() + { + return this.CoordMinE + this.EndLineNoE * this.CoordSpaceE; + } + public double DispMinP() + { + return this.CoordMinP + this.StartLineNoP * this.CoordSpaceP; + } + public double DispMaxP() + { + return this.CoordMinP + this.EndLineNoP * this.CoordSpaceP; + } + public double DispMinNPSH() + { + return this.CoordMinNPSH + this.StartLineNoNPSH * this.CoordSpaceNPSH; + } + public double DispMaxNPSH() + { + return this.CoordMinNPSH + this.EndLineNoNPSH * this.CoordSpaceNPSH; + } + // + public int? UnitQ + { + get { return _unitQ; } + set + { + _unitQ = value; + } + } + private int? _unitQ = null; + + // + public int? UnitH + { + get { return _unitH; } + set + { + _unitH = value; + } + } + private int? _unitH = null; + + // + public int? UnitP { get { return _unitP; } set { _unitP = value; } } + private int? _unitP = null; + + + public Object Clone() //瀵瑰鎻愪緵涓�涓垱寤鸿嚜韬殑娴呰〃鍓湰鐨勮兘鍔� + { + return this.MemberwiseClone(); + } + + //鍧愭爣鍒诲害鐨勬渶灏忓�� + public double TitleMinH { get { return CoordMinH + StartLineNoH * CoordSpaceH; } } + + // + protected bool isNull = false; + public bool IsNull + { + get { return isNull; } + } + + public static LxpCoordinateParas ToParameter(string strChartCoord) + { + try + { + var paras = new LxpCoordinateParas(strChartCoord); + if (paras.isNull) + return null; + else + return paras; + } + catch (Exception) + { + return null; + } + } + + public string ToDsString() + { + return ToDsString(this); + } + + public static string ToDsString(LxpCoordinateParas paras) + { + if (paras == null) + return "";//涓轰簡ACCESS鍙兘鐢�"" + + StringBuilder sbQ = new StringBuilder(); + sbQ.Append("1,");//1锛氳〃绀哄潎鍖� + sbQ.Append(paras.UnitQ==null?"": paras.UnitQ.ToString()); sbQ.Append(","); + sbQ.Append(paras.GridNumberX); sbQ.Append(","); + sbQ.Append(paras.CoordMinQ); sbQ.Append(","); + sbQ.Append(paras.CoordSpaceQ); + + // + StringBuilder sbY = new StringBuilder(); + sbY.Append("1,");//1锛氳〃绀哄潎鍖� + sbY.Append(paras.GridNumberY); + + // + StringBuilder sbH = new StringBuilder(); + sbH.Append(paras.UnitH == null ? "" : paras.UnitH.ToString()); sbH.Append(",");//瑕佷繚鐣欏皬鏁�, 鍥犱负鍗曚綅鍘熷洜 + sbH.Append(paras.CoordMinH); sbH.Append(","); + sbH.Append(paras.CoordSpaceH); sbH.Append(","); + sbH.Append(paras.StartLineNoH); sbH.Append(","); + sbH.Append(paras.EndLineNoH); + + StringBuilder sbE = new StringBuilder(); + sbE.Append("0,");//鏆傛椂娌℃湁鍗曚綅 + + sbE.Append(paras.CoordMinE); sbE.Append(","); + sbE.Append(paras.CoordSpaceE); sbE.Append(","); + sbE.Append(paras.StartLineNoE); sbE.Append(","); + sbE.Append(paras.EndLineNoE); + + StringBuilder sbP = new StringBuilder(); + sbP.Append(paras.UnitP == null ? "" : paras.UnitP.ToString()); sbP.Append(","); + sbP.Append(paras.CoordMinP); sbP.Append(","); + sbP.Append(paras.CoordSpaceP); sbP.Append(","); + sbP.Append(paras.StartLineNoP); sbP.Append(","); + sbP.Append(paras.EndLineNoP); + + StringBuilder sbNPSH = new StringBuilder(); + sbNPSH.Append(",");//鏆傛椂娌℃湁鍗曚綅 + sbNPSH.Append(paras.CoordMinNPSH); sbNPSH.Append(","); + sbNPSH.Append(paras.CoordSpaceNPSH); sbNPSH.Append(","); + sbNPSH.Append(paras.StartLineNoNPSH); sbNPSH.Append(","); + sbNPSH.Append(paras.EndLineNoNPSH); + + StringBuilder sbPanel = new StringBuilder(); + sbPanel.Append(paras.DispStyle); sbPanel.Append(","); + sbPanel.Append(paras.DislocationNumUp); sbPanel.Append(","); + sbPanel.Append(paras.DislocationNumDown); + + string strChartCoord = string.Format("{0}|{1}|{2}|{3}|{4}|{5}|{6}", + sbQ.ToString(), sbY.ToString(), sbH.ToString(), sbE.ToString(), sbP.ToString(), sbNPSH.ToString(), + sbPanel.ToString()); + + return strChartCoord; + } + + + } +} diff --git a/Yw.Coordinate/LxpCoordinateParasConver.cs b/Yw.Coordinate/LxpCoordinateParasConver.cs new file mode 100644 index 0000000..c0e8e61 --- /dev/null +++ b/Yw.Coordinate/LxpCoordinateParasConver.cs @@ -0,0 +1,21 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Yw.Coordinate; + +namespace Yw.Coordinate +{ + // 绂诲績娉� + public class LxpCoordinateParasConver + { + public static string ToDsString(LxpCoordinateParas paras) + { + return LxpCoordinateParas.ToDsString(paras); + } + public static LxpCoordinateParas ToParameter(string strChartCoord) + { + return LxpCoordinateParas.ToParameter(strChartCoord); + } + } +} diff --git a/Yw.Coordinate/Properties/PublishProfiles/FolderProfile.pubxml b/Yw.Coordinate/Properties/PublishProfiles/FolderProfile.pubxml new file mode 100644 index 0000000..639934f --- /dev/null +++ b/Yw.Coordinate/Properties/PublishProfiles/FolderProfile.pubxml @@ -0,0 +1,12 @@ +锘�<?xml version="1.0" encoding="utf-8"?> +<!-- +https://go.microsoft.com/fwlink/?LinkID=208121. +--> +<Project> + <PropertyGroup> + <Configuration>Release</Configuration> + <Platform>Any CPU</Platform> + <PublishDir>bin\Release\net6.0\publish\</PublishDir> + <PublishProtocol>FileSystem</PublishProtocol> + </PropertyGroup> +</Project> \ No newline at end of file diff --git a/Yw.Coordinate/Properties/PublishProfiles/FolderProfile.pubxml.user b/Yw.Coordinate/Properties/PublishProfiles/FolderProfile.pubxml.user new file mode 100644 index 0000000..e98e258 --- /dev/null +++ b/Yw.Coordinate/Properties/PublishProfiles/FolderProfile.pubxml.user @@ -0,0 +1,9 @@ +锘�<?xml version="1.0" encoding="utf-8"?> +<!-- +https://go.microsoft.com/fwlink/?LinkID=208121. +--> +<Project> + <PropertyGroup> + <History>True|2023-11-24T04:41:35.1109248Z;True|2023-11-07T10:59:03.8484346+08:00;True|2023-09-22T13:16:35.5213053+08:00;True|2023-09-19T13:47:08.6616971+08:00;True|2023-09-19T13:42:42.1690038+08:00;True|2023-09-18T15:12:24.4129783+08:00;False|2023-09-18T15:11:19.1798407+08:00;True|2023-09-01T13:20:20.4261550+08:00;True|2023-09-01T11:08:43.5292206+08:00;True|2023-08-29T16:21:32.3346453+08:00;</History> + </PropertyGroup> +</Project> \ No newline at end of file diff --git a/Yw.Coordinate/QhCoordinateParas.cs b/Yw.Coordinate/QhCoordinateParas.cs new file mode 100644 index 0000000..bb34075 --- /dev/null +++ b/Yw.Coordinate/QhCoordinateParas.cs @@ -0,0 +1,224 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Yw.Coordinate +{ + public class QhCoordinateParas: ICloneable + { + public QhCoordinateParas( ) + { + } + public QhCoordinateParas(ZlpCoordinateParas rhs) + { + this.IsLogQ = rhs.IsLogQ; + this.GridValueQ = rhs.GridValueQ; + this.UnitQ = rhs.UnitQ; + + this.IsLogH = rhs.IsLogH; + this.GridValueH = rhs.GridValueH; + this.UnitH = rhs.UnitH; + } + public QhCoordinateParas(QhCoordinateParas rhs) + { + this.IsLogQ = rhs.IsLogQ; + this.GridValueQ = rhs.GridValueQ; + this.UnitQ = rhs.UnitQ; + + this.IsLogH = rhs.IsLogH; + this.GridValueH = rhs.GridValueH; + this.UnitH = rhs.UnitH; + } + public QhCoordinateParas(string strChartCoord) + { + if (string.IsNullOrEmpty(strChartCoord)) + { + isNull = true; + return; + } + + string[] coords = strChartCoord.Split('|'); + if (coords.Count() != 2) + { + isNull = true; + return; + } + + + this.GridValueQ = new List<double>(); + string sbQ = coords[0]; + string[] coordParasQ = sbQ.Split(','); + //this.UnitQ = (UnitQ)Convert.ToInt32(coordParasQ[0]); + this.IsLogQ = Convert.ToBoolean(coordParasQ[1]); + + for (int i = 2; i < coordParasQ.Count(); i++) + this.GridValueQ.Add(Convert.ToDouble(coordParasQ[i])); + + this.GridValueH = new List<double>(); + string sbH = coords[1]; + string[] coordParasH = sbH.Split(','); + //this.UnitH = (UnitH)Convert.ToInt32(coordParasH[0]); + this.IsLogH = Convert.ToBoolean(coordParasH[1]); + for (int i = 2; i < coordParasH.Count(); i++) + this.GridValueH.Add(Convert.ToDouble(coordParasH[i])); + } + + private bool _isLogQ = false;//榛樿涓嶆槸瀵规暟鍧愭爣 + public bool IsLogQ + { + get { return _isLogQ; } + set + { + _isLogQ = value; + } + } + + public List<double> GridValueQ = null; + private int? _unitQ = null; + public int? UnitQ + { + get { return _unitQ; } + set + { + _unitQ = value; + } + } + + + public int? UnitH + { + get { return _unitH; } + set + { + _unitH = value; + } + } + private int? _unitH = null; + public List<double> GridValueH = null; + private bool _isLogH = false;//榛樿涓嶆槸瀵规暟鍧愭爣 + public bool IsLogH + { + get { return _isLogH; } + set + { + _isLogH = value; + } + } + + + protected bool isNull = false; + public bool IsNull + { + get { return isNull; } + } + + + public double MinH + { + get + { + if (GridValueH == null || GridValueH.Count == 0) + return 0; + return GridValueH.First(); + } + } + public double MaxH + { + get + { + if (GridValueH == null || GridValueH.Count == 0) + return 0; + return GridValueH.Last(); + } + } + + + public double MinQ + { + get + { + if (GridValueQ == null || GridValueQ.Count == 0) + return 0; + return GridValueQ.First(); + } + } + public double MaxQ + { + get + { + if (GridValueQ == null || GridValueQ.Count == 0) + return 0; + return GridValueQ.Last(); + } + } + + + + + + + + + + + + + #region Clone + public QhCoordinateParas Clone() //瀵瑰鎻愪緵涓�涓垱寤鸿嚜韬殑娴呰〃鍓湰鐨勮兘鍔� + { + return new QhCoordinateParas(this); + } + object ICloneable.Clone() + { + return this.Clone(); + } + + #endregion + + public string ToDsString() + { + return ToDsString(this); + } + public static string ToDsString(QhCoordinateParas paras) + { + if (paras == null) + return "";//涓轰簡ACCESS鍙兘鐢�"" + if (paras.GridValueQ == null || paras.GridValueQ.Count < 3) + return ""; + if (paras.GridValueH == null || paras.GridValueH.Count < 3) + return ""; + + StringBuilder sbQ = new StringBuilder(); + sbQ.Append(paras.UnitQ == null ? "" : paras.UnitQ.ToString());sbQ.Append(","); + sbQ.Append(paras.IsLogQ); sbQ.Append(","); + sbQ.Append(string.Join(",", paras.GridValueQ)); + + // + StringBuilder sbH = new StringBuilder(); + sbH.Append(paras.UnitH == null ? "" : paras.UnitH.ToString()); sbH.Append(","); + sbQ.Append(paras.IsLogH); sbQ.Append(","); + sbH.Append(string.Join(",", paras.GridValueH)); + + string strChartCoord = string.Format("{0}|{1}", sbQ.ToString(), sbH.ToString()); + + return strChartCoord; + } + public static QhCoordinateParas ToParameter(string strChartCoord) + { + try + { + var paras = new QhCoordinateParas(strChartCoord); + if (paras.isNull) + return null; + else + return paras; + } + catch (Exception) + { + return null; + } + } + + } +} diff --git a/Yw.Coordinate/Yw.Coordinate.csproj b/Yw.Coordinate/Yw.Coordinate.csproj new file mode 100644 index 0000000..d3d470a --- /dev/null +++ b/Yw.Coordinate/Yw.Coordinate.csproj @@ -0,0 +1,34 @@ +<Project Sdk="Microsoft.NET.Sdk"> + + <PropertyGroup> + <TargetFramework>net6.0</TargetFramework> + <ImplicitUsings>enable</ImplicitUsings> + <Nullable>disable</Nullable> + <AssemblyName>$(MSBuildProjectName)</AssemblyName> + <RootNamespace>$(MSBuildProjectName.Replace(" ", "_"))</RootNamespace> + <GenerateDocumentationFile>True</GenerateDocumentationFile> + <ProduceReferenceAssembly>True</ProduceReferenceAssembly> + <Version>1.0.1</Version> + </PropertyGroup> + + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> + <NoWarn>1701;1702;1591;CS8632</NoWarn> + </PropertyGroup> + + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'"> + <NoWarn>1701;1702;1591;CS8632</NoWarn> + </PropertyGroup> + + <ItemGroup> + <Compile Remove="AxisXyCalcer.cs" /> + </ItemGroup> + + <ItemGroup> + <PackageReference Include="Yw.Calculation.Core" Version="1.0.3" /> + <PackageReference Include="Yw.MathNet.Core" Version="1.0.0" /> + </ItemGroup> + + <ItemGroup> + <ProjectReference Include="..\Yw.CurveBase.Core\Yw.CurveBase.Core.csproj" /> + </ItemGroup> +</Project> diff --git a/Yw.Coordinate/ZlpCoordinateParas.cs b/Yw.Coordinate/ZlpCoordinateParas.cs new file mode 100644 index 0000000..ace2347 --- /dev/null +++ b/Yw.Coordinate/ZlpCoordinateParas.cs @@ -0,0 +1,214 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Yw.Coordinate +{ + public class ZlpCoordinateParas : ICloneable + { + public ZlpCoordinateParas() + { + } + public ZlpCoordinateParas(ZlpCoordinateParas rhs) + { + this.IsLogQ = rhs.IsLogQ; + this.GridValueQ = rhs.GridValueQ; + this.UnitQ = rhs.UnitQ; + + this.IsLogH = rhs.IsLogH; + this.GridValueH = rhs.GridValueH; + this.UnitH = rhs.UnitH; + } + public ZlpCoordinateParas(string strChartCoord) + { + if (string.IsNullOrEmpty(strChartCoord)) + { + isNull = true; + return; + } + + string[] coords = strChartCoord.Split('|'); + if (coords.Count() != 2) + { + isNull = true; + return; + } + + + this.GridValueQ = new List<double>(); + string sbQ = coords[0]; + string[] coordParasQ = sbQ.Split(','); + //this.UnitQ = (UnitQ)Convert.ToInt32(coordParasQ[0]); + this.IsLogQ = Convert.ToBoolean(coordParasQ[1]); + + for (int i = 2; i < coordParasQ.Count(); i++) + this.GridValueQ.Add(Convert.ToDouble(coordParasQ[i])); + + this.GridValueH = new List<double>(); + string sbH = coords[1]; + string[] coordParasH = sbH.Split(','); + //this.UnitH = (UnitH)Convert.ToInt32(coordParasH[0]); + this.IsLogH = Convert.ToBoolean(coordParasH[1]); + for (int i = 2; i < coordParasH.Count(); i++) + this.GridValueH.Add(Convert.ToDouble(coordParasH[i])); + } + + private bool _isLogQ = false;//榛樿涓嶆槸瀵规暟鍧愭爣 + public bool IsLogQ + { + get { return _isLogQ; } + set + { + _isLogQ = value; + } + } + + public List<double> GridValueQ = null; + private int? _unitQ = null; + public int? UnitQ + { + get { return _unitQ; } + set + { + _unitQ = value; + } + } + + + public int? UnitH + { + get { return _unitH; } + set + { + _unitH = value; + } + } + private int? _unitH = null; + public List<double> GridValueH = null; + private bool _isLogH = false;//榛樿涓嶆槸瀵规暟鍧愭爣 + public bool IsLogH + { + get { return _isLogH; } + set + { + _isLogH = value; + } + } + + + protected bool isNull = false; + public bool IsNull + { + get { return isNull; } + } + + + public double MinH + { + get + { + if (GridValueH == null || GridValueH.Count == 0) + return 0; + return GridValueH.First(); + } + } + public double MaxH + { + get + { + if (GridValueH == null || GridValueH.Count == 0) + return 0; + return GridValueH.Last(); + } + } + + + public double MinQ + { + get + { + if (GridValueQ == null || GridValueQ.Count == 0) + return 0; + return GridValueQ.First(); + } + } + public double MaxQ + { + get + { + if (GridValueQ == null || GridValueQ.Count == 0) + return 0; + return GridValueQ.Last(); + } + } + + + + + + + + + + + + + #region Clone + public ZlpCoordinateParas Clone() //瀵瑰鎻愪緵涓�涓垱寤鸿嚜韬殑娴呰〃鍓湰鐨勮兘鍔� + { + return new ZlpCoordinateParas(this); + } + object ICloneable.Clone() + { + return this.Clone(); + } + + #endregion + + public string ToDsString() + { + return ToDsString(this); + } + public static string ToDsString(ZlpCoordinateParas paras) + { + if (paras == null) + return "";//涓轰簡ACCESS鍙兘鐢�"" + if (paras.GridValueQ == null || paras.GridValueQ.Count < 3) + return ""; + if (paras.GridValueH == null || paras.GridValueH.Count < 3) + return ""; + + StringBuilder sbQ = new StringBuilder(); + sbQ.Append(paras.UnitQ == null ? "" : paras.UnitQ.ToString()); sbQ.Append(","); + sbQ.Append(paras.IsLogQ); sbQ.Append(","); + sbQ.Append(string.Join(",", paras.GridValueQ)); + + // + StringBuilder sbH = new StringBuilder(); + sbH.Append(paras.UnitH == null ? "" : paras.UnitH.ToString()); sbH.Append(","); + sbQ.Append(paras.IsLogH); sbQ.Append(","); + sbH.Append(string.Join(",", paras.GridValueH)); + + string strChartCoord = string.Format("{0}|{1}", sbQ.ToString(), sbH.ToString()); + + return strChartCoord; + } + public static ZlpCoordinateParas ToParameter(string strChartCoord) + { + try + { + var paras = new ZlpCoordinateParas(strChartCoord); + if (paras.isNull) + return null; + else + return paras; + } + catch (Exception) + { + return null; + } + } + + } +} -- Gitblit v1.9.3