Exemplo n.º 1
0
 public IEnumerator<INavigationAction> Execute(IRobot robot)
 {
     while (true) {
         yield return new TurnAction(90 * rand.Next(4));
         yield return new MotionAction(15 - rand.Next(30));
     }
 }
Exemplo n.º 2
0
        public Response(IRobot robot, Message message, string[] match)
        {
            _envelope = new Envelope(message);

            _robot = robot;
            Match = match;
        }
Exemplo n.º 3
0
        public StashListener(IRobot robot)
            : base("Stash Listener", "/stash", robot)
        {
            _settings = new List<IPluginSetting>
            {
                new PluginSetting(Robot, this, "AtlassianStashUrl"),
                new PluginSetting(Robot, this, "AtlassianStashNotifyRoomName"),
                new PluginSetting(Robot, this, "AtlassianStashHipchatAuthToken"),
            };

            Post["/"] = x =>
            {
                var model = this.Bind<StashModel>();

                Robot.EventEmitter.Emit("StashCommit", model);

                Robot.SendNotification(
                    Robot.Settings.Get("AtlassianStashNotifyRoomName"),
                    Robot.Settings.Get("AtlassianStashHipchatAuthToken"),
                    BuildMessage(model),
                    true);

                return HttpStatusCode.OK;
            };
        }
 // Functions
 /// <summary>
 /// Default constructor setting up simulator.
 /// 
 /// Note: Edits Factory->Simulator.
 /// </summary>
 public SimulatorViewModel()
 {
     //_sim = Factory.currentIRobotInstance;
     suiSimulatorUI = new StringUI();
     Factory.getSimulatorInstance.IUIOutput = suiSimulatorUI;
     _sim = Factory.getSimulatorInstance;
 }
Exemplo n.º 5
0
Arquivo: DoIt.cs Projeto: nubot/nubot
 public override void Attach(IRobot robot)
 {
     robot.Hear("do\\s*it", async ctx =>
     {
         await ctx.SendAsync("http://i.imgur.com/pKove8A.gif");
     });
 }
Exemplo n.º 6
0
 public Default(IRobot robot)
     : base("Default", robot)
 {
     HelpMessages = new List<string> {
         "help - Show help of all currently loaded plugin(s)"
     };
 }
Exemplo n.º 7
0
        public void SetupAdapters(IRobot robot)
        {
            if (_adaptersLoaded)
            {
                // should we toss an exception instead?
                return;
            }

            _adaptersLoaded = true;

            foreach (var adapter in robot.Settings.Adapters.Where(a => a.Enabled).Select(a => a.Name))
            {
                Console.WriteLine("Trying to load adapter named '{0}'", adapter);

                var instance = _container.TryGetInstance<IRobotAdapter>(adapter);
                if (instance == null)
                {
                    Console.WriteLine("No adapter found named '{0}'", adapter);
                    continue;
                }

                instance.Setup(robot);
                Adapters.Add(instance);
            }

            InitializeHelpText();
        }
Exemplo n.º 8
0
        public GoogleImages(IRobot robot)
            : base("Google Images", robot)
        {
            HelpMessages = new List<string>
            {
                "image|img me <query> - Queries Google Images for <query> and returns a random top result.",
                "animate me <query> - The same thing as `image me`, except adds a few parameters to try to return an animated GIF instead.",
                "mustache me <url> - Adds a mustache to the specified URL.",
                "mustache me <query> - Searches Google Images for the specified query and mustaches it."
            };

            Robot.Respond(@"(image|img) (me) (.*)", msg => ImageMe(msg.Match[3], url => msg.Send(url)));
            Robot.Respond(@"(animate) (me) (.*)", msg => ImageMe(msg.Match[3], url => msg.Send(url), true));

            Robot.Respond(@"(?:mo?u)?sta(?:s|c)he?(?: me)? (.*)", msg =>
            {
                const string mustachify = "http://mustachify.me/?";
                var imagery = msg.Match[1];

                if (imagery.StartsWith("http"))
                {
                    msg.Send(string.Format("{0}{1}", mustachify, string.Format("src={0}", HttpUtility.UrlEncode(imagery))));
                }
                else
                {
                    ImageMe(imagery, url => msg.Send(string.Format("{0}src={1}", mustachify, HttpUtility.UrlEncode(url))), false, true);
                }
            });
        }
