Exemplo n.º 1
0
        public override void Randomize()
        {
            int    arraylength = -1;
            Random rand        = new Random();
            int    strlength;

            byte[] strbuf, myByte;

            //header
            header = new Messages.std_msgs.Header();
            header.Randomize();
            //status
            status = rand.Next();
            //details
            strlength = rand.Next(100) + 1;
            strbuf    = new byte[strlength];
            rand.NextBytes(strbuf);  //fill the whole buffer with random bytes
            for (int __x__ = 0; __x__ < strlength; __x__++)
            {
                if (strbuf[__x__] == 0) //replace null chars with non-null random ones
                {
                    strbuf[__x__] = (byte)(rand.Next(254) + 1);
                }
            }
            strbuf[strlength - 1] = 0; //null terminate
            details = Encoding.ASCII.GetString(strbuf);
        }
 public override void Randomize()
 {
     header = new Messages.std_msgs.Header();
     header.Randomize();
     goal_id = new Messages.actionlib_msgs.GoalID();
     goal_id.Randomize();
     goal = new LandingGoal();
     goal.Randomize();
 }
Exemplo n.º 3
0
        public override void Randomize()
        {
            int    arraylength = -1;
            Random rand        = new Random();
            int    strlength;

            byte[] strbuf, myByte;

            //header
            header = new Messages.std_msgs.Header();
            header.Randomize();
            //system_status
            system_status = rand.Next();
            //topics
            arraylength = rand.Next(10);
            if (topics == null)
            {
                topics = new string[arraylength];
            }
            else
            {
                Array.Resize(ref topics, arraylength);
            }
            for (int i = 0; i < topics.Length; i++)
            {
                //topics[i]
                strlength = rand.Next(100) + 1;
                strbuf    = new byte[strlength];
                rand.NextBytes(strbuf);  //fill the whole buffer with random bytes
                for (int __x__ = 0; __x__ < strlength; __x__++)
                {
                    if (strbuf[__x__] == 0) //replace null chars with non-null random ones
                    {
                        strbuf[__x__] = (byte)(rand.Next(254) + 1);
                    }
                }
                strbuf[strlength - 1] = 0; //null terminate
                topics[i]             = Encoding.ASCII.GetString(strbuf);
            }
            //err_code
            arraylength = rand.Next(10);
            if (err_code == null)
            {
                err_code = new int[arraylength];
            }
            else
            {
                Array.Resize(ref err_code, arraylength);
            }
            for (int i = 0; i < err_code.Length; i++)
            {
                //err_code[i]
                err_code[i] = rand.Next();
            }
            //topic_msg
            arraylength = rand.Next(10);
            if (topic_msg == null)
            {
                topic_msg = new string[arraylength];
            }
            else
            {
                Array.Resize(ref topic_msg, arraylength);
            }
            for (int i = 0; i < topic_msg.Length; i++)
            {
                //topic_msg[i]
                strlength = rand.Next(100) + 1;
                strbuf    = new byte[strlength];
                rand.NextBytes(strbuf);  //fill the whole buffer with random bytes
                for (int __x__ = 0; __x__ < strlength; __x__++)
                {
                    if (strbuf[__x__] == 0) //replace null chars with non-null random ones
                    {
                        strbuf[__x__] = (byte)(rand.Next(254) + 1);
                    }
                }
                strbuf[strlength - 1] = 0; //null terminate
                topic_msg[i]          = Encoding.ASCII.GetString(strbuf);
            }
        }