예제 #1
0
 /// <summary>
 /// モータコントローラ,LED,カメラといったハードウェアとのインターフェイスを初期化します.
 /// <para>失敗した場合,エラーメッセージを表示してアプリケーションを終了します.</para>
 /// </summary>
 public void InitializedHardWare()
 {
     /* ハードウェアを初期化する */
     // LED照明の初期化
     try {
         Led led = Led.GetInstance();
         led.Initiazlie();
         led.SetTimer(1600);
     } catch (Exception ex) {
         MessageBox.Show(ex.Message + NagaraStage.Properties.Strings.InitLedException01);
         Environment.Exit(1);
     }
     // モータコントローラボードの初期化
     try {
         MotorControler mc = MotorControler.GetInstance(ParameterManager);
         mc.Initialize();
         //mc.InitializeMotorControlBoard(MechaAxisAddress.XAddress);
         //mc.InitializeMotorControlBoard(MechaAxisAddress.YAddress);
         //mc.InitializeMotorControlBoard(MechaAxisAddress.ZAddress);
     } catch (Exception ex) {
         MessageBox.Show(ex.Message + NagaraStage.Properties.Strings.InitMotorException01);
         Environment.Exit(1);
     }
     //カメラの初期化
     try {
         Camera cam = Camera.GetInstance();
         cam.Initialize();
     } catch (Exception ex) {
         MessageBox.Show(ex.Message + NagaraStage.Properties.Strings.InitCameraExcetion01);
         Environment.Exit(1);
     }
 }
예제 #2
0
        List <ImageTaking> TakeSequentialImage(double ax, double ay, double dz, int nimage)
        {
            MotorControler mc     = MotorControler.GetInstance(parameterManager);
            Camera         camera = Camera.GetInstance();

            Vector3            initialpos = mc.GetPoint();
            List <ImageTaking> lit        = new List <ImageTaking>();

            for (int i = 0; i < nimage; i++)
            {
                Vector3 dstpoint = new Vector3(
                    initialpos.X + ax * dz * i,
                    initialpos.Y + ay * dz * i,
                    initialpos.Z + dz * i
                    );
                mc.MovePoint(dstpoint);
                mc.Join();

                byte[]      b     = camera.ArrayImage;
                Mat         image = new Mat(440, 512, MatType.CV_8U, b);
                ImageTaking it    = new ImageTaking();
                it.img        = image.Clone();
                it.StageCoord = mc.GetPoint();
                lit.Add(it);

                //image.Release();
                //imagec.Release();
            }

            return(lit);
        }
예제 #3
0
            /// <param name="task">アクティビティのタスク</param>
            /// <param name="handler">タスク終了時のイベントハンドラ</param>
            /// <returns>アクティビティスレッド</returns>
            protected Thread Create(ActivityTask task, ActivityEventHandler handler)
            {
                ThreadStart start = new ThreadStart(delegate
                {
                    ActivityEventArgs args = new ActivityEventArgs();
                    try
                    {
                        task();
                        args.IsCompleted = true;
                    }
                    catch (ThreadAbortException ex)
                    {
                        args.IsAborted = true;
                        args.Exception = ex;
                    }
                    catch (Exception ex)
                    {
                        args.Exception = ex;
                    }
                    finally
                    {
                        MotorControler mc = MotorControler.GetInstance(parameterManager);
                        mc.AbortMoving();
                        mc.SlowDownStopAll();

                        if (handler != null)
                        {
                            handler(this, args);
                        }
                    }
                });

                return(Create(start));
            }
예제 #4
0
        /// <summary>
        /// 現在,どこのゲルにいるのかを現在の座標値と,前回調べた境界面の座標値から算出します.
        /// </summary>
        /// <returns>現在いるゲル</returns>
        private GelLayer getWhichLayerNow()
        {
            MotorControler mc = MotorControler.GetInstance(parameterManager);
            double         z  = mc.GetPoint().Z;
            GelLayer       gelLayer;

            if (z > UpTop)
            {
                gelLayer = GelLayer.OverOut;
            }
            else if (z <= UpTop && z >= UpBottom)
            {
                gelLayer = GelLayer.Over;
            }
            else if (z < UpBottom && z > LowTop)
            {
                gelLayer = GelLayer.Base;
            }
            else if (z <= LowTop && z >= LowBottom)
            {
                gelLayer = GelLayer.Under;
            }
            else if (z < LowBottom)
            {
                gelLayer = GelLayer.UnderOut;
            }
            else
            {
                gelLayer = GelLayer.Unknown;
            }
            return(gelLayer);
        }