Exemplo n.º 9
0
        public JiraListener(IRobot robot)
            : base("Jira Listener", "/jira", robot)
        {
            _settings = new List<IPluginSetting>
            {
                new PluginSetting(Robot, this, "AtlassianJiraUrl"),
                new PluginSetting(Robot, this, "AtlassianJiraNotifyRoomName"),
                new PluginSetting(Robot, this, "AtlassianJiraHipchatAuthToken")
            };

            Post["/"] = x =>
            {
                var model = this.Bind<JiraModel>(new BindingConfig { IgnoreErrors = true, BodyOnly = true, Overwrite = true });

                Robot.EventEmitter.Emit("JiraEvent", model);

                //Robot.SendNotification(
                //    Robot.Settings.Get("AtlassianJiraNotifyRoomName").Trim(),
                //    Robot.Settings.Get("AtlassianJiraHipchatAuthToken").Trim(),
                //    BuildMessage(model),
                //    true);

                return HttpStatusCode.OK;
            };
        }
Exemplo n.º 10
0
Arquivo: Ping.cs Projeto: nubot/nubot
 public override void Attach(IRobot robot)
 {
     robot.Listen("ping", async ctx =>
     {
         await ctx.SendAsync("PONG");
     });
 }
Exemplo n.º 11
0
        public GithubListener(IRobot robot)
            : base("Github Listener", "/github", robot)
        {
            _settings = new List<IPluginSetting>
            {
                new PluginSetting(Robot, this, "GithubUrl"),
                new PluginSetting(Robot, this, "GithubNotifyRoomName"),
                new PluginSetting(Robot, this, "GithubHipchatAuthToken"),
            };

            Post["/"] = x =>
            {
                var model = this.Bind<GithubModel>();

                Robot.EventEmitter.Emit("Github.Push", model);

                foreach (var buildMessage in BuildMessages(model))
                {
                    Robot.SendNotification(
                        Robot.Settings.Get("GithubNotifyRoomName"),
                        Robot.Settings.Get("GithubHipchatAuthToken"),
                        buildMessage);
                }

                return HttpStatusCode.OK;
            };
        }
Exemplo n.º 12
0
        public override async void Attach(IRobot robo, CancellationToken token)
        {
            robo.Bus.On<SendChatMessage>(msg =>
            {
                if (Console.CursorLeft != 0)
                {
                    Console.WriteLine();
                }
                Console.WriteLine((msg.MeMessage ? "/me " : "") + msg.Message);
            });

            await Task.Factory.StartNew(async () =>
            {
                while (!token.IsCancellationRequested)
                {
                    string line = await Console.In.ReadLineAsync();
                    robo.Bus.Send(new RawChatMessage(
                                      from: "user",
                                      room: "Console",
                                      when: DateTimeOffset.UtcNow,
                                      id: (_nextId++).ToString(),
                                      content: line,
                                      fromRobot: false));
                }
            });
        }
Exemplo n.º 13
0
Arquivo: Echo.cs Projeto: nubot/nubot
 public override void Attach(IRobot robot)
 {
     robot.Listen("echo (?<Message>.*)", async ctx =>
     {
         await ctx.SendAsync("{0}", ctx.Parameters["Message"]);
     });
 }
Exemplo n.º 14
0
 /// <summary>
 /// Execute the command on the robot 
 /// update robot position with the simulated position
 /// </summary>
 /// <param name="robot"></param>
 /// <returns></returns>
 public bool Run(IRobot robot)
 {
     if (robot.Position == null)
         return false;
     robot.Position = Simulate(robot);
     return true;
 }
