QElectroTech 0.200.1-dev
Loading...
Searching...
No Matches
ContactUsage Struct Reference

The ContactUsage struct How many slave contacts a master element currently uses, broken down by contact type. More...

#include <contactusage.h>

Collaboration diagram for ContactUsage:
Collaboration graph

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.

Detailed Description

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:

  • a slave stands for as many contacts as its "number" kind information says, so a 4 pole contact counts as 4, not as 1
  • a changeover contact is counted once, as sw. CrossRefItem's NOElements() and NCElements() both return it, so adding those two lists together would count it twice.

Member Enumeration Documentation

◆ 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.

Member Function Documentation

◆ addSlave()

void ContactUsage::addSlave ( Type type,
int contacts )
inline

Add one slave element to the tally.

Parameters
typethe contact type the slave declares
contactshow many contacts it stands for. Values below 1 are treated as 1: an element which declares no contact count is still one contact.
Here is the caller graph for this function:

◆ total()

int ContactUsage::total ( ) const
inline
Here is the caller graph for this function:

Member Data Documentation

◆ nc

int ContactUsage::nc = 0

Normally closed.

◆ no

int ContactUsage::no = 0

Normally open.

◆ other

int ContactUsage::other = 0

Neither of the above.

◆ sw

int ContactUsage::sw = 0

Changeover.


The documentation for this struct was generated from the following file: