Exemplo n.º 1
0
        /// <summary>
        /// Runs this command.
        /// </summary>
        /// <returns>Return code for the command</returns>
        public int Run()
        {
            Program.DisplayHeader();
            var robots = RobotConfiguration.Load().ToList();

            if (robots.Count == 0)
            {
                Console.WriteLine("There are no Vector robots configured.");
                return(-1);
            }

            string robotName = Authentication.StandardizeRobotName(NameOrSerial);
            string serial    = NameOrSerial.ToLower();

            var robot = robots.FirstOrDefault(r => r.RobotName == robotName || r.SerialNumber.ToLower() == serial);

            if (robot == null)
            {
                Console.WriteLine($"Robot '{NameOrSerial}' was not found.");
                return(-1);
            }
            robots.RemoveAt(robots.IndexOf(robot));
            RobotConfiguration.Save(robots);
            Console.WriteLine($"Removed {robot.RobotName} ({robot.SerialNumber}).");
            return(0);
        }
Exemplo n.º 2
0
        //=======================================================================

        //=======================================================================
        private void btnAddNewRobot_Click(object sender, RoutedEventArgs e)
        {
            this.ResetRobotDetails();
            this.ShowRobotDetailsSection();
            this._selectedRobotConfiguration = new RobotConfiguration();
            this._pageMode = PageMode.Add;
        }
Exemplo n.º 3
0
        private void tmrRobot_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            try
            {
                LogStep("Robot Service elapsed method triggered.");

                var appPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

                _configuration = CustomConfiguration.Settings.Robot(LogStep);

                tmrRobot.Interval = _configuration.ExecutionMilliseconds;

                LogStep("Robot Service configuration updated.");

                foreach (var def in _configuration.ServiceClasses)
                {
                    var serviceClassManager = new RobotServiceClassManager(def, appPath);

                    serviceClassManager.Error += serviceClassManager_Error;
                    serviceClassManager.Step  += serviceClassManager_Step;

                    var thread = new Thread(serviceClassManager.Execute);

                    thread.Start();
                }
            }
            catch (Exception exp)
            {
                LogException(exp);
            }
        }
Exemplo n.º 4
0
        public SimpleRobotController([NotNull] IModuleData moduleData)
        {
            node       = FrameNode.Instantiate("SimpleRobotNode");
            ModuleData = moduleData ?? throw new ArgumentNullException(nameof(moduleData));

            Config = new RobotConfiguration();
        }
