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

Day 101 of 365 · Advanced · Month 4: Network in detail

Can the device do it? bdnvl and bdnvs

Not every device has every value. bdnvl and bdnvs jump when a device cannot read or cannot write a LogicType – before the error.

Lesson 13 min Week 15

What you learn today

  • Check before reading
  • Check before writing
  • Avoid IncorrectLogicType

Yesterday you asked whether a device is there. Today you ask whether it can do something. A gas sensor has no switch, a wall heater no thermometer. If you read Temperature from a heater, the chip reports IncorrectLogicType and stays on that line.

When that happens

As long as you know every device, the error hardly ever occurs. It shows up when the chip does not know what sits on a pin:

  • a universal chip you attach to different devices
  • a loop over all pins with dr0
  • a ReferenceId someone else entered

bdnvl: can it read that?

bdnvl device Temperature no_thermo     # jumps if not readable
l temp device Temperature

bdnvl stands for branch if device not valid for load: the chip jumps if the device can not read this LogicType. Otherwise it continues on the next line, and reading is safe.

bdnvs: can it write that?

bdnvs device On not_switchable         # jumps if not writable
s device On 1

bdnvs (not valid for store) checks writing. A gas sensor cannot write On, a wall heater can.

Instructionjumps if
bdnvl device LogicType targetthe device cannot read the LogicType
bdnvs device LogicType targetthe device cannot write the LogicType

Both take a device like l and s: a pin, db or a register with a ReferenceId. There is no counterpart for lbn. There the chip checks all matching devices before reading and reports IncorrectLogicType as soon as one of them lacks the value.

Warning

bdnvl checks the ability, not the presence. If the device is missing entirely, bdnvl reports an error as well (DeviceNotFound). So check with bdns first, then with bdnvl.

Tip

The simulator of the IC10 coder has a strict mode. Then only the LogicTypes listed on the device apply, and bdnvl jumps as in the game. Without strict mode the simulator allows every LogicType, and the jump never comes.

Diagram

Reading with l, writing with s Gas sensor (d0) Temperature 293.15 IC10 r0 = 293.15 Wall light (d1) On 1 l r0 d0 Temperature device → register s d1 On 1 value → device
First check whether the device is there, then whether it has the value, then read or write.

Exercise

Task

A universal chip: what hangs on the pins is not fixed.

  • d0: a load. If it is there and can write On, it follows the lever “Freigabe” (Open).
  • d1: a measuring device. If it is there and can read Temperature, the display on d2 shows the temperature in °C, otherwise −999.
  • If a device is missing on any pin, there is no error.

Hints

Hint 1

Before every access first bdns, then bdnvs or bdnvl – both jump to the next section.

Hint 2

Set c to NOVALUE before checking the meter. Then −999 is shown when a check jumps.

Hint 3

Check the display on d2 with bdns before writing as well.

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

Esc
↑ ↓ selectEnter open/ opens search anywhere