/// <summary> /// Method to return an instance of Analyzer /// </summary> /// <param name="_callerLog"></param> /// <param name="_calleeLog"></param> /// <param name="_wavValidator"></param> /// <returns></returns> public static Analyzer getInstance(string _callerLog, string _calleeLog, WavFileInfo _wavInfo, string _resultDir) { Analyzer a = null; try { a = new Analyzer(_callerLog, _calleeLog, _wavInfo, _resultDir); } catch (Exception e) { Console.WriteLine("Error in creating analyzer instance. Message:\n" + e.Message); a = null; } return a; }
private WavFileInfo wInfo; // To find out which files can be recognized by callee #endregion Fields #region Constructors /// <summary> /// Class constructor /// </summary> /// <param name="_callerLog"></param> /// <param name="_calleeLog"></param> /// <param name="wavValidator"></param> private Analyzer(string _callerLog, string _calleeLog, WavFileInfo _wavInfo, string _resultDir) { try { callerFileReader = new StreamReader(_callerLog); calleeFileReader = new StreamReader(_calleeLog); this.resultDir = _resultDir; } catch (Exception e) { if (callerFileReader != null) callerFileReader.Close(); if (calleeFileReader != null) calleeFileReader.Close(); throw new Exception(e.Message); } this.wInfo = _wavInfo; ri = new ResultInterpreter(wInfo); aggResult = new AggregateResult(this); iterationNum = 0; }
private WavFileInfo wInfo; // Instance containing information about files that callee can recognize #endregion Fields #region Constructors /// <summary> /// Class constructor /// </summary> public GatewayTestDriver(string callerExeName, string calleeExeName, string sipServer, string callerExtension, string calleeExtension, string extnToDial, string callerGrammarFile, string calleeGrammarFile, string callerResultFile, string calleeResultFile, string[] callerWavFile, string calleeWavFile, WavFileInfo _wInfo, string _dirName, string _configFileName) { this.calleeExtension = calleeExtension; this.callerExtension = callerExtension; this.configFileName = _configFileName; this.dirName = _dirName; string calleeArguments; StringBuilder callerArguments = new StringBuilder(); #region Code segment to initialize caller process callerProcess = new Process(); callerProcess.StartInfo.FileName = callerExeName; callerProcess.StartInfo.UseShellExecute = true; callerProcess.StartInfo.RedirectStandardError = false; callerProcess.StartInfo.RedirectStandardOutput = false; callerArguments.Append(sipServer + " " + callerExtension + " " + extnToDial + " " + callerGrammarFile + " " + callerResultFile + " " + dirName + " " + configFileName); // callerArguments.Append(numIterations); for (int i = 0; i < callerWavFile.Length; i++) { callerArguments.Append(" "); callerArguments.Append(callerWavFile[i]); } callerProcess.StartInfo.Arguments = callerArguments.ToString(); callerProcess.Exited += new EventHandler(callerProcess_Exited); #endregion #region Code segment to initialize callee process calleeProcess = new Process(); calleeProcess.StartInfo.FileName = calleeExeName; calleeProcess.StartInfo.UseShellExecute = true; calleeProcess.StartInfo.RedirectStandardError = false; calleeProcess.StartInfo.RedirectStandardOutput = false; calleeArguments = sipServer + " " + calleeExtension + " " + callerExtension + " " + calleeGrammarFile + " " + calleeResultFile + " " + dirName + " " + configFileName + " " + calleeWavFile; calleeProcess.StartInfo.Arguments = calleeArguments; calleeProcess.Exited += new EventHandler(calleeProcess_Exited); #endregion calleeTerminationTimer = new System.Timers.Timer(); calleeTerminationTimer.Enabled = false; calleeTerminationTimer.Elapsed +=new ElapsedEventHandler(calleeTerminationTimer_Elapsed); calleeTerminationTimer.Interval = 30000; // Set it to fire after 30 seconds once enabled callerTerminationTimer = new System.Timers.Timer(); callerTerminationTimer.Enabled = false; callerTerminationTimer.Elapsed += new ElapsedEventHandler(callerTerminationTimer_Elapsed); callerTerminationTimer.Interval = 20000; // Set it to fire after 20 seconds once enabled this.calleeResultFile = calleeResultFile; this.callerResultFile = callerResultFile; this.calleeGrammarFile = calleeGrammarFile; wInfo = _wInfo; analyzer = null; }
/// <summary> /// Helper method to select wav files for caller and callee to play. These files should be recognized by the callee. /// </summary> /// <param name="wInfo"></param> /// <returns></returns> private string[] selectWavFiles(WavFileInfo wInfo, string searchPattern) { string[] wavFileList = null; string[] result = null; List<string> validatedWavFiles = new List<string>(); wavFileList = Directory.GetFiles(Environment.CurrentDirectory, searchPattern); for (int i = 0; i < wavFileList.Length; i++) { if (wInfo.wavFileRecognizedByGrammar(wavFileList[i]) == true) validatedWavFiles.Add(wavFileList[i]); } if (validatedWavFiles.Count > 0) { result = new string[validatedWavFiles.Count]; for (int j = 0; j < validatedWavFiles.Count; j++) { result[j] = validatedWavFiles[j]; } } return result; }
private bool selectWavFiles() { wInfo = WavFileInfo.getInstance("GatewayTestCallee.xml", "MapFile.txt"); if (wInfo == null) { Console.WriteLine("Main : Error in creating wav File validator. Exiting."); Environment.Exit(-1); } /** * Retrieve list of valid wav files for caller and callee */ callerWavFiles = selectWavFiles(wInfo, "CallerWav*.wav"); calleeWavFiles = selectWavFiles(wInfo, "CalleeWav*.wav"); Console.WriteLine("Wav files selected for caller"); for (int i = 0; i < callerWavFiles.Length; i++) Console.WriteLine(callerWavFiles[i]); Console.WriteLine("Wav files selected for callee"); for (int i = 0; i < calleeWavFiles.Length; i++) Console.WriteLine(calleeWavFiles[i]); if (callerWavFiles == null || callerWavFiles.Length == 0 || calleeWavFiles == null || calleeWavFiles.Length == 0) { Console.WriteLine("No valid wav files for caller or callee to play in the execution directory {0}.", Environment.CurrentDirectory); return false; } else return true; }
private WavFileInfo wInfo; // WavFileInfo instance #endregion Fields #region Constructors /// <summary> /// Class constructor /// </summary> public ResultInterpreter(WavFileInfo _wInfo) { wInfo = _wInfo; callerData = null; calleeData = null; }