Exemplo n.º 15
0
        public Admin(IRobot robot)
            : base("Nubot Admin", "/nubot", robot)
        {
            HelpMessages = new List<string>
            {
                "admin plugins list - List plugin(s) currently loaded",
                "admin plugins reload - Reload plugin(s)"
            };

            Get["version"] = x => Robot.Version;
            Get["ping"] = x => "PONG";
            Get["time"] = x => string.Format("Server time is: {0}", DateTime.Now);
            Get["ip"] = x => new WebClient().DownloadString("http://ifconfig.me/ip");
            Get["plugins"] = x => ShowPlugins();
            Get["info"] = x =>
            {
                var currentProcess = Process.GetCurrentProcess();
                return string.Format("[pid:{0}] [Start Time:{1}]", currentProcess.Id, currentProcess.StartTime);
            };

            Get["admin"] = x => View["index.cshtml", new IndexViewModel { RobotPlugins = Robot.RobotPlugins, RobotVersion = Robot.Version }];

            Get["plugins"] = x => View["plugins.cshtml", new IndexViewModel { RobotPlugins = Robot.RobotPlugins, RobotVersion = Robot.Version }];
            Post["plugins/update"] = parameters =>
            {
                var settings = this.Bind<List<SettingsModel>>();

                foreach (var setting in settings)
                {
                    Robot.Settings.Set(setting.Key, setting.Value);
                }

                return Response.AsRedirect("/nubot/plugins");
            };
        }
Exemplo n.º 16
0
 private static void SomeFunctionThatAcceptsRobot(IRobot robot)
 {
     robot.ReactToHuman("Pavel");
     robot.TurnLeft();
     robot.GoToDock();
     
 }
Exemplo n.º 17
0
        public void Setup(IRobot robot)
        {
            robot.AddResponder(@"bing\s+(me\s+)?(?<query>.*)", (session, message, room, match) =>
            {
                Task.Factory.StartNew(() =>
                {
                    var query = match.ValueFor("query");

                    var result = _bingClient.WebSearch(query);

                    var resultMatch = Regex.Match(result, @"<div class=""sb_tlst""><h3><a href=""(?<result>[^""]*)");

                    string resultMessage;
                    if (resultMatch.Success)
                    {
                        resultMessage = string.Format("@{0} {1}", session.Message.User.Name, resultMatch.ValueFor("result"));
                    }
                    else
                    {
                        resultMessage = string.Format("@{0} Sorry, Bing had zero results for '{1}'", session.Message.User.Name, query);
                    }

                    robot.SendMessage(room, resultMessage);
                });
            });
        }
Exemplo n.º 18
0
 /// <summary>
 /// Execute the robots report function
 /// </summary>
 /// <param name="robot"></param>
 /// <returns></returns>
 public bool Run(IRobot robot)
 {
     if (robot.Position == null)
         return false;
     robot.Report();
     return true;
 }
Exemplo n.º 19
0
 public JabbrListenerWorker(LogOnInfo logOnInfo, JabbRClient client, string[] rooms, IRobot robo, string userName)
 {
     _robo = robo;
     _rooms = rooms;
     _client = client;
     _logOnInfo = logOnInfo;
     _userName = userName;
 }
Exemplo n.º 20
0
 public void Add(IRobot robot)
 {
     var type = robot.GetType();
     if (!_robots.ContainsKey(type))
     {
         _robots.Add(type, robot);
     }
 }
Exemplo n.º 21
0
 public void Remove(IRobot robot)
 {
     var type = robot.GetType();
     if (_robots.ContainsKey(type))
     {
         _robots.Remove(type);
     }
 }
