/// <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);
        }
示例#2
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!");
            }
        }