Exemplo n.º 1
0
        public BotStepResult Step(BotStepInput input)
        {
            var beginTimeMilli = GetTimeMilli();

            StepLastInput = input;

            Exception exception = null;

            var listMotion = new List <MotionRecommendation>();

            IBotTask[][] outputListTaskPath = null;

            try
            {
                MemorizeStepInput(input);

                outputListTaskPath = StepOutputListTaskPath()?.ToArray();

                foreach (var moduleToggle in outputListTaskPath.ConcatNullable().OfType <ModuleToggleTask>().Select(moduleToggleTask => moduleToggleTask?.module).WhereNotDefault())
                {
                    ToggleLastStepIndexFromModule[moduleToggle] = stepIndex;
                }

                foreach (var taskPath in outputListTaskPath.EmptyIfNull())
                {
                    var taskMotionParam = taskPath?.LastOrDefault()?.Motion;

                    if (null == taskMotionParam)
                    {
                        continue;
                    }

                    listMotion.Add(new MotionRecommendation
                    {
                        Id          = motionId++,
                        MotionParam = taskMotionParam,
                    });
                }
            }
            catch (Exception e)
            {
                exception = e;
            }

            var stepResult = new BotStepResult
            {
                Exception          = exception,
                ListMotion         = listMotion?.ToArrayIfNotEmpty(),
                OutputListTaskPath = outputListTaskPath,
            };

            MemorizeStepResult(stepResult);

            StepLastResult = new PropertyGenTimespanInt64 <BotStepResult>(stepResult, beginTimeMilli, GetTimeMilli());

            ++stepIndex;

            return(stepResult);
        }
Exemplo n.º 2
0
Arquivo: Bot.cs Projeto: Fulborg/A-Bot
        public BotStepResult Step(BotStepInput input)
        {
            var beginTimeMilli = GetTimeMilli();

            StepLastInput = input;

            Exception exception = null;

            var listMotion = new List <MotionRecommendation>();

            IBotTask[][] outputListTaskPath = null;

            try
            {
                MemorizeStepInput(input);

                outputListTaskPath = ((IBotTask) new BotTask(null)
                {
                    Component = strategy.GetTasks(this)
                })
                                     ?.EnumeratePathToNodeFromTreeDFirst(node => node?.Component)
                                     ?.Where(taskPath => (taskPath?.LastOrDefault()).ShouldBeIncludedInStepOutput())
                                     ?.TakeSubsequenceWhileUnwantedInferenceRuledOut()
                                     ?.ToArray();

                foreach (var moduleToggle in outputListTaskPath.ConcatNullable().OfType <ModuleToggleTask>()
                         .Select(moduleToggleTask => moduleToggleTask?.module).WhereNotDefault())
                {
                    ToggleLastStepIndexFromModule[moduleToggle] = stepIndex;
                }

                foreach (var effect in outputListTaskPath.EmptyIfNull().SelectMany(taskPath =>
                                                                                   (taskPath?.LastOrDefault()?.ApplicableEffects()).EmptyIfNull()))
                {
                    listMotion.Add(effect);
                }
            }
            catch (Exception e)
            {
                exception = e;
            }

            var stepResult = new BotStepResult
            {
                Exception          = exception,
                ListMotion         = listMotion?.ToArrayIfNotEmpty(),
                OutputListTaskPath = outputListTaskPath,
            };

            MemorizeStepResult(stepResult);

            StepLastResult = new PropertyGenTimespanInt64 <BotStepResult>(stepResult, beginTimeMilli, GetTimeMilli());

            ++stepIndex;

            return(stepResult);
        }
Exemplo n.º 3
0
        void MemorizeStepInput(BotStepInput input)
        {
            ConfigSerialAndStruct = (input?.ConfigSerial?.String).DeserializeIfDifferent(ConfigSerialAndStruct);

            MemoryMeasurementAtTime = input?.FromProcessMemoryMeasurement?.MapValue(measurement => measurement?.Parse());

            MemoryMeasurementAccu.Accumulate(MemoryMeasurementAtTime);

            OverviewMemory.Aggregate(MemoryMeasurementAtTime);
        }