예제 #5
0
        public void ShowReFollowTrackDifinitionUi(double x, double y)  //H26 9/26 by GTR
        {
            MotorControler mc         = MotorControler.GetInstance(parameterManager);
            Vector3        initialpos = mc.GetPoint();

            Line[] lines = DrawCrossMark(x, y);
            // Grid markを定義する位置を確認するダイアログボックスを表示する
            //GridMarkDefinitionUtil util = new GridMarkDefinitionUtil(coordManager);
            //SelectGridMarkWindow sgWindow = new SelectGridMarkWindow();
            //sgWindow.GridMarkPoint = util.NextPoint;
            // ユーザーがGrid markを定義する位置を選択したならば,その箇所でGridf markを定義する.
            Camera  camera = Camera.GetInstance();
            Vector2 emulsionSystemPoint = coordManager.TransToEmulsionCoord((int)x, (int)y);
            //coordManager.SetGridMark(emulsionSystemPoint, sgWindow.GridMarkPoint, camera.ArrayImage);
            //WriteLine(string.Format(Properties.Strings.DefineGridMark,
            //          sgWindow.GridMarkPoint, emulsionSystemPoint.X, emulsionSystemPoint.Y));


            string       datarootdirpathw  = string.Format(@"C:\test");
            string       txtfileName_sh_up = datarootdirpathw + string.Format(@"\ReTrackFollowPosi.txt");
            StreamWriter twriter_sh_up     = File.CreateText(txtfileName_sh_up);

            twriter_sh_up.WriteLine("{0} {1} {2}", emulsionSystemPoint.X, emulsionSystemPoint.Y, initialpos.Z);
            twriter_sh_up.Close();

            // バツ印を消去
            emulsionViewerCanvas.Children.Remove(lines[0]);
            emulsionViewerCanvas.Children.Remove(lines[1]);
        }
예제 #6
0
        private void contextSpeed4_Selected(object sender, RoutedEventArgs e)
        {
            MotorControler mc = MotorControler.GetInstance(parameterManager);

            mc.SetMotorSpeed(parameterManager.MotorSpeed4.X, VectorId.X);
            mc.SetMotorSpeed(parameterManager.MotorSpeed4.Y, VectorId.Y);
        }
예제 #7
0
        //surfacercog not change!!
        private void surfrecog(int thre, double deltaz)
        {
            MotorControler mc     = MotorControler.GetInstance(parameterManager);
            Camera         camera = Camera.GetInstance();

            bool flag = true;

            while (flag)
            {
                mc.MoveDistance(deltaz, VectorId.Z);
                mc.Join();
                Thread.Sleep(100);

                byte[] b   = camera.ArrayImage;
                Mat    src = new Mat(440, 512, MatType.CV_8U, b);
                Mat    mat = src.Clone();

                Cv2.GaussianBlur(mat, mat, Cv.Size(3, 3), -1);
                Mat gau = mat.Clone();
                Cv2.GaussianBlur(gau, gau, Cv.Size(17, 17), -1);
                Cv2.Subtract(gau, mat, mat);
                Cv2.Threshold(mat, mat, 10, 1, ThresholdType.Binary);
                int brightness = Cv2.CountNonZero(mat);

                if (brightness > thre)
                {
                    flag = false;
                }
            }
        }
예제 #8
0
        private void task()
        {
            MotorControler mc = MotorControler.GetInstance(parameterManager);

            mc.MovePoint(X, Y, Z);
            mc.Join();
        }
예제 #9
0
        void MotorKeyHandler_Unloaded(object sender, System.Windows.RoutedEventArgs e)
        {
#if !_NoHardWare
            MotorControler mc = MotorControler.GetInstance(parameterManager);
            mc.AbortMoving();
            mc.SlowDownStopAll();
#endif
        }
