public ActionPortIn GetActionInport(List <UInt32> used, UInt32 portId, UInt32 portInstanceId) { if (this.Count > 0) { foreach (ActionBranch a in this) { ActionPortIn ai = a.GetActionInport(used, portId, portInstanceId); if (ai != null) { return(ai); } } } return(null); }
public override ActionPortIn GetActionInport(List <UInt32> used, UInt32 portId, UInt32 portInstanceId) { ActionPortIn ai = base.GetActionInport(used, portId, portInstanceId); if (ai == null) { if (!used.Contains(BranchId)) { used.Add(BranchId); if (_list != null) { ai = _list.GetActionInport(used, portId, portInstanceId); } } } return(ai); }
/// <summary> /// create action components and make port links /// </summary> /// <param name="designer"></param> public override bool LoadToDesigner(List <UInt32> used, MethodDiagramViewer designer) { if (designer.LoadAction(this)) { if (_ifActions != null) { if (_ifActions.LoadToDesigner(used, designer)) { //make port link if (this.OutPortList[0].LinkedInPort == null) { LinkLineNode end = this.OutPortList[0].End; ActionPortIn pi = _ifActions.GetInPort(this.OutPortList[0].LinkedPortID, this.OutPortList[0].LinkedPortInstanceID); if (pi == null) { throw new MathException("Out port {0} is linked to [{1},{2}] of Branch {3}; but [{1},{2}] is not among the in-ports of the branch", this.OutPortList[0].PortID, this.OutPortList[0].LinkedPortID, this.OutPortList[0].LinkedPortInstanceID, _ifActions.BranchId); } LinkLineNode start = pi.Start; end.SetNext(start); start.SetPrevious(end); } } } if (_elseActions != null) { if (_elseActions.LoadToDesigner(used, designer)) { //make port link if (this.OutPortList[1].LinkedInPort == null) { LinkLineNode end = this.OutPortList[1].End; ActionPortIn pi = _elseActions.GetInPort(this.OutPortList[1].LinkedPortID, this.OutPortList[1].LinkedPortInstanceID); if (pi == null) { throw new MathException("Out port {0} is linked to [{1},{2}] of Branch {3}; but [{1},{2}] is not among the in-ports of the branch", this.OutPortList[1].PortID, this.OutPortList[1].LinkedPortID, this.OutPortList[1].LinkedPortInstanceID, _elseActions.BranchId); } LinkLineNode start = pi.Start; end.SetNext(start); start.SetPrevious(end); } } } return(true); } return(false); }
public override void LinkJumpBranches() { if (_jumpToId != 0) { if (_jumpToActionBranch == null) { throw new DesignerException("Cannot set portlink from {0} to {1}. Linked actions not set", this.BranchId, _jumpToId); } ActionPortOut po = this.OutPortList[0]; ActionPortIn pi = _jumpToActionBranch.GetInPort(po.LinkedPortID, po.LinkedPortInstanceID); //.InPortList[po.LinkedPortIndex]; if (pi == null) { throw new DesignerException("out-port {0} is linked to [{1},{2}] of the jump-to-branch {3}, but in-port [{1},{2}] is not among the in-port list of the branch", po.PortID, po.LinkedPortID, po.LinkedPortInstanceID, _jumpToActionBranch.BranchId); } LinkLineNode start = po.End; LinkLineNode end; LinkLineNodeOutPort pipo = pi.Start as LinkLineNodeOutPort; if (pipo != null) { if (pipo.LinkedPortID != pi.PortID || pipo.LinkedPortInstanceID != pi.PortInstanceID) { throw new DesignerException("Input [{0},{1}] is already linked to [{2},{3}], cannot link it to [{4},{5}]", pi.PortID, pi.PortInstanceID, pipo.PortID, pipo.PortInstanceID, po.PortID, po.PortInstanceID); } } else { end = pi.Start; if (end != start) { start.SetNext(end); end.SetPrevious(start); po.LinkedPortID = pi.PortID; pi.LinkedPortID = po.PortID; } else { //it is not an error, it is already linked } } } base.LinkJumpBranches(); }