Exemplo n.º 5
0
        /// <summary>
        /// Runs this instance.
        /// </summary>
        /// <returns>Return code for the command</returns>
        public int Run()
        {
            Program.DisplayHeader();
            Program.WriteLineWordWrap("Vector requires all requests be authorized by an authenticated Anki user.  This application will enable this device to authenticate with your Vector robot for use with a Vector SDK program.");
            Console.WriteLine();
            if (!AddSerialNumberAndCertificate())
            {
                return(-1);
            }
            if (!AddRobotName())
            {
                return(-1);
            }
            if (!AddIPAddress())
            {
                return(-1);
            }
            if (!AddGuid())
            {
                return(-1);
            }

            RobotConfiguration.AddOrUpdate(robot);
            Console.WriteLine("Success.");
            return(0);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Attempts to connect to the Robot.
        /// </summary>
        /// <param name="controllerConfig"></param>
        /// <param name="robotConfig"></param>
        /// <returns>True if the connection initially succeeded.</returns>
        public async Task <bool> ConnectAsync(VectorControllerPlusConfig controllerConfig, RobotConfiguration robotConfig = null)
        {
            this.controllerConfig = controllerConfig;
            this.robotConfig      = robotConfig;

            if (Robot == null || !Robot.IsConnected)
            {
                try
                {
                    Connection              = ConnectedState.Connecting;
                    Robot                   = await(robotConfig == null ? Robot.NewConnection() : Robot.NewConnection(robotConfig));
                    Robot.Disconnected     += OnDisconnect;
                    Connection              = ConnectedState.Connected;
                    LastConnectionError     = null;
                    LastConnectionException = null;
                    return(true);
                }
                catch (Exception e)
                {
                    Connection              = ConnectedState.Disconnected;
                    LastConnectionError     = e.Message;
                    LastConnectionException = e;
                    return(false);
                }
            }
            else
            {
                return(true);
            }
        }
Exemplo n.º 7
0
        private IVectorControllerPlus CreateController(RobotConfiguration robotConfig = null)
        {
            var controller = new VectorControllerPlus();

            controller.OnBehaviourReport += async(report) => { logger?.LogInformation(report.Description); };
            return(controller);
        }
Exemplo n.º 8
0
        protected override void Load(ContainerBuilder builder)
        {
            var apiUrl         = _configuration["api:url"];
            var apiAccessToken = _configuration["api:access_token"];

            var suppliers = new List <SupplierSettings>();

            _configuration.GetSection("suppliers").Bind(suppliers);

            var colorMappings = new List <ColorMapping>();

            _configuration.GetSection("color_mappings").Bind(colorMappings);

            var ignoredProducts = new List <string>();

            _configuration.GetSection("ignored_products").Bind(ignoredProducts);

            var robotConfig = new RobotConfiguration(apiUrl, apiAccessToken, suppliers, colorMappings, ignoredProducts);

            builder.RegisterInstance(robotConfig).As <IRobotConfiguration>();
            builder.RegisterType <ColorBuilder>().As <IColorBuilder>();
            builder.RegisterType <Differ>().As <IDiffer>();
            builder.RegisterType <PriceManagerBuilder>().As <IPriceManagerBuilder>();
            builder.RegisterType <PriceWebServiceProcessor>().As <IProcessor>();
            builder.RegisterInstance(_startArgs).AsSelf();

            Log.Debug("Connecting to API");
            var apiFactory = new ShopApiFactory();

            try
            {
                apiFactory.InitFactories(apiUrl, apiAccessToken).Wait();
            }
            catch (Exception e)
            {
                Log.Fatal(e, "Unable to connect to API");
                throw;
            }

            builder.RegisterInstance(apiFactory).As <IShopApiFactory>();

            builder.RegisterType <ProductCreator>().As <IProductCreator>();
            builder.RegisterType <ProductUpdater>().As <IProductUpdater>();
            builder.RegisterType <ProductRemover>().As <IProductRemover>();

            builder.RegisterType <CategoryProcessor>().As <ICategoryProcessor>();
            builder.RegisterType <CombinationsProcessor>().As <ICombinationsProcessor>();
            builder.RegisterType <FeatureProcessor>().As <IFeatureProcessor>();
            builder.RegisterType <ImageProcessor>().As <IImageProcessor>();
            builder.RegisterType <ManufacturerProcessor>().As <IManufacturerProcessor>();
            builder.RegisterType <StockProcessor>().As <IStockProcessor>();
            builder.RegisterType <SupplierProcessor>().As <ISupplierProcessor>();

            builder.RegisterType <Robot>().As <IRobot>();
        }
Exemplo n.º 9
0
        //=======================================================================

        //=======================================================================
        protected void lstBuiltInRobotConfigurations_SelectedRobotChanged(object sender, EventArgs e)
        {
            if (this.lstBuiltInRobotConfigurations.SelectedRobot != null)
            {
                this._selectedRobotConfiguration = this.lstBuiltInRobotConfigurations.SelectedRobot;
                this.lstConfiguredRobots.ClearSelection();
                this._selectedRobotConfigurationIsBuiltIn = true;
                this._pageMode = PageMode.Edit;
                this.PopulateRobotDetails();
                this.btnRemoveRobot.IsEnabled = false;
            }
        }
Exemplo n.º 10
0
        public RobotService()
        {
            Executing = new Dictionary <String, DateTime>();
#if !DEBUG
            InitializeComponent();
#endif
            _configuration   = CustomConfiguration.Settings.Robot();
            this.ServiceName = _configuration.ServiceName;
#if DEBUG
            tmrRobot = new System.Timers.Timer();
            this.tmrRobot_Elapsed(null, null);
#endif
        }
Exemplo n.º 11
0
        void OnHandMenuAddRobot()
        {
            void MenuListClick(string robotName)
            {
                var robotConfig = new RobotConfiguration
                {
                    SavedRobotName = robotName,
                    AttachedToTf   = true
                };

                ModuleListPanel.Instance.CreateModule(ModuleType.Robot, configuration: robotConfig);
            }

            hololensHandMenu.SetPalm(Resource.GetRobotNames().Select(
                                         robotName => new HololensMenuEntry(robotName, () => MenuListClick(robotName))));
        }
Exemplo n.º 12
0
    // Use this for initialization
    void Start()
    {
        robotConfig = GameObject.Find("RobotConfiguration").GetComponent <RobotConfiguration>();

        listStyle = new GUIStyle("button");
        listStyle.normal.background = new Texture2D(0, 0);
        listStyle.hover.background  = Resources.Load("Images/darksquaretexture") as Texture2D;
        listStyle.active.background = Resources.Load("images/highlightsquaretexture") as Texture2D;
        listStyle.alignment         = TextAnchor.MiddleLeft;
        listStyle.normal.textColor  = Color.white;

        highlightStyle = new GUIStyle(listStyle);
        highlightStyle.normal.background = listStyle.active.background;
        highlightStyle.hover.background  = highlightStyle.normal.background;

        items = new List <string>();
    }
Exemplo n.º 13
0
        private IEnumerable <RobotConfiguration> LoadRobotConfigurations()
        {
            ICollection <RobotConfiguration> configurations = new List <RobotConfiguration>();

            string directory = string.Format("{0}\\{1}", Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "MoveTheRobot");

            foreach (string filePath in Directory.EnumerateFiles(directory))
            {
                XmlDocument document = new XmlDocument();
                document.Load(filePath);

                XmlNode configurationNode = document.FirstChild;

                RobotConfiguration configuration = new RobotConfiguration
                {
                    Id     = new Guid(configurationNode.Attributes["Id"].Value),
                    Name   = configurationNode.Attributes["Name"].Value,
                    Motors = new List <Motor>()
                };

                XmlNodeList motorsNodes = configurationNode.FirstChild.ChildNodes;

                foreach (XmlNode motorNode in motorsNodes)
                {
                    Motor motor = new Motor
                    {
                        Id                   = new Guid(motorNode.Attributes["Id"].Value),
                        Name                 = motorNode.Attributes["Name"].Value,
                        MinValue             = int.Parse(motorNode.Attributes["MinValue"].Value),
                        MaxValue             = int.Parse(motorNode.Attributes["MaxValue"].Value),
                        RobotConfigurationId = new Guid(motorNode.Attributes["RobotConfigurationId"].Value)
                    };

                    configuration.Motors.Add(motor);
                }

                configurations.Add(configuration);
                Debug.WriteLine(configuration.ToString());
            }

            return(configurations);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Serialize all robot configuration data
        /// </summary>
        /// <returns>Configuration of robot</returns>
        public RobotConfiguration Serialize()
        {
            var robotConfiguration = new RobotConfiguration
            {
                Modeled = false,
                Items   = new List <PartData>(),
            };

            foreach (var pair in ItemData)
            {
                PartData data = null;
                var      go   = pair.Value.GameObject;
                switch (pair.Value.Type)
                {
                case ItemType.RevoluteJoint:
                    data = go.GetComponent <RevoluteJoint>().Serialize();
                    break;

                case ItemType.RotaryJoint:
                    data = go.GetComponent <RotaryJoint>().Serialize();
                    break;

                case ItemType.Beam:
                    data = go.GetComponent <Beam>().Serialize();
                    break;

                case ItemType.BasicTip:
                    data = go.GetComponent <BasicTip>().Serialize();
                    break;

                case ItemType.Undefined:
                default:
                    throw new ArgumentOutOfRangeException();
                }

                data.Id = pair.Key;
                robotConfiguration.Items.Add(data);
            }

            return(robotConfiguration);
        }
Exemplo n.º 15
0
        /// <summary>
        /// Runs this command.
        /// </summary>
        /// <returns>Return code for the command</returns>
        public int Run()
        {
            Program.DisplayHeader();
            var robots = RobotConfiguration.Load().ToList();

            if (robots.Count == 0)
            {
                Console.WriteLine("There are no Vector robots configured.");
                return(0);
            }

            Console.WriteLine("Configured Vector Robots:");
            if (Verbose)
            {
                DisplayRobotsVerbose(robots);
            }
            else
            {
                DisplayRobotsNormal(robots);
            }
            return(0);
        }
Exemplo n.º 16
0
        private void saveButton_Click(object sender, EventArgs e)
        {
            RobotConfiguration = new RobotConfiguration();

            RobotConfiguration.Name   = nameTextBox.Text;
            RobotConfiguration.Id     = Guid.NewGuid();
            RobotConfiguration.Motors = new List <Motor>();

            foreach (AddMotorControl motorControl in motorsControls)
            {
                Motor motor = motorControl.Motor;
                motor.RobotConfigurationId = RobotConfiguration.Id;
                RobotConfiguration.Motors.Add(motor);
            }

            bool saved = RobotConfiguration.Save();

            if (!saved)
            {
                Debug.WriteLine("File already exists!");
            }
        }
Exemplo n.º 17
0
 //=======================================================================
 //=======================================================================
 protected void lstConfiguredRobots_SelectedRobotChanged(object sender, EventArgs e)
 {
     if (this.lstConfiguredRobots.SelectedRobot != null)
     {
         this._selectedRobotConfiguration = this.lstConfiguredRobots.SelectedRobot;
         this.lstBuiltInRobotConfigurations.ClearSelection();
         this._selectedRobotConfigurationIsBuiltIn = false;
         this._pageMode = PageMode.Edit;
         this.PopulateRobotDetails();
         this.btnRemoveRobot.IsEnabled = true;
     }
     else
     {
         this.btnRemoveRobot.IsEnabled = false;
     }
 }
Exemplo n.º 18
0
 //=======================================================================
 //=======================================================================
 private void btnAddNewRobot_Click(object sender, RoutedEventArgs e)
 {
     this.ResetRobotDetails();
     this.ShowRobotDetailsSection();
     this._selectedRobotConfiguration = new RobotConfiguration();
     this._pageMode = PageMode.Add;
 }
 /// <summary>
 /// Edit the Robot configuration This API allows to edit the Robot configuration.
 /// </summary>
 /// <exception cref="SigningToday.Client.ApiException">Thrown when fails to make API call</exception>
 /// <param name="robotConfiguration">RobotConfiguration.</param>
 /// <param name="username">The _username_ associated to the account (optional)</param>
 /// <param name="domain">The _domain_ associated to the account (optional)</param>
 /// <returns></returns>
 public void RobotConfigurationPut(RobotConfiguration robotConfiguration, string username = default(string), string domain = default(string))
 {
     RobotConfigurationPutWithHttpInfo(robotConfiguration, username, domain);
 }
 /// <summary>
 /// Edit the Robot configuration This API allows to edit the Robot configuration.
 /// </summary>
 /// <exception cref="SigningToday.Client.ApiException">Thrown when fails to make API call</exception>
 /// <param name="robotConfiguration">RobotConfiguration.</param>
 /// <param name="username">The _username_ associated to the account (optional)</param>
 /// <param name="domain">The _domain_ associated to the account (optional)</param>
 /// <returns>Task of void</returns>
 public async System.Threading.Tasks.Task RobotConfigurationPutAsync(RobotConfiguration robotConfiguration, string username = default(string), string domain = default(string))
 {
     await RobotConfigurationPutAsyncWithHttpInfo(robotConfiguration, username, domain);
 }
Exemplo n.º 21
0
        public void UpdateConfiguration(RobotConfiguration config, [NotNull, ItemNotNull] IEnumerable <string> fields)
        {
            bool hasRobotName       = false;
            bool hasSourceParameter = false;

            foreach (string field in fields)
            {
                switch (field)
                {
                case nameof(RobotConfiguration.Visible):
                    RobotController.Visible = config.Visible;
                    break;

                case nameof(RobotConfiguration.SourceParameter)
                    when config.SourceParameter != RobotController.Config.SourceParameter:
                    hasSourceParameter = true;
                    break;

                case nameof(RobotConfiguration.SourceParameter):
                    break;

                case nameof(RobotConfiguration.SavedRobotName)
                    when config.SavedRobotName != RobotController.Config.SavedRobotName:
                    hasRobotName = true;
                    break;

                case nameof(RobotConfiguration.SavedRobotName):
                    break;

                case nameof(RobotConfiguration.FramePrefix):
                    RobotController.FramePrefix = config.FramePrefix;
                    break;

                case nameof(RobotConfiguration.FrameSuffix):
                    RobotController.FrameSuffix = config.FrameSuffix;
                    break;

                case nameof(RobotConfiguration.AttachedToTf):
                    RobotController.AttachedToTf = config.AttachedToTf;
                    break;

                case nameof(RobotConfiguration.RenderAsOcclusionOnly):
                    RobotController.RenderAsOcclusionOnly = config.RenderAsOcclusionOnly;
                    break;

                case nameof(RobotConfiguration.Tint):
                    RobotController.Tint = config.Tint.ToUnityColor();
                    break;

                case nameof(RobotConfiguration.Metallic):
                    RobotController.Metallic = config.Metallic;
                    break;

                case nameof(RobotConfiguration.Smoothness):
                    RobotController.Smoothness = config.Smoothness;
                    break;

                default:
                    Logger.Warn($"{this}: Unknown field '{field}'");
                    break;
                }
            }

            if (hasRobotName || hasSourceParameter)
            {
                if (!hasRobotName)
                {
                    config.SavedRobotName = "";
                }

                if (!hasSourceParameter)
                {
                    config.SourceParameter = "";
                }

                RobotController.ProcessRobotSource(config.SavedRobotName, config.SourceParameter);

                if (IsSelected)
                {
                    panel.HelpText.Label = RobotController.HelpText;
                }

                UpdateModuleButton();
            }

            ResetPanel();
        }
        /// <summary>
        /// Edit the Robot configuration This API allows to edit the Robot configuration.
        /// </summary>
        /// <exception cref="SigningToday.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="robotConfiguration">RobotConfiguration.</param>
        /// <param name="username">The _username_ associated to the account (optional)</param>
        /// <param name="domain">The _domain_ associated to the account (optional)</param>
        /// <returns>Task of ApiResponse</returns>
        public async System.Threading.Tasks.Task <ApiResponse <Object> > RobotConfigurationPutAsyncWithHttpInfo(RobotConfiguration robotConfiguration, string username = default(string), string domain = default(string))
        {
            // verify the required parameter 'robotConfiguration' is set
            if (robotConfiguration == null)
            {
                throw new ApiException(400, "Missing required parameter 'robotConfiguration' when calling RobotApi->RobotConfigurationPut");
            }

            var    localVarPath         = "/robot/configuration";
            var    localVarPathParams   = new Dictionary <String, String>();
            var    localVarQueryParams  = new List <KeyValuePair <String, String> >();
            var    localVarHeaderParams = new Dictionary <String, String>(this.Configuration.DefaultHeader);
            var    localVarFormParams   = new Dictionary <String, String>();
            var    localVarFileParams   = new Dictionary <String, FileParameter>();
            Object localVarPostBody     = null;

            // to determine the Content-Type header
            String[] localVarHttpContentTypes = new String[] {
                "application/json"
            };
            String localVarHttpContentType = this.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);

            // to determine the Accept header
            String[] localVarHttpHeaderAccepts = new String[] {
                "*/*"
            };
            String localVarHttpHeaderAccept = this.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);

            if (localVarHttpHeaderAccept != null)
            {
                localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept);
            }

            if (username != null)
            {
                localVarQueryParams.AddRange(this.Configuration.ApiClient.ParameterToKeyValuePairs("", "username", username));                   // query parameter
            }
            if (domain != null)
            {
                localVarQueryParams.AddRange(this.Configuration.ApiClient.ParameterToKeyValuePairs("", "domain", domain));                 // query parameter
            }
            if (robotConfiguration != null && robotConfiguration.GetType() != typeof(byte[]))
            {
                localVarPostBody = this.Configuration.ApiClient.Serialize(robotConfiguration); // http body (model) parameter
            }
            else
            {
                localVarPostBody = robotConfiguration; // byte array
            }

            // authentication (OAuth2) required
            // oauth required
            if (!String.IsNullOrEmpty(this.Configuration.AccessToken))
            {
                localVarHeaderParams["Authorization"] = "Bearer " + this.Configuration.AccessToken;
            }

            // make the HTTP request
            IRestResponse localVarResponse = (IRestResponse)await this.Configuration.ApiClient.CallApiAsync(localVarPath,
                                                                                                            Method.PUT, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
                                                                                                            localVarPathParams, localVarHttpContentType);

            int localVarStatusCode = (int)localVarResponse.StatusCode;

            if (ExceptionFactory != null)
            {
                Exception exception = ExceptionFactory("RobotConfigurationPut", localVarResponse);
                if (exception != null)
                {
                    throw exception;
                }
            }

            return(new ApiResponse <Object>(localVarStatusCode,
                                            localVarResponse.Headers.ToDictionary(x => x.Name, x => string.Join(",", x.Value)),
                                            null));
        }
