コード例 #1
0
        static void Main()
        {
            // This creates a form that prompts the user to select a directory
            //ASEN.ExperimentDialog formTest = new ASEN.ExperimentDialog();
            //Application.Run(formTest);

            ASEN_MotorControl motorTest = new ASEN_MotorControl("27501994", 3200);

            motorTest.InitializeMotor();
            motorTest.HomeMotor();
            motorTest.MoveMotorLinear(1);
            motorTest.DisconnectMotor();
        }
コード例 #2
0
        public void RunState()
        {
            // Want to create the filenames sans-extensions
            string RCWSForePath = this.RCWSPath + "\\img_RCWS_fore";
            string RCWSAftPath  = this.RCWSPath + "\\img_RCWS_aft";

            // Motor Control Setup
            this.motor1 = new ASEN_MotorControl(serials[0], this.velocity);
            this.motor2 = new ASEN_MotorControl(serials[1], this.velocity);
            this.motor3 = new ASEN_MotorControl(serials[2], this.velocity);

            // Initializing the motors
            motor1.InitializeMotor();
            motor2.InitializeMotor();
            motor3.InitializeMotor();

            // Initializing the process info for the python process to run for the Env Sensors
            Py                        = new ProcessStartInfo();                                      // Initializing the process start info
            Py.FileName               = pyPath;                                                      // Path to the python exe
            Py.Arguments              = "SerialReader.py" + " " + this.path + " " + this.teensyPort; // The .py script to run and its arguments
            Py.UseShellExecute        = false;                                                       // Do not use OS shell
            Py.CreateNoWindow         = true;                                                        // We don't need new window
            Py.RedirectStandardOutput = true;                                                        // Redirecting output from the python stdout
            Py.RedirectStandardInput  = true;                                                        // Redirecting input from the python stdin
            Py.RedirectStandardOutput = true;                                                        // Any output, generated by application will be redirected back
            Py.RedirectStandardError  = true;                                                        // Any error in standard output will be redirected back (for example exceptions)

            // Initial homing of the motors
            var  list    = new List <Task>();
            Task homing1 = Task.Factory.StartNew(() => motor1.HomeMotor());

            list.Add(homing1);
            if (prevMY != MA_Y)
            {
                Task homing2 = Task.Factory.StartNew(() => motor2.HomeMotor());
                list.Add(homing2);
            }
            if (prevMX != MA_X)
            {
                Task homing3 = Task.Factory.StartNew(() => motor3.HomeMotor());
                list.Add(homing3);
            }

            Task.WaitAll(list.ToArray());

            // Now we move the motors to their initial position.
            // This means the tilt-tip stage is moved to its proper position, while the linear
            // stage is moved to the RCWS's specified fore defocus position
            var  moveList = new List <Task>();
            Task moving1  = Task.Factory.StartNew(() => motor1.MoveMotorLinear(RCWS_DFORE));

            moveList.Add(moving1);
            if (prevMY != MA_Y)
            {
                Task moving2 = Task.Factory.StartNew(() => motor2.MoveMotorPitch(MA_Y));
                moveList.Add(moving2);
            }
            if (prevMX != MA_X)
            {
                Task moving3 = Task.Factory.StartNew(() => motor3.MoveMotorYaw(MA_X));
                moveList.Add(moving3);
            }

            Task.WaitAll(moveList.ToArray());
            // ASEN_SHA Initializing Device
            currentSHA = new ASEN_SHA((short)gain);
            currentSHA.CameraConnectionAndSetup(SHA_EXPT);

            ASICamera(RCWSForePath, RCWSAftPath);

            currentSHA.CloseCamera();
            motor1.DisconnectMotor();
            motor2.DisconnectMotor();
            motor3.DisconnectMotor();
        }