Ejemplo n.º 1
0
        private void cbxInput_Click(object sender, EventArgs e)
        {
            // Populate the list:
            this.SuspendLayout();

            //string zFilter = "*" + Properties.Settings.Default.TomoDataFormatExtension;
            //string[] fileEntries = Directory.GetFiles(Properties.Settings.Default.SYRMEP_HPC_MappedInputPath, zFilter, SearchOption.TopDirectoryOnly);


            string zResult = SYRMEP_HPC.Execute("ls " + Properties.Settings.Default.SYRMEP_HPC_InputPath + "/*" + Properties.Settings.Default.TomoDataFormatExtension);

            string[] fileEntries = zResult.Split('\n');
            fileEntries = fileEntries.Take(fileEntries.Length - 1).ToArray();

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

            if (fileEntries.Length == 0)
            {
                zDict.Add("<none>", "<none>");
            }
            else
            {
                foreach (string fileName in fileEntries)
                {
                    zDict.Add(fileName, Path.GetFileName(fileName));
                }
            }

            cbxInput.DataSource    = new BindingSource(zDict, null);
            cbxInput.DisplayMember = "Value";
            cbxInput.ValueMember   = "Key";

            this.ResumeLayout();
        }
Ejemplo n.º 2
0
        private void runRemoteReconstruction(object sender, EventArgs e)
        {
            // Run Job Convert To TDF:
            IJob zJob;

            mPreProcessOnGoing     = false;
            mPhaseRetrievalOnGoing = false;


            string zFileName = Path.GetFileName(mInputTDF);

            zFileName = zFileName.Remove(zFileName.Length - 4) + "_corr_phrt.tdf";

            string zString   = string.Empty;
            string pythoncmd = (string.IsNullOrEmpty(Properties.Settings.Default.SYRMEP_HPC_PythonPath)) ? "python " : Properties.Settings.Default.SYRMEP_HPC_PythonPath + "/python ";

            // Unix-like command line:
            zString = pythoncmd + Properties.Settings.Default.SYRMEP_HPC_SourcePath + '/' + Properties.Settings.Default.GetTDFDimensionJob + " " + mInputTDF;
            string zResult = SYRMEP_HPC.Execute(zString);

            string[] zLines       = zResult.Split('\n');
            int      zProjections = Int32.Parse((zLines[0].Split(' '))[1]);
            int      zSlices      = Int32.Parse((zLines[1].Split(' '))[1]);


            int zTo = zSlices - 1;

            int zThreads = Convert.ToInt32(Properties.Settings.Default.SYRMEP_HPC_Processes);

            // Unix-style:
            string zOutputPath = Properties.Settings.Default.SYRMEP_HPC_OutputPath + '/' + Path.GetFileNameWithoutExtension(mInputTDF) + '/' + @"slices" + '/';

            if (mAngles_ProjTo == 0)
            {
                mAngles_ProjTo = zProjections - 1;
            }



            // Create an instance for the reconstruction job:
            zJob = new RemoteReconstructionJob(
                zFileName,
                zOutputPath,
                false,
                mAirSx,
                mAirDx,
                mFlatEnd,
                mHalfHalf,
                mHalfHalfLine,
                mExtFOV,
                mExtFOVRight,
                mExtFOVOverlap,
                mExtFOVNormalize,
                mExtFOVAverage,
                mRingRemoval,

                mAngles,
                mAngles_ProjFrom,
                mAngles_ProjTo,
                mCenter,
                mReconFunc,
                mReconParam1,
                mScale,
                mOverPaddding,
                mLogTransform,
                mCircle,
                mZeroneMode,
                mCorrectionOffset,
                0,
                zTo,
                zThreads,
                mDecimateFactor,
                mDownscaleFactor,

                mPostProcess,
                mPostProcessPolarFilt,
                mPostProcessConvertArgs,
                mPostProcessCropArgs,
                mDynamicFlatFielding,

                mRolling,
                mRollShift
                );


            // Create an instance of JobExecuter with the pre processing job:
            IJobExecuter zExecuter = new RemoteJobExecuter(zJob);

            // Execute the job splitting it with several processes (if specified):
            zExecuter.Run();

            // Start the monitoring of the job:
            mJobMonitor.Run(zExecuter, "slice");

            this.mReconstructionOnGoing = true;

            // Reset status bar:
            this.toolStripStatusLabel1.Text = string.Empty;
        }
