adapnex::core::SR

Bistable latch with dominant set.

Synopsis

Declared in <adapnex/core/bistable.h>

class SR;

Description

Maintains a boolean state across execution cycles. If SET is true, the output Q becomes true, regardless of the state of RESET. If RESET is true and SET is false, the output Q becomes false. If both SET and RESET are true simultaneously, set has priority and Q becomes true.

Parameter Type Direction Description

SET

bool

Input

Causes the output to become true. Overrides RESET.

RESET

bool

Input

Causes the output to become false.

Q

bool

Output

The current stored state of the latch.

Common Use Case

Alarm systems and fault indicators where an active fault condition must prevent an operator from clearing the alarm until the fault is resolved.

Example: Persisting Alarm

class AlarmTask : public Task {
public:
    bool over_temperature = false;
    bool reset_button = false;
    bool alarm_active = false;

private:
    SR alarm_latch;

    void Update() override {
        // The alarm remains active as long as over_temperature is true, even if reset is pressed.
        alarm_latch(over_temperature, reset_button, alarm_active);
    }
};

Bistable latches maintain state across cycles and must be instantiated as member variables of a task rather than locally within Update().

Member Functions

Name

Description

operator()

Function call operators

Data Members

Name

Description

Q

The state output.

RESET

The reset input.

SET

The set input.

Created with MrDocs