private void playTraining(IWiimoteReferenceRecord pReferenceRecord, VideoUserOptions pOptions) { try { if (!mTrainingStarted) { initializeTraining(); } if (isTrainingVideoRunning()) { return; } if (isTrainingVideoPaused()) { mVideoPlayer.resume(); return; } if (mCurrentVideoIndex == WiimoteDataStore.getWiimoteDataStore().getNumberOfTrainingSegmentInfoRecords()) { return; } playTrainingVideo(pReferenceRecord, pOptions); } catch (WiimoteConnectionException ex) { throw ex; } }
public static WiimoteDataStore Deserialize() { // Deserialization try { lock (_dataStoreSync) { XmlSerializer s = new XmlSerializer(typeof(WiimoteDataStore)); if (!File.Exists(ProjectConstants.WIIMOTE_DATA_PATH + @"\" + ProjectConstants.WIIMOTE_DATA_STORE)) { return(WiimoteDataStore.m_WiimoteDataStore); } TextReader r = new StreamReader(ProjectConstants.WIIMOTE_DATA_PATH + @"\" + ProjectConstants.WIIMOTE_DATA_STORE); WiimoteDataStore.m_WiimoteDataStore = (WiimoteDataStore)s.Deserialize(r); r.Close(); m_WiimoteDataStore.initialize(); m_WiimoteDataStore.initializeAfterLoad(); } } catch (WiimoteDataStoreException e) { MessageBox.Show(e.Message, "Wiimote Data Store Issue", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(WiimoteDataStore.m_WiimoteDataStore); }
/** * 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 void deleteReferenceRecordSelected(DataGridViewRow lTrainingSegmentRow, DataGridViewRow lReferenceRow, int index) { TrainingSegmentInfo trainingSegmentInfo = (TrainingSegmentInfo)lTrainingSegmentRow.DataBoundItem; WiimoteReferenceRecord referenceRecord = (WiimoteReferenceRecord)lReferenceRow.DataBoundItem; DialogResult result; if (referenceRecord.getNumberOfWiimoteReferenceRecordingItems() > 0) { result = MessageBox.Show("There are Multiple Recording Items for this Reference. Do you want to delete all the Recording Items ?", "Need User Input", MessageBoxButtons.YesNo); } else { trainingSegmentInfo.deleteWiimoteReferenceRecord(index); return; } if (result == System.Windows.Forms.DialogResult.Yes) { referenceRecord.deleleAllWiimoteReferenceRecordingItems(); trainingSegmentInfo.deleteChildItem(index); } this.m_parent.SetTrainingSegmentInfoBindingSource(WiimoteDataStore.getWiimoteDataStore().TrainingSegmentInfoRecords); }
private void setCurrentPlay() { ITrainingSegmentInfo lSegmentInfo = getPreviousSegment(); if (lSegmentInfo != null) { mOutputParent.SetPreviousPlayName(getFormattedPlayName(lSegmentInfo)); } else { mOutputParent.SetPreviousPlayName(""); } if (mCurrentTrainingSegment != null && WiimoteDataStore.getWiimoteDataStore().getNumberOfTrainingSegmentInfoRecords() > 0) { mOutputParent.SetCurentPlayName(getFormattedPlayName(mCurrentTrainingSegment)); } else { mOutputParent.SetCurentPlayName(""); } lSegmentInfo = getNextSegment(); if (lSegmentInfo != null) { mOutputParent.SetNextPlayName(getFormattedPlayName(lSegmentInfo)); } else { mOutputParent.SetNextPlayName(""); } setCurrentSubFrame(); }
public void processCalibration() { try { setMessage(ProjectConstants.CALIBRATION_STARTED_MESSAGE); Thread.Sleep(ProjectConstants.CALIBRATION_MESSAGE_LOOK_TIME); IWiimoteCalibrationRecord l_StandStill = m_CalibrationRecord.getStandStillRecordingItem(DateTime.UtcNow); if (!mCalibrationRunning) { return; } setMessage(ProjectConstants.STAND_STILL_IN_PROGRESS_MESSAGE); recordCalibrationItem(l_StandStill); if (!mCalibrationRunning) { return; } setMessage(ProjectConstants.STAND_STILL_CALIBRATION_DONE_MESSAGE); Thread.Sleep(ProjectConstants.CALIBRATION_MESSAGE_LOOK_TIME); IWiimoteCalibrationRecord l_Left = m_CalibrationRecord.getLeftRecordingItem(DateTime.UtcNow); if (!mCalibrationRunning) { return; } setMessage(ProjectConstants.LEFT_CALIBRATION_IN_PROGRESS_MESSAGE); recordCalibrationItem(l_Left); if (!mCalibrationRunning) { return; } setMessage(ProjectConstants.LEFT_CALIBRATION_DONE_MESSAGE); Thread.Sleep(ProjectConstants.CALIBRATION_MESSAGE_LOOK_TIME); IWiimoteCalibrationRecord l_Right = m_CalibrationRecord.getRightRecordingItem(DateTime.UtcNow); if (!mCalibrationRunning) { return; } setMessage(ProjectConstants.RIGHT_CALIBRATION_IN_PROGRESS_MESSAGE); recordCalibrationItem(l_Right); m_CalibrationRecord.calculateCalibration(); WiimoteDataStore.getWiimoteDataStore().save(); if (!mCalibrationRunning) { return; } setMessage(ProjectConstants.CALIBRATION_DONE_MESSAGE); } catch (WiimoteCommunicationException ex) { throw ex; } catch (WiimoteConnectionException ex) { throw ex; } return; }
public static WiimoteDataStore getWiimoteDataStore() { if (m_WiimoteDataStore == null) { m_WiimoteDataStore = new WiimoteDataStore(); } return(m_WiimoteDataStore); }
public void newTrainingSegmentSelected() { string trainingSegmentName = ProjectConstants.UNTITLED_REFERENCE_NAME + (WiimoteDataStore.getWiimoteDataStore().HighestTrainingSegmentInfoIndex + 1); TrainingSegmentInfo lTrainingSegmentInfo = WiimoteDataStore.getWiimoteDataStore().addTrainingSegmentInfoRecord(trainingSegmentName); this.m_parent.SetTrainingSegmentInfoBindingSource(WiimoteDataStore.getWiimoteDataStore().TrainingSegmentInfoRecords); }
private ITrainingSegmentInfo getPreviousSegment() { if (mCurrentVideoIndex == 0) { return(null); } else { return(WiimoteDataStore.getWiimoteDataStore().getTrainingSegmentInfo(mCurrentVideoIndex - 1)); } }
private ITrainingSegmentInfo getNextSegment() { if (mCurrentVideoIndex == WiimoteDataStore.getWiimoteDataStore().getNumberOfTrainingSegmentInfoRecords() - 1) { return(WiimoteDataStore.getWiimoteDataStore().getTrainingSegmentInfo(0)); } else { return(WiimoteDataStore.getWiimoteDataStore().getTrainingSegmentInfo(mCurrentVideoIndex + 1)); } }
public void Initialize() { TimerThread.getTimerThread().BeatTimerEvent += new TimerThread.OnBeatTimerEvent(OnBeatTimerEvent); TimerThread.getTimerThread().StartingRecordingTimerEvent += new TimerThread.OnStartingRecordingTimerEvent(OnStartingRecordingTimerEvent); TimerThread.getTimerThread().TimerCompletedEvent += new TimerThread.OnTimerCompletedEvent(OnTimerCompletedEvent); TimerThread.getTimerThread().TimerInterruptedEvent += new TimerThread.OnTimerInterruptedEvent(OnTimerInterruptedEvent); MatlabWrapper.MatlabWiimoteWrapper.initialize(); WiimoteDataStore.Deserialize(); m_WiimoteDataAdaptor.initialize((WiimoteCalibrationRecordInfo)getCalibrationRecord()); m_WiimoteStateThreadRunState = false; }
private void startRecording(IWiimoteReferenceRecord pReferenceRecord, int pPrerecordingTime) { //setup Wiimote recording WiimoteDataStore dataStore = WiimoteDataStore.getWiimoteDataStore(); string lDateString = DateTime.Now.Month.ToString() + "_" + DateTime.Now.Day.ToString() + "_" + DateTime.Now.Year.ToString() + "_" + DateTime.Now.Hour.ToString() + "_" + DateTime.Now.Minute.ToString() + "_" + DateTime.Now.Second.ToString(); string lPlayname = "Play" + pReferenceRecord.RecordName + "_" + lDateString; IWiimotePlayRecord lPlayRecord = mCurrentTrainingSegment.addWiimotePlayRecord(lPlayname, DateTime.Today, 0); mWiimotes.startRecording(lPlayRecord, false, this, "", false); mRecordingStarted = true; System.Threading.Thread.Sleep(pPrerecordingTime); }
public void loadTrainingVideoInfoData() { WiimoteDataStore dataStore = WiimoteDataStore.getWiimoteDataStore(); int lNumRecords = dataStore.getNumberOfWiimoteReferenceRecords(); mVideoInfoList = new List <TrainingSegmentInfo>(); for (int lIndex = 0; lIndex < lNumRecords; lIndex++) { WiimoteReferenceRecord lReferenceRecord = dataStore.getWiimoteReferenceRecord(lIndex); if (lReferenceRecord.VideoPath != null && lReferenceRecord.VideoPath.CompareTo("") != 0) { mVideoInfoList.Add(new TrainingSegmentInfo(lReferenceRecord)); } } }
public bool nextFrame() { if (mVideoPlayer != null && (mVideoPlayer.getVideoState() == VideoState.Running || mVideoPlayer.getVideoState() == VideoState.Paused)) { return(false); } mCurrentVideoIndex = (mCurrentVideoIndex + 1) % WiimoteDataStore.getWiimoteDataStore().getNumberOfTrainingSegmentInfoRecords(); mCurrentTrainingSegment = WiimoteDataStore.getWiimoteDataStore().getTrainingSegmentInfo(mCurrentVideoIndex); mCurrentSubVideoIndex = 0; setCurrentPlay(); setCommandOptions(); return(true); }
public void initializeTraining() { try { loadTrainingVideoInfoData(); if (WiimoteDataStore.getWiimoteDataStore().getNumberOfTrainingSegmentInfoRecords() == 0) { return; // throw exception here } mTrainingStarted = true; mCurrentTrainingSegment = WiimoteDataStore.getWiimoteDataStore().getTrainingSegmentInfo(0); } catch (WiimoteConnectionException ex) { Console.WriteLine(ex); throw ex; } }
public bool previousFrame() { if (mVideoPlayer != null && (mVideoPlayer.getVideoState() == VideoState.Running || mVideoPlayer.getVideoState() == VideoState.Paused)) { return(false); } if (mCurrentVideoIndex > 0) { mCurrentVideoIndex = mCurrentVideoIndex - 1; } mCurrentTrainingSegment = WiimoteDataStore.getWiimoteDataStore().getTrainingSegmentInfo(mCurrentVideoIndex); mCurrentSubVideoIndex = 0; setCurrentPlay(); setCommandOptions(); return(true); }
public bool gotoFirstSegment() { if (mVideoPlayer != null && (mVideoPlayer.getVideoState() == VideoState.Running || mVideoPlayer.getVideoState() == VideoState.Paused)) { return(false); } if (WiimoteDataStore.getWiimoteDataStore().getNumberOfTrainingSegmentInfoRecords() == 0) { throw new TrainingVideoException("No Training Data Loaded"); } mCurrentVideoIndex = 0; mCurrentSubVideoIndex = 0; mCurrentTrainingSegment = WiimoteDataStore.getWiimoteDataStore().getTrainingSegmentInfo(mCurrentVideoIndex); setCurrentPlay(); setCommandOptions(); return(true); }
/** * 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 Form1() { cleanup(); InitializeComponent(); string workingDirectory = MainGUI.Properties.Settings.Default.WorkingDirectory; string wiimoteApplicationPath = MainGUI.Properties.Settings.Default.WiimoteApplicationPath; string matlabApplicationPath = MainGUI.Properties.Settings.Default.MatlapApplicationPath; string mediaDirectory = MainGUI.Properties.Settings.Default.MediaDirectory; ProjectConstants.initialize(workingDirectory, wiimoteApplicationPath, matlabApplicationPath, mediaDirectory); Environment.CurrentDirectory = ProjectConstants.PROJECT_PATH; this.openVideoDialog = new System.Windows.Forms.OpenFileDialog(); this.openMP3FileDialog = new System.Windows.Forms.OpenFileDialog(); this.openWiimoteSimulationFileDialog = new System.Windows.Forms.OpenFileDialog(); // openVideoDialog // this.openVideoDialog.DefaultExt = "avi"; this.openVideoDialog.FileName = "kangaroo.avi"; this.openVideoDialog.Filter = "movie files|*.avi||"; this.openVideoDialog.Title = "Choose a movie to play"; // openMP3Dialog // this.openMP3FileDialog.DefaultExt = "mpw"; this.openMP3FileDialog.Filter = "mp3 files|*.mp3||"; this.openMP3FileDialog.Title = "Choose a mp3 file to play"; // openWiimoteSimulationDialog // this.openWiimoteSimulationFileDialog.DefaultExt = "csv"; this.openWiimoteSimulationFileDialog.Filter = "csv files|*.csv||"; this.openWiimoteSimulationFileDialog.Title = "Choose a wiimote data file for simulation"; //open Wiimote Dialog this.openWiimoteDataDialog = new System.Windows.Forms.OpenFileDialog(); this.openWiimoteDataDialog.DefaultExt = "csv"; this.openWiimoteDataDialog.Filter = "csv files|*.csv||"; this.openWiimoteDataDialog.Title = "Choose Wiimote Data File to upload"; this.saveFileDialog = new System.Windows.Forms.SaveFileDialog(); this.saveFileDialog.DefaultExt = "csv"; this.saveFileDialog.Filter = "csv files|*.csv||"; saveFileDialog.InitialDirectory = ProjectConstants.WIIMOTE_REFERENCE_DATA_PATH; this.wiimoteDisconnect.Enabled = false; Configuration config = Configuration.getConfiguration(); config.initialize(); this.configurationBindingSource.DataSource = config; WiimoteDataStore.getWiimoteDataStore().initialize(); Wiimotes l_Wiimotes = Wiimotes.getWiimotesObject(); m_WiimoteRecordingHandler = new WiimoteRecordingHandler(l_Wiimotes, this); m_WiimoteRecordingHandler.Initialize(); m_WiimoteCalibrationHandler = new WiimoteCalibrationHandler(l_Wiimotes, this); m_WiimoteCalibrationHandler.Initialize(); this.trainingSegmentInfoBindingSource.DataSource = WiimoteDataStore.getWiimoteDataStore().TrainingSegmentInfoRecords; InitializeBluetoothSetupTab(); initializeTraining(l_Wiimotes); applicationStartSpeech(); InitializeMogreComponent(); mSpeechRecognition = SpeechRecognition.getSpeechRecognition(); mSpeechRecognition.VoiceCommandReceivedEvent += new SpeechRecognition.OnVoiceCommandReceivedEvent(OnVoiceCommandReceivedEvent); setButtonVoiceCommandOff(false); this.quartenionViewerControl.SetWiimotes(l_Wiimotes); //OSCCommunication oscCommunication = new OSCCommunication(); //oscCommunication.Initialize(l_Wiimotes); /* * try * { * m_OgreControl = new OgreControl(this.ogrePanel.Handle); * m_OgreControl.Init(); * * } * catch (MogreWrapperException e) * { * MessageBox.Show(e.Message, * "An Ogre exception has occurred!"); * } * * Disposed += new EventHandler(Form1_Disposed); * Resize += new EventHandler(Form1_Resize); * Paint += new PaintEventHandler(Form1_Paint); */ }
private void SaveReference_Click(object sender, EventArgs e) { WiimoteDataStore.Serialize(); }
public void save() { WiimoteDataStore.getWiimoteDataStore().save(); }
public IWiimoteCalibrationRecordInfo getCalibrationRecord() { return(WiimoteDataStore.getWiimoteDataStore().Calibration); }
public void save() { WiimoteDataStore.Serialize(); }