Exemplo n.º 22
0
 public CommandCenter(ICommandParser commandParser, IRobot robot, ISurface surface, CommandFactory commandFactory)
 {
     _robot = robot;
     _commandParser = commandParser;
     Surface = surface;
     _commandFactory = commandFactory;
     _executedCommands = new List<ICommand>();
 }
Exemplo n.º 23
0
        public PlaceCommand(IRobot robot, int x = 0, int y = 0, Direction direction = Direction.North)
        {
            _robot = robot;

            X = x;
            Y = y;
            Direction = direction;
        }
Exemplo n.º 24
0
 public override void Attach(IRobot robo, CancellationToken token)
 {
     robo.Hear(msg =>
     {
         string type = msg.DirectedAtRobot ? "DM" : "OH";
         robo.Log.Trace("[{0} In {1}] {2}: {3}", type, msg.Room, msg.From, msg.Content);
     });
 }
Exemplo n.º 25
0
 public override void Attach(IRobot robot)
 {
     robot.Hear("ship\\s*it", async ctx =>
     {
         var squirrel = robot.Random(Squirrels);
         await ctx.SendAsync(squirrel);
     });
 }
Exemplo n.º 26
0
        protected RobotPluginBase(string pluginName, IRobot robot)
        {
            Name = pluginName;

            Robot = robot;

            HelpMessages = new List<string>();
        }
Exemplo n.º 27
0
 /// <summary>
 /// Execute the command on the robot 
 /// update robot position with the simulated position
 /// </summary>
 /// <param name="robot"></param>
 /// <returns></returns>
 public bool Run(IRobot robot)
 {
     // Has robot been positioned?
     if (robot.Position == null)
         return false;
     robot.Position = Simulate(robot);
     return true;
 }
Exemplo n.º 28
0
 public ControlSystem(IConveyor conveyor, IRobot robot, IVacuumPort vacuumPort)
 {
     _conveyor = conveyor;
     _robot = robot;
     _vacuumPort = vacuumPort;
     CleanupStart += _vacuumPort.OnCleanUp;
     CleanupComplete += _vacuumPort.OnCleanUpComplete;
 }
Exemplo n.º 29
0
 /// <summary>
 ///  Simulate the target position without changing the robots position
 /// </summary>
 /// <param name="robot"></param>
 /// <returns></returns>
 public Position Simulate(IRobot robot)
 {
     if (robot.Position == null)
         return null;
     int direction = (int)robot.Position.Facing;
     if (--direction < 0)
         direction = 3;
     return new Position(robot.Position.X, robot.Position.Y, (Direction)direction);
 }
Exemplo n.º 30
0
 public override void AttachToHttpApp(IRobot robo, IAppBuilder app)
 {
     app.UseFunc(next => async environment => {
         var req = new Request(environment);
         TraceRequest(robo, req);
         await next(environment);
         TraceResponse(robo, req, new Response(environment));
     });
 }
