Ejemplo n.º 1
0
        void HandleTrigger(string argument)
        {
            switch (argument)
            {
            case "GoUp":
                _crawlerStatus = CrawlerStatus.GoUp;
                _lowerLandingGear.Lock();
                _upperLandingGear.Unlock();
                ExtendPistons();
                break;

            case "GoDown":
                _crawlerStatus = CrawlerStatus.GoDown;
                _upperLandingGear.Lock();
                _lowerLandingGear.Unlock();
                ExtendPistons();
                break;

            case "Stop":
                _crawlerStatus = CrawlerStatus.Stop;
                break;

            default:
                Echo($"Invalid option: {argument}\n");
                break;
            }
        }
    public void Update()
    {
        UpdatedStatus = false;
        UpdatedStride = false;
        if (Stopped)
        {
            _State = LegState.Stopped;
        }

        if (TargetLeg == LegStatus.Lowered)
        {
            LandingGear.Lock();
        }
        UpdateMotor(Rotor1);
        UpdateHinge(Hinge1);
        UpdateHinge(Hinge2);
        UpdateHinge(Hinge3);
        UpdateHinge(Hinge4);
        if (LandingGear.LockMode != LandingGearMode.Locked)
        {
            Rotor2.Enabled           = true;
            Rotor2.TargetVelocityRad = Rotor2.Angle / -2;
        }
        else
        {
            Rotor2.Enabled = false;
        }
    }
Ejemplo n.º 3
0
        public void Main(string argument, UpdateType updateSource)
        {
            try {
                Warnings.Clear();
                ResolveOperation();
                HandleArgs(argument);
                Governor();
                CheckUpdateFrequency();

                OperationGraphic.Selection = (UInt16)Operations.ToArrayIndex(Operation);
                StatusLCDs.WriteText(OperationGraphic.Render(), true);
                StatusLCDs.WriteText(RenderMaxImpulseAxis(), true);
                ConsoleLCDs.WriteText(RenderMaxImpulseAxis(), true);
                ConsoleLCDs.WriteText("Argument: " + (argument ?? "Null") + '\n', true);
                ConsoleLCDs.WriteText("UpdateType: " + updateSource.ToString() + '\n', true);
            } catch (BlockNullReferenceException BlockNull) {
                string ErrorMessageFormatted = "CRITICAL ERROR:\n" + BlockNull.Message;
                ConsoleLCDs.WriteText(ErrorMessageFormatted, false);
                StatusLCDs.WriteText(ErrorMessageFormatted, false);

                StatusLCDs.FlushText();
                ConsoleLCDs.FlushText();
                throw;
            } catch (KlangSafetyException KlangSafety) {
                Piston.Enabled = false;
                OutRiggerRelease();
                Lock.Enabled  = false;
                Foot.Enabled  = true;
                Foot.AutoLock = true;
                Foot.Lock();
                Runtime.UpdateFrequency = UpdateFrequency.None;

                string ErrorMessageFormatted = "CRITICAL ERROR:\n" + KlangSafety.Message;
                ConsoleLCDs.WriteText(ErrorMessageFormatted, false);
                StatusLCDs.WriteText(ErrorMessageFormatted, false);

                StatusLCDs.FlushText();
                ConsoleLCDs.FlushText();
                throw;
            } catch (Exception) {
                throw;
            }

            if (Warnings.Count > 0)
            {
                string WarningMessageFormatted = "|| WARNINGS ||:\n";
                foreach (string Warning in Warnings)
                {
                    WarningMessageFormatted += Warning + "\n";
                }
                WarningMessageFormatted += "|| END OF WARNINGS ||\n\n";
                ConsoleLCDs.WriteText(WarningMessageFormatted + ConsoleLCDs.GetText(), false);
                StatusLCDs.WriteText(WarningMessageFormatted + StatusLCDs.GetText(), false);
            }
            Echo(ConsoleLCDs.GetText());
            StatusLCDs.FlushText();
            ConsoleLCDs.FlushText();
        }
Ejemplo n.º 4
0
 private void ToggleGear(IMyLandingGear gear, bool state)
 {
     if (state)
     {
         gear.Lock();
         gear.AutoLock = true;
     }
     else
     {
         gear.Unlock();
         gear.AutoLock = false;
     }
 }
Ejemplo n.º 5
0
            bool TryLockInLGear(double distance)
            {
                IMyLandingGear clamp = Reference as IMyLandingGear;

                clamp.Enabled = true;
                if (AutoLockDistance > 0)
                {
                    clamp.AutoLock = distance < AutoLockDistance;
                }
                if (clamp.LockMode == LandingGearMode.ReadyToLock)
                {
                    clamp.Lock();
                }
                return(clamp.LockMode == LandingGearMode.Locked);
            }
