Esempio n. 1
0
        /// <summary>
        /// post请求
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="communicationType">通讯类型:1 http</param>
        /// <param name="serviceName"></param>
        /// <param name="pathName"></param>
        /// <param name="postData"></param>
        /// <returns></returns>
        public static T Post <T>(int communicationType, string serviceName, string pathName, Dictionary <string, string> postData)
        {
            string serviceUri = GetHttpRequestUri(serviceName, pathName);

            ICommunicationHelper client = CommunicationHelperFactory.GetInstance(communicationType);

            return(client.Post <T>(serviceUri, postData));
        }
Esempio n. 2
0
 /// <summary>
 /// Initializes a new instance of the CommandProcessor class.
 /// </summary>
 /// <param name="commandLineTextBox">
 /// Control to input commands.
 /// </param>
 /// <param name="historyBox">
 /// Control for commands and responses history.
 /// </param>
 /// <param name="communicationHelper">
 /// Class that communicates with robot.
 /// </param>
 /// <param name="commandHistory">
 /// Class that containts command history.
 /// </param>
 public CommandProcessor(
     TextBox commandLineTextBox,
     HistoryBox historyBox,
     ICommunicationHelper communicationHelper,
     CommandHistory commandHistory)
 {
     this.commandLineTextBox  = commandLineTextBox;
     this.historyBox          = historyBox;
     this.communicationHelper = communicationHelper;
     this.commandHistory      = commandHistory;
 }
Esempio n. 3
0
 /// <summary>
 /// Initializes a new instance of the CommandProcessor class.
 /// </summary>
 /// <param name="commandLineTextBox">
 /// Control to input commands.
 /// </param>
 /// <param name="historyBox">
 /// Control for commands and responses history.
 /// </param>
 /// <param name="communicationHelper">
 /// Class that communicates with robot.
 /// </param>
 /// <param name="commandHistory">
 /// Class that containts command history.
 /// </param>
 public CommandProcessor(
     TextBox commandLineTextBox, 
     HistoryBox historyBox, 
     ICommunicationHelper communicationHelper, 
     CommandHistory commandHistory)
 {
     this.commandLineTextBox = commandLineTextBox;
     this.historyBox = historyBox;
     this.communicationHelper = communicationHelper;
     this.commandHistory = commandHistory;
 }
Esempio n. 4
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;
        }
Esempio n. 5
0
        public ServerSettings(ICommunicationHelper communication, IServiceProvider provider, IOptionsMonitor <LastConnectionSettings> options, SaveConnectionSettings saveConnection)
        {
            InitializeComponent();
            _communication  = communication;
            _provider       = provider;
            _settings       = options.CurrentValue;
            _saveConnection = saveConnection;

            HostTextBox.Text = _settings.Host;
            PortTextBox.Text = _settings.Port;
            NickTextBox.Text = _settings.Nickname;
        }
Esempio n. 6
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;
        }
Esempio n. 7
0
        public GameScreen(Window window, ICommunicationHelper communication, string gamemodeName, GameDto game, IAssets assets)
        {
            Owner = window;
            InitializeComponent();
            _communication = communication;
            _timer         = new Timer(TimeTextBlock);
            _assets        = assets;
            Game           = game;
            GamemodeName   = gamemodeName;

            TimeTextBlock.FontFamily  = _assets.Font;
            BombsTextBlock.FontFamily = _assets.Font;
            Initialize();
        }
Esempio n. 8
0
        public GameSettings(ICommunicationHelper communication, Gamemodes gamemodes, IServiceProvider provider)
        {
            InitializeComponent();
            _communication = communication;
            _provider      = provider;

            LockSliders();
            LevelsList.ItemsSource  = gamemodes.List;
            LevelsList.SelectedItem = gamemodes.List.FirstOrDefault();

            BombsSlider.Minimum  = GamemodeDto.MinBombs;
            HeightSlider.Minimum = GamemodeDto.MinHeight;
            HeightSlider.Maximum = GamemodeDto.MaxHeight;
            WidthSlider.Minimum  = GamemodeDto.MinWidth;
            WidthSlider.Maximum  = GamemodeDto.MaxWidth;
        }
Esempio n. 9
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;
        }
Esempio n. 10
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;
        }
Esempio n. 11
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>
        /// 获取实例
        /// </summary>
        /// <param name="type">1 http</param>
        /// <returns></returns>
        public static ICommunicationHelper GetInstance(int type)
        {
            ICommunicationHelper communicationHelper = null;

            switch (type)
            {
            //http通信请求
            case (int)CommunicationType.HTTP:
                communicationHelper = new HttpClientHelper();
                break;
            }

            //没有找到,向外面抛出异常
            if (communicationHelper == null)
            {
                throw new Exception("can instance communicationhelper for type:" + type);
            }

            return(communicationHelper);
        }
 protected AbstractSearchComponent()
 {
     //Default communication HTTP. Derived classes can set their own communication method
     m_HttpAPIHelper = new HttpRestAPIHelper();
 }
Esempio n. 14
0
 /// <summary>
 /// Инициализация экземпляра класса для взаимодействия с роботом.
 /// </summary>
 /// <param name="communicationHelper">Уже проинициализированный экземпляр.</param>
 public void Initialize(CommunicationHelper communicationHelper)
 {
     this.communicationHelper = communicationHelper;
 }
Esempio n. 15
0
 /// <summary>
 /// this constructor is to inject HTTPHelper to enable unit testing
 /// </summary>
 /// <param name="m_HttpAPIHelper"></param>
 public NewsAPISearchhComponent(ICommunicationHelper httpAPIHelper)
 {
     m_HttpAPIHelper = httpAPIHelper;
 }
 /// <summary>
 /// this constructor is to inject HTTPHelper to enable unit testing
 /// </summary>
 /// <param name="m_HttpAPIHelper"></param>
 public FlickerSearchSearchComponent(ICommunicationHelper httpAPIHelper)
 {
     m_HttpAPIHelper = httpAPIHelper;
 }
Esempio n. 17
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;
        }
Esempio n. 18
0
 /// <summary>
 /// Инициализация экземпляра класса для взаимодействия с роботом.
 /// </summary>
 /// <param name="communicationHelper">Уже проинициализированный экземпляр.</param>
 public void Initialize(CommunicationHelper communicationHelper)
 {
     this.communicationHelper = communicationHelper;
 }