Exemple #1
0
        private static OscBundle CreateTestBundle()
        {
            IPEndPoint sourceEndPoint = new IPEndPoint(IPAddress.Loopback, Port);
            OscBundle  bundle         = new OscBundle(sourceEndPoint);

            OscBundle  nestedBundle  = new OscBundle(sourceEndPoint);
            OscMessage nestedMessage = new OscMessage(sourceEndPoint, TestMethod);

            nestedMessage.AppendNil();
            nestedMessage.Append("Some String");
            nestedMessage.Append(10);
            nestedMessage.Append(100000L);
            nestedMessage.Append(1234.567f);
            nestedMessage.Append(10.0012345);
            nestedMessage.Append(new byte[] { 1, 2, 3, 4 });
            nestedMessage.Append(new OscTimeTag());
            nestedMessage.Append('c');
            nestedMessage.Append(Color.DarkGoldenrod);
            nestedMessage.Append(true);
            nestedMessage.Append(false);
            nestedMessage.Append(float.PositiveInfinity);
            nestedBundle.Append(nestedMessage);
            bundle.Append(nestedBundle);

            OscMessage message = new OscMessage(sourceEndPoint, AliveMethod);

            message.Append(9876.543f);
            bundle.Append(message);

            return(bundle);
        }
Exemple #2
0
        public void sendMessage(String address, String data)
        {
            OscBundle  bundle  = new OscBundle(solidworksPlugin);
            OscMessage message = new OscMessage(solidworksPlugin, address, data);

            bundle.Append(message);
            bundle.Send(openFrameworks);
        }
Exemple #3
0
        public void SendMessage(SensorData sensor1Data, SensorData sensor2Data)
        {
            OscBundle sBundle = new OscBundle(_sourceEndPoint);

            OscMessage dataOscMessage = CreateOscMessage(sensor1Data);

            sBundle.Append(dataOscMessage);

            dataOscMessage = CreateOscMessage(sensor2Data);
            sBundle.Append(dataOscMessage);

            _oscMessageQueue.Enqueue(dataOscMessage);

            //MemoryStream memoryStream = new MemoryStream();
            //Resources.Image.Save(memoryStream, ImageFormat.Jpeg);

            //oscMessage.Append(memoryStream.ToArray());

            //sSendMessages = false;
        }
Exemple #4
0
    //  sends the messages stored in messagesThisFrame as a bundle, then clears messagesThisFrame
    private void SendBundle()
    {
        OscBundle frameBundle = new OscBundle(localEndPoint);

        foreach (OscMessage message in messagesThisFrame)
        {
            frameBundle.Append(message);
        }
        //UnityEngine.Debug.Log("sending bundle");
        frameBundle.Send(externalEndPoint);

        messagesThisFrame.Clear();
    }
Exemple #5
0
        private void AppendToBundle <T>(OscBundle oscBundle, OscMessage sourceMsg, OscMessage aliveMsg, OscMessage fseqMsg, bool forceSet = false) where T : ITUIOEntity
        {
            // http://www.tuio.org/?specification - Message & Bundle Format
            //
            // /tuio/2Dcur source application@address
            // /tuio/2Dcur alive s_id0 ... s_idN
            // /tuio/2Dcur set s x y X Y m
            // /tuio/2Dcur fseq f_id
            //
            // nb. TUIOsharp does not enforce an order for alive/set messages so long as they're before fseq

            oscBundle.Append(sourceMsg);

            // entities: alive, set
            aliveMsg.ClearData();             // nb. also clears address
            aliveMsg.Append("alive");

            oscBundle.Append(aliveMsg);

            for (int i = 0; i < _entities.Count; i++)
            {
                ITUIOEntity e = _entities[i];
                if (e.GetType() != typeof(T))
                {
                    continue;
                }

                aliveMsg.Append(e.Id);
                if (forceSet || e.isSendRequired)
                {
                    oscBundle.Append(e.oscMessage);                     // set
                    e.isSendRequired = false;
                }
            }

            // frame sequence
            fseqMsg.UpdateDataAt(1, fseq);
            oscBundle.Append(fseqMsg);
        }
        private OscBundle CreateBundle()
        {
            var ipAddress      = _setting.UseLoopback ? IPAddress.Loopback : IPAddress.Parse(_setting.IpAddress);
            var sourceEndPoint = new IPEndPoint(ipAddress, _setting.Port);
            var bundle         = new OscBundle(sourceEndPoint);

            var nestedBundle = new OscBundle(sourceEndPoint);

            foreach (var bindValue in _setting.BindValues)
            {
                var message = new OscMessage(sourceEndPoint, bindValue.Address);
                message.Append(bindValue.Value);
                nestedBundle.Append(message);
            }
            bundle.Append(nestedBundle);
            return(bundle);
        }
