Exemplo n.º 1
0
        private void UpdateProcessActions(ProcessBase p)
        {
            string name = p.ToString();

            if (!_performedActionsCount.ContainsKey(name))
            {
                _performedActionsCount.Add(name, 1);
            }
            else
            {
                Node proc  = GetProcess(name);
                int  count = 0;
                while (proc is ActionPrefix)
                {
                    proc = ((ActionPrefix)proc).Process;
                    count++;
                }
                int countPerformed = _performedActionsCount[name];
                //System.Windows.Forms.MessageBox.Show("Count: " + count + ", countperformed: " + countPerformed);
                if (countPerformed == count - 1)
                {
                    _performedActionsCount[name] = 0;
                }
                else
                {
                    _performedActionsCount[name]++;
                }
            }
        }
Exemplo n.º 2
0
        public void NewState(List <ProcessBase> activeProcs, CandidateAction chosenAction)
        {
            StringBuilder builder = new StringBuilder();

            if (chosenAction != null)
            {
                UpdateProcessActions(chosenAction.Process1);
                if (chosenAction.Process2 != null)
                {
                    UpdateProcessActions(chosenAction.Process2);
                }
            }
            foreach (ProcessBase pb in activeProcs)
            {
                string name = pb.ToString();
                Node   proc = GetProcess(name);
                RemovePerformedActions(name, ref proc);
                builder.Append("\n\n# " + name + ": \n");
                if (pb.Parent != null)
                {
                    builder.Append("# Parent chain: ");
                    ProcessBase parent = pb.Parent;

                    List <string> parts = new List <string>();
                    while (parent != null)
                    {
                        Node   parentProc = GetProcess(parent.ToString());
                        string oneParent  = parent + ": ";
                        if (parentProc.ChildNodes[0] != null)
                        {
                            _formatter.Start(parentProc.ChildNodes[0]);
                            oneParent += (_formatter.GetFormatted());
                        }
                        if (parentProc.ChildNodes[1] != null)
                        {
                            _formatter.Start(parentProc.ChildNodes[1]);
                            oneParent += _formatter.GetFormatted();
                        }
                        parts.Add(oneParent);
                        parent = parent.Parent;
                    }
                    parts.Reverse();
                    builder.Append(string.Join("; ", parts.ToArray()));
                    builder.Append("\n");
                }
                _formatter.Start(proc);
                builder.Append(FormatProc(_formatter.GetFormatted()));
            }
            _string = builder.ToString();
        }