Exemplo n.º 23
0
    /// <summary>
    /// Runs the proper initialization methods based on what robot has been loaded.
    /// </summary>
    public void Initialize()
    {
        holdingLimit      = 1;
        interactorObjects = new List <GameObject>();
        interactors       = new List <Interactor>();
        vectors           = new List <Vector3>();
        gamepieces        = new List <string>();
        StreamReader reader;
        string       line;
        int          counter;

        gamepieces.Add("gamepiece");
        if (File.Exists(PlayerPrefs.GetString("dpmSelectedRobot") + "\\dpmConfiguration.txt"))
        {
            reader  = new StreamReader(PlayerPrefs.GetString("dpmSelectedRobot") + "\\dpmConfiguration.txt");
            line    = "";
            counter = 0;

            while ((line = reader.ReadLine()) != null)
            {
                if (line.Equals("#Nodes"))
                {
                    counter++;
                }
                else if (counter == 1)
                {
                    if (line.Equals("#Vectors"))
                    {
                        counter++;
                    }
                    else
                    {
                        interactorObjects.Add(GameObject.Find(line));
                    }
                }
                else if (counter == 2)
                {
                    if (line.Equals("#Gamepieces"))
                    {
                        counter++;
                    }
                    else
                    {
                        vectors.Add(RobotConfiguration.DeserializeVector3Array(line));
                    }
                }
            }
            reader.Close();
        }

        line    = "";
        counter = 0;
        reader  = new StreamReader(PlayerPrefs.GetString("dpmSelectedField") + "\\driverpracticemode.txt");

        while ((line = reader.ReadLine()) != null)
        {
            if (line.Equals("#Gamepieces"))
            {
                counter++;
            }
            else if (counter == 1)
            {
                if (line.Equals("#HoldingLimit"))
                {
                    counter++;
                }
                else
                {
                    gamepieces[0] = line;
                }
            }
            else if (counter == 2)
            {
                holdingLimit = Mathf.RoundToInt(float.Parse(line));
            }
        }
        reader.Close();

        for (int i = 0; i < interactorObjects.Count; i++)
        {
            interactors.Add(interactorObjects[i].AddComponent <Interactor>());
            interactors[i].collisionKeyword = gamepieces[0];
        }



        if (isConfiguring)
        {
            robotConfig = GameObject.Find("RobotConfiguration").GetComponent <RobotConfiguration>();
            UpdateConfiguration();
        }
    }
 void Start()
 {
     configuration = GetComponent <RobotConfiguration>();
     EquipWeapons();
 }
