| | |
| | | using System.Runtime.InteropServices; |
| | | using Hydro.HydraulicOptimizer; |
| | | using Hydro.Core; |
| | | using System.Xml.Linq; |
| | | |
| | | namespace Hydro.MapView |
| | | { |
| | |
| | | { |
| | | bool use_old = false; |
| | | public string Name; |
| | | private LinkViewModelList _links=new LinkViewModelList(); |
| | | public LinkViewModelList Links { get { return _links; } set { base.Links= _links = value; } } |
| | | private LinkViewModelList _links = new LinkViewModelList(); |
| | | public LinkViewModelList Links { get { return _links; } set { base.Links = _links = value; } } |
| | | |
| | | private NodeViewModelList _nodes = new NodeViewModelList(); |
| | | public NodeViewModelList Nodes { get { return _nodes; }set { base.Nodes = _nodes = value; } } |
| | | public NodeViewModelList Nodes { get { return _nodes; } set { base.Nodes = _nodes = value; } } |
| | | |
| | | public NodeViewModel StartPoint { get; set; } |
| | | |
| | |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | public string WriteToJson() |
| | | { |
| | |
| | | EndPoint = network.EndPoint; |
| | | } |
| | | } |
| | | public List<IBaseViewModel> Add(MapViewNetWork net0, PointF3D offset = null, bool isCopy = false) |
| | | public List<IBaseViewModel> Add(MapViewNetWork net0, PointF3D offset = null, bool isCopy = false, NodeViewModel ConnectNode = null) |
| | | { |
| | | if (offset == null) |
| | | { |
| | |
| | | Hash_ID.Add(l.ID); |
| | | list.Add(l); |
| | | }); |
| | | if (ConnectNode != null) |
| | | { |
| | | list.Add(AddPipe(ConnectNode, net.StartPoint)); |
| | | } |
| | | //BuildRelation(); |
| | | return list; |
| | | } |
| | |
| | | List<BaseModel> objects = new List<BaseModel>(); |
| | | objects.AddRange(Nodes); |
| | | objects.AddRange(Links); |
| | | return objects.Select(o=>(IBaseViewModel)o).ToList(); |
| | | return objects.Select(o => (IBaseViewModel)o).ToList(); |
| | | } |
| | | } |
| | | public void Rename() |
| | |
| | | public void LoadRepeaters(int MaxLevel, dict<string, dynamic> param, Dictionary<TemplateType, bool> viewModel, bool ViewMode = true) |
| | | { |
| | | |
| | | |
| | | |
| | | repeaters.ForEach(r => |
| | | { |
| | | |
| | |
| | | Add(r); |
| | | r.Visible = false; |
| | | } |
| | | |
| | | |
| | | |
| | | }); |
| | | } |
| | |
| | | |
| | | // 定义 visited 字典记录已访问过的节点和待访问的节点队列 |
| | | Dictionary<NodeViewModel, bool> visited;//= new Dictionary<Node, bool>(); |
| | | private bool _isCalculated=false; |
| | | private bool _isCalculated = false; |
| | | |
| | | public void BFS(MapViewNetWork net, NodeViewModel startNode, Vector3 vector) |
| | | { |
| | |
| | | |
| | | public List<NodeViewModel> GetNode(string node) |
| | | { |
| | | return Nodes.FindAll(n => n.ID == node).Select(n=> (NodeViewModel)n).ToList(); |
| | | return Nodes.FindAll(n => n.ID == node).Select(n => (NodeViewModel)n).ToList(); |
| | | } |
| | | |
| | | public List<TimePoint> Calc(string inpPath, string configPath = null) |
| | |
| | | SetLinkFromWparam(this, list, "Velocity"); |
| | | SetLinkFromWparam(this, list, "Headloss"); |
| | | |
| | | Links.ForEach(l=> |
| | | Links.ForEach(l => |
| | | { |
| | | l.EN_HEADLOSS_MINOR = (float)Math.Round(l.MinorLoss * Math.Pow(l.EN_VELOCITY, 2) / 2 / 9.8, 4); |
| | | l.EN_HEADLOSS_LINE = l.EN_HEADLOSS - l.EN_HEADLOSS_MINOR; |
| | |
| | | calcParam.setVars = new List<SetVar>(); |
| | | reservoirs.ForEach(r => |
| | | { |
| | | calcParam.setVars.Add(new SetVar (r.ID,true,(int)EpanetEnum.NodeValueType.水池水位,(float)val.ObjFunctionValue)); |
| | | calcParam.setVars.Add(new SetVar(r.ID, true, (int)EpanetEnum.NodeValueType.水池水位, (float)val.ObjFunctionValue)); |
| | | }); |
| | | |
| | | wdnmoParam =wdo.CalcbyResult(calcParam, wdnmoParam); |
| | | wdnmoParam = wdo.CalcbyResult(calcParam, wdnmoParam); |
| | | var list = wdnmoParam.ResultPoints; |
| | | if (list == null) return list; |
| | | list.Sort((a, b) => string.Compare(a.Key, b.Key)); |
| | |
| | | |
| | | //构造一个List<LinkViewModel>类,能够实现List的所有功能 |
| | | [Serializable] |
| | | public class LinkViewModelList:List<LinkCalcModel> |
| | | public class LinkViewModelList : List<LinkCalcModel> |
| | | { |
| | | //List<LinkCalcModel> base; |
| | | Dictionary<string, LinkViewModel> dict;// |
| | |
| | | /// </summary> |
| | | public void UpdateDict() |
| | | { |
| | | this.dict= new Dictionary<string, LinkViewModel>(); |
| | | this.dict = new Dictionary<string, LinkViewModel>(); |
| | | base.ForEach(link => |
| | | { |
| | | if (!dict.ContainsKey(link.ID)) |
| | |
| | | /// </summary> |
| | | /// <param name="oldID"></param> |
| | | /// <param name="newID"></param> |
| | | public void ChangeID(string oldID,string newID) |
| | | public void ChangeID(string oldID, string newID) |
| | | { |
| | | if (dict.ContainsKey(oldID)) |
| | | { |
| | | dict[oldID].ID = newID; |
| | | dict.Add(newID, dict[oldID]); |
| | | dict.Remove(oldID); |
| | | dict.Remove(oldID); |
| | | } |
| | | } |
| | | /// <summary> |
| | |
| | | dict.Add(link.ID, link); |
| | | }); |
| | | } |
| | | |
| | | |
| | | public bool RemoveAt(int index) |
| | | { |
| | | if (index < 0 || index >= base.Count) return false; |
| | |
| | | { |
| | | if (dict.ContainsKey(ID)) |
| | | return dict[ID]; |
| | | else |
| | | else |
| | | return (LinkViewModel)base.Find(l => l.ID == ID); |
| | | } |
| | | } |
| | |
| | | { |
| | | //List<NodeCalcModel> base; |
| | | Dictionary<string, NodeCalcModel> dict;//=new Dictionary<string, NodeCalcModel>();// |
| | | public NodeViewModelList():base() |
| | | public NodeViewModelList() : base() |
| | | { |
| | | this.dict = new Dictionary<string, NodeCalcModel>(); |
| | | } |