public void Initialise()
 {
     var server = new OscServer(TransportType.Udp, IPAddress.Loopback, Convert.ToInt32(ConfigurationManager.AppSettings["ListenOnPort"]));
     server.RegisterMethod("/");
     server.MessageReceived += MessageReceived;
     server.Start();
 }
        public MainWindow()
        {
            InitializeComponent();

            OscServer oscServer;
            
            oscServer = new OscServer(TransportType.Udp, IPAddress.Loopback, Port);

            oscServer.FilterRegisteredMethods = false;
			oscServer.RegisterMethod(AliveMethod);
            oscServer.RegisterMethod(TestMethod);
            oscServer.BundleReceived += new EventHandler<OscBundleReceivedEventArgs>(oscServer_BundleReceived);
			oscServer.MessageReceived += new EventHandler<OscMessageReceivedEventArgs>(oscServer_MessageReceived);
            oscServer.ReceiveErrored += new EventHandler<Bespoke.Common.ExceptionEventArgs>(oscServer_ReceiveErrored);
            oscServer.ConsumeParsingExceptions = false;

            oscServer.Start();
            Console.WriteLine("Server started.");

            //Start playing audio
            string audioFileName = "/file/path";
            mp = new MediaPlayer();
            mp.MediaOpened += new EventHandler(mp_MediaOpened);
            bool isPaused = false;
            bool isPlaying = false;
        }
        public void Connect()
        {
            if (!Connected)
            {
                comPort = null;

                Process findCom = new Process();
                findCom.StartInfo.FileName = Properties.Settings.Default.FindComPath;
                findCom.StartInfo.CreateNoWindow = true;
                findCom.StartInfo.RedirectStandardOutput = true;
                findCom.StartInfo.UseShellExecute = false;
                findCom.OutputDataReceived += new DataReceivedEventHandler(findCom_OutputDataReceived);
                findCom.Start();
                findCom.BeginOutputReadLine();
                findCom.WaitForExit();

                uint oscPort = MIN_OSC_PORT;
                bool oscConnected = false;
                while (!oscConnected && oscPort < MAX_OSC_PORT)
                {
                    osc = new OscServer(TransportType.Udp, IPAddress.Loopback, (int)oscPort);
                    osc.FilterRegisteredMethods = false;
                    osc.MessageReceived += new EventHandler<OscMessageReceivedEventArgs>(osc_MessageReceived);
                    osc.ReceiveErrored += new EventHandler<Bespoke.Common.ExceptionEventArgs>(osc_ReceiveErrored);
                    osc.BundleReceived += new EventHandler<OscBundleReceivedEventArgs>(osc_BundleReceived);

                    try
                    {
                        osc.Start();
                        oscConnected = true;
                    }
                    catch (Exception e)
                    {
                        oscPort++;
                    }
                }

                if (!oscConnected)
                {
                    throw new Exception("Could not connect to any UDP port in the specified range");
                }
                else if(comPort != null)
                {
                    waxRec = new Process();
                    waxRec.StartInfo.FileName = Properties.Settings.Default.WaxRecPath;
                    waxRec.StartInfo.Arguments = string.Format("\\\\.\\{0} -osc localhost:{1} -init \"MODE=1\\r\\n", comPort, oscPort);
                    waxRec.StartInfo.CreateNoWindow = true;
                    waxRec.StartInfo.UseShellExecute = false;
                    waxRec.Start();

                    if (!waxRec.HasExited)
                    {
                        Connected = true;
                    }
                }
            }
        }
