Beispiel #1
0
        protected override void Action()
        {
            try
            {
                var controls = new ControlsModel(Params.FirstStepVelocity, Params.FirstStepVelocity);
                ComputedNewControls?.Invoke(this, controls);
                Sender.UpdateAndSendControls(controls);
                Thread.Sleep(Params.FirstStepLength);

                var controls2 = new ControlsModel(Params.SecondStepVelocity, Params.SecondStepVelocity);
                ComputedNewControls?.Invoke(this, controls2);
                Sender.UpdateAndSendControls(controls2);
                Thread.Sleep(Params.SecondStepLength);

                var controls3 = new ControlsModel(0, 0);
                ComputedNewControls?.Invoke(this, controls3);
                Sender.UpdateAndSendControls(controls3);
                _result = "success";
            }
            catch (Exception ex)
            {
                Logger.Error("Error while executing experiment");
                Logger.Error(ex);
                _result = "error";
            }
        }
        public PartialViewResult GetTextbox2()
        {
            ViewBag.PostAction = Constants.REDIS_KEY_TEXTBOX2;
            ControlsModel controls = new ControlsModel();

            return(PartialView(Constants.TEXTBOX_POPUP_PARTIAL_VIEW_NAME, controls.Textbox2));
        }
        public PartialViewResult GetDatetimePicker()
        {
            ControlsModel controls = new ControlsModel();

            ViewBag.Items = GetSelectListForDatetimeTypes(controls);
            return(PartialView(Constants.DATETIME_POPUP_PARTIAL_VIEW_NAME, controls.DatetimePicker));
        }
 public ControlsSender(RobotConnectionService robotConnectionService, int interval) : base(robotConnectionService)
 {
     _controls       = new ControlsModel(0, 0);
     _timer          = new Timer(interval);
     _timer.Elapsed += TimerOnElapsed;
     _timer.Start();
 }
        private ViewResult GetAllControlsView(bool isEditable)
        {
            ViewBag.Title    = Constants.TITLE;
            ViewBag.Editable = isEditable;
            ControlsModel controls = new ControlsModel();

            return(View(Constants.CONTROLS_VIEW_NAME, controls));
        }
        private System.Collections.IEnumerable GetSelectListForDatetimeTypes(ControlsModel controls)
        {
            SelectList items = new SelectList(new List <SelectListItem>()
            {
                new SelectListItem {
                    Value = Constants.DATETIME_LOCAL_VALUE, Text = Constants.DATETIME_LOCAL_TEXT, Selected = (controls.DatetimePicker.Type == Constants.DATETIME_LOCAL_VALUE)
                },
                new SelectListItem {
                    Value = Constants.DATE_VALUE, Text = Constants.DATE_TEXT, Selected = (controls.DatetimePicker.Type == Constants.DATE_VALUE)
                },
            });

            return(items.Items);
        }
        public void SubscribeAndStart(RobotConnectionService robot, IGamepadService gamepad, string parametersHeader)
        {
            _robot   = robot;
            _gamepad = gamepad;

            _writer = new FileWriter(_config);
            _writer.WriteLine(parametersHeader);
            _writer.WriteLine(_formatter.GetHeader());
            _log      = new DatalogModel();
            Setpoints = new ControlsModel(0, 0);

            try
            {
                // _gamepad.RobotControlChanged += GamepadSerrvice_RobotControlChanged;
                _robot.SpeedCurrentFeedbackReceived       += RobotConnection_SpeedCurrentReceived;
                _robot.VoltageTemperatureFeedbackReceived += RobotConnection_VoltageTemperatureReceived;
                _logger.Info($"Started on path {_config.Path}");
                LoggingStarted?.Invoke(this, EventArgs.Empty);
            }
            catch (Exception e)
            {
                _logger.Error($"Cannot subscribe: {e.Message}. Please connect first.");
            }
        }
        public PartialViewResult GetButton()
        {
            ControlsModel controls = new ControlsModel();

            return(PartialView(Constants.BUTTON_POPUP_PARTIAL_VIEW_NAME, controls.Button));
        }
        public IHttpActionResult Get(string formName, string objectId)
        {
            Dictionary <Guid?, string> entityList = null;

            if (!string.IsNullOrEmpty(objectId) && objectId != "empty")
            {
                entityList = context.GetEntityListFromEntityDefination(formName, Guid.Parse(objectId));
            }
            var entityDefination = context.GetEntityDefination(formName);

            XmlDocument doc = new XmlDocument();

            doc.Load(System.Web.Hosting.HostingEnvironment.MapPath("~/Resources/" + entityDefination.FirstOrDefault().Value));
            EntityDefinationModel entity = new EntityDefinationModel();

            XmlNodeList controlNodes = doc.DocumentElement.SelectNodes("form/control/input");

            XmlNode entityNode    = doc.DocumentElement;
            string  identityValue = entityNode.SelectSingleNode("identity").InnerText;

            entity.FormId = Guid.Parse(identityValue);

            if (!string.IsNullOrEmpty(objectId) && objectId != "empty")
            {
                entity.Title    = entityNode.SelectSingleNode("title/update").InnerText;
                entity.ObjectId = Guid.Parse(objectId);
            }
            else
            {
                entity.Title    = entityNode.SelectSingleNode("title/add").InnerText;
                entity.ObjectId = Guid.NewGuid();
            }
            entity.EntityDefinationId = entityDefination.FirstOrDefault().Key;

            List <ControlsModel> controls = new List <ControlsModel>();

            foreach (XmlNode node in controlNodes)
            {
                ControlsModel control = new ControlsModel();
                control.Label  = node.SelectSingleNode("label").InnerText;
                control.Type   = node.SelectSingleNode("type").InnerText;
                control.Name   = node.SelectSingleNode("name").InnerText;
                control.Values = node.SelectSingleNode("values").InnerText.Split(',');
                control.Id     = Guid.Parse(node.SelectSingleNode("id").InnerText);
                if (!string.IsNullOrEmpty(objectId) && objectId != "empty")
                {
                    var entityValue = entityList.FirstOrDefault(x => x.Key == control.Id);
                    if (entityValue.Value != null)
                    {
                        control.value = entityValue.Value;
                    }
                    else
                    {
                        if (node.SelectSingleNode("selectedvalues") != null)
                        {
                            control.value = node.SelectSingleNode("selectedvalues").InnerText;
                        }
                    }
                }
                else
                {
                    if (node.SelectSingleNode("selectedvalues") != null)
                    {
                        control.value = node.SelectSingleNode("selectedvalues").InnerText;
                    }
                }
                controls.Add(control);
            }

            entity.ControlModelList = controls;

            return(this.Ok(entity));
        }
 public ManualViewModel()
 {
     manuelModel = new ControlsModel();
 }
 public AutoPilotViewModel()
 {
     autoPilotModel = new ControlsModel();
 }
 public void UpdateAndSendControls(ControlsModel controls) => _controls = controls;