Exemplo n.º 1
0
 private void Exit_Click(object sender, EventArgs e)
 {
     Wiimotes.getWiimotesObject().cleanup();
     m_WiimoteRecordingHandler.disconnectWiimotes();
     mTrainingHandler.CleanupMedia();
     Environment.Exit(0);
 }
 public static WiimoteRecordingHandler getWiimoteRecordingHandler(Wiimotes p_Wiimotes, Form1 form)
 {
     if (m_WiimoteRecordingHandler == null)
     {
         m_WiimoteRecordingHandler = new WiimoteRecordingHandler(p_Wiimotes, form);
     }
     return(m_WiimoteRecordingHandler);
 }
Exemplo n.º 3
0
        public void setWiimotesObject(Wiimotes pWiimotes)
        {
            mWiimotes = pWiimotes;
            mWiimotes.WiimoteDisconnectedEvent += new Wiimotes.OnWiimoteDisconnectedEvent(OnWiimoteDisconnectedEvent);

            mSpeechRecognition = SpeechRecognition.getSpeechRecognition();
            mSpeechRecognition.VoiceCommandReceivedEvent += new SpeechRecognition.OnVoiceCommandReceivedEvent(OnVoiceCommandReceivedEvent);
            mSpeechRecognition.startEngine();
        }
Exemplo n.º 4
0
        private static void inputClient_DataReceived(IAsyncResult result)
        {
            var bytesReceived = client.Client.EndReceive(result);

            if (bytesReceived > 0)
            {
                Console.WriteLine("Disconnecting");
                Wiimotes.DisconnectAll();
            }
        }
        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();
        }
Exemplo n.º 6
0
        //public static void Test3SpaceSensorAccGyro()
        //{
        //    SpaceSensorMain spaceSensorMain = new SpaceSensorMain();
        //    spaceSensorMain.SpaceSensorObject1.Connect();

        //    CSVFileWriter csvFileWriter = new CSVFileWriter(@"D:\temp\TestData.csv");

        //    for (int i = 0; i < 50; i++)
        //    {
        //        SensorData sensorDataObj = spaceSensorMain.SpaceSensorObject1.ReadAccGyroData();
        //        //Quaternion sensor2QuatObj = _spaceSensorMain.SpaceSensorObject2.ReadOrientation();
        //        StringBuilder dataRow = new StringBuilder();

        //        dataRow.Append(String.Format("{0:hh:mm:ss.fff}", DateTime.Now));
        //        dataRow.Append("," + sensorDataObj.AccDataObject.DataVector.X);
        //        dataRow.Append("," + sensorDataObj.AccDataObject.DataVector.Y);
        //        dataRow.Append("," + sensorDataObj.AccDataObject.DataVector.Z);
        //        dataRow.Append("," + sensorDataObj.GyroDataObject.Pitch);
        //        dataRow.Append("," + sensorDataObj.GyroDataObject.Roll);
        //        dataRow.Append("," + sensorDataObj.GyroDataObject.Yaw);

        //        csvFileWriter.writeLine(dataRow.ToString());
        //        Thread.Sleep(100);

        //    }

        //    csvFileWriter.close();
        //}

        public static void Test3SpaceSensor()
        {
            Wiimotes wiimotesObj = Wiimotes.getWiimotesObject();

            wiimotesObj.connectWiimotes(1);
            wiimotesObj.StartDataCollection(@"D:\temp\TestData.csv", true);
            Thread.Sleep(30000);
            wiimotesObj.StopDataCollection();
            Thread.Sleep(3000);
            wiimotesObj.disconnectWiimotes();
            Application.Exit();
        }
        public WiimoteRecordingHandler(Wiimotes p_Wiimotes, Form1 form)
        {
            m_parent = form;

            m_RecordReference = false;
            m_RecordPlay      = false;

            m_Wiimotes = p_Wiimotes;

            this.m_parent.wiimoteConnectionProgress.Maximum = Configuration.getConfiguration().MaxWiimoteConnectionTries;

            m_Wiimotes.RecordingBeatEvent      += new Wiimotes.OnRecordingBeatEvent(OnRecordingBeatEvent);
            m_Wiimotes.RecordingStartedEvent   += new Wiimotes.OnRecordingStartedEvent(OnRecordingStartedEvent);
            m_Wiimotes.RecordingCompletedEvent += new Wiimotes.OnRecordingCompletedEvent(OnRecordingCompletedEvent);
            m_Wiimotes.WiimoteUpdateEvent      += new Wiimotes.OnWiimoteUpdateEvent(OnWiimoteUpdateEvent);
        }
