00001 /*************************************************************************** 00002 * Copyright (C) 2005 by David Saxton * 00003 * david@bluehaze.org * 00004 * * 00005 * This program is free software; you can redistribute it and/or modify * 00006 * it under the terms of the GNU General Public License as published by * 00007 * the Free Software Foundation; either version 2 of the License, or * 00008 * (at your option) any later version. * 00009 ***************************************************************************/ 00010 00011 #ifndef SWITCH_H 00012 #define SWITCH_H 00013 00014 #include <qguardedptr.h> 00015 #include <qobject.h> 00016 00017 class CircuitDocument; 00018 class Component; 00019 class Pin; 00020 class Resistance; 00021 class QTimer; 00022 00026 class Switch : public QObject 00027 { 00028 Q_OBJECT 00029 00030 public: 00031 enum State 00032 { 00033 Open, 00034 Closed, 00035 }; 00036 00037 Switch( Component * parent, Pin * p1, Pin * p2, State state ); 00038 ~Switch(); 00043 void setState( State state ); 00044 State state() const { return m_state; } 00049 void setBounce( bool bounce, int msec = 5 ); 00054 void bounce(); 00062 bool calculateCurrent(); 00063 00064 protected slots: 00070 void stopBouncing(); 00071 00072 protected: 00073 void startBouncing(); 00074 00075 bool m_bBounce; 00076 int m_bouncePeriod_ms; 00077 unsigned long long m_bounceStart; // Simulator time that bouncing started 00078 Resistance * m_pBounceResistance; 00079 State m_state; 00080 Component * m_pComponent; 00081 QGuardedPtr<Pin> m_pP1; 00082 QGuardedPtr<Pin> m_pP2; 00083 QTimer * m_pStopBouncingTimer; 00084 }; 00085 00086 #endif
1.5.1