What you learn today
- Buttons inside and outside
- Status lights
- Announcements with sound
A lever in the chamber is fine to start with. But whoever stands outside cannot reach it, and whoever waits in the base cannot see whether the airlock is busy. A good airlock has buttons on both sides, a display and an announcement.
Buttons inside and outside
Each button calls the airlock to its own side:
| Button | sits | picks |
|---|---|---|
| “Innen” | in the base and in the chamber next to the inner door | direction 0: fill, inner door open |
| “Aussen” | outside and in the chamber next to the outer door | direction 1: pump empty, outer door open |
Whoever wants to go out calls the airlock with “Innen”, steps in and presses “Aussen” in the chamber. A batch with Average reads buttons with the same name together: if one is pressed, the value is greater than 0.
A button reports Activate 1 while it is held. For the direction only the new press counts, the edge from 0 upwards:
lbn inner BUTTON HASH("Innen") Activate Average
slt tmp oldInner inner # 1 = just pressed
select dir tmp 0 dir
move oldInner inner # for the next tick
Without an edge the one who presses longer wins: if someone outside holds “Aussen”, “Innen” would never get through. With an edge the latest new press wins.
The panel writes the direction into a logic memory “Richtung”. The chip that drives doors and vent reads it just like the lever before – the define then says StructureLogicMemory instead of StructureLogicSwitch. That way you spread the work over two chips, and neither hits the 4096 characters.
Status lights
Wall lights and flashing lights only know On – no colour and no dimming. Colour is available on the LED display through Color:
select colour ready Color.Green Color.Yellow
select colour ok colour Color.Red
sbn DISPLAY HASH("Status") Color colour
Green: the airlock is ready on the chosen side. Yellow: it is changing over, please wait. Red: the sensor is missing. The flashing light “Warnlicht” runs as long as it is not green.
Never write Color to a wall light. It does not know this LogicType, and a device that cannot write a LogicType stops the chip with an error. Coloured feedback belongs on the LED display.
Announcements with sound
The speaker (StructureKlaxon) picks its sound through SoundAlert – that is the same number as Mode. On 1 plays, On 0 is silent. The game has announcements made for airlocks:
| Name | Number | fits |
|---|---|---|
Sound.Depressurising | 20 | pumping down |
Sound.Pressurising | 21 | filling |
Sound.AirlockCycling | 22 | airlock changing over |
Sound.MalfunctionDetected | 26 | fault |
select sound dir Sound.Depressurising Sound.Pressurising
lbn tmp HORN HASH("Ansage") SoundAlert Average
beq tmp sound same_sound
sbn HORN HASH("Ansage") SoundAlert sound
same_sound:
sbn HORN HASH("Ansage") On warn
The chip only writes the sound when it changes: every write of SoundAlert triggers the sound again, even with the same value.
At a number position a name needs its namespace: Sound.Depressurising, Color.Green. The bare name alone is not a number there.
Exercise
Task
Build the control panel as a chip of its own. It drives no doors. It only tells the airlock where to go and shows what it is doing.
- Button “Innen”: direction 0, button “Aussen”: direction 1 – each only on a new press (edge). The direction goes into the logic memory “Richtung” via
Setting. After start-up the direction is 0. - The airlock is ready with direction 1 below
EMPTYand with direction 0 fromFULL(sensor “Schleuse”). - LED display “Status”:
Setting= chamber pressure,Colorgreen (ready), yellow (changing over), red (sensor missing; thenSetting−1). - Flashing light “Warnlicht” on as long as the airlock is not ready.
- Speaker “Ansage”:
SoundAlertSound.Depressurisingwhile pumping down,Sound.Pressurisingwhile filling,Sound.MalfunctionDetectedwithout a sensor.Onlike the warning light.
Hints
Hint 1
Edge: slt tmp oldInner inner, select dir tmp 0 dir, then move oldInner inner. The same for “Aussen” with 1.
Hint 2
Ready: slt tmp press EMPTY, sge ready press FULL, then select ready dir tmp ready.
Hint 3
Colour: select colour ready Color.Green Color.Yellow, then select colour ok colour Color.Red.
Hint 4
Warning light and speaker: seqz warn ready. For NaN ready is 0, so there is a warning.
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