What you learn today
- Production as a subsystem
- Accept orders
- Report status
The third subsystem manufactures. Production gets an order from the central unit – “20 pieces” – and works through it. It does not decide what is needed, logistics knows that. It only decides how to manufacture.
Accepting orders
An order is a piece count in “PR_Auftrag”. 0 means: nothing to do. A new order is every change of the number. If it switches from 0 to 20, the work begins, and if it stays at 20, the same order continues.
Counting uses the autolathe's ExportCount – according to the game the number of parts output since the last ClearMemory. Instead of clearing the counter for every order, the chip remembers the counter at the start as a base:
seq tmp order last
bnez tmp produce # same order: keep counting
beqz ok produce # accept nothing without an autolathe
move basis count # counter at the start of the order
move last order
produce:
sub made count basis
That has an advantage: the chip does not need to know when the clearing takes effect. It always computes “now minus start” and is right straight away.
Reporting status
| Memory | Content |
|---|---|
| “PR_Fortschritt” | percent of the running order, 0 without an order, −1 without autolathe |
| “PR_Status” | 0 fine, 2 autolathe missing |
| “PR_Puls” | heartbeat |
A finished order stays finished: if the order still says 20 and 20 pieces are made, the autolathe does not start again. Only a new number starts a new round.
Protection against nonsense
A negative piece count or a missing order memory count as 0. If the autolathe is missing, the chip accepts no new order – otherwise it computes with a base made of NaN and never gets back on track. When the autolathe returns, it accepts the order in the next pass.
Production only reports 0 or 2, there is no warning here. Whether an order takes too long is judged by the central unit – it sees the progress and knows when it was ordered.
Exercise
Task
Build the production subsystem: heartbeat “PR_Puls”, order from “PR_Auftrag” (nonsense = 0), counting via the ExportCount of the autolathe “PR_Drehbank” with a remembered base, autolathe on up to the piece count, progress in “PR_Fortschritt” and status in “PR_Status” according to the table above.
Hints
Hint 1
New order: seq tmp order last, jump over the acceptance if equal, likewise without an autolathe.
Hint 2
Made = counter − base, the autolathe runs with slt running made order.
Hint 3
Progress: divide, times 100, round, min 100, 0 without an order, −1 without autolathe.
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