From 15d15d24fbccb9b70a305b46b71453b2ab1a720e Mon Sep 17 00:00:00 2001 From: qinjie <qinjie@163.com> Date: 星期二, 19 十二月 2023 15:43:46 +0800 Subject: [PATCH] 提交代码 --- Hydro.Revit/Model/NetWorkOutViewModel.cs | 39 +++++++++++++ Hydro.Revit/Base/IBaseInterface.cs | 5 + Hydro.Core/Enum/ObjectEnum.cs | 8 ++ Hydro.Revit/Model/ValveViewModel.cs | 2 Hydro.Core/Common/CheckModel.cs | 6 ++ Hydro.Revit/Model/JunctionViewModel.cs | 6 + Hydro.Revit/Hydro.Revit2022.csproj | 1 Hydro.Revit/Model/WaterTankViewModel.cs | 2 Hydro.Revit/Model/PumpAdapterViewModel.cs | 2 Test/Program.cs | 4 Hydro.Revit/Model/PipeViewModel.cs | 2 Hydro.Revit/RevitNetWork.cs | 94 +++++++++++++++++++------------ Hydro.Revit/Model/NozzleViewModel.cs | 2 Hydro.Revit/Model/HydrantBoxViewModel.cs | 1 Hydro.Core/Node/NozzleModel.cs | 3 + Hydro.Revit/Model/WaterPumpViewModel.cs | 2 16 files changed, 139 insertions(+), 40 deletions(-) diff --git a/Hydro.Core/Common/CheckModel.cs b/Hydro.Core/Common/CheckModel.cs index ef97ae5..be2b579 100644 --- a/Hydro.Core/Common/CheckModel.cs +++ b/Hydro.Core/Common/CheckModel.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; +using static Hydro.Core.ObjectEnum; namespace Hydro.Core.Model { @@ -20,5 +21,10 @@ public class FailModel : BaseModel { public string FailReason { get; set; } + + public FailType Type { get; set; } + + public string ModelName { get; set; } } + } diff --git a/Hydro.Core/Enum/ObjectEnum.cs b/Hydro.Core/Enum/ObjectEnum.cs index 8dcff12..d0b75bd 100644 --- a/Hydro.Core/Enum/ObjectEnum.cs +++ b/Hydro.Core/Enum/ObjectEnum.cs @@ -28,5 +28,13 @@ 娴侀噺鍔熺巼鏇茬嚎 = 2, 娴侀噺鏁堢巼鏇茬嚎 = 3 } + + public enum FailType + { + 缂哄皯Node1鎴朜ode2杩炴帴灞炴�� = 1, + 鍠峰ご鍙兘杩炴帴绠¢亾 = 2, + 缂哄皯姘寸鎴栨按姹犲璞� = 3, + 绠′欢瀵硅薄杩炵浠跺璞� = 4 + } } } diff --git a/Hydro.Core/Node/NozzleModel.cs b/Hydro.Core/Node/NozzleModel.cs index 3d6827e..560f949 100644 --- a/Hydro.Core/Node/NozzleModel.cs +++ b/Hydro.Core/Node/NozzleModel.cs @@ -22,6 +22,9 @@ /// </summary> public string PatternID { get; set; } + public string Node1 { get; set; } + public string Node2 { get; set; } + public override string ToString() { if (string.IsNullOrEmpty(PatternID)) PatternID = ""; diff --git a/Hydro.Revit/Base/IBaseInterface.cs b/Hydro.Revit/Base/IBaseInterface.cs index 6c27341..084a8b8 100644 --- a/Hydro.Revit/Base/IBaseInterface.cs +++ b/Hydro.Revit/Base/IBaseInterface.cs @@ -18,5 +18,10 @@ /// </summary> string SystemType { get; set; } + /// <summary> + /// 妤煎眰 + /// </summary> + string Floor { get; set; } + } } diff --git a/Hydro.Revit/Hydro.Revit2022.csproj b/Hydro.Revit/Hydro.Revit2022.csproj index cd8cf5b..13fc9d5 100644 --- a/Hydro.Revit/Hydro.Revit2022.csproj +++ b/Hydro.Revit/Hydro.Revit2022.csproj @@ -44,6 +44,7 @@ <Compile Include="Base\IBaseInterface.cs" /> <Compile Include="Model\HydrantBoxViewModel.cs" /> <Compile Include="Model\JunctionViewModel.cs" /> + <Compile Include="Model\NetWorkOutViewModel.cs" /> <Compile Include="Model\NozzleViewModel.cs" /> <Compile Include="Model\PipeViewModel.cs" /> <Compile Include="Model\PositionModel.cs" /> diff --git a/Hydro.Revit/Model/HydrantBoxViewModel.cs b/Hydro.Revit/Model/HydrantBoxViewModel.cs index 744dd7a..52227cb 100644 --- a/Hydro.Revit/Model/HydrantBoxViewModel.cs +++ b/Hydro.Revit/Model/HydrantBoxViewModel.cs @@ -17,5 +17,6 @@ { public string PositionJson { get; set; } public string SystemType { get; set; } + public string Floor { get; set; } } } diff --git a/Hydro.Revit/Model/JunctionViewModel.cs b/Hydro.Revit/Model/JunctionViewModel.cs index c972c45..b36992c 100644 --- a/Hydro.Revit/Model/JunctionViewModel.cs +++ b/Hydro.Revit/Model/JunctionViewModel.cs @@ -9,11 +9,15 @@ namespace Hydro.Revit.Model { - public class JunctionViewModel:JunctionModel,IBaseInterface + public class JunctionViewModel : JunctionModel, IBaseInterface { public string PositionJson { get; set; } public string SystemType { get; set; } + public string Floor { get; set; } + public string Node1 { get; set; } + + public string Node2 { get; set; } public void Draw() { throw new NotImplementedException(); diff --git a/Hydro.Revit/Model/NetWorkOutViewModel.cs b/Hydro.Revit/Model/NetWorkOutViewModel.cs new file mode 100644 index 0000000..29a38fa --- /dev/null +++ b/Hydro.Revit/Model/NetWorkOutViewModel.cs @@ -0,0 +1,39 @@ +锘縰sing Hydro.Core.Model; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Hydro.Revit.Model +{ + public class NetWorkOutViewModel + { + public long BimFaceID { get; set; } + + public List<HydrantBoxViewModel> HydrantBoxes { get; set; } = new List<HydrantBoxViewModel>(); + + public List<JunctionViewModel> Junctions { get; set; } = new List<JunctionViewModel>(); + + public List<NozzleViewModel> Nozzles { get; set; } = new List<NozzleViewModel>(); + + public List<PipeViewModel> Pipes { get; set; } = new List<PipeViewModel>(); + + public List<PumpAdapterViewModel> PumpAdapters { get; set; } = new List<PumpAdapterViewModel>(); + + public List<ValveViewModel> Valves { get; set; } = new List<ValveViewModel>(); + + public List<WaterPumpViewModel> Pumps { get; set; } = new List<WaterPumpViewModel>(); + + public List<WaterTankViewModel> Tanks { get; set; } = new List<WaterTankViewModel>(); + + public List<ReservoisModel> Reservos { get; set; } = new List<ReservoisModel>(); + + public List<MeterModel> Meters { get; set; }= new List<MeterModel>(); + + public List<NodeCalcModel> Nodes { get; set; } = new List<NodeCalcModel>(); + public List<LinkCalcModel> Links { get; set; } = new List<LinkCalcModel>(); + } + + +} diff --git a/Hydro.Revit/Model/NozzleViewModel.cs b/Hydro.Revit/Model/NozzleViewModel.cs index b63850c..b032d9a 100644 --- a/Hydro.Revit/Model/NozzleViewModel.cs +++ b/Hydro.Revit/Model/NozzleViewModel.cs @@ -14,5 +14,7 @@ { public string PositionJson { get; set; } public string SystemType { get; set; } + + public string Floor { get; set; } } } diff --git a/Hydro.Revit/Model/PipeViewModel.cs b/Hydro.Revit/Model/PipeViewModel.cs index 08b4efb..9d34577 100644 --- a/Hydro.Revit/Model/PipeViewModel.cs +++ b/Hydro.Revit/Model/PipeViewModel.cs @@ -13,5 +13,7 @@ { public string PositionJson { get; set; } public string SystemType { get; set; } + + public string Floor { get; set; } } } diff --git a/Hydro.Revit/Model/PumpAdapterViewModel.cs b/Hydro.Revit/Model/PumpAdapterViewModel.cs index 576e147..8eab80c 100644 --- a/Hydro.Revit/Model/PumpAdapterViewModel.cs +++ b/Hydro.Revit/Model/PumpAdapterViewModel.cs @@ -14,5 +14,7 @@ { public string PositionJson { get; set; } public string SystemType { get; set; } + + public string Floor { get; set; } } } diff --git a/Hydro.Revit/Model/ValveViewModel.cs b/Hydro.Revit/Model/ValveViewModel.cs index 5aae6e5..3d285e2 100644 --- a/Hydro.Revit/Model/ValveViewModel.cs +++ b/Hydro.Revit/Model/ValveViewModel.cs @@ -12,5 +12,7 @@ { public string PositionJson { get; set; } public string SystemType { get; set; } + + public string Floor { get; set; } } } diff --git a/Hydro.Revit/Model/WaterPumpViewModel.cs b/Hydro.Revit/Model/WaterPumpViewModel.cs index c8c6925..9ff1662 100644 --- a/Hydro.Revit/Model/WaterPumpViewModel.cs +++ b/Hydro.Revit/Model/WaterPumpViewModel.cs @@ -12,5 +12,7 @@ { public string PositionJson { get; set; } public string SystemType { get; set; } + + public string Floor { get; set; } } } diff --git a/Hydro.Revit/Model/WaterTankViewModel.cs b/Hydro.Revit/Model/WaterTankViewModel.cs index 0d7e69d..b06e0c9 100644 --- a/Hydro.Revit/Model/WaterTankViewModel.cs +++ b/Hydro.Revit/Model/WaterTankViewModel.cs @@ -12,5 +12,7 @@ { public string PositionJson { get; set; } public string SystemType { get; set; } + + public string Floor { get; set; } } } diff --git a/Hydro.Revit/RevitNetWork.cs b/Hydro.Revit/RevitNetWork.cs index a7c6387..334c72d 100644 --- a/Hydro.Revit/RevitNetWork.cs +++ b/Hydro.Revit/RevitNetWork.cs @@ -11,59 +11,79 @@ { public class RevitNetWork : NetWork { - public void AddJunction(JunctionViewModel junction) + public void AddJunction(JunctionViewModel junction) { - CheckNodesExist(junction); - Nodes.Add(junction); + if (!CheckNodesExist(junction)) + Nodes.Add(junction); } - public void AddJunctions(List<JunctionViewModel> junctions) + public new List<PipeViewModel> Pipes + { + get + { + var js = Links.Where(d => d is PipeViewModel); + return js?.Select(d => d as PipeViewModel).ToList(); + } + } + + public new List<NozzleViewModel> Nozzles + { + get + { + var js = Nodes.Where(d => d is NozzleViewModel); + return js?.Select(d => d as NozzleViewModel).ToList(); + } + } + + public void AddJunctions(List<JunctionViewModel> junctions) { junctions.ForEach(junction => { AddJunction(junction); }); } - public void AddTank(WaterTankViewModel tank) + public void AddTank(WaterTankViewModel tank) { - CheckNodesExist(tank); - Nodes.Add(tank); + if (!CheckNodesExist(tank)) + Nodes.Add(tank); } - public void AddTanks(List<WaterTankViewModel> tanks) + public List<HydrantBoxViewModel> HydrantBoxes => Nodes.Where((NodeCalcModel d) => d is HydrantBoxViewModel)?.Select((NodeCalcModel d) => d as HydrantBoxViewModel).ToList(); + + public void AddTanks(List<WaterTankViewModel> tanks) { tanks.ForEach(tank => { AddTank(tank); }); - WaterTankViewModel kk=null; - Nodes.Select(n => (WaterTankViewModel)n).ToList().Sort(o => o.PositionJson); - WaterTankViewModels + // WaterTankViewModel kk=null; + // Nodes.Select(n => (WaterTankViewModel)n).ToList().Sort(o => o.PositionJson); + // WaterTankViewModels - ((WaterTankViewModel) Nodes[0]).PositionJson + //((WaterTankViewModel) Nodes[0]).PositionJson } - public void AddPipe(PipeViewModel pipe) + public void AddPipe(PipeViewModel pipe) { - CheckLinksExist(pipe); - Links.Add(pipe); + if (!CheckLinksExist(pipe)) + Links.Add(pipe); } - public void AddPipes(List<PipeViewModel> pipes) + public void AddPipes(List<PipeViewModel> pipes) { pipes.ForEach(pipe => { AddPipe(pipe); }); } - public void AddPump(WaterPumpViewModel pump) + public void AddPump(WaterPumpViewModel pump) { - CheckLinksExist(pump); - Links.Add(pump); + if (!CheckLinksExist(pump)) + Links.Add(pump); } - public void AddPumps(List<WaterPumpViewModel> pumps) + public void AddPumps(List<WaterPumpViewModel> pumps) { pumps.ForEach(pump => { AddPump(pump); }); } - public void AddValve(ValveViewModel valve) + public void AddValve(ValveViewModel valve) { - CheckLinksExist(valve); - Links.Add(valve); + if (!CheckLinksExist(valve)) + Links.Add(valve); } public void AddValves(List<ValveViewModel> valves) @@ -73,35 +93,35 @@ public void AddHydrantBox(HydrantBoxViewModel hydrantBox) { - CheckNodesExist(hydrantBox); - Nodes.Add(hydrantBox); + if (!CheckNodesExist(hydrantBox)) + Nodes.Add(hydrantBox); } - public void AddHydrantBoxs(List<HydrantBoxViewModel> hydrantBoxs) + public void AddHydrantBoxs(List<HydrantBoxViewModel> hydrantBoxs) { hydrantBoxs.ForEach(hydrantBox => { AddHydrantBox(hydrantBox); }); } - - public void AddNozzle(NozzleViewModel nozzle) + + public void AddNozzle(NozzleViewModel nozzle) { - CheckNodesExist(nozzle); - Nodes.Add(nozzle); + if (!CheckNodesExist(nozzle)) + Nodes.Add(nozzle); } - public void AddNozzles(List<NozzleViewModel> nozzles) + public void AddNozzles(List<NozzleViewModel> nozzles) { nozzles.ForEach(nozzle => { AddNozzle(nozzle); }); } - private void CheckNodesExist(NodeCalcModel node) + private bool CheckNodesExist(NodeCalcModel node) { - if (Nodes.Any(d => d.ID == node.ID)) - throw new Exception("宸插瓨鍦ㄩ噸澶嶇殑瀵硅薄"); + return Nodes.Any(d => d.ID == node.ID); + // throw new Exception("宸插瓨鍦ㄩ噸澶嶇殑瀵硅薄"); } - private void CheckLinksExist(LinkCalcModel link) + private bool CheckLinksExist(LinkCalcModel link) { - if (Links.Any(d => d.ID == link.ID)) - throw new Exception("宸插瓨鍦ㄩ噸澶嶇殑瀵硅薄"); + return Links.Any(d => d.ID == link.ID); + //throw new Exception("宸插瓨鍦ㄩ噸澶嶇殑瀵硅薄"); } } } diff --git a/Test/Program.cs b/Test/Program.cs index d8f56d8..ab5c58c 100644 --- a/Test/Program.cs +++ b/Test/Program.cs @@ -17,7 +17,7 @@ const string revitInpPath = "d:\\t2.inp"; static void Main(string[] args) { - Test4(); + Test3(); } static void Test1() @@ -138,7 +138,7 @@ static void Test3() { var nw = new NetWorkMapModel(); - var result = nw.Calc("d:\\revitinp.inp"); + var result = nw.Calc("d:\\xiaofang.inp"); Console.WriteLine(result); Console.ReadLine(); } -- Gitblit v1.9.3