public override byte[] Serialize(bool partofsomethingelse)
        {
            int pos = 0;

            byte[] headerBytes = header.Serialize();
            byte[] goalIDBytes = goal_id.Serialize();
            byte[] goalBytes   = goal.Serialize();

            byte[] bytes = new byte[headerBytes.Length + goalBytes.Length + goalIDBytes.Length];
            headerBytes.CopyTo(bytes, 0);
            pos = headerBytes.Length;
            goalIDBytes.CopyTo(bytes, pos);
            pos += goalIDBytes.Length;
            goalBytes.CopyTo(bytes, pos);

            return(bytes);
        }
Ejemplo n.º 2
0
        public override byte[] Serialize(bool partofsomethingelse)
        {
            int  currentIndex = 0, length = 0;
            bool hasmetacomponents = false;

            byte[]        thischunk, scratch1, scratch2;
            List <byte[]> pieces = new List <byte[]>();
            GCHandle      h;

            //goal_id
            if (goal_id == null)
            {
                goal_id = new Messages.actionlib_msgs.GoalID();
            }
            pieces.Add(goal_id.Serialize(true));
            //status
            pieces.Add(new[] { (byte)status });
            //text
            if (text == null)
            {
                text = "";
            }
            scratch1  = Encoding.ASCII.GetBytes((string)text);
            thischunk = new byte[scratch1.Length + 4];
            scratch2  = BitConverter.GetBytes(scratch1.Length);
            Array.Copy(scratch1, 0, thischunk, 4, scratch1.Length);
            Array.Copy(scratch2, thischunk, 4);
            pieces.Add(thischunk);
            //combine every array in pieces into one array and return it
            int __a_b__f = pieces.Sum((__a_b__c) => __a_b__c.Length);
            int __a_b__e = 0;

            byte[] __a_b__d = new byte[__a_b__f];
            foreach (var __p__ in pieces)
            {
                Array.Copy(__p__, 0, __a_b__d, __a_b__e, __p__.Length);
                __a_b__e += __p__.Length;
            }
            return(__a_b__d);
        }
Ejemplo n.º 3
0
        public override byte[] Serialize(bool partofsomethingelse)
        {
            int  currentIndex = 0, length = 0;
            bool hasmetacomponents = false;

            byte[]        thischunk, scratch1, scratch2;
            List <byte[]> pieces = new List <byte[]>();
            GCHandle      h;

            //header
            if (header == null)
            {
                header = new Header();
            }
            pieces.Add(header.Serialize(true));
            //goal_id
            if (goal_id == null)
            {
                goal_id = new Messages.actionlib_msgs.GoalID();
            }
            pieces.Add(goal_id.Serialize(true));
            //goal
            if (goal == null)
            {
                goal = new Messages.object_recognition_msgs.ObjectRecognitionGoal();
            }
            pieces.Add(goal.Serialize(true));
            //combine every array in pieces into one array and return it
            int __a_b__f = pieces.Sum((__a_b__c) => __a_b__c.Length);
            int __a_b__e = 0;

            byte[] __a_b__d = new byte[__a_b__f];
            foreach (var __p__ in pieces)
            {
                Array.Copy(__p__, 0, __a_b__d, __a_b__e, __p__.Length);
                __a_b__e += __p__.Length;
            }
            return(__a_b__d);
        }