public Robot(IRobotConfiguration configuration, StartArgs startArgs, IPriceManagerBuilder priceManagerBuilder, IDiffer differ) { _configuration = configuration; _startArgs = startArgs; _priceManagerBuilder = priceManagerBuilder; _differ = differ; }
/// <summary> /// Connect to Vector on the local network using the specified robotConfiguration and IP address /// </summary> /// <param name="robotConfiguration">The robot configuration.</param> /// <param name="ipAddress">The IP address.</param> /// <param name="timeout">The timeout.</param> /// <returns>A task that represents the asynchronous operation; the task result contains the connected client.</returns> public static async Task <Client> Connect(IRobotConfiguration robotConfiguration, IPAddress ipAddress, int timeout) { var channelCredentials = CreateChannelCredentials(robotConfiguration.Certificate, robotConfiguration.Guid); var channel = await ConnectChannel(channelCredentials, ipAddress.ToString(), robotConfiguration.RobotName, timeout).ConfigureAwait(false); return(await ConnectClient(channel, robotConfiguration.Certificate, robotConfiguration.Guid, ipAddress).ConfigureAwait(false)); }
/// <summary> /// Validates the specified robot configuration. /// </summary> /// <param name="robotConfiguration">The robot configuration.</param> /// <returns>A list of errors</returns> public static IEnumerable <string> TryValidate(this IRobotConfiguration robotConfiguration) { if (robotConfiguration == null) { throw new ArgumentNullException(nameof(robotConfiguration)); } if (string.IsNullOrWhiteSpace(robotConfiguration.RobotName)) { yield return("Robot name is missing"); } if (string.IsNullOrWhiteSpace(robotConfiguration.SerialNumber)) { yield return("Serial number is missing"); } if (string.IsNullOrWhiteSpace(robotConfiguration.Certificate)) { yield return("SSL certificate is missing"); } if (string.IsNullOrWhiteSpace(robotConfiguration.Guid)) { yield return("GUID token is missing"); } if (!RobotNameIsValid(robotConfiguration.RobotName)) { yield return("Invalid robot name. Please match the format exactly. Example: Vector-A1B2"); } if (!SerialNumberIsValid(robotConfiguration.SerialNumber)) { yield return("Serial number is not the correct format."); } }
public ColorBuilder(IRobotConfiguration configuration) { _colorCodes = new Dictionary <string, string>(); foreach (var colorMapping in configuration.ColorMappings) { _colorCodes[colorMapping.Name] = colorMapping.Code; } }
/// <summary> /// Finds the current robot address if possible or returns the address from the configuration. /// </summary> /// <param name="robotConfiguration">The robot configuration.</param> /// <returns>A task that represents the asynchronous operation; the task result contains the IP address.</returns> public static async Task <IPAddress> FindRobotAddress(this IRobotConfiguration robotConfiguration) { if (robotConfiguration == null) { throw new ArgumentNullException(nameof(robotConfiguration)); } return(await FindRobotAddress(robotConfiguration.RobotName).ConfigureAwait(false) ?? robotConfiguration.IPAddress); }
public RobotAssembler(IRobotConfiguration configuration, ILogConfiguration logConfiguration, IEnumerable<ComposablePartCatalog> partCatalogs) { _configuration = configuration; _logConfiguiration = logConfiguration; _log = _logConfiguiration.CreateLogger("RobotAssembler"); Compose(partCatalogs); }
/// <summary> /// Adds the specified robot configuration to the configuration file using the specified SDK configuration file path. /// <para>The robot configuration is appended if new or updated if already exists</para> /// </summary> /// <param name="sdkConfigFilePath">The SDK configuration file path.</param> /// <param name="robot">The robot configuration.</param> public static void AddOrUpdate(string sdkConfigFilePath, IRobotConfiguration robot) { var list = new List <IRobotConfiguration>() { robot }; SaveFile(sdkConfigFilePath, list); }
/// <summary> /// Validates the specified robot configuration. /// </summary> /// <param name="robotConfiguration">The robot configuration.</param> /// <returns> /// The robot configuration unchanged. /// </returns> /// <exception cref="VectorConfigurationException">Validation error</exception> public static IRobotConfiguration Validate(this IRobotConfiguration robotConfiguration) { var error = TryValidate(robotConfiguration).FirstOrDefault(); if (string.IsNullOrEmpty(error)) { return(robotConfiguration); } throw new VectorConfigurationException(error); }
public Robot(string name, ILogConfiguration logConfig, IRobotConfiguration configuration, IMessageBus bus, IEnumerable<IPart> parts, IHttpHost httpHost) { var loggerName = String.Format("Robot.{0}", name); _logger = logConfig.CreateLogger(loggerName); Name = name; Configuration = configuration; Parts = parts; HttpHost = httpHost; Bus = bus; }
/// <summary> /// Updates the configuration file data /// </summary> /// <param name="robot">The robot configuration.</param> /// <param name="ankiVectorPath">The anki_vector folder path.</param> /// <param name="data">The configuration file data.</param> private static void WriteConfig(IRobotConfiguration robot, string ankiVectorPath, KeyDataCollection data) { data[GuidKey] = robot.Guid; data[NameKey] = robot.RobotName; if (!data.ContainsKey(CertKey)) { data[CertKey] = Path.Combine(ankiVectorPath, robot.RobotName + "-" + robot.SerialNumber + ".cert"); } if (robot.IPAddress != null) { data[IpKey] = robot.IPAddress.ToString(); } if (!File.Exists(data[CertKey])) { File.WriteAllText(data[CertKey], robot.Certificate); } }
public HandlerRegistration(IRobotConfiguration configuration, List<IMessageHandler> handlers) { _configuration = configuration; _handlers = handlers; }
/// <summary> /// Adds the specified robot configuration to the configuration file using the default SDK configuration file path. /// <para>The robot configuration is appended if new or updated if already exists</para> /// </summary> /// <param name="robot">The robot.</param> public static void AddOrUpdate(IRobotConfiguration robot) { AddOrUpdate(DefaultSdkConfigFilePath, robot); }
public RobotAssembler(IRobotConfiguration configuration, ILogConfiguration logConfiguration, IEnumerable<Assembly> partAssemblies, IEnumerable<string> partDirectories) : this(configuration, logConfiguration, BuildCatalogs(partAssemblies, partDirectories)) { }
public RobotAssembler(IRobotConfiguration configuration, ILogConfiguration logConfiguration, IEnumerable<Assembly> partAssemblies) : this(configuration, logConfiguration, partAssemblies, Enumerable.Empty<string>()) { }
public RobotAssembler(IRobotConfiguration configuration, ILogConfiguration logConfiguration, IEnumerable<string> partDirectories) : this(configuration, logConfiguration, Enumerable.Empty<Assembly>(), partDirectories) { }
public RobotAssembler(IRobotConfiguration configuration, ILogConfiguration logConfiguration) : this(configuration, logConfiguration, Enumerable.Empty<Assembly>(), Enumerable.Empty<string>()) { }