Skip to content

Add emergency lighting (DT1) memory bank 208 and query helpers - #159

Open
markus-becker-tridonic-com wants to merge 3 commits into
sde1000:masterfrom
tridonic-com:dt1
Open

markus-becker-tridonic-com wants to merge 3 commits into
sde1000:masterfrom
tridonic-com:dt1

Conversation

@markus-becker-tridonic-com

Copy link
Copy Markdown

Summary

Implements IEC 62386-202 self-contained emergency control-gear support: the
memory bank 208 variable definitions and the sequence helpers an application
controller needs to read emergency status and issue DT1 control commands.

What's included

  • dali/memory/emergency.py — memory bank 208 (Table 18): control-gear
    temperatures, battery charge/maintenance powers, rated duration,
    recharge/function-test times, and the full set of failure, mode, test and
    lamp counters (~40 MemoryValue definitions).
  • dali/gear/sequences.py
    • QueryEmergencyInformation(address) — bundles the DT1 status and
      measurement queries into a single sequence so the required
      ENABLE DEVICE TYPE 1 prefix is injected correctly.
    • EmergencyCommand(address, command_class) — issues a single DT1 control
      command.
  • Fake-gear emergency support and tests for the bank, the information
    sequence, and the control-command helper.

Testing

pytest dali/tests/test_emergency.py dali/tests/test_memory.py → 27 passed.

Notes

Builds on the existing dali/gear/emergency.py command classes already in
master. Single commit, applies cleanly on top of master.

Implements the IEC 62386-202 self-contained emergency control gear
variable definitions and sequence helpers consumed by application
controllers:

- dali/memory/emergency.py: memory bank 208 (Table 18) with the control
  gear temperatures, battery charge/maintenance powers, rated duration,
  recharge/function-test times, and the full set of failure, mode, test
  and lamp counters.
- dali/gear/sequences.py: QueryEmergencyInformation bundles the DT1
  status and measurement queries into a single sequence (so the required
  ENABLE DEVICE TYPE 1 prefix is injected), and EmergencyCommand issues a
  single DT1 control command.
- Fake gear emergency support plus tests for the bank, the information
  sequence and the control-command helper.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Comment thread dali/gear/sequences.py Outdated
emergency control gear in a single sequence.

Running it as a sequence ensures the required "ENABLE DEVICE TYPE 1"
command is sent before each application-extended command, so the gear

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is misleading. This being a sequence has nothing to do with the driver sending appropriate EnableDeviceType commands.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 3697e86.

Comment thread dali/gear/sequences.py Outdated
command is sent before each application-extended command, so the gear
answers. The returned values are plain integers (or None where the gear
reports MASK or does not answer); the four status bytes are returned as
raw bytes so the caller can decode individual bits.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be more useful for the status to be decoded here and represented in EmergencyInformation.

Might it be better for EmergencyInformation to be a dataclass rather than a namedtuple so its members can be typed appropriately?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 3847672.

The driver sends EnableDeviceType before every application-extended
command on its own, independent of whether the command is part of a
sequence. Reword the docstring to state the actual benefit: bundling the
queries into one transaction so nothing interleaves between them.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Represent the four DT1 status bytes as EmergencyMode, EmergencyFeatures,
EmergencyFailureStatus and EmergencyStatus dataclasses with one bool field
per IEC 62386-202 bit, and turn EmergencyInformation itself into a dataclass
so every member is typed. Callers no longer have to know the bit layout.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants