24 #include <QPushButton>
28 #include <QTextStream>
29 #include <QVBoxLayout>
30 #include <QHBoxLayout>
43 #define executableSuffix ".exe"
45 #define executableSuffix ""
52 setWindowTitle(tr(
"Qucs Simulation Messages"));
64 DataSet = QDir::convertSeparators(Info.dirPath()) +
65 QDir::separator() + Doc->
DataSet;
70 all =
new QVBoxLayout(
this);
73 QGroupBox *Group1 =
new QGroupBox(tr(
"Progress:"));
74 all->addWidget(Group1);
75 QVBoxLayout *vbox1 =
new QVBoxLayout();
76 Group1->setLayout(vbox1);
80 ProgText->setTextFormat(Qt::PlainText);
86 QGroupBox *HGroup =
new QGroupBox();
87 QHBoxLayout *hbox =
new QHBoxLayout();
90 all->addWidget(HGroup);
91 QLabel *progr =
new QLabel(tr(
"Progress:"));
92 hbox->addWidget(progr);
96 HGroup->setLayout(hbox);
98 QGroupBox *Group2 =
new QGroupBox(tr(
"Errors and Warnings:"));
99 all->addWidget(Group2);
100 QVBoxLayout *vbox2 =
new QVBoxLayout();
104 ErrText->setTextFormat(Qt::PlainText);
106 ErrText->setWordWrapMode(QTextOption::NoWrap);
107 ErrText->setMinimumSize(400,80);
108 Group2->setLayout(vbox2);
110 QHBoxLayout *Butts =
new QHBoxLayout();
111 all->addLayout(Butts);
113 Display =
new QPushButton(tr(
"Goto display page"));
118 Abort =
new QPushButton(tr(
"Abort simulation"));
119 Butts->addWidget(
Abort);
120 connect(
Abort,SIGNAL(clicked()),SLOT(reject()));
133 Abort->setText(tr(
"Abort simulation"));
136 QString txt = tr(
"Starting new simulation on %1 at %2").
137 arg(QDate::currentDate().toString(
"ddd dd. MMM yyyy")).
138 arg(QTime::currentTime().toString(
"hh:mm:ss:zzz"));
144 qDebug() <<
"running!";
145 ErrText->insert(tr(
"ERROR: Simulator is still running!"));
151 ProgText->insert(tr(
"creating netlist... "));
154 ErrText->insert(tr(
"ERROR: Cannot write netlist file!"));
166 ErrText->insert(tr(
"ERROR: Cannot simulate a text file!"));
176 connect(&
SimProcess, SIGNAL(readyReadStandardOutput()),
200 qDebug() <<
"goin thru SPICE branch on simmmessage.cpp";
201 if(Line.left(5) ==
"SPICE") {
210 QString FileName = Line.section(
'"', 1,1);
211 Line = Line.section(
'"', 2);
219 com <<
"-g" <<
"_ref";
220 com <<
"-if" <<
"spice" <<
"-of" <<
"qucs";
223 if(FileName.find(QDir::separator()) < 0)
226 SpiceFile.setName(FileName);
227 if(!SpiceFile.open(QIODevice::ReadOnly)) {
228 ErrText->insert(tr(
"ERROR: Cannot open SPICE file \"%1\".").arg(FileName));
236 Line.replace(
',',
' ');
238 if(!Line.isEmpty())
Stream <<
" _ref";
244 qDebug() <<
"start QucsConv" << prog << com.join(
" ");
248 ErrText->insert(tr(
"SIM ERROR: Cannot start QucsConv!"));
253 QByteArray SpiceContent = SpiceFile.readAll();
255 QString command(SpiceContent);
265 disconnect(&
SimProcess, SIGNAL(wroteToStdin()), 0, 0);
281 s = s.stripWhiteSpace();
282 if(s.isEmpty())
continue;
283 if(s.at(0) ==
'#')
continue;
284 if(s.at(0) ==
'.')
if(s.left(5) !=
".Def:") {
288 Stream <<
" " << s <<
'\n';
304 static QString
pathName(QString longpath) {
305 const char * lpath = QDir::convertSeparators(longpath).ascii();
307 int len = GetShortPathNameA(lpath,spath,
sizeof(spath)-1);
309 return QString(spath);
329 QStringList Arguments;
332 QString QucsDigiLib =
"qucsdigilib.bat";
333 QString QucsDigi =
"qucsdigi.bat";
334 QString QucsVeri =
"qucsveri.bat";
336 QString QucsDigiLib =
"qucsdigilib";
337 QString QucsDigi =
"qucsdigi";
338 QString QucsVeri =
"qucsveri";
341 bool isVerilog =
false;
349 Stream << Doc->toPlainText();
363 libs.replace(
" ",
",-l");
364 libs =
"-Wl,-l" + libs;
371 libs.replace(
" ",
",-l");
372 libs =
"-c,-l" + libs;
382 QString text = Doc->toPlainText();
385 QString lib = Doc->
Library.lower();
386 if (lib.isEmpty()) lib =
"work";
389 if(!vhdlDir.exists(
"vhdl"))
390 if(!vhdlDir.mkdir(
"vhdl")) {
391 ErrText->insert(tr(
"ERROR: Cannot create VHDL directory \"%1\"!")
392 .arg(vhdlDir.path()+
"/vhdl"));
395 vhdlDir.setPath(vhdlDir.path()+
"/vhdl");
396 if(!vhdlDir.exists(lib))
397 if(!vhdlDir.mkdir(lib)) {
398 ErrText->insert(tr(
"ERROR: Cannot create VHDL directory \"%1\"!")
399 .arg(vhdlDir.path()+
"/"+lib));
402 vhdlDir.setPath(vhdlDir.path()+
"/"+lib);
404 destFile.setName(vhdlDir.filePath(entity+
".vhdl"));
405 if(!destFile.open(QIODevice::WriteOnly)) {
406 ErrText->insert(tr(
"ERROR: Cannot create \"%1\"!")
407 .arg(destFile.name()));
410 destFile.writeBlock(text.ascii(), text.length());
422 for(QStringList::Iterator it =
Collect.begin();
425 if ((*it).right(4) !=
".lst" &&
426 (*it).right(5) !=
".vhdl" &&
427 (*it).right(4) !=
".vhd" &&
428 (*it).right(2) !=
".v") {
436 if(SimTime.length()>0&&SimTime.at(0) ==
'\xA7') {
438 ErrText->insert(SimTime.mid(1));
444 <<
" initial begin\n"
445 <<
" $dumpfile(\"digi.vcd\");\n"
447 <<
" #" << SimTime <<
" $finish;\n"
449 <<
"endmodule // TestBench\n";
469 QStringList usedComponents;
472 QMessageBox::critical(
this, tr(
"Error"), tr(
"Cannot read netlist!"));
477 while (i.hasNext()) {
479 if (net.contains(i.key()))
480 usedComponents << i.key();
485 if (! usedComponents.isEmpty()) {
495 if (!
NetlistFile.open(QFile::Append | QFile::Text))
496 QMessageBox::critical(
this, tr(
"Error"), tr(
"Cannot read netlist!"));
501 out <<
"# --module=" << usedComponents.join(
" ") <<
"\n";
512 Program = QDir::toNativeSeparators(Program+
"/"+
"asco"+QString(
executableSuffix));
514 <<
"-o" <<
"asco_out";
518 Arguments <<
"-b" <<
"-g" <<
"-i"
529 << QDir::toNativeSeparators(SimPath)
539 << QDir::toNativeSeparators(SimPath)
557 #ifdef SPEEDUP_PROGRESSBAR
558 waitForUpdate =
false;
571 QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
576 if ( !file.exists() ){
577 ErrText->insert(tr(
"ERROR: Program not found: %1").arg(Program));
584 qDebug() <<
"Command :" << Program << Arguments.join(
" ");
588 ErrText->insert(tr(
"ERROR: Cannot start simulator!"));
600 if(pc->
Model ==
".Opt")
615 #ifdef SPEEDUP_PROGRESSBAR
619 QTimer::singleShot(20,
this, SLOT(slotUpdateProgressBar()));
620 waitForUpdate =
true;
649 #ifdef SPEEDUP_PROGRESSBAR
651 void SimMessage::slotUpdateProgressBar()
654 waitForUpdate =
false;
662 QTextCursor cursor =
ErrText->textCursor();
663 cursor.movePosition(QTextCursor::End);
679 Abort->setText(tr(
"Close window"));
683 QDate d = QDate::currentDate();
684 QTime t = QTime::currentTime();
687 QString txt = tr(
"Simulation ended on %1 at %2").
688 arg(d.toString(
"ddd dd. MMM yyyy")).
689 arg(t.toString(
"hh:mm:ss:zzz"));
690 ProgText->insert(
"\n" + txt +
"\n" + tr(
"Ready.") +
"\n");
693 QString txt = tr(
"Errors occurred during simulation on %1 at %2").
694 arg(d.toString(
"ddd dd. MMM yyyy")).
695 arg(t.toString(
"hh:mm:ss:zzz"));
696 ProgText->insert(
"\n" + txt +
"\n" + tr(
"Aborted.") +
"\n");
700 if(file.open(QIODevice::WriteOnly)) {
702 QTextStream stream(&file);
703 stream << tr(
"Output:\n-------") <<
"\n\n";
704 for(
int z=0; z<
ProgText->document()->blockCount(); z++)
705 stream <<
ProgText->document()->findBlockByNumber(z).text() <<
"\n";
706 stream <<
"\n\n\n" << tr(
"Errors:\n-------") <<
"\n\n";
707 for(
int z=0; z<
ErrText->document()->blockCount(); z++)
708 stream <<
ErrText->document()->findBlockByNumber(z).text() <<
"\n";
716 if(ifile.open(QIODevice::ReadOnly)) {
717 if(ofile.open(QIODevice::WriteOnly)) {
718 QByteArray data = ifile.readAll();
719 ofile.writeBlock(data);
static QString pathName(QString longpath)
void slotReadSpiceNetlist()
Definition of the TextDoc class.
tQucsSettings QucsSettings
void FinishSimulation(int)
Component * findOptimization(Schematic *)
void displayDataPage(QString &, QString &)
SimMessage(QWidget *, QWidget *parent=0)
QProgressBar * SimProgress
Definitions and declarations for the main application.
Q3PtrList< Component > * Components
void SimulationEnded(int, SimMessage *)
static QMap< QString, QString > vaComponents
void startSimulator()
SimMessage::startSimulator simulates the document in view.
The TextDoc class definition.
void slotFinishSpiceNetlist(int status)
QString properName(const QString &Name)
void slotSimEnded(int status)