public ConnectionClient(IniWatcher ini, IMyGridTerminalSystem gts, IMyIntergridCommunicationSystem igc, CommandLine commandLine, IProcessManager manager, Action <string> logger) { this.gts = gts; this.igc = igc; this.logger = logger; this.mainProcess = manager.Spawn(this.listen, "cc-listen", period: 5); this.listenerCmd = new CommandLine("Connection client listener", null, this.mainProcess); this.listenerCmd.RegisterCommand(new Command("ac-progress", Command.Wrap(this.progress), "", nArgs: 1)); this.listenerCmd.RegisterCommand(new Command("ac-done", Command.Wrap(this.done), "")); this.listenerCmd.RegisterCommand(new Command("ac-cancel", Command.Wrap(this.serverCancel), "")); this.listenerCmd.RegisterCommand(new Command("ac-ko", Command.Wrap(this.ko), "")); this.listener = this.igc.UnicastListener; ini.Add(this); this.Read(ini); this.addCmds(commandLine); manager.AddOnSave(this.save); if (ini.ContainsKey(SECTION, "state")) { ConnectionState state; Enum.TryParse(ini.Get(SECTION, "state").ToString(), out state); this.State = state; } }
/// <summary>Creates a PilotAssist</summary> /// <param name="gts">To get the different blocks</param> /// <param name="ini">Parsed ini that contains the configuration. See <see cref="Read(Ini)"/> for more information</param> /// <param name="logger">Optional logger</param> /// <param name="manager">Used to schedule itself</param> /// <param name="wc">Wheel controller used to actually controll the wheels</param> public PilotAssist(IMyGridTerminalSystem gts, IniWatcher ini, Action <string> logger, ISaveManager manager, WheelsController wc) { this.logger = logger; this.wheelControllers = wc; this.gts = gts; this.Read(ini); this.ManuallyBraked = !this.shouldBrake() && this.Braked; this.wasPreviouslyAutoBraked = this.shouldBrake(); manager.Spawn(this.handle, "pilot-assist"); manager.AddOnSave(this.save); ini.Add(this); }