stationeers.de Mod workshop · Dominik1199
DE Sign in
  1. Home
  2. IC10 academy
  3. Day 269

Day 269 of 365 · Pro · Month 9: Logistics and greenhouse

Pattern collection pro

The patterns of the pro level as building blocks: tracking, load shedding, target quantity and collective alarm – and one hysteresis subroutine that serves all three controls.

Lesson 22 min Week 39

What you learn today

  • Tracking and load shedding as building blocks
  • Target quantities and collective alarm as building blocks
  • Combine blocks

Once you have built many plants you notice: they are the same shapes again and again. A pro does not write them anew every time but recognises them as building blocks and puts them together.

Four building blocks of the pro level

BlockShapeExample
Trackingread a setpoint, convert, write to allsolar panels follow the sun
Load sheddinghysteresis, output “on” abovecomfort off with little reserve
Target quantityhysteresis, output “on” belowfurnace up to 200 ingots
Collective alarmmany conditions, one signalone light for everything

Tracking always has the same form, whether panels, lights or valves follow:

lbn target SENSOR HASH("Sonne") Horizontal Average
jal convert                # to suit the build
select target night PARK target   # park at night
sb PANEL Horizontal target

The conversion depends on how you built it – for solar panels you know it from day 186. At night a select sends the devices into a parking position.

One block for three controls

Generator, load shedding and target quantity look different but are the same hysteresis: “on below the lower limit, off from the upper one”. With load shedding only the output is inverted – shedding happens below the limit, the light is the opposite of that.

So you write the hysteresis once as a subroutine. Before each call you set four registers:

RegisterContent
valuethe reading
lowbelow this it turns on
highfrom here it turns off
statethe previous state, afterwards the new one
move value level
move low GEN_ON
move high GEN_OFF
move state gen
jal hyst
move gen state

The previous state of each control stays in a register of its own (gen, shed, furn). The subroutine only works on state.

Combining blocks

A collective alarm connects blocks that know nothing about each other: batteries missing, store missing. Each condition becomes 0 or 1, or combines them. In addition each control gets its own safe direction: without a battery value the generator runs, without a store the furnace stands still.

Warning

A subroutine must not overwrite registers the caller still needs. That is why the hysteresis has its own helper register h and does not touch tmp.

Diagram

Calling and returning from a subroutine Main loop 2 l r0 d0 Temperature 3 jal celsius 4 s d2 Setting r1 5 l r0 d1 Temperature 6 jal celsius 7 s d3 Setting r1 8 j start celsius: sub r1 r0 273.15 j ra ra = 4 back to line ra
Three calls, one subroutine: only the registers value, low, high and state change.

Exercise

Task

Write the subroutine hyst (on below low, off from high, state in state) and use it three times:

  • generator “Notstrom”: battery ratio, 30 % / 90 %, on without a battery
  • load shedding: battery ratio, 25 % / 40 %, light “Komfort” is the opposite, off without a battery
  • target quantity: ingots in slot 0 of the locker “Barren”, 50 / 200, arc furnace “Huette” (On as release, another chip starts the stacks), off without the locker
  • light “Sammel” on when battery or locker are missing

Hints

Hint 1

The subroutine has four lines plus j ra: slt h value high, and state state h, slt h value low, or state state h.

Hint 2

Before each jal hyst: set value, low, high and state. Afterwards put the state back into gen, shed or furn.

Hint 3

The comfort light is seqz tmp shed.

Quiz

3 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

Esc
↑ ↓ selectEnter open/ opens search anywhere