// Routine to handle Generation of XLS file Creation private void GenerateXLS_Click_Click(object sender, EventArgs e) { try { ReplayTrial.cleanUp(); DisplayFileCreation.cleanUp(); // validate the input File name chosen by the User String geLogFileName = this.selectTrialBox.Text; if (this.selectTrialBox == null || this.selectTrialBox.Text == null || geLogFileName == null || geLogFileName == "") { MessageBox.Show("Select a valid Trial file to replay"); this.selectTrialBox.Clear(); return; } String xlsFileName = ATUtil.retrieveXLSFileName(geLogFileName, "GELOG"); if (ATUtil.checkIfXLSFileExists(xlsFileName)) { MessageBox.Show("XLS File Exists"); this.selectTrialBox.Clear(); return; } String displayFileName = setUp(geLogFileName); // Create Human Readable File WaitMessageForm waitMessageFrm = new WaitMessageForm(); //waitMessageFrm.Location = new System.Drawing.Point(0, 0); waitMessageFrm.TopMost = true; waitMessageFrm.BringToFront(); waitMessageFrm.Show(); waitMessageFrm.Refresh(); XML2XLS converter = new XML2XLS(displayFileName); try { converter.convert(); waitMessageFrm.Hide(); waitMessageFrm.Close(); MessageBox.Show(" XML to XLS file converted Successfully"); } catch (SystemException e3) { // do nothing MessageBox.Show(e3.Message); } catch (Exception e2) { // do nothing MessageBox.Show(e2.Message); } finally { converter = null; } } catch (ATLogicException e3) { MessageBox.Show("Analysis Tool Exception : Error Creating XLS file : " + e3.getATLogicErrorMessage()); MessageBox.Show("Analysis Tool Exception : Error Creating XLS file : " + e3.StackTrace); this.selectTrialBox.Clear(); return; } catch (SystemException e4) { MessageBox.Show(" AT Exception :Error Creating XLS file : " + e4.Message); MessageBox.Show(" AT Exception : Error Creating XLS file : " + e4.StackTrace); this.selectTrialBox.Clear(); return; } catch (Exception e5) { MessageBox.Show(" Generic Exception : Error Creating XLS file : " + e5.Message); MessageBox.Show(" Generic Exception : Error Creating XLS file : " + e5.StackTrace); this.selectTrialBox.Clear(); return; } }
// Routine to do the following functions : // 1> Validates the file names at each step // 2> Checks and Creates Gaze file if not found // 3> checks and creates Display File if not found // on ERROR : throws ATLogic Exception with a User message Wrapped around the System message. private String setUp(String gelogFileName) { ReplayTrial.cleanUp(); DisplayFileCreation.cleanUp(); // validate the input File name chosen by the User String geLogFileName = this.selectTrialBox.Text; if (this.selectTrialBox == null || this.selectTrialBox.Text == null || geLogFileName == null || geLogFileName == "") { MessageBox.Show("Select a valid Trial file to replay"); this.selectTrialBox.Clear(); return(null); } // Validation Success at this point // retrieve EDF file( created by Eyelink ) that is found in the session directory. String edfFileName = getEDFFileName(geLogFileName); if (edfFileName == null) { MessageBox.Show("EDF File not found : given gelogFile " + geLogFileName); this.selectTrialBox.Clear(); return(null); } //1. From the EDF file obtained above,convert the file from .EDF format to .ASC file format and //2. Create Gaze Files (split the single .ASC file into as many gaze files as the number of trials foudn in the session). //3. Retrieve the gaze file for the Given Trial string edfGazeFileName = null; try { edfGazeFileName = createAndRetrieveGazeFile(edfFileName, geLogFileName); } catch (Exception) { MessageBox.Show("EDF Gaze File not found : given edfFile " + edfFileName); this.selectTrialBox.Clear(); return(null); } if (edfGazeFileName == null) { MessageBox.Show("Error retrieving Edf Gaze File : given gelogFile " + geLogFileName); this.selectTrialBox.Clear(); return(null); } // At this point, we have both gaze file and gelog file required to create a display file. // Retrieve a name for the Display file to be created from the given gelog file and gaze file names. String displayFileName = null; try { displayFileName = DisplayFileCreation.GetDisplayFileName(geLogFileName); } catch (Exception) { MessageBox.Show("Error Retrieving Display File Name "); this.selectTrialBox.Clear(); return(null); } if (displayFileName == null) { MessageBox.Show("Error Retrieving Display File Name "); this.selectTrialBox.Clear(); return(null); } if (!File.Exists(displayFileName)) { DisplayFileCreation.create(geLogFileName, edfGazeFileName, displayFileName); } if (!File.Exists(displayFileName)) { MessageBox.Show("Error Creating Display File Name :" + displayFileName); this.selectTrialBox.Clear(); return(displayFileName); } return(displayFileName); }
/** * Event to handle replay button click * Creates a Display File and Human readable file for the input Trial if one does not exist and replays the trial * Display File - user_selected__trial_name.display ( XML file format) * Display Readable File - user_selected_trial_name.xls ( Microsoft Excel file ) * * @Author : Smitha Madhavamurthy * @date : 04-05-2007 * */ private void replay_click(object sender, EventArgs e) { try { ReplayTrial.cleanUp(); DisplayFileCreation.cleanUp(); // validate the input File name chosen by the User String geLogFileName = this.selectTrialBox.Text; if (this.selectTrialBox == null || this.selectTrialBox.Text == null || geLogFileName == null || geLogFileName == "") { MessageBox.Show("Select a valid Trial file to replay"); this.selectTrialBox.Clear(); return; } String displayFileName = setUp(geLogFileName); // Check to see user's option of the Speed of Replay try { String speedFactor = "NORMAL"; ReplayTrial.DisplayFileName = displayFileName; if (slow_speed) { speedFactor = "SLOW"; } else if (very_slow_speed) { speedFactor = "VERYSLOW"; } else if (fast_speed) { speedFactor = "FAST"; } else { speedFactor = "NORMAL"; } // Now invoke the routine to Start Replaying the Trial ReplayTrial.display(speedFactor); } catch (SystemException e1) { MessageBox.Show(" System Exception : Error replaying Trial : " + e1.Message); MessageBox.Show(" System Exception : Error replaying Trial : " + e1.StackTrace); this.selectTrialBox.Clear(); return; } catch (ATLogicException e2) { MessageBox.Show("Analysis Tool Exception : Error replaying Trial : " + e2.getATLogicErrorMessage()); MessageBox.Show("Analysis Tool Exception : Error replaying Trial : " + e2.StackTrace); this.selectTrialBox.Clear(); return; } } catch (ATLogicException e3) { MessageBox.Show("Analysis Tool Exception : Error replaying Trial : " + e3.getATLogicErrorMessage()); MessageBox.Show("Analysis Tool Exception : Error replaying Trial : " + e3.StackTrace); this.selectTrialBox.Clear(); return; } catch (SystemException e4) { MessageBox.Show(" AT Exception : Error replaying Trial : " + e4.Message); MessageBox.Show(" AT Exception : Error replaying Trial : " + e4.StackTrace); this.selectTrialBox.Clear(); return; } catch (Exception e5) // any generic Exception { MessageBox.Show(" Generic Exception : Error replaying Trial : " + e5.Message); MessageBox.Show(" Generic Exception : Error replaying Trial : " + e5.StackTrace); this.selectTrialBox.Clear(); return; } this.selectTrialBox.Clear(); // clears the field that holds the user selected Trial name }