Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

CElement.hh

Go to the documentation of this file.
00001 #ifndef CElement_HH
00002 #define CElement_HH
00003 
00004 #include <math/Complex.hh>
00005 #include <electro/CSignal.hh>
00006 #include <electro/CBranch.hh>
00007 #include <iostream>
00008 #include <vector>
00009 
00010 
00011 const double  MAX_DOUBLE=1.0e99;
00012 
00013 class CElement;
00014 class CBranch;
00015 class CCircuit;
00016 
00020   class CPin
00021   {
00022     public:
00029       CPin(CElement *dst_item=NULL, unsigned int dst_pin=0){element=dst_item;pin=dst_pin;}
00034       ~CPin(){pin=0;element=NULL;};
00040       CElement *element;
00046       unsigned int pin;
00047     };
00048 
00049   
00053   class CElement
00054   {
00055     public:
00068       CElement(std::string symbol="",std::string name="",int x=0,int y=0,int rot=0);
00069       
00074       ~CElement();
00075 
00081       std::string getUnitSymbol() {return m_unitSymbol;}
00087       virtual std::string getValueSymbol() {return m_valueSymbol;}
00093       virtual std::string getValueString();
00101       virtual double getValue() {return 0;}
00102       
00103       
00108       std::string getType(void){return m_symbol;}
00114       std::string getName(void){return m_name;}
00120       int getX(void){return m_x;}
00126       int getY(void){return m_y;}
00132       int getRot(void){return m_rot;}
00133     
00139       void setName(std::string name){m_name=name;}
00140 //      void setSymbol(std::string symbol){m_symbol=symbol;}
00146       void setX(int x){m_x=x;}
00152       void setY(int y){m_y=y;}
00159       void setRot(int rot){m_rot=rot;}
00160 
00168       bool conect(CElement *dest,unsigned int src_pin,unsigned int dest_pin);
00174       bool disconect(unsigned int src_pin);
00175     
00180       virtual void print(){ std::cout << m_symbol << ":"<< m_name << std::endl;}
00185       void print_conections();
00186     
00190       std::vector<CPin *> pins;
00194       CBranch *branch;    
00198       CSignal *signal;
00199 
00203       virtual void draw();
00207       void drawConnections();
00211       virtual void drawName();
00217       virtual void drawValue();
00218 
00219       
00220       // TODO: change these functions to one that returns Glib::Point.
00226       virtual int getPinX(int pinNumber);
00232       virtual int getPinY(int pinNumber);
00233     
00237       void setParent(CCircuit* parent) {m_ParentCircuit = parent;};
00238       
00239     protected: 
00243       std::string m_name;
00247       std::string m_symbol;
00252       std::string m_unitSymbol;
00257       std::string m_valueSymbol;
00261       int m_x;
00265       int m_y;
00269       int m_rot;
00274       unsigned int m_max_pin(){return pins.size();}
00278       CCircuit* m_ParentCircuit; 
00279   };
00280 
00281 
00289   class CExNode : public CElement
00290   {
00291     protected: 
00292  
00293     public:
00300       CExNode(std::string name,int x=0,int y=0) : CElement("EXNODE",name,x,y){};
00307       ~CExNode(){ }
00313       void add(CPin * pin){ pins.push_back(pin); }
00317       int count_pins(){return pins.size();}
00322       unsigned int nr;
00323   };
00324 
00325 
00326 
00330 class CNode : public CElement
00331 {
00332 protected: 
00333     
00334 public:
00342     CNode(std::string name,int x=0,int y=0) : CElement("NODE",name,x,y){
00343          for(int i=0;i<4;i++)
00344             pins.push_back(new CPin());
00345     };
00350     ~CNode(){};
00351 
00352     
00353     void draw();
00354     void drawName();
00355     void drawValue();
00356 
00357     // TODO: change these functions to one that returns Glib::Point.
00358     int getPinX(int pinNumber) {return m_x;}
00359     int getPinY(int pinNumber) {return m_y;}
00360 
00364     CExNode *papa;
00365 };
00366 
00367 
00371 class CElementPasive:public CElement
00372 {
00373 public:
00374 
00379     CElementPasive():CElement(){};
00390     CElementPasive(std::string symbol,std::string name,int x=0,int y=0,int rot=0):
00391         CElement(symbol,name,x,y,rot){};
00392     
00397     virtual ~CElementPasive(){};
00398 
00405     virtual Complex getZc(double omega){return Complex(0,0);};
00412      virtual Complex getYc(double omega){return Complex(0,0);};
00413     
00414 };
00418 class CElementActive:public CElement
00419 {
00420 protected:
00422     double m_omega;
00424     double m_fi0;  
00425 public:
00430     CElementActive():CElement(){};
00444     CElementActive(std::string symbol,std::string name,double omega=0,double fi0=0,int x=0,int y=0,int rot=0):
00445       CElement(symbol,name,x,y,rot)
00446       {
00447         m_omega=omega;
00448         m_fi0=fi0;
00449       };
00450     
00455     virtual ~CElementActive(){};
00456 
00462     double getOmega(void){return m_omega;};
00468     void setOmega(double omega){m_omega=omega;};
00474     double getFi0(void){return m_fi0;};
00480     void setFi0(double fi){m_fi0=fi;};
00481   
00482 };
00483 
00487 class CElementControl:public CElement
00488 {
00489 protected:
00490     double m_gm;
00491     std::string m_on;
00492 public:
00494     CElementControl():CElement(){};
00495     CElementControl(std::string symbol,std::string name,double gm, std::string on,int x=0,int y=0,int rot=0):
00496       CElement(symbol,name,x,y,rot)
00497       {
00498         m_gm=gm;
00499         m_on=on;
00500       };
00501     
00503     virtual ~CElementControl(){};
00504 
00510     double getGm(void){return m_gm;};
00516     void setGm(double gm){m_gm=gm;};
00517     
00523     std::string getOn(void ){return m_on;}
00529     void setOn(std::string on){m_on=on;};
00530     std::string getValueString();    
00531 };
00532 
00533 #endif

Generated on Sun Jan 16 11:05:56 2005 for RolLerCoaster by  doxygen 1.3.9.1