コード例 #1
0
        private void buttonHue_Click(object sender, RoutedEventArgs e)
        {
            ShowHue = !ShowHue;

            buttonLabeling.IsEnabled = !ShowHue;

            buttonHue.Background = ShowHue ? General.OnBrush : General.OffBrush;

            if (ShowHue)
            {
                General.cam.ResetFlag();

                Task.Run(() =>
                {
                    while (ShowHue)
                    {
                        TestLed.CheckColorForDebug();
                        Sleep(100);
                    }
                });
            }
            else
            {
                General.cam.ResetFlag();
            }
        }
コード例 #2
0
        private async void buttonSave_Click(object sender, RoutedEventArgs e)
        {
            if (IsBusy)
            {
                return;
            }

            if (!General.CheckPress())
            {
                MessageBox.Show("ゴールデンサンプルをセットして\nレバーを下げてください");
                return;
            }

            try
            {
                //LED全点灯の処理
                buttonSave.Background = Brushes.DodgerBlue;

                buttonLedOn.IsEnabled    = false;
                buttonLabeling.IsEnabled = false;
                buttonHue.IsEnabled      = false;

                IsBusy           = true;
                RingCal.IsActive = true;

                await Task.Run(() => General.PowSupply(true));

                await General.LedAllOn();

                var tm = new GeneralTimer(3000);
                tm.start();

                FlagLabeling = true;
                labeling();

                await Task.Run(() =>
                {
                    while (true)
                    {
                        if (tm.FlagTimeout)
                        {
                            break;
                        }
                        if (CanSaveLedPpint)
                        {
                            break;
                        }
                    }
                });

                if (!CanSaveLedPpint)
                {
                    goto FAIL;
                }
                else
                {
                    await Task.Delay(1000);

                    if (!SaveLedPoint() /*座標保存*/ || !SaveLedLum() /*輝度保存*/)
                    {
                        goto FAIL;
                    }

                    SaveCameraCommonPropForLed();//カメラプロパティ保存

                    //カラーチェック
                    FlagLabeling = false;
                    General.cam.ResetFlag();

                    await Task.Delay(1000);

                    TestLed.CheckColorForDebug();
                    if (!CheckCol())
                    {
                        goto FAIL;
                    }

                    General.PlaySound(General.soundSuccess);
                    labelMess.Content    = "自動補正完了しました!";
                    labelMess.Foreground = Brushes.DodgerBlue;
                    (FindResource("SbMessage") as Storyboard).Begin();
                    await Task.Delay(1000);

                    return;
                }

FAIL:
                General.PlaySound(General.soundFail);
                labelMess.Content    = "LED全点灯が認識できません\nカメラプロパティの調整をしてください";
                labelMess.Foreground = Brushes.HotPink;
                (FindResource("SbMessage") as Storyboard).Begin();
                await Task.Delay(1000);
            }
            finally
            {
                FlagLabeling     = false;
                RingCal.IsActive = false;
                await Task.Delay(150);

                buttonSave.Background = Brushes.Transparent;

                buttonLedOn.IsEnabled    = true;
                buttonLabeling.IsEnabled = true;
                buttonHue.IsEnabled      = true;

                IsBusy = false;
                General.ResetIo();
            }
        }