コード例 #1
0
        internal void CreateTransition(bool[] isFormulaSatisfied, int targetStateIndex, int continuationId)
        {
            var transition = _transitionCount;

            _transitionCount++;
            _transitions[transition] = new LtmdpTransition {
                Index = transition
            };
            var t = (Transition *)(_transitions + transition);

            t->SourceStateIndex = 0;
            t->TargetStateIndex = targetStateIndex;
            t->Formulas         = new StateFormulaSet(isFormulaSatisfied);
            t->Flags            = TransitionFlags.IsValidFlag | TransitionFlags.IsStateTransformedToIndexFlag;
            t->ActivatedFaults  = new FaultSet();
            StepGraph.SetTargetOfFinalOrUnsplitChoice(continuationId, transition);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: PerryAsleep/Fumen
        /// <summary>
        /// Loads PadData and creates the InputStepGraph and OutputStepGraph.
        /// </summary>
        /// <returns>
        /// True if no errors were generated and false otherwise.
        /// </returns>
        private static async Task <bool> LoadPadDataAndCreateStepGraphs()
        {
            // If the types are the same, just create one StepGraph.
            if (Config.Instance.InputChartType == Config.Instance.OutputChartType)
            {
                // Load the input PadData.
                var padData = await LoadPadData(Config.Instance.InputChartType);

                if (padData == null)
                {
                    return(false);
                }

                // Create the StepGraph and use it for both the InputStepGraph and the OutputStepGraph.
                LogInfo("Creating StepGraph.");
                InputStepGraph = StepGraph.CreateStepGraph(padData, padData.StartingPositions[0][0][L],
                                                           padData.StartingPositions[0][0][R]);
                OutputStepGraph = InputStepGraph;
                if (!CreateOutputStartNodes())
                {
                    return(false);
                }
                LogInfo("Finished creating StepGraph.");
            }

            // If the types are separate, create two graphs.
            else
            {
                // Load the PadData for both the input and output type.
                var inputPadDataTask  = LoadPadData(Config.Instance.InputChartType);
                var outputPadDataTask = LoadPadData(Config.Instance.OutputChartType);
                await Task.WhenAll(inputPadDataTask, outputPadDataTask);

                var inputPadData  = await inputPadDataTask;
                var outputPadData = await outputPadDataTask;
                if (inputPadData == null || outputPadData == null)
                {
                    return(false);
                }

                LogInfo("Creating StepGraphs.");

                // Create each graph on their own thread as these can take a few seconds.
                var inputGraphTask = Task.Factory.StartNew(() =>
                {
                    InputStepGraph = StepGraph.CreateStepGraph(
                        inputPadData,
                        inputPadData.StartingPositions[0][0][L],
                        inputPadData.StartingPositions[0][0][R]);
                });
                var outputGraphTask = Task.Factory.StartNew(() =>
                {
                    OutputStepGraph = StepGraph.CreateStepGraph(
                        outputPadData,
                        outputPadData.StartingPositions[0][0][L],
                        outputPadData.StartingPositions[0][0][R]);
                });
                await Task.WhenAll(inputGraphTask, outputGraphTask);

                if (!CreateOutputStartNodes())
                {
                    return(false);
                }

                LogInfo("Finished creating StepGraphs.");
            }

            return(true);
        }
コード例 #3
0
 internal void Clear()
 {
     _transitionCount = 0;
     _choiceResolver.PrepareNextState();
     StepGraph.Clear();
 }