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

Day 354 of 365 · Expert · Month 12: Masterpieces

Masterpiece: logistics

Masterpiece logistics: count stock over many slots, request supply with hysteresis as a fixed batch size and report stock and state to the central unit.

Lesson 25 min Week 51

What you learn today

  • Logistics as a subsystem
  • Report stock
  • Requests

The fourth subsystem knows what is there. Logistics counts the stock in storage and says when supply is needed. It manufactures nothing and does not order directly from production either – its request goes to the central unit, which decides.

Reporting stock

The lockers “LG_Lager” are counted slot by slot. lbns with Sum adds up the quantity of one slot over all lockers with that name – for piece counts Sum is right, because adding is really intended here. A small loop goes through the slots, all within one tick.

Whether the lockers exist at all, Sum does not reveal: without a match it returns 0, and 0 pieces would be a valid stock. That is why the chip also reads a value with Average – if the locker is missing, that is NaN.

Requests

A request that is recomputed every tick (“I need ZIEL minus stock”) changes with every delivered piece – and production would take every change for a new order. That is why logistics requests a fixed batch size and holds the request with a hysteresis:

slt tmp stock ZIEL
and req req tmp                   # runs until ZIEL is reached
slt tmp stock MIN
or req req tmp                    # starts below MIN
mul tmp req LOS                   # 0 or a fixed batch size
StockRequest
below 5020 pieces
50 to 69, request was already runningstill 20 pieces
from 700

A batch of 20 pieces lifts the stock from just below 50 to above 70 – that is exactly how the three values are matched to each other. Whoever changes them has to redo this calculation.

Reports

MemoryContent
“LG_Bestand”pieces in storage, −1 without locker
“LG_Anforderung”0 or the batch size
“LG_Status”0 enough, 1 below the minimum stock, 2 no storage
“LG_Puls”heartbeat
Warning

The loop over the slots costs instructions: every slot needs four. With 30 slots per locker that would be 120 instructions just for counting – almost the whole tick. Only count the slots you really use.

Exercise

Task

Build the logistics subsystem: heartbeat “LG_Puls”, stock of the lockers “LG_Lager” over slots 0 to 7, request “LG_Anforderung” (20 pieces below 50, held until 70), status “LG_Status” and stock in “LG_Bestand” – as a Logic Memory and on the display of the same name.

Hints

Hint 1

Loop: lbns tmp LAGER HASH("LG_Lager") slot Quantity Sum, add, add slot slot 1, blt slot FAECHER count.

Hint 2

Presence: lbn tmp LAGER HASH("LG_Lager") Open Average and snanz ok tmp.

Hint 3

Request like a hysteresis with ZIEL and MIN, then mul tmp req LOS.

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