public void Execute(ProcessNode currentNode, ProcessNode previousNode) { string endpoint = "tcp://127.0.0.1:5556"; // Create using (var context = new ZContext()) using (var requester = new ZSocket(context, ZSocketType.REQ)) { // Connect requester.Connect(endpoint); string requestText = "Do some work"; Console.WriteLine("Request {0}", requestText); // Send requester.Send(new ZFrame(requestText)); // Receive using (ZFrame reply = requester.ReceiveFrame()) { Console.WriteLine("Received: {0} ", reply.ReadString()); } currentNode.Done(); } }
/// <summary> /// 构建NodeInstance /// </summary> /// <param name="bizProcessID"></param> /// <param name="node"></param> /// <param name="userID"></param> /// <param name="cUserID"></param> /// <param name="userName"></param> /// <param name="userCode"></param> /// <returns></returns> public static ProcessNodeInstance BuildNodeInstance(int bizProcessID, ProcessNode node, int userID, string userName, string userCode) { ProcessNodeInstance nodeInstance = new ProcessNodeInstance(); nodeInstance.ProcessID = node.ProcessID; nodeInstance.NodeID = node.ID; nodeInstance.ProcessType = node.ProcessType; nodeInstance.NodeSeq = node.NodeSeq; nodeInstance.NodeName = node.NodeName; nodeInstance.NodeType = node.NodeType; nodeInstance.Expression = node.Expression; nodeInstance.IsHandSign = node.IsHandSign; nodeInstance.RoleID = node.RoleID; nodeInstance.Description = node.Description; nodeInstance.CreatedTime = WebHelper.DateTimeNow; nodeInstance.LastUpdatedTime = WebHelper.DateTimeNow; nodeInstance.BizProcessID = bizProcessID; nodeInstance.UserID = userID; nodeInstance.UserCode = userCode; nodeInstance.UserName = userName; nodeInstance.Status = (int)CommonConsts.NodeStatus.NotExecute; nodeInstance.CreateTime = WebHelper.DateTimeNow; nodeInstance.CreatorName = WebHelper.GetCurrentUser().LoginName; nodeInstance.IsDeleted = false; nodeInstance.ModifyTime = WebHelper.DateTimeNow; nodeInstance.ModifierName = WebHelper.GetCurrentUser().LoginName; return(nodeInstance); }
// Use this for initialization void Start() { //FlowAI生成 Create FlowAI. _flowAI = GetComponent <FlowAIHolder>().flowAI; //ノード生成 Create nodes. var rotNode = new ProcessNode(); var foundBranch = new BranchNode(); var missingBranch = new BranchNode(); var alertNode = new ProcessNode(); var stopAlertNode = new ProcessNode(); var stopRotNode = new ProcessNode(); //ノード初期化 Initialize nodes. rotNode.Initialize(0.1f, foundBranch, () => _isRot = true); stopRotNode.Initialize(0.1f, missingBranch, () => _isRot = false); foundBranch.Initialize(alertNode, 0.1f, foundBranch, 0.1f, () => _isFound); missingBranch.Initialize(stopAlertNode, 0.1f, missingBranch, 0.1f, () => !_isFound); alertNode.Initialize(0.1f, stopRotNode, () => Debug.Log("Alert!")); stopAlertNode.Initialize(0.1f, rotNode, () => Debug.Log("Alert stopped")); //ノード追加 Add nodes at FlowAIBasis. _flowAI.AddNode(rotNode, foundBranch, missingBranch, alertNode, stopAlertNode, stopRotNode); //エントリポイントの次のノードを設定 Setting next node for entry point node. _flowAI.entryPointNode.nextNode = rotNode; //AI開始 Transition entry point. _flowAI.Entry(); }
public void ProcessNodeTest() { var basis = new FlowAIBasis(); var proc1 = new ProcessNode(); var proc2 = new ProcessNode(); var proc3 = new ProcessNode(); var terminal = new ProcessNode(); var branch = new RandomBranchNode(); proc1.Initialize(0.3f, branch, () => Debug.Log("completed process1")); branch.nextNode1 = proc2; branch.nextNode2 = proc3; proc2.Initialize(0.1f, terminal, () => Debug.Log("completed process2")); proc3.Initialize(0.2f, terminal, () => Debug.Log("completerd process3")); terminal.Initialize(0.0f, null); basis.AddNode(proc1, proc2, proc3, terminal, branch); basis.entryPointNode.nextNode = proc1; basis.Entry(); for(int f1=0;f1<50;f1++) { Debug.LogFormat("---{0}sec---", (f1 + 1) * 0.1f); basis.Update(0.1f); } }
private static INode GetNodeFromData(string[] nodeData) { switch (nodeData[1]) { case "Begin": var startingNode = new StartingNode(int.Parse(nodeData[0])); startingNode.AddFollowingNode(int.Parse(nodeData[2])); return(startingNode); case "End": return(new EndingNode(int.Parse(nodeData[0]))); case "Decis": var decisionNode = new DecisionNode(int.Parse(nodeData[0])); decisionNode.AddLeftNode(int.Parse(nodeData[3]), nodeData[5]); decisionNode.AddRightNode(int.Parse(nodeData[2]), nodeData[4]); return(decisionNode); case "Proc": var processNode = new ProcessNode(int.Parse(nodeData[0])); processNode.AddFollowingNode(int.Parse(nodeData[2])); return(processNode); default: return(null); } }
private static INode GetNodeFromGSAData(string[] nodeData) { var nodeType = nodeData[1].ToLower(); if (nodeType == "begin") { var startingNode = new StartingNode(int.Parse(nodeData[0])); startingNode.AddFollowingNode(int.Parse(nodeData[2])); return(startingNode); } else if (nodeType == "end") { return(new EndingNode(int.Parse(nodeData[0]))); } else if (new Regex(@"y[0-9]+").IsMatch(nodeType)) { var processNode = new ProcessNode(int.Parse(nodeData[0])); processNode.AddFollowingNode(int.Parse(nodeData[2])); return(processNode); } else if (new Regex(@"x[0-9]+").IsMatch(nodeType)) { var decisionNode = new DecisionNode(int.Parse(nodeData[0])); decisionNode.AddLeftNode(int.Parse(nodeData[3])); decisionNode.AddRightNode(int.Parse(nodeData[2])); return(decisionNode); } else { return(null); } }
public void BranchNodeTest() { float elapsed = 0f; var basis = new FlowAIBasis(); var branch = new BranchNode(); var proc1 = new ProcessNode(); var proc2 = new ProcessNode(); branch.Initialize( proc1, 0.2f, proc2, 0.2f, () => { return elapsed < 0.5f; }); proc1.Initialize(0.2f, branch, () => Debug.Log("プロセス1完了")); proc2.Initialize(0.2f, branch, () => Debug.Log("プロセス2完了")); basis.entryPointNode.nextNode = branch; basis.AddNode(branch, proc1, proc2); basis.Entry(); for(int f1=0;f1<50;f1++) { elapsed += 0.1f; Debug.LogFormat("---{0:0.0}sec---", elapsed); basis.Update(0.1f); } }
// Use this for initialization void Start() { //FlowAI生成 Create FlowAI. _flowAI = GetComponent <FlowAIHolder>().flowAI; //ノード生成 Create nodes. var foundBranch = new BranchNode(); var missingBranch = new BranchNode(); var foundBranch2 = new BranchNode(); var missingBranch2 = new BranchNode(); // 旋回 var rotNode = new ProcessNode(); var stopRotNode = new ProcessNode(); // 攻撃 var ShootingNode = new ProcessNode(); var StopShootingNode = new ProcessNode(); foundBranch.summary = "見てる?"; missingBranch.summary = "見てない"; foundBranch2.summary = "打てる?"; missingBranch2.summary = "打てない"; rotNode.summary = "まわる"; stopRotNode.summary = "回らない"; ShootingNode.summary = "打ちます"; StopShootingNode.summary = "打つのやめます"; //ノード初期化 Initialize nodes. rotNode.Initialize(0.1f, foundBranch, () => _isRot = true); stopRotNode.Initialize(0.1f, ShootingNode, () => _isRot = false); ShootingNode.Initialize(0.1f, foundBranch2, () => _isBullet = true); StopShootingNode.Initialize(0.1f, rotNode, () => _isBullet = false); foundBranch.Initialize(stopRotNode, 0.1f, rotNode, 0.1f, () => _isFound); missingBranch.Initialize(rotNode, 0.1f, stopRotNode, 0.1f, () => !_isFound); foundBranch2.Initialize(ShootingNode, 0.1f, StopShootingNode, 0.1f, () => _isFound); missingBranch2.Initialize(StopShootingNode, 0.1f, ShootingNode, 0.1f, () => !_isFound); //ノード追加 Add nodes at FlowAIBasis. _flowAI.AddNode(rotNode, foundBranch, missingBranch, stopRotNode, ShootingNode, StopShootingNode, foundBranch2, missingBranch2); //エントリポイントの次のノードを設定 Setting next node for entry point node. _flowAI.entryPointNode.nextNode = rotNode; //AI開始 Transition entry point. _flowAI.Entry(); animator = GetComponent <Animator>(); //animator.SetTrigger("Shot"); }
// GET: ProcessNodes/Create public ActionResult Create() { ProcessNode processNode = new ProcessNode(); //set default value return(View(processNode)); }
void Start() { _flowAI = GetComponent <FlowAIHolder>().flowAI; proc1 = new ProcessNode(); proc2 = new ProcessNode(); proc3 = new ProcessNode(); proc4 = new ProcessNode(); proc5 = new ProcessNode(); rand1 = new BranchNode(); proc1.Initialize(1.0f, rand1, () => TFDebug.Log("visualizer", "proc1 finished"), "PROCESS1"); proc2.Initialize(1.0f, proc3, () => TFDebug.Log("visualizer", "proc2 finished"), "PROCESS2"); proc3.Initialize(1.0f, proc1, () => TFDebug.Log("visualizer", "proc3 finished"), "PROCESS3"); proc4.Initialize(1.0f, proc5, () => TFDebug.Log("visualizer", "proc4 finished"), "PROCESS4"); proc5.Initialize(1.0f, proc1, () => TFDebug.Log("visualizer", "proc5 finished"), "PROCESS5"); rand1.Initialize(proc2, 1.0f, proc4, 1.0f, () => { bool result = Random.Range(0, 2) == 0; TFDebug.Log("visualizer", "rand1 {0}", result.ToString()); return(result); }); rand1.summary = "RANDOM"; _flowAI.AddNode(proc1, proc2, proc3, proc4, proc5, rand1); _flowAI.entryPointNode.nextNode = proc1; _flowAI.Entry(); }
void INodeHandler.Execute(ProcessNode processNode, ProcessNode previousNode) { Console.WriteLine(processNode.NodeName + " Executing Sequence"); bool result = true; if (processNode.Expression != null) { Console.WriteLine(processNode.NodeName + " Conditional Sequence"); Console.WriteLine("Condition: " + processNode.Expression); var globals = new Globals(processNode.InputParameters.ToDictionary(e => e.Key, e => e.Value)); try { result = CSharpScript.EvaluateAsync <bool>(processNode.Expression, globals: globals).Result; Console.WriteLine("Condition result: " + result.ToString()); } catch (Exception e) { Console.WriteLine(e.Message); } } if (result) { processNode.Done(); } }
protected async Task UpgradeServerAsync( string toVersion, ProcessNode node, CancellationToken token = default) { KillSlavedServerProcess(node.Process); if (toVersion == "current") { RunLocalServer(node); return; } var serverBuildInfo = ServerBuildDownloadInfo.Create(toVersion); var serverPath = await _serverBuildRetriever.GetServerPath(serverBuildInfo, token); CopyFilesRecursively(new DirectoryInfo(serverPath), new DirectoryInfo(node.ServerPath)); var locator = new ConfigurableRavenServerLocator(Path.Combine(node.ServerPath, "Server"), toVersion, node.DataDir, node.Url); var result = await RunServer(locator); Assert.Equal(node.Url, result.ServerUrl); node.Process = result.ServerProcess; node.Version = toVersion; }
public NodeGraph(XPathNavigator xPathNavigator) { _startNodeID = xPathNavigator.GetAttribute("startNode", ""); _endNodeID = xPathNavigator.GetAttribute("endNode", ""); //Create all the nodes first xPathNavigator.MoveToChild("Node", ""); do { var nodeID = xPathNavigator.GetAttribute("id", ""); if (nodeID == _endNodeID) { _nodes[nodeID] = new EndNode(xPathNavigator.Clone()); } else { _nodes[nodeID] = new ProcessNode(xPathNavigator.Clone()); if (nodeID == _startNodeID) { _startNode = _nodes[nodeID]; } } } while (xPathNavigator.MoveToNext("Node", "")); // now set all the connections between them xPathNavigator.MoveToFirst(); do { var nodeID = xPathNavigator.GetAttribute("id", ""); var currentNode = _nodes[nodeID]; if (!(currentNode is EndNode)) { ProcessNode processNode = (ProcessNode)currentNode; if (xPathNavigator.MoveToChild("NextNode", "")) { do { var id = xPathNavigator.GetAttribute("id", ""); Node nextNode = null; try { nextNode = _nodes[id]; } catch (ArgumentNullException e) { throw new XmlException("NextNode with id=[" + id + "] could not be found.", e); } processNode.NextNodes.Add(nextNode); } while (xPathNavigator.MoveToNext("NextNode", "")); } else { throw new XmlException("Node[id=" + currentNode.ID + "] has no next node but is not defined as endNode in the NodeGraph."); } } xPathNavigator.MoveToParent(); } while (xPathNavigator.MoveToNext("Node", "")); }
public void Append(ProcessNode node) { if (null == mSequenceNode) { mSequenceNode = new SequenceNode(); } mSequenceNode.Append(node); }
public void DisplayProcessToBeHookedOnStart(IProcess aProcess) { lock (_lock) { _toHookOnStartGroup.AddChild(ProcessNode.NotRunning(aProcess)); ExpandCategoryNodes(); } }
public ProcessGroupNode Add(IProcess aProcess) { var aNode = ProcessNode.From(aProcess); var group = GroupFor(aNode); group.Group(aNode); return(group); }
private ProcessGroupNode InitializeGroupFor(ProcessNode aNode) { var group = new ProcessGroupNode(aNode); _groups.Add(group); AddNodeInLexigographycalOrder(group); return(group); }
public void ProcessNodeAdapterUpdateTest() { ProcessNodeAdapter pna = new ProcessNodeAdapter(); ProcessNode pn = pna.Load("506B7138-CB9B-4E48-BEF4-4AC48CAD9FF6"); pn.CreateTime = pn.CreateTime.AddYears(10); pn.CreatorName = pn.CreatorName + "UDP"; pn.Description = pn.Description + "UDP"; pna.Update(pn); }
private static void PrintNode(string indent, ProcessNode processNode) { var reportedProcess = processNode.ReportedProcess; Console.WriteLine($"{indent}{reportedProcess.Path} [ran {(reportedProcess.ExitTime - reportedProcess.CreationTime).TotalMilliseconds}ms]"); foreach (var childrenProcess in processNode.Children) { var newIndent = new string(' ', indent.Length) + (childrenProcess == processNode.Children.Last() ? "└──" : "├──"); PrintNode(newIndent, childrenProcess); } }
//[ValidateAntiForgeryToken] public ActionResult DeleteConfirmed(int id) { ProcessNode processNode = _processNodeService.Find(id); _processNodeService.Delete(processNode); _unitOfWork.SaveChanges(); if (Request.IsAjaxRequest()) { return(Json(new { success = true }, JsonRequestBehavior.AllowGet)); } DisplaySuccessMessage("Has delete a ProcessNode record"); return(RedirectToAction("Index")); }
void INodeHandler.Execute(ProcessNode processNode, ProcessNode previousNode) { Console.WriteLine(processNode.NodeName); sequenceWait.GetOrAdd(processNode, new List <ProcessNode>(processNode.PreviousNodes)); lock (sequenceWait[processNode]) { sequenceWait[processNode].Remove(previousNode); } if (sequenceWait[processNode].Count == 0) { processNode.Done(); } }
public void ProcessFile(ProcessNode node, SolutionNode parent) { if (node.IsValid) { List <SolutionNode> list = new List <SolutionNode>(); ProcessFile(node.Path, list); foreach (SolutionNode solution in list) { parent.SolutionsTable[solution.Name] = solution; } } }
// GET: ProcessNodes/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ProcessNode processNode = _processNodeService.Find(id); if (processNode == null) { return(HttpNotFound()); } return(View(processNode)); }
private void AttachSelectedProcess() { if (_tree.SelectedNode != null) { ProcessNode node = _tree.SelectedNode.Tag as ProcessNode; if (node != null) { PluginMain.debugManager.AttachToProcess((uint)node.PID); } Close(); } }
public void ReduceDaysbyPctTest() { var node = new ProcessNode(); Assert.IsTrue(node.ReduceDaysbyPct(0).PlannedBeginTime == node.PlannedCompletionTime); //node.PlannedCompletionTime = DateTime.Now; // //Assert.IsTrue(node.ReduceDaysbyPct(0).PlannedBeginTime == node.PlannedCompletionTime); Assert.IsTrue(node.ReduceDaysbyPct(1).PlannedBeginTime == node.PlannedCompletionTime.Value.AddDays(1)); node.PlannedBeginTime = null; Assert.IsTrue(node.ReduceDaysbyPct(1).PlannedBeginTime == node.PlannedCompletionTime); }
public void IncreaseHoursbyPbtTest() { var node = new ProcessNode(); Assert.IsTrue(node.IncreaseHoursbyPbt(0).PlannedCompletionTime == node.PlannedBeginTime); node.PlannedBeginTime = DateTime.Now; Assert.IsTrue(node.IncreaseHoursbyPbt(0).PlannedCompletionTime == node.PlannedBeginTime); Assert.IsTrue(node.IncreaseHoursbyPbt(1).PlannedCompletionTime == node.PlannedBeginTime.Value.AddHours(1)); node.PlannedBeginTime = null; Assert.IsTrue(node.IncreaseHoursbyPbt(1).PlannedCompletionTime == node.PlannedCompletionTime); }
public void Display(IEnumerable <IProcess> toHookOnStart, IEnumerable <IRunningProcess> unhooked, IEnumerable <IRunningProcess> hookedInactive, IEnumerable <IRunningProcess> hookedActive) { lock (_lock) { toHookOnStart.ForEach(p => _toHookOnStartGroup.AddChild(ProcessNode.From(p))); _unHooked.Add(unhooked.Cast <IProcess>()); _hookedInactive.Add(hookedInactive.Cast <IProcess>()); _hookedActive.Add(hookedActive.Cast <IProcess>()); } ExpandCategoryNodes(); }
/// <summary> /// 根据流程上下文计算流程节点 /// </summary> /// <param name="nodeList"></param> /// <param name="bizProcessContext"></param> /// <returns></returns> public List <ProcessNode> CacluateProcessNodesByCondition(List <ProcessNode> nodeList, Hashtable bizProcessContext) { for (int i = nodeList.Count - 1; i >= 0; i--) { ProcessNode node = nodeList[i]; //使用表达式分析加载流程上下文对象 WorkflowExpressionParser parser = new WorkflowExpressionParser(bizProcessContext); //使用节点表达式计算,如果不符合表达式,从列表里面移除 if (!parser.CacluateCondition(node.Expression)) { nodeList.Remove(node); } } return(nodeList); }
public void ReduceHoursbyPctTest() { var node = new ProcessNode(); Assert.IsTrue(node.ReduceHoursbyPct(-2).PlannedBeginTime == node.PlannedCompletionTime); node.PlannedBeginTime = DateTime.Now; Assert.IsTrue(node.ReduceHoursbyPct(0).PlannedCompletionTime == node.PlannedCompletionTime); Assert.IsTrue(node.ReduceHoursbyPct(1).PlannedCompletionTime == node.PlannedCompletionTime.Value.AddHours(1)); node.PlannedBeginTime = null; Assert.IsTrue(node.ReduceHoursbyPct(1).PlannedBeginTime == node.PlannedBeginTime); Assert.Fail(); }
public void Traverse(IAstNode astNode) { ProcessNode?.Invoke(astNode); switch (astNode.AstNodeType) { case AstNodeTypes.VarStatement: Traverse(astNode.AsVarStatement().Expression); break; case AstNodeTypes.PrintStatement: foreach (var printExpr in astNode.AsPrintStatement().PrintExpressions) { Traverse(printExpr); } break; case AstNodeTypes.PrintExpression: Traverse(astNode.AsPrintExpression().Expression); break; case AstNodeTypes.UnaryOperator: Traverse(astNode.AsUnaryOp().Operand); break; case AstNodeTypes.BinaryOperator: Traverse(astNode.AsBinaryOp().LeftOperand); Traverse(astNode.AsBinaryOp().RightOperand); break; case AstNodeTypes.NumberLiteral: break; case AstNodeTypes.StringLiteral: break; case AstNodeTypes.VarReference: break; } PostProcessNode?.Invoke(astNode.AstNodeType); }