Esempio n. 1
0
            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;
                }
            }
Esempio n. 2
0
 /// <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);
 }
        public Program()
        {
            this.Runtime.UpdateFrequency = UpdateFrequency.Update1;
            this.manager = Process.CreateManager(this.Echo);
            var screen = this.GridTerminalSystem.GetBlockWithName("SMB LCD (Rear Seat)") as IMyTextPanel;
            var logger = new Logger(this.manager, screen);

            this.cmd = new CommandLine("Small Mobile Base", logger.Log, this.manager);

            var ini              = new IniWatcher(this.Me, this.manager);
            var controller       = this.GridTerminalSystem.GetBlockWithName("SMB Remote Control (Forward)") as IMyShipController;
            var transformer      = new CoordinatesTransformer(controller, this.manager);
            var wheelsController = new WheelsController(this.cmd, controller, this.GridTerminalSystem, ini, this.manager, transformer);

            new ConnectionClient(ini, this.GridTerminalSystem, this.IGC, this.cmd, this.manager, logger.Log);

            new CameraTurret(this.GridTerminalSystem, this.manager);

            new PilotAssist(this.GridTerminalSystem, ini, logger.Log, this.manager, wheelsController);
        }
Esempio n. 4
0
        public Program()
        {
            this.Runtime.UpdateFrequency = UpdateFrequency.Update1;
            var cockpits = new List <IMyCockpit>();

            this.GridTerminalSystem.GetBlocksOfType(cockpits, c => c.CubeGrid == this.Me.CubeGrid);
            IMyCockpit cockpit = cockpits.First();

            this.manager = Process.CreateManager(this.Echo);
            var ct     = new CoordinatesTransformer(cockpit, this.manager);
            var logger = new Logger(this.manager, cockpit.GetSurface(0), new Color(0, 39, 15), new Color(27, 228, 33), this.Echo, 1.0f);

            this.cmd = new CommandLine("Small welder", logger.Log, this.manager);
            var ini    = new IniWatcher(this.Me, this.manager);
            var wc     = new WheelsController(this.cmd, cockpit, this.GridTerminalSystem, ini, this.manager, ct);
            var ac     = new ArmController(ini, this, this.cmd, cockpit, wc, this.manager);
            var client = new ConnectionClient(ini, this.GridTerminalSystem, this.IGC, this.cmd, this.manager, logger.Log);
            var ah     = new PilotAssist(this.GridTerminalSystem, ini, logger.Log, this.manager, wc);

            ah.AddBraker(client);
        }
Esempio n. 5
0
        public Program()
        {
            this.Runtime.UpdateFrequency = UpdateFrequency.Update1;
            var            topLefts  = new List <IMyTextSurface>();
            var            topRights = new List <IMyTextSurface>();
            IMyTextSurface keyboard;
            IMyCockpit     cockpit;

            this.manager = Process.CreateManager(this.Echo);
            this.initCockpit(out cockpit, topLefts, topRights, out keyboard);
            var ct     = new CoordinatesTransformer(cockpit, this.manager);
            var logger = new Logger(this.manager, keyboard, new Color(0, 39, 15), new Color(27, 228, 33), this.Echo, 1.0f);

            this.cmd = new CommandLine("Boring machine", logger.Log, this.manager);
            var ini = new IniWatcher(this.Me, this.manager);
            var wc  = new WheelsController(this.cmd, cockpit, this.GridTerminalSystem, ini, this.manager, ct);
            var ac  = new ArmController(ini, this, this.cmd, cockpit, wc, this.manager);
            var iw  = new InventoryWatcher(this.cmd, this.GridTerminalSystem, cockpit);
            var cc  = new ConnectionClient(ini, this.GridTerminalSystem, this.IGC, this.cmd, this.manager, logger.Log);
            var rcs = new List <IMyRemoteControl>();

            this.GridTerminalSystem.GetBlocksOfType(rcs, r => r.CubeGrid == this.Me.CubeGrid);
            IMyRemoteControl frc = rcs.First(r => r.DisplayNameText.Contains("Forward"));
            IMyRemoteControl brc = rcs.First(r => r.DisplayNameText.Contains("Backward"));
            var ap = new Autopilot(ini, wc, this.cmd, frc, logger.Log, this.manager);
            var ah = new PilotAssist(this.GridTerminalSystem, ini, logger.Log, this.manager, wc);

            ah.AddBraker(cc);
            ah.AddDeactivator(ap);
            var ar = new AutoRoutineHandler(this.cmd);

            // TODO parse routines
            new MiningRoutines(ini, this.cmd, ap, this.manager);
            var progs = new List <IMyProgrammableBlock>();

            this.GridTerminalSystem.GetBlocksOfType(progs, pr => pr.CubeGrid == this.Me.CubeGrid);
            var genStatus = new GeneralStatus(this, ac, cc);

            new ScreensController(genStatus, iw, topLefts, topRights, this.scheme, cockpit.CustomData, this.manager);
        }