internal void SetCurrentNode(PowerThreadNode toNode) { // if (IsContained(toNode)) { CurrentNode = toNode; } }
public Transmission(PowerThreadNode from, PowerThreadNode to) { this.FromNode = from; ConditionBranches = new List <TransmissionConditionBranch>() { new TransmissionConditionBranch { Condition = TransmissionCondition.Default, ToNode = to } }; }
private PowerThreadNode GetNextNode(PowerThreadContext context, PowerThreadNode fromNode) { var transmission = Transmissions.FirstOrDefault(p => p.FromNode.ObjectId == fromNode.ObjectId); if (transmission == null) { return(PowerThreadDefaultNodes.DefaultEndNode); } foreach (var item in transmission.ConditionBranches) { if (item.Condition.IsSatisified(context)) { return(item.ToNode); } } // return(PowerThreadDefaultNodes.MissFoundNode); }
public void Next(PowerThreadContext context, PowerThreadNode fromNode) { if (context.IsCurrentNode(fromNode) == false) { throw new InvalidThreadActionException("Not actived thread node!"); } if (fromNode.Equals(PowerThreadDefaultNodes.DefaultEndNode)) { throw new InvalidTransmissionSinceThreadAlreadyEnd(); } var toNode = GetNextNode(context, fromNode); if (toNode != null) { context.PowerThread.SetCurrentNode(toNode); if (!IsEndNode(toNode)) { toNode.LoadNode(); } if (toNode.IsEnd) { context.PowerThread.SetState(PowerThreadState.End); } else if (IsUnfound(toNode)) { context.PowerThread.SetState(PowerThreadState.ErrorMissFoundNode); } else { context.PowerThread.SetState(PowerThreadState.Processing); } } else { // 如果找不到下一个节点, 也认为其结束。 context.PowerThread.SetState(PowerThreadState.End); } }
private bool IsContained(PowerThreadNode node) { bool result = this.Nodes.Any(p => p.ObjectId == node.ObjectId); return(result); }
public void TerminateThreadAtNode(PowerThreadNode fromNode) { StateMachine.TerminateThread(Context, fromNode); }
public void GoNextNode(PowerThreadNode fromNode) { // todo StateMachine.Next(Context, fromNode); }
public void TerminateThread(PowerThreadContext context, PowerThreadNode fromNode) { context.PowerThread.SetState(PowerThreadState.Terminated); }
private bool IsUnfound(PowerThreadNode toNode) { return(toNode.Name == "[UnfoundNode]"); }
private bool IsEndNode(PowerThreadNode toNode) { return(toNode.Equals(PowerThreadDefaultNodes.DefaultEndNode)); }
internal bool IsCurrentNode(PowerThreadNode fromNode) { return(fromNode.ObjectId == PowerThread.CurrentNode.ObjectId); }