Example #1
0
        void SaveCurrentTrialXML(Encoding encoding)
        {
            Trial t = _trials[_currentTrialIndex];

            StreamWriter writer = new StreamWriter(_outputFilePath, true);

            string toRecord = "<trial";

            // first record all parameters
            foreach (string p in _parameters)
            {
                toRecord += " " + p + "=\"" + t.GetParameterData(p) + "\"";
            }

            Dictionary <string, string> savedData = t.GetResultsData();

            if (savedData.Count > 0)
            {
                if (_resultsHeader != null)
                {
                    foreach (string rh in _resultsHeader)
                    {
                        toRecord += " " + rh + "=\"" + t.GetResultData(rh) + "\"";
                    }
                }
                //					// need to order data according to _results header
                //					string[] toWrite = new string[_results.Count];
                //					// order elements to write them in a formatted order in the record file
                //					foreach(KeyValuePair<string, string> p in savedData) { toWrite[_results.IndexOf(p.Key)] = p.Value; }
                //					// prepare formatted string to receive the data
                //					for(int i = 0; i < _results.Count; i++) { toRecord += " "+_results[i]+"=\"{"+i+"}\""; }
                //					toRecord = string.Format(toRecord, toWrite);
                //				}
                // order does not matter if the results header was provided
                else
                {
                    foreach (KeyValuePair <string, string> p in savedData)
                    {
                        toRecord += " " + p.Key + "=\"" + p.Value + "\"";
                    }
                }
            }
            // always save main timer (should be able to rename it)
            toRecord += " TaskCompletionTime=\"" + t.GetMainRawDuration() + "\"";
            // save all timers at the end
            if (_timersHeader != null)
            {
                foreach (string th in _timersHeader)
                {
                    toRecord += " " + th + "=\"" + t.GetTimerRawDuration(th) + "\"";
                }
            }

            toRecord += "/>";
            writer.WriteLine(toRecord);
            writer.Close();
        }
Example #2
0
        /// <summary>
        /// Get data for a given parameter of the experiment.
        /// </summary>
        /// <param name="parameter">Name of the parameter.</param>
        /// <returns>The data associated.</returns>
        public string GetParameterData(string parameter)
        {
            if (_currentExperiment == null)
            {
                throw new ExperimentNotCreatedException();
            }
            Trial t = _currentExperiment.GetCurrentTrial();

            return(t.GetParameterData(parameter));
        }