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();
        }
        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();
        }
        public void RunState()
        {
            // Here's where we call the other methods

            // ASEN_SHA



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

            Dictionary <string, string> SettingValues = new Dictionary <string, string>();



            MotorConfiguration motorConfig = new MotorConfiguration(serials[0]);

            motorConfig = motor1.GetMotorConfiguration(serials[0], 1);



            // Initializing each motor one-by-one
            motor1.InitializeMotor();
            //motor2.InitializeMotor();
            //motor3.InitializeMotor();

            // Homing the motors first
            motor1.HomeMotor();
            //motor2.HomeMotor();
            //motor3.HomeMotor();

            // Now we move to whatever positon we desire
            motor1.MoveMotor(RCWS_DFORE);
            //motor2.MoveMotor(MA_X);
            //motor3.MoveMotor(MA_Y);



            // ASEN_RCWS Initializing Camera
            this.currentRCWS = new ASEN_RCWS(cameraInUse);
            currentRCWS.InitializeCamera();


            /*
             * // ASEN_SHA Initializing Device
             * this.currentSHA = new ASEN_SHA();
             * currentSHA.CameraConnectionAndSetup();
             *
             *
             *
             * // ASEN_Environmental
             * this.teensy = new ASEN_ENV(this.teensyPort, path);
             * this.READ = true;
             *
             *
             *
             * Task teensyRead = Task.Factory.StartNew(() => TeensyParallel(ref this.teensyLock));
             * Task imageRead = Task.Factory.StartNew(() => ImagingParallel());
             *
             * Task.WaitAll(imageRead);
             *
             * // After the image is done reading, we have to set READ to false.
             * // Note that we have to block access to this variable as it is also shared by teensy read
             * lock (this.teensyLock)
             * {
             *  this.READ = false;
             * }
             *
             * Task.WaitAll(teensyRead);
             *
             * currentRCWS.Disconnect();
             * //currentSHA.CloseCamera();
             */
        }