Exemplo n.º 8
0
        static void Main(string[] args)
        {
            Wiimotes.ButtonClicked += Button;
            int numConnnected = Wiimotes.Connect(5);

            if (numConnnected > 0)
            {
                Console.WriteLine("{0} wiimote(s) found", numConnnected);
                Console.WriteLine("Press ENTER to quit");
                Console.ReadLine();
                Wiimotes.DisconnectAll();
            }
            else
            {
                Console.WriteLine("No Wiimotes found");
            }
        }
Exemplo n.º 9
0
        private void initializeTraining(Wiimotes pWiimotes)
        {
            try
            {
                if (Configuration.getConfiguration().TrainingMode)
                {
                    InitializeTrainingVideoLayout();
                }

                mTrainingHandler = new TrainingHandler(trainingVideoPanel1);
                mTrainingHandler.Initialize();
                mTrainingHandler.LoadTraining();
                trainingVideoPanel1.setWiimotesObject(pWiimotes);
            }
            catch (VideoPanelControl.TrainingVideoException ex)
            {
                MessageBox.Show(ex.Message, "Training Issue", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 10
0
        public void Initialize(Wiimotes wiimotesObj)
        {
            sSendMessages = true;

            if (TransportType == TransportType.Tcp)
            {
                sOscClient = new OscClient(Destination.Address, Destination.Port);
                sOscClient.Connect();
            }

            _sourceEndPoint = new IPEndPoint(IPAddress.Loopback, Port);

            wiimotesObj.RecordingStartedEvent   += new Wiimotes.OnRecordingStartedEvent(OnRecordingStartedEvent);
            wiimotesObj.RecordingCompletedEvent += new Wiimotes.OnRecordingCompletedEvent(OnRecordingCompletedEvent);

            Thread serverThread = new Thread(RunWorker);

            serverThread.Start();
        }
Exemplo n.º 11
0
        static void Main(string[] args)
        {
            var port    = Convert.ToInt32(args[0]);
            var timeout = Convert.ToInt32(args[1]);
            var buffer  = new byte[12];

            client = new TcpClient();
            client.Connect(IPAddress.Loopback, port);
            client.Client.BeginReceive(termBuffer, 0, 1, SocketFlags.None,
                                       inputClient_DataReceived, null);

            Console.WriteLine("Connected to Nexus at 127.0.0.1:{0}", port);

            Wiimotes.ButtonClicked += Button;
            int numConnnected = Wiimotes.Connect(timeout);

            if (numConnnected > 0)
            {
                Console.WriteLine("{0} wiimote(s) found", numConnnected);

                CopyInt(ref buffer, 1, 0);
                CopyInt(ref buffer, numConnnected, 4);
                CopyInt(ref buffer, 0, 8);

                client.Client.Send(buffer);
                Wiimotes.Poll();
            }
            else
            {
                CopyInt(ref buffer, 1, 0);
                CopyInt(ref buffer, 0, 4);
                CopyInt(ref buffer, 0, 8);

                client.Client.Send(buffer);
                Console.WriteLine("No Wiimotes found");
            }
        }
Exemplo n.º 12
0
        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);
 */
        }
 public SpaceSensorDataAdaptor(Wiimotes pParent)
     : base(pParent)
 {
 }
Exemplo n.º 14
0
 public void setWiimotesObject(Wiimotes pWiimotes)
 {
     mTrainingVideoRunner.setWiimotesObject(pWiimotes);
 }
Exemplo n.º 15
0
        public void SetWiimotes(Wiimotes wiimotes)
        {
            _wiimotes = wiimotes;

            _wiimotes.RecordingDataReceivedEvent += new Wiimotes.OnRecordingDataReceivedEvent(OnRecordingDataReceivedEvent);
        }
Exemplo n.º 16
0
 public SpaceSensorDataAdaptor(Wiimotes pParent)
     : base(pParent)
 {
 }
Exemplo n.º 17
0
        public void setWiimotesObject(Wiimotes pWiimotes)
        {
            mWiimotes = pWiimotes;
            mWiimotes.WiimoteDisconnectedEvent += new Wiimotes.OnWiimoteDisconnectedEvent(OnWiimoteDisconnectedEvent);
//            mWiimotes.WiimoteActionEvent += new Wiimotes.OnWiimoteActionEvent(OnWiimoteActionEvent);
        }