예제 #1
0
        public MainInterface()
        {
            InitializeComponent();
            database = new DatabaseControl();
            bw.WorkerSupportsCancellation = true;
            bw.WorkerReportsProgress      = true;

            blankList = new List <bool>();

            //studies = database.Load();
            currentStudy            = new Study();
            studyDisplay.DataSource = database.GetStudies();

            currentSubject = new Subject();
            //subjectDisplay.DataSource = currentStudy.subjects;

            currentSession = new Session();
            //sessionDisplay.DataSource = currentSubject.sessions;

            currentTrial = new Trial();
            //trialDisplay.DataSource = currentSession.trials;

            radiusSettings.SelectedIndex = 1;

            this.Refresh();
        }
예제 #2
0
        public MainInterface()
        {
            InitializeComponent();
            database = new DatabaseControl();
            bw.WorkerSupportsCancellation = true;
            bw.WorkerReportsProgress = true;

            blankList = new List<bool>();

            //studies = database.Load();
            currentStudy = new Study();
            studyDisplay.DataSource = database.GetStudies();

            currentSubject = new Subject();
            //subjectDisplay.DataSource = currentStudy.subjects;

            currentSession = new Session();
            //sessionDisplay.DataSource = currentSubject.sessions;

            currentTrial = new Trial();
            //trialDisplay.DataSource = currentSession.trials;

            radiusSettings.SelectedIndex = 1;

            this.Refresh();
        }
예제 #3
0
        public void ExportStudyToMultipleFiles(DatabaseControl db, Study study, string directory)
        {
            string header = "StudyName,SubjectID,SessionName,SessionDate,TrialName,SessionSync1.Onset,SessionSync1.Offset,SessionSync2.Onset,SessionSync2.Offset,";

            for (int i = 0; i < 15; i++)
            {
                header += string.Format("Sensor{0}.ID,Sensor{0}.Time,Sensor{0}.Switch,Sensor{0}.X,Sensor{0}.Y,Sensor{0}.Z,Sensor{0}.Pitch,Sensor{0}.Roll,Sensor{0}.Yaw,Sensor{0}.quality,", i);
            }


            foreach (Subject sub in db.GetSubjects(study))
            {
                foreach (Session sess in db.GetSessions(sub))
                {
                    foreach (Trial trial in db.GetTrials(sess))
                    {
                        Console.WriteLine("Dumping trial : " + trial.name);
                        string filename = directory + "\\" + study.name + "-" + sub.id + "-" + sess.name + "-" + trial.name + ".csv";
                        status = string.Format("{0} - {1} - {2} - {3}", study.name, sub.id, sess.name, trial.name);

                        using (System.IO.StreamWriter file = new System.IO.StreamWriter(@filename))
                        {
                            file.Write(header + "\n");

                            int total = db.GetSensorReadings(trial).Count();
                            int count = 0;
                            foreach (SensorReading pt in db.GetSensorReadings(trial))
                            {
                                count++;
                                percent = Convert.ToInt32(Math.Ceiling((float)count / (float)total * 100.0));
                                Sensor[] sensors = pt.sensors;


                                // Append study/sub/sess/trial data
                                file.Write(string.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8}", study.name, sub.id, sess.name, sess.tdate, trial.name, sess.sync1_on, sess.sync1_off, sess.sync2_on, sess.sync2_off));
                                for (int i = 0; i < sensors.Length; i++)
                                {
                                    if (sensors[i].active == 1)
                                    {
                                        // Append sensor data whether sensor is active or not
                                        file.Write(string.Format(",{0},{9},{1},{2:0.00},{3:0.00},{4:0.00},{5:0.00},{6:0.00},{7:0.00},{8}",
                                                                 i, sensors[i].button, sensors[i].x, sensors[i].y, sensors[i].z, sensors[i].pitch, sensors[i].roll, sensors[i].yaw, sensors[i].quality, sensors[i].time));
                                    }
                                    else
                                    {
                                        // If the sensor wasn't active then append a blank filler
                                        file.Write(",,,,,,,,,,");
                                    }
                                }
                                file.Write("\n");
                            }
                        }
                        percent = 0;
                    }
                }
            }
        }
