//Opens a door programatically. As opposed to the user opening the door //Aka, set the programResponsible variable when opening and set a time to close. public void ProgramOpen() { door.OpenDoor(); ProgramOpening = true; autoCloseInSecondsOnceOpen = timeOpenExiting; //used to be below line but that didn't wait for the door to open before starting the timer. //Used to be a bool but now you can optinally send other values than default to it to keep it open loonger. //autoCloseTime = P.Time + TimeSpan.FromSeconds(timeOpenExiting); }
public static void ToggleOpenAndEnable(this IMyDoor door, Boolean open, Boolean enabled) { switch (door.Status) { case DoorStatus.Open: if (open) { door.Enabled = enabled; } else { door.Enabled = true; door.CloseDoor(); } break; case DoorStatus.Opening: if (!open) { door.Enabled = true; door.CloseDoor(); } break; case DoorStatus.Closing: if (open) { door.Enabled = true; door.OpenDoor(); } break; case DoorStatus.Closed: if (open) { door.Enabled = true; door.OpenDoor(); } else { door.Enabled = enabled; } break; } }
public void setState(bool open) { if (open) { door.OpenDoor(); } else { door.CloseDoor(); } }
void ProcessJobs() { if (schedule.Count > 0 && schedule[0].TTJ <= 0) { Job curr = schedule[0]; schedule.RemoveAt(0); string name = "ANTI-"; IMyDoor antiDoor = GridTerminalSystem.GetBlockWithName("[NO-RENAME] Anti Door " + curr.misNo) as IMyDoor; switch (curr.type) { case JobType.OpenDoor: if (antiDoor != null) { antiDoor.OpenDoor(); } break; case JobType.Launch: IMyProgrammableBlock missile = GridTerminalSystem.GetBlockWithName(name + curr.misNo) as IMyProgrammableBlock; if (missile == null) { string message = "ABORTING LAUNCH: MISSILE DOES NOT EXIST: \"" + name + curr.misNo + "\""; Output(message); Function(false); //ErrorOutput(message); return; } else { Entry target; long id; if (curr.code.Length > 0 && long.TryParse(curr.code, out id) && TryGetAMT(id, out target)) { missile.TryRun("prep " + target.Position.X + " " + target.Position.Y + " " + target.Position.Z + " " + curr.code); } } break; case JobType.CloseDoor: if (antiDoor != null) { antiDoor.CloseDoor(); } break; } } foreach (Job job in schedule) { --job.TTJ; } }
private void DepressurizeSequence() { if (_vent.GetOxygenLevel() == 0) { _outerDoor.Enabled = true; _outerDoor.OpenDoor(); _status = VentStatus.Depressurized; } else if (_innerDoor.Status == DoorStatus.Closed) { _innerDoor.Enabled = false; _vent.Depressurize = true; } }
private void PressurizeSequence() { if (_vent.Status == VentStatus.Pressurized) { _outerDoor.Enabled = false; _innerDoor.Enabled = true; _innerDoor.OpenDoor(); _status = VentStatus.Pressurized; } else if (_outerDoor.Status == DoorStatus.Closed) { _outerDoor.Enabled = _vent.Depressurize = false; } }
public void Main(string argument, UpdateType updateSource) { Runtime.UpdateFrequency = UpdateFrequency.Update10; IMyTextPanel codeScreen = (IMyTextPanel)GridTerminalSystem.GetBlockWithName("KodePanel"); IMyTextPanel acceptScreen = (IMyTextPanel)GridTerminalSystem.GetBlockWithName("AcceptScreen"); IMyDoor myDoor = (IMyDoor)GridTerminalSystem.GetBlockWithName("CommandDoor"); IMyButtonPanel buttonPanel = (IMyButtonPanel)GridTerminalSystem.GetBlockWithName("Button"); string inputPassword = codeScreen.GetText(); if (inputPassword == passcode) { myDoor.OpenDoor(); acceptScreen.WriteText("Code Accepted"); } else { myDoor.CloseDoor(); } }
/// <summary> /// If a sensor is activated /// </summary> private void If_Activated() { IMyDoor door = null; for (int i = 0; i < sensors.Count; i++) { if (sensors [i].IsActive) { string [] data = sensors [i].CustomData.Split(':'); // The custom data string seperated by ':' if (data.Length <= 1) { errorFLAG = 4; errorText = $"Custom data on ({sensors [i].CustomName}) is missing custom data"; break; } string pressureInfo = Is_Under_Pressure(data [0]); // will see if the room is pressurized or not if (pressureInfo == "Error") { errorFLAG = 4; errorText = $"({data [0]}) has no vents.\n Check custom data on each vent\n for the Airlock"; break; } for (int j = 0; j < doors.Count; j++) { if (sensors [i].CustomData == doors [j].CustomData) // If sensor and door mhas matching custom data { door = doors [j]; if (data [1] == "Inside") // If the sensors custom data includes "Inside" { errorFLAG = 0; if (pressureInfo == "100.00%" && pressureInfo != "0.00%" && pressureInfo != "Not pressurized") // If the room is 100% pressurized; Open door { door.GetActionWithName("OnOff_On").Apply(door); // Turn door on if (door.Status != DoorStatus.Opening || door.Status != DoorStatus.Open) // If the door is not open or opening; Open door { door.OpenDoor(); } } break; } else if (data [1] == "Outside") // If the sensors custom data include "Outside" { //errorText = $"(Info) - pressureInfo"; errorFLAG = 0; if (pressureInfo == "0.00%" && pressureInfo != "100.00%" || pressureInfo == "Not pressurized") // If the room not pressuzrized; Open door { door.GetActionWithName("OnOff_On").Apply(door); // Turn door on if (door.Status != DoorStatus.Opening || door.Status != DoorStatus.Open) // If door is not open or opening; Open door { door.OpenDoor(); } } break; } else { errorFLAG = 4; errorText = $"({data [0]}) has erros. Activated sensor does not include \"Inside\" or \"Outside\""; break; } } } if (door == null) { errorFLAG = 4; errorText = $"No Custom data on airlock doors is matching sensor ({sensors [i].CustomName})"; } break; } } }
public void Open() { _block.OpenDoor(); }
public void open() { door.OpenDoor(); opened = DateTime.Now; }
public void Open() => block_.OpenDoor();
public void Main(string argument, UpdateType updateSource) { string pressurizationType; if (updateSource == UpdateType.Trigger) { //Determine which side the user is entering and ensure all doors are closed calibration(); pressurizationType = ActivatedSensor.CustomData; state = getRequestedPressure(pressurizationType); //Adjust lighting to show that the room is undergoing a pressure change changeLightProperties(Red, 0.75f); SpinningLight.Enabled = true; Echo("Lights modified"); OppositeSensor.Enabled = false; //Change the room pressure based on which sensor was tripped if (state == PressureStates.Positive) { Vent.Depressurize = false; Echo("Room pressurizing"); } else if (state == PressureStates.Negative) { Vent.Depressurize = true; Echo("Room depressurizing"); } Runtime.UpdateFrequency = UpdateFrequency.Update100; } else if (updateSource == UpdateType.Update100) { //This allows the script to execute every 300 ticks instead of the stock 100 Update100Runs++; Echo(FinishedCycle.ToString()); if (Update100Runs % 3 == 0 && !FinishedCycle) { Echo("i-runs: " + Update100Runs.ToString()); if (isAirlockPressurized(state)) { //Change the lights to green to indicate it is finished cycling changeLightProperties(Green, 0.85f); SpinningLight.Enabled = false; //Open the door on the other side to allow exit IMyDoor oppositeDoor = getOppositeDoor(); oppositeDoor.OpenDoor(); Echo($"{oppositeDoor.CustomName} opened"); FinishedCycle = true; Update100Runs = 0; } else { Echo("ERROR"); } } else if (Update100Runs % 5 == 0 && FinishedCycle) { changeLightProperties(NormalColor, 1.5f); OppositeSensor.Enabled = true; Echo("Reset to beginning"); //The script doesn't need to run anymore so disable further runs Runtime.UpdateFrequency = UpdateFrequency.None; Update100Runs = 0; } } }
public DoorHandler(string doorName, IMyGridTerminalSystem gts) { name = doorName; // TODO: find the door. doorObj = (IMyDoor)gts.GetBlockWithName(name); // initialize the statemachine doorStateMachine = new StateMachine(); doorStateMachine.overrideState("closing"); // Set up the transititions, default to locked if no door. doorStateMachine.transitions.Add("enable", () => { if (doorObj == null) { return("locked"); } return((doorObj.Enabled) ? "opening" : "enable"); }); doorStateMachine.transitions.Add("opening", () => { if (doorObj == null) { return("locked"); } return((doorObj.Status == DoorStatus.Open) ? "open_wait" : "opening"); }); doorStateMachine.transitions.Add("timer_wait", () => { if (doorObj == null) { return("locked"); } return((doorStateMachine.timerActive()) ? "timer_wait" : "closing"); }); doorStateMachine.transitions.Add("closing", () => { if (doorObj == null) { return("locked"); } return((doorObj.Status == DoorStatus.Closed) ? "locked" : "closing"); }); // no transition for locked. doorStateMachine.actions.Add("enable", () => { if (doorObj == null) { return; } doorObj.Enabled = true; }); doorStateMachine.actions.Add("opening", () => { if (doorObj == null) { return; } if (doorObj.Status == DoorStatus.Opening) { return; } doorObj.OpenDoor(); }); doorStateMachine.actions.Add("open_wait", () => { if (doorObj == null) { return; } doorStateMachine.startTimer(5); doorStateMachine.overrideState("timer_wait"); }); doorStateMachine.actions.Add("closing", () => { if (doorObj == null) { return; } if (doorObj.Status == DoorStatus.Closing) { return; } doorObj.Enabled = true; doorObj.CloseDoor(); }); doorStateMachine.actions.Add("locked", () => { if (doorObj == null) { return; } doorObj.Enabled = false; }); }