My Project  0.0.16
QUCS Mapping
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
switch.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  switch.cpp
3  ------------
4  begin : Sat Feb 25 2006
5  copyright : (C) 2006 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 "switch.h"
19 #include "node.h"
20 #include "schematic.h"
21 
22 
24 {
25  Description = QObject::tr("switch (time controlled)");
26 
27  Props.append(new Property("init", "off", false,
28  QObject::tr("initial state")+" [on, off]"));
29  Props.append(new Property("time", "1 ms", false,
30  QObject::tr("time when state changes (semicolon separated list possible)")));
31  Props.append(new Property("Ron", "0", false,
32  QObject::tr("resistance of \"on\" state in ohms")));
33  Props.append(new Property("Roff", "1e12", false,
34  QObject::tr("resistance of \"off\" state in ohms")));
35  Props.append(new Property("Temp", "26.85", false,
36  QObject::tr("simulation temperature in degree Celsius")));
37 
38  createSymbol();
39  tx = x1+4;
40  ty = y2+4;
41  Model = "Switch";
42  Name = "S";
43 }
44 
45 // -------------------------------------------------------
47 {
48  Switch *p = new Switch();
49  p->Props.getFirst()->Value = Props.getFirst()->Value;
50  p->recreate(0);
51  return p;
52 }
53 
54 // -------------------------------------------------------
55 Element* Switch::info(QString& Name, char* &BitmapFile, bool getNewOne)
56 {
57  Name = QObject::tr("Switch");
58  BitmapFile = (char *) "switch";
59 
60  if(getNewOne) return new Switch();
61  return 0;
62 }
63 
64 // -------------------------------------------------------
65 QString Switch::netlist()
66 {
67  QString s = Model+":"+Name;
68 
69  // output all node names
70  s += " "+Ports.first()->Connection->Name;
71  s += " "+Ports.next()->Connection->Name;
72 
73  // output all properties
74  Property *p2 = Props.first();
75  s += " "+p2->Name+"=\""+p2->Value+"\"";
76  p2 = Props.next();
77  s += " "+p2->Name+"=\"["+p2->Value+"]\"";
78  for(p2 = Props.next(); p2 != 0; p2 = Props.next())
79  s += " "+p2->Name+"=\""+p2->Value+"\"";
80 
81  return s + '\n';
82 }
83 
84 // -------------------------------------------------------
86 {
87  if(Props.getFirst()->Value != "on") {
88  Lines.append(new Line(-15, 0, 15,-15,QPen(QPen::darkBlue,2)));
89  y1 = -17;
90  }
91  else {
92  Lines.append(new Line(-15, 0, 16,-5,QPen(QPen::darkBlue,2)));
93  y1 = -7;
94  }
95 
96  Lines.append(new Line(-30, 0,-15, 0,QPen(QPen::darkBlue,2)));
97  Lines.append(new Line( 17, 0, 30, 0,QPen(QPen::darkBlue,2)));
98  Arcs.append(new Arc( 12, -3, 5, 5, 0, 16*360,QPen(QPen::darkBlue,2)));
99  Ellips.append(new Area(-18, -3, 6, 6, QPen(QPen::darkBlue,2),
100  QBrush(Qt::darkBlue, Qt::SolidPattern)));
101 
102  Ports.append(new Port(-30, 0));
103  Ports.append(new Port( 30, 0));
104 
105  x1 = -30;
106  x2 = 30; y2 = 7;
107 }