예제 #10
0
        private void viewTimer_Ticked(object sender, EventArgs e)
        {
            MotorControler mc = MotorControler.GetInstance(parameterManager);
            Vector3        p  = mc.GetPoint();

            coordinateLabel.Content = string.Format("X:{0:0.00000}, Y:{1:0.00000}, Z:{2:0.0000}",
                                                    p.X, p.Y, p.Z);
        }
예제 #11
0
        private void task()
        {
            MotorControler mc      = MotorControler.GetInstance(parameterManager);
            Camera         camera  = Camera.GetInstance();
            TracksManager  tm      = parameterManager.TracksManager;
            Surface        surface = Surface.GetInstance(parameterManager);
            int            mod     = parameterManager.ModuleNo;
            int            pl      = parameterManager.PlateNo;
            bool           dubflag;
            Led            led_ = Led.GetInstance();

            for (int i = 0; i < tm.NumOfTracks; i++)
            {
                Track myTrack = tm.GetTrack(i);
                Console.WriteLine(myTrack.IdString);
                string[] sp1 = myTrack.IdString.Split('-');

                string       logtxt = string.Format(@"C:\MKS_test\WorkingTime\{0}\{1}-{2}_Trackingtime.txt", mod, mod, pl);
                SimpleLogger SL1    = new SimpleLogger(logtxt, sp1[0], sp1[1]);

                MessageBoxResult r;
                // Massage box to check tracking is ok or not, if OK is put, will go to track position.
                r = MessageBox.Show(
                    String.Format("Let's go to {0}; {1} {2}. OK->Go, Cancel->exit", myTrack.IdString, myTrack.MsX, myTrack.MsY),
                    Properties.Strings.LensTypeSetting,
                    MessageBoxButton.OKCancel);
                if (r == MessageBoxResult.Cancel)
                {
                    return;
                }

                // Go to the track position
                double dstx = myTrack.MsX;
                double dsty = myTrack.MsY;
                mc.MovePointXY(dstx, dsty, delegate {
                    stage.WriteLine(Properties.Strings.MovingComplete);
                });
                mc.Join();

                SL1.Info("Tracking Start");
                // Beampatternmatching
                BPMW(myTrack, mod, pl);
                SL1.Info("Tracking End");
                mc.Join();
                Thread.Sleep(100);

                // Massage box to cheack tracking is ok or not, it Ok is put, it will go to next track.
                r = MessageBox.Show(
                    "OK->Next, Cancel->exit",
                    Properties.Strings.LensTypeSetting,
                    MessageBoxButton.OKCancel);
                if (r == MessageBoxResult.Cancel)
                {
                    return;
                }
            }
        }
예제 #12
0
        private void gotrack(Track myTrack)
        {
            MotorControler mc   = MotorControler.GetInstance(parameterManager);
            double         dstx = myTrack.MsX + coordManager.HFDX;
            double         dsty = myTrack.MsY + coordManager.HFDY;

            mc.MovePointXY(dstx, dsty, delegate {
                stage.WriteLine(Properties.Strings.MovingComplete);
            });
        }
예제 #13
0
        private void parametersTimer_Tick(object sender, EventArgs e)
        {
            // モータの座標値を更新する
            MotorControler mc = MotorControler.GetInstance(parameterManager);
            Vector3        presentPosition = mc.GetPoint();

            drawPositionOnViewer(presentPosition);

            // モータ稼働中は速度の変更を禁止にする
            speedComboBox.IsEnabled = (!mc.IsMoving);
        }