Ejemplo n.º 3
0
        private void runRemotePhaseRetrieval(object sender, EventArgs e)
        {
            // Run Job Convert To TDF:
            IJob zJob;

            // Execute with conventional flat fielding:
            mPreProcessOnGoing     = false;
            mReconstructionOnGoing = false;


            string zFileName = Path.GetFileName(mInputTDF);

            zFileName = zFileName.Remove(zFileName.Length - 4) + "_corr.tdf";



            string zString   = string.Empty;
            string pythoncmd = (string.IsNullOrEmpty(Properties.Settings.Default.SYRMEP_HPC_PythonPath)) ? "python " : Properties.Settings.Default.SYRMEP_HPC_PythonPath + "/python ";

            // Unix-like command line:
            zString = pythoncmd + Properties.Settings.Default.SYRMEP_HPC_SourcePath + '/' + Properties.Settings.Default.GetTDFDimensionJob + " " + mInputTDF;
            string zResult = SYRMEP_HPC.Execute(zString);

            string[] zLines       = zResult.Split('\n');
            int      zProjections = Int32.Parse((zLines[0].Split(' '))[1]);
            int      zSlices      = Int32.Parse((zLines[1].Split(' '))[1]);


            int zTo = zProjections - 1;

            int zThreads = Convert.ToInt32(Properties.Settings.Default.SYRMEP_HPC_Processes);

            zJob = new RemotePhaseRetrievalJob(
                zFileName,
                zFileName.Remove(zFileName.Length - 4) + "_phrt.tdf",
                this.mMethod,
                0,
                zTo,
                this.mParam1,
                this.mParam2,
                this.mDistance,
                this.mEnergy,
                this.mPixelsize,
                this.mPad,
                zThreads
                );


            // Create an instance of JobExecuter with the pre processing job:
            IJobExecuter zExecuter = new RemoteJobExecuter(zJob);

            // Execute the job splitting it with several processes (if specified):
            zExecuter.Run();

            mJobMonitor.Run(zExecuter, "tomo");

            // Reset status bar:
            this.toolStripStatusLabel1.Text = string.Empty;

            mPhaseRetrievalOnGoing = true;
        }
Ejemplo n.º 4
0
        private void btnRun_Click(object sender, EventArgs e)
        {
            // Run Job Convert To TDF:
            IJob zJob;

            string zFileName = Path.GetFileName(mInputTDF);


            string zString   = string.Empty;
            string pythoncmd = (string.IsNullOrEmpty(Properties.Settings.Default.SYRMEP_HPC_PythonPath)) ? "python " : Properties.Settings.Default.SYRMEP_HPC_PythonPath + "/python ";

            // Unix-like command line:
            zString = pythoncmd + Properties.Settings.Default.SYRMEP_HPC_SourcePath + '/' + Properties.Settings.Default.GetTDFDimensionJob + " " + mInputTDF;
            string zResult = SYRMEP_HPC.Execute(zString);

            string[] zLines       = zResult.Split('\n');
            int      zProjections = Int32.Parse((zLines[0].Split(' '))[1]);
            int      zSlices      = Int32.Parse((zLines[1].Split(' '))[1]);

            int zTo = zSlices - 1;


            int zThreads = Convert.ToInt32(Properties.Settings.Default.SYRMEP_HPC_Processes);

            // Execute with conventional flat fielding:
            zJob = new RemotePreProcessingJob(
                // Get combobox selection (in handler)
                zFileName,
                zFileName.Remove(zFileName.Length - 4) + "_corr.tdf",
                0,
                zTo,
                mAirSx,
                mAirDx,
                this.mFlatEnd,    // use flat at the end
                this.mHalfHalf,
                this.mHalfHalfLine,
                this.mExtFOV,
                this.mExtFOVRight,
                this.mExtFOVOverlap,
                this.mExtFOVNormalize,
                this.mExtFOVAverage,
                this.mRingRemoval,
                this.mDynamicFlatFielding,
                zThreads,
                false,
                "-"
                );


            // Create an instance of JobExecuter with the pre processing job:
            IJobExecuter zExecuter = new RemoteJobExecuter(zJob);

            // Execute the job splitting it with several processes (if specified):
            zExecuter.Run();

            // Start the monitoring of the job:
            mJobMonitor.Run(zExecuter, "sino");



            this.mPreProcessOnGoing = true;

            this.lblPreProcessing.Enabled  = true;
            this.lblPhaseRetrieval.Enabled = false;
            this.lblReconstruction.Enabled = false;

            // Reset status bar:
            this.toolStripStatusLabel1.Text = string.Empty;
        }
