![]() |
QElectroTech 0.200.1-dev
|
The ContactUsage struct How many slave contacts a master element currently uses, broken down by contact type. More...
#include <contactusage.h>

Public Types | |
| enum | Type { NO , NC , SW , Other } |
Public Member Functions | |
| int | total () const |
| void | addSlave (Type type, int contacts) |
Public Attributes | |
| int | no = 0 |
| Normally open. | |
| int | nc = 0 |
| Normally closed. | |
| int | sw = 0 |
| Changeover. | |
| int | other = 0 |
| Neither of the above. | |
The ContactUsage struct How many slave contacts a master element currently uses, broken down by contact type.
Header-only and free of any graphics dependency so that the counting rules can be unit tested on their own. MasterElement::contactUsage() is the thin wrapper that feeds it the linked elements.
This counts contacts, which is what tells you how many contacts an auxiliary block must provide. It is deliberately not the count that MasterElement::isFull() uses: a master's max_slaves is a number of slots, and a slave fills exactly one slot however many contacts it carries.
Two rules are easy to get wrong, and both live here so that every caller gets them right:
| enum ContactUsage::Type |
Contact types a slave can declare. Mirrors ElementData::SlaveState, which is not used directly so that this header stays free of the element data dependencies and can be unit tested on its own. MasterElement::contactUsage() maps between the two.
| Enumerator | |
|---|---|
| NO | Normally open. |
| NC | Normally closed. |
| SW | Changeover. |
| Other | Neither of the above. |
|
inline |
Add one slave element to the tally.
| type | the contact type the slave declares |
| contacts | how many contacts it stands for. Values below 1 are treated as 1: an element which declares no contact count is still one contact. |

|
inline |

| int ContactUsage::nc = 0 |
Normally closed.
| int ContactUsage::no = 0 |
Normally open.
| int ContactUsage::other = 0 |
Neither of the above.
| int ContactUsage::sw = 0 |
Changeover.