Ejemplo n.º 1
0
    public void Populate()
    {
        LastUpdated = Time.time;
        Flows.Clear();
        SetPotentialsFromNavigationField();
        Target.SeedPotentials(AddTraversal);
        DebugInstance = this;
        while (_heap.Any())
        {
            CellPotentialHeapEntry cellPotentialHeapEntry = _heap.ExtractDominating();
            Vector2i position = cellPotentialHeapEntry.Position;

            float currentPotential = Potentials[position.x, position.y];

            if (currentPotential < cellPotentialHeapEntry.Potential)
            {
                continue;
            }

            Potentials[position.x, position.y] = cellPotentialHeapEntry.Potential;

            TryAddTraversal(position, DownLeft, currentPotential);
            TryAddTraversal(position, DownRight, currentPotential);
            TryAddTraversal(position, UpLeft, currentPotential);
            TryAddTraversal(position, UpRight, currentPotential);

            TryAddTraversal(position, Left, currentPotential);
            TryAddTraversal(position, Right, currentPotential);
            TryAddTraversal(position, Down, currentPotential);
            TryAddTraversal(position, Up, currentPotential);

            CellPotentialHeapEntry.ReturnCellCostHeapEntry(cellPotentialHeapEntry);
        }
        Target.Finished(this);
    }
        public override bool TryParse()
        {
            if (!base.TryParse())
            {
                return(false);
            }

            // groups, flows, branches, bcs
            Groups.Clear();
            Flows.Clear();
            Branches.Clear();
            BusinessComponents.Clear();
            RecoverySteps.Clear();
            GeneralSteps.Clear();

            ReportNodeType[] childNodes = Node.ReportNode;
            if (childNodes != null)
            {
                foreach (ReportNodeType node in childNodes)
                {
                    // business component
                    BusinessComponentReport bc = BusinessComponents.TryParseAndAdd(node, this.Node);
                    if (bc != null)
                    {
                        AllBCsEnumerator.Add(bc);
                        continue;
                    }

                    // group
                    GroupReport group = Groups.TryParseAndAdd(node, this.Node);
                    if (group != null)
                    {
                        AllBCsEnumerator.Merge(group.AllBCsEnumerator);
                        continue;
                    }

                    // flow
                    FlowReport flow = Flows.TryParseAndAdd(node, this.Node);
                    if (flow != null)
                    {
                        AllBCsEnumerator.Merge(flow.AllBCsEnumerator);
                        continue;
                    }

                    // branch
                    BranchReport branch = Branches.TryParseAndAdd(node, this.Node);
                    if (branch != null)
                    {
                        AllBCsEnumerator.Merge(branch.AllBCsEnumerator);
                        continue;
                    }

                    // recovery step
                    RecoveryStepReport recovery = RecoverySteps.TryParseAndAdd(node, this.Node);
                    if (recovery != null)
                    {
                        AllBCsEnumerator.Merge(recovery.AllBCsEnumerator);
                        continue;
                    }

                    // general step
                    GeneralStepReport generalStep = GeneralSteps.TryParseAndAdd(node, this.Node);
                    if (generalStep != null)
                    {
                        AllBCsEnumerator.Merge(generalStep.AllBCsEnumerator);
                        continue;
                    }
                }
            }

            return(true);
        }