Exemple #7
0
        private static OscBundle CreateTestBundle()
        {
            //Program.ipAddress = IPAddress.Parse("192.168.1.126");
            //Program.ipAddress = IPAddress.Loopback;
            IPEndPoint sourceEndPoint = new IPEndPoint(Program.ipAddress, Properties.Settings.Default.Port);
            OscBundle  bundle         = new OscBundle(sourceEndPoint);

/*
 *          OscBundle nestedBundle = new OscBundle(sourceEndPoint);
 *          OscMessage nestedMessage = new OscMessage(sourceEndPoint, TestMethod);
 *          nestedMessage.AppendNil();
 *          nestedMessage.Append("Some String");
 *          nestedMessage.Append(10);
 *          nestedMessage.Append(100000L);
 *          nestedMessage.Append(1234.567f);
 *          nestedMessage.Append(10.0012345);
 *          nestedMessage.Append(new byte[] { 1, 2, 3, 4 });
 *          nestedMessage.Append(new OscTimeTag());
 *          nestedMessage.Append('c');
 *          nestedMessage.Append(Color.DarkGoldenrod);
 *          nestedMessage.Append(true);
 *          nestedMessage.Append(false);
 *          nestedMessage.Append(float.PositiveInfinity);
 *          nestedBundle.Append(nestedMessage);
 *          bundle.Append(nestedBundle);
 *
 *          OscMessage message = new OscMessage(sourceEndPoint, AliveMethod);
 *          message.Append(9876.543f);
 *          bundle.Append(message);
 *
 *          OscMessage pingMessage = new OscMessage(sourceEndPoint, PingMethod);
 *          bundle.Append(pingMessage);
 */

            OscMessage labelMessage = new OscMessage(sourceEndPoint, LabelMethod);

            bundle.Append(labelMessage);

            return(bundle);
        }
Exemple #8
0
        private OscBundle GetFrameBundle()
        {
            OscBundle bundle = new OscBundle(_ipEndPoint);

            bundle.Append(GetAliveMessage());
            foreach (OscMessage msg in GetCursorMessages())
            {
                bundle.Append(msg);
            }
            bundle.Append(GetSequenceMessage());

            return bundle;
        }
Exemple #9
0
        /// <summary>
        /// Sends a single packet synchronously to each destination device, with the given pairs
        /// of OSC addresses and data objects</summary>
        /// <param name="addressesAndData">The list of pairs</param>
        /// <param name="first">The index of the first pair to send</param>
        /// <param name="count">The number of pairs to send</param>
        protected void SendPacket(IList<Tuple<string, object>> addressesAndData, int first, int count)
        {
            if (addressesAndData.Count < first + count)
                return;

            OscPacket packet;
            if (count == 1)
            {
                packet = new OscMessage(ReceivingEndpoint, addressesAndData[first].Item1, addressesAndData[first].Item2);
            }
            else
            {
                var bundle = new OscBundle(ReceivingEndpoint, null);
                for (int i = first; i < first + count; i++)
                {
                    Tuple<string, object> tuple = addressesAndData[i];
                    var message = new OscMessage(ReceivingEndpoint, tuple.Item1, tuple.Item2);
                    bundle.Append(message);
                }
                packet = bundle;
            }

            foreach (IPEndPoint destination in DestinationEndpoints)
            {
                packet.Send(destination);
                NumMessagesEverSent++;
            }
        }
        //Return an OSC bundle for skeleton index provided
        /*
        OscBundle skeletonToOSCBundle(Skeleton s, int index)
        {
            Skeleton2DdataCoordEventArgs e = Skeleton2DDataExtract.skeletonToSkeleton2DdataCoordEventArgs(s, index);
            return skeleton2DdataCoordEventArgsToOSCBundle(e);
        }
         */

        OscBundle skeleton2DdataCoordEventArgsToOSCBundle(Skeleton2DdataCoordEventArgs e)
        { 
            //Bundles are collections of messages
            OscBundle bundle = new OscBundle(transmitter_ipendpoint);
            //Messages are like packets, label with their type by method name
            OscMessage message = new OscMessage(transmitter_ipendpoint, SKELETON_METHOD);
            //Both bundles and messages can be nested
            //Must have at least one bundle and on message

            //Send the whole skeleton
            //Send packet number
            message.Append(sent_bundles);
            //Debug.WriteLine("Sent bundle: " + sent_bundles);
            //Send the index
            message.Append(e.index);
            //Then append each point in order, x then y
            int num_points = e._points.Count();
            for (int i = 0; i < num_points; i++)
            {
                Point normalized_point = normalize_skeleton_point(e._points[i]);
                message.Append((float)normalized_point.X);
                message.Append((float)normalized_point.Y);
            }
            message.Append(kinect_id); //#19
            //There are 19 things appended to this message. If you add more,
            //you must change the numSkeletonOSCArgs in the c++ code

            bundle.Append(message);
            return bundle;
        }
        OscBundle skeleton2DdataCoordEventArgsToOSCBundle(Skeleton2DdataCoordEventArgs e)
        { 
            //Bundles are collections of messages
            OscBundle bundle = new OscBundle(transmitter_ipendpoint);
            //Messages are like packets, label with their type by method name
            OscMessage message = new OscMessage(transmitter_ipendpoint, DEMO_METHOD);
            //Both bundles and messages can be nested
            //Must have at least one bundle and on message

            //Send the whole skeleton
            //First send the index
            message.Append(e.index);
            //Then append each point in order, x then y
            int num_points = e._points.Count();
            for (int i = 0; i < num_points; i++)
            {
                Point normalized_point = normalize_skeleton_point(e._points[i]);
                message.Append((float)normalized_point.X);
                message.Append((float)normalized_point.Y);
            }
            bundle.Append(message);
            return bundle;
        }
 public static void SendOSCMessages(List<string> Addresses)
 {
     sourceEndPoint = new IPEndPoint(serverIPAddress, 53000);
     OscBundle bundle = new OscBundle(sourceEndPoint);
     foreach (string Address in Addresses)
         bundle.Append(OSCMessage.CreateMessage(Address));
     bundle.Send(sourceEndPoint);
 }