예제 #14
0
        private void startButton_Click(object sender, RoutedEventArgs e)
        {
            if (!System.IO.Directory.Exists(destinationDir))
            {
                MessageBox.Show(Properties.Strings.DirNotFound);
                return;
            }
            if (fileNameTextBox.Background == Brushes.Pink)
            {
                MessageBox.Show(Properties.Strings.FileNameInvalid);
                return;
            }

            AccumImage accumImage = AccumImage.GetInstance(parameterManager);

            if (accumImage.IsActive)
            {
                MessageBoxResult r = MessageBox.Show(
                    Properties.Strings.ShootException01, Properties.Strings.Abort + "?",
                    MessageBoxButton.YesNo);
                if (r == MessageBoxResult.Yes)
                {
                    accumImage.Abort();
                }
                else
                {
                    return;
                }
            }

            try {
                accumImage.FilePath       = destinationDir;
                accumImage.FilenamePrefix = fileName;

                double         distance = double.Parse(distanceTextBox.Text);
                MotorControler mc       = MotorControler.GetInstance(parameterManager);
                accumImage.IntervalUm = double.Parse(intervalTextBox.Text);
                accumImage.StartPoint = mc.GetPoint().Z;
                accumImage.EndPoint   = accumImage.StartPoint
                                        + ((bool)minusRadioButton.IsChecked ? -distance : distance);

                progressPanel.Visibility = Visibility.Visible;
                progressBar.Minimum      = 0;
                progressBar.Maximum      = distance / accumImage.IntervalUm;

                accumImage.Start();
                abortButton.IsEnabled = true;
                ledGroupBox.IsEnabled = false;
                Properties.Settings.Default.ShootDistance = double.Parse(distanceTextBox.Text);
                Properties.Settings.Default.ShootInterval = accumImage.IntervalUm;
            } catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }
예제 #15
0
        /// <summary>
        /// アクティビティの動作スレッド用のメソッドです。
        /// 直接呼び出さないでください。
        /// </summary>
        private void task()
        {
            GridMark       nearestMark = getNearestGirdMark();
            MotorControler mc          = MotorControler.GetInstance(parameterManager);

            mc.MovePointXY(nearestMark.x, nearestMark.y);
            mc.Join();

            // 新たにグリッドーマークの座標を取得したら、
            // Ipt.setHyperFineXYにその座標と既知の座標(予測点)のズレ(エンコーダ座標系)を渡す
        }
예제 #16
0
        /// <summary>
        /// コンピュータ画面上のピクセル値の座標からエマルションの座標値に変換します.
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <returns>エマルションでの座標値</returns>
        public Vector2 TransToEmulsionCoord(int x, int y)
        {
            MotorControler mc            = MotorControler.GetInstance();
            int            emX           = ParameterManager.ImageResolution.Width;
            int            emY           = ParameterManager.ImageResolution.Height;
            Vector3        motorPosition = mc.GetPoint();
            Vector2        p             = new Vector2();

            p.X = motorPosition.X - (x - emX / 2) * parameterManager.CameraMainResolution;
            p.Y = motorPosition.Y + (y - emY / 2) * parameterManager.CameraSubResolution;
            return(p);
        }
예제 #17
0
        private void task()
        {
            MotorControler mc          = MotorControler.GetInstance(parameterManager);
            Vector3        CenterPoint = mc.GetPoint();

            string fileName = string.Format(@"c:\test\coordinate.txt");

            System.IO.StreamWriter sw = new System.IO.StreamWriter(fileName, true, System.Text.Encoding.GetEncoding("shift_jis"));
            string coordinate         = string.Format("{0} {1} {2}\n", CenterPoint.X, CenterPoint.Y, CenterPoint.Z);

            sw.Write(coordinate);
            sw.Close();
        }
예제 #18
0
        private void task()
        {
            // レンズが50倍に設定されていない場合は例外を返すようにしたいがやり方が分からん(20140724)

            //現在地からスパイラルサーチ30視野でグリッドマークを検出する
            //検出したら視野の真ん中に持ってくる
            try
            {
                MotorControler      mc = MotorControler.GetInstance(parameterManager);
                IGridMarkRecognizer GridMarkRecognizer = coordManager;
                mc.SetSpiralCenterPoint();
                Led     led          = Led.GetInstance();
                Vector2 encoderPoint = new Vector2(-1, -1);
                encoderPoint.X = mc.GetPoint().X;
                encoderPoint.Y = mc.GetPoint().Y;//おこられたのでしかたなくこうする 吉田20150427
                Vector2 viewerPoint = new Vector2(-1, -1);

                bool continueFlag = true;
                while (continueFlag)
                {
                    led.AdjustLight(parameterManager);
                    viewerPoint = GridMarkRecognizer.SearchGridMarkx50();
                    if (viewerPoint.X < 0 || viewerPoint.Y < 0)
                    {
                        System.Diagnostics.Debug.WriteLine(String.Format("grid mark not found"));
                        mc.MoveInSpiral(true);
                        mc.Join();
                        continueFlag = (mc.SpiralIndex < 30);
                    }
                    else
                    {
                        System.Diagnostics.Debug.WriteLine(String.Format("******** {0}  {1}", viewerPoint.X, viewerPoint.Y));
                        encoderPoint = coordManager.TransToEmulsionCoord(viewerPoint);
                        mc.MovePointXY(encoderPoint);
                        mc.Join();
                        continueFlag = false;
                    }
                } // while

                mc.MovePointXY(encoderPoint);
                mc.Join();
                viewerPoint  = GridMarkRecognizer.SearchGridMarkx50();
                encoderPoint = coordManager.TransToEmulsionCoord(viewerPoint);
                mc.MovePointXY(encoderPoint);
                mc.Join();
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("exception");
            }
        }
