Exemplo n.º 1
0
        public void Schedule(int index = 0, int delay = 0)
        {
            System.Threading.Timer timer = new System.Threading.Timer(
                delegate(object state)
            {
                if (this.commandSchedule.Count <= index)
                {
                    return;
                }

                int scheduleTime = 0;
                if (commandSchedule[index].commandType == DroneCommandType.DRONE_FLYING)
                {
                    scheduleTime = 5000;
                }
                else if (commandSchedule[index].commandType == DroneCommandType.DRONE_PILOTING)
                {
                    scheduleTime = commandSchedule[index].sustainTime;
                }

                byte[] packetBytes = CommandPacketManager.SerializeCommand(this.commandSchedule[index]);
                byte temp          = packetBytes[packetBytes.Length - 1];
                packetBytes[packetBytes.Length - 1] = packetBytes[packetBytes.Length - 2];
                packetBytes[packetBytes.Length - 2] = temp;

                AddACKCheckEvent(delegate()
                {
                    mainForm.UpdateLog("schedule" + index.ToString() + " success");
                    Schedule(++this.scheduleIndex, scheduleTime + BebopDrone.SCHEDULE_WAIT_TERM);
                },
                                 2000,
                                 "Schedule time out.");
                server.WriteData(id, packetBytes);
            }, null, delay, System.Threading.Timeout.Infinite);
        }
Exemplo n.º 2
0
        // Device have to return ACK if device connect to drone
        public void CheckConnection()
        {
            CommandPacket packet =
                CommandPacketManager.CommandPack(DroneCommandType.ACK,
                                                 DroneFlyingMode.NONE);

            byte[] packetBytes = CommandPacketManager.SerializeCommand(packet);

            server.WriteData(id, packetBytes);
        }
Exemplo n.º 3
0
        // Device have to return ACK if device command to drone successfully
        public void Land()
        {
            CommandPacket packet =
                CommandPacketManager.CommandPack(DroneCommandType.DRONE_FLYING,
                                                 DroneFlyingMode.LAND);

            byte[] packetBytes = CommandPacketManager.SerializeCommand(packet);

            AddACKCheckEvent(delegate() { mainForm.UpdateLog("Land success"); },
                             2000,
                             "Land time out.");
            server.WriteData(id, packetBytes);
        }
Exemplo n.º 4
0
        // Device have to return ACK if drone move done successfully
        public void PCMD_Move(sbyte roll, sbyte pitch, sbyte yaw, sbyte gaz, short time)
        {
            // Move
            CommandPacket packet =
                CommandPacketManager.CommandPack(DroneCommandType.DRONE_PILOTING,
                                                 DroneFlyingMode.NONE,
                                                 roll, pitch, yaw, gaz, time);

            byte[] packetBytes = CommandPacketManager.SerializeCommand(packet);
            byte   temp        = packetBytes[packetBytes.Length - 1];

            packetBytes[packetBytes.Length - 1] = packetBytes[packetBytes.Length - 2];
            packetBytes[packetBytes.Length - 2] = temp;

            AddACKCheckEvent(delegate() { mainForm.UpdateLog("PCMD move Success"); },
                             2000,
                             "PCMD move time out.");
            server.WriteData(id, packetBytes);
        }