Exemple #13
0
        private static OscBundle CreateTestBundle()
        {
            IPEndPoint sourceEndPoint = new IPEndPoint(IPAddress.Loopback, Port);
            OscBundle bundle = new OscBundle(sourceEndPoint);

            OscBundle nestedBundle = new OscBundle(sourceEndPoint);
            OscMessage nestedMessage = new OscMessage(sourceEndPoint, TestMethod);
            nestedMessage.AppendNil();
            nestedMessage.Append("Some String");
            nestedMessage.Append(10);
            nestedMessage.Append(100000L);
            nestedMessage.Append(1234.567f);
            nestedMessage.Append(10.0012345);
            nestedMessage.Append(new byte[] { 1, 2, 3, 4 });
            nestedMessage.Append(new OscTimeTag());
            nestedMessage.Append('c');
            nestedMessage.Append(Color.DarkGoldenrod);
            nestedMessage.Append(true);
            nestedMessage.Append(false);
            nestedMessage.Append(float.PositiveInfinity);
            nestedBundle.Append(nestedMessage);
            bundle.Append(nestedBundle);

            OscMessage message = new OscMessage(sourceEndPoint, AliveMethod);
            message.Append(9876.543f);
            bundle.Append(message);

            return bundle;
        }
Exemple #14
0
        private static OscPacket DeserialiseBundle(JsonReader reader)
        {
            reader.Read(); // property timetag
            reader.Read();
            var tag = (ulong)Convert.ChangeType(reader.Value, typeof(ulong));

            var ret = new OscBundle(new OscTimeTag(tag));

            while (reader.TokenType != JsonToken.EndObject) // empty bundle
            {
                if (reader.TokenType == JsonToken.PropertyName)
                {
                    if (reader.ValueType == typeof(string) && StringComparer.OrdinalIgnoreCase.Compare(reader.Value, "messages") == 0) // mesages found
                    {
                        // messages
                        while (reader.TokenType != JsonToken.StartArray)
                        {
                            reader.Read(); // start array
                        }

                        while (reader.TokenType != JsonToken.EndArray)
                        {
                            if (reader.TokenType == JsonToken.StartObject)
                            {
                                var msg = CreateFromJson(reader) as OscMessage;
                                if (msg != null)
                                {
                                    ret.Append(msg);
                                }
                            }
                            else
                            {
                                reader.Read();
                            }
                        }
                    }
                    else if (reader.ValueType == typeof(string) && StringComparer.OrdinalIgnoreCase.Compare(reader.Value, "bundles") == 0) // nested bundles
                    {
                        // messages
                        while (reader.TokenType != JsonToken.StartArray)
                        {
                            reader.Read(); // start array
                        }

                        while (reader.TokenType != JsonToken.EndArray)
                        {
                            if (reader.TokenType == JsonToken.StartObject)
                            {
                                var bundle = CreateFromJson(reader) as OscBundle;
                                if (bundle != null)
                                {
                                    ret.Append(bundle);
                                }
                            }
                            else
                            {
                                reader.Read();
                            }
                        }
                    }
                }
                else
                {
                    reader.Read();
                }
            }

            return(ret);
        }
        public void SendMessage(SensorData sensor1Data, SensorData sensor2Data)
        {
            OscBundle sBundle = new OscBundle(_sourceEndPoint);

            OscMessage dataOscMessage = CreateOscMessage(sensor1Data);
            sBundle.Append(dataOscMessage);

            dataOscMessage = CreateOscMessage(sensor2Data);
            sBundle.Append(dataOscMessage);

            _oscMessageQueue.Enqueue(dataOscMessage);

            //MemoryStream memoryStream = new MemoryStream();
            //Resources.Image.Save(memoryStream, ImageFormat.Jpeg);

            //oscMessage.Append(memoryStream.ToArray());

            //sSendMessages = false;
        }