/// <summary> /// This method calls the <see cref="ITracker.Record()" /> method after /// initializing the recordings start time and successful start /// of the presentation. /// </summary> /// <returns> /// <strong>True</strong> if starting was successful, otherwise /// <strong>false</strong>. /// </returns> public bool StartRecording() { // Check for valid presentation thread if (this.presentationThread == null || !this.presentationThread.IsAlive) { this.Cursor = Cursors.WaitCursor; // create new raw data table for subject this.subjectRawDataTable = new SQLiteOgamaDataSet.RawdataDataTable { TableName = this.currentTracker.Subject.SubjectName + "Rawdata" }; // Start presentation in a separate thread, if (this.StartPresentation()) { this.Cursor = Cursors.Default; return true; } } else { InformationDialog.Show( "Recording is active", "The tracker is currently recording. Please stop the current recording first. By typing ESC for example.", false, MessageBoxIcon.Warning); } this.Cursor = Cursors.Default; return false; }
public virtual SQLiteOgamaDataSet.RawdataDataTable GetData() { this.Adapter.SelectCommand = this.CommandCollection[0]; var dataTable = new SQLiteOgamaDataSet.RawdataDataTable(); this.Adapter.Fill(dataTable); return dataTable; }
/// <summary> /// Initializes a new instance of the DataToTable structure. /// </summary> /// <param name="newRawData">A <see cref="List{RawData}"/> with the new data.</param> /// <param name="newRawDataTable">A <see cref="SQLiteOgamaDataSet.RawdataDataTable"/> of the current subject /// where to write the data to.</param> public DataToTable(List<RawData> newRawData, SQLiteOgamaDataSet.RawdataDataTable newRawDataTable) { this.RawDataList = newRawData.ToArray(); this.RawDataTable = newRawDataTable; }
/// <summary> /// Gets the whole raw data table for the given subject using the query: /// SELECT SubjectRawdata.* FROM [Subject] /// Uses given subjects whole raw data table. /// </summary> /// <param name="subject">A <see cref="string"/> with the subject name to which the data belongs.</param> /// <returns>The whole <see cref="SQLiteOgamaDataSet.RawdataDataTable"/> for the given subject.</returns> /// <exception cref="ArgumentNullException">Thrown, when subject is null or empty.</exception> public static SQLiteOgamaDataSet.RawdataDataTable GetRawDataBySubject(string subject) { if (subject == string.Empty) { throw new ArgumentNullException(); } if (!Document.ActiveDocument.DocDataSet.RawDataAdapterDict.ContainsKey(subject)) { return null; } SQLiteDataAdapter adapter = Document.ActiveDocument.DocDataSet.RawDataAdapterDict[subject]; // Create the SelectCommand. var command = new SQLiteCommand( "SELECT " + subject + "Rawdata.* FROM [" + subject + "Rawdata]", Document.ActiveDocument.DocDataSet.DatabaseConnection); // Set SelectCommand adapter.SelectCommand = command; // Create DataTable var dataTable = new SQLiteOgamaDataSet.RawdataDataTable(); // Fill it with Data referring to Subject and Trial adapter.Fill(dataTable); return dataTable; }
/// <summary> /// Gets raw data table with rows found for the Query: /// SELECT * WHERE (TrialSequence = @TrialSequence) AND (EventID is NULL) ORDER BY SubjectName, TrialSequence, Time /// Uses given subjects raw data table. /// </summary> /// <param name="subject">A <see cref="string"/> with the subject name to which the data belongs.</param> /// <param name="trialSequence">A <see cref="int"/> with the trial sequence number. (Param1)</param> /// <returns>A <see cref="SQLiteOgamaDataSet.RawdataDataTable"/> with found rows.</returns> /// <exception cref="ArgumentNullException">Thrown, when subject is null or empty.</exception> public static DataTable GetRawDataBySubjectAndTrialSequenceWithoutEvents(string subject, int trialSequence) { if (subject == string.Empty) { throw new ArgumentNullException(); } if (!Document.ActiveDocument.DocDataSet.RawDataAdapterDict.ContainsKey(subject)) { return null; } SQLiteDataAdapter adapter = Document.ActiveDocument.DocDataSet.RawDataAdapterDict[subject]; // Create the SelectCommand. var command = new SQLiteCommand( "SELECT " + subject + "Rawdata.* FROM [" + subject + "Rawdata] WHERE (TrialSequence = @TrialSequence) AND (EventID is NULL)" + " ORDER BY SubjectName, TrialSequence, Time", Document.ActiveDocument.DocDataSet.DatabaseConnection); // Add the parameters for the SelectCommand. command.Parameters.Add("@TrialSequence", DbType.Int32); // Set SelectCommand adapter.SelectCommand = command; // Set Parameters adapter.SelectCommand.Parameters[0].Value = trialSequence; // Create DataTable var dataTable = new SQLiteOgamaDataSet.RawdataDataTable(); // Fill it with Data adapter.Fill(dataTable); // Give correct name dataTable.TableName = subject + "Rawdata"; return dataTable; }
/// <summary> /// Gets raw data table with rows found for the Query: /// SELECT * WHERE Trial=Param1 AND MousePosX IS NOT NULL ORDER BY Time /// Uses given subjects raw data table /// </summary> /// <param name="subject">A <see cref="string"/> with the subject name to which the data belongs.</param> /// <param name="trialSequence">A <see cref="int"/> with the trial sequence number. (Param1)</param> /// <returns>A <see cref="SQLiteOgamaDataSet.RawdataDataTable"/> with found rows.</returns> /// <exception cref="ArgumentNullException">Thrown, when subject is null or empty.</exception> public static SQLiteOgamaDataSet.RawdataDataTable GetMouseDataBySubjectTrial(string subject, int trialSequence) { if (subject == string.Empty) { throw new ArgumentNullException(); } if (!Document.ActiveDocument.DocDataSet.RawDataAdapterDict.ContainsKey(subject)) { return null; } SQLiteDataAdapter adapter = Document.ActiveDocument.DocDataSet.RawDataAdapterDict[subject]; // Create the SelectCommand. var command = new SQLiteCommand( "SELECT " + subject + "Rawdata.* FROM [" + subject + "Rawdata] WHERE (TrialSequence = @Param1) AND (MousePosX IS NOT NULL)" + " ORDER BY Time", Document.ActiveDocument.DocDataSet.DatabaseConnection); // Add the parameters for the SelectCommand. command.Parameters.Add("@Param1", DbType.Int32); // Set SelectCommand adapter.SelectCommand = command; // Set Parameters adapter.SelectCommand.Parameters[0].Value = trialSequence; // Create DataTable var dataTable = new SQLiteOgamaDataSet.RawdataDataTable(); // Fill it with Data referring to Subject and Trial adapter.Fill(dataTable); return dataTable; }
/// <summary> /// This method writes a new <see cref="List{RawData}"/> information /// to the trials data table of the dataset. /// </summary> /// <remarks>This change has to be afterwards written to the database file /// with a call to /// <code>Queries.CreateRawDataTableInDB(subjectName); /// Queries.WriteRawDataWithBulkStatement(subjectName);</code></remarks> /// <param name="subjectName">A <see cref="string"/> with the subject name.</param> /// <param name="lstRawData">A <see cref="List{RawData}"/> with the /// new raw data.</param> /// <returns><strong>True</strong>, if successful otherwise, <strong>false</strong>.</returns> public static bool WriteRawDataListToDataSet(string subjectName, List<RawData> lstRawData) { // Create Subjects rawdata table var subjectRawDataTable = new SQLiteOgamaDataSet.RawdataDataTable(); // Give it correct name subjectRawDataTable.TableName = subjectName + "Rawdata"; try { SaveDataToTable(lstRawData.ToArray(), subjectRawDataTable); // Add the raw data table to the DataTableCollection. Document.ActiveDocument.DocDataSet.Tables.Add(subjectRawDataTable); } catch (Exception ex) { ExceptionMethods.HandleException(ex); return false; } finally { subjectRawDataTable.Dispose(); } return true; }
/// <summary> /// Initializes a new instance of the DataToTable structure. /// </summary> /// <param name="newRawData">A <see cref="List{RawData}"/> with the new data.</param> /// <param name="newRawDataTable">A <see cref="SQLiteOgamaDataSet.RawdataDataTable"/> of the current subject /// where to write the data to.</param> public DataToTable(List <RawData> newRawData, SQLiteOgamaDataSet.RawdataDataTable newRawDataTable) { this.RawDataList = newRawData.ToArray(); this.RawDataTable = newRawDataTable; }