Пример #1
0
        /// <summary>
        /// Initializes a new instance of the DriveHelperTest class.
        /// </summary>
        public DriveHelperTest()
        {
            var mock = new Mock<ICommunicationHelper>();
            mock.Setup(x => x.SendMessageToRobot(It.IsAny<string>())).Returns(true);
            this.communicationHelper = mock.Object;

            this.controlSettings = new ControlSettings();

            // Специально для тестов переопределяю максимальные скорости нормального и турбо режимов моторов.
            this.controlSettings.DriveModeNormalMaxSpeed = 190;
            this.controlSettings.DriveModeTurboMaxSpeed = 255;
        }
Пример #2
0
        /// <summary>
        /// Initializes a new instance of the GunHelper class.
        /// </summary>
        /// <param name="communicationHelper">
        /// Объект для взаимодействия с головой робота.
        /// </param>
        /// <param name="controlSettings">
        /// Опции управления роботом.
        /// </param>
        public GunHelper(CommunicationHelper communicationHelper, ControlSettings controlSettings)
        {
            if (communicationHelper == null)
            {
                throw new ArgumentNullException("communicationHelper");
            }

            if (controlSettings == null)
            {
                throw new ArgumentNullException("controlSettingsHelper");
            }

            this.communicationHelper = communicationHelper;
            this.controlSettings     = controlSettings;
        }
Пример #3
0
        /// <summary>
        /// Initializes a new instance of the AudioHelper class.
        /// </summary>
        /// <param name="communicationHelper">
        /// Объект, упращающий взаимодействие с роботом.
        /// </param>
        /// <param name="controlSettings">
        /// Опции управления роботом.
        /// </param>
        public AudioHelper(UdpCommunicationHelper communicationHelper, ControlSettings controlSettings)
        {
            if (communicationHelper == null)
            {
                throw new ArgumentNullException("communicationHelper");
            }

            if (controlSettings == null)
            {
                throw new ArgumentNullException("controlSettingsHelper");
            }

            this.communicationHelper = communicationHelper;
            this.controlSettings = controlSettings;
        }
Пример #4
0
        /// <summary>
        /// Initializes a new instance of the DriveHelper class.
        /// </summary>
        /// <param name="communicationHelper">
        /// Объект для взаимодействия с головой робота.
        /// </param>
        /// <param name="controlSettings">
        /// Опции управления роботом.
        /// </param>
        public DriveHelper(ICommunicationHelper communicationHelper, ControlSettings controlSettings)
        {
            if (communicationHelper == null)
            {
                throw new ArgumentNullException("communicationHelper");
            }

            if (controlSettings == null)
            {
                throw new ArgumentNullException("controlSettingsHelper");
            }

            this.communicationHelper = communicationHelper;
            this.controlSettings     = controlSettings;

            this.speedForKeyboardControl = controlSettings.Speed3;
        }
Пример #5
0
        /// <summary>
        /// Initializes a new instance of the DriveHelper class.
        /// </summary>
        /// <param name="communicationHelper">
        /// Объект для взаимодействия с головой робота.
        /// </param>
        /// <param name="controlSettings">
        /// Опции управления роботом.
        /// </param>
        public DriveHelper(ICommunicationHelper communicationHelper, ControlSettings controlSettings)
        {
            if (communicationHelper == null)
            {
                throw new ArgumentNullException("communicationHelper");
            }

            if (controlSettings == null)
            {
                throw new ArgumentNullException("controlSettingsHelper");
            }

            this.communicationHelper = communicationHelper;
            this.controlSettings = controlSettings;

            this.speedForKeyboardControl = controlSettings.Speed3;
        }
Пример #6
0
        /// <summary>
        /// Initializes a new instance of the LookHelper class.
        /// </summary>
        /// <param name="communicationHelper">
        /// Объект для взаимодействия с головой робота.
        /// </param>
        /// <param name="controlSettings">
        /// Опции управления роботом.
        /// </param>
        public LookHelper(ICommunicationHelper communicationHelper, ControlSettings controlSettings)
        {
            if (communicationHelper == null)
            {
                throw new ArgumentNullException("communicationHelper");
            }

            if (controlSettings == null)
            {
                throw new ArgumentNullException("controlSettingsHelper");
            }

            this.communicationHelper = communicationHelper;
            this.controlSettings     = controlSettings;

            this.fixedLookX = this.controlSettings.HorizontalForwardDegree;
            this.fixedLookY = this.controlSettings.VerticalForwardDegree;
        }
Пример #7
0
        /// <summary>
        /// Loads settings from XML file.
        /// </summary>
        public void Load()
        {
            if (!File.Exists(this.settingsFullFilename))
            {
                // If configuration file doesn't exists then it is created with default values.
                this.Save();
            }

            var        serializer = new XmlSerializer(typeof(ControlSettings));
            TextReader reader     = new StreamReader(this.settingsFullFilename);

            try
            {
                this.Settings = serializer.Deserialize(reader) as ControlSettings;
            }
            finally
            {
                reader.Close();
            }
        }
Пример #8
0
        /// <summary>
        /// Initializes a new instance of the LookHelper class.
        /// </summary>
        /// <param name="communicationHelper">
        /// Объект для взаимодействия с головой робота.
        /// </param>
        /// <param name="controlSettings">
        /// Опции управления роботом.
        /// </param>
        public LookHelper(ICommunicationHelper communicationHelper, ControlSettings controlSettings)
        {
            if (communicationHelper == null)
            {
                throw new ArgumentNullException("communicationHelper");
            }

            if (controlSettings == null)
            {
                throw new ArgumentNullException("controlSettingsHelper");
            }

            this.communicationHelper = communicationHelper;
            this.controlSettings = controlSettings;

            this.fixedLookX = this.controlSettings.HorizontalForwardDegree;
            this.fixedLookY = this.controlSettings.VerticalForwardDegree;
        }
        /// <summary>
        /// Loads settings from XML file.
        /// </summary>
        public void Load()
        {
            if (!File.Exists(this.settingsFullFilename))
            {
                // If configuration file doesn't exists then it is created with default values.
                this.Save();
            }

            var serializer = new XmlSerializer(typeof(ControlSettings));
            TextReader reader = new StreamReader(this.settingsFullFilename);
            try
            {
                this.Settings = serializer.Deserialize(reader) as ControlSettings;
            }
            finally
            {
                reader.Close();
            }
        }