Exemplo n.º 31
0
        public SimpleCommandParser(IRobot robot)
        {
            ParamGuard.NotNull(robot, nameof(robot));

            this.robot = robot;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="RobotController"/> class
 /// </summary>
 /// <param name="robot">Robot that is controlled</param>
 public RobotController(IRobot robot)
 {
     // Store robot for later use
     this.robot = robot;
 }
Exemplo n.º 33
0
 public override NotReturnValue Interpret(IRobot robot)
 {
     robot.Down();
     return(new NotReturnValue());
 }
 private static void PrintPosition(IRobot newRobot)
 {
     TestContext.Out.WriteLine($"Robot position: {newRobot.Position.Row} {newRobot.Position.Column} {newRobot.Direction}{(newRobot.IsLost ? " LOST" : string.Empty)}");
 }
Exemplo n.º 35
0
 /// <summary>
 /// 添加一个接口
 /// </summary>
 /// <param name="robot"></param>
 /// <returns></returns>
 public bool Add(IRobot robot)
 {
     return(true);
 }
Exemplo n.º 36
0
 public RightCommand(IRobot robot) : base(robot)
 {
 }
Exemplo n.º 37
0
 public void Execute(IRobot robot)
 {
     robot.Beep();
 }
Exemplo n.º 38
0
        //private readonly ICrawlerHistory m_CrawlerHistory;
        //private readonly int m_GroupId;

        public FundServiceCrawler(Crawler crawler, IRobot robot, Uri baseUri)
            : base(crawler, robot, baseUri)
        {
            //m_GroupId = baseUri.GetHashCode();
        }
Exemplo n.º 39
0
 public CleanedPlacesService(IRobot _robot)
 {
     robot = _robot;
 }
Exemplo n.º 40
0
 public override IAction CreateAction(IRobot item, IMapDataProvider mapDataProvider, string actionParameters)
 {
     return(new MoveAction(item, mapDataProvider));
 }
 public Controller(IDisplay display, IReader reader, IRobot robot)
 {
     _display = display;
     _reader  = reader;
     _robot   = robot;
 }
Exemplo n.º 42
0
 public Moved(IRobot robot, ICalculator calculator) : base(robot, calculator)
 {
 }
Exemplo n.º 43
0
 public LeftCommand(IRobot robot) : base(robot)
 {
 }
Exemplo n.º 44
0
        /// <summary>
        /// Retrieves a plate description.
        /// </summary>
        /// <param name="robot">The robot to find the plate type for.</param>
        /// <param name="plateID">The <c>plateID</c> of the plate.</param>
        /// <returns>The <c>IPlateInfo</c> describing the plate.</returns>
        public IPlateInfo GetPlateInfo(IRobot robot, string plateID)
        {
            return(_plateInfoCache.GetPlateInfo(robot, plateID));

            /*
             * Replaced by cache
             *
             * // Check arguments - do it up front to avoid possible inconsistencies later
             * if (robot == null) throw new System.NullReferenceException("robot must not be null");
             * if (plateID == null) throw new System.NullReferenceException("plateID must not be null");
             *
             * // Log the call
             * if (_log.IsDebugEnabled)
             * {
             *  string msg = "Called " + this + ".GetPlateInfo(robot=" + robot.ToString() + ", plateID=\"" + plateID + "\")";
             *  _log.Debug(msg);
             * }
             *
             * // Special case for ReliabilityTestPlate
             * if ("ReliabilityTestPlate".Equals(plateID))
             * {
             *  OPPF.Integrations.ImagerLink.PlateInfo dummy = new OPPF.Integrations.ImagerLink.PlateInfo();
             *  dummy.DateDispensed = DateTime.Now;
             *  dummy.ExperimentName = "Dummy Expt Name";
             *  dummy.PlateNumber = 1;
             *  dummy.PlateTypeID = "1";
             *  dummy.ProjectName = "Dummy Project Name";
             *  dummy.UserEmail = "DummyEmailAddress";
             *  dummy.UserName = "******";
             *
             *  return dummy;
             * }
             *
             * // Declare the return variable
             * OPPF.Integrations.ImagerLink.PlateInfo pi = null;
             *
             * try
             * {
             *  // Create and populate the request object
             *  getPlateInfo request = new getPlateInfo();
             *  request.robot = OPPF.Utilities.RobotUtils.createProxy(robot);
             *  request.plateID = plateID;
             *
             *  // Make the web service call
             *  WSPlate wsPlate = new WSPlate();
             *  getPlateInfoResponse response = wsPlate.getPlateInfo(request);
             *
             *  // Get the webservice proxy PlateInfo
             *  OPPF.Proxies.PlateInfo ppi = response.getPlateInfoReturn;
             *
             *  // Map it into an IPlateInfo
             *  pi = new OPPF.Integrations.ImagerLink.PlateInfo();
             *  pi.DateDispensed = ppi.dateDispensed;
             *  pi.ExperimentName = ppi.experimentName;
             *  pi.PlateNumber = ppi.plateNumber;
             *  pi.PlateTypeID = ppi.plateTypeID;
             *  pi.ProjectName = ppi.projectName;
             *  pi.UserEmail = ppi.userEmail;
             *  pi.UserName = ppi.userName;
             *
             * }
             * catch (Exception e)
             * {
             *  string msg = "WSPlate.getPlateInfo threw " + e.GetType() + ":\n" + e.Message + "\nfor plate \"" + plateID + "\" in robot \"" + robot.Name + "\"\n - probably not in LIMS - not fatal.";
             *  msg = msg + WSPlateFactory.SoapExceptionToString(e);
             *
             *  // Log it
             *  _log.Error(msg, e);
             *
             *  // Don't rethrow - return null - don't want to stop imaging
             * }
             *
             * // Return the IPlateInfo
             * return pi;
             */
        }
Exemplo n.º 45
0
 public ProgramExecutor(IProgram program, IRobot robot)
 {
     this.Robot   = robot;
     this.Program = program;
 }
Exemplo n.º 46
0
 public void Init()
 {
     _commandRecorder     = new CommandRecorder();
     _robotCommandHandler = new RobotCommandHandler(_commandRecorder);
     _robot = MockRepository.GenerateStub <IRobot>();
 }
Exemplo n.º 47
0
 public BotClient(CommandLineOptions options, IRobot bot)
 {
     this.Options = options;
     this.Bot     = bot;
     this._Timer  = new Stopwatch();
 }
        public override void DoService(IRobot robot, int procedureTime)
        {
            base.DoService(robot, procedureTime);

            robot.Happiness -= 7;
        }
Exemplo n.º 49
0
        public IRobot RobotInstance(string assemlyName)                                            //LFNet.Robot.Robot, LFNet.Robot
        {
            IRobot obj = (IRobot)Activator.CreateInstance(Type.GetType(assemlyName), false, true); //Activator.CreateInstance(Type, false, true));

            return(obj);
        }
Exemplo n.º 50
0
 public RoboComponent(IRobot robot)
 {
     this.Robot = robot ?? throw new ArgumentNullException(nameof(robot));
 }
Exemplo n.º 51
0
 public bool DoAction(IField currentField, IRobot currentRobot)
 {
     currentRobot.CurrentDirection = currentRobot.CurrentDirection.Next();
     return(true);
 }
Exemplo n.º 52
0
 public void InvalidStartingCoordinates([ValueSource("GetInstances")] IRobot robotImpl)
 {
     Assert.Warn("Recommended test additions");
 }
Exemplo n.º 53
0
 public MoveAction(IRobot item, IMapDataProvider mapDataProvider) : base(item, mapDataProvider)
 {
 }
Exemplo n.º 54
0
 public void InvalidNumberOfCommands([ValueSource("GetInstances")] IRobot robotImpl)
 {
     Assert.Warn("Recommended test additions");
 }
Exemplo n.º 55
0
 public Simulation()
 {
     Robot    = new Robot();
     TableTop = new TableTop(5, 5);
 }
Exemplo n.º 56
0
 public void NumberOfGivenCommandsExceedsDeclaration([ValueSource("GetInstances")] IRobot robotImpl)
 {
     Assert.Warn("Recommended test additions");
 }
Exemplo n.º 57
0
 public void Collision([ValueSource("GetInstances")] IRobot robotImpl)
 {
     Assert.Warn("Recommended test additions");
 }
Exemplo n.º 58
0
 public void OutOfBounds([ValueSource("GetInstances")] IRobot robotImpl)
 {
     Assert.Warn("Recommended test additions");
 }
Exemplo n.º 59
0
 private InputValidator GetInputValidator(IRobot robot, ITable table)
 {
     return(new InputValidator(robot, table));
 }
Exemplo n.º 60
0
 public LeftPositionCalculator(IRobot robot, ICalculator calculator) : base(robot, calculator)
 {
 }