CoolingWaterLoop.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text.RegularExpressions;
  5. using Autodesk.Revit.UI;
  6. using SAGA.DotNetUtils.Extend;
  7. using SAGA.GplotDrawData;
  8. using SAGA.GplotRelationComputerManage;
  9. using SAGA.Models;
  10. using SAGA.RevitUtils.Windows;
  11. namespace SAGA.GplotManage.UploadRelated {
  12. /// <summary>
  13. /// 空调冷却水
  14. /// </summary>
  15. class CoolingWaterLoop : Gplot {
  16. public override GraphTypeEnum GraphType => GraphTypeEnum.CoolingWaterLoop;
  17. public override Type DataType => typeof(LogicNode);
  18. protected override void DealUploadData() {
  19. //查找夏天冷却水
  20. string name = $"{CsSeasonType.Summer.GetDescription()}-{CsSystemType.CoolingWater.GetDescription()}";
  21. //取出冷站冷却水
  22. var dn = DrawDataServer.GetLogicNode()?.Nodes.FirstOrDefault(t => t.Name == name);
  23. if (dn != null)
  24. {
  25. DrawNode(dn);
  26. }
  27. }
  28. private void DrawNode(LogicNode ln1) {
  29. //避免移除数据对原始数据造成影响
  30. var ln = new LogicNode { Name = ln1.Name };
  31. ln1.Nodes.ForEach(ln.Nodes.Add);
  32. if (ln.Nodes.Count == 0) return;
  33. var node = ln.Nodes[0];
  34. var lastIds = new List<string>();
  35. for (int i = 0; i < ln.Nodes.Count; i++) {
  36. var currIds = new List<string>();
  37. //当前节点为子节点
  38. if (node.Nodes.Count == 0) {
  39. continue;
  40. }
  41. //当前节点的子节点也包含子节点
  42. if (node.Nodes.Any(t => t.Nodes.Count > 0)) {
  43. DrawNode(node);
  44. continue;
  45. }
  46. var m = node.Nodes.Count;
  47. var regStr = "地源热泵|供冷冷却水泵|供冷冷冻水泵|地埋管";
  48. var ids = node.Nodes.Select(t1 => {
  49. var elment = t1.Elements.FirstOrDefault(t => Regex.IsMatch(t.FamilyName ?? "", regStr));
  50. return elment != null ? elment.Id : "";
  51. }).ToList();
  52. if (node.RelationType == ChildrenRelationType.ParallelCon) {
  53. currIds.AddRange(ids);
  54. }
  55. else if (node.RelationType == ChildrenRelationType.SeriesCon) {
  56. //取出最后一个作为连接点
  57. currIds.Add(ids.LastOrDefault());
  58. //设备串联
  59. for (int j = 0; j < m - 1; j++) {
  60. Criterias.criterias.Add(GetReleateData(ids[j], ids[j + 1]));
  61. }
  62. }
  63. if (lastIds.Count > 0)
  64. {
  65. foreach (var lastId in lastIds)
  66. {
  67. foreach (var currId in currIds)
  68. {
  69. Criterias.criterias.Add(GetReleateData(lastId, currId));
  70. }
  71. }
  72. }
  73. lastIds.Clear();
  74. lastIds.AddRange(currIds);
  75. //移除当前元素,避免查找污染
  76. ln.Nodes.Remove(node);
  77. i--;
  78. node = ln.Nodes.FirstOrDefault(t => IsConnector(t, node));
  79. if (node == null) break;
  80. }
  81. }
  82. public bool IsConnector(LogicNode node1, LogicNode node2) {
  83. if (node1 == null || node2 == null) return false;
  84. if (node1 == node2) return false;
  85. return node1.RealNodes.Any(n => node2.RealNodes.
  86. Any(n1 => n.ToString() == n1.ToString()));
  87. }
  88. public override void Computer()
  89. {
  90. throw new NotImplementedException();
  91. }
  92. public override void Show(GplotShowType showType)
  93. {
  94. throw new NotImplementedException();
  95. }
  96. }
  97. /// <summary>
  98. /// 冷冻水管道平面
  99. /// </summary>
  100. public class ChillWaterLoop_V : Gplot
  101. {
  102. public override Type DataType => typeof(AcWater);
  103. public override GraphTypeEnum GraphType => GraphTypeEnum.ChillWaterLoop_V;
  104. public override void Computer()
  105. {
  106. ComputerPipes.Computer();
  107. }
  108. [CheckAndKeepGplotLaster]
  109. public override void Show(GplotShowType showType = GplotShowType.Default)
  110. {
  111. }
  112. protected override void DealUploadData()
  113. {
  114. }
  115. }
  116. }