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
        // Process with methods to be called when using the ASI camera
        private void ASICamera(string foreFile, string aftFile)
        {
            // Name of the ASCOM driver for the ASI
            cameraInUse = "ASCOM.ASICamera2.Camera";
            ASEN_RCWS currCamera = new ASEN_RCWS(cameraInUse);

            currCamera.InitializeCamera();

            // Starting the environmental sensors process
            var envProcess = Process.Start(this.Py);

            // Take a capture of the image at the fore distance
            currCamera.Capture(RCWS_EXPT, true);
            currCamera.SaveImage(foreFile + ".csv");

            // Taking a caputre with the SHA at the fore distance
            byte[]  spotFieldFore = currentSHA.GatherCameraData(SHA_EXPT, SHAPath + "\\img_fore.csv");
            float[] zernikesFore  = currentSHA.ProcessCameraData(SHAPath + "\\wft_fore.csv", SHAPath + "\\spt_fore", SHAPath + "\\zernikes_fore.csv");

            // Moving the RCWS motor to the aft location
            motor1.MoveMotorLinear(RCWS_DAFT);

            // Taking a capture of the image at the aft distance
            currCamera.Capture(RCWS_EXPT, true);
            currCamera.SaveImage(aftFile + ".csv");

            // Taking a capture with the SHA at the aft distance
            byte[]  spotFieldAft = currentSHA.GatherCameraData(SHA_EXPT, SHAPath + "\\img_aft.csv");
            float[] zernikesAft  = currentSHA.ProcessCameraData(SHAPath + "\\wft_aft.csv", SHAPath + "\\spt_aft", SHAPath + "\\zernikes_aft.csv");


            // Ending the env. sensors process
            envProcess.StandardInput.Close();

            // Disconnecting from the ASI
            currCamera.Disconnect();
        }
        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();
        }