Exemple #4
0
        public Form1()
        {
            InitializeComponent();
            osc_server = new OscServer(Bespoke.Common.Net.TransportType.Tcp, IPAddress.Parse("127.0.0.1"), 5253);
            osc_server.MessageReceived += new OscMessageReceivedHandler(osc_server_MessageReceived);

            //Need to build in Connected/Disconnected/FailedConnect Event Handlers
            osc_server.FilterRegisteredMethods = false;

            dataGridView1.ColumnCount = 3;
        }
        private void init()
        {
            sOscServer = new OscServer(TransportType.Udp, IPAddress.Loopback, ServerPort, ServerAddress, Bespoke.Common.Net.TransmissionType.Multicast);
            sOscServer.RegisterMethod("/test");
            sOscServer.MessageReceived += new OscMessageReceivedHandler(sOscServer_MessageReceived);
            OscPacket.LittleEndianByteOrder = false;
            sOscServer.Start();

            if (debug)
            {
                Console.WriteLine("OSC Client: " + sOscServer.TransmissionType.ToString());
            }
        }
 public InputServer(ILog log, IInputController inputController)
 {
     this.log = log;
     this.inputController = inputController;
     server = new OscServer(TransportType.Udp, IPAddress.Any, DEFAULT_VIP_PORT);
     server.RegisterMethod(JOYPAD_BUTTON_EVENT);
     server.RegisterMethod(MOUSE_EVENT);
     server.RegisterMethod(SCROLL_EVENT);
     server.RegisterMethod(KEYBOARD_EVENT);
     server.RegisterMethod(VOLUME_EVENT);
     server.MessageReceived += new OscMessageReceivedHandler(server_MessageReceived);
     server.Start();
     log.Log(LogLevel.Info, "Starting Input Server");
 }
Exemple #7
0
		static void Main(string[] args)
		{
            sOscServer = new OscServer(TransportType.Tcp, IPAddress.Loopback, 5253);
            sOscServer.BundleReceived += new OscBundleReceivedHandler(sOscServer_BundleReceived);
			sOscServer.MessageReceived += new OscMessageReceivedHandler(sOscServer_MessageReceived);
            sOscServer.FilterRegisteredMethods = false;

			sOscServer.Start();

			Console.WriteLine("OSC Client: " + sOscServer.TransmissionType.ToString());
			Console.WriteLine("Press any key to exit.");
			Console.ReadKey();
			sOscServer.Stop();
		}
Exemple #8
0
        public static void Main()
        {
            var server = new OscServer(TransportType.Udp, IPAddress.Loopback,
                                       Convert.ToInt32(ConfigurationManager.AppSettings["ListenOnPort"]));
            server.RegisterMethod("/");
            server.MessageReceived += MessageReceived;
            server.Start();

            Console.WriteLine("Dummy Receiver started.");
            Console.WriteLine("Awaiting messages...");
            Console.WriteLine("Press any key to exit.");
            Console.ReadKey();
            server.Stop();
        }
Exemple #9
0
		static void Main(string[] args)
		{
            OscPacket.LittleEndianByteOrder = false;
            sOscServer = new OscServer(TransportType.Udp, IPAddress.Parse("127.0.0.1"), 6250);
            sOscServer.BundleReceived += new OscBundleReceivedHandler(sOscServer_BundleReceived);
			sOscServer.MessageReceived += new OscMessageReceivedHandler(sOscServer_MessageReceived);
            sOscServer.FilterRegisteredMethods = false;

			sOscServer.Start();

			Console.WriteLine("OSC Client: " + sOscServer.TransmissionType.ToString());
			Console.WriteLine("Press any key to exit.");
			Console.ReadKey();
			sOscServer.Stop();
		}
        public MainWindow()
        {
            InitializeComponent();

            MMDeviceEnumerator DevEnum = new MMDeviceEnumerator();
            device = DevEnum.GetDefaultAudioEndpoint(EDataFlow.eRender, ERole.eMultimedia);

            OscServer oscServer;
            oscServer = new OscServer(TransportType.Udp, IPAddress.Any, Port);

            oscServer.FilterRegisteredMethods = false;
            oscServer.RegisterMethod(AliveMethod);
            oscServer.RegisterMethod(TestMethod);
            oscServer.BundleReceived += new EventHandler<OscBundleReceivedEventArgs>(oscServer_BundleReceived);
            oscServer.MessageReceived += new EventHandler<OscMessageReceivedEventArgs>(oscServer_MessageReceived);
            oscServer.ReceiveErrored += new EventHandler<Bespoke.Common.ExceptionEventArgs>(oscServer_ReceiveErrored);
            oscServer.ConsumeParsingExceptions = false;

            oscServer.Start();
        }
		public static void Main(string[] args)
		{
            OscServer oscServer;
            DemoType demoType = GetDemoType();
            switch (demoType)
            {
                case DemoType.Udp:
                    oscServer = new OscServer(TransportType.Udp, IPAddress.Loopback, Port);
                    break;

                case DemoType.Tcp:
                    oscServer = new OscServer(TransportType.Tcp, IPAddress.Loopback, Port);
                    break;

                case DemoType.Multicast:
                    oscServer = new OscServer(IPAddress.Parse("224.25.26.27"), Port);
                    break;

                default:
                    throw new Exception("Unsupported receiver type.");
            }
            
            oscServer.FilterRegisteredMethods = false;
			oscServer.RegisterMethod(AliveMethod);
            oscServer.RegisterMethod(TestMethod);
            oscServer.BundleReceived += new EventHandler<OscBundleReceivedEventArgs>(oscServer_BundleReceived);
			oscServer.MessageReceived += new EventHandler<OscMessageReceivedEventArgs>(oscServer_MessageReceived);
            oscServer.ReceiveErrored += new EventHandler<ExceptionEventArgs>(oscServer_ReceiveErrored);
            oscServer.ConsumeParsingExceptions = false;

            oscServer.Start();

			Console.WriteLine("Osc Receiver: " + demoType.ToString());
			Console.WriteLine("Press any key to exit.");
			Console.ReadKey();
			oscServer.Stop();
		}
