Qucs-GUI
0.0.19
|
00001 /*************************************************************************** 00002 switch.cpp 00003 ------------ 00004 begin : Sat Feb 25 2006 00005 copyright : (C) 2006 by Michael Margraf 00006 email : michael.margraf@alumni.tu-berlin.de 00007 ***************************************************************************/ 00008 00009 /*************************************************************************** 00010 * * 00011 * This program is free software; you can redistribute it and/or modify * 00012 * it under the terms of the GNU General Public License as published by * 00013 * the Free Software Foundation; either version 2 of the License, or * 00014 * (at your option) any later version. * 00015 * * 00016 ***************************************************************************/ 00017 #include "switch.h" 00018 #include "node.h" 00019 #include "schematic.h" 00020 00021 00022 Switch::Switch() 00023 { 00024 Description = QObject::tr("switch (time controlled)"); 00025 00026 Props.append(new Property("init", "off", false, 00027 QObject::tr("initial state")+" [on, off]")); 00028 Props.append(new Property("time", "1 ms", false, 00029 QObject::tr("time when state changes (semicolon separated list possible, even numbered lists are repeated)"))); 00030 Props.append(new Property("Ron", "0", false, 00031 QObject::tr("resistance of \"on\" state in ohms"))); 00032 Props.append(new Property("Roff", "1e12", false, 00033 QObject::tr("resistance of \"off\" state in ohms"))); 00034 Props.append(new Property("Temp", "26.85", false, 00035 QObject::tr("simulation temperature in degree Celsius"))); 00036 Props.append(new Property("MaxDuration", "1e-6", false, 00037 QObject::tr("Max possible switch transition time (transition time 1/100 smallest value in 'time', or this number)"))); 00038 Props.append(new Property("Transition", "spline", false, 00039 QObject::tr("Resistance transition shape")+" [abrupt, linear, spline]")); 00040 00041 createSymbol(); 00042 tx = x1+4; 00043 ty = y2+4; 00044 Model = "Switch"; 00045 Name = "S"; 00046 } 00047 00048 // ------------------------------------------------------- 00049 Component* Switch::newOne() 00050 { 00051 Switch *p = new Switch(); 00052 p->Props.getFirst()->Value = Props.getFirst()->Value; 00053 p->recreate(0); 00054 return p; 00055 } 00056 00057 // ------------------------------------------------------- 00058 Element* Switch::info(QString& Name, char* &BitmapFile, bool getNewOne) 00059 { 00060 Name = QObject::tr("Switch"); 00061 BitmapFile = (char *) "switch"; 00062 00063 if(getNewOne) return new Switch(); 00064 return 0; 00065 } 00066 00067 // ------------------------------------------------------- 00068 QString Switch::netlist() 00069 { 00070 QString s = Model+":"+Name; 00071 00072 // output all node names 00073 s += " "+Ports.at(0)->Connection->Name; 00074 s += " "+Ports.at(1)->Connection->Name; 00075 00076 // output all properties 00077 Property *p2 = Props.first(); 00078 s += " "+p2->Name+"=\""+p2->Value+"\""; 00079 p2 = Props.next(); 00080 s += " "+p2->Name+"=\"["+p2->Value+"]\""; 00081 for(p2 = Props.next(); p2 != 0; p2 = Props.next()) 00082 s += " "+p2->Name+"=\""+p2->Value+"\""; 00083 00084 return s + '\n'; 00085 } 00086 00087 // ------------------------------------------------------- 00088 void Switch::createSymbol() 00089 { 00090 if(Props.getFirst()->Value != "on") { 00091 Lines.append(new Line(-15, 0, 15,-15,QPen(Qt::darkBlue,2))); 00092 y1 = -17; 00093 } 00094 else { 00095 Lines.append(new Line(-15, 0, 16,-5,QPen(Qt::darkBlue,2))); 00096 y1 = -7; 00097 } 00098 00099 Lines.append(new Line(-30, 0,-15, 0,QPen(Qt::darkBlue,2))); 00100 Lines.append(new Line( 17, 0, 30, 0,QPen(Qt::darkBlue,2))); 00101 Arcs.append(new Arc( 12, -3, 5, 5, 0, 16*360,QPen(Qt::darkBlue,2))); 00102 Ellips.append(new Area(-18, -3, 6, 6, QPen(Qt::darkBlue,2), 00103 QBrush(Qt::darkBlue, Qt::SolidPattern))); 00104 00105 Ports.append(new Port(-30, 0)); 00106 Ports.append(new Port( 30, 0)); 00107 00108 x1 = -30; 00109 x2 = 30; y2 = 7; 00110 }