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

Day 314 of 365 · Expert · Month 11: Optimisation and debugging

Project: bug hunt

Project bug hunt: the tank farm script hides seven errors, loud and silent ones. Four milestones prove that all of them are fixed.

Project 40 min Week 45

What you learn today

  • Repair a script with hidden bugs
  • Test cases prove the fix

A colleague programmed the tank farm and then moved to the Mars outpost. His script does not load, and even when it does, it does nonsense. Your job this week: a bug hunt. The code hides seven errors. The checker marks two of them in red, the other five are silent.

The setup

DevicePrefabName
two pipe analyzers on the same tankStructurePipeAnalysizer“Tank”
fill pumpStructureVolumePump“Fuellpumpe”
vent valveStructureDigitalValve“Ablass”
LED displayStructureConsoleLED5“Fuellstand”
flashing lightStructureFlashingLight“TankAlarm”

How it should work

  • The pump fills when the pressure drops below 4000 kPa and only stops above 4500 kPa.
  • Above 5000 kPa the vent valve opens, the pump stands still then.
  • The display shows the fill level in percent of 5000 kPa, rounded.
  • If the analyzers are missing: pump off, valve closed, alarm on, display -1.

Approach

  1. Loud errors first: whatever the checker marks red prevents loading.
  2. Then take the table of expectations from day 313 and go through it case by case. Every test case that does not hold points to a silent error.
  3. For every find a probe or a look in the simulator: what does the chip really see?

Milestones

  1. The pump fills with hysteresis.
  2. The overpressure valve opens above 5000 kPa and stops the pump.
  3. The fill level is right in percent.
  4. Without analyzers everything goes into the safe state.
Tip

Two analyzers are attached to the same tank. Think about what Sum makes of that and which batch mode suits a pressure.

Warning

Do not repair by moving the limits until the tests turn green. The values in the defines are right – the errors are in the code below.

Diagram

Temperature curve with hysteresis 21 °C 19 °C band: state is kept Heater on on off off On at 19 °C, off only at 21 °C – nothing switches in between.
The fill pump works with hysteresis: on below 4000 kPa, only off again above 4500 kPa. Above 5000 kPa the vent valve opens.

Project task

Task

Find and fix the seven errors in the tank farm script. Afterwards the system should work exactly as described above. The four milestones show you what is still wrong.

Milestones

  1. Milestone 1: pump fills with hysteresis
  2. Milestone 2: vent overpressure
  3. Milestone 3: fill level in percent
  4. Milestone 4: analyzers gone

Hints

Hint 1

Loud: exponent notation in the define and the case of the LogicType.

Hint 2

Silent: Sum instead of Average, swapped limits in the hysteresis, missing mul … 100.

Hint 3

Also silent: no NaN guard including the alarm, and the jump back is missing at the end.

Quiz

2 questions. You pass from 60 % – the server does the grading.

Complete the day

  • Passed all milestones of the project
  • 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