Example #1
0
ConfigMap* ConfigMapParser::map() throw(PARSEEXCEPTION_THROW)
{
  expect(T::CMT_CBL);
  ConfigMap* cm = new ConfigMap();
  std::string* currComments = 0;
  if(token.type == T::CMT_COMMENT)
    currComments = comments();
  try
  {
    while(token.type == T::CMT_KEY)
    {
      std::string key = token.value;
      nextToken();
      try
      {
        expect(T::CMT_EQ);
        if(prefixValue(token))
        {
          ConfigValue* cv = value();
          if(currComments)
            cv->setComment(*currComments);
          try
          {
            (*cm)[key] = *cv;
          }
          catch(invalid_key& ik)
          {
            P_ERROR(ik.what());
          }
          delete cv;
        }
        else
        {
          P_ERROR("Expected begin of a value (`{`, `[` or VALUE), got `" + T::type2str(token.type) + "`");
        }
      }
      catch(ParseException)
      {
        if(currComments) delete currComments;
        throw;
      }
      expect(T::CMT_SEMICOLON);
    }
    expect(T::CMT_CBR);

    if(currComments)
      delete currComments;
    currComments = 0;
    if(token.type == T::CMT_COMMENT)
      currComments = comments();
  }
  catch(ParseException)
  {
    delete cm;
    if(currComments) delete currComments;
    throw;
  }
  if(currComments) delete currComments;
  return cm;
}
Example #2
0
int ConfigMapParser::file(ConfigMap* configMap) throw(PARSEEXCEPTION_THROW)
{
  size_t size = configMap->length();
  std::string* currComments = 0;
  if(token.type == T::CMT_COMMENT)
    currComments = comments();
  while(token.type == T::CMT_KEY)
  {
    size_t keyLine = token.line;
    size_t keyColumn = token.column;
    std::string key = token.value;
    nextToken();
    try
    {
      expect(T::CMT_EQ);
      if(prefixValue(token))
      {
        ConfigValue* cv = value();
        if(currComments)
          cv->setComment(*currComments);
        try
        {
          (*configMap)[key] = *cv;
        }
        catch(invalid_key& ik)
        {
          std::cout<<"[EXCEPTION ERROR ] ConfigMapParser.cpp 1"<<std::endl;
          throw ParseException(keyLine, keyColumn, ik.what());
        }
        delete cv;
      }
      else
      {
        P_ERROR("Expected begin of a value (`{`, `[` or VALUE), got `" + T::type2str(token.type) + "`");
      }
    }
    catch(ParseException)
    {
      if(currComments) delete currComments;
      throw;
    }
    expect(T::CMT_SEMICOLON);

    if(currComments)
      delete currComments;
    currComments = 0;
    if(token.type == T::CMT_COMMENT)
      currComments = comments();
  }
  expect(T::CMT_EOF);
  if(currComments) delete currComments;
  return configMap->length() - size;
}
Example #3
0
ListConfigValue* ConfigMapParser::list() throw(PARSEEXCEPTION_THROW)
{
  expect(T::CMT_ABL);
  ListConfigValue* lcv = new ListConfigValue();
  std::string* currComments = 0;
  try
  {
    if(token.type == T::CMT_COMMENT)
      currComments = comments();
    if(prefixValue(token))
    {
      ConfigValue* cv = value();
      if(currComments)
      {
        cv->setComment(*currComments);
        delete currComments;
        currComments = 0;
      }
      lcv->append(*cv);
      delete cv;
      while(token.type == T::CMT_COMMA)
      {
        nextToken();
        if(token.type == T::CMT_COMMENT)
          currComments = comments();
        if(prefixValue(token))
        {
          ConfigValue* cv = value();
          if(currComments)
          {
            cv->setComment(*currComments);
            delete currComments;
            currComments = 0;
          }
          lcv->append(*cv);
          delete cv;
        }
        else
          break;
      }
    }
    expect(T::CMT_ABR);
  }
  catch(ParseException)
  {
    if(currComments)
      delete currComments;
    delete lcv;
    throw;
  }
  return lcv;
}
Example #4
0
static std::shared_ptr<std::vector<std::string> >
extract_vorbis_comments(const memory_cptr &mem) {
  std::shared_ptr<std::vector<std::string> > comments(new std::vector<std::string>);
  mm_mem_io_c in(mem->get_buffer(), mem->get_size());
  uint32_t i, n, len;

  try {
    in.skip(7);                 // 0x03 "vorbis"
    n = in.read_uint32_le();    // vendor_length
    in.skip(n);                 // vendor_string
    n = in.read_uint32_le();    // user_comment_list_length

    comments->reserve(n);

    for (i = 0; i < n; i++) {
      len = in.read_uint32_le();
      memory_cptr buffer(new memory_c((unsigned char *)safemalloc(len + 1), len + 1));

      if (in.read(buffer->get_buffer(), len) != len)
        throw false;

      comments->push_back(std::string((char *)buffer->get_buffer(), len));
    }
  } catch(...) {
  }

  return comments;
}
Example #5
0
BuildingsForm::BuildingsForm(QWidget* parent): QDialog(parent)
{
	setupUi(this);
	
	currentBuildingTextEdit->setReadOnly(true);

	modifyBuildingPushButton->setDefault(true);

	buildingsListWidget->setSelectionMode(QAbstractItemView::SingleSelection);

	connect(addBuildingPushButton, SIGNAL(clicked()), this, SLOT(addBuilding()));
	connect(removeBuildingPushButton, SIGNAL(clicked()), this, SLOT(removeBuilding()));
	connect(buildingsListWidget, SIGNAL(currentRowChanged(int)), this, SLOT(buildingChanged(int)));
	connect(closePushButton, SIGNAL(clicked()), this, SLOT(close()));
	connect(modifyBuildingPushButton, SIGNAL(clicked()), this, SLOT(modifyBuilding()));

	connect(moveBuildingUpPushButton, SIGNAL(clicked()), this, SLOT(moveBuildingUp()));
	connect(moveBuildingDownPushButton, SIGNAL(clicked()), this, SLOT(moveBuildingDown()));

	connect(sortBuildingsPushButton, SIGNAL(clicked()), this, SLOT(sortBuildings()));
	connect(buildingsListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(modifyBuilding()));

	connect(commentsPushButton, SIGNAL(clicked()), this, SLOT(comments()));

	centerWidgetOnScreen(this);
	restoreFETDialogGeometry(this);
	//restore splitter state
	QSettings settings(COMPANY, PROGRAM);
	if(settings.contains(this->metaObject()->className()+QString("/splitter-state")))
		splitter->restoreState(settings.value(this->metaObject()->className()+QString("/splitter-state")).toByteArray());
	
	this->filterChanged();
}
Example #6
0
// TODO: Filter the extraction based on the user selection.
void
List_extractor::visit(Def* d) {
  std::cout << debug(d->name()) << '\n';

  const Location& loc = d->loc;
  if (loc.is_internal() || loc.is_eof())
    return;

  if (Comment_block* c = comments().find(d->loc))
    std::cout << "Doc: " << c->text() << '\n';
}
void Argument1DString::writeData(QXmlStreamWriter &xmlWriter)
{
  xmlWriter.writeStartElement("Argument1D");
  {
    xmlWriter.writeAttribute("Id" , id());
    xmlWriter.writeAttribute("Caption" , caption());
    xmlWriter.writeAttribute("IsOptional" , isOptional() ? "True" : "False");

    for(const QString& comment : comments())
    {
      xmlWriter.writeComment(comment);
    }
    //write value definition;
    valueDefinitionInternal()->writeData(xmlWriter);

    xmlWriter.writeStartElement("Dimensions");
    {
      xmlWriter.writeStartElement("Dimension");
      {
        xmlWriter.writeAttribute("Id" , m_dimension->id());
        xmlWriter.writeAttribute("Caption" , m_dimension->caption());
        xmlWriter.writeAttribute("Length" , QString::number(length()));
      }
      xmlWriter.writeEndElement();
    }
    xmlWriter.writeEndElement();

    xmlWriter.writeStartElement("Values");
    {
      int ind[1] = {0};
      int str[1] = {length()};
      QString* values = new QString[length()];
      getValues(ind,str,values);


      for(int i = 0 ; i < length() ; i++)
      {
        xmlWriter.writeStartElement("Value");
        {
          xmlWriter.writeCharacters(values[i]);
        }
        xmlWriter.writeEndElement();
      }

      delete[] values;
    }
    xmlWriter.writeEndElement();
  }
  xmlWriter.writeEndElement();
}
Example #8
0
QString Item::debugInfo() const
{
    QString info;
    info += QLatin1String("### Item: ###################\n");
    if (!title().isNull())
        info += QLatin1String("title: #") + title() + QLatin1String("#\n");
    if (!link().isNull())
        info += QLatin1String("link: #") + link() + QLatin1String("#\n");
    if (!description().isNull())
        info += QLatin1String("description: #") + description() + QLatin1String("#\n");
    if (!content().isNull())
        info += QLatin1String("content: #") + content() + QLatin1String("#\n");
    if (!author().isNull())
        info += QLatin1String("author: #") + author() + QLatin1String("#\n");
    if (!comments().isNull())
        info += QLatin1String("comments: #") + comments() + QLatin1String("#\n");
    QString dpubdate = dateTimeToString(pubDate());
    if (!dpubdate.isNull())
        info += QLatin1String("pubDate: #") + dpubdate + QLatin1String("#\n");
    if (!guid().isNull())
        info += QLatin1String("guid: #") + guid() + QLatin1String("#\n");
    if (guidIsPermaLink())
        info += QLatin1String("guid is PL: #true#\n");
    if (!source().isNull())
         info += source().debugInfo();
    
    QList<Category> cats = categories();
    for (QList<Category>::ConstIterator it = cats.constBegin(); it != cats.constEnd(); ++it)
        info += (*it).debugInfo();
    QList<Enclosure> encs = enclosures();
    for (QList<Enclosure>::ConstIterator it = encs.constBegin(); it != encs.constEnd(); ++it)
        info += (*it).debugInfo();

    info += QLatin1String("### Item end ################\n");
    return info;
}
Example #9
0
//---------------------------------------------------------------------------
void File_Exr::Data_Parse()
{
    
    if (CC4(Buffer+Buffer_Offset)==0x762F3101) //"v/1"+1 //Header
        Header();
    else if (name=="comments" && type=="string")
        comments();
    else if (name=="compression" && type=="compression" && Element_Size==1)
        compression();
    else if (name=="dataWindow" && type=="box2i" && Element_Size==16)
        dataWindow();
    else if (name=="displayWindow" && type=="box2i" && Element_Size==16)
        displayWindow();
    else if (name=="pixelAspectRatio" && type=="float" && Element_Size==4)
        pixelAspectRatio();
    else
        Skip_XX(Element_Size,                                   "value");
}
Example #10
0
int restoreFromDump(mysqlpp::Connection* conn, const wxString& filename)
{
    int toRet = 1;
    wxFFile backup_file(filename);
    if(backup_file.IsOpened())
    {
        wxString fileContent;
        backup_file.ReadAll(&fileContent);
//   wxMessageBox(fileContent);
//wxRegEx comments(_("--[^x22\\x27].*"), wxRE_NEWLINE);
// \x22[^\x22]*\x22|\x27[^\x27]*\x27|/\*.*?\*/|(\#|--)([^\x22\x27]*?)$ - groups 1 and 2
        wxRegEx comments(_("\\x22\\x27[^\\x22\\x27]*\\x22\\x27|/\\*.*?\\*/|(\\#|--)[^\\x22\\x27]*?$"), wxRE_ADVANCED|wxRE_NEWLINE);
//wxRegEx comments(_("\\x22[^\\x22]*\\x22|\\x27[^\\x27]*\\x27|/\\*.*?\\*/|(\\#|--)([^\\x22\\x27]*?)$"), wxRE_ADVANCED|wxRE_NEWLINE);


        comments.ReplaceAll(&fileContent, _(""));
//comments.ReplaceAll(&fileContent, _("*\\2"));

        fileContent.Trim();
        wxRegEx semicolons(_("(?m);\\s*$"), wxRE_ADVANCED|wxRE_NEWLINE);
        semicolons.ReplaceAll(&fileContent, _("^")); //in the future take care of that - if ^ symbol is inside the satatement

//wxMessageBox(fileContent);

        wxStringTokenizer tkz(fileContent, _("^"));
        while ( tkz.HasMoreTokens() )
        {
            wxString sql_query = tkz.GetNextToken().Trim(false);
//wxMessageBox(sql_query);

            mysqlpp::Query query = conn->query();
            query << wx2std(sql_query, wxConvUI);
            query.execute();

        }

    }
    else
    {
        wxMessageBox(_T("Failed to open backup file."));
        toRet = 0;
    }
    return toRet;
}
Example #11
0
//---------------------------------------------------------------------------
void File_Exr::Data_Parse()
{
         if (name_End==0)
        ImageData();
    else if (name=="channels" && type=="chlist")
        channels();
    else if (name=="comments" && type=="string")
        comments();
    else if (name=="compression" && type=="compression" && Element_Size==1)
        compression();
    else if (name=="dataWindow" && type=="box2i" && Element_Size==16)
        dataWindow();
    else if (name=="displayWindow" && type=="box2i" && Element_Size==16)
        displayWindow();
    else if (name=="pixelAspectRatio" && type=="float" && Element_Size==4)
        pixelAspectRatio();
    else
        Skip_XX(Element_Size,                                   "value");
}
    //_______________________________________________________
    void DemoWidget::realize( void )
    {
        assert( !_mainWidget );
        assert( _widget );

        // create main widget (vbox)
        _mainWidget = gtk_box_new( GTK_ORIENTATION_VERTICAL, 0 );
        gtk_box_set_spacing( GTK_BOX( _mainWidget ), 10 );
        gtk_widget_show( _mainWidget );

        // horizontal box
        GtkWidget* hbox( gtk_box_new( GTK_ORIENTATION_HORIZONTAL, 0 ) );
        gtk_box_pack_start( GTK_BOX( _mainWidget ), hbox, false, true, 0 );
        gtk_widget_show( hbox );

        // label
        std::string comments( _comments.empty() ? _name:_comments );
        GtkWidget* label( gtk_label_new( comments.c_str() ) );

        PangoAttrList* attributes( pango_attr_list_new() );
        pango_attr_list_insert( attributes, pango_attr_weight_new( PANGO_WEIGHT_BOLD ) );
        gtk_label_set_attributes( GTK_LABEL( label ), attributes );
        pango_attr_list_unref( attributes );

        gtk_box_pack_start( GTK_BOX( hbox ), label, false, true, 0 );

        gtk_widget_show( label );

        // icon
        if( !_iconName.empty() )
        {
            GtkIconTheme* theme( gtk_icon_theme_get_default() );
            GdkPixbuf* icon( gtk_icon_theme_load_icon( theme, _iconName.c_str(), 22, (GtkIconLookupFlags) 0, 0L ) );
            GtkWidget* image( gtk_image_new_from_pixbuf( icon ) );
            gtk_box_pack_end( GTK_BOX( hbox ), image, false, false, 0 );
            gtk_widget_show( image );

        }

        // main content
        gtk_box_pack_start( GTK_BOX( _mainWidget ), _widget, true, true, 0 );
        gtk_widget_show( _widget );
    }
