Example #1
0
        public void Run(Dictionary <String, Object> dict)
        {
            Stopwatch       watch  = new Stopwatch();
            MOTMasterScript script = prepareScript(scriptPath, dict);

            if (script != null)
            {
                MOTMasterSequence sequence = getSequenceFromScript(script);

                try
                {
                    prepareCameraControl();

                    armTranslationStageForTimedMotion(script);

                    GrabImage((int)script.Parameters["NumberOfFrames"]);

                    buildPattern(sequence, (int)script.Parameters["PatternLength"]);

                    waitUntilCameraIsReadyForAcquisition();

                    watch.Start();
                    runPattern(sequence);
                    watch.Stop();
                    //MessageBox.Show(watch.ElapsedMilliseconds.ToString());
                    if (saveEnable)
                    {
                        waitUntilCameraAquisitionIsDone();
                        try
                        {
                            checkDataArrived();
                        }
                        catch (DataNotArrivedFromHardwareControllerException)
                        {
                            return;
                        }
                        Dictionary <String, Object> report = GetExperimentReport();
                        save(script, scriptPath, imageData, report);
                    }
                    finishCameraControl();
                    disarmAndReturnTranslationStage();
                }
                catch (System.Net.Sockets.SocketException e)
                {
                    MessageBox.Show("CameraControllable not found. \n Is there a hardware controller running? \n \n" + e.Message, "Remoting Error");
                }
            }
            else
            {
                MessageBox.Show("Unable to load pattern. \n Check that the script file exists and that it compiled successfully");
            }
        }
Example #2
0
 private void armTranslationStageForTimedMotion(MOTMasterScript script)
 {
     tstage.TSConnect();
     Thread.Sleep(50);
     tstage.TSInitialize((double)script.Parameters["TSAcceleration"], (double)script.Parameters["TSDeceleration"],
                         (double)script.Parameters["TSDistance"], (double)script.Parameters["TSVelocity"]);
     Thread.Sleep(50);
     tstage.TSOn();
     Thread.Sleep(50);
     tstage.TSAutoTriggerDisable();
     Thread.Sleep(50);
     tstage.TSGo();
 }
Example #3
0
 private void save(MOTMasterScript script, string pathToPattern, byte[][,] imageData, Dictionary<String, Object> report)
 {
     ioHelper.StoreRun(motMasterDataPath, controllerWindow.GetSaveBatchNumber(), pathToPattern, hardwareClassPath,
         script.Parameters, report, cameraAttributesPath, imageData);
 }
Example #4
0
 private MOTMasterSequence getSequenceFromScript(MOTMasterScript script)
 {
     MOTMasterSequence sequence = script.GetSequence();
     return sequence;
 }
Example #5
0
 private void armTranslationStageForTimedMotion(MOTMasterScript script)
 {
     tstage.TSConnect();
     Thread.Sleep(50);
     tstage.TSInitialize((double)script.Parameters["TSAcceleration"], (double)script.Parameters["TSDeceleration"],
         (double)script.Parameters["TSDistance"], (double)script.Parameters["TSVelocity"]);
     Thread.Sleep(50);
     tstage.TSOn();
     Thread.Sleep(50);
     tstage.TSAutoTriggerDisable();
     Thread.Sleep(50);
     tstage.TSGo();
 }
Example #6
0
        private MOTMasterSequence getSequenceFromScript(MOTMasterScript script)
        {
            MOTMasterSequence sequence = script.GetSequence();

            return(sequence);
        }
Example #7
0
 private void save(MOTMasterScript script, string pathToPattern, ushort[][,] imageData, double[,] dividedImage, double[] columnSum, double[] rowSum, Dictionary <String, Object> report)
 {
     ioHelper.StoreRun(motMasterDataPath, controllerWindow.GetSaveBatchNumber(), pathToPattern, hardwareClassPath,
                       script.Parameters, report, cameraAttributesPath, imageData, absImage, columnSum, rowSum);
 }
Example #8
0
 private void save(MOTMasterScript script, string pathToPattern, ushort[,] imageData, Dictionary <String, Object> report)
 {
     ioHelper.StoreRun(motMasterDataPath, controllerWindow.GetSaveBatchNumber(), pathToPattern, hardwareClassPath,
                       script.Parameters, report, cameraAttributesPath, imageData);
 }