Ejemplo n.º 3
0
        public override bool TryParse()
        {
            if (!base.TryParse())
            {
                return(false);
            }

            // name
            if (string.IsNullOrWhiteSpace(Name))
            {
                Name = Properties.Resources.Test_Step;
            }

            // groups, flows, branches, bcs
            Groups.Clear();
            Flows.Clear();
            Branches.Clear();
            BusinessComponents.Clear();
            RecoverySteps.Clear();
            SubGeneralSteps.Clear();

            ReportNodeType[] childNodes = Node.ReportNode;
            if (childNodes != null)
            {
                foreach (ReportNodeType node in childNodes)
                {
                    // business component
                    BusinessComponentReport bc = BusinessComponents.TryParseAndAdd(node, this.Node);
                    if (bc != null)
                    {
                        AllBCsEnumerator.Add(bc);
                        continue;
                    }

                    // group
                    GroupReport group = Groups.TryParseAndAdd(node, this.Node);
                    if (group != null)
                    {
                        AllBCsEnumerator.Merge(group.AllBCsEnumerator);
                        continue;
                    }

                    // flow
                    FlowReport flow = Flows.TryParseAndAdd(node, this.Node);
                    if (flow != null)
                    {
                        AllBCsEnumerator.Merge(flow.AllBCsEnumerator);
                        continue;
                    }

                    // branch
                    BranchReport branch = Branches.TryParseAndAdd(node, this.Node);
                    if (branch != null)
                    {
                        AllBCsEnumerator.Merge(branch.AllBCsEnumerator);
                        continue;
                    }

                    // recovery steps
                    RecoveryStepReport recovery = RecoverySteps.TryParseAndAdd(node, this.Node);
                    if (recovery != null)
                    {
                        AllBCsEnumerator.Merge(recovery.AllBCsEnumerator);
                        continue;
                    }

                    // sub general steps
                    GeneralStepReport subStep = SubGeneralSteps.TryParseAndAdd(node, this.Node);
                    if (subStep != null)
                    {
                        AllBCsEnumerator.Merge(subStep.AllBCsEnumerator);
                        continue;
                    }
                }
            }

            return(true);
        }
Ejemplo n.º 4
0
        public override bool TryParse()
        {
            if (!base.TryParse())
            {
                return(false);
            }

            // for the branch (case) report node, the next level node is "Step" type
            // case name and description is retrieved from the "Step" type node
            ReportNodeType[] childNodes = Node.ReportNode;
            if (childNodes == null || childNodes.Length == 0)
            {
                return(false);
            }
            ReportNodeType caseStepNode = childNodes[0];

            if (caseStepNode.type.ToLower() != NodeType_Step)
            {
                return(false);
            }
            CaseName        = caseStepNode.Data.Name;
            CaseDescription = caseStepNode.Data.Description;

            // groups, flows, branches, bcs
            Groups.Clear();
            Flows.Clear();
            Branches.Clear();
            BusinessComponents.Clear();
            RecoverySteps.Clear();
            GeneralSteps.Clear();

            childNodes = caseStepNode.ReportNode;
            if (childNodes != null)
            {
                foreach (ReportNodeType node in childNodes)
                {
                    // business component
                    BusinessComponentReport bc = BusinessComponents.TryParseAndAdd(node, this.Node);
                    if (bc != null)
                    {
                        AllBCsEnumerator.Add(bc);
                        continue;
                    }

                    // group
                    GroupReport group = Groups.TryParseAndAdd(node, this.Node);
                    if (group != null)
                    {
                        AllBCsEnumerator.Merge(group.AllBCsEnumerator);
                        continue;
                    }

                    // flow
                    FlowReport flow = Flows.TryParseAndAdd(node, this.Node);
                    if (flow != null)
                    {
                        AllBCsEnumerator.Merge(flow.AllBCsEnumerator);
                        continue;
                    }

                    // branch
                    BranchReport branch = Branches.TryParseAndAdd(node, this.Node);
                    if (branch != null)
                    {
                        AllBCsEnumerator.Merge(branch.AllBCsEnumerator);
                        continue;
                    }

                    // recovery step
                    RecoveryStepReport recovery = RecoverySteps.TryParseAndAdd(node, this.Node);
                    if (recovery != null)
                    {
                        AllBCsEnumerator.Merge(recovery.AllBCsEnumerator);
                        continue;
                    }

                    // general step
                    GeneralStepReport generalStep = GeneralSteps.TryParseAndAdd(node, this.Node);
                    if (generalStep != null)
                    {
                        AllBCsEnumerator.Merge(generalStep.AllBCsEnumerator);
                        continue;
                    }
                }
            }

            return(true);
        }