예제 #4
0
        public void ExportStudyToMultipleFiles(DatabaseControl db, Study study, string directory)
        {
            string header = "StudyName,SubjectID,SessionName,SessionDate,TrialName,SessionSync1.Onset,SessionSync1.Offset,SessionSync2.Onset,SessionSync2.Offset,";

            for (int i = 0; i < 15; i++)
            {
                header += string.Format("Sensor{0}.ID,Sensor{0}.Time,Sensor{0}.Switch,Sensor{0}.X,Sensor{0}.Y,Sensor{0}.Z,Sensor{0}.Pitch,Sensor{0}.Roll,Sensor{0}.Yaw,Sensor{0}.quality,", i);
            }

            foreach (Subject sub in db.GetSubjects(study))
            {
                foreach (Session sess in db.GetSessions(sub))
                {
                    foreach (Trial trial in db.GetTrials(sess))
                    {
                        Console.WriteLine("Dumping trial : " + trial.name);
                        string filename = directory + "\\" + study.name + "-" + sub.id + "-" + sess.name + "-" + trial.name + ".csv";
                        status = string.Format("{0} - {1} - {2} - {3}", study.name, sub.id, sess.name, trial.name);

                        using (System.IO.StreamWriter file = new System.IO.StreamWriter(@filename))
                        {
                            file.Write(header + "\n");

                            int total = db.GetSensorReadings(trial).Count();
                            int count = 0;
                            foreach (SensorReading pt in db.GetSensorReadings(trial))
                            {
                                count++;
                                percent = Convert.ToInt32(Math.Ceiling((float)count / (float)total * 100.0));
                                Sensor[] sensors = pt.sensors;

                                // Append study/sub/sess/trial data
                                file.Write(string.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8}", study.name, sub.id, sess.name, sess.tdate, trial.name, sess.sync1_on, sess.sync1_off, sess.sync2_on, sess.sync2_off));
                                for (int i = 0; i < sensors.Length; i++)
                                {
                                    if (sensors[i].active == 1)
                                    {
                                        // Append sensor data whether sensor is active or not
                                        file.Write(string.Format(",{0},{9},{1},{2:0.00},{3:0.00},{4:0.00},{5:0.00},{6:0.00},{7:0.00},{8}",
                                            i, sensors[i].button, sensors[i].x, sensors[i].y, sensors[i].z, sensors[i].pitch, sensors[i].roll, sensors[i].yaw, sensors[i].quality, sensors[i].time));
                                    }
                                    else
                                    {
                                        // If the sensor wasn't active then append a blank filler
                                        file.Write(",,,,,,,,,,");
                                    }
                                }
                                file.Write("\n");
                            }
                        }
                        percent = 0;
                    }
                }
            }
        }
예제 #5
0
        // This function will return a list of all of the times that the sync key was hit
        public List<int> FindSyncTimes(DatabaseControl db, Study study, Subject sub, Session sess)
        {
            List<int> times = new List<int>();

            return times;
        }
예제 #6
0
 public Exporter runExportSubjectByTrial(DatabaseControl database, Study currentStudy, Subject currentSubject, String directory)
 {
     Thread.Sleep(100);
     exporter.ExportSubjectToMultipleFiles(database, currentStudy, currentSubject, directory);
     return(exporter);
 }
예제 #7
0
 public Exporter runExportSubject(DatabaseControl database, Study currentStudy, Subject currentSubject, String filename)
 {
     Thread.Sleep(100);
     exporter.ExportSubjectToCSVOneFile(database, currentStudy, currentSubject, filename);
     return(exporter);
 }
예제 #8
0
        // This function will return a list of all of the times that the sync key was hit
        public List <int> FindSyncTimes(DatabaseControl db, Study study, Subject sub, Session sess)
        {
            List <int> times = new List <int>();

            return(times);
        }
예제 #9
0
 public Recorder(DatabaseControl database)
 {
     this.database = database;
     this.running = false;
 }
예제 #10
0
 public Exporter runExportSubjectByTrial(DatabaseControl database, Study currentStudy, Subject currentSubject, String directory)
 {
     Thread.Sleep(100);
     exporter.ExportSubjectToMultipleFiles(database, currentStudy, currentSubject, directory);
     return exporter;
 }
예제 #11
0
 public Exporter runExportSubject(DatabaseControl database, Study currentStudy, Subject currentSubject, String filename)
 {
     Thread.Sleep(100);
     exporter.ExportSubjectToCSVOneFile(database, currentStudy, currentSubject, filename);
     return exporter;
 }
예제 #12
0
 public Recorder(DatabaseControl database)
 {
     this.database = database;
     this.running  = false;
 }