コード例 #1
0
ファイル: App.Bot.cs プロジェクト: SDManson/GitRepo
        void BotProgress(bool motionEnable)
        {
            botLock.IfLockIsAvailableEnter(() =>
            {
                var memoryMeasurementLast = this.MemoryMeasurementLast;

                var time = memoryMeasurementLast?.End;

                if (!time.HasValue)
                {
                    return;
                }

                if (time <= bot?.StepLastInput?.TimeMilli)
                {
                    return;
                }

                BotConfigLoad();

                var stepResult = bot.Step(new Bot.BotStepInput
                {
                    TimeMilli = time.Value,
                    FromProcessMemoryMeasurement = memoryMeasurementLast,
                    StepLastMotionResult         = BotStepLastMotionResult?.Value,
                    ConfigSerial = BotConfigLoaded?.Value.Value,
                });

                if (motionEnable)
                {
                    BotMotion(memoryMeasurementLast, stepResult?.ListMotion);
                }
            });
        }
コード例 #2
0
        void BotProgress(bool motionEnable)
        {
            botLock.IfLockIsAvailableEnter(() =>
            {
                var memoryMeasurementLast = this.MemoryMeasurementLast;

                var time = memoryMeasurementLast?.End;

                if (!time.HasValue)
                {
                    return;
                }

                if (time <= bot?.StepLastInput?.TimeMilli)
                {
                    return;
                }

                BotConfigLoad();

                bot.Step(new Bot.BotStepInput
                {
                    TimeMilli = time.Value,
                    FromProcessMemoryMeasurement = memoryMeasurementLast,
                    StepLastMotionResult         = BotStepLastMotionResult?.Value,
                    ConfigSerial = BotConfigLoaded?.Value.Value,
                });

                if (motionEnable)
                {
                    Task.Run(() =>
                    {
                        App.motionMutex.WaitOne();
                        botLock.WhenLockIsAvailableEnter(90000, () =>
                        {
                            BotMotion(this.MemoryMeasurementLast, bot.StepLastResult?.ListMotion);
                            App.motionMutex.ReleaseMutex();
                            Thread.Sleep(FromMotionToMeasurementDelayMilli);
                        });
                    });
                }
            });
        }
コード例 #3
0
        void BotProgress(bool motionEnable)
        {
            botLock.IfLockIsAvailableEnter(() =>
            {
                Debug.WriteLine($"Bot at thread {Thread.CurrentThread.ManagedThreadId} called BotProgress");
                var memoryMeasurementLast = this.MemoryMeasurementLast;

                var time = memoryMeasurementLast?.End;

                if (!time.HasValue)
                {
                    return;
                }

                if (time <= bot?.StepLastInput?.TimeMilli)
                {
                    return;
                }

                BotConfigLoad();

                var stepResult = bot.Step(new Bot.BotStepInput
                {
                    TimeMilli = time.Value,
                    FromProcessMemoryMeasurement = memoryMeasurementLast,
                    StepLastMotionResult         = BotStepLastMotionResult?.Value,
                    ConfigSerial = BotConfigLoaded?.Value.Value,
                });

                if (motionEnable)
                {
                    BotMotion(memoryMeasurementLast, stepResult?.ListMotion);
                }
                Debug.WriteLine($"Bot at thread {Thread.CurrentThread.ManagedThreadId} finished BotProgress");
            }, nameof(BotProgress) + Process.GetCurrentProcess().Id);
        }