public void RunRobot(RobotEntity robot) { Task robotTask = new Task(() => RobotAction(robot)); robotTask.Start(); _tasks.Add(robotTask); }
public void AddPart(PartType type, RobotEntity robot) { var newPart = new Part() { Type = type, Robot = robot }; _context.Parts.Add(newPart); _context.SaveChanges(); }
public void CreateInstruction(int idPart, int value, RobotEntity robot) { var existPart = robot.Parts.Any(p => p.Id == idPart); if (!existPart) return; var instruction = new Instruction() { PartId = idPart, Value = value }; _context.Instructions.Add(instruction); _context.SaveChanges(); }
private void RobotAction(RobotEntity robot) { do { foreach (Part part in robot.Parts) { foreach (Instruction instruction in part.Instructions) { Console.WriteLine( String.Format("Robot: {2}, part: {0}, value {1}", part.Type, instruction.Value, robot.Identification)); System.Threading.Thread.Sleep(1000); } } } while (true); }
/// <summary> /// Method for robot creating /// </summary> /// <param name="place">place of robot</param> /// <param name="parts">robot´s parts</param> public string CreateRobot(string place, List<Part> parts) { var newRobot = new RobotEntity() { Parts = parts, Place = place }; do { newRobot.Identification = String.Format("{0}_{1}", place, GetIdentifactionNumber()); var existedRobot = GetRobot(newRobot.Identification); if (existedRobot == null) break; } while (true); _context.Robots.Add(newRobot); _context.SaveChanges(); return newRobot.Identification; }