예제 #19
0
        private void surfacerecog()
        {
            Surface        surface = Surface.GetInstance(parameterManager);
            MotorControler mc      = MotorControler.GetInstance(parameterManager);

            /*
             *          string[] sp = myTrack.IdString.Split('-');
             *
             *          //string datfileName = string.Format("{0}.dat", System.DateTime.Now.ToString("yyyyMMdd_HHmmss"));
             *          string datfileName = string.Format(@"c:\test\bpm\{0}\{1}-{2}-{3}-{4}-{5}.dat", mod, mod, pl, sp[0], sp[1], System.DateTime.Now.ToString("ddHHmmss"));
             *          BinaryWriter writer = new BinaryWriter(File.Open(datfileName, FileMode.Create));
             */

            try
            {
                if (mc.IsMoving)
                {
                    MessageBoxResult r = MessageBox.Show(
                        Properties.Strings.SurfaceException01,
                        Properties.Strings.Abort + "?",
                        MessageBoxButton.YesNo);
                    if (r == MessageBoxResult.Yes)
                    {
                        mc.AbortMoving();
                    }
                    else
                    {
                        return;
                    }
                }
                mc.Join();

                //Surface surface = Surface.GetInstance(parameterManager);

                try
                {
                    surface.Start(true);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, Properties.Strings.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Properties.Strings.Error);
            }
            mc.Join();
        }
예제 #20
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        /// <param name="mainWindow">親コントロール</param>
        public Stage(IMainWindow mainWindow)
            : base(mainWindow)
        {
            this.window           = mainWindow;
            this.parameterManager = window.ParameterManager;
            this.coordManager     = window.CoordManager;
            InitializeComponent();

            this.KeyDown += KeyHandleStageControl_KeyDown_1;

            this.parameterManager.PlateChanged        += emulsionNumber_Changed;
            this.parameterManager.ModuleChanged       += emulsionNumber_Changed;
            this.parameterManager.EmulsionTypeChanged += emulsionType_Changed;
            this.parameterManager.LensTypeChanged     += lensType_Changed;
            this.window.RibbonTabSelected             += windowRibbonTab_Selected;
            MotorControler mc = MotorControler.GetInstance(parameterManager);

            mc.SpiralMoved += spiralMoved_Completed;

            this.parametersTimer          = new DispatcherTimer(DispatcherPriority.Normal);
            this.parametersTimer.Interval = new TimeSpan(ParameterManager.ParamtersIntervalMilliSec * 1000);
            this.parametersTimer.Tick    += parametersTimer_Tick;
            this.messages = new MessageList();
            this.messages.CallbackOfAdd = delegate(string latestStr) {
                Dispatcher.BeginInvoke(new Action(delegate() {
                    string wrapCode  = System.Environment.NewLine;
                    infoTextBox.Text = latestStr + wrapCode + infoTextBox.Text;
                }), null);
            };
            this.emulsionViewerCanvas.MouseDown += delegate(object sender, MouseButtonEventArgs e) {
                if (viewMouseDownAction != null)
                {
                    viewMouseDownAction(sender, e);
                }
            };

            parametersTimer.Start();
#if !NoHardware
            Led led = Led.GetInstance();
            led.SetDcPower(0);
            led.OnPulse();
#endif
            this.Focus();

            //ActivityManager manager = ActivityManager.GetInstance(parameterManager);
            //TigerScan scan = new TigerScan(parameterManager);
            //manager.Enqueue(scan);
            //manager.Start();
        }
