public IEnumerator<INavigationAction> Execute(IRobot robot) { while (true) { yield return new TurnAction(90 * rand.Next(4)); yield return new MotionAction(15 - rand.Next(30)); } }
public Response(IRobot robot, Message message, string[] match) { _envelope = new Envelope(message); _robot = robot; Match = match; }
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; }
public override void Attach(IRobot robot) { robot.Hear("do\\s*it", async ctx => { await ctx.SendAsync("http://i.imgur.com/pKove8A.gif"); }); }
public Default(IRobot robot) : base("Default", robot) { HelpMessages = new List<string> { "help - Show help of all currently loaded plugin(s)" }; }
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(); }
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); } }); }
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; }; }
public override void Attach(IRobot robot) { robot.Listen("ping", async ctx => { await ctx.SendAsync("PONG"); }); }
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; }; }
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)); } }); }
public override void Attach(IRobot robot) { robot.Listen("echo (?<Message>.*)", async ctx => { await ctx.SendAsync("{0}", ctx.Parameters["Message"]); }); }
/// <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; }
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"); }; }
private static void SomeFunctionThatAcceptsRobot(IRobot robot) { robot.ReactToHuman("Pavel"); robot.TurnLeft(); robot.GoToDock(); }
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); }); }); }
/// <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; }
public JabbrListenerWorker(LogOnInfo logOnInfo, JabbRClient client, string[] rooms, IRobot robo, string userName) { _robo = robo; _rooms = rooms; _client = client; _logOnInfo = logOnInfo; _userName = userName; }
public void Add(IRobot robot) { var type = robot.GetType(); if (!_robots.ContainsKey(type)) { _robots.Add(type, robot); } }
public void Remove(IRobot robot) { var type = robot.GetType(); if (_robots.ContainsKey(type)) { _robots.Remove(type); } }
public CommandCenter(ICommandParser commandParser, IRobot robot, ISurface surface, CommandFactory commandFactory) { _robot = robot; _commandParser = commandParser; Surface = surface; _commandFactory = commandFactory; _executedCommands = new List<ICommand>(); }
public PlaceCommand(IRobot robot, int x = 0, int y = 0, Direction direction = Direction.North) { _robot = robot; X = x; Y = y; Direction = direction; }
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); }); }
public override void Attach(IRobot robot) { robot.Hear("ship\\s*it", async ctx => { var squirrel = robot.Random(Squirrels); await ctx.SendAsync(squirrel); }); }
protected RobotPluginBase(string pluginName, IRobot robot) { Name = pluginName; Robot = robot; HelpMessages = new List<string>(); }
/// <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; }
public ControlSystem(IConveyor conveyor, IRobot robot, IVacuumPort vacuumPort) { _conveyor = conveyor; _robot = robot; _vacuumPort = vacuumPort; CleanupStart += _vacuumPort.OnCleanUp; CleanupComplete += _vacuumPort.OnCleanUpComplete; }
/// <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); }
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)); }); }
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; }
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)}"); }
/// <summary> /// 添加一个接口 /// </summary> /// <param name="robot"></param> /// <returns></returns> public bool Add(IRobot robot) { return(true); }
public RightCommand(IRobot robot) : base(robot) { }
public void Execute(IRobot robot) { robot.Beep(); }
//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(); }
public CleanedPlacesService(IRobot _robot) { robot = _robot; }
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; }
public Moved(IRobot robot, ICalculator calculator) : base(robot, calculator) { }
public LeftCommand(IRobot robot) : base(robot) { }
/// <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; */ }
public ProgramExecutor(IProgram program, IRobot robot) { this.Robot = robot; this.Program = program; }
public void Init() { _commandRecorder = new CommandRecorder(); _robotCommandHandler = new RobotCommandHandler(_commandRecorder); _robot = MockRepository.GenerateStub <IRobot>(); }
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; }
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); }
public RoboComponent(IRobot robot) { this.Robot = robot ?? throw new ArgumentNullException(nameof(robot)); }
public bool DoAction(IField currentField, IRobot currentRobot) { currentRobot.CurrentDirection = currentRobot.CurrentDirection.Next(); return(true); }
public void InvalidStartingCoordinates([ValueSource("GetInstances")] IRobot robotImpl) { Assert.Warn("Recommended test additions"); }
public MoveAction(IRobot item, IMapDataProvider mapDataProvider) : base(item, mapDataProvider) { }
public void InvalidNumberOfCommands([ValueSource("GetInstances")] IRobot robotImpl) { Assert.Warn("Recommended test additions"); }
public Simulation() { Robot = new Robot(); TableTop = new TableTop(5, 5); }
public void NumberOfGivenCommandsExceedsDeclaration([ValueSource("GetInstances")] IRobot robotImpl) { Assert.Warn("Recommended test additions"); }
public void Collision([ValueSource("GetInstances")] IRobot robotImpl) { Assert.Warn("Recommended test additions"); }
public void OutOfBounds([ValueSource("GetInstances")] IRobot robotImpl) { Assert.Warn("Recommended test additions"); }
private InputValidator GetInputValidator(IRobot robot, ITable table) { return(new InputValidator(robot, table)); }
public LeftPositionCalculator(IRobot robot, ICalculator calculator) : base(robot, calculator) { }