예제 #1
0
        /**
         * The TuioClient stops listening to TUIO messages on the configured UDP port
         */
        public void disconnect()
        {
            if (receiver!=null) receiver.Close();
                receiver = null;

                connected = false;
        }
예제 #2
0
 private void buttonConnect_Click(object sender, System.EventArgs e)
 {
     //osc = new OSCUDPTalk(textBoxRemoteHost.Text, int.Parse(textBoxRemotePort.Text), int.Parse(textBoxLocalPort.Text), true);
     transmitter = new OSCTransmitter(textBoxRemoteHost.Text, int.Parse(textBoxRemotePort.Text));
     receiver    = new OSCReceiver(int.Parse(textBoxLocalPort.Text));
     updateComponents(true);
     listenerThread = new Thread(new ThreadStart(this.receive));
     listenerThread.Start();
 }
예제 #3
0
		public void connect() {
			try {
				receiver = new OSCReceiver(port);
				startListening();
				
			} catch (Exception e) {
				Console.WriteLine("failed to connect to port "+port);
				Console.WriteLine(e.Message);
			}
		}
예제 #4
0
 /**
  * The TuioClient starts listening to TUIO messages on the configured UDP port
  * All reveived TUIO messages are decoded and the resulting TUIO events are broadcasted to all registered TuioListeners
  */
 public void connect()
 {
     try {
         receiver = new OSCReceiver(port);
         connected = true;
         statusString = "Thread Started";
         thread = new Thread(new ThreadStart(listen));
         thread.Start();
     } catch (Exception e) {
         Console.WriteLine("failed to connect to port "+port);
         Console.WriteLine(e.Message);
         statusString = "failed to connect to port " + port + " " + e.Message;
         Console.WriteLine(statusString);
     }
 }
예제 #5
0
 private void disconnect()
 {
     if (transmitter != null)
     {
         transmitter.Close();
     }
     if (receiver != null)
     {
         receiver.Close();
     }
     if (listenerThread != null)
     {
         listenerThread.Abort();
     }
     listenerThread = null;
     receiver       = null;
     transmitter    = null;
 }
        private void oscListenerLoop()
        {
            OSCReceiver oscReceiver = null;
            OSCMessage oscWiimoteData = null;

            oscStopNow = false;

            double[] beams = new double[200];

            beams[0] = 0.0d;
            beams[1] = 0.0d;
            beams[2] = 0.0d;

            double accel = 0.0d;
            double accelBase = 0.0d;
            double speed = 0.0d;
            double dist = 0.0d;
            double dT = 0.0d;
            double par4 = 0.0d;

            long currTick;
            long prevTick;

            currTick = prevTick = DateTime.Now.Ticks;

            try
            {
                int oscPort = Convert.ToInt32(oscPortTextBox.Text);

                oscReceiver = new OSCReceiver(oscPort);

                oscReceiver.Connect();

                Tracer.Trace("OSC connected and listening on port " + oscPort);

                while (!oscStopNow && (oscWiimoteData = (OSCMessage)oscReceiver.Receive()) != null)
                {
                    string addr = oscWiimoteData.Address;

                    if (wiiValuesControls.ContainsKey(addr))
                    {
                        wiimoteValuesUserControl = (WiimoteValuesUserControl)wiiValuesControls[addr];
                    }
                    else
                    {
                        this.Invoke(new MethodInvoker(createWiimoteValuesUserControl));
                        wiiValuesControls.Add(addr, wiimoteValuesUserControl);
                    }

                    wiimoteValuesUserControl.values = oscWiimoteData;

                    switch (addr)
                    {
                        case "/wiimote-g":

                            currTick = DateTime.Now.Ticks;

                            dT = (double)(currTick - prevTick) / 10000000.0d;       // sec

                            //   string str = DateTime.Now.ToLongTimeString() + "  OSC packet: " + oscWiimoteData.Address + "   ";

                            int i = 0;

                            foreach (object obj in oscWiimoteData.Values)
                            {
                                //                        str += obj.ToString() + "   ";
                                if (i == 0)
                                {
                                    try
                                    {
                                        beams[i] = Convert.ToDouble((float)obj);
                                    }
                                    catch
                                    {
                                        beams[i] = 0.0d;
                                    }
                                    accel = beams[i];  //  m/c2
                                }
                                if (i == 4)
                                {
                                    try
                                    {
                                        beams[i] = Convert.ToDouble((float)obj);
                                    }
                                    catch
                                    {
                                        beams[i] = 0.0d;
                                    }
                                    par4 = beams[i];
                                }
                                i++;
                            }

                            if (par4 > 0.0d)
                            {
                                accelBase = accel;
                                speed = 0.0d;
                                dist = 0.0d;
                            }
                            else
                            {
                                accel -= accelBase;
                                speed += accel * dT;
                                dist += speed * dT;
                            }

                            // oscilloscope.AddData(beams[0], beams[1], beams[2]);

                            oscilloscope.AddData(accel, speed * 100.0d, dist * 100.0d);

                            //                    Tracer.Trace(str.Trim());

                            prevTick = currTick;
                            break;
                    }
                }
            }
            catch (Exception exc)
            {
                Tracer.Error(exc.ToString());
            }
            finally
            {
                if (oscReceiver != null)
                {
                    oscReceiver.Close();
                }
                Tracer.Trace("OSC finished and closed");
            }
        }
예제 #7
0
        /**
         * The TuioClient starts listening to TUIO messages on the configured UDP port
         * All reveived TUIO messages are decoded and the resulting TUIO events are broadcasted to all registered TuioListeners
         */
        public void connect()
        {
            TuioTime.initSession();
            currentTime = new TuioTime();
            currentTime.reset();

            try {
                receiver = new OSCReceiver(port);
                thread = new Thread(new ThreadStart(listen));
                thread.Start();
                connected = true;
            } catch (Exception e) {
                Console.WriteLine("failed to connect to port "+port);
                Console.WriteLine(e.Message);
            }
        }
예제 #8
0
        /**
         * The TuioClient stops listening to TUIO messages on the configured UDP port
         */
        public void disconnect()
        {
            if (receiver!=null) receiver.Close();
                receiver = null;

                aliveObjectList.Clear();
                aliveCursorList.Clear();
                objectList.Clear();
                cursorList.Clear();
                freeCursorList.Clear();
                frameObjects.Clear();
                frameCursors.Clear();

                connected = false;
        }
예제 #9
0
 private void stopListening()
 {
     if (receiver != null)
         receiver.Close();
     thread.Abort();
     listening = false;
     receiver = null;
 }
예제 #10
0
        private void stopListening()
        {
            listening = false;

                if (receiver!=null) receiver.Close();

                receiver = null;
        }
예제 #11
0
 private void buttonConnect_Click(object sender, System.EventArgs e)
 {
     //osc = new OSCUDPTalk(textBoxRemoteHost.Text, int.Parse(textBoxRemotePort.Text), int.Parse(textBoxLocalPort.Text), true);
     transmitter = new OSCTransmitter(textBoxRemoteHost.Text, int.Parse(textBoxRemotePort.Text));
     receiver = new OSCReceiver(int.Parse(textBoxLocalPort.Text));
     updateComponents(true);
     listenerThread = new Thread(new ThreadStart(this.receive));
     listenerThread.Start();
 }
예제 #12
0
 private void disconnect()
 {
     if(transmitter != null) transmitter.Close();
     if(receiver != null) receiver.Close();
     if(listenerThread !=null) listenerThread.Abort();
     listenerThread = null;
     receiver = null;
     transmitter = null;
 }
/*