/**
         * This method
         *  1) Prepares the csv log file for logging Wiimote Data
         *  2) Initializes the Matlab matrix to send data
         */

        public override string startWiimoteLogging(IWiimoteChildRecord wiimoteRecord)
        {
            try
            {
                ITrainingSegmentInfo l_ParentRecord = (ITrainingSegmentInfo)wiimoteRecord.ParentRecord;
                //TODO : Change to member variable
                IWiimoteCalibrationRecordInfo l_Calibration = WiimoteDataStore.getWiimoteDataStore().Calibration;
                setCalibration();

                m_CSVFileWriter = new WiimoteCSVFileWriter(wiimoteRecord.FilePath.Insert(wiimoteRecord.FilePath.Length - 4, "CSharp"));
                m_CSVFileWriter = new WiimoteCSVFileWriter(wiimoteRecord.FilePath);
                m_CSVFileWriter.logHeader(m_CalibrationRecord);

                startRecordingSignalMatlab();
            }
            catch (PipeCommunicationException ex)
            {
                throw new WiimoteCommunicationException(ex);
            }
            catch (CSVFileFormatException ex)
            {
                throw new WiimoteCommunicationException(ex);
            }

            return(null);
        }
        public virtual void logHeader(IWiimoteCalibrationRecordInfo p_CalibrationRecord)
        {
            try
            {
                writeLine("BPM," + 0);
                writeLine("BPB," + 0);
                writeLine("NumBar," + 0);
                writeLine("LeadIn," + 0);
                writeLine();

                writeLine("MusicFile,None");
                writeLine();

                writeLine("Calibration Info Start");
                if (p_CalibrationRecord.WiimotesSwitched)
                {
                    writeLine("LRswitched,True");
                }
                else
                {
                    writeLine("LRswitched,False");
                }

                writeLine("Sequence #,Time,Acc Pitch Orientation #WM1, Acc Roll Orientation #WM1,Acc X #WM1,Acc Y #WM1,Acc Z #WM1," +
                          "Raw Yaw #WM1,Raw Pitch #WM1,Raw Roll #WM1,Speed Yaw #WM1, Speed Pitch #WM1,Speed Roll #WM1," +
                          "Acc Pitch Orientation #WM2, Acc Roll Orientation #WM2,Acc X #WM2,Acc Y #WM2,Acc Z #WM2," +
                          "Raw Yaw #WM2,Raw Pitch #WM2,Raw Roll #WM2,Speed Yaw #WM2, Speed Pitch #WM2,Speed Roll #WM2");

                string calibrationMessage = "0,0,0,0," +
                                            p_CalibrationRecord.getCalibrationValue(ProjectConstants.WIMMOTE1_DATA_ACCX_COLUMN_INDEX) + "," +
                                            p_CalibrationRecord.getCalibrationValue(ProjectConstants.WIMMOTE1_DATA_ACCY_COLUMN_INDEX) + "," +
                                            p_CalibrationRecord.getCalibrationValue(ProjectConstants.WIMMOTE1_DATA_ACCZ_COLUMN_INDEX) + ",0,0,0," +
                                            p_CalibrationRecord.getCalibrationValue(ProjectConstants.WIMMOTE1_DATA_YAW_COLUMN_INDEX) + "," +
                                            p_CalibrationRecord.getCalibrationValue(ProjectConstants.WIMMOTE1_DATA_PITCH_COLUMN_INDEX) + "," +
                                            p_CalibrationRecord.getCalibrationValue(ProjectConstants.WIMMOTE1_DATA_ROLL_COLUMN_INDEX) + ",0,0," +
                                            p_CalibrationRecord.getCalibrationValue(ProjectConstants.WIMMOTE2_DATA_ACCX_COLUMN_INDEX) + "," +
                                            p_CalibrationRecord.getCalibrationValue(ProjectConstants.WIMMOTE2_DATA_ACCY_COLUMN_INDEX) + "," +
                                            p_CalibrationRecord.getCalibrationValue(ProjectConstants.WIMMOTE2_DATA_ACCZ_COLUMN_INDEX) + ",0,0,0," +
                                            p_CalibrationRecord.getCalibrationValue(ProjectConstants.WIMMOTE2_DATA_YAW_COLUMN_INDEX) + "," +
                                            p_CalibrationRecord.getCalibrationValue(ProjectConstants.WIMMOTE2_DATA_PITCH_COLUMN_INDEX) + "," +
                                            p_CalibrationRecord.getCalibrationValue(ProjectConstants.WIMMOTE2_DATA_ROLL_COLUMN_INDEX);
                writeLine(calibrationMessage);


                writeLine("Calibration Info End");
                writeLine();

                writeLine("Sequence #,Time,Acc Pitch Orientation #WM1, Acc Roll Orientation #WM1,Acc X #WM1,Acc Y #WM1,Acc Z #WM1," +
                          "Raw Yaw #WM1,Raw Pitch #WM1,Raw Roll #WM1,Speed Yaw #WM1, Speed Pitch #WM1,Speed Roll #WM1," +
                          "Acc Pitch Orientation #WM2, Acc Roll Orientation #WM2,Acc X #WM2,Acc Y #WM2,Acc Z #WM2," +
                          "Raw Yaw #WM2,Raw Pitch #WM2,Raw Roll #WM2,Speed Yaw #WM2, Speed Pitch #WM2,Speed Roll #WM2");
            }
            catch (CSVFileException e)
            {
                throw e;
            }
        }
        public WiimoteCalibrationHandler(Wiimotes p_Wiimotes, Form1 p_Form)
        {
            m_Status            = CalibrationStatus.CalibrationNotStarted;
            m_Wiimotes          = p_Wiimotes;
            m_parent            = p_Form;
            m_CalibrationRecord = m_Wiimotes.getCalibrationRecord();

            m_Wiimotes.RecordingCompletedEvent   += new Wiimotes.OnRecordingCompletedEvent(OnRecordingCompletedEvent);
            m_Wiimotes.RecordingInterruptedEvent += new Wiimotes.OnRecordingInterruptedEvent(OnRecordingInterruptedEvent);

            calibrationRecordingSync = new object();
        }
        public virtual void logHeader(IWiimoteCalibrationRecordInfo p_CalibrationRecord)
        {
            try
            {
                writeLine("BPM," + 0);
                writeLine("BPB," + 0);
                writeLine("NumBar," + 0);
                writeLine("LeadIn," + 0);
                writeLine();

                writeLine("MusicFile,None");
                writeLine();

                writeLine("Calibration Info Start");
                if (p_CalibrationRecord.WiimotesSwitched)
                    writeLine("LRswitched,True");
                else
                    writeLine("LRswitched,False");

                writeLine("Sequence #,Time,Acc Pitch Orientation #WM1, Acc Roll Orientation #WM1,Acc X #WM1,Acc Y #WM1,Acc Z #WM1," +
                                      "Raw Yaw #WM1,Raw Pitch #WM1,Raw Roll #WM1,Speed Yaw #WM1, Speed Pitch #WM1,Speed Roll #WM1," +
                                      "Acc Pitch Orientation #WM2, Acc Roll Orientation #WM2,Acc X #WM2,Acc Y #WM2,Acc Z #WM2," +
                                      "Raw Yaw #WM2,Raw Pitch #WM2,Raw Roll #WM2,Speed Yaw #WM2, Speed Pitch #WM2,Speed Roll #WM2");

                string calibrationMessage = "0,0,0,0," +
                p_CalibrationRecord.getCalibrationValue(ProjectConstants.WIMMOTE1_DATA_ACCX_COLUMN_INDEX) + "," +
                p_CalibrationRecord.getCalibrationValue(ProjectConstants.WIMMOTE1_DATA_ACCY_COLUMN_INDEX) + "," +
                p_CalibrationRecord.getCalibrationValue(ProjectConstants.WIMMOTE1_DATA_ACCZ_COLUMN_INDEX) + ",0,0,0," +
                p_CalibrationRecord.getCalibrationValue(ProjectConstants.WIMMOTE1_DATA_YAW_COLUMN_INDEX) + "," +
                p_CalibrationRecord.getCalibrationValue(ProjectConstants.WIMMOTE1_DATA_PITCH_COLUMN_INDEX) + "," +
                p_CalibrationRecord.getCalibrationValue(ProjectConstants.WIMMOTE1_DATA_ROLL_COLUMN_INDEX) + ",0,0," +
                p_CalibrationRecord.getCalibrationValue(ProjectConstants.WIMMOTE2_DATA_ACCX_COLUMN_INDEX) + "," +
                p_CalibrationRecord.getCalibrationValue(ProjectConstants.WIMMOTE2_DATA_ACCY_COLUMN_INDEX) + "," +
                p_CalibrationRecord.getCalibrationValue(ProjectConstants.WIMMOTE2_DATA_ACCZ_COLUMN_INDEX) + ",0,0,0," +
                p_CalibrationRecord.getCalibrationValue(ProjectConstants.WIMMOTE2_DATA_YAW_COLUMN_INDEX) + "," +
                p_CalibrationRecord.getCalibrationValue(ProjectConstants.WIMMOTE2_DATA_PITCH_COLUMN_INDEX) + "," +
                p_CalibrationRecord.getCalibrationValue(ProjectConstants.WIMMOTE2_DATA_ROLL_COLUMN_INDEX);
                writeLine(calibrationMessage);

                writeLine("Calibration Info End");
                writeLine();

                writeLine("Sequence #,Time,Acc Pitch Orientation #WM1, Acc Roll Orientation #WM1,Acc X #WM1,Acc Y #WM1,Acc Z #WM1," +
                                      "Raw Yaw #WM1,Raw Pitch #WM1,Raw Roll #WM1,Speed Yaw #WM1, Speed Pitch #WM1,Speed Roll #WM1," +
                                      "Acc Pitch Orientation #WM2, Acc Roll Orientation #WM2,Acc X #WM2,Acc Y #WM2,Acc Z #WM2," +
                                      "Raw Yaw #WM2,Raw Pitch #WM2,Raw Roll #WM2,Speed Yaw #WM2, Speed Pitch #WM2,Speed Roll #WM2");
            }
            catch (CSVFileException e)
            {
                throw e;
            }
        }
        public override void logHeader(IWiimoteCalibrationRecordInfo p_CalibrationRecord)
        {
            try
            {
                writeLine("Sensor," + "3Space");
                writeLine("BPM," + 0);
                writeLine("BPB," + 0);
                writeLine("NumBar," + 0);
                writeLine("LeadIn," + 0);
                writeLine();

                writeLine("MusicFile,None");
                writeLine();

                writeLine("Calibration Info Start");
                if (p_CalibrationRecord.WiimotesSwitched)
                {
                    writeLine("LRswitched,True");
                }
                else
                {
                    writeLine("LRswitched,False");
                }

                writeLine("Sequence #,Time,Acc X #S1,Acc Y #S1,Acc Z #S1," +
                          "Pitch #S1,Yaw #S1, Roll #S1," +
                          "Quat X #S1,Quat Y #S1,Quat Z #S1, Quat W #S1," +
                          "Acc X #S2,Acc Y #S2,Acc Z #S2," +
                          "Pitch #S2, Yaw #S2, Roll #S2," +
                          "Quat X #S2,Quat Y #S2,Quat Z #S2, Quat W #S2,");

                string calibrationMessage = "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0";
                writeLine(calibrationMessage);


                writeLine("Calibration Info End");
                writeLine();

                writeLine("Sequence #,Time,Acc X #S1,Acc Y #S1,Acc Z #S1," +
                          "Pitch #S1, Yaw #S1,Roll #S1," +
                          "Quat X #S1,Quat Y #S1,Quat Z #S1, Quat W #S1," +
                          "Acc X #S2,Acc Y #S2,Acc Z #S2," +
                          "Pitch #S2,Yaw #S2,Roll #S2," +
                          "Quat X #S2,Quat Y #S2,Quat Z #S2, Quat W #S2,");
            }
            catch (CSVFileException e)
            {
                throw e;
            }
        }
