// ------------------------------------------------------------------------
bool OctaveWindow::startOctave()
{
  if(octProcess.isRunning())
    return true;

  QStringList CommandLine;
  CommandLine << "octave" << "--no-history" << "-i" << "-f" << "-p"
	      << QDir::convertSeparators(QucsSettings.OctaveDir);
  octProcess.setArguments(CommandLine);

  disconnect(&octProcess, 0, 0, 0);
  connect(&octProcess, SIGNAL(readyReadStderr()), SLOT(slotDisplayErr()));
  connect(&octProcess, SIGNAL(readyReadStdout()), SLOT(slotDisplayMsg()));
  connect(&octProcess, SIGNAL(processExited()), SLOT(slotOctaveEnded()));

  output->clear();

  if(!octProcess.start()) {
    output->setText(tr("ERROR: Cannot start Octave!"));
    return false;
  }

  adjustDirectory();
  return true;
}
Exemplo n.º 2
0
// ------------------------------------------------------------------------
bool OctaveWindow::startOctave()
{
  if(octProcess.state()==QProcess::Running)
    return true;

  QString OctavePath=SwieeSettings.OctaveBinDir.canonicalPath();


  QString Program;
  QStringList Arguments;

  OctavePath = QDir::toNativeSeparators(OctavePath+"/"+"octave"+QString(executableSuffix));

  QFileInfo progOctave(OctavePath);

  if (! progOctave.exists()) {
      qDebug() << "Octave not found: " << OctavePath;
      QMessageBox::critical(0, QObject::tr("Error"),
                            QObject::tr("Octave not found in: %1\n\n"
                                        "Set the Octave location on the application settings.").arg(OctavePath));
      return false;
  }

  Program = OctavePath;
  Arguments << "--no-history" << "-i" << "-f" << "-p"
            << QDir::toNativeSeparators(SwieeSettings.OctaveDir); // m-files location

  disconnect(&octProcess, 0, 0, 0);
  connect(&octProcess, SIGNAL(readyReadStandardError()), SLOT(slotDisplayErr()));
  connect(&octProcess, SIGNAL(readyReadStandardOutput()), SLOT(slotDisplayMsg()));
  connect(&octProcess, SIGNAL(finished(int)), SLOT(slotOctaveEnded(int)));
#ifdef __MINGW32__
  QString sep(";"); // path separator
#else
  QString sep(":");
#endif

  // append process PATH, othewise Octave does not find gnuplot
  QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
  env.insert("PATH", env.value("PATH") + sep + SwieeSettings.BinDir );
  octProcess.setProcessEnvironment(env);
  output->clear();

  qDebug() << "Command :" << Program << Arguments.join(" ");
  octProcess.start(Program, Arguments);

  if(octProcess.state()!=QProcess::Running&&
          octProcess.state()!=QProcess::Starting) {
    output->setText(tr("ERROR: Cannot start Octave!"));
    return false;
  }

  adjustDirectory();
  return true;
}
Exemplo n.º 3
0
// ------------------------------------------------------------------------
bool SimMessage::startProcess()
{
  Abort->setText(tr("Abort simulation"));
  Display->setDisabled(true);

  ProgText->insert(tr("Starting new simulation on ")+
                   QDate::currentDate().toString("ddd dd. MMM yyyy"));
  ProgText->insert(tr(" at ")+
                   QTime::currentTime().toString("hh:mm:ss")+"\n\n");

  SimProcess.blockSignals(false);
  if(SimProcess.isRunning()) {
    ErrText->insert(tr("ERROR: Simulator is still running!"));
    FinishSimulation(-1);
    return false;
  }

  Collect.clear();  // clear list for NodeSets, SPICE components etc.
  ProgText->insert(tr("creating netlist... "));
  NetlistFile.setName(QucsHomeDir.filePath("netlist.txt"));
   if(!NetlistFile.open(IO_WriteOnly)) {
    ErrText->insert(tr("ERROR: Cannot write netlist file!"));
    FinishSimulation(-1);
    return false;
  }

  Stream.setDevice(&NetlistFile);

  if(!DocWidget->inherits("QTextEdit")) {
    SimPorts =
       ((Schematic*)DocWidget)->prepareNetlist(Stream, Collect, ErrText);
    if(SimPorts < -5) {
      NetlistFile.close();
      FinishSimulation(-1);
      return false;
    }
  }
  Collect.append("*");   // mark the end


  disconnect(&SimProcess, 0, 0, 0);
  connect(&SimProcess, SIGNAL(readyReadStderr()), SLOT(slotDisplayErr()));
  connect(&SimProcess, SIGNAL(readyReadStdout()),
                       SLOT(slotReadSpiceNetlist()));
  connect(&SimProcess, SIGNAL(processExited()),
                       SLOT(slotFinishSpiceNetlist()));

  nextSPICE();
  return true;
  // Since now, the Doc pointer may be obsolete, as the user could have
  // closed the schematic !!!
}
Exemplo n.º 4
0
// ------------------------------------------------------------------------
bool OctaveWindow::startOctave()
{
  if(octProcess.state()==QProcess::Running)
    return true;

  QString Program;
  QStringList Arguments;

  QString OctavePath = QDir::toNativeSeparators(QucsSettings.OctaveExecutable);

  // Override Octave path by enviroment variable if it is set
  if (QucsSettings.QucsOctave.isEmpty()) Program = OctavePath;
  else Program = QucsSettings.QucsOctave;

  Arguments << "--no-history" << "-i" << "-f" << "-p"
            << QDir::toNativeSeparators(QucsSettings.OctaveDir); // m-files location

  disconnect(&octProcess, 0, 0, 0);
  connect(&octProcess, SIGNAL(readyReadStandardError()), SLOT(slotDisplayErr()));
  connect(&octProcess, SIGNAL(readyReadStandardOutput()), SLOT(slotDisplayMsg()));
  connect(&octProcess, SIGNAL(finished(int)), SLOT(slotOctaveEnded(int)));
#ifdef __MINGW32__
  QString sep(";"); // path separator
#else
  QString sep(":");
#endif

  // append process PATH, othewise Octave does not find gnuplot
  QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
  env.insert("PATH", env.value("PATH") + sep + QucsSettings.BinDir );
  octProcess.setProcessEnvironment(env);
  output->clear();

  qDebug() << "Command :" << Program << Arguments.join(" ");
  octProcess.start(Program, Arguments);
  octProcess.waitForStarted();

  if(octProcess.state()!=QProcess::Running) {
    output->setText(tr("ERROR: Failed to execute \"%1\"").arg(Program));
    return false;
  }

  adjustDirectory();
  return true;
}
Exemplo n.º 5
0
// ------------------------------------------------------------------------
void ImportDialog::slotImport()
{
  MsgText->clear();
  if (OutputEdit->text().isEmpty())
    return;

  ImportButt->setDisabled(true);
  AbortButt->setDisabled(false);

  QFile File(SimguiSettings.SimguiWorkDir.filePath(OutputEdit->text()));
  if(File.exists())
    if(QMessageBox::information(this, tr("Info"),
          tr("Output file already exists!")+"\n"+tr("Overwrite it?"),
          tr("&Yes"), tr("&No"), 0,1,1))
      {
	ImportButt->setDisabled(false);
	AbortButt->setDisabled(true);
	return;
      }

  QFileInfo Info(ImportEdit->text());
  QString Suffix = Info.extension();
  QString Program;
  QStringList CommandLine;

  QString executableSuffix = "";
#ifdef __MINGW32__
  executableSuffix = ".exe";
#endif

  Program = SimguiSettings.BinDir + "simguiconv" + executableSuffix;
  CommandLine  << "-if";
  
  if((Suffix == "citi") || (Suffix == "cit"))
    CommandLine << "citi";
  else if(Suffix == "vcd")
    CommandLine << "vcd";
  else if(Suffix == "asc")
    CommandLine << "zvr";
  else if(Suffix == "mdl")
    CommandLine << "mdl";
  else if(Suffix == "csv")
    CommandLine << "csv";
  else if(Suffix == "dat")
    CommandLine << "simguidata";
  else if(Suffix == "cir")
    CommandLine << "spice";
  else for(;;) {
    if(Suffix.at(0) == 's')
      if(Suffix.at(2) == 'p')
        if(Suffix.length() == 3)
          if(Suffix.at(1).isDigit()) {
            CommandLine << "touchstone";
            break;
          }

    MsgText->append(tr("ERROR: Unknown file format! Please check file name extension!"));
    return;
  }

  CommandLine << "-of";
  switch(OutType->currentItem()) {
  case 0:
    CommandLine << "simguidata";
    break;
  case 1:
    CommandLine << "touchstone";
    if (!OutputData->text().isEmpty())
      CommandLine << "-d" << OutputData->text();
    break;
  case 2:
    CommandLine << "csv";
    if (!OutputData->text().isEmpty())
      CommandLine << "-d" << OutputData->text();
    break;
  case 3:
    CommandLine << "simguilib";
    break;
  case 4:
    CommandLine << "simgui";
    break;
  case 5:
    CommandLine << "matlab";
    break;
  default:
    CommandLine << "simguidata";
    break;
  }

  CommandLine << "-i" << ImportEdit->text()
              << "-o" << SimguiSettings.SimguiWorkDir.filePath(OutputEdit->text());

  Process.blockSignals(false);

  disconnect(&Process, 0, 0, 0);
  connect(&Process, SIGNAL(readyReadStandardError()), SLOT(slotDisplayErr()));
  connect(&Process, SIGNAL(readyReadStandardOutput()), SLOT(slotDisplayMsg()));
  connect(&Process, SIGNAL(finished(int)), SLOT(slotProcessEnded(int)));

  MsgText->append(tr("Running command line:")+"\n");
  MsgText->append(Program + CommandLine.join(" "));
  MsgText->append("\n");

  qDebug() << "Command:" << Program << CommandLine.join(" ");
  Process.start(Program, CommandLine);
  
  if(!Process.Running)
    MsgText->append(tr("ERROR: Cannot start converter!"));
}
Exemplo n.º 6
0
// ------------------------------------------------------------------------
void SimMessage::startSimulator()
{
  // Using the Doc pointer here is risky as the user may have closed
  // the schematic, but converting the SPICE netlists is (hopefully)
  // faster than the user (I have no other idea).

  QString SimTime;
  QStringList CommandLine;
  QString SimPath = QDir::convertSeparators (QucsHomeDir.absPath());
#ifdef __MINGW32__
  QString QucsDigi = "qucsdigi.bat";
#else
  QString QucsDigi = "qucsdigi";
#endif
  SimOpt = NULL;

  if(DocWidget->inherits("QTextEdit")) {
    // Take VHDL file in memory as it could contain unsaved changes.
    Stream << ((TextDoc*)DocWidget)->text();
    NetlistFile.close();
    ProgText->insert(tr("done.\n"));  // of "creating netlist... 

    SimTime = ((TextDoc*)DocWidget)->SimTime;
#ifdef __MINGW32__
    CommandLine << getShortPathName(QucsSettings.BinDir + QucsDigi)
		<< "netlist.txt" << DataSet
		<< SimTime << getShortPathName(SimPath)
		<< getShortPathName(QucsSettings.BinDir);
#else
    CommandLine << QucsSettings.BinDir + QucsDigi << "netlist.txt" << DataSet
       << SimTime << SimPath << QucsSettings.BinDir;
#endif
  }
  else {
    // output NodeSets, SPICE simulations etc.
    Stream << Collect.join("\n") << '\n';
    SimTime = ((Schematic*)DocWidget)->createNetlist(Stream, SimPorts);
    NetlistFile.close();
    if(SimTime.at(0) == '§') {
      ErrText->insert(SimTime.mid(1));
      FinishSimulation(-1);
      return;
    }
    ProgText->insert(tr("done.\n"));  // of "creating netlist... 

    if(SimPorts < 0) {
      if((SimOpt = findOptimization((Schematic*)DocWidget))) {
	((Optimize_Sim*)SimOpt)->createASCOnetlist();
	CommandLine << QucsSettings.AscoDir + "asco" << "-qucs" <<
	  QucsHomeDir.filePath("asco_netlist.txt") << "-o" << "asco_out";
      }
      else {
	CommandLine << QucsSettings.BinDir + "qucsator" << "-b" << "-g"
           << "-i" << QucsHomeDir.filePath("netlist.txt") << "-o" << DataSet;
      }
    } else {
#ifdef __MINGW32__
      CommandLine << getShortPathName(QucsSettings.BinDir + QucsDigi)
		  << "netlist.txt" << DataSet
		  << SimTime << getShortPathName(SimPath)
		  << getShortPathName(QucsSettings.BinDir) << "-c";
#else
      CommandLine << QucsSettings.BinDir + QucsDigi << "netlist.txt"
         << DataSet << SimTime << SimPath << QucsSettings.BinDir << "-c";
#endif
    }
  }

  SimProcess.setArguments(CommandLine);

  disconnect(&SimProcess, 0, 0, 0);
  connect(&SimProcess, SIGNAL(readyReadStderr()), SLOT(slotDisplayErr()));
  connect(&SimProcess, SIGNAL(readyReadStdout()), SLOT(slotDisplayMsg()));
  connect(&SimProcess, SIGNAL(processExited()), SLOT(slotSimEnded()));

#ifdef SPEEDUP_PROGRESSBAR
  waitForUpdate = false;
#endif
  wasLF = false;
  ProgressText = "";
  if(!SimProcess.start()) {
    ErrText->insert(tr("ERROR: Cannot start simulator!"));
    FinishSimulation(-1);
    return;
  }
}