My Project  0.0.16
QUCS Mapping
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
bjt.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  bjt.cpp
3  ---------
4  begin : Fri Jun 4 2004
5  copyright : (C) 2003 by Michael Margraf
6  email : michael.margraf@alumni.tu-berlin.de
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #include "bjt.h"
19 #include "node.h"
20 
21 
23 {
24  // properties obtained from "Basic_BJT" in bjtsub.cpp
25  Description = QObject::tr("bipolar junction transistor");
26  createSymbol();
27  tx = x2+4;
28  ty = y1+4;
29  Model = "_BJT";
30 }
31 
32 // -------------------------------------------------------
34 {
35  BJT* p = new BJT();
36  p->Props.getFirst()->Value = Props.getFirst()->Value;
37  p->recreate(0);
38  return p;
39 }
40 
41 // -------------------------------------------------------
42 Element* BJT::info(QString& Name, char* &BitmapFile, bool getNewOne)
43 {
44  Name = QObject::tr("npn transistor");
45  BitmapFile = (char *) "npn";
46 
47  if(getNewOne) return new BJT();
48  return 0;
49 }
50 
51 // -------------------------------------------------------
52 Element* BJT::info_pnp(QString& Name, char* &BitmapFile, bool getNewOne)
53 {
54  Name = QObject::tr("pnp transistor");
55  BitmapFile = (char *) "pnp";
56 
57  if(getNewOne) {
58  BJT* p = new BJT();
59  p->Props.getFirst()->Value = "pnp";
60  p->recreate(0);
61  return p;
62  }
63  return 0;
64 }
65 
66 // -------------------------------------------------------
68 {
69  Lines.append(new Line(-10,-15,-10, 15,QPen(QPen::darkBlue,3)));
70  Lines.append(new Line(-30, 0,-10, 0,QPen(QPen::darkBlue,2)));
71  Lines.append(new Line(-10, -5, 0,-15,QPen(QPen::darkBlue,2)));
72  Lines.append(new Line( 0,-15, 0,-30,QPen(QPen::darkBlue,2)));
73  Lines.append(new Line(-10, 5, 0, 15,QPen(QPen::darkBlue,2)));
74  Lines.append(new Line( 0, 15, 0, 30,QPen(QPen::darkBlue,2)));
75 
76  if(Props.getFirst()->Value == "npn") {
77  Lines.append(new Line( -6, 15, 0, 15,QPen(QPen::darkBlue,2)));
78  Lines.append(new Line( 0, 9, 0, 15,QPen(QPen::darkBlue,2)));
79  }
80  else {
81  Lines.append(new Line( -5, 10, -5, 16,QPen(QPen::darkBlue,2)));
82  Lines.append(new Line( -5, 10, 1, 10,QPen(QPen::darkBlue,2)));
83  }
84 
85  Ports.append(new Port(-30, 0));
86  Ports.append(new Port( 0,-30));
87  Ports.append(new Port( 0, 30));
88 
89  x1 = -30; y1 = -30;
90  x2 = 4; y2 = 30;
91 }
92 
93 // -------------------------------------------------------
94 QString BJT::netlist()
95 {
96  QString s = "BJT:"+Name;
97 
98  // output all node names
99  for(Port *p1 = Ports.first(); p1 != 0; p1 = Ports.next())
100  s += " "+p1->Connection->Name; // node names
101  s += " "+Ports.at(1)->Connection->Name; // connect substrate to collector
102 
103  // output all properties
104  for(Property *p2 = Props.first(); p2 != 0; p2 = Props.next())
105  s += " "+p2->Name+"=\""+p2->Value+"\"";
106 
107  return s + '\n';
108 }