Ejemplo n.º 6
0
            public void GearsLock(bool bLock = true)
            {
                for (int i = 0; i < gearList.Count; i++)
                {
                    IMyLandingGear g = gearList[i] as IMyLandingGear;
                    if (g == null)
                    {
                        continue;
                    }
                    if (bLock)
                    {
                        g.Lock();
                    }
                    else
                    {
                        g.Unlock();
                    }

                    //                blockApplyAction(gearList[i], "Lock");
                }
            }
Ejemplo n.º 7
0
        public void Main(string argument, UpdateType updateSource)
        {
            try
            {
                switch (argument)
                {
                case "RUN":
                {
                    if (!running)
                    {
                        switch (_state)
                        {
                        case State.Closed:
                        {
                            _pistonInOut.Reverse();
                            _timer.TriggerDelay = 0.5f;
                            _timer.StartCountdown();
                            _gear.Unlock();

                            _state  = State.Open_Initial;
                            running = true;
                        }
                        break;

                        case State.Open:
                        {
                            _pistonSlide.Reverse();
                            _timer.TriggerDelay = 5f;
                            _timer.StartCountdown();
                            _state  = State.Close_Initial;
                            running = true;
                        }
                        break;
                        }
                    }
                }
                break;

                case "TIMER":
                {
                    if (running)
                    {
                        switch (_state)
                        {
                        case State.Open_Initial:
                        {
                            _pistonSlide.Reverse();
                            _timer.TriggerDelay = 5f;
                            _timer.StartCountdown();
                            _state = State.Open_Final;
                        }
                        break;

                        case State.Open_Final:
                        {
                            _state  = State.Open;
                            running = false;
                        }
                        break;

                        case State.Close_Initial:
                        {
                            _pistonInOut.Reverse();
                            _timer.TriggerDelay = 0.5f;
                            _timer.StartCountdown();

                            _state = State.Close_Final;
                        }
                        break;

                        case State.Close_Final:
                        {
                            _gear.Lock();
                            _state  = State.Closed;
                            running = false;
                        }
                        break;
                        }
                    }
                }
                break;
                }
            }
            catch (Exception e)
            {
                EchoText("Error: " + e.Message);
            }
        }
Ejemplo n.º 8
0
 private static void OutRiggerSecure()
 {
     Lock.Enabled  = true;
     Lock.AutoLock = true;
     Lock.Lock();
 }
Ejemplo n.º 9
0
 protected override void OnExecuting(IMyLandingGear landingGear)
 => landingGear.Lock();
Ejemplo n.º 10
0
        public Program()
        {
            var error = false;

            _upperLandingGear = GridTerminalSystem.GetBlockWithName("Lower Landing Gear") as IMyLandingGear;
            _lowerLandingGear = GridTerminalSystem.GetBlockWithName("Upper Landing Gear") as IMyLandingGear;

            _portBaseLandingGear      = GridTerminalSystem.GetBlockWithName("Port Base Landing Gear") as IMyLandingGear;
            _starboardBaseLandingGear = GridTerminalSystem.GetBlockWithName("Starboard Base Landing Gear") as IMyLandingGear;

            _piston1 = GridTerminalSystem.GetBlockWithName("Piston 1") as IMyExtendedPistonBase;
            _piston2 = GridTerminalSystem.GetBlockWithName("Piston 2") as IMyExtendedPistonBase;
            _piston3 = GridTerminalSystem.GetBlockWithName("Piston 3") as IMyExtendedPistonBase;

            if (_upperLandingGear == null)
            {
                Echo("No top landing gear");
                error = true;
            }

            if (_lowerLandingGear == null)
            {
                Echo("No bottom landing gear");
                error = true;
            }

            if (_portBaseLandingGear == null)
            {
                Echo("No port landing gear");
                error = true;
            }

            if (_starboardBaseLandingGear == null)
            {
                Echo("No starboard landing gear");
                error = true;
            }

            if (_piston1 == null)
            {
                Echo("No piston #1");
                error = true;
            }

            if (_piston2 == null)
            {
                Echo("No piston #2");
                error = true;
            }

            if (_piston3 == null)
            {
                Echo("No piston #3");
                error = true;
            }

            if (error)
            {
                Echo("Errors found. Please fix and recompile");
                return;
            }

            Runtime.UpdateFrequency = UpdateFrequency.Update10;

            _upperLandingGear.AutoLock = false;
            _upperLandingGear.Lock();

            _lowerLandingGear.AutoLock = false;
            _lowerLandingGear.Lock();

            _portBaseLandingGear.AutoLock      = false;
            _starboardBaseLandingGear.AutoLock = false;

            _crawlerStatus = CrawlerStatus.Stop;

            _init = true;
            Echo($"Crawler startup @ {DateTime.Now}");
        }