Exemplo n.º 25
0
        public static RobotConfiguration Robot(this CustomConfiguration config, Action <string> logMethod = null)
        {
            lock (_lockObjectData)
            {
                if (logMethod != null)
                {
                    logMethod("Atualizando configurações do serviço");
                }

                var appPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                var xmlPath = Path.Combine(appPath, "RobotConfiguration.xml");

                if (File.Exists(xmlPath))
                {
                    var xmlConfigReader = new StreamReader(xmlPath);
                    var xml             = xmlConfigReader.ReadToEnd();
                    xmlConfigReader.Close();

                    if (!String.IsNullOrEmpty(xml))
                    {
                        var reader = new StringReader(xml);
                        var ds     = new DataSet();
                        ds.ReadXml(reader);

                        var robotConfig = ds.Tables["robotConfig"];
                        _configuration = new RobotConfiguration();

                        if (robotConfig != null)
                        {
                            if (robotConfig.Rows.Count > 0)
                            {
                                if (robotConfig.Columns.IndexOf("name") > -1)
                                {
                                    _configuration.ServiceName = robotConfig.Rows[0]["name"].ToString();
                                }

                                if (robotConfig.Columns.IndexOf("executionMilliseconds") > -1)
                                {
                                    int millisecconds;

                                    if (int.TryParse(robotConfig.Rows[0]["executionMilliseconds"].ToString(), out millisecconds))
                                    {
                                        _configuration.ExecutionMilliseconds = Math.Max(millisecconds, 1000);
                                    }
                                }

                                if (robotConfig.Columns.IndexOf("executionTimeoutMinutes") > -1)
                                {
                                    int minutes;

                                    if (int.TryParse(robotConfig.Rows[0]["executionTimeoutMinutes"].ToString(), out minutes))
                                    {
                                        _configuration.ExecutionTimeout = minutes;
                                    }
                                }

                                if (robotConfig.Columns.IndexOf("logSteps") > -1)
                                {
                                    _configuration.LogSteps = robotConfig.Rows[0]["logSteps"].ToString().ToLower() == "true" || robotConfig.Rows[0]["logSteps"].ToString().ToLower() == "1";
                                }

                                if (robotConfig.Columns.IndexOf("logTextFile") > -1)
                                {
                                    _configuration.LogTextFile = robotConfig.Rows[0]["logTextFile"].ToString().ToLower() == "true" || robotConfig.Rows[0]["logTextFile"].ToString().ToLower() == "1";
                                }

                                if (_configuration.LogTextFile)
                                {
                                    if (robotConfig.Columns.IndexOf("textFilePath") > -1)
                                    {
                                        _configuration.TextFilePath = robotConfig.Rows[0]["textFilePath"].ToString();
                                    }
                                }
                            }
                        }

                        var configClasses   = new List <ServiceClassDefinition>();
                        var tbServicesClass = ds.Tables["serviceClass"];

                        if (tbServicesClass != null)
                        {
                            if (tbServicesClass.Rows.Count > 0)
                            {
                                configClasses.AddRange(from DataRow row in tbServicesClass.Rows
                                                       select new ServiceClassDefinition
                                {
                                    AssemblyName = Convert.ToString(row["assemblyName"]),
                                    TypeFullName = Convert.ToString(row["typeFullName"])
                                });
                            }
                        }

                        if (_configuration.ServiceClasses.Count != configClasses.Count)
                        {
                            _configuration.ServiceClasses = configClasses;
                        }
                        else
                        {
                            var isEqual = true;
                            var x       = 0;
                            foreach (var def in _configuration.ServiceClasses)
                            {
                                if (def.AssemblyName != configClasses[x].AssemblyName || def.TypeFullName != configClasses[x].TypeFullName)
                                {
                                    isEqual = false;
                                    break;
                                }

                                x++;
                            }

                            if (!isEqual)
                            {
                                _configuration.ServiceClasses = configClasses;
                            }
                        }
                    }
                }
                else
                {
                    throw new FileNotFoundException("O Arquivo 'RobotConfiguration.xml' não foi encontrado na mesma pasta do executável do serviço.");
                }

                if (String.IsNullOrWhiteSpace(_configuration.ServiceName))
                {
                    _configuration.ServiceName = "Executador automático de processos";
                }

                if (logMethod != null)
                {
                    logMethod("Configurações do serviço atualizadas");
                }

                return(_configuration);
            }
        }