What you learn today
- Two doors, one chamber
- Dangers during the change
- State instead of sequence
Mars morning, the drill outside reports a full ore box. Only a wall lies between you and the outside air. A simple door in it would let base air out every time it opens – and if someone leaves it open, you lose the whole base. That is why you go through an airlock.
Two doors, one chamber
| Part | Job |
|---|---|
| Inner door | separates the base from the chamber |
| Chamber | small room with a gas sensor and an active vent |
| Outer door | separates the chamber from the outside |
Instead of the whole base, only the small chamber changes its pressure. The active vent sucks the chamber air through a pipe into a tank (Vent.Inward, 1) and blows it back in when you come home (Vent.Outward, 0). That way hardly any air is lost.
A trip outside has three steps: inner door shut, pump the chamber empty, outer door open. Coming in is the mirror image: outer door shut, fill the chamber, inner door open.
Dangers during the change
- Both doors open: the base is connected straight to the outside air and vents.
- Opening a door against pressure: if the outer door opens with a full chamber, the chamber air is lost. If the inner door opens with an empty chamber, base air rushes into the chamber and the base pressure drops.
- Vent running with a door open: if it keeps sucking while the outer door is open, it pulls outside air into your air tank.
- Sensor gone: without a reading the chip does not know what is in the chamber. Then no door may open.
State instead of sequence
The first idea is often a sequence with waiting times:
# not like this: sequence with waits
sbn DOOR HASH("Innentuer") Open 0
sleep 5
sbn VENT HASH("Schleuse") On 1
sleep 30
sbn DOOR HASH("Aussentuer") Open 1
sleep 30 counts seconds, not kilopascals. If the vent has no power or the tank is full, the chamber is still full after 30 seconds – and the outer door opens anyway. During sleep the chip also reacts to nothing: no sensor failure, no abort.
Better: every tick the chip asks what the situation is right now and derives from it how each device must be set. The lever “Richtung” says where you are going (1 = out), the sensor how full the chamber is:
lbn out LEVER HASH("Richtung") Setting Average
lbn press SENSOR HASH("Schleuse") Pressure Average
slt empty press EMPTY # 1 = chamber empty
and tmp out empty # out AND empty?
sbn DOOR HASH("Aussentuer") Open tmp
If the vent is not running, empty stays 0 and the door stays shut. If the sensor fails, press is NaN, slt returns 0 – and again the door stays shut.
A door can open without your chip wanting it: by hand with a crowbar or through a second chip. Never rely on a door being shut just because you wrote Open 0. When it matters, read Open back.
Diagram
Exercise
Task
For now the airlock is operated by hand; your chip only keeps watch. The doors are named “Innentuer” and “Aussentuer”, plus there is an LED display “Status” and a flashing light “Warnlicht”.
- “Status” shows the state of the doors: inner door open counts 1, outer door open counts 2. Both shut = 0, both open = 3.
- The flashing light is on while both doors are open.
- If a door is missing from the network (NaN), “Status” shows −1 and the flashing light is on.
Hints
Hint 1
State: mul state outer 2, then add state state inner.
Hint 2
Danger: seq danger state 3.
Hint 3
If a door is missing, state is NaN. snan missing state notices it, select then sets −1, and or danger danger missing switches the light on.
Quiz
5 questions. You pass from 60 % – the server does the grading.
Complete the day
- Passed the simulator exercise
- Passed the quiz with at least 60 %
Without an account progress is saved in this browser only.
Report a mistake in this lesson
Please sign in to report. Sign in