/// <summary> /// Load your modules or register your services here! /// </summary> /// <param name="kernel">The kernel.</param> private static void RegisterServices(IKernel kernel) { var qhub = new QueryHub(); var chub = new CommandHub(qhub); kernel.Bind<CommandHub>().ToConstant(chub); kernel.Bind<QueryHub>().ToConstant(qhub); }
private static bool InteractiveConsole(CommandHub cmdHub) { var stdio = CmdConsole.StdIO; stdio.Write("(Press [Enter] to start interactive interface)\n", Color32.FromConsoleColor(ConsoleColor.Green)); var sw = Stopwatch.StartNew(); var line = stdio.ReadLine(); sw.Stop(); if (line == null) { Logging.warning("Read an EOF from stdin"); if (sw.ElapsedMilliseconds < 50) { Logging.warning("...within 50 ms. Keep running without interactive interface."); Logging.warning("Please use --no-cli option if the program do not run from a console."); return(false); } Logging.warning("...exiting..."); } else { cmdHub.CmdLoop(CmdConsole.StdIO); } return(true); }
private void Awake() { if (!_instance && (!_instance == this)) { _instance = this; } }
public async Task <IHttpActionResult> Post(DrillHole drillHole) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { _context.DrillHoles.Add(drillHole); await _context.SaveChangesAsync(); // TODO: Use Web API SignalR Integration // https://www.nuget.org/packages/Microsoft.AspNet.WebApi.SignalR/ using (CommandHub hub = new CommandHub()) { hub.UpdateDisplay(drillHole); } return(Ok(drillHole)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
/// <summary> /// Load your modules or register your services here! /// </summary> /// <param name="kernel">The kernel.</param> private static void RegisterServices(IKernel kernel) { var qhub = new QueryHub(); var chub = new CommandHub(qhub); kernel.Bind <CommandHub>().ToConstant(chub); kernel.Bind <QueryHub>().ToConstant(qhub); }
public static int Main(string[] args) { try { if (args.ToList().Exists(a => a == "/debug" || a == "/d")) { ConsoleHelper.ShowDebug = true; ConsoleHelper.DebugWriteLine("Debug Mode Active"); var count = 0; foreach (var arg in args) { ConsoleHelper.DebugWriteLine("arg[" + count++.ToString() + "] = " + arg); } } #if DEBUG /* * args = new string[] { "f.rd", @"C:\Users\kboronka\Documents\Virtual Machines\caches", @"/pause" }; * args = new string[] { "rdp", "192.168.171.208", @"username", "password", @"/pause" }; * args = new string[] { "ip.set", "gigabit", "dhcp", @"/debug", @"/pause", @"/admin" }; * args = new string[] { "ip.set", "gigabit", "192.168.14.111", "255.255.255.0", @"/debug", @"/pause", @"/admin" }; * args = new string[] { "ip.config", @"/pause" }; * args = new string[] { "mssql-gs", "192.168.14.110", "TestDB", "sa", "test123", @"\scripts\", @"/pause" }; * args = new string[] { "f.open", "c:\temp" }; * args = new string[] { "file.open", @"c:\temp", @"/pause" }; * args = new string[] { "-b.net", "3.5", @"LabelPrinter.sln", "/p:Configuration=Release /p:Platform=\"Any CPU\"" }; * args = new string[] { "fanuc.downloadPR", "10.240.26.104", @"C:\Temp\posreg.test.csv", @"/pause" }; * args = new string[] { "svn.GetAssemblyVersion", @"https://github.com/kboronka/sar-tool/trunk/sar/Properties/AssemblyInfo.cs", @"/pause" }; * args = new string[] { "svn.GetNewAssemblyVersion", @"https://github.com/kboronka/sar-tool/trunk/sar/Properties/AssemblyInfo.cs", @"/pause" }; * args = new string[] { "dotNetVersions", @"/pause" }; * args = new string[] { "r", "test.cs", @"break;\r\n(.*)case", @"break;\n\n\n$1case", @"/pause" }; */ #endif var hub = new CommandHub(); Progress.Start(); if (args.Length == 0) { ConsoleHelper.ApplicationTitle(); } int exitCode = hub.ProcessCommands(args); Progress.Stop(); return(exitCode); } catch (Exception ex) { ConsoleHelper.WriteException(ex); Progress.Stop(); return(ConsoleHelper.EXIT_ERROR); } }
private static void HandleArgCmd(Argument argcmd, CommandHub cmdHub) { if (argcmd.paras.Count == 0) { Environment.Exit(-1); } var cmdrun = Command.FromArray(argcmd.paras.ToArray()); cmdHub.HandleCommand(CmdConsole.StdIO, cmdrun); Environment.Exit(cmdrun.statusCode); }
public ControllerProxy(CabinetController controller, IServiceProvider provider) { this.controller = controller; _provider = provider; _context = (ApplicationDbContext)provider.GetService(typeof(ApplicationDbContext)); _hub = (CommandHub)provider.GetService(typeof(CommandHub)); cabinet = _context.Cabinets.Select(s => s).SingleOrDefault(p => (p.ControllerId == controller.Id)); _hub.CommandStatusUpdated += Hub_CommandStatusUpdated; }
protected Command(CommandHub parent, string name, List<string> commands, string help, List<string> examples) { this.function = new FunctionPointer(this.Execute); this.usage = help; this.name = name; this.commands = commands; this.examples = examples; this.commandHub = parent; foreach (string command in commands) { parent.Add(command.ToLower(), this); } }
void AdrenalineRush() { _playerMovement = GameObject.FindGameObjectWithTag("Player").GetComponent <Movement>(); ++EnemySpawner.Kills; CommandHub.LogMetrics(); Debug.Log("Kills: " + EnemySpawner.Kills); Debug.Log("Shots Fired: " + BulletPool.ShotsFired); if ((EnemySpawner.Kills % _killStreak) == 0) { _playerMovement.setAdrenalineRush(true); adrenCounter++; } }
public override void OnInspectorGUI() { //base.OnInspectorGUI(); CommandHub commandHub = target as CommandHub; serializedObject.Update(); EditorGUILayout.PropertyField(_saveFilePath); EditorGUILayout.PropertyField(_saveFileName); serializedObject.ApplyModifiedProperties(); //if (GUILayout.Button("Save Level")) //{ // commandHub.SaveLevel(_saveFilePath.stringValue + _saveFileName.stringValue); //} }
void Start() { baseFire = Instantiate(baseFire, Vector3.zero, Quaternion.identity); personCountBase = personCount; stressResolution = "calm"; diffusing = false; diffusionFail = false; charging = false; chargeFail = false; gridTarget = new Vector2(-1f, -1f); rWTarget = new Vector2(-1f, -1f); sideTracked = false; GetComponent <Renderer>().sharedMaterial = materials[client]; odin = GameObject.FindGameObjectsWithTag("odin")[0]; baseFire.odin = odin; baseFire.bulletManager = odin.GetComponent <BulletManager>(); baseFire.shooterObject = gameObject; mover = GetComponent <Mover>(); //personCountText = GetComponentInChildren<TextMesh>(); //personCountText = transform.GetChild(1).GetComponent<TextMesh>(); personCountText.text = personCount.ToString(); //deployedIndexText = transform.GetChild(2).GetComponent<TextMesh>(); commandHub = GameObject.FindGameObjectsWithTag("Player")[client].GetComponent <CommandHub>(); commandHub.deployedUnits.Add(gameObject); enemies = new List <Enemy>(); spottedUnits = new List <GameObject>(); currentCommand = "idle"; localUnit = commandHub.isLocalPlayer; if (!isServer) { return; } InitBT(); StartCoroutine(ShootCoroutine()); StartCoroutine(RefreshCoroutine()); }
static void MainContinued(ArgParseResult ar, Controller controller) { LogFileWriter logWriter = null; ar.TryGetValue("--cmd", out var argcmd); if (argcmd == null) { Logging.info(NameWithVertionText); if (GuiMode) { Logging.info("(GUI mode)"); LogStdout = false; } } if (ar.TryGetValue("--log-file", out var logFile)) { Logging.info($"Logging file: {logFile.FirstParaOrThrow}"); logWriter = new LogFileWriter(logFile.FirstParaOrThrow, Logging.RootLogger); logWriter.Start(); logWriter.WriteHistoryLog(); } if (ar.TryGetValue("-c", out var v)) { specifiedConfigPath = v.FirstParaOrThrow; Logging.info($"configuation file: {specifiedConfigPath}"); } else if (ar.ContainsKey("--config-stdin")) { Logging.info("reading configuration from stdin until EOF..."); specifiedConfigContent = Console.In.ReadToEnd(); Logging.info($"configuration read {specifiedConfigContent.Length} chars"); } if (ar.TryGetValue("--socket-impl", out var socketImpl)) { MyStream.SetSocketImpl(socketImpl.FirstParaOrThrow); } long lastPackets = 0, lastBytes = 0; void updateTitle() { lock (CmdConsole.ConsoleOnStdIO.Lock) { var p = MyStream.TotalCopiedPackets; var b = MyStream.TotalCopiedBytes; Console.Title = $"{controller.RunningConnections}/{controller.TotalHandledConnections} current/total connections | relayed {p:N0} Δ{p - lastPackets:N0} packets / {b:N0} Δ{b - lastBytes:N0} bytes - {BuildInfo.AppName}"; lastPackets = p; lastBytes = b; } } bool titleUpdateRunning = false; Timer titleUpdateTimer = null; titleUpdateTimer = new Timer((x) => { if (titleUpdateRunning) { updateTitle(); } else { titleUpdateTimer.Change(-1, -1); Console.Title = BuildInfo.AppName; } }); controller.ConfigTomlLoaded += (x) => { if (x.TryGetValue <string>("log_file", out var log_file)) { log_file = controller.ProcessFilePath(log_file); if (logWriter?.LogFile != log_file) { logWriter?.Stop(); if (log_file != null) { logWriter = new LogFileWriter(log_file, Logging.RootLogger); logWriter.Start(); } } } var toRun = x.TryGetValue("update_title", Environment.OSVersion.Platform == PlatformID.Win32NT) && !GuiMode; if (toRun != titleUpdateRunning) { if (toRun) { titleUpdateRunning = true; titleUpdateTimer.Change(1000, 1000); } else { titleUpdateRunning = false; } } }; if (ar.ContainsKey("--force-jit")) { ForceJit(); } else if (ar.ContainsKey("--force-jit-async")) { Task.Run(() => ForceJit()); } if (argcmd == null || specifiedConfigPath != null || specifiedConfigContent != null) { if (specifiedConfigPath != null) { Commands.loadController(controller, specifiedConfigPath); } else if (specifiedConfigContent != null) { controller.FuncGetConfigFile = () => Controller.ConfigFile.FromContent(specifiedConfigContent); controller.Load(); controller.Start(); } else { var paths = GetConfigFilePaths(); controller.LoadConfigFileFromMultiPaths(paths); controller.Start(); } } var cmdHub = new CommandHub(); CommandHub = cmdHub; cmdHub.Prompt = $"{BuildInfo.AppName}>"; Commands.AddCommands(cmdHub, controller, null, new string[] { "all" }); cmdHub.AddCmdHandler("newbie", (cmd) => Commands.NewbieWizard(cmd, controller, specifiedConfigPath ?? configFilePath)); cmdHub.AddCmdHandler("ver", (cmd) => cmd.WriteLine(NameWithVertionText)); if (Environment.OSVersion.Platform == PlatformID.Win32NT) { cmdHub.AddCmdHandler("openfolder", (cmd) => { if (cmd.args.Length == 0) { Process.Start("explorer", "."); } else if (cmd.args.Length > 1) { goto WRONT_ARG; } else if (cmd.args[0] == "exe") { OpenFolerAndShowFile(Process.GetCurrentProcess().MainModule.FileName); } else if (cmd.args[0] == "config") { OpenFolerAndShowFile(controller.CurrentConfig.FilePath); } else { goto WRONT_ARG; } return; WRONT_ARG: cmd.statusCode = 1; cmd.WriteLine("wrong arguments"); void OpenFolerAndShowFile(string fileName) => Process.Start("explorer", $"/select, \"{fileName}\""); }, "Usage: openfolder [exe|config]"); } if (argcmd != null) { HandleArgCmd(argcmd, cmdHub); return; } #if NS_WINFORM cmdHub.AddCmdHandler("gui", (cmd) => { var winform = new WinForm.WinFormController(controller); winform.StartUIThread(); winform.Invoke(() => winform.ShowControllerForm(false)); }); if (GuiMode) { return; } #endif if (ar.ContainsKey("--no-cli")) { goto WAITFOREVER; } if (InteractiveConsole(cmdHub)) { Environment.Exit(0); return; } WAITFOREVER: #if NS_WINFORM if (GuiMode) { return; } #endif while (true) { Thread.Sleep(int.MaxValue); } }