Example #13
0
SubjectsForm::SubjectsForm(QWidget* parent): QDialog(parent)
{
	setupUi(this);
	
	currentSubjectTextEdit->setReadOnly(true);
	
	renameSubjectPushButton->setDefault(true);

	subjectsListWidget->setSelectionMode(QAbstractItemView::SingleSelection);

	connect(closePushButton, SIGNAL(clicked()), this, SLOT(close()));
	connect(addSubjectPushButton, SIGNAL(clicked()), this, SLOT(addSubject()));
	connect(removeSubjectPushButton, SIGNAL(clicked()), this, SLOT(removeSubject()));
	connect(renameSubjectPushButton, SIGNAL(clicked()), this, SLOT(renameSubject()));

	connect(moveSubjectUpPushButton, SIGNAL(clicked()), this, SLOT(moveSubjectUp()));
	connect(moveSubjectDownPushButton, SIGNAL(clicked()), this, SLOT(moveSubjectDown()));

	connect(sortSubjectsPushButton, SIGNAL(clicked()), this, SLOT(sortSubjects()));
	connect(subjectsListWidget, SIGNAL(currentRowChanged(int)), this, SLOT(subjectChanged(int)));
	connect(activateSubjectPushButton, SIGNAL(clicked()), this, SLOT(activateSubject()));
	connect(deactivateSubjectPushButton, SIGNAL(clicked()), this, SLOT(deactivateSubject()));
	connect(subjectsListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(renameSubject()));

	connect(commentsPushButton, SIGNAL(clicked()), this, SLOT(comments()));

	centerWidgetOnScreen(this);
	restoreFETDialogGeometry(this);
	//restore splitter state
	QSettings settings(COMPANY, PROGRAM);
	if(settings.contains(this->metaObject()->className()+QString("/splitter-state")))
		splitter->restoreState(settings.value(this->metaObject()->className()+QString("/splitter-state")).toByteArray());
	
	subjectsListWidget->clear();
	for(int i=0; i<gt.rules.subjectsList.size(); i++){
		Subject* sbj=gt.rules.subjectsList[i];
		subjectsListWidget->addItem(sbj->name);
	}
	
	if(subjectsListWidget->count()>0)
		subjectsListWidget->setCurrentRow(0);
}
Example #14
0
void QCrashReporter::sendReport()
{
    QHash<QString, QString> options;
    options.insert("BuildID", StarviewerBuildID);
    options.insert("ProductName", ApplicationNameString);
    options.insert("Version", StarviewerVersionString);
    options.insert("Email", m_emailLineEdit->text());

    QString comments(m_descriptionTextEdit->toPlainText());
    if (m_hostInformationCheckBox->isChecked())
    {
        comments += QString("\n// %1:\n").arg(tr("Host information"));
        comments += m_hostInformationTextEdit->toPlainText();
    }

    options.insert("Comments", comments);
    options.insert("CrashTime", QByteArray::number(QDateTime::currentDateTime().toTime_t()));
    // El valor 1 significa que es tindran en compte les condicions d'acceptacio programades al fitxer
    // de configuracio del "collector".
    // El valor 0 significa que s'acceptaran tots els reports. Les condicions d'acceptacio no es tenen en compte.
    options.insert("Throttleable", "1");

    // Enviem el report només en cas de release.
#ifdef QT_NO_DEBUG
    bool success = CrashReporterSender::sendReport("http://starviewer.udg.edu/crashreporter/submit", m_minidumpPath, options);

    if (success)
    {
        INFO_LOG(QString("Crash report enviat: %1").arg(m_minidumpPath));
    }
    else
    {
        ERROR_LOG(QString("Error al enviar el crash report: %1").arg(m_minidumpPath));
    }
#endif

    m_sendReportAnimation->hide();
    m_sendReportLabel->hide();
}
Example #15
0
void ImageScanner::scanImageComments()
{
    MetadataFields fields;
    fields << MetadataInfo::Headline
           << MetadataInfo::Title;

    QVariantList metadataInfos = m_metadata.getMetadataFields(fields);

    // handles all possible fields, multi-language, author, date
    CaptionsMap captions = m_metadata.getImageComments();

    if (captions.isEmpty() && !hasValidField(metadataInfos))
    {
        return;
    }

    DatabaseAccess access;
    ImageComments comments(access, m_scanInfo.id);

    // Description
    if (!captions.isEmpty())
    {
        comments.replaceComments(captions);
    }

    // Headline
    if (!metadataInfos[0].isNull())
    {
        comments.addHeadline(metadataInfos[0].toString());
    }

    // Title
    if (!metadataInfos[1].isNull())
    {
        comments.addTitle(metadataInfos[1].toString());
    }
}
Example #16
0
int
main (int argc, char **argv)
{
  int ch;
  int errflg=0,i,j;
  double l,c,ctot,r=0.0,g=0.0,k=0.0,lm=0.0,cm=0.0,len;
  unsigned gotl=0,gotc=0,gotr=0,gotg=0,gotk=0,gotcm=0,gotlen=0;
  unsigned gotname=0, gotnum=0;
  char *name = "";
  double **matrix, **inverse;
  double *tpeigenvalues, *gammaj;
  char *options;
  int num, node;
  char **pname, *s;
  int use_opt;
  char *optarg;

  pname = argv;
  argv++;
  argc--;

  ch = 0;
  while (argc > 0) {
    s = *argv++;
    argc--;
    while ((ch = *s++)) {
      if (*s)
	optarg = s;
      else if (argc)
	optarg = *argv;
      else
	optarg = NULL;
      use_opt = 0;

      switch (ch) {
      case 'o':
	name = (char *) tmalloc((unsigned) (strlen(optarg)*sizeof(char)));
	(void) strcpy(name,optarg);
	gotname=1;
	use_opt = 1;
	break;
      case 'l':
	sscanf(optarg,"%lf",&l);
	gotl=1;
	use_opt = 1;
	break;
      case 'c':
	sscanf(optarg,"%lf",&c);
	gotc=1;
	use_opt = 1;
	break;
      case 'r':
	sscanf(optarg,"%lf",&r);
	use_opt = 1;
	gotr=1;
	break;
      case 'g':
	sscanf(optarg,"%lf",&g);
	use_opt = 1;
	gotg=1;
	break;
      case 'k':
	sscanf(optarg,"%lf",&k);
	use_opt = 1;
	gotk=1;
	break;
      case 'x':
	sscanf(optarg,"%lf",&cm);
	use_opt = 1;
	gotcm=1;
	break;
      case 'L':
	sscanf(optarg,"%lf",&len);
	use_opt = 1;
	gotlen=1;
	break;
      case 'n':
	sscanf(optarg,"%d",&num);
	use_opt = 1;
	gotnum=1;
	break;
      case 'h':
	usage(pname);
	exit(1);
	break;
      case '-':
	break;
      default:
	usage(pname);
	exit(2);
	break;
      }
      if (use_opt) {
	if (optarg == s)
	  s += strlen(s);
	else if (optarg) {
	  argc--;
	  argv++;
	}
      }
    }
  }

  if (errflg) {
    usage(argv);
    exit (2);
  }

  if (gotl + gotc + gotname + gotnum + gotlen < 5) {
    fprintf(stderr,"l, c, model_name, number_of_conductors and length must be specified.\n");
    fprintf(stderr,"%s -u for details.\n",pname[0]);
    fflush(stdout);
    exit(1);
  }

  if ( (k<0.0?-k:k) >=1.0 ) {
    fprintf(stderr,"Error: |k| must be less than 1.0\n");
    fflush(stderr);
    exit(1);
  }

  if (num == 1) {
    fprintf(stdout,"* single conductor line\n");
    fflush(stdout);
    exit(1);
  }

  lm = l*k;
  switch(num) {

  case 1: ctot = c; break;
  case 2: ctot = c + cm; break;
  default: ctot = c + 2*cm; break;
  }

  comments(r,l,g,c,ctot,cm,lm,k,name,num,len);

  matrix = (double **) tmalloc((unsigned) (sizeof(double*)*(num+1)));
  inverse = (double **) tmalloc((unsigned) (sizeof(double*)*(num+1)));
  tpeigenvalues = (double *) tmalloc((unsigned) (sizeof(double)*(num+1)));

  for (i=1;i<=num;i++) {
    matrix[i] = (double *) tmalloc((unsigned) (sizeof(double)*(num+1)));
    inverse[i] = (double *) tmalloc((unsigned) (sizeof(double)*(num+1)));
  }

  for (i=1;i<=num;i++) {
    tpeigenvalues[i] = -2.0 * cos(M_PI*i/(num+1));
  }

  for (i=1;i<=num;i++) {
    for (j=1;j<=num;j++) {
      matrix[i][j] = phi(i-1,tpeigenvalues[j]);
    }
  }
  gammaj = (double *) tmalloc((unsigned) (sizeof(double)*(num+1)));

  for (j=1;j<=num;j++) {
    gammaj[j] = 0.0;
    for (i=1;i<=num;i++) {
      gammaj[j] += matrix[i][j] * matrix[i][j];
    }
    gammaj[j] = sqrt(gammaj[j]);
  }

  for (j=1;j<=num;j++) {
    for (i=1;i<=num; i++) {
      matrix[i][j] /= gammaj[j];
    }
  }

  tfree(gammaj);

  /* matrix = M set up */

  {
    MatrixPtr othermatrix;
    double *rhs, *solution;
    double *irhs, *isolution;
    int errflg, err, singular_row, singular_col;
    double *elptr;

    rhs = (double *) tmalloc((unsigned) (sizeof(double)*(num+1)));
    irhs = (double *) tmalloc((unsigned) (sizeof(double)*(num+1)));
    solution = (double *) tmalloc((unsigned) (sizeof(double)*(num+1)));
    isolution = (double *) tmalloc((unsigned) (sizeof(double)*(num+1)));

    othermatrix = spCreate(num,0,&errflg);

    for (i=1;i<=num;i++) {
      for (j=1; j<=num; j++) {
	elptr = spGetElement(othermatrix,i,j);
	*elptr = matrix[i][j];
      }
    }

#ifdef DEBUG_LEVEL1
    (void) spPrint(othermatrix,0,1,0);
#endif

    for (i=1;i<=num;i++) rhs[i] = 0.0;
    rhs[1]=1.0;

    err =
      spOrderAndFactor(othermatrix,rhs,THRSH,ABS_THRSH,DIAG_PIVOTING);

    spErrorMessage(othermatrix,stderr,NULL);

    switch(err) {

    case spNO_MEMORY:
      fprintf(stderr,"No memory in spOrderAndFactor\n");
      fflush(stderr);
      exit(1);
    case spSINGULAR:
      (void)
	spWhereSingular(othermatrix,&singular_row,&singular_col);
      fprintf(stderr,"Singular matrix: problem in row %d and col %d\n", singular_row, singular_col);
      fflush(stderr);
      exit(1);
    default: break;
    }

    for (i=1;i<=num;i++) {
      for (j=1;j<=num;j++) {
	rhs[j] = (j==i?1.0:0.0);
	irhs[j] = 0.0;
      }
      (void) spSolveTransposed(othermatrix,rhs,solution, irhs, isolution);
      for (j=1;j<=num;j++) {
	inverse[i][j] = solution[j];
      }
    }

    tfree(rhs);
    tfree(solution);
  }

  /* inverse = M^{-1} set up */

  fprintf(stdout,"\n");
  fprintf(stdout,"* Lossy line models\n");

  options = (char *) tmalloc((unsigned) 256);
  (void) strcpy(options,"rel=1.2 nocontrol");
  for (i=1;i<=num;i++) {
    fprintf(stdout,".model mod%d_%s ltra %s r=%0.12g l=%0.12g g=%0.12g c=%0.12g len=%0.12g\n",
	    i,name,options,r,l+tpeigenvalues[i]*lm,g,ctot-tpeigenvalues[i]*cm,len);
    /*i,name,options,r,l+tpeigenvalues[i]*lm,g,ctot+tpeigenvalues[i]*cm,len);*/
  }


  fprintf(stdout,"\n");
  fprintf(stdout,"* subcircuit m_%s - modal transformation network for %s\n",name,name);
  fprintf(stdout,".subckt m_%s", name);
  for (i=1;i<= 2*num; i++) {
    fprintf(stdout," %d",i);
  }
  fprintf(stdout,"\n");
  for (j=1;j<=num;j++) fprintf(stdout,"v%d %d 0 0v\n",j,j+2*num);

  for (j=1;j<=num;j++) {
    for (i=1; i<=num; i++) {
      fprintf(stdout,"f%d 0 %d v%d %0.12g\n",
	      (j-1)*num+i,num+j,i,inverse[j][i]);
    }
  }

  node = 3*num+1;
  for (j=1;j<=num;j++) {
    fprintf(stdout,"e%d %d %d %d 0 %0.12g\n", (j-1)*num+1,
	    node, 2*num+j, num+1, matrix[j][1]);
    node++;
    for (i=2; i<num; i++) {
      fprintf(stdout,"e%d %d %d %d 0 %0.12g\n", (j-1)*num+i,
	      node,node-1,num+i,matrix[j][i]);
      node++;
    }
    fprintf(stdout,"e%d %d %d %d 0 %0.12g\n", j*num,j,node-1,
	    2*num,matrix[j][num]);
  }
  fprintf(stdout,".ends m_%s\n",name);

  fprintf(stdout,"\n");
  fprintf(stdout,"* Subckt %s\n", name);
  fprintf(stdout,".subckt %s",name);
  for (i=1;i<=2*num;i++) {
    fprintf(stdout," %d",i);
  }
  fprintf(stdout,"\n");

  fprintf(stdout,"x1");
  for (i=1;i<=num;i++)  fprintf(stdout," %d", i);
  for (i=1;i<=num;i++)  fprintf(stdout," %d", 2*num+i);
  fprintf(stdout," m_%s\n",name);

  for (i=1;i<=num;i++) 
    fprintf(stdout,"o%d %d 0 %d 0 mod%d_%s\n",i,2*num+i,3*num+i,i,name);

  fprintf(stdout,"x2");
  for (i=1;i<=num;i++)  fprintf(stdout," %d", num+i);
  for (i=1;i<=num;i++)  fprintf(stdout," %d", 3*num+i);
  fprintf(stdout," m_%s\n",name);

  fprintf(stdout,".ends %s\n",name);

  tfree(tpeigenvalues);
  for (i=1;i<=num;i++) {
    tfree(matrix[i]);
    tfree(inverse[i]);
  }
  tfree(matrix);
  tfree(inverse);
  tfree(name);
  tfree(options);

  return EXIT_NORMAL; 
}
Example #17
0
bool Argument1DString::writeToFile() const
{
  if(currentArgumentIOType() == HydroCouple::File)
  {
    QFile file(m_inputFile.absoluteFilePath());

    if(file.open(QIODevice::WriteOnly))
    {
      QXmlStreamWriter xmlWriter(&file);
      xmlWriter.setAutoFormatting(true);

      xmlWriter.writeStartElement("Argument1D");
      {
        xmlWriter.writeAttribute("Id" , id());
        xmlWriter.writeAttribute("Caption" , caption());
        xmlWriter.writeAttribute("IsOptional" , isOptional() ? "True" : "False");

        for(const QString& comment : comments())
        {
          xmlWriter.writeComment(comment);
        }

        //write value definition;
        valueDefinitionInternal()->writeData(xmlWriter);

        xmlWriter.writeStartElement("Dimensions");
        {
          xmlWriter.writeStartElement("Dimension");
          {
            xmlWriter.writeAttribute("Id" , m_dimension->id());
            xmlWriter.writeAttribute("Caption" , m_dimension->caption());
            xmlWriter.writeAttribute("Length" , QString::number(length()));
          }
          xmlWriter.writeEndElement();
        }
        xmlWriter.writeEndElement();

        xmlWriter.writeStartElement("Values");
        {
          int ind[1] = {0};
          int str[1] = {length()};
          QString *values = new QString[length()];
          getValues(ind,str,values);

          for(int i = 0 ; i < length() ; i++)
          {
            xmlWriter.writeStartElement("Value");
            {
              xmlWriter.writeCharacters(values[i]);
            }
            xmlWriter.writeEndElement();
          }

          delete[] values;
        }
        xmlWriter.writeEndElement();
      }
      xmlWriter.writeEndElement();

      file.close();

      return false;
    }
  }

  return false;
}
Example #18
0
QString Argument1DDouble::toString() const
{
  if(currentArgumentIOType() == HydroCouple::File)
  {
     return   QFileInfo(modelComponent()->componentInfo()->libraryFilePath()).absoluteDir().relativeFilePath(m_inputFile.absoluteFilePath());
  }
  else
  {
    QString data;
    QXmlStreamWriter xmlWriter(&data);
    xmlWriter.setAutoFormatting(true);

    xmlWriter.writeStartDocument();
    {
      xmlWriter.writeStartElement("Argument1D");
      {
        xmlWriter.writeAttribute("Id" , id());
        xmlWriter.writeAttribute("Caption" , caption());
        xmlWriter.writeAttribute("IsOptional" , isOptional() ? "True" : "False");

        for(const QString& comment : comments())
        {
          xmlWriter.writeComment(comment);
        }

        //write value definition;
        valueDefinitionInternal()->writeData(xmlWriter);

        xmlWriter.writeStartElement("Dimensions");
        {
          xmlWriter.writeStartElement("Dimension");
          {
            xmlWriter.writeAttribute("Id" , m_dimension->id());
            xmlWriter.writeAttribute("Caption" , m_dimension->caption());
            xmlWriter.writeAttribute("Length" , QString::number(length()));
          }
          xmlWriter.writeEndElement();
        }
        xmlWriter.writeEndElement();

        xmlWriter.writeStartElement("Values");
        {
          int ind[1] = {0};
          int str[1] = {length()};
          double values[length()];
          getValues(ind,str,values);

          for(int i = 0 ; i < length() ; i++)
          {
            xmlWriter.writeStartElement("Value");
            {
              xmlWriter.writeCharacters(QString::number(values[i]));
            }
            xmlWriter.writeEndElement();
          }
        }
        xmlWriter.writeEndElement();
      }
      xmlWriter.writeEndElement();
    }
    xmlWriter.writeEndDocument();

    return data;
  }
}
Example #19
0
void GxsChannelPostItem::loadComments()
{
	QString title = QString::fromUtf8(mPost.mMeta.mMsgName.c_str());
	comments(title);
}