Example #9
0
        public void Run(Dictionary <String, Object> dict)
        {
            Stopwatch       watch  = new Stopwatch();
            MOTMasterScript script = prepareScript(scriptPath, dict);

            if (script != null)
            {
                MOTMasterSequence sequence = getSequenceFromScript(script);

                try
                {
                    prepareCameraControl();
                    Console.WriteLine("prepared Camera Control");
                    armTranslationStageForTimedMotion(script);

                    GrabImage((int)script.Parameters["NumberOfFrames"]);
                    Console.WriteLine("'grabbed image'");
                    buildPattern(sequence, (int)script.Parameters["PatternLength"]);
                    Console.WriteLine("built pattern");
                    waitUntilCameraIsReadyForAcquisition();

                    watch.Start();
                    Console.WriteLine("watch started");
                    runPattern(sequence);
                    Console.WriteLine("sequence finished");
                    watch.Stop();
                    Console.WriteLine("watch stopped");
                    //MessageBox.Show(watch.ElapsedMilliseconds.ToString());
                    if (saveEnable)
                    {
                        Console.WriteLine("waiting for camera acquisition to finish");

                        waitUntilCameraAquisitionIsDone();
                        Console.WriteLine("waited for camera acquisition to finish");
                        try
                        {
                            checkDataArrived();
                        }
                        catch (DataNotArrivedFromHardwareControllerException)
                        {
                            Console.WriteLine("Data not arrived from hardware controller");
                            return;
                        }
                        int[] ROIforImageProcessing = { (int)script.Parameters["ROIforImageProcessingx1"], (int)script.Parameters["ROIforImageProcessingx2"], (int)script.Parameters["ROIforImageProcessingy1"], (int)script.Parameters["ROIforImageProcessingy2"] };
                        processImages(ROIforImageProcessing);
                        Console.WriteLine("processed images");
                        Dictionary <String, Object> report = GetExperimentReport();
                        Console.WriteLine("got experiment report");
                        if (absImage == null)
                        {
                            save(script, scriptPath, imageData, report);
                        }
                        else
                        {
                            save(script, scriptPath, imageData, absImage, columnSum, rowSum, report);
                        }
                        Console.WriteLine("saved images");
                    }
                    else
                    {
                        Console.WriteLine("waiting for camera acquisition to finish");

                        waitUntilCameraAquisitionIsDone();
                        Console.WriteLine("waited for camera acquisition to finish");
                    }

                    finishCameraControl();
                    Console.WriteLine("finished camera control");
                    disarmAndReturnTranslationStage();
                }
                catch (System.Net.Sockets.SocketException e)
                {
                    MessageBox.Show("CameraControllable not found. \n Is there a hardware controller running? \n \n" + e.Message, "Remoting Error");
                }
            }
            else
            {
                MessageBox.Show("Unable to load pattern. \n Check that the script file exists and that it compiled successfully");
            }
        }
Example #10
0
 private void save(MOTMasterScript script, string pathToPattern, Dictionary<String, Object> report)
 {
     ioHelper.StoreRun(motMasterDataPath, controllerWindow.GetSaveBatchNumber(), pathToPattern, hardwareClassPath,
         script.Parameters, report, config.ExternalFilePattern);
 }
Example #11
0
 private void save(MOTMasterScript script, string pathToPattern, Dictionary <String, Object> report)
 {
     ioHelper.StoreRun(motMasterDataPath, controllerWindow.GetSaveBatchNumber(), pathToPattern, hardwareClassPath,
                       script.Parameters, report, config.ExternalFilePattern);
 }
Example #12
0
        public void Go(Dictionary <String, Object> dict)
        {
            status = RunningState.running;
            Stopwatch       watch  = new Stopwatch();
            MOTMasterScript script = prepareScript(scriptPath, dict);

            if (script != null)
            {
                MOTMasterSequence sequence = getSequenceFromScript(script);

                try
                {
                    if (config.CameraUsed)
                    {
                        prepareCameraControl();
                    }

                    if (config.TranslationStageUsed)
                    {
                        armTranslationStageForTimedMotion(script);
                    }

                    if (config.CameraUsed)
                    {
                        GrabImage((int)script.Parameters["NumberOfFrames"]);
                    }

                    buildPattern(sequence, (int)script.Parameters["PatternLength"]);

                    if (config.CameraUsed)
                    {
                        waitUntilCameraIsReadyForAcquisition();
                    }

                    watch.Start();

                    if (controllerWindow.RunUntilStoppedState)
                    {
                        while (status == RunningState.running)
                        {
                            if (!config.Debug)
                            {
                                runPattern(sequence);
                            }
                        }
                    }
                    else
                    {
                        for (int i = 0; i < controllerWindow.GetIterations() && status == RunningState.running; i++)
                        {
                            if (!config.Debug)
                            {
                                runPattern(sequence);
                            }
                        }
                    }

                    if (!config.Debug)
                    {
                        clearDigitalPattern(sequence);
                    }


                    watch.Stop();
                    //MessageBox.Show(watch.ElapsedMilliseconds.ToString());
                    if (saveEnable)
                    {
                        if (config.CameraUsed)
                        {
                            waitUntilCameraAquisitionIsDone();
                            try
                            {
                                checkDataArrived();
                            }
                            catch (DataNotArrivedFromHardwareControllerException)
                            {
                                return;
                            }
                            Dictionary <String, Object> report = null;
                            if (config.ReporterUsed)
                            {
                                report = GetExperimentReport();
                            }

                            save(script, scriptPath, imageData, report);
                        }
                        else
                        {
                            Dictionary <String, Object> report = null;
                            if (config.ReporterUsed)
                            {
                                report = GetExperimentReport();
                            }

                            save(script, scriptPath, report);
                        }
                    }
                    if (config.CameraUsed)
                    {
                        finishCameraControl();
                    }
                    if (config.TranslationStageUsed)
                    {
                        disarmAndReturnTranslationStage();
                    }
                }
                catch (System.Net.Sockets.SocketException e)
                {
                    MessageBox.Show("CameraControllable not found. \n Is there a hardware controller running? \n \n" + e.Message, "Remoting Error");
                }
            }
            else
            {
                MessageBox.Show("Unable to load pattern. \n Check that the script file exists and that it compiled successfully");
            }
            status = RunningState.stopped;
        }
Example #13
0
 // ONGOING: these save functions should probably take a sequence argument
 private void save(MOTMasterSequence sequence, MOTMasterScript script, string pathToPattern, byte[][,] imageData, Dictionary <String, Object> report)
 {
     ioHelper.StoreRun(motMasterDataPath, controllerWindow.GetSaveBatchNumber(), pathToPattern, hardwareClassPath,
                       sequence, script.Parameters, report, cameraAttributesPath, imageData, externalFilesPath, config.ExternalFilePattern);
 }