コード例 #1
0
        /* Create the commands to send to the simulator */
        private List <Command> ExtractValidCommands(FlightCommand flightCommand)
        {
            List <Command> validCommands = new List <Command>();

            if (isNewCommand("aileron", flightCommand.Aileron))
            {
                validCommands.Add(new Command("/controls/flight/aileron", flightCommand.Aileron));
            }

            if (isNewCommand("elevator", flightCommand.Elevator))
            {
                validCommands.Add(new Command("/controls/flight/elevator", flightCommand.Elevator));
            }

            if (isNewCommand("rudder", flightCommand.Rudder))
            {
                validCommands.Add(new Command("/controls/flight/rudder", flightCommand.Rudder));
            }

            if (isNewCommand("throttle", flightCommand.Throttle))
            {
                validCommands.Add(new Command("/controls/engines/current-engine/throttle",
                                              flightCommand.Throttle));
            }

            return(validCommands);
        }
コード例 #2
0
        /* Send commands to simulator return false if got error in simulator */
        public bool SendCommand(FlightCommand flightCommand)
        {
            if (!_isConnected)
            {
                if (_isConnected = _simTcpClient.InitializeConnection())
                {
                    return(false);
                }
            }

            List <Command> commands = ExtractValidCommands(flightCommand);

            foreach (Command commad in commands)
            {
                bool res = _simTcpClient.RunCommandAndVerify(commad);
                if (!res)
                {
                    return(false);
                }
            }
            return(true);
        }