#include <switch.h>
Collaboration diagram for Switch:

Public Types | |
| enum | State { Open, Closed } |
Public Member Functions | |
| Switch (Component *parent, Pin *p1, Pin *p2, State state) | |
| ~Switch () | |
| void | setState (State state) |
| State | state () const |
| void | setBounce (bool bounce, int msec=5) |
| void | bounce () |
| bool | calculateCurrent () |
Protected Slots | |
| void | stopBouncing () |
Protected Member Functions | |
| void | startBouncing () |
Protected Attributes | |
| bool | m_bBounce |
| int | m_bouncePeriod_ms |
| unsigned long long | m_bounceStart |
| Resistance * | m_pBounceResistance |
| State | m_state |
| Component * | m_pComponent |
| QGuardedPtr< Pin > | m_pP1 |
| QGuardedPtr< Pin > | m_pP2 |
| QTimer * | m_pStopBouncingTimer |
Definition at line 26 of file switch.h.
| void Switch::setState | ( | State | state | ) |
If bouncing has been set to true, then the state will not switch immediately to that given.
Definition at line 54 of file switch.cpp.
References m_bBounce, m_state, startBouncing(), and stopBouncing().
Referenced by ECSPST::buttonStateChanged(), ECSPDT::buttonStateChanged(), ECDPST::buttonStateChanged(), ECDPDT::buttonStateChanged(), ECRotoSwitch::buttonStateChanged(), ECPTMSwitch::buttonStateChanged(), ECPTBSwitch::buttonStateChanged(), ECKeyPad::buttonStateChanged(), ECRotoSwitch::setActivePosition(), and Switch().
| void Switch::setBounce | ( | bool | bounce, | |
| int | msec = 5 | |||
| ) |
Tell the switch whether to bounce or not, for the given duration, when the state is changed.
Definition at line 71 of file switch.cpp.
References m_bBounce, and m_bouncePeriod_ms.
Referenced by ECSPST::dataChanged(), ECSPDT::dataChanged(), ECDPST::dataChanged(), ECDPDT::dataChanged(), ECPTMSwitch::dataChanged(), ECPTBSwitch::dataChanged(), and ECKeyPad::dataChanged().
| void Switch::bounce | ( | ) |
Tell the switch to continue bouncing (updates the resistance value). Called from the simulator.
Definition at line 105 of file switch.cpp.
References m_bouncePeriod_ms, m_bounceStart, m_pBounceResistance, m_pStopBouncingTimer, Simulator::self(), Resistance::setConductance(), and Simulator::time().
Referenced by startBouncing().
| bool Switch::calculateCurrent | ( | ) |
Attempts to calculate the current that is flowing through the switch. (If all the connectors at one of the ends know their currents, then this switch will give the current to the pins at either end).
Definition at line 143 of file switch.cpp.
References Pin::inputWireList(), m_pP1, m_pP2, Pin::outputWireList(), and state().
| void Switch::stopBouncing | ( | ) | [protected, slot] |
Called from a QTimer timeout - our bouncing period has come to an end. This will then fully disconnect or connect the pins depending on the current state.
Definition at line 124 of file switch.cpp.
References Component::circuitDocument(), Simulator::detachSwitch(), m_pBounceResistance, m_pComponent, m_pP1, m_pP2, m_state, Component::removeElement(), and Simulator::self().
Referenced by setState(), and Switch().
1.5.1