/// <summary> /// Initializes a new instance of the <see cref="ReserveBehaviorControl" /> class. /// </summary> /// <param name="robotConfiguration">The robot configuration.</param> /// <param name="reserveControl">if set to <c>true</c> to reserve control on construction.</param> /// <exception cref="VectorControlException">Unable to reserve behavior control</exception> public ReserveBehaviorControl(RobotConfiguration robotConfiguration, bool reserveControl = true) { this.robotConfiguration = robotConfiguration; if (reserveControl) { ReserveControl().Wait(); } }
/// <summary> /// Initializes a new instance of the <see cref="ReserveBehaviorControl"/> class. /// </summary> /// <param name="reserveControl">if set to <c>true</c> to reserve control on construction.</param> /// <exception cref="VectorConfigurationException">No Robot Configuration found; please run the configuration tool to setup the robot connection.</exception> public ReserveBehaviorControl(bool reserveControl = true) { var configuration = RobotConfiguration.LoadDefault(); this.robotConfiguration = configuration ?? throw new VectorConfigurationException("No Robot Configuration found; please run the configuration tool to setup the robot connection."); if (reserveControl) { ReserveControl().Wait(); } }
/// <summary> /// Updates the specified robot configuration with a new login /// </summary> /// <param name="robotConfiguration">The robot configuration.</param> /// <param name="emailAddress">The email address.</param> /// <param name="password">The password.</param> /// <param name="ipAddress">The IP address.</param> /// <returns>A task that represents the asynchronous operation.</returns> /// <exception cref="VectorAuthenticationException">IP address could not be determined; please provide IP address.</exception> public static async Task Login(RobotConfiguration robotConfiguration, string emailAddress, string password, IPAddress ipAddress = null) { if (robotConfiguration == null) { throw new ArgumentNullException(nameof(robotConfiguration)); } ipAddress = await FindRobotAddress(robotConfiguration.RobotName).ConfigureAwait(false) ?? ipAddress; robotConfiguration.IPAddress = ipAddress ?? throw new VectorAuthenticationException(VectorAuthenticationFailureType.IPAddress, "IP address could not be determined; please provide IP address."); if (string.IsNullOrEmpty(robotConfiguration.Certificate)) { robotConfiguration.Certificate = await GetCertificate(robotConfiguration.SerialNumber).ConfigureAwait(false); } robotConfiguration.Guid = await GetTokenGuid(await GetSessionToken(emailAddress, password).ConfigureAwait(false), robotConfiguration.Certificate, robotConfiguration.RobotName, robotConfiguration.IPAddress).ConfigureAwait(false); }
/// <summary> /// Updates the specified robot configuration with a new login /// </summary> /// <param name="robotConfiguration">The robot configuration.</param> /// <param name="emailAddress">The email address.</param> /// <param name="password">The password.</param> /// <param name="remoteHost">The optional remote host to connect to (otherwise uses configured remote host).</param> /// <returns>A task that represents the asynchronous operation; the task result the modified robot configuration parameter instance.</returns> /// <exception cref="ArgumentNullException">robotConfiguration</exception> public static async Task <RobotConfiguration> RemoteLogin(RobotConfiguration robotConfiguration, string emailAddress, string password, string remoteHost = null) { if (robotConfiguration == null) { throw new ArgumentNullException(nameof(robotConfiguration)); } if (string.IsNullOrEmpty(robotConfiguration.Certificate)) { robotConfiguration.Certificate = await GetCertificate(robotConfiguration.SerialNumber).ConfigureAwait(false); } if (!string.IsNullOrWhiteSpace(remoteHost)) { robotConfiguration.RemoteHost = remoteHost; } robotConfiguration.Guid = await GetTokenGuid(await GetSessionToken(emailAddress, password).ConfigureAwait(false), robotConfiguration.Certificate, robotConfiguration.RobotName, robotConfiguration.RemoteHost).ConfigureAwait(false); return(robotConfiguration); }
public static async Task <RobotConfiguration> RemoteLogin(string serialNumber, string robotName, string emailAddress, string password, string remoteHost) { if (string.IsNullOrWhiteSpace(remoteHost)) { throw new ArgumentException("Remote host cannot be empty.", nameof(remoteHost)); } robotName = StandardizeRobotName(robotName); serialNumber = serialNumber?.ToLowerInvariant(); var result = new RobotConfiguration { RobotName = robotName, RemoteHost = remoteHost, Certificate = await GetCertificate(serialNumber).ConfigureAwait(false), SerialNumber = serialNumber }; result.Guid = await GetTokenGuid(await GetSessionToken(emailAddress, password).ConfigureAwait(false), result.Certificate, robotName, remoteHost).ConfigureAwait(false); return(result); }