Ejemplo n.º 5
0
        static void Main()
        {
            try
            {
                //Properties.Settings.Default["FormSettings_OpenOnce"] = false;
                Properties.Settings.Default["SessionID"] = Program.GetTimestamp(DateTime.Now);
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                SplashScreen mSplashSchreen = new SplashScreen();
                mSplashSchreen.ShowSplashScreen();
                Application.DoEvents();

                Application.CurrentCulture = CultureInfo.InvariantCulture;

                // Things to do at startup:
                mSplashSchreen.SetStatus(Properties.Resources.Splash, "");

                /*StartProcess("\"" + Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + Path.DirectorySeparatorChar + Properties.Settings.Default.MatlabPath
                 + Path.DirectorySeparatorChar + Properties.Settings.Default.MatlabOpen + "\"",
                 +  "\"" + Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + Path.DirectorySeparatorChar + Properties.Settings.Default.MatlabPath + "\" " +
                 +  Properties.Settings.Default.MatlabInvisible);*/

                //mSplashSchreen.SetStatus(Properties.Resources.Splash_GPU, "");
                //mSplashSchreen.SetStatus(Properties.Resources.Splash_Recon, "");
                //System.Threading.Thread.Sleep(1900);
                mSplashSchreen.SetStatus(Properties.Resources.Splash, "");


                if (Program.CheckVCRedistributable(@"SOFTWARE\Classes\Installer\Products\67D6ECF5CD5FBA732B8B22BAC8DE1B4D") == false)
                {
                    // Show a message:
                    SplashScreen.CloseForm();
                    DialogResult zResult = MessageBox.Show("Microsoft Visual C++ 2008 (x64) not found. Continue anyway?",
                                                           Properties.Settings.Default.ProgramName, MessageBoxButtons.YesNo, MessageBoxIcon.Question);


                    if (zResult == DialogResult.No)
                    {
                        // Run VC++ 2010 Redistributable x64:

                        /*Program.StartProcess("\"" + Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + Path.DirectorySeparatorChar +
                         * Properties.Settings.Default.DependenciesPath + Path.DirectorySeparatorChar + Properties.Settings.Default.VC2008Redistributable_x64 + "\"", "");*/

                        Application.Exit();
                        return;
                    }
                }
                if (Program.CheckVCRedistributable(@"SOFTWARE\Classes\Installer\Products\1926E8D15D0BCE53481466615F760A7F") == false)
                {
                    // Show a message:
                    SplashScreen.CloseForm();
                    DialogResult zResult = MessageBox.Show("Microsoft Visual C++ 2010 (x64) not found. Continue anyway?",
                                                           Properties.Settings.Default.ProgramName, MessageBoxButtons.YesNo, MessageBoxIcon.Question);


                    if (zResult == DialogResult.No)
                    {
                        // Run VC++ 2010 Redistributable x64:

                        /*Program.StartProcess("\"" + Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + Path.DirectorySeparatorChar +
                         * Properties.Settings.Default.DependenciesPath + Path.DirectorySeparatorChar + Properties.Settings.Default.VC2010Redistributable_x64 + "\"", "");*/


                        Application.Exit();
                        return;
                    }
                }
                if ((Program.CheckVCRedistributable(@"SOFTWARE\Classes\Installer\Dependencies\{d992c12e-cab2-426f-bde3-fb8c53950b0d}") == false) &
                    (Program.CheckVCRedistributable(@"SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x64") == false))
                {
                    // Show a message:
                    SplashScreen.CloseForm();
                    DialogResult zResult = MessageBox.Show("Microsoft Visual C++ 2015 (x64) not found. Continue anyway?",
                                                           Properties.Settings.Default.ProgramName, MessageBoxButtons.YesNo, MessageBoxIcon.Question);


                    if (zResult == DialogResult.No)
                    {
                        // Run VC++ 2010 Redistributable x64:

                        /*Program.StartProcess("\"" + Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + Path.DirectorySeparatorChar +
                         * Properties.Settings.Default.DependenciesPath + Path.DirectorySeparatorChar + Properties.Settings.Default.VC2015Redistributable_x64 + "\"", "");*/


                        Application.Exit();
                        return;
                    }
                }

                if (Properties.Settings.Default.SYRMEP_Version)
                {
                    try
                    {
                        string text = SYRMEP_HPC.Execute("echo 'hello'");
                    }
                    catch (Exception ex)
                    {
                        // Show a message:
                        SplashScreen.CloseForm();
                        DialogResult zResult = MessageBox.Show("Error while connecting to SYRMEP HPC: " + ex.Message + "\n\nContinue anyway?",
                                                               Properties.Settings.Default.ProgramName, MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                        if (zResult == DialogResult.No)
                        {
                            Application.Exit();
                            return;
                        }


                        // Get reference to the dialog type.

                        /*var dialogTypeName = "System.Windows.Forms.PropertyGridInternal.GridErrorDlg";
                         * var dialogType = typeof(Form).Assembly.GetType(dialogTypeName);
                         *
                         * // Create dialog instance.
                         * var dialog = (Form)Activator.CreateInstance(dialogType, new PropertyGrid());
                         *
                         * // Populate relevant properties on the dialog instance.
                         * dialog.Text = Properties.Settings.Default.ProgramName;
                         * dialogType.GetProperty("Details").SetValue(dialog, ex.Message, null);
                         * dialogType.GetProperty("Message").SetValue(dialog, "Error while connecting to SYRMEP HPC. Continue anyway?", null);
                         *
                         * // Display dialog.
                         * var zResult = dialog.ShowDialog();
                         * if (zResult == DialogResult.Cancel)
                         * {
                         *  Application.Exit();
                         *  return;
                         * }*/
                    }
                }



                // Open the main form:
                Application.Run(new MainForm());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Activate the monitoring (usually this has to be run by exploiting the BackgroundWorker pattern).
        /// No effects are produced if no JobExecuter instance is associated to the RemoteJobMonitor.
        /// </summary>
        public void Start()
        {
            this.mMonitorStarted = true;


            while (mMonitorStarted == true)
            {
                if (mJobExecuter != null)
                {
                    /* List<string> zFileNameList = new List<string>();
                     * List<int> zCountList = new List<int>();
                     * List<int> zLocalCountList = new List<int>();*/

                    int zCount      = 0;
                    int zLocalCount = 0;

                    IMonitoredJob zJob = (IMonitoredJob)mJobExecuter.Job;

                    string   zLine;
                    DateTime zT0, zT1;
                    TimeSpan zElapsedTime;
                    //int zProcessedFiles = 0;
                    //int zProcessedLines = 0;
                    bool zFinished = false;



                    // Number of files to process (in order to return the percentage of job completion):
                    int zFilesToProcess;
                    if (mNrOfLinesToMonitor == 0)
                    {
                        zFilesToProcess = zJob.To - zJob.From + 1;
                    }
                    else
                    {
                        zFilesToProcess = mNrOfLinesToMonitor;
                    }



                    //
                    // Raise up the the event for the start up of the monitoring:
                    //
                    if (JobStarted != null)
                    {
                        JobStarted(this, new JobEventArgs(Environment.NewLine + "Job for " + zJob.ToString() + " submitted...", 0.0));
                    }

                    try
                    {
                        // Get a first timestamp:
                        zT0 = DateTime.Now;

                        // Wait until the files exist:
                        TimeSpan  zTimeOut   = TimeSpan.FromSeconds(Properties.Settings.Default.TimeOutWaitForLogInSeconds);
                        Stopwatch zStopWatch = Stopwatch.StartNew();
                        bool      zDone      = false;

                        while ((zStopWatch.Elapsed < zTimeOut) && (zDone == false))
                        {
                            string zresult = SYRMEP_HPC.Execute("ls " + zJob.LogFile);

                            if (zresult.StartsWith(zJob.LogFile))
                            {
                                zDone = true;
                            }
                            // Sleep the thread:
                            if (zJob is IRemoteMonitoredJob)
                            {
                                Thread.Sleep(Properties.Settings.Default.RemoteLogRefreshRateMilliseconds);
                            }
                            else
                            {
                                Thread.Sleep(Properties.Settings.Default.LocalLogRefreshRateMilliseconds);
                            }
                        }

                        if (zDone == false)
                        {
                            if (JobError != null)
                            {
                                // Add the time for the execution of the whole job:
                                JobError(this, new JobEventArgs(Environment.NewLine + "Job error: A time out occurred while looking for log files.", 1.0));
                            }
                        }



                        // Start a loop 'till the last file has been processed. Set also a timeout.
                        while (!zFinished)
                        {
                            int zProcessedFiles = 0;

                            // For each file to log:
                            zLocalCount = 0;

                            string zResult = SYRMEP_HPC.Execute("cat " + zJob.LogFile);

                            string[] zLines = zResult.Split('\n');
                            zLocalCount     = zLines.Length - 1;
                            zProcessedFiles = countFreq("\t" + this.mStrToMonitor, zResult);


                            // Check if the number of lines in the log file is greater than the number of lines read
                            // at the previous step. If true there is something to log and we raise up the event:
                            if (zLocalCount >= zCount)
                            {
                                int diff = zLocalCount - zCount;

                                for (int k = 0; k < diff; k++)
                                {
                                    zLine = zLines[zCount + k];

                                    // Raise up the event:
                                    if (JobStep != null)
                                    {
                                        JobStep(this, new JobEventArgs(Environment.NewLine + zLine, zProcessedFiles / ((double)(zFilesToProcess))));
                                    }
                                }
                            }


                            zCount = zLocalCount;


                            // Check ending condition:
                            if (zProcessedFiles >= zFilesToProcess)
                            {
                                zFinished = true;
                            }

                            // Sleep the thread:
                            if (zJob is IRemoteMonitoredJob)
                            {
                                Thread.Sleep(Properties.Settings.Default.RemoteLogRefreshRateMilliseconds);
                            }
                            else
                            {
                                Thread.Sleep(Properties.Settings.Default.LocalLogRefreshRateMilliseconds);
                            }
                        }


                        //
                        // Raise up the the event for completion of the monitoring:
                        //

                        // Get the last timestamp:
                        zT1          = DateTime.Now;
                        zElapsedTime = zT1 - zT0;

                        // Delete log:
                        if (File.Exists(zJob.LogFile))
                        {
                            string zResult = SYRMEP_HPC.Execute("rm " + zJob.LogFile);
                        }

                        // Raise the event:
                        if (JobCompleted != null)
                        {
                            // Add the time for the execution of the whole job:
                            JobCompleted(this, new JobEventArgs(Environment.NewLine + "Job for " + zJob.ToString() + " completed successfully in "
                                                                + zElapsedTime.ToString(@"hh\:mm\:ss") + ".", 1.0));
                        }
                        mJobExecuter = null;
                    }
                    catch (Exception e)
                    {
                        if (JobError != null)
                        {
                            // Add the time for the execution of the whole job:
                            JobError(this, new JobEventArgs(Environment.NewLine + "Job error: " + e.Message + ".", 1.0));
                        }
                        mJobExecuter = null;
                    }
                }

                // Sleep:
                Thread.Sleep(Properties.Settings.Default.LocalLogRefreshRateMilliseconds);
            }
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Single process execution of the filter.
 /// </summary>
 /// <param name="e"></param>
 /// <returns></returns>
 public void Run()
 {
     // Run asynchronously:
     new Task(() => { SYRMEP_HPC.Execute(mJob.GetCommandLine()); }).Start();
 }