Beispiel #1
0
void Package::setId(const QString &i) {
    if (i != id()) {
        m_id = i;
        emit dataChanged(this, IdRole);
    }
}
Beispiel #2
0
void Texture2::destroy(){
	if(id()){
		glDeleteTextures(1, &mID);
		mID = 0;
	}
}
Beispiel #3
0
void MakeTOFResMisAlignment() {
  //
  // Create TClonesArray of residual misalignment objects for TOF
  //

  const char* macroname = "MakeTOFResMisAlignment.C";

  TClonesArray *array = new TClonesArray("AliAlignObjParams",2000);
  TClonesArray &alobj = *array;
   
  // Activate CDB storage and load geometry from CDB
  AliCDBManager* cdb = AliCDBManager::Instance();
  if (!cdb->IsDefaultStorageSet())
    cdb->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
  cdb->SetRun(0);

  AliCDBStorage* storage;
  TString Storage;

  if( TString(gSystem->Getenv("TOCDB")) == TString("kTRUE") ){
    Storage = gSystem->Getenv("STORAGE");
    if (!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) {
      Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data());
      return;
    }
    storage = cdb->GetStorage(Storage.Data());
    if (!storage) {
      Error(macroname,"Unable to open storage %s\n",Storage.Data());
      return;
    }
    AliCDBPath path("GRP","Geometry","Data");
    AliCDBEntry *entry = storage->Get(path.GetPath(),cdb->GetRun());
    if (!entry)
      Fatal(macroname,"Could not get the specified CDB entry!");

    entry->SetOwner(0);
    TGeoManager* geom = (TGeoManager*) entry->GetObject();
    AliGeomManager::SetGeometry(geom);
  } else
    AliGeomManager::LoadGeometry(); //load geom from default CDB storage

  AliGeomManager::ELayerID idTOF = AliGeomManager::kTOF;
  Int_t j=0;
  Int_t nSectors=18;

  //Produce objects for TOF supermodules
  Int_t iIndex=0; //let all modules have index=0 in a layer with no LUT
  AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer;
  UShort_t dvoluid = AliGeomManager::LayerToVolUID(iLayer,iIndex); //dummy vol id 
  Double_t smdx, smdy, smdz=0., dpsi=0., dtheta, dphi=0.;
  for(Int_t isect=0; isect<nSectors; isect++) {
    TString symname(Form("TOF/sm%02d",isect));
    new(alobj[j++]) AliAlignObjParams(symname.Data(),
				      dvoluid,
				      smdx, smdy, smdz, dpsi, dtheta, dphi, kFALSE);
  }

  Int_t strId=-1;
  Double_t dx=0., dy=0., dz=0., dpsi=0., dtheta=0., dphi=0.;
  //TRandom *rnd   = new TRandom(4357);
  Double_t sigmatr = 0.1; // sigma (in cm) for shift w.r.t. local ideal RS

  Int_t nstrA=15;
  Int_t nstrB=19;
  Int_t nstrC=19;
  Int_t nStrips=nstrA+2*nstrB+2*nstrC;

  Double_t cuty=0., cutz=0., cut=3*sigmatr;
  for (Int_t isect = 0; isect < nSectors; isect++) {
    for (Int_t istr = 1; istr <= nStrips; istr++) {
      //dy = rnd->Gaus(0.,sigmatr);
      //dz = rnd->Gaus(0.,sigmatr);
      //strId++;

      switch (istr) {
      case 25:
      case 29:
      case 63:
      case 67:
	cuty = sigmatr*0.6;
	dy  = AliMathBase::TruncatedGaus(0., sigmatr, cut, cuty);
	dz  = AliMathBase::TruncatedGaus(0., sigmatr, cut);
	strId++;
	break;
	/*
      case 38:
	cuty = sigmatr*2.5;
	cutz = sigmatr*2.5;
	dy  = AliMathBase::TruncatedGaus(0., sigmatr, cut, cuty);
	dz  = AliMathBase::TruncatedGaus(0., sigmatr, cut, cutz);
	strId++;
	break;
      case 54:
	cuty = sigmatr*2.5;
	cutz = sigmatr*2.5;
	dy  = AliMathBase::TruncatedGaus(0., sigmatr, cut, cuty);
	dz  = AliMathBase::TruncatedGaus(0., sigmatr, cutz, cut);
	strId++;
	break;
	*/
      default:
	dy = AliMathBase::TruncatedGaus(0., sigmatr, cut);
	dz = AliMathBase::TruncatedGaus(0., sigmatr, cut);
	strId++;
	break;
      }

      if ((isect==13 || isect==14 || isect==15) && (istr >= 39 && istr <= 53)) continue;
      new(alobj[j++]) AliAlignObjParams(AliGeomManager::SymName(idTOF,strId),
					AliGeomManager::LayerToVolUID(idTOF,strId),
					dx, dy, dz, dpsi, dtheta, dphi, kFALSE);
    }
  }

  if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ) {
    // save on file
    const char* filename = "TOFresidualMisalignment.root";
    TFile f(filename,"RECREATE");
    if(!f){
      Error(macroname,"cannot open file for output\n");
      return;
    }
    Info(macroname,"Saving alignment objects to the file %s", filename);
    f.cd();
    f.WriteObject(array,"TOFAlignObjs","kSingleKey");
    f.Close();
  } else {
    // save in CDB storage
    AliCDBMetaData* md = new AliCDBMetaData();
    md->SetResponsible("Silvia Arcelli");
    md->SetComment("Residual misalignment for TOF, sigmatr=1mm in the local RS");
    md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
    AliCDBId id("TOF/Align/Data",0,AliCDBRunRange::Infinity());
    storage->Put(array,id,md);
  }

  array->Delete();

}
void KisLensBlurFilter::process(KisPaintDeviceSP device,
                            const QRect& rect,
                            const KisFilterConfiguration* config,
                            KoUpdater* progressUpdater
                           ) const
{
    QPoint srcTopLeft = rect.topLeft();

    Q_ASSERT(device != 0);

    if (!config) config = new KisFilterConfiguration(id().id(), 1);

    QVariant value;
    config->getProperty("irisShape", value);
    QString irisShape = value.toString();
    config->getProperty("irisRadius", value);
    uint irisRadius = value.toUInt();
    config->getProperty("irisRotation", value);
    uint irisRotation = value.toUInt();

    if (irisRadius < 1)
        return;

    QBitArray channelFlags;
    if (config) {
        channelFlags = config->channelFlags();
    } 
    if (channelFlags.isEmpty() || !config) {
        channelFlags = QBitArray(device->colorSpace()->channelCount(), true);
    }
    
    QPolygonF irisShapePoly;

    int sides = 1;
    qreal angle = 0;

    if (irisShape == "Triangle") sides = 3;
    else if (irisShape == "Quadrilateral (4)") sides = 4;
    else if (irisShape == "Pentagon (5)") sides = 5;
    else if (irisShape == "Hexagon (6)") sides = 6;
    else if (irisShape == "Heptagon (7)") sides = 7;
    else if (irisShape == "Octagon (8)") sides = 8;
    else return;

    for (int i = 0; i < sides; ++i) {
        irisShapePoly << QPointF(0.5 * cos(angle), 0.5 * sin(angle));
        angle += 2 * M_PI / sides;
    }

    QTransform transform;
    transform.rotate(irisRotation);
    transform.scale(irisRadius * 2, irisRadius * 2);

    QPolygonF transformedIris;
    for (int i = 0; i < irisShapePoly.count(); ++i) {
        transformedIris << irisShapePoly[i] * transform;
    }

    // find extremes to determine kernel size required
    qreal minX = 0, maxX = 0, minY = 0, maxY = 0;
    for (int i = 0; i < transformedIris.count(); ++i) {
        if (transformedIris[i].x() < minX) minX = transformedIris[i].x();
        if (transformedIris[i].x() > maxX) maxX = transformedIris[i].x();
        if (transformedIris[i].y() < minY) minY = transformedIris[i].y();
        if (transformedIris[i].y() > maxY) maxY = transformedIris[i].y();
    }

    int kernelWidth = ceil(maxX) - ceil(minX);
    int kernelHeight = ceil(maxY) - ceil(minY);

    QImage kernelRepresentation(kernelWidth, kernelHeight, QImage::Format_RGB32);
    kernelRepresentation.fill(0);

    QPainter imagePainter(&kernelRepresentation);
    imagePainter.setRenderHint(QPainter::Antialiasing);
    imagePainter.setBrush(QColor::fromRgb(255, 255, 255));

    QTransform offsetTransform;
    offsetTransform.translate(-minX, -minY);
    imagePainter.setTransform(offsetTransform);
    imagePainter.drawPolygon(transformedIris, Qt::WindingFill);

    // construct kernel from image
    Matrix<qreal, Dynamic, Dynamic> irisKernel(kernelHeight, kernelWidth);
    for (int j = 0; j < kernelHeight; ++j) {
        for (int i = 0; i < kernelWidth; ++i) {
            irisKernel(j, i) = qRed(kernelRepresentation.pixel(i, j));
        }
    }

    // apply convolution
    KisConvolutionPainter painter(device);
    painter.setChannelFlags(channelFlags);
    painter.setProgress(progressUpdater);

    KisConvolutionKernelSP kernel = KisConvolutionKernel::fromMatrix(irisKernel, 0, irisKernel.sum());
    painter.applyMatrix(kernel, device, srcTopLeft, srcTopLeft, rect.size(), BORDER_REPEAT);
}
PreconditionerBlockMS<space_type>::PreconditionerBlockMS(space_ptrtype Xh,             // (u)x(p)
                                                         ModelProperties model,        // model
                                                         std::string const& p,         // prefix
                                                         sparse_matrix_ptrtype AA )    // The matrix
    :
        M_backend(backend()),           // the backend associated to the PC
        M_Xh( Xh ),
        M_Vh( Xh->template functionSpace<0>() ), // Potential
        M_Qh( Xh->template functionSpace<1>() ), // Lagrange
        M_Vh_indices( M_Vh->nLocalDofWithGhost() ),
        M_Qh_indices( M_Qh->nLocalDofWithGhost() ),
        M_uin( M_backend->newVector( M_Vh )  ),
        M_uout( M_backend->newVector( M_Vh )  ),
        M_pin( M_backend->newVector( M_Qh )  ),
        M_pout( M_backend->newVector( M_Qh )  ),
        U( M_Xh, "U" ),
        M_mass(M_backend->newMatrix(M_Vh,M_Vh)),
        M_L(M_backend->newMatrix(M_Qh,M_Qh)),
        M_er( 1. ),
        M_model( model ),
        M_prefix( p ),
        M_prefix_11( p+".11" ),
        M_prefix_22( p+".22" ),
        u(M_Vh, "u"),
        ozz(M_Vh, "ozz"),
        zoz(M_Vh, "zoz"),
        zzo(M_Vh, "zzo"),
        M_ozz(M_backend->newVector( M_Vh )),
        M_zoz(M_backend->newVector( M_Vh )),
        M_zzo(M_backend->newVector( M_Vh )),
        X(M_Qh, "X"),
        Y(M_Qh, "Y"),
        Z(M_Qh, "Z"),
        M_X(M_backend->newVector( M_Qh )),
        M_Y(M_backend->newVector( M_Qh )),
        M_Z(M_backend->newVector( M_Qh )),
        phi(M_Qh, "phi")
{
    tic();
    LOG(INFO) << "[PreconditionerBlockMS] setup starts";
    this->setMatrix( AA );
    this->setName(M_prefix);

    /* Indices are need to extract sub matrix */
    std::iota( M_Vh_indices.begin(), M_Vh_indices.end(), 0 );
    std::iota( M_Qh_indices.begin(), M_Qh_indices.end(), M_Vh->nLocalDofWithGhost() );

    M_11 = AA->createSubMatrix( M_Vh_indices, M_Vh_indices, true, true);

    /* Boundary conditions */
    BoundaryConditions M_bc = M_model.boundaryConditions();
    map_vector_field<FEELPP_DIM,1,2> m_dirichlet_u { M_bc.getVectorFields<FEELPP_DIM> ( "u", "Dirichlet" ) };
    map_scalar_field<2> m_dirichlet_p { M_bc.getScalarFields<2> ( "phi", "Dirichlet" ) };

    /* Compute the mass matrix (needed in first block, constant) */
    auto f2A = form2(_test=M_Vh, _trial=M_Vh, _matrix=M_mass);
    auto f1A = form1(_test=M_Vh);
    f2A = integrate(_range=elements(M_Vh->mesh()), _expr=inner(idt(u),id(u))); // M
    for(auto const & it : m_dirichlet_u )
    {
        LOG(INFO) << "Applying " << it.second << " on " << it.first << " for "<<M_prefix_11<<"\n";
        f2A += on(_range=markedfaces(M_Vh->mesh(),it.first), _expr=it.second,_rhs=f1A, _element=u, _type="elimination_symmetric");
    }
    
    /* Compute the L (= er * grad grad) matrix (the second block) */
    auto f2L = form2(_test=M_Qh,_trial=M_Qh, _matrix=M_L);
    for(auto it : M_model.materials() )
    { 
        f2L += integrate(_range=markedelements(M_Qh->mesh(),marker(it)), _expr=M_er*inner(gradt(phi), grad(phi)));
    }
    auto f1LQ = form1(_test=M_Qh);

    for(auto const & it : m_dirichlet_p)
    {
        LOG(INFO) << "Applying " << it.second << " on " << it.first << " for "<<M_prefix_22<<"\n";
        f2L += on(_range=markedfaces(M_Qh->mesh(),it.first),_element=phi, _expr=it.second, _rhs=f1LQ, _type="elimination_symmetric");
    }


    if(soption(_name="pc-type", _prefix=M_prefix_11) == "ams")
#if FEELPP_DIM == 3
    {
        M_grad  = Grad( _domainSpace=M_Qh, _imageSpace=M_Vh);

        // This preconditioner is linked to that backend : the backend will
        // automatically use the preconditioner.
        auto prec = preconditioner(_pc=pcTypeConvertStrToEnum(soption(M_prefix_11+".pc-type")),
                                   _backend=backend(_name=M_prefix_11),
                                   _prefix=M_prefix_11,
                                   _matrix=M_11
                                  );
        prec->setMatrix(M_11);
        prec->attachAuxiliarySparseMatrix("G",M_grad.matPtr());
        if(boption(M_prefix_11+".useEdge"))
        {
            LOG(INFO) << "[ AMS ] : using SetConstantEdgeVector \n";
            ozz.on(_range=elements(M_Vh->mesh()),_expr=vec(cst(1),cst(0),cst(0)));
            zoz.on(_range=elements(M_Vh->mesh()),_expr=vec(cst(0),cst(1),cst(0)));
            zzo.on(_range=elements(M_Vh->mesh()),_expr=vec(cst(0),cst(0),cst(1)));
            *M_ozz = ozz; M_ozz->close();
            *M_zoz = zoz; M_zoz->close();
            *M_zzo = zzo; M_zzo->close();

            prec->attachAuxiliaryVector("Px",M_ozz);
            prec->attachAuxiliaryVector("Py",M_zoz);
            prec->attachAuxiliaryVector("Pz",M_zzo);
        }
        else
        {
            LOG(INFO) << "[ AMS ] : using SetCoordinates \n";
            X.on(_range=elements(M_Vh->mesh()),_expr=Px());
            Y.on(_range=elements(M_Vh->mesh()),_expr=Py());
            Z.on(_range=elements(M_Vh->mesh()),_expr=Pz());
            *M_X = X; M_X->close();
            *M_Y = Y; M_Y->close();
            *M_Z = Z; M_Z->close();
            prec->attachAuxiliaryVector("X",M_X);
            prec->attachAuxiliaryVector("Y",M_Y);
            prec->attachAuxiliaryVector("Z",M_Z);
        }
    }
#else
    std::cerr << "ams preconditioner is not interfaced in two dimensions\n";
#endif
    toc( "[PreconditionerBlockMS] setup done ", FLAGS_v > 0 );
}
void MakeZDCFullMisAlignment(){
  // Create TClonesArray of full misalignment objects for ZDC
  //
  const char* macroname = "MakeZDCFullMisAlignment.C";

  TClonesArray *array = new TClonesArray("AliAlignObjParams",10);
  TClonesArray &alobj = *array;

  Double_t dx=0., dy=2., dz=0.;
  Double_t dpsi=0., dtheta=0., dphi=0.;

  const char *ZDCCn="ZDC/NeutronZDC_C";
  const char *ZDCCp="ZDC/ProtonZDC_C";
  const char *ZDCAn="ZDC/NeutronZDC_A";
  const char *ZDCAp="ZDC/ProtonZDC_A";

  Int_t iIndex=0; //let all modules have index=0 in a layer with no LUT
  AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer;
  UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iIndex);

  new(alobj[0]) AliAlignObjParams(ZDCCn, volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
  new(alobj[1]) AliAlignObjParams(ZDCCp, volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
  new(alobj[2]) AliAlignObjParams(ZDCAn, volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
  new(alobj[3]) AliAlignObjParams(ZDCAp, volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);

  if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ){
    // save in file
    const char* filename = "ZDCfullMisalignment.root";
    TFile f(filename,"RECREATE");
    if(!f){
      Error(macroname,"cannot open file for output\n");
      return;
    }
    Info(macroname,"Saving alignment objects to the file %s", filename);
    f.cd();
    f.WriteObject(array,"ZDCAlignObjs","kSingleKey");
    f.Close();
  }else{
    // save in CDB storage
    TString Storage = gSystem->Getenv("STORAGE");
    if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) {
      Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data());
      return;
    }
    Info(macroname,"Saving alignment objects in CDB storage %s",
	 Storage.Data());
    AliCDBManager* cdb = AliCDBManager::Instance();
    AliCDBStorage* storage = cdb->GetStorage(Storage.Data());
    if(!storage){
      Error(macroname,"Unable to open storage %s\n",Storage.Data());
      return;
    }
    AliCDBMetaData* md = new AliCDBMetaData();
    md->SetResponsible("Chiara Oppedisano");
    md->SetComment("Alignment objects for ZDC full misalignment");
    md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
    AliCDBId id("ZDC/Align/Data",0,AliCDBRunRange::Infinity());
    storage->Put(array,id,md);
  }

  array->Delete();

}
/******************************************************************************
* ASetCanvas :: ASetCanvas - Constructor for our main window                  *
******************************************************************************/
ASetCanvas::ASetCanvas(unsigned long windowId)
  : IFrameWindow( windowId )
  /*---------------------------------------------------------------------------|
  |  Create the ISplitCanvases                                                 |
  ----------------------------------------------------------------------------*/
  , horzCanvas1( ID_HORIZCANVAS1, this, this )
  , vertCanvas1( ID_VERTCANVAS1,  &horzCanvas1, &horzCanvas1 )
  , vertCanvas2( ID_VERTCANVAS2,  &horzCanvas1, &horzCanvas1 )
  , vertCanvas3( ID_VERTCANVAS3,  &horzCanvas1, &horzCanvas1 )
  /*---------------------------------------------------------------------------|
  |  Create the ISetCanvases                                                   |
  ----------------------------------------------------------------------------*/
  , setCanvas1( ID_SETCANVAS1, &vertCanvas1, &vertCanvas1 )
  , setCanvas2( ID_SETCANVAS2, &vertCanvas1, &vertCanvas1 )
  , setCanvas3( ID_SETCANVAS3, &vertCanvas2, &vertCanvas2 )
  , setCanvas4( ID_SETCANVAS4, &vertCanvas2, &vertCanvas2 )
  , setCanvas5( ID_SETCANVAS5, &vertCanvas3, &vertCanvas3 )
  , setCanvas6( ID_SETCANVAS6, &vertCanvas3, &vertCanvas3 )
  /*---------------------------------------------------------------------------|
  |  Create the radio buttons for each ISetCanvases                            |
  ----------------------------------------------------------------------------*/
  , vRadioGroup1( ID_VRADIO,      &setCanvas1, 5, AButtons::vertical )
  , vRadioGroup2( ID_VRADIO + 5,  &setCanvas3, 6, AButtons::vertical )
  , vRadioGroup3( ID_VRADIO + 11, &setCanvas5, 7, AButtons::vertical )
  , hRadioGroup1( ID_HRADIO,      &setCanvas2, 5, AButtons::horizontal )
  , hRadioGroup2( ID_HRADIO + 5,  &setCanvas4, 6, AButtons::horizontal )
  , hRadioGroup3( ID_HRADIO + 11, &setCanvas6, 7, AButtons::horizontal )
{
/*-----------------------------------------------------------------------------|
|  Set the icon for the main window and make the split canvas the client area  |
------------------------------------------------------------------------------*/
  setIcon( id() );
  setClient( &horzCanvas1 );

/*-----------------------------------------------------------------------------|
|  Set the split canvas orientation                                            |
------------------------------------------------------------------------------*/
  horzCanvas1.setOrientation( ISplitCanvas::horizontalSplit );
  vertCanvas1.setOrientation( ISplitCanvas::verticalSplit );
  vertCanvas2.setOrientation( ISplitCanvas::verticalSplit );
  vertCanvas3.setOrientation( ISplitCanvas::verticalSplit );

/*-----------------------------------------------------------------------------|
|  Set three ISetCanvases to have 3 vertical decks                             |
------------------------------------------------------------------------------*/
  setCanvas1.setDeckOrientation( ISetCanvas::vertical );
  setCanvas3.setDeckOrientation( ISetCanvas::vertical );
  setCanvas5.setDeckOrientation( ISetCanvas::vertical );

/*-----------------------------------------------------------------------------|
|  Set three ISetCanvases to have 3 horizontal decks                           |
------------------------------------------------------------------------------*/
  setCanvas2.setDeckOrientation( ISetCanvas::horizontal );
  setCanvas4.setDeckOrientation( ISetCanvas::horizontal );
  setCanvas6.setDeckOrientation( ISetCanvas::horizontal );

/*-----------------------------------------------------------------------------|
|  Set each ISetCanvases to have 3 decks                                       |
------------------------------------------------------------------------------*/
  setCanvas1.setDeckCount( 3 );
  setCanvas2.setDeckCount( 3 );
  setCanvas3.setDeckCount( 3 );
  setCanvas4.setDeckCount( 3 );
  setCanvas5.setDeckCount( 3 );
  setCanvas6.setDeckCount( 3 );

  show();

} /* end ASetCanvas :: ASetCanvas */
status_t WifiDisplaySource::resume() {
    sp<AMessage> msg = new AMessage(kWhatResume, id());

    sp<AMessage> response;
    return PostAndAwaitResponse(msg, &response);
}
void WifiDisplaySource::onMessageReceived(const sp<AMessage> &msg) {
    switch (msg->what()) {
        case kWhatStart:
        {
            uint32_t replyID;
            CHECK(msg->senderAwaitsResponse(&replyID));

            AString iface;
            CHECK(msg->findString("iface", &iface));

            status_t err = OK;

            ssize_t colonPos = iface.find(":");

            unsigned long port;

            if (colonPos >= 0) {
                const char *s = iface.c_str() + colonPos + 1;

                char *end;
                port = strtoul(s, &end, 10);

                if (end == s || *end != '\0' || port > 65535) {
                    err = -EINVAL;
                } else {
                    iface.erase(colonPos, iface.size() - colonPos);
                }
            } else {
                port = kWifiDisplayDefaultPort;
            }

            if (err == OK) {
                if (inet_aton(iface.c_str(), &mInterfaceAddr) != 0) {
                    sp<AMessage> notify = new AMessage(kWhatRTSPNotify, id());

                    err = mNetSession->createRTSPServer(
                            mInterfaceAddr, port, notify, &mSessionID);
                } else {
                    err = -EINVAL;
                }
            }

            mState = AWAITING_CLIENT_CONNECTION;

            sp<AMessage> response = new AMessage;
            response->setInt32("err", err);
            response->postReply(replyID);
            break;
        }

        case kWhatRTSPNotify:
        {
            int32_t reason;
            CHECK(msg->findInt32("reason", &reason));

            switch (reason) {
                case ANetworkSession::kWhatError:
                {
                    int32_t sessionID;
                    CHECK(msg->findInt32("sessionID", &sessionID));

                    int32_t err;
                    CHECK(msg->findInt32("err", &err));

                    AString detail;
                    CHECK(msg->findString("detail", &detail));

                    ALOGE("An error occurred in session %d (%d, '%s/%s').",
                          sessionID,
                          err,
                          detail.c_str(),
                          strerror(-err));

                    mNetSession->destroySession(sessionID);

                    if (sessionID == mClientSessionID) {
                        mClientSessionID = 0;

                        mClient->onDisplayError(
                                IRemoteDisplayClient::kDisplayErrorUnknown);
                    }
                    break;
                }

                case ANetworkSession::kWhatClientConnected:
                {
                    int32_t sessionID;
                    CHECK(msg->findInt32("sessionID", &sessionID));

                    if (mClientSessionID > 0) {
                        ALOGW("A client tried to connect, but we already "
                              "have one.");

                        mNetSession->destroySession(sessionID);
                        break;
                    }

                    CHECK_EQ(mState, AWAITING_CLIENT_CONNECTION);

                    CHECK(msg->findString("client-ip", &mClientInfo.mRemoteIP));
                    CHECK(msg->findString("server-ip", &mClientInfo.mLocalIP));

                    if (mClientInfo.mRemoteIP == mClientInfo.mLocalIP) {
                        // Disallow connections from the local interface
                        // for security reasons.
                        mNetSession->destroySession(sessionID);
                        break;
                    }

                    CHECK(msg->findInt32(
                                "server-port", &mClientInfo.mLocalPort));
                    mClientInfo.mPlaybackSessionID = -1;

                    mClientSessionID = sessionID;

                    ALOGI("We now have a client (%d) connected.", sessionID);

                    mState = AWAITING_CLIENT_SETUP;

                    status_t err = sendM1(sessionID);
                    CHECK_EQ(err, (status_t)OK);
                    break;
                }

                case ANetworkSession::kWhatData:
                {
                    status_t err = onReceiveClientData(msg);

                    if (err != OK) {
                        mClient->onDisplayError(
                                IRemoteDisplayClient::kDisplayErrorUnknown);
                    }

#if 0
                    // testing only.
                    char val[PROPERTY_VALUE_MAX];
                    if (property_get("media.wfd.trigger", val, NULL)) {
                        if (!strcasecmp(val, "pause") && mState == PLAYING) {
                            mState = PLAYING_TO_PAUSED;
                            sendTrigger(mClientSessionID, TRIGGER_PAUSE);
                        } else if (!strcasecmp(val, "play")
                                    && mState == PAUSED) {
                            mState = PAUSED_TO_PLAYING;
                            sendTrigger(mClientSessionID, TRIGGER_PLAY);
                        }
                    }
#endif
                    break;
                }

                case ANetworkSession::kWhatNetworkStall:
                {
                    break;
                }

                default:
                    TRESPASS();
            }
            break;
        }

        case kWhatStop:
        {
            CHECK(msg->senderAwaitsResponse(&mStopReplyID));

            CHECK_LT(mState, AWAITING_CLIENT_TEARDOWN);

            if (mState >= AWAITING_CLIENT_PLAY) {
                // We have a session, i.e. a previous SETUP succeeded.

                status_t err = sendTrigger(
                        mClientSessionID, TRIGGER_TEARDOWN);

                if (err == OK) {
                    mState = AWAITING_CLIENT_TEARDOWN;

                    (new AMessage(kWhatTeardownTriggerTimedOut, id()))->post(
                            kTeardownTriggerTimeouSecs * 1000000ll);

                    break;
                }

                // fall through.
            }

            finishStop();
            break;
        }

        case kWhatPause:
        {
            uint32_t replyID;
            CHECK(msg->senderAwaitsResponse(&replyID));

            status_t err = OK;

            if (mState != PLAYING) {
                err = INVALID_OPERATION;
            } else {
                mState = PLAYING_TO_PAUSED;
                sendTrigger(mClientSessionID, TRIGGER_PAUSE);
            }

            sp<AMessage> response = new AMessage;
            response->setInt32("err", err);
            response->postReply(replyID);
            break;
        }

        case kWhatResume:
        {
            uint32_t replyID;
            CHECK(msg->senderAwaitsResponse(&replyID));

            status_t err = OK;

            if (mState != PAUSED) {
                err = INVALID_OPERATION;
            } else {
                mState = PAUSED_TO_PLAYING;
                sendTrigger(mClientSessionID, TRIGGER_PLAY);
            }

            sp<AMessage> response = new AMessage;
            response->setInt32("err", err);
            response->postReply(replyID);
            break;
        }

        case kWhatReapDeadClients:
        {
            mReaperPending = false;

            if (mClientSessionID == 0
                    || mClientInfo.mPlaybackSession == NULL) {
                break;
            }

            if (mClientInfo.mPlaybackSession->getLastLifesignUs()
                    + kPlaybackSessionTimeoutUs < ALooper::GetNowUs()) {
                ALOGI("playback session timed out, reaping.");

                mNetSession->destroySession(mClientSessionID);
                mClientSessionID = 0;

                mClient->onDisplayError(
                        IRemoteDisplayClient::kDisplayErrorUnknown);
            } else {
                scheduleReaper();
            }
            break;
        }

        case kWhatPlaybackSessionNotify:
        {
            int32_t playbackSessionID;
            CHECK(msg->findInt32("playbackSessionID", &playbackSessionID));

            int32_t what;
            CHECK(msg->findInt32("what", &what));

            if (what == PlaybackSession::kWhatSessionDead) {
                ALOGI("playback session wants to quit.");

                mClient->onDisplayError(
                        IRemoteDisplayClient::kDisplayErrorUnknown);
            } else if (what == PlaybackSession::kWhatSessionEstablished) {
                mPlaybackSessionEstablished = true;

                if (mClient != NULL) {
                    if (!mSinkSupportsVideo) {
                        mClient->onDisplayConnected(
                                NULL,  // SurfaceTexture
                                0, // width,
                                0, // height,
                                mUsingHDCP
                                    ? IRemoteDisplayClient::kDisplayFlagSecure
                                    : 0,
                                0);
                    } else {
                        size_t width, height;

                        CHECK(VideoFormats::GetConfiguration(
                                    mChosenVideoResolutionType,
                                    mChosenVideoResolutionIndex,
                                    &width,
                                    &height,
                                    NULL /* framesPerSecond */,
                                    NULL /* interlaced */));

                        mClient->onDisplayConnected(
                                mClientInfo.mPlaybackSession
                                    ->getSurfaceTexture(),
                                width,
                                height,
                                mUsingHDCP
                                    ? IRemoteDisplayClient::kDisplayFlagSecure
                                    : 0,
                                playbackSessionID);
                    }
                }

                finishPlay();

                if (mState == ABOUT_TO_PLAY) {
                    mState = PLAYING;
                }
            } else if (what == PlaybackSession::kWhatSessionDestroyed) {
                disconnectClient2();
            } else {
                CHECK_EQ(what, PlaybackSession::kWhatBinaryData);

                int32_t channel;
                CHECK(msg->findInt32("channel", &channel));

                sp<ABuffer> data;
                CHECK(msg->findBuffer("data", &data));

                CHECK_LE(channel, 0xffu);
                CHECK_LE(data->size(), 0xffffu);

                int32_t sessionID;
                CHECK(msg->findInt32("sessionID", &sessionID));

                char header[4];
                header[0] = '$';
                header[1] = channel;
                header[2] = data->size() >> 8;
                header[3] = data->size() & 0xff;

                mNetSession->sendRequest(
                        sessionID, header, sizeof(header));

                mNetSession->sendRequest(
                        sessionID, data->data(), data->size());
            }
            break;
        }

        case kWhatKeepAlive:
        {
            int32_t sessionID;
            CHECK(msg->findInt32("sessionID", &sessionID));

            if (mClientSessionID != sessionID) {
                // Obsolete event, client is already gone.
                break;
            }

            sendM16(sessionID);
            break;
        }

        case kWhatTeardownTriggerTimedOut:
        {
            if (mState == AWAITING_CLIENT_TEARDOWN) {
                ALOGI("TEARDOWN trigger timed out, forcing disconnection.");

                CHECK_NE(mStopReplyID, 0);
                finishStop();
                break;
            }
            break;
        }

        case kWhatHDCPNotify:
        {
            int32_t msgCode, ext1, ext2;
            CHECK(msg->findInt32("msg", &msgCode));
            CHECK(msg->findInt32("ext1", &ext1));
            CHECK(msg->findInt32("ext2", &ext2));

            ALOGI("Saw HDCP notification code %d, ext1 %d, ext2 %d",
                    msgCode, ext1, ext2);

            switch (msgCode) {
                case HDCPModule::HDCP_INITIALIZATION_COMPLETE:
                {
                    mHDCPInitializationComplete = true;

                    if (mSetupTriggerDeferred) {
                        mSetupTriggerDeferred = false;

                        sendTrigger(mClientSessionID, TRIGGER_SETUP);
                    }
                    break;
                }

                case HDCPModule::HDCP_SHUTDOWN_COMPLETE:
                case HDCPModule::HDCP_SHUTDOWN_FAILED:
                {
                    // Ugly hack to make sure that the call to
                    // HDCPObserver::notify is completely handled before
                    // we clear the HDCP instance and unload the shared
                    // library :(
                    (new AMessage(kWhatFinishStop2, id()))->post(300000ll);
                    break;
                }

                default:
                {
                    ALOGE("HDCP failure, shutting down.");

                    mClient->onDisplayError(
                            IRemoteDisplayClient::kDisplayErrorUnknown);
                    break;
                }
            }
            break;
        }

        case kWhatFinishStop2:
        {
            finishStop2();
            break;
        }

        default:
            TRESPASS();
    }
}
Beispiel #10
0
message *
message_login_fail::duplicate() {
    return new message_login_fail(id(), status());
}
status_t WifiDisplaySource::onSetupRequest(
        int32_t sessionID,
        int32_t cseq,
        const sp<ParsedMessage> &data) {
    CHECK_EQ(sessionID, mClientSessionID);
    if (mClientInfo.mPlaybackSessionID != -1) {
        // We only support a single playback session per client.
        // This is due to the reversed keep-alive design in the wfd specs...
        sendErrorResponse(sessionID, "400 Bad Request", cseq);
        return ERROR_MALFORMED;
    }

    AString transport;
    if (!data->findString("transport", &transport)) {
        sendErrorResponse(sessionID, "400 Bad Request", cseq);
        return ERROR_MALFORMED;
    }

    RTPSender::TransportMode rtpMode = RTPSender::TRANSPORT_UDP;

    int clientRtp, clientRtcp;
    if (transport.startsWith("RTP/AVP/TCP;")) {
        AString interleaved;
        if (ParsedMessage::GetAttribute(
                    transport.c_str(), "interleaved", &interleaved)
                && sscanf(interleaved.c_str(), "%d-%d",
                          &clientRtp, &clientRtcp) == 2) {
            rtpMode = RTPSender::TRANSPORT_TCP_INTERLEAVED;
        } else {
            bool badRequest = false;

            AString clientPort;
            if (!ParsedMessage::GetAttribute(
                        transport.c_str(), "client_port", &clientPort)) {
                badRequest = true;
            } else if (sscanf(clientPort.c_str(), "%d-%d",
                              &clientRtp, &clientRtcp) == 2) {
            } else if (sscanf(clientPort.c_str(), "%d", &clientRtp) == 1) {
                // No RTCP.
                clientRtcp = -1;
            } else {
                badRequest = true;
            }

            if (badRequest) {
                sendErrorResponse(sessionID, "400 Bad Request", cseq);
                return ERROR_MALFORMED;
            }

            rtpMode = RTPSender::TRANSPORT_TCP;
        }
    } else if (transport.startsWith("RTP/AVP;unicast;")
            || transport.startsWith("RTP/AVP/UDP;unicast;")) {
        bool badRequest = false;

        AString clientPort;
        if (!ParsedMessage::GetAttribute(
                    transport.c_str(), "client_port", &clientPort)) {
            badRequest = true;
        } else if (sscanf(clientPort.c_str(), "%d-%d",
                          &clientRtp, &clientRtcp) == 2) {
        } else if (sscanf(clientPort.c_str(), "%d", &clientRtp) == 1) {
            // No RTCP.
            clientRtcp = -1;
        } else {
            badRequest = true;
        }

        if (badRequest) {
            sendErrorResponse(sessionID, "400 Bad Request", cseq);
            return ERROR_MALFORMED;
        }
#if 1
    // The older LG dongles doesn't specify client_port=xxx apparently.
    } else if (transport == "RTP/AVP/UDP;unicast") {
        clientRtp = 19000;
        clientRtcp = -1;
#endif
    } else {
        sendErrorResponse(sessionID, "461 Unsupported Transport", cseq);
        return ERROR_UNSUPPORTED;
    }

    int32_t playbackSessionID = makeUniquePlaybackSessionID();

    sp<AMessage> notify = new AMessage(kWhatPlaybackSessionNotify, id());
    notify->setInt32("playbackSessionID", playbackSessionID);
    notify->setInt32("sessionID", sessionID);

    sp<PlaybackSession> playbackSession =
        new PlaybackSession(
                mNetSession, notify, mInterfaceAddr, mHDCP, mMediaPath.c_str());

    looper()->registerHandler(playbackSession);

    AString uri;
    data->getRequestField(1, &uri);

    if (strncasecmp("rtsp://", uri.c_str(), 7)) {
        sendErrorResponse(sessionID, "400 Bad Request", cseq);
        return ERROR_MALFORMED;
    }

    if (!(uri.startsWith("rtsp://") && uri.endsWith("/wfd1.0/streamid=0"))) {
        sendErrorResponse(sessionID, "404 Not found", cseq);
        return ERROR_MALFORMED;
    }

    RTPSender::TransportMode rtcpMode = RTPSender::TRANSPORT_UDP;
    if (clientRtcp < 0) {
        rtcpMode = RTPSender::TRANSPORT_NONE;
    }

    status_t err = playbackSession->init(
            mClientInfo.mRemoteIP.c_str(),
            clientRtp,
            rtpMode,
            clientRtcp,
            rtcpMode,
            mSinkSupportsAudio,
            mUsingPCMAudio,
            mSinkSupportsVideo,
            mChosenVideoResolutionType,
            mChosenVideoResolutionIndex,
            mChosenVideoProfile,
            mChosenVideoLevel);

    if (err != OK) {
        looper()->unregisterHandler(playbackSession->id());
        playbackSession.clear();
    }

    switch (err) {
        case OK:
            break;
        case -ENOENT:
            sendErrorResponse(sessionID, "404 Not Found", cseq);
            return err;
        default:
            sendErrorResponse(sessionID, "403 Forbidden", cseq);
            return err;
    }

    mClientInfo.mPlaybackSessionID = playbackSessionID;
    mClientInfo.mPlaybackSession = playbackSession;

    AString response = "RTSP/1.0 200 OK\r\n";
    AppendCommonResponse(&response, cseq, playbackSessionID);

    if (rtpMode == RTPSender::TRANSPORT_TCP_INTERLEAVED) {
        response.append(
                StringPrintf(
                    "Transport: RTP/AVP/TCP;interleaved=%d-%d;",
                    clientRtp, clientRtcp));
    } else {
        int32_t serverRtp = playbackSession->getRTPPort();

        AString transportString = "UDP";
        if (rtpMode == RTPSender::TRANSPORT_TCP) {
            transportString = "TCP";
        }

        if (clientRtcp >= 0) {
            response.append(
                    StringPrintf(
                        "Transport: RTP/AVP/%s;unicast;client_port=%d-%d;"
                        "server_port=%d-%d\r\n",
                        transportString.c_str(),
                        clientRtp, clientRtcp, serverRtp, serverRtp + 1));
        } else {
            response.append(
                    StringPrintf(
                        "Transport: RTP/AVP/%s;unicast;client_port=%d;"
                        "server_port=%d\r\n",
                        transportString.c_str(),
                        clientRtp, serverRtp));
        }
    }

    response.append("\r\n");

    err = mNetSession->sendRequest(sessionID, response.c_str());

    if (err != OK) {
        return err;
    }

    mState = AWAITING_CLIENT_PLAY;

    scheduleReaper();
    scheduleKeepAlive(sessionID);

    return OK;
}
bool DeclarativeDataPluginItem::operator<( const AbstractDataPluginItem *other ) const
{
    return other->id()< id() ;
}
Beispiel #13
0
void cChar::Serialize(ISerialization &archive)
{
	if (archive.isReading())
	{
		archive.read("name",			orgname);
		archive.read("title",			title);
		archive.read("account",			account);
		archive.read("creationday",		creationday);
		archive.read("gmmoveeff",		gmMoveEff);
		archive.read("guildtype",		GuildType);
		archive.read("guildtraitor",	GuildTraitor);
		archive.read("dispz",			dispz);
		archive.read("cell",			cell);
		archive.read("dir",				dir);
		archive.read("race",			race);
		archive.read("body",			xid);	setId(xid);
		archive.read("skin",			skin);	xskin = skin;
		archive.read("priv",			priv);
		
		archive.read("priv3a",			priv3[0]);
		archive.read("priv3b",			priv3[1]);
		archive.read("priv3c",			priv3[2]);
		archive.read("priv3d",			priv3[3]);
		archive.read("priv3e",			priv3[4]);
		archive.read("priv3f",			priv3[5]);
		archive.read("priv3g",			priv3[6]);
		// end of meta-gm save
		
		archive.read("stablemaster",	stablemaster_serial);
		archive.read("npctype",			npc_type);
		archive.read("time_unused",		time_unused);
		
		archive.read("allmove",			priv2);
		archive.read("font",			fonttype);
		archive.read("say",				saycolor);
		archive.read("emote",			emotecolor);
		archive.read("strength",		st);
		archive.read("strength2",		st2);
		archive.read("dexterity",		dx);
		archive.read("dexterity2",		dx2);
		archive.read("intelligence",	in);
		archive.read("intelligence2",	in2);
		archive.read("hitpoints",		hp);
		archive.read("spawnregion",		spawnregion);
		archive.read("stamina",			stm);
		archive.read("mana",			mn);
		archive.read("npc",				npc);
		archive.read("holdgold",		holdg);
		archive.read("shop",			shop);
		archive.read("own",				ownserial);
		archive.read("robe",			robe);
		archive.read("karma",			karma);
		archive.read("fame",			fame);
		archive.read("kills",			kills);
		archive.read("deaths",			deaths);
		archive.read("dead",			dead);
		archive.read("packitem",		packitem);
		archive.read("fixedlight",		fixedlight);
		archive.read("speech",			speech);
		archive.read("trigger",			trigger);
		archive.read("trigword",		trigword);
		archive.read("disablemsg",		disabledmsg);
		unsigned int j;
		for (j=0;j<TRUESKILLS;j++)
		{
			char t[256] = {0,};
			numtostr(j, t);
			string temp = string("skill") + string(t);
			archive.read(temp, baseskill[j]);
			temp = string("skl") + string(t);
			archive.read(temp, lockSkill[j] );
		}
		archive.read("cantrain", cantrain);
		
		archive.read("att",				att);
		archive.read("def",				def);
		archive.read("lodamage",		lodamage);
		archive.read("hidamage",		hidamage);
		archive.read("war",				war);
		archive.read("npcwander",		npcWander);
		archive.read("oldnpcwander",	oldnpcWander);
		archive.read("carve",			carve);
		archive.read("fx1",				fx1);
		archive.read("fy1",				fy1);
		archive.read("fz1",				fz1);
		archive.read("fx2",				fx2);
		archive.read("fy2",				fy2);
		archive.read("spawn",			spawnserial);
		archive.read("hidden",			hidden);
		archive.read("hunger",			hunger);
		archive.read("npcaitype",		npcaitype);
		archive.read("spattack",		spattack);
		archive.read("spadelay",		spadelay);
		archive.read("taming",			taming);
		archive.read("summonremainingseconds", summontimer);
		if (summontimer != 0)
			summontimer += uiCurrentTime;
		archive.read("advobj",			advobj);
		archive.read("poison",			poison);
		archive.read("poisoned",		poisoned);
		archive.read("fleeat",			fleeat);
		archive.read("reattackat",		reattackat);
		archive.read("split",			split);
		archive.read("splitchance",		splitchnc);
		// Begin of Guild related things (DasRaetsel)
		archive.read("guildtoggle",		guildtoggle);  
		archive.read("guildnumber",		guildnumber);  
		archive.read("guildtitle",		guildtitle);  
		archive.read("guildfealty",		guildfealty);  
		archive.read("murderrate",		murderrate);
		archive.read("menupriv",		menupriv);  
		archive.read("questtype",		questType);  
		archive.read("questdestregion",	questDestRegion);  
		archive.read("questorigregion",	questOrigRegion);  
		archive.read("questbountypostserial", questBountyPostSerial);  
		archive.read("questbountyreward", questBountyReward);  
		archive.read("jailtimer",		jailtimer);
		if (jailtimer != 0)
			jailtimer += uiCurrentTime;
		archive.read("jailsecs",		jailsecs); 
		archive.read("gmrestrict",		gmrestrict); 
	}
	else if ( archive.isWritting())
	{
		if(incognito)
		{//save original name
			archive.write("name", orgname);
		} 
		else
		{
			archive.write("name", name);
		}
		
		archive.write("title",			title);
		archive.write("account",		account);
		archive.write("creationday",	creationday);
		archive.write("gmmoveeff",		gmMoveEff);
		archive.write("guildtype",		GuildType);
		archive.write("guildtraitor",	GuildTraitor);
		archive.write("dispz",			dispz);
		archive.write("cell",			cell);
		archive.write("dir",			dir);
		archive.write("race",			race);
		//AntiChrist - incognito and polymorph spell special stuff - 12/99
		if(incognito || polymorph)
		{//if under incognito spell, don't save BODY but the original XBODY
			archive.write("body", xid);
		} 
		else
		{//else backup body normally
			archive.write("body", id());
		}
		archive.write("xbody", xid);
		//AntiChrist - incognito spell special stuff - 12/99
		if(incognito)
		{//if under incognito spell, don't save SKIN but the original XSKIN
			archive.write("skin", xskin);
		} 
		else
		{//else backup skin normally
			archive.write("skin", skin);
		}
		
		archive.write("xskin",			xskin);
		archive.write("priv",			priv);
		
		archive.write("priv3a",			priv3[0]);
		archive.write("priv3b",			priv3[1]);
		archive.write("priv3c",			priv3[2]);
		archive.write("priv3d",			priv3[3]);
		archive.write("priv3e",			priv3[4]);
		archive.write("priv3f",			priv3[5]);
		archive.write("priv3g",			priv3[6]);
		// end of meta-gm save
		
		archive.write("stablemaster",	stablemaster_serial);
		archive.write("npctype",		npc_type);
		archive.write("time_unused",	time_unused);
		
		archive.write("allmove",		priv2);
		archive.write("font",			fonttype);
		archive.write("say",			saycolor);
		archive.write("emote",			emotecolor);
		archive.write("strength",		st);
		archive.write("strength2",		st2);
		archive.write("dexterity",		dx);
		archive.write("dexterity2",		dx2);
		archive.write("intelligence",	in);
		archive.write("intelligence2",	in2);
		archive.write("hitpoints",		hp);
		archive.write("spawnregion",	spawnregion);
		archive.write("stamina",		stm);
		archive.write("mana",			mn);
		archive.write("npc",			npc);
		archive.write("holdgold",		holdg);
		archive.write("shop",			shop);
		archive.write("own",			ownserial);
		archive.write("robe",			robe);
		archive.write("karma",			karma);
		archive.write("fame",			fame);
		archive.write("kills",			kills);
		archive.write("deaths",			deaths);
		archive.write("dead",			dead);
		archive.write("packitem",		packitem);
		archive.write("fixedlight",		fixedlight);
		archive.write("speech",			speech);
		archive.write("trigger",		trigger);
		archive.write("trigword",		trigword);
		archive.write("disablemsg",		disabledmsg);
		unsigned int j;
		for (j=0;j<TRUESKILLS;j++)
		{
			char t[256] = {0,};
			numtostr(j, t);
			string temp = string("skill") + string(t);
			archive.write(temp, baseskill[j]);
			temp = string("skl") + string(t);
			archive.write(temp, lockSkill[j] );
		}
		archive.write("cantrain", cantrain);
		
		archive.write("att",			att);
		archive.write("def",			def);
		archive.write("lodamage",		lodamage);
		archive.write("hidamage",		hidamage);
		archive.write("war",			war);
		archive.write("npcwander",		npcWander);
		archive.write("oldnpcwander",	oldnpcWander);
		archive.write("carve",			carve);
		archive.write("fx1",			fx1);
		archive.write("fy1",			fy1);
		archive.write("fz1",			fz1);
		archive.write("fx2",			fx2);
		archive.write("fy2",			fy2);
		archive.write("spawn",			spawnserial);
		archive.write("hidden",			hidden);
		archive.write("hunger",			hunger);
		archive.write("npcaitype",		npcaitype);
		archive.write("spattack",		spattack);
		archive.write("spadelay",		spadelay);
		archive.write("taming",			taming);
		archive.write("summonremainingseconds", summontimer/MY_CLOCKS_PER_SEC);
		
		archive.write("advobj",			advobj);
		archive.write("poison",			poison);
		archive.write("poisoned",		poisoned);
		archive.write("fleeat",			fleeat);
		archive.write("reattackat",		reattackat);
		archive.write("split",			split);
		archive.write("splitchance",	splitchnc);
		// Begin of Guild related things (DasRaetsel)
		archive.write("guildtoggle",	guildtoggle);  
		archive.write("guildnumber",	guildnumber);  
		archive.write("guildtitle",		guildtitle);  
		archive.write("guildfealty",	guildfealty);  
		archive.write("murderrate",		murderrate);
		archive.write("menupriv",		menupriv);  
		archive.write("questtype",		questType);  
		archive.write("questdestregion",questDestRegion);  
		archive.write("questorigregion",questOrigRegion);  
		archive.write("questbountypostserial", questBountyPostSerial);  
		archive.write("questbountyreward", questBountyReward);  
		archive.write("jailtimer",		jailtimer/MY_CLOCKS_PER_SEC); 
		archive.write("jailsecs",		jailsecs); 
		archive.write("gmrestrict",		gmrestrict); 
	}
	cUObject::Serialize(archive);
}
bool ogc_geod_datum :: to_wkt(
   char      buffer[],
   int       options,
   size_t    buflen) const
{
   OGC_UTF8_NAME buf_name;
   OGC_TBUF      buf_hdr;
   OGC_TBUF      buf_ellipsoid;
   OGC_TBUF      buf_anchor;
   OGC_TBUF      buf_id;
   int           opts  =  (options | OGC_WKT_OPT_INTERNAL);
   size_t        len   = 0;
   bool          rc    = true;
   const char *  opn   = "[";
   const char *  cls   = "]";
   const char *  kwd   = obj_kwd();

   if ( (options & OGC_WKT_OPT_PARENS) != 0 )
   {
      opn = "(";
      cls = ")";
   }

   if ( (opts & OGC_WKT_OPT_TOP_ID_ONLY) != 0 )
      opts |= OGC_WKT_OPT_NO_IDS;

   if ( buffer == OGC_NULL )
      return false;
   *buffer = 0;

   if ( !is_visible() )
      return true;

   rc &= ogc_ellipsoid :: to_wkt(_ellipsoid, buf_ellipsoid, opts, OGC_TBUF_MAX);
   rc &= ogc_anchor    :: to_wkt(_anchor,    buf_anchor,    opts, OGC_TBUF_MAX);

   ogc_string::escape_str(buf_name, _name, OGC_UTF8_NAME_MAX);
   sprintf(buf_hdr, "%s%s\"%s\"",
      kwd, opn, buf_name);

   OGC_CPY_TO_BUF( buf_hdr       );
   OGC_ADD_TO_BUF( buf_ellipsoid );
   OGC_ADD_TO_BUF( buf_anchor    );

   if ( _ids != OGC_NULL && (options & OGC_WKT_OPT_NO_IDS) == 0 )
   {
      for (int i = 0; i < id_count(); i++)
      {
         rc &= ogc_id :: to_wkt(id(i), buf_id, opts, OGC_TBUF_MAX);
         OGC_ADD_TO_BUF( buf_id );
         if ( (options & OGC_WKT_OPT_OLD_SYNTAX) != 0 )
            break;
      }
   }

   OGC_CPY_TO_BUF( cls );

   if ( (options & OGC_WKT_OPT_INTERNAL) == 0 &&
        (options & OGC_WKT_OPT_EXPAND)   != 0 )
   {
      rc &= ogc_utils :: expand_wkt(buffer, buffer, "", options, buflen);
   }

   return rc;
}
Beispiel #15
0
TEST_F(PageIOTestEnv, test_alloc_one) {
    auto p = m_page_io->alloc();
    EXPECT_NE(0, p.id());
}
Beispiel #16
0
void nl_convert_rinf_t::convert(const pstring &contents)
{
	plib::pistringstream istrm(contents);
	plib::putf8_reader reader(istrm);
	tokenizer tok(*this, reader);
	auto lm = read_lib_map(s_lib_map);

	out("NETLIST_START(dummy)\n");
	add_term("GND", "GND");
	add_term("VCC", "VCC");
	tokenizer::token_t token = tok.get_token();
	while (true)
	{
		if (token.is_type(tokenizer::ENDOFFILE) || token.is(tok.m_tok_END))
		{
			dump_nl();
			// FIXME: Parameter
			out("NETLIST_END()\n");
			return;
		}
		else if (token.is(tok.m_tok_HEA))
		{
			/* seems to be start token - ignore */
			token = tok.get_token();
		}
		else if (token.is(tok.m_tok_APP))
		{
			/* version string */
			pstring app = tok.get_string();
			out("// APP: {}\n", app);
			token = tok.get_token();
		}
		else if (token.is(tok.m_tok_TIM))
		{
			/* time */
			out("// TIM:");
			for (int i=0; i<6; i++)
			{
				long x = tok.get_number_long();
				out(" {}", x);
			}
			out("\n");
			token = tok.get_token();
		}
		else if (token.is(tok.m_tok_TYP))
		{
			pstring id(tok.get_identifier());
			out("// TYP: {}\n", id);
			token = tok.get_token();
		}
		else if (token.is(tok.m_tok_ADDC))
		{
			std::unordered_map<pstring, pstring> attr;
			pstring id = tok.get_identifier();
			pstring s1 = tok.get_string();
			pstring s2 = tok.get_string();

			token = tok.get_token();
			while (token.is(tok.m_tok_ATTC))
			{
				pstring tid = tok.get_identifier();
				if (tid != id)
				{
					out("Error: found {} expected {} in {}\n", tid, id, token.str());
					return;
				}
				pstring at = tok.get_string();
				pstring val = tok.get_string();
				attr[at] = val;
				token = tok.get_token();
			}
			pstring sim = attr["Simulation"];
			pstring val = attr["Value"];
			pstring com = attr["Comment"];
			if (val == "")
				val = com;

			if (sim == "CAP")
			{
				add_device("CAP", id, get_sp_val(val));
			}
			else if (sim == "RESISTOR")
			{
				add_device("RES", id, get_sp_val(val));
			}
			else
			{
				pstring lib = attr["Library Reference"];
				auto f = lm.find(lib);
				if (f != lm.end())
					add_device(f->second.dev, id);
				else
					add_device(lib, id);
			}
		}
		else if (token.is(tok.m_tok_NET))
		{
			pstring dev = tok.get_identifier();
			pstring pin = tok.get_identifier_or_number();
			pstring net = tok.get_string();
			add_term(net, dev + "." + pin);
			token = tok.get_token();
			if (token.is(tok.m_tok_TER))
			{
				token = tok.get_token();
				while (token.is_type(plib::ptokenizer::IDENTIFIER))
				{
					pin = tok.get_identifier_or_number();
					add_term(net, token.str() + "." + pin);
					token = tok.get_token();
				}
			}
		}
#if 0
			token = tok.get_token();
			/* skip to semicolon */
			do
			{
				token = tok.get_token();
			} while (!token.is(tok.m_tok_SEMICOLON));
			token = tok.get_token();
			pstring sval = "";
			if (token.is(tok.m_tok_VALUE))
			{
				pstring vname = tok.get_string();
				sval = tok.get_string();
				tok.require_token(tok.m_tok_SEMICOLON);
				token = tok.get_token();
			}
			switch (name.code_at(0))
			{
				case 'Q':
				{
					add_device("QBJT", name, sval);
				}
					break;
				case 'R':
					{
						double val = get_sp_val(sval);
						add_device("RES", name, val);
					}
					break;
				case 'C':
					{
						double val = get_sp_val(sval);
						add_device("CAP", name, val);
					}
					break;
				case 'P':
					if (sval.ucase() == "HIGH")
						add_device("TTL_INPUT", name, 1);
					else if (sval.ucase() == "LOW")
						add_device("TTL_INPUT", name, 0);
					else
						add_device("ANALOG_INPUT", name, sval.as_double());
					add_pin_alias(name, "1", "Q");
					break;
				case 'D':
					/* Pin 1 = Anode, Pin 2 = Cathode */
					add_device("DIODE", name, sval);
					add_pin_alias(name, "1", "A");
					add_pin_alias(name, "2", "K");
					break;
				case 'U':
				case 'X':
				{
					pstring tname = "TTL_" + sval + "_DIP";
					add_device(tname, name);
					break;
				}
				default:
					tok.error("// IGNORED " + name);
			}

		}
		else if (token.is(tok.m_tok_SIGNAL))
Beispiel #17
0
void SetCalibDB() {

  Int_t firstRun   =  0; // What is this                                                
  Int_t lastRun    = 9999999;
  Int_t beamPeriod =  1;
  char* objFormat  = "";

  TString DBFolder  ="local://$ALICE_ROOT/OCDB/EMCAL/beamtest07";
  firstRun  =  0;
  lastRun   =  999999999;
  objFormat = "EMCAL beam test 2007 gain factors and pedestals";

  AliEMCALCalibData *calibda=new AliEMCALCalibData("EMCAL");

  Float_t fADCpedestal = 0.009;
  Float_t fADCchannel  = 0.0153;  // 250 GeV / (16*1024)                               
  Float_t ped = 0.;
  Float_t cc = fADCchannel;

  Int_t nSMod  = 12;
  Int_t nCol   = 48;
  Int_t nRow   = 24;
  Int_t nRow2  = 12; //Modules 11 and 12 are half modules                          

  Int_t colOffset = 40;
  Int_t rowOffset = 8;

  Double_t gain_ratios[8][8] =
    {
      15.9289, 16.2141, 16.1204, 15.9118,
      15.9363, 15.9402, 16.2257, 16.0097,
      16.058, 16.1116, 16.039, 16.4167,
      16.2148, 16.1399, 16.1515, 16.2194,
      15.9082, 16.0776, 16.0496, 16.2353,
      15.8054, 16.2158, 16.2344, 16.1023,
      15.8903, 16.2387, 16.13, 16.157,
      16.0685, 16.172, 16.3495, 16.3887,
      16.2842, 16.049, 16.4328, 16.3954,
      16.4226, 15.7254, 16.1634, 16.3182,
      16.4216, 16.1201, 16.0000, 16.2305,
      16.0266, 16.3573, 16.1382, 16.237,
      16.2981, 16.1796, 15.854, 16.4189,
      15.6425, 16.287, 16.3293, 16.6308,
      16.2469, 16.0412, 16.252, 16.3367,
      16.1412, 16.0646, 16.3996, 16.3479
    };

  
  Float_t gains[8][8] =
    {
      4.43274, 6.7283, 8.23733, 3.59882,
      4.2717, 2.85658, 4.86389, 2.71961,
      3.05523, 3.02552, 3.50615, 3.26494,
      6.69024, 2.51058, 8.42275, 2.83824,
      8.05074, 5.36051, 4.36794, 4.73468,
      9.9684, 5.5, 6.42999, 5.6,
      7.37306, 5.28314, 5.27662, 5.26982,
      3.29468, 5.23107, 6.40948, 4.06855,
      4.09685, 5.37323, 5.32816, 5.89487,
      9.2395, 5.3, 4.77239, 5.0,
      4.85923, 3.44063, 4.74517, 5.28772,
      3.80171, 4.84878, 5.12039, 4.59205,
      2.34745, 3.16971, 3.61231, 3.65195,
      3.43496, 3.4, 3.65678, 2.9,
      2.71648, 3.39577, 3.40896, 3.31741,
      3.24286, 3.51346, 2.61503, 3.44246
    };

  for(Int_t supermodule=0; supermodule < nSMod; supermodule++) {
    for(Int_t column=0; column< nCol; column++) {
      if(supermodule >= 10)
        nRow = nRow2;
      for(Int_t row=0; row< nRow; row++) {
	if(supermodule < 2 && column > 39 && row > 7 && row < 16) {
	  cc = 1./gain_ratios[column-colOffset][row-rowOffset]/gains[column-colOffset][row-rowOffset];
	  cout << "column = " << column << " column - colOffset = " << column-colOffset << " row = " << " row Offset = " << row-rowOffset << endl;
	}
        calibda->SetADCchannel(supermodule,column,row,cc);
        calibda->SetADCpedestal(supermodule,column,row,ped);
      }
    }
  }

  //Store calibration data into database
  AliCDBMetaData md;
  md.SetComment(objFormat);
  md.SetBeamPeriod(beamPeriod);
  md.SetResponsible("David Silvermyr");
  AliCDBId id("EMCAL/Calib/Data",firstRun,lastRun); // create in
						    // EMCAL/Calib/Data DBFolder                     

  AliCDBManager* man = AliCDBManager::Instance();
  AliCDBStorage* loc = man->GetStorage(DBFolder.Data());
  loc->Put(calibda, id, &md);

}
connection_options connection_engine::container::make_options() {
    connection_options opts = options_;
    opts.container_id(id()).link_prefix(id_gen_.next()+"/");
    return opts;
}
void KisCutCopyActionFactory::run(bool willCut, bool makeSharpClip, KisViewManager *view)
{
    KisImageSP image = view->image();
    if (!image) return;

    bool haveShapesSelected = view->selectionManager()->haveShapesSelected();

    if (haveShapesSelected) {
        // XXX: "Add saving of XML data for Cut/Copy of shapes"

        KisImageBarrierLocker locker(image);
        if (willCut) {
            view->canvasBase()->toolProxy()->cut();
        } else {
            view->canvasBase()->toolProxy()->copy();
        }
    } else {
        KisNodeSP node = view->activeNode();
        if (!node) return;

        KisSelectionSP selection = view->selection();
        if (selection.isNull()) return;

        {
            KisImageBarrierLocker locker(image);
            KisPaintDeviceSP dev = node->paintDevice();
            if (!dev) {
                dev = node->projection();
            }

            if (!dev) {
                view->showFloatingMessage(
                    i18nc("floating message when cannot copy from a node",
                          "Cannot copy pixels from this type of layer "),
                    QIcon(), 3000, KisFloatingMessage::Medium);

                return;
            }

            if (dev->exactBounds().isEmpty()) {
                view->showFloatingMessage(
                    i18nc("floating message when copying empty selection",
                          "Selection is empty: no pixels were copied "),
                    QIcon(), 3000, KisFloatingMessage::Medium);

                return;
            }

            ActionHelper::copyFromDevice(view, dev, makeSharpClip);
        }

        if (willCut) {
            KUndo2Command *command = 0;

            if (willCut && node->hasEditablePaintDevice()) {
                struct ClearSelection : public KisTransactionBasedCommand {
                    ClearSelection(KisNodeSP node, KisSelectionSP sel)
                        : m_node(node), m_sel(sel) {}
                    KisNodeSP m_node;
                    KisSelectionSP m_sel;

                    KUndo2Command* paint() {
                        KisSelectionSP cutSelection = m_sel;
                        // Shrinking the cutting area was previously used
                        // for getting seamless cut-paste. Now we use makeSharpClip
                        // instead.
                        // QRect originalRect = cutSelection->selectedExactRect();
                        // static const int preciseSelectionThreshold = 16;
                        //
                        // if (originalRect.width() > preciseSelectionThreshold ||
                        //     originalRect.height() > preciseSelectionThreshold) {
                        //     cutSelection = new KisSelection(*m_sel);
                        //     delete cutSelection->flatten();
                        //
                        //     KisSelectionFilter* filter = new KisShrinkSelectionFilter(1, 1, false);
                        //
                        //     QRect processingRect = filter->changeRect(originalRect);
                        //     filter->process(cutSelection->pixelSelection(), processingRect);
                        // }

                        KisTransaction transaction(m_node->paintDevice());
                        m_node->paintDevice()->clearSelection(cutSelection);
                        m_node->setDirty(cutSelection->selectedRect());
                        return transaction.endAndTake();
                    }
                };

                command = new ClearSelection(node, selection);
            }

            KUndo2MagicString actionName = willCut ?
                                           kundo2_i18n("Cut") :
                                           kundo2_i18n("Copy");
            KisProcessingApplicator *ap = beginAction(view, actionName);

            if (command) {
                ap->applyCommand(command,
                                 KisStrokeJobData::SEQUENTIAL,
                                 KisStrokeJobData::NORMAL);
            }

            KisOperationConfiguration config(id());
            config.setProperty("will-cut", willCut);
            endAction(ap, config.toXML());
        }
    }
}
bool ogc_ellipsoid :: to_wkt(
   char      buffer[],
   int       options,
   size_t    buflen) const
{
   OGC_UTF8_NAME buf_name;
   OGC_TBUF      buf_hdr;
   OGC_TBUF      buf_lenunit;
   OGC_TBUF      buf_id;
   OGC_NBUF      buf_sm_axis;
   OGC_NBUF      buf_flattening;
   int           opts  =  (options | OGC_WKT_OPT_INTERNAL);
   size_t        len   = 0;
   bool          rc    = true;
   const char *  opn   = "[";
   const char *  cls   = "]";
   const char *  kwd   = obj_kwd();

   if ( (options & OGC_WKT_OPT_PARENS) != 0 )
   {
      opn = "(";
      cls = ")";
   }

   if ( (opts & OGC_WKT_OPT_TOP_ID_ONLY) != 0 )
      opts |= OGC_WKT_OPT_NO_IDS;

   if ( buffer == OGC_NULL )
      return false;
   *buffer = 0;

   if ( !is_visible() )
      return true;

   if ( (options & OGC_WKT_OPT_OLD_SYNTAX) != 0 )
      kwd = alt_kwd();

   double flattening = _flattening;
   if ( flattening != 0.0 )
      flattening = (1.0 / flattening);

   ogc_string :: dtoa(_semi_major_axis, buf_sm_axis);
   ogc_string :: dtoa( flattening,      buf_flattening);

   if ( (options & OGC_WKT_OPT_OLD_SYNTAX) == 0 )
      rc &= ogc_lenunit :: to_wkt(_lenunit, buf_lenunit, opts, OGC_TBUF_MAX);
   else
      *buf_lenunit = 0;

   ogc_string::escape_str(buf_name, _name, OGC_UTF8_NAME_MAX);
   sprintf(buf_hdr, "%s%s\"%s\",%s,%s",
      kwd, opn, buf_name, buf_sm_axis, buf_flattening);

   OGC_CPY_TO_BUF( buf_hdr     );
   OGC_ADD_TO_BUF( buf_lenunit );

   if ( _ids != OGC_NULL && (options & OGC_WKT_OPT_NO_IDS) == 0 )
   {
      for (int i = 0; i < id_count(); i++)
      {
         rc &= ogc_id :: to_wkt(id(i), buf_id, opts, OGC_TBUF_MAX);
         OGC_ADD_TO_BUF( buf_id );
         if ( (options & OGC_WKT_OPT_OLD_SYNTAX) != 0 )
            break;
      }
   }

   OGC_CPY_TO_BUF( cls );

   if ( (options & OGC_WKT_OPT_INTERNAL) == 0 &&
        (options & OGC_WKT_OPT_EXPAND)   != 0 )
   {
      rc &= ogc_utils :: expand_wkt(buffer, buffer, "", options, buflen);
   }

   return rc;
}
Beispiel #21
0
String BuiltinType::defineHtml() const
{
	return L"<^><span class=\"TypeConcept\">" + typeHtml((id() == (uint)-1) ? L"&empty;" : nickFor(id())) + L"</span>";
}
Beispiel #22
0
bool Event::isValid() const
{   // negative values are allowed and indicate calculated values
    return id() != 0 && m_installationId != 0;
}
Beispiel #23
0
void CRMAcctLineEdit::sInfo()
{
  if (_crmacctInfoAction)
    _crmacctInfoAction->crmacctInformation(this, id());
}
Beispiel #24
0
void UploadRejectList(Int_t firstRun=0, Int_t lastRun=AliCDBRunRange::Infinity())
{
  AliCDBManager::Instance()->SetDefaultStorage("alien://folder=/alice/data/2015/OCDB");
  AliCDBManager::Instance()->SetRun(firstRun);
  AliCDBManager::Instance()->SetSpecificStorage("MUON/Calib/RejectList","alien://folder=/alice/cern.ch/user/l/laphecet/OCDB2015");

  AliMpCDB::LoadAll();
  
  AliMUONRejectList rl;
  
  rl.SetDetectionElementProbability(806,1.0); // alignment problem
  
  // first round of checks in LHC13f with first run of the period : 4 holes
  rl.SetHVProbability("MchHvLvRight/Chamber03Right/Quad4Sect1",1.0);
  rl.SetPCBProbability(811,4,1.0);
  rl.SetPCBProbability(900,1,1.0);
  rl.SetPCBProbability(1010,0,1.0);
  
  // second scan of LHC13f: all runs
  
  // DE 612 : one of the 7-8 HV capa per PCB went bad ?
  // remove 3 full manus and then the channels in between...
  rl.SetManuProbability(612,1034,1.0);
  rl.SetManuProbability(612,112,1.0);
  rl.SetManuProbability(612,14,1.0);
  
  for ( Int_t i = 0; i < 8; ++i )
  {
    rl.SetChannelProbability(612,111,i,1.0);
    rl.SetChannelProbability(612,113,40+i,1.0);

    rl.SetChannelProbability(612,15,40+i,1.0);
    rl.SetChannelProbability(612,13,i,1.0);
    
  }
  
  for ( Int_t i = 48; i <= 63; ++i )
  {
    rl.SetChannelProbability(612,1141,i,1.0);
  }
  for ( Int_t i = 32; i <= 47; ++i )
  {
    rl.SetChannelProbability(612,1141,i,1.0);
  }
  
  for ( Int_t i = 0; i <= 31; ++i )
  {
    rl.SetChannelProbability(612,1140,i,1.0);
  }
  
  // DE 714 : same story as in DE 612 ...
  rl.SetManuProbability(714,111,1.0);
  rl.SetManuProbability(714,216,1.0);
  rl.SetManuProbability(714,1143,1.0);

  for ( Int_t i = 47; i <= 32; ++i )
  {
    rl.SetChannelProbability(714,112,i,1.0);
  }
  for ( Int_t i = 0; i <= 15; ++i )
  {
    rl.SetChannelProbability(714,215,i,1.0);
  }
  for ( Int_t i = 18; i <= 63; ++i )
  {
    rl.SetChannelProbability(714,1233,i,1.0);
  }
  for ( Int_t i = 32; i <= 47; ++i )
  {
    rl.SetChannelProbability(714,112,i,1.0);
  }
  rl.SetChannelProbability(714,1142,0,1.0);
  rl.SetChannelProbability(714,1142,1,1.0);

  
  rl.SetManuProbability(903,1129,1.0);
  rl.SetManuProbability(903,108,1.0);

  // only for run 196646
  rl.SetDetectionElementProbability(919,1.0);
  rl.SetPCBProbability(918,1,1.0);
  rl.SetPCBProbability(918,2,1.0);
  rl.SetPCBProbability(918,3,1.0);
  rl.SetBusPatchProbability(1648,1.0); // BP on DE 918
  
  AliCDBId id("MUON/Calib/RejectList",firstRun,lastRun);

  AliCDBMetaData metaData;
  metaData.SetBeamPeriod(0);
  metaData.SetResponsible("MUON TRK");
  metaData.SetComment("Uploaded by UploadRejectList.C macro (handmade by L. Aphecetche) using information from MC vs Data tracking efficiency studies (Javier Martin Bianco) - eye scan (P. Pillot) - only for run 196646 -");
    
  AliCDBManager::Instance()->Put(&rl,id,&metaData);
}
Beispiel #25
0
void Texture2::begin() const { glBindTexture(GL_TEXTURE_2D, (GLuint)id()); }
Beispiel #26
0
QString AudioDecoder::name() const
{
    return QLatin1String(AudioDecoder::name(id()));
}
/**
 * \brief Start-Funktion der Testumgebung
 *
 * Diese Funktion wird einmal beim Starten der Testumgebung
 * aufgerufen.
 */
TEFUNC
void initialize(int /*argc*/, char** /*argv*/) {

	// --------- Ein wenig Testkram, ist unbedeutetnd -------------

	orientationInit.normalize();
	Quaternion test(0,M_PI/2,M_PI/2);
	cout << test << endl
		 << M_PI/2 << endl
		 << test.getEulerRotation() << endl;

//		exit (0);


	//----------------- uhr initialisieren --------------------
	timer.init();
	
	// --- Anlegen der Zeiger und Objekte mit denen gearbeitet werden soll ----

	RigidBodyPtr body;
	GeometryPtr boxGeo;

	// Erste id ist null. Wird dann hochgezählt.
	Id id(Id::typeBox,0);


	// -------------- Einfache Rotation -----------
	//Euler
	id.setNumber(0);
	
	body = rigidBodySystemEuler.create(id);
	
	body->setPosition(positionInit);
	body->setMass(massInit);
	body->setOrientation(orientationInit);
	body->setVelocity(velocityInit);
	body->setAngularVelocity(angularVelocityInit);
		
 	boxGeo = geometrySystem.createBox(body, boxScaleInit);
 	boxGeo->setBounciness(0.6);
 	boxGeo->setColor(Graphics::red);
  

	//Runge-Kutta
	id.setNumber(1);
	
	body = rigidBodySystemRunge.create(id);
	body->setPosition(Vec3(-300.0, 0.0, 0.0));
	
	body->setPosition(positionInit);
	body->setMass(massInit);
	body->setOrientation(orientationInit);
	body->setVelocity(velocityInit);
	body->setAngularVelocity(angularVelocityInit);
		
	boxGeo = geometrySystem.createBox(body, boxScaleInit);
   	boxGeo->setBounciness(0.6);
	boxGeo->setColor(Graphics::blue);

	// Verlet-Baltman
	 id.setNumber(2);

 	body = rigidBodySystemVerlet.create(id);
 	body->setPosition(positionInit);

 	body->setMass(massInit);
 	body->setOrientation(orientationInit);
 	body->setVelocity(velocityInit);
 	body->setAngularVelocity(angularVelocityInit);

		
   	boxGeo = geometrySystem.createBox(body, boxScaleInit);
   	boxGeo->setBounciness(0.6);
   	boxGeo->setColor(Graphics::green);


	referenceBody->setPosition(positionInit);
	referenceBody->setMass(massInit);
	referenceBody->setOrientation(orientationInit);
	referenceBody->setVelocity(velocityInit);
	referenceBody->setAngularVelocity(angularVelocityInit);
		
	boxGeo = geometrySystem.createBox(referenceBody, boxScaleInit);
	boxGeo->setBounciness(0.6);
	boxGeo->setColor(Graphics::yellow);

	// ------------- Keine Visosity -------------
	rigidBodySystemEuler.disableViscosity();
	rigidBodySystemRunge.disableViscosity();
	rigidBodySystemVerlet.disableViscosity();
	
			
}
Beispiel #28
0
void TextLine::write(Xml& xml) const
      {
      xml.stag(QString("%1 id=\"%2\"").arg(name()).arg(id()));
      writeProperties(xml);
      xml.etag();
      }
forwarding_actor_proxy::~forwarding_actor_proxy() {
  anon_send(m_manager, make_message(atom("_DelProxy"), node(), id()));
}
Beispiel #30
0
 IdType subId(const cpgrid::Entity<0>& e, int i) const
 {
     return id(e.template subEntity<cc>(i));
 }