예제 #21
0
        public List <Thread> CreateTask()
        {
            List <Thread> taskList = new List <Thread>();

            taskList.Add(Create(new ThreadStart(delegate {
                try {
                    task();
                } catch (ThreadAbortException ex) {
                } finally {
                    MotorControler mc = MotorControler.GetInstance();
                    mc.AbortMoving();
                    mc.SlowDownStopAll();
                }
            })));
            return(taskList);
        }
예제 #22
0
        }//BeamDetection

        private void BPMW(Track myTrack, int mod, int pl)
        {
            MotorControler mc = MotorControler.GetInstance(parameterManager);

            try
            {
                string datarootdirpath        = string.Format(@"C:\MKS_test\bpm\{0}-{1}", mod, pl);
                System.IO.DirectoryInfo mydir = System.IO.Directory.CreateDirectory(datarootdirpath);
                string[] sp = myTrack.IdString.Split('-');

                string       logtxt = string.Format(@"C:\MKS_test\WorkingTime\{0}\{1}-{2}_BPMW.txt", mod, mod, pl);
                SimpleLogger SL1    = new SimpleLogger(logtxt, sp[0], sp[1]);

                string uptxt = string.Format(@"c:\MKS_test\bpm\{0}-{1}\{2}-{3}-{4}-{5}_up.txt", mod, pl, mod, pl, sp[0], sp[1]);
                string dwtxt = string.Format(@"c:\MKS_test\bpm\{0}-{1}\{2}-{3}-{4}-{5}_dw.txt", mod, pl - 1, mod, pl - 1, sp[0], sp[1]);
                BeamDetection(uptxt, true);

                BeamPatternMatch bpm = new BeamPatternMatch(8, 200);
                bpm.ReadTrackDataTxtFile(dwtxt, false);

                bpm.ReadTrackDataTxtFile(uptxt, true);

                SL1.Info("Tracking Start");

                bpm.DoPatternMatch();
                SL1.Info("Tracking end");

                stage.WriteLine(String.Format("pattern match dx,dy = {0}, {1}", bpm.GetPeakX() * 0.2625 * 0.001, bpm.GetPeakY() * 0.2625 * 0.001));
                Vector3 BfPoint = mc.GetPoint();
                mc.MoveDistance(bpm.GetPeakX() * 0.2625 * 0.001, VectorId.X);
                mc.Join();
                mc.MoveDistance(-bpm.GetPeakY() * 0.2625 * 0.001, VectorId.Y);
                mc.Join();
                Led led = Led.GetInstance();
                led.AdjustLight(parameterManager);
                Vector3 AfPoint = mc.GetPoint();
                stage.WriteLine(String.Format("Move dx,dy = {0}, {1}", BfPoint.X - AfPoint.X, BfPoint.Y - AfPoint.Y));
            }
            catch (ArgumentOutOfRangeException)
            {
                MessageBox.Show("ID numver is not existed。 ");
            }
            catch (System.Exception)
            {
                MessageBox.Show("No beam battern。 ");
            }
        }
예제 #23
0
        private void GoTopUp()
        {
            MotorControler mc      = MotorControler.GetInstance(parameterManager);
            Surface        surface = Surface.GetInstance(parameterManager);

            try
            {
                Vector3 cc = mc.GetPoint();
                double  Zp = surface.UpTop + 0.015;
                mc.MoveTo(new Vector3(cc.X, cc.Y, Zp));
                mc.Join();
            }
            catch (ArgumentOutOfRangeException)
            {
                MessageBox.Show("Cannot move to top surface of upperlayer ");
            }
        }
예제 #24
0
 private Surface(ParameterManager _parameterManager)
     : base(_parameterManager)
 {
     if (_parameterManager == null)
     {
         throw new ArgumentNullException();
     }
     this.parameterManager = _parameterManager;
     initializeSurfaces();
     Exited += delegate(object sender, ActivityEventArgs e) {
         MotorControler mc = MotorControler.GetInstance(parameterManager);
         mc.SetMotorSpeed(
             speedBeforeStart.X,
             speedBeforeStart.Y,
             speedBeforeStart.Z);
     };
 }