Esempio n. 6
0
        /**
         * This method
         *  1) Prepares the csv log file for logging Wiimote Data
         *  2) Initializes the Matlab matrix to send data
         */

        public override string startWiimoteLogging(IWiimoteChildRecord wiimoteRecord)
        {
            try
            {
                ITrainingSegmentInfo l_ParentRecord = (ITrainingSegmentInfo)wiimoteRecord.ParentRecord;
                //TODO : Change to member variable
                IWiimoteCalibrationRecordInfo l_Calibration = WiimoteDataStore.getWiimoteDataStore().Calibration;
                setCalibration();
                StartDataCollection(wiimoteRecord.FilePath);

                startRecordingSignalMatlab();
            }
            catch (CSVFileFormatException ex)
            {
                throw new WiimoteCommunicationException(ex);
            }
            catch (Exception ex)
            {
                throw new WiimoteCommunicationException(ex);
            }
            return(null);
        }
        public override void logHeader(IWiimoteCalibrationRecordInfo p_CalibrationRecord)
        {
            try
            {
                writeLine("Sensor," + "3Space");
                writeLine("BPM," + 0);
                writeLine("BPB," + 0);
                writeLine("NumBar," + 0);
                writeLine("LeadIn," + 0);
                writeLine();

                writeLine("MusicFile,None");
                writeLine();

                writeLine("Calibration Info Start");
                if (p_CalibrationRecord.WiimotesSwitched)
                    writeLine("LRswitched,True");
                else
                    writeLine("LRswitched,False");

                writeLine("Sequence #,Time,Acc X #S1,Acc Y #S1,Acc Z #S1," +
                                      "Pitch #S1,Yaw #S1, Roll #S1," +
                                      "Quat X #S1,Quat Y #S1,Quat Z #S1, Quat W #S1," +
                                      "Acc X #S2,Acc Y #S2,Acc Z #S2," +
                                      "Pitch #S2, Yaw #S2, Roll #S2," +
                                      "Quat X #S2,Quat Y #S2,Quat Z #S2, Quat W #S2,");

                string calibrationMessage = "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0";
                writeLine(calibrationMessage);

                writeLine("Calibration Info End");
                writeLine();

                writeLine("Sequence #,Time,Acc X #S1,Acc Y #S1,Acc Z #S1," +
                                      "Pitch #S1, Yaw #S1,Roll #S1," +
                                      "Quat X #S1,Quat Y #S1,Quat Z #S1, Quat W #S1," +
                                      "Acc X #S2,Acc Y #S2,Acc Z #S2," +
                                      "Pitch #S2,Yaw #S2,Roll #S2," +
                                      "Quat X #S2,Quat Y #S2,Quat Z #S2, Quat W #S2,");
            }
            catch (CSVFileException e)
            {
                throw e;
            }
        }
        public WiimoteCalibrationHandler(Wiimotes p_Wiimotes,Form1 p_Form)
        {
            m_Status = CalibrationStatus.CalibrationNotStarted;
            m_Wiimotes = p_Wiimotes;
            m_parent = p_Form;
            m_CalibrationRecord = m_Wiimotes.getCalibrationRecord();

            m_Wiimotes.RecordingCompletedEvent += new Wiimotes.OnRecordingCompletedEvent(OnRecordingCompletedEvent);
            m_Wiimotes.RecordingInterruptedEvent += new Wiimotes.OnRecordingInterruptedEvent(OnRecordingInterruptedEvent);

            calibrationRecordingSync = new object();
        }