LineDetector¶
Overview¶
Perimeter line that carries many detectors addressed by number (fence, buried cable, wall sensor line). The line is one Thing with its full address range in the property range. A detector on the line is not a Thing: its identity is the line plus its number.
- Added in: PQ Framework 2.1
- Namespace:
Pq.Adapters.Framework - Category:
line_detector
When to Use¶
- Perimeter line with addressable detectors, where one controller reports state per detector number
- Fence or cable systems where an operator works with ranges of detectors, not single devices
Do not use it for a single sensor with its own address in the panel; that stays an IntrusionDetector on a detector Thing.
States¶
The function holds several tokens at once (for example alarm and bypass). A token is either detector-scoped or line-scoped.
Detector-Scoped States¶
A detector-scoped token always carries the affected detectors as an address set in Members, for example { "intrusion.alarm": "392-393" }.
| State | Status id | Description |
|---|---|---|
Clear |
detection.clear (hidden) |
No detection condition present |
Prealarm |
intrusion.prealarm |
Threshold exceeded, approaching alarm |
Alarm |
intrusion.alarm |
Full alarm condition triggered |
Bypassed |
intrusion.bypassed |
Excluded from security monitoring |
Tamper |
intrusion.tamper |
Device enclosure opened or tampered |
Fault |
supervision.fault |
Detector malfunction detected |
Open |
position.open |
Active detector that no armed partition guards |
Clear is the hidden default state: a quiet line reports the function as cleared.
Line-Scoped States¶
A line-scoped token concerns the whole line and never has a key in Members. A line fault and a detector fault are different tokens. The place of a cut travels on the cut event, not in Members (see Cut Location).
| State | Status id | Description |
|---|---|---|
LineCut |
supervision.line.cut |
Line cut; detectors beyond the cut are read from the other side or lost |
LineFault |
supervision.line.fault |
Line or bus fault |
LineRedundancyLost |
supervision.line.redundancy.lost |
Ring reads the line from one side only |
Actions¶
None generated. The framework implements the behaviour by hand: the adapter hands the function the raw picture of the line, and the function computes the state and publishes events from the difference against the previous picture.
Usage in an Adapter¶
After every read of the line, build a LinePicture in logical addresses and call Apply:
await lineFunction.Apply(
new LinePicture
{
Active = AddressSet.Parse("392-393"), // detectors that sense an intrusion now
Prealarm = AddressSet.Empty, // detectors in pre-alarm
Tamper = AddressSet.Empty, // detectors with opened or damaged enclosure
Fault = AddressSet.Empty, // detectors that report a fault
Conditions = LineCondition.None, // Cut, Fault, RedundancyLost (flags)
CutBetween = null, // where the cut lies, e.g. new AddressInterval(341, 342); null when unknown
},
timestamp);
- The picture is raw: it knows nothing about partitions or bypass. The function derives the state and the events.
- Never publish line or detector events by hand. The function adds
locationanddetectorto each event; a hand-written event misses them. - Every
Applycarries the whole picture, not a delta. A detector missing fromActiveis quiet. - Detectors outside
rangeare not processed:Applydrops them from the picture, so they publish no state and no event.
Derivation¶
The function combines the picture with two inputs it owns: the guarded detectors (covered by an armed SoftwarePartition) and the bypassed detectors, and with the alarm memory of the partitions that cover the line.
| State | Detectors |
|---|---|
Alarm |
Active that are guarded and not bypassed, plus the detectors the alarm memory of a partition holds |
Open |
Active that are not guarded and not bypassed |
Prealarm |
Prealarm that are guarded and not bypassed |
Tamper |
Tamper of the picture, bypass does not hide it |
Fault |
Fault of the picture, bypass does not hide it |
Bypassed |
the bypassed detectors inside range |
An active detector that is bypassed is neither alarm nor open. The line conditions come from Conditions unchanged.
Alarm memory. A detector that raised the alarm of an armed partition stays in Alarm after the fence calms, also when it
is bypassed later, until the alarm of that partition ends: a disarm, a rearm or an alarm reset (see
SoftwarePartition). A detector that two partitions remember stays in Alarm until both alarms end.
Without an armed partition nothing is held: an active detector is only Open. ActiveDetectors, which refuses an arm, reads
the live picture only, so a remembered detector that calmed refuses no arm. The memory is not stored: after a restart the
first picture raises the alarm again only for detectors that still stand.
Detector Events¶
The function compares each new state with the previous one and publishes one event per detector that changed.
| Detector | Enters | Leaves |
|---|---|---|
Alarm |
intrusion.alarm (Critical) |
intrusion.cleared |
Prealarm |
intrusion.prealarm (Warn) |
intrusion.cleared |
Open |
intrusion.contact.open (Warn) |
intrusion.contact.closed |
Tamper |
intrusion.tamper (Critical) |
intrusion.tamper.cleared |
Fault |
supervision.fault (Warn) |
technical.fault.cleared |
Rules:
intrusion.clearedis published once when a detector leaves alarm and prealarm. A detector that moves from prealarm to alarm publishes nointrusion.cleared. A remembered detector leaves alarm when the memory ends, not when the fence calms.contact.closedis published only when an open detector physically closes. An open detector that turns into an alarm (its partition is armed) or becomes bypassed stays open on the fence and publishes nocontact.closed. Cancelling the bypass of a still active detector publishes nocontact.open.- Bypass never suppresses tamper or fault.
- A detector that is bypassed while in alarm stays in alarm through the alarm memory of its partition.
Line Events¶
| Condition | Enters | Leaves |
|---|---|---|
LineCondition.Cut |
supervision.line.cut (Critical) |
supervision.line.cut.cleared |
LineCondition.Fault |
supervision.line.fault (Warn) |
supervision.line.fault.cleared |
LineCondition.RedundancyLost |
supervision.line.redundancy.lost (Warn) |
supervision.line.redundancy.restored |
Cut Location¶
The adapter sets LinePicture.CutBetween when the device tells where the cut lies. The value is an AddressInterval in logical addresses:
| Bound | Meaning |
|---|---|
From |
Last detector still read from the head end of the line (the end that reads the line in normal operation) |
To |
First detector read from beyond the cut (for a ring, the first detector the other end took over) |
Detectors between From and To are read by no side. A cut between detectors 341 and 342 is 341-342.
| Situation | Behaviour |
|---|---|
CutBetween is null |
The cut works without a location; the event carries no location |
Conditions has no Cut |
CutBetween is ignored |
| Cut appears with a known place | supervision.line.cut carries location and detector of To and detectorBefore of From |
| Lasting cut without a place, place becomes known | supervision.line.cut is published again with the place |
| Lasting cut, place changes to another known place | supervision.line.cut is published again with the new place, the same way a moving alarm publishes its new detector; no cut.cleared |
| Lasting cut, place becomes unknown | Nothing is published; the cut keeps its last known place, so the same place reported again publishes nothing |
| Cut clears | supervision.line.cut.cleared without location |
The place is not in Members: the cut stays a line-scoped token, so every map segment of the line shows the cut (LineStateFilter in Pq.Domain.Lines passes line-scoped tokens). The alarm panel and the map read the place from the location of the cut event, the same way as for a detector alarm.
First Picture¶
Nothing is published before the first Apply. The first picture after start sets the full state, but publishes events only for conditions that already last and matter for security: alarms, tampers and a cut line. A lasting cut carries its place when the picture has CutBetween. A restart during an intrusion still raises the alarm. Open detectors, prealarms, faults, bypass and other line conditions publish no event at the first picture.
Bypass¶
The device does not hold bypass, so the function keeps it and persists it across restarts.
| Method | Effect |
|---|---|
Bypass(detector, timestamp, personId?) |
Bypasses one detector; returns true when it was not bypassed before |
CancelBypass(detector, timestamp, personId?) |
Cancels the bypass; returns true when it was bypassed before |
Each change publishes pq.event.intrusion.bypassed.remote or pq.event.intrusion.bypassed.cleared.remote (Info) with location, detector and personId, then re-evaluates the state. A change that changes nothing returns false and publishes nothing.
The bypass command (LineCommandRunner.Bypass) refuses a detector outside range with a failure ("Detector 3 is not on line A, whose range is 1-2."); nothing is stored and no event is published. The cancel command accepts a detector outside range, so a bypass kept from a wider range can be cleaned. A kept bypass outside range does not count: BypassedDetectors and the Bypassed state hold only detectors inside range.
Reading the State¶
| Member | Content |
|---|---|
Members |
Detectors per state token (AddressSet); a state without detectors has no key |
Conditions |
LineCondition flags of the line |
ActiveDetectors |
Active, not bypassed detectors, guarded or not (Alarm plus Open); they refuse the arming of a partition |
BypassedDetectors |
Bypassed detectors inside range |
Refresh(timestamp) re-reads which detectors the armed partitions guard. A SoftwarePartition calls it after its arming changed; an adapter does not call it.
Events¶
Every event that one detector causes carries location (canonical LineLocation text <line guid>#<detector>) and detector (number, display only). This includes the bypass events and the alarm of a software partition: pq.event.intrusion.alarm, .prealarm, .cleared, .bypassed.remote, .bypassed.cleared.remote, .tamper, .tamper.cleared, .contact.open, .contact.closed, pq.event.supervision.fault, pq.event.technical.fault.cleared.
Line-scoped events carry no location: pq.event.supervision.line.cut.cleared, .fault, .fault.cleared, .redundancy.lost, .redundancy.restored. pq.event.supervision.line.cut carries location, detector and detectorBefore only when the place of the cut is known (Cut Location); without it the event carries none of them.
Properties¶
| Property | Type | Required | Description |
|---|---|---|---|
range |
address_set (AddressSet) |
yes | Detector addresses of the line, e.g. 1-200,300-310; gaps are allowed. Device discovery fills it. |
- The framework declares
rangeinfunctions.yamlwithrange: [1, 2147483647]; an adapter never declares it. An adapter with a tighter bound (for example 1-500 per line controller) checks it in itsIAdapterTreeValidator. - An empty
rangeis a tree-build error ("range is empty: run device discovery or enter the detectors of the line, e.g. 1-2"); the device does not start. - A line range (
ILineRange) that covers a detector outsiderangeof its line is a tree-build error on itsaddresses. The generated tree builder callsLineRangeCheck.Validatefor this when the adapter has a device type withLineDetector. - The property shows in the category
linedetectorof the device settings. The create-device dialog hides function properties, so it cannot enterrange; device discovery fills it.
Construction¶
extended_construction: true: the hand-written partial LineDetectorFunction provides the constructor.
YAML Example¶
device_types:
- type_id: PerimeterLine
name: "Perimeter line"
category: line_detector
functions:
# range (LineDetector property) holds the detectors, e.g. 1-200,300-310; discovery fills it
LineDetector:
See Also¶
- IntrusionDetector - single intrusion sensor
- Partition - alarm group
- SoftwarePartition - partition armed in PQ over line ranges
- Modeling conventions - line detector modeling