Ejemplo n.º 1
0
        public static void GetState()
        {
            client = new TCP();

            byte[]  response = client.Send(new MultirotorState().GetCommand(), 1024);
            dynamic json     = JsonConvert.DeserializeObject(MessagePackSerializer.ConvertToJson(response));

            JToken parsed = JToken.Parse(MessagePackSerializer.ConvertToJson(response));
            JToken val    = parsed[3]["landed_state"];

            IsFlying = (bool)val;

            // 0 is landed
            // 1 is flying
            Debug.WriteLine(IsFlying);

            client.Close();
        }
Ejemplo n.º 2
0
        public void StartMissionLoop(ArrayList commands)
        {
            TCP client = new TCP();

            foreach (MessagePackCommand command in commands)
            {
                if (command.Method == "hover")
                {
                    int delay = Convert.ToInt32(command.args[0]);
                    Debug.WriteLine("Delaying for {0}", delay);
                    Thread.Sleep(delay);
                }
                else
                {
                    client.Send(command, 128);
                }

                // This may be unnecessary between commands
                Thread.Sleep(500);
            }

            client.Close();
        }