What you learn today
- Read and write all devices of a type
- Difference to lbn/sbn
- “all lights off”
Closing time in the base: all wall lights should go off. You could switch each one by its name. Without names it is quicker.
lb and sb
| Instruction | Form | hits |
|---|---|---|
lbn | lbn r? type name LogicType batchmode | all devices of the type with this name |
lb | lb r? type LogicType batchmode | all devices of the type |
sbn | sbn type name LogicType value | all devices of the type with this name |
sb | sb type LogicType value | all devices of the type |
The name is simply missing. Everything else stays the same, including the batch modes.
define LIGHT HASH("StructureWallLight") # Wall Light
alias count r0
sb LIGHT On 0 # all wall lights off
lb count LIGHT On Sum # how many are still on?
What lb is good at asking
lb count LIGHT On Sum: how many lights are on?Onis 0 or 1, so the sum counts.lb count SENSOR Temperature Count: how many gas sensors does the chip see at all?lb temp SENSOR Temperature Average: mean temperature over all sensors of the base.
One type only
sb hits exactly one prefab. Wall light, long wall light and round light are different types – “all lights off” needs a line of its own for every light type.
sb does not ask. A sb VENT On 0 switches off every active vent on the network, including the one in the airlock you were not thinking about. Only use sb for things where “all” may really mean all: lights, display colours, signs. Anything to do with air, pressure or power needs names.
When to use what
| Task | Instruction |
|---|---|
| all lights off | sb |
| light in the storage | sbn with a name |
| mean temperature of the whole base | lb |
| temperature in the lab | lbn with a name |
Diagram
Exercise
Task
A main switch for the lights: the network holds three wall lights with different names, a lever “Hauptschalter” and an LED display “Licht an”.
- Lever flipped: all wall lights on, otherwise all off – with
sb. - The display shows how many wall lights are on right now – with
lb.
Hints
Hint 1
Read the lever with lbn by its name.
Hint 2
sb LIGHT On switch switches all wall lights at once.
Hint 3
lb count LIGHT On Sum counts the lights that are on.
Quiz
4 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