예제 #25
0
        public List <Thread> CreateTask()
        {
            List <Thread> taskList = new List <Thread>();

            taskList.Add(Create(new ThreadStart(delegate {
                try {
                    task();
                } catch (ThreadAbortException ex) {
                } finally {
                    MotorControler mc = MotorControler.GetInstance();
                    mc.AbortMoving();
                    mc.SlowDownStopAll();
                }
            })));
            //SurfaceLanding sl = new SurfaceLanding(parameterManager);
            //taskList.AddRange(sl.CreateTask());
            return(taskList);
        }
예제 #26
0
            /// <summary>
            /// 撮影終了地点に到着してるかどうかを判定します.
            /// </summary>
            /// <param name="direction">移動方向</param>
            /// <returns>true:到着してる, false:到着していない</returns>
            private bool isOnEndPoint(PlusMinus direction)
            {
                bool           flag  = false;
                MotorControler mc    = MotorControler.GetInstance(parameterManager);
                double         point = mc.GetPoint().Z;

                switch (direction)
                {
                case PlusMinus.Plus:
                    flag = (startPoint <= endPoint);
                    break;

                case PlusMinus.Minus:
                    flag = (startPoint >= endPoint);
                    break;
                }
                return(flag);
            }
예제 #27
0
        void KeyHandleWorkspace_KeyUp(object sender, System.Windows.Input.KeyEventArgs e)
        {
            // モータの移動処理を停止する.
            MotorControler mc = MotorControler.GetInstance(parameterManager);

            if (e.Key == Key.A || e.Key == Key.D)
            {
                mc.SlowDownStop(VectorId.X);
            }
            if (e.Key == Key.W || e.Key == Key.X)
            {
                mc.SlowDownStop(VectorId.Y);
            }
            if (e.Key == Key.Q || e.Key == Key.E)
            {
                mc.SlowDownStop(VectorId.Z);
            }
        }
예제 #28
0
        private void task()
        {
            isActive = true;
            MotorControler mc     = MotorControler.GetInstance(parameterManager);
            Camera         camera = Camera.GetInstance();

            imagesUri = new List <string>();
            for (int i = 0; i < photographySpotList.Count; ++i)
            {
                mc.MovePoint(photographySpotList[i]);
                mc.Join();
                camera.Stop();
                BitmapSource image = camera.Image;
                saveTemp(image);
                camera.Start();
            }
            isActive = false;
        }
예제 #29
0
        private void task()
        {
            MotorControler mc      = MotorControler.GetInstance(parameterManager);
            Camera         camera  = Camera.GetInstance();
            TracksManager  tm      = parameterManager.TracksManager;
            Track          myTrack = tm.GetTrack(tm.TrackingIndex);
            Surface        surface = Surface.GetInstance(parameterManager);
            int            mod     = parameterManager.ModuleNo;
            int            pl      = parameterManager.PlateNo;
            bool           dubflag;
            Led            led_ = Led.GetInstance();

            BeamFollower(myTrack, mod, pl, false);


            GoTopUp();
            mc.Join();
            Thread.Sleep(100);
        }
예제 #30
0
            private void nextTrackButton_Click(object sender, RoutedEventArgs e)
            {
                if (!parameterManager.TracksManager.IsInitialized)
                {
                    MessageBox.Show(Properties.Strings.TracksManagerException01);
                    return;
                }

                TracksManager tracksManager = parameterManager.TracksManager;

                if (tracksManager.TrackingIndex + 1 >= tracksManager.NumOfTracks)
                {
                    MessageBox.Show(Properties.Strings.TrackFoundComplete);
                    return;
                }
                tracksManager.UpdateTrack();
                UpdateTrackInfo();

                MotorControler mc = MotorControler.GetInstance();

                if (mc.IsMoving)
                {
                    if (askAbortMotorMoving())
                    {
                        mc.AbortMoving();
                        stage.WriteLine(Properties.Strings.AbortMotor);
                    }
                    else
                    {
                        return;
                    }
                }
                Track track = tracksManager.Track;

                stage.WriteLine(Properties.Strings.Moving);
#if !NoHardware
                mc.MovePointXY(track.MsX, track.MsX, delegate {
                    stage.WriteLine(Properties.Strings.MovingComplete);
                });
#endif
                tracksItem[tracksManager.TrackingIndex].FontWeight = FontWeights.Bold;
            }