Exemple #12
0
        private void InitializeServer()
        {
            if (m_udpServer != null)
            {
                m_udpServer.ReceiveErrored -= oscServer_ReceiveErrored;
                m_udpServer.MessageReceived -= m_oscUdpServer_MessageReceived;
                m_udpServer.Stop();
                m_udpServer = null;
            }

            m_udpServer = new OscServer(TransportType.Udp, IPAddress.Any, ReceivingPort, true);

            //Bespoke uses a List instead of a HashSet and doesn't do pattern matching, so
            //  it's inefficient and non-conformant. Let's get all messages and do the filtering
            //  and matching ourselves.
            m_udpServer.FilterRegisteredMethods = false;

            // Receive notifications for all OSC messages, no matter how they're bundled.
            m_udpServer.MessageReceived += m_oscUdpServer_MessageReceived;

            // These two go together. ConsumeParsingExceptions needs to be false for our event
            //  handler to be called.
            m_udpServer.ReceiveErrored += oscServer_ReceiveErrored;
            m_udpServer.ConsumeParsingExceptions = false;

            // A possible error is that another ATF-app is using the given port #. What can we do
            //  in that case?
            try
            {
                m_udpServer.Start();
                m_serverStatusMsg = "Running";
            }
            catch (SocketException e)
            {
                Outputs.WriteLine(OutputMessageType.Error, e.Message);
                m_serverStatusMsg = "Not running. Could be two apps using the same port #. Exception text: \"" +
                    e.Message + '\"';
            }

            // to-do: subscribe to an app shutdown event? Or have a finalizer?
            //m_oscUdpServer.Stop();
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
            dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
            dispatcherTimer.Interval = new TimeSpan(0, 0, 1);
            dispatcherTimer.Start();

            comms_connect.Content = "Connect";

            Port = MySettings.Default.portSetting;
            kinectFrontIP.Address = IPAddress.Parse(MySettings.Default.kinectFrontIPSetting);
            kinectFrontIP.Port = Port;
            kinectBackIP.Address = IPAddress.Parse(MySettings.Default.kinectBackIPSetting);
            kinectBackIP.Port = Port;
            limboViewerIP.Address = IPAddress.Parse(MySettings.Default.limboViewerIPSetting);
            limboViewerIP.Port = Port;
            imageServerIP.Address = IPAddress.Parse(MySettings.Default.imageServerIPSetting);
            imageServerIP.Port = Port;
            limboStandIP.Address = IPAddress.Parse(MySettings.Default.limboStandIPSetting);
            limboStandIP.Port = Port;
            ipadIP.Address = IPAddress.Parse(MySettings.Default.iPadIPSetting);
            ipadIP.Port = Port;

            portInput.Text = Port.ToString();
            kinectFrontIPInput.Text = MySettings.Default.kinectFrontIPSetting;
            kinectBackIPInput.Text = MySettings.Default.kinectBackIPSetting;
            limboViewerIPInput.Text = MySettings.Default.limboViewerIPSetting;
            imageServerIPInput.Text = MySettings.Default.imageServerIPSetting;
            limboStandIPInput.Text = MySettings.Default.limboStandIPSetting;
            ipadIPInput.Text = MySettings.Default.iPadIPSetting;

            userCount = MySettings.Default.userCountSetting;
            userCountDisplay.Text = userCount.ToString();

            CellPhoneNumberDisplayBox.Text = "User Cell Phone Numeber";

            myIPAddrText.Text = LocalIPAddress();

            iPadLED.Fill = new SolidColorBrush(Colors.Gray);
            limboViewerLED.Fill = new SolidColorBrush(Colors.Gray);
            limboStandLED.Fill = new SolidColorBrush(Colors.Gray);
            imageServerLED.Fill = new SolidColorBrush(Colors.Gray);
            kinectFrontLED.Fill = new SolidColorBrush(Colors.Gray);
            kinectBackLED.Fill = new SolidColorBrush(Colors.Gray);
            remoteLED.Fill = new SolidColorBrush(Colors.Gray);

            //sourceEndPoint.Address = IPAddress.Parse("192.168.0.114");
            //sourceEndPoint.Port = Convert.ToInt32(12345);

            oscCmdServer = new OscServer(TransportType.Udp, IPAddress.Parse(LocalIPAddress()), 10000);
            //oscCmdServer = new OscServer(IPAddress.Parse("224.25.26.27"), Port);
            oscCmdServer.FilterRegisteredMethods = false;
            //oscCmdServer.RegisterMethod(oscCmd);
            oscCmdServer.RegisterMethod(kinectFrontCmd);
            oscCmdServer.RegisterMethod(kinectBackCmd);
            //oscCmdServer.RegisterMethod(TestMethod);
            oscCmdServer.BundleReceived += new EventHandler<OscBundleReceivedEventArgs>(oscCmdServer_BundleReceived);
            oscCmdServer.MessageReceived += new EventHandler<OscMessageReceivedEventArgs>(oscCmdServer_MessageReceived);
            oscCmdServer.ReceiveErrored += new EventHandler<ExceptionEventArgs>(oscCmdServer_ReceiveErrored);
            oscCmdServer.ConsumeParsingExceptions = false;
            oscCmdServer.Start();

            updateUserStatus();
        }
        public static Boolean Initialize()
        {
            try
              {
            if (!m_boolInitialized && !m_boolInitError)
            {

              // Check if Muse-IO is running

              // Launch Muse-IO
              String musePath = "";
              if (File.Exists(@"C:\Program Files (x86)\Muse\muse-io.exe"))
              {
            musePath = @"C:\Program Files (x86)\Muse\muse-io.exe";
              }
              else if (File.Exists(@"C:\Program Files\Muse\muse-io.exe"))
              {
            musePath = @"C:\Program Files\Muse\muse-io.exe";
              }
              else
              {
            if (MessageBox.Show("Could not find Muse-IO. Would you like to install it?", "Install Muse SDK", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
            {
              System.Diagnostics.Process.Start("http://storage.googleapis.com/musesdk/musesdk-2.4.2-windows-installer.exe");
            }
            else
            {
              MessageBox.Show("You can manually launch Muse-IO with this command: \r\nmuse-io --preset 14 --device Muse --osc osc.tcp://localhost:5000", "Muse IO Command Line", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
            }
              }

              if (musePath != "")
              {
            museIO = Process.Start(musePath, "muse-io --preset 14 --osc osc.tcp://localhost:5000");
              }

              oscServer = new OscServer(TransportType.Tcp, IPAddress.Loopback, 5000);

              oscServer.FilterRegisteredMethods = false;
              oscServer.RegisterMethod(AliveMethod);
              oscServer.RegisterMethod(TestMethod);
              oscServer.BundleReceived += oscServer_BundleReceived;
              oscServer.MessageReceived += oscServer_MessageReceived;
              oscServer.ConsumeParsingExceptions = false;

              oscServer.Start();

              m_boolInitialized = true;
              return true;
            }

            if (m_boolInitialized)
              return true;
              }
              catch (Exception ex)
              {
            m_boolInitError = true;
            throw (new Exception("The 'Muse' plugin failed to initialize: " + ex.Message));
              }
              return false;
        }
        //Start OSC receiver
        private void btnStartOSCRecv_Click(object sender, RoutedEventArgs e)
        {
            //Get the transport type
            if ((string)cmbbOSCRecvType.SelectedItem == UDP_STRING)
            {
                receiver_ipendpoint = new IPEndPoint(IPAddress.Loopback, Convert.ToInt32(txtOSCRecvPort.Text));
                osc_receiver = new OscServer(TransportType.Udp, IPAddress.Loopback, Convert.ToInt32(txtOSCRecvPort.Text));
            }
            else if ((string)cmbbOSCRecvType.SelectedItem == TCP_STRING)
            {
                receiver_ipendpoint = new IPEndPoint(IPAddress.Loopback, Convert.ToInt32(txtOSCRecvPort.Text));
                osc_receiver = new OscServer(TransportType.Tcp, IPAddress.Loopback, Convert.ToInt32(txtOSCRecvPort.Text));
            }
            else
            {
                //Do nothing
                Debug.WriteLine("Receiver transport type not recognized");
                return;
            }


            osc_receiver.FilterRegisteredMethods = false;
            osc_receiver.RegisterMethod(DEMO_METHOD);
            //To receive from OSC demo app
            string AliveMethod = "/osctest/alive";
            string TestMethod = "/osctest/test";
            osc_receiver.RegisterMethod(AliveMethod);
            osc_receiver.RegisterMethod(TestMethod);

            osc_receiver.BundleReceived += new EventHandler<OscBundleReceivedEventArgs>(osc_receiver_BundleReceived);
            osc_receiver.MessageReceived += new EventHandler<OscMessageReceivedEventArgs>(osc_receiver_MessageReceived);
            osc_receiver.ReceiveErrored += new EventHandler<Bespoke.Common.ExceptionEventArgs>(osc_receiver_ReceiveErrored);
            osc_receiver.ConsumeParsingExceptions = false;
            osc_receiver.Start();
            btnStartOSCRecv.IsEnabled = false;
            cmbbOSCRecvType.IsEnabled = false;
            txtOSCRecvPort.IsEnabled = false;
        }
Exemple #16
0
        private void ConnectOSCListener()
        {
            if (_casparDevice.IsConnected)
            {
                changeControlStatus(true);
                label1.Text = "Connecting to CasparCG (OSC)";
                changeControlStatus(false);

                Logger.Info("OSC Client Connect");
                _oscServer = new OscServer(Bespoke.Common.Net.TransportType.Tcp, IPAddress.Parse(casparServerIp), casparServerOscPort);

                _oscServer.MessageReceived += oscServerMessageReceived;
                //_oscServer.Connected += new OscServerConnectedHandler(osc_server_Connected);
                //_oscServer.Disconnected += new OscServerDisconnectedHandler(osc_server_Disconnected);
                //Need to build in Connected/Disconnected/FailedConnect Event Handlers
                _oscServer.FilterRegisteredMethods = false;
                _oscServer.Start();
            }
        }
        private void StartServer()
        {
            //Start a Listening server populated with computer's own IP address and port 53001
            string host = Dns.GetHostName();
            IPHostEntry ip = Dns.GetHostEntry(host);
            server = new OscServer(TransportType.Udp, ip.AddressList[1], 53001); //ME on 53001

            server.PacketReceived += new EventHandler<OscPacketReceivedEventArgs>(server_PacketReceived);

            server.Start();
        }
        /// <summary>
        /// Execute startup tasks
        /// </summary>
        /// <param name="sender">object sending the event</param>
        /// <param name="e">event arguments</param>
        private void WindowLoaded(object sender, RoutedEventArgs e)
        {
            inFlag = false;
            outFlag = false;
            dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
            dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
            dispatcherTimer.Interval = new TimeSpan(0, 0, 1);
            dispatcherTimer.Start();
            kinectServerIP.Address = IPAddress.Parse(MySettings.Default.kinectServerIPSetting);
            kinectServerIP.Port = MySettings.Default.kinectServerPortSetting;
            cmdServerIP.Address = IPAddress.Parse(MySettings.Default.cmdServerIPSetting);
            cmdServerIP.Port = MySettings.Default.cmdServerPortSetting;

            kinectIpInput.Text = kinectServerIP.Address.ToString();
            kinectPortInput.Text = kinectServerIP.Port.ToString();
            cmdIpInput.Text = cmdServerIP.Address.ToString();
            cmdPortInput.Text = cmdServerIP.Port.ToString();

            kinectHeight = MySettings.Default.kinectHeightSetting;
            startPosition = MySettings.Default.startPositionSetting;
            endPosition = MySettings.Default.endPositionSetting;
            kinectOffset = MySettings.Default.kinectOffsetSetting;

            kinectHeightInput.Text = kinectHeight.ToString();
            startPositionInput.Text = startPosition.ToString();
            endPositionInput.Text = endPosition.ToString();
            kinectOffsetInput.Text = kinectOffset.ToString();

            // show my ip address
            ipShowTextBlock.Text = LocalIPAddress();

            frameCount = 0;
            userPosition = -100;

            currentPosition = 0;
            pastPosition = 0;

            //moveStep = 0.005;

            kinectID = MySettings.Default.kinectIDSetting;
            if (kinectID == 1)
            {
                kinectIDText.Text = "Front";
            }
            else if (kinectID == 2)
            {
                kinectIDText.Text = "Back";
            }
            kinectIDInput.Text = kinectID.ToString();

            kinectMsgAddr = "/kinect/" + kinectID.ToString();

            // Create the drawing group we'll use for drawing
            this.drawingGroup = new DrawingGroup();

            // Create an image source that we can use in our image control
            this.imageSource = new DrawingImage(this.drawingGroup);

            // Display the drawing using our image control
            Image.Source = this.imageSource;

            // Look through all sensors and start the first connected one.
            // This requires that a Kinect is connected at the time of app startup.
            // To make your app robust against plug/unplug,
            // it is recommended to use KinectSensorChooser provided in Microsoft.Kinect.Toolkit (See components in Toolkit Browser).
            foreach (var potentialSensor in KinectSensor.KinectSensors)
            {
                if (potentialSensor.Status == KinectStatus.Connected)
                {
                    this.sensor = potentialSensor;
                    break;
                }
            }

            if (null != this.sensor)
            {
                // smoothing parameter
                /*
                // Some smoothing with little latency (defaults).
                // Only filters out small jitters.
                // Good for gesture recognition in games.
                TransformSmoothParameters smoothingParam = new TransformSmoothParameters();
                {
                    smoothingParam.Smoothing = 0.5f;
                    smoothingParam.Correction = 0.5f;
                    smoothingParam.Prediction = 0.5f;
                    smoothingParam.JitterRadius = 0.05f;
                    smoothingParam.MaxDeviationRadius = 0.04f;
                };
                */

                // Smoothed with some latency.
                // Filters out medium jitters.
                // Good for a menu system that needs to be smooth but
                // doesn't need the reduced latency as much as gesture recognition does.
                TransformSmoothParameters smoothingParam = new TransformSmoothParameters();
                {
                    smoothingParam.Smoothing = 0.5f;
                    smoothingParam.Correction = 0.1f;
                    smoothingParam.Prediction = 0.5f;
                    smoothingParam.JitterRadius = 0.1f;
                    smoothingParam.MaxDeviationRadius = 0.1f;
                };

                // Very smooth, but with a lot of latency.
                // Filters out large jitters.
                // Good for situations where smooth data is absolutely required
                // and latency is not an issue.

                //TransformSmoothParameters smoothingParam = new TransformSmoothParameters();
                //{
                //    smoothingParam.Smoothing = 0.7f;
                //    smoothingParam.Correction = 0.3f;
                //    smoothingParam.Prediction = 1.0f;
                //    smoothingParam.JitterRadius = 1.0f;
                //    smoothingParam.MaxDeviationRadius = 1.0f;
                //};

                // Turn on the skeleton stream to receive skeleton frames
                //this.sensor.SkeletonStream.Enable();
                this.sensor.SkeletonStream.Enable(smoothingParam);

                // Add an event handler to be called whenever there is new color frame data
                this.sensor.SkeletonFrameReady += this.SensorSkeletonFrameReady;

                // Start the sensor!
                try
                {
                    this.sensor.Start();
                    kinectAngle = this.sensor.ElevationAngle;
                    angleText.Text = kinectAngle.ToString();
                    //this.sensor.ElevationAngle = -23;
                    ResetFrameRateCounters();
                }
                catch (IOException)
                {
                    this.sensor = null;
                }
                catch (Exception ex)
                {
                    Trace.WriteLine(ex.ToString());
                }
            }

            if (null == this.sensor)
            {
                this.statusBarText.Text = Properties.Resources.NoKinectReady;
            }

               //oscCmdReceiver = new OscServer(TransportType.Udp, IPAddress.Loopback, cmdServerPort);
            oscCmdReceiver = new OscServer(TransportType.Udp, IPAddress.Parse(LocalIPAddress()), cmdServerPort);
            //oscCmdReceiver = new OscServer(IPAddress.Parse("224.25.26.27"), cmdServerPort);
            oscCmdReceiver.FilterRegisteredMethods = false;
            //oscCmdServer.RegisterMethod(oscCmd);
            oscCmdReceiver.RegisterMethod(kinectMsgAddr);
            oscCmdReceiver.BundleReceived += new EventHandler<OscBundleReceivedEventArgs>(oscCmdReceiver_BundleReceived);
            oscCmdReceiver.MessageReceived += new EventHandler<OscMessageReceivedEventArgs>(oscCmdReceiver_MessageReceived);
            oscCmdReceiver.ReceiveErrored += new EventHandler<ExceptionEventArgs>(oscCmdReceiver_ReceiveErrored);
            oscCmdReceiver.ConsumeParsingExceptions = false;
            oscCmdReceiver.Start();
        }
Exemple #19
0
        void setupOSC()
        {
            //OSC
            kinectServer1 = new OscServer(TransportType.Udp, IPAddress.Any, kinectPort1, kinectAddress1, Bespoke.Common.Net.TransmissionType.Unicast);
            kinectServer2 = new OscServer(TransportType.Udp, IPAddress.Any, kinectPort2, kinectAddress2, Bespoke.Common.Net.TransmissionType.Unicast);
            kinectServer1.FilterRegisteredMethods = true;
            kinectServer1.BundleReceived += new OscBundleReceivedHandler(kinect1Updated);
            kinectServer2.BundleReceived += new OscBundleReceivedHandler(kinect2Updated);

            //start listening
            kinectServer1.Start();
            kinectServer2.Start();
        }
Exemple #20
0
        private void Worker_DoWork(object sender, DoWorkEventArgs e)
        {
            debug("Running background worker");
            debug("Starting server on " + ipAddress.ToString() + ":" + port);

            server = new OscServer(TransportType.Udp, ipAddress, port);

            server.BundleReceived += Server_BundleReceived;
            server.MessageReceived += Server_MessageReceived;
            server.PacketReceived += Server_PacketReceived;
            server.ReceiveErrored += Server_ReceiveErrored;

            server.Start();
        }
Exemple #21
0
		public static void Main(string[] args)
		{
            OscServer oscServer;
            DemoType demoType = /*GetDemoType();*/ DemoType.Udp;
            switch (demoType)
            {
                case DemoType.Udp:
                    oscServer = new OscServer(TransportType.Udp, IPAddress.Any, Port);
                    break;

                case DemoType.Tcp:
                    oscServer = new OscServer(TransportType.Tcp, IPAddress.Loopback, Port);
                    break;

                case DemoType.Multicast:
                    oscServer = new OscServer(IPAddress.Parse("224.25.26.27"), Port);
                    break;

                default:
                    throw new Exception("Unsupported receiver type.");
            }
            
            oscServer.FilterRegisteredMethods = false;
			oscServer.RegisterMethod(AliveMethod);
            oscServer.RegisterMethod(TestMethod);
            oscServer.RegisterMethod(MouseMethod);
            oscServer.BundleReceived += new EventHandler<OscBundleReceivedEventArgs>(oscServer_BundleReceived);
			oscServer.MessageReceived += new EventHandler<OscMessageReceivedEventArgs>(oscServer_MessageReceived);
            oscServer.ReceiveErrored += new EventHandler<ExceptionEventArgs>(oscServer_ReceiveErrored);
            oscServer.ConsumeParsingExceptions = false;

            handsets = new VirtualHandset[HANDSET_COUNT];
            motorMin = new int[HANDSET_COUNT];
            motorMax = new int[HANDSET_COUNT];

            String[] comPorts = { "COM9", "COM4", "COM5", "COM6", "COM7", "COM8" };
            for ( int i=0; i<HANDSET_COUNT; i++ ) {
                VirtualHandset handset = new VirtualHandset();
                int result = handset.Connect(comPorts[i]);
                if (result != 0) {
                    // -20 = virtual com port device not found (USB unplugged)
                    // -30 = com port found but couldn't connect to hardware
                    Console.WriteLine("error " + result + " opening " + comPorts[i]);
                    continue;
                }

                VirtualHandset.ControlUnitSettings settings = new VirtualHandset.ControlUnitSettings();
                result = handset.GetAllSettings( ref settings );
                if (result == 0)
                {
                    Console.Write(comPorts[i]+": OEM Information: "+(char)settings.OEMInformation[0]+" "+(char)settings.OEMInformation[1]+
                        " "+(char)settings.OEMInformation[2]+" "+(char)settings.OEMInformation[3]+" (" +(settings.OEMInformation.Length-4)+" more) ");

                }
                else
                {
                    Console.WriteLine("error " + result + " getting control unit settings for " + comPorts[i]);
                    continue;
                }

                int handsetIndex = 0;
                if ((char)settings.OEMInformation[0] == 'L')
                    handsetIndex = 0;
                else if ((char)settings.OEMInformation[0] == 'R')
                    handsetIndex = 3;
                else
                {
                    Console.WriteLine(comPorts[i] + ": invalid OEMInformation[0] '" + (char)settings.OEMInformation[0] + "' (should be 'L' or 'R')");
                    continue;
                }

                if ((char)settings.OEMInformation[1] == '1')
                    handsetIndex += 0;
                else if ((char)settings.OEMInformation[1] == '2')
                    handsetIndex += 1;
                else if ((char)settings.OEMInformation[1] == '3')
                    handsetIndex += 2;
                else
                {
                    Console.WriteLine(comPorts[i] + ": invalid OEMInformation[1] '" + (char)settings.OEMInformation[1] + "' (should be '1', '2' or '3')");
                    continue;
                }

                handsets[handsetIndex] = handset;
                motorMin[handsetIndex] = settings.LowerLimit[0] + 1; // don't drive right to the very limit
                motorMax[handsetIndex] = settings.UpperLimit[0] - 1; // don't drive right to the very limit
                Console.WriteLine( " lower " + motorMin[handsetIndex] + " upper " + motorMax[handsetIndex] );
                Console.WriteLine("  -> assigning handset to index " + handsetIndex);

                // add event-handler for synchronizing the PC after driving
                //handsets[handsetIndex].OnSynchronizeAfterDriving += new VirtualHandset.OnSynchronizeAfterDrivingDelegate(onSynchronizeAfterDriving);

            }

            for (int i = 0; i < HANDSET_COUNT; i++)
            {
                if (handsets[i] == null)
                {
                    Console.WriteLine("handset " + i + " missing, filling in with dummy");
                    handsets[i] = new VirtualHandset();
                }
               // moveMotorToPosition(i, INITIAL_POS);
            }

            oscServer.Start();

            // figure out my ip address
            IPHostEntry host;
            string localIP = "?";
            host = Dns.GetHostEntry(Dns.GetHostName());
            foreach (IPAddress ip in host.AddressList)
            {
                if (ip.AddressFamily.ToString() == "InterNetwork")
                {
                    localIP = ip.ToString();
                }
            }
			Console.WriteLine("Osc Receiver: " + demoType.ToString() + " listening on address " + localIP + " port " + Port );
			Console.WriteLine("Press any key to exit.");
			Console.ReadKey();

			oscServer.Stop();

            for (int i = 0; i < HANDSET_COUNT; i++)
            {
                if (handsets[i] == null)
                    continue;
                handsets[i].Disconnect